Add `sigset64_t` and accompanying functions.
This doesn't address `struct sigaction` and `sigaction`. That will
come later.
Bug: http://b/72493232
Test: ran tests
Change-Id: I4134346757ce3a4dac6feae413361cec16223386
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 9ecb10c..f812df5 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -356,9 +356,9 @@
}
static void* SignalHandlerFn(void* arg) {
- sigset_t wait_set;
- sigfillset(&wait_set);
- return reinterpret_cast<void*>(sigwait(&wait_set, reinterpret_cast<int*>(arg)));
+ sigset64_t wait_set;
+ sigfillset64(&wait_set);
+ return reinterpret_cast<void*>(sigwait64(&wait_set, reinterpret_cast<int*>(arg)));
}
TEST(pthread, pthread_sigmask) {
@@ -402,6 +402,47 @@
ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
}
+TEST(pthread, pthread_sigmask64_SIGTRMIN) {
+ // Check that SIGRTMIN isn't blocked.
+ sigset64_t original_set;
+ sigemptyset64(&original_set);
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, NULL, &original_set));
+ ASSERT_FALSE(sigismember64(&original_set, SIGRTMIN));
+
+ // Block SIGRTMIN.
+ sigset64_t set;
+ sigemptyset64(&set);
+ sigaddset64(&set, SIGRTMIN);
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, &set, NULL));
+
+ // Check that SIGRTMIN is blocked.
+ sigset64_t final_set;
+ sigemptyset64(&final_set);
+ ASSERT_EQ(0, pthread_sigmask64(SIG_BLOCK, NULL, &final_set));
+ ASSERT_TRUE(sigismember64(&final_set, SIGRTMIN));
+ // ...and that sigprocmask64 agrees with pthread_sigmask64.
+ sigemptyset64(&final_set);
+ ASSERT_EQ(0, sigprocmask64(SIG_BLOCK, NULL, &final_set));
+ ASSERT_TRUE(sigismember64(&final_set, SIGRTMIN));
+
+ // Spawn a thread that calls sigwait64 and tells us what it received.
+ pthread_t signal_thread;
+ int received_signal = -1;
+ ASSERT_EQ(0, pthread_create(&signal_thread, NULL, SignalHandlerFn, &received_signal));
+
+ // Send that thread SIGRTMIN.
+ pthread_kill(signal_thread, SIGRTMIN);
+
+ // See what it got.
+ void* join_result;
+ ASSERT_EQ(0, pthread_join(signal_thread, &join_result));
+ ASSERT_EQ(SIGRTMIN, received_signal);
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(join_result));
+
+ // Restore the original signal mask.
+ ASSERT_EQ(0, pthread_sigmask64(SIG_SETMASK, &original_set, NULL));
+}
+
static void test_pthread_setname_np__pthread_getname_np(pthread_t t) {
ASSERT_EQ(0, pthread_setname_np(t, "short"));
char name[32];