diff --git a/src/duct/include/commpage.h b/src/duct/include/commpage.h index a247b1817..4de8dc71f 100644 --- a/src/duct/include/commpage.h +++ b/src/duct/include/commpage.h @@ -7,9 +7,19 @@ extern uint8_t __commpage[]; #endif -#define _COMM_PAGE_BASE_ADDRESS (__commpage) +//#ifndef __ASSEMBLER__ +//#define _COMM_PAGE_BASE_ADDRESS (__commpage) +//#else +//#define _COMM_PAGE_BASE_ADDRESS ___commpage@GOTPCREL(%rip) +//#endif #define _COMM_PAGE_AREA_LENGTH ( 1 * 4096 ) /* reserved length of entire comm area */ -//#define _COMM_PAGE_BASE_ADDRESS ( 0xffff0000 ) /* base address of allocated memory */ + +#ifdef __x86_64__ +#define _COMM_PAGE_BASE_ADDRESS ( 0x7fffffe00000 ) /* base address of allocated memory */ +#else +#define _COMM_PAGE_BASE_ADDRESS ( 0xaaaa0000 ) /* base address of allocated memory */ +#endif + #define _COMM_PAGE_START_ADDRESS ( _COMM_PAGE_BASE_ADDRESS ) /* address traditional commpage code starts on */ #define _COMM_PAGE_AREA_USED ( 1 * 4096 ) /* this is the amt actually allocated */ #define _COMM_PAGE_SIGS_OFFSET 0x8000 /* offset to routine signatures */ diff --git a/src/duct/src/CMakeLists.txt b/src/duct/src/CMakeLists.txt index 8b54fd744..9ad34fae1 100644 --- a/src/duct/src/CMakeLists.txt +++ b/src/duct/src/CMakeLists.txt @@ -2,21 +2,13 @@ project(duct) cmake_minimum_required(VERSION 2.4.0) -if(CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_INSTALL_LIBDIR STREQUAL "lib32") - set(BITS 32) - add_definitions(-DTARGET_CPU_X86=1) -else(CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_INSTALL_LIBDIR STREQUAL "lib32") - set(BITS 64) - add_definitions(-DTARGET_CPU_X86_64=1) -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__ -D__DYNAMIC__) add_definitions(-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1080) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -w") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-flat_namespace -Wl,-undefined,suppress") SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/darling") SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) diff --git a/src/duct/src/commpage.c b/src/duct/src/commpage.c index 0a710d75d..178cca053 100644 --- a/src/duct/src/commpage.c +++ b/src/duct/src/commpage.c @@ -1,12 +1,16 @@ #include +#include -uint8_t __commpage[_COMM_PAGE_AREA_LENGTH]; +//uint8_t __commpage[_COMM_PAGE_AREA_LENGTH]; __attribute__((constructor)) void _darling_initialize_commpage(void) { - *(_COMM_PAGE_NCPUS) = 1; - *(_COMM_PAGE_VERSION) = 12; + mmap(_COMM_PAGE_BASE_ADDRESS, _COMM_PAGE_AREA_LENGTH, PROT_READ|PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + + *((uint8_t*)_COMM_PAGE_NCPUS) = 1; + *((uint8_t*)_COMM_PAGE_VERSION) = 12; *((uint64_t*) _COMM_PAGE_MEMORY_SIZE) = 1024LL*1024LL*1024LL; } diff --git a/src/libc/CMakeLists.txt b/src/libc/CMakeLists.txt index 685306cf8..588ff72db 100644 --- a/src/libc/CMakeLists.txt +++ b/src/libc/CMakeLists.txt @@ -19,7 +19,7 @@ add_definitions(-D__LIBC__ -D__DARWIN_UNIX03=1 -D__DARWIN_64_BIT_INO_T=1 -D__DAR #add_definitions("'-D__weak_reference(sym,alias)=__asm__(\".weak \" \\\#alias );__asm__(\".equ \" \\\#alias \", \" \\\#sym)'") #add_definitions("'-D__weak_reference(sym,alias)='") add_definitions("'-D__warn_references(name,warning)='") -add_definitions(-Ddladdr=__darwin_dladdr) +#add_definitions(-Ddladdr=__darwin_dladdr) add_definitions(-DBUILDING_LIBC) # Hide warnings that get spammed @@ -35,8 +35,7 @@ add_definitions( set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -fPIC -w ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/weak_reference.h") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0") # development flags -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,--version-script=${DARLING_TOP_DIRECTORY}/darwin.map -Bsymbolic-functions") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--defsym=__darwin_pthread_self=pthread_self") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/fbsdcompat") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/pthreads") diff --git a/src/libc/gen/platfunc.h b/src/libc/gen/platfunc.h index b720d798a..87e0fd6d8 100644 --- a/src/libc/gen/platfunc.h +++ b/src/libc/gen/platfunc.h @@ -1,5 +1,3 @@ -// Modified by Lubos Dolezel for Darling - /* * Copyright (c) 2003-2010 Apple Inc. All rights reserved. * @@ -40,7 +38,7 @@ // This is a shared macro which calls PLATFUNC_VARIANT_NAME which has different // implementations in __ASSEMBLER__ and !__ASSEMBLER__ #define PLATFUNC_DESCRIPTOR_NAME(name, variant) \ - PLATFUNC_VARIANT_NAME(name, variant) + PLATFUNC_VARIANT_NAME(platfunc_##name,variant) #ifdef __ASSEMBLER__ @@ -54,24 +52,16 @@ */ #define MP_SPIN_TRIES 1000 -#ifndef DARLING - -#define PLATFUNC_VARIANT_NAME(name, variant) _ ## name ## $VARIANT$ ## variant - -#else - -#define PLATFUNC_VARIANT_NAME(name, variant) name ##$VARIANT$ ## variant - -#endif +#define PLATFUNC_VARIANT_NAME(name, variant) _##name##$VARIANT$##variant #if defined (__i386__) #define PLATFUNC_DESCRIPTOR_FIELD_POINTER .long -#define PLATFUNC_DESCRIPTOR_REFERENCE(name, variant) \ - .long PLATFUNC_DESCRIPTOR_NAME(name, variant) +#define PLATFUNC_DESCRIPTOR_REFERENCE(name,variant) \ + .long PLATFUNC_DESCRIPTOR_NAME(name,variant) #elif defined (__x86_64__) #define PLATFUNC_DESCRIPTOR_FIELD_POINTER .quad #define PLATFUNC_DESCRIPTOR_REFERENCE(name, variant) \ - .quad PLATFUNC_DESCRIPTOR_NAME(name, variant) + .quad PLATFUNC_DESCRIPTOR_NAME(name,variant) #else #error unsupported architecture #endif @@ -79,77 +69,43 @@ #ifdef VARIANT_DYLD #define PLATFUNC_FUNCTION_START_GENERIC(name, variant, codetype, alignment) \ - PLATFUNC_FUNCTION_START(name, variant, codetype, alignment) \ + PLATFUNC_FUNCTION_START(name,variant, codetype, alignment) \ .globl _ ## name ;\ _ ## name ## : #define PLATFUNC_DESCRIPTOR(name, variant, must, cant) -#elif defined(DARLING) - -#undef PLATFUNC_DESCRIPTOR_NAME -#define PLATFUNC_DESCRIPTOR_NAME(name, variant) name##$VARIANT_DESC$##variant - -#define PLATFUNC_FUNCTION_START_GENERIC(name, variant, codetype, alignment) \ - PLATFUNC_FUNCTION_START(name, variant, codetype, alignment) - -#define PLATFUNC_DESCRIPTOR(name, variant, must, cant) \ - .globl PLATFUNC_DESCRIPTOR_NAME(name,variant) ;\ - .hidden PLATFUNC_DESCRIPTOR_NAME(name,variant) ;\ - PLATFUNC_DESCRIPTOR_NAME(name,variant) ## : ;\ - PLATFUNC_DESCRIPTOR_FIELD_POINTER PLATFUNC_VARIANT_NAME(name,variant) ;\ - .long must ;\ - .long cant ;\ - #else /* VARIANT_DYLD */ #define PLATFUNC_FUNCTION_START_GENERIC PLATFUNC_FUNCTION_START #define PLATFUNC_DESCRIPTOR(name, variant, must, cant) \ .const_data ;\ - .private_extern PLATFUNC_DESCRIPTOR_NAME(name, variant) ;\ - PLATFUNC_DESCRIPTOR_NAME(name, variant) ## : ;\ - PLATFUNC_DESCRIPTOR_FIELD_POINTER PLATFUNC_VARIANT_NAME(name, variant) ;\ + .private_extern PLATFUNC_DESCRIPTOR_NAME(name,variant) ;\ + PLATFUNC_DESCRIPTOR_NAME(name,variant) ## : ;\ + PLATFUNC_DESCRIPTOR_FIELD_POINTER PLATFUNC_VARIANT_NAME(name,variant) ;\ .long must ;\ .long cant ;\ .text #endif /* VARIANT_DYLD */ -#ifdef DARLING - -#define PLATFUNC_FUNCTION_START(name, variant, codetype, alignment) \ - .text ;\ - .align (2< extern size_t malloc_good_size(size_t size); -__asm__(".symver errno, errno@DARWIN"); extern int errno; pthread_once_t re_init_c = PTHREAD_ONCE_INIT; diff --git a/src/libc/pthreads/pthread_tsd.c b/src/libc/pthreads/pthread_tsd.c index 4d446402d..b801c9c4b 100644 --- a/src/libc/pthreads/pthread_tsd.c +++ b/src/libc/pthreads/pthread_tsd.c @@ -253,12 +253,4 @@ _pthread_keys_init() } -#ifdef DARLING - -// Needed for Darling libdyld - -int __darwin_pthread_key_create(pthread_key_t *key, void (*destructor)(void*)) __attribute__((weak, alias("pthread_key_create"))); -int __darwin_pthread_key_delete(pthread_key_t key) __attribute__((weak, alias("pthread_key_delete"))); -int __darwin_pthread_setspecific(pthread_key_t key, const void *value) __attribute__((weak, alias("pthread_setspecific"))); -#endif diff --git a/src/libc/threads/cprocs.c b/src/libc/threads/cprocs.c index ef572ffaa..ffcad5873 100644 --- a/src/libc/threads/cprocs.c +++ b/src/libc/threads/cprocs.c @@ -135,7 +135,6 @@ _cproc_fork_child() */ #undef errno -__asm__(".symver errno, errno@DARWIN"); extern int errno; extern int *__error(void); extern int __pthread_canceled(int); diff --git a/src/libc/x86_64/CMakeLists.txt b/src/libc/x86_64/CMakeLists.txt index 7ede519ce..5a341bb69 100644 --- a/src/libc/x86_64/CMakeLists.txt +++ b/src/libc/x86_64/CMakeLists.txt @@ -3,15 +3,15 @@ project(libc-x86_64) cmake_minimum_required(VERSION 2.8.0) enable_language(C ASM) -add_definitions(-D_getcontext=getcontext) -add_definitions(-D_moncount=moncount) -add_definitions(-D__setcontext=_setcontext) -add_definitions(-D_getmcontext=getmcontext) -add_definitions(-D__ctx_done=_ctx_done) -add_definitions(-D__ctx_start=_ctx_start) -add_definitions(-D_cpu_number=cpu_number) -add_definitions(-D_sys_icache_invalidate=sys_icache_invalidate) -add_definitions(-D_sys_dcache_flush=sys_dcache_flush) +#add_definitions(-D_getcontext=getcontext) +#add_definitions(-D_moncount=moncount) +#add_definitions(-D__setcontext=_setcontext) +#add_definitions(-D_getmcontext=getmcontext) +#add_definitions(-D__ctx_done=_ctx_done) +#add_definitions(-D__ctx_start=_ctx_start) +#add_definitions(-D_cpu_number=cpu_number) +#add_definitions(-D_sys_icache_invalidate=sys_icache_invalidate) +#add_definitions(-D_sys_dcache_flush=sys_dcache_flush) add_definitions(-DPRIVATE) #set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/../../duct/include/commpage.h -include ${DARLING_TOP_DIRECTORY}/platform-include/sys/time.h") @@ -31,16 +31,16 @@ set(x86_64_sources ../i386/pthreads/init_cpu_capabilities.c ) -add_definitions(-D_preempt=preempt) -add_definitions(-D_backoff=backoff) -add_definitions(-D_pthread_getspecific=pthread_getspecific) -add_definitions(-D__commpage_pthread_mutex_lock=_commpage_pthread_mutex_lock) -add_definitions(-D_pthread_self=pthread_self) -add_definitions(-D___pthread_set_self=__pthread_set_self) -add_definitions(-D_start_wqthread=start_wqthread) -add_definitions(-D_thread_start=thread_start) -add_definitions(-D__pthread_start=_pthread_start) -add_definitions(-D__pthread_wqthread=_pthread_wqthread) +#add_definitions(-D_preempt=preempt) +#add_definitions(-D_backoff=backoff) +#add_definitions(-D_pthread_getspecific=pthread_getspecific) +#add_definitions(-D__commpage_pthread_mutex_lock=_commpage_pthread_mutex_lock) +#add_definitions(-D_pthread_self=pthread_self) +#add_definitions(-D___pthread_set_self=__pthread_set_self) +#add_definitions(-D_start_wqthread=start_wqthread) +#add_definitions(-D_thread_start=thread_start) +#add_definitions(-D__pthread_start=_pthread_start) +#add_definitions(-D__pthread_wqthread=_pthread_wqthread) set(x86_64_sources ${x86_64_sources} pthreads/preempt.S @@ -85,7 +85,7 @@ set(x86_64_sources ${x86_64_sources} sys/setjmp.S sys/_sigtramp.S sys/spinlocks_asm.S - #sys/spinlocks.c # aliases in other complation units don't work, work done in spinlocks_asm.S + sys/spinlocks.c # aliases in other complation units don't work, work done in spinlocks_asm.S ) diff --git a/src/libc/x86_64/gen/_ctx_start.S b/src/libc/x86_64/gen/_ctx_start.S index 38db8ac41..dfca3e9c8 100644 --- a/src/libc/x86_64/gen/_ctx_start.S +++ b/src/libc/x86_64/gen/_ctx_start.S @@ -50,11 +50,6 @@ #if defined(__x86_64__) -#ifdef DARLING -# define __ctx_start _ctx_start -# define __ctx_done _ctx_done -#endif - #include /* diff --git a/src/libc/x86_64/gen/_setcontext.S b/src/libc/x86_64/gen/_setcontext.S index 82ff79201..004a6a104 100644 --- a/src/libc/x86_64/gen/_setcontext.S +++ b/src/libc/x86_64/gen/_setcontext.S @@ -24,10 +24,6 @@ #if defined(__x86_64__) -#ifdef DARLING -# define __setcontext _setcontext -#endif - #include #define MCONTEXT_SS_RAX 16 diff --git a/src/libc/x86_64/gen/cpu_number.S b/src/libc/x86_64/gen/cpu_number.S index 2ba332c05..cc08534cc 100644 --- a/src/libc/x86_64/gen/cpu_number.S +++ b/src/libc/x86_64/gen/cpu_number.S @@ -37,10 +37,6 @@ * osfmk/i386/mp_desc.c. */ -#ifdef DARLING -# define _cpu_number cpu_number -#endif - /* return logical cpu number in %rax */ .globl _cpu_number diff --git a/src/libc/x86_64/gen/getcontext.S b/src/libc/x86_64/gen/getcontext.S index ad06e9d84..b36f963c2 100644 --- a/src/libc/x86_64/gen/getcontext.S +++ b/src/libc/x86_64/gen/getcontext.S @@ -24,10 +24,6 @@ #if defined(__x86_64__) -#ifdef DARLING -# define _getcontext getcontext -#endif - #include #define MCONTEXT_SS_RAX 16 diff --git a/src/libc/x86_64/gen/icacheinval.S b/src/libc/x86_64/gen/icacheinval.S index 6990d5d8d..9990c734b 100644 --- a/src/libc/x86_64/gen/icacheinval.S +++ b/src/libc/x86_64/gen/icacheinval.S @@ -26,13 +26,8 @@ #include -#ifdef DARLING -# define _sys_icache_invalidate sys_icache_invalidate -# define _sys_dcache_flush sys_dcache_flush -#endif - .text - .align (2<<4), 0x00 + .align 4, 0x00 /* void sys_icache_invalidate(addr_t start, int length) */ diff --git a/src/libc/x86_64/gen/mcount.S b/src/libc/x86_64/gen/mcount.S index 287fb3e63..062519d91 100644 --- a/src/libc/x86_64/gen/mcount.S +++ b/src/libc/x86_64/gen/mcount.S @@ -20,12 +20,11 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include +#import .text - .globl mcount -mcount: -#ifndef DARLING /* DARLING-TODO, moncount is defunct/deprecated API */ + .globl _mcount +_mcount: pushq %rbp // setup mcount's frame movq %rsp, %rbp subq $64, %rsp // allocate space for storage and alignment @@ -50,5 +49,4 @@ mcount: movq %rbp, %rsp popq %rbp // tear down frame -#endif ret diff --git a/src/libc/x86_64/pthreads/pthread_getspecific.S b/src/libc/x86_64/pthreads/pthread_getspecific.S index f1805687e..50d6371c4 100644 --- a/src/libc/x86_64/pthreads/pthread_getspecific.S +++ b/src/libc/x86_64/pthreads/pthread_getspecific.S @@ -24,10 +24,6 @@ #include "pthread_machdep.h" -#ifdef DARLING -# define _pthread_getspecific pthread_getspecific -#endif - .text .align (2<<2), 0x90 .globl _pthread_getspecific diff --git a/src/libc/x86_64/pthreads/pthread_mutex_lock.S b/src/libc/x86_64/pthreads/pthread_mutex_lock.S index cbc55f572..209362b0a 100644 --- a/src/libc/x86_64/pthreads/pthread_mutex_lock.S +++ b/src/libc/x86_64/pthreads/pthread_mutex_lock.S @@ -24,10 +24,6 @@ #include #include -#ifdef DARLING -# define __commpage_pthread_mutex_lock _commpage_pthread_mutex_lock -#endif - #define PTHRW_LVAL 0 #define PTHRW_UVAL 4 diff --git a/src/libc/x86_64/pthreads/pthread_self.S b/src/libc/x86_64/pthreads/pthread_self.S index f96bbb250..1ff6e122e 100644 --- a/src/libc/x86_64/pthreads/pthread_self.S +++ b/src/libc/x86_64/pthreads/pthread_self.S @@ -24,10 +24,6 @@ #include "pthread_machdep.h" -#ifdef DARLING -# define _pthread_self pthread_self -#endif - .text .align (2<<2), 0x90 .globl _pthread_self diff --git a/src/libc/x86_64/pthreads/pthread_set_self.S b/src/libc/x86_64/pthreads/pthread_set_self.S index 2e042579f..322531ed4 100644 --- a/src/libc/x86_64/pthreads/pthread_set_self.S +++ b/src/libc/x86_64/pthreads/pthread_set_self.S @@ -23,10 +23,6 @@ #include -#ifdef DARLING -# define ___pthread_set_self __pthread_set_self -#endif - .text .align (2<<2), 0x90 .globl ___pthread_set_self diff --git a/src/libc/x86_64/pthreads/start_wqthread.S b/src/libc/x86_64/pthreads/start_wqthread.S index 9de82547f..2087838e9 100644 --- a/src/libc/x86_64/pthreads/start_wqthread.S +++ b/src/libc/x86_64/pthreads/start_wqthread.S @@ -25,11 +25,6 @@ #include "pthread_machdep.h" #include -#ifdef DARLING -# define _start_wqthread start_wqthread -# define __pthread_wqthread _pthread_wqthread -#endif - .text .align (2<<2), 0x90 .globl _start_wqthread diff --git a/src/libc/x86_64/pthreads/thread_start.S b/src/libc/x86_64/pthreads/thread_start.S index d62712efa..ab5a7b279 100644 --- a/src/libc/x86_64/pthreads/thread_start.S +++ b/src/libc/x86_64/pthreads/thread_start.S @@ -25,11 +25,6 @@ #include "pthread_machdep.h" #include -#ifdef DARLING -# define _thread_start thread_start -# define __pthread_start _pthread_start -#endif - .text .align (2<<2), 0x90 .globl _thread_start diff --git a/src/libc/x86_64/string/__bzero.S b/src/libc/x86_64/string/__bzero.S index c9a668a27..c16f31ac9 100644 --- a/src/libc/x86_64/string/__bzero.S +++ b/src/libc/x86_64/string/__bzero.S @@ -1,3 +1,3 @@ - .globl __bzero -__bzero: - jmp bzero@PLT + .globl ___bzero +___bzero: + jmp _bzero diff --git a/src/libc/x86_64/string/bcopy.c b/src/libc/x86_64/string/bcopy.c index 5457244d8..3187decbf 100644 --- a/src/libc/x86_64/string/bcopy.c +++ b/src/libc/x86_64/string/bcopy.c @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * @@ -23,7 +22,6 @@ */ #include -#include #include "platfunc.h" PLATFUNC_DESCRIPTOR_PROTOTYPE(bcopy, sse42) @@ -35,18 +33,8 @@ static const platfunc_descriptor *bcopy_platfunc_descriptors[] = { 0 }; -void bcopy_chooser(const void *src, void *dest, size_t n) -#ifndef DARLING -__asm__("_bcopy"); -#else -__asm__("bcopy"); -#endif -void bcopy_chooser(const void *src, void *dest, size_t n) { -#ifndef DARLING +void *bcopy_chooser() __asm__("_bcopy"); +void *bcopy_chooser() { __asm__(".desc _bcopy, 0x100"); -#endif - void (*impl)(const void *src, void *dest, size_t n); - impl = find_platform_function((const platfunc_descriptor **) bcopy_platfunc_descriptors); - - impl(src, dest, n); + return find_platform_function((const platfunc_descriptor **) bcopy_platfunc_descriptors); } diff --git a/src/libc/x86_64/string/bcopy_sse3x.S b/src/libc/x86_64/string/bcopy_sse3x.S index 57670f173..0881b1400 100644 --- a/src/libc/x86_64/string/bcopy_sse3x.S +++ b/src/libc/x86_64/string/bcopy_sse3x.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. * @@ -37,10 +36,6 @@ * The following #defines are tightly coupled to the u-architecture: */ -#ifdef DARLING -# define _longcopy longcopy@PLT -#endif - #define kShort 80 // too short to bother with SSE (must be >=80) #define kVeryLong (500*1024) // large enough for non-temporal stores (>=8192 and <2GB) #define kFastUCode ((16*1024)-15) // cutoff for microcode fastpath for "rep/movsl" diff --git a/src/libc/x86_64/string/bzero.c b/src/libc/x86_64/string/bzero.c index 43c091c82..d5feed575 100644 --- a/src/libc/x86_64/string/bzero.c +++ b/src/libc/x86_64/string/bzero.c @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * @@ -23,7 +22,6 @@ */ #include -#include #include "platfunc.h" PLATFUNC_DESCRIPTOR_PROTOTYPE(bzero, sse42) @@ -35,11 +33,8 @@ static const platfunc_descriptor *bzero_platfunc_descriptors[] = { 0 }; -void bzero_chooser(void *s, size_t n) __asm__("bzero"); -void bzero_chooser(void *s, size_t n) { - //__asm__(".desc _bzero, 0x100"); - void (*impl)(void*, size_t); - impl = find_platform_function((const platfunc_descriptor **) bzero_platfunc_descriptors); - - impl(s, n); +void *bzero_chooser() __asm__("_bzero"); +void *bzero_chooser() { + __asm__(".desc _bzero, 0x100"); + return find_platform_function((const platfunc_descriptor **) bzero_platfunc_descriptors); } diff --git a/src/libc/x86_64/string/ffs.S b/src/libc/x86_64/string/ffs.S index cd314ff4d..8a4eb8302 100644 --- a/src/libc/x86_64/string/ffs.S +++ b/src/libc/x86_64/string/ffs.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005-2006 Apple Computer, Inc. All rights reserved. * @@ -22,16 +21,9 @@ * @APPLE_LICENSE_HEADER_END@ */ -#ifdef DARLING -# define _ffs ffs -# define _ffsl ffsl -# define _fls fls -# define _flsl flsl -#endif - .text - .align (2<<2) + .align 2 .globl _ffs _ffs: movl $(-1), %edx @@ -41,7 +33,7 @@ _ffs: ret - .align (2<<2) + .align 2 .globl _ffsl _ffsl: movl $(-1), %edx @@ -51,7 +43,7 @@ _ffsl: ret - .align (2<<2) + .align 2 .globl _fls _fls: movl $(-1), %edx @@ -61,7 +53,7 @@ _fls: ret - .align (2<<2) + .align 2 .globl _flsl _flsl: movl $(-1), %edx diff --git a/src/libc/x86_64/string/longcopy_sse3x.S b/src/libc/x86_64/string/longcopy_sse3x.S index c70ae628d..86dad2925 100644 --- a/src/libc/x86_64/string/longcopy_sse3x.S +++ b/src/libc/x86_64/string/longcopy_sse3x.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. * @@ -56,13 +55,7 @@ // void longcopy(const void *dest, void *sou, size_t len) -#ifdef DARLING -# define _longcopy longcopy -# define _memcpy memcpy@PLT -.globl longcopy -#endif - -// .private_extern _longcopy + .private_extern _longcopy _longcopy: pushq %rbp // set up a frame for backtraces movq %rsp,%rbp @@ -103,7 +96,7 @@ LBigChunkLoop: // ecx = scratch reg used to read a byte of each cache line // eax = chunk offset - .align (2<<4),0x90 // 16-byte align inner loops + .align 4,0x90 // 16-byte align inner loops LTouchLoop: movzb (%rsi,%rax),%ecx // touch line 0, 2, 4, or 6 of page movzb 1*64(%rsi,%rax),%ecx // touch line 1, 3, 5, or 7 diff --git a/src/libc/x86_64/string/memcmp.S b/src/libc/x86_64/string/memcmp.S index 93c9a35eb..398357da6 100644 --- a/src/libc/x86_64/string/memcmp.S +++ b/src/libc/x86_64/string/memcmp.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * @@ -41,15 +40,8 @@ #define kShort 18 // too short for vectors (must be >16) -#ifdef DARLING -# define _memcmp memcmp -# define _bcmp bcmp -.type memcmp, @function -.type bcmp, @function -#endif - .text - .align (2<<4) + .align 4 .globl _memcmp .globl _bcmp diff --git a/src/libc/x86_64/string/memcpy.c b/src/libc/x86_64/string/memcpy.c index a25db30ef..7a98a4c79 100644 --- a/src/libc/x86_64/string/memcpy.c +++ b/src/libc/x86_64/string/memcpy.c @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * @@ -23,7 +22,6 @@ */ #include -#include #include "platfunc.h" PLATFUNC_DESCRIPTOR_PROTOTYPE(memcpy, sse42) @@ -35,11 +33,8 @@ static const platfunc_descriptor *memcpy_platfunc_descriptors[] = { 0 }; -void *memcpy_chooser(void *dest, const void *src, size_t n) __asm__("memcpy"); -void *memcpy_chooser(void *dest, const void *src, size_t n) { - // __asm__(".desc _memcpy, 0x100"); - void *(*impl)(void *, const void *, size_t); - impl = find_platform_function((const platfunc_descriptor **) memcpy_platfunc_descriptors); - - return impl(dest, src, n); +void *memcpy_chooser() __asm__("_memcpy"); +void *memcpy_chooser() { + __asm__(".desc _memcpy, 0x100"); + return find_platform_function((const platfunc_descriptor **) memcpy_platfunc_descriptors); } diff --git a/src/libc/x86_64/string/memmove.c b/src/libc/x86_64/string/memmove.c index 2d8c54d29..64764235d 100644 --- a/src/libc/x86_64/string/memmove.c +++ b/src/libc/x86_64/string/memmove.c @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * @@ -23,7 +22,6 @@ */ #include -#include #include "platfunc.h" PLATFUNC_DESCRIPTOR_PROTOTYPE(memmove, sse42) @@ -35,11 +33,8 @@ static const platfunc_descriptor *memmove_platfunc_descriptors[] = { 0 }; -void *memmove_chooser(void *dest, const void *src, size_t n) __asm__("memmove"); -void *memmove_chooser(void *dest, const void *src, size_t n) { - //__asm__(".desc _memmove, 0x100"); - void *(*impl)(void *, const void *, size_t); - impl = find_platform_function((const platfunc_descriptor **) memmove_platfunc_descriptors); - - return impl(dest, src, n); +void *memmove_chooser() __asm__("_memmove"); +void *memmove_chooser() { + __asm__(".desc _memmove, 0x100"); + return find_platform_function((const platfunc_descriptor **) memmove_platfunc_descriptors); } diff --git a/src/libc/x86_64/string/memset.S b/src/libc/x86_64/string/memset.S index cb0b0cb0e..e79c214b3 100644 --- a/src/libc/x86_64/string/memset.S +++ b/src/libc/x86_64/string/memset.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * @@ -43,15 +42,6 @@ * on P4s and probably other processors. */ -#ifdef DARLING -# define _memset memset -# define _memset_pattern4 memset_pattern4 -# define _memset_pattern8 memset_pattern8 -# define _memset_pattern16 memset_pattern16 -# define _bzero bzero@PLT -.type memset, @function -#endif - #define kShort 255 // for nonzero memset(), too short for commpage diff --git a/src/libc/x86_64/string/strcmp.S b/src/libc/x86_64/string/strcmp.S index 83c2e6e27..6a069c0a5 100644 --- a/src/libc/x86_64/string/strcmp.S +++ b/src/libc/x86_64/string/strcmp.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * @@ -35,15 +34,10 @@ // reading bytes past the difference. To avoid this, we never do a load // that crosses a page boundary. -#ifdef DARLING -# define _strcmp strcmp -.type strcmp, @function -#endif - .text .globl _strcmp - .align (2<<4) + .align 4 _strcmp: // int strcmp(const char *s1,const char *s2); // In order to avoid spurious page faults, we loop over: diff --git a/src/libc/x86_64/string/strcpy.S b/src/libc/x86_64/string/strcpy.S index ff32ed57e..d667b05f1 100644 --- a/src/libc/x86_64/string/strcpy.S +++ b/src/libc/x86_64/string/strcpy.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * @@ -37,15 +36,10 @@ // // We align the destination, because unaligned vector stores are slow. -#ifdef DARLING -# define _strcpy strcpy -.type strcpy, @function -#endif - .text .globl _strcpy - .align (2<<4) + .align 4 _strcpy: // char *strcpy(const char *dst, const char *src); movq %rdi,%rcx // preserve dest ptr so we can return it movl %edi,%edx // copy low 4 bytes of dest ptr diff --git a/src/libc/x86_64/string/strlcat.S b/src/libc/x86_64/string/strlcat.S index 5844f8a73..50a45a85d 100644 --- a/src/libc/x86_64/string/strlcat.S +++ b/src/libc/x86_64/string/strlcat.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007 Apple Inc. All rights reserved. * @@ -47,11 +46,6 @@ // On Core2 class machines, this algorithm seems to be faster than the // naive byte-by-byte version for operands longer than about 11 bytes. -#ifdef DARLING -# define _strlcat strlcat -.type strlcat, @function -#endif - .text .globl _strlcat @@ -64,7 +58,7 @@ // %rsi = source ptr // %rdx = size - .align (2<<4) + .align 4 _strlcat: // size_t *strlcat(char *dst, const char *src, size_t size); movl %edi,%ecx // copy buffer ptr movq %rdi,%r10 // save copies of buffer ptr and length diff --git a/src/libc/x86_64/string/strlcpy.S b/src/libc/x86_64/string/strlcpy.S index 4863dac0f..6564dd235 100644 --- a/src/libc/x86_64/string/strlcpy.S +++ b/src/libc/x86_64/string/strlcpy.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2007 Apple Inc. All rights reserved. * @@ -44,11 +43,6 @@ // with one exception: 0x01 bytes preceeding the first zero are also // mapped to 0x80. -#ifdef DARLING -# define _strlcpy strlcpy -.type strlcpy,@function -#endif - .text .globl _strlcpy @@ -57,7 +51,7 @@ // %rsi = source ptr // %rdx = length - .align (2<<4) + .align 4 _strlcpy: // size_t *strlcpy(char *dst, const char *src, size_t size); movl %esi,%ecx // copy source ptr movq %rdi,%r10 // copy dest ptr diff --git a/src/libc/x86_64/string/strlen.S b/src/libc/x86_64/string/strlen.S index 5e0aced29..54ea653ac 100644 --- a/src/libc/x86_64/string/strlen.S +++ b/src/libc/x86_64/string/strlen.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005-2007 Apple Inc. All rights reserved. * @@ -32,14 +31,9 @@ * We favor the fall-through (ie, short operand) path. */ -#ifdef DARLING -# define _strlen strlen -.type strlen, @function -#endif - .text .globl _strlen - .align (2<<4), 0x90 + .align 4, 0x90 _strlen: // size_t strlen(char *b); pxor %xmm0,%xmm0 // zero %xmm0 movl %edi,%ecx // copy low half of ptr diff --git a/src/libc/x86_64/string/strncmp.S b/src/libc/x86_64/string/strncmp.S index e093c3ca3..8608e7002 100644 --- a/src/libc/x86_64/string/strncmp.S +++ b/src/libc/x86_64/string/strncmp.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005-2006 Apple Computer, Inc. All rights reserved. * @@ -35,17 +34,12 @@ // reading bytes past the difference. To avoid this, we never do a load // that crosses a page boundary. -#ifdef DARLING -# define _strncmp strncmp -.type strncmp, @function -#endif - #define kShort 20 // too short for vectors (must be >16) .text .globl _strncmp - .align (2<<4) + .align 4 _strncmp: // int strncmp(const char *s1, const char *s2, size_t len); cmpq $(kShort),%rdx // worth accelerating? ja LNotShort // yes diff --git a/src/libc/x86_64/string/strncpy.S b/src/libc/x86_64/string/strncpy.S index 548ee266c..c926083d9 100644 --- a/src/libc/x86_64/string/strncpy.S +++ b/src/libc/x86_64/string/strncpy.S @@ -1,4 +1,3 @@ -// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * @@ -43,12 +42,6 @@ // and does not terminate the string if its length is greater than or // equal to n. -#ifdef DARLING -# define _strncpy strncpy -# define _bzero bzero@PLT -.type strncpy, @function -#endif - #define kShort 31 // too short to bother with vector loop .text diff --git a/src/libc/x86_64/sys/OSAtomic.S b/src/libc/x86_64/sys/OSAtomic.S index a403acfa5..abc6bdef6 100644 --- a/src/libc/x86_64/sys/OSAtomic.S +++ b/src/libc/x86_64/sys/OSAtomic.S @@ -28,7 +28,7 @@ #include #define DECLARE(x) \ - .align 1<<2 ; \ + .align 2 ; \ .globl x ; \ .globl x ## Barrier ; \ x: ; \ @@ -41,7 +41,7 @@ x ## Barrier: #define ATOMIC_RET_ORIG 0 #define ATOMIC_RET_NEW 1 -#ifndef DARLING +#ifndef DARLING__DISABLED // compare and exchange 32-bit // xchg32 .macro xchg32 diff --git a/src/libc/x86_64/sys/_setjmp.S b/src/libc/x86_64/sys/_setjmp.S index 62ceca5d3..02cd31ebf 100644 --- a/src/libc/x86_64/sys/_setjmp.S +++ b/src/libc/x86_64/sys/_setjmp.S @@ -55,11 +55,6 @@ #define JB_FPCONTROL 76 #define JB_MASK 80 -#ifdef DARLING -# define __setjmp _setjmp -# define __longjmp _longjmp -#endif - LEAF(__setjmp, 0) // %rdi is a jmp_buf (struct sigcontext *) diff --git a/src/libc/x86_64/sys/_sigtramp.S b/src/libc/x86_64/sys/_sigtramp.S index fa64ebe5c..4ec4cb180 100644 --- a/src/libc/x86_64/sys/_sigtramp.S +++ b/src/libc/x86_64/sys/_sigtramp.S @@ -42,12 +42,6 @@ #define MCONTEXT_SS_R8 80 #define MCONTEXT_SS_RIP 144 -#ifdef DARLING -# define __sigtramp _sigtramp -# define ___sigreturn __sigreturn@PLT -# define ___in_sigtramp __in_sigtramp@GOTPCREL -#endif - /* register use: %rbx uctx @@ -61,13 +55,9 @@ _sigtramp( ) */ -#ifdef DARLING -# define __sigtramp _sigtramp -#endif - .globl __sigtramp .text - .align 1<<4 + .align 4 __sigtramp: Lstart: /* Although this routine does not need any stack frame, various parts @@ -162,12 +152,8 @@ Lend: DW_OP_breg(3), UCONTEXT_UC_MCONTEXT, DW_OP_deref, \ DW_OP_plus_uconst, MCONTEXT_SS_R8+(8*(regno-8)), 1 -#ifndef DARLING /* Unwind tables. */ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -#else - .text -#endif EH_frame1: .set L$set$0,LECIE1-LSCIE1 @@ -264,10 +250,8 @@ Lcfa_start: .byte DW_OP_plus_uconst, MCONTEXT_SS_RSP, DW_OP_deref Lcfa_end: - .align 1<<3 + .align 3 LEFDE1: -#ifndef DARLING .subsections_via_symbols -#endif diff --git a/src/libc/x86_64/sys/atomic.c b/src/libc/x86_64/sys/atomic.c index 5897da8d0..f786e7a9d 100644 --- a/src/libc/x86_64/sys/atomic.c +++ b/src/libc/x86_64/sys/atomic.c @@ -25,7 +25,7 @@ #include #include "platfunc.h" -#ifndef DARLING +#ifndef DARLING__DISABLED #define RESOLVER_UP_MP(symbol) \ PLATFUNC_DESCRIPTOR(symbol, up, kUP, 0); \ PLATFUNC_DESCRIPTOR(symbol, mp, 0, kUP); \ diff --git a/src/libc/x86_64/sys/i386_gettimeofday_asm.S b/src/libc/x86_64/sys/i386_gettimeofday_asm.S index ffeeb5138..15c4ff906 100644 --- a/src/libc/x86_64/sys/i386_gettimeofday_asm.S +++ b/src/libc/x86_64/sys/i386_gettimeofday_asm.S @@ -31,19 +31,11 @@ #include #include "platfunc.h" -#ifdef DARLING -# define _mach_absolute_time mach_absolute_time@PLT -#endif - #define NSEC_PER_SEC 1000*1000*1000 #define NSEC_PER_USEC 1000 -#ifndef DARLING .private_extern ___commpage_gettimeofday -#else -# define ___commpage_gettimeofday __commpage_gettimeofday -#endif - .align 1<<4 + .align 4 ___commpage_gettimeofday: // %rdi = ptr to timeval pushq %rbp // set up a frame for backtraces diff --git a/src/libc/x86_64/sys/nanotime.S b/src/libc/x86_64/sys/nanotime.S index 839727681..f5413be6c 100644 --- a/src/libc/x86_64/sys/nanotime.S +++ b/src/libc/x86_64/sys/nanotime.S @@ -29,10 +29,6 @@ #include #include -#ifdef DARLING -# define _mach_absolute_time mach_absolute_time -#endif - /* * 64-bit version _mach_absolute_time. We return the 64-bit nanotime in %rax, */ diff --git a/src/libc/x86_64/sys/setjmp.S b/src/libc/x86_64/sys/setjmp.S index 03b35e1da..870959725 100644 --- a/src/libc/x86_64/sys/setjmp.S +++ b/src/libc/x86_64/sys/setjmp.S @@ -43,7 +43,7 @@ * */ -#ifdef DARLING +#ifdef DARLING__DISABLED # define x__setjmp _setjmp # define x_setjmp setjmp # define x_longjmp longjmp diff --git a/src/libc/x86_64/sys/spinlocks.c b/src/libc/x86_64/sys/spinlocks.c index 4fa880d89..eecd57a80 100644 --- a/src/libc/x86_64/sys/spinlocks.c +++ b/src/libc/x86_64/sys/spinlocks.c @@ -25,7 +25,7 @@ #include #include "platfunc.h" -#ifndef DARLING +#ifndef DARLING__DISABLED #define RESOLVER_UP_MP(symbol) \ PLATFUNC_DESCRIPTOR_PROTOTYPE(symbol, up); \ PLATFUNC_DESCRIPTOR_PROTOTYPE(symbol, mp); \ diff --git a/src/libc/x86_64/sys/spinlocks_asm.S b/src/libc/x86_64/sys/spinlocks_asm.S index 6706a55fa..08bf9bc44 100644 --- a/src/libc/x86_64/sys/spinlocks_asm.S +++ b/src/libc/x86_64/sys/spinlocks_asm.S @@ -43,12 +43,6 @@ PLATFUNC_FUNCTION_START(_spin_lock_try, up, 64, 4) PLATFUNC_DESCRIPTOR(OSSpinLockTry,up,kUP,0) PLATFUNC_DESCRIPTOR(_spin_lock_try,up,kUP,0) -#ifdef DARLING -.globl OSSpinLockTry -.globl _spin_lock_try -OSSpinLockTry: -_spin_lock_try: -#endif PLATFUNC_FUNCTION_START_GENERIC(OSSpinLockTry, mp, 64, 4) PLATFUNC_FUNCTION_START_GENERIC(_spin_lock_try, mp, 64, 4) xorl %eax, %eax @@ -90,15 +84,6 @@ PLATFUNC_DESCRIPTOR(_spin_lock,up,kUP,0) PLATFUNC_DESCRIPTOR(spin_lock,up,kUP,0) -#ifdef DARLING -.globl OSSpinLockLock -.globl _spin_lock -.globl spin_lock - -OSSpinLockLock: -_spin_lock: -spin_lock: -#endif PLATFUNC_FUNCTION_START_GENERIC(OSSpinLockLock, mp, 64, 4) PLATFUNC_FUNCTION_START_GENERIC(_spin_lock, mp, 64, 4) PLATFUNC_FUNCTION_START_GENERIC(spin_lock, mp, 64, 4) diff --git a/src/libm/CMakeLists.txt b/src/libm/CMakeLists.txt index 6b3747847..1d13eac41 100644 --- a/src/libm/CMakeLists.txt +++ b/src/libm/CMakeLists.txt @@ -5,11 +5,12 @@ enable_language(C ASM) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3 -w -ggdb -O0") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__DARWIN_UNIX03 -fPIC -w -DBUILDING_FOR_CARBONCORE_LEGACY -funroll-loops -msse3") # -DBUILDING_FOR_CARBONCORE_LEGACY") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,--version-script=${DARLING_TOP_DIRECTORY}/darwin.map") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-flat_namespace -Wl,-undefined,suppress -Wl,-alias_list,${CMAKE_CURRENT_SOURCE_DIR}/Exports/libm_Intel.a.alias") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-alias_list,${CMAKE_CURRENT_SOURCE_DIR}/Exports/libmathCommonIntel.alias") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Source/Intel) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../kernel-include) -add_definitions(-Dliteral8=text -Dliteral4=text -Dliteral16=text -Dmovsxw=movswl -DPRIVATE) +add_definitions(-Dmovsxw=movswl -DPRIVATE) set(libm_sources Source/abs.c @@ -262,11 +263,11 @@ set_target_properties(system_m_extra PROPERTIES COMPILE_FLAGS "-UBUILDING_FOR_CA #add_library(system_m_extra_no_fenv OBJECT Source/Intel/xmm_log.c) #set_target_properties(system_m_extra_no_fenv PROPERTIES COMPILE_FLAGS "-UBUILDING_FOR_CARBONCORE_LEGACY -ftrapping-math -fPIC -DNO_FENV") -add_library(system_m_no_fenv STATIC ${libm_nofenv_sources}) # $) -set_target_properties(system_m_no_fenv PROPERTIES COMPILE_FLAGS "-UBUILDING_FOR_CARBONCORE_LEGACY -ftrapping-math -fPIC -DNO_FENV") +#add_library(system_m_no_fenv OBJECT ${libm_nofenv_sources}) # $) +#set_target_properties(system_m_no_fenv PROPERTIES COMPILE_FLAGS "-UBUILDING_FOR_CARBONCORE_LEGACY -ftrapping-math -fPIC -DNO_FENV") -add_library(system_m SHARED ${libm_sources} $) -target_link_libraries(system_m PRIVATE "-Wl,--whole-archive" system_m_no_fenv) +add_darling_library(system_m SHARED ${libm_sources} $) +#target_link_libraries(system_m) install(TARGETS system_m DESTINATION ${CMAKE_INSTALL_LIBDIR}/darling) diff --git a/src/libm/Source/Intel/acosf.S b/src/libm/Source/Intel/acosf.S index ae6ed418b..50c3e8874 100644 --- a/src/libm/Source/Intel/acosf.S +++ b/src/libm/Source/Intel/acosf.S @@ -28,8 +28,8 @@ S0: .double 4.999999720603234088021257968 S1: .double -3.333333463718495862077843807 - ////.const - .align (1<<4) + .const + .align 4 /* Define some coefficients for center polynomial (used for x in [-.62, +.62]). These are stored in pairs at aligned addresses for use in SIMD @@ -158,12 +158,11 @@ T1: .double +2.7185038560132749878882294, -8.6073428141752546318770571 showing that a valid result will be obtained regardless of which value rsqrtss provides. */ -#define _acosf acosf - .align (1<<5) + .align 5 #if !defined DevelopmentInstrumentation // This is the regular name used in the deployed implementation. - .globl acosf - acosf: + .globl _acosf + _acosf: #else // This is the name used for a special test version of the routine. .globl _acosfInstrumented diff --git a/src/libm/Source/Intel/acoshf.S b/src/libm/Source/Intel/acoshf.S index 92c1ca320..4dca0dbc2 100644 --- a/src/libm/Source/Intel/acoshf.S +++ b/src/libm/Source/Intel/acoshf.S @@ -11,9 +11,9 @@ #include #include "abi.h" -////.const +.const -.align (1<<4) +.align 4 .quad 0x3e607933f5c9e7de, 0xbfb348d7f4d2c2c1 // c0, d .quad 0xbec93b87a2f58777, 0x0000000000000000 // c1, 0 .quad 0x3ffb9a832f4eb8b5, 0x3ffec80a0deff17f // a0, b0 @@ -286,7 +286,7 @@ acoshf_polys: .quad 0x40582c7cd80ad8f9, 0x4045c4c4d92795e2 // p01 q01 .literal8 -.align (1<<3) +.align 3 one: .quad 0x3ff0000000000000 onehalf: .quad 0x3fe0000000000000 onethird: .quad 0x3fd5555555555555 @@ -297,7 +297,7 @@ onef: .long 0x3f800000 .text -.align (1<<4) +.align 4 #if defined( __x86_64__ ) #define RELATIVE_ADDR( _a ) (_a)( %rip ) #else diff --git a/src/libm/Source/Intel/asinf.S b/src/libm/Source/Intel/asinf.S index 2ed00b09d..38782f602 100644 --- a/src/libm/Source/Intel/asinf.S +++ b/src/libm/Source/Intel/asinf.S @@ -27,8 +27,8 @@ S0: .double 4.999999720603234088021257968 S1: .double -3.333333463718495862077843807 - ////.const - .align (1<<4) + .const + .align 4 /* Define some coefficients for center polynomial (used for x in [-.57, +.57]). These are stored in pairs at aligned addresses for use in SIMD @@ -162,11 +162,11 @@ T1: .double +2.7174503090559850822332204, -8.3122365980471962999776635 showing that a valid result will be obtained regardless of which value rsqrtss provides. */ - .align (1<<5) + .align 5 #if !defined DevelopmentInstrumentation // This is the regular name used in the deployed implementation. - .globl asinf - asinf: + .globl _asinf + _asinf: #else // This is the name used for a special test version of the routine. .globl _asinfInstrumented diff --git a/src/libm/Source/Intel/asinhf.S b/src/libm/Source/Intel/asinhf.S index 04cb04109..1f41d6992 100644 --- a/src/libm/Source/Intel/asinhf.S +++ b/src/libm/Source/Intel/asinhf.S @@ -52,7 +52,7 @@ #include #include "abi.h" -////.const +.const // Coefficients for 7th order polynomial approximation on [0, 1/4] // The polynomail is computed in packed factored form as follows: @@ -61,7 +61,7 @@ // lo double: (cx * (x + alo)) * (x(x + b1lo) + b0lo) // // The high and low parts are then unpacked and multiplied. -.align (1<<4) +.align 4 asinhf_low: .quad 0x4008183efcaf7119, 0x4007eba0a6c21cf1 // b0hi, b0lo .quad 0x3ffe9547f4507ace, 0xbffd2c173c2ad586 // ahi, alo .quad 0x40021aa6afb79159, 0xc0015e2ed556dde5 // b1hi, b1lo @@ -69,7 +69,7 @@ asinhf_low: .quad 0x4008183efcaf7119, 0x4007eba0a6c21cf1 // b0hi, b0lo // Coefficients for rational approximation on [1/4, 4] // p(x) and q(x) are computed side-by-side in packed arithmetic, then unpacked and divided. -.align (1<<4) +.align 4 asinhf_mid: .quad 0x3e4328ccef61bd30, 0x3f80f6f9cf323b3c // p[0], q[0] .quad 0x3f80f6e561f06785, 0x3f85b29a3e277523 // p[1], q[1] .quad 0x3f85b32a2f11b40a, 0x3f8e26416e925090 // p[2], q[2] @@ -79,7 +79,7 @@ asinhf_mid: .quad 0x3e4328ccef61bd30, 0x3f80f6f9cf323b3c // p[0], q[0] .quad 0x3f26c17c7b263d18, 0x3f001e11059bddca // p[6], q[6] -.align (1<<4) +.align 4 // Polynomial coefficients for the correction to log(2x) for the "large" case. // The polynomial is computed in factored form as follows: // @@ -348,7 +348,7 @@ asinhf_hi_table: .quad 0x0000000000000000, 0x3ff0000000000000 // log(1.00000), 1 .quad 0x3fe61e3efda46467, 0x3fe0080402010080 // log(1.99609), 1/1.99609 .literal8 -.align (1<<3) +.align 3 one: .quad 0x3ff0000000000000 onehalf: .quad 0x3fe0000000000000 onethird: .quad 0x3fd5555555555555 @@ -360,7 +360,7 @@ log2: .quad 0x3fe62e42fefa39ef // ln(2) #else #define RELATIVE_ADDR( _a ) (_a)-asinhf_body( %ecx ) -.align (1<<4) +.align 4 asinhf_pic: movl (%esp), %ecx // Copy address of this instruction to %ecx ret diff --git a/src/libm/Source/Intel/atan2f.S b/src/libm/Source/Intel/atan2f.S index 90217dd69..c4b16bfce 100644 --- a/src/libm/Source/Intel/atan2f.S +++ b/src/libm/Source/Intel/atan2f.S @@ -29,8 +29,8 @@ AlmostpPi: .double +3.1415924 C2: .double 0.0029352921857004596570518 - //.const - .align (1<<4) + .const + .align 4 /* Define some coefficients for center polynomial (used for x in [-1, +1]). These are stored in pairs at aligned addresses for use in SIMD @@ -42,7 +42,7 @@ C11: .double -2.9466967515109826289085300, -4.9721072376211623038916292 C10: .double 5.4728447324456990092824269, 6.7197076223592378022736307 // This needs to be 16-byte aligned because it is used in an orpd instruction. - .align (1<<4) + .align 4 pPi: .double +3.141592653589793238462643 // pi. @@ -209,9 +209,9 @@ pPi: .double +3.141592653589793238462643 // pi. (x1, y1) are in the same quadrant, then y0/x0 <= y1/x1 implies atan2f(y0, x0) <= atan2f(y1, x1).) */ - .align (1<<5) - .globl atan2f -atan2f: + .align 5 + .globl _atan2f +_atan2f: cvtss2sd Argy, y // Convert to double precision. cvtss2sd Argx, x diff --git a/src/libm/Source/Intel/atanf.S b/src/libm/Source/Intel/atanf.S index d531aec90..f4644146b 100644 --- a/src/libm/Source/Intel/atanf.S +++ b/src/libm/Source/Intel/atanf.S @@ -21,8 +21,8 @@ pHalfPi: .double +1.5707963267948966192313217 C2: .double 0.0029352921857004596570518 - //.const - .align (1<<4) + .const + .align 4 /* Define some coefficients for center polynomial (used for x in [-1, +1]). These are stored in pairs at aligned addresses for use in SIMD @@ -155,11 +155,11 @@ T10: .double 0.1730466268612773143731748, 0.1408679409162453515360961 Exhaustive testing proved this routine returns faithfully rounded results. */ - .align (1<<5) + .align 5 #if !defined DevelopmentInstrumentation // This is the regular name used in the deployed implementation. - .globl atanf - atanf: + .globl _atanf + _atanf: #else // This is the name used for a special test version of the routine. .globl _atanfInstrumented diff --git a/src/libm/Source/Intel/atanhf.S b/src/libm/Source/Intel/atanhf.S index 4ae67b811..3efd7ade7 100644 --- a/src/libm/Source/Intel/atanhf.S +++ b/src/libm/Source/Intel/atanhf.S @@ -12,8 +12,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // Polynomial coefficients used for the 7/8 < |x| < 1 case. These are addressed by offset from big_table, // so take care if you move things around. @@ -554,7 +554,7 @@ small_table: .quad 0x0000000000000000, 0x3ff0000000000000 // a = 0 // a = 7/8 .literal8 -.align (1<<3) +.align 3 one_256th: .quad 0x3f70000000000000 // 1/256 one: .quad 0x3ff0000000000000 one_plus_eps: .quad 0x3ff0000000000001 // 1 + ulp @@ -567,7 +567,7 @@ exp_mask: .quad 0x7ff0000000000000ULL // exponent bits / +Inf neglog2_2: .quad 0xbfd62e42fefa39ef // -ln(2)/2 .literal4 -.align (1<<2) +.align 2 f256: .long 0x43800000 // 256.0f .text @@ -577,7 +577,7 @@ f256: .long 0x43800000 // 256.0f #elif defined( __i386__ ) #define RELATIVE_ADDR( _a) (_a)-atanhf_body( CX_P ) #define INDEX %edi -.align (1<<4) +.align 4 atanhf_pic: movl (%esp), %ecx // copy address of local_addr to %ecx ret diff --git a/src/libm/Source/Intel/cbrtf.S b/src/libm/Source/Intel/cbrtf.S index 4ffe56711..8e8ce2d70 100644 --- a/src/libm/Source/Intel/cbrtf.S +++ b/src/libm/Source/Intel/cbrtf.S @@ -52,8 +52,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // Minimax polynomial coefficents (addressed by offset from cbrt_table) .quad 0x4000204182c17486, 0xbff8b5b876f0d973 // b1lo b1hi @@ -261,7 +261,7 @@ exponent_bias: .quad 0x3ff0000000000000, 0x3d50000000000000 denormal_bias: .quad 0x3ff0000000000000, 0x3ab0000000000000 .text -.align (1<<4) +.align 4 #if defined( __x86_64__ ) #define RELATIVE_ADDR( _a ) (_a)( %rip ) diff --git a/src/libm/Source/Intel/ceil.S b/src/libm/Source/Intel/ceil.S index 34b300aa6..293fe68fa 100644 --- a/src/libm/Source/Intel/ceil.S +++ b/src/libm/Source/Intel/ceil.S @@ -7,16 +7,14 @@ * Copyright 2009, Apple Inc. */ -.type ceil, @function #ifdef __i386__ #ifdef __SSE3__ - .text -.align (1<<4) -.globl ceil -ceil: +.align 4 +.globl _ceil +_ceil: mov 8(%esp), %ecx fldl 4(%esp) cmp $0x43300000, %ecx // if x is negative or x > 0x1.0p53 @@ -48,9 +46,9 @@ ceil: #else // i386, no SSE3 .text -.align (1<<4) -.globl ceil -ceil: +.align 4 +.globl _ceil +_ceil: mov 8(%esp), %ecx fldl 4(%esp) cmp $0x43300000, %ecx // if x is negative or x > 0x1.0p53 @@ -93,16 +91,16 @@ ceil: #else // x86_64 -//.const -.align (1<<4) +.const +.align 4 one: .quad 0x3ff0000000000000 absmask:.quad 0x7fffffffffffffff thresh: .quad 0x4330000000000000 .text -.align (1<<4) -.globl ceil -ceil: +.align 4 +.globl _ceil +_ceil: movd %xmm0, %rcx andq absmask(%rip), %rcx // |x| cmpq thresh(%rip), %rcx // if |x| >= 0x1.0p52 or isnan(x) diff --git a/src/libm/Source/Intel/ceilf.S b/src/libm/Source/Intel/ceilf.S index 82eaad58a..bb290f409 100644 --- a/src/libm/Source/Intel/ceilf.S +++ b/src/libm/Source/Intel/ceilf.S @@ -3,17 +3,16 @@ * * Steve Canon, March 2009. */ - -.type ceilf, @function + #if defined __i386__ #include .set cpubits, _COMM_PAGE_CPU_CAPABILITIES .text -.align (1<<4) -.globl ceilf -ceilf: +.align 4 +.globl _ceilf +_ceilf: movss 4(%esp), %xmm0 // load argument testl $(kHasSSE4_1), cpubits jz 0f @@ -24,7 +23,7 @@ ceilf: flds 4(%esp) ret -.align (1<<4) +.align 4 0: // no SSE 4.1 mov 4(%esp), %eax mov $23, %cl @@ -48,29 +47,29 @@ ceilf: cvttps2dq %xmm0, %xmm0 // set inexact 1: flds 4(%esp) ret -.align (1<<4) +.align 4 2: cvttps2dq %xmm0, %xmm0 // set inexact cmp $1, %edx // if x > 0, goto 3 jge 3f andl $0x80000000, 4(%esp) // copysign(0.0, x) flds 4(%esp) ret -.align (1<<4) +.align 4 3: movl $0x3f800000, 4(%esp) // return 1.0 flds 4(%esp) ret #elif defined __x86_64__ -//.const -.align (1<<4) +.const +.align 4 one: .long 0x3f800000 absmask:.long 0x7fffffff .text -.align (1<<4) -.globl ceilf -ceilf: +.align 4 +.globl _ceilf +_ceilf: movd %xmm0, %eax andl absmask(%rip), %eax movd absmask(%rip), %xmm1 diff --git a/src/libm/Source/Intel/cosh.S b/src/libm/Source/Intel/cosh.S index e528cc5c6..34955d8ae 100644 --- a/src/libm/Source/Intel/cosh.S +++ b/src/libm/Source/Intel/cosh.S @@ -12,10 +12,8 @@ #include #include "abi.h" -.type cosh, @function - -//.const -.align (1<<4) +.const +.align 4 // Polynomial coefficients, offset from exp2table .quad 0x3f55e52272e0eaec, 0x3f55e52272e0eaec // c4 .quad 0x401cc9eea1e24220, 0x401cc9eea1e24220 // c3/c4 @@ -163,7 +161,7 @@ small_poly: .quad 0x3fe0000000000000 .double 0.20918130318061568990950557203211923657510680e-8 .literal8 -.align (1<<3) +.align 3 one_n7: .quad 0x3f80000000000000 lge_p7: .quad 0x40671547652b82fe lge_hi: .quad 0x3ff7154760000000 @@ -181,7 +179,7 @@ poly_mask: .quad 0xfffffe0000000000 #else #define RELATIVE_ADDR(_a) (_a)-cosh_body(%ecx) -.align (1<<4) +.align 4 cosh_pic: movl (%esp), %ecx ret diff --git a/src/libm/Source/Intel/coshf.S b/src/libm/Source/Intel/coshf.S index fb078d8a6..e27f3a886 100644 --- a/src/libm/Source/Intel/coshf.S +++ b/src/libm/Source/Intel/coshf.S @@ -11,13 +11,11 @@ #include #include "abi.h" -.type coshf, @function - // This is identical to sinhf with some indices permuted to compute cosh instead. // Read the detailed comments in that file for more information. -//.const -.align (1<<4) +.const +.align 4 .quad 0x3f811111111110fe, 0x3fa555f78359bc34 // c5, c4 = 0.0083333..., 0.0416715 .quad 0x4034000000000018, 0x4027ff4991a5ebc5 // c3/c5 = 0.1666666.../c5, c2/c4 = 0.5/c4 coshf_table: .quad 0x0000000000000000, 0x3ff0000000000000 // sinh(0/16), cosh(0/16) @@ -220,7 +218,7 @@ sixteen: .quad 0x4030000000000000 // 16 #define RELATIVE_ADDR(_a) (_a)-coshf_body( %ecx ) #define RELATIVE_ADDR_B(_a) (_a)-coshf_body_eleven( %ecx ) -.align (1<<4) +.align 4 coshf_pic: movl (%esp), %ecx // Copy address of this instruction to %ecx ret diff --git a/src/libm/Source/Intel/e_cbrtl.S b/src/libm/Source/Intel/e_cbrtl.S index d5f3f6413..48a89acb0 100644 --- a/src/libm/Source/Intel/e_cbrtl.S +++ b/src/libm/Source/Intel/e_cbrtl.S @@ -8,9 +8,9 @@ */ #define ENTRY(name) \ - .globl name; \ - .align (1<<4); \ - name##: + .globl _##name; \ + .align 4; \ + _##name##: #if defined( __LP64__ ) #define LOCAL_STACK_SIZE 20 @@ -20,15 +20,15 @@ #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 onethird: .long 0xaaaaaaab, 0xaaaaaaaa, 0x00003ffd, 0x00000000 //(long double) 1.0L/3.0L -.align (1<<3) +.align 3 correction: .double 0.62996052494743658238361, 0.79370052598409973737585, 1.0, 1.2599210498948731647672, 1.5874010519681994747517 coeffs: .double 1.7830491344381518, -1.5730724799776633, 1.2536000054780357, -0.60460822457398278, 0.15834924310704463, -0.017322841453552703 -.align (1<<2) +.align 2 infinity: .single +Infinity // Stack: diff --git a/src/libm/Source/Intel/exp.S b/src/libm/Source/Intel/exp.S index d5f88bbee..ce3913984 100644 --- a/src/libm/Source/Intel/exp.S +++ b/src/libm/Source/Intel/exp.S @@ -20,8 +20,8 @@ Tables and Constants ****************************************************************************/ -//.const -.align (1<<4) +.const +.align 4 // Coefficients for the 4th order minimax polynomial @@ -175,7 +175,7 @@ small_poly: .quad 0x3ff0000000000000 .quad 0x3f8111116e99ac77 .literal8 -.align (1<<3) +.align 3 lge_p7: .quad 0x40671547652b82fe lge: .quad 0x3ff71547652b82fe lge_hi: .quad 0x3ff7154760000000 diff --git a/src/libm/Source/Intel/exp2.S b/src/libm/Source/Intel/exp2.S index b9a8758bd..cad1892fb 100644 --- a/src/libm/Source/Intel/exp2.S +++ b/src/libm/Source/Intel/exp2.S @@ -17,8 +17,8 @@ Tables and Constants ****************************************************************************/ -//.const -.align (1<<4) +.const +.align 4 // Coefficients for the 4th order minimax polynomial @@ -176,7 +176,7 @@ small_poly: .quad 0x3ff0000000000000 .literal8 -.align (1<<3) +.align 3 one_p7: .quad 0x4060000000000000 tiny_val: .quad 0x0010000000000001 huge_val: .quad 0x7fefffffffffffff diff --git a/src/libm/Source/Intel/exp2f.S b/src/libm/Source/Intel/exp2f.S index 4206ad824..5a76b3131 100644 --- a/src/libm/Source/Intel/exp2f.S +++ b/src/libm/Source/Intel/exp2f.S @@ -55,7 +55,7 @@ // // -.align (1<<4) +.align 4 // 8th order minimax fit of exp2 on [-1.0,1.0]. |error| < 0.402865722354948566583852e-9: exp2f_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 = 0.961813690023115610862381719985771e-2 / 0.134107709538786543922336536865157e-5, c0 = 1.0 + 0.278626872016317130037181614004e-10 .quad 0x408f10e7f73e6d8f, 0x3fe62e42fd0933ee // c5/c8 = 0.133318252930790403741964203236548e-2 / 0.134107709538786543922336536865157e-5, c1 = .693147176943623740308984004029708 @@ -64,7 +64,7 @@ exp2f_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 .quad 0x3eb67fe1dc3105ba // c8 = 0.134107709538786543922336536865157e-5 -.align (1<<3) +.align 3 exp2f_nofenv_c: .quad 0x3ff0000000058fca // 1.0 + -8.09329727503262700660348520172e-11 .double 0.693147206709644041218074094717934 .double 0.240226515050550309232521176082490 @@ -85,7 +85,7 @@ exp2f_nofenv_c: .quad 0x3ff0000000058fca // 1.0 + -8. #define RELATIVE_ADDR_B( _a) (_a)-exp2f_no_fenv_body( CX_P ) //a short routine to get the local address -.align (1<<4) +.align 4 exp2f_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/expf.S b/src/libm/Source/Intel/expf.S index f6b693e72..3fb4b7bf7 100644 --- a/src/libm/Source/Intel/expf.S +++ b/src/libm/Source/Intel/expf.S @@ -59,7 +59,7 @@ // // -.align (1<<4) +.align 4 // 8th order minimax fit of exp2 on [-1.0,1.0]. |error| < 0.402865722354948566583852e-9: expf_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 = 0.961813690023115610862381719985771e-2 / 0.134107709538786543922336536865157e-5, c0 = 1.0 + 0.278626872016317130037181614004e-10 .quad 0x408f10e7f73e6d8f, 0x3fe62e42fd0933ee // c5/c8 = 0.133318252930790403741964203236548e-2 / 0.134107709538786543922336536865157e-5, c1 = .693147176943623740308984004029708 @@ -68,7 +68,7 @@ expf_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 .quad 0x3eb67fe1dc3105ba // c8 = 0.134107709538786543922336536865157e-5 -.align (1<<3) +.align 3 expf_nofenv_c: .quad 0x3ff0000000058fca // 1.0 + -8.09329727503262700660348520172e-11 .double 0.693147206709644041218074094717934 .double 0.240226515050550309232521176082490 @@ -90,7 +90,7 @@ reciprocalLn2: .quad 0x3ff71547652b82fe // 1.0 / ln( #define RELATIVE_ADDR_B( _a) (_a)-expf_no_fenv_body( CX_P ) //a short routine to get the local address -.align (1<<4) +.align 4 expf_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/expl.S b/src/libm/Source/Intel/expl.S index cd5500352..10eb3a8d7 100644 --- a/src/libm/Source/Intel/expl.S +++ b/src/libm/Source/Intel/expl.S @@ -14,8 +14,8 @@ inf: .long 0x7f800000 minf: .long 0xff800000 -//.const -.align (1<<4) +.const +.align 4 maxldbl: .quad 0xffffffffffffffff, 0x7ffe minldbl: .quad 0x8000000000000000, 0x0001 ln2_hi: .quad 0xB17217F7D1D00000, 0x3ffe diff --git a/src/libm/Source/Intel/expm1.S b/src/libm/Source/Intel/expm1.S index 7f6da7d44..21db6d53d 100644 --- a/src/libm/Source/Intel/expm1.S +++ b/src/libm/Source/Intel/expm1.S @@ -20,8 +20,8 @@ Tables and Constants ****************************************************************************/ -//.const -.align (1<<4) +.const +.align 4 // Coefficients for the 4th order minimax polynomial // approximation of exp2( ) on the interval [-0x1p-27, 0x1p-7] @@ -176,7 +176,7 @@ small_poly: .quad 0x402861b02f2c3241, 0x401552de659eae97 // Other useful constants .literal8 -.align (1<<3) +.align 3 lge_p7: .quad 0x40671547652b82fe lge: .quad 0x3ff71547652b82fe lge_hi: .quad 0x3ff7154760000000 diff --git a/src/libm/Source/Intel/expm1f.S b/src/libm/Source/Intel/expm1f.S index b42e235ca..fb4894147 100644 --- a/src/libm/Source/Intel/expm1f.S +++ b/src/libm/Source/Intel/expm1f.S @@ -11,10 +11,10 @@ #include #include "abi.h" -//.const +.const //minimax polynomial for exp2(x)-1 -.align (1<<4) +.align 4 // 8th order minimax fit of exp2 on [-1.0,1.0]. |error| < 0.402865722354948566583852e-9: expm1f_c: .quad 0x40bc03f30399c376, 0x3dbea2a63403aaa8 // c4/c8 = 0.961813690023115610862381719985771e-2 / 0.134107709538786543922336536865157e-5, c0 = 0.278626872016317130037181614004e-10 .quad 0x408f10e7f73e6d8f, 0x3fe62e42fd0933ee // c5/c8 = 0.133318252930790403741964203236548e-2 / 0.134107709538786543922336536865157e-5, c1 = .693147176943623740308984004029708 @@ -172,7 +172,7 @@ two6: .quad 0x4050000000000000 // 0x1.0p6 #define RELATIVE_ADDR_B( _a) (_a)-expm1f_no_fenv_body( CX_P ) //a short routine to get the local address -.align (1<<4) +.align 4 expm1f_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/floor.S b/src/libm/Source/Intel/floor.S index 42ee0a3ba..f3a85c54e 100644 --- a/src/libm/Source/Intel/floor.S +++ b/src/libm/Source/Intel/floor.S @@ -12,9 +12,9 @@ #ifdef __SSE3__ .text -.align (1<<4) -.globl floor -floor: +.align 4 +.globl _floor +_floor: mov 8(%esp), %ecx fldl 4(%esp) cmp $0x43300000, %ecx // if x is negative or x > 0x1.0p53 @@ -48,9 +48,9 @@ floor: #else // i386, no SSE3 .text -.align (1<<4) -.globl floor -floor: +.align 4 +.globl _floor +_floor: mov 8(%esp), %ecx and $0x7fffffff, %ecx // high word of |x| fldl 4(%esp) @@ -78,16 +78,16 @@ floor: #else // x86_64 -//.const -.align (1<<4) +.const +.align 4 mone: .quad 0xbff0000000000000 absmask:.quad 0x7fffffffffffffff thresh: .quad 0x432fffffffffffff .text -.align (1<<4) -.globl floor -floor: +.align 4 +.globl _floor +_floor: movd %xmm0, %rcx andq absmask(%rip), %rcx // |x| subq $1, %rcx diff --git a/src/libm/Source/Intel/floorf.S b/src/libm/Source/Intel/floorf.S index 7cfc4e2a4..9532cadf1 100644 --- a/src/libm/Source/Intel/floorf.S +++ b/src/libm/Source/Intel/floorf.S @@ -10,9 +10,9 @@ .set cpubits, _COMM_PAGE_CPU_CAPABILITIES .text -.align (1<<4) -.globl floorf -floorf: +.align 4 +.globl _floorf +_floorf: movss 4(%esp), %xmm0 // load argument testl $(kHasSSE4_1), cpubits jz 0f @@ -23,7 +23,7 @@ floorf: flds 4(%esp) ret -.align (1<<4) +.align 4 0: // no SSE 4.1 mov 4(%esp), %eax mov $23, %cl @@ -48,29 +48,29 @@ floorf: cvttps2dq %xmm0, %xmm0 // set inexact 1: flds 4(%esp) ret -.align (1<<4) +.align 4 2: cvttps2dq %xmm0, %xmm0 // set inexact cmp $0xffffffff, %edx // if x < 0.0, goto 3 jl 3f andl $0x80000000, 4(%esp) // copysign(0.0, x) flds 4(%esp) ret -.align (1<<4) +.align 4 3: movl $0xbf800000, 4(%esp) // return 1.0 flds 4(%esp) ret #elif defined __x86_64__ -//.const -.align (1<<4) +.const +.align 4 mone: .long 0xbf800000 absmask:.long 0x7fffffff .text -.align (1<<4) -.globl floorf -floorf: +.align 4 +.globl _floorf +_floorf: movd %xmm0, %ecx andl $0x7fffffff, %ecx // |x| subl $1, %ecx // subtract 1. This forces |+-0| to -0 diff --git a/src/libm/Source/Intel/fmod.S b/src/libm/Source/Intel/fmod.S index 1181f444b..b8dfb048c 100644 --- a/src/libm/Source/Intel/fmod.S +++ b/src/libm/Source/Intel/fmod.S @@ -6,9 +6,9 @@ */ .text -.align (1<<4) -.globl fmodf -fmodf: +.align 4 +.globl _fmodf +_fmodf: #if defined __x86_64__ #define xf -4(%rsp) #define yf -8(%rsp) @@ -34,9 +34,9 @@ fmodf: ret .text -.align (1<<4) -.globl fmod -fmod: +.align 4 +.globl _fmod +_fmod: #if defined __x86_64__ #define x -8(%rsp) #define y -16(%rsp) @@ -62,9 +62,9 @@ fmod: ret .text -.align (1<<4) -.globl fmodl -fmodl: +.align 4 +.globl _fmodl +_fmodl: #if defined __x86_64__ #define xl 8(%rsp) #define yl 24(%rsp) diff --git a/src/libm/Source/Intel/hypot.S b/src/libm/Source/Intel/hypot.S index bb32da24f..73c6173d1 100644 --- a/src/libm/Source/Intel/hypot.S +++ b/src/libm/Source/Intel/hypot.S @@ -10,8 +10,8 @@ #endif .text -.globl hypot -.globl cabs +.globl _hypot +.globl _cabs #if defined __i386__ @@ -20,9 +20,9 @@ // Entry point -------------------------------------------------------- -.align (1<<4) -cabs: -hypot: +.align 4 +_cabs: +_hypot: mov 8(%esp), %eax mov 16(%esp), %edx mov ABSHI, %ecx @@ -55,7 +55,7 @@ L_returnFromYHiIsZero: // Special case handling ---------------------------------------------- L_xHiIsZero: - cmpl $0, 4(%esp) // is the low word of x zero? + cmp $0, 4(%esp) // is the low word of x zero? jnz L_returnFromXHiIsZero // if not, jump back to mainline L_returnAbsY: and %ecx, 16(%esp) @@ -63,7 +63,7 @@ L_returnAbsY: ret L_yHiIsZero: - cmpl $0, 12(%esp) // is the low word of y zero? + cmp $0, 12(%esp) // is the low word of y zero? jnz L_returnFromYHiIsZero // if not, jump back to mainline L_returnAbsX: and %ecx, 8(%esp) @@ -73,7 +73,7 @@ L_returnAbsX: L_xIsSpecial: cmp INFHI, %edx // check if y is infinity jnz L_returnAbsX - cmpl $0, 12(%esp) + cmp $0, 12(%esp) jz L_returnAbsY jmp L_returnAbsX @@ -84,9 +84,9 @@ L_xIsSpecial: // Entry point -------------------------------------------------------- -.align (1<<4) -cabs: -hypot: +.align 4 +_cabs: +_hypot: movd %xmm0, %rax movd %xmm1, %rdx mov ABSMASK, %rcx diff --git a/src/libm/Source/Intel/hypotf.S b/src/libm/Source/Intel/hypotf.S index c17e9692f..3a7e1dd49 100644 --- a/src/libm/Source/Intel/hypotf.S +++ b/src/libm/Source/Intel/hypotf.S @@ -13,25 +13,25 @@ #define INFINITY $0x7f800000 .text -.globl cabsf -.globl hypotf +.globl _cabsf +.globl _hypotf // Entry points ------------------------------------------------------- #if defined __i386__ -.align (1<<4) -cabsf: // on i386, we can use the same code for -hypotf: // hypotf and cabsf, because the arguments +.align 4 +_cabsf: // on i386, we can use the same code for +_hypotf: // hypotf and cabsf, because the arguments mov 4(%esp), %eax // come in at the same stack offsets mov 8(%esp), %edx // movss 4(%esp), %xmm0 // real at esp + 4 movss 8(%esp), %xmm1 // imag at esp + 8 #else -.align (1<<4) // however, on x86_64, the registers used -cabsf: // are different. cabsf's arguments come +.align 4 // however, on x86_64, the registers used +_cabsf: // are different. cabsf's arguments come pshufd $0xfd, %xmm0, %xmm1 // in packed in xmm0. -.align (1<<4) -hypotf: // +.align 4 +_hypotf: // movd %xmm0, %eax // hypotf, on the other hand, gets x in movd %xmm1, %edx // xmm0 and y in xmm1. #endif diff --git a/src/libm/Source/Intel/hypotl.S b/src/libm/Source/Intel/hypotl.S index 502b79306..8fd00075f 100644 --- a/src/libm/Source/Intel/hypotl.S +++ b/src/libm/Source/Intel/hypotl.S @@ -26,11 +26,11 @@ // Entry point --------------------------------------------------------------- .text -.globl hypotl -.globl cabsl -.align (1<<4) -hypotl: -cabsl: +.globl _hypotl +.globl _cabsl +.align 4 +_hypotl: +_cabsl: // Check argument scaling ---------------------------------------------------- // @@ -262,7 +262,7 @@ L_scaledHypot: // Useful constants ---------------------------------------------------------- .literal16 -.align (1<<4) +.align 4 L_infinity: .quad 0x8000000000000000, 0x0000000000007fff L_tiny: diff --git a/src/libm/Source/Intel/log.S b/src/libm/Source/Intel/log.S index c62c0da8e..9179e5cba 100644 --- a/src/libm/Source/Intel/log.S +++ b/src/libm/Source/Intel/log.S @@ -18,8 +18,8 @@ #include #include "abi.h" -//.const -.align (1<<5) +.const +.align 5 xone: .quad 0x3ff0000000000000, 0 frexp_exp_mask: .quad 0x7ff0000000000000, 0 frexp_mant_mask: .quad 0x800fffffffffffff, 0 @@ -28,7 +28,7 @@ frexp_head_mask: .quad 0x000ff00000000000, 0 //log10_key_mask: .quad 0x07e0000000000000, 0 log1p_not_ulp_mask: .quad 0xfffffffffffffffe, 0 -.align (1<<5) +.align 5 lgel: .quad 0xB8AA3B295C17F0BC, 0x3fff ln2l: .quad 0xB17217F7D1CF79AC, 0x3ffe //ln(2) rounded up to long double @@ -37,13 +37,13 @@ log102l: .quad 0x9A209A84FBCFF799, 0x3ffd //log10(2) rounded up (almost 1/2 ulp) c0: .quad 0xFFFFFFFFFFFFFFD7, 0xbffd //c0 = -.4999999999999999988974167423L -.align (1<<5) +.align 5 a01: .double .827742667285236703751556405085096, -2.00038644890076831031534988283768 //a0,a1 b01: .double 1.51843353412997067893915870795354, 1.54454569915832086827096843200102 //b0,b1 // The lookup table is in a funny format since it has 2 long double and a single. // {10-byte va ; 2-byte pad ; 4-byte single a ; 10-byte lg1pa ; 6-byte pad} -.align (1<<5) +.align 5 LOOKUP: // This is the table for a, ap1, va, lg1pa: a = (float)k*scale, ap1 = a + 1, va = (long double)1./(1.+a), lg1pa = (long double)log2(1.+a) // In C this would be @@ -375,7 +375,7 @@ isPowerOf10: // {10^n, log10(10^n)} for n < 64 .quad 0x3ff0000000000000, 0x0000000000000000 //{0x1p+0, 0x0p+0}, k=63 .literal8 -.align (1<<3) +.align 3 one: .double 1.0 mone: .double -1.0 diff --git a/src/libm/Source/Intel/log10f.S b/src/libm/Source/Intel/log10f.S index 0ce859300..3059113c3 100644 --- a/src/libm/Source/Intel/log10f.S +++ b/src/libm/Source/Intel/log10f.S @@ -9,8 +9,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // 256 entry of Lookup table of values used for log10 calculation, generated as: // @@ -300,7 +300,7 @@ log10_m_table: .quad 0x0, 0x3ff0000000000000 // log10(1.00 .literal8 -.align (1<<3) +.align 3 one: .double 1.0 onehalf: .double 0.5 onethird: .quad 0x3fd5555555555555 // 1/3 @@ -321,7 +321,7 @@ log10_of_2: .quad 0x3fd34413509f79ff // log10(2) #define RELATIVE_ADDR2( _a, _i, _step) (_a)-rel_addr( CX_P, _i, _step ) //a short routine to get the local address -.align (1<<4) +.align 4 log10f_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/log2f.S b/src/libm/Source/Intel/log2f.S index 17bf83f34..fc9950ece 100644 --- a/src/libm/Source/Intel/log2f.S +++ b/src/libm/Source/Intel/log2f.S @@ -9,8 +9,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // 256 entry of Lookup table of values used for log2 calculation, generated as: // @@ -300,7 +300,7 @@ log2f_table: .quad 0x0, 0x3ff0000000000000 //log2(1.00000), 1/ .quad 0x3fefe8e4f15bd1a0, 0x3fe0080402010080 //log2(1.99609), 1/1.99609 .literal8 -.align (1<<3) +.align 3 one: .double 1.0 onehalf: .double 0.5 onethird: .quad 0x3fd5555555555555 // 1/3 @@ -321,7 +321,7 @@ recip_log2: .quad 0x3ff71547652b82fe // 1.0 / ln(2) #define RELATIVE_ADDR2( _a, _i, _step) (_a)-rel_addr( CX_P, _i, _step ) //a short routine to get the local address -.align (1<<4) +.align 4 log2f_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/logf.S b/src/libm/Source/Intel/logf.S index a96849e16..0be684463 100644 --- a/src/libm/Source/Intel/logf.S +++ b/src/libm/Source/Intel/logf.S @@ -15,8 +15,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // 511 entry of Lookup table of values used for log and log1p calculation, generated as: // @@ -436,7 +436,7 @@ log_m_table: .quad 0x0000000000000000, 0x3ff0000000000000 // log1p(0.0000 .literal8 -.align (1<<3) +.align 3 one: .double 1.0 onehalf: .double 0.5 onethird: .quad 0x3fd5555555555555 // 1/3 @@ -448,7 +448,7 @@ almost1: .quad 0x3fefffffffffffffULL // 1.0 - DBL_EPSILON/2 log2: .quad 0x3fe62e42fefa39efULL // ln(2) .literal4 -.align (1<<2) +.align 2 f256: .long 0x43800000 //256.0f r256: .long 0x3b800000 //1.0f/256.0f @@ -465,7 +465,7 @@ r256: .long 0x3b800000 //1.0f/256.0f #define RELATIVE_ADDR2( _a, _i, _step) (_a)-rel_addr( CX_P, _i, _step ) //a short routine to get the local address -.align (1<<4) +.align 4 logf_pic: movl (%esp), %ecx //copy address of local_addr to %ecx ret #else diff --git a/src/libm/Source/Intel/lroundl.S b/src/libm/Source/Intel/lroundl.S index 4a49ecb9d..ab04461e9 100644 --- a/src/libm/Source/Intel/lroundl.S +++ b/src/libm/Source/Intel/lroundl.S @@ -11,20 +11,20 @@ #include "abi.h" #include -.align (1<<2) +.align 2 .literal4 two63: .long 0x5f000000 mtwo63: .long 0xdf000000 one: .long 1 inf: .long 0x7f800000 -.align (1<<3) +.align 3 .literal8 cutoff32: .double 2147483647.5 // 2**31-0.5 mcutoff32: .double -2147483648.5 // 2**31-0.5 -.align (1<<4) +.align 4 .literal16 cutoff: .quad 0xffffffffffffffff, 0x403d sign: .quad 0x0, 0xffffffffffffffff diff --git a/src/libm/Source/Intel/machine/asm.h b/src/libm/Source/Intel/machine/asm.h index a526b283f..c0486f93b 100644 --- a/src/libm/Source/Intel/machine/asm.h +++ b/src/libm/Source/Intel/machine/asm.h @@ -22,16 +22,15 @@ */ #define ENTRY(name) \ - .type name, @function; \ - .globl name; \ - .align (2<<4); \ - name##: + .globl _##name; \ + .align 4; \ + _##name##: #ifndef NO_FENV #define PRIVATE_ENTRY(name) \ - .globl name; .hidden name; \ - .align (2<<4); \ - name##: + .globl _##name; .private_extern _##name; \ + .align 4; \ + _##name##: #else #define PRIVATE_ENTRY(name) #endif diff --git a/src/libm/Source/Intel/modf.S b/src/libm/Source/Intel/modf.S index 5d24d3c52..dc80e4e64 100644 --- a/src/libm/Source/Intel/modf.S +++ b/src/libm/Source/Intel/modf.S @@ -25,9 +25,9 @@ #if defined __i386__ .text -.align (1<<4) -.globl modf -modf: +.align 4 +.globl _modf +_modf: movl 8(%esp), %eax // high word of x andl $0x7fffffff, %eax // high word of |x| subl $0x3ff00000, %eax // subtract off exponent bias @@ -78,17 +78,17 @@ modf: #else // __x86_64__ -//.const -.align (1<<4) +.const +.align 4 absmask: .quad 0x7fffffffffffffff one: .quad 0x3ff0000000000000 .text -.align (1<<4) -.globl modf -modf: +.align 4 +.globl _modf +_modf: movsd absmask(%rip), %xmm1 andpd %xmm0, %xmm1 // |x| movd %xmm1, %rax diff --git a/src/libm/Source/Intel/modff.S b/src/libm/Source/Intel/modff.S index 5ad88c560..e6675bac5 100644 --- a/src/libm/Source/Intel/modff.S +++ b/src/libm/Source/Intel/modff.S @@ -85,7 +85,7 @@ ENTRY( modff ) movl 4+FRAME_SIZE( STACKP), RESULT_P flds FRAME_SIZE( STACKP ) // { x } fld %st(0) - fstpl (RESULT_P) + fstp (RESULT_P) #else movss %xmm0, (RESULT_P) #endif diff --git a/src/libm/Source/Intel/nearbyint.S b/src/libm/Source/Intel/nearbyint.S index 6ab327046..ce3cc7bf4 100644 --- a/src/libm/Source/Intel/nearbyint.S +++ b/src/libm/Source/Intel/nearbyint.S @@ -5,12 +5,12 @@ // // -- Stephen Canon, January 2010 -#include +#include .text -.align (1<<4) -.globl nearbyint -nearbyint: +.align 4 +.globl _nearbyint +_nearbyint: // Fast path if SSE4.1 is available ------------------------------------------ diff --git a/src/libm/Source/Intel/nearbyintf.S b/src/libm/Source/Intel/nearbyintf.S index 2ce611952..bc5132979 100644 --- a/src/libm/Source/Intel/nearbyintf.S +++ b/src/libm/Source/Intel/nearbyintf.S @@ -5,12 +5,12 @@ // // -- Stephen Canon, January 2010 -#include +#include .text -.align (1<<4) -.globl nearbyintf -nearbyintf: +.align 4 +.globl _nearbyintf +_nearbyintf: // Fast path if SSE4.1 is available ------------------------------------------ diff --git a/src/libm/Source/Intel/nextafterl.S b/src/libm/Source/Intel/nextafterl.S index 8abe5cf97..5059f3798 100644 --- a/src/libm/Source/Intel/nextafterl.S +++ b/src/libm/Source/Intel/nextafterl.S @@ -11,14 +11,14 @@ #include "abi.h" #if defined( __x86_64__ ) -.align (1<<3) +.align 3 .literal8 signBit: .quad 0x8000000000000000 nonSignBit: .quad 0x7fffffffffffffff #endif -.align (1<<4) -//.const +.align 4 +.const tiny: .quad 0x8000000000000000, 0x1 //0x1.0p-16382 big: .quad 0x8000000000000000, 0x7ffe //0x1.0p16383 diff --git a/src/libm/Source/Intel/powf.S b/src/libm/Source/Intel/powf.S index 5b1081b10..1729cbe47 100644 --- a/src/libm/Source/Intel/powf.S +++ b/src/libm/Source/Intel/powf.S @@ -16,7 +16,7 @@ #include "machine/asm.h" #include "abi.h" -//.const +.const gMaskShift: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ @@ -34,7 +34,7 @@ gMaskShift: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 31,31,31,31, 31,31,31,31,31,31,31,31,31,31,31,31, \ 31,31,31,31, 31,31,31,31,31,31,31,31,31,31,31,31 -.align (1<<4) +.align 4 // 8th order minimax fit of exp2 on [-1.0,1.0]. |error| < 0.402865722354948566583852e-9: powf_exp_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 = 0.961813690023115610862381719985771e-2 / 0.134107709538786543922336536865157e-5, c0 = 1.0 + 0.278626872016317130037181614004e-10 .quad 0x408f10e7f73e6d8f, 0x3fe62e42fd0933ee // c5/c8 = 0.133318252930790403741964203236548e-2 / 0.134107709538786543922336536865157e-5, c1 = .693147176943623740308984004029708 @@ -98,7 +98,7 @@ powf_exp_c: .quad 0x40bc03f30399c376, 0x3ff000000001ea2a // c4/c8 // exact powers of two. (These are 1.0 + 1 ulp and 1.0 - 1ulp.) The other values will land somewhere in the // range [ 1.0 - 2**-8, 1.0 + 2**-7 ]. (Experimentally verified for all floats 1.0 <= x < 2.0.) // -.align (1<<3) +.align 3 powf_log2_c: .quad 0x3ff0000000000000, 0x8000000000000000 // 1, -log2l(1) .quad 0x3fefc00000000000, 0x3f872c7ba20f7327 // 0.992188, -log2l(0.992188) .quad 0x3fef80fe03f80fe0, 0x3f9715662c7f3dbc // 0.984496, -log2l(0.984496) @@ -659,7 +659,7 @@ ENTRY( powf ) jmp 9f -.align (1<<4) +.align 4 // return value in %xmm0 9: pop DI_P @@ -697,7 +697,7 @@ ___ipowf: movapd %xmm0, %xmm2 // r = x jmp 3f -.align (1<<4) +.align 4 // do{ 2: mulsd %xmm0, %xmm0 // x *= x test $1, %edx diff --git a/src/libm/Source/Intel/rint.S b/src/libm/Source/Intel/rint.S index a5a14d4a1..cf91fb666 100644 --- a/src/libm/Source/Intel/rint.S +++ b/src/libm/Source/Intel/rint.S @@ -6,13 +6,13 @@ // // -- Stephen Canon, January 2010 -.globl rint +.globl _rint #if defined __i386__ .text -.align (1<<4) -rint: +.align 4 +_rint: fldl 4(%esp) frndint ret @@ -24,8 +24,8 @@ absmask: .quad 0x7fffffffffffffff twop52: .quad 0x4330000000000000 .text -.align (1<<4) -rint: +.align 4 +_rint: movd %xmm0, %rcx mov %rcx, %rdx and absmask(%rip), %rcx // |x| diff --git a/src/libm/Source/Intel/rintf.S b/src/libm/Source/Intel/rintf.S index 7a1b2236e..7f381634d 100644 --- a/src/libm/Source/Intel/rintf.S +++ b/src/libm/Source/Intel/rintf.S @@ -7,9 +7,9 @@ // -- Stephen Canon, January 2010 .text -.align (1<<4) -.globl rintf -rintf: +.align 4 +.globl _rintf +_rintf: #if defined __i386__ movl 4(%esp), %ecx movss 4(%esp), %xmm0 diff --git a/src/libm/Source/Intel/rintl.S b/src/libm/Source/Intel/rintl.S index 10882d213..0a0d7e7b9 100644 --- a/src/libm/Source/Intel/rintl.S +++ b/src/libm/Source/Intel/rintl.S @@ -21,9 +21,9 @@ #endif .text -.align (1<<4) -.globl rintl -rintl: +.align 4 +.globl _rintl +_rintl: movswl exponent, %eax fldt input mov %eax, %edx diff --git a/src/libm/Source/Intel/round.S b/src/libm/Source/Intel/round.S index 0ead743db..fa1f3e957 100644 --- a/src/libm/Source/Intel/round.S +++ b/src/libm/Source/Intel/round.S @@ -25,9 +25,9 @@ #endif .text -.align (1<<4) -.globl round -round: +.align 4 +.globl _round +_round: movl 8(%esp), %ecx cmpl $0x43300000, %ecx fldl 4(%esp) @@ -67,17 +67,17 @@ round: #else //x86_64 -//.const -.align (1<<4) +.const +.align 4 one: .quad 0x3ff0000000000000 absmask:.quad 0x7fffffffffffffff half: .quad 0x3fe0000000000000 thresh: .quad 0x4330000000000000 .text -.align (1<<4) -.globl round -round: +.align 4 +.globl _round +_round: movd %xmm0, %rcx andq absmask(%rip), %rcx movsd absmask(%rip), %xmm2 diff --git a/src/libm/Source/Intel/roundf.S b/src/libm/Source/Intel/roundf.S index e980d94df..987df6f27 100644 --- a/src/libm/Source/Intel/roundf.S +++ b/src/libm/Source/Intel/roundf.S @@ -7,9 +7,9 @@ #if defined __i386__ .text -.align (1<<4) -.globl roundf -roundf: +.align 4 +.globl _roundf +_roundf: mov 4(%esp), %eax // load the input, x movss 4(%esp), %xmm0 and $0x7f800000, %eax // |x| @@ -31,13 +31,13 @@ roundf: cvttps2dq %xmm0, %xmm0 // raise inexact 1: flds 4(%esp) ret -.align (1<<4) +.align 4 2: je 3f // if |x| >= 0.5f, goto 3 andl $0x80000000, 4(%esp) // copysign(0.0, x) cvttps2dq %xmm0, %xmm0 // raise inexact flds 4(%esp) ret -.align (1<<4) +.align 4 3: addl $0x00800000, 4(%esp) andl $0xff800000, 4(%esp) // copysign(1.0, x) cvttps2dq %xmm0, %xmm0 // raise inexact @@ -46,18 +46,18 @@ roundf: #elif defined __x86_64__ -//.const -.align (1<<4) +.const +.align 4 mzero: .long 0x80000000 -.align (1<<4) +.align 4 expbit: .long 0x00800000 -.align (1<<4) +.align 4 expmask:.long 0xff800000 .text -.align (1<<4) -.globl roundf -roundf: +.align 4 +.globl _roundf +_roundf: movd %xmm0, %eax and $0x7f800000, %eax // |x| mov $23, %ecx @@ -79,12 +79,12 @@ roundf: paddd %xmm2, %xmm0 // add 0.5 (ish -- non-integral bits are garbage) pand %xmm3, %xmm0 // truncate 1: ret -.align (1<<4) +.align 4 2: je 3f // if |x| >= 0.5f, goto 3 cvttps2dq %xmm0, %xmm1 // raise inexact andps mzero(%rip), %xmm0 // copysign(0.0, x) ret -.align (1<<4) +.align 4 3: cvttps2dq %xmm0, %xmm1 // raise inexact paddd expbit(%rip), %xmm0 pand expmask(%rip), %xmm0 // copysign(1.0, x) diff --git a/src/libm/Source/Intel/scalbn.S b/src/libm/Source/Intel/scalbn.S index ec403550c..855d0ccfd 100644 --- a/src/libm/Source/Intel/scalbn.S +++ b/src/libm/Source/Intel/scalbn.S @@ -8,10 +8,10 @@ // // -- Stephen Canon, January 2010 -.globl scalbn -.globl ldexp -.globl scalb -.globl scalbln +.globl _scalbn +.globl _ldexp +.globl _scalb +.globl _scalbln #if defined __x86_64__ @@ -26,8 +26,8 @@ mthreek: .quad 0xc0a7700000000000 #define clamplo mthreek(%rip) .text -.align (1<<4) -scalb: +.align 4 +_scalb: movsd %xmm0, floatval pcmpeqd %xmm0, %xmm0 fldl floatval // load x on x87 @@ -45,8 +45,8 @@ L_nIsNaN: movapd %xmm1, %xmm0 // since n is a NaN, we just return n ret -.align (1<<4) -scalbln: +.align 4 +_scalbln: movsd %xmm0, floatval pcmpeqd %xmm0, %xmm0 fldl floatval // load x on x87 @@ -59,9 +59,9 @@ scalbln: cmovl %rdx, ln // n == -3000 jmp L_common -.align (1<<4) -scalbn: -ldexp: +.align 4 +_scalbn: +_ldexp: movsd %xmm0, floatval fldl floatval // load x on x87 pcmpeqd %xmm0, %xmm0 @@ -97,8 +97,8 @@ mthreek: .quad 0xc0a7700000000000 #define clamplo (mthreek-0b)(%ecx) .text -.align (1<<4) -scalb: +.align 4 +_scalb: call 0f 0: pop %ecx // conjure pic info movsd 12(%esp), %xmm1 // load n @@ -118,10 +118,10 @@ L_nIsNaN: fldl 12(%esp) // n is nan, return n ret -.align (1<<4) -scalbln: -scalbn: -ldexp: +.align 4 +_scalbln: +_scalbn: +_ldexp: mov 12(%esp), n // load n fldl floatval // load x on x87 fld1 diff --git a/src/libm/Source/Intel/scalbnf.S b/src/libm/Source/Intel/scalbnf.S index 7c8a776ad..d025d492b 100644 --- a/src/libm/Source/Intel/scalbnf.S +++ b/src/libm/Source/Intel/scalbnf.S @@ -8,17 +8,17 @@ .text -.globl scalblnf -.globl scalbnf -.globl ldexpf +.globl _scalblnf +.globl _scalbnf +.globl _ldexpf #if defined __x86_64__ #define n %edi #define ln %rdi -.align (1<<4) -scalblnf: +.align 4 +_scalblnf: cvtss2sd %xmm0, %xmm0 // (double)x mov $300, %rdx cmp %rdx, ln // if n > 300 @@ -28,9 +28,9 @@ scalblnf: cmovl %rdx, ln // n == -300 jmp L_common -.align (1<<4) -scalbnf: -ldexpf: +.align 4 +_scalbnf: +_ldexpf: cvtss2sd %xmm0, %xmm0 // (double)x mov $300, %edx cmp %edx, n // if n > 300 @@ -50,10 +50,10 @@ L_common: #define n %eax -.align (1<<4) -scalblnf: -scalbnf: -ldexpf: +.align 4 +_scalblnf: +_scalbnf: +_ldexpf: cvtss2sd 4(%esp), %xmm0 // (double)x mov 8(%esp), n mov $300, %edx diff --git a/src/libm/Source/Intel/scalbnl.S b/src/libm/Source/Intel/scalbnl.S index eab14a5a1..c9b828491 100644 --- a/src/libm/Source/Intel/scalbnl.S +++ b/src/libm/Source/Intel/scalbnl.S @@ -8,9 +8,9 @@ .text -.globl scalblnl -.globl scalbnl -.globl ldexpl +.globl _scalblnl +.globl _scalbnl +.globl _ldexpl #if defined __x86_64__ @@ -20,8 +20,8 @@ #define ln %rdi #define nw %di -.align (1<<4) -scalblnl: +.align 4 +_scalblnl: fldt 8(%rsp) // load x fld1 fstpt floatval // conjure 1.0L @@ -32,9 +32,9 @@ scalblnl: jl L_bigNegativeN // carefully. jmp L_scaleX -.align (1<<4) -scalbnl: -ldexpl: +.align 4 +_scalbnl: +_ldexpl: fldt 8(%rsp) // load x #elif defined __i386__ @@ -44,10 +44,10 @@ ldexpl: #define n %eax #define nw %ax -.align (1<<4) -scalblnl: -scalbnl: -ldexpl: +.align 4 +_scalblnl: +_scalbnl: +_ldexpl: mov 20(%esp), n // load n fldt floatval // load x diff --git a/src/libm/Source/Intel/sinfcosf.S b/src/libm/Source/Intel/sinfcosf.S index 4b8f0b575..8c67739ab 100644 --- a/src/libm/Source/Intel/sinfcosf.S +++ b/src/libm/Source/Intel/sinfcosf.S @@ -9,14 +9,14 @@ .literal8 - .align (1<<3) + .align 3 Half: .double .5 - //.const + .const - .align (1<<4) + .align 4 /* Coefficients to calculate x*(x**4+c0*x**2+c1) * c4*(x**4+c2*x**2+c3). @@ -154,9 +154,9 @@ C4: .double 0.076492480587904088 Exhaustive testing proved this routine returns faithfully rounded results. */ - .align (1<<5) - .globl sinf -sinf: + .align 5 + .globl _sinf +_sinf: // Put x into an integer register. #if defined __i386__ @@ -361,9 +361,9 @@ HandleNaN: Exhaustive testing proved this routine returns faithfully rounded results. */ - .align (1<<5) - .globl cosf -cosf: + .align 5 + .globl _cosf +_cosf: // This code is identical to _sinf except for the addition of Half. // Put x into an integer register. diff --git a/src/libm/Source/Intel/sinh.S b/src/libm/Source/Intel/sinh.S index b1623f5e0..cf9cd6994 100755 --- a/src/libm/Source/Intel/sinh.S +++ b/src/libm/Source/Intel/sinh.S @@ -12,8 +12,8 @@ #include #include "abi.h" -//.const -.align (1<<4) +.const +.align 4 // Polynomial coefficients, offset from exp2table .quad 0x3f55e52272e0eaec, 0x3f55e52272e0eaec // c4 .quad 0x401cc9eea1e24220, 0x401cc9eea1e24220 // c3/c4 @@ -161,7 +161,7 @@ small_poly: .quad 0x3fc5555555555555 .quad 0x3de61bfa2e91919a .literal8 -.align (1<<3) +.align 3 one_n7: .quad 0x3f80000000000000 lge_p7: .quad 0x40671547652b82fe lge_hi: .quad 0x3ff7154760000000 @@ -178,7 +178,7 @@ huge_val: .quad 0x7fefffffffffffff #else #define RELATIVE_ADDR(_a) (_a)-sinh_body(%ecx) -.align (1<<4) +.align 4 sinh_pic: movl (%esp), %ecx ret diff --git a/src/libm/Source/Intel/sinhf.S b/src/libm/Source/Intel/sinhf.S index 5d62dcfe9..0a26d4b0d 100644 --- a/src/libm/Source/Intel/sinhf.S +++ b/src/libm/Source/Intel/sinhf.S @@ -47,9 +47,9 @@ // For the "uninteresting range", the code is taken directly from expf. Read the // comments in that file for more information. -//.const +.const -.align (1<<4) +.align 4 .quad 0x3f811111111110fe, 0x3fa555f78359bc34 // c5, c4 = 0.0083333..., 0.0416715 .quad 0x4034000000000018, 0x4027ff4991a5ebc5 // c3/c5 = 0.1666666.../c5, c2/c4 = 0.5/c4 .quad 0x0000000000000000, 0x3ff0000000000000 // 0, 1 @@ -252,7 +252,7 @@ sixteen: .quad 0x4030000000000000 // 16 #define RELATIVE_ADDR(_a) (_a)-sinhf_body( %ecx ) #define RELATIVE_ADDR_B(_a) (_a)-sinhf_body_eleven( %ecx ) -.align (1<<4) +.align 4 sinhf_pic: movl (%esp), %ecx // Copy address of this instruction to %ecx ret diff --git a/src/libm/Source/Intel/tanf.S b/src/libm/Source/Intel/tanf.S index da1dfacce..7870cd066 100644 --- a/src/libm/Source/Intel/tanf.S +++ b/src/libm/Source/Intel/tanf.S @@ -9,15 +9,15 @@ .literal8 - .align (1<<3) + .align 3 NegativeOne: .double -1 - //.const + .const - .align (1<<4) + .align 4 /* Coefficients to calculate: @@ -167,9 +167,9 @@ c20: .double +0.58807104225499649417, +3.82127246397188494330 Exhaustive testing proved this routine returns faithfully rounded results. */ - .align (1<<5) - .globl tanf -tanf: + .align 5 + .globl _tanf +_tanf: // Put x into an integer register. #if defined __i386__ diff --git a/src/libm/Source/Intel/tanh.S b/src/libm/Source/Intel/tanh.S index 74a5028e1..0fcea800a 100644 --- a/src/libm/Source/Intel/tanh.S +++ b/src/libm/Source/Intel/tanh.S @@ -17,8 +17,8 @@ Tables and Constants ****************************************************************************/ -//.const -.align (1<<4) +.const +.align 4 abs_mask: .quad 0x7fffffffffffffff, 0x0000000000000000 four_exp: .quad 0x0020000000000000, 0x0000000000000000 one: .quad 0x3ff0000000000000, 0x0000000000000000 @@ -324,7 +324,7 @@ small_poly: .quad 0xbf29111400a41fbf, 0x0000000000000000 // c .literal8 -.align (1<<3) +.align 3 m2_lge_p7: .quad 0xc0771547652b82fe m2_lge: .quad 0xc0071547652b82fe m2_lge_hi: .quad 0xc007154760000000 diff --git a/src/libm/Source/Intel/tanhf.S b/src/libm/Source/Intel/tanhf.S index 3de5b1ddb..7959eda4d 100644 --- a/src/libm/Source/Intel/tanhf.S +++ b/src/libm/Source/Intel/tanhf.S @@ -11,13 +11,11 @@ #include #include "abi.h" -.type tanhf, @function - // This is identical to sinhf with some indices permuted to compute tanh instead. // Read the detailed comments in that file for more information. -//.const -.align (1<<4) +.const +.align 4 .quad 0x3f811111111110fe, 0x3fa555f78359bc34 // c5, c4 = 0.0083333..., 0.0416715 .quad 0x4034000000000018, 0x4027ff4991a5ebc5 // c3/c5 = 0.1666666.../c5, c2/c4 = 0.5/c4 tanhf_table: .quad 0x0000000000000000, 0x3ff0000000000000 // sinh(0/16), cosh(0/16) @@ -210,7 +208,7 @@ sixteen: .quad 0x4030000000000000 // 16 #define RELATIVE_ADDR(_a) (_a)-tanhf_body( %ecx ) #define RELATIVE_ADDR_B(_a) (_a)-tanhf_body_eleven( %ecx ) -.align (1<<4) +.align 4 tanhf_pic: movl (%esp), %ecx // Copy address of this instruction to %ecx ret diff --git a/src/libm/Source/Intel/trunc.S b/src/libm/Source/Intel/trunc.S index 4c2109fdd..e9e5bf616 100644 --- a/src/libm/Source/Intel/trunc.S +++ b/src/libm/Source/Intel/trunc.S @@ -25,9 +25,9 @@ #endif .text -.align (1<<4) -.globl trunc -trunc: +.align 4 +.globl _trunc +_trunc: movl 8(%esp), %ecx cmpl $0x43300000, %ecx fldl 4(%esp) @@ -47,17 +47,17 @@ trunc: #else //x86_64 -//.const -.align (1<<4) +.const +.align 4 one: .quad 0x3ff0000000000000 absmask:.quad 0x7fffffffffffffff half: .quad 0x3fe0000000000000 thresh: .quad 0x4330000000000000 .text -.align (1<<4) -.globl trunc -trunc: +.align 4 +.globl _trunc +_trunc: movd %xmm0, %rcx andq absmask(%rip), %rcx movsd absmask(%rip), %xmm2 diff --git a/src/libm/Source/Intel/truncf.S b/src/libm/Source/Intel/truncf.S index 0a3ceafa4..afd2443b5 100644 --- a/src/libm/Source/Intel/truncf.S +++ b/src/libm/Source/Intel/truncf.S @@ -12,9 +12,9 @@ #if defined __i386__ .text -.align (1<<4) -.globl truncf -truncf: +.align 4 +.globl _truncf +_truncf: movss 4(%esp), %xmm0 // load argument testl $(kHasSSE4_1), cpubits jz 0f @@ -24,7 +24,7 @@ truncf: flds 4(%esp) // ret -.align (1<<4) +.align 4 0: mov 4(%esp), %eax // load the input, x and $0x7f800000, %eax // |x| mov $23, %ecx @@ -40,7 +40,7 @@ truncf: 1: flds 4(%esp) ret -.align (1<<4) +.align 4 2: // Handle |x| < 1.0 here. andl $0x80000000, 4(%esp) // copysign(0.0, x) cvttps2dq %xmm0, %xmm0 // raise inexact @@ -49,14 +49,14 @@ truncf: #elif defined __x86_64__ -//.const -.align (1<<4) +.const +.align 4 mzero: .long 0x80000000 .text -.align (1<<4) -.globl truncf -truncf: +.align 4 +.globl _truncf +_truncf: movd %xmm0, %eax and $0x7f800000, %eax // |x| mov $23, %ecx @@ -71,7 +71,7 @@ truncf: cvttps2dq %xmm0, %xmm1 // raise inexact andps %xmm2, %xmm0 // mask off non-integral bits 1: ret -.align (1<<4) +.align 4 2: cvttps2dq %xmm0, %xmm1 // raise inexact andps mzero(%rip), %xmm0 // copysign(0.0, x) ret