Revert "Make sem_wait able to return errno EINTR for sdk > 23."

Broke the build. There's no such file as bionic_sdk_version.h anywhere in the tree.

This reverts commit 892b61d340.

Change-Id: Iec3f4588edfb1d1524bb5f16451fd05dc6ebe44a
This commit is contained in:
Dan Albert 2016-01-26 00:20:06 +00:00
parent 892b61d340
commit 6d51085202
4 changed files with 1 additions and 88 deletions

View file

@ -114,9 +114,3 @@ __noreturn void __libc_init(void* raw_args,
exit(slingshot(args.argc, args.argv, args.envp));
}
extern "C" uint32_t android_get_application_target_sdk_version();
uint32_t bionic_get_application_target_sdk_version() {
return android_get_application_target_sdk_version();
}

View file

@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
#include <android/api-level.h>
#include <elf.h>
#include <errno.h>
#include <stddef.h>
@ -107,7 +106,3 @@ __noreturn void __libc_init(void* raw_args,
exit(slingshot(args.argc, args.argv, args.envp));
}
uint32_t bionic_get_application_target_sdk_version() {
return __ANDROID_API__;
}

View file

@ -41,7 +41,6 @@
#include "private/bionic_constants.h"
#include "private/bionic_futex.h"
#include "private/bionic_sdk_version.h"
#include "private/bionic_time_conversions.h"
// In this implementation, a semaphore contains a
@ -221,13 +220,7 @@ int sem_wait(sem_t* sem) {
return 0;
}
int result = __futex_wait_ex(sem_count_ptr, shared, shared | SEMCOUNT_MINUS_ONE, false, nullptr);
if (bionic_get_application_target_sdk_version() > 23) {
if (result ==-EINTR) {
errno = EINTR;
return -1;
}
}
__futex_wait_ex(sem_count_ptr, shared, shared | SEMCOUNT_MINUS_ONE, false, nullptr);
}
}

View file

@ -24,7 +24,6 @@
#include <unistd.h>
#include "private/bionic_constants.h"
#include "ScopedSignalHandler.h"
TEST(semaphore, sem_init) {
sem_t s;
@ -159,71 +158,3 @@ TEST(semaphore, sem_getvalue) {
ASSERT_EQ(0, sem_getvalue(&s, &i));
ASSERT_EQ(1, i);
}
extern "C" void android_set_application_target_sdk_version(uint32_t target);
static void sem_wait_test_signal_handler(int) {
}
static void* SemWaitEINTRThreadFn(void* arg) {
sem_t* sem = reinterpret_cast<sem_t*>(arg);
uintptr_t have_eintr = 0;
uintptr_t have_error = 0;
while (true) {
int result = sem_wait(sem);
if (result == 0) {
break;
}
if (result == -1) {
if (errno == EINTR) {
have_eintr = 1;
} else {
have_error = 1;
break;
}
}
}
return reinterpret_cast<void*>((have_eintr << 1) | have_error);
}
TEST(semaphore, sem_wait_no_EINTR_in_sdk_less_equal_than_23) {
#if defined(__BIONIC__)
android_set_application_target_sdk_version(23U);
sem_t s;
ASSERT_EQ(0, sem_init(&s, 0, 0));
ScopedSignalHandler handler(SIGUSR1, sem_wait_test_signal_handler);
pthread_t thread;
ASSERT_EQ(0, pthread_create(&thread, nullptr, SemWaitEINTRThreadFn, &s));
// Give some time for the thread to run sem_wait.
usleep(500000);
ASSERT_EQ(0, pthread_kill(thread, SIGUSR1));
// Give some time for the thread to handle signal.
usleep(500000);
ASSERT_EQ(0, sem_post(&s));
void* result;
ASSERT_EQ(0, pthread_join(thread, &result));
ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(result));
#else
GTEST_LOG_(INFO) << "This test tests sem_wait's compatibility for old sdk versions";
#endif
}
TEST(semaphore, sem_wait_EINTR_in_sdk_greater_than_23) {
#if defined(__BIONIC__)
android_set_application_target_sdk_version(24U);
#endif
sem_t s;
ASSERT_EQ(0, sem_init(&s, 0, 0));
ScopedSignalHandler handler(SIGUSR1, sem_wait_test_signal_handler);
pthread_t thread;
ASSERT_EQ(0, pthread_create(&thread, nullptr, SemWaitEINTRThreadFn, &s));
// Give some time for the thread to run sem_wait.
usleep(500000);
ASSERT_EQ(0, pthread_kill(thread, SIGUSR1));
// Give some time for the thread to handle signal.
usleep(500000);
ASSERT_EQ(0, sem_post(&s));
void* result;
ASSERT_EQ(0, pthread_join(thread, &result));
ASSERT_EQ(2U, reinterpret_cast<uintptr_t>(result));
}