this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add libauto, add TLS monitoring functions into libdyld, add Cocoa umbrella framework (CoreData subframework is missing entirely)

+102 -46
+4
.gitmodules
··· 116 116 path = src/external/sqlite 117 117 url = ../darling-sqlite.git 118 118 branch = darling 119 + [submodule "src/external/libauto"] 120 + path = src/external/libauto 121 + url = ../darling-libauto.git 122 + branch = darling
+4
etc/dylib.conf
··· 57 57 /usr/lib/libexpat.1.5.2.dylib=libexpat.so 58 58 /usr/lib/libsqlite3.dylib=libsqlite3.so 59 59 /usr/lib/libsqlite3.0.dylib=libsqlite3.so 60 + /usr/lib/libauto.dylib=libauto.so 60 61 61 62 [CoreFoundation.framework] 62 63 A=libCFFExtra.so 63 64 64 65 [Foundation.framework] 65 66 C=libCFFExtra.so 67 + 68 + [Cocoa.framework] 69 + A=libCocoa.so 66 70 67 71 [CFNetwork.framework] 68 72 A=libcfnetwork.so
+2
src/CMakeLists.txt
··· 124 124 add_subdirectory(csu) 125 125 add_subdirectory(external/python/2.6/Python-2.6.9) 126 126 add_subdirectory(external/expat) 127 + add_subdirectory(external/libauto) 128 + add_subdirectory(Cocoa) 127 129 128 130 if (NOT DARLING_NO_EXECUTABLES) 129 131 add_subdirectory(external/shell_cmds)
+7 -2
src/Cocoa/CMakeLists.txt
··· 10 10 SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 11 11 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 12 12 13 - add_library(Cocoa SHARED zero.c) 14 - target_link_libraries(Cocoa -lgnustep-gui CoreFoundation) 13 + add_library(Cocoa SHARED empty.c) 14 + 15 + if (FRAMEWORK_APPKIT) 16 + set(AppKit "AppKit") 17 + endif (FRAMEWORK_APPKIT) 18 + 19 + target_link_libraries(Cocoa CFFExtra ${AppKit}) 15 20 16 21 install(TARGETS Cocoa DESTINATION "${CMAKE_INSTALL_LIBDIR}/darling") 17 22
src/Cocoa/empty.c

This is a binary file and will not be displayed.

-7
src/Cocoa/visibility.h
··· 1 - #ifndef VISIBILITY_H 2 - #define VISIBILITY_H 3 - 4 - #define DARLING_VISIBLE __attribute__((visibility("default"))) 5 - 6 - #endif 7 -
-29
src/Cocoa/zero.c
··· 1 - #include "visibility.h" 2 - #include <sys/ioctl.h> 3 - #include <linux/kd.h> 4 - 5 - /* GNUstep defines these as static const, Apple actually exports them */ 6 - 7 - #ifdef __x86_64__ 8 - # define CGFloat double 9 - #else 10 - # define CGFloat float 11 - #endif 12 - 13 - struct FLPair 14 - { 15 - CGFloat a, b; 16 - }; 17 - 18 - DARLING_VISIBLE const struct FLPair NSZeroPoint = { 0, 0 }; 19 - DARLING_VISIBLE const struct FLPair NSZeroSize = { 0, 0 }; 20 - DARLING_VISIBLE const struct FLPair NSZeroRect = { 0, 0 }; 21 - 22 - DARLING_VISIBLE void NSBeep() 23 - { 24 - int ms = 5000; 25 - int freq = 440; 26 - int fd = 0; 27 - 28 - ioctl(fd, KDMKTONE, (ms<<16 | 1193180/freq)); 29 - }
+2 -1
src/libdyld/CMakeLists.txt
··· 9 9 cmake_policy(SET CMP0003 NEW) 10 10 endif(COMMAND cmake_policy) 11 11 12 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ggdb -O0") 12 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ggdb -O0 -fblocks") 13 13 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/darwin.map -Wl,-Bsymbolic-functions") 14 14 15 15 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) ··· 18 18 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/darwin) 19 19 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu) 20 20 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu/bsd) 21 + include_directories(${DARLING_TOP_DIRECTORY}/src/external/libobjc2) 21 22 22 23 set(dyld_SRCS 23 24 eh/BufReWriter.cpp
+1 -1
src/libdyld/MachOObject.cpp
··· 522 522 if (path.empty()) 523 523 { 524 524 std::stringstream ss; 525 - ss << "dyld: Library not loaded: " << dylib; 525 + ss << "dyld: Library not loaded: " << dylib << " as a dependency of " << this->path(); 526 526 throw std::runtime_error(ss.str()); 527 527 } 528 528
+50
src/libdyld/TLS.cpp
··· 22 22 #include <map> 23 23 #include <cassert> 24 24 #include <cstring> 25 + #include <objc/blocks_runtime.h> 26 + #include <vector> 25 27 #include "log.h" 26 28 #include "trace.h" 27 29 #include "mutex.h" 30 + #include "dyld_priv.h" 28 31 29 32 extern "C" { 30 33 int __darwin_pthread_key_create(long *key, void (*destructor)(void*)); ··· 37 40 static std::map<void*, Darling::ImageData*> m_images; 38 41 static std::map<pthread_key_t, Darling::ImageData*> m_imagesKey; 39 42 static Darling::Mutex m_imagesMutex; 43 + struct tlv_listener 44 + { 45 + enum dyld_tlv_states state; 46 + dyld_tlv_state_change_handler handler; 47 + }; 48 + 49 + static std::vector<tlv_listener> g_tlvListeners; 50 + static void notifyTLSListeners(enum dyld_tlv_states state, void* mem, size_t size); 40 51 41 52 // Used for a thread-local list of destructor-object pairs (DestructorLinkedListElement) 42 53 static long m_keyDestructors; 54 + static std::map<void*,size_t> g_allocatedTLS; 55 + 56 + __attribute__((weak)) void *_Block_copy(void *); 43 57 44 58 static void TLSSetupDestructors() 45 59 { ··· 114 128 115 129 void Darling::TLSTeardownThread(Darling::ThreadData data) 116 130 { 131 + Darling::MutexLock _l(&m_imagesMutex); 117 132 TRACE1((void*) data); 133 + 134 + auto it = g_allocatedTLS.find(data); 135 + if (it != g_allocatedTLS.end()) 136 + { 137 + notifyTLSListeners(dyld_tlv_state_deallocated, it->first, it->second); 138 + g_allocatedTLS.erase(it); 139 + } 140 + 118 141 delete [] data; 119 142 } 120 143 ··· 143 166 144 167 // Delete the data upon thread exit 145 168 __darwin_pthread_setspecific(key, data); 169 + g_allocatedTLS[data] = id->length; 170 + notifyTLSListeners(dyld_tlv_state_allocated, data, id->length); 146 171 147 172 LOG << "TLS data allocated at " << (void*)data << std::endl; 148 173 ··· 179 204 abort(); 180 205 } 181 206 207 + void dyld_register_tlv_state_change_handler(enum dyld_tlv_states state, dyld_tlv_state_change_handler handler) 208 + { 209 + g_tlvListeners.push_back(tlv_listener { state, Block_copy(handler) }); 210 + } 211 + 212 + void dyld_enumerate_tlv_storage(dyld_tlv_state_change_handler handler) 213 + { 214 + Darling::MutexLock _l(&m_imagesMutex); 215 + for (auto it = g_allocatedTLS.begin(); it != g_allocatedTLS.end(); it++) 216 + { 217 + const dyld_tlv_info info = { sizeof(dyld_tlv_info), it->first, it->second }; 218 + handler(dyld_tlv_state_allocated, &info); 219 + } 220 + } 221 + 222 + static void notifyTLSListeners(enum dyld_tlv_states state, void* mem, size_t size) 223 + { 224 + const dyld_tlv_info info = { sizeof(dyld_tlv_info), mem, size }; 225 + for (auto it = g_tlvListeners.begin(); it != g_tlvListeners.end(); it++) 226 + { 227 + if (it->state == state) 228 + it->handler(state, &info); 229 + } 230 + } 231 +
+7 -5
src/libdyld/darwin.map
··· 14 14 NSVersionOfRunTimeLibrary; 15 15 NSVersionOfLinkTimeLibrary; 16 16 _NSGetExecutablePath; 17 - NSCreateObjectFileImageFromFile; 18 - NSLinkModule; 19 - NSDestroyObjectFileImage; 20 - NSUnLinkModule; 21 - NSLinkEditError; 17 + NSCreateObjectFileImageFromFile; 18 + NSLinkModule; 19 + NSDestroyObjectFileImage; 20 + NSUnLinkModule; 21 + NSLinkEditError; 22 22 23 23 _dyld_image_count; 24 24 _dyld_get_image_header; ··· 42 42 _dyld_fork_child; 43 43 _tlv_bootstrap; 44 44 _tlv_atexit; 45 + dyld_register_tlv_state_change_handler; 46 + dyld_enumerate_tlv_storage; 45 47 }; 46 48
+25 -1
src/libdyld/dyld_priv.h
··· 1 1 /* 2 2 This file is part of Darling. 3 3 4 - Copyright (C) 2015 Lubos Dolezel 4 + Copyright (C) 2015-2016 Lubos Dolezel 5 5 6 6 Darling is free software: you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by ··· 20 20 #ifndef DYLD_PRIV_H 21 21 #define DYLD_PRIV_H 22 22 #include <stdint.h> 23 + #include <stddef.h> 23 24 24 25 namespace Darling { 25 26 class LoadableObject; ··· 51 52 dyld_register_image_state_change_handler(enum dyld_image_states state, bool batch, dyld_image_state_change_handler handler); 52 53 53 54 void _dyld_run_handler_for_state(Darling::LoadableObject* obj); 55 + 56 + enum dyld_tlv_states { 57 + dyld_tlv_state_allocated = 10, 58 + dyld_tlv_state_deallocated = 20 59 + }; 60 + 61 + typedef struct { 62 + size_t info_size; 63 + void * tlv_addr; 64 + size_t tlv_size; 65 + } dyld_tlv_info; 66 + 67 + #if __BLOCKS__ 68 + typedef void (^dyld_tlv_state_change_handler)(enum dyld_tlv_states state, const dyld_tlv_info *info); 69 + 70 + extern void 71 + dyld_register_tlv_state_change_handler(enum dyld_tlv_states state, dyld_tlv_state_change_handler handler); 72 + 73 + extern void 74 + dyld_enumerate_tlv_storage(dyld_tlv_state_change_handler handler); 75 + 76 + #endif 77 + 54 78 55 79 } 56 80