]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/commitdiff
Merge "Move some pthread functions to signal.h."
authorDan Albert <danalbert@google.com>
Sat, 22 Nov 2014 22:38:50 +0000 (22:38 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Sat, 22 Nov 2014 22:38:51 +0000 (22:38 +0000)
13 files changed:
libc/arch-arm/include/machine/endian.h
libc/arch-arm64/include/machine/endian.h
libc/arch-mips/bionic/atexit.h [deleted file]
libc/arch-mips/bionic/crtbegin.c
libc/arch-mips/bionic/crtbegin_so.c [deleted file]
libc/arch-mips/include/machine/endian.h
libc/arch-mips64/bionic/atexit.h [deleted file]
libc/arch-mips64/bionic/crtbegin.c
libc/arch-mips64/bionic/crtbegin_so.c [deleted file]
libc/arch-mips64/include/machine/endian.h
libc/arch-x86_64/include/machine/endian.h
tests/gtest_ex.h [new file with mode: 0644]
tests/pthread_test.cpp

index 8d9723d7a85c0aa075c5501078b2ce3051c91d72..04bba20dc8c1be59a86d40b4a48acc9fe083a309 100644 (file)
 
 #endif  /* __GNUC__ */
 
-#if defined(__ARMEB__)
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
 #define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
 #define __STRICT_ALIGNMENT
 #include <sys/types.h>
 #include <sys/endian.h>
index 87a038d0e4eba7e66512a8f40b3142fe33ff2c77..4743733633b4eb4aa362feca995da83d14e95b7f 100644 (file)
@@ -29,9 +29,6 @@
 #ifndef _AARCH64_ENDIAN_H_
 #define _AARCH64_ENDIAN_H_
 
-#include <sys/types.h>
-#include <sys/endian.h>
-
 #ifdef __GNUC__
 
 #define __swap16md(x) ({                                        \
 
 #endif  /* __GNUC__ */
 
-#if defined(__AARCH64EB__)
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
 #define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
+#include <sys/types.h>
+#include <sys/endian.h>
 
 #endif /* _AARCH64_ENDIAN_H_ */
diff --git a/libc/arch-mips/bionic/atexit.h b/libc/arch-mips/bionic/atexit.h
deleted file mode 100644 (file)
index 759008c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-extern void *__dso_handle;
-extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void))
-{
-  return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
-}
index 28e8817f9785ca0b0f454f007f5646ec14be9263..50e9eeb0272cad93d72ac2cfed901e4d732cd5cf 100644 (file)
@@ -91,4 +91,4 @@ __asm__ (
 );
 
 #include "../../arch-common/bionic/__dso_handle.h"
-#include "atexit.h"
+#include "../../arch-common/bionic/atexit.h"
diff --git a/libc/arch-mips/bionic/crtbegin_so.c b/libc/arch-mips/bionic/crtbegin_so.c
deleted file mode 100644 (file)
index d664ce6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-#include "../../arch-common/bionic/__dso_handle_so.h"
-#include "atexit.h"
index 41a9004f40a33d8f45e2620c659365e72b7e112f..9270e9d9fc616f7901ef3b54b0f9a03a219674fb 100644 (file)
 #endif  /* __mips32r2__ */
 #endif  /* __GNUC__ */
 
-#if defined(__MIPSEB__)
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
 #define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
 #define __STRICT_ALIGNMENT
 #include <sys/types.h>
 #include <sys/endian.h>
diff --git a/libc/arch-mips64/bionic/atexit.h b/libc/arch-mips64/bionic/atexit.h
deleted file mode 100644 (file)
index 759008c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-extern void *__dso_handle;
-extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void))
-{
-  return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
-}
index 2ea31ad6423a38e20935da2349ce7bbf5032fe7f..1374fea35528919d9c9c32c0b70023ea11581a2c 100644 (file)
@@ -91,4 +91,4 @@ __asm__ (
 );
 
 #include "../../arch-common/bionic/__dso_handle.h"
-#include "atexit.h"
+#include "../../arch-common/bionic/atexit.h"
diff --git a/libc/arch-mips64/bionic/crtbegin_so.c b/libc/arch-mips64/bionic/crtbegin_so.c
deleted file mode 100644 (file)
index d664ce6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-#include "../../arch-common/bionic/__dso_handle_so.h"
-#include "atexit.h"
index 41a9004f40a33d8f45e2620c659365e72b7e112f..9270e9d9fc616f7901ef3b54b0f9a03a219674fb 100644 (file)
 #endif  /* __mips32r2__ */
 #endif  /* __GNUC__ */
 
-#if defined(__MIPSEB__)
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
 #define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
 #define __STRICT_ALIGNMENT
 #include <sys/types.h>
 #include <sys/endian.h>
index 7889a374f4708d532fe9c9f605f84ad848474679..8a3b0c583fa18e8f22a21c0dcb24e1b92e36ce8e 100644 (file)
@@ -56,6 +56,7 @@
 #endif /* __GNUC__ */
 
 #define _BYTE_ORDER _LITTLE_ENDIAN
+#include <sys/types.h>
 #include <sys/endian.h>
 
 #endif /* _MACHINE_ENDIAN_H_ */
diff --git a/tests/gtest_ex.h b/tests/gtest_ex.h
new file mode 100644 (file)
index 0000000..fe1d894
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+template<typename F>
+void test_isolated(F test) {
+  int pid = fork();
+  ASSERT_NE(-1, pid) << strerror(errno);
+
+  if (pid == 0) {
+    test();
+    _exit(testing::Test::HasFailure() ? 1 : 0);
+  }
+
+  int status;
+  ASSERT_EQ(pid, waitpid(pid, &status, 0));
+  ASSERT_TRUE(WIFEXITED(status));
+  ASSERT_EQ(0, WEXITSTATUS(status)) << "Forked test has failed, see above..";
+}
index b5e12a5489e6c9c30f985603bf1befd4097bf6c6..797468efe430b050c6083b03e8366f3572714bda 100644 (file)
@@ -19,6 +19,7 @@
 #include "private/ScopeGuard.h"
 #include "BionicDeathTest.h"
 #include "ScopedSignalHandler.h"
+#include "gtest_ex.h"
 
 #include <errno.h>
 #include <inttypes.h>
@@ -721,22 +722,24 @@ static int g_atfork_child_calls = 0;
 static void AtForkChild1() { g_atfork_child_calls = (g_atfork_child_calls << 4) | 1; }
 static void AtForkChild2() { g_atfork_child_calls = (g_atfork_child_calls << 4) | 2; }
 
-TEST(pthread, pthread_atfork) {
-  ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
-  ASSERT_EQ(0, pthread_atfork(AtForkPrepare2, AtForkParent2, AtForkChild2));
+TEST(pthread, pthread_atfork_smoke) {
+  test_isolated([] {
+    ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
+    ASSERT_EQ(0, pthread_atfork(AtForkPrepare2, AtForkParent2, AtForkChild2));
 
-  int pid = fork();
-  ASSERT_NE(-1, pid) << strerror(errno);
+    int pid = fork();
+    ASSERT_NE(-1, pid) << strerror(errno);
 
-  // Child and parent calls are made in the order they were registered.
-  if (pid == 0) {
-    ASSERT_EQ(0x12, g_atfork_child_calls);
-    _exit(0);
-  }
-  ASSERT_EQ(0x12, g_atfork_parent_calls);
+    // Child and parent calls are made in the order they were registered.
+    if (pid == 0) {
+      ASSERT_EQ(0x12, g_atfork_child_calls);
+      _exit(0);
+    }
+    ASSERT_EQ(0x12, g_atfork_parent_calls);
 
-  // Prepare calls are made in the reverse order.
-  ASSERT_EQ(0x21, g_atfork_prepare_calls);
+    // Prepare calls are made in the reverse order.
+    ASSERT_EQ(0x21, g_atfork_prepare_calls);
+  });
 }
 
 TEST(pthread, pthread_attr_getscope) {