summaryrefslogtreecommitdiffstats
path: root/lib/ext2fs/compiler.h
blob: 3bb3521d644ec8ae657dbcac8612da8ef7061587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _EXT2FS_COMPILER_H
#define _EXT2FS_COMPILER_H

#include <stddef.h>

#ifdef __GNUC__

#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif

#define container_of(ptr, type, member) ({				\
	__typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
	(type *)( (char *)__mptr - offsetof(type,member) );})
#else
#define container_of(ptr, type, member)				\
	((type *)((char *)(ptr) - offsetof(type, member)))
#endif


#endif /* _EXT2FS_COMPILER_H */