made the code work with VC++ compiler (use make CONF=windows)

Fri, 12 Oct 2012 10:54:55 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 10:54:55 +0200
changeset 69
fb59270b1de3
parent 68
88dbea299440
child 70
6721482eaf8e
child 71
303dabadff1c

made the code work with VC++ compiler (use make CONF=windows)

gcc-debug.mk file | annotate | diff | comparison | revisions
gcc.mk file | annotate | diff | comparison | revisions
osx.mk file | annotate | diff | comparison | revisions
suncc-debug.mk file | annotate | diff | comparison | revisions
suncc.mk file | annotate | diff | comparison | revisions
test/Makefile file | annotate | diff | comparison | revisions
test/buffer_tests.c file | annotate | diff | comparison | revisions
test/dlist_tests.c file | annotate | diff | comparison | revisions
test/list_tests.c file | annotate | diff | comparison | revisions
test/map_tests.c file | annotate | diff | comparison | revisions
test/mpool_tests.c file | annotate | diff | comparison | revisions
test/string_tests.c file | annotate | diff | comparison | revisions
ucx/Makefile file | annotate | diff | comparison | revisions
ucx/allocator.h file | annotate | diff | comparison | revisions
ucx/buffer.c file | annotate | diff | comparison | revisions
ucx/buffer.h file | annotate | diff | comparison | revisions
ucx/dlist.c file | annotate | diff | comparison | revisions
ucx/list.c file | annotate | diff | comparison | revisions
ucx/logging.h file | annotate | diff | comparison | revisions
ucx/map.c file | annotate | diff | comparison | revisions
ucx/map.h file | annotate | diff | comparison | revisions
ucx/mempool.c file | annotate | diff | comparison | revisions
ucx/mempool.h file | annotate | diff | comparison | revisions
ucx/string.c file | annotate | diff | comparison | revisions
ucx/string.h file | annotate | diff | comparison | revisions
ucx/test.h file | annotate | diff | comparison | revisions
ucx/ucx.h file | annotate | diff | comparison | revisions
windows.mk file | annotate | diff | comparison | revisions
     1.1 --- a/gcc-debug.mk	Thu Oct 11 16:29:30 2012 +0200
     1.2 +++ b/gcc-debug.mk	Fri Oct 12 10:54:55 2012 +0200
     1.3 @@ -31,8 +31,10 @@
     1.4  AR = ar
     1.5  RM = rm
     1.6  
     1.7 -CFLAGS  = -std=gnu99 -g -fstrict-aliasing -Wstrict-aliasing
     1.8 +CFLAGS  = -std=gnu99 -g -fstrict-aliasing -Wstrict-aliasing -c
     1.9 +COFLAGS = -o
    1.10  LDFLAGS = 
    1.11 +LOFLAGS = -o
    1.12  ARFLAGS = -r
    1.13  RMFLAGS = -f
    1.14  
     2.1 --- a/gcc.mk	Thu Oct 11 16:29:30 2012 +0200
     2.2 +++ b/gcc.mk	Fri Oct 12 10:54:55 2012 +0200
     2.3 @@ -31,8 +31,10 @@
     2.4  AR = ar
     2.5  RM = rm
     2.6  
     2.7 -CFLAGS  = -std=gnu99 -O3 -fstrict-aliasing
     2.8 +CFLAGS  = -std=gnu99 -O3 -fstrict-aliasing -c
     2.9 +COFLAGS = -o
    2.10  LDFLAGS = 
    2.11 +LOFLAGS = -o
    2.12  ARFLAGS = -r
    2.13  RMFLAGS = -f
    2.14  
     3.1 --- a/osx.mk	Thu Oct 11 16:29:30 2012 +0200
     3.2 +++ b/osx.mk	Fri Oct 12 10:54:55 2012 +0200
     3.3 @@ -31,8 +31,10 @@
     3.4  AR = ar
     3.5  RM = rm
     3.6  
     3.7 -CFLAGS  = -std=gnu99 -g
     3.8 +CFLAGS  = -std=gnu99 -g -c
     3.9 +COFLAGS = -o
    3.10  LDFLAGS = 
    3.11 +LOFLAGS = -o
    3.12  ARFLAGS = -r
    3.13  RMFLAGS = -f
    3.14  
     4.1 --- a/suncc-debug.mk	Thu Oct 11 16:29:30 2012 +0200
     4.2 +++ b/suncc-debug.mk	Fri Oct 12 10:54:55 2012 +0200
     4.3 @@ -31,8 +31,10 @@
     4.4  AR = ar
     4.5  RM = rm
     4.6  
     4.7 -CFLAGS  = -g -xalias_level=compatible
     4.8 +CFLAGS  = -g -c
     4.9 +COFLAGS = -o
    4.10  LDFLAGS = 
    4.11 +LOFLAGS = -o
    4.12  ARFLAGS = -r
    4.13  RMFLAGS = -f
    4.14  
     5.1 --- a/suncc.mk	Thu Oct 11 16:29:30 2012 +0200
     5.2 +++ b/suncc.mk	Fri Oct 12 10:54:55 2012 +0200
     5.3 @@ -31,8 +31,10 @@
     5.4  AR = ar
     5.5  RM = rm
     5.6  
     5.7 -CFLAGS  = -O
     5.8 -LDFLAGS = 
     5.9 +CFLAGS  = -O -c
    5.10 +COFLAGS = -o
    5.11 +LDFLAGS =
    5.12 +LOFLAGS = -o
    5.13  ARFLAGS = -r
    5.14  RMFLAGS = -f
    5.15  
     6.1 --- a/test/Makefile	Thu Oct 11 16:29:30 2012 +0200
     6.2 +++ b/test/Makefile	Fri Oct 12 10:54:55 2012 +0200
     6.3 @@ -42,10 +42,11 @@
     6.4  all: ../build/test1
     6.5  
     6.6  ../build/test1: $(OBJ)
     6.7 -	$(LD) $(LDFLAGS) -o ../build/test$(APP_EXT) $(OBJ) ../build/libucx.a
     6.8 +	$(LD) $(LDFLAGS) $(LOFLAGS)../build/test$(APP_EXT) $(OBJ) \
     6.9 +		../build/libucx.$(LIB_EXT)
    6.10  
    6.11  ../build/%.$(OBJ_EXT): %.c ../build
    6.12 -	$(CC) $(CFLAGS) -I../ -o $@ -c $<
    6.13 +	$(CC) $(CFLAGS) -I../ $(COFLAGS)$@ $<
    6.14  
    6.15  ../build:
    6.16  	mkdir -p build
     7.1 --- a/test/buffer_tests.c	Thu Oct 11 16:29:30 2012 +0200
     7.2 +++ b/test/buffer_tests.c	Fri Oct 12 10:54:55 2012 +0200
     7.3 @@ -5,7 +5,7 @@
     7.4  #include "buffer_tests.h"
     7.5  
     7.6  UCX_TEST_IMPLEMENT(test_ucx_buffer_seektell) {
     7.7 -    char *buffer = malloc(16);
     7.8 +    char *buffer = (char*) malloc(16);
     7.9      memset(buffer, 32, 7);
    7.10      buffer[7] = 0;
    7.11  
    7.12 @@ -48,7 +48,7 @@
    7.13  }
    7.14  
    7.15  UCX_TEST_IMPLEMENT(test_ucx_buffer_putc) {
    7.16 -    char *buffer = malloc(16);
    7.17 +    char *buffer = (char*) malloc(16);
    7.18      memset(buffer, 32, 16);
    7.19  
    7.20      UcxBuffer *b = ucx_buffer_new(buffer, 16, UCX_BUFFER_DEFAULT);
    7.21 @@ -74,7 +74,7 @@
    7.22  }
    7.23  
    7.24  UCX_TEST_IMPLEMENT(test_ucx_buffer_getc) {
    7.25 -    char *buffer = malloc(16);
    7.26 +    char *buffer = (char*) malloc(16);
    7.27      memset(buffer, 32, 8);
    7.28      for (int i = 8; i < 16 ; i++) {
    7.29          buffer[i] = 40+i;
    7.30 @@ -104,7 +104,7 @@
    7.31  }
    7.32  
    7.33  UCX_TEST_IMPLEMENT(test_ucx_buffer_write) {
    7.34 -    char *buffer = malloc(16);
    7.35 +    char *buffer = (char*) malloc(16);
    7.36      memset(buffer, 32, 8);
    7.37      for (int i = 8; i < 16 ; i++) {
    7.38          buffer[i] = 40+i;
    7.39 @@ -115,8 +115,8 @@
    7.40  
    7.41      UCX_TEST_BEGIN
    7.42  
    7.43 -    char* teststring = "this is way too much";
    7.44 -    r = ucx_buffer_write(teststring, 1, 20, b);
    7.45 +    const char* teststring = "this is way too much";
    7.46 +    r = ucx_buffer_write((void*)teststring, 1, 20, b);
    7.47      UCX_TEST_ASSERT(r == 16, "string not correctly trimed");
    7.48      UCX_TEST_ASSERT(memcmp(buffer, teststring, 16) == 0,
    7.49              "buffer data incorrect");
    7.50 @@ -128,10 +128,10 @@
    7.51      UCX_TEST_ASSERT(memcmp(buffer, "this is not too much", 16) == 0,
    7.52              "modified buffer is incorrect");
    7.53  
    7.54 -    char* threebytestring = "  t  h  r  e  e   ";
    7.55 +    const char* threebytestring = "  t  h  r  e  e   ";
    7.56      memset(buffer, 49, 16);
    7.57      ucx_buffer_seek(b, 0, SEEK_SET);
    7.58 -    r = ucx_buffer_write(threebytestring, 3, 6, b);
    7.59 +    r = ucx_buffer_write((void*)threebytestring, 3, 6, b);
    7.60      UCX_TEST_ASSERT(r == 15, "three byte string not correctly trimed");
    7.61      UCX_TEST_ASSERT(b->pos == 15,
    7.62              "position after write of three byte string incorrect");
    7.63 @@ -146,7 +146,7 @@
    7.64  }
    7.65  
    7.66  UCX_TEST_IMPLEMENT(test_ucx_buffer_write_ax) {
    7.67 -    char *buffer = malloc(4);
    7.68 +    char *buffer = (char*) malloc(4);
    7.69  
    7.70      UcxBuffer *b = ucx_buffer_new(buffer, 16,
    7.71              UCX_BUFFER_AUTOEXTEND | UCX_BUFFER_AUTOFREE);
    7.72 @@ -154,9 +154,9 @@
    7.73  
    7.74      UCX_TEST_BEGIN
    7.75  
    7.76 -    char* teststring = "this is way too much";
    7.77 -    r = ucx_buffer_write(teststring, 1, 20, b);
    7.78 -    buffer = b->space; /* autoextend is enabled, so we MUST retrieve pointer */
    7.79 +    const char* teststring = "this is way too much";
    7.80 +    r = ucx_buffer_write((void*)teststring, 1, 20, b);
    7.81 +    buffer = (char*) b->space; /*autoextend enabled, we MUST retrieve pointer*/
    7.82      UCX_TEST_ASSERT(r == 20, "not all characters written");
    7.83      UCX_TEST_ASSERT(b->size == 32, "buffer not properly extended");
    7.84      UCX_TEST_ASSERT(b->pos == 20, "position incorrect");
    7.85 @@ -170,7 +170,7 @@
    7.86  }
    7.87  
    7.88  UCX_TEST_IMPLEMENT(test_ucx_buffer_read) {
    7.89 -    char *buffer = malloc(16);
    7.90 +    char *buffer = (char*) malloc(16);
    7.91      memset(buffer, 56, 8);
    7.92      for (int i = 8; i < 16 ; i++) {
    7.93          buffer[i] = 40+i;
    7.94 @@ -211,7 +211,7 @@
    7.95  }
    7.96  
    7.97  UCX_TEST_IMPLEMENT(test_ucx_buffer_extract) {
    7.98 -    char *buffer = malloc(16);
    7.99 +    char *buffer = (char*) malloc(16);
   7.100      strcpy(buffer, "this is a test!");
   7.101  
   7.102      UcxBuffer *src = ucx_buffer_new(buffer, 16, UCX_BUFFER_AUTOFREE),
     8.1 --- a/test/dlist_tests.c	Thu Oct 11 16:29:30 2012 +0200
     8.2 +++ b/test/dlist_tests.c	Fri Oct 12 10:54:55 2012 +0200
     8.3 @@ -8,11 +8,13 @@
     8.4      UcxDlist *list = ucx_dlist_append(NULL, "Hello");
     8.5      UCX_TEST_BEGIN
     8.6      
     8.7 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
     8.8 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
     8.9 +            "failed");
    8.10      
    8.11      list = ucx_dlist_append(list, " World!");
    8.12      
    8.13 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    8.14 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    8.15 +            "failed");
    8.16      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    8.17      UCX_TEST_END
    8.18      
    8.19 @@ -25,8 +27,10 @@
    8.20  
    8.21      list = ucx_dlist_prepend(list, "Hello");
    8.22      
    8.23 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    8.24 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    8.25 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    8.26 +            "failed");
    8.27 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    8.28 +            "failed");
    8.29      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    8.30      
    8.31      UCX_TEST_END
    8.32 @@ -58,8 +62,10 @@
    8.33      
    8.34      list = ucx_dlist_concat(list, list2);
    8.35      
    8.36 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    8.37 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    8.38 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    8.39 +            "failed");
    8.40 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    8.41 +            "failed");
    8.42      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    8.43      
    8.44      UCX_TEST_END
    8.45 @@ -86,7 +92,7 @@
    8.46      list = ucx_dlist_append(list, "the ");
    8.47      list = ucx_dlist_append(list, "first!");
    8.48      
    8.49 -    char* first = (char*) (ucx_dlist_first(list)->data);
    8.50 +    const char* first = (const char*) (ucx_dlist_first(list)->data);
    8.51      
    8.52      UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed");
    8.53      
    8.54 @@ -100,7 +106,7 @@
    8.55      list = ucx_dlist_append(list, "the ");
    8.56      list = ucx_dlist_append(list, "last!");
    8.57      
    8.58 -    char* last = (char*) (ucx_dlist_last(list)->data);
    8.59 +    const char* last = (const char*) (ucx_dlist_last(list)->data);
    8.60      
    8.61      UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
    8.62      
    8.63 @@ -114,7 +120,7 @@
    8.64      list = ucx_dlist_append(list, "the ");
    8.65      list = ucx_dlist_append(list, "mid!");
    8.66      
    8.67 -    char* mid = (char*) (ucx_dlist_get(list, 1)->data);
    8.68 +    const char* mid = (const char*) (ucx_dlist_get(list, 1)->data);
    8.69      
    8.70      UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
    8.71      
    8.72 @@ -130,8 +136,10 @@
    8.73      
    8.74      list = ucx_dlist_remove(list, ucx_dlist_get(list, 1));
    8.75      
    8.76 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    8.77 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    8.78 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    8.79 +            "failed");
    8.80 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    8.81 +            "failed");
    8.82      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    8.83      
    8.84      UCX_TEST_END
     9.1 --- a/test/list_tests.c	Thu Oct 11 16:29:30 2012 +0200
     9.2 +++ b/test/list_tests.c	Fri Oct 12 10:54:55 2012 +0200
     9.3 @@ -7,11 +7,13 @@
     9.4  UCX_TEST_IMPLEMENT(test_ucx_list_append) {
     9.5      UcxList *list = ucx_list_append(NULL, "Hello");
     9.6      UCX_TEST_BEGIN
     9.7 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
     9.8 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
     9.9 +            "failed");
    9.10      
    9.11      list = ucx_list_append(list, " World!");
    9.12      
    9.13 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    9.14 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    9.15 +            "failed");
    9.16      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    9.17  
    9.18      UCX_TEST_END
    9.19 @@ -23,8 +25,10 @@
    9.20      UCX_TEST_BEGIN
    9.21      list = ucx_list_prepend(list, "Hello");
    9.22      
    9.23 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    9.24 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    9.25 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    9.26 +            "failed");
    9.27 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    9.28 +            "failed");
    9.29      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    9.30      
    9.31      UCX_TEST_END
    9.32 @@ -56,8 +60,10 @@
    9.33      list = ucx_list_concat(list, list2);
    9.34      UCX_TEST_BEGIN
    9.35      
    9.36 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    9.37 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    9.38 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    9.39 +            "failed");
    9.40 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    9.41 +            "failed");
    9.42      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    9.43      
    9.44      UCX_TEST_END
    9.45 @@ -87,7 +93,7 @@
    9.46      list = ucx_list_append(list, "the ");
    9.47      list = ucx_list_append(list, "last!");
    9.48      
    9.49 -    char* last = (char*) (ucx_list_last(list)->data);
    9.50 +    const char* last = (const char*) (ucx_list_last(list)->data);
    9.51      
    9.52      UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
    9.53      
    9.54 @@ -102,7 +108,7 @@
    9.55      list = ucx_list_append(list, "the ");
    9.56      list = ucx_list_append(list, "mid!");
    9.57      
    9.58 -    char* mid = (char*) (ucx_list_get(list, 1)->data);
    9.59 +    const char* mid = (const char*) (ucx_list_get(list, 1)->data);
    9.60      
    9.61      UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
    9.62      
    9.63 @@ -118,8 +124,10 @@
    9.64      
    9.65      list = ucx_list_remove(list, ucx_list_get(list, 1));
    9.66      
    9.67 -    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
    9.68 -    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
    9.69 +    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    9.70 +            "failed");
    9.71 +    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    9.72 +            "failed");
    9.73      UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    9.74      UCX_TEST_END
    9.75      
    10.1 --- a/test/map_tests.c	Thu Oct 11 16:29:30 2012 +0200
    10.2 +++ b/test/map_tests.c	Fri Oct 12 10:54:55 2012 +0200
    10.3 @@ -17,7 +17,8 @@
    10.4  UCX_TEST_IMPLEMENT(test_ucx_key) {
    10.5      UcxKey key = ucx_key("This is a text.", 15);
    10.6      UCX_TEST_BEGIN
    10.7 -    UCX_TEST_ASSERT(strncmp(key.data, "This is a text.", 15) == 0, "failed");
    10.8 +    UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0,
    10.9 +            "failed");
   10.10      UCX_TEST_ASSERT(key.len == 15, "failed");
   10.11      UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed");
   10.12      
   10.13 @@ -179,9 +180,9 @@
   10.14  }
   10.15  
   10.16  void* test_ucx_map_store_load_encdec(void *value, void *data, size_t *size) {
   10.17 -    char *string = (char*) value;
   10.18 +    const char *string = (const char*) value;
   10.19      size_t n = strlen(string);
   10.20 -    char *encoded = malloc(n+1);
   10.21 +    char *encoded = (char*) malloc(n+1);
   10.22      for (int i = 0 ; i < n ; i++) {
   10.23          encoded[i] = string[n-1-i];
   10.24      }
   10.25 @@ -218,29 +219,29 @@
   10.26              test_ucx_map_store_load_encdec, NULL);
   10.27      fclose(f);
   10.28  
   10.29 -    char *value;
   10.30 +    const char *value;
   10.31      UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed");
   10.32  
   10.33 -    value = ucx_map_cstr_get(map, "test");
   10.34 +    value = (const char *) ucx_map_cstr_get(map, "test");
   10.35      UCX_TEST_ASSERT(value != NULL, "value not found for key: test");
   10.36      UCX_TEST_ASSERT(strcmp(value, "test") == 0, "value error for key: test");
   10.37  
   10.38 -    value = ucx_map_cstr_get(map, "key");
   10.39 +    value = (const char *) ucx_map_cstr_get(map, "key");
   10.40      UCX_TEST_ASSERT(value != NULL, "value not found for key: key");
   10.41      UCX_TEST_ASSERT(strcmp(value, "value") == 0, "value error for key: key");
   10.42  
   10.43 -    value = ucx_map_cstr_get(map, "other.very.long.key");
   10.44 +    value = (const char *) ucx_map_cstr_get(map, "other.very.long.key");
   10.45      UCX_TEST_ASSERT(value != NULL,
   10.46              "value not found for key: other.very.long.key");
   10.47      UCX_TEST_ASSERT(strcmp(value, "value") == 0,
   10.48              "value error for key: other.very.long.key");
   10.49  
   10.50 -    value = ucx_map_cstr_get(map, "testkey");
   10.51 +    value = (const char *) ucx_map_cstr_get(map, "testkey");
   10.52      UCX_TEST_ASSERT(value != NULL, "value not found for key: testkey");
   10.53      UCX_TEST_ASSERT(strcmp(value, "testvalue") == 0,
   10.54              "value error for key: testkey");
   10.55  
   10.56 -    value = ucx_map_cstr_get(map, "simple");
   10.57 +    value = (const char *) ucx_map_cstr_get(map, "simple");
   10.58      UCX_TEST_ASSERT(value != NULL, "value not found for key: simple");
   10.59      UCX_TEST_ASSERT(strcmp(value, "not a key but an extremely long value "
   10.60              "to test if the buffer extension works as designed") == 0,
   10.61 @@ -281,10 +282,10 @@
   10.62  
   10.63      UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed");
   10.64      UcxMapIterator iter = ucx_map_iterator(map);
   10.65 -    char *value; size_t n;
   10.66 +    const char *value; size_t n;
   10.67      UCX_MAP_FOREACH(value, iter) {
   10.68          n = strlen(value);
   10.69 -        UCX_TEST_ASSERT(strncmp(pool->data[iter.index], value, n),
   10.70 +        UCX_TEST_ASSERT(strncmp((const char*) pool->data[iter.index], value, n),
   10.71                  "values of map does not match pooled values");
   10.72      }
   10.73  
   10.74 @@ -302,9 +303,9 @@
   10.75      
   10.76      UcxMap *clone = ucx_map_clone(map, NULL, NULL);
   10.77      
   10.78 -    char *v1 = ucx_map_cstr_get(map, "key1");
   10.79 -    char *v2 = ucx_map_cstr_get(map, "key2");
   10.80 -    char *v3 = ucx_map_cstr_get(map, "key3");
   10.81 +    const char *v1 = (const char *) ucx_map_cstr_get(map, "key1");
   10.82 +    const char *v2 = (const char *) ucx_map_cstr_get(map, "key2");
   10.83 +    const char *v3 = (const char *) ucx_map_cstr_get(map, "key3");
   10.84      
   10.85      UCX_TEST_BEGIN
   10.86      
   10.87 @@ -312,9 +313,9 @@
   10.88      UCX_TEST_ASSERT(v2 != NULL, "failed key 2");
   10.89      UCX_TEST_ASSERT(v3 != NULL, "failed key 3");
   10.90      
   10.91 -    char *c1 = ucx_map_cstr_get(clone, "key1");
   10.92 -    char *c2 = ucx_map_cstr_get(clone, "key2");
   10.93 -    char *c3 = ucx_map_cstr_get(clone, "key3");
   10.94 +    const char *c1 = (const char *) ucx_map_cstr_get(clone, "key1");
   10.95 +    const char *c2 = (const char *) ucx_map_cstr_get(clone, "key2");
   10.96 +    const char *c3 = (const char *) ucx_map_cstr_get(clone, "key3");
   10.97      
   10.98      UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)");
   10.99      UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)");
  10.100 @@ -350,7 +351,7 @@
  10.101      UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count");
  10.102      UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect");
  10.103      for (int i = 0 ; i < 10 ; i++) {
  10.104 -        char *value = ucx_map_cstr_get(map, keys[i]);
  10.105 +        const char *value = (const char *) ucx_map_cstr_get(map, keys[i]);
  10.106          UCX_TEST_ASSERT(value != NULL, "new map is missing old keys");
  10.107          UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0,
  10.108                  "new map contains incorrect values");
    11.1 --- a/test/mpool_tests.c	Thu Oct 11 16:29:30 2012 +0200
    11.2 +++ b/test/mpool_tests.c	Fri Oct 12 10:54:55 2012 +0200
    11.3 @@ -2,7 +2,7 @@
    11.4   *
    11.5   */
    11.6  
    11.7 -#include <inttypes.h>
    11.8 +#include <stdint.h>
    11.9  
   11.10  #include "mpool_tests.h"
   11.11  
   11.12 @@ -146,11 +146,11 @@
   11.13      
   11.14      ucx_mempool_set_destr(test, test_setdestr);
   11.15      
   11.16 -    int *rtest, n = 2;
   11.17 +    intptr_t *rtest, n = 2;
   11.18      do {
   11.19          n *= 2;
   11.20          UCX_TEST_ASSERT(n < 65536, "test corrupt - no movement for realloc");
   11.21 -        rtest = ucx_mempool_realloc(pool, test, n*sizeof(intptr_t));
   11.22 +        rtest = (intptr_t*) ucx_mempool_realloc(pool, test, n*sizeof(intptr_t));
   11.23      } while (rtest == test);
   11.24      test = rtest;
   11.25      
    12.1 --- a/test/string_tests.c	Thu Oct 11 16:29:30 2012 +0200
    12.2 +++ b/test/string_tests.c	Fri Oct 12 10:54:55 2012 +0200
    12.3 @@ -32,7 +32,7 @@
    12.4      
    12.5      len = s1.length + s2.length + s3.length;
    12.6      
    12.7 -    cat.ptr = malloc(len + 1);
    12.8 +    cat.ptr = (char*) malloc(len + 1);
    12.9      cat.ptr[len] = 0;
   12.10      cat.length = len;
   12.11      
    13.1 --- a/ucx/Makefile	Thu Oct 11 16:29:30 2012 +0200
    13.2 +++ b/ucx/Makefile	Fri Oct 12 10:54:55 2012 +0200
    13.3 @@ -44,10 +44,10 @@
    13.4  all: libucx
    13.5  
    13.6  libucx: $(OBJ)
    13.7 -	$(AR) $(ARFLAGS) ../build/libucx.$(LIB_EXT) $(OBJ)
    13.8 +	$(AR) $(ARFLAGS) $(AOFLAGS)../build/libucx.$(LIB_EXT) $(OBJ)
    13.9  
   13.10  ../build/%.$(OBJ_EXT): %.c ../build
   13.11 -	$(CC) $(CFLAGS) -c $< -o $@
   13.12 +	$(CC) $(CFLAGS) $(COFLAGS)$@ $<
   13.13  
   13.14  ../build:
   13.15  	mkdir -p ../build
    14.1 --- a/ucx/allocator.h	Thu Oct 11 16:29:30 2012 +0200
    14.2 +++ b/ucx/allocator.h	Fri Oct 12 10:54:55 2012 +0200
    14.3 @@ -1,6 +1,8 @@
    14.4  #ifndef ALLOCATOR_H
    14.5  #define	ALLOCATOR_H
    14.6  
    14.7 +#include "ucx.h"
    14.8 +
    14.9  #ifdef	__cplusplus
   14.10  extern "C" {
   14.11  #endif
    15.1 --- a/ucx/buffer.c	Thu Oct 11 16:29:30 2012 +0200
    15.2 +++ b/ucx/buffer.c	Fri Oct 12 10:54:55 2012 +0200
    15.3 @@ -67,7 +67,7 @@
    15.4          npos = buffer->pos;
    15.5          break;
    15.6      case SEEK_END:
    15.7 -        npos = strlen(buffer->space);
    15.8 +        npos = strlen((const char*) buffer->space);
    15.9          break;
   15.10      }
   15.11  
    16.1 --- a/ucx/buffer.h	Thu Oct 11 16:29:30 2012 +0200
    16.2 +++ b/ucx/buffer.h	Fri Oct 12 10:54:55 2012 +0200
    16.3 @@ -1,6 +1,7 @@
    16.4  #ifndef BUFFER_H
    16.5  #define	BUFFER_H
    16.6  
    16.7 +#include "ucx.h"
    16.8  #include <sys/types.h>
    16.9  #include <stdio.h>
   16.10  
    17.1 --- a/ucx/dlist.c	Thu Oct 11 16:29:30 2012 +0200
    17.2 +++ b/ucx/dlist.c	Fri Oct 12 10:54:55 2012 +0200
    17.3 @@ -117,7 +117,7 @@
    17.4  UcxDlist *ucx_dlist_sort_merge(int length,
    17.5          UcxDlist* restrict ls, UcxDlist* restrict le, UcxDlist* restrict re,
    17.6          cmp_func fnc, void* data) {
    17.7 -    UcxDlist *sorted[length];
    17.8 +    ucx_dynarray_new(UcxDlist*, sorted, length);
    17.9      UcxDlist *rc, *lc;
   17.10  
   17.11      lc = ls; rc = le;
   17.12 @@ -151,7 +151,9 @@
   17.13      }
   17.14      sorted[length-1]->next = NULL;
   17.15  
   17.16 -    return sorted[0];
   17.17 +    UcxDlist *ret = sorted[0];
   17.18 +    ucx_dynarray_free(sorted);
   17.19 +    return ret;
   17.20  }
   17.21  
   17.22  UcxDlist *ucx_dlist_sort(UcxDlist *l, cmp_func fnc, void *data) {
    18.1 --- a/ucx/list.c	Thu Oct 11 16:29:30 2012 +0200
    18.2 +++ b/ucx/list.c	Fri Oct 12 10:54:55 2012 +0200
    18.3 @@ -113,7 +113,8 @@
    18.4  UcxList *ucx_list_sort_merge(int length,
    18.5          UcxList* restrict ls, UcxList* restrict le, UcxList* restrict re,
    18.6          cmp_func fnc, void* data) {
    18.7 -    UcxList *sorted[length];
    18.8 +
    18.9 +    ucx_dynarray_new(UcxList*, sorted, length);
   18.10      UcxList *rc, *lc;
   18.11  
   18.12      lc = ls; rc = le;
   18.13 @@ -145,7 +146,9 @@
   18.14      }
   18.15      sorted[length-1]->next = NULL;
   18.16  
   18.17 -    return sorted[0];
   18.18 +    UcxList *ret = sorted[0];
   18.19 +    ucx_dynarray_free(sorted);
   18.20 +    return ret;
   18.21  }
   18.22  
   18.23  UcxList *ucx_list_sort(UcxList *l, cmp_func fnc, void *data) {
    19.1 --- a/ucx/logging.h	Thu Oct 11 16:29:30 2012 +0200
    19.2 +++ b/ucx/logging.h	Fri Oct 12 10:54:55 2012 +0200
    19.3 @@ -1,6 +1,7 @@
    19.4  #ifndef LOGGING_H
    19.5  #define LOGGING_H
    19.6  
    19.7 +#include "ucx.h"
    19.8  #include "string.h"
    19.9  #include <stdio.h>
   19.10  
    20.1 --- a/ucx/map.c	Thu Oct 11 16:29:30 2012 +0200
    20.2 +++ b/ucx/map.c	Fri Oct 12 10:54:55 2012 +0200
    20.3 @@ -177,7 +177,7 @@
    20.4      UcxKey key;
    20.5      key.data = data;
    20.6      key.len = len;
    20.7 -    key.hash = ucx_hash(data, len);
    20.8 +    key.hash = ucx_hash((const char*) data, len);
    20.9      return key;
   20.10  }
   20.11  
   20.12 @@ -281,13 +281,13 @@
   20.13  
   20.14          /* read into key buffer */
   20.15          n = 16;
   20.16 -        key = malloc(n);
   20.17 +        key = (char*) malloc(n);
   20.18          r = 0;
   20.19          do {
   20.20              if (c == '=') break;
   20.21              if (r > n - 2) {
   20.22                  n *= 2;
   20.23 -                key = realloc(key, n);
   20.24 +                key = (char*) realloc(key, n);
   20.25              }
   20.26              key[r] = c;
   20.27              r++;
   20.28 @@ -310,13 +310,13 @@
   20.29  
   20.30          /* read into value buffer */
   20.31          n = 64;
   20.32 -        value = malloc(n);
   20.33 +        value = (char*) malloc(n);
   20.34          r = 0;
   20.35          do {
   20.36              if (c == '\n') break;
   20.37              if (r > n - 2) {
   20.38                  n *= 2;
   20.39 -                value = realloc(value, n);
   20.40 +                value = (char*) realloc(value, n);
   20.41              }
   20.42              value[r] = c;
   20.43              r++;
   20.44 @@ -328,18 +328,18 @@
   20.45              size_t decodedSize;
   20.46              void *decoded = decoder(value, decdata, &decodedSize);
   20.47              free(value);
   20.48 -            value = decoded;
   20.49 +            value = (char*) decoded;
   20.50              r = decodedSize;
   20.51          } else {
   20.52              r += 2;
   20.53 -            value = realloc(value, r);
   20.54 +            value = (char*) realloc(value, r);
   20.55          }
   20.56  
   20.57          if (allocator.pool) {
   20.58              void *pooledValue = allocator.malloc(allocator.pool, r);
   20.59              memcpy(pooledValue, value, r);
   20.60              free(value);
   20.61 -            value = pooledValue;
   20.62 +            value = (char*) pooledValue;
   20.63          }
   20.64  
   20.65          ucx_map_cstr_put(map, key, value);
   20.66 @@ -362,7 +362,7 @@
   20.67          if (encoder) {
   20.68              size_t encodedSize;
   20.69              void *encoded = encoder(v, encdata, &encodedSize);
   20.70 -            value = sstrn(encoded,encodedSize - 1);
   20.71 +            value = sstrn((char*) encoded,encodedSize - 1);
   20.72          } else {
   20.73              value = sstr(v);
   20.74          }
    21.1 --- a/ucx/map.h	Thu Oct 11 16:29:30 2012 +0200
    21.2 +++ b/ucx/map.h	Fri Oct 12 10:54:55 2012 +0200
    21.3 @@ -15,7 +15,7 @@
    21.4  #endif
    21.5  
    21.6  #define UCX_MAP_FOREACH(elm,iter) \
    21.7 -        for(;ucx_map_iter_next(&iter,(void*)&elm)==0;)
    21.8 +        for(;ucx_map_iter_next(&iter,(void**)&elm)==0;)
    21.9  
   21.10  typedef struct UcxMap          UcxMap;
   21.11  typedef struct UcxKey          UcxKey;
    22.1 --- a/ucx/mempool.c	Thu Oct 11 16:29:30 2012 +0200
    22.2 +++ b/ucx/mempool.c	Fri Oct 12 10:54:55 2012 +0200
    22.3 @@ -27,7 +27,7 @@
    22.4      UcxMempool *pool = (UcxMempool*)malloc(sizeof(UcxMempool));
    22.5      if (pool == NULL) return NULL;
    22.6      
    22.7 -    pool->data = malloc(n * sizeof(void*));
    22.8 +    pool->data = (void**) malloc(n * sizeof(void*));
    22.9      if (pool->data == NULL) {
   22.10          free(pool);
   22.11          return NULL;
   22.12 @@ -39,7 +39,7 @@
   22.13  }
   22.14  
   22.15  int ucx_mempool_chcap(UcxMempool *pool, size_t newcap) {
   22.16 -    void **data = realloc(pool->data, newcap*sizeof(void*));
   22.17 +    void **data = (void**) realloc(pool->data, newcap*sizeof(void*));
   22.18      if (data == NULL) {
   22.19          return 1;
   22.20      } else {
    23.1 --- a/ucx/mempool.h	Thu Oct 11 16:29:30 2012 +0200
    23.2 +++ b/ucx/mempool.h	Fri Oct 12 10:54:55 2012 +0200
    23.3 @@ -5,6 +5,7 @@
    23.4  #ifndef MPOOL_H
    23.5  #define	MPOOL_H
    23.6  
    23.7 +#include "ucx.h"
    23.8  #include <stddef.h>
    23.9  #include "allocator.h"
   23.10  
    24.1 --- a/ucx/string.c	Thu Oct 11 16:29:30 2012 +0200
    24.2 +++ b/ucx/string.c	Fri Oct 12 10:54:55 2012 +0200
    24.3 @@ -6,7 +6,7 @@
    24.4   */
    24.5  
    24.6  #include <stdlib.h>
    24.7 -#include <strings.h>
    24.8 +#include <string.h>
    24.9  #include <stdarg.h>
   24.10  
   24.11  #include "string.h"
   24.12 @@ -110,7 +110,7 @@
   24.13  
   24.14      /* special case: exact match - no processing needed */
   24.15      if (s.length == d.length && strncmp(s.ptr, d.ptr, s.length) == 0) {
   24.16 -        result = malloc(sizeof(sstr_t));
   24.17 +        result = (sstr_t*) malloc(sizeof(sstr_t));
   24.18          result[0] = sstrn("", 0);
   24.19          return result;
   24.20      }
   24.21 @@ -137,12 +137,12 @@
   24.22          }
   24.23          if ((*n) == nmax) break;
   24.24      }
   24.25 -    result = malloc(sizeof(sstr_t) * (*n));
   24.26 +    result = (sstr_t*) malloc(sizeof(sstr_t) * (*n));
   24.27  
   24.28      char *pptr = sv.ptr;
   24.29      for (int i = 0 ; i < *n ; i++) {
   24.30          size_t l = strlen(pptr);
   24.31 -        char* ptr = malloc(l + 1);
   24.32 +        char* ptr = (char*) malloc(l + 1);
   24.33          memcpy(ptr, pptr, l);
   24.34          ptr[l] = 0;
   24.35  
    25.1 --- a/ucx/string.h	Thu Oct 11 16:29:30 2012 +0200
    25.2 +++ b/ucx/string.h	Fri Oct 12 10:54:55 2012 +0200
    25.3 @@ -8,6 +8,7 @@
    25.4  #ifndef _SSTRING_H
    25.5  #define	_SSTRING_H
    25.6  
    25.7 +#include "ucx.h"
    25.8  #include <stddef.h>
    25.9  
   25.10  /* use macros for literals only */
    26.1 --- a/ucx/test.h	Thu Oct 11 16:29:30 2012 +0200
    26.2 +++ b/ucx/test.h	Fri Oct 12 10:54:55 2012 +0200
    26.3 @@ -33,6 +33,7 @@
    26.4  #ifndef TEST_H
    26.5  #define	TEST_H
    26.6  
    26.7 +#include "ucx.h"
    26.8  #include <stdio.h>
    26.9  #include <string.h>
   26.10  #include <setjmp.h>
   26.11 @@ -42,6 +43,10 @@
   26.12  extern "C" {
   26.13  #endif
   26.14  
   26.15 +#ifndef __FUNCTION__
   26.16 +#define __FUNCTION__ __func__
   26.17 +#endif
   26.18 +
   26.19  typedef struct {
   26.20      unsigned int success;
   26.21      unsigned int failure;
   26.22 @@ -60,7 +65,7 @@
   26.23  #define UCX_TEST_IMPLEMENT(name) void name(UcxTestSuite* _suite_,FILE *_output_)
   26.24  
   26.25  #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\
   26.26 -        fwrite(__func__, 1, strlen(__func__), _output_);\
   26.27 +        fwrite(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\
   26.28          fwrite("... ", 1, 4, _output_);\
   26.29          jmp_buf _env_; \
   26.30          if (!setjmp(_env_)) {
    27.1 --- a/ucx/ucx.h	Thu Oct 11 16:29:30 2012 +0200
    27.2 +++ b/ucx/ucx.h	Fri Oct 12 10:54:55 2012 +0200
    27.3 @@ -13,12 +13,23 @@
    27.4  #ifdef	__cplusplus
    27.5  #ifndef _Bool
    27.6  #define _Bool bool
    27.7 +#define restrict
    27.8  #endif
    27.9  extern "C" {
   27.10  #endif
   27.11  
   27.12  #define UCX_FOREACH(type,list,elem) \
   27.13          for (type elem = list ; elem != NULL ; elem = elem->next)
   27.14 +
   27.15 +#ifdef __cplusplus
   27.16 +#define ucx_dynarray_new(type,identifier,length)\
   27.17 +    type* identifier; identifier = new type[length]
   27.18 +#define ucx_dynarray_free(identifier) delete [] identifier
   27.19 +#else
   27.20 +#define ucx_dynarray_new(type,identifier,length)\
   27.21 +    type identifier[length]
   27.22 +#define ucx_dynarray_free(identifier)
   27.23 +#endif
   27.24      
   27.25  /* element1,element2,custom data -> {-1,0,1} */
   27.26  typedef int(*cmp_func)(void*,void*,void*);
    28.1 --- a/windows.mk	Thu Oct 11 16:29:30 2012 +0200
    28.2 +++ b/windows.mk	Fri Oct 12 10:54:55 2012 +0200
    28.3 @@ -26,15 +26,18 @@
    28.4  # POSSIBILITY OF SUCH DAMAGE.
    28.5  #
    28.6  
    28.7 -CC = gcc
    28.8 -LD = gcc
    28.9 -AR = ar
   28.10 +CC = cl
   28.11 +LD = link
   28.12 +AR = lib
   28.13  RM = rm
   28.14  
   28.15 -CFLAGS  = -std=gnu99
   28.16 +CFLAGS  = -c -TP
   28.17 +COFLAGS = -Fo
   28.18  LDFLAGS = 
   28.19 -ARFLAGS = -r
   28.20 -RMFLAGS = -f
   28.21 +LOFLAGS = -OUT:
   28.22 +ARFLAGS =
   28.23 +AOFLAGS = -OUT:
   28.24 +RMFLAGS = -f 
   28.25  
   28.26  OBJ_EXT = obj
   28.27  LIB_EXT = lib

mercurial