summaryrefslogtreecommitdiff
path: root/tool/m4/ruby_thread.m4
diff options
context:
space:
mode:
Diffstat (limited to 'tool/m4/ruby_thread.m4')
-rw-r--r--tool/m4/ruby_thread.m433
1 files changed, 33 insertions, 0 deletions
diff --git a/tool/m4/ruby_thread.m4 b/tool/m4/ruby_thread.m4
new file mode 100644
index 0000000000..3831bc4c06
--- /dev/null
+++ b/tool/m4/ruby_thread.m4
@@ -0,0 +1,33 @@
+dnl -*- Autoconf -*-
+AC_DEFUN([RUBY_THREAD], [
+AC_ARG_WITH(thread,
+ AS_HELP_STRING([--with-thread=IMPLEMENTATION], [specify the thread implementation to use]),
+ [THREAD_MODEL=$withval], [
+ THREAD_MODEL=
+ AS_CASE(["$target_os"],
+ [mingw*], [
+ THREAD_MODEL=win32
+ ],
+ [
+ AS_IF([test "$rb_with_pthread" = "yes"], [
+ THREAD_MODEL=pthread
+ ])
+ ]
+ )
+])
+
+AS_CASE(["$THREAD_MODEL"],
+[pthread], [AC_CHECK_HEADERS(pthread.h)],
+[win32], [],
+[""], [AC_MSG_ERROR(thread model is missing)],
+ [AC_MSG_ERROR(unknown thread model $THREAD_MODEL)])
+
+THREAD_IMPL_H=thread_$THREAD_MODEL.h
+AS_IF([test ! -f "$srcdir/$THREAD_IMPL_H"],
+ [AC_MSG_ERROR('$srcdir/$THREAD_IMPL_H' must exist)])
+THREAD_IMPL_SRC=thread_$THREAD_MODEL.c
+AS_IF([test ! -f "$srcdir/$THREAD_IMPL_SRC"],
+ [AC_MSG_ERROR('$srcdir/$THREAD_IMPL_SRC' must exist)])
+AC_DEFINE_UNQUOTED(THREAD_IMPL_H, ["$THREAD_IMPL_H"])
+AC_DEFINE_UNQUOTED(THREAD_IMPL_SRC, ["$THREAD_IMPL_SRC"])
+])dnl