OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * be found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Testing suite for NativeClient threads | 8 * Testing suite for NativeClient threads |
9 */ | 9 */ |
10 | 10 |
11 #include <errno.h> | 11 #include <errno.h> |
12 #include <limits.h> | 12 #include <limits.h> |
13 #include <pthread.h> | 13 #include <pthread.h> |
14 #include <semaphore.h> | 14 #include <semaphore.h> |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 could fix this, but this happens with Linux glibc too. */ | 335 could fix this, but this happens with Linux glibc too. */ |
336 #ifndef __GLIBC__ | 336 #ifndef __GLIBC__ |
337 EXPECT_EQ(EPERM, rv); | 337 EXPECT_EQ(EPERM, rv); |
338 #endif | 338 #endif |
339 | 339 |
340 TEST_FUNCTION_END; | 340 TEST_FUNCTION_END; |
341 } | 341 } |
342 | 342 |
343 pthread_once_t once_control = PTHREAD_ONCE_INIT; | 343 pthread_once_t once_control = PTHREAD_ONCE_INIT; |
344 | 344 |
345 typedef int AtomicInt32; /* Why is this needed? We included pthread already. */ | 345 /* |
| 346 * The nacl-newlib pthread.h declares this type, but glibc's pthread.h does not. |
| 347 */ |
| 348 #ifdef __GLIBC__ |
| 349 typedef int AtomicInt32; |
| 350 #endif |
346 | 351 |
347 void pthread_once_routine() { | 352 void pthread_once_routine() { |
348 static AtomicInt32 count = 0; | 353 static AtomicInt32 count = 0; |
349 AtomicInt32 res = __sync_fetch_and_add(&count, 1); | 354 AtomicInt32 res = __sync_fetch_and_add(&count, 1); |
350 EXPECT_LE(res, 1); | 355 EXPECT_LE(res, 1); |
351 } | 356 } |
352 | 357 |
353 void* OnceThread(void *userdata) { | 358 void* OnceThread(void *userdata) { |
354 CHECK_OK(pthread_once(&once_control, pthread_once_routine)); | 359 CHECK_OK(pthread_once(&once_control, pthread_once_routine)); |
355 return 0; | 360 return 0; |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 TestRealloc(); | 828 TestRealloc(); |
824 TestStackSize(); | 829 TestStackSize(); |
825 | 830 |
826 /* We have disabled this test by default since it is flaky under VMWARE. */ | 831 /* We have disabled this test by default since it is flaky under VMWARE. */ |
827 if (g_run_intrinsic) TestIntrinsics(); | 832 if (g_run_intrinsic) TestIntrinsics(); |
828 | 833 |
829 TestCondvar(); | 834 TestCondvar(); |
830 | 835 |
831 return g_errors; | 836 return g_errors; |
832 } | 837 } |
OLD | NEW |