general: First pass cast qualifier warning fixes.

ck_pring
Samy Al Bahra 10 years ago
parent d2c26d60f3
commit 7d70240449

2
configure vendored

@ -599,7 +599,7 @@ elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER"
INSTALL_LIBS="install-lib" INSTALL_LIBS="install-lib"
fi fi
CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS" CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS"
PTHREAD_CFLAGS="-pthread" PTHREAD_CFLAGS="-pthread"
if test "$COMPILER" = "mingw64"; then if test "$COMPILER" = "mingw64"; then
ENVIRONMENT=64 ENVIRONMENT=64

@ -131,9 +131,9 @@ CK_PR_FAS_S(8, uint8_t, "xchgb")
{ \ { \
T r; \ T r; \
__asm__ __volatile__(I " %1, %0" \ __asm__ __volatile__(I " %1, %0" \
: "=q" (r) \ : "=q" (r) \
: "m" (*(C *)target) \ : "m" (*(const C *)target) \
: "memory"); \ : "memory"); \
return (r); \ return (r); \
} }

@ -150,7 +150,7 @@ run_test(unsigned int is, unsigned int ad)
if (i & 1) { if (i & 1) {
if (ck_hs_put_unique(&hs[j], h, test[i]) == false) if (ck_hs_put_unique(&hs[j], h, test[i]) == false)
ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]);
} else if (ck_hs_apply(&hs[j], h, test[i], test_unique, (char *)test[i]) == false) { } else if (ck_hs_apply(&hs[j], h, test[i], test_unique, (void *)(uintptr_t)test[i]) == false) {
ck_error("ERROR: Failed to apply for insertion.\n"); ck_error("ERROR: Failed to apply for insertion.\n");
} }
@ -161,7 +161,7 @@ run_test(unsigned int is, unsigned int ad)
ck_error("ERROR: Failed to remove apply.\n"); ck_error("ERROR: Failed to remove apply.\n");
} }
if (ck_hs_apply(&hs[j], h, test[i], test_negative, (char *)test[i]) == false) if (ck_hs_apply(&hs[j], h, test[i], test_negative, (char *)(uintptr_t)test[i]) == false)
ck_error("ERROR: Failed to apply.\n"); ck_error("ERROR: Failed to apply.\n");
break; break;
@ -272,7 +272,7 @@ run_test(unsigned int is, unsigned int ad)
} }
/* Attempt in-place mutation. */ /* Attempt in-place mutation. */
if (ck_hs_apply(&hs[j], h, test[i], test_ip, (void *)test[i]) == false) if (ck_hs_apply(&hs[j], h, test[i], test_ip, (void *)(uintptr_t)test[i]) == false)
ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]); ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]);
d = ck_hs_get(&hs[j], h, test[i]) != NULL; d = ck_hs_get(&hs[j], h, test[i]) != NULL;

@ -83,7 +83,7 @@ main(void)
mode |= CK_HT_WORKLOAD_DELETE; mode |= CK_HT_WORKLOAD_DELETE;
#endif #endif
if (ck_ht_init(&ht, mode, NULL, &my_allocator, 16, 6602834) == false) { if (ck_ht_init(&ht, mode, NULL, &my_allocator, 2, 6602834) == false) {
perror("ck_ht_init"); perror("ck_ht_init");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

@ -29,7 +29,7 @@ libck.a: $(OBJECTS)
ck_array.o: $(INCLUDE_DIR)/ck_array.h $(SDIR)/ck_array.c ck_array.o: $(INCLUDE_DIR)/ck_array.h $(SDIR)/ck_array.c
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_array.o $(SDIR)/ck_array.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_array.o $(SDIR)/ck_array.c
ck_epoch.o: $(INCLUDE_DIR)/ck_epoch.h $(SDIR)/ck_epoch.c ck_epoch.o: $(INCLUDE_DIR)/ck_epoch.h $(SDIR)/ck_epoch.c $(INCLUDE_DIR)/ck_stack.h
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_epoch.o $(SDIR)/ck_epoch.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_epoch.o $(SDIR)/ck_epoch.c
ck_hs.o: $(INCLUDE_DIR)/ck_hs.h $(SDIR)/ck_hs.c ck_hs.o: $(INCLUDE_DIR)/ck_hs.h $(SDIR)/ck_hs.c
@ -41,7 +41,7 @@ ck_rhs.o: $(INCLUDE_DIR)/ck_rhs.h $(SDIR)/ck_rhs.c
ck_ht.o: $(INCLUDE_DIR)/ck_ht.h $(SDIR)/ck_ht.c ck_ht.o: $(INCLUDE_DIR)/ck_ht.h $(SDIR)/ck_ht.c
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_ht.o $(SDIR)/ck_ht.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_ht.o $(SDIR)/ck_ht.c
ck_hp.o: $(SDIR)/ck_hp.c ck_hp.o: $(SDIR)/ck_hp.c $(INCLUDE_DIR)/ck_hp.h $(INCLUDE_DIR)/ck_stack.h
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_hp.o $(SDIR)/ck_hp.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_hp.o $(SDIR)/ck_hp.c
ck_barrier_centralized.o: $(SDIR)/ck_barrier_centralized.c ck_barrier_centralized.o: $(SDIR)/ck_barrier_centralized.c
@ -62,4 +62,3 @@ ck_barrier_mcs.o: $(SDIR)/ck_barrier_mcs.c
clean: clean:
rm -rf $(TARGET_DIR)/*.dSYM $(TARGET_DIR)/*~ $(TARGET_DIR)/*.o \ rm -rf $(TARGET_DIR)/*.dSYM $(TARGET_DIR)/*~ $(TARGET_DIR)/*.o \
$(OBJECTS) $(TARGET_DIR)/libck.a $(TARGET_DIR)/libck.so $(OBJECTS) $(TARGET_DIR)/libck.a $(TARGET_DIR)/libck.so

@ -498,24 +498,26 @@ leave:
return cursor; return cursor;
} }
static inline void * static inline const void *
ck_hs_marshal(unsigned int mode, const void *key, unsigned long h) ck_hs_marshal(unsigned int mode, const void *key, unsigned long h)
{ {
void *insert;
#ifdef CK_HS_PP #ifdef CK_HS_PP
const void *insert;
if (mode & CK_HS_MODE_OBJECT) { if (mode & CK_HS_MODE_OBJECT) {
insert = (void *)((uintptr_t)CK_HS_VMA(key) | ((h >> 25) << CK_MD_VMA_BITS)); insert = (void *)((uintptr_t)CK_HS_VMA(key) |
((h >> 25) << CK_MD_VMA_BITS));
} else { } else {
insert = (void *)key; insert = key;
} }
return insert;
#else #else
(void)mode; (void)mode;
(void)h; (void)h;
insert = (void *)key;
#endif
return insert; return key;
#endif
} }
bool bool
@ -570,7 +572,7 @@ ck_hs_gc(struct ck_hs *hs, unsigned long cycles, unsigned long seed)
ck_hs_map_bound_get(map, h), CK_HS_PROBE); ck_hs_map_bound_get(map, h), CK_HS_PROBE);
if (first != NULL) { if (first != NULL) {
void *insert = ck_hs_marshal(hs->mode, entry, h); const void *insert = ck_hs_marshal(hs->mode, entry, h);
ck_pr_store_ptr(first, insert); ck_pr_store_ptr(first, insert);
ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]); ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]);
@ -614,7 +616,8 @@ ck_hs_fas(struct ck_hs *hs,
const void *key, const void *key,
void **previous) void **previous)
{ {
void **slot, **first, *object, *insert; const void *insert;
void **slot, **first, *object;
unsigned long n_probes; unsigned long n_probes;
struct ck_hs_map *map = hs->map; struct ck_hs_map *map = hs->map;
@ -660,7 +663,8 @@ ck_hs_apply(struct ck_hs *hs,
ck_hs_apply_fn_t *fn, ck_hs_apply_fn_t *fn,
void *cl) void *cl)
{ {
void **slot, **first, *object, *insert, *delta; const void *insert;
void **slot, **first, *object, *delta;
unsigned long n_probes; unsigned long n_probes;
struct ck_hs_map *map; struct ck_hs_map *map;
@ -731,7 +735,8 @@ ck_hs_set(struct ck_hs *hs,
const void *key, const void *key,
void **previous) void **previous)
{ {
void **slot, **first, *object, *insert; const void *insert;
void **slot, **first, *object;
unsigned long n_probes; unsigned long n_probes;
struct ck_hs_map *map; struct ck_hs_map *map;
@ -788,7 +793,8 @@ ck_hs_put_internal(struct ck_hs *hs,
const void *key, const void *key,
enum ck_hs_probe_behavior behavior) enum ck_hs_probe_behavior behavior)
{ {
void **slot, **first, *object, *insert; const void *insert;
void **slot, **first, *object;
unsigned long n_probes; unsigned long n_probes;
struct ck_hs_map *map; struct ck_hs_map *map;

@ -122,7 +122,7 @@ static inline void MurmurHash3_x86_32 ( const void * key, int len,
//---------- //----------
// body // body
const uint32_t * blocks = (const uint32_t *)(void *)(data + nblocks*4); const uint32_t * blocks = (const uint32_t *)(const void *)(data + nblocks*4);
for(i = -nblocks; i; i++) for(i = -nblocks; i; i++)
{ {
@ -179,7 +179,7 @@ static inline uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed
if (!((uintptr_t)data & 0x7)) if (!((uintptr_t)data & 0x7))
k = *data++; k = *data++;
else { else {
memcpy(&k, (void *)data, sizeof(k)); memcpy(&k, data, sizeof(k));
data++; data++;
} }
@ -248,9 +248,9 @@ static inline uint64_t MurmurHash64B ( const void * key, int len, uint64_t seed
switch(len) switch(len)
{ {
case 3: h2 ^= ((unsigned char*)data)[2] << 16; case 3: h2 ^= ((const unsigned char*)data)[2] << 16;
case 2: h2 ^= ((unsigned char*)data)[1] << 8; case 2: h2 ^= ((const unsigned char*)data)[1] << 8;
case 1: h2 ^= ((unsigned char*)data)[0]; case 1: h2 ^= ((const unsigned char*)data)[0];
h2 *= m; h2 *= m;
}; };

@ -782,24 +782,25 @@ leave:
return offset; return offset;
} }
static inline void * static inline const void *
ck_rhs_marshal(unsigned int mode, const void *key, unsigned long h) ck_rhs_marshal(unsigned int mode, const void *key, unsigned long h)
{ {
void *insert;
#ifdef CK_RHS_PP #ifdef CK_RHS_PP
const void *insert;
if (mode & CK_RHS_MODE_OBJECT) { if (mode & CK_RHS_MODE_OBJECT) {
insert = (void *)((uintptr_t)CK_RHS_VMA(key) | ((h >> 25) << CK_MD_VMA_BITS)); insert = (void *)((uintptr_t)CK_RHS_VMA(key) | ((h >> 25) << CK_MD_VMA_BITS));
} else { } else {
insert = (void *)key; insert = key;
} }
return insert;
#else #else
(void)mode; (void)mode;
(void)h; (void)h;
insert = (void *)key;
#endif
return insert; return key;
#endif
} }
bool bool
@ -1047,7 +1048,8 @@ ck_rhs_fas(struct ck_rhs *hs,
void **previous) void **previous)
{ {
long slot, first; long slot, first;
void *object, *insert; void *object;
const void *insert;
unsigned long n_probes; unsigned long n_probes;
struct ck_rhs_map *map = hs->map; struct ck_rhs_map *map = hs->map;
struct ck_rhs_entry_desc *desc, *desc2; struct ck_rhs_entry_desc *desc, *desc2;
@ -1108,7 +1110,8 @@ ck_rhs_apply(struct ck_rhs *hs,
ck_rhs_apply_fn_t *fn, ck_rhs_apply_fn_t *fn,
void *cl) void *cl)
{ {
void *object, *insert, *delta = false; const void *insert;
void *object, *delta = false;
unsigned long n_probes; unsigned long n_probes;
long slot, first; long slot, first;
struct ck_rhs_map *map; struct ck_rhs_map *map;
@ -1211,7 +1214,8 @@ ck_rhs_set(struct ck_rhs *hs,
void **previous) void **previous)
{ {
long slot, first; long slot, first;
void *object, *insert; void *object;
const void *insert;
unsigned long n_probes; unsigned long n_probes;
struct ck_rhs_map *map; struct ck_rhs_map *map;
@ -1290,7 +1294,8 @@ ck_rhs_put_internal(struct ck_rhs *hs,
enum ck_rhs_probe_behavior behavior) enum ck_rhs_probe_behavior behavior)
{ {
long slot, first; long slot, first;
void *object, *insert; void *object;
const void *insert;
unsigned long n_probes; unsigned long n_probes;
struct ck_rhs_map *map; struct ck_rhs_map *map;

Loading…
Cancel
Save