Fix c99 compatibility: use __typeof__ instead of typeof in public headers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 11 Jun 2012 14:15:25 +0000 (10:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 18 Jun 2012 17:51:11 +0000 (13:51 -0400)
Reported-by: John Steele Scott <toojays@toojays.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/align.h
include/lttng/bitfield.h
include/lttng/tracepoint-rcu.h

index 9154051e33e59363cf24ee77a065dd675ab976b6..913327a8aac02d0db5a01db5f4fddb1676edf19e 100644 (file)
@@ -23,7 +23,7 @@
 #define PAGE_SIZE              sysconf(_SC_PAGE_SIZE)
 #define PAGE_MASK              (~(PAGE_SIZE - 1))
 #define __ALIGN_MASK(v, mask)  (((v) + (mask)) & ~(mask))
-#define ALIGN(v, align)                __ALIGN_MASK(v, (typeof(v)) (align) - 1)
+#define ALIGN(v, align)                __ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
 #define PAGE_ALIGN(addr)       ALIGN(addr, PAGE_SIZE)
 
 /**
index df8ab0b2b67a224bed60a9b86d866494a288f37f..9bef7e3c32747b13cadfcee6a8acbd36f51a5a83 100644 (file)
@@ -27,8 +27,8 @@
 /* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
 #define _bt_piecewise_rshift(_v, _shift)                               \
 ({                                                                     \
-       typeof(_v) ___v = (_v);                                         \
-       typeof(_shift) ___shift = (_shift);                             \
+       __typeof__(_v) ___v = (_v);                                             \
+       __typeof__(_shift) ___shift = (_shift);                         \
        unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1);  \
        unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
                                                                        \
@@ -39,8 +39,8 @@
 
 #define _bt_piecewise_lshift(_v, _shift)                               \
 ({                                                                     \
-       typeof(_v) ___v = (_v);                                         \
-       typeof(_shift) ___shift = (_shift);                             \
+       __typeof__(_v) ___v = (_v);                                             \
+       __typeof__(_shift) ___shift = (_shift);                         \
        unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1);  \
        unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
                                                                        \
@@ -78,7 +78,7 @@
 
 #define _bt_bitfield_write_le(_ptr, type, _start, _length, _v)         \
 do {                                                                   \
-       typeof(_v) __v = (_v);                                          \
+       __typeof__(_v) __v = (_v);                                              \
        type *__ptr = (void *) (_ptr);                                  \
        unsigned long __start = (_start), __length = (_length);         \
        type mask, cmask;                                               \
@@ -95,7 +95,7 @@ do {                                                                  \
                                                                        \
        /* Trim v high bits */                                          \
        if (__length < sizeof(__v) * CHAR_BIT)                          \
-               __v &= ~((~(typeof(__v)) 0) << __length);               \
+               __v &= ~((~(__typeof__(__v)) 0) << __length);           \
                                                                        \
        /* We can now append v with a simple "or", shift it piece-wise */ \
        this_unit = start_unit;                                         \
@@ -137,7 +137,7 @@ do {                                                                        \
 
 #define _bt_bitfield_write_be(_ptr, type, _start, _length, _v)         \
 do {                                                                   \
-       typeof(_v) __v = (_v);                                          \
+       __typeof__(_v) __v = (_v);                                              \
        type *__ptr = (void *) (_ptr);                                  \
        unsigned long __start = (_start), __length = (_length);         \
        type mask, cmask;                                               \
@@ -154,7 +154,7 @@ do {                                                                        \
                                                                        \
        /* Trim v high bits */                                          \
        if (__length < sizeof(__v) * CHAR_BIT)                          \
-               __v &= ~((~(typeof(__v)) 0) << __length);               \
+               __v &= ~((~(__typeof__(__v)) 0) << __length);           \
                                                                        \
        /* We can now append v with a simple "or", shift it piece-wise */ \
        this_unit = end_unit - 1;                                       \
@@ -230,8 +230,8 @@ do {                                                                        \
 
 #define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)       \
 do {                                                                   \
-       typeof(*(_vptr)) *__vptr = (_vptr);                             \
-       typeof(*__vptr) __v;                                            \
+       __typeof__(*(_vptr)) *__vptr = (_vptr);                         \
+       __typeof__(*__vptr) __v;                                                \
        type *__ptr = (void *) (_ptr);                                  \
        unsigned long __start = (_start), __length = (_length);         \
        type mask, cmask;                                               \
@@ -249,9 +249,9 @@ do {                                                                        \
        end_unit = (end + (ts - 1)) / ts;                               \
                                                                        \
        this_unit = end_unit - 1;                                       \
-       if (_bt_is_signed_type(typeof(__v))                             \
+       if (_bt_is_signed_type(__typeof__(__v))                         \
            && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \
-               __v = ~(typeof(__v)) 0;                                 \
+               __v = ~(__typeof__(__v)) 0;                                     \
        else                                                            \
                __v = 0;                                                \
        if (start_unit == end_unit - 1) {                               \
@@ -262,7 +262,7 @@ do {                                                                        \
                        cmask &= mask;                                  \
                }                                                       \
                __v = _bt_piecewise_lshift(__v, end - __start);         \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
                *__vptr = __v;                                          \
                break;                                                  \
        }                                                               \
@@ -272,13 +272,13 @@ do {                                                                      \
                cmask = __ptr[this_unit];                               \
                cmask &= mask;                                          \
                __v = _bt_piecewise_lshift(__v, cshift);                \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
                end -= cshift;                                          \
                this_unit--;                                            \
        }                                                               \
        for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
                __v = _bt_piecewise_lshift(__v, ts);                    \
-               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               __v |= _bt_unsigned_cast(__typeof__(__v), __ptr[this_unit]);\
                end -= ts;                                              \
        }                                                               \
        if (__start % ts) {                                             \
@@ -287,18 +287,18 @@ do {                                                                      \
                cmask >>= (__start % ts);                               \
                cmask &= mask;                                          \
                __v = _bt_piecewise_lshift(__v, ts - (__start % ts));   \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
        } else {                                                        \
                __v = _bt_piecewise_lshift(__v, ts);                    \
-               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               __v |= _bt_unsigned_cast(__typeof__(__v), __ptr[this_unit]);\
        }                                                               \
        *__vptr = __v;                                                  \
 } while (0)
 
 #define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)       \
 do {                                                                   \
-       typeof(*(_vptr)) *__vptr = (_vptr);                             \
-       typeof(*__vptr) __v;                                            \
+       __typeof__(*(_vptr)) *__vptr = (_vptr);                         \
+       __typeof__(*__vptr) __v;                                                \
        type *__ptr = (void *) (_ptr);                                  \
        unsigned long __start = (_start), __length = (_length);         \
        type mask, cmask;                                               \
@@ -316,9 +316,9 @@ do {                                                                        \
        end_unit = (end + (ts - 1)) / ts;                               \
                                                                        \
        this_unit = start_unit;                                         \
-       if (_bt_is_signed_type(typeof(__v))                             \
+       if (_bt_is_signed_type(__typeof__(__v))                         \
            && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \
-               __v = ~(typeof(__v)) 0;                                 \
+               __v = ~(__typeof__(__v)) 0;                                     \
        else                                                            \
                __v = 0;                                                \
        if (start_unit == end_unit - 1) {                               \
@@ -329,7 +329,7 @@ do {                                                                        \
                        cmask &= mask;                                  \
                }                                                       \
                __v = _bt_piecewise_lshift(__v, end - __start);         \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
                *__vptr = __v;                                          \
                break;                                                  \
        }                                                               \
@@ -339,13 +339,13 @@ do {                                                                      \
                cmask = __ptr[this_unit];                               \
                cmask &= mask;                                          \
                __v = _bt_piecewise_lshift(__v, ts - cshift);           \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
                __start += ts - cshift;                                 \
                this_unit++;                                            \
        }                                                               \
        for (; this_unit < end_unit - 1; this_unit++) {                 \
                __v = _bt_piecewise_lshift(__v, ts);                    \
-               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               __v |= _bt_unsigned_cast(__typeof__(__v), __ptr[this_unit]);\
                __start += ts;                                          \
        }                                                               \
        if (end % ts) {                                                 \
@@ -354,10 +354,10 @@ do {                                                                      \
                cmask >>= ts - (end % ts);                              \
                cmask &= mask;                                          \
                __v = _bt_piecewise_lshift(__v, end % ts);              \
-               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __v |= _bt_unsigned_cast(__typeof__(__v), cmask);               \
        } else {                                                        \
                __v = _bt_piecewise_lshift(__v, ts);                    \
-               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               __v |= _bt_unsigned_cast(__typeof__(__v), __ptr[this_unit]);\
        }                                                               \
        *__vptr = __v;                                                  \
 } while (0)
index 918837e1a162b553091441bf8e0cd02d2015f89c..a754048cc51ccc624a028c522aa8a030fbf04fcf 100644 (file)
@@ -33,7 +33,7 @@
 
 #define tp_rcu_dereference_bp(p)                                            \
        ({                                                                   \
-               typeof(p) _________p1 = URCU_FORCE_CAST(typeof(p),           \
+               __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p),   \
                        tracepoint_dlopen.rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \
                (_________p1);                                               \
        })
This page took 0.031729 seconds and 4 git commands to generate.