Move toydispatch into libobjc2.
Some build system tidies. Add -retain / release to Protocol. Initial work on clang-specific makefile.main
parent
b5f4782dbf
commit
a83428b883
@ -0,0 +1,79 @@
|
|||||||
|
.POSIX:
|
||||||
|
|
||||||
|
.SUFFIXES: .c .bc .m
|
||||||
|
|
||||||
|
VERSION = 4
|
||||||
|
|
||||||
|
#CC=clang
|
||||||
|
|
||||||
|
CFLAGS += -fPIC
|
||||||
|
CPPFLAGS += -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP
|
||||||
|
CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500
|
||||||
|
|
||||||
|
PREFIX?= /usr/local
|
||||||
|
LIB_DIR= ${PREFIX}/lib
|
||||||
|
HEADER_DIR= ${PREFIX}/include
|
||||||
|
|
||||||
|
OBJECTS = \
|
||||||
|
NSBlocks.bc\
|
||||||
|
Protocol2.bc\
|
||||||
|
abi_version.bc\
|
||||||
|
blocks_runtime.bc\
|
||||||
|
caps.bc\
|
||||||
|
category_loader.bc\
|
||||||
|
class_table.bc\
|
||||||
|
dtable.bc\
|
||||||
|
eh_personality.bc\
|
||||||
|
encoding2.bc\
|
||||||
|
hash_table.bc\
|
||||||
|
hooks.bc\
|
||||||
|
ivar.bc\
|
||||||
|
legacy_malloc.bc\
|
||||||
|
loader.bc\
|
||||||
|
mutation.bc\
|
||||||
|
properties.bc\
|
||||||
|
protocol.bc\
|
||||||
|
runtime.bc\
|
||||||
|
sarray2.bc\
|
||||||
|
selector_table.bc\
|
||||||
|
sendmsg2.bc\
|
||||||
|
statics_loader.bc\
|
||||||
|
sync.bc\
|
||||||
|
toydispatch.bc
|
||||||
|
|
||||||
|
all: libobjc.so.$(VERSION) libobjc.a
|
||||||
|
|
||||||
|
libobjc.so.$(VERSION): libobjc.o
|
||||||
|
@echo Linking shared library...
|
||||||
|
@ld -shared -o $@ libobjc.o
|
||||||
|
|
||||||
|
libobjc.a: libobjc.o
|
||||||
|
@echo Linking static library...
|
||||||
|
@ld -r -s -o $@ libobjc.o
|
||||||
|
|
||||||
|
libobjc.o: libobjc.bc
|
||||||
|
llc -O3 -filetype=obj -o libobjc.o libobjc.bc
|
||||||
|
|
||||||
|
libobjc.bc: $(OBJECTS)
|
||||||
|
@echo Linking bitcode...
|
||||||
|
pwd
|
||||||
|
llvm-ld -internalize-public-api-file=../exports.txt -link-as-library -native -o libobjc.bc $(OBJECTS)
|
||||||
|
|
||||||
|
.c.bc: obj
|
||||||
|
clang $(CPPFLAGS) $(CFLAGS) -emit-llvm -c $< -o $@
|
||||||
|
|
||||||
|
.m.bc: obj
|
||||||
|
clang $(CPPFLAGS) $(CFLAGS) -emit-llvm -c $< -o $@
|
||||||
|
|
||||||
|
obj:
|
||||||
|
mkdir obj
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -m 444 libobjc.so.$(VERSION) $(LIB_DIR)
|
||||||
|
install -m 444 libobjc.a $(LIB_DIR)
|
||||||
|
ln -sf $(LIB_DIR)/libobjc.so.$(VERSION) $(LIB_DIR)/libobjc.so
|
||||||
|
install -d $(HEADER_DIR)/objc
|
||||||
|
install -m 444 objc/*.h $(HEADER_DIR)/objc
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f obj/*
|
||||||
@ -0,0 +1,174 @@
|
|||||||
|
.objc_sel_nameautorelease
|
||||||
|
.objc_sel_namecopy
|
||||||
|
.objc_sel_namedealloc
|
||||||
|
.objc_sel_namerelease
|
||||||
|
.objc_sel_nameretain
|
||||||
|
_Block_copy
|
||||||
|
_Block_object_assign
|
||||||
|
_Block_object_dispose
|
||||||
|
_Block_release
|
||||||
|
_NSConcreteGlobalBlock
|
||||||
|
_NSConcreteStackBlock
|
||||||
|
__gnu_objc_personality_v0
|
||||||
|
__objc_class_name_Object
|
||||||
|
__objc_class_name_Protocol
|
||||||
|
__objc_class_name_Protocol2
|
||||||
|
__objc_class_name___ObjC_Protocol_Holder_Ugly_Hack
|
||||||
|
__objc_exec_class
|
||||||
|
__objc_id_typeinfo
|
||||||
|
__objc_msg_forward2
|
||||||
|
__objc_msg_forward3
|
||||||
|
__objc_responds_to
|
||||||
|
__objc_runtime_mutex
|
||||||
|
__objc_runtime_threads_alive
|
||||||
|
__objc_sync_init
|
||||||
|
__objc_uninstalled_dtable
|
||||||
|
__objc_update_dispatch_table_for_class
|
||||||
|
_objc_class_for_boxing_foreign_exception
|
||||||
|
_objc_load_callback
|
||||||
|
_objc_lookup_class
|
||||||
|
_objc_selector_type_mismatch
|
||||||
|
_objc_unexpected_exception
|
||||||
|
block_getType_np
|
||||||
|
class_addIvar
|
||||||
|
class_addMethod
|
||||||
|
class_addProtocol
|
||||||
|
class_conformsToProtocol
|
||||||
|
class_copyIvarList
|
||||||
|
class_copyMethodList
|
||||||
|
class_copyPropertyList
|
||||||
|
class_copyProtocolList
|
||||||
|
class_createInstance
|
||||||
|
class_getClassMethod
|
||||||
|
class_getClassVariable
|
||||||
|
class_getInstanceMethod
|
||||||
|
class_getInstanceSize
|
||||||
|
class_getInstanceVariable
|
||||||
|
class_getIvarLayout
|
||||||
|
class_getMethodImplementation
|
||||||
|
class_getMethodImplementation_stret
|
||||||
|
class_getName
|
||||||
|
class_getProperty
|
||||||
|
class_getSuperclass
|
||||||
|
class_getVersion
|
||||||
|
class_getWeakIvarLayout
|
||||||
|
class_isMetaClass
|
||||||
|
class_pose_as
|
||||||
|
class_replaceMethod
|
||||||
|
class_respondsToSelector
|
||||||
|
class_setIvarLayout
|
||||||
|
class_setSuperclass
|
||||||
|
class_setVersion
|
||||||
|
class_setWeakIvarLayout
|
||||||
|
class_table_get_safe
|
||||||
|
class_table_insert
|
||||||
|
class_table_internal_create
|
||||||
|
get_imp
|
||||||
|
ivar_getName
|
||||||
|
ivar_getOffset
|
||||||
|
ivar_getTypeEncoding
|
||||||
|
method_copyArgumentType
|
||||||
|
method_copyReturnType
|
||||||
|
method_exchangeImplementations
|
||||||
|
method_getArgumentType
|
||||||
|
method_getImplementation
|
||||||
|
method_getName
|
||||||
|
method_getNumberOfArguments
|
||||||
|
method_getReturnType
|
||||||
|
method_getTypeEncoding
|
||||||
|
method_get_number_of_arguments
|
||||||
|
method_setImplementation
|
||||||
|
objc_aligned_size
|
||||||
|
objc_alignof_type
|
||||||
|
objc_allocateClassPair
|
||||||
|
objc_atomic_malloc
|
||||||
|
objc_calloc
|
||||||
|
objc_check_abi_version
|
||||||
|
objc_collect_garbage_data
|
||||||
|
objc_compute_ivar_offsets
|
||||||
|
objc_copy_dtable_for_class
|
||||||
|
objc_create_block_classes_as_subclasses_of
|
||||||
|
objc_disposeClassPair
|
||||||
|
objc_enumerationMutation
|
||||||
|
objc_exception_throw
|
||||||
|
objc_free
|
||||||
|
objc_getClass
|
||||||
|
objc_getClassList
|
||||||
|
objc_getMetaClass
|
||||||
|
objc_getProperty
|
||||||
|
objc_getProtocol
|
||||||
|
objc_getRequiredClass
|
||||||
|
objc_get_class
|
||||||
|
objc_get_meta_class
|
||||||
|
objc_get_slot
|
||||||
|
objc_get_type_qualifiers
|
||||||
|
objc_init_buffered_statics
|
||||||
|
objc_init_load_messages_table
|
||||||
|
objc_init_protocols
|
||||||
|
objc_init_statics
|
||||||
|
objc_layout_structure
|
||||||
|
objc_layout_structure_get_info
|
||||||
|
objc_layout_structure_next_member
|
||||||
|
objc_load_buffered_categories
|
||||||
|
objc_load_class
|
||||||
|
objc_lookUpClass
|
||||||
|
objc_lookup_class
|
||||||
|
objc_malloc
|
||||||
|
objc_msg_lookup
|
||||||
|
objc_msg_lookup_sender
|
||||||
|
objc_msg_lookup_super
|
||||||
|
objc_msg_profile
|
||||||
|
objc_msg_sender
|
||||||
|
objc_msg_sendv
|
||||||
|
objc_next_class
|
||||||
|
objc_plane_lookup
|
||||||
|
objc_promoted_size
|
||||||
|
objc_proxy_lookup
|
||||||
|
objc_realloc
|
||||||
|
objc_registerClassPair
|
||||||
|
objc_setProperty
|
||||||
|
objc_sizeof_type
|
||||||
|
objc_skip_argspec
|
||||||
|
objc_skip_type_qualifiers
|
||||||
|
objc_skip_typespec
|
||||||
|
objc_slot_lookup_super
|
||||||
|
objc_sync_enter
|
||||||
|
objc_sync_exit
|
||||||
|
objc_test_capability
|
||||||
|
objc_valloc
|
||||||
|
object_getClass
|
||||||
|
object_getClassName
|
||||||
|
object_getIndexedIvars
|
||||||
|
object_setClass
|
||||||
|
property_getName
|
||||||
|
protocol_conformsToProtocol
|
||||||
|
protocol_copyMethodDescriptionList
|
||||||
|
protocol_copyPropertyList
|
||||||
|
protocol_copyProtocolList
|
||||||
|
protocol_create
|
||||||
|
protocol_for_name
|
||||||
|
protocol_getMethodDescription
|
||||||
|
protocol_getName
|
||||||
|
protocol_getProperty
|
||||||
|
protocol_isEqual
|
||||||
|
sel_copyTypedSelectors_np
|
||||||
|
sel_copyTypes_np
|
||||||
|
sel_eq
|
||||||
|
sel_getName
|
||||||
|
sel_getType_np
|
||||||
|
sel_getUid
|
||||||
|
sel_get_any_typed_uid
|
||||||
|
sel_get_any_uid
|
||||||
|
sel_get_name
|
||||||
|
sel_get_type
|
||||||
|
sel_get_typed_uid
|
||||||
|
sel_get_uid
|
||||||
|
sel_isEqual
|
||||||
|
sel_is_mapped
|
||||||
|
sel_registerName
|
||||||
|
sel_registerTypedName_np
|
||||||
|
sel_register_name
|
||||||
|
sel_register_typed_name
|
||||||
|
selector_create
|
||||||
|
toy_dispatch_async_f
|
||||||
|
toy_dispatch_queue_create
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define __TOY_DISPATCH__
|
#define __TOY_DISPATCH__
|
||||||
#include "toydispatch.h"
|
#include "objc/toydispatch.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of total space in the ring buffer. Must be a power of two.
|
* Amount of total space in the ring buffer. Must be a power of two.
|
||||||
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* toydispatch implements a (tiny) subset of the libdispatch interfaces. It
|
|
||||||
* can produce FIFO work queues, but not concurrent ones (although queues are
|
|
||||||
* concurrent with respect to each other, as with libdispatch). Unlike
|
|
||||||
* libdispatch, queues all run on the same system thread. This is less
|
|
||||||
* efficient, so the real libdispatch should be used on platforms where it is
|
|
||||||
* available.
|
|
||||||
*
|
|
||||||
* Toydispatch symbol names are prefixed with toy_ so programs can be linked to
|
|
||||||
* both libdispatch and toydispatch.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* If the real libdispatch exists, use that instead of the toy one. */
|
|
||||||
#if !defined(__has_include)
|
|
||||||
#define __has_include(x) 0
|
|
||||||
#endif
|
|
||||||
#if __has_include(<dispatch/dispatch.h>) && !defined(__TOY_DISPATCH__)
|
|
||||||
# include <dispatch/dispatch.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function type for functions that can be added to dispatch queues.
|
|
||||||
*/
|
|
||||||
typedef void (*dispatch_function_t)(void *);
|
|
||||||
|
|
||||||
typedef struct dispatch_queue * dispatch_queue_t;
|
|
||||||
|
|
||||||
#define dispatch_queue_create toy_dispatch_queue_create
|
|
||||||
/**
|
|
||||||
* Create a new queue. Both parameters are ignored by toydispatch.
|
|
||||||
*/
|
|
||||||
dispatch_queue_t dispatch_queue_create(const char *label,
|
|
||||||
void *attr);
|
|
||||||
|
|
||||||
#define dispatch_async_f toy_dispatch_async_f
|
|
||||||
/**
|
|
||||||
* Add a function to the queue.
|
|
||||||
*/
|
|
||||||
void dispatch_async_f(dispatch_queue_t queue, void *context,
|
|
||||||
dispatch_function_t work);
|
|
||||||
|
|
||||||
#define dispatch_release toy_dispatch_release
|
|
||||||
void dispatch_release(dispatch_queue_t queue);
|
|
||||||
|
|
||||||
#define dispatch_retain toy_dispatch_retain
|
|
||||||
void dispatch_retain(dispatch_queue_t queue);
|
|
||||||
#endif
|
|
||||||
Loading…
Reference in New Issue