commit 2aa03790a7c549ccd4b881a3e5efee3b607b38d1
parent 2394bdbeefcb6d7ee06b6cbb4bed345b2e835a35
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 8 May 2020 14:04:15 +0200
compile all files with gnu11 option to avoid clang warning about typedef redefinitions in libsheepyObject. Update for FreeBSD 12, dirname uses given buffer in parameters instead of the internal like FreeBSD 11 and before. Add src/runTests.sh to run libsheepy tests.
buildAsan.sh | 2 +-
buildMemcheck.sh | 2 +-
buildMusl.sh | 2 +-
buildMuslMemcheck.sh | 2 +-
release/libsheepy.c | 15 +++++++++------
release/libsheepyObject.h | 2 +-
src/json/libsheepyObject.c | 2 --
src/json/runTests.sh | 3 +++
src/libsheepy.c | 15 +++++++++------
src/libsheepyObject.h | 2 +-
src/runTests.sh | 5 +++++
11 files changed, 32 insertions(+), 20 deletions(-)
Diffstat:
11 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/buildAsan.sh b/buildAsan.sh
@@ -1,6 +1,6 @@
# compile libsheepy without recycling (see libsheepyObject.h for more information)
-CC="gcc -g3 -std=gnu99 -fPIC -pipe -mrdrnd -pthread -DrecycleContainers=0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address"
+CC="gcc -g3 -std=gnu11 -fPIC -pipe -mrdrnd -pthread -DrecycleContainers=0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address"
STATIC="ar -cvq"
DYNAMIC="-shared -fsanitize=address -lasan"
diff --git a/buildMemcheck.sh b/buildMemcheck.sh
@@ -1,6 +1,6 @@
# compile libsheepy without recycling (see libsheepyObject.h for more information)
-CC="gcc -g3 -std=gnu99 -fPIC -pipe -mrdrnd -pthread -DrecycleContainers=0"
+CC="gcc -g3 -std=gnu11 -fPIC -pipe -mrdrnd -pthread -DrecycleContainers=0"
STATIC="ar -cvq"
DYNAMIC="-shared"
diff --git a/buildMusl.sh b/buildMusl.sh
@@ -1,4 +1,4 @@
-CC="gcc -g3 -std=gnu99 -fPIC -pipe -mrdrnd -pthread -specs /usr/local/musl/lib/musl-gcc.specs -DMUSL_LIBC=1"
+CC="gcc -g3 -std=gnu11 -fPIC -pipe -mrdrnd -pthread -specs /usr/local/musl/lib/musl-gcc.specs -DMUSL_LIBC=1"
STATIC="ar -cvq"
DYNAMIC="-shared"
diff --git a/buildMuslMemcheck.sh b/buildMuslMemcheck.sh
@@ -1,6 +1,6 @@
# compile libsheepy without recycling (see libsheepyObject.h for more information)
-CC="gcc -g3 -std=gnu99 -fPIC -pipe -mrdrnd -pthread -specs /usr/local/musl/lib/musl-gcc.specs -DMUSL_LIBC=1 -DrecycleContainers=0"
+CC="gcc -g3 -std=gnu11 -fPIC -pipe -mrdrnd -pthread -specs /usr/local/musl/lib/musl-gcc.specs -DMUSL_LIBC=1 -DrecycleContainers=0"
STATIC="ar -cvq"
DYNAMIC="-shared"
diff --git a/release/libsheepy.c b/release/libsheepy.c
@@ -47,17 +47,13 @@ typedef enum { LOCALE_NORMAL, LOCALE_TURKIC, LOCALE_LITHUANIAN } localeType;
#include <ctype.h>
#include <sys/time.h>
#include <stdio.h>
-#if (!(__OpenBSD__ || __HAIKU__))
#include <ucontext.h>
-#endif
#include <libgen.h>
#include <inttypes.h>
#include <dirent.h>
#include <stdarg.h>
#include <errno.h>
-#if (!(__OpenBSD__ || __HAIKU__))
#include <wordexp.h>
-#endif
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
@@ -74,6 +70,8 @@ typedef enum { LOCALE_NORMAL, LOCALE_TURKIC, LOCALE_LITHUANIAN } localeType;
#endif
#if (!(__TERMUX__ || __OpenBSD__ || MUSL_LIBC || __HAIKU__))
#endif
+#if ((__FreeBSD__))
+#endif
#if (!(__arm__ || __APPLE__ || __i386__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __HAIKU__))
internal void segfault_sigaction(int signal, siginfo_t *si, void *arg);
internal void segfault_sigaction(int signal UNUSED, siginfo_t *si UNUSED, void *arg UNUSED);
@@ -769,6 +767,11 @@ int nanoSleepF(uint64_t time);
// setlocale
#include "locale.h"
+#if ((__FreeBSD__))
+// WIFEXITED WEXITSTATUS
+#include <sys/wait.h>
+#endif
+
/** \file
@@ -1382,7 +1385,7 @@ int print_b_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtyp
}
#endif
-// #if __APPLE__ || __FreeBSD_ || __TERMUX___ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
+// #if __APPLE__ || __FreeBSD__ || __TERMUX___ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
static const char sheepyBuild[] = "/.sheepy/build";
@@ -2044,7 +2047,7 @@ char *shDirname(const char *path) {
return(strdup("./"));
}
- #if (__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__)
+ #if (__APPLE__ || __OpenBSD__ || __DragonFly__)
// pointer to internal buffer in dirname
char *tmp = dirname((char*)path);
dir = strdup(tmp);
diff --git a/release/libsheepyObject.h b/release/libsheepyObject.h
@@ -89,7 +89,7 @@ static const bool checkObjectTypes = true;
//
// The check is done by comparing the stack pointer to the object address, when
// stack pointer < &object, the object is on stack
-#if !__sun__
+#if !(__sun__ || __FreeBSD__)
#if __amd64__
#define NFreeStackCheck 1
#endif
diff --git a/src/json/libsheepyObject.c b/src/json/libsheepyObject.c
@@ -42,9 +42,7 @@
#include <stdio.h>
#include <dirent.h>
#include <stdarg.h>
-#if (!(__OpenBSD__ || __HAIKU__))
#include <wordexp.h>
-#endif
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
diff --git a/src/json/runTests.sh b/src/json/runTests.sh
@@ -0,0 +1,3 @@
+gcc -mrdrnd -g3 -std=gnu99 -o libsheepyObjectTest libsheepyObjectTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+./libsheepyObjectTest
+
diff --git a/src/libsheepy.c b/src/libsheepy.c
@@ -47,17 +47,13 @@ typedef enum { LOCALE_NORMAL, LOCALE_TURKIC, LOCALE_LITHUANIAN } localeType;
#include <ctype.h>
#include <sys/time.h>
#include <stdio.h>
-#if (!(__OpenBSD__ || __HAIKU__))
#include <ucontext.h>
-#endif
#include <libgen.h>
#include <inttypes.h>
#include <dirent.h>
#include <stdarg.h>
#include <errno.h>
-#if (!(__OpenBSD__ || __HAIKU__))
#include <wordexp.h>
-#endif
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
@@ -74,6 +70,8 @@ typedef enum { LOCALE_NORMAL, LOCALE_TURKIC, LOCALE_LITHUANIAN } localeType;
#endif
#if (!(__TERMUX__ || __OpenBSD__ || MUSL_LIBC || __HAIKU__))
#endif
+#if ((__FreeBSD__))
+#endif
void *myMalloc(size_t l);
void *myRealloc(void *buffer, size_t l);
#if (!(__arm__ || __APPLE__ || __i386__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __HAIKU__))
@@ -782,6 +780,11 @@ int argc; char **argv;
// setlocale
#include "locale.h"
+#if ((__FreeBSD__))
+// WIFEXITED WEXITSTATUS
+#include <sys/wait.h>
+#endif
+
/** \file
@@ -1438,7 +1441,7 @@ int print_b_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtyp
}
#endif
-// #if __APPLE__ || __FreeBSD_ || __TERMUX___ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
+// #if __APPLE__ || __FreeBSD__ || __TERMUX___ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
static const char sheepyBuild[] = "/.sheepy/build";
@@ -2100,7 +2103,7 @@ char *shDirname(const char *path) {
return(strdup("./"));
}
- #if (__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__)
+ #if (__APPLE__ || __OpenBSD__ || __DragonFly__)
// pointer to internal buffer in dirname
char *tmp = dirname((char*)path);
dir = strdup(tmp);
diff --git a/src/libsheepyObject.h b/src/libsheepyObject.h
@@ -89,7 +89,7 @@ static const bool checkObjectTypes = true;
//
// The check is done by comparing the stack pointer to the object address, when
// stack pointer < &object, the object is on stack
-#if !__sun__
+#if !(__sun__ || __FreeBSD__)
#if __amd64__
#define NFreeStackCheck 1
#endif
diff --git a/src/runTests.sh b/src/runTests.sh
@@ -0,0 +1,5 @@
+gcc -mrdrnd -g3 -std=gnu99 -c -DunitTest -fprofile-arcs -ftest-coverage -Wall -Wextra libsheepy.c
+gcc -g3 -std=gnu99 -o libsheepyUnitTests libsheepy.o libsheepyTest.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit -rdynamic
+
+chmod 222 writeOnlyText.null
+./libsheepyUnitTests