Skip to content

Instantly share code, notes, and snippets.

@shirok
Created February 14, 2013 18:30
Show Gist options
  • Select an option

  • Save shirok/4955047 to your computer and use it in GitHub Desktop.

Select an option

Save shirok/4955047 to your computer and use it in GitHub Desktop.
diff --git a/configure.ac b/configure.ac
index aa17d7c..d0f37ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,6 +199,12 @@ case $GAUCHE_THREAD_TYPE in
THREADDLLIBS="-lpthread -lrt"
GAUCHE_THREAD_TYPE=pthreads
;;
+ *-*-openbsd*)
+ AC_DEFINE(GC_OPENBSD_THREADS,1,[Define to use OpenBSD threads])
+ INCLUDES="$INCLUDES -pthread"
+ THREADLIBS="-lpthread"
+ GAUCHE_THREAD_TYPE=pthreads
+ ;;
*-*-solaris*)
AC_DEFINE(GC_SOLARIS_THREADS,1,[Define to use Solaris threads])
AC_DEFINE(GC_SOLARIS_PTHREADS,1,[Define to use Solaris pthreads])
diff --git a/ext/net/gauche-net.h b/ext/net/gauche-net.h
index 7377a36..40ab3d4 100644
--- a/ext/net/gauche-net.h
+++ b/ext/net/gauche-net.h
@@ -74,6 +74,10 @@ typedef SOCKET Socket;
#endif
#include <gauche/extern.h>
+#ifdef __OpenBSD__
+#include <sys/uio.h>
+#endif /*__OpenBSD__*/
+
SCM_DECL_BEGIN
/* windows stuff */
@@ -94,7 +98,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
* Sockaddr_storage
*/
-#if !defined(HAVE_STRUCT_SOCKADDR_STORAGE) && !defined(_MSC_VER)
+#if !defined(HAVE_STRUCT_SOCKADDR_STORAGE) && !defined(_MSC_VER) && !defined(__OpenBSD__)
/* Alternative implementation in case the system doesn't provide
sockaddr_storage. The code is based on the reference implementation
provided in RFC3493.
@kuwa72
Copy link
Copy Markdown

kuwa72 commented Feb 16, 2013

取り急ぎ報告だけ
手元の環境(OpenBSD5.2 amd64)では下記エラーになります。BoehmGCは2011年7月ころにOpenBSDでコンパイルできるパッチが入ったようですが、OpenBSD5.1から5.2の変更でpthreadが入ってスレッド関係のAPIが変更になったため、逆に動かなくなっているようです。
http://www.openbsd.org/plus52.html
The pthread_suspend_np(3) and pthread_resume_np(3) function are no longer functional and become ENOTSUP stubs.
OpenBSD5.1ならこれで動かもしれませんが。

TARGETLIB=pwd gcc -std=gnu99 -g -O2 -fPIC -DPIC -Wl,--rpath -Wl,pwd -L. -Wl,--soname,libgauche-0.9.so.0.4 -shared -o libgauche-0.9.so box.o core.o vm.o compaux.o macro.o code.o error.o class.o prof.o collection.o boolean.o char.o string.o list.o hash.o treemap.o bits.o port.o write.o read.o vector.o weak.o symbol.o keyword.o gloc.o compare.o regexp.o signal.o parameter.o module.o proc.o number.o bignum.o load.o paths.o lazy.o repl.o autoloads.o system.o compile.o libalpha.o libbool.o libchar.o libdict.o libeval.o libexc.o libio.o liblazy.o liblist.o libmisc.o libmod.o libnum.o libobj.o libomega.o libproc.o librx.o libstr.o libsym.o libsys.o libvec.o ls -1 ../gc/.libs/*.o | grep -v '/cord' | grep -v '/staticrootslib' -lutil -lm -lpthread
TARGETLIB=pwd /bin/sh ./makeverslink libgauche-0.9.so
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I. -I./../gc/include -I../gc/include -I./../gc/libatomic_ops/src -I../gc/libatomic_ops/src -g -O2 -fPIC -DPIC -fomit-frame-pointer -c main.c
TARGETLIB=pwd gcc -std=gnu99 -g -O2 -fPIC -DPIC -Wl,--rpath -Wl,pwd -L. -rdynamic -o gosh main.o -lgauche-0.9 -lutil -lm -lpthread
./libgauche-0.9.so.0.4: ¥033[1;36mwarning: strcpy() is almost always misused, please use strlcpy()¥033[0;30m
./libgauche-0.9.so.0.4: ¥033[1;36mwarning: strcat() is almost always misused, please use strlcat()¥033[0;30m
./libgauche-0.9.so.0.4: ¥033[1;36mwarning: sprintf() is often misused, please use snprintf()¥033[0;30m
./libgauche-0.9.so.0.4: undefined reference to pthread_resume_np' ./libgauche-0.9.so.0.4: undefined reference topthread_suspend_np'
collect2: ld returned 1 exit status
*** Error code 1

Stop in /home/yuichiro/Gauche/src (line 213 of Makefile).
*** Error code 1

Stop in /home/yuichiro/Gauche (line 37 of Makefile).

@shirok
Copy link
Copy Markdown
Author

shirok commented Feb 16, 2013

ふーむ、本家(boehm gc)にも一応報告上がっているようだけどまだ根本的な対応はされていないみたいですね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment