ports/122525: [PATCH] lang/see[-devel]: add locking for thread-safety
Simun Mikecin
numisemis at yahoo.com
Mon Apr 7 10:40:03 UTC 2008
>Number: 122525
>Category: ports
>Synopsis: [PATCH] lang/see[-devel]: add locking for thread-safety
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Mon Apr 07 10:40:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Simun Mikecin
>Release: FreeBSD/amd64 7.0-RELEASE
>Organization:
>Environment:
FreeBSD xxx 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Mon Feb 25 14:12:19 CET 2008 root at xxx:/usr/obj/usr/src.7.0/sys/XXX amd64
>Description:
libsee/dtoa.c requires thread locking functions to be thread-safe.
This patch adds new option MULTIPLE_THREADS to both lang/see and lang/see-devel. With this option enabled libsee/dtoa.c is compiled with proper thread locking.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
diff -urN see-devel.orig/Makefile see-devel/Makefile
--- see-devel.orig/Makefile 2008-04-06 12:03:46.000000000 +0200
+++ see-devel/Makefile 2008-04-07 12:30:38.425779648 +0200
@@ -7,6 +7,7 @@
PORTNAME= see
PORTVERSION= 3.0.1376
+PORTREVISION= 1
CATEGORIES= lang devel
MASTER_SITES= http://www.evolane.com/download/mirror/etcl/ \
http://www.evolane.fr/download/mirror/etcl/
@@ -17,7 +18,8 @@
OPTIONS= GC "Use Boehm-Weiser garbage collection package" on \
OPTIMIZED_CFLAGS "Enable some additional optimizations" off \
- SEE_DEBUG "Internal SEE library debugging" off
+ SEE_DEBUG "Internal SEE library debugging" off \
+ MULTIPLE_THREADS "Enable thread-safety" on
CONFLICTS= see-[0-9]*
@@ -32,6 +34,10 @@
.include <bsd.port.pre.mk>
+.if defined(WITH_MULTIPLE_THREADS)
+CFLAGS+= -DMULTIPLE_THREADS
+.endif
+
.if !defined(WITH_SEE_DEBUG)
CFLAGS+= -DNDEBUG
.endif
@@ -44,9 +50,11 @@
LIB_DEPENDS+= gc:${PORTSDIR}/devel/boehm-gc
.else
CONFIGURE_ARGS+= --without-boehm-gc
+.if !defined(WITH_MULTIPLE_THREADS)
PTHREAD_CFLAGS=
PTHREAD_LIBS=
.endif
+.endif
post-patch:
@${REINPLACE_CMD} -e "s|PACKAGE_BUGREPORT='leonard at users|PACKAGE_BUGREPORT='leonard\\\@users|" \
diff -urN see-devel.orig/files/patch-libsee_dtoa.c see-devel/files/patch-libsee_dtoa.c
--- see-devel.orig/files/patch-libsee_dtoa.c 1970-01-01 01:00:00.000000000 +0100
+++ see-devel/files/patch-libsee_dtoa.c 2008-04-07 11:34:32.013901000 +0200
@@ -0,0 +1,24 @@
+--- libsee/dtoa.c.orig 2005-12-24 04:35:38.000000000 +0100
++++ libsee/dtoa.c 2008-04-07 11:30:11.529829910 +0200
+@@ -168,6 +168,11 @@
+ * the result overflows to +-Infinity or underflows to 0.
+ */
+
++#ifdef MULTIPLE_THREADS
++#include <pthread.h>
++static pthread_mutex_t mylock[2] = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER };
++#endif
++
+ #ifndef Long
+ #define Long long
+ #endif
+@@ -470,6 +475,9 @@
+ #ifndef MULTIPLE_THREADS
+ #define ACQUIRE_DTOA_LOCK(n) /*nothing*/
+ #define FREE_DTOA_LOCK(n) /*nothing*/
++#else
++#define ACQUIRE_DTOA_LOCK(n) pthread_mutex_lock(&mylock[n]);
++#define FREE_DTOA_LOCK(n) pthread_mutex_unlock(&mylock[n]);
+ #endif
+
+ #define Kmax 15
diff -urN see.orig/Makefile see/Makefile
--- see.orig/Makefile 2008-01-29 10:36:02.000000000 +0100
+++ see/Makefile 2008-04-07 12:19:31.878542851 +0200
@@ -7,6 +7,7 @@
PORTNAME= see
PORTVERSION= 2.0.1131
+PORTREVISION= 1
CATEGORIES= lang devel
MASTER_SITES= http://www.powerband.net.au/~david.leonard/ \
http://freshmeat.net/redir/see/45974/url_tgz/
@@ -16,7 +17,8 @@
OPTIONS= GC "Use Boehm-Weiser garbage collection package" on \
OPTIMIZED_CFLAGS "Enable some additional optimizations" off \
- SEE_DEBUG "Internal SEE library debugging" off
+ SEE_DEBUG "Internal SEE library debugging" off \
+ MULTIPLE_THREADS "Enable thread-safety" on
CONFLICTS= see-devel-[0-9]*
@@ -33,6 +35,10 @@
.include <bsd.port.pre.mk>
+.if defined(WITH_MULTIPLE_THREADS)
+CFLAGS+= -DMULTIPLE_THREADS
+.endif
+
.if !defined(WITH_SEE_DEBUG)
CFLAGS+= -DNDEBUG
.endif
@@ -45,9 +51,11 @@
LIB_DEPENDS+= gc:${PORTSDIR}/devel/boehm-gc
.else
CONFIGURE_ARGS+= --without-boehm-gc
+.if !defined(WITH_MULTIPLE_THREADS)
PTHREAD_CFLAGS=
PTHREAD_LIBS=
.endif
+.endif
post-patch:
@${REINPLACE_CMD} -e "s|PACKAGE_BUGREPORT='leonard at users|PACKAGE_BUGREPORT='leonard\\\@users|" \
diff -urN see.orig/files/patch-libsee_dtoa.c see/files/patch-libsee_dtoa.c
--- see.orig/files/patch-libsee_dtoa.c 1970-01-01 01:00:00.000000000 +0100
+++ see/files/patch-libsee_dtoa.c 2008-04-07 11:34:32.013901035 +0200
@@ -0,0 +1,24 @@
+--- libsee/dtoa.c.orig 2005-12-24 04:35:38.000000000 +0100
++++ libsee/dtoa.c 2008-04-07 11:30:11.529829910 +0200
+@@ -168,6 +168,11 @@
+ * the result overflows to +-Infinity or underflows to 0.
+ */
+
++#ifdef MULTIPLE_THREADS
++#include <pthread.h>
++static pthread_mutex_t mylock[2] = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER };
++#endif
++
+ #ifndef Long
+ #define Long long
+ #endif
+@@ -470,6 +475,9 @@
+ #ifndef MULTIPLE_THREADS
+ #define ACQUIRE_DTOA_LOCK(n) /*nothing*/
+ #define FREE_DTOA_LOCK(n) /*nothing*/
++#else
++#define ACQUIRE_DTOA_LOCK(n) pthread_mutex_lock(&mylock[n]);
++#define FREE_DTOA_LOCK(n) pthread_mutex_unlock(&mylock[n]);
+ #endif
+
+ #define Kmax 15
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list