Add visibility attributes on all internal functions so that we aren't ever exporting them outside of libobjc.

main
theraven 15 years ago
parent c2f572f9a1
commit 6c7cf4a5a6

@ -1,3 +1,4 @@
#include "visibility.h"
#include "objc/runtime.h" #include "objc/runtime.h"
#include "module.h" #include "module.h"
#include <assert.h> #include <assert.h>
@ -49,7 +50,7 @@ static int known_abi_count =
}\ }\
} while(0) } while(0)
BOOL objc_check_abi_version(unsigned long version, unsigned long module_size) PRIVATE BOOL objc_check_abi_version(unsigned long version, unsigned long module_size)
{ {
struct objc_abi_version *v = NULL; struct objc_abi_version *v = NULL;
for (int i=0 ; i<known_abi_count ; i++) for (int i=0 ; i<known_abi_count ; i++)

@ -23,6 +23,7 @@
THE SOFTWARE. THE SOFTWARE.
*/ */
#include "visibility.h"
#include "objc/runtime.h" #include "objc/runtime.h"
#include "class.h" #include "class.h"
#include "lock.h" #include "lock.h"
@ -61,7 +62,7 @@ static alias_table_internal_table *alias_table;
#include "pool.h" #include "pool.h"
void __objc_init_alias_table(void) PRIVATE void __objc_init_alias_table(void)
{ {
alias_table = alias_table_internal_create(128); alias_table = alias_table_internal_create(128);
} }
@ -90,7 +91,7 @@ Class alias_getClass(const char *alias_name)
return alias->class; return alias->class;
} }
void alias_table_insert(Alias alias) PRIVATE void alias_table_insert(Alias alias)
{ {
alias_table_internal_insert(alias_table, alias); alias_table_internal_insert(alias_table, alias);
} }

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include "objc/runtime.h" #include "objc/runtime.h"
#include "visibility.h"
#include "loader.h" #include "loader.h"
#define BUFFER_TYPE struct objc_category #define BUFFER_TYPE struct objc_category
@ -53,7 +54,7 @@ static BOOL try_load_category(struct objc_category *cat)
* Attaches a category to its class, if the class is already loaded. Buffers * Attaches a category to its class, if the class is already loaded. Buffers
* it for future resolution if not. * it for future resolution if not.
*/ */
void objc_try_load_category(struct objc_category *cat) PRIVATE void objc_try_load_category(struct objc_category *cat)
{ {
if (!try_load_category(cat)) if (!try_load_category(cat))
{ {
@ -61,7 +62,7 @@ void objc_try_load_category(struct objc_category *cat)
} }
} }
void objc_load_buffered_categories(void) PRIVATE void objc_load_buffered_categories(void)
{ {
BOOL shouldReshuffle = NO; BOOL shouldReshuffle = NO;

@ -8,6 +8,7 @@
#include "lock.h" #include "lock.h"
#include "ivar.h" #include "ivar.h"
#include "dtable.h" #include "dtable.h"
#include "visibility.h"
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -36,13 +37,13 @@ static load_messages_table *load_table;
SEL loadSel; SEL loadSel;
void objc_init_load_messages_table(void) PRIVATE void objc_init_load_messages_table(void)
{ {
load_table = load_messages_create(4096); load_table = load_messages_create(4096);
loadSel = sel_registerName("load"); loadSel = sel_registerName("load");
} }
void objc_send_load_message(Class class) PRIVATE void objc_send_load_message(Class class)
{ {
Class meta = class->isa; Class meta = class->isa;
for (struct objc_method_list *l=meta->methods ; NULL!=l ; l=l->next) for (struct objc_method_list *l=meta->methods ; NULL!=l ; l=l->next)
@ -105,7 +106,7 @@ void objc_setDeveloperMode_np(enum objc_developer_mode_np newMode)
// Class table manipulation // Class table manipulation
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void class_table_insert(Class class) PRIVATE void class_table_insert(Class class)
{ {
if (!objc_test_class_flag(class, objc_class_flag_resolved)) if (!objc_test_class_flag(class, objc_class_flag_resolved))
{ {
@ -119,19 +120,19 @@ void class_table_insert(Class class)
class_table_internal_insert(class_table, class); class_table_internal_insert(class_table, class);
} }
Class class_table_get_safe(const char *class_name) PRIVATE Class class_table_get_safe(const char *class_name)
{ {
if (NULL == class_name) { return Nil; } if (NULL == class_name) { return Nil; }
return class_table_internal_table_get(class_table, class_name); return class_table_internal_table_get(class_table, class_name);
} }
Class class_table_next(void **e) PRIVATE Class class_table_next(void **e)
{ {
return class_table_internal_next(class_table, return class_table_internal_next(class_table,
(struct class_table_internal_table_enumerator**)e); (struct class_table_internal_table_enumerator**)e);
} }
void __objc_init_class_tables(void) PRIVATE void __objc_init_class_tables(void)
{ {
class_table = class_table_internal_create(4096); class_table = class_table_internal_create(4096);
objc_init_load_messages_table(); objc_init_load_messages_table();
@ -141,7 +142,7 @@ void __objc_init_class_tables(void)
// Loader functions // Loader functions
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
BOOL objc_resolve_class(Class cls) PRIVATE BOOL objc_resolve_class(Class cls)
{ {
// Skip this if the class is already resolved. // Skip this if the class is already resolved.
if (objc_test_class_flag(cls, objc_class_flag_resolved)) { return YES; } if (objc_test_class_flag(cls, objc_class_flag_resolved)) { return YES; }
@ -245,7 +246,7 @@ BOOL objc_resolve_class(Class cls)
return YES; return YES;
} }
void objc_resolve_class_links(void) PRIVATE void objc_resolve_class_links(void)
{ {
LOCK_UNTIL_RETURN(__objc_runtime_mutex); LOCK_UNTIL_RETURN(__objc_runtime_mutex);
Class class = unresolved_class_list; Class class = unresolved_class_list;
@ -365,7 +366,7 @@ static void reload_class(struct objc_class *class, struct objc_class *old)
/** /**
* Loads a class. This function assumes that the runtime mutex is locked. * Loads a class. This function assumes that the runtime mutex is locked.
*/ */
void objc_load_class(struct objc_class *class) PRIVATE void objc_load_class(struct objc_class *class)
{ {
struct objc_class *existingClass = class_table_get_safe(class->name); struct objc_class *existingClass = class_table_get_safe(class->name);
if (Nil != existingClass) if (Nil != existingClass)

@ -8,12 +8,13 @@
#include "method_list.h" #include "method_list.h"
#include "slot_pool.h" #include "slot_pool.h"
#include "dtable.h" #include "dtable.h"
#include "visibility.h"
dtable_t __objc_uninstalled_dtable; PRIVATE dtable_t __objc_uninstalled_dtable;
/** Head of the list of temporary dtables. Protected by initialize_lock. */ /** Head of the list of temporary dtables. Protected by initialize_lock. */
InitializingDtable *temporary_dtables; PRIVATE InitializingDtable *temporary_dtables;
mutex_t initialize_lock; PRIVATE mutex_t initialize_lock;
static uint32_t dtable_depth = 8; static uint32_t dtable_depth = 8;
@ -55,14 +56,14 @@ struct objc_dtable
mutex_t lock; mutex_t lock;
}; };
void __objc_init_dispatch_tables () PRIVATE void __objc_init_dispatch_tables ()
{ {
INIT_LOCK(initialize_lock); INIT_LOCK(initialize_lock);
} }
Class class_getSuperclass(Class); Class class_getSuperclass(Class);
void __objc_update_dispatch_table_for_class(Class cls) PRIVATE void __objc_update_dispatch_table_for_class(Class cls)
{ {
static BOOL warned = NO; static BOOL warned = NO;
if (!warned) if (!warned)
@ -95,7 +96,7 @@ static dtable_t create_dtable_for_class(Class class)
} }
void objc_resize_dtables(uint32_t newSize) PRIVATE void objc_resize_dtables(uint32_t newSize)
{ {
if (1<<dtable_depth > newSize) { return; } if (1<<dtable_depth > newSize) { return; }
dtable_depth <<= 1; dtable_depth <<= 1;
@ -223,7 +224,7 @@ static void update_dtable(dtable_t dtable)
SparseArrayDestroy(methods); SparseArrayDestroy(methods);
} }
void objc_update_dtable_for_class(Class cls) PRIVATE void objc_update_dtable_for_class(Class cls)
{ {
dtable_t dtable = dtable_for_class(cls); dtable_t dtable = dtable_for_class(cls);
// Be lazy about constructing the slot list - don't do it unless we actually // Be lazy about constructing the slot list - don't do it unless we actually
@ -236,7 +237,7 @@ void objc_update_dtable_for_class(Class cls)
} }
struct objc_slot* objc_dtable_lookup(dtable_t dtable, uint32_t uid) PRIVATE struct objc_slot* objc_dtable_lookup(dtable_t dtable, uint32_t uid)
{ {
if (NULL == dtable) { return NULL; } if (NULL == dtable) { return NULL; }
@ -273,7 +274,7 @@ struct objc_slot* objc_dtable_lookup(dtable_t dtable, uint32_t uid)
} }
return NULL; return NULL;
} }
dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls) PRIVATE dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
{ {
dtable_t dtable = calloc(1, sizeof(struct objc_dtable)); dtable_t dtable = calloc(1, sizeof(struct objc_dtable));
dtable->cls = cls; dtable->cls = cls;
@ -284,7 +285,7 @@ dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
#else #else
void __objc_init_dispatch_tables () PRIVATE void __objc_init_dispatch_tables ()
{ {
INIT_LOCK(initialize_lock); INIT_LOCK(initialize_lock);
__objc_uninstalled_dtable = SparseArrayNewWithDepth(dtable_depth); __objc_uninstalled_dtable = SparseArrayNewWithDepth(dtable_depth);
@ -393,7 +394,7 @@ static void mergeMethodsFromSuperclass(Class super, Class cls, SparseArray *meth
Class class_getSuperclass(Class); Class class_getSuperclass(Class);
void objc_update_dtable_for_class(Class cls) PRIVATE void objc_update_dtable_for_class(Class cls)
{ {
// Only update real dtables // Only update real dtables
if (!classHasDtable(cls)) { return; } if (!classHasDtable(cls)) { return; }
@ -409,7 +410,7 @@ void objc_update_dtable_for_class(Class cls)
mergeMethodsFromSuperclass(cls, cls, methods); mergeMethodsFromSuperclass(cls, cls, methods);
SparseArrayDestroy(methods); SparseArrayDestroy(methods);
} }
void __objc_update_dispatch_table_for_class(Class cls) PRIVATE void __objc_update_dispatch_table_for_class(Class cls)
{ {
static BOOL warned = NO; static BOOL warned = NO;
if (!warned) if (!warned)
@ -472,7 +473,7 @@ static SparseArray *create_dtable_for_class(Class class)
Class class_table_next(void **e); Class class_table_next(void **e);
void objc_resize_dtables(uint32_t newSize) PRIVATE void objc_resize_dtables(uint32_t newSize)
{ {
// If dtables already have enough space to store all registered selectors, do nothing // If dtables already have enough space to store all registered selectors, do nothing
if (1<<dtable_depth > newSize) { return; } if (1<<dtable_depth > newSize) { return; }
@ -498,7 +499,7 @@ void objc_resize_dtables(uint32_t newSize)
} }
} }
dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls) PRIVATE dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
{ {
return SparseArrayCopy(old); return SparseArrayCopy(old);
} }
@ -510,7 +511,7 @@ void objc_resolve_class(Class);
/** /**
* Send a +initialize message to the receiver, if required. * Send a +initialize message to the receiver, if required.
*/ */
void objc_send_initialize(id object) PRIVATE void objc_send_initialize(id object)
{ {
Class class = object->isa; Class class = object->isa;
// If the first message is sent to an instance (weird, but possible and // If the first message is sent to an instance (weird, but possible and

@ -13,8 +13,8 @@
/** /**
* Class of exceptions to distinguish between this and other exception types. * Class of exceptions to distinguish between this and other exception types.
*/ */
const uint64_t objc_exception_class = EXCEPTION_CLASS('G','N','U','C','O','B','J','C'); static const uint64_t objc_exception_class = EXCEPTION_CLASS('G','N','U','C','O','B','J','C');
const uint64_t cxx_exception_class = EXCEPTION_CLASS('G','N','U','C','C','+','+','\0'); static const uint64_t cxx_exception_class = EXCEPTION_CLASS('G','N','U','C','C','+','+','\0');
/** /**
* Structure used as a header on thrown exceptions. * Structure used as a header on thrown exceptions.
@ -96,7 +96,7 @@ void objc_exception_throw(id object)
abort(); abort();
} }
Class get_type_table_entry(struct _Unwind_Context *context, static Class get_type_table_entry(struct _Unwind_Context *context,
struct dwarf_eh_lsda *lsda, struct dwarf_eh_lsda *lsda,
int filter) int filter)
{ {

@ -1,10 +1,11 @@
#include "objc/toydispatch.h" #include "objc/toydispatch.h"
#include "lock.h" #include "lock.h"
#include "visibility.h"
static dispatch_queue_t garbage_queue; static dispatch_queue_t garbage_queue;
void objc_collect_garbage_data(void(*cleanup)(void*), void *garbage) PRIVATE void objc_collect_garbage_data(void(*cleanup)(void*), void *garbage)
{ {
if (0 == garbage_queue) if (0 == garbage_queue)
{ {

@ -3,11 +3,12 @@
#include "objc/runtime.h" #include "objc/runtime.h"
#include "class.h" #include "class.h"
#include "ivar.h" #include "ivar.h"
#include "visibility.h"
ptrdiff_t objc_alignof_type(const char *); ptrdiff_t objc_alignof_type(const char *);
ptrdiff_t objc_sizeof_type(const char *); ptrdiff_t objc_sizeof_type(const char *);
void objc_compute_ivar_offsets(Class class) PRIVATE void objc_compute_ivar_offsets(Class class)
{ {
int i = 0; int i = 0;
/* If this class was compiled with support for late-bound ivars, the /* If this class was compiled with support for late-bound ivars, the

@ -3,6 +3,7 @@
#include "properties.h" #include "properties.h"
#include "class.h" #include "class.h"
#include "lock.h" #include "lock.h"
#include "visibility.h"
#include <stdlib.h> #include <stdlib.h>
#define BUFFER_TYPE struct objc_protocol_list #define BUFFER_TYPE struct objc_protocol_list
@ -191,7 +192,7 @@ static BOOL init_protocols(struct objc_protocol_list *protocols)
return YES; return YES;
} }
void objc_init_protocols(struct objc_protocol_list *protocols) PRIVATE void objc_init_protocols(struct objc_protocol_list *protocols)
{ {
if (!init_protocols(protocols)) if (!init_protocols(protocols))
{ {

@ -4,6 +4,7 @@
#include <assert.h> #include <assert.h>
#include "sarray2.h" #include "sarray2.h"
#include "visibility.h"
static void *EmptyArrayData[256]; static void *EmptyArrayData[256];
static SparseArray EmptyArray = { 0xff, 0, 0, (void**)&EmptyArrayData}; static SparseArray EmptyArray = { 0xff, 0, 0, (void**)&EmptyArrayData};
@ -27,7 +28,7 @@ static void init_pointers(SparseArray * sarray)
} }
} }
} }
SparseArray * SparseArrayNewWithDepth(uint32_t depth) PRIVATE SparseArray * SparseArrayNewWithDepth(uint32_t depth)
{ {
SparseArray * sarray = calloc(1, sizeof(SparseArray)); SparseArray * sarray = calloc(1, sizeof(SparseArray));
sarray->refCount = 1; sarray->refCount = 1;
@ -37,11 +38,11 @@ SparseArray * SparseArrayNewWithDepth(uint32_t depth)
return sarray; return sarray;
} }
SparseArray *SparseArrayNew() PRIVATE SparseArray *SparseArrayNew()
{ {
return SparseArrayNewWithDepth(32); return SparseArrayNewWithDepth(32);
} }
SparseArray *SparseArrayExpandingArray(SparseArray *sarray) PRIVATE SparseArray *SparseArrayExpandingArray(SparseArray *sarray)
{ {
// Expanding a child sarray has undefined results. // Expanding a child sarray has undefined results.
assert(sarray->refCount == 1); assert(sarray->refCount == 1);
@ -113,13 +114,13 @@ static void *SparseArrayFind(SparseArray * sarray, uint32_t * index)
return SARRAY_EMPTY; return SARRAY_EMPTY;
} }
void *SparseArrayNext(SparseArray * sarray, uint32_t * idx) PRIVATE void *SparseArrayNext(SparseArray * sarray, uint32_t * idx)
{ {
(*idx)++; (*idx)++;
return SparseArrayFind(sarray, idx); return SparseArrayFind(sarray, idx);
} }
void SparseArrayInsert(SparseArray * sarray, uint32_t index, void *value) PRIVATE void SparseArrayInsert(SparseArray * sarray, uint32_t index, void *value)
{ {
if (sarray->shift > 0) if (sarray->shift > 0)
{ {
@ -158,7 +159,7 @@ void SparseArrayInsert(SparseArray * sarray, uint32_t index, void *value)
} }
} }
SparseArray *SparseArrayCopy(SparseArray * sarray) PRIVATE SparseArray *SparseArrayCopy(SparseArray * sarray)
{ {
SparseArray *copy = calloc(1, sizeof(SparseArray)); SparseArray *copy = calloc(1, sizeof(SparseArray));
copy->refCount = 1; copy->refCount = 1;
@ -180,7 +181,7 @@ SparseArray *SparseArrayCopy(SparseArray * sarray)
return copy; return copy;
} }
void SparseArrayDestroy(SparseArray * sarray) PRIVATE void SparseArrayDestroy(SparseArray * sarray)
{ {
// Don't really delete this sarray if its ref count is > 0 // Don't really delete this sarray if its ref count is > 0
if (sarray == &EmptyArray || if (sarray == &EmptyArray ||

@ -14,6 +14,7 @@
#include "method_list.h" #include "method_list.h"
#include "class.h" #include "class.h"
#include "selector.h" #include "selector.h"
#include "visibility.h"
#ifdef TYPE_DEPENDENT_DISPATCH #ifdef TYPE_DEPENDENT_DISPATCH
# define TDD(x) x # define TDD(x) x
@ -219,7 +220,7 @@ void objc_resize_dtables(uint32_t);
/** /**
* Create data structures to store selectors. * Create data structures to store selectors.
*/ */
void __objc_init_selector_tables() PRIVATE void __objc_init_selector_tables()
{ {
selector_list = SparseArrayNew(); selector_list = SparseArrayNew();
INIT_LOCK(selector_table_lock); INIT_LOCK(selector_table_lock);
@ -296,7 +297,7 @@ static inline void register_selector_locked(SEL aSel)
/** /**
* Registers a selector. This assumes that the argument is never deallocated. * Registers a selector. This assumes that the argument is never deallocated.
*/ */
SEL objc_register_selector(SEL aSel) PRIVATE SEL objc_register_selector(SEL aSel)
{ {
if (isSelRegistered(aSel)) if (isSelRegistered(aSel))
{ {
@ -479,7 +480,7 @@ unsigned sel_copyTypedSelectors_np(const char *selName, SEL *const sels, unsigne
return found; return found;
} }
void objc_register_selectors_from_list(struct objc_method_list *l) PRIVATE void objc_register_selectors_from_list(struct objc_method_list *l)
{ {
for (int i=0 ; i<l->count ; i++) for (int i=0 ; i<l->count ; i++)
{ {
@ -491,14 +492,14 @@ void objc_register_selectors_from_list(struct objc_method_list *l)
/** /**
* Register all of the (unregistered) selectors that are used in a class. * Register all of the (unregistered) selectors that are used in a class.
*/ */
void objc_register_selectors_from_class(Class class) PRIVATE void objc_register_selectors_from_class(Class class)
{ {
for (struct objc_method_list *l=class->methods ; NULL!=l ; l=l->next) for (struct objc_method_list *l=class->methods ; NULL!=l ; l=l->next)
{ {
objc_register_selectors_from_list(l); objc_register_selectors_from_list(l);
} }
} }
void objc_register_selector_array(SEL selectors, unsigned long count) PRIVATE void objc_register_selector_array(SEL selectors, unsigned long count)
{ {
// GCC is broken and always sets the count to 0, so we ignore count until // GCC is broken and always sets the count to 0, so we ignore count until
// we can throw stupid and buggy compilers in the bin. // we can throw stupid and buggy compilers in the bin.
@ -515,7 +516,7 @@ void objc_register_selector_array(SEL selectors, unsigned long count)
* All of the functions in this section are deprecated and should not be used * All of the functions in this section are deprecated and should not be used
* in new code. * in new code.
*/ */
#ifdef NO_LEGACY
SEL sel_get_typed_uid (const char *name, const char *types) SEL sel_get_typed_uid (const char *name, const char *types)
{ {
if (NULL == name) { return NULL; } if (NULL == name) { return NULL; }
@ -590,6 +591,8 @@ BOOL sel_eq(SEL s1, SEL s2)
return sel_isEqual(s1, s2); return sel_isEqual(s1, s2);
} }
#endif // NO_LEGACY
/* /*
* Some simple sanity tests. * Some simple sanity tests.
*/ */

@ -3,6 +3,7 @@
#include "objc/runtime.h" #include "objc/runtime.h"
#include "module.h" #include "module.h"
#include "constant_string.h" #include "constant_string.h"
#include "visibility.h"
#define BUFFER_TYPE struct objc_static_instance_list #define BUFFER_TYPE struct objc_static_instance_list
#include "buffer.h" #include "buffer.h"
@ -39,7 +40,7 @@ static BOOL try_init_statics(struct objc_static_instance_list *statics)
} }
return YES; return YES;
} }
void objc_init_statics(struct objc_static_instance_list *statics) PRIVATE void objc_init_statics(struct objc_static_instance_list *statics)
{ {
if (!try_init_statics(statics)) if (!try_init_statics(statics))
{ {
@ -47,7 +48,7 @@ void objc_init_statics(struct objc_static_instance_list *statics)
} }
} }
void objc_init_buffered_statics(void) PRIVATE void objc_init_buffered_statics(void)
{ {
BOOL shouldReshuffle = NO; BOOL shouldReshuffle = NO;

@ -0,0 +1,8 @@
#if defined _WIN32 || defined __CYGWIN__
# define PUBLIC __attribute__((dllexport))
# define PRIVATE
#else
# define PUBLIC __attribute__ ((visibility("default")))
# define PRIVATE __attribute__ ((visibility("hidden")))
#endif
Loading…
Cancel
Save