Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105782
b: refs/heads/master
c: e0deaff
h: refs/heads/master
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Jul 25, 2008
1 parent ce26347 commit 21e5da4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5df439ef06d4173357711a04740aa8bfcf50d621
refs/heads/master: e0deaff470900a4c3222ca7139f6c9639e26a2f5
21 changes: 1 addition & 20 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/typecheck.h>
#include <asm/byteorder.h>
#include <asm/bug.h>

Expand Down Expand Up @@ -441,26 +442,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

/*
* Check at compile time that something is of a particular type.
* Always evaluates to 1 so you may use it easily in comparisons.
*/
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})

/*
* Check at compile time that 'function' is a certain type, or is a pointer
* to that type (needs to use typedef for the function type.)
*/
#define typecheck_fn(type,function) \
({ typeof(type) __tmp = function; \
(void)__tmp; \
})

struct sysinfo;
extern int do_sysinfo(struct sysinfo *info);

Expand Down
24 changes: 24 additions & 0 deletions trunk/include/linux/typecheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef TYPECHECK_H_INCLUDED
#define TYPECHECK_H_INCLUDED

/*
* Check at compile time that something is of a particular type.
* Always evaluates to 1 so you may use it easily in comparisons.
*/
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})

/*
* Check at compile time that 'function' is a certain type, or is a pointer
* to that type (needs to use typedef for the function type.)
*/
#define typecheck_fn(type,function) \
({ typeof(type) __tmp = function; \
(void)__tmp; \
})

#endif /* TYPECHECK_H_INCLUDED */

0 comments on commit 21e5da4

Please sign in to comment.