summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile79
-rw-r--r--hugin.c34
-rw-r--r--main_complete.c4
3 files changed, 71 insertions, 46 deletions
diff --git a/Makefile b/Makefile
index 3a23387..bb21cfd 100644
--- a/Makefile
+++ b/Makefile
@@ -3,58 +3,89 @@ include Makefile.files
CFLAGS=-Werror -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -O2
CXXFLAGS=$(CFLAGS)
-all: complete obj simple syslog filter mutex minimal disabled
+all: complete obj simple syslog filter mutex minimal simple-disabled \
+ complete-disabled
complete:
- gcc ${CFLAGS} ${HUGIN_SOURCES} main_complete.c -o hugin-complete -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER -DWITH_HUG_MUTEX
- g++ ${CXXFLAGS} ${HUGIN_SOURCES} main_complete.c -o hugin-complete -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER -DWITH_HUG_MUTEX
+ gcc ${CFLAGS} ${HUGIN_SOURCES} main_complete.c -o hugin-$@ \
+ -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER -DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ ${CXXFLAGS} ${HUGIN_SOURCES} main_complete.c -o hugin-$@ \
+ -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER -DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
obj:
# Compile hugin as c prog and link with c++ program (use hugin.hpp)
g++ ${CXXFLAGS} main_simple.cc -c
gcc ${CFLAGS} hugin.c -c
- g++ main_simple.o hugin.o -o hugin-obj
+ g++ main_simple.o hugin.o -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
# Compile hugin as c++ prog and link with c++ program
g++ ${CXXFLAGS} main_simple.c -c
g++ ${CXXFLAGS} hugin.c -c
- g++ main_simple.o hugin.o -o hugin-obj
+ g++ main_simple.o hugin.o -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
simple:
- gcc ${CFLAGS} hugin.c main_simple.c -o hugin-simple
- g++ ${CXXFLAGS} hugin.c main_simple.c -o hugin-simple
+ gcc ${CFLAGS} hugin.c main_simple.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ ${CXXFLAGS} hugin.c main_simple.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
minimal:
- gcc ${CFLAGS} hugin.c main_minimal.c -o hugin-minimal
- g++ ${CXXFLAGS} hugin.c main_minimal.c -o hugin-minimal
+ gcc ${CFLAGS} hugin.c main_minimal.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ ${CXXFLAGS} hugin.c main_minimal.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
syslog:
gcc ${CFLAGS} hugin.c hugin_syslog.c main_syslog.c \
- -o hugin-syslog -DWITH_HUG_SYSLOG
+ -o hugin-$@ -DWITH_HUG_SYSLOG
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
g++ ${CXXFLAGS} hugin.c hugin_syslog.c main_syslog.c \
- -o hugin-syslog -DWITH_HUG_SYSLOG
+ -o hugin-$@ -DWITH_HUG_SYSLOG
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
filter:
- gcc ${CFLAGS} hugin.c hugin_filter.c main_filter.c -o hugin-filter \
+ gcc ${CFLAGS} hugin.c hugin_filter.c main_filter.c -o hugin-$@ \
-DWITH_HUG_FILTER
- g++ ${CXXFLAGS} hugin.c hugin_filter.c main_filter.c -o hugin-filter \
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ ${CXXFLAGS} hugin.c hugin_filter.c main_filter.c -o hugin-$@ \
-DWITH_HUG_FILTER
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
mutex:
- gcc ${CFLAGS} hugin.c main_mutex.c -o hugin-mutex -DWITH_HUG_MUTEX
- g++ ${CXXFLAGS} hugin.c main_mutex.c -o hugin-mutex -DWITH_HUG_MUTEX
-
-disabled:
- gcc -DDISABLE_HUGIN ${CFLAGS} hugin.c main_simple.c \
- -o hugin-simple-disabled
- g++ -DDISABLE_HUGIN ${CXXFLAGS} hugin.c main_simple.c \
- -o hugin-simple-disabled
+ gcc ${CFLAGS} hugin.c main_mutex.c -o hugin-$@ -DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ ${CXXFLAGS} hugin.c main_mutex.c -o hugin-$@ -DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+simple-disabled:
+ gcc -DDISABLE_HUGIN ${CFLAGS} hugin.c main_simple.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+ g++ -DDISABLE_HUGIN ${CXXFLAGS} hugin.c main_simple.c -o hugin-$@
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
+
+complete-disabled:
gcc -DDISABLE_HUGIN ${CFLAGS} ${HUGIN_SOURCES} main_complete.c \
- -o hugin-complete-disabled -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER \
+ -o hugin-$@ -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER \
-DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
+
g++ -DDISABLE_HUGIN ${CXXFLAGS} ${HUGIN_SOURCES} main_complete.c \
- -o hugin-complete-disabled -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER \
+ -o hugin-$@ -DWITH_HUG_SYSLOG -DWITH_HUG_FILTER \
-DWITH_HUG_MUTEX
+ (./hugin-$@ || (echo "Failed running $@"; false) ) 2>&1
clean:
- rm -f hugin_{complete,complete-cpp,simple,syslog,filter,mutex,minimal}
+ rm -f hugin-{complete,complete-cpp,simple,syslog,filter,mutex}
+ rm -f hugin-{minimal,simple-disabled,complete-disabled,obj}
diff --git a/hugin.c b/hugin.c
index bfb43e8..e755841 100644
--- a/hugin.c
+++ b/hugin.c
@@ -46,7 +46,7 @@
typedef HANDLE mutex_t;
// see http://stackoverflow.com/questions/558223/va-copy-porting-to-visual-c
-#define va_copy(dest, src) (dest = src)
+//#define va_copy(dest, src) (dest = src)
# else
# include <pthread.h>
@@ -407,22 +407,14 @@ int __debug(const char *func, const int line,
//
// Generate message
//
-
- // Get number of bytes needed for the buffer:
va_list va;
va_start(va, fmt);
-
- // Use a copy of va_list for 64bit fix:
- // see http://www.bailopan.net/blog/?p=30
- //
- // Not available in windows. So hugin may break in 64bit windows
-
- va_list vacpy;
- va_copy(vacpy, va);
-
- hdr_bufsz = scprintf(hdr_fmt, HDR_ARGS);
- msg_bufsz = vscprintf(fmt, vacpy);
- if(hdr_bufsz < 0 || msg_bufsz < 0) return 1; // Bad format?
+ {
+ hdr_bufsz = scprintf(hdr_fmt, HDR_ARGS);
+ msg_bufsz = vscprintf(fmt, va);
+ if(hdr_bufsz < 0 || msg_bufsz < 0) return 1; // Bad format?
+ // va_end(va);
+ }
buf = (char*)malloc(hdr_bufsz + msg_bufsz + 1);
if(!buf) return 1; // Out of memory
@@ -430,11 +422,13 @@ int __debug(const char *func, const int line,
sz = sprintf(buf, hdr_fmt, HDR_ARGS);
if(sz < 0) return 1; // Unknown error
- va_copy(vacpy, va);
- sz = vsprintf(buf + sz, fmt, vacpy);
- if(sz < 0) return 1; // Unknown error
-
- va_end(va);
+ {
+ //va_list va;
+ //va_start(va, fmt);
+ sz = vsprintf(buf + sz, fmt, va);
+ if(sz < 0) return 1; // Unknown error
+ va_end(va);
+ }
//
// Send message to output
diff --git a/main_complete.c b/main_complete.c
index a649078..a79dbc5 100644
--- a/main_complete.c
+++ b/main_complete.c
@@ -63,8 +63,8 @@ int main(int argc, char *argv[])
INFO(example, "We are up and running");
DEBUG(example, "Or are we %d?", 42);
-
- DEBUG(foo, "Or are we %d?", 42);
+ int a = 0;
+ DEBUG(foo, "Or are we %d?", 1/a);
hug_close();