Skip to content

Commit 17f1334

Browse files
committed
Build & getconf fixes for macOS (and UnixWare)
src/lib/libast/features/standards: - Add heuristic (u_long availability) for systems that hide rather than reveal functionality in the presence of _POSIX_SOURCE, etc. - Define _DARWIN_C_SOURCE, like _GNU_SOURCE, to enable the full range of definitions on macOS systems. - Due to the above, remove MACH (macOS)-specific hack. - These changes ported from att#1492 - thanks to Lev Kujawski (@lkujaw). His PR indicates that this fixes the standards macros on UnixWare, too. Therefore, no longer exclude UnixWare from standards macros (re: ff70c27). src/lib/libast/comp/conf.sh: - Promote the 'op' member in Conf_t (struct Conf_s) from short to int. This allows some Darwin/macOS values, now exposed, to fit that would otherwise be truncated, namely: _CS_DARWIN_USER_CACHE_DIR 65538 _CS_DARWIN_USER_DIR 65536 _CS_DARWIN_USER_TEMP_DIR 65537 Thus, the following AST getconf values are now correct on macOS: $ /opt/ast/bin/getconf | grep ^DARWIN DARWIN_USER_CACHE_DIR=/var/folders/nx/(REDACTED)/C/ DARWIN_USER_DIR=/var/folders/nx/(REDACTED)/0/ DARWIN_USER_TEMP_DIR=/var/folders/nx/(REDACTED)/T/ src/lib/libast/features/tty: - Include <sys/ioctl.h> if available. This silences a compiler warning in src/lib/libast/misc/procopen.c about an invalid implicit declaration of ioctl(2).
1 parent 0d2d6bb commit 17f1334

File tree

3 files changed

+59
-26
lines changed

3 files changed

+59
-26
lines changed

src/lib/libast/comp/conf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ struct Conf_s
15461546
short standard;
15471547
short section;
15481548
short call;
1549-
short op;
1549+
int op;
15501550
};
15511551
15521552
typedef struct Prefix_s

src/lib/libast/features/standards

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
set stdio
2+
3+
# Flag systems that omit necessary definitions such as u_long
4+
# when _POSIX_SOURCE or _XOPEN_SOURCE are defined.
5+
# Affected: Mac OS X, UnixWare.
6+
typ u_long
7+
28
# In FreeBSD, definitions like _POSIX_SOURCE and such are used to *limit*
39
# functionality to known API; they don't enable anything. The general intent in
4-
# BSD is to enable everything by default (effectively, providing the
5-
# _KITCHEN_SINK_SOURCE mentioned below). So we look for that here, but stay
10+
# BSD is to enable everything by default. So we look for that here, but stay
611
# careful that we don't get fooled by presence of FreeBSD that underpins some
712
# subsystems in Mac OS X; there are other Apple-specific portability hacks
813
# elsewhere we should not interfere with.
9-
if tst note{ FreeBSD, DragonFly BSD, or UnixWare }end compile{
14+
if tst note{ FreeBSD or DragonFly BSD }end compile{
1015
#include <sys/param.h>
11-
#if (!defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__USLC__)) || defined(APPLE)
12-
#error not a FreeBSD or DragonFly BSD system
16+
#if (!defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__APPLE__) || defined(__MACH__)
17+
#error not one of the listed systems
1318
#endif
1419
}end {
1520
}
16-
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
21+
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{
1722
#define _ALL_SOURCE 1
1823
#define _POSIX_SOURCE 1
1924
#define _POSIX_C_SOURCE 21000101L
2025
#define _XOPEN_SOURCE 9900
2126
#define _GNU_SOURCE 1
27+
#define _DARWIN_C_SOURCE 1
2228
#define __EXTENSIONS__ 1
2329
#include <sys/types.h>
2430
#include <sys/stat.h>
2531
#include <stdlib.h>
2632
#include <unistd.h>
33+
#include <fcntl.h>
34+
#if _typ_u_long
35+
u_long _test_dummy_;
36+
#endif
2737
}end {
2838
#ifndef _ALL_SOURCE
2939
#define _ALL_SOURCE 1
@@ -40,20 +50,28 @@ elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _
4050
#ifndef _GNU_SOURCE
4151
#define _GNU_SOURCE 1
4252
#endif
53+
#ifndef _DARWIN_C_SOURCE
54+
#define _DARWIN_C_SOURCE 1
55+
#endif
4356
#ifndef __EXTENSIONS__
4457
#define __EXTENSIONS__ 1
4558
#endif
4659
}
47-
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
60+
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{
4861
#define _ALL_SOURCE 1
4962
#define _POSIX_SOURCE 1
5063
#define _XOPEN_SOURCE 9900
5164
#define _GNU_SOURCE 1
65+
#define _DARWIN_C_SOURCE 1
5266
#define __EXTENSIONS__ 1
5367
#include <sys/types.h>
5468
#include <sys/stat.h>
5569
#include <stdlib.h>
5670
#include <unistd.h>
71+
#include <fcntl.h>
72+
#if _typ_u_long
73+
u_long _test_dummy;
74+
#endif
5775
}end {
5876
#ifndef _ALL_SOURCE
5977
#define _ALL_SOURCE 1
@@ -67,20 +85,28 @@ elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ work
6785
#ifndef _GNU_SOURCE
6886
#define _GNU_SOURCE 1
6987
#endif
88+
#ifndef _DARWIN_C_SOURCE
89+
#define _DARWIN_C_SOURCE 1
90+
#endif
7091
#ifndef __EXTENSIONS__
7192
#define __EXTENSIONS__ 1
7293
#endif
7394
}
74-
elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
95+
elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{
7596
#define _POSIX_SOURCE 1
7697
#define _POSIX_C_SOURCE 21000101L
7798
#define _XOPEN_SOURCE 9900
7899
#define _GNU_SOURCE 1
100+
#define _DARWIN_C_SOURCE 1
79101
#define __EXTENSIONS__ 1
80102
#include <sys/types.h>
81103
#include <sys/stat.h>
82104
#include <stdlib.h>
83105
#include <unistd.h>
106+
#include <fcntl.h>
107+
#if _typ_u_long
108+
u_long _test_dummy;
109+
#endif
84110
}end {
85111
#ifndef _POSIX_SOURCE
86112
#define _POSIX_SOURCE 1
@@ -94,6 +120,9 @@ elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__
94120
#ifndef _GNU_SOURCE
95121
#define _GNU_SOURCE 1
96122
#endif
123+
#ifndef _DARWIN_C_SOURCE
124+
#define _DARWIN_C_SOURCE 1
125+
#endif
97126
#ifndef __EXTENSIONS__
98127
#define __EXTENSIONS__ 1
99128
#endif
@@ -106,6 +135,10 @@ elif tst note{ _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile
106135
#include <sys/stat.h>
107136
#include <stdlib.h>
108137
#include <unistd.h>
138+
#include <fcntl.h>
139+
#if _typ_u_long
140+
u_long _test_dummy;
141+
#endif
109142
}end {
110143
#ifndef _POSIX_SOURCE
111144
#define _POSIX_SOURCE 1
@@ -124,6 +157,10 @@ elif tst note{ _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
124157
#include <sys/stat.h>
125158
#include <stdlib.h>
126159
#include <unistd.h>
160+
#include <fcntl.h>
161+
#if _typ_u_long
162+
u_long _test_dummy;
163+
#endif
127164
}end {
128165
#ifndef _XOPEN_SOURCE
129166
#define _XOPEN_SOURCE 1
@@ -138,6 +175,10 @@ elif tst note{ _XOPEN_SOURCE works }end compile{
138175
#include <sys/stat.h>
139176
#include <stdlib.h>
140177
#include <unistd.h>
178+
#include <fcntl.h>
179+
#if _typ_u_long
180+
u_long _test_dummy;
181+
#endif
141182
}end {
142183
#ifndef _XOPEN_SOURCE
143184
#define _XOPEN_SOURCE 1
@@ -147,6 +188,10 @@ else tst note{ __EXTENSIONS__ works }end compile{
147188
#define __EXTENSIONS__ 1
148189
#include <sys/types.h>
149190
#include <sys/stat.h>
191+
#include <fcntl.h>
192+
#if _typ_u_long
193+
u_long _test_dummy;
194+
#endif
150195
}end {
151196
#ifndef __EXTENSIONS__
152197
#define __EXTENSIONS__ 1
@@ -167,19 +212,3 @@ if tst -D_ISOC99_SOURCE -lm note{ _ISOC99_SOURCE plays nice }end link{
167212
#endif
168213
}
169214
endif
170-
171-
cat{
172-
173-
/*
174-
* this is a nasty game we all play to honor standards symbol visibility
175-
* it would help if all implementations had
176-
* _KITCHEN_SINK_SOURCE
177-
* that enabled all symbols from the latest implemented standards
178-
* that's probably the most useful but least portable request
179-
*/
180-
181-
#if __MACH__
182-
#undef _POSIX_SOURCE
183-
#endif
184-
185-
}end

src/lib/libast/features/tty

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
hdr termios,termio,sgtty
1+
hdr termios,termio,sgtty,sys/ioctl
22
sys termios,termio,ioctl,bsdtty,nttyio,ttyio
33
lib tcgetattr,tcgetpgrp termios.h
44
mac _POSIX_VDISABLE termios.h
@@ -107,6 +107,10 @@ cat{
107107
# endif /* TCSANOW */
108108
#endif /* _hdr_termios */
109109

110+
#if _hdr_sys_ioctl
111+
# include <sys/ioctl.h>
112+
#endif
113+
110114
/* set ECHOCTL if driver can echo control characters as ^c */
111115
#ifdef LCTLECH
112116
# ifndef ECHOCTL

0 commit comments

Comments
 (0)