summaryrefslogtreecommitdiff
path: root/src/pal/src/include/pal
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-02-10 20:35:12 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-02-10 20:35:12 +0900
commit4b11dc566a5bbfa1378d6266525c281b028abcc8 (patch)
treeb48831a898906734f8884d08b6e18f1144ee2b82 /src/pal/src/include/pal
parentdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (diff)
downloadcoreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.gz
coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.bz2
coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.zip
Imported Upstream version 1.0.0.9910upstream/1.0.0.9910
Diffstat (limited to 'src/pal/src/include/pal')
-rw-r--r--src/pal/src/include/pal/modulename.h3
-rw-r--r--src/pal/src/include/pal/palinternal.h20
-rw-r--r--src/pal/src/include/pal/printfcpp.hpp55
-rw-r--r--src/pal/src/include/pal/sharedmemory.h21
-rw-r--r--src/pal/src/include/pal/thread.hpp18
-rw-r--r--src/pal/src/include/pal/threadsusp.hpp2
-rw-r--r--src/pal/src/include/pal/utils.h56
-rw-r--r--src/pal/src/include/pal/virtual.h5
8 files changed, 80 insertions, 100 deletions
diff --git a/src/pal/src/include/pal/modulename.h b/src/pal/src/include/pal/modulename.h
index 70b0a610dc..20001f8797 100644
--- a/src/pal/src/include/pal/modulename.h
+++ b/src/pal/src/include/pal/modulename.h
@@ -28,9 +28,6 @@ extern "C"
#endif // __cplusplus
const char *PAL_dladdr(LPVOID ProcAddress);
-#if defined(_AIX)
-int GetLibRotorNameViaLoadQuery(LPSTR pszBuf);
-#endif
#ifdef __cplusplus
}
diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h
index f7856be902..48e2f3c683 100644
--- a/src/pal/src/include/pal/palinternal.h
+++ b/src/pal/src/include/pal/palinternal.h
@@ -335,7 +335,7 @@ function_name() to call the system's implementation
#undef va_arg
#endif
-#if !defined(_MSC_VER) && defined(FEATURE_PAL) && defined(_WIN64)
+#if !defined(_MSC_VER) && defined(_WIN64)
#undef _BitScanForward64
#endif
@@ -358,6 +358,7 @@ function_name() to call the system's implementation
#undef memchr
#undef strlen
#undef strnlen
+#undef wcsnlen
#undef stricmp
#undef strstr
#undef strcmp
@@ -502,7 +503,6 @@ function_name() to call the system's implementation
#undef vfwprintf
#undef vprintf
#undef wprintf
-#undef swprintf
#undef wcstod
#undef wcstol
#undef wcstoul
@@ -525,10 +525,6 @@ function_name() to call the system's implementation
#undef iswspace
#undef towlower
#undef towupper
-#undef vsprintf
-#undef vswprintf
-#undef _vsnprintf
-#undef vsnprintf
#undef wvsnprintf
#ifdef _AMD64_
@@ -606,15 +602,19 @@ function_name() to call the system's implementation
#define INFTIM -1
#endif // !HAVE_INFTIM
-#if (__GNUC__ >= 4)
#define OffsetOf(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
-#else
-#define OffsetOf(s, f) (INT)(SIZE_T)&(((s*)0)->f)
-#endif /* __GNUC__ version check*/
#undef assert
#define assert (Use__ASSERTE_instead_of_assert) assert
+#ifndef __ANDROID__
+#define TEMP_DIRECTORY_PATH "/tmp/"
+#else
+// On Android, "/tmp/" doesn't exist; temporary files should go to
+// /data/local/tmp/
+#define TEMP_DIRECTORY_PATH "/data/local/tmp/"
+#endif
+
#define PROCESS_PIPE_NAME_PREFIX ".dotnet-pal-processpipe"
#ifdef __cplusplus
diff --git a/src/pal/src/include/pal/printfcpp.hpp b/src/pal/src/include/pal/printfcpp.hpp
index 0a728c9fd7..12e923a506 100644
--- a/src/pal/src/include/pal/printfcpp.hpp
+++ b/src/pal/src/include/pal/printfcpp.hpp
@@ -32,22 +32,6 @@ typedef char16_t wchar_16; // __wchar_16_cpp (which is defined in palinternal.h)
extern "C"
{
int
- __cdecl
- PAL__vsnprintf(
- LPSTR Buffer,
- size_t Count,
- LPCSTR Format,
- va_list ap);
-
- int
- __cdecl
- PAL__wvsnprintf(
- LPWSTR Buffer,
- size_t Count,
- LPCWSTR Format,
- va_list ap);
-
- int
__cdecl
PAL_vfprintf(
PAL_FILE *stream,
@@ -71,48 +55,9 @@ namespace CorUnix
const char *format,
va_list ap);
- int
- InternalWvsnprintf(
- CPalThread *pthrCurrent,
- LPWSTR Buffer,
- size_t Count,
- LPCWSTR Format,
- va_list ap);
-
- int
- InternalVsnprintf(
- CPalThread *pthrCurrent,
- LPSTR Buffer,
- size_t Count,
- LPCSTR Format,
- va_list ap);
-
- int
- InternalVfwprintf(
- CPalThread *pthrCurrent,
- PAL_FILE *stream,
- const wchar_16 *format,
- va_list ap);
-
}
#else // __cplusplus
- int
- __cdecl
- PAL__vsnprintf(
- LPSTR Buffer,
- size_t Count,
- LPCSTR Format,
- va_list ap);
-
- int
- __cdecl
- PAL__wvsnprintf(
- LPWSTR Buffer,
- size_t Count,
- LPCWSTR Format,
- va_list ap);
-
int
__cdecl
PAL_vfprintf(
diff --git a/src/pal/src/include/pal/sharedmemory.h b/src/pal/src/include/pal/sharedmemory.h
index 45cc4b2c8d..2e0d9d2a79 100644
--- a/src/pal/src/include/pal/sharedmemory.h
+++ b/src/pal/src/include/pal/sharedmemory.h
@@ -15,30 +15,33 @@
#define _countof(a) (sizeof(a) / sizeof(a[0]))
#endif // !_countof
+// The temporary folder is used for storing shared memory files and their lock files.
+// The location of the temporary folder varies (e.g. /data/local/tmp on Android)
+// and is set in TEMP_DIRECTORY_PATH. TEMP_DIRECTORY_PATH ends with '/'
// - Global shared memory files go in:
-// /tmp/.dotnet/shm/global/<fileName>
+// {tmp}/.dotnet/shm/global/<fileName>
// - Session-scoped shared memory files go in:
-// /tmp/.dotnet/shm/session<sessionId>/<fileName>
+// {tmp}/.dotnet/shm/session<sessionId>/<fileName>
// - Lock files associated with global shared memory files go in:
-// /tmp/.dotnet/lockfiles/global/<fileName>
+// {tmp}/.dotnet/lockfiles/global/<fileName>
// - Lock files associated with session-scoped shared memory files go in:
-// /tmp/.dotnet/lockfiles/session<sessionId>/<fileName>
+// {tmp}/.dotnet/lockfiles/session<sessionId>/<fileName>
#define SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT (_MAX_FNAME - 1)
#define SHARED_MEMORY_MAX_NAME_CHAR_COUNT (_countof("Global\\") - 1 + SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT)
-#define SHARED_MEMORY_TEMP_DIRECTORY_PATH "/tmp"
-#define SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_PATH "/tmp/.dotnet"
+#define SHARED_MEMORY_TEMP_DIRECTORY_PATH TEMP_DIRECTORY_PATH
+#define SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet"
-#define SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH "/tmp/.dotnet/shm"
-#define SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH "/tmp/.dotnet/lockfiles"
+#define SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet/shm"
+#define SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet/lockfiles"
static_assert_no_msg(_countof(SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH) >= _countof(SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH));
#define SHARED_MEMORY_GLOBAL_DIRECTORY_NAME "global"
#define SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX "session"
static_assert_no_msg(_countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) >= _countof(SHARED_MEMORY_GLOBAL_DIRECTORY_NAME));
-#define SHARED_MEMORY_UNIQUE_TEMP_NAME_TEMPLATE "/tmp/.coreclr.XXXXXX"
+#define SHARED_MEMORY_UNIQUE_TEMP_NAME_TEMPLATE TEMP_DIRECTORY_PATH ".coreclr.XXXXXX"
#define SHARED_MEMORY_MAX_SESSION_ID_CHAR_COUNT (10)
diff --git a/src/pal/src/include/pal/thread.hpp b/src/pal/src/include/pal/thread.hpp
index e6dacd2136..ddacfb9039 100644
--- a/src/pal/src/include/pal/thread.hpp
+++ b/src/pal/src/include/pal/thread.hpp
@@ -94,11 +94,6 @@ namespace CorUnix
);
PAL_ERROR
- InitializeGlobalThreadData(
- void
- );
-
- PAL_ERROR
CreateThreadData(
CPalThread **ppThread
);
@@ -243,12 +238,6 @@ namespace CorUnix
friend
PAL_ERROR
- InitializeGlobalThreadData(
- void
- );
-
- friend
- PAL_ERROR
CreateThreadData(
CPalThread **ppThread
);
@@ -338,13 +327,6 @@ namespace CorUnix
// Limit address of the stack of this thread
void* m_stackLimit;
- // The default stack size of a newly created thread (currently 256KB)
- // when the dwStackSize paramter of PAL_CreateThread()
- // is zero. This value can be set by setting the
- // environment variable PAL_THREAD_DEFAULT_STACK_SIZE
- // (the value should be in bytes and in hex).
- static DWORD s_dwDefaultThreadStackSize;
-
//
// The thread entry routine (called from InternalCreateThread)
//
diff --git a/src/pal/src/include/pal/threadsusp.hpp b/src/pal/src/include/pal/threadsusp.hpp
index e1e85e265c..dfd65d0f8b 100644
--- a/src/pal/src/include/pal/threadsusp.hpp
+++ b/src/pal/src/include/pal/threadsusp.hpp
@@ -55,6 +55,8 @@ Abstract:
#if HAVE_SYS_SEMAPHORE_H
#include <sys/semaphore.h>
+#elif HAVE_SEMAPHORE_H
+#include <semaphore.h>
#endif // HAVE_SYS_SEMAPHORE_H
#elif HAS_PTHREAD_MUTEXES && HAVE_MACH_EXCEPTIONS
diff --git a/src/pal/src/include/pal/utils.h b/src/pal/src/include/pal/utils.h
index 3ddad4ae2f..f381d957ab 100644
--- a/src/pal/src/include/pal/utils.h
+++ b/src/pal/src/include/pal/utils.h
@@ -20,10 +20,66 @@ Abstract:
#ifndef _PAL_UTILS_H_
#define _PAL_UTILS_H_
+#include <stdint.h>
+
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Alignment helpers (copied for PAL use from stdmacros.h)
+
+inline size_t ALIGN_UP(size_t val, size_t alignment)
+{
+ // alignment must be a power of 2 for this implementation to work (need modulo otherwise)
+ _ASSERTE(0 == (alignment & (alignment - 1)));
+ size_t result = (val + (alignment - 1)) & ~(alignment - 1);
+ _ASSERTE(result >= val); // check for overflow
+ return result;
+}
+
+inline void* ALIGN_UP(void* val, size_t alignment)
+{
+ return (void*)ALIGN_UP((size_t)val, alignment);
+}
+
+inline uint8_t* ALIGN_UP(uint8_t* val, size_t alignment)
+{
+ return (uint8_t*)ALIGN_UP((size_t)val, alignment);
+}
+
+inline size_t ALIGN_DOWN(size_t val, size_t alignment)
+{
+ // alignment must be a power of 2 for this implementation to work (need modulo otherwise)
+ _ASSERTE(0 == (alignment & (alignment - 1)));
+ size_t result = val & ~(alignment - 1);
+ return result;
+}
+
+inline void* ALIGN_DOWN(void* val, size_t alignment)
+{
+ return (void*)ALIGN_DOWN((size_t)val, alignment);
+}
+
+inline uint8_t* ALIGN_DOWN(uint8_t* val, size_t alignment)
+{
+ return (uint8_t*)ALIGN_DOWN((size_t)val, alignment);
+}
+
+inline BOOL IS_ALIGNED(size_t val, size_t alignment)
+{
+ // alignment must be a power of 2 for this implementation to work (need modulo otherwise)
+ _ASSERTE(0 == (alignment & (alignment - 1)));
+ return 0 == (val & (alignment - 1));
+}
+
+inline BOOL IS_ALIGNED(const void* val, size_t alignment)
+{
+ return IS_ALIGNED((size_t)val, alignment);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
#ifdef __cplusplus
extern "C"
{
diff --git a/src/pal/src/include/pal/virtual.h b/src/pal/src/include/pal/virtual.h
index a4e225281e..31d225fc04 100644
--- a/src/pal/src/include/pal/virtual.h
+++ b/src/pal/src/include/pal/virtual.h
@@ -58,12 +58,7 @@ enum VIRTUAL_CONSTANTS
VIRTUAL_EXECUTE,
VIRTUAL_EXECUTE_READ,
- /* Page manipulation constants. */
-#ifdef __sparc__
- VIRTUAL_PAGE_SIZE = 0x2000,
-#else // __sparc__
VIRTUAL_PAGE_SIZE = 0x1000,
-#endif // __sparc__
VIRTUAL_PAGE_MASK = VIRTUAL_PAGE_SIZE - 1,
BOUNDARY_64K = 0xffff
};