mirror of
https://github.com/darlinghq/darling-libobjc2.git
synced 2025-03-03 06:06:05 +00:00
Add visibility attributes on all internal functions so that we aren't ever exporting them outside of libobjc.
This commit is contained in:
parent
c2f572f9a1
commit
6c7cf4a5a6
@ -1,3 +1,4 @@
|
||||
#include "visibility.h"
|
||||
#include "objc/runtime.h"
|
||||
#include "module.h"
|
||||
#include <assert.h>
|
||||
@ -49,7 +50,7 @@ static int known_abi_count =
|
||||
}\
|
||||
} 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;
|
||||
for (int i=0 ; i<known_abi_count ; i++)
|
||||
|
@ -23,6 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "visibility.h"
|
||||
#include "objc/runtime.h"
|
||||
#include "class.h"
|
||||
#include "lock.h"
|
||||
@ -61,7 +62,7 @@ static alias_table_internal_table *alias_table;
|
||||
#include "pool.h"
|
||||
|
||||
|
||||
void __objc_init_alias_table(void)
|
||||
PRIVATE void __objc_init_alias_table(void)
|
||||
{
|
||||
alias_table = alias_table_internal_create(128);
|
||||
}
|
||||
@ -90,7 +91,7 @@ Class alias_getClass(const char *alias_name)
|
||||
return alias->class;
|
||||
}
|
||||
|
||||
void alias_table_insert(Alias alias)
|
||||
PRIVATE void alias_table_insert(Alias alias)
|
||||
{
|
||||
alias_table_internal_insert(alias_table, alias);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include "objc/runtime.h"
|
||||
#include "visibility.h"
|
||||
#include "loader.h"
|
||||
|
||||
#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
|
||||
* 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))
|
||||
{
|
||||
@ -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;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "lock.h"
|
||||
#include "ivar.h"
|
||||
#include "dtable.h"
|
||||
#include "visibility.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@ -36,13 +37,13 @@ static load_messages_table *load_table;
|
||||
|
||||
SEL loadSel;
|
||||
|
||||
void objc_init_load_messages_table(void)
|
||||
PRIVATE void objc_init_load_messages_table(void)
|
||||
{
|
||||
load_table = load_messages_create(4096);
|
||||
loadSel = sel_registerName("load");
|
||||
}
|
||||
|
||||
void objc_send_load_message(Class class)
|
||||
PRIVATE void objc_send_load_message(Class class)
|
||||
{
|
||||
Class meta = class->isa;
|
||||
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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void class_table_insert(Class class)
|
||||
PRIVATE void class_table_insert(Class class)
|
||||
{
|
||||
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 class_table_get_safe(const char *class_name)
|
||||
PRIVATE Class class_table_get_safe(const char *class_name)
|
||||
{
|
||||
if (NULL == class_name) { return Nil; }
|
||||
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,
|
||||
(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);
|
||||
objc_init_load_messages_table();
|
||||
@ -141,7 +142,7 @@ void __objc_init_class_tables(void)
|
||||
// Loader functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL objc_resolve_class(Class cls)
|
||||
PRIVATE BOOL objc_resolve_class(Class cls)
|
||||
{
|
||||
// Skip this if the class is already resolved.
|
||||
if (objc_test_class_flag(cls, objc_class_flag_resolved)) { return YES; }
|
||||
@ -245,7 +246,7 @@ BOOL objc_resolve_class(Class cls)
|
||||
return YES;
|
||||
}
|
||||
|
||||
void objc_resolve_class_links(void)
|
||||
PRIVATE void objc_resolve_class_links(void)
|
||||
{
|
||||
LOCK_UNTIL_RETURN(__objc_runtime_mutex);
|
||||
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.
|
||||
*/
|
||||
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);
|
||||
if (Nil != existingClass)
|
||||
|
31
dtable.c
31
dtable.c
@ -8,12 +8,13 @@
|
||||
#include "method_list.h"
|
||||
#include "slot_pool.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. */
|
||||
InitializingDtable *temporary_dtables;
|
||||
mutex_t initialize_lock;
|
||||
PRIVATE InitializingDtable *temporary_dtables;
|
||||
PRIVATE mutex_t initialize_lock;
|
||||
static uint32_t dtable_depth = 8;
|
||||
|
||||
|
||||
@ -55,14 +56,14 @@ struct objc_dtable
|
||||
mutex_t lock;
|
||||
};
|
||||
|
||||
void __objc_init_dispatch_tables ()
|
||||
PRIVATE void __objc_init_dispatch_tables ()
|
||||
{
|
||||
INIT_LOCK(initialize_lock);
|
||||
}
|
||||
|
||||
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;
|
||||
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; }
|
||||
dtable_depth <<= 1;
|
||||
@ -223,7 +224,7 @@ static void update_dtable(dtable_t dtable)
|
||||
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);
|
||||
// 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; }
|
||||
|
||||
@ -273,7 +274,7 @@ struct objc_slot* objc_dtable_lookup(dtable_t dtable, uint32_t uid)
|
||||
}
|
||||
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->cls = cls;
|
||||
@ -284,7 +285,7 @@ dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
|
||||
#else
|
||||
|
||||
|
||||
void __objc_init_dispatch_tables ()
|
||||
PRIVATE void __objc_init_dispatch_tables ()
|
||||
{
|
||||
INIT_LOCK(initialize_lock);
|
||||
__objc_uninstalled_dtable = SparseArrayNewWithDepth(dtable_depth);
|
||||
@ -393,7 +394,7 @@ static void mergeMethodsFromSuperclass(Class super, Class cls, SparseArray *meth
|
||||
|
||||
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
|
||||
if (!classHasDtable(cls)) { return; }
|
||||
@ -409,7 +410,7 @@ void objc_update_dtable_for_class(Class cls)
|
||||
mergeMethodsFromSuperclass(cls, cls, 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;
|
||||
if (!warned)
|
||||
@ -472,7 +473,7 @@ static SparseArray *create_dtable_for_class(Class class)
|
||||
|
||||
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 (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);
|
||||
}
|
||||
@ -510,7 +511,7 @@ void objc_resolve_class(Class);
|
||||
/**
|
||||
* 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;
|
||||
// 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.
|
||||
*/
|
||||
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 objc_exception_class = EXCEPTION_CLASS('G','N','U','C','O','B','J','C');
|
||||
static const uint64_t cxx_exception_class = EXCEPTION_CLASS('G','N','U','C','C','+','+','\0');
|
||||
|
||||
/**
|
||||
* Structure used as a header on thrown exceptions.
|
||||
@ -96,9 +96,9 @@ void objc_exception_throw(id object)
|
||||
abort();
|
||||
}
|
||||
|
||||
Class get_type_table_entry(struct _Unwind_Context *context,
|
||||
struct dwarf_eh_lsda *lsda,
|
||||
int filter)
|
||||
static Class get_type_table_entry(struct _Unwind_Context *context,
|
||||
struct dwarf_eh_lsda *lsda,
|
||||
int filter)
|
||||
{
|
||||
dw_eh_ptr_t record = lsda->type_table -
|
||||
dwarf_size_of_fixed_size_field(lsda->type_table_encoding)*filter;
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include "objc/toydispatch.h"
|
||||
#include "lock.h"
|
||||
#include "visibility.h"
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
3
ivar.c
3
ivar.c
@ -3,11 +3,12 @@
|
||||
#include "objc/runtime.h"
|
||||
#include "class.h"
|
||||
#include "ivar.h"
|
||||
#include "visibility.h"
|
||||
|
||||
ptrdiff_t objc_alignof_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;
|
||||
/* If this class was compiled with support for late-bound ivars, the
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "properties.h"
|
||||
#include "class.h"
|
||||
#include "lock.h"
|
||||
#include "visibility.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BUFFER_TYPE struct objc_protocol_list
|
||||
@ -191,7 +192,7 @@ static BOOL init_protocols(struct objc_protocol_list *protocols)
|
||||
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))
|
||||
{
|
||||
|
15
sarray2.c
15
sarray2.c
@ -4,6 +4,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "sarray2.h"
|
||||
#include "visibility.h"
|
||||
|
||||
static void *EmptyArrayData[256];
|
||||
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));
|
||||
sarray->refCount = 1;
|
||||
@ -37,11 +38,11 @@ SparseArray * SparseArrayNewWithDepth(uint32_t depth)
|
||||
return sarray;
|
||||
}
|
||||
|
||||
SparseArray *SparseArrayNew()
|
||||
PRIVATE SparseArray *SparseArrayNew()
|
||||
{
|
||||
return SparseArrayNewWithDepth(32);
|
||||
}
|
||||
SparseArray *SparseArrayExpandingArray(SparseArray *sarray)
|
||||
PRIVATE SparseArray *SparseArrayExpandingArray(SparseArray *sarray)
|
||||
{
|
||||
// Expanding a child sarray has undefined results.
|
||||
assert(sarray->refCount == 1);
|
||||
@ -113,13 +114,13 @@ static void *SparseArrayFind(SparseArray * sarray, uint32_t * index)
|
||||
return SARRAY_EMPTY;
|
||||
}
|
||||
|
||||
void *SparseArrayNext(SparseArray * sarray, uint32_t * idx)
|
||||
PRIVATE void *SparseArrayNext(SparseArray * sarray, uint32_t * idx)
|
||||
{
|
||||
(*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)
|
||||
{
|
||||
@ -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));
|
||||
copy->refCount = 1;
|
||||
@ -180,7 +181,7 @@ SparseArray *SparseArrayCopy(SparseArray * sarray)
|
||||
return copy;
|
||||
}
|
||||
|
||||
void SparseArrayDestroy(SparseArray * sarray)
|
||||
PRIVATE void SparseArrayDestroy(SparseArray * sarray)
|
||||
{
|
||||
// Don't really delete this sarray if its ref count is > 0
|
||||
if (sarray == &EmptyArray ||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "method_list.h"
|
||||
#include "class.h"
|
||||
#include "selector.h"
|
||||
#include "visibility.h"
|
||||
|
||||
#ifdef TYPE_DEPENDENT_DISPATCH
|
||||
# define TDD(x) x
|
||||
@ -219,7 +220,7 @@ void objc_resize_dtables(uint32_t);
|
||||
/**
|
||||
* Create data structures to store selectors.
|
||||
*/
|
||||
void __objc_init_selector_tables()
|
||||
PRIVATE void __objc_init_selector_tables()
|
||||
{
|
||||
selector_list = SparseArrayNew();
|
||||
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.
|
||||
*/
|
||||
SEL objc_register_selector(SEL aSel)
|
||||
PRIVATE SEL objc_register_selector(SEL aSel)
|
||||
{
|
||||
if (isSelRegistered(aSel))
|
||||
{
|
||||
@ -479,7 +480,7 @@ unsigned sel_copyTypedSelectors_np(const char *selName, SEL *const sels, unsigne
|
||||
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++)
|
||||
{
|
||||
@ -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.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
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
|
||||
// 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
|
||||
* in new code.
|
||||
*/
|
||||
|
||||
#ifdef NO_LEGACY
|
||||
SEL sel_get_typed_uid (const char *name, const char *types)
|
||||
{
|
||||
if (NULL == name) { return NULL; }
|
||||
@ -590,6 +591,8 @@ BOOL sel_eq(SEL s1, SEL s2)
|
||||
return sel_isEqual(s1, s2);
|
||||
}
|
||||
|
||||
#endif // NO_LEGACY
|
||||
|
||||
/*
|
||||
* Some simple sanity tests.
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "objc/runtime.h"
|
||||
#include "module.h"
|
||||
#include "constant_string.h"
|
||||
#include "visibility.h"
|
||||
|
||||
#define BUFFER_TYPE struct objc_static_instance_list
|
||||
#include "buffer.h"
|
||||
@ -39,7 +40,7 @@ static BOOL try_init_statics(struct objc_static_instance_list *statics)
|
||||
}
|
||||
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))
|
||||
{
|
||||
@ -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;
|
||||
|
||||
|
8
visibility.h
Normal file
8
visibility.h
Normal file
@ -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…
x
Reference in New Issue
Block a user