Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54288
b: refs/heads/master
c: c5e631c
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell authored and Linus Torvalds committed May 7, 2007
1 parent 17d5274 commit 79fc6d5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 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: f34d9d2dcb7f17b64124841345b23adc0843e7a5
refs/heads/master: c5e631cf65f4d6875efcd571275436f2964a8b48
15 changes: 13 additions & 2 deletions trunk/arch/um/include/user_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@

#include "sysdep/ptrace.h"

/* Copied from kernel.h */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Copied from kernel.h and compiler-gcc.h */

/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)

/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a) \
BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))

Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/compiler-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
__asm__ ("" : "=r"(__ptr) : "0"(ptr)); \
(typeof(ptr)) (__ptr + (off)); })

/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a) \
BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))

#define inline inline __attribute__((always_inline))
#define __inline__ __inline__ __attribute__((always_inline))
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/compiler-intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
__ptr = (unsigned long) (ptr); \
(typeof(ptr)) (__ptr + (off)); })

/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */
#define __must_be_array(a) 0

#endif

#define uninitialized_var(x) x
3 changes: 2 additions & 1 deletion trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ extern const char linux_proc_banner[];
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
Expand Down

0 comments on commit 79fc6d5

Please sign in to comment.