Merge 7a5b758 for LLVM update to 349610
Change-Id: I1ba0bbe7b606a2539855c4eb67804d1001bd8b0b
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..9591f08
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,5 @@
+# Default maintainers and code reviewers:
[email protected]
[email protected]
[email protected]
[email protected]
diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt
index f9e63f4..ff922c8 100644
--- a/runtime/src/CMakeLists.txt
+++ b/runtime/src/CMakeLists.txt
@@ -50,6 +50,9 @@
if(${LIBOMP_USE_HWLOC})
include_directories(${LIBOMP_HWLOC_INSTALL_DIR}/include)
endif()
+if(ANDROID)
+ include_directories(${LIBOMP_SRC_DIR}/android)
+endif()
# Getting correct source files to build library
set(LIBOMP_CFILES)
@@ -95,6 +98,9 @@
libomp_append(LIBOMP_CXXFILES kmp_gsupport.cpp)
libomp_append(LIBOMP_ASMFILES z_Linux_asm.S) # Unix assembly file
endif()
+ if(ANDROID)
+ libomp_append(LIBOMP_CXXFILES android/nltypes_stubs.cpp)
+ endif()
libomp_append(LIBOMP_CFILES thirdparty/ittnotify/ittnotify_static.c LIBOMP_USE_ITT_NOTIFY)
libomp_append(LIBOMP_CXXFILES kmp_debugger.cpp LIBOMP_USE_DEBUGGER)
libomp_append(LIBOMP_CXXFILES kmp_stats.cpp LIBOMP_STATS)
diff --git a/runtime/src/android/nl_types.h b/runtime/src/android/nl_types.h
new file mode 100644
index 0000000..4f596c2
--- /dev/null
+++ b/runtime/src/android/nl_types.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef ANDROID_NLTYPES_H
+#define ANDROID_NLTYPES_H
+
+#include_next <nl_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+nl_catd catopen(const char*, int);
+char* catgets(nl_catd, int, int, const char*);
+int catclose(nl_catd);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* ANDROID_NLTYPES_H */
+
diff --git a/runtime/src/android/nltypes_stubs.cpp b/runtime/src/android/nltypes_stubs.cpp
new file mode 100644
index 0000000..e93729c
--- /dev/null
+++ b/runtime/src/android/nltypes_stubs.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <nl_types.h>
+
+#include <errno.h>
+
+__attribute__((weak,visibility("hidden")))
+nl_catd catopen(const char*, int) {
+ return reinterpret_cast<nl_catd>(-1);
+}
+
+__attribute__((weak,visibility("hidden")))
+char* catgets(nl_catd, int, int, const char* message) {
+ return const_cast<char*>(message);
+}
+
+__attribute__((weak,visibility("hidden")))
+int catclose(nl_catd) {
+ // Since we didn't hand out a valid nl_catd, you can't be returning one to us.
+ errno = EBADF;
+ return -1;
+}
diff --git a/runtime/src/kmp_affinity.h b/runtime/src/kmp_affinity.h
index 34147fd..e62508a 100644
--- a/runtime/src/kmp_affinity.h
+++ b/runtime/src/kmp_affinity.h
@@ -233,6 +233,7 @@
#elif __NR_sched_getaffinity != 5196
#error Wrong code for getaffinity system call.
#endif /* __NR_sched_getaffinity */
+#else
#error Unknown or unsupported architecture
#endif /* KMP_ARCH_* */
class KMPNativeAffinity : public KMPAffinity {
diff --git a/runtime/src/z_Linux_util.cpp b/runtime/src/z_Linux_util.cpp
index aa0302c..ab9c353 100644
--- a/runtime/src/z_Linux_util.cpp
+++ b/runtime/src/z_Linux_util.cpp
@@ -828,6 +828,13 @@
and also gives the user the stack space they requested for all threads */
stack_size += gtid * __kmp_stkoffset * 2;
+#if defined(__ANDROID__) && __ANDROID_API__ < 19
+ // Round the stack size to a multiple of the page size. Older versions of
+ // Android (until KitKat) would fail pthread_attr_setstacksize with EINVAL
+ // if the stack size was not a multiple of the page size.
+ stack_size = (stack_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+#endif
+
KA_TRACE(10, ("__kmp_create_worker: T#%d, default stacksize = %lu bytes, "
"__kmp_stksize = %lu bytes, final stacksize = %lu bytes\n",
gtid, KMP_DEFAULT_STKSIZE, __kmp_stksize, stack_size));