summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/birdlib.h2
-rw-r--r--lib/mempool.c1
-rw-r--r--lib/printf.c15
-rw-r--r--lib/resource.c1
-rw-r--r--lib/slab.c1
5 files changed, 18 insertions, 2 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h
index b7cd6b4..12a581b 100644
--- a/lib/birdlib.h
+++ b/lib/birdlib.h
@@ -13,7 +13,7 @@
/* Ugly structure offset handling macros */
-#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
+#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
diff --git a/lib/mempool.c b/lib/mempool.c
index bb6dcff..e6f277b 100644
--- a/lib/mempool.c
+++ b/lib/mempool.c
@@ -27,6 +27,7 @@
struct lp_chunk {
struct lp_chunk *next;
unsigned int size;
+ uintptr_t data_align[0];
byte data[0];
};
diff --git a/lib/printf.c b/lib/printf.c
index 0e3b4d9..c3f7074 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -120,7 +120,8 @@ static char * number(char * str, long num, int base, int size, int precision,
* available space to avoid buffer overflows and it allows some more
* format specifiers: |%I| for formatting of IP addresses (any non-zero
* width is automatically replaced by standard IP address width which
- * depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format)
+ * depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format),
+ * |%R| for Router / Network ID (u32 value printed as IPv4 address)
* and |%m| resp. |%M| for error messages (uses strerror() to translate @errno code to
* message text). On the other hand, it doesn't support floating
* point numbers.
@@ -133,6 +134,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
int len;
unsigned long num;
int i, base;
+ u32 x;
char *str, *start;
const char *s;
char ipbuf[STD_ADDRESS_P_LENGTH+1];
@@ -277,6 +279,17 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
s = ipbuf;
goto str;
+ /* Router/Network ID - essentially IPv4 address in u32 value */
+ case 'R':
+ x = va_arg(args, u32);
+ bsprintf(ipbuf, "%d.%d.%d.%d",
+ ((x >> 24) & 0xff),
+ ((x >> 16) & 0xff),
+ ((x >> 8) & 0xff),
+ (x & 0xff));
+ s = ipbuf;
+ goto str;
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
diff --git a/lib/resource.c b/lib/resource.c
index 289af93..8f91450 100644
--- a/lib/resource.c
+++ b/lib/resource.c
@@ -250,6 +250,7 @@ resource_init(void)
struct mblock {
resource r;
unsigned size;
+ uintptr_t data_align[0];
byte data[0];
};
diff --git a/lib/slab.c b/lib/slab.c
index 568f01a..17511d2 100644
--- a/lib/slab.c
+++ b/lib/slab.c
@@ -62,6 +62,7 @@ static struct resclass sl_class = {
struct sl_obj {
node n;
+ uintptr_t data_align[0];
byte data[0];
};