1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 /* For targets which don't have the required sync support. Really
12 these should be provided by gcc itself. FIXME. */
14 #if !defined (HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4) || !defined (HAVE_SYNC_FETCH_AND_ADD_4)
16 static pthread_mutex_t sync_lock
= PTHREAD_MUTEX_INITIALIZER
;
20 #ifndef HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4
23 __sync_bool_compare_and_swap_4 (uint32
*, uint32
, uint32
)
24 __attribute__ ((visibility ("hidden")));
27 __sync_bool_compare_and_swap_4 (uint32
* ptr
, uint32 old
, uint32
new)
32 i
= pthread_mutex_lock (&sync_lock
);
43 i
= pthread_mutex_unlock (&sync_lock
);
51 #ifndef HAVE_SYNC_FETCH_AND_ADD_4
54 __sync_fetch_and_add_4 (uint32
*, uint32
)
55 __attribute__ ((visibility ("hidden")));
58 __sync_fetch_and_add_4 (uint32
* ptr
, uint32 add
)
63 i
= pthread_mutex_lock (&sync_lock
);
69 i
= pthread_mutex_unlock (&sync_lock
);
77 // Called to initialize a new m (including the bootstrap m).
85 // Initialize signal handling.
86 runtime_m()->gsignal
= runtime_malg(32*1024, &stack
, &stacksize
); // OS X wants >=8K, Linux >=2K
89 ss
.ss_size
= stacksize
;
90 if(sigaltstack(&ss
, nil
) < 0)