]> git.saurik.com Git - apple/objc4.git/commitdiff
objc4-237.tar.gz mac-os-x-1033 mac-os-x-1034 mac-os-x-1035 mac-os-x-1036 mac-os-x-1037 mac-os-x-1038 mac-os-x-1039 v237
authorApple <opensource@apple.com>
Thu, 20 Nov 2003 23:22:30 +0000 (23:22 +0000)
committerApple <opensource@apple.com>
Thu, 20 Nov 2003 23:22:30 +0000 (23:22 +0000)
Makefile
runtime/objc-private.h
runtime/objc-runtime.m
runtime/objc-sel-table.h
runtime/objc-sync.m

index 36ecd5f733159804c00f2086699c64716032b0ba..3b33ca1adb3c564f012a9139825302827965b39b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -119,19 +119,6 @@ CFLAGS += $(ARCH_FLAGS)
 LDFLAGS += $(ARCH_FLAGS) -dynamiclib -dynamic -compatibility_version 1 -current_version $(CURRENT_PROJECT_VERSION) 
 endif
 
-ifeq "$(PLATFORM)" "Darwin"
-# Determine Mac OS X version
-# 6.x = Jaguar, 7.x = Panther
-ifeq "$(OS_VERSION)" ""
-  OS_VERSION = $(shell uname -r)
-endif
-DARWIN_MAJOR_VERSION = $(word 1, $(subst ., ,$(OS_VERSION)))
-DARWIN_MINOR_VERSION = $(word 2, $(subst ., ,$(OS_VERSION)))
-ifeq "$(DARWIN_MAJOR_VERSION)" "7"
-CFLAGS += -DMACOSX_PANTHER
-endif
-endif
-
 CFLAGS += $(OTHER_CFLAGS) $(RC_CFLAGS)
 LDFLAGS += $(OTHER_LDFLAGS)
 
index b15a828b1e0dbbf1ff1b7e19cca3d3e125c8375a..6c09b7d8081eb2a217c023f377806d820a725cde 100644 (file)
 
     #import <objc/objc-runtime.h>
 
-#ifdef MACOSX_PANTHER
     #import <malloc/malloc.h>
-#else
-    // pre-Panther
-    #import <objc/malloc.h>
-#endif
 
 
 /* Opaque cookie used in _getObjc... routines.  File format independant.
index 5498f6008a49cacaf4da1e19e321cb4c8bdd37d6..bb204b85d0a5fcb6837105e3183ae483a5f2497e 100644 (file)
@@ -1760,7 +1760,6 @@ static void       _objc_map_image(headerType *mh, unsigned long   vmaddr_slide)
 
     trace(0xb101, 0, 0, 0);
 
-#ifdef MACOSX_PANTHER
     // Check if all loaded libraries up to and including this one are prebound
     // SPI introduced in Panther (Mac OS X 10.3)
     all_modules_prebound = _dyld_all_twolevel_modules_prebound();
@@ -1772,7 +1771,6 @@ static void       _objc_map_image(headerType *mh, unsigned long   vmaddr_slide)
             warned = all_modules_prebound;
         }
     }
-#endif
 
     // Register any categories and/or classes and/or selectors this image contains
     _objc_add_categories_from_image (hInfo);
index 66d7401a3f9fe3d727a9c978760c976f1177c4f6..b62295d1c52beced7761ef7aabceb1c55d964da4 100644 (file)
@@ -1,3 +1,27 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
 /* Last update: cjk - 16 October 2000
  * To construct this list, I enabled the code in the search function which
  * is marked DUMP_SELECTORS, and launched a few apps with stdout redirected
index 945e5e82653127383f7434a5600cec9f81308182..86be2a18bfc741dd81d5149226d4d7a828a934b4 100644 (file)
@@ -23,7 +23,7 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 //
-//  objc_sync.h
+//  objc_sync.m
 //
 //  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 //
@@ -32,8 +32,6 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <pthread.h>
-#define PTHREAD_MUTEX_RECURSIVE          2
-#include <CoreFoundation/CFDictionary.h>
 #include <AssertMacros.h>
 
 #include "objc-sync.h"
@@ -71,18 +69,21 @@ done:
 
 struct SyncData
 {
-       struct SyncData*        nextData;
-       id                      object;
-       unsigned int            lockCount;
+       struct SyncData*        nextData;       // only accessed while holding sTableLock
+       id                      object;         // only accessed while holding sTableLock
+       unsigned int            lockCount;      // only accessed while holding sTableLock
        pthread_mutex_t         mutex;
        pthread_cond_t          conditionVariable;
 };
 typedef struct SyncData SyncData;
 
+
 static pthread_mutex_t         sTableLock = PTHREAD_MUTEX_INITIALIZER;
 static SyncData*               sDataList = NULL;
 
-static SyncData* id2data(id object)
+enum usage { ACQUIRE, RELEASE, CHECK };
+
+static SyncData* id2data(id object, enum usage why)
 {
     SyncData* result = NULL;
     int err;
@@ -106,7 +107,11 @@ static SyncData* id2data(id object)
             firstUnused = p;
     }
     
-    // if no corresponding SyncData found, but an unused one was found, use it
+    // no SyncData currently associated with object
+    if ( (why == RELEASE) || (why == CHECK) )
+       goto done;
+    
+    // an unused one was found, use it
     if ( firstUnused != NULL ) {
         result = firstUnused;
         result->object = object;
@@ -129,6 +134,21 @@ static SyncData* id2data(id object)
     sDataList = result;
     
 done:
+    if ( result != NULL ) {
+        switch ( why ) {
+            case ACQUIRE:
+                result->lockCount++;
+                break;
+            case RELEASE:
+                result->lockCount--;
+                if ( result->lockCount == 0 )
+                    result->object = NULL;  // now recycled
+                break;
+            case CHECK:
+                // do nothing
+                break;
+        }
+    }
     pthread_mutex_unlock(&sTableLock);
     return result;
 }
@@ -142,14 +162,12 @@ int objc_sync_enter(id obj)
 {
     int result = OBJC_SYNC_SUCCESS;
     
-    SyncData* data = id2data(obj);
+    SyncData* data = id2data(obj, ACQUIRE);
     require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_INITIALIZED, "id2data failed");
        
     result = pthread_mutex_lock(&data->mutex);
     require_noerr_string(result, done, "pthread_mutex_lock failed");
-       
-    data->lockCount++; // note: lockCount is only modified when corresponding mutex is held
-       
+               
 done: 
     return result;
 }
@@ -161,15 +179,8 @@ int objc_sync_exit(id obj)
 {
     int result = OBJC_SYNC_SUCCESS;
     
-    SyncData* data;
-    data = id2data(obj); // XXX should assert that we didn't create it
-    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_INITIALIZED, "id2data failed");
-
-    int oldLockCount = data->lockCount--;
-    if ( oldLockCount == 1 ) {
-        // XXX should move off the main chain to speed id2data searches
-        data->object = NULL;   // recycle data
-    }
+    SyncData* data = id2data(obj, RELEASE); 
+    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_OWNING_THREAD_ERROR, "id2data failed");
     
     result = pthread_mutex_unlock(&data->mutex);
     require_noerr_string(result, done, "pthread_mutex_unlock failed");
@@ -188,8 +199,8 @@ int objc_sync_wait(id obj, long long milliSecondsMaxWait)
 {
     int result = OBJC_SYNC_SUCCESS;
             
-    SyncData* data = id2data(obj);
-    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_INITIALIZED, "id2data failed");
+    SyncData* data = id2data(obj, CHECK);
+    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_OWNING_THREAD_ERROR, "id2data failed");
     
     
     // XXX need to retry cond_wait under out-of-our-control failures
@@ -223,8 +234,8 @@ int objc_sync_notify(id obj)
 {
     int result = OBJC_SYNC_SUCCESS;
         
-    SyncData* data = id2data(obj);
-    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_INITIALIZED, "id2data failed");
+    SyncData* data = id2data(obj, CHECK);
+    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_OWNING_THREAD_ERROR, "id2data failed");
 
     result = pthread_cond_signal(&data->conditionVariable);
     require_noerr_string(result, done, "pthread_cond_signal failed");
@@ -243,8 +254,8 @@ int objc_sync_notifyAll(id obj)
 {
     int result = OBJC_SYNC_SUCCESS;
         
-    SyncData* data = id2data(obj);
-    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_INITIALIZED, "id2data failed");
+    SyncData* data = id2data(obj, CHECK);
+    require_action_string(data != NULL, done, result = OBJC_SYNC_NOT_OWNING_THREAD_ERROR, "id2data failed");
 
     result = pthread_cond_broadcast(&data->conditionVariable);
     require_noerr_string(result, done, "pthread_cond_broadcast failed");