| 1 |
--- ElectricFence-2.2.2/efence.c.jj 1999-04-12 21:00:49.000000000 -0400
|
| 2 |
+++ ElectricFence-2.2.2/efence.c 2003-02-03 11:20:18.000000000 -0500
|
| 3 |
@@ -174,6 +174,15 @@ static int internalUse = 0;
|
| 4 |
static int noAllocationListProtection = 0;
|
| 5 |
|
| 6 |
#ifdef USE_SEMAPHORE
|
| 7 |
+
|
| 8 |
+#include <stdbool.h>
|
| 9 |
+
|
| 10 |
+#pragma weak sem_init
|
| 11 |
+#pragma weak sem_post
|
| 12 |
+#pragma weak sem_wait
|
| 13 |
+
|
| 14 |
+static int pthread_initialization = 0;
|
| 15 |
+
|
| 16 |
/*
|
| 17 |
* EF_sem is a semaphore used to allow one thread at a time into
|
| 18 |
* these routines.
|
| 19 |
@@ -274,7 +283,7 @@ initialize(void)
|
| 20 |
EF_Print(version);
|
| 21 |
|
| 22 |
#ifdef USE_SEMAPHORE
|
| 23 |
- if (sem_init(&EF_sem, 0, 1) >= 0) {
|
| 24 |
+ if (sem_init != NULL && !pthread_initialization && sem_init(&EF_sem, 0, 1) >= 0) {
|
| 25 |
semEnabled = 1;
|
| 26 |
}
|
| 27 |
#endif
|
| 28 |
@@ -397,6 +406,21 @@ initialize(void)
|
| 29 |
release();
|
| 30 |
}
|
| 31 |
|
| 32 |
+#ifdef USE_SEMAPHORE
|
| 33 |
+void
|
| 34 |
+__libc_malloc_pthread_startup (bool first_time)
|
| 35 |
+{
|
| 36 |
+ if (first_time) {
|
| 37 |
+ pthread_initialization = 1;
|
| 38 |
+ initialize ();
|
| 39 |
+ } else {
|
| 40 |
+ pthread_initialization = 0;
|
| 41 |
+ if (!semEnabled && sem_init != NULL && sem_init(&EF_sem, 0, 1) >= 0)
|
| 42 |
+ semEnabled = 1;
|
| 43 |
+ }
|
| 44 |
+}
|
| 45 |
+#endif
|
| 46 |
+
|
| 47 |
/*
|
| 48 |
* allocateMoreSlots is called when there are only enough slot structures
|
| 49 |
* left to support the allocation of a single malloc buffer.
|
| 50 |
--- ElectricFence-2.2.2/Makefile.jj 1999-04-13 13:22:49.000000000 -0400
|
| 51 |
+++ ElectricFence-2.2.2/Makefile 2003-02-03 11:27:06.000000000 -0500
|
| 52 |
@@ -1,6 +1,6 @@
|
| 53 |
PIC= -fPIC
|
| 54 |
CFLAGS= -g -DUSE_SEMAPHORE $(PIC)
|
| 55 |
-LIBS= -lpthread
|
| 56 |
+LIBS=
|
| 57 |
|
| 58 |
prefix=/usr
|
| 59 |
BIN_INSTALL_DIR= $(prefix)/bin
|
| 60 |
@@ -54,8 +54,8 @@ libefence.a: $(OBJECTS)
|
| 61 |
$(AR) crv libefence.a $(OBJECTS)
|
| 62 |
|
| 63 |
libefence.so.0.0: $(OBJECTS)
|
| 64 |
- gcc -g -shared -Wl,-soname,libefence.so.0 -o libefence.so.0.0 \
|
| 65 |
- $(OBJECTS) -lpthread -lc
|
| 66 |
+ gcc -shared -Wl,-soname,libefence.so.0 -o libefence.so.0.0 \
|
| 67 |
+ $(CFLAGS) $(OBJECTS)
|
| 68 |
|
| 69 |
tstheap: libefence.a tstheap.o
|
| 70 |
- rm -f tstheap
|