Browse Source

Merge branch 'master' of github.com:troydhanson/uthash

Troy D. Hanson 10 years ago
parent
commit
a73bfcc8f5
10 changed files with 37 additions and 30 deletions
  1. 3 1
      doc/Makefile
  2. 4 4
      libut/Makefile
  3. 4 4
      libut/tests/Makefile
  4. 6 3
      src/uthash.h
  5. 10 8
      tests/Makefile
  6. 1 1
      tests/all_funcs
  7. 1 1
      tests/do_tests.mingw
  8. 5 5
      tests/lru_cache/Makefile
  9. 1 1
      tests/mexpand
  10. 2 2
      tests/threads/Makefile

+ 3 - 1
doc/Makefile

@@ -13,4 +13,6 @@ stage:
 	rm -if ${TMP}/*
 	rm -if ${TMP}/*
 	cp *.html *.css *.png ${TMP}
 	cp *.html *.css *.png ${TMP}
 
 
-
+.PHONY: clean
+clean:
+	$(RM) $(HTML)

+ 4 - 4
libut/Makefile

@@ -1,7 +1,7 @@
 OBJS=libut.a
 OBJS=libut.a
 all: $(OBJS) 
 all: $(OBJS) 
 INCDIR=./include
 INCDIR=./include
-CFLAGS=-I$(INCDIR)
+CFLAGS+=-I$(INCDIR)
 CFLAGS+=-Wall -Wextra
 CFLAGS+=-Wall -Wextra
 CFLAGS+=-g
 CFLAGS+=-g
 
 
@@ -9,13 +9,13 @@ libut.a: libut.o utvector.o utmm.o ringbuf.o
 	ar r $@ $^
 	ar r $@ $^
 
 
 libut.o: src/libut.c $(INCDIR)/libut.h
 libut.o: src/libut.c $(INCDIR)/libut.h
-	$(CC) $(CFLAGS) -c $<
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
 
 
 utvector.o: src/utvector.c $(INCDIR)/utvector.h
 utvector.o: src/utvector.c $(INCDIR)/utvector.h
-	$(CC) $(CFLAGS) -c $<
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
 
 
 utmm.o: src/utmm.c $(INCDIR)/utmm.h
 utmm.o: src/utmm.c $(INCDIR)/utmm.h
-	$(CC) $(CFLAGS) -c $<
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
 
 
 ringbuf.o: src/ringbuf.c $(INCDIR)/ringbuf.h
 ringbuf.o: src/ringbuf.c $(INCDIR)/ringbuf.h
 	$(CC) $(CFLAGS) -c $<
 	$(CC) $(CFLAGS) -c $<

+ 4 - 4
libut/tests/Makefile

@@ -2,10 +2,10 @@ PROGS=test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12
       test13 test14 test15 test16
       test13 test14 test15 test16
 OBJS=$(patsubst %,%.o,$(PROGS))
 OBJS=$(patsubst %,%.o,$(PROGS))
 
 
-CFLAGS = -I../include
+CFLAGS += -I../include
 CFLAGS += -g
 CFLAGS += -g
 CFLAGS += -Wall -Wextra
 CFLAGS += -Wall -Wextra
-LDFLAGS=-L.. -lut 
+LDFLAGS += -L.. -lut
 
 
 TEST_TARGET=run_tests
 TEST_TARGET=run_tests
 TESTS=./do_tests
 TESTS=./do_tests
@@ -15,10 +15,10 @@ all: $(OBJS) $(PROGS) $(TEST_TARGET)
 # static pattern rule: multiple targets 
 # static pattern rule: multiple targets 
 
 
 $(OBJS): %.o: %.c
 $(OBJS): %.o: %.c
-	$(CC) -c $(CFLAGS) $< 
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
 
 
 $(PROGS): %: %.o
 $(PROGS): %: %.o
-	$(CC) -o $@ $(CFLAGS) $< $(LDFLAGS)
+	$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $< $(LDFLAGS)
 
 
 
 
 run_tests: $(PROGS)
 run_tests: $(PROGS)

+ 6 - 3
src/uthash.h

@@ -60,17 +60,20 @@ do {
 #endif
 #endif
 
 
 /* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
 /* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
-#if defined (_WIN32)
+#if defined(_WIN32)
 #if defined(_MSC_VER) && _MSC_VER >= 1600
 #if defined(_MSC_VER) && _MSC_VER >= 1600
 #include <stdint.h>
 #include <stdint.h>
-#elif defined(__WATCOMC__)
+#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__)
 #include <stdint.h>
 #include <stdint.h>
 #else
 #else
 typedef unsigned int uint32_t;
 typedef unsigned int uint32_t;
 typedef unsigned char uint8_t;
 typedef unsigned char uint8_t;
 #endif
 #endif
-#else
+#elif defined(__GNUC__) && !defined(__VXWORKS__)
 #include <stdint.h>
 #include <stdint.h>
+#else
+typedef unsigned int uint32_t;
+typedef unsigned char uint8_t;
 #endif
 #endif
 
 
 #define UTHASH_VERSION 1.9.9
 #define UTHASH_VERSION 1.9.9

+ 10 - 8
tests/Makefile

@@ -14,7 +14,7 @@ PROGS = test1 test2 test3 test4 test5 test6 test7 test8 test9   \
         test66 test67 test68 test69 test70 test71 test72 test73 \
         test66 test67 test68 test69 test70 test71 test72 test73 \
         test74 test75 test76 test77 test78 test79 test80 test81 \
         test74 test75 test76 test77 test78 test79 test80 test81 \
         test82 test83 test84 test85
         test82 test83 test84 test85
-CFLAGS = -I$(HASHDIR) 
+CFLAGS += -I$(HASHDIR)
 #CFLAGS += -DHASH_BLOOM=16
 #CFLAGS += -DHASH_BLOOM=16
 #CFLAGS += -O2
 #CFLAGS += -O2
 CFLAGS += -g
 CFLAGS += -g
@@ -81,28 +81,30 @@ cplusplus:
 	CC=$(CXX) $(MAKE) all 
 	CC=$(CXX) $(MAKE) all 
 
 
 example: example.c $(HASHDIR)/uthash.h
 example: example.c $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) -o $@ $(@).c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(@).c
 
 
 $(PROGS) $(UTILS) : $(HASHDIR)/uthash.h
 $(PROGS) $(UTILS) : $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) -o $@ $(@).c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(@).c
 
 
 hashscan : $(HASHDIR)/uthash.h
 hashscan : $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) $(MUR_CFLAGS) -o $@ $(@).c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(MUR_CFLAGS) $(LDFLAGS) -o $@ $(@).c
 
 
 sleep_test : $(HASHDIR)/uthash.h 
 sleep_test : $(HASHDIR)/uthash.h 
-	$(CC) $(CFLAGS) -DHASH_BLOOM=16 -o $@ $(@).c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) -DHASH_BLOOM=16 $(LDFLAGS) -o $@ $(@).c
 
 
 $(FUNCS) : $(HASHDIR)/uthash.h
 $(FUNCS) : $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) -DHASH_FUNCTION=HASH_$@ -o keystat.$@ keystat.c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) -DHASH_FUNCTION=HASH_$@ \
+		$(LDFLAGS) -o keystat.$@ keystat.c
 
 
 $(SPECIAL_FUNCS) : $(HASHDIR)/uthash.h
 $(SPECIAL_FUNCS) : $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) $(MUR_CFLAGS) -DHASH_FUNCTION=HASH_$@ -o keystat.$@ keystat.c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(MUR_CFLAGS) -DHASH_FUNCTION=HASH_$@ \
+		$(LDFLAGS) -o keystat.$@ keystat.c
 
 
 run_tests: $(PROGS)
 run_tests: $(PROGS)
 	perl $(TESTS)
 	perl $(TESTS)
 
 
 run_tests_mingw: $(PROGS)
 run_tests_mingw: $(PROGS)
-	/bin/sh do_tests.mingw
+	/bin/bash do_tests.mingw
 
 
 astyle:
 astyle:
 	astyle -n --style=kr --indent-switches --add-brackets *.c
 	astyle -n --style=kr --indent-switches --add-brackets *.c

+ 1 - 1
tests/all_funcs

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 
 function proceed {
 function proceed {
   read -p "proceed ? [n] " response
   read -p "proceed ? [n] " response

+ 1 - 1
tests/do_tests.mingw

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 
 echo "MinGW test script starting"
 echo "MinGW test script starting"
 
 

+ 5 - 5
tests/lru_cache/Makefile

@@ -1,21 +1,21 @@
 CC=gcc
 CC=gcc
 
 
-CFLAGS=-W -Werror -Wall -Wextra -std=c99 \
+CFLAGS+=-W -Werror -Wall -Wextra -std=c99 \
 	-D_FORTIFY_SOURCE=2 -fstack-protector -g \
 	-D_FORTIFY_SOURCE=2 -fstack-protector -g \
 	-Wformat=2 -pedantic -pedantic-errors \
 	-Wformat=2 -pedantic -pedantic-errors \
 	-D_GNU_SOURCE=1 -D_BSD_SOURCE=1 \
 	-D_GNU_SOURCE=1 -D_BSD_SOURCE=1 \
 	-I../../src
 	-I../../src
 
 
-LDFLAGS=-pthread
+LDFLAGS+=-pthread
 
 
 cache: main.o cache.o
 cache: main.o cache.o
-	$(CC) $(CFLAGS) $(LDFLAGS) main.o cache.o -o cache
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) main.o cache.o -o cache
 
 
 main.o: main.c
 main.o: main.c
-	$(CC) $(CFLAGS) -c main.c -o main.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c main.c -o main.o
 
 
 cache.o: cache.c
 cache.o: cache.c
-	$(CC) $(CFLAGS) -c cache.c -o cache.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c cache.c -o cache.o
 
 
 clean:
 clean:
 	rm -f cache *.o
 	rm -f cache *.o

+ 1 - 1
tests/mexpand

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 
 # utility to macro-expand a test program
 # utility to macro-expand a test program
 CC=gcc
 CC=gcc

+ 2 - 2
tests/threads/Makefile

@@ -4,7 +4,7 @@ PROGS = test1 test2
 # Thread support requires compiler-specific options
 # Thread support requires compiler-specific options
 # ----------------------------------------------------------------------------
 # ----------------------------------------------------------------------------
 # GNU 
 # GNU 
-CFLAGS = -I$(HASHDIR) -g -pthread
+CFLAGS += -I$(HASHDIR) -g -pthread
 # Solaris (Studio 11) 
 # Solaris (Studio 11) 
 #CFLAGS = -I$(HASHDIR) -g -mt
 #CFLAGS = -I$(HASHDIR) -g -mt
 # ----------------------------------------------------------------------------
 # ----------------------------------------------------------------------------
@@ -16,7 +16,7 @@ endif
 all: $(PROGS) run_tests
 all: $(PROGS) run_tests
 
 
 $(PROGS) : $(HASHDIR)/uthash.h
 $(PROGS) : $(HASHDIR)/uthash.h
-	$(CC) $(CFLAGS) -o $@ $(@).c 
+	$(CC) $(CPPLFAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(@).c
 
 
 debug:
 debug:
 	$(MAKE) all HASH_DEBUG=1
 	$(MAKE) all HASH_DEBUG=1