1/*
2 * Copyright (c) 2006 - 2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/***********************************************************************
25 * Not to be installed in /usr/include
26 ***********************************************************************/
27
28#ifndef _LIBC_SYS_CDEFS_H_
29#define _LIBC_SYS_CDEFS_H_
30
31/*
32 * Now include the real sys/cdefs.h.  The checks in libc-features.h will assure
33 * that those macros are consistent with the current build environment.
34 */
35#include_next <sys/cdefs.h>
36#ifndef _LIBC_NO_FEATURE_VERIFICATION
37#if defined(__arm__) || defined(__i386__) || defined(__x86_64__)
38#  include "libc-features.h"
39#else
40#  error "Unknown architecture."
41#endif
42#endif /* _LIBC_NO_FEATURE_VERIFICATION */
43
44/*
45 * symbol suffixes used for symbol versioning
46 */
47#if defined(VARIANT_LEGACY)
48#  define LIBC_SUF_UNIX03		/* nothing */
49#  define LIBC_SUF_64_BIT_INO_T		/* nothing */
50#  define LIBC_SUF_NON_CANCELABLE	/* nothing */
51#  define LIBC_SUF_1050			/* nothing */
52#else /* !VARIANT_LEGACY */
53#  if __DARWIN_ONLY_UNIX_CONFORMANCE
54#    define LIBC_SUF_UNIX03		/* nothing */
55#  else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */
56#    define LIBC_SUF_UNIX03		"$UNIX2003"
57#  endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */
58
59#  if defined(VARIANT_INODE32)
60#    define LIBC_SUF_64_BIT_INO_T	/* nothing */
61#  else /* !VARIANT_INODE32 */
62#    if __DARWIN_ONLY_64_BIT_INO_T
63#      define LIBC_SUF_64_BIT_INO_T	/* nothing */
64#    else /* !__DARWIN_ONLY_64_BIT_INO_T */
65#      define LIBC_SUF_64_BIT_INO_T	"$INODE64"
66#    endif /* __DARWIN_ONLY_64_BIT_INO_T */
67#  endif /* VARIANT_INODE32 */
68
69#  if defined(VARIANT_CANCELABLE)
70#    define LIBC_SUF_NON_CANCELABLE	/* nothing */
71#  else /* !LIBC_NON_CANCELABLE */
72#    define LIBC_SUF_NON_CANCELABLE	"$NOCANCEL"
73#  endif /* LIBC_NON_CANCELABLE */
74
75#  if defined(VARIANT_PRE1050)
76#    define LIBC_SUF_1050		/* nothing */
77#  else /* !VARIANT_PRE1050 */
78#    if __DARWIN_ONLY_VERS_1050
79#      define LIBC_SUF_1050		/* nothing */
80#    else /* !__DARWIN_ONLY_VERS_1050 */
81#      define LIBC_SUF_1050		"$1050"
82#    endif /* __DARWIN_ONLY_VERS_1050 */
83#  endif /* VARIANT_PRE1050 */
84
85#endif /* LIBC_UNIX03 */
86
87#define LIBC_SUF_EXTSN			"$DARWIN_EXTSN"
88
89/*
90 * symbol versioning macros
91 */
92#define LIBC_ALIAS(sym)		__asm("_" __STRING(sym) LIBC_SUF_UNIX03)
93#define LIBC_ALIAS_C(sym)	__asm("_" __STRING(sym) LIBC_SUF_NON_CANCELABLE LIBC_SUF_UNIX03)
94#define LIBC_ALIAS_I(sym)	__asm("_" __STRING(sym) LIBC_SUF_64_BIT_INO_T LIBC_SUF_UNIX03)
95#define LIBC_INODE64(sym)	__asm("_" __STRING(sym) LIBC_SUF_64_BIT_INO_T)
96
97#define LIBC_1050(sym)		__asm("_" __STRING(sym) LIBC_SUF_1050)
98#define LIBC_1050ALIAS(sym)	__asm("_" __STRING(sym) LIBC_SUF_1050 LIBC_SUF_UNIX03)
99#define LIBC_1050ALIAS_C(sym)	__asm("_" __STRING(sym) LIBC_SUF_1050 LIBC_SUF_NON_CANCELABLE LIBC_SUF_UNIX03)
100#define LIBC_1050ALIAS_I(sym)	__asm("_" __STRING(sym) LIBC_SUF_1050 LIBC_SUF_64_BIT_INO_T LIBC_SUF_UNIX03)
101#define LIBC_1050INODE64(sym)	__asm("_" __STRING(sym) LIBC_SUF_1050 LIBC_SUF_64_BIT_INO_T)
102
103#define LIBC_EXTSN(sym)		__asm("_" __STRING(sym) LIBC_SUF_EXTSN)
104#define LIBC_EXTSN_C(sym)	__asm("_" __STRING(sym) LIBC_SUF_EXTSN LIBC_SUF_NON_CANCELABLE)
105
106extern int pthread_key_init_np(int, void (*)(void *));
107
108#include <TargetConditionals.h>
109#if TARGET_IPHONE_SIMULATOR
110/* Simulator keys are offset by 200 */
111#define	__LIBC_PTHREAD_KEY(x)		(210 + (x))
112#else
113#define	__LIBC_PTHREAD_KEY(x)		(10 + (x))
114#endif
115
116/*
117 * Libc pthread key assignments
118 */
119#define __LIBC_PTHREAD_KEY_XLOCALE	__LIBC_PTHREAD_KEY(0)
120#define __LIBC_PTHREAD_KEY_TTYNAME	__LIBC_PTHREAD_KEY(1)
121#define __LIBC_PTHREAD_KEY_LOCALTIME	__LIBC_PTHREAD_KEY(2)
122#define __LIBC_PTHREAD_KEY_GMTIME	__LIBC_PTHREAD_KEY(3)
123#define __LIBC_PTHREAD_KEY_GDTOA_BIGINT	__LIBC_PTHREAD_KEY(4)
124#define __LIBC_PTHREAD_KEY_PARSEFLOAT	__LIBC_PTHREAD_KEY(5)
125
126#endif /* _LIBC_SYS_CDEFS_H_ */
127