Annotation of objc/objc-private.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.0 (the 'License').  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License."
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: /*
                     25:  *     objc-private.h
                     26:  *     Copyright 1988, NeXT, Inc.
                     27:  */
                     28: 
                     29: #ifndef _OBJC_PRIVATE_H_
                     30: #define _OBJC_PRIVATE_H_
                     31: 
                     32: #import "objc-config.h"
                     33: 
                     34: #ifdef KERNEL
                     35: #import        <mach/mach_types.h>
                     36: #import        <mach/machine/simple_lock.h>
                     37: 
                     38: #define        mutex_alloc()   simple_lock_alloc()
                     39: #define        mutex_init(x)   simple_lock_init(x)
                     40: #define        mutex_lock(x)   simple_lock(x)
                     41: #define        mutex_try_lock(x)       simple_lock_try(x)
                     42: #define        mutex_unlock(x) simple_unlock(x)
                     43: #define        mutex_clear(x)
                     44: #define mutex          slock
                     45: #define        mutex_t         simple_lock_t
                     46: #else /* KERNEL */
                     47: #import <mach/cthreads.h>
                     48: #endif /* KERNEL */
                     49: 
                     50: #import <stdlib.h>
                     51: #import <stdarg.h>
                     52: #import <stdio.h>
                     53: #import <string.h>
                     54: #import <ctype.h>
                     55: 
                     56: #import "objc.h"
                     57: #import "objc-runtime.h"
                     58: #import "hashtable.h"
                     59: 
                     60: #import <sys/time.h>
                     61: 
                     62: struct header_info
                     63: {
                     64:   const struct mach_header *mhdr;
                     65:   Module mod_ptr;
                     66:   unsigned int mod_count;
                     67:   void *frozenTable;
                     68:   unsigned long image_slide;
                     69:   unsigned int objcSize;
                     70: };
                     71: extern struct header_info *_objc_headerVector (const struct mach_header * const *machhdrs);
                     72: extern unsigned int _objc_headerCount (void);
                     73: extern void _objc_addHeader (const struct mach_header *header, long vmaddr_slide);
                     74: extern void _objc_removeHeader (const struct mach_header *header);
                     75: extern SEL __S(_sel_registerName)(const char *str);
                     76: 
                     77: /* utilities */
                     78: static inline unsigned int _objc_strhash (const unsigned char *s)
                     79: {
                     80:   unsigned int hash = 0;
                     81: 
                     82:   /* Unroll the loop. */
                     83:   while (1)
                     84:     { 
                     85:       if (*s == '\0') 
                     86:        break;
                     87:       hash ^= *s++;
                     88:       if (*s == '\0') 
                     89:        break;
                     90:       hash ^= *s++ << 8;
                     91:       if (*s == '\0') 
                     92:        break;
                     93:       hash ^= *s++ << 16;
                     94:       if (*s == '\0') 
                     95:        break;
                     96:       hash ^= *s++ << 24;
                     97:     }
                     98:   
                     99:   return hash;
                    100: }
                    101: 
                    102: extern const char *__S(_nameForHeader) (const struct mach_header *);
                    103: 
                    104: /* debug */
                    105: extern int gettime(void);
                    106: extern void print_time(const char *, int, struct timeval *);
                    107: 
                    108: /* initialize */
                    109: extern void __S(_sel_init) (const struct mach_header *,
                    110:                       const char *, unsigned int, void *);
                    111: extern void __S(_sel_unloadSelectors)(const char *, const char *);
                    112: extern void _class_install_relationships(Class, long);
                    113: extern void _objc_add_category(Category, int);
                    114: extern void _objc_remove_category(Category, int);
                    115: extern void _class_removeProtocols(Class, struct objc_protocol_list *);
                    116: extern NXZone *_objc_create_zone(void);
                    117: extern void _objc_removeClass(Class);
                    118: 
                    119: /* method lookup */
                    120: extern BOOL class_respondsToMethod(Class, SEL);
                    121: extern IMP class_lookupMethod(Class, SEL);
                    122: extern IMP class_lookupMethodInMethodList(struct objc_method_list *mlist, 
                    123:                                           SEL sel);
                    124: 
                    125: /* message dispatcher */
                    126: extern Cache _cache_create(Class);
                    127: extern IMP _class_lookupMethodAndLoadCache(Class, SEL);
                    128: extern id _objc_msgForward (id self, SEL sel, ...);
                    129: 
                    130: /* errors */
                    131: volatile void __S(_objc_fatal)(const char *message);
                    132: extern volatile void _objc_error(id, const char *, va_list);
                    133: extern volatile void __objc_error(id, const char *, ...);
                    134: extern void _objc_inform(const char *fmt, ...);
                    135: extern void _NXLogError(const char *format, ...);
                    136: 
                    137: /* magic */
                    138: extern Class _objc_getFreedObjectClass (void);
                    139: extern Class _objc_getNonExistentClass (void);
                    140: extern const struct objc_cache emptyCache;
                    141: extern void _objc_flush_caches (Class cls);
                    142: 
                    143: /* locking */
                    144: extern int _objc_multithread_mask;
                    145: extern struct mutex classLock;
                    146: extern struct mutex messageLock;
                    147: 
                    148: #ifdef KERNEL
                    149: #ifdef hppa  /* The sense of kernel locks on the hp are backwards! */
                    150: #define OBJC_DECLARE_LOCK(MUTEX) struct slock MUTEX = { -1,-1,-1,-1 }
                    151: #elif defined(ppc)
                    152: #define OBJC_DECLARE_LOCK(MUTEX) struct slock MUTEX = { 0, 0, 0, 0 }
                    153: #else
                    154: #define OBJC_DECLARE_LOCK(MUTEX) struct slock MUTEX = { 0 }
                    155: #endif hppa
                    156: #define OBJC_LOCK(MUTEX)
                    157: #define OBJC_UNLOCK(MUTEX)
                    158: #define OBJC_TRYLOCK(MUTEX)    1
                    159: 
                    160: #else /* KERNEL */
                    161: 
                    162: #define OBJC_DECLARE_LOCK(MUTEX) struct mutex MUTEX = { 0, #MUTEX }
                    163: 
                    164: #ifdef FREEZE
                    165: #define OBJC_LOCK(MUTEX)
                    166: #define OBJC_UNLOCK(MUTEX)
                    167: #else /* FREEZE */
                    168: #ifdef OBJC_COLLECTING_CACHE
                    169: #define OBJC_LOCK(MUTEX)       mutex_lock (MUTEX)
                    170: #define OBJC_UNLOCK(MUTEX)     mutex_unlock (MUTEX)
                    171: #define OBJC_TRYLOCK(MUTEX)    mutex_try_lock (MUTEX)
                    172: #else
                    173: #define OBJC_LOCK(MUTEX)               \
                    174:   do                                   \
                    175:     {                                  \
                    176:       if (!_objc_multithread_mask)     \
                    177:        mutex_lock (MUTEX);             \
                    178:     }                                  \
                    179:   while (0)
                    180: 
                    181: #define OBJC_UNLOCK(MUTEX)             \
                    182:   do                                   \
                    183:     {                                  \
                    184:       if (!_objc_multithread_mask)     \
                    185:        mutex_unlock (MUTEX);           \
                    186:     }                                  \
                    187:   while (0)
                    188: 
                    189: #endif /* OBJC_COLLECTING_CACHE */
                    190: #endif /* FREEZE */
                    191: #endif /* KERNEL */
                    192: 
                    193: #endif /* _OBJC_PRIVATE_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.