cvsdist 3b0ae35
--- ElectricFence-2.2.2/efence.c.jj	1999-04-12 21:00:49.000000000 -0400
cvsdist 3b0ae35
+++ ElectricFence-2.2.2/efence.c	2003-02-03 11:20:18.000000000 -0500
cvsdist 3b0ae35
@@ -174,6 +174,15 @@ static int		internalUse = 0;
cvsdist 3b0ae35
 static int		noAllocationListProtection = 0;
cvsdist 3b0ae35
 
cvsdist 3b0ae35
 #ifdef USE_SEMAPHORE
cvsdist 3b0ae35
+
cvsdist 3b0ae35
+#include <stdbool.h>
cvsdist 3b0ae35
+
cvsdist 3b0ae35
+#pragma weak sem_init
cvsdist 3b0ae35
+#pragma weak sem_post
cvsdist 3b0ae35
+#pragma weak sem_wait
cvsdist 3b0ae35
+
cvsdist 3b0ae35
+static int		pthread_initialization = 0;
cvsdist 3b0ae35
+
cvsdist 3b0ae35
 /*
cvsdist 3b0ae35
  * EF_sem is a semaphore used to allow one thread at a time into
cvsdist 3b0ae35
  * these routines.
cvsdist 3b0ae35
@@ -274,7 +283,7 @@ initialize(void)
cvsdist 3b0ae35
 	EF_Print(version);
cvsdist 3b0ae35
 
cvsdist 3b0ae35
 #ifdef USE_SEMAPHORE
cvsdist 3b0ae35
-	if (sem_init(&EF_sem, 0, 1) >= 0) {
cvsdist 3b0ae35
+	if (sem_init != NULL && !pthread_initialization && sem_init(&EF_sem, 0, 1) >= 0) {
cvsdist 3b0ae35
 		semEnabled = 1;
cvsdist 3b0ae35
 	}
cvsdist 3b0ae35
 #endif
cvsdist 3b0ae35
@@ -397,6 +406,21 @@ initialize(void)
cvsdist 3b0ae35
 	release();
cvsdist 3b0ae35
 }
cvsdist 3b0ae35
 
cvsdist 3b0ae35
+#ifdef USE_SEMAPHORE
cvsdist 3b0ae35
+void
cvsdist 3b0ae35
+__libc_malloc_pthread_startup (bool first_time)
cvsdist 3b0ae35
+{
cvsdist 3b0ae35
+	if (first_time) {
cvsdist 3b0ae35
+		pthread_initialization = 1;
cvsdist 3b0ae35
+		initialize ();
cvsdist 3b0ae35
+	} else {
cvsdist 3b0ae35
+		pthread_initialization = 0;
cvsdist 3b0ae35
+		if (!semEnabled && sem_init != NULL && sem_init(&EF_sem, 0, 1) >= 0)
cvsdist 3b0ae35
+			semEnabled = 1;
cvsdist 3b0ae35
+	}
cvsdist 3b0ae35
+}
cvsdist 3b0ae35
+#endif
cvsdist 3b0ae35
+
cvsdist 3b0ae35
 /*
cvsdist 3b0ae35
  * allocateMoreSlots is called when there are only enough slot structures
cvsdist 3b0ae35
  * left to support the allocation of a single malloc buffer.
cvsdist 3b0ae35
--- ElectricFence-2.2.2/Makefile.jj	1999-04-13 13:22:49.000000000 -0400
cvsdist 3b0ae35
+++ ElectricFence-2.2.2/Makefile	2003-02-03 11:27:06.000000000 -0500
cvsdist 3b0ae35
@@ -1,6 +1,6 @@
cvsdist 3b0ae35
 PIC= -fPIC
cvsdist 3b0ae35
 CFLAGS= -g -DUSE_SEMAPHORE $(PIC)
cvsdist 3b0ae35
-LIBS= -lpthread
cvsdist 3b0ae35
+LIBS=
cvsdist 3b0ae35
 
cvsdist 3b0ae35
 prefix=/usr
cvsdist 3b0ae35
 BIN_INSTALL_DIR= $(prefix)/bin
cvsdist 3b0ae35
@@ -54,8 +54,8 @@ libefence.a: $(OBJECTS)
cvsdist 3b0ae35
 	$(AR) crv libefence.a $(OBJECTS)
cvsdist 3b0ae35
 
cvsdist 3b0ae35
 libefence.so.0.0: $(OBJECTS)
cvsdist 3b0ae35
-	gcc -g -shared -Wl,-soname,libefence.so.0 -o libefence.so.0.0 \
cvsdist 3b0ae35
-		$(OBJECTS) -lpthread -lc 
cvsdist 3b0ae35
+	gcc -shared -Wl,-soname,libefence.so.0 -o libefence.so.0.0 \
cvsdist 3b0ae35
+		$(CFLAGS) $(OBJECTS) 
cvsdist 3b0ae35
 
cvsdist 3b0ae35
 tstheap: libefence.a tstheap.o
cvsdist 3b0ae35
 	- rm -f tstheap