summaryrefslogtreecommitdiffstats
path: root/clib
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2015-02-18 16:14:28 -0600
committerAdriana Kobylak <anoo@us.ibm.com>2015-02-18 16:14:28 -0600
commit76ce4aadee1a7a890001affed54a0fb1110b1793 (patch)
tree14a358904909e8fe0f631d414333c26de81e5042 /clib
parentaa8354ef7ee6606fe32453e3eedce9af8038230a (diff)
downloadffs-76ce4aadee1a7a890001affed54a0fb1110b1793.tar.gz
ffs-76ce4aadee1a7a890001affed54a0fb1110b1793.zip
Support to compile in 64bit for Ubuntu Little Endian
Diffstat (limited to 'clib')
-rw-r--r--clib/Rules.cunit.mk2
-rw-r--r--clib/Rules.mk8
-rw-r--r--clib/Rules.test.mk2
-rw-r--r--clib/compare.h2
-rw-r--r--clib/hash.h8
-rw-r--r--clib/misc.h45
-rw-r--r--clib/slab.h18
-rw-r--r--clib/src/array.c2
-rw-r--r--clib/src/crc32_main.c2
-rw-r--r--clib/src/ecc.c20
-rw-r--r--clib/src/list.c10
-rw-r--r--clib/src/memory_leak_detection.c40
-rw-r--r--clib/src/slab.c14
-rw-r--r--clib/src/table.c4
-rw-r--r--clib/src/tree.c6
-rw-r--r--clib/src/value.c8
-rw-r--r--clib/src/vector.c44
-rw-r--r--clib/src/vector_iter.c2
-rw-r--r--clib/table.h2
-rw-r--r--clib/tree.h2
-rw-r--r--clib/vector.h42
-rw-r--r--clib/vector_iter.h2
22 files changed, 160 insertions, 125 deletions
diff --git a/clib/Rules.cunit.mk b/clib/Rules.cunit.mk
index c848f1e..9fe4338 100644
--- a/clib/Rules.cunit.mk
+++ b/clib/Rules.cunit.mk
@@ -22,7 +22,7 @@
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
-CFLAGS += -m32 -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
+CFLAGS += -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
LDFLAGS = -rdynamic -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
TARGETS=clib
diff --git a/clib/Rules.mk b/clib/Rules.mk
index 17a84fa..342fd0f 100644
--- a/clib/Rules.mk
+++ b/clib/Rules.mk
@@ -22,10 +22,10 @@
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
-CFLAGS += -m32 -D_GNU_SOURCE -std=gnu99 -fshort-enums -D_FILE_OFFSET_BITS=64
-CFLAGS += -iquote$(DEPTH)
+CFLAGS += -D_GNU_SOURCE -std=gnu99 -fshort-enums -D_FILE_OFFSET_BITS=64
+CFLAGS += -iquote$(DEPTH) -fPIC
-LDFLAGS=-L. -m32
+LDFLAGS=-L.
# array.o array_iter.o dispatch.o watch.o signal.o heap.o
@@ -48,7 +48,7 @@ vpath %.h ..
all: $(TARGETS)
libclib.so: $(OBJS)
- $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$@ -o $@ $^ -lpthread \
+ $(CC) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^ -lpthread \
-lrt
libclib.a: $(OBJS)
diff --git a/clib/Rules.test.mk b/clib/Rules.test.mk
index 8d91d84..bcb1fb1 100644
--- a/clib/Rules.test.mk
+++ b/clib/Rules.test.mk
@@ -22,7 +22,7 @@
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
-CFLAGS += -m32 -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
+CFLAGS += -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
LDFLAGS = -rdynamic -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
TARGETS=exception \
diff --git a/clib/compare.h b/clib/compare.h
index 296983e..438d5ac 100644
--- a/clib/compare.h
+++ b/clib/compare.h
@@ -43,7 +43,7 @@ typedef int (*compare_f) (const void *, const void *);
*/
static inline int default_compare(const void *v1, const void *v2)
{
- const int i1 = (const int)v1, i2 = (const int)v2;
+ const int i1 = (const long)v1, i2 = (const long)v2;
return i1 - i2;
}
diff --git a/clib/hash.h b/clib/hash.h
index 52eb22f..29fd9ec 100644
--- a/clib/hash.h
+++ b/clib/hash.h
@@ -26,7 +26,7 @@
/*
* File: hash.h
* Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Various int32 hash functions
+ * Descr: Various int64 hash functions
* Note:
* Date: 10/03/10
*/
@@ -38,13 +38,13 @@
/* ======================================================================= */
-static inline int32_t int32_hash1(int32_t);
+static inline int64_t int64_hash1(int64_t);
-typedef uint32_t(*hash_t) (char *, uint32_t);
+typedef uint64_t(*hash_t) (char *, uint64_t);
/* ======================================================================= */
-static inline int32_t int32_hash1(int32_t key)
+static inline int64_t int64_hash1(int64_t key)
{
key = ~key + (key << 15);
key = key ^ (key >> 12);
diff --git a/clib/misc.h b/clib/misc.h
index ddec6d0..edb5da5 100644
--- a/clib/misc.h
+++ b/clib/misc.h
@@ -49,6 +49,51 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#ifndef be16toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be16toh(x) __bswap_16(x)
+#define htobe16(x) __bswap_16(x)
+#define le16toh(x) (x)
+#define htole16(x) (x)
+#else
+#define be16toh(x) (x)
+#define htobe16(x) (x)
+#define le16toh(x) __bswap_16(x)
+#define htole16(x) __bswap_16(x)
+#endif
+#endif
+
+#ifndef be32toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be32toh(x) __bswap_32(x)
+#define htobe32(x) __bswap_32(x)
+#define le32toh(x) (x)
+#define htole32(x) (x)
+#else
+#define be32toh(x) (x)
+#define htobe32(x) (x)
+#define le32toh(x) __bswap_32(x)
+#define htole32(x) __bswap_32(x)
+#endif
+#endif
+
+#ifndef be64toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be64toh(x) __bswap_64(x)
+#define htobe64(x) __bswap_64(x)
+#define le64toh(x) (x)
+#define htole64(x) (x)
+#else
+#define be64toh(x) (x)
+#define htobe64(x) (x)
+#define le64toh(x) __bswap_64(x)
+#define htole64(x) __bswap_64(x)
+#endif
+#endif
+
#ifndef gettid
#define gettid() ({ \
pid_t __tid = (pid_t)syscall(SYS_gettid); \
diff --git a/clib/slab.h b/clib/slab.h
index bbd5991..40151a4 100644
--- a/clib/slab.h
+++ b/clib/slab.h
@@ -89,13 +89,13 @@ struct slab_header {
ident_t id; //!< identification
char name[SLAB_NAME_SIZE]; //!< slab name
- size_t page_size; //!< page size
- size_t align_size; //!< page alignment size
- size_t page_count; //!< page count
+ uint32_t page_size; //!< page size
+ uint32_t align_size; //!< page alignment size
+ uint32_t page_count; //!< page count
- size_t alloc_size; //!< allocation size
- size_t data_size; //!< data size
- size_t bitmap_size; //!< bitmap size
+ uint32_t alloc_size; //!< allocation size
+ uint32_t data_size; //!< data size
+ uint32_t bitmap_size; //!< bitmap size
};
typedef struct slab_header slab_header_t;
@@ -122,11 +122,11 @@ typedef struct slab slab_t; //!< Alias for the @em slab class
*/
/*! @cond */
#define slab_init(...) STRCAT(slab_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int slab_init3(slab_t * self, const char *name, size_t alloc_size)
+extern int slab_init3(slab_t * self, const char *name, uint32_t alloc_size)
__nonnull((1, 2));
-extern int slab_init4(slab_t * self, const char *name, size_t alloc_size,
+extern int slab_init4(slab_t * self, const char *name, uint32_t alloc_size,
size_t page_size) __nonnull((1, 2));
-extern int slab_init5(slab_t * self, const char *name, size_t alloc_size,
+extern int slab_init5(slab_t * self, const char *name, uint32_t alloc_size,
size_t page_size, size_t align_size) __nonnull((1, 2));
/*! @endcond */
diff --git a/clib/src/array.c b/clib/src/array.c
index 19659cb..4a0581a 100644
--- a/clib/src/array.c
+++ b/clib/src/array.c
@@ -99,7 +99,7 @@ const char *__array_msg[] = {
#define __index_to_page_hashed(i,s) \
({ \
- typeof(i) _h = int32_hash1(__index_to_page((i),(s))); \
+ typeof(i) _h = int64_hash1(__index_to_page((i),(s))); \
_h; \
})
diff --git a/clib/src/crc32_main.c b/clib/src/crc32_main.c
index d848eab..889d096 100644
--- a/clib/src/crc32_main.c
+++ b/clib/src/crc32_main.c
@@ -65,7 +65,7 @@ int main(int argc, const char *argv[])
void *in_buf = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0);
if (in_buf == MAP_FAILED) {
/* FIXME could still try to use read().... */
- printf("mmap %d failed: %s\n", filesize, strerror(errno));
+ printf("mmap %d failed: %s\n", (uint32_t)filesize, strerror(errno));
return 1;
}
diff --git a/clib/src/ecc.c b/clib/src/ecc.c
index a161668..c9a5f38 100644
--- a/clib/src/ecc.c
+++ b/clib/src/ecc.c
@@ -50,17 +50,7 @@
#include "ecc.h"
#include "builtin.h"
#include "attribute.h"
-
-#ifndef be64toh
-#include <byteswap.h>
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define be64toh(x) __bswap_64(x)
-#define htobe64(x) __bswap_64(x)
-#else
-#define be64toh(x) (x)
-#define htobe64(x) (x)
-#endif
-#endif
+#include "misc.h"
/*
* This is an alternative way to calculate the ECC byte taken
@@ -185,11 +175,11 @@ static void __ecc_dump(FILE * __out, uint32_t __addr,
fprintf(__out,
"[%.8s_%.8s %.*s%.2s%.*s %.8s_%.8s %.*s%.2s%.*s] ",
- hex + 0, hex + 8, (c1 != e1) ? strlen(ansi_red) : 0,
- ansi_red, hex + 16, (c1 != e1) ? strlen(ansi_norm) : 0,
+ hex + 0, hex + 8, (c1 != e1) ? (uint32_t)strlen(ansi_red) : 0,
+ ansi_red, hex + 16, (c1 != e1) ? (uint32_t)strlen(ansi_norm) : 0,
ansi_norm, hex + 18, hex + 26,
- (c2 != e2) ? strlen(ansi_red) : 0, ansi_red, hex + 34,
- (c2 != e2) ? strlen(ansi_norm) : 0, ansi_norm);
+ (c2 != e2) ? (uint32_t)strlen(ansi_red) : 0, ansi_red, hex + 34,
+ (c2 != e2) ? (uint32_t)strlen(ansi_norm) : 0, ansi_norm);
fprintf(__out, "[%.8s %.8s]\n", ascii + 0, ascii + 9);
}
diff --git a/clib/src/list.c b/clib/src/list.c
index 03f6a20..5c33a48 100644
--- a/clib/src/list.c
+++ b/clib/src/list.c
@@ -40,14 +40,14 @@ void list_dump(list_t * self, FILE * out)
fprintf(out,
"===================================================================\n");
- fprintf(out, "head: %8x node: %8x\n", (uint32_t) self,
- (uint32_t) & self->node);
+ fprintf(out, "head: %8lx node: %8lx\n", (ulong) self,
+ (ulong) & self->node);
list_node_t *node = &self->node;
do {
- fprintf(out, " node: %8x - prev: %8x - next: %8x\n",
- (uint32_t) node, (uint32_t) node->prev,
- (uint32_t) node->next);
+ fprintf(out, " node: %8lx - prev: %8lx - next: %8lx\n",
+ (ulong) node, (ulong) node->prev,
+ (ulong) node->next);
node = node->next;
} while (node != &self->node);
diff --git a/clib/src/memory_leak_detection.c b/clib/src/memory_leak_detection.c
index 2705ef1..07c6bd3 100644
--- a/clib/src/memory_leak_detection.c
+++ b/clib/src/memory_leak_detection.c
@@ -148,7 +148,7 @@ static int Check_Leak_List(const void *p)
/* Check the ending sentinel. */
Ending_Sentinel =
- (Sentinel_t *) ((unsigned int)Current_Item +
+ (Sentinel_t *) ((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t) +
Current_Item->User_Size);
if (*Ending_Sentinel == SENTINEL_VALUE) {
@@ -165,7 +165,7 @@ static int Check_Leak_List(const void *p)
Data_Start =
(unsigned
long)((unsigned
- int)
+ long)
Current_Item
+
sizeof
@@ -216,7 +216,7 @@ static int Check_Leak_List(const void *p)
" Size: %d\n"
" Allocated in module %s, function %s, at line %d\n",
Current_Item,
- (void *)((unsigned int)
+ (void *)((unsigned long)
Current_Item +
sizeof
(Memory_Leak_Data_t)),
@@ -235,7 +235,7 @@ static int Check_Leak_List(const void *p)
" Address: %p\n" " Size: %d\n"
" Allocated in module %s, function %s, at line %d\n",
Current_Item,
- (void *)((unsigned int)Current_Item +
+ (void *)((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t)),
Current_Item->User_Size,
Current_Item->Module_Name,
@@ -261,7 +261,7 @@ static int Check_Leak_List(const void *p)
Current_Item->Signature,
Current_Item->Signature, LEAK_SIGNATURE,
LEAK_SIGNATURE,
- (void *)((unsigned int)Current_Item +
+ (void *)((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t)),
Current_Item->User_Size,
Current_Item->User_Size,
@@ -428,7 +428,7 @@ static void Remove_Memory_Allocation_From_Chain(Memory_Leak_Data_t *
/* Calculate the address of the ending sentinel so that we can access it. */
Ending_Sentinel =
- (Sentinel_t *) ((unsigned int)Memory_Leak_Data +
+ (Sentinel_t *) ((unsigned long)Memory_Leak_Data +
sizeof(Memory_Leak_Data_t) +
Memory_Leak_Data->User_Size);
@@ -506,7 +506,7 @@ void Print_Leak_List(void)
/* Check the ending sentinel. */
Ending_Sentinel =
- (Sentinel_t *) ((unsigned int)Current_Item +
+ (Sentinel_t *) ((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t) +
Current_Item->User_Size);
if (*Ending_Sentinel == SENTINEL_VALUE) {
@@ -526,7 +526,7 @@ void Print_Leak_List(void)
" Allocated in module %s, function %s, at line %d\n\n",
Current_Item->Mem_Address,
Current_Item,
- (void *)((unsigned int)Current_Item +
+ (void *)((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t)),
Current_Item->Alignment,
Current_Item->User_Size,
@@ -543,7 +543,7 @@ void Print_Leak_List(void)
" Alignment: %u\n" " Size: %d\n"
" Allocated in module %s, function %s, at line %d\n\n",
Current_Item->Mem_Address, Current_Item,
- (void *)((unsigned int)Current_Item +
+ (void *)((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t)),
Current_Item->Alignment,
Current_Item->User_Size,
@@ -569,7 +569,7 @@ void Print_Leak_List(void)
Current_Item->Signature,
Current_Item->Signature, LEAK_SIGNATURE,
LEAK_SIGNATURE,
- (void *)((unsigned int)Current_Item +
+ (void *)((unsigned long)Current_Item +
sizeof(Memory_Leak_Data_t)),
Current_Item->Alignment,
Current_Item->User_Size,
@@ -677,7 +677,7 @@ int MEMORY_func(size_t sz,
if (sz == 0) {
Error = EINVAL;
fprintf(stderr,
- "MALLOC: request is invalid - size[%u] in module %s, function %s at line %d\n",
+ "MALLOC: request is invalid - size[%lu] in module %s, function %s at line %d\n",
sz, mod_name, func, line);
print_backtrace();
}
@@ -702,7 +702,7 @@ int MEMORY_func(size_t sz,
if (Error) {
fprintf(stderr,
- "MEMORY_func: request for aligned memory uses invalid alignment! size[%u], alignment [%u] in module %s, function %s at line %d\n",
+ "MEMORY_func: request for aligned memory uses invalid alignment! size[%lu], alignment [%u] in module %s, function %s at line %d\n",
sz, Alignment, mod_name, func, line);
}
@@ -711,7 +711,7 @@ int MEMORY_func(size_t sz,
if (Memory_Location == NULL) {
Error = EINVAL;
fprintf(stderr,
- "MEMORY_func: Location to place address of allocated memory is NULL! size[%u], alignment [%u] in module %s, function %s at line %d\n",
+ "MEMORY_func: Location to place address of allocated memory is NULL! size[%lu], alignment [%u] in module %s, function %s at line %d\n",
sz, Alignment, mod_name, func, line);
} else
*Memory_Location = NULL;
@@ -748,13 +748,13 @@ int MEMORY_func(size_t sz,
Memory_Leak_Data = (Memory_Leak_Data_t *) ptr;
} else {
Proposed_User_Address =
- (unsigned int)ptr +
+ (unsigned long)ptr +
sizeof(Memory_Leak_Data_t);
Shift_Amount =
Alignment -
(Proposed_User_Address % Alignment);
Memory_Leak_Data =
- (Memory_Leak_Data_t *) ((unsigned int)ptr +
+ (Memory_Leak_Data_t *) ((unsigned long)ptr +
Shift_Amount);
}
@@ -764,12 +764,12 @@ int MEMORY_func(size_t sz,
/* Create the address to return to the caller. This address should be the first byte after
our memory leak data. */
ptr =
- (void *)((unsigned int)Memory_Leak_Data +
+ (void *)((unsigned long)Memory_Leak_Data +
sizeof(Memory_Leak_Data_t));
/* Calculate the address of the trailing sentinel. */
Ending_Sentinel =
- (Sentinel_t *) ((unsigned int)ptr + sz);
+ (Sentinel_t *) ((unsigned long)ptr + sz);
/* Initialize our memory leak data. */
Memory_Leak_Data->Signature = LEAK_SIGNATURE;
@@ -920,7 +920,7 @@ void FREE_func(const void *p, const char *mod_name, const char *func,
* prevent wrap around when we subtract sizeof(Memory_Leak_Data_t) to get the starting address of
* the memory leak data associated with p.
*/
- if ((p == NULL) || ((unsigned int)p <= sizeof(Memory_Leak_Data_t))) {
+ if ((p == NULL) || ((unsigned long)p <= sizeof(Memory_Leak_Data_t))) {
fprintf(stderr,
"FREE: request has invalid user address [%p]. Request came from module %s, function %s, line %d\n",
p, mod_name, func, line);
@@ -942,7 +942,7 @@ void FREE_func(const void *p, const char *mod_name, const char *func,
if (!Check_Leak_List(p)) {
/* Get access to the memory leak data. */
Memory_Leak_Data =
- (Memory_Leak_Data_t *) ((unsigned int)p -
+ (Memory_Leak_Data_t *) ((unsigned long)p -
sizeof(Memory_Leak_Data_t));
USER3_PRINT_LINE
@@ -1178,7 +1178,7 @@ void *Realloc_func(void *p, size_t size, const char *mod_name, const char *func,
/* Get access to the memory leak data. */
Memory_Leak_Data =
(Memory_Leak_Data_t
- *) ((unsigned int)p -
+ *) ((unsigned long)p -
sizeof
(Memory_Leak_Data_t));
diff --git a/clib/src/slab.c b/clib/src/slab.c
index 1e5e5a8..9ee4353 100644
--- a/clib/src/slab.c
+++ b/clib/src/slab.c
@@ -63,7 +63,7 @@ typedef struct slab_node slab_node_t;
struct slab_node {
uint8_t magic[4];
- size_t free;
+ uint32_t free;
tree_node_t node;
uint32_t bitmap[];
@@ -98,7 +98,7 @@ static slab_node_t *__slab_grow(slab_t * self)
node->free = SLAB_ALLOC_COUNT(self);
- tree_node_init(&node->node, (const void *)int32_hash1((int32_t) node));
+ tree_node_init(&node->node, (const void *)int64_hash1((int64_t) node));
splay_insert(&self->tree, &node->node);
self->hdr.page_count++;
@@ -108,21 +108,21 @@ static slab_node_t *__slab_grow(slab_t * self)
/* ======================================================================= */
-int slab_init3(slab_t * self, const char *name, size_t alloc_size)
+int slab_init3(slab_t * self, const char *name, uint32_t alloc_size)
{
size_t page_size = max(sysconf(_SC_PAGESIZE),
__round_pow2(alloc_size * SLAB_PAGE_DIVISOR));
return slab_init5(self, name, alloc_size, page_size, page_size);
}
-int slab_init4(slab_t * self, const char *name, size_t alloc_size,
+int slab_init4(slab_t * self, const char *name, uint32_t alloc_size,
size_t page_size)
{
size_t align_size = (size_t) sysconf(_SC_PAGESIZE);
return slab_init5(self, name, alloc_size, page_size, align_size);
}
-int slab_init5(slab_t * self, const char *name, size_t alloc_size,
+int slab_init5(slab_t * self, const char *name, uint32_t alloc_size,
size_t page_size, size_t align_size)
{
assert(self != NULL);
@@ -144,7 +144,7 @@ int slab_init5(slab_t * self, const char *name, size_t alloc_size,
return -1;
}
- size_t __page_size = (size_t) sysconf(_SC_PAGESIZE);
+ uint32_t __page_size = (uint32_t) sysconf(_SC_PAGESIZE);
align_size = __round_pow2(align_size);
if (align_size % __page_size) {
@@ -286,7 +286,7 @@ int slab_free(slab_t * self, void *ptr)
assert(node != NULL);
if (unlikely(SLAB_NODE_MAGIC_CHECK(node->magic))) {
- int32_t hash = int32_hash1((int32_t) node);
+ int64_t hash = int64_hash1((int64_t) node);
if (splay_find(&self->tree, (const void *)hash) == NULL) {
UNEXPECTED("'%s' invalid slab_node pointer, %p",
self->hdr.name, ptr);
diff --git a/clib/src/table.c b/clib/src/table.c
index ee848cb..82a35aa 100644
--- a/clib/src/table.c
+++ b/clib/src/table.c
@@ -49,7 +49,7 @@
#define TABLE_PAGE_DIVISOR 32
/* ======================================================================= */
-int table_init(table_t * self, const char *name, size_t col_nr)
+int table_init(table_t * self, const char *name, uint32_t col_nr)
{
assert(self != NULL);
assert(name != NULL);
@@ -635,7 +635,7 @@ void table_dump(table_t * self, FILE * out)
}
fprintf(out,
- "table: [ size: %d cols: %d rows: %d name: '%s']\n",
+ "table: [ size: %ld cols: %ld rows: %ld name: '%s']\n",
sizeof(value_t), table_columns(self), table_rows(self),
self->hdr.name);
diff --git a/clib/src/tree.c b/clib/src/tree.c
index cb86ee3..5cd4c08 100644
--- a/clib/src/tree.c
+++ b/clib/src/tree.c
@@ -385,7 +385,7 @@ void tree_dump(tree_t * self, FILE * out)
int __tree_node_dump(tree_node_t * node) {
if (node != NULL)
return fprintf(out, "node[%p] left[%p] right[%p] "
- "parent[%p] -- key[%d]\n",
+ "parent[%p] -- key[%ld]\n",
node, node->left, node->right,
node->parent, (intptr_t) node->key);
else
@@ -414,7 +414,7 @@ void tree_node_dump(tree_node_t * node, FILE * out)
}
fprintf(out, "node:[%p] left[%p] right[%p] parent[%p] "
- "key[%d]\n", root, root->left, root->right,
+ "key[%ld]\n", root, root->left, root->right,
root->parent, (intptr_t) node->key);
level++;
@@ -591,7 +591,7 @@ int splay_remove(tree_t * self, tree_node_t * node)
}
#else
if (self->root->left != NULL && self->root->right != NULL) {
- if (parity(int32_hash1((int32_t) self->root))) {
+ if (parity(int64_hash1((int64_t) self->root))) {
x = splay(self->root->left, node->key,
self->compare);
x->right = self->root->right;
diff --git a/clib/src/value.c b/clib/src/value.c
index cadf8fd..899221e 100644
--- a/clib/src/value.c
+++ b/clib/src/value.c
@@ -74,7 +74,7 @@ void value_dump(const value_t * self, FILE * out)
break;
case VT_I64:
fprintf(out, "value: [ data: %lld size: %d type: %s ] %p\n",
- self->i64, self->size, type_name[self->type], self);
+ (long long)self->i64, self->size, type_name[self->type], self);
break;
case VT_U8:
fprintf(out, "value: [ data: %ud size: %d type: %s ] %p\n",
@@ -90,7 +90,7 @@ void value_dump(const value_t * self, FILE * out)
break;
case VT_U64:
fprintf(out, "value: [ data: %lld size: %d type: %s ] %p\n",
- self->u64, self->size, type_name[self->type], self);
+ (long long)self->u64, self->size, type_name[self->type], self);
break;
case VT_REAL32:
fprintf(out, "value: [ data: %f size: %d type: %s ] %p\n",
@@ -112,7 +112,7 @@ void value_dump(const value_t * self, FILE * out)
break;
case VT_STR_OFF:
fprintf(out, "value: [ data: %llu size: %d type: %s ] %p\n",
- self->u64, self->size, type_name[self->type], self);
+ (long long)self->u64, self->size, type_name[self->type], self);
break;
case VT_STR_CONST:
fprintf(out, "value: [ data: '%s' size: %d type: %s ] %p\n",
@@ -133,7 +133,7 @@ void value_dump(const value_t * self, FILE * out)
break;
case VT_BLOB_OFF:
fprintf(out, "value: [ data: %llu size: %d type: %s ] %p\n",
- self->u64, self->size, type_name[self->type], self);
+ (long long)self->u64, self->size, type_name[self->type], self);
break;
case VT_BLOB_FILE:
fprintf(out, "value: [ data: '%s' size: %d type: %s ] %p\n",
diff --git a/clib/src/vector.c b/clib/src/vector.c
index c4f44cc..73aa5c4 100644
--- a/clib/src/vector.c
+++ b/clib/src/vector.c
@@ -83,21 +83,21 @@ struct vector_node {
#define __index_to_page_hashed(i,s) \
({ \
- typeof(i) _h = int32_hash1(__index_to_page((i),(s))); \
+ typeof(i) _h = int64_hash1(__index_to_page((i),(s))); \
_h; \
})
/*! @endcond */
/* ======================================================================= */
-static vector_node_t *__vector_find_page(vector_t * self, size_t idx)
+static vector_node_t *__vector_find_page(vector_t * self, uint64_t idx)
{
const void *hash;
hash = (const void *)__index_to_page_hashed(idx, self->hdr.elem_num);
tree_node_t *node = tree_find(&self->tree, hash);
if (unlikely(node == NULL)) {
- UNEXPECTED("'%d' index out of range", idx);
+ UNEXPECTED("'%ld' index out of range", idx);
return NULL;
}
@@ -140,9 +140,9 @@ static vector_node_t *__vector_grow(vector_t * self)
node->magic[2] = VECTOR_NODE_MAGIC[2];
node->magic[3] = VECTOR_NODE_MAGIC[3];
- node->address = (uint32_t) node;
+ node->address = (ulong) node;
- size_t hash = __index_to_page_hashed(vector_capacity(self),
+ uint64_t hash = __index_to_page_hashed(vector_capacity(self),
self->hdr.elem_num);
tree_node_init(&node->node, (const void *)hash);
@@ -162,15 +162,15 @@ static int __vector_compare(const int i1, const int i2)
/* ======================================================================= */
-int vector_init3(vector_t * self, const char *name, size_t elem_size)
+int vector_init3(vector_t * self, const char *name, uint32_t elem_size)
{
- size_t page_size = max(sysconf(_SC_PAGESIZE),
+ uint32_t page_size = max(sysconf(_SC_PAGESIZE),
__round_pow2(elem_size * VECTOR_PAGE_DIVISOR));
return vector_init4(self, name, elem_size, page_size);
}
-int vector_init4(vector_t * self, const char *name, size_t elem_size,
- size_t page_size)
+int vector_init4(vector_t * self, const char *name, uint32_t elem_size,
+ uint32_t page_size)
{
assert(self != NULL);
@@ -251,7 +251,7 @@ int vector_delete(vector_t * self)
return 0;
}
-const void *vector_at(vector_t * self, size_t idx)
+const void *vector_at(vector_t * self, uint32_t idx)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -261,12 +261,12 @@ const void *vector_at(vector_t * self, size_t idx)
return node->data + (self->hdr.elem_size * (idx % self->hdr.elem_num));
}
-int vector_get3(vector_t * self, size_t idx, void *ptr)
+int vector_get3(vector_t * self, uint32_t idx, void *ptr)
{
return vector_get4(self, idx, ptr, 1);
}
-int vector_get4(vector_t * self, size_t idx, void *ptr, size_t count)
+int vector_get4(vector_t * self, uint32_t idx, void *ptr, uint32_t count)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -283,7 +283,7 @@ int vector_get4(vector_t * self, size_t idx, void *ptr, size_t count)
return 0;
}
-static inline int __vector_put(vector_t * self, size_t idx, const void *ptr)
+static inline int __vector_put(vector_t * self, uint32_t idx, const void *ptr)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -303,12 +303,12 @@ static inline int __vector_put(vector_t * self, size_t idx, const void *ptr)
return 0;
}
-int vector_put3(vector_t * self, size_t idx, const void *ptr)
+int vector_put3(vector_t * self, uint32_t idx, const void *ptr)
{
return vector_put4(self, idx, ptr, 1);
}
-int vector_put4(vector_t * self, size_t idx, const void *ptr, size_t count)
+int vector_put4(vector_t * self, uint32_t idx, const void *ptr, uint32_t count)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -327,13 +327,13 @@ int vector_put4(vector_t * self, size_t idx, const void *ptr, size_t count)
return 0;
}
-size_t vector_size1(vector_t * self)
+uint32_t vector_size1(vector_t * self)
{
assert(self != NULL);
return self->hdr.size;
}
-int vector_size2(vector_t * self, size_t size)
+int vector_size2(vector_t * self, uint32_t size)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -355,21 +355,21 @@ int vector_size2(vector_t * self, size_t size)
return self->hdr.size = size;
}
-size_t vector_pages(vector_t * self)
+uint32_t vector_pages(vector_t * self)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
return self->hdr.page_count;
}
-size_t vector_capacity(vector_t * self)
+uint32_t vector_capacity(vector_t * self)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
return self->hdr.page_count * self->hdr.elem_num;
}
-size_t vector_elem_size(vector_t * self)
+uint32_t vector_elem_size(vector_t * self)
{
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
@@ -557,7 +557,7 @@ ssize_t vector_load(vector_t * self, FILE * in)
return -1;
}
- node->address = (uint32_t) node;
+ node->address = (ulong) node;
tree_node_init(&node->node, node->node.key);
splay_insert(&self->tree, &node->node);
@@ -626,7 +626,7 @@ int vector_receive(vector_t * self, mqueue_t * mq)
assert(!VECTOR_NODE_MAGIC_CHECK(node->magic));
- node->address = (uint32_t) node;
+ node->address = (ulong) node;
tree_node_init(&node->node, node->node.key);
splay_insert(&self->tree, &node->node);
diff --git a/clib/src/vector_iter.c b/clib/src/vector_iter.c
index c7d0c50..f3db641 100644
--- a/clib/src/vector_iter.c
+++ b/clib/src/vector_iter.c
@@ -173,7 +173,7 @@ int vector_iter_pos2(vector_iter_t * self, size_t pos)
assert(self != NULL);
if (vector_size(self->vector) <= pos) {
- UNEXPECTED("'%d' index out-of-range", pos);
+ UNEXPECTED("'%ld' index out-of-range", pos);
return -1;
}
diff --git a/clib/table.h b/clib/table.h
index 36e4bd4..ceed6d1 100644
--- a/clib/table.h
+++ b/clib/table.h
@@ -130,7 +130,7 @@ typedef struct table table_t; //!< Alias for the @em table class
* @param col_nr [in] Number of columns
* @return None
*/
-extern int table_init(table_t *, const char *, size_t)
+extern int table_init(table_t *, const char *, uint32_t)
/*! @cond */
__nonnull((1, 2)) /*! @endcond */ ;
diff --git a/clib/tree.h b/clib/tree.h
index 82b1a30..f6736f8 100644
--- a/clib/tree.h
+++ b/clib/tree.h
@@ -108,7 +108,7 @@ struct tree {
tree_node_t *max; //!< reference to the node with largest 'key' in the tree
compare_f compare; //!< Reference to the function used to distinguish tree_nodes
- size_t size; //!< Cache of the number of tree_node's contained in the @em tree
+ uint32_t size; //!< Cache of the number of tree_node's contained in the @em tree
};
typedef struct tree tree_t; //!< Alias for the @em tree class
diff --git a/clib/vector.h b/clib/vector.h
index 9b9260d..1d39b4f 100644
--- a/clib/vector.h
+++ b/clib/vector.h
@@ -97,13 +97,13 @@ struct vector_header {
ident_t id; //!< identification
char name[VECTOR_NAME_SIZE]; //!< vector name
- size_t page_size; //!< data page size (in bytes)
- size_t page_count; //!< number of data pages allocated (currently)
+ uint32_t page_size; //!< data page size (in bytes)
+ uint32_t page_count; //!< number of data pages allocated (currently)
- size_t elem_size; //!< element size (in bytes)
- size_t elem_num; //!< element count (per page)
+ uint32_t elem_size; //!< element size (in bytes)
+ uint32_t elem_num; //!< element count (per page)
- size_t size; //!< number of initialized elements
+ uint32_t size; //!< number of initialized elements
};
typedef struct vector_header vector_header_t; //!< Alias for the @em vector_header class
@@ -120,7 +120,7 @@ typedef struct vector vector_t; //!< Alias for the @em vector class
/* ======================================================================= */
/*!
- * @fn void vector_init(vector_t * self, const char * name, size_t elem_size [, size_t page_size])
+ * @fn void vector_init(vector_t * self, const char * name, uint32_t elem_size [, uint32_t page_size])
* @brief Constructs an @em vector container object
* @details For example,
* @code
@@ -139,10 +139,10 @@ typedef struct vector vector_t; //!< Alias for the @em vector class
*/
/*! @cond */
#define vector_init(...) STRCAT(vector_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_init3(vector_t *, const char *, size_t)
+extern int vector_init3(vector_t *, const char *, uint32_t)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
-extern int vector_init4(vector_t *, const char *, size_t, size_t)
+extern int vector_init4(vector_t *, const char *, uint32_t, uint32_t)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
/*! @endcond */
@@ -184,12 +184,12 @@ __nonnull((1)) /*! @endcond */ ;
* @throws UNEXPECTED if @em self pointer is NULL
* @throws UNEXPECTED if vector element at @em idx is uninitialized
*/
-extern const void *vector_at(vector_t *, size_t)
+extern const void *vector_at(vector_t *, uint32_t)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
/*!
- * @fn void vector_get(vector_t * self, size_t idx, const void * ptr, size_t count=1)
+ * @fn void vector_get(vector_t * self, uint32_t idx, const void * ptr, uint32_t count=1)
* @brief Copy content from the @em vector
* @details Copies @em elem_num element(s) starting at position @em elem_off in the source @em vector to destination pointer @em ptr
* @note If the fourth parameter is omitted, it defaults to 1
@@ -212,16 +212,16 @@ __nonnull((1)) /*! @endcond */ ;
*/
/*! @cond */
#define vector_get(...) STRCAT(vector_get, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_get3(vector_t *, size_t, void *)
+extern int vector_get3(vector_t *, uint32_t, void *)
/*! @cond */
__nonnull((1, 3)) /*! @endcond */ ;
-extern int vector_get4(vector_t *, size_t, void *, size_t)
+extern int vector_get4(vector_t *, uint32_t, void *, uint32_t)
/*! @cond */
__nonnull((1, 3)) /*! @endcond */ ;
/*! @endcond */
/*!
- * @fn void vector_put(vector_t * self, size_t idx, const void * ptr, size_t count=1)
+ * @fn void vector_put(vector_t * self, uint32_t idx, const void * ptr, uint32_t count=1)
* @brief Assign new content to the @em vector
* @details Copies @em elem_num element(s) from source pointer @em ptr to the destination @em vector starting at position @em elem_off
* @note If the fourth parameter is omitted, it defaults to 1
@@ -244,16 +244,16 @@ __nonnull((1, 3)) /*! @endcond */ ;
*/
/*! @cond */
#define vector_put(...) STRCAT(vector_put, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_put3(vector_t *, size_t, const void *)
+extern int vector_put3(vector_t *, uint32_t, const void *)
/*! @cond */
__nonnull((1, 3)) /*! @endcond */ ;
-extern int vector_put4(vector_t *, size_t, const void *, size_t)
+extern int vector_put4(vector_t *, uint32_t, const void *, uint32_t)
/*! @cond */
__nonnull((1, 3)) /*! @endcond */ ;
/*! @endcond */
/*!
- * @fn size_t vector_size(vector_t * self, size_t size = 1)
+ * @fn uint32_t vector_size(vector_t * self, uint32_t size = 1)
* @brief Return or set the size of the @em vector
* @details Return or set the number of allocated elements in the @em vector
* @details For example,
@@ -272,10 +272,10 @@ __nonnull((1, 3)) /*! @endcond */ ;
*/
/*! @cond */
#define vector_size(...) STRCAT(vector_size, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern size_t vector_size1(vector_t *)
+extern uint32_t vector_size1(vector_t *)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
-extern int vector_size2(vector_t *, size_t)
+extern int vector_size2(vector_t *, uint32_t)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
/*! @endcond */
@@ -297,7 +297,7 @@ __nonnull((1)) /*! @endcond */ ;
* @return The number of pages that conform the vector's content
* @throws UNEXPECTED if @em self pointer is NULL
*/
-extern size_t vector_pages(vector_t *)
+extern uint32_t vector_pages(vector_t *)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
@@ -318,11 +318,11 @@ __nonnull((1)) /*! @endcond */ ;
* @return The number of total elements that conform the vector's content
* @throws UNEXPECTED if @em self pointer is NULL
*/
-extern size_t vector_capacity(vector_t *)
+extern uint32_t vector_capacity(vector_t *)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
-extern size_t vector_elem_size(vector_t *)
+extern uint32_t vector_elem_size(vector_t *)
/*! @cond */
__nonnull((1)) /*! @endcond */ ;
diff --git a/clib/vector_iter.h b/clib/vector_iter.h
index 5dc14bf..764a7fc 100644
--- a/clib/vector_iter.h
+++ b/clib/vector_iter.h
@@ -64,7 +64,7 @@ typedef struct vector_iter vector_iter_t; //!< Alias for the @em vector_iter cla
*/
struct vector_iter {
vector_t *vector; //!< Reference to the target vector object
- size_t idx; //!< Current position of the iterator
+ uint32_t idx; //!< Current position of the iterator
uint32_t flags; //!< Iterator configuration flags
};
OpenPOWER on IntegriCloud