Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nspr.h" |
michael@0 | 7 | #include "pprthred.h" |
michael@0 | 8 | #include "plgetopt.h" |
michael@0 | 9 | |
michael@0 | 10 | #include <stdio.h> |
michael@0 | 11 | #include <stdlib.h> |
michael@0 | 12 | #include <string.h> |
michael@0 | 13 | |
michael@0 | 14 | #ifndef XP_BEOS |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | * Test PR_GetThreadAffinityMask |
michael@0 | 18 | * The function is called by each of local, global and global bound threads |
michael@0 | 19 | * The test should be run on both single and multi-cpu systems |
michael@0 | 20 | */ |
michael@0 | 21 | static void PR_CALLBACK thread_start(void *arg) |
michael@0 | 22 | { |
michael@0 | 23 | PRUint32 mask = 0; |
michael@0 | 24 | |
michael@0 | 25 | if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask)) |
michael@0 | 26 | printf("\tthread_start: PR_GetCurrentThreadAffinityMask failed\n"); |
michael@0 | 27 | else |
michael@0 | 28 | printf("\tthread_start: AffinityMask = 0x%x\n",mask); |
michael@0 | 29 | |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | int main(int argc, char **argv) |
michael@0 | 33 | { |
michael@0 | 34 | PRThread *t; |
michael@0 | 35 | |
michael@0 | 36 | printf("main: creating local thread\n"); |
michael@0 | 37 | |
michael@0 | 38 | t = PR_CreateThread(PR_USER_THREAD, |
michael@0 | 39 | thread_start, 0, |
michael@0 | 40 | PR_PRIORITY_NORMAL, |
michael@0 | 41 | PR_LOCAL_THREAD, |
michael@0 | 42 | PR_JOINABLE_THREAD, |
michael@0 | 43 | 0); |
michael@0 | 44 | |
michael@0 | 45 | if (NULL == t) { |
michael@0 | 46 | printf("main: cannot create local thread\n"); |
michael@0 | 47 | exit(1); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | PR_JoinThread(t); |
michael@0 | 51 | |
michael@0 | 52 | printf("main: creating global thread\n"); |
michael@0 | 53 | t = PR_CreateThread(PR_USER_THREAD, |
michael@0 | 54 | thread_start, 0, |
michael@0 | 55 | PR_PRIORITY_NORMAL, |
michael@0 | 56 | PR_GLOBAL_THREAD, |
michael@0 | 57 | PR_JOINABLE_THREAD, |
michael@0 | 58 | 0); |
michael@0 | 59 | |
michael@0 | 60 | if (NULL == t) { |
michael@0 | 61 | printf("main: cannot create global thread\n"); |
michael@0 | 62 | exit(1); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | PR_JoinThread(t); |
michael@0 | 66 | |
michael@0 | 67 | printf("main: creating global bound thread\n"); |
michael@0 | 68 | t = PR_CreateThread(PR_USER_THREAD, |
michael@0 | 69 | thread_start, 0, |
michael@0 | 70 | PR_PRIORITY_NORMAL, |
michael@0 | 71 | PR_GLOBAL_BOUND_THREAD, |
michael@0 | 72 | PR_JOINABLE_THREAD, |
michael@0 | 73 | 0); |
michael@0 | 74 | |
michael@0 | 75 | if (NULL == t) { |
michael@0 | 76 | printf("main: cannot create global bound thread\n"); |
michael@0 | 77 | exit(1); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | PR_JoinThread(t); |
michael@0 | 81 | |
michael@0 | 82 | return 0; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | #else /* !XP_BEOS */ |
michael@0 | 86 | |
michael@0 | 87 | int main() |
michael@0 | 88 | { |
michael@0 | 89 | printf( "This test is not supported on the BeOS\n" ); |
michael@0 | 90 | return 0; |
michael@0 | 91 | } |
michael@0 | 92 | #endif /* !XP_BEOS */ |