aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDavid Johnson <davijoh3@cisco.com>2018-12-14 14:53:41 -0500
committerDavid Johnson <davijoh3@cisco.com>2019-01-02 10:55:55 -0500
commitd9818dd68c162079f3ddb5443a78d0d91d55d0fe (patch)
tree71a597e8fb2c9c7ebd70870ae78091872591e216 /src/vppinfra
parentd6897c1597c4f0904d5956f7d794e3f001d52f72 (diff)
Fixes for buliding for 32bit targets:
* u32/u64/uword mismatches * pointer-to-int fixes * printf formatting issues * issues with incorrect "ULL" and related suffixes * structure alignment and padding issues Change-Id: I70b989007758755fe8211c074f651150680f60b4 Signed-off-by: David Johnson <davijoh3@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/clib.h3
-rw-r--r--src/vppinfra/crc32.h4
-rw-r--r--src/vppinfra/cuckoo_template.h2
-rw-r--r--src/vppinfra/dlmalloc.c31
-rw-r--r--src/vppinfra/dlmalloc.h14
5 files changed, 27 insertions, 27 deletions
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index 95dadd9c09d..8aec1f16beb 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -81,6 +81,9 @@
#define CLIB_PACKED(x) x __attribute__ ((packed))
#define CLIB_UNUSED(x) x __attribute__ ((unused))
+/* similar to CLIB_CACHE_LINE_ALIGN_MARK() but with arbitrary alignment */
+#define CLIB_ALIGN_MARK(name, alignment) u8 name[0] __attribute__((aligned(alignment)))
+
/* Make a string from the macro's argument */
#define CLIB_STRING_MACRO(x) #x
diff --git a/src/vppinfra/crc32.h b/src/vppinfra/crc32.h
index 5f4d94f3847..fec67cd9757 100644
--- a/src/vppinfra/crc32.h
+++ b/src/vppinfra/crc32.h
@@ -30,14 +30,14 @@ clib_crc32c (u8 * s, int len)
{
u32 v = 0;
-#if __x86_64__
+#if defined(__x86_64__)
for (; len >= 8; len -= 8, s += 8)
v = _mm_crc32_u64 (v, *((u64 *) s));
#else
/* workaround weird GCC bug when using _mm_crc32_u32
which happens with -O2 optimization */
#if !defined (__i686__)
- volatile ("":::"memory");
+ asm volatile ("":::"memory");
#endif
#endif
diff --git a/src/vppinfra/cuckoo_template.h b/src/vppinfra/cuckoo_template.h
index eccbde108c4..c3b2bc98aaa 100644
--- a/src/vppinfra/cuckoo_template.h
+++ b/src/vppinfra/cuckoo_template.h
@@ -291,7 +291,7 @@ typedef struct CV (clib_cuckoo)
} CVT (clib_cuckoo);
void CV (clib_cuckoo_init) (CVT (clib_cuckoo) * h, const char *name,
- u64 nbuckets,
+ uword nbuckets,
void (*garbage_callback) (CVT (clib_cuckoo) *,
void *),
void *garbage_ctx);
diff --git a/src/vppinfra/dlmalloc.c b/src/vppinfra/dlmalloc.c
index 8a07621b7a5..9ed1e04f776 100644
--- a/src/vppinfra/dlmalloc.c
+++ b/src/vppinfra/dlmalloc.c
@@ -4089,8 +4089,7 @@ size_t destroy_mspace(mspace msp) {
return freed;
}
-void mspace_get_address_and_size (mspace msp, unsigned long long *addrp,
- unsigned long long *sizep)
+void mspace_get_address_and_size (mspace msp, char **addrp, size_t *sizep)
{
mstate ms;
msegment *this_seg;
@@ -4098,7 +4097,7 @@ void mspace_get_address_and_size (mspace msp, unsigned long long *addrp,
ms = (mstate)msp;
this_seg = &ms->seg;
- *addrp = (unsigned long long) this_seg->base;
+ *addrp = this_seg->base;
*sizep = this_seg->size;
}
@@ -4157,11 +4156,11 @@ int mspace_enable_disable_trace (mspace msp, int enable)
}
void* mspace_get_aligned (mspace msp,
- unsigned long long n_user_data_bytes,
- unsigned long long align,
- unsigned long long align_offset) {
+ unsigned long n_user_data_bytes,
+ unsigned long align,
+ unsigned long align_offset) {
char *rv;
- unsigned long long searchp;
+ unsigned long searchp;
unsigned *wwp; /* "where's Waldo" pointer */
mstate ms = (mstate)msp;
@@ -4183,7 +4182,7 @@ void* mspace_get_aligned (mspace msp,
mchunkptr p = mem2chunk(rv);
size_t psize = chunksize(p);
- mheap_get_trace ((u64)rv + sizeof (unsigned), psize);
+ mheap_get_trace ((unsigned long)rv + sizeof (unsigned), psize);
}
wwp = (unsigned *)rv;
@@ -4201,7 +4200,7 @@ void* mspace_get_aligned (mspace msp,
* Waldo is the address of the chunk of memory returned by mspace_malloc,
* which we need later to call mspace_free...
*/
- if (align > 4<<10 || align_offset == ~0ULL) {
+ if (align > 4<<10 || align_offset == ~0UL) {
n_user_data_bytes -= sizeof(unsigned);
assert(align_offset == 0);
rv = internal_memalign(ms, (size_t)align, n_user_data_bytes);
@@ -4210,7 +4209,7 @@ void* mspace_get_aligned (mspace msp,
if (rv && use_trace(ms)) {
mchunkptr p = mem2chunk(rv);
size_t psize = chunksize(p);
- mheap_get_trace ((u64)rv, psize);
+ mheap_get_trace ((unsigned long)rv, psize);
}
return rv;
}
@@ -4228,7 +4227,7 @@ void* mspace_get_aligned (mspace msp,
return rv;
/* Honor the alignment request */
- searchp = (unsigned long long)(rv + sizeof (unsigned));
+ searchp = (unsigned long)(rv + sizeof (unsigned));
#if 0 /* this is the idea... */
while ((searchp + align_offset) % align)
@@ -4236,7 +4235,7 @@ void* mspace_get_aligned (mspace msp,
#endif
{
- unsigned long long where_now, delta;
+ unsigned long where_now, delta;
where_now = (searchp + align_offset) % align;
delta = align - where_now;
@@ -4245,13 +4244,13 @@ void* mspace_get_aligned (mspace msp,
}
wwp = (unsigned *)(searchp - sizeof(unsigned));
- *wwp = (searchp - (((unsigned long long) rv) + sizeof (*wwp)));
+ *wwp = (searchp - (((unsigned long) rv) + sizeof (*wwp)));
assert (*wwp < align);
if (use_trace(ms)) {
mchunkptr p = mem2chunk(rv);
size_t psize = chunksize(p);
- mheap_get_trace ((u64)rv, psize);
+ mheap_get_trace ((unsigned long)rv, psize);
}
return (void *) searchp;
}
@@ -4276,7 +4275,7 @@ void mspace_put (mspace msp, void *p_arg)
mchunkptr p = mem2chunk(object_header);
size_t psize = chunksize(p);
- mheap_put_trace ((u64)p_arg, psize);
+ mheap_put_trace ((unsigned long)p_arg, psize);
}
#if CLIB_DEBUG > 0
@@ -4300,7 +4299,7 @@ void mspace_put_no_offset (mspace msp, void *p_arg)
mchunkptr p = mem2chunk(p_arg);
size_t psize = chunksize(p);
- mheap_put_trace ((u64)p_arg, psize);
+ mheap_put_trace ((unsigned long)p_arg, psize);
}
mspace_free (msp, p_arg);
}
diff --git a/src/vppinfra/dlmalloc.h b/src/vppinfra/dlmalloc.h
index b7a8eea80a0..216df4737ca 100644
--- a/src/vppinfra/dlmalloc.h
+++ b/src/vppinfra/dlmalloc.h
@@ -1448,22 +1448,20 @@ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad);
DLMALLOC_EXPORT int mspace_mallopt(int, int);
DLMALLOC_EXPORT void* mspace_get_aligned (mspace msp,
- unsigned long long n_user_data_bytes,
- unsigned long long align,
- unsigned long long align_offset);
+ unsigned long n_user_data_bytes,
+ unsigned long align,
+ unsigned long align_offset);
DLMALLOC_EXPORT int mspace_is_heap_object (mspace msp, void *p);
-DLMALLOC_EXPORT void mspace_get_address_and_size (mspace msp,
- unsigned long long *addrp,
- unsigned long long *sizep);
+DLMALLOC_EXPORT void mspace_get_address_and_size (mspace msp, char **addrp, size_t *sizep);
DLMALLOC_EXPORT void mspace_put (mspace msp, void *p);
DLMALLOC_EXPORT void mspace_put_no_offset (mspace msp, void *p);
DLMALLOC_EXPORT size_t mspace_usable_size_with_delta (const void *p);
DLMALLOC_EXPORT void mspace_disable_expand (mspace msp);
DLMALLOC_EXPORT void *mspace_least_addr (mspace msp);
-DLMALLOC_EXPORT void mheap_get_trace (u64 offset, u64 size);
-DLMALLOC_EXPORT void mheap_put_trace (u64 offset, u64 size);
+DLMALLOC_EXPORT void mheap_get_trace (uword offset, uword size);
+DLMALLOC_EXPORT void mheap_put_trace (uword offset, uword size);
DLMALLOC_EXPORT int mspace_enable_disable_trace (mspace msp, int enable);
#endif /* MSPACES */