]> git.saurik.com Git - apple/libc.git/blame - gen/compat.5
Libc-1439.40.11.tar.gz
[apple/libc.git] / gen / compat.5
CommitLineData
a9aaacca 1.Dd July 21, 2020
3d9156a7
A
2.Os Darwin
3.Dt COMPAT 5
4.Sh NAME
5.Nm compat
6.Nd manipulate compatibility settings
7.Sh SYNOPSIS
8.Ev COMMAND_MODE=legacy|unix2003
a9aaacca
A
9.br
10.Ev SYSTEM_VERSION_COMPAT=1
3d9156a7
A
11.Lp
12.Fd #define _POSIX_C_SOURCE
224c7076 13.Fd #define _DARWIN_C_SOURCE
3d9156a7 14.Fd #define _NONSTD_SOURCE
224c7076
A
15.Fd defined(__LP64__)
16.Lp
17.In sys/cdefs.h
18.Fd defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)
3d9156a7
A
19.Sh DESCRIPTION
20Setting the environment variable
21.Ev COMMAND_MODE
1f2f436a
A
22to the value legacy causes utility programs to behave as closely to
23Mac OS X 10.3's utility programs as possible. When in this mode all of 10.3's
24flags are accepted, and in some cases extra flags are accepted, but no flags
25that were used in 10.3 will have been removed or changed in meaning. Any
26behavioral changes in this mode are documented in the LEGACY sections of the
27individual utilities.
3d9156a7
A
28.Pp
29Setting the environment variable
30.Ev COMMAND_MODE
34e8f829 31to the value unix2003 causes utility programs to obey the
3d9156a7
A
32.St -susv3
33standards even if doing so would alter the behavior of flags used in 10.3.
34.Pp
224c7076
A
35The value of
36.Ev COMMAND_MODE
1f2f436a
A
37is case insensitive and if it is unset or set to something other than legacy
38or unix2003 it behaves as if it were set to unix2003.
a9aaacca
A
39.Pp
40Setting the environment variable
41.Ev SYSTEM_VERSION_COMPAT
42to 1 causes the system version to be reported as 10.16 when running on macOS 11 or later.
1f2f436a 43.Sh COMPILATION
3d9156a7
A
44Defining
45.Dv _NONSTD_SOURCE
1f2f436a
A
46for i386 causes library and kernel calls to behave as closely to Mac
47OS X 10.3's library and kernel calls as possible. Any behavioral changes are
48documented in the LEGACY sections of the man pages for the individual function
49calls. Defining this macro when compiling for any other architecture will
50result in a compilation error.
3d9156a7 51.Pp
224c7076
A
52Defining
53.Dv _POSIX_C_SOURCE
3d9156a7 54or
224c7076
A
55.Dv _DARWIN_C_SOURCE
56causes library and kernel calls to conform to the SUSv3
57standards even if doing so would alter the behavior of functions used in 10.3.
58Defining
3d9156a7 59.Dv _POSIX_C_SOURCE
224c7076
A
60also removes functions, types, and other interfaces that are not part of SUSv3
61from the normal C namespace, unless
62.Dv _DARWIN_C_SOURCE
63is also defined (i.e.,
64.Dv _DARWIN_C_SOURCE
65is
66.Dv _POSIX_C_SOURCE
67with non-POSIX extensions).
68In any of these cases, the
69.Dv _DARWIN_FEATURE_UNIX_CONFORMANCE
70feature macro will be defined to the SUS conformance level (it is undefined
71otherwise).
3d9156a7 72.Pp
224c7076
A
73Starting in Mac OS X 10.5, if none of the macros
74.Dv _NONSTD_SOURCE ,
75.Dv _POSIX_C_SOURCE
76or
77.Dv _DARWIN_C_SOURCE
78are defined, and the environment variable
79.Ev MACOSX_DEPLOYMENT_TARGET
80is either undefined or set to 10.5 or greater (or equivalently, the
81.Xr gcc 1
82option
83.Fl mmacosx-version-min
84is either not specified or set to 10.5 or greater), then UNIX conformance will
85be on by default, and non-POSIX extensions will also be available
86(this is the equivalent of defining
87.Dv _DARWIN_C_SOURCE ) .
1f2f436a
A
88For version values less that 10.5, UNIX conformance will be off when targeting
89i386 (the equivalent of defining
224c7076 90.Dv _NONSTD_SOURCE ) .
1f2f436a
A
91.Pp
92In order to provide both legacy and conformance versions of functions, two
93versions of affected functions are provided. Legacy variants have symbol names
94with no suffix in order to maintain ABI compatibility. Conformance versions
95have a $UNIX2003 suffix appended to their symbol name. These $UNIX2003
96suffixes are automatically appended by the compiler tool-chain and should not
97be used directly.
98.Pp
99Platforms that were released after these updates only have conformance variants
100available and do not have a $UNIX2003 suffix.
101.Pp
102.TS
103center;
104c s s s s
105c c | c c c
106c c | c c c
107l c | c c c
108l c | c c c
109l c | c c c
110l c | c c c
111l c | c c c
112l c | c c c
113l c | c c c.
114T{
115.Dv i386
116T}
117=
118user defines deployment namespace conformance suffix
119 target
120_
121T{
122.Em (none)
123T} < 10.5 full 10.3 compatibility (none)
124T{
125.Em (none)
126T} >= 10.5 full SUSv3 conformance $UNIX2003
127T{
128.Em _NONSTD_SOURCE
129T} (any) full 10.3 compatibility (none)
130T{
131.Em _DARWIN_C_SOURCE
132T} < 10.4 full 10.3 compatibility (none)
133T{
134.Em _DARWIN_C_SOURCE
135T} >= 10.4 full SUSv3 conformance $UNIX2003
136T{
137.Em _POSIX_C_SOURCE
138T} < 10.4 strict 10.3 compatibility (none)
139T{
140.Em _POSIX_C_SOURCE
141T} >= 10.4 strict SUSv3 conformance $UNIX2003
142_
143.T&
144c s s s s
1f2f436a
A
145c c | c c c
146c c | c c c
147l c | c c c
148l c | c s s
149l c | c c c
150l c | c c c.
151T{
152.Dv Newer Architectures
153T}
154=
155user defines deployment namespace conformance suffix
156 target
157_
158T{
159.Em (none)
160T} (any) full SUSv3 conformance (none)
161T{
162.Em _NONSTD_SOURCE
163T} (any) (error)
164T{
165.Em _DARWIN_C_SOURCE
166T} (any) full SUSv3 conformance (none)
167T{
168.Em _POSIX_C_SOURCE
169T} (any) strict SUSv3 conformance (none)
170_
171.TE
3d9156a7 172.Sh STANDARDS
1f2f436a 173With COMMAND_MODE set to anything other than legacy, utility functions conform to
224c7076 174.St -susv3 .
3d9156a7
A
175.Pp
176With
1f2f436a 177.Dv _POSIX_C_SOURCE
3d9156a7 178or
1f2f436a
A
179.Dv _DARWIN_C_SOURCE
180for i386, or when building for any other architecture,
3d9156a7 181system and library calls conform to
224c7076 182.St -susv3 .
3d9156a7 183.Sh BUGS
224c7076
A
184Different parts of a program can be compiled with different compatibility
185settings.
186The resultant program will normally work as expected, for example a regex
187created by the SUSv3
3d9156a7
A
188.Fn regcomp 3
189can be passed to the legacy
190.Fn regfree 3
191with no unexpected results. Some cases are less clear cut, for example
224c7076 192what does the programmer intend when they use the SUSv3
3d9156a7
A
193.Fn regcomp 3
194to compile a regex, but the legacy
195.Fn regexec 3
196to execute it? Any interpretation will surprise someone.