Rename static_assert to avoid conflicting with C++'11 (and later) (XCC)
authorDan Cross <crossd@gmail.com>
Wed, 4 Nov 2015 19:22:26 +0000 (14:22 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 10 Nov 2015 16:09:45 +0000 (11:09 -0500)
The C++ standard laid claim to the name, 'static_assert' in the
C++'11 standard; our macro caused conflict trying to build C++
programs. Rename ours to avoid the conflict.

C11 also has support for _Static_assert and the 'static_assert'
macro in the 'assert.h' header. We should migrate to that.  This
is an incremental step in that direction.

Signed-off-by: Dan Cross <crossd@gmail.com>
[removed undef of parlib_static_assert; we aren't overriding stuff]
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/ceq.c
user/parlib/include/assert.h
user/parlib/ucq.c

index bdd933c..e7566ab 100644 (file)
@@ -44,7 +44,7 @@ void ceq_init(struct ceq *ceq, uint8_t op, size_t nr_events, size_t ring_sz)
        atomic_init(&ceq->prod_idx, 0);
        atomic_init(&ceq->cons_pub_idx, 0);
        atomic_init(&ceq->cons_pvt_idx, 0);
        atomic_init(&ceq->prod_idx, 0);
        atomic_init(&ceq->cons_pub_idx, 0);
        atomic_init(&ceq->cons_pvt_idx, 0);
-       static_assert(sizeof(struct spin_pdr_lock) <= sizeof(ceq->u_lock));
+       parlib_static_assert(sizeof(struct spin_pdr_lock) <= sizeof(ceq->u_lock));
        spin_pdr_init((struct spin_pdr_lock*)&ceq->u_lock);
 }
 
        spin_pdr_init((struct spin_pdr_lock*)&ceq->u_lock);
 }
 
index f025423..0abc723 100644 (file)
@@ -16,7 +16,6 @@
 __BEGIN_DECLS
 
 #undef assert
 __BEGIN_DECLS
 
 #undef assert
-#undef static_assert
 #undef warn
 
 void _warn(const char*, int, const char*, ...);
 #undef warn
 
 void _warn(const char*, int, const char*, ...);
@@ -33,8 +32,8 @@ void _assert_failed(const char *file, int line, const char *msg)
                        _assert_failed(__FILE__, __LINE__, #x);                            \
        } while (0)
 
                        _assert_failed(__FILE__, __LINE__, #x);                            \
        } while (0)
 
-// static_assert(x) will generate a compile-time error if 'x' is false.
-#define static_assert(x)       switch (x) case 0: case (x):
+// parlib_static_assert(x) will generate a compile-time error if 'x' is false.
+#define parlib_static_assert(x)        switch (x) case 0: case (x):
 
 __END_DECLS
 
 
 __END_DECLS
 
index dcbe8e2..8d0551f 100644 (file)
@@ -32,7 +32,7 @@ void ucq_init_raw(struct ucq *ucq, uintptr_t pg1, uintptr_t pg2)
        ucq->prod_overflow = FALSE;
        atomic_set(&ucq->nr_extra_pgs, 0);
        atomic_set(&ucq->spare_pg, pg2);
        ucq->prod_overflow = FALSE;
        atomic_set(&ucq->nr_extra_pgs, 0);
        atomic_set(&ucq->spare_pg, pg2);
-       static_assert(sizeof(struct spin_pdr_lock) <= sizeof(ucq->u_lock));
+       parlib_static_assert(sizeof(struct spin_pdr_lock) <= sizeof(ucq->u_lock));
        spin_pdr_init((struct spin_pdr_lock*)(&ucq->u_lock));
        ucq->ucq_ready = TRUE;
 }
        spin_pdr_init((struct spin_pdr_lock*)(&ucq->u_lock));
        ucq->ucq_ready = TRUE;
 }