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
--- a/gcc-debug.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/gcc-debug.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -31,8 +31,10 @@
 AR = ar
 RM = rm
 
-CFLAGS  = -std=gnu99 -g -fstrict-aliasing -Wstrict-aliasing
+CFLAGS  = -std=gnu99 -g -fstrict-aliasing -Wstrict-aliasing -c
+COFLAGS = -o
 LDFLAGS = 
+LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f
 
--- a/gcc.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/gcc.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -31,8 +31,10 @@
 AR = ar
 RM = rm
 
-CFLAGS  = -std=gnu99 -O3 -fstrict-aliasing
+CFLAGS  = -std=gnu99 -O3 -fstrict-aliasing -c
+COFLAGS = -o
 LDFLAGS = 
+LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f
 
--- a/osx.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/osx.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -31,8 +31,10 @@
 AR = ar
 RM = rm
 
-CFLAGS  = -std=gnu99 -g
+CFLAGS  = -std=gnu99 -g -c
+COFLAGS = -o
 LDFLAGS = 
+LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f
 
--- a/suncc-debug.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/suncc-debug.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -31,8 +31,10 @@
 AR = ar
 RM = rm
 
-CFLAGS  = -g -xalias_level=compatible
+CFLAGS  = -g -c
+COFLAGS = -o
 LDFLAGS = 
+LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f
 
--- a/suncc.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/suncc.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -31,8 +31,10 @@
 AR = ar
 RM = rm
 
-CFLAGS  = -O
-LDFLAGS = 
+CFLAGS  = -O -c
+COFLAGS = -o
+LDFLAGS =
+LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f
 
--- a/test/Makefile	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/Makefile	Fri Oct 12 10:54:55 2012 +0200
@@ -42,10 +42,11 @@
 all: ../build/test1
 
 ../build/test1: $(OBJ)
-	$(LD) $(LDFLAGS) -o ../build/test$(APP_EXT) $(OBJ) ../build/libucx.a
+	$(LD) $(LDFLAGS) $(LOFLAGS)../build/test$(APP_EXT) $(OBJ) \
+		../build/libucx.$(LIB_EXT)
 
 ../build/%.$(OBJ_EXT): %.c ../build
-	$(CC) $(CFLAGS) -I../ -o $@ -c $<
+	$(CC) $(CFLAGS) -I../ $(COFLAGS)$@ $<
 
 ../build:
 	mkdir -p build
--- a/test/buffer_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/buffer_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -5,7 +5,7 @@
 #include "buffer_tests.h"
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_seektell) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     memset(buffer, 32, 7);
     buffer[7] = 0;
 
@@ -48,7 +48,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_putc) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     memset(buffer, 32, 16);
 
     UcxBuffer *b = ucx_buffer_new(buffer, 16, UCX_BUFFER_DEFAULT);
@@ -74,7 +74,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_getc) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     memset(buffer, 32, 8);
     for (int i = 8; i < 16 ; i++) {
         buffer[i] = 40+i;
@@ -104,7 +104,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_write) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     memset(buffer, 32, 8);
     for (int i = 8; i < 16 ; i++) {
         buffer[i] = 40+i;
@@ -115,8 +115,8 @@
 
     UCX_TEST_BEGIN
 
-    char* teststring = "this is way too much";
-    r = ucx_buffer_write(teststring, 1, 20, b);
+    const char* teststring = "this is way too much";
+    r = ucx_buffer_write((void*)teststring, 1, 20, b);
     UCX_TEST_ASSERT(r == 16, "string not correctly trimed");
     UCX_TEST_ASSERT(memcmp(buffer, teststring, 16) == 0,
             "buffer data incorrect");
@@ -128,10 +128,10 @@
     UCX_TEST_ASSERT(memcmp(buffer, "this is not too much", 16) == 0,
             "modified buffer is incorrect");
 
-    char* threebytestring = "  t  h  r  e  e   ";
+    const char* threebytestring = "  t  h  r  e  e   ";
     memset(buffer, 49, 16);
     ucx_buffer_seek(b, 0, SEEK_SET);
-    r = ucx_buffer_write(threebytestring, 3, 6, b);
+    r = ucx_buffer_write((void*)threebytestring, 3, 6, b);
     UCX_TEST_ASSERT(r == 15, "three byte string not correctly trimed");
     UCX_TEST_ASSERT(b->pos == 15,
             "position after write of three byte string incorrect");
@@ -146,7 +146,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_write_ax) {
-    char *buffer = malloc(4);
+    char *buffer = (char*) malloc(4);
 
     UcxBuffer *b = ucx_buffer_new(buffer, 16,
             UCX_BUFFER_AUTOEXTEND | UCX_BUFFER_AUTOFREE);
@@ -154,9 +154,9 @@
 
     UCX_TEST_BEGIN
 
-    char* teststring = "this is way too much";
-    r = ucx_buffer_write(teststring, 1, 20, b);
-    buffer = b->space; /* autoextend is enabled, so we MUST retrieve pointer */
+    const char* teststring = "this is way too much";
+    r = ucx_buffer_write((void*)teststring, 1, 20, b);
+    buffer = (char*) b->space; /*autoextend enabled, we MUST retrieve pointer*/
     UCX_TEST_ASSERT(r == 20, "not all characters written");
     UCX_TEST_ASSERT(b->size == 32, "buffer not properly extended");
     UCX_TEST_ASSERT(b->pos == 20, "position incorrect");
@@ -170,7 +170,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_read) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     memset(buffer, 56, 8);
     for (int i = 8; i < 16 ; i++) {
         buffer[i] = 40+i;
@@ -211,7 +211,7 @@
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_buffer_extract) {
-    char *buffer = malloc(16);
+    char *buffer = (char*) malloc(16);
     strcpy(buffer, "this is a test!");
 
     UcxBuffer *src = ucx_buffer_new(buffer, 16, UCX_BUFFER_AUTOFREE),
--- a/test/dlist_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/dlist_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -8,11 +8,13 @@
     UcxDlist *list = ucx_dlist_append(NULL, "Hello");
     UCX_TEST_BEGIN
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
     
     list = ucx_dlist_append(list, " World!");
     
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     UCX_TEST_END
     
@@ -25,8 +27,10 @@
 
     list = ucx_dlist_prepend(list, "Hello");
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     
     UCX_TEST_END
@@ -58,8 +62,10 @@
     
     list = ucx_dlist_concat(list, list2);
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     
     UCX_TEST_END
@@ -86,7 +92,7 @@
     list = ucx_dlist_append(list, "the ");
     list = ucx_dlist_append(list, "first!");
     
-    char* first = (char*) (ucx_dlist_first(list)->data);
+    const char* first = (const char*) (ucx_dlist_first(list)->data);
     
     UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed");
     
@@ -100,7 +106,7 @@
     list = ucx_dlist_append(list, "the ");
     list = ucx_dlist_append(list, "last!");
     
-    char* last = (char*) (ucx_dlist_last(list)->data);
+    const char* last = (const char*) (ucx_dlist_last(list)->data);
     
     UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
     
@@ -114,7 +120,7 @@
     list = ucx_dlist_append(list, "the ");
     list = ucx_dlist_append(list, "mid!");
     
-    char* mid = (char*) (ucx_dlist_get(list, 1)->data);
+    const char* mid = (const char*) (ucx_dlist_get(list, 1)->data);
     
     UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
     
@@ -130,8 +136,10 @@
     
     list = ucx_dlist_remove(list, ucx_dlist_get(list, 1));
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     
     UCX_TEST_END
--- a/test/list_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/list_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -7,11 +7,13 @@
 UCX_TEST_IMPLEMENT(test_ucx_list_append) {
     UcxList *list = ucx_list_append(NULL, "Hello");
     UCX_TEST_BEGIN
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
     
     list = ucx_list_append(list, " World!");
     
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
 
     UCX_TEST_END
@@ -23,8 +25,10 @@
     UCX_TEST_BEGIN
     list = ucx_list_prepend(list, "Hello");
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     
     UCX_TEST_END
@@ -56,8 +60,10 @@
     list = ucx_list_concat(list, list2);
     UCX_TEST_BEGIN
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     
     UCX_TEST_END
@@ -87,7 +93,7 @@
     list = ucx_list_append(list, "the ");
     list = ucx_list_append(list, "last!");
     
-    char* last = (char*) (ucx_list_last(list)->data);
+    const char* last = (const char*) (ucx_list_last(list)->data);
     
     UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
     
@@ -102,7 +108,7 @@
     list = ucx_list_append(list, "the ");
     list = ucx_list_append(list, "mid!");
     
-    char* mid = (char*) (ucx_list_get(list, 1)->data);
+    const char* mid = (const char*) (ucx_list_get(list, 1)->data);
     
     UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
     
@@ -118,8 +124,10 @@
     
     list = ucx_list_remove(list, ucx_list_get(list, 1));
     
-    UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed");
-    UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
+            "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
+            "failed");
     UCX_TEST_ASSERT(list->next->next == NULL, "failed");
     UCX_TEST_END
     
--- a/test/map_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/map_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -17,7 +17,8 @@
 UCX_TEST_IMPLEMENT(test_ucx_key) {
     UcxKey key = ucx_key("This is a text.", 15);
     UCX_TEST_BEGIN
-    UCX_TEST_ASSERT(strncmp(key.data, "This is a text.", 15) == 0, "failed");
+    UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0,
+            "failed");
     UCX_TEST_ASSERT(key.len == 15, "failed");
     UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed");
     
@@ -179,9 +180,9 @@
 }
 
 void* test_ucx_map_store_load_encdec(void *value, void *data, size_t *size) {
-    char *string = (char*) value;
+    const char *string = (const char*) value;
     size_t n = strlen(string);
-    char *encoded = malloc(n+1);
+    char *encoded = (char*) malloc(n+1);
     for (int i = 0 ; i < n ; i++) {
         encoded[i] = string[n-1-i];
     }
@@ -218,29 +219,29 @@
             test_ucx_map_store_load_encdec, NULL);
     fclose(f);
 
-    char *value;
+    const char *value;
     UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed");
 
-    value = ucx_map_cstr_get(map, "test");
+    value = (const char *) ucx_map_cstr_get(map, "test");
     UCX_TEST_ASSERT(value != NULL, "value not found for key: test");
     UCX_TEST_ASSERT(strcmp(value, "test") == 0, "value error for key: test");
 
-    value = ucx_map_cstr_get(map, "key");
+    value = (const char *) ucx_map_cstr_get(map, "key");
     UCX_TEST_ASSERT(value != NULL, "value not found for key: key");
     UCX_TEST_ASSERT(strcmp(value, "value") == 0, "value error for key: key");
 
-    value = ucx_map_cstr_get(map, "other.very.long.key");
+    value = (const char *) ucx_map_cstr_get(map, "other.very.long.key");
     UCX_TEST_ASSERT(value != NULL,
             "value not found for key: other.very.long.key");
     UCX_TEST_ASSERT(strcmp(value, "value") == 0,
             "value error for key: other.very.long.key");
 
-    value = ucx_map_cstr_get(map, "testkey");
+    value = (const char *) ucx_map_cstr_get(map, "testkey");
     UCX_TEST_ASSERT(value != NULL, "value not found for key: testkey");
     UCX_TEST_ASSERT(strcmp(value, "testvalue") == 0,
             "value error for key: testkey");
 
-    value = ucx_map_cstr_get(map, "simple");
+    value = (const char *) ucx_map_cstr_get(map, "simple");
     UCX_TEST_ASSERT(value != NULL, "value not found for key: simple");
     UCX_TEST_ASSERT(strcmp(value, "not a key but an extremely long value "
             "to test if the buffer extension works as designed") == 0,
@@ -281,10 +282,10 @@
 
     UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed");
     UcxMapIterator iter = ucx_map_iterator(map);
-    char *value; size_t n;
+    const char *value; size_t n;
     UCX_MAP_FOREACH(value, iter) {
         n = strlen(value);
-        UCX_TEST_ASSERT(strncmp(pool->data[iter.index], value, n),
+        UCX_TEST_ASSERT(strncmp((const char*) pool->data[iter.index], value, n),
                 "values of map does not match pooled values");
     }
 
@@ -302,9 +303,9 @@
     
     UcxMap *clone = ucx_map_clone(map, NULL, NULL);
     
-    char *v1 = ucx_map_cstr_get(map, "key1");
-    char *v2 = ucx_map_cstr_get(map, "key2");
-    char *v3 = ucx_map_cstr_get(map, "key3");
+    const char *v1 = (const char *) ucx_map_cstr_get(map, "key1");
+    const char *v2 = (const char *) ucx_map_cstr_get(map, "key2");
+    const char *v3 = (const char *) ucx_map_cstr_get(map, "key3");
     
     UCX_TEST_BEGIN
     
@@ -312,9 +313,9 @@
     UCX_TEST_ASSERT(v2 != NULL, "failed key 2");
     UCX_TEST_ASSERT(v3 != NULL, "failed key 3");
     
-    char *c1 = ucx_map_cstr_get(clone, "key1");
-    char *c2 = ucx_map_cstr_get(clone, "key2");
-    char *c3 = ucx_map_cstr_get(clone, "key3");
+    const char *c1 = (const char *) ucx_map_cstr_get(clone, "key1");
+    const char *c2 = (const char *) ucx_map_cstr_get(clone, "key2");
+    const char *c3 = (const char *) ucx_map_cstr_get(clone, "key3");
     
     UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)");
     UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)");
@@ -350,7 +351,7 @@
     UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count");
     UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect");
     for (int i = 0 ; i < 10 ; i++) {
-        char *value = ucx_map_cstr_get(map, keys[i]);
+        const char *value = (const char *) ucx_map_cstr_get(map, keys[i]);
         UCX_TEST_ASSERT(value != NULL, "new map is missing old keys");
         UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0,
                 "new map contains incorrect values");
--- a/test/mpool_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/mpool_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -2,7 +2,7 @@
  *
  */
 
-#include <inttypes.h>
+#include <stdint.h>
 
 #include "mpool_tests.h"
 
@@ -146,11 +146,11 @@
     
     ucx_mempool_set_destr(test, test_setdestr);
     
-    int *rtest, n = 2;
+    intptr_t *rtest, n = 2;
     do {
         n *= 2;
         UCX_TEST_ASSERT(n < 65536, "test corrupt - no movement for realloc");
-        rtest = ucx_mempool_realloc(pool, test, n*sizeof(intptr_t));
+        rtest = (intptr_t*) ucx_mempool_realloc(pool, test, n*sizeof(intptr_t));
     } while (rtest == test);
     test = rtest;
     
--- a/test/string_tests.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/test/string_tests.c	Fri Oct 12 10:54:55 2012 +0200
@@ -32,7 +32,7 @@
     
     len = s1.length + s2.length + s3.length;
     
-    cat.ptr = malloc(len + 1);
+    cat.ptr = (char*) malloc(len + 1);
     cat.ptr[len] = 0;
     cat.length = len;
     
--- a/ucx/Makefile	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/Makefile	Fri Oct 12 10:54:55 2012 +0200
@@ -44,10 +44,10 @@
 all: libucx
 
 libucx: $(OBJ)
-	$(AR) $(ARFLAGS) ../build/libucx.$(LIB_EXT) $(OBJ)
+	$(AR) $(ARFLAGS) $(AOFLAGS)../build/libucx.$(LIB_EXT) $(OBJ)
 
 ../build/%.$(OBJ_EXT): %.c ../build
-	$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) $(COFLAGS)$@ $<
 
 ../build:
 	mkdir -p ../build
--- a/ucx/allocator.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/allocator.h	Fri Oct 12 10:54:55 2012 +0200
@@ -1,6 +1,8 @@
 #ifndef ALLOCATOR_H
 #define	ALLOCATOR_H
 
+#include "ucx.h"
+
 #ifdef	__cplusplus
 extern "C" {
 #endif
--- a/ucx/buffer.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/buffer.c	Fri Oct 12 10:54:55 2012 +0200
@@ -67,7 +67,7 @@
         npos = buffer->pos;
         break;
     case SEEK_END:
-        npos = strlen(buffer->space);
+        npos = strlen((const char*) buffer->space);
         break;
     }
 
--- a/ucx/buffer.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/buffer.h	Fri Oct 12 10:54:55 2012 +0200
@@ -1,6 +1,7 @@
 #ifndef BUFFER_H
 #define	BUFFER_H
 
+#include "ucx.h"
 #include <sys/types.h>
 #include <stdio.h>
 
--- a/ucx/dlist.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/dlist.c	Fri Oct 12 10:54:55 2012 +0200
@@ -117,7 +117,7 @@
 UcxDlist *ucx_dlist_sort_merge(int length,
         UcxDlist* restrict ls, UcxDlist* restrict le, UcxDlist* restrict re,
         cmp_func fnc, void* data) {
-    UcxDlist *sorted[length];
+    ucx_dynarray_new(UcxDlist*, sorted, length);
     UcxDlist *rc, *lc;
 
     lc = ls; rc = le;
@@ -151,7 +151,9 @@
     }
     sorted[length-1]->next = NULL;
 
-    return sorted[0];
+    UcxDlist *ret = sorted[0];
+    ucx_dynarray_free(sorted);
+    return ret;
 }
 
 UcxDlist *ucx_dlist_sort(UcxDlist *l, cmp_func fnc, void *data) {
--- a/ucx/list.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/list.c	Fri Oct 12 10:54:55 2012 +0200
@@ -113,7 +113,8 @@
 UcxList *ucx_list_sort_merge(int length,
         UcxList* restrict ls, UcxList* restrict le, UcxList* restrict re,
         cmp_func fnc, void* data) {
-    UcxList *sorted[length];
+
+    ucx_dynarray_new(UcxList*, sorted, length);
     UcxList *rc, *lc;
 
     lc = ls; rc = le;
@@ -145,7 +146,9 @@
     }
     sorted[length-1]->next = NULL;
 
-    return sorted[0];
+    UcxList *ret = sorted[0];
+    ucx_dynarray_free(sorted);
+    return ret;
 }
 
 UcxList *ucx_list_sort(UcxList *l, cmp_func fnc, void *data) {
--- a/ucx/logging.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/logging.h	Fri Oct 12 10:54:55 2012 +0200
@@ -1,6 +1,7 @@
 #ifndef LOGGING_H
 #define LOGGING_H
 
+#include "ucx.h"
 #include "string.h"
 #include <stdio.h>
 
--- a/ucx/map.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/map.c	Fri Oct 12 10:54:55 2012 +0200
@@ -177,7 +177,7 @@
     UcxKey key;
     key.data = data;
     key.len = len;
-    key.hash = ucx_hash(data, len);
+    key.hash = ucx_hash((const char*) data, len);
     return key;
 }
 
@@ -281,13 +281,13 @@
 
         /* read into key buffer */
         n = 16;
-        key = malloc(n);
+        key = (char*) malloc(n);
         r = 0;
         do {
             if (c == '=') break;
             if (r > n - 2) {
                 n *= 2;
-                key = realloc(key, n);
+                key = (char*) realloc(key, n);
             }
             key[r] = c;
             r++;
@@ -310,13 +310,13 @@
 
         /* read into value buffer */
         n = 64;
-        value = malloc(n);
+        value = (char*) malloc(n);
         r = 0;
         do {
             if (c == '\n') break;
             if (r > n - 2) {
                 n *= 2;
-                value = realloc(value, n);
+                value = (char*) realloc(value, n);
             }
             value[r] = c;
             r++;
@@ -328,18 +328,18 @@
             size_t decodedSize;
             void *decoded = decoder(value, decdata, &decodedSize);
             free(value);
-            value = decoded;
+            value = (char*) decoded;
             r = decodedSize;
         } else {
             r += 2;
-            value = realloc(value, r);
+            value = (char*) realloc(value, r);
         }
 
         if (allocator.pool) {
             void *pooledValue = allocator.malloc(allocator.pool, r);
             memcpy(pooledValue, value, r);
             free(value);
-            value = pooledValue;
+            value = (char*) pooledValue;
         }
 
         ucx_map_cstr_put(map, key, value);
@@ -362,7 +362,7 @@
         if (encoder) {
             size_t encodedSize;
             void *encoded = encoder(v, encdata, &encodedSize);
-            value = sstrn(encoded,encodedSize - 1);
+            value = sstrn((char*) encoded,encodedSize - 1);
         } else {
             value = sstr(v);
         }
--- a/ucx/map.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/map.h	Fri Oct 12 10:54:55 2012 +0200
@@ -15,7 +15,7 @@
 #endif
 
 #define UCX_MAP_FOREACH(elm,iter) \
-        for(;ucx_map_iter_next(&iter,(void*)&elm)==0;)
+        for(;ucx_map_iter_next(&iter,(void**)&elm)==0;)
 
 typedef struct UcxMap          UcxMap;
 typedef struct UcxKey          UcxKey;
--- a/ucx/mempool.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/mempool.c	Fri Oct 12 10:54:55 2012 +0200
@@ -27,7 +27,7 @@
     UcxMempool *pool = (UcxMempool*)malloc(sizeof(UcxMempool));
     if (pool == NULL) return NULL;
     
-    pool->data = malloc(n * sizeof(void*));
+    pool->data = (void**) malloc(n * sizeof(void*));
     if (pool->data == NULL) {
         free(pool);
         return NULL;
@@ -39,7 +39,7 @@
 }
 
 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap) {
-    void **data = realloc(pool->data, newcap*sizeof(void*));
+    void **data = (void**) realloc(pool->data, newcap*sizeof(void*));
     if (data == NULL) {
         return 1;
     } else {
--- a/ucx/mempool.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/mempool.h	Fri Oct 12 10:54:55 2012 +0200
@@ -5,6 +5,7 @@
 #ifndef MPOOL_H
 #define	MPOOL_H
 
+#include "ucx.h"
 #include <stddef.h>
 #include "allocator.h"
 
--- a/ucx/string.c	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/string.c	Fri Oct 12 10:54:55 2012 +0200
@@ -6,7 +6,7 @@
  */
 
 #include <stdlib.h>
-#include <strings.h>
+#include <string.h>
 #include <stdarg.h>
 
 #include "string.h"
@@ -110,7 +110,7 @@
 
     /* special case: exact match - no processing needed */
     if (s.length == d.length && strncmp(s.ptr, d.ptr, s.length) == 0) {
-        result = malloc(sizeof(sstr_t));
+        result = (sstr_t*) malloc(sizeof(sstr_t));
         result[0] = sstrn("", 0);
         return result;
     }
@@ -137,12 +137,12 @@
         }
         if ((*n) == nmax) break;
     }
-    result = malloc(sizeof(sstr_t) * (*n));
+    result = (sstr_t*) malloc(sizeof(sstr_t) * (*n));
 
     char *pptr = sv.ptr;
     for (int i = 0 ; i < *n ; i++) {
         size_t l = strlen(pptr);
-        char* ptr = malloc(l + 1);
+        char* ptr = (char*) malloc(l + 1);
         memcpy(ptr, pptr, l);
         ptr[l] = 0;
 
--- a/ucx/string.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/string.h	Fri Oct 12 10:54:55 2012 +0200
@@ -8,6 +8,7 @@
 #ifndef _SSTRING_H
 #define	_SSTRING_H
 
+#include "ucx.h"
 #include <stddef.h>
 
 /* use macros for literals only */
--- a/ucx/test.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/test.h	Fri Oct 12 10:54:55 2012 +0200
@@ -33,6 +33,7 @@
 #ifndef TEST_H
 #define	TEST_H
 
+#include "ucx.h"
 #include <stdio.h>
 #include <string.h>
 #include <setjmp.h>
@@ -42,6 +43,10 @@
 extern "C" {
 #endif
 
+#ifndef __FUNCTION__
+#define __FUNCTION__ __func__
+#endif
+
 typedef struct {
     unsigned int success;
     unsigned int failure;
@@ -60,7 +65,7 @@
 #define UCX_TEST_IMPLEMENT(name) void name(UcxTestSuite* _suite_,FILE *_output_)
 
 #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\
-        fwrite(__func__, 1, strlen(__func__), _output_);\
+        fwrite(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\
         fwrite("... ", 1, 4, _output_);\
         jmp_buf _env_; \
         if (!setjmp(_env_)) {
--- a/ucx/ucx.h	Thu Oct 11 16:29:30 2012 +0200
+++ b/ucx/ucx.h	Fri Oct 12 10:54:55 2012 +0200
@@ -13,12 +13,23 @@
 #ifdef	__cplusplus
 #ifndef _Bool
 #define _Bool bool
+#define restrict
 #endif
 extern "C" {
 #endif
 
 #define UCX_FOREACH(type,list,elem) \
         for (type elem = list ; elem != NULL ; elem = elem->next)
+
+#ifdef __cplusplus
+#define ucx_dynarray_new(type,identifier,length)\
+    type* identifier; identifier = new type[length]
+#define ucx_dynarray_free(identifier) delete [] identifier
+#else
+#define ucx_dynarray_new(type,identifier,length)\
+    type identifier[length]
+#define ucx_dynarray_free(identifier)
+#endif
     
 /* element1,element2,custom data -> {-1,0,1} */
 typedef int(*cmp_func)(void*,void*,void*);
--- a/windows.mk	Thu Oct 11 16:29:30 2012 +0200
+++ b/windows.mk	Fri Oct 12 10:54:55 2012 +0200
@@ -26,15 +26,18 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-CC = gcc
-LD = gcc
-AR = ar
+CC = cl
+LD = link
+AR = lib
 RM = rm
 
-CFLAGS  = -std=gnu99
+CFLAGS  = -c -TP
+COFLAGS = -Fo
 LDFLAGS = 
-ARFLAGS = -r
-RMFLAGS = -f
+LOFLAGS = -OUT:
+ARFLAGS =
+AOFLAGS = -OUT:
+RMFLAGS = -f 
 
 OBJ_EXT = obj
 LIB_EXT = lib

mercurial