aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-18 16:35:54 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:36 -0700
commitd16c7a0d4290dcc5a033710e6a5139031c88a323 (patch)
tree53288cba1e5b76525644d33402ddd7b39bff31b6 /expression.h
parentMark more identifiers reserved. (diff)
downloadsparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.tar.gz
sparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.tar.bz2
sparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.zip
Add __sizeof_ptr__ that looks at a pointer expression and
returns the size of the underlying object. This is different from "sizeof(*expr)" for arrays, where the array would degenerate to a pointer to one member, and thus "sizeof(*expr)" gives the size of one entry in the array. Why do this? It's useful for things like #define memset(a,b,c) ({ \ (void) __builtin_warning(__sizeof_ptr__(a) > 1, __sizeof_ptr__(a) != (c), "check memset size"); \ memset(a, b, c); }) where we really want to check the size of the object we're doing the "memset()" on, but the regular sizeof() just doesn't cut it.
Diffstat (limited to 'expression.h')
-rw-r--r--expression.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/expression.h b/expression.h
index 1bd7923..cb156f2 100644
--- a/expression.h
+++ b/expression.h
@@ -27,6 +27,7 @@ enum expression_type {
EXPR_CAST,
EXPR_SIZEOF,
EXPR_ALIGNOF,
+ EXPR_PTRSIZEOF,
EXPR_CONDITIONAL,
EXPR_SELECT, // a "safe" conditional expression
EXPR_STATEMENT,