]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - lib/birdlib.h
Filter: Fix function comparison
[thirdparty/bird.git] / lib / birdlib.h
index 428b3209ff8c542ad4c8a1d39de79cfd00c3d776..5202b0c8b2ae20765b73ce5255801990f49a96a9 100644 (file)
@@ -38,7 +38,7 @@ struct align_probe { char x; long int y; };
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
 #define BYTES(n) ((((uint) (n)) + 7) / 8)
 #define CALL(fn, args...) ({ if (fn) fn(args); })
-#define ADVANCE(w, r, l) ({ r -= l; w += l; })
+#define ADVANCE(w, r, l) ({ r -= (l); w += (l); })
 
 static inline int uint_cmp(uint i1, uint i2)
 { return (int)(i1 > i2) - (int)(i1 < i2); }
@@ -56,6 +56,13 @@ static inline int u64_cmp(u64 i1, u64 i2)
 #define BIT32_CLR(b,p)         ((b)[(p)/32] &= ~BIT32_VAL(p))
 #define BIT32_ZERO(b,l)                memset((b), 0, (l)/8)
 
+/* The same, but counting bits from MSB */
+#define BIT32R_VAL(p)          ((((u32) 1) << 31) >> ((p) % 32))
+#define BIT32R_TEST(b,p)       ((b)[(p)/32] & BIT32R_VAL(p))
+#define BIT32R_SET(b,p)                ((b)[(p)/32] |= BIT32R_VAL(p))
+#define BIT32R_CLR(b,p)                ((b)[(p)/32] &= ~BIT32R_VAL(p))
+#define BIT32R_ZERO(b,l)       memset((b), 0, (l)/8)
+
 #ifndef NULL
 #define NULL ((void *) 0)
 #endif
@@ -66,6 +73,10 @@ static inline int u64_cmp(u64 i1, u64 i2)
 #define UNUSED __attribute__((unused))
 #define PACKED __attribute__((packed))
 
+#ifndef HAVE_THREAD_LOCAL
+#define _Thread_local
+#endif
+
 /* Microsecond time */
 
 typedef s64 btime;
@@ -157,6 +168,15 @@ void debug(const char *msg, ...);  /* Printf to debug output */
 #define ASSERT(x) do { if (!(x)) log(L_BUG "Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0)
 #endif
 
+#ifdef DEBUGGING
+asm(
+    ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
+    ".byte 1\n" /* Python */
+    ".asciz \"bird-gdb.py\"\n"
+    ".popsection\n"
+   );
+#endif
+
 /* Pseudorandom numbers */
 
 u32 random_u32(void);