summaryrefslogtreecommitdiffstats
path: root/Include/pymacro.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@wyplay.com>2011-09-29 10:12:39 (GMT)
committerVictor Stinner <vstinner@wyplay.com>2011-09-29 10:12:39 (GMT)
commit573696a9cab740783cf762899fca72c2f03293b1 (patch)
treec70f4fa64d4b5c7c1e0181de5e575a6ad2a69fa5 /Include/pymacro.h
parent6f1ba077c0381c88f78614373157f71ea179e212 (diff)
downloadcpython-573696a9cab740783cf762899fca72c2f03293b1.zip
cpython-573696a9cab740783cf762899fca72c2f03293b1.tar.gz
cpython-573696a9cab740783cf762899fca72c2f03293b1.tar.bz2
pymacro.h: Inline _Py_ARRAY_LENGTH_CHECK() and add http://ccodearchive.net/
Diffstat (limited to 'Include/pymacro.h')
-rw-r--r--Include/pymacro.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h
index 22f1d71..07f4785 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -19,20 +19,10 @@
((char *)(foo) \
+ Py_BUILD_ASSERT(offsetof(struct foo, string) == 0))
- Written by Rusty Russell, public domain. */
+ Written by Rusty Russell, public domain, http://ccodearchive.net/ */
#define Py_BUILD_ASSERT(cond) \
(sizeof(char [1 - 2*!(cond)]) - 1)
-#if defined(__GNUC__)
-/* Two gcc extensions.
- &a[0] degrades to a pointer: a different type from an array */
-#define _Py_ARRAY_LENGTH_CHECK(array) \
- Py_BUILD_ASSERT(!__builtin_types_compatible_p(typeof(array), \
- typeof(&(array)[0])))
-#else
-#define _Py_ARRAY_LENGTH_CHECK(array) 0
-#endif
-
/* Get the number of elements in a visible array
@@ -40,9 +30,18 @@
parameters. With correct compiler support, such usage will cause a build
error (see Py_BUILD_ASSERT).
- Written by Rusty Russell, public domain. */
+ Written by Rusty Russell, public domain, http://ccodearchive.net/ */
+#if defined(__GNUC__)
+/* Two gcc extensions.
+ &a[0] degrades to a pointer: a different type from an array */
#define Py_ARRAY_LENGTH(array) \
- (sizeof(array) / sizeof((array)[0]) + _Py_ARRAY_LENGTH_CHECK(array))
+ (sizeof(array) / sizeof((array)[0]) \
+ + Py_BUILD_ASSERT(!__builtin_types_compatible_p(typeof(array), \
+ typeof(&(array)[0]))))
+#else
+#define Py_ARRAY_LENGTH(array) \
+ (sizeof(array) / sizeof((array)[0]))
+#endif
/* Define macros for inline documentation. */