X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d9a64523371fa019c4575bb400cbbc3a50ac9903..HEAD:/tests/workq_sigprof.c diff --git a/tests/workq_sigprof.c b/tests/workq_sigprof.c index 6ea38a8c9..f6cdf3444 100644 --- a/tests/workq_sigprof.c +++ b/tests/workq_sigprof.c @@ -10,61 +10,68 @@ #include -#if !TARGET_OS_IPHONE +#if !defined(__arm__) + +T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); static pthread_t workq_thread; static bool signal_received; -static void signal_handler(int sig __unused, siginfo_t *b __unused, void* unused __unused) { - if (pthread_self() == workq_thread) { - signal_received = true; - } +static void +signal_handler(int sig __unused, siginfo_t *b __unused, void* unused __unused) +{ + if (pthread_self() == workq_thread) { + signal_received = true; + } } -static void workq_block(void *unused __unused) { - workq_thread = pthread_self(); +static void +workq_block(void *unused __unused) +{ + workq_thread = pthread_self(); - /* - sigset_t set; - sigemptyset(&set); - sigaddset(&set, SIGPROF); - pthread_sigmask(SIG_UNBLOCK, &set, NULL); - */ + /* + * sigset_t set; + * sigemptyset(&set); + * sigaddset(&set, SIGPROF); + * pthread_sigmask(SIG_UNBLOCK, &set, NULL); + */ - uint64_t spin_start = mach_absolute_time(); - while (mach_absolute_time() - spin_start < 30 * NSEC_PER_SEC) - if (signal_received) { - T_PASS("Got SIGPROF!"); - T_END; - } - } + uint64_t spin_start = mach_absolute_time(); + while (mach_absolute_time() - spin_start < 30 * NSEC_PER_SEC) { + if (signal_received) { + T_PASS("Got SIGPROF!"); + T_END; + } + } +} T_DECL(workq_sigprof, "test that workqueue threads can receive sigprof") { - struct sigaction sa = { - .sa_sigaction = signal_handler - }; - sigfillset(&sa.sa_mask); - T_ASSERT_POSIX_ZERO(sigaction(SIGPROF, &sa, NULL), NULL); + struct sigaction sa = { + .sa_sigaction = signal_handler + }; + sigfillset(&sa.sa_mask); + T_ASSERT_POSIX_ZERO(sigaction(SIGPROF, &sa, NULL), NULL); - dispatch_queue_t q = dispatch_get_global_queue(0, 0); - dispatch_async_f(q, NULL, workq_block); + dispatch_queue_t q = dispatch_get_global_queue(0, 0); + dispatch_async_f(q, NULL, workq_block); - struct itimerval timerval = { - .it_interval = {.tv_usec = 10000}, - .it_value = {.tv_usec = 10000} - }; - T_ASSERT_POSIX_ZERO(setitimer(ITIMER_PROF, &timerval, NULL), NULL); + struct itimerval timerval = { + .it_interval = {.tv_usec = 10000}, + .it_value = {.tv_usec = 10000} + }; + T_ASSERT_POSIX_ZERO(setitimer(ITIMER_PROF, &timerval, NULL), NULL); - dispatch_main(); + dispatch_main(); } -#else //!TARGET_OS_IPHONE +#else //!defined(__arm__) T_DECL(workq_sigprof, "test that workqueue threads can receive sigprof") { - T_EXPECTFAIL; - T_FAIL(" setitimer/sigprof doesn't seem to be delivered on embeded platforms"); + T_EXPECTFAIL; + T_FAIL(" setitimer/sigprof not supported on 32bit arm platforms"); } -#endif //!TARGET_OS_IPHONE +#endif //!defined(__arm__)