secure, regex and pthreads building

This commit is contained in:
Lubos Dolezel 2014-12-29 17:10:47 +01:00
parent c280ed5e43
commit 63b90ac2f8
10 changed files with 134 additions and 6 deletions

View File

@ -2,7 +2,7 @@ project(darling-libsystem)
cmake_minimum_required(VERSION 2.4.0)
add_definitions(-D_DARWIN_C_SOURCE -D_POSIX_C_SOURCE)
add_definitions(-D_DARWIN_C_SOURCE -D_POSIX_C_SOURCE -DDARLING)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libc/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libm/Source")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform-include")

View File

@ -46,5 +46,6 @@ extern uint8_t __commpage[];
#define _COMM_PAGE_END (_COMM_PAGE_START_ADDRESS+0xfff) /* end of common page */
#define _COMM_PAGE_TEXT_START (_COMM_PAGE_START_ADDRESS+0x1000)
#endif

View File

@ -22,10 +22,11 @@ endif(CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_INSTALL_LIBDIR STREQUAL "lib32")
add_definitions(-DTARGET_OS_MAC=1)
add_definitions(-DHAVE_STDINT_H=1)
add_definitions(-D__APPLE__)
add_definitions(-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1080)
add_definitions("'-D__weak_reference(sym,alias)=__asm__(\".weak alias\");__asm__(\".equ alias, sym\")'")
add_definitions("'-D__warn_references(name,warning)='")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -w")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,--unresolved-symbols=ignore-all")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/fbsdcompat")
@ -52,6 +53,9 @@ add_subdirectory(stdtime)
add_subdirectory(sys)
add_subdirectory(stdlib)
add_subdirectory(stdio)
add_subdirectory(secure)
add_subdirectory(regex)
add_subdirectory(pthreads)
add_library(system_c SHARED
$<TARGET_OBJECTS:libc-db>
@ -65,6 +69,11 @@ add_library(system_c SHARED
$<TARGET_OBJECTS:libc-stdtime>
$<TARGET_OBJECTS:libc-sys>
$<TARGET_OBJECTS:libc-stdlib>
$<TARGET_OBJECTS:libc-stdio>)
$<TARGET_OBJECTS:libc-stdio>
$<TARGET_OBJECTS:libc-secure>
$<TARGET_OBJECTS:libc-regex>
$<TARGET_OBJECTS:libc-pthreads>)
# TODO: see ./xcodescripts/variants.xcconfig
#SET_TARGET_PROPERTIES(system_c PROPERTIES LINKER_LANGUAGE C)

View File

@ -123,7 +123,7 @@ set(gen_sources ${gen_sources}
FreeBSD/termios.c
FreeBSD/time.c
FreeBSD/times.c
FreeBSD/timezone.c
# FreeBSD/timezone.c # incompatible with 'long timezone'
FreeBSD/ttyname.c
FreeBSD/ttyslot.c
FreeBSD/ualarm.c
@ -148,7 +148,7 @@ SET_SOURCE_FILES_PROPERTIES(FreeBSD/readdir.c PROPERTIES COMPILE_FLAGS "${CMAKE_
SET_SOURCE_FILES_PROPERTIES(FreeBSD/rewinddir.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_REWINDDIR -include __dirent.h")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/seekdir.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_SEEKDIR -include __dirent.h")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/sleep.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_SLEEP")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/telldir.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS__SEEKDIR -DLIBC_ALIAS_TELLDIR -include __dirent.h")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/telldir.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -include __dirent.h")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/termios.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_TCDRAIN")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/timezone.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0")
SET_SOURCE_FILES_PROPERTIES(FreeBSD/ttyname.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_TTYNAME_R")

View File

@ -20,7 +20,7 @@
# error Feature mismatch: __DARWIN_ONLY_64_BIT_INO_T == 1
#endif /* __DARWIN_ONLY_64_BIT_INO_T */
#define __APPLE_PR3417676_HACK__ 1
#define PLOCKSTAT 1
/* #undef PLOCKSTAT 1 */
#define NOTIFY_TZ 1
/* #undef LIBC_NO_LIBCRASHREPORTERCLIENT */
/* #undef FEATURE_SMALL_STDIOBUF */

View File

@ -89,6 +89,7 @@
/*
* symbol versioning macros
*/
#ifndef DARLING
#define LIBC_ALIAS(sym) __asm("_" __STRING(sym) LIBC_SUF_UNIX03)
#define LIBC_ALIAS_C(sym) __asm("_" __STRING(sym) LIBC_SUF_NON_CANCELABLE LIBC_SUF_UNIX03)
#define LIBC_ALIAS_I(sym) __asm("_" __STRING(sym) LIBC_SUF_64_BIT_INO_T LIBC_SUF_UNIX03)
@ -103,6 +104,24 @@
#define LIBC_EXTSN(sym) __asm("_" __STRING(sym) LIBC_SUF_EXTSN)
#define LIBC_EXTSN_C(sym) __asm("_" __STRING(sym) LIBC_SUF_EXTSN LIBC_SUF_NON_CANCELABLE)
#else // DARLING
#define LIBC_ALIAS(sym) __asm(__STRING(sym) LIBC_SUF_UNIX03)
#define LIBC_ALIAS_C(sym) __asm(__STRING(sym) LIBC_SUF_NON_CANCELABLE LIBC_SUF_UNIX03)
#define LIBC_ALIAS_I(sym) __asm(__STRING(sym) LIBC_SUF_64_BIT_INO_T LIBC_SUF_UNIX03)
#define LIBC_INODE64(sym) __asm(__STRING(sym) LIBC_SUF_64_BIT_INO_T)
#define LIBC_1050(sym) __asm(__STRING(sym) LIBC_SUF_1050)
#define LIBC_1050ALIAS(sym) __asm(__STRING(sym) LIBC_SUF_1050 LIBC_SUF_UNIX03)
#define LIBC_1050ALIAS_C(sym) __asm(__STRING(sym) LIBC_SUF_1050 LIBC_SUF_NON_CANCELABLE LIBC_SUF_UNIX03)
#define LIBC_1050ALIAS_I(sym) __asm(__STRING(sym) LIBC_SUF_1050 LIBC_SUF_64_BIT_INO_T LIBC_SUF_UNIX03)
#define LIBC_1050INODE64(sym) __asm(__STRING(sym) LIBC_SUF_1050 LIBC_SUF_64_BIT_INO_T)
#define LIBC_EXTSN(sym) __asm(__STRING(sym) LIBC_SUF_EXTSN)
#define LIBC_EXTSN_C(sym) __asm(__STRING(sym) LIBC_SUF_EXTSN LIBC_SUF_NON_CANCELABLE)
#endif // DARLING
extern int __pthread_tsd_first;
extern int pthread_key_init_np(int, void (*)(void *));

View File

@ -0,0 +1,22 @@
project(libc-pthreads)
cmake_minimum_required(VERSION 2.4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/../../duct/include/commpage.h -include ${CMAKE_CURRENT_SOURCE_DIR}/../../platform-include/sys/time.h")
set(pthreads_sources
pthread.c
pthread_cancelable.c
pthread_cond.c
pthread_mutex.c
pthread_rwlock.c
pthread_tsd.c
thread_setup.c
)
SET_SOURCE_FILES_PROPERTIES(pthread.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_PTHREAD_CANCEL -DLIBC_ALIAS_PTHREAD_SETCANCELSTATE -DLIBC_ALIAS_PTHREAD_SETCANCELTYPE -DLIBC_ALIAS_PTHREAD_SIGMASK -DLIBC_ALIAS_PTHREAD_TESTCANCEL")
SET_SOURCE_FILES_PROPERTIES(pthread_cancelable.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLIBC_ALIAS_PTHREAD_COND_TIMEDWAIT -DLIBC_ALIAS_PTHREAD_COND_WAIT -DLIBC_ALIAS_PTHREAD_JOIN -DLIBC_ALIAS_SIGWAIT")
SET_SOURCE_FILES_PROPERTIES(thread_setup.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0")
add_library(libc-pthreads OBJECT ${pthreads_sources})

25
libc/regex/CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
project(libc-regex)
cmake_minimum_required(VERSION 2.4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_C99_SOURCE -D_FORTIFY_SOURCE=0 -D__va_list=__builtin_va_list -DHAVE_CONFIG_H")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/TRE")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/FreeBSD")
set(regex_sources
FreeBSD/regerror.c
TRE/lib/regcomp.c
TRE/lib/regexec.c
TRE/lib/tre-ast.c
TRE/lib/tre-compile.c
TRE/lib/tre-match-backtrack.c
TRE/lib/tre-match-parallel.c
TRE/lib/tre-mem.c
TRE/lib/tre-parse.c
TRE/lib/tre-stack.c
)
#SET_SOURCE_FILES_PROPERTIES(FreeBSD/snprintf.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS}")
add_library(libc-regex OBJECT ${regex_sources})

View File

@ -0,0 +1,28 @@
project(libc-secure)
cmake_minimum_required(VERSION 2.4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_C99_SOURCE -D_FORTIFY_SOURCE=0 -D__va_list=__builtin_va_list")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../gdtoa/FreeBSD")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../gdtoa")
set(secure_sources
chk_fail.c
memcpy_chk.c
memmove_chk.c
memset_chk.c
snprintf_chk.c
sprintf_chk.c
stpcpy_chk.c
stpncpy_chk.c
strcat_chk.c
strcpy_chk.c
strncat_chk.c
strncpy_chk.c
vsnprintf_chk.c
vsprintf_chk.c
)
#SET_SOURCE_FILES_PROPERTIES(FreeBSD/snprintf.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS}")
add_library(libc-secure OBJECT ${secure_sources})

View File

@ -485,6 +485,7 @@
/*
* symbol versioning macros
*/
#ifndef DARLING
#define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03)
#define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03)
#define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03)
@ -499,6 +500,29 @@
#define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN)
#define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE)
#else // DARLING
/*
* Darling doesn't use underscore prefixing for symbols just like the rest of the Linux world.
* Using prefixing causes symbol naming conflicts, i.e. the following declarations result in the same symbol name:
* * pthread_testcancel() asm("_pthread_testcancel");
* * _pthread_testcancel()
* while on OS X, the latter would have symbol name __pthread_testcancel().
*/
#define __DARWIN_ALIAS(sym) __asm(__STRING(sym) __DARWIN_SUF_UNIX03)
#define __DARWIN_ALIAS_C(sym) __asm(__STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03)
#define __DARWIN_ALIAS_I(sym) __asm(__STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03)
#define __DARWIN_NOCANCEL(sym) __asm(__STRING(sym) __DARWIN_SUF_NON_CANCELABLE)
#define __DARWIN_INODE64(sym) __asm(__STRING(sym) __DARWIN_SUF_64_BIT_INO_T)
#define __DARWIN_1050(sym) __asm(__STRING(sym) __DARWIN_SUF_1050)
#define __DARWIN_1050ALIAS(sym) __asm(__STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03)
#define __DARWIN_1050ALIAS_C(sym) __asm(__STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03)
#define __DARWIN_1050ALIAS_I(sym) __asm(__STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03)
#define __DARWIN_1050INODE64(sym) __asm(__STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T)
#define __DARWIN_EXTSN(sym) __asm(__STRING(sym) __DARWIN_SUF_EXTSN)
#define __DARWIN_EXTSN_C(sym) __asm(__STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE)
#endif // DARLING
/*
* symbol release macros