michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nspr.h" michael@0: #include "pprthred.h" michael@0: #include "plgetopt.h" michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #ifndef XP_BEOS michael@0: michael@0: /* michael@0: * Test PR_GetThreadAffinityMask michael@0: * The function is called by each of local, global and global bound threads michael@0: * The test should be run on both single and multi-cpu systems michael@0: */ michael@0: static void PR_CALLBACK thread_start(void *arg) michael@0: { michael@0: PRUint32 mask = 0; michael@0: michael@0: if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask)) michael@0: printf("\tthread_start: PR_GetCurrentThreadAffinityMask failed\n"); michael@0: else michael@0: printf("\tthread_start: AffinityMask = 0x%x\n",mask); michael@0: michael@0: } michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: PRThread *t; michael@0: michael@0: printf("main: creating local thread\n"); michael@0: michael@0: t = PR_CreateThread(PR_USER_THREAD, michael@0: thread_start, 0, michael@0: PR_PRIORITY_NORMAL, michael@0: PR_LOCAL_THREAD, michael@0: PR_JOINABLE_THREAD, michael@0: 0); michael@0: michael@0: if (NULL == t) { michael@0: printf("main: cannot create local thread\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: PR_JoinThread(t); michael@0: michael@0: printf("main: creating global thread\n"); michael@0: t = PR_CreateThread(PR_USER_THREAD, michael@0: thread_start, 0, michael@0: PR_PRIORITY_NORMAL, michael@0: PR_GLOBAL_THREAD, michael@0: PR_JOINABLE_THREAD, michael@0: 0); michael@0: michael@0: if (NULL == t) { michael@0: printf("main: cannot create global thread\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: PR_JoinThread(t); michael@0: michael@0: printf("main: creating global bound thread\n"); michael@0: t = PR_CreateThread(PR_USER_THREAD, michael@0: thread_start, 0, michael@0: PR_PRIORITY_NORMAL, michael@0: PR_GLOBAL_BOUND_THREAD, michael@0: PR_JOINABLE_THREAD, michael@0: 0); michael@0: michael@0: if (NULL == t) { michael@0: printf("main: cannot create global bound thread\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: PR_JoinThread(t); michael@0: michael@0: return 0; michael@0: } michael@0: michael@0: #else /* !XP_BEOS */ michael@0: michael@0: int main() michael@0: { michael@0: printf( "This test is not supported on the BeOS\n" ); michael@0: return 0; michael@0: } michael@0: #endif /* !XP_BEOS */