summaryrefslogtreecommitdiff
path: root/devel/pthread-stublib
diff options
context:
space:
mode:
authordrochner <drochner>2006-03-21 19:23:08 +0000
committerdrochner <drochner>2006-03-21 19:23:08 +0000
commit4a7261902a99efa1fffaf6dec69ad4bb3d4c67dc (patch)
tree4d54181d5004372677aff31d45929442c3fbf04e /devel/pthread-stublib
parentb5aa9471b393bbb2fae2c12035999271623fc5b1 (diff)
downloadpkgsrc-4a7261902a99efa1fffaf6dec69ad4bb3d4c67dc.tar.gz
Add a library to catch calls to pthread_mutex* and *specific* functions
where the base system doesn't provide stubs for non-threaded programs (which is just NetBSD<=2 for now). This is absolutely primitive and just sufficient to make MesaLib usable with nonthreaded programs.
Diffstat (limited to 'devel/pthread-stublib')
-rw-r--r--devel/pthread-stublib/DESCR3
-rw-r--r--devel/pthread-stublib/Makefile19
-rw-r--r--devel/pthread-stublib/PLIST2
-rw-r--r--devel/pthread-stublib/buildlink3.mk28
-rw-r--r--devel/pthread-stublib/files/Makefile13
-rw-r--r--devel/pthread-stublib/files/pthread-stubs.c53
6 files changed, 118 insertions, 0 deletions
diff --git a/devel/pthread-stublib/DESCR b/devel/pthread-stublib/DESCR
new file mode 100644
index 00000000000..60d4eebd0aa
--- /dev/null
+++ b/devel/pthread-stublib/DESCR
@@ -0,0 +1,3 @@
+Provide dummy implementations of pthread functions like mutex operations
+to enable libraries to be used in both thread-aware and non-threaded programs.
+This is for NetBSD<=2; newer operating systems don't need it.
diff --git a/devel/pthread-stublib/Makefile b/devel/pthread-stublib/Makefile
new file mode 100644
index 00000000000..4f270a31b4f
--- /dev/null
+++ b/devel/pthread-stublib/Makefile
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/03/21 19:23:08 drochner Exp $
+
+DISTNAME= pthread-stublib-1.0
+CATEGORIES= devel
+DISTFILES= # empty
+
+MAINTAINER= drochner@NetBSD.org
+COMMENT= Library providing noop-stubs for pthread functions
+
+WRKSRC= ${WRKDIR}
+NO_CHECKSUM= yes
+USE_LIBTOOL= yes
+
+ONLY_FOR_PLATFORM= NetBSD-[12].*-*
+
+do-extract:
+ ${CP} ${FILESDIR}/pthread-stubs.c ${FILESDIR}/Makefile ${WRKSRC}
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/devel/pthread-stublib/PLIST b/devel/pthread-stublib/PLIST
new file mode 100644
index 00000000000..712786296ee
--- /dev/null
+++ b/devel/pthread-stublib/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2006/03/21 19:23:08 drochner Exp $
+lib/libpthstub.la
diff --git a/devel/pthread-stublib/buildlink3.mk b/devel/pthread-stublib/buildlink3.mk
new file mode 100644
index 00000000000..c8fb660bb48
--- /dev/null
+++ b/devel/pthread-stublib/buildlink3.mk
@@ -0,0 +1,28 @@
+# $NetBSD: buildlink3.mk,v 1.1.1.1 2006/03/21 19:23:08 drochner Exp $
+# XXX
+# XXX This file was created automatically using createbuildlink-3.10.
+# XXX After this file has been verified as correct, the comment lines
+# XXX beginning with "XXX" should be removed. Please do not commit
+# XXX unverified buildlink3.mk files.
+# XXX
+# XXX Packages that only install static libraries or headers should
+# XXX include the following line:
+# XXX
+# XXX BUILDLINK_DEPMETHOD.pthread-stublib?= build
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
+PTHREAD_STUBLIB_BUILDLINK3_MK:= ${PTHREAD_STUBLIB_BUILDLINK3_MK}+
+
+.if !empty(BUILDLINK_DEPTH:M+)
+BUILDLINK_DEPENDS+= pthread-stublib
+.endif
+
+BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Npthread-stublib}
+BUILDLINK_PACKAGES+= pthread-stublib
+
+.if !empty(PTHREAD_STUBLIB_BUILDLINK3_MK:M+)
+BUILDLINK_DEPENDS.pthread-stublib+= pthread-stublib>=1.0
+BUILDLINK_PKGSRCDIR.pthread-stublib?= ../../devel/pthread-stublib
+.endif # PTHREAD_STUBLIB_BUILDLINK3_MK
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
diff --git a/devel/pthread-stublib/files/Makefile b/devel/pthread-stublib/files/Makefile
new file mode 100644
index 00000000000..ec4538a1a34
--- /dev/null
+++ b/devel/pthread-stublib/files/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/03/21 19:23:08 drochner Exp $
+
+all: libpthstub.la
+
+libpthstub.la: pthread-stubs.lo
+ ${LIBTOOL} --mode=link ${CC} -o $@ $? -rpath ${PREFIX}/lib
+
+pthread-stubs.lo: pthread-stubs.c
+ ${LIBTOOL} --mode=compile ${CC} -c -o $@ $?
+
+install:
+ ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} libpthstub.la \
+ ${PREFIX}/lib
diff --git a/devel/pthread-stublib/files/pthread-stubs.c b/devel/pthread-stublib/files/pthread-stubs.c
new file mode 100644
index 00000000000..8f3ae7649cb
--- /dev/null
+++ b/devel/pthread-stublib/files/pthread-stubs.c
@@ -0,0 +1,53 @@
+/* $NetBSD: pthread-stubs.c,v 1.1.1.1 2006/03/21 19:23:08 drochner Exp $ */
+
+#include <sys/cdefs.h>
+
+int __pthstub_mutex_noop(void);
+
+__weak_alias(pthread_mutex_init,__pthstub_noop)
+__weak_alias(pthread_mutex_lock,__pthstub_noop)
+__weak_alias(pthread_mutex_trylock,__pthstub_noop)
+__weak_alias(pthread_mutex_unlock,__pthstub_noop)
+__weak_alias(pthread_mutex_destroy,__pthstub_noop)
+__weak_alias(pthread_key_create,__pthstub_noop)
+__weak_alias(pthread_self,__pthstub_noop)
+
+int
+__pthstub_noop()
+{
+
+ return (0);
+}
+
+__weak_alias(pthread_setspecific,__pthstub_setspecific)
+__weak_alias(pthread_getspecific,__pthstub_getspecific)
+static void *__pthstub_localdata;
+
+int
+__pthstub_setspecific(int k, void *v)
+{
+
+ __pthstub_localdata = v;
+ return (0);
+}
+
+void *
+__pthstub_getspecific()
+{
+
+ return (__pthstub_localdata);
+}
+
+__weak_alias(pthread_once,__pthstub_once)
+static int __once_done;
+
+int
+__pthstub_once(void *oc, void (*f)(void))
+{
+
+ if (!__once_done) {
+ (*f)();
+ __once_done = 1;
+ }
+ return (0);
+}