From 102084ab7cfe74178f423392a3e70677e246a89a Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 11 Sep 2009 08:21:58 +0000 Subject: [PATCH] Changes to compile on CentOS-5.3 --- class.c | 24 ++++++++++-------------- lock.h | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/class.c b/class.c index 615d29c..c8f1564 100644 --- a/class.c +++ b/class.c @@ -136,6 +136,7 @@ typedef struct class_node #include "lock.h" static class_node_ptr class_table_array[CLASS_TABLE_SIZE]; +static int __class_table_was_set_up = 0; /* The table writing mutex - we lock on writing to avoid conflicts between different writers, but we read without locks. That is @@ -163,17 +164,6 @@ static mutex_t __class_table_lock; \ HASH = (HASH ^ (HASH >> 10) ^ (HASH >> 20)) & CLASS_TABLE_MASK; -/* Setup the table. */ -static void -class_table_setup (void) -{ - /* Start - nothing in the table. */ - memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE); - - /* The table writing mutex. */ - INIT_LOCK(__class_table_lock); -} - /* Insert a class in the table (used when a new class is registered). */ static void @@ -428,13 +418,19 @@ __objc_init_class_tables (void) { /* Allocate the class hash table. */ - if (__class_table_lock) + if (__class_table_was_set_up) return; LOCK(__objc_runtime_mutex); - - class_table_setup (); + if (!__class_table_was_set_up) + { + /* Start - nothing in the table. */ + memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE); + /* The table writing mutex. */ + INIT_LOCK(__class_table_lock); + __class_table_was_set_up = 1; + } UNLOCK(__objc_runtime_mutex); } diff --git a/lock.h b/lock.h index 837759d..0b8dbcd 100644 --- a/lock.h +++ b/lock.h @@ -14,6 +14,7 @@ typedef HANDLE mutex_t; #else #define _XOPEN 500 +#define __USE_UNIX98 1 # include typedef pthread_mutex_t mutex_t;