diff options
40 files changed, 1365 insertions, 1463 deletions
diff --git a/.gitignore b/.gitignore index 53349ead37..83808394eb 100644 --- a/.gitignore +++ b/.gitignore @@ -250,3 +250,7 @@ Temporary Items # Ignore folders created by the test build TestWrappers_x64_debug TestWrappers_x64_release + +Vagrantfile +.vagrant + diff --git a/CMakeLists.txt b/CMakeLists.txt index aa0ad09ef8..56e4ee84cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,16 @@ project(CoreCLR) if(CMAKE_SYSTEM_NAME STREQUAL Linux) set(CLR_CMAKE_PLATFORM_UNIX 1) set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_LINUX 1) endif(CMAKE_SYSTEM_NAME STREQUAL Linux) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(CLR_CMAKE_PLATFORM_UNIX 1) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_DARWIN 1) + set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>") +endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + # Build a list of compiler definitions by putting -D in front of each define. function(get_compile_definitions DefinitionName) # Get the current list of definitions @@ -126,7 +134,7 @@ if (WIN32) endif (CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64) elseif (CLR_CMAKE_PLATFORM_UNIX) - # Set flag to indicate if this will be a 64bit Linux build + # Set flag to indicate if this will be a 64bit build if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) set(IS_64BIT_BUILD 1) endif (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) @@ -285,17 +293,24 @@ endif (WIN32) if (CLR_CMAKE_PLATFORM_UNIX) add_definitions(-DPLATFORM_UNIX=1) - add_definitions(-D__LINUX__=1) add_definitions(-DFEATURE_PAL_SXS) if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) - message("Detected Linux x86_64") - add_definitions(-DLINUX64) add_definitions(-DBIT64=1) add_definitions(-DFEATURE_PAL) else (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) message(FATAL_ERROR "error: Detected non x86_64 target processor. Not supported!") endif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) + + if(CLR_CMAKE_PLATFORM_LINUX) + add_definitions(-D__LINUX__=1) + message("Detected Linux x86_64") + add_definitions(-DLINUX64) + endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_DARWIN) + message("Detected OSX x86_64") + add_definitions(-D_XOPEN_SOURCE) + endif(CLR_CMAKE_PLATFORM_DARWIN) endif(CLR_CMAKE_PLATFORM_UNIX) @@ -62,6 +62,21 @@ check_prereqs() build_coreclr() { + #determine nproc in a platform independent way + NPROCS=1 + OS=`uname` + + if [ $OS = "Linux" ]; then + NPROCS=`grep -c ^processor /proc/cpuinfo` + elif [ $OS = "Darwin" ]; then + NPROCS=`sysctl hw.ncpu | awk '{print $2}'` + else + echo Failed to detect build platform. + exit 1 + fi + + NPROCS=1 + # All set to commence the build echo Commencing build of native components for $__BuildArch/$__BuildType diff --git a/src/coreclr/hosts/unixcorerun/corerun.cpp b/src/coreclr/hosts/unixcorerun/corerun.cpp index 2d5f129398..4dba489579 100644 --- a/src/coreclr/hosts/unixcorerun/corerun.cpp +++ b/src/coreclr/hosts/unixcorerun/corerun.cpp @@ -17,7 +17,11 @@ #include <set> // The name of the CoreCLR native runtime DLL. +#if defined(__APPLE__) +static const char * const coreClrDll = "libcoreclr.dylib"; +#else static const char * const coreClrDll = "libcoreclr.so"; +#endif // Windows types used by the ExecuteAssembly function typedef unsigned int DWORD; diff --git a/src/debug/di/amd64/floatconversion.S b/src/debug/di/amd64/floatconversion.S index bde59abaf1..cea9cc97df 100644 --- a/src/debug/di/amd64/floatconversion.S +++ b/src/debug/di/amd64/floatconversion.S @@ -9,4 +9,4 @@ LEAF_ENTRY FPFillR8, _TEXT movdqa xmm0, [rdi] ret -LEAF_END FPFillR8 +LEAF_END FPFillR8, _TEXT diff --git a/src/debug/ee/amd64/dbghelpers.S b/src/debug/ee/amd64/dbghelpers.S index f652312175..7debc0e26e 100644 --- a/src/debug/ee/amd64/dbghelpers.S +++ b/src/debug/ee/amd64/dbghelpers.S @@ -17,7 +17,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, FuncEvalHijackPersonalityRoutine END_PROLOGUE mov [rsp], rdi - call FuncEvalHijackWorker + call C_FUNC(FuncEvalHijackWorker) // // The following nop is crucial. It is important that the OS *not* recognize @@ -67,7 +67,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, ExceptionHijackPersonalityRoutine mov [rsp + 18h], rax // DD Hijack primitive already set the stack. So just make the call now. - call ExceptionHijackWorker + call C_FUNC(ExceptionHijackWorker) // // The following nop is crucial. It is important that the OS *not* recognize diff --git a/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/dlls/mscoree/coreclr/CMakeLists.txt index d17df90ffb..8393cbc0dd 100644 --- a/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -12,14 +12,17 @@ set(END_LIBRARY_GROUP) else(WIN32) add_definitions(-DNO_CRT_INIT) + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) # This option is necessary to ensure that the overloaded delete operator defined inside # of the utilcode will be used instead of the standard library delete operator. -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic-functions") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic-functions") # The following linked options can be inserted into the linker libraries list to # ensure proper resolving of circular references between a subset of the libraries. -set(START_LIBRARY_GROUP -Wl,--start-group) -set(END_LIBRARY_GROUP -Wl,--end-group) + set(START_LIBRARY_GROUP -Wl,--start-group) + set(END_LIBRARY_GROUP -Wl,--end-group) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) endif (WIN32) diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 6eb2f91007..48f7ebc8a3 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -3280,37 +3280,10 @@ GetModuleFileNameW( #define GetModuleFileName GetModuleFileNameA #endif -#ifdef __APPLE__ -// Get the base address of a module given an address in that module -PALAPI -LPCVOID -PAL_GetModuleBaseFromAddress(LPCVOID pAddress); - -// Retrieve the UUID in the image. -PALAPI -BOOL -PAL_GetUUIDOfImage(LPCVOID pImageBase, BYTE * pUUID); - -// Retrieve the version stored in the Info.plist file in the CoreCLR bundle. -PALAPI -DWORD -PAL_GetVersionString(IN WCHAR * pwszCoreClrFullPath, - IN OUT WCHAR * pwszVersionString, - IN DWORD cchVersionStringBuffer, - OUT DWORD *pcchVersionStringBufferRequired); - -PALAPI -DWORD -PAL_GetCoreCLRVersionString( - IN OUT WCHAR * pwszVersionString, - IN DWORD cchVersionStringBuffer, - OUT DWORD *pcchVersionStringBufferRequired); -#else // __APPLE__ // Get base address of the coreclr module PALAPI LPCVOID PAL_GetCoreClrModuleBase(); -#endif // __APPLE__ PALIMPORT LPVOID @@ -6139,7 +6112,7 @@ PAL_CppRethrow(); // #ifdef PLATFORM_UNIX #ifdef __APPLE__ -#define MAKEDLLNAME_W(name) L"lib" name L".dylib" +#define MAKEDLLNAME_W(name) u"lib" name u".dylib" #define MAKEDLLNAME_A(name) "lib" name ".dylib" #elif defined(_AIX) #define MAKEDLLNAME_W(name) L"lib" name L".a" diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index e983b001c8..9401e00592 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -9,8 +9,22 @@ include_directories(include) # Compile options +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + add_definitions(-D_TARGET_MAC64) + set(PLATFORM_SOURCES + arch/i386/context.clang.s + arch/i386/dispatchexceptionwrapper.S + exception/machexception.cpp + exception/machmessage.cpp + locale/locale.cpp + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + add_definitions(-D__LINUX__=1) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) + add_definitions(-DPLATFORM_UNIX=1) -add_definitions(-D__LINUX__=1) add_definitions(-DLP64COMPATIBLE=1) add_definitions(-DFEATURE_PAL=1) add_definitions(-DCORECLR=1) @@ -128,14 +142,30 @@ set(SOURCES add_library(CoreClrPal STATIC ${SOURCES} + ${PLATFORM_SOURCES} ) target_link_libraries(CoreClrPal - pthread - rt dl m ) +if(CMAKE_SYSTEM_NAME STREQUAL Linux) +target_link_libraries(CoreClrPal + pthread + rt +) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + find_library(COREFOUNDATION CoreFoundation) + find_library(CORESERVICES CoreServices) + find_library(SECURITY Security) + target_link_libraries(CoreClrPal + ${COREFOUNDATION} + ${CORESERVICES} + ${SECURITY} + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) add_subdirectory(examples) diff --git a/src/pal/src/arch/i386/context.clang.s b/src/pal/src/arch/i386/context.clang.s new file mode 100644 index 0000000000..b13de6d7da --- /dev/null +++ b/src/pal/src/arch/i386/context.clang.s @@ -0,0 +1,15 @@ + .text + .globl _DBG_CheckStackAlignment + +_DBG_CheckStackAlignment: + // Prolog - at this point we are at aligned - 8 (for the call) + pushq %rbp // aligned -16 + movq %rsp, %rbp + + testl $0xf,%esp // can get away with esp even on AMD64. + jz .+3 + int3 + + // Epilog + popq %rbp + ret diff --git a/src/pal/src/arch/i386/context.cpp b/src/pal/src/arch/i386/context.cpp index 7b5c1fab0d..ffccf0f67b 100644 --- a/src/pal/src/arch/i386/context.cpp +++ b/src/pal/src/arch/i386/context.cpp @@ -1143,7 +1143,7 @@ CONTEXT_SetThreadContextOnPort( // the xmm values) then we don't have values for the other set. This is a problem since Mach only // supports setting both groups as a single unit. So in this case we'll need to fetch the current // values first. - if (lpContext->ContextFlags & CONTEXT_ALL_FLOATING != + if ((lpContext->ContextFlags & CONTEXT_ALL_FLOATING) != CONTEXT_ALL_FLOATING) { mach_msg_type_number_t StateCountGet = StateCount; @@ -1321,10 +1321,11 @@ Function: This function interrupts otherwise. --*/ // Bullseye has parsing problems if "asm" comes after VOID -asm VOID + +#ifndef __clang__ +VOID DBG_CheckStackAlignment() { -#ifndef __llvm__ #ifdef _X86_ // Prolog - at this point we are at aligned - 4 (for the call) push ebp // aligned - 8 @@ -1337,16 +1338,14 @@ DBG_CheckStackAlignment() #else #error Unexpected architecture. #endif -#endif // !__llvm__ test esp,STACK_ALIGN_REQ-1 // can get away with esp even on AMD64. jz .+3 int 3 -#ifndef __llvm__ // Epilog leave -#endif // !__llvm__ } +#endif // !__clang__ #endif // DEBUG && APPLE diff --git a/src/pal/src/arch/i386/dispatchexceptionwrapper.s b/src/pal/src/arch/i386/dispatchexceptionwrapper.s index 831ce93f54..952e5a0cbb 100644 --- a/src/pal/src/arch/i386/dispatchexceptionwrapper.s +++ b/src/pal/src/arch/i386/dispatchexceptionwrapper.s @@ -18,7 +18,7 @@ // increase the size of the function to include a call statement, // even though it will never be executed. -#if defined(_AMD64_) +#if defined(__x86_64__) #define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionmmmmmmP8_CONTEXTP17_EXCEPTION_RECORD #else //!defined(_AMD64_) #define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionP8_CONTEXTP17_EXCEPTION_RECORD diff --git a/src/pal/src/config.h b/src/pal/src/config.h index 554061ddfc..904d85e27f 100644 --- a/src/pal/src/config.h +++ b/src/pal/src/config.h @@ -1,528 +1,5 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -/* config.h. Generated from config.h.in by configure. */ -/*++ - - - -Module Name: - - include/pal/config.h.in - - process this file with configure to create the PAL's configuration header - ---*/ - -#ifndef _PAL_CONFIG_H_INCLUDED -#define _PAL_CONFIG_H_INCLUDED 1 - -/*++ -_NO_DEBUG_MESSAGES_ : configure option --disable-dbgmsg - -This turns off compilation of TRACE, WARN, ERROR and ENTRY debug messages ---*/ - -#define _NO_DEBUG_MESSAGES_ 0 - - -/*++ -CHECK_TRACE_SPECIFIERS : configure option --enable-tracechecks - -Ask gcc to check the format specifiers used in trace macros. Not on by default, -because gcc will complain about %I64d and %S ---*/ - -#define CHECK_TRACE_SPECIFIERS 0 - -/* Define as 1 if you have wchar.h. */ -#define HAVE_WCHAR_H 1 - -/* Define as 1 if you have ieeefp.h. */ -#define HAVE_IEEEFP_H 0 - -/* Define as 1 if you have alloca.h. */ -#define HAVE_ALLOCA_H 1 - -/* Define as 1 if you have stdint.h. */ -#define HAVE_STDINT_H 1 - -/* Define as 1 if you have netdb.h. */ -#define HAVE_NETDB_H 1 - -/* Define as 1 if you have inttypes.h. */ -#define HAVE_INTTYPES_H 1 - -/* Define as 1 if you have sys/vmparam.h. */ -#define HAVE_SYS_VMPARAM_H 0 - -/* Define as 1 if you have mach/vm_types.h. */ -#define HAVE_MACH_VM_TYPES_H 0 - -/* Define as 1 if you have mach/vm_param.h. */ -#define HAVE_MACH_VM_PARAM_H 0 - -/* Define as 1 if you have sys/param.h. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define as 1 if you have sys/filio.h. */ -#define HAVE_SYS_FILIO_H 0 - -/* Define as 1 if you have sys/sockio.h. */ -#define HAVE_SYS_SOCKIO_H 0 - -/* Define as 1 if you have procfs.h. */ -#define HAVE_PROCFS_H 0 - -/* Define as 1 if you have sys/event.h. */ -#define HAVE_KQUEUE 0 - -// Define as 1 if you are using dylibs and need dlcompat. -#define NEED_DLCOMPAT 0 - -/* Define as 1 if you have crt_externs.h. */ -#define HAVE_CRT_EXTERNS_H 0 - -// Define as 1 if you have sys/time.h. -#define HAVE_SYS_TIME_H 1 - -/* Define as 1 if you have pthread_np.h */ -#define HAVE_PTHREAD_NP_H 0 - -/* Define as 1 if you have sys/lwp.h */ -#define HAVE_SYS_LWP_H 0 - -/* Define as 1 if you have towlower. */ -#define HAVE_TOWLOWER 0 - -/* Define as 1 if struct stat contains st_atimespec, etc. */ -#define HAVE_STAT_TIMESPEC 0 - -/* Define as 1 if struct stat contains st_atimensec, etc. */ -#define HAVE_STAT_NSEC 0 - -/* Define as 1 if struct sockaddr contains sa_len. */ -#define HAVE_SOCKADDR_SA_LEN 0 - -/* Define as 1 if getpwuid_r function exists. */ -#define HAVE_GETPWUID_R 1 - -/* Define as 1 if you have extern char *tzname. */ -#define HAVE_TZNAME 1 - -/* Define as 1 if you have extern long int timezone. */ -#define HAVE_TIMEZONE_VAR 0 - -/* Define as 1 if struct tm has tm_gmtoff. */ -#define HAVE_TM_GMTOFF 1 - -// Define as 1 if the BSD struct reg is supported. -#define HAVE_BSD_REGS_T 0 - -// Define as 1 if ptrace's struct pt_regs is supported. -#define HAVE_PT_REGS 1 - -// Define as 1 if mcontext_t contains a gregset_t. -#define HAVE_GREGSET_T 1 - -// Define as 1 if realpath() does not require that the last path component -// be a file. -#define REALPATH_SUPPORTS_NONEXISTENT_FILES 0 - -// Define as 1 if sscanf supports the "%ll" format. -#define SSCANF_SUPPORT_ll 0 - -// Define as 1 if sscanf has trouble parsing a float from -// something like "12.34e" (e.g. AIX) -#define SSCANF_CANNOT_HANDLE_MISSING_EXPONENT 0 - -// Define as 1 if snprintf works correctly for large values of n. -#define HAVE_LARGE_SNPRINTF_SUPPORT 1 - -/* Define as 1 if select() on a fifo that has not had any data - written to it returns that data is available for reading. */ -#define HAVE_BROKEN_FIFO_SELECT 0 - -/* Define as 1 if kevent() on a fifo returns EV_ERROR. */ -#define HAVE_BROKEN_FIFO_KEVENT 1 - -// Define as 1 if ftruncate correctly returns failure on large lengths. -#define HAVE_FTRUNCATE_LARGE_LENGTH_SUPPORT 0 - -// Define as 1 if ftruncate returns failure but extends the file anyway. -#define HAS_FTRUNCATE_LENGTH_ISSUE 0 - -/* Define as 1 if SYS_yield is a supported syscall. */ -#define HAVE_YIELD_SYSCALL 0 - -// Define as 1 if pthreads are Mach threads. -#define HAVE_MACH_THREADS 0 - -// Define as 1 if pthreads are Solaris threads. -#define HAVE_SOLARIS_THREADS 0 - -// Define as 1 if pthreads has pthread_suspend -#define HAVE_PTHREAD_SUSPEND 0 - -// Define as 1 if pthreads has pthread_suspend_np -#define HAVE_PTHREAD_SUSPEND_NP 0 - -// Define as 1 if pthreads has pthread_continue -#define HAVE_PTHREAD_CONTINUE 0 - -// Define as 1 if pthreads has pthread_resume_np -#define HAVE_PTHREAD_RESUME_NP 0 - -// Define as 1 if pthreads has pthread_continue_np -#define HAVE_PTHREAD_CONTINUE_NP 0 - -// Define as 1 if mkstemp64 is used instead of mkstemp -#define MKSTEMP64_IS_USED_INSTEAD_OF_MKSTEMP 0 - -// Define as 1 if open64 is used instead of open -#define OPEN64_IS_USED_INSTEAD_OF_OPEN 0 - -// Define as 1 if pthread has thread_self -#define HAVE_THREAD_SELF 0 - -// Define as 1 if pthread has _lwp_self -#define HAVE__LWP_SELF 0 - -// Define as 1 if sched_get_priority_[min|max] is supported -#define HAVE_SCHED_GET_PRIORITY 1 - -// Define as the hardcoded min and max thread priority (for platforms where -// sched_get_priority_[min|max] does not exist -#define PAL_THREAD_PRIORITY_MIN 0 -#define PAL_THREAD_PRIORITY_MAX 0 - -// Define as 1 if pthread_setschedparam requires special privileges -#define SET_SCHEDPARAM_NEEDS_PRIVS 0 - -/* Define as 1 if Mach exceptions are supported. */ -#define HAVE_MACH_EXCEPTIONS 0 - -// Define as 1 if Mach's vm_read and vm_write are supported. -#define HAVE_VM_READ 0 - -/* Define as 1 if sigreturn is supported. */ -#define HAVE_SIGRETURN 0 - -/* Define as 1 if _thread_sys_sigreturn is supported. */ -#define HAVE__THREAD_SYS_SIGRETURN 0 - -// Define as 1 if setcontext is supported. -#define HAVE_SETCONTEXT 1 - -// Define as 1 if getcontext is supported. -#define HAVE_GETCONTEXT 1 - -// Define as 1 if copysign is supported. -#define HAVE_COPYSIGN 1 - -// Define as 1 if gethrtime (Solaris/HPUX) is supported. -#define HAVE_GETHRTIME 0 - -// Define as 1 if read_real_time (AIX) is supported. -#define HAVE_READ_REAL_TIME 0 - -// Define as 1 if fsync is supported. -#define HAVE_FSYNC 1 - -// Define as 1 if current platform has a working gettimeofday -#define HAVE_WORKING_GETTIMEOFDAY 1 - -// Define as 1 if current platform has a working clock_gettime -#define HAVE_WORKING_CLOCK_GETTIME 1 - -// Define as 1 if clock_gettime supports CLOCK_MONOTONIC. -#define HAVE_CLOCK_MONOTONIC 1 - -/* Define as 1 if futimes is supported. */ -#define HAVE_FUTIMES 1 - -/* Define as 1 if utimes is supported. */ -#define HAVE_UTIMES 1 - -/* Define as 1 if sysctl is supported. */ -#define HAVE_SYSCTL 1 - -/* Define as 1 if sysconf is supported. */ -#define HAVE_SYSCONF 1 - -/* Define as 1 if strtok_r is supported. */ -#define HAVE_STRTOK_R 1 - -/* Define as 1 if localtime_r is supported. */ -#define HAVE_LOCALTIME_R 1 - -/* Define as 1 if ctime_r is supported. */ -#define HAVE_CTIME_R 1 - -/* Defined as 1 if gmtime_r is supported. */ -#define HAVE_GMTIME_R 1 - -/* Define as 1 if timegm is supported. */ -#define HAVE_TIMEGM 1 - -/* Define as 1 if _snwprintf is supported. */ -#define HAVE__SNWPRINTF 0 - -// Define as 1 if poll is supported. -#define HAVE_POLL 1 - -// Define as 1 if INFTIM is defined. -#define HAVE_INFTIM 0 - -// Define as 1 if CHAR_BIT is defined -#define HAVE_CHAR_BIT 0 - -/* Define as 1 if directio is supported. */ -#define HAVE_DIRECTIO 0 - -/* Define as 1 if use of directio is disabled, - even if HAVE_DIRECTIO is defined. */ -#define DIRECTIO_DISABLED 0 - -/* Define as 1 if vm_allocate is supported. */ -#define HAVE_VM_ALLOCATE 0 - -/* Define as 1 if statfs is supported. */ -#define HAVE_STATFS 0 - -/* Define as 1 if statvfs is supported. */ -#define HAVE_STATVFS 1 - -/* Define as 1 if statvfs64 prototype is broken. */ -#define STATVFS64_PROTOTYPE_BROKEN 0 - -/* Define as 1 if siginfo_t is supported. */ -#define HAVE_SIGINFO_T 1 - -/* Define as 1 if ucontext_t is supported. */ -#define HAVE_UCONTEXT_T 1 - -/* Defined to sizeof(off_t). */ -#define SIZEOF_OFF_T 8 - -/* Define as 1 if in_addr_t is supported. */ -#define HAVE_IN_ADDR_T 0 - -// Define as 1 if caddr_t is supported. -#define HAVE_CADDR_T 0 - -/* Define as 1 if socklen_t is supported. */ -#define HAVE_SOCKLEN_T 1 - -/* Define as 1 if sockaddr_ext is supported. */ -#define HAVE_SOCKADDR_EXT 0 - -/* Define as 1 if pthread_rwlock_t is supported. */ -#define HAVE_PTHREAD_RWLOCK_T 1 - -/* Define as 1 if Core Foundation is supported (Darwin/Mac OS X only). */ -#define HAVE_COREFOUNDATION 0 - -/* Define as 1 if _NSGetEnviron is supported (Darwin/Mac OS X only). */ -#define HAVE__NSGETENVIRON 0 - -/* Define this if debug channel output should be appended to existing files - instead of overwriting */ -/* #undef _PAL_APPEND_DBG_OUTPUT_ */ - -/* Define as 1 if mmap() can map a file descriptor for /dev/zero */ -#define HAVE_MMAP_DEV_ZERO 1 - -// Define as 1 if mmap() ignores its hint parameter. -#define MMAP_IGNORES_HINT 0 - -// Define as 1 if mmap() ignores its protection parameter when -// mapping anonymous pages. -#define MMAP_ANON_IGNORES_PROTECTION 0 - -// Define as 1 if mmap() allows remapping previously mapped pages -#define MMAP_DOESNOT_ALLOW_REMAP 0 - -// Define as 1 if there cannot be more than one shared mapping of a file -// region per process at the same time -#define ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS 0 - -// Define as 1 if pthread_create() modifies errno when it succeeds. -#define PTHREAD_CREATE_MODIFIES_ERRNO 0 - -// Define as 1 if sem_init() modifies errno when it succeeds. -#define SEM_INIT_MODIFIES_ERRNO 0 - -// Define as 1 if prwatch_t is supported -#define HAVE_PRWATCH_T 0 - -// Define as 1 if /proc/<pid>/ctl is supported. -#define HAVE_PROCFS_CTL 0 - -// Define as the name of the memory file in /proc/<pid> -#define PROCFS_MEM_NAME "" - -// Define as 1 if including sys/user.h will result in -// _DEBUG being defined -#define USER_H_DEFINES_DEBUG 0 - -// Define as 1 if close(fd) blocks until there is any outstanding -// syscall using fd (e.g. AIX) -#define CLOSE_BLOCKS_ON_OUTSTANDING_SYSCALLS 0 - -// Define as 1 if sendto returns EHOSTUNREACH when sendto'ing using a -// "to" sockaddr which does not match the socket address family -// (e.g. AIX) -#define SENDTO_RETURNS_UNREACH_ON_WRONG_AF 0 - -// Define as 1 if shutdown fails on connectionless sockets -// (e.g. AIX) -#define SHUTDOWN_FAILS_ON_CONNECTIONLESS_SOCKETS 1 - -// Define as 1 if it is possible to broadcast on a socket regardless of SO_BROADCAST -// (e.g. Solaris) -#define BROADCAST_ALLOWED_WITHOUT_SO_BROADCAST 0 - -// Define as 1 if SO_RCVTIMEO and SO_SNDTIMEO are not supported -// or are ignored -#define SO_TIMEO_NOT_SUPPORTED 0 - -// Define as 1 if write of 0 bytes to the console hangs. -#define WRITE_0_BYTES_HANGS_TTY 0 - -// Define as 1 if acos is compatible with Windows. -#define HAVE_COMPATIBLE_ACOS 1 - -// Define as 1 if asin is compatible with Windows. -#define HAVE_COMPATIBLE_ASIN 1 - -// Define as 1 if pow is compatible with Windows. -#define HAVE_COMPATIBLE_POW 0 - -// Define as 1 if pow returns -Inf when given a negative base and a -// large magnitude odd exponent. -#define HAVE_VALID_NEGATIVE_INF_POW 1 - -// Define as 1 if pow returns +Inf when given a negative base and a -// large magnitude even exponent. -#define HAVE_VALID_POSITIVE_INF_POW 1 - -// Define as 1 if atan2 is compatible with Windows. -#define HAVE_COMPATIBLE_ATAN2 1 - -// Define as 1 if exp is compatible with Windows. -#define HAVE_COMPATIBLE_EXP 1 - -// Define as 1 if log is compatible with Windows. -#define HAVE_COMPATIBLE_LOG 1 - -// Define as 1 if log10 is compatible with Windows. -#define HAVE_COMPATIBLE_LOG10 1 - -// Define as 1 if ttrace is supported -#define HAVE_TTRACE 0 - -// Define as 1 if calling dlopen() on a library which is already -// opened returns a different handle -#define RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN 0 - -// If 1, SetThreadPriority() will not actually modify the pthread priority -// for threads which aren't critical or idle -#define PAL_IGNORE_NORMAL_THREAD_PRIORITY 0 - -// Define as a macro that correctly calls ptrace for the platform, e.g.: -// #define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (void*)(addr), (data), 0) -// Note that for autconfig substitution to properly occur the argument list -// must not be present in this file -- it should only be in the appropriate -// AC_DEFINE statement -#define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (void*)(addr), (data)) - -// Define as the ptrace cmd value to attach to a process -#define PAL_PT_ATTACH PTRACE_ATTACH - -// Define as the ptrace cmd value to detach from a process -#define PAL_PT_DETACH PTRACE_DETACH - -// Define as the ptrace cmd value to read a word from a process's data space -#define PAL_PT_READ_D PTRACE_PEEKDATA - -// Define as the ptrace cmd value to write a word to a process's data space -#define PAL_PT_WRITE_D PTRACE_POKEDATA - -// Define as 1 if ISO locale names needs to be in lowercase -#define HAVE_LOWERCASE_ISO_NAME 0 - -// Define as 1 if ISO locale names need an underscore after -// the "ISO" in the name. -#define HAVE_UNDERSCORE_ISO_NAME 0 - -// Define as 1 if we have per-thread locales as defined in xlocale.h -#define HAVE_XLOCALE 0 - -// Define as 1 if ungetc dose not return EOF on write-only file -#define UNGETC_NOT_RETURN_EOF 1 - -// Define as 1 if malloc(0) returns null -#define MALLOC_ZERO_RETURNS_NULL 0 - -// Define as 1 if error function for glob takes specific parameters -#define ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS 1 - -// Define the ja_JP locale name -#define JA_JP_LOCALE_NAME "ja_JP_LOCALE_NOT_FOUND" - -// Define the ko_KR locale name -#define KO_KR_LOCALE_NAME "ko_KR_LOCALE_NOT_FOUND" - -// Define the zh_TW locale name -#define ZH_TW_LOCALE_NAME "zh_TW_LOCALE_NOT_FOUND" - -// Define as 1 if thread suspension uses signals -#define USE_SIGNALS_FOR_THREAD_SUSPENSION 1 - -// Define as 1 if platform has POSIX semaphores -#define HAS_POSIX_SEMAPHORES 1 - -// Define as 1 if suspending a thread while blocked on a lock can cause a hang -#define DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0 - -// Define as 1 if sigwait cannot take a full sigset as a valid parameter -#define SIGWAIT_FAILS_WHEN_PASSED_FULL_SIGSET 0 - -// Define as 1 if a thread cannot suspend itself using the native suspension function -#define SELF_SUSPEND_FAILS_WITH_NATIVE_SUSPENSION 0 - -// Define as 1 if netdb.h defines MAXHOSTNAMELEN -#define NETDB_DEFINES_MAXHOSTNAMELEN 0 - -// Define as 1 if sys/param.h defines MAXHOSTNAMELEN -#define SYS_PARAM_DEFINES_MAXHOSTNAMELEN 0 - -// Define as 1 if getpwuid_r sets errno to ERANGE instead of returning ERANGE error -#define GETPWUID_R_SETS_ERRNO 1 - -// Define as 1 in order to use pipes as native support for thread blocking in the -// Synchronization Manager -#define SYNCHMGR_PIPE_BASED_THREAD_BLOCKING 0 - -// Define as 1 in order to signal conditions from a thread suspension safe area -#define SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING 1 - -// Define as 1 if C-runtime file functions (e.g. fwrite) use the ferror() -// value set by a previous file operation. -#define FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL 0 - -// Define as 1 if platform has SYSV semaphores -#define HAS_SYSV_SEMAPHORES 1 - -// Define as 1 if platform has pthread mutexes -#define HAS_PTHREAD_MUTEXES 1 - -// Define as 1 if using stack protection, but need implementation -#define NEED_STACK_PROTECTOR_IMPL 0 - -#endif // _PAL_CONFIG_H_INCLUDED - - +#if defined(__APPLE__) +#include "config.h.osx" +#else +#include "config.h.linux" +#endif diff --git a/src/pal/src/config.h.linux b/src/pal/src/config.h.linux new file mode 100644 index 0000000000..90ba8356ed --- /dev/null +++ b/src/pal/src/config.h.linux @@ -0,0 +1,531 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/* config.h. Generated from config.h.in by configure. */ +/*++ + + + +Module Name: + + include/pal/config.h.in + + process this file with configure to create the PAL's configuration header + +--*/ + +#ifndef _PAL_CONFIG_H_INCLUDED +#define _PAL_CONFIG_H_INCLUDED 1 + +/*++ +_NO_DEBUG_MESSAGES_ : configure option --disable-dbgmsg + +This turns off compilation of TRACE, WARN, ERROR and ENTRY debug messages +--*/ + +#define _NO_DEBUG_MESSAGES_ 0 + + +/*++ +CHECK_TRACE_SPECIFIERS : configure option --enable-tracechecks + +Ask gcc to check the format specifiers used in trace macros. Not on by default, +because gcc will complain about %I64d and %S +--*/ + +#define CHECK_TRACE_SPECIFIERS 0 + +/* Define as 1 if you have wchar.h. */ +#define HAVE_WCHAR_H 1 + +/* Define as 1 if you have ieeefp.h. */ +#define HAVE_IEEEFP_H 0 + +/* Define as 1 if you have alloca.h. */ +#define HAVE_ALLOCA_H 1 + +/* Define as 1 if you have stdint.h. */ +#define HAVE_STDINT_H 1 + +/* Define as 1 if you have netdb.h. */ +#define HAVE_NETDB_H 1 + +/* Define as 1 if you have inttypes.h. */ +#define HAVE_INTTYPES_H 1 + +/* Define as 1 if you have stropts.h. */ +#define HAVE_STROPTS_H 1 + +/* Define as 1 if you have sys/vmparam.h. */ +#define HAVE_SYS_VMPARAM_H 0 + +/* Define as 1 if you have mach/vm_types.h. */ +#define HAVE_MACH_VM_TYPES_H 0 + +/* Define as 1 if you have mach/vm_param.h. */ +#define HAVE_MACH_VM_PARAM_H 0 + +/* Define as 1 if you have sys/param.h. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define as 1 if you have sys/filio.h. */ +#define HAVE_SYS_FILIO_H 0 + +/* Define as 1 if you have sys/sockio.h. */ +#define HAVE_SYS_SOCKIO_H 0 + +/* Define as 1 if you have procfs.h. */ +#define HAVE_PROCFS_H 0 + +/* Define as 1 if you have sys/event.h. */ +#define HAVE_KQUEUE 0 + +// Define as 1 if you are using dylibs and need dlcompat. +#define NEED_DLCOMPAT 0 + +/* Define as 1 if you have crt_externs.h. */ +#define HAVE_CRT_EXTERNS_H 0 + +// Define as 1 if you have sys/time.h. +#define HAVE_SYS_TIME_H 1 + +/* Define as 1 if you have pthread_np.h */ +#define HAVE_PTHREAD_NP_H 0 + +/* Define as 1 if you have sys/lwp.h */ +#define HAVE_SYS_LWP_H 0 + +/* Define as 1 if you have towlower. */ +#define HAVE_TOWLOWER 0 + +/* Define as 1 if struct stat contains st_atimespec, etc. */ +#define HAVE_STAT_TIMESPEC 0 + +/* Define as 1 if struct stat contains st_atimensec, etc. */ +#define HAVE_STAT_NSEC 0 + +/* Define as 1 if struct sockaddr contains sa_len. */ +#define HAVE_SOCKADDR_SA_LEN 0 + +/* Define as 1 if getpwuid_r function exists. */ +#define HAVE_GETPWUID_R 1 + +/* Define as 1 if you have extern char *tzname. */ +#define HAVE_TZNAME 1 + +/* Define as 1 if you have extern long int timezone. */ +#define HAVE_TIMEZONE_VAR 0 + +/* Define as 1 if struct tm has tm_gmtoff. */ +#define HAVE_TM_GMTOFF 1 + +// Define as 1 if the BSD struct reg is supported. +#define HAVE_BSD_REGS_T 0 + +// Define as 1 if ptrace's struct pt_regs is supported. +#define HAVE_PT_REGS 1 + +// Define as 1 if mcontext_t contains a gregset_t. +#define HAVE_GREGSET_T 1 + +// Define as 1 if realpath() does not require that the last path component +// be a file. +#define REALPATH_SUPPORTS_NONEXISTENT_FILES 0 + +// Define as 1 if sscanf supports the "%ll" format. +#define SSCANF_SUPPORT_ll 0 + +// Define as 1 if sscanf has trouble parsing a float from +// something like "12.34e" (e.g. AIX) +#define SSCANF_CANNOT_HANDLE_MISSING_EXPONENT 0 + +// Define as 1 if snprintf works correctly for large values of n. +#define HAVE_LARGE_SNPRINTF_SUPPORT 1 + +/* Define as 1 if select() on a fifo that has not had any data + written to it returns that data is available for reading. */ +#define HAVE_BROKEN_FIFO_SELECT 0 + +/* Define as 1 if kevent() on a fifo returns EV_ERROR. */ +#define HAVE_BROKEN_FIFO_KEVENT 1 + +// Define as 1 if ftruncate correctly returns failure on large lengths. +#define HAVE_FTRUNCATE_LARGE_LENGTH_SUPPORT 0 + +// Define as 1 if ftruncate returns failure but extends the file anyway. +#define HAS_FTRUNCATE_LENGTH_ISSUE 0 + +/* Define as 1 if SYS_yield is a supported syscall. */ +#define HAVE_YIELD_SYSCALL 0 + +// Define as 1 if pthreads are Mach threads. +#define HAVE_MACH_THREADS 0 + +// Define as 1 if pthreads are Solaris threads. +#define HAVE_SOLARIS_THREADS 0 + +// Define as 1 if pthreads has pthread_suspend +#define HAVE_PTHREAD_SUSPEND 0 + +// Define as 1 if pthreads has pthread_suspend_np +#define HAVE_PTHREAD_SUSPEND_NP 0 + +// Define as 1 if pthreads has pthread_continue +#define HAVE_PTHREAD_CONTINUE 0 + +// Define as 1 if pthreads has pthread_resume_np +#define HAVE_PTHREAD_RESUME_NP 0 + +// Define as 1 if pthreads has pthread_continue_np +#define HAVE_PTHREAD_CONTINUE_NP 0 + +// Define as 1 if mkstemp64 is used instead of mkstemp +#define MKSTEMP64_IS_USED_INSTEAD_OF_MKSTEMP 0 + +// Define as 1 if open64 is used instead of open +#define OPEN64_IS_USED_INSTEAD_OF_OPEN 0 + +// Define as 1 if pthread has thread_self +#define HAVE_THREAD_SELF 0 + +// Define as 1 if pthread has _lwp_self +#define HAVE__LWP_SELF 0 + +// Define as 1 if sched_get_priority_[min|max] is supported +#define HAVE_SCHED_GET_PRIORITY 1 + +// Define as the hardcoded min and max thread priority (for platforms where +// sched_get_priority_[min|max] does not exist +#define PAL_THREAD_PRIORITY_MIN 0 +#define PAL_THREAD_PRIORITY_MAX 0 + +// Define as 1 if pthread_setschedparam requires special privileges +#define SET_SCHEDPARAM_NEEDS_PRIVS 0 + +/* Define as 1 if Mach exceptions are supported. */ +#define HAVE_MACH_EXCEPTIONS 0 + +// Define as 1 if Mach's vm_read and vm_write are supported. +#define HAVE_VM_READ 0 + +/* Define as 1 if sigreturn is supported. */ +#define HAVE_SIGRETURN 0 + +/* Define as 1 if _thread_sys_sigreturn is supported. */ +#define HAVE__THREAD_SYS_SIGRETURN 0 + +// Define as 1 if setcontext is supported. +#define HAVE_SETCONTEXT 1 + +// Define as 1 if getcontext is supported. +#define HAVE_GETCONTEXT 1 + +// Define as 1 if copysign is supported. +#define HAVE_COPYSIGN 1 + +// Define as 1 if gethrtime (Solaris/HPUX) is supported. +#define HAVE_GETHRTIME 0 + +// Define as 1 if read_real_time (AIX) is supported. +#define HAVE_READ_REAL_TIME 0 + +// Define as 1 if fsync is supported. +#define HAVE_FSYNC 1 + +// Define as 1 if current platform has a working gettimeofday +#define HAVE_WORKING_GETTIMEOFDAY 1 + +// Define as 1 if current platform has a working clock_gettime +#define HAVE_WORKING_CLOCK_GETTIME 1 + +// Define as 1 if clock_gettime supports CLOCK_MONOTONIC. +#define HAVE_CLOCK_MONOTONIC 1 + +/* Define as 1 if futimes is supported. */ +#define HAVE_FUTIMES 1 + +/* Define as 1 if utimes is supported. */ +#define HAVE_UTIMES 1 + +/* Define as 1 if sysctl is supported. */ +#define HAVE_SYSCTL 1 + +/* Define as 1 if sysconf is supported. */ +#define HAVE_SYSCONF 1 + +/* Define as 1 if strtok_r is supported. */ +#define HAVE_STRTOK_R 1 + +/* Define as 1 if localtime_r is supported. */ +#define HAVE_LOCALTIME_R 1 + +/* Define as 1 if ctime_r is supported. */ +#define HAVE_CTIME_R 1 + +/* Defined as 1 if gmtime_r is supported. */ +#define HAVE_GMTIME_R 1 + +/* Define as 1 if timegm is supported. */ +#define HAVE_TIMEGM 1 + +/* Define as 1 if _snwprintf is supported. */ +#define HAVE__SNWPRINTF 0 + +// Define as 1 if poll is supported. +#define HAVE_POLL 1 + +// Define as 1 if INFTIM is defined. +#define HAVE_INFTIM 0 + +// Define as 1 if CHAR_BIT is defined +#define HAVE_CHAR_BIT 0 + +/* Define as 1 if directio is supported. */ +#define HAVE_DIRECTIO 0 + +/* Define as 1 if use of directio is disabled, + even if HAVE_DIRECTIO is defined. */ +#define DIRECTIO_DISABLED 0 + +/* Define as 1 if vm_allocate is supported. */ +#define HAVE_VM_ALLOCATE 0 + +/* Define as 1 if statfs is supported. */ +#define HAVE_STATFS 0 + +/* Define as 1 if statvfs is supported. */ +#define HAVE_STATVFS 1 + +/* Define as 1 if statvfs64 prototype is broken. */ +#define STATVFS64_PROTOTYPE_BROKEN 0 + +/* Define as 1 if siginfo_t is supported. */ +#define HAVE_SIGINFO_T 1 + +/* Define as 1 if ucontext_t is supported. */ +#define HAVE_UCONTEXT_T 1 + +/* Defined to sizeof(off_t). */ +#define SIZEOF_OFF_T 8 + +/* Define as 1 if in_addr_t is supported. */ +#define HAVE_IN_ADDR_T 0 + +// Define as 1 if caddr_t is supported. +#define HAVE_CADDR_T 0 + +/* Define as 1 if socklen_t is supported. */ +#define HAVE_SOCKLEN_T 1 + +/* Define as 1 if sockaddr_ext is supported. */ +#define HAVE_SOCKADDR_EXT 0 + +/* Define as 1 if pthread_rwlock_t is supported. */ +#define HAVE_PTHREAD_RWLOCK_T 1 + +/* Define as 1 if Core Foundation is supported (Darwin/Mac OS X only). */ +#define HAVE_COREFOUNDATION 0 + +/* Define as 1 if _NSGetEnviron is supported (Darwin/Mac OS X only). */ +#define HAVE__NSGETENVIRON 0 + +/* Define this if debug channel output should be appended to existing files + instead of overwriting */ +/* #undef _PAL_APPEND_DBG_OUTPUT_ */ + +/* Define as 1 if mmap() can map a file descriptor for /dev/zero */ +#define HAVE_MMAP_DEV_ZERO 1 + +// Define as 1 if mmap() ignores its hint parameter. +#define MMAP_IGNORES_HINT 0 + +// Define as 1 if mmap() ignores its protection parameter when +// mapping anonymous pages. +#define MMAP_ANON_IGNORES_PROTECTION 0 + +// Define as 1 if mmap() allows remapping previously mapped pages +#define MMAP_DOESNOT_ALLOW_REMAP 0 + +// Define as 1 if there cannot be more than one shared mapping of a file +// region per process at the same time +#define ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS 0 + +// Define as 1 if pthread_create() modifies errno when it succeeds. +#define PTHREAD_CREATE_MODIFIES_ERRNO 0 + +// Define as 1 if sem_init() modifies errno when it succeeds. +#define SEM_INIT_MODIFIES_ERRNO 0 + +// Define as 1 if prwatch_t is supported +#define HAVE_PRWATCH_T 0 + +// Define as 1 if /proc/<pid>/ctl is supported. +#define HAVE_PROCFS_CTL 0 + +// Define as the name of the memory file in /proc/<pid> +#define PROCFS_MEM_NAME "" + +// Define as 1 if including sys/user.h will result in +// _DEBUG being defined +#define USER_H_DEFINES_DEBUG 0 + +// Define as 1 if close(fd) blocks until there is any outstanding +// syscall using fd (e.g. AIX) +#define CLOSE_BLOCKS_ON_OUTSTANDING_SYSCALLS 0 + +// Define as 1 if sendto returns EHOSTUNREACH when sendto'ing using a +// "to" sockaddr which does not match the socket address family +// (e.g. AIX) +#define SENDTO_RETURNS_UNREACH_ON_WRONG_AF 0 + +// Define as 1 if shutdown fails on connectionless sockets +// (e.g. AIX) +#define SHUTDOWN_FAILS_ON_CONNECTIONLESS_SOCKETS 1 + +// Define as 1 if it is possible to broadcast on a socket regardless of SO_BROADCAST +// (e.g. Solaris) +#define BROADCAST_ALLOWED_WITHOUT_SO_BROADCAST 0 + +// Define as 1 if SO_RCVTIMEO and SO_SNDTIMEO are not supported +// or are ignored +#define SO_TIMEO_NOT_SUPPORTED 0 + +// Define as 1 if write of 0 bytes to the console hangs. +#define WRITE_0_BYTES_HANGS_TTY 0 + +// Define as 1 if acos is compatible with Windows. +#define HAVE_COMPATIBLE_ACOS 1 + +// Define as 1 if asin is compatible with Windows. +#define HAVE_COMPATIBLE_ASIN 1 + +// Define as 1 if pow is compatible with Windows. +#define HAVE_COMPATIBLE_POW 0 + +// Define as 1 if pow returns -Inf when given a negative base and a +// large magnitude odd exponent. +#define HAVE_VALID_NEGATIVE_INF_POW 1 + +// Define as 1 if pow returns +Inf when given a negative base and a +// large magnitude even exponent. +#define HAVE_VALID_POSITIVE_INF_POW 1 + +// Define as 1 if atan2 is compatible with Windows. +#define HAVE_COMPATIBLE_ATAN2 1 + +// Define as 1 if exp is compatible with Windows. +#define HAVE_COMPATIBLE_EXP 1 + +// Define as 1 if log is compatible with Windows. +#define HAVE_COMPATIBLE_LOG 1 + +// Define as 1 if log10 is compatible with Windows. +#define HAVE_COMPATIBLE_LOG10 1 + +// Define as 1 if ttrace is supported +#define HAVE_TTRACE 0 + +// Define as 1 if calling dlopen() on a library which is already +// opened returns a different handle +#define RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN 0 + +// If 1, SetThreadPriority() will not actually modify the pthread priority +// for threads which aren't critical or idle +#define PAL_IGNORE_NORMAL_THREAD_PRIORITY 0 + +// Define as a macro that correctly calls ptrace for the platform, e.g.: +// #define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (void*)(addr), (data), 0) +// Note that for autconfig substitution to properly occur the argument list +// must not be present in this file -- it should only be in the appropriate +// AC_DEFINE statement +#define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (void*)(addr), (data)) + +// Define as the ptrace cmd value to attach to a process +#define PAL_PT_ATTACH PTRACE_ATTACH + +// Define as the ptrace cmd value to detach from a process +#define PAL_PT_DETACH PTRACE_DETACH + +// Define as the ptrace cmd value to read a word from a process's data space +#define PAL_PT_READ_D PTRACE_PEEKDATA + +// Define as the ptrace cmd value to write a word to a process's data space +#define PAL_PT_WRITE_D PTRACE_POKEDATA + +// Define as 1 if ISO locale names needs to be in lowercase +#define HAVE_LOWERCASE_ISO_NAME 0 + +// Define as 1 if ISO locale names need an underscore after +// the "ISO" in the name. +#define HAVE_UNDERSCORE_ISO_NAME 0 + +// Define as 1 if we have per-thread locales as defined in xlocale.h +#define HAVE_XLOCALE 0 + +// Define as 1 if ungetc dose not return EOF on write-only file +#define UNGETC_NOT_RETURN_EOF 1 + +// Define as 1 if malloc(0) returns null +#define MALLOC_ZERO_RETURNS_NULL 0 + +// Define as 1 if error function for glob takes specific parameters +#define ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS 1 + +// Define the ja_JP locale name +#define JA_JP_LOCALE_NAME "ja_JP_LOCALE_NOT_FOUND" + +// Define the ko_KR locale name +#define KO_KR_LOCALE_NAME "ko_KR_LOCALE_NOT_FOUND" + +// Define the zh_TW locale name +#define ZH_TW_LOCALE_NAME "zh_TW_LOCALE_NOT_FOUND" + +// Define as 1 if thread suspension uses signals +#define USE_SIGNALS_FOR_THREAD_SUSPENSION 1 + +// Define as 1 if platform has POSIX semaphores +#define HAS_POSIX_SEMAPHORES 1 + +// Define as 1 if suspending a thread while blocked on a lock can cause a hang +#define DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0 + +// Define as 1 if sigwait cannot take a full sigset as a valid parameter +#define SIGWAIT_FAILS_WHEN_PASSED_FULL_SIGSET 0 + +// Define as 1 if a thread cannot suspend itself using the native suspension function +#define SELF_SUSPEND_FAILS_WITH_NATIVE_SUSPENSION 0 + +// Define as 1 if netdb.h defines MAXHOSTNAMELEN +#define NETDB_DEFINES_MAXHOSTNAMELEN 0 + +// Define as 1 if sys/param.h defines MAXHOSTNAMELEN +#define SYS_PARAM_DEFINES_MAXHOSTNAMELEN 0 + +// Define as 1 if getpwuid_r sets errno to ERANGE instead of returning ERANGE error +#define GETPWUID_R_SETS_ERRNO 1 + +// Define as 1 in order to use pipes as native support for thread blocking in the +// Synchronization Manager +#define SYNCHMGR_PIPE_BASED_THREAD_BLOCKING 0 + +// Define as 1 in order to signal conditions from a thread suspension safe area +#define SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING 1 + +// Define as 1 if C-runtime file functions (e.g. fwrite) use the ferror() +// value set by a previous file operation. +#define FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL 0 + +// Define as 1 if platform has SYSV semaphores +#define HAS_SYSV_SEMAPHORES 1 + +// Define as 1 if platform has pthread mutexes +#define HAS_PTHREAD_MUTEXES 1 + +// Define as 1 if using stack protection, but need implementation +#define NEED_STACK_PROTECTOR_IMPL 0 + +#endif // _PAL_CONFIG_H_INCLUDED + + diff --git a/src/pal/src/config.h.osx b/src/pal/src/config.h.osx new file mode 100644 index 0000000000..47203d289a --- /dev/null +++ b/src/pal/src/config.h.osx @@ -0,0 +1,533 @@ +/* config.h. Generated from config.h.in by configure. */ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + include/pal/config.h.in + + process this file with configure to create the PAL's configuration header + +--*/ + +#ifndef _PAL_CONFIG_H_INCLUDED +#define _PAL_CONFIG_H_INCLUDED 1 + +/*++ +_DEBUG : configure option --disable-debug + +This turns off compilation of debug-only code. +--*/ +#define _DEBUG 1 + +/*++ +_NO_DEBUG_MESSAGES_ : configure option --disable-dbgmsg + +This turns off compilation of TRACE, WARN, ERROR and ENTRY debug messages +--*/ + +#define _NO_DEBUG_MESSAGES_ 0 + + +/*++ +CHECK_TRACE_SPECIFIERS : configure option --enable-tracechecks + +Ask gcc to check the format specifiers used in trace macros. Not on by default, +because gcc will complain about %I64d and %S +--*/ + +#define CHECK_TRACE_SPECIFIERS 0 + +/* Define as 1 if you have wchar.h. */ +#define HAVE_WCHAR_H 1 + +/* Define as 1 if you have ieeefp.h. */ +#define HAVE_IEEEFP_H 0 + +/* Define as 1 if you have alloca.h. */ +#define HAVE_ALLOCA_H 1 + +/* Define as 1 if you have stdint.h. */ +#define HAVE_STDINT_H 1 + +/* Define as 1 if you have netdb.h. */ +#define HAVE_NETDB_H 1 + +/* Define as 1 if you have inttypes.h. */ +#define HAVE_INTTYPES_H 1 + +/* Define as 1 if you have stropts.h. */ +#define HAVE_STROPTS_H 0 + +/* Define as 1 if you have sys/vmparam.h. */ +#define HAVE_SYS_VMPARAM_H 1 + +/* Define as 1 if you have mach/vm_types.h. */ +#define HAVE_MACH_VM_TYPES_H 1 + +/* Define as 1 if you have mach/vm_param.h. */ +#define HAVE_MACH_VM_PARAM_H 1 + +/* Define as 1 if you have sys/param.h. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define as 1 if you have sys/filio.h. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define as 1 if you have sys/sockio.h. */ +#define HAVE_SYS_SOCKIO_H 1 + +/* Define as 1 if you have procfs.h. */ +#define HAVE_PROCFS_H 0 + +/* Define as 1 if you have sys/event.h. */ +#define HAVE_KQUEUE 1 + +// Define as 1 if you are using dylibs and need dlcompat. +#define NEED_DLCOMPAT 0 + +/* Define as 1 if you have crt_externs.h. */ +#define HAVE_CRT_EXTERNS_H 1 + +// Define as 1 if you have sys/time.h. +#define HAVE_SYS_TIME_H 1 + +/* Define as 1 if you have pthread_np.h */ +#define HAVE_PTHREAD_NP_H 0 + +/* Define as 1 if you have sys/lwp.h */ +#define HAVE_SYS_LWP_H 0 + +/* Define as 1 if you have towlower. */ +#define HAVE_TOWLOWER 0 + +/* Define as 1 if struct stat contains st_atimespec, etc. */ +#define HAVE_STAT_TIMESPEC 1 + +/* Define as 1 if struct stat contains st_atimensec, etc. */ +#define HAVE_STAT_NSEC 0 + +/* Define as 1 if struct sockaddr contains sa_len. */ +#define HAVE_SOCKADDR_SA_LEN 1 + +/* Define as 1 if getpwuid_r function exists. */ +#define HAVE_GETPWUID_R 1 + +/* Define as 1 if you have extern char *tzname. */ +#define HAVE_TZNAME 1 + +/* Define as 1 if you have extern long int timezone. */ +#define HAVE_TIMEZONE_VAR 0 + +/* Define as 1 if struct tm has tm_gmtoff. */ +#define HAVE_TM_GMTOFF 1 + +// Define as 1 if the BSD struct reg is supported. +#define HAVE_BSD_REGS_T 0 + +// Define as 1 if ptrace's struct pt_regs is supported. +#define HAVE_PT_REGS 0 + +// Define as 1 if mcontext_t contains a gregset_t. +#define HAVE_GREGSET_T 0 + +// Define as 1 if realpath() does not require that the last path component +// be a file. +#define REALPATH_SUPPORTS_NONEXISTENT_FILES 0 + +// Define as 1 if sscanf supports the "%ll" format. +#define SSCANF_SUPPORT_ll 0 + +// Define as 1 if sscanf has trouble parsing a float from +// something like "12.34e" (e.g. AIX) +#define SSCANF_CANNOT_HANDLE_MISSING_EXPONENT 0 + +// Define as 1 if snprintf works correctly for large values of n. +#define HAVE_LARGE_SNPRINTF_SUPPORT 0 + +/* Define as 1 if select() on a fifo that has not had any data + written to it returns that data is available for reading. */ +#define HAVE_BROKEN_FIFO_SELECT 0 + +/* Define as 1 if kevent() on a fifo returns EV_ERROR. */ +#define HAVE_BROKEN_FIFO_KEVENT 0 + +// Define as 1 if ftruncate correctly returns failure on large lengths. +#define HAVE_FTRUNCATE_LARGE_LENGTH_SUPPORT 1 + +// Define as 1 if ftruncate returns failure but extends the file anyway. +#define HAS_FTRUNCATE_LENGTH_BUG 1 + +/* Define as 1 if SYS_yield is a supported syscall. */ +#define HAVE_YIELD_SYSCALL 0 + +// Define as 1 if pthreads are Mach threads. +#define HAVE_MACH_THREADS 1 + +// Define as 1 if pthreads are Solaris threads. +#define HAVE_SOLARIS_THREADS 0 + +// Define as 1 if pthreads has pthread_suspend +#define HAVE_PTHREAD_SUSPEND 0 + +// Define as 1 if pthreads has pthread_suspend_np +#define HAVE_PTHREAD_SUSPEND_NP 0 + +// Define as 1 if pthreads has pthread_continue +#define HAVE_PTHREAD_CONTINUE 0 + +// Define as 1 if pthreads has pthread_resume_np +#define HAVE_PTHREAD_RESUME_NP 0 + +// Define as 1 if pthreads has pthread_continue_np +#define HAVE_PTHREAD_CONTINUE_NP 0 + +// Define as 1 if mkstemp64 is used instead of mkstemp +#define MKSTEMP64_IS_USED_INSTEAD_OF_MKSTEMP 0 + +// Define as 1 if open64 is used instead of open +#define OPEN64_IS_USED_INSTEAD_OF_OPEN 0 + +// Define as 1 if pthread has thread_self +#define HAVE_THREAD_SELF 0 + +// Define as 1 if pthread has _lwp_self +#define HAVE__LWP_SELF 0 + +// Define as 1 if sched_get_priority_[min|max] is supported +#define HAVE_SCHED_GET_PRIORITY 1 + +// Define as the hardcoded min and max thread priority (for platforms where +// sched_get_priority_[min|max] does not exist +#define PAL_THREAD_PRIORITY_MIN 0 +#define PAL_THREAD_PRIORITY_MAX 0 + +// Define as 1 if pthread_setschedparam requires special privileges +#define SET_SCHEDPARAM_NEEDS_PRIVS 0 + +/* Define as 1 if Mach exceptions are supported. */ +#define HAVE_MACH_EXCEPTIONS 1 + +// Define as 1 if Mach's vm_read and vm_write are supported. +#define HAVE_VM_READ 1 + +/* Define as 1 if sigreturn is supported. */ +#define HAVE_SIGRETURN 0 + +/* Define as 1 if _thread_sys_sigreturn is supported. */ +#define HAVE__THREAD_SYS_SIGRETURN 0 + +// Define as 1 if setcontext is supported. +#define HAVE_SETCONTEXT 1 + +// Define as 1 if getcontext is supported. +#define HAVE_GETCONTEXT 1 + +// Define as 1 if copysign is supported. +#define HAVE_COPYSIGN 1 + +// Define as 1 if gethrtime (Solaris/HPUX) is supported. +#define HAVE_GETHRTIME 0 + +// Define as 1 if read_real_time (AIX) is supported. +#define HAVE_READ_REAL_TIME 0 + +// Define as 1 if fsync is supported. +#define HAVE_FSYNC 1 + +// Define as 1 if current platform has a working gettimeofday +#define HAVE_WORKING_GETTIMEOFDAY 1 + +// Define as 1 if current platform has a working clock_gettime +#define HAVE_WORKING_CLOCK_GETTIME 0 + +// Define as 1 if clock_gettime supports CLOCK_MONOTONIC. +#define HAVE_CLOCK_MONOTONIC 0 + +/* Define as 1 if futimes is supported. */ +#define HAVE_FUTIMES 1 + +/* Define as 1 if utimes is supported. */ +#define HAVE_UTIMES 1 + +/* Define as 1 if sysctl is supported. */ +#define HAVE_SYSCTL 1 + +/* Define as 1 if sysconf is supported. */ +#define HAVE_SYSCONF 0 + +/* Define as 1 if strtok_r is supported. */ +#define HAVE_STRTOK_R 1 + +/* Define as 1 if localtime_r is supported. */ +#define HAVE_LOCALTIME_R 1 + +/* Define as 1 if ctime_r is supported. */ +#define HAVE_CTIME_R 1 + +/* Defined as 1 if gmtime_r is supported. */ +#define HAVE_GMTIME_R 1 + +/* Define as 1 if timegm is supported. */ +#define HAVE_TIMEGM 1 + +/* Define as 1 if _snwprintf is supported. */ +#define HAVE__SNWPRINTF 0 + +// Define as 1 if poll is supported. +#define HAVE_POLL 1 + +// Define as 1 if INFTIM is defined. +#define HAVE_INFTIM 0 + +// Define as 1 if CHAR_BIT is defined +#define HAVE_CHAR_BIT 0 + +/* Define as 1 if directio is supported. */ +#define HAVE_DIRECTIO 0 + +/* Define as 1 if use of directio is disabled, + even if HAVE_DIRECTIO is defined. */ +#define DIRECTIO_DISABLED 0 + +/* Define as 1 if vm_allocate is supported. */ +#define HAVE_VM_ALLOCATE 1 + +/* Define as 1 if statfs is supported. */ +#define HAVE_STATFS 0 + +/* Define as 1 if statvfs is supported. */ +#define HAVE_STATVFS 1 + +/* Define as 1 if statvfs64 prototype is broken. */ +#define STATVFS64_PROTOTYPE_BROKEN 0 + +/* Define as 1 if siginfo_t is supported. */ +#define HAVE_SIGINFO_T 1 + +/* Define as 1 if ucontext_t is supported. */ +#define HAVE_UCONTEXT_T 0 + +/* Defined to sizeof(off_t). */ +#define SIZEOF_OFF_T 8 + +/* Define as 1 if in_addr_t is supported. */ +#define HAVE_IN_ADDR_T 1 + +// Define as 1 if caddr_t is supported. +#define HAVE_CADDR_T 0 + +/* Define as 1 if socklen_t is supported. */ +#define HAVE_SOCKLEN_T 1 + +/* Define as 1 if sockaddr_ext is supported. */ +#define HAVE_SOCKADDR_EXT 0 + +/* Define as 1 if pthread_rwlock_t is supported. */ +#define HAVE_PTHREAD_RWLOCK_T 1 + +/* Define as 1 if Core Foundation is supported (Darwin/Mac OS X only). */ +#define HAVE_COREFOUNDATION 1 + +/* Define as 1 if _NSGetEnviron is supported (Darwin/Mac OS X only). */ +#define HAVE__NSGETENVIRON 1 + +/* Define this if debug channel output should be appended to existing files + instead of overwriting */ +/* #undef _PAL_APPEND_DBG_OUTPUT_ */ + +/* Define as 1 if mmap() can map a file descriptor for /dev/zero */ +#define HAVE_MMAP_DEV_ZERO 0 + +// Define as 1 if mmap() ignores its hint parameter. +#define MMAP_IGNORES_HINT 0 + +// Define as 1 if mmap() ignores its protection parameter when +// mapping anonymous pages. +#define MMAP_ANON_IGNORES_PROTECTION 0 + +// Define as 1 if mmap() allows remapping previously mapped pages +#define MMAP_DOESNOT_ALLOW_REMAP 0 + +// Define as 1 if there cannot be more than one shared mapping of a file +// region per process at the same time +#define ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS 0 + +// Define as 1 if pthread_create() modifies errno when it succeeds. +#define PTHREAD_CREATE_MODIFIES_ERRNO 0 + +// Define as 1 if sem_init() modifies errno when it succeeds. +#define SEM_INIT_MODIFIES_ERRNO 0 + +// Define as 1 if prwatch_t is supported +#define HAVE_PRWATCH_T 0 + +// Define as 1 if /proc/<pid>/ctl is supported. +#define HAVE_PROCFS_CTL 0 + +// Define as the name of the memory file in /proc/<pid> +#define PROCFS_MEM_NAME "" + +// Define as 1 if including sys/user.h will result in +// _DEBUG being defined +#define USER_H_DEFINES_DEBUG 0 + +// Define as 1 if close(fd) blocks until there is any outstanding +// syscall using fd (e.g. AIX) +#define CLOSE_BLOCKS_ON_OUTSTANDING_SYSCALLS 0 + +// Define as 1 if sendto returns EHOSTUNREACH when sendto'ing using a +// "to" sockaddr which does not match the socket address family +// (e.g. AIX) +#define SENDTO_RETURNS_UNREACH_ON_WRONG_AF 0 + +// Define as 1 if shutdown fails on connectionless sockets +// (e.g. AIX) +#define SHUTDOWN_FAILS_ON_CONNECTIONLESS_SOCKETS 1 + +// Define as 1 if it is possible to broadcast on a socket regardless of SO_BROADCAST +// (e.g. Solaris) +#define BROADCAST_ALLOWED_WITHOUT_SO_BROADCAST 0 + +// Define as 1 if SO_RCVTIMEO and SO_SNDTIMEO are not supported +// or are ignored +#define SO_TIMEO_NOT_SUPPORTED 0 + +// Define as 1 if write of 0 bytes to the console hangs. +#define WRITE_0_BYTES_HANGS_TTY 0 + +// Define as 1 if acos is compatible with Windows. +#define HAVE_COMPATIBLE_ACOS 1 + +// Define as 1 if asin is compatible with Windows. +#define HAVE_COMPATIBLE_ASIN 1 + +// Define as 1 if pow is compatible with Windows. +#define HAVE_COMPATIBLE_POW 0 + +// Define as 1 if pow returns -Inf when given a negative base and a +// large magnitude odd exponent. +#define HAVE_VALID_NEGATIVE_INF_POW 1 + +// Define as 1 if pow returns +Inf when given a negative base and a +// large magnitude even exponent. +#define HAVE_VALID_POSITIVE_INF_POW 1 + +// Define as 1 if atan2 is compatible with Windows. +#define HAVE_COMPATIBLE_ATAN2 1 + +// Define as 1 if exp is compatible with Windows. +#define HAVE_COMPATIBLE_EXP 1 + +// Define as 1 if log is compatible with Windows. +#define HAVE_COMPATIBLE_LOG 1 + +// Define as 1 if log10 is compatible with Windows. +#define HAVE_COMPATIBLE_LOG10 1 + +// Define as 1 if ttrace is supported +#define HAVE_TTRACE 0 + +// Define as 1 if calling dlopen() on a library which is already +// opened returns a different handle +#define RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN 0 + +// If 1, SetThreadPriority() will not actually modify the pthread priority +// for threads which aren't critical or idle +#define PAL_IGNORE_NORMAL_THREAD_PRIORITY 0 + +// Define as a macro that correctly calls ptrace for the platform, e.g.: +// #define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (int*)(addr), (data), 0) +// Note that for autconfig substitution to properly occur the argument list +// must not be present in this file -- it should only be in the appropriate +// AC_DEFINE statement +#define PAL_PTRACE(cmd, pid, addr, data) ptrace((cmd), (pid), (caddr_t)(addr), (data)) + +// Define as the ptrace cmd value to attach to a process +#define PAL_PT_ATTACH PT_ATTACH + +// Define as the ptrace cmd value to detach from a process +#define PAL_PT_DETACH PT_DETACH + +// Define as the ptrace cmd value to read a word from a process's data space +#define PAL_PT_READ_D PT_READ_D + +// Define as the ptrace cmd value to write a word to a process's data space +#define PAL_PT_WRITE_D PT_WRITE_D + +// Define as 1 if ISO locale names needs to be in lowercase +#define HAVE_LOWERCASE_ISO_NAME 0 + +// Define as 1 if ISO locale names need an underscore after +// the "ISO" in the name. +#define HAVE_UNDERSCORE_ISO_NAME 0 + +// Define as 1 if we have per-thread locales as defined in xlocale.h +#define HAVE_XLOCALE 1 + +// Define as 1 if ungetc dose not return EOF on write-only file +#define UNGETC_NOT_RETURN_EOF 0 + +// Define as 1 if malloc(0) returns null +#define MALLOC_ZERO_RETURNS_NULL 0 + +// Define as 1 if error function for glob takes specific parameters +#define ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS 1 + +// Define the ja_JP locale name +#define JA_JP_LOCALE_NAME "ja_JP.SJIS" + +// Define the ko_KR locale name +#define KO_KR_LOCALE_NAME "ko_KR.eucKR" + +// Define the zh_TW locale name +#define ZH_TW_LOCALE_NAME "zh_TW.BIG5" + +// Define as 1 if thread suspension uses signals +#define USE_SIGNALS_FOR_THREAD_SUSPENSION 0 + +// Define as 1 if platform has POSIX semaphores +#define HAS_POSIX_SEMAPHORES 0 + +// Define as 1 if suspending a thread while blocked on a lock can cause a hang +#define DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 1 + +// Define as 1 if sigwait cannot take a full sigset as a valid parameter +#define SIGWAIT_FAILS_WHEN_PASSED_FULL_SIGSET 0 + +// Define as 1 if a thread cannot suspend itself using the native suspension function +#define SELF_SUSPEND_FAILS_WITH_NATIVE_SUSPENSION 0 + +// Define as 1 if netdb.h defines MAXHOSTNAMELEN +#define NETDB_DEFINES_MAXHOSTNAMELEN 0 + +// Define as 1 if sys/param.h defines MAXHOSTNAMELEN +#define SYS_PARAM_DEFINES_MAXHOSTNAMELEN 0 + +// Define as 1 if getpwuid_r sets errno to ERANGE instead of returning ERANGE error +#define GETPWUID_R_SETS_ERRNO 0 + +// Define as 1 in order to use pipes as native support for thread blocking in the +// Synchronization Manager +#define SYNCHMGR_PIPE_BASED_THREAD_BLOCKING 0 + +// Define as 1 in order to signal conditions from a thread suspension safe area +#define SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING 1 + +// Define as 1 if C-runtime file functions (e.g. fwrite) use the ferror() +// value set by a previous file operation. +#define FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL 0 + +// Define as 1 if platform has SYSV semaphores +#define HAS_SYSV_SEMAPHORES 1 + +// Define as 1 if platform has pthread mutexes +#define HAS_PTHREAD_MUTEXES 1 + +// Define as 1 if using stack protection, but need implementation +#define NEED_STACK_PROTECTOR_IMPL 1 + +#endif // _PAL_CONFIG_H_INCLUDED + + diff --git a/src/pal/src/cruntime/path.cpp b/src/pal/src/cruntime/path.cpp index 4cae89ddd2..1d7fffab9c 100644 --- a/src/pal/src/cruntime/path.cpp +++ b/src/pal/src/cruntime/path.cpp @@ -547,13 +547,6 @@ _fullpath( goto fullpathExit; } - if ('\0' != path_copy[cPathCopy-1]) - { - TRACE("relPath=%s is larger than %lu characters!\n", - relPath ? relPath : "NULL", cPathCopy-1); - goto fullpathExit; - } - FILEDosToUnixPathA(path_copy); if(NULL == realpath(path_copy, realpath_buf)) diff --git a/src/pal/src/cruntime/wchar.cpp b/src/pal/src/cruntime/wchar.cpp index 8006386638..83c086c0ec 100644 --- a/src/pal/src/cruntime/wchar.cpp +++ b/src/pal/src/cruntime/wchar.cpp @@ -36,6 +36,7 @@ Abstract: #if HAVE_COREFOUNDATION #define CF_EXCLUDE_CSTD_HEADERS #include <CoreFoundation/CoreFoundation.h> +#include <wctype.h> #else #include <wctype.h> #endif @@ -779,7 +780,7 @@ PAL_towlower( wchar_16 c ) kCFAllocatorDefault, 1); if (cfString != NULL) { - CFStringAppendCharacters(cfString, &c, 1); + CFStringAppendCharacters(cfString, (const UniChar*)&c, 1); CFStringLowercase(cfString, NULL); c = CFStringGetCharacterAtIndex(cfString, 0); CFRelease(cfString); @@ -838,7 +839,7 @@ PAL_towupper( wchar_16 c ) kCFAllocatorDefault, 1); if (cfString != NULL) { - CFStringAppendCharacters(cfString, &c, 1); + CFStringAppendCharacters(cfString, (const UniChar*)&c, 1); CFStringUppercase(cfString, NULL); c = CFStringGetCharacterAtIndex(cfString, 0); CFRelease(cfString); diff --git a/src/pal/src/examples/CMakeLists.txt b/src/pal/src/examples/CMakeLists.txt index 7f01f4523e..7d0450dcf3 100644 --- a/src/pal/src/examples/CMakeLists.txt +++ b/src/pal/src/examples/CMakeLists.txt @@ -14,7 +14,5 @@ add_executable(palexmpl add_dependencies(palexmpl CoreClrPal) target_link_libraries(palexmpl - pthread - rt CoreClrPal ) diff --git a/src/pal/src/exception/machexception.cpp b/src/pal/src/exception/machexception.cpp index 5bf4074a76..f42840def0 100644 --- a/src/pal/src/exception/machexception.cpp +++ b/src/pal/src/exception/machexception.cpp @@ -41,7 +41,9 @@ Abstract: #include <string.h> #include <unistd.h> #include <pthread.h> +#if defined(__powerpc__) #include <architecture/ppc/cframe.h> +#endif #include <dlfcn.h> #include <mach-o/loader.h> diff --git a/src/pal/src/exception/machmessage.cpp b/src/pal/src/exception/machmessage.cpp index eca953c222..f1b4388d6c 100644 --- a/src/pal/src/exception/machmessage.cpp +++ b/src/pal/src/exception/machmessage.cpp @@ -1137,7 +1137,7 @@ thread_act_t MachMessage::GetThreadFromState(thread_state_flavor_t eFlavor, thre // Transform a exception handler behavior type into the corresponding Mach message ID for the notification. mach_msg_id_t MachMessage::MapBehaviorToNotificationType(exception_behavior_t eBehavior) { - switch (eBehavior) + switch ((uint)eBehavior) { case EXCEPTION_DEFAULT: return EXCEPTION_RAISE_MESSAGE_ID; diff --git a/src/pal/src/exception/machmessage.h b/src/pal/src/exception/machmessage.h index 00b37c18ff..8225852507 100644 --- a/src/pal/src/exception/machmessage.h +++ b/src/pal/src/exception/machmessage.h @@ -53,7 +53,7 @@ typedef mach_exception_data_type_t mach_exception_subcode_t; #define NONPAL_TRACE(_format, ...) #endif // _DEBUG -struct CorUnix::MachExceptionHandler; +struct MachExceptionHandler; // Abstraction of a subset of Mach message types. Provides accessors that hide the subtle differences in the // message layout of similar message types. @@ -318,7 +318,7 @@ private: exception_raise_state_reply_64_t raise_state_reply_64; exception_raise_state_identity_reply_64_t raise_state_identity_reply_64; } data; - }; + } __attribute__((packed));; // Re-initializes this data structure (to the same state as default construction, containing no message). void ResetMessage(); diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp index 976266ec71..69a9cffb19 100644 --- a/src/pal/src/file/file.cpp +++ b/src/pal/src/file/file.cpp @@ -1174,12 +1174,24 @@ DeleteFileA( dwLastError = FILEGetLastErrorFromErrnoAndFilename(lpUnixFileName); goto done; } + + lpFullUnixFileName = reinterpret_cast<LPSTR>(InternalMalloc(pThread, cchFullUnixFileName)); + if ( lpFullUnixFileName == NULL ) + { + ERROR("InternalMalloc() failed\n"); + palError = ERROR_NOT_ENOUGH_MEMORY; + goto done; + } + + // Initialize the path to zeroes... + ZeroMemory(lpFullUnixFileName, cchFullUnixFileName); // Compute the absolute pathname to the file. This pathname is used // to determine if two file names represent the same file. palError = InternalCanonicalizeRealPath(pThread, lpUnixFileName, lpFullUnixFileName, cchFullUnixFileName); if (palError != NO_ERROR) { + InternalFree(pThread, lpFullUnixFileName); lpFullUnixFileName = InternalStrdup(pThread, lpUnixFileName); if (!lpFullUnixFileName) { diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index b7074b4c7d..32f32d63e2 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -56,7 +56,9 @@ Abstract: #include <sys/types.h> #include <sys/mman.h> +#if !defined(__APPLE__) #include <gnu/lib-names.h> +#endif using namespace CorUnix; @@ -94,13 +96,6 @@ PDLLMAIN g_pRuntimeDllMain = NULL; // linked into some utility. extern char g_szCoreCLRPath[MAX_PATH]; -#if defined(CORECLR) && defined(__APPLE__) -// Under CoreCLR/Mac the pal_module above actually represents the PAL, the PALRT and mscorwks (they're all -// linked into one binary). The PAL has no DllMain, but the other two do. Cache their DllMain entrypoints here -// so we can call them properly (e.g. thread attaches). -PDLLMAIN g_pPalRTDllMain = NULL; -#endif // CORECLR && __APPLE__ - /* static function declarations ***********************************************/ static BOOL LOADValidateModule(MODSTRUCT *module); @@ -108,9 +103,7 @@ static LPWSTR LOADGetModuleFileName(MODSTRUCT *module); static HMODULE LOADLoadLibrary(LPCSTR ShortAsciiName, BOOL fDynamic); static void LOAD_SEH_CallDllMain(MODSTRUCT *module, DWORD dwReason, LPVOID lpReserved); static MODSTRUCT *LOADAllocModule(void *dl_handle, LPCSTR name); -#if !defined(CORECLR) || !defined(__APPLE__) static INT FindLibrary(CHAR* pszRelName, CHAR** ppszFullName); -#endif // !CORECLR || !__APPLE__ /* API function definitions ***************************************************/ @@ -298,9 +291,7 @@ GetProcAddress( { MODSTRUCT *module; FARPROC ProcAddress = NULL; -#if !defined(CORECLR) || !defined(__APPLE__) LPCSTR symbolName = lpProcName; -#endif // !defined(CORECLR) || !defined(__APPLE__) PERF_ENTRY(GetProcAddress); ENTRY("GetProcAddress (hModule=%p, lpProcName=%p (%s))\n", @@ -341,12 +332,11 @@ GetProcAddress( // If we're looking for a symbol inside the PAL, we try the PAL_ variant // first because otherwise we run the risk of having the non-PAL_ // variant preferred over the PAL's implementation. -#if !defined(CORECLR) || !defined(__APPLE__) if (module->dl_handle == pal_module.dl_handle) { int iLen = 4 + strlen(lpProcName) + 1; LPSTR lpPALProcName = (LPSTR) alloca(iLen); - + if (strcpy_s(lpPALProcName, iLen, "PAL_") != SAFECRT_SUCCESS) { ERROR("strcpy_s failed!\n"); @@ -364,62 +354,12 @@ GetProcAddress( ProcAddress = (FARPROC) dlsym(module->dl_handle, lpPALProcName); symbolName = lpPALProcName; } -#else // !CORECLR || !__APPLE__ - if (module == &pal_module) - { - // Attempting to lookup a symbol exported by the PAL/runtime itself. - - // Under CoreCLR/Mac the PAL "module" represents either the entire CoreCLR binary (including PAL, - // PALRT and mscorwks) or just the PAL in the (uncommon) case of a standalone PAL. We can tell the - // difference in these cases by whether the sys_module field of pal_module was initialized to contain - // a non-NULL value: this is only done in the CoreCLR case. - if (pal_module.sys_module) - { - // Trying to locate a symbol in the PAL, PALRT or mscorwks. - int iLen = 4 + strlen(lpProcName) + 1; - LPSTR lpPALProcName = (LPSTR) alloca(iLen); - - if (strcpy_s(lpPALProcName, iLen, "PAL_") != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed!\n"); - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto done; - } - - if (strcat_s(lpPALProcName, iLen, lpProcName) != SAFECRT_SUCCESS) - { - ERROR("strcat_s failed!\n"); - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto done; - } - - ProcAddress = (FARPROC)LookupFunctionInCoreCLR(pal_module.sys_module, lpPALProcName); - } - else - { - // Trying to locate a symbol in the standalone PAL. We don't support this (it's brittle to lump - // the PAL namespace in with some random host code). Just fall through to the failure case. - ASSERT("Attempted to lookup proc address in a standalone PAL"); - } - } -#endif // !CORECLR || !__APPLE__ // If we aren't looking inside the PAL or we didn't find a PAL_ variant // inside the PAL, fall back to a normal search. if (ProcAddress == NULL) { -#if defined(CORECLR) && defined(__APPLE__) - if (module->dl_handle) - { -#endif // CORECLR && __APPLE__ ProcAddress = (FARPROC) dlsym(module->dl_handle, lpProcName); -#if defined(CORECLR) && defined(__APPLE__) - } - else if (module->sys_module) - { - ProcAddress = (FARPROC)LookupFunctionInCoreCLR(module->sys_module, lpProcName); - } -#endif // CORECLR && __APPLE__ } if (ProcAddress) @@ -834,7 +774,6 @@ PAL_UnregisterLibraryW( /* Internal PAL functions *****************************************************/ -#if !defined(CORECLR) || !defined(__APPLE__) /*++ LOADGetLibRotorPalSoFileName @@ -909,7 +848,6 @@ Done: } return iRetVal; } -#endif // !CORECLR || !__APPLE__ /*++ Function : @@ -931,9 +869,7 @@ Notes : extern "C" BOOL LOADInitializeModules(LPWSTR exe_name) { -#if !defined(CORECLR) || !defined(__APPLE__) LPWSTR lpwstr = NULL; -#endif // !defined(CORECLR) || !defined(__APPLE__) #if RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN LPSTR pszExeName = NULL; @@ -954,9 +890,6 @@ BOOL LOADInitializeModules(LPWSTR exe_name) /* initialize module for main executable */ TRACE("Initializing module for main executable\n"); exe_module.self=(HMODULE)&exe_module; -#if defined(CORECLR) && defined(__APPLE__) - exe_module.sys_module = NULL; -#endif // CORECLR && __APPLE__ exe_module.dl_handle=dlopen(NULL, RTLD_LAZY); if(!exe_module.dl_handle) { @@ -973,7 +906,6 @@ BOOL LOADInitializeModules(LPWSTR exe_name) TRACE("Initializing module for PAL library\n"); pal_module.self=(HANDLE)&pal_module; -#if !defined(CORECLR) || !defined(__APPLE__) if (g_szCoreCLRPath[0] == '\0') { pal_module.lib_name=NULL; @@ -1002,63 +934,6 @@ BOOL LOADInitializeModules(LPWSTR exe_name) #endif } } -#else // !CORECLR || !__APPLE__ - // Under CoreCLR/Mac we have a single binary instead of separate dynamic libraries. Here pal_module - // represents all of that dylib (with dl_handle == NULL and sys_module != NULL). We still support some - // scenarios with a standalone PAL statically linked into host code. These cases are differented by - // sys_module being NULL (and GetProcAddress() will not work on such a module). - pal_module.lib_name = UTIL_MBToWC_Alloc("CoreCLR", -1); - if(NULL == pal_module.lib_name) - { - ERROR("MBToWC failure, unable to save full name of PAL module\n"); - goto Done; - } - pal_module.dl_handle = NULL; - - // Determine whether we're part of CoreCLR or a standalone PAL. Do this by looking at the g_szCoreCLRPath - // global: this is set to a non-zero length string by PAL initialization in the CoreCLR case. - if (g_szCoreCLRPath[0] != '\0') - { - // We're part of a full CoreCLR. Determine our module's handle and cache it for future - // GetProcAddress() operations). - pal_module.sys_module = FindCoreCLRHandle(); - if (pal_module.sys_module == NULL) - { - ASSERT("FindCoreCLRHandle() failure"); - goto Done; - } - } - else - { - // We're just a standalone PAL. Disable any functionality that needs to peek into the containing - // module (since we know nothing about that module). - pal_module.sys_module = NULL; - } - - // If we really are running in CoreCLR then we need to locate and remember the DllMain routines for the - // PalRT and mscorwks (the PAL itself doesn't have one). We use these to keep the components up to date - // with thread attaches and detaches. We can't call them here for the process attach, however, since we - // are still partway through PAL initialization. We rely on PAL_InitializeCoreCLR to call us back on - // LOADInitCoreCLRModules once PAL initialization is complete. - if (pal_module.sys_module) - { - g_pPalRTDllMain = (PDLLMAIN)LookupFunctionInCoreCLR(pal_module.sys_module, "PalRtDllMain"); - if (g_pPalRTDllMain == NULL) - { - ERROR("Failed to locate PalRT DllMain\n"); - SetLastError(ERROR_INVALID_DLL); - goto Done; - } - - g_pRuntimeDllMain = (PDLLMAIN)LookupFunctionInCoreCLR(pal_module.sys_module, "CoreDllMain"); - if (g_pRuntimeDllMain == NULL) - { - ERROR("Failed to locate Mscorwks DllMain\n"); - SetLastError(ERROR_INVALID_DLL); - goto Done; - } - } -#endif // !CORECLR || !__APPLE__ pal_module.refcount=-1; pal_module.next=&exe_module; @@ -1241,30 +1116,6 @@ void LOADCallDllMain(DWORD dwReason, LPVOID lpReserved) LockModuleList(); -#if defined(CORECLR) && defined(__APPLE__) - // The CoreCLR needs to simulate PalRT and mscorwks being separate libraries rather - // than a single binary. - if (InLoadOrder && g_pPalRTDllMain) - { -#if !_NO_DEBUG_MESSAGES_ - /* reset ENTRY nesting level back to zero while inside the callback... */ - int old_level; - old_level = DBG_change_entrylevel(0); -#endif /* !_NO_DEBUG_MESSAGES_ */ - - { - PAL_LeaveHolder holder; - g_pPalRTDllMain((HMODULE) module, dwReason, lpReserved); - } - g_pRuntimeDllMain((HMODULE) module, dwReason, lpReserved); - -#if !_NO_DEBUG_MESSAGES_ - /* ...and set nesting level back to what it was */ - DBG_change_entrylevel(old_level); -#endif /* !_NO_DEBUG_MESSAGES_ */ - } -#endif // CORECLR && __APPLE__ - module = &exe_module; do { if (!InLoadOrder) @@ -1298,30 +1149,6 @@ void LOADCallDllMain(DWORD dwReason, LPVOID lpReserved) module = module->next; } while (module != &exe_module); -#if defined(CORECLR) && defined(__APPLE__) - // The CoreCLR needs to simulate PalRT and CoreCLR being separate libraries rather - // than a single binary. - if (!InLoadOrder && g_pPalRTDllMain) - { -#if !_NO_DEBUG_MESSAGES_ - /* reset ENTRY nesting level back to zero while inside the callback... */ - int old_level; - old_level = DBG_change_entrylevel(0); -#endif /* !_NO_DEBUG_MESSAGES_ */ - - g_pRuntimeDllMain((HMODULE) module, dwReason, lpReserved); - { - PAL_LeaveHolder holder; - g_pPalRTDllMain((HMODULE) module, dwReason, lpReserved); - } - -#if !_NO_DEBUG_MESSAGES_ - /* ...and set nesting level back to what it was */ - DBG_change_entrylevel(old_level); -#endif /* !_NO_DEBUG_MESSAGES_ */ - } -#endif // CORECLR && __APPLE__ - UnlockModuleList(); } @@ -1502,9 +1329,6 @@ static MODSTRUCT *LOADAllocModule(void *dl_handle, LPCSTR name) } module->dl_handle = dl_handle; -#if defined(CORECLR) && defined(__APPLE__) - module->sys_module = NULL; -#endif // CORECLR && __APPLE__ #if NEED_DLCOMPAT if (isdylib(module)) { @@ -1556,7 +1380,11 @@ static HMODULE LOADLoadLibrary(LPCSTR ShortAsciiName, BOOL fDynamic) // As a result, we have to use the full name (i.e. lib.so.6) that is defined by LIBC_SO. if (strcmp(ShortAsciiName, LIBC_NAME_WITHOUT_EXTENSION) == 0) { +#if defined(__APPLE__) + ShortAsciiName = "libc.dylib"; +#else ShortAsciiName = LIBC_SO; +#endif } LockModuleList(); @@ -1881,7 +1709,6 @@ BOOL PAL_LOADUnloadPEFile(void * ptr) return retval; } -#if !defined(CORECLR) || !defined(__APPLE__) /*++ Function: FindLibrary @@ -2060,7 +1887,6 @@ Done: // *ppszFullName to NULL. return iRetVal; } -#endif // !CORECLR || !__APPLE__ /*++ LOADInitCoreCLRModules @@ -2077,483 +1903,9 @@ Return value: --*/ BOOL LOADInitCoreCLRModules() { -#ifdef __APPLE__ - { - PAL_LeaveHolder holder; - if (!g_pPalRTDllMain((HMODULE)&pal_module, DLL_PROCESS_ATTACH, NULL)) - return FALSE; - } -#endif // __APPLE__ return g_pRuntimeDllMain((HMODULE)&pal_module, DLL_PROCESS_ATTACH, NULL); } -#if defined(CORECLR) && defined(__APPLE__) -// Abstract the API used to load and query for functions in the CoreCLR binary to make it easier to change the -// underlying implementation. - -// Load the CoreCLR module into memory given the directory in which it resides. Returns NULL on failure. -CORECLRHANDLE LoadCoreCLR(const char *szPath) -{ - CFStringRef hPath = NULL; - CFURLRef hUrl = NULL; - CFBundleRef hBundle = NULL; - - // We're handed the full path to the CoreCLR directory but CFBundleCreate wants the path of the bundle - // directory that contains it. So we have to strip two directory components off. - int iLen = strlen(szPath) + 1; - char *szBundlePath = (char*)alloca(iLen); - - if (strcpy_s(szBundlePath, iLen, szPath) != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed!\n"); - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto done; - } - - // Null out the last three slashes: - // <foo>/CoreCLR.bundle/Contents/MacOS/ -> <foo>/CoreCLR.bundle/Contents/MacOS - // <foo>/CoreCLR.bundle/Contents/MacOS -> <foo>/CoreCLR.bundle/Contents - // <foo>/CoreCLR.bundle/Contents -> <foo>/CoreCLR.bundle - TRACE("LoadCoreCLR: szPath = \"%s\"\n", szPath); - for (int i = 0; i < 3; i++) - { - char *szLastSlash = rindex(szBundlePath, '/'); - if (szLastSlash == NULL) - { - ERROR("Got invalid bundle path \"%s\"\n", szPath); - SetLastError(ERROR_INVALID_PARAMETER); - goto done; - } - *szLastSlash = '\0'; - } - - // Convert the pathname provided as a cstring to a CFString. - hPath = CFStringCreateWithCString(kCFAllocatorDefault, szBundlePath, kCFStringEncodingUTF8); - if (hPath == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto done; - } - - // Convert the path into a URL. - hUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, hPath, kCFURLPOSIXPathStyle, TRUE); - if (hUrl == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto done; - } - - // Load the bundle from the URL. - hBundle = CFBundleCreate(kCFAllocatorDefault, hUrl); - - done: - if (hUrl) - CFRelease(hUrl); - if (hPath) - CFRelease(hPath); - - return hBundle; -} - -// Lookup the named function in the given CoreCLR image. Returns NULL on failure. -void *LookupFunctionInCoreCLR(CORECLRHANDLE hCoreCLR, const char *szFunction) -{ - CFStringRef hFunction = NULL; - void *pFunction = NULL; - - // Convert the function name provided as a cstring to a CFString. - hFunction = CFStringCreateWithCString(kCFAllocatorDefault, szFunction, kCFStringEncodingUTF8); - if (hFunction == NULL) - goto done; - - // Look up the function name in the bundle. - { - // We temporarily leave PAL as a workaround for what is presumably a problem in gdb (as of version 477). - // The function we call here may call into dyld for linking new images, and gdb sets a breakpoint deep - // in there so that it knows about it, and can load new symbol files. We leave the PAL so that we - // unhook the exception port for hardware breakpoints. - // - // Strictly speaking, we'd expect this to work without leaving the PAL: For a breakpoint exception, if - // no managed debugger is attached, our thread-level handler sends back a message to the system that - // we do not with to handle it. This causes the system to forward the exception message to the task - // and host-level handlers. However, gdb's host-level handler seems to hang in this case. - PAL_LeaveHolder holder; - pFunction = CFBundleGetFunctionPointerForName(hCoreCLR, hFunction); - } - - done: - if (hFunction) - CFRelease(hFunction); - - return pFunction; -} - -// Locate the CoreCLR module handle associated with the code currently executing. Returns NULL on failure. -CORECLRHANDLE FindCoreCLRHandle() -{ - // Return NULL when we're not really part of CoreCLR (i.e. we're a standalone PAL). - if (g_szCoreCLRPath[0] == '\0') - { - SetLastError(ERROR_NOT_SUPPORTED); - return NULL; - } - - // Reloading the same bundle will just return a reference to the exiting copy and we know the path from - // which the host originally loaded us. - return LoadCoreCLR(g_szCoreCLRPath); -} -#endif // CORECLR && __APPLE__ - -/*++ -Function: - PAL_GetModuleBaseFromAddress - - Given an address, returns the base address of the dynamic module which contains that address, - or NULL if none. - - Notes: - This is a replacement for code that casts HMODULEs to pointers on Windows. - Ideally this would take an HMODULE instead of an address, but that is harder - we don't seem to - have a way to map it directly to a dyld index or to get an address from it. Eg., we're not - guaranteed toh ave a module name, dllMain or dyld handle. - */ -#ifdef __APPLE__ -PALAPI -LPCVOID -PAL_GetModuleBaseFromAddress(LPCVOID pAddress) -{ - LPCVOID retval = NULL; - - PERF_ENTRY(PAL_GetModuleBaseFromAddress); - ENTRY("PAL_GetModuleBaseFromAddress (pAddress=%p)\n", pAddress); - - // Given a pointer into the module, get the header at the start of the module - retval = _dyld_get_image_header_containing_address(pAddress); - if (retval == NULL) - { - // All modules we load use dyld (even bundles are implemented using this in the OS) - TRACE("Address isn't recognized as being in a dyld module: %p\n", pAddress); - goto done; - } - - TRACE("base address of module with address %p is %p\n", pAddress, retval); - -done: - LOGEXIT("PAL_GetModuleBaseFromAddress returns %p\n", retval); - PERF_EXIT(PAL_GetModuleBaseFromAddress); - return retval; -} - -//--------------------------------------------------------------------------------------- -// -// Retrieve the UUID in the image. -// -// Arguments: -// pImageBase - the base address of where an image is loaded into memory -// pUUID - out parameter; return the UUID in the image -// -// Assumptions: -// The buffer pointed to by pUUID must have at least 16 bytes. -// -// Return Value: -// TRUE if this function successfully retrieves the UUID from the specified image -// - -PALAPI -BOOL -PAL_GetUUIDOfImage(LPCVOID pImageBase, BYTE * pUUID) -{ - PERF_ENTRY(PAL_GetUUIDOfImage); - ENTRY("PAL_GetUUIDOfImage (pImageBase=%p, pUUID=%p)\n", pImageBase, pUUID); - - // There should be a Mach-O header at the image base. - const mach_header * pHeader; - pHeader = reinterpret_cast<const mach_header *>(pImageBase); - - const load_command * pCurCommand = NULL; - UINT32 cLoadCommands = 0; - BOOL fFoundUUID = FALSE; - - // The offset to the magic number is the same for both mach_header and for - // mach_header_64 (same size too), so it's safe to use it to check for - // MH_MAGIC_64. - if (pHeader->magic == MH_MAGIC) - { - // Immediately following the header are the load commands. - cLoadCommands = pHeader->ncmds; - pCurCommand = reinterpret_cast<const load_command *>(pHeader + 1); - - } - else if (pHeader->magic == MH_MAGIC_64) - { - const mach_header_64 * pHeader64; - pHeader64 = reinterpret_cast<const mach_header_64 *>(pImageBase); - cLoadCommands = pHeader64->ncmds; - pCurCommand = reinterpret_cast<const load_command *>(pHeader64 + 1); - } - - if (pCurCommand) - { - // Loop through the load commmands to find the LC_UUID load command. - for (UINT32 i = 0; i < cLoadCommands; i++) - { - if (pCurCommand->cmd == LC_UUID) - { - const uuid_command * pUUIDCommand = reinterpret_cast<const uuid_command *>(pCurCommand); - - // sanity check - if (pUUIDCommand->cmdsize == sizeof(uuid_command)) - { - // Copy the 16-byte UUID into the out buffer. - memcpy(pUUID, pUUIDCommand->uuid, sizeof(pUUIDCommand->uuid)); - fFoundUUID = TRUE; - break; - } - } - pCurCommand = reinterpret_cast<const load_command *>((SIZE_T)pCurCommand + pCurCommand->cmdsize); - } - } - - LOGEXIT("PAL_GetUUIDOfImage\n"); - PERF_EXIT(PAL_GetUUIDOfImage); - return fFoundUUID; -} - -//--------------------------------------------------------------------------------------- -// Retrieve the version stored in the Info.plist file in a bundle. -// -// Arguments: -// bundle - Target bundle. -// pwszVersionString - out parameter; buffer to be filled with the version string -// cchVersionStringBuffer - size of the buffer in # of characters pointed to by pwszVersionString -// pcchVersionStringBufferRequired - required size in characters, including NULL. -// -// Return Value: -// Return the number of characters in the version string (excluding NULL) or 0 if the operation fails. -// -// Notes: -// Call GetLastError() to retrieve more information if the function fails. -// -static DWORD GetBundleVersionString(IN CFBundleRef bundle, - IN WCHAR *pwszVersionString, - IN DWORD cchVersionStringBuffer, - IN DWORD *pcchVersionStringBufferRequired) -{ - CFTypeRef hVersionString = NULL; - CFStringRef hRealVersionString = NULL; - - *pcchVersionStringBufferRequired = 0; - - // Get a CFTypeRef to the version string stored in the Info.plist file in the CoreCLR bundle. - // CFTypeRef is like an System.Object. It's the base class in CoreFoundation. - hVersionString = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey); - if (hVersionString == NULL || CFGetTypeID(hVersionString) != CFStringGetTypeID()) - { - SetLastError(ERROR_INVALID_DATA); - return 0; - } - hRealVersionString = static_cast<CFStringRef>(hVersionString); - - // Get the length of the version string. - S_UINT32 cchRealVersionString(ClrSafeInt<CFIndex>(CFStringGetLength(hRealVersionString))); - if (cchRealVersionString.IsOverflow() || - !cchRealVersionString.addition(cchRealVersionString.Value(), 1ul, *pcchVersionStringBufferRequired)) - { - SetLastError(ERROR_INVALID_DATA); - return 0; - } - - if (*pcchVersionStringBufferRequired > cchVersionStringBuffer) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return 0; - } - - // Copy the version string into the output buffer and make sure we put the NULL character at the end. - CFStringGetCharacters(hRealVersionString, CFRangeMake(0, cchRealVersionString.Value()), pwszVersionString); - pwszVersionString[cchRealVersionString.Value()] = L'\0'; - - return cchRealVersionString.Value(); -} - -//--------------------------------------------------------------------------------------- -// -// Retrieve the version stored in the Info.plist file in a bundle containing the passed in executable path. -// -// Arguments: -// pwszCoreClrFullPath - full path to CoreCLR -// pwszVersionString - out parameter; buffer to be filled with the version string -// cchVersionStringBuffer - size of the buffer in # of characters pointed to by pwszVersionString -// pcchVersionStringBufferRequired - required size in characters, including NULL. -// -// Return Value: -// Return the number of characters in the version string (excluding NULL) or 0 if the operation fails. -// -// Notes: -// Call GetLastError() to retrieve more information if the function fails. -// - -PALAPI -DWORD -PAL_GetVersionString(IN WCHAR * pwszCoreClrFullPath, - IN OUT WCHAR * pwszVersionString, - IN DWORD cchVersionStringBuffer, - OUT DWORD *pcchVersionStringBufferRequired) -{ - PERF_ENTRY(PAL_GetVersionString); - ENTRY("PAL_GetVersionString (pwszCoreClrFullPath=%p (%S), pwszVersionString=%p, " - "cchVersionStringBuffer=%u, pcchVersionStringBufferRequired=%p)\n", - (pwszCoreClrFullPath ? pwszCoreClrFullPath : W16_NULLSTRING), - (pwszCoreClrFullPath ? pwszCoreClrFullPath : W16_NULLSTRING), - pwszVersionString, cchVersionStringBuffer, pcchVersionStringBufferRequired); - - // various handles for dealing with the Core Foundation APIs - CFStringRef hPath = NULL; - CFURLRef hURL = NULL; - CFBundleRef hBundle = NULL; - - DWORD cchFullPath = PAL_wcslen(pwszCoreClrFullPath); - DWORD cchVersionString = 0; - - // Make sure the full path is not too long. - if (cchFullPath > MAX_PATH) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto LExit; - } - - // Include an extra space for the NULL character. - WCHAR wszBundlePath[MAX_PATH + 1]; - if (wcscpy_s(wszBundlePath, cchFullPath + 1, pwszCoreClrFullPath) != SAFECRT_SUCCESS) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto LExit; - } - - // Null out the last three slashes: - // <foo>/CoreCLR.bundle/Contents/MacOS/ -> <foo>/CoreCLR.bundle/Contents/MacOS - // <foo>/CoreCLR.bundle/Contents/MacOS -> <foo>/CoreCLR.bundle/Contents - // <foo>/CoreCLR.bundle/Contents -> <foo>/CoreCLR.bundle - for (int i = 0; i < 3; i++) - { - WCHAR * pwszLastSlash = PAL_wcsrchr(wszBundlePath, L'/'); - if (pwszLastSlash == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - goto LExit; - } - - *pwszLastSlash = '\0'; - } - - // Create a CFStringRef representation of the bundle path. - hPath = CFStringCreateWithCharacters(kCFAllocatorDefault, wszBundlePath, (CFIndex)PAL_wcslen(wszBundlePath)); - if (hPath == NULL) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto LExit; - } - - // Create a CFURLRef representation of the bundle path. - hURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, hPath, kCFURLPOSIXPathStyle, true); - if (hURL == NULL) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto LExit; - } - - // Create a handle to the CoreCLR bundle. - hBundle = CFBundleCreate(kCFAllocatorDefault, hURL); - if (hBundle == NULL) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto LExit; - } - - cchVersionString = GetBundleVersionString(hBundle, pwszVersionString, cchVersionStringBuffer, - pcchVersionStringBufferRequired); - -LExit: - if (hURL != NULL) - { - CFRelease(hURL); - } - - if (hPath != NULL) - { - CFRelease(hPath); - } - - if (hBundle != NULL) - { - CFRelease(hBundle); - } - - LOGEXIT("PAL_GetVersionString returns %u, pwszVersionString=\"%S\", *pcchVersionStringBufferRequired=%u\n", - cchVersionString, (pwszVersionString ? pwszVersionString : W16_NULLSTRING), - (pcchVersionStringBufferRequired ? *pcchVersionStringBufferRequired : 0)); - PERF_EXIT(PAL_GetVersionString); - return cchVersionString; -} - -//--------------------------------------------------------------------------------------- -// -// Retrieve the version stored in the Info.plist file in the CoreCLR bundle. -// -// Arguments: -// pwszVersionString - out parameter; buffer to be filled with the version string -// cchVersionStringBuffer - size of the buffer in # of characters pointed to by pwszVersionString -// pcchVersionStringBufferRequired - required size in characters, including NULL. -// -// Return Value: -// Return the number of characters in the version string (excluding NULL) or 0 if the operation fails. -// -// Notes: -// Call GetLastError() to retrieve more information if the function fails. -// - -PALAPI -DWORD -PAL_GetCoreCLRVersionString( - IN OUT WCHAR * pwszVersionString, - IN DWORD cchVersionStringBuffer, - IN DWORD *pcchVersionStringBufferRequired) -{ - PERF_ENTRY(PAL_GetCoreCLRVersionString); - ENTRY("PAL_GetCoreCLRVersionString (pwszVersionString=%p, cchVersionStringBuffer=%u, " - "pcchVersionStringBufferRequired=%p)\n", - pwszVersionString, cchVersionStringBuffer, pcchVersionStringBufferRequired); - - // various handles for dealing with the Core Foundation APIs - CFBundleRef hBundle = NULL; - - DWORD cchVersionString = 0; - - // NOTE: This code knows that CORECLRHANDLE is actually a CFBundleRef - hBundle = (CFBundleRef)FindCoreCLRHandle(); - if (hBundle == NULL) - { - SetLastError(ERROR_INVALID_DATA); - goto LExit; - } - - cchVersionString = GetBundleVersionString(hBundle, pwszVersionString, cchVersionStringBuffer, - pcchVersionStringBufferRequired); - -LExit: - if (hBundle != NULL) - { - CFRelease(hBundle); - } - - LOGEXIT("PAL_GetCoreCLRVersionString returns %u, pwszVersionString=\"%S\", *pcchVersionStringBufferRequired=%u\n", - cchVersionString, (pwszVersionString ? pwszVersionString : W16_NULLSTRING), - (pcchVersionStringBufferRequired ? *pcchVersionStringBufferRequired : 0)); - PERF_EXIT(PAL_GetCoreCLRVersionString); - return cchVersionString; -} -#else // __APPLE__ - // Get base address of the coreclr module PALAPI LPCVOID @@ -2598,5 +1950,3 @@ PAL_GetCoreClrModuleBase() PERF_EXIT(PAL_GetCoreClrModuleBase); return retval; } - -#endif // __APPLE__ diff --git a/src/pal/src/locale/locale.cpp b/src/pal/src/locale/locale.cpp index 5593ffe6ed..eb7c73dffe 100644 --- a/src/pal/src/locale/locale.cpp +++ b/src/pal/src/locale/locale.cpp @@ -359,7 +359,7 @@ static CFStringRef CFStringCreateMacFormattedLocaleName(LPCWSTR lpLocaleName) return NULL; } - CFStringAppendCharacters(cfMutableLocaleName, lpLocaleName, PAL_wcslen(lpLocaleName)); + CFStringAppendCharacters(cfMutableLocaleName, (const UniChar*)lpLocaleName, PAL_wcslen(lpLocaleName)); CFStringFindAndReplace(cfMutableLocaleName, CFSTR("-"), @@ -848,7 +848,7 @@ GetUserDefaultLocaleName( SetLastError(ERROR_INSUFFICIENT_BUFFER); goto EXIT; } - CFStringGetCharacters(cfLocaleName,CFRangeMake(0,iStrLen),lpLocaleName); + CFStringGetCharacters(cfLocaleName,CFRangeMake(0,iStrLen),(UniChar*)lpLocaleName); lpLocaleName[iStrLen]=L'\0'; iRetVal=iStrLen+1; @@ -1554,7 +1554,7 @@ GetCalendarInfoEx( } else if (cchData >= length + 1) { - CFStringGetCharacters(cfString, CFRangeMake(0, length), lpCalData); + CFStringGetCharacters(cfString, CFRangeMake(0, length), (UniChar*)lpCalData); lpCalData[length] = L'\0'; nRetval = length + 1; } @@ -1614,7 +1614,7 @@ GetDateFormatHelper( * expected by Core Foundation. However, currently no one calls this * with a format where this would actually matter. */ - cfStringFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, lpFormat, PAL_wcslen(lpFormat)); + cfStringFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); if (cfStringFormat == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1645,7 +1645,7 @@ GetDateFormatHelper( } else if (cchDate >= length + 1) { - CFStringGetCharacters(cfStringDate, CFRangeMake(0, length), lpDateStr); + CFStringGetCharacters(cfStringDate, CFRangeMake(0, length), (UniChar*)lpDateStr); lpDateStr[length] = L'\0'; nRetval = length + 1; } @@ -1945,13 +1945,13 @@ CompareStringHelper( cchCount2 = PAL_wcslen( lpString2 ); } - cfString1 = CFStringCreateWithCharacters(kCFAllocatorDefault, lpString1, cchCount1); + cfString1 = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpString1, cchCount1); if (cfString1 == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } - cfString2 = CFStringCreateWithCharacters(kCFAllocatorDefault, lpString2, cchCount2); + cfString2 = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpString2, cchCount2); if (cfString2 == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -3841,7 +3841,7 @@ CLEANUP: } else if (cchData >= length + 1) { - CFStringGetCharacters(cfString, CFRangeMake(0, length), lpLCData); + CFStringGetCharacters(cfString, CFRangeMake(0, length), (UniChar*)lpLCData); lpLCData[length] = L'\0'; nRetval = length + 1; } @@ -4181,7 +4181,7 @@ GetSystemDefaultLocaleName( SetLastError(ERROR_INSUFFICIENT_BUFFER); goto EXIT; } - CFStringGetCharacters(cfLocaleName,CFRangeMake(0,iStrLen),lpLocaleName); + CFStringGetCharacters(cfLocaleName,CFRangeMake(0,iStrLen),(UniChar*)lpLocaleName); lpLocaleName[iStrLen]=L'\0'; iRetVal=iStrLen+1; @@ -4365,7 +4365,7 @@ static EnumResult EnumDateFormatsExExHelper(DATEFMT_ENUMPROCEXEXW lpDateFmtEnumP goto EXIT; } - CFStringGetCharacters(cfString, CFRangeMake(0, length), buffer); + CFStringGetCharacters(cfString, CFRangeMake(0, length), (UniChar*)buffer); buffer[length] = L'\0'; calid = CFLocaleGetCALID(cfLocale); @@ -4514,7 +4514,7 @@ static EnumResult EnumTimeFormatsExHelper(TIMEFMT_ENUMPROCEXW lpTimeFmtEnumProc, goto EXIT; } - CFStringGetCharacters(cfString, CFRangeMake(0, length), buffer); + CFStringGetCharacters(cfString, CFRangeMake(0, length), (UniChar*)buffer); buffer[length] = L'\0'; TRACE("EnumTimeFormatsEx invoking callback for \"%S\"\n", buffer); @@ -4661,7 +4661,7 @@ static BOOL EnumCalendarInfoExEx_Helper( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - CFStringGetCharacters(cfString, CFRangeMake(0, length), buffer); + CFStringGetCharacters(cfString, CFRangeMake(0, length), (UniChar*)buffer); buffer[length] = L'\0'; TRACE("EnumCalendarInfoExEx invoking callback for \"%S\"\n", buffer); @@ -4916,7 +4916,7 @@ LCMapStringHelper( SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } - CFStringAppendCharacters(cfMutableString, lpSrcStr, cchSrc); + CFStringAppendCharacters(cfMutableString, (const UniChar*)lpSrcStr, cchSrc); switch (dwMapFlags) { @@ -4959,7 +4959,7 @@ LCMapStringHelper( } else { - CFStringGetCharacters(cfMutableString, CFRangeMake(0, nRetval), lpDestStr); + CFStringGetCharacters(cfMutableString, CFRangeMake(0, nRetval), (UniChar*)lpDestStr); } } @@ -5085,7 +5085,7 @@ PAL_NormalizeStringExW( SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } - CFStringAppendCharacters(cfMutableString, lpSrcStr, cchSrc); + CFStringAppendCharacters(cfMutableString, (const UniChar*)lpSrcStr, cchSrc); // TODO: Additionally, we should normalize according to the locale. // Unfortunately, Core Foundation has no such function in Mac OS X 10.4. @@ -5114,7 +5114,7 @@ PAL_NormalizeStringExW( nRetval = 0; goto EXIT; } - CFStringGetCharacters(cfMutableString, CFRangeMake(0, nRetval), lpDestStr); + CFStringGetCharacters(cfMutableString, CFRangeMake(0, nRetval), (UniChar*)lpDestStr); if (nRetval != length) { lpDestStr[length] = L'\0'; @@ -5180,14 +5180,14 @@ PAL_ParseDateW( goto EXIT; } - cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, lpFormat, PAL_wcslen(lpFormat)); + cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); if (cfFormat == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } - cfString = CFStringCreateWithCharacters(kCFAllocatorDefault, lpString, PAL_wcslen(lpString)); + cfString = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpString, PAL_wcslen(lpString)); if (cfString == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -5208,7 +5208,7 @@ PAL_ParseDateW( CFDateFormatterSetFormat(cfFormatter,cfFormat); // Does format contain 'Z' - cfFormatString = CFStringCreateWithCharacters(kCFAllocatorDefault, lpFormat, PAL_wcslen(lpFormat)); + cfFormatString = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); if (cfFormatString == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -5319,7 +5319,7 @@ PAL_FormatDateW( goto EXIT; } - cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, lpFormat, PAL_wcslen(lpFormat)); + cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); if (cfFormat == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -5482,7 +5482,7 @@ PAL_FormatDateW( goto EXIT; } - CFStringGetCharacters(cfString,CFRangeMake(0, strLen),lpDestStr); + CFStringGetCharacters(cfString,CFRangeMake(0, strLen),(UniChar*)lpDestStr); lpDestStr[strLen] = L'\0'; RetVal = strLen; @@ -5723,7 +5723,7 @@ static BOOL CFNumberFormatterSetPropertyString(CFNumberFormatterRef formatter, C // NULL means default if (sPropertyValue == NULL) return TRUE; - CFStringRef cfPropertyValue = CFStringCreateWithCharacters(kCFAllocatorDefault, sPropertyValue, PAL_wcslen(sPropertyValue)); + CFStringRef cfPropertyValue = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)sPropertyValue, PAL_wcslen(sPropertyValue)); if (cfPropertyValue == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -5761,11 +5761,11 @@ static BOOL CFNumberFormatterAdjust(CFNumberFormatterRef formatter, LPCSTR forma case ' ': CFStringAppend(sFormat,CFSTR(" ")); break; case '-': if(sMinus) - CFStringAppendCharacters(sFormat,sMinus,PAL_wcslen(sMinus)); + CFStringAppendCharacters(sFormat,(const UniChar*)sMinus,PAL_wcslen(sMinus)); break; case '$': if(sDollar) - CFStringAppendCharacters(sFormat,sDollar,PAL_wcslen(sDollar)); + CFStringAppendCharacters(sFormat,(const UniChar*)sDollar,PAL_wcslen(sDollar)); break; default: @@ -5822,7 +5822,7 @@ static int CFNumberFormatHelper(CFNumberFormatterRef formatter, PALNUMBER number SetLastError(ERROR_INSUFFICIENT_BUFFER); return -1; } - CFStringGetCharacters(cfFormattedNumber,CFRangeMake(0,iStrLen),pBuffer); + CFStringGetCharacters(cfFormattedNumber,CFRangeMake(0,iStrLen),(UniChar*)pBuffer); pBuffer[iStrLen]=L'\0'; } diff --git a/src/pal/src/locale/unicode.cpp b/src/pal/src/locale/unicode.cpp index a33ef44f52..d3dd7940b2 100644 --- a/src/pal/src/locale/unicode.cpp +++ b/src/pal/src/locale/unicode.cpp @@ -1231,7 +1231,7 @@ ReleaseLock: goto ReleaseString; } CFStringGetCharacters(cfString, CFRangeMake(0, length), - lpWideCharStr); + (UniChar*)lpWideCharStr); retval = length; } else @@ -1559,7 +1559,7 @@ ReleaseLock: } cfString = CFStringCreateWithCharacters(kCFAllocatorDefault, - lpWideCharStr, charsToConvert); + (const UniChar*)lpWideCharStr, charsToConvert); if (cfString == NULL) { ERROR("CFString creation failed.\n"); diff --git a/src/pal/src/memory/heap.cpp b/src/pal/src/memory/heap.cpp index 1ad5676229..3d9b94151a 100644 --- a/src/pal/src/memory/heap.cpp +++ b/src/pal/src/memory/heap.cpp @@ -446,7 +446,7 @@ HeapReAlloc( { CPalThread *pthrCurrent = InternalGetCurrentThread(); pthrCurrent->suspensionInfo.EnterUnsafeRegion(); - malloc_zone_realloc((malloc_zone_t *)hHeap, lpmem, fullsize); + pMem = (BYTE *) malloc_zone_realloc((malloc_zone_t *)hHeap, lpmem, fullsize); pthrCurrent->suspensionInfo.LeaveUnsafeRegion(); } #else // __APPLE__ diff --git a/src/pal/src/misc/fmtmessage.cpp b/src/pal/src/misc/fmtmessage.cpp index 3a53b3b07b..ea7e98b792 100644 --- a/src/pal/src/misc/fmtmessage.cpp +++ b/src/pal/src/misc/fmtmessage.cpp @@ -49,7 +49,6 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC); /* Function pointers and handles. */ typedef VOID * HSATELLITE; static HSATELLITE s_hSatellite = NULL; -#if !defined(CORECLR) || !defined(__APPLE__) static LPVOID s_lpLibRotorPalRt = NULL; typedef HSATELLITE (__stdcall *FnLoadSatelliteResource)(LPCWSTR); static FnLoadSatelliteResource LoadSatelliteResource; @@ -57,45 +56,7 @@ typedef BOOL (__stdcall *FnFreeSatelliteResource)(HSATELLITE); static FnFreeSatelliteResource FreeSatelliteResource; typedef UINT (__stdcall *FnLoadSatelliteStringW)(HSATELLITE, UINT, LPWSTR, UINT); static FnLoadSatelliteStringW LoadSatelliteStringW; -#else // !CORECLR || !__APPLE__ -// Under CoreCLR/Mac both the PAL and PALRT are statically linked. Thus we can reference the resource -// routines from the runtime without using GetProcAddress. -EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceW(LPCWSTR SatelliteResourceFileName); -EXTERN_C BOOL PALAPI PAL_FreeSatelliteResource(HSATELLITE SatelliteResource); -EXTERN_C UINT PALAPI PAL_LoadSatelliteStringW(HSATELLITE SatelliteResource, - UINT uID, - LPWSTR lpBuffer, - UINT nBufferMax); -#define LoadSatelliteResource PAL_LoadSatelliteResourceW -#define FreeSatelliteResource PAL_FreeSatelliteResource -#define LoadSatelliteStringW PAL_LoadSatelliteStringW - -// We are still a few build tools that link in rotor_pal before rotor_palrt has even been built. For -// these guys we have the linker redirect the symbol lookups back here to stubs that will assert an -// error message (this is no worse than the non-CoreCLR behavior where the runtime dynamic library -// load would fail if triggered by one of these build tools). -EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceW_NoRT(LPCWSTR SatelliteResourceFileName) -{ - ASSERT("Tried to call PAL_LoadSatelliteResourceW from an image not linked with rotor_palrt\n"); - return NULL; -} -EXTERN_C BOOL PALAPI PAL_FreeSatelliteResource_NoRT(HSATELLITE SatelliteResource) -{ - ASSERT("Tried to call PAL_FreeSatelliteResource from an image not linked with rotor_palrt\n"); - return FALSE; -} -EXTERN_C UINT PALAPI PAL_LoadSatelliteStringW_NoRT(HSATELLITE SatelliteResource, - UINT uID, - LPWSTR lpBuffer, - UINT nBufferMax) -{ - ASSERT("Tried to call PAL_LoadSatelliteStringW from an image not linked with rotor_palrt\n"); - return 0; -} - -#endif // !CORECLR || !__APPLE__ -#if !defined(CORECLR) || !defined(__APPLE__) /*++ Function : @@ -145,7 +106,6 @@ static LPVOID FMTMSG_LoadLibrary( ) error: return s_lpLibRotorPalRt; } -#endif // !CORECLR || !__APPLE__ /*++ @@ -160,9 +120,6 @@ Function : static HSATELLITE FMTMSG_FormatMessageInit( void ) { static const WCHAR ROTORPALSATFILE[] = { -#ifndef CORECLR - 'r','o','t','o','r','_', -#endif // !CORECLR 'p','a','l','.','s','a','t','e','l','l','i','t','e', '\0' }; @@ -170,7 +127,6 @@ static HSATELLITE FMTMSG_FormatMessageInit( void ) HSATELLITE hSatellite; -#if !defined(CORECLR) || !defined(__APPLE__) LPVOID lpLibRotorPalRt; TRACE( "Initilizing the dynamic library and the satellite files.\n" ); @@ -202,7 +158,6 @@ static HSATELLITE FMTMSG_FormatMessageInit( void ) "Reason %s.\n", dlerror() ); goto error; } -#endif // !CORECLR || !__APPLE__ /* Load the satellite file. */ if ( !PAL_GetPALDirectoryW( SatPathAndFile, MAX_PATH ) ) @@ -245,23 +200,19 @@ Function : BOOL FMTMSG_FormatMessageCleanUp( void ) { TRACE( "Cleaning up the dynamic library and the satellite files.\n" ); -#if !defined(CORECLR) || !defined(__APPLE__) if ( s_lpLibRotorPalRt ) { -#endif // !CORECLR || !__APPLE__ if (s_hSatellite) { (*FreeSatelliteResource)(s_hSatellite); s_hSatellite = NULL; } -#if !defined(CORECLR) || !defined(__APPLE__) if ( dlclose( s_lpLibRotorPalRt ) != 0 ) { ASSERT( "Unable to close the dynamic library\n" ); } s_lpLibRotorPalRt = NULL; } -#endif // !CORECLR || !__APPLE__ return TRUE; } diff --git a/src/pal/src/misc/miscpalapi.cpp b/src/pal/src/misc/miscpalapi.cpp index 8342cd2327..c2d7d6e2fa 100644 --- a/src/pal/src/misc/miscpalapi.cpp +++ b/src/pal/src/misc/miscpalapi.cpp @@ -60,7 +60,6 @@ BOOL PALAPI PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN UINT cchDirectoryName ) { -#if !defined(CORECLR) || !defined(__APPLE__) LPWSTR lpFullPathAndName = NULL; LPWSTR lpEndPoint = NULL; BOOL bRet = FALSE; @@ -110,68 +109,6 @@ EXIT: LOGEXIT( "PAL_GetPALDirectoryW returns BOOL %d.\n", bRet); PERF_EXIT(PAL_GetPALDirectoryW); return bRet; -#else // !CORECLR || !__APPLE__ - BOOL bRet = FALSE; - char szDirectory[MAX_PATH + 1]; - - PERF_ENTRY(PAL_GetPALDirectoryW); - ENTRY( "PAL_GetPALDirectoryW( %p, %d )\n", lpDirectoryName, cchDirectoryName ); - - // Under CoreCLR/Mac PAL is not a separate dynamic library, but is statically linked instead. Under normal - // circumstances the PAL will be linked into a single binary containing all the CoreCLR code, but there - // are still cases where build tools depend upon and statically link the PAL themselves. We can tell the - // difference because CoreCLR initialization sets the value of the g_szCoreCLRPath to the very information - // we want to return here. If this has not been set we'll assume this is a standalone PAL and derive the - // installation directory from the main executable directory. - if (g_szCoreCLRPath[0] != '\0') - { - if (strlen(g_szCoreCLRPath) >= sizeof(szDirectory)) - { - ASSERT("Internal buffer not large enough"); - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto EXIT; - } - strcpy_s(szDirectory, sizeof(szDirectory), g_szCoreCLRPath); - } - else - { - // We must be a standalone PAL linked into some application (e.g. the build tools such as build.exe or - // fxprun). So our installation directory is simply the directory the executable resides in. - uint32_t bufsize = sizeof(szDirectory); - if (_NSGetExecutablePath(szDirectory, &bufsize)) - { - ASSERT("_NSGetExecutablePath failure\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - - // Strip off executable name (but leave trailing '/'). - char *pszLastSlash = rindex(szDirectory, '/'); - if (pszLastSlash == NULL) - { - ASSERT("_NSGetExecutablePath returned filename without path\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - pszLastSlash[1] = '\0'; - } - - // Once we get here we have the directory in 8-bit format in szDirectory, just need to convert - // it to wide characters now. - if (MultiByteToWideChar(CP_UTF8, 0, szDirectory, -1, lpDirectoryName, cchDirectoryName) == 0) - { - ASSERT("PAL_GetPALDirectoryW: MultiByteToWideChar failed\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - - bRet = TRUE; - -EXIT: - LOGEXIT( "PAL_GetPALDirectoryW returns BOOL %d.\n", bRet); - PERF_EXIT(PAL_GetPALDirectoryW); - return bRet; -#endif // !CORECLR || !__APPLE__ } PALIMPORT diff --git a/src/pal/src/misc/version.cpp b/src/pal/src/misc/version.cpp index 0b714e0379..04c5cd8e28 100644 --- a/src/pal/src/misc/version.cpp +++ b/src/pal/src/misc/version.cpp @@ -257,7 +257,7 @@ GetVersionExW( if (len > static_cast<int>((sizeof(lpVersionInformation->szCSDVersion)/2) - 1)) len = (sizeof(lpVersionInformation->szCSDVersion)/2) - 1; CFStringGetCharacters(serviceRelease, CFRangeMake(0, len), - lpVersionInformation->szCSDVersion); + (UniChar*)lpVersionInformation->szCSDVersion); lpVersionInformation->szCSDVersion[len] = 0; CFRelease(serviceRelease); } diff --git a/src/pal/tools/cppmunge/cppmunge.c b/src/pal/tools/cppmunge/cppmunge.c index d661461861..56a9a2cfc0 100644 --- a/src/pal/tools/cppmunge/cppmunge.c +++ b/src/pal/tools/cppmunge/cppmunge.c @@ -35,7 +35,9 @@ #include <assert.h> #include <ctype.h> +#if !defined(__APPLE__) #include <linux/limits.h> +#endif #include <limits.h> #include <stdio.h> #include <stdlib.h> diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh index 723fc1d0e0..ff7c2a9c86 100755 --- a/src/pal/tools/gen-buildsys-clang.sh +++ b/src/pal/tools/gen-buildsys-clang.sh @@ -24,15 +24,27 @@ else buildtype=$2 fi +OS=`uname` + # Locate llvm # This can be a little complicated, because the common use-case of Ubuntu with # llvm-3.5 installed uses a rather unusual llvm installation with the version # number postfixed (i.e. llvm-ar-3.5), so we check for that first. +# Additionally, OSX doesn't use the llvm- prefix. +if [ $OS = "Linux" ]; then + llvm_prefix="llvm-" +elif [ $OS = "Darwin" ]; then + llvm_prefix="" +else + echo "Unable to determine build platform" + exit 1 +fi + desired_llvm_version=3.5 locate_llvm_exec() { - if which $1-$desired_llvm_version > /dev/null 2>&1 + if which $llvm_prefix$1-$desired_llvm_version > /dev/null 2>&1 then - echo $(which $1-$desired_llvm_version) + echo $(which $llvm_prefix$1-$desired_llvm_version) elif which $1 > /dev/null 2>&1 then echo $(which $1) @@ -40,16 +52,18 @@ locate_llvm_exec() { exit 1 fi } -llvm_ar=$(locate_llvm_exec llvm-ar) +llvm_ar=$(locate_llvm_exec ar) [[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; } -llvm_link=$(locate_llvm_exec llvm-link) +llvm_link=$(locate_llvm_exec link) [[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; } -llvm_nm=$(locate_llvm_exec llvm-nm) +llvm_nm=$(locate_llvm_exec nm) [[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; } -llvm_objdump=$(locate_llvm_exec llvm-objdump) -[[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; } -llvm_ranlib=$(locate_llvm_exec llvm-ranlib) +llvm_ranlib=$(locate_llvm_exec ranlib) [[ $? -eq 0 ]] || { echo "Unable to locate llvm-ranlib"; exit 1; } +if [ $OS = "Linux" ]; then + llvm_objdump=$(locate_llvm_exec objdump) + [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; } +fi cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override.txt \ -DCMAKE_AR=$llvm_ar \ diff --git a/src/vm/amd64/cgencpu.h b/src/vm/amd64/cgencpu.h index ccc7d519e9..68a45f8e19 100644 --- a/src/vm/amd64/cgencpu.h +++ b/src/vm/amd64/cgencpu.h @@ -56,8 +56,10 @@ EXTERN_C void FastCallFinalizeWorker(Object *obj, PCODE funcPtr); #define HAS_NDIRECT_IMPORT_PRECODE 1 //#define HAS_REMOTING_PRECODE 1 // TODO: Implement +#if !defined(__APPLE__) #define HAS_FIXUP_PRECODE 1 #define HAS_FIXUP_PRECODE_CHUNKS 1 +#endif // ThisPtrRetBufPrecode one is necessary for closed delegates over static methods with return buffer #define HAS_THISPTR_RETBUF_PRECODE 1 diff --git a/src/vm/amd64/jithelpers_fast.S b/src/vm/amd64/jithelpers_fast.S index cdaa48e1a8..a981254806 100644 --- a/src/vm/amd64/jithelpers_fast.S +++ b/src/vm/amd64/jithelpers_fast.S @@ -16,12 +16,11 @@ LEAF_END JIT_PatchedCodeStart, _TEXT // change at runtime as the GC changes. Initially it should simply be a copy of the // larger of the two functions (JIT_WriteBarrier_PostGrow) to ensure we have created // enough space to copy that code in. - .align 16 +.balign 16 LEAF_ENTRY JIT_WriteBarrier, _TEXT - #ifdef _DEBUG // In debug builds, this just contains jump to the debug version of the write barrier by default - jmp JIT_WriteBarrier_Debug + jmp C_FUNC(JIT_WriteBarrier_Debug) #endif // Do the move into the GC . It is correct to take an AV here, the EH code @@ -38,38 +37,41 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT // a special non-volatile calling convention, this should be changed to // just one. - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Check the lower and upper ephemeral region bounds cmp rsi, rax - jb Exit + // jb Exit + .byte 0x72, 0x36 nop // padding for alignment of constant - movabs r8, 0F0F0F0F0F0F0F0F0h + movabs r8, 0xF0F0F0F0F0F0F0F0 cmp rsi, r8 - jae Exit + // jae Exit + .byte 0x73, 0x26 nop // padding for alignment of constant - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Touch the card table entry, if not already dirty. shr rdi, 0Bh cmp byte ptr [rdi + rax], 0FFh - jne UpdateCardTable + // jne UpdateCardTable + .byte 0x75, 0x02 REPRET UpdateCardTable: mov byte ptr [rdi + rax], 0FFh ret - .align 16 + .balign 16 Exit: REPRET // make sure this guy is bigger than any of the other guys - .align 16 + .balign 16 nop LEAF_END_MARKED JIT_WriteBarrier, _TEXT @@ -99,12 +101,15 @@ LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT // See if this is in GCHeap PREPARE_EXTERNAL_VAR g_lowest_address, rax cmp rdi, [rax] - jb NotInHeap + // jb NotInHeap + .byte 0x72, 0x0e PREPARE_EXTERNAL_VAR g_highest_address, rax cmp rdi, [rax] - jnb NotInHeap + // jnb NotInHeap + .byte 0x73, 0x02 - jmp JIT_WriteBarrier + // call C_FUNC(JIT_WriteBarrier) + .byte 0xeb, 0x84 NotInHeap: // See comment above about possible AV @@ -228,7 +233,7 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT mov byte ptr [rcx], 0FFh ret - .align 16 + .balign 16 NotInHeap_ByRefWriteBarrier: // If WRITE_BARRIER_CHECK then we won't have already done the mov and should do it here // If !WRITE_BARRIER_CHECK we want _NotInHeap and _Leave to be the same and have both diff --git a/src/vm/amd64/jithelpers_fastwritebarriers.S b/src/vm/amd64/jithelpers_fastwritebarriers.S index d1366e825b..1e225b0b5b 100644 --- a/src/vm/amd64/jithelpers_fastwritebarriers.S +++ b/src/vm/amd64/jithelpers_fastwritebarriers.S @@ -6,7 +6,7 @@ .intel_syntax noprefix #include "unixasmmacros.inc" - .align 4 + .balign 4 LEAF_ENTRY JIT_WriteBarrier_PreGrow32, _TEXT // Do the move into the GC . It is correct to take an AV here, the EH code // figures out that this came from a WriteBarrier and correctly maps it back @@ -18,12 +18,14 @@ LEAF_ENTRY JIT_WriteBarrier_PreGrow32, _TEXT PATCH_LABEL JIT_WriteBarrier_PreGrow32_PatchLabel_Lower cmp rsi, -0F0F0F10h // 0F0F0F0F0h - jb Exit_PreGrow32 + .byte 0x72, 0x22 + // jb Exit_PreGrow32 shr rdi, 0Bh PATCH_LABEL JIT_WriteBarrier_PreGrow32_PatchLabel_CardTable_Check cmp byte ptr [rdi + 0F0F0F0F0h], 0FFh - jne UpdateCardTable_PreGrow32 + .byte 0x75, 0x03 + // jne UpdateCardTable_PreGrow32 REPRET nop // padding for alignment of constant @@ -33,12 +35,12 @@ PATCH_LABEL JIT_WriteBarrier_PreGrow32_PatchLabel_CardTable_Update mov byte ptr [rdi + 0F0F0F0F0h], 0FFh ret - .align 16 + .balign 16 Exit_PreGrow32: REPRET LEAF_END_MARKED JIT_WriteBarrier_PreGrow32, _TEXT - .align 8 + .balign 8 LEAF_ENTRY JIT_WriteBarrier_PreGrow64, _TEXT // Do the move into the GC . It is correct to take an AV here, the EH code // figures out that this came from a WriteBarrier and correctly maps it back @@ -51,33 +53,35 @@ LEAF_ENTRY JIT_WriteBarrier_PreGrow64, _TEXT // Can't compare a 64 bit immediate, so we have to move it into a // register. Value of this immediate will be patched at runtime. PATCH_LABEL JIT_WriteBarrier_PreGrow64_Patch_Label_Lower - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Check the lower ephemeral region bound. cmp rsi, rax - jb Exit_PreGrow64 + .byte 0x72, 0x23 + // jb Exit_PreGrow64 nop // padding for alignment of constant PATCH_LABEL JIT_WriteBarrier_PreGrow64_Patch_Label_CardTable - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Touch the card table entry, if not already dirty. shr rdi, 0Bh cmp byte ptr [rdi + rax], 0FFh - jne UpdateCardTable_PreGrow64 + .byte 0x75, 0x02 + // jne UpdateCardTable_PreGrow64 REPRET UpdateCardTable_PreGrow64: mov byte ptr [rdi + rax], 0FFh ret - .align 16 + .balign 16 Exit_PreGrow64: REPRET LEAF_END_MARKED JIT_WriteBarrier_PreGrow64, _TEXT - .align 8 + .balign 8 // See comments for JIT_WriteBarrier_PreGrow (above). LEAF_ENTRY JIT_WriteBarrier_PostGrow64, _TEXT // Do the move into the GC . It is correct to take an AV here, the EH code @@ -94,41 +98,44 @@ LEAF_ENTRY JIT_WriteBarrier_PostGrow64, _TEXT // a special non-volatile calling convention, this should be changed to // just one. PATCH_LABEL JIT_WriteBarrier_PostGrow64_Patch_Label_Lower - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Check the lower and upper ephemeral region bounds cmp rsi, rax - jb Exit_PostGrow64 + .byte 0x72,0x33 + // jb Exit_PostGrow64 nop // padding for alignment of constant PATCH_LABEL JIT_WriteBarrier_PostGrow64_Patch_Label_Upper - movabs r8, 0F0F0F0F0F0F0F0F0h + movabs r8, 0xF0F0F0F0F0F0F0F0 cmp rsi, r8 - jae Exit_PostGrow64 + .byte 0x73,0x23 + // jae Exit_PostGrow64 nop // padding for alignment of constant PATCH_LABEL JIT_WriteBarrier_PostGrow64_Patch_Label_CardTable - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 // Touch the card table entry, if not already dirty. shr rdi, 0Bh cmp byte ptr [rdi + rax], 0FFh - jne UpdateCardTable_PostGrow64 + .byte 0x75, 0x02 + // jne UpdateCardTable_PostGrow64 REPRET UpdateCardTable_PostGrow64: mov byte ptr [rdi + rax], 0FFh ret - .align 16 + .balign 16 Exit_PostGrow64: REPRET LEAF_END_MARKED JIT_WriteBarrier_PostGrow64, _TEXT - .align 4 + .balign 4 LEAF_ENTRY JIT_WriteBarrier_PostGrow32, _TEXT // Do the move into the GC . It is correct to take an AV here, the EH code // figures out that this came from a WriteBarrier and correctly maps it back @@ -142,20 +149,23 @@ LEAF_ENTRY JIT_WriteBarrier_PostGrow32, _TEXT PATCH_LABEL JIT_WriteBarrier_PostGrow32_PatchLabel_Lower cmp rsi, -0F0F0F10h // 0F0F0F0F0h - jb Exit_PostGrow32 + .byte 0x72, 0x2e + // jb Exit_PostGrow32 NOP_3_BYTE // padding for alignment of constant PATCH_LABEL JIT_WriteBarrier_PostGrow32_PatchLabel_Upper cmp rsi, -0F0F0F10h // 0F0F0F0F0h - jae Exit_PostGrow32 + .byte 0x73, 0x22 + // jae Exit_PostGrow32 // Touch the card table entry, if not already dirty. shr rdi, 0Bh PATCH_LABEL JIT_WriteBarrier_PostGrow32_PatchLabel_CheckCardTable cmp byte ptr [rdi + 0F0F0F0F0h], 0FFh - jne UpdateCardTable_PostGrow32 + .byte 0x75, 0x03 + // jne UpdateCardTable_PostGrow32 REPRET nop // padding for alignment of constant @@ -165,13 +175,13 @@ PATCH_LABEL JIT_WriteBarrier_PostGrow32_PatchLabel_UpdateCardTable mov byte ptr [rdi + 0F0F0F0F0h], 0FFh ret - .align 16 + .balign 16 Exit_PostGrow32: REPRET LEAF_END_MARKED JIT_WriteBarrier_PostGrow32, _TEXT - .align 4 + .balign 4 LEAF_ENTRY JIT_WriteBarrier_SVR32, _TEXT // // SVR GC has multiple heaps, so it cannot provide one single @@ -192,7 +202,8 @@ LEAF_ENTRY JIT_WriteBarrier_SVR32, _TEXT PATCH_LABEL JIT_WriteBarrier_SVR32_PatchLabel_CheckCardTable cmp byte ptr [rdi + 0F0F0F0F0h], 0FFh - jne UpdateCardTable_SVR32 + .byte 0x75, 0x03 + // jne UpdateCardTable_SVR32 REPRET nop // padding for alignment of constant @@ -203,7 +214,7 @@ PATCH_LABEL JIT_WriteBarrier_SVR32_PatchLabel_UpdateCardTable ret LEAF_END_MARKED JIT_WriteBarrier_SVR32, _TEXT - .align 8 + .balign 8 LEAF_ENTRY JIT_WriteBarrier_SVR64, _TEXT // // SVR GC has multiple heaps, so it cannot provide one single @@ -221,12 +232,13 @@ LEAF_ENTRY JIT_WriteBarrier_SVR64, _TEXT NOP_3_BYTE // padding for alignment of constant PATCH_LABEL JIT_WriteBarrier_SVR64_PatchLabel_CardTable - movabs rax, 0F0F0F0F0F0F0F0F0h + movabs rax, 0xF0F0F0F0F0F0F0F0 shr rdi, 0Bh cmp byte ptr [rdi + rax], 0FFh - jne UpdateCardTable_SVR64 + .byte 0x75, 0x02 + // jne UpdateCardTable_SVR64 REPRET UpdateCardTable_SVR64: diff --git a/src/vm/amd64/jithelpers_slow.S b/src/vm/amd64/jithelpers_slow.S index 32b0d5fdaf..0cd5768f35 100644 --- a/src/vm/amd64/jithelpers_slow.S +++ b/src/vm/amd64/jithelpers_slow.S @@ -92,7 +92,7 @@ LEAF_ENTRY JIT_WriteBarrier_Debug, _TEXT mov byte ptr [rdi], 0FFh ret - .align 16 + .balign 16 Exit_Debug: REPRET LEAF_END_MARKED JIT_WriteBarrier_Debug, _TEXT diff --git a/src/vm/amd64/theprestubamd64.S b/src/vm/amd64/theprestubamd64.S index 7966b2c87e..dd9a042f16 100644 --- a/src/vm/amd64/theprestubamd64.S +++ b/src/vm/amd64/theprestubamd64.S @@ -8,14 +8,14 @@ #include "asmconstants.h" NESTED_ENTRY ThePreStub, _TEXT, ProcessCLRException - PROLOG_WITH_TRANSITION_BLOCK + PROLOG_WITH_TRANSITION_BLOCK 0, 0, 0, 0, 0 // // call PreStubWorker // lea rdi, [rsp + __PWTB_TransitionBlock] // pTransitionBlock* mov rsi, METHODDESC_REGISTER - call PreStubWorker + call C_FUNC(PreStubWorker) EPILOG_WITH_TRANSITION_BLOCK_TAILCALL TAILJMP_RAX diff --git a/src/vm/amd64/unixasmhelpers.S b/src/vm/amd64/unixasmhelpers.S index cc271ea938..8db8815849 100644 --- a/src/vm/amd64/unixasmhelpers.S +++ b/src/vm/amd64/unixasmhelpers.S @@ -27,7 +27,7 @@ LEAF_ENTRY PrecodeFixupThunk, _TEXT lea METHODDESC_REGISTER,[rax+r11*8] // Tail call to prestub - jmp ThePreStub + jmp C_FUNC(ThePreStub) LEAF_END PrecodeFixupThunk, _TEXT @@ -94,7 +94,7 @@ LEAF_END HelperMethodFrameRestoreState, _TEXT // generation will need to altered accordingly. // // EXTERN_C VOID __stdcall NDirectImportThunk()// -NESTED_ENTRY NDirectImportThunk, _TEXT +NESTED_ENTRY NDirectImportThunk, _TEXT, Handler // // Save integer parameter registers. @@ -116,7 +116,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT // Call NDirectImportWorker w/ the NDirectMethodDesc* // mov rdi, METHODDESC_REGISTER - call NDirectImportWorker + call C_FUNC(NDirectImportWorker) RESTORE_FLOAT_ARGUMENT_REGISTERS 0 @@ -150,7 +150,7 @@ LEAF_END moveOWord, _TEXT // // The JIT expects this helper to preserve registers used for return values // -NESTED_ENTRY JIT_RareDisableHelper, _TEXT +NESTED_ENTRY JIT_RareDisableHelper, _TEXT, Handler // First integer return register push rax @@ -163,7 +163,7 @@ NESTED_ENTRY JIT_RareDisableHelper, _TEXT // Second float return register movdqa [rsp+0x10], xmm1 - call JIT_RareDisableHelperWorker + call C_FUNC(JIT_RareDisableHelperWorker) movdqa xmm0, [rsp] movdqa xmm1, [rsp+0x10] @@ -173,3 +173,20 @@ NESTED_ENTRY JIT_RareDisableHelper, _TEXT ret NESTED_END JIT_RareDisableHelper, _TEXT + +LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT + + test rdi, rdi + jz NullObject + + + mov rax, [rdi + OFFSETOF__DelegateObject___methodPtr] + mov rdi, [rdi + OFFSETOF__DelegateObject___target] // replace "this" pointer + + jmp rax + +NullObject: + mov rdi, CORINFO_NullReferenceException_ASM + jmp C_FUNC(JIT_InternalThrow) + +LEAF_END SinglecastDelegateInvokeStub, _TEXT diff --git a/src/vm/amd64/unixasmmacros.inc b/src/vm/amd64/unixasmmacros.inc index ded46bddce..79d2ea5044 100644 --- a/src/vm/amd64/unixasmmacros.inc +++ b/src/vm/amd64/unixasmmacros.inc @@ -24,21 +24,33 @@ .byte 0xE0 .endm +#if defined(__APPLE__) +#define C_FUNC(name) _##name +#else +#define C_FUNC(name) name +#endif + .macro PATCH_LABEL Name - .global \Name -\Name: + .global C_FUNC(\Name) +C_FUNC(\Name): .endm .macro LEAF_ENTRY Name, Section - .global \Name + .global C_FUNC(\Name) +#if defined(__APPLE__) + .text +#else .type \Name, %function -\Name: +#endif +C_FUNC(\Name): .endm .macro LEAF_END_MARKED Name, Section -\Name\()_End: - .global \Name\()_End +C_FUNC(\Name\()_End): + .global C_FUNC(\Name\()_End) +#if !defined(__APPLE__) .size \Name, .-\Name +#endif .endm .macro LEAF_END Name, Section @@ -46,7 +58,7 @@ .endm .macro PREPARE_EXTERNAL_VAR Name, HelperReg - mov \HelperReg, [rip + \Name@GOTPCREL] + mov \HelperReg, [rip + C_FUNC(\Name)@GOTPCREL] .endm .macro push_nonvol_reg Register diff --git a/src/vm/amd64/unixstubs.cpp b/src/vm/amd64/unixstubs.cpp index d7a86bb826..c51ca40e4c 100644 --- a/src/vm/amd64/unixstubs.cpp +++ b/src/vm/amd64/unixstubs.cpp @@ -47,11 +47,6 @@ extern "C" PORTABILITY_ASSERT("Implement for PAL"); } - void SinglecastDelegateInvokeStub() - { - PORTABILITY_ASSERT("Implement for PAL"); - } - void TheUMEntryPrestub() { PORTABILITY_ASSERT("Implement for PAL"); diff --git a/src/vm/amd64/virtualcallstubamd64.S b/src/vm/amd64/virtualcallstubamd64.S index 2271631c7c..e86e3b9535 100644 --- a/src/vm/amd64/virtualcallstubamd64.S +++ b/src/vm/amd64/virtualcallstubamd64.S @@ -24,9 +24,9 @@ // or the ResolveCacheElem when r11 has the PROMOTE_CHAIN_FLAG set // [rsp+8] m_ReturnAddress: contains the return address of caller to stub -NESTED_ENTRY ResolveWorkerAsmStub, _TEXT +NESTED_ENTRY ResolveWorkerAsmStub, _TEXT, Handler - PROLOG_WITH_TRANSITION_BLOCK 0, 8, rdx + PROLOG_WITH_TRANSITION_BLOCK 0, 8, rdx, 0, 0 // token stored in rdx by prolog @@ -36,7 +36,7 @@ NESTED_ENTRY ResolveWorkerAsmStub, _TEXT and rcx, 7 // flags sub rsi, rcx // indirection cell - call VSD_ResolveWorker + call C_FUNC(VSD_ResolveWorker) EPILOG_WITH_TRANSITION_BLOCK_TAILCALL TAILJMP_RAX @@ -85,6 +85,6 @@ Fail_RWCLAS: pop rsi // Restore the original saved rdx value push r10 // pass the DispatchToken or ResolveCacheElem to promote to ResolveWorkerAsmStub - jmp ResolveWorkerAsmStub + jmp C_FUNC(ResolveWorkerAsmStub) LEAF_END ResolveWorkerChainLookupAsmStub, _TEXT |