X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fcast.h;h=802698da23ae2fcca48c158d464b4efd8b34eedb;hb=77ccca8a4264f354b6f3b4e859fd3b82bba2ce84;hp=5c64fac864a8e1eb78588dcc7558177d759ce0e1;hpb=d775f576e4ffc0973c5f183b57b2baa089f555dc;p=pspp diff --git a/src/libpspp/cast.h b/src/libpspp/cast.h index 5c64fac864..802698da23 100644 --- a/src/libpspp/cast.h +++ b/src/libpspp/cast.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,11 +99,11 @@ not yet carefully examined the situation, or if you are not sure. Use CHAR_CAST if you are convinced that this is actually a correct cast. */ #define CHAR_CAST(TYPE, POINTER) \ - ((void) verify_true (sizeof (*(POINTER)) == 1), \ - (void) (sizeof (*(POINTER) + 1)), \ - (void) verify_true (sizeof (*(TYPE) NULL) == 1), \ - (void) (sizeof (*(TYPE) NULL + 1)), \ - (TYPE) (POINTER)) + ((void) verify_expr (sizeof (*(POINTER)) == 1, 1), \ + (void) (sizeof (*(POINTER) + 1)), \ + (void) verify_expr (sizeof (*(TYPE) NULL) == 1, 1), \ + (void) (sizeof (*(TYPE) NULL + 1)), \ + (TYPE) (POINTER)) #define CHAR_CAST_BUG(TYPE, POINTER) CHAR_CAST(TYPE, POINTER) /* Given POINTER, a pointer to the given MEMBER within structure @@ -112,4 +112,11 @@ (CHECK_POINTER_COMPATIBILITY (&((STRUCT *) 0)->MEMBER, POINTER), \ (STRUCT *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER))) +/* A null pointer constant suitable for use in a varargs parameter list. + + This is useful because a literal 0 may not have the same width as a null + pointer. NULL by itself is also insufficient because in C it may expand to + simply 0. */ +#define NULL_SENTINEL ((void *) NULL) + #endif /* libpspp/cast.h */