]>
git.saurik.com Git - apple/libdispatch.git/blob - src/shims.h
2 * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
27 #ifndef __DISPATCH_OS_SHIMS__
28 #define __DISPATCH_OS_SHIMS__
31 #if HAVE_PTHREAD_WORKQUEUES
32 #include <pthread_workqueue.h>
35 #include <pthread_np.h>
38 #if !HAVE_DECL_FD_COPY
39 #define FD_COPY(f, t) (void)(*(t) = *(f))
42 #if !HAVE_NORETURN_BUILTIN_TRAP
44 * XXXRW: Work-around for possible clang bug in which __builtin_trap() is not
45 * marked noreturn, leading to a build error as dispatch_main() *is* marked
46 * noreturn. Mask by marking __builtin_trap() as noreturn locally.
49 void __builtin_trap(void);
52 #include "shims/atomic.h"
53 #include "shims/tsd.h"
54 #include "shims/hw_config.h"
55 #include "shims/perfmon.h"
57 #include "shims/getprogname.h"
58 #include "shims/malloc_zone.h"
59 #include "shims/time.h"
62 // Clear the stack before calling long-running thread-handler functions that
63 // never return (and don't take arguments), to facilitate leak detection and
64 // provide cleaner backtraces. <rdar://problem/9050566>
65 #define _dispatch_clear_stack(s) do { \
66 void *a[(s)/sizeof(void*) ? (s)/sizeof(void*) : 1]; \
67 a[0] = pthread_get_stackaddr_np(pthread_self()); \
68 bzero((void*)&a[1], a[0] - (void*)&a[1]); \
71 #define _dispatch_clear_stack(s)