diff --git a/Makefile b/Makefile
index 42efe6f..bcc06f1 100644
--- a/Makefile
+++ b/Makefile
@@ -572,6 +572,22 @@ lib_links_bsd_debug:
ln -sf ../../../markdown/.libs/libkc3_markdown_debug.so.0.0 lib/kc3/0.1/markdown.so
ln -sf ../../../socket/.libs/libkc3_socket_debug.so.0.0 lib/kc3/0.1/socket.so
+lib_links_darwin:
+ ln -sf ../../../ekc3/.libs/libekc3.0.dylib lib/kc3/0.1/ekc3.so
+ ln -sf ../../../event/.libs/libkc3_event.0.dylib lib/kc3/0.1/event.so
+ ln -sf ../../../http/.libs/libkc3_http.0.dylib lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json.0.dylib lib/kc3/0.1/json.so
+ ln -sf ../../../markdown/.libs/libkc3_markdown.0.dylib lib/kc3/0.1/markdown.so
+ ln -sf ../../../socket/.libs/libkc3_socket.0.dylib lib/kc3/0.1/socket.so
+
+lib_links_darwin_debug:
+ ln -sf ../../../ekc3/.libs/libekc3_debug.0.dylib lib/kc3/0.1/ekc3.so
+ ln -sf ../../../event/.libs/libkc3_event_debug.0.dylib lib/kc3/0.1/event.so
+ ln -sf ../../../http/.libs/libkc3_http_debug.0.dylib lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json_debug.0.dylib lib/kc3/0.1/json.so
+ ln -sf ../../../markdown/.libs/libkc3_markdown_debug.0.dylib lib/kc3/0.1/markdown.so
+ ln -sf ../../../socket/.libs/libkc3_socket_debug.0.dylib lib/kc3/0.1/socket.so
+
lib_links_linux:
ln -sf ../../../ekc3/.libs/libekc3.so lib/kc3/0.1/ekc3.so
ln -sf ../../../event/.libs/libkc3_event.so lib/kc3/0.1/event.so
diff --git a/config.subr b/config.subr
index a84e029..b94a95f 100644
--- a/config.subr
+++ b/config.subr
@@ -557,43 +557,43 @@ update_build_lib() {
}
update_build_objc() {
- OBJCC_MAIN=.build_objcc_main.tmp
- OBJCC_ASAN=.build_objcc_asan.tmp
- OBJCC_COV=.build_objcc_cov.tmp
- OBJCC_DEBUG=.build_objcc_debug.tmp
+ OBJC_MAIN=.build_objc_main.tmp
+ OBJC_ASAN=.build_objc_asan.tmp
+ OBJC_COV=.build_objc_cov.tmp
+ OBJC_DEBUG=.build_objc_debug.tmp
mkdir -p .build
- echo "#!/bin/sh" >> ${OBJCC_ASAN}
- echo "# gen by configure" >> ${OBJCC_ASAN}
- echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_ASAN}
- echo "CPPFLAGS=\"${CPPFLAGS_ASAN}\"" >> ${OBJCC_ASAN}
- echo "CFLAGS=\"${CFLAGS_ASAN}\"" >> ${OBJCC_ASAN}
- echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_ASAN}
- update_and_chmod 755 ${OBJCC_ASAN} .build_objcc_asan
-
- echo "#!/bin/sh" >> ${OBJCC_COV}
- echo "# gen by configure" >> ${OBJCC_COV}
- echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_COV}
- echo "CPPFLAGS=\"${CPPFLAGS_COV}\"" >> ${OBJCC_COV}
- echo "CFLAGS=\"${CFLAGS_COV}\"" >> ${OBJCC_COV}
- echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_COV}
- update_and_chmod 755 ${OBJCC_COV} .build_objcc_cov
-
- echo "#!/bin/sh" >> ${OBJCC_DEBUG}
- echo "# gen by configure" >> ${OBJCC_DEBUG}
- echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_DEBUG}
- echo "CPPFLAGS=\"${CPPFLAGS_DEBUG}\"" >> ${OBJCC_DEBUG}
- echo "CFLAGS=\"${CFLAGS_DEBUG}\"" >> ${OBJCC_DEBUG}
- echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_DEBUG}
- update_and_chmod 755 ${OBJCC_DEBUG} .build_objcc_debug
-
- echo "#!/bin/sh" >> ${OBJCC_MAIN}
- echo "# gen by configure" >> ${OBJCC_MAIN}
- echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_MAIN}
- echo "CPPFLAGS=\"${CPPFLAGS}\"" >> ${OBJCC_MAIN}
- echo "CFLAGS=\"${CFLAGS}\"" >> ${OBJCC_MAIN}
- echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_MAIN}
- update_and_chmod 755 ${OBJCC_MAIN} .build_objcc_main
+ echo "#!/bin/sh" >> ${OBJC_ASAN}
+ echo "# gen by configure" >> ${OBJC_ASAN}
+ echo "OBJC=\"${OBJC}\"" >> ${OBJC_ASAN}
+ echo "CPPFLAGS=\"${CPPFLAGS_ASAN}\"" >> ${OBJC_ASAN}
+ echo "CFLAGS=\"${CFLAGS_ASAN}\"" >> ${OBJC_ASAN}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJC_ASAN}
+ update_and_chmod 755 ${OBJC_ASAN} .build_objc_asan
+
+ echo "#!/bin/sh" >> ${OBJC_COV}
+ echo "# gen by configure" >> ${OBJC_COV}
+ echo "OBJC=\"${OBJC}\"" >> ${OBJC_COV}
+ echo "CPPFLAGS=\"${CPPFLAGS_COV}\"" >> ${OBJC_COV}
+ echo "CFLAGS=\"${CFLAGS_COV}\"" >> ${OBJC_COV}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJC_COV}
+ update_and_chmod 755 ${OBJC_COV} .build_objc_cov
+
+ echo "#!/bin/sh" >> ${OBJC_DEBUG}
+ echo "# gen by configure" >> ${OBJC_DEBUG}
+ echo "OBJC=\"${OBJC}\"" >> ${OBJC_DEBUG}
+ echo "CPPFLAGS=\"${CPPFLAGS_DEBUG}\"" >> ${OBJC_DEBUG}
+ echo "CFLAGS=\"${CFLAGS_DEBUG}\"" >> ${OBJC_DEBUG}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJC_DEBUG}
+ update_and_chmod 755 ${OBJC_DEBUG} .build_objc_debug
+
+ echo "#!/bin/sh" >> ${OBJC_MAIN}
+ echo "# gen by configure" >> ${OBJC_MAIN}
+ echo "OBJC=\"${OBJC}\"" >> ${OBJC_MAIN}
+ echo "CPPFLAGS=\"${CPPFLAGS}\"" >> ${OBJC_MAIN}
+ echo "CFLAGS=\"${CFLAGS}\"" >> ${OBJC_MAIN}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJC_MAIN}
+ update_and_chmod 755 ${OBJC_MAIN} .build_objc_main
}
update_build_prog() {
@@ -822,14 +822,14 @@ echo "LIBTOOL = $LIBTOOL" >> ${CONFIG_MK}
#echo "SWIFTC = $SWIFTC" >> ${CONFIG_MK}
#echo "HAVE_SWIFT = $HAVE_SWIFT" >> ${CONFIG_MK}
-if [ "x$OBJCC" = "x" ]; then
+if [ "x$OBJC" = "x" ]; then
if test -x "$(which clang 2>/dev/null)"; then
- OBJCC="$(which clang)"
+ OBJC="$(which clang)"
else
- OBJCC=clang
+ OBJC=clang
fi
fi
-echo "OBJCC = $OBJCC" >> ${CONFIG_MK}
+echo "OBJC = $OBJC" >> ${CONFIG_MK}
PREFIX="${PREFIX:-/usr/local}"
echo "PREFIX = $PREFIX" >> ${CONFIG_MK}
diff --git a/env b/env
index d494448..c160898 100644
--- a/env
+++ b/env
@@ -1,2 +1,5 @@
export LD_LIBRARY_PATH="$PWD/libkc3/.libs:$PWD/ekc3/.libs:$PWD/http/.libs:$PWD/markdown/.libs:$PWD/lib/kc3/0.1:$LD_LIBRARY_PATH"
+export DYLD_LIBRARY_PATH="$PWD/libkc3/.libs:$PWD/ekc3/.libs:$PWD/http/.libs:$PWD/markdown/.libs:$PWD/lib/kc3/0.1:$DYLD_LIBRARY_PATH"
+export KC3_HTTPD_HOST=0.0.0.0
+export KC3_HTTPD_PORT=58000
#export MALLOC_OPTIONS=CDFGJU
diff --git a/libkc3/facts.c b/libkc3/facts.c
index a067221..38959e2 100644
--- a/libkc3/facts.c
+++ b/libkc3/facts.c
@@ -442,7 +442,14 @@ s_facts * facts_lock_clean (s_facts *facts)
s_facts * facts_lock_init (s_facts *facts)
{
+ uw i;
assert(facts);
+ if (true) {
+ i = (uw) &facts->rwlock;
+ err_write_1("facts_lock_init: ");
+ err_inspect_uw_hexadecimal(&i);
+ err_write_1("\n");
+ }
if (pthread_rwlock_init(&facts->rwlock, NULL)) {
err_puts("facts_lock_init: pthread_rwlock_init");
assert(! "facts_lock_init: pthread_rwlock_init");
@@ -455,15 +462,43 @@ s_facts * facts_lock_init (s_facts *facts)
s_facts * facts_lock_r (s_facts *facts)
{
+ sw e;
+ uw i;
pthread_t thread;
assert(facts);
thread = pthread_self();
- if (facts->rwlock_thread != thread &&
- pthread_rwlock_rdlock(&facts->rwlock)) {
- err_puts("facts_lock_r: pthread_rwlock_rdlock");
- assert(! "facts_lock_r: pthread_rwlock_rdlock");
- abort();
- return NULL;
+ if (facts->rwlock_thread != thread) {
+ if (true) {
+ i = (uw) &facts->rwlock;
+ err_write_1("facts_lock_r: ");
+ err_inspect_uw_hexadecimal(&i);
+ err_write_1("\n");
+ }
+ if ((e = pthread_rwlock_rdlock(&facts->rwlock))) {
+ err_write_1("facts_lock_r: pthread_rwlock_rdlock: ");
+ switch (e) {
+ case EAGAIN:
+ err_puts("the maximum number of read locks on this lock has"
+ " been exceeded");
+ break;
+ case EDEADLK:
+ err_puts("the current thread already owns this lock for"
+ " writing");
+ break;
+ case EINVAL:
+ err_puts("invalid lock");
+ break;
+ case ENOMEM:
+ err_puts("not enough memory to initialize the lock");
+ break;
+ default:
+ err_puts("unknown error");
+ break;
+ }
+ assert(! "facts_lock_r: pthread_rwlock_rdlock");
+ abort();
+ return NULL;
+ }
}
return facts;
}
diff --git a/libkc3/tag.c b/libkc3/tag.c
index b9ff02d..00dea61 100644
--- a/libkc3/tag.c
+++ b/libkc3/tag.c
@@ -11,6 +11,7 @@
* THIS SOFTWARE.
*/
#include <string.h>
+#include <strings.h>
#include "alloc.h"
#include "array.h"
#include "assert.h"
@@ -48,6 +49,10 @@
#include "unquote.h"
#include "var.h"
+#ifdef __APPLE__
+# define explicit_bzero(p, size) bzero(p, size)
+#endif
+
s_tag g_tag_first;
s_tag g_tag_last;
diff --git a/markdown/md4c b/markdown/md4c
index 481fbfb..c5a6da5 160000
--- a/markdown/md4c
+++ b/markdown/md4c
@@ -1 +1 @@
-Subproject commit 481fbfbdf72daab2912380d62bb5f2187d438408
+Subproject commit c5a6da53d3a1db532246a4d97f68913a2f22d39e
diff --git a/window/sdl2/demo/macos/.build_objc_asan b/window/sdl2/demo/macos/.build_objc_asan
new file mode 100755
index 0000000..ed98d2b
--- /dev/null
+++ b/window/sdl2/demo/macos/.build_objc_asan
@@ -0,0 +1,6 @@
+#!/bin/sh
+# gen by configure
+OBJC="/usr/bin/clang"
+CPPFLAGS=""
+CFLAGS=""
+/opt/homebrew/bin/glibtool --tag=CC --mode=compile ${OBJC} ${CPPFLAGS} ${CFLAGS} -c "$1" -o "$2" >> .build/log 2>&1
diff --git a/window/sdl2/demo/macos/.build_objc_cov b/window/sdl2/demo/macos/.build_objc_cov
new file mode 100755
index 0000000..ed98d2b
--- /dev/null
+++ b/window/sdl2/demo/macos/.build_objc_cov
@@ -0,0 +1,6 @@
+#!/bin/sh
+# gen by configure
+OBJC="/usr/bin/clang"
+CPPFLAGS=""
+CFLAGS=""
+/opt/homebrew/bin/glibtool --tag=CC --mode=compile ${OBJC} ${CPPFLAGS} ${CFLAGS} -c "$1" -o "$2" >> .build/log 2>&1
diff --git a/window/sdl2/demo/macos/.build_objc_debug b/window/sdl2/demo/macos/.build_objc_debug
new file mode 100755
index 0000000..ed98d2b
--- /dev/null
+++ b/window/sdl2/demo/macos/.build_objc_debug
@@ -0,0 +1,6 @@
+#!/bin/sh
+# gen by configure
+OBJC="/usr/bin/clang"
+CPPFLAGS=""
+CFLAGS=""
+/opt/homebrew/bin/glibtool --tag=CC --mode=compile ${OBJC} ${CPPFLAGS} ${CFLAGS} -c "$1" -o "$2" >> .build/log 2>&1
diff --git a/window/sdl2/demo/macos/.build_objc_main b/window/sdl2/demo/macos/.build_objc_main
new file mode 100755
index 0000000..ed98d2b
--- /dev/null
+++ b/window/sdl2/demo/macos/.build_objc_main
@@ -0,0 +1,6 @@
+#!/bin/sh
+# gen by configure
+OBJC="/usr/bin/clang"
+CPPFLAGS=""
+CFLAGS=""
+/opt/homebrew/bin/glibtool --tag=CC --mode=compile ${OBJC} ${CPPFLAGS} ${CFLAGS} -c "$1" -o "$2" >> .build/log 2>&1
diff --git a/window/sdl2/demo/macos/configure b/window/sdl2/demo/macos/configure
index d4c12e8..65c1b60 100755
--- a/window/sdl2/demo/macos/configure
+++ b/window/sdl2/demo/macos/configure
@@ -37,6 +37,13 @@ echo "APP_ASAN = ${APP_ASAN}" >> ${CONFIG_MK}
echo "APP_COV = ${APP_COV}" >> ${CONFIG_MK}
echo "APP_DEBUG = ${APP_DEBUG}" >> ${CONFIG_MK}
+update_build
+update_build_objc
+update_build_prog
+
+build_lo
+build_prog
+
APP_PROG=${APP}/Contents/MacOS/${PROG}
APP_PROG_ASAN=${APP_ASAN}/Contents/MacOS/${PROG_ASAN}
APP_PROG_COV=${APP_COV}/Contents/MacOS/${PROG_COV}