]>
git.saurik.com Git - apple/dyld.git/blob - unit-tests/test-cases/tlv-basic/main.c
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <stdio.h> // fprintf(), NULL
24 #include <stdlib.h> // exit(), EXIT_SUCCESS
27 #include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
35 __thread
static int c
;
36 __thread
static int d
= 5;
39 static void* work(void* arg
)
41 uintptr_t offset
= (uintptr_t)arg
;
42 //fprintf(stderr, "self=%p, &a=%p\n", pthread_self(), get_a());
43 void* result
= malloc(10);
45 FAIL("tlv-basic: a non-zero on slow-path");
49 FAIL("tlv-basic: b not five");
54 FAIL("tlv-basic: c non-zero");
59 FAIL("tlv-basic: gd not five");
63 for(int i
=0; i
< 10000; ++i
) {
69 if ( a
!= 3 + offset
+ i
) {
70 FAIL("tlv-basic: a not three");
73 if ( b
!= 7 + offset
+ i
) {
74 FAIL("tlv-basic: b not seven");
77 if ( c
!= 11 + offset
+ i
) {
78 FAIL("tlv-basic: c not eleven");
81 if ( d
!= 13 + offset
+ i
) {
82 FAIL("tlv-basic: d not thirteen");
93 if ( pthread_create(&worker1
, NULL
, work
, (void*)1) != 0 ) {
94 FAIL("pthread_create failed");
99 if ( pthread_create(&worker2
, NULL
, work
, (void*)10) != 0 ) {
100 FAIL("pthread_create failed");
105 if ( pthread_create(&worker3
, NULL
, work
, (void*)100) != 0 ) {
106 FAIL("pthread_create failed");
111 //fprintf(stderr, "waiting for worker 1\n");
112 pthread_join(worker1
, &result
);
113 //fprintf(stderr, "waiting for worker 2\n");
114 pthread_join(worker2
, &result
);
115 //fprintf(stderr, "waiting for worker 3\n");
116 pthread_join(worker3
, &result
);