blob: 4834c7240227b8ef52e9e8cedc038b079f87267c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
BEGIN {
HAVE_SYS_CDEFS_H = 0
HAVE_SYS_CDEFS_BEGIN_END_DECLS = 0
HAVE_SYS_CDEFS_NONNULL = 0
HAVE_SYS_CDEFS_THROW = 0
}
END {
if (!HAVE_SYS_CDEFS_H &&
(HAVE_SYS_CDEFS_BEGIN_END_DECLS ||
HAVE_SYS_CDEFS_NONNULL ||
HAVE_SYS_CDEFS_THROW)) {
print "config.h is inconsistent" > "/dev/stderr"
close("/dev/stderr")
exit 1
}
}
FILENAME ~ /config\.h$/ {
if ($0 ~ /^#define HAVE_SYS_CDEFS_H 1$/) {
HAVE_SYS_CDEFS_H = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_BEGIN_END_DECLS 1$/) {
HAVE_SYS_CDEFS_BEGIN_END_DECLS = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_NONNULL 1$/) {
HAVE_SYS_CDEFS_NONNULL = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_THROW 1$/) {
HAVE_SYS_CDEFS_THROW = 1
}
}
FILENAME !~ /config\.h$/ {
if ($0 ~ /^\/\*HEADER\*\/$/) {
if (HAVE_SYS_CDEFS_H) {
print "#include <sys/cdefs.h>"
}
if (!HAVE_SYS_CDEFS_THROW) {
print "#define __THROW /* nothing */"
}
if (!HAVE_SYS_CDEFS_NONNULL) {
print "#define __nonnull(arg) /* nothing */"
}
print ""
if (HAVE_SYS_CDEFS_BEGIN_END_DECLS) {
print "__BEGIN_DECLS"
} else {
print "#ifdef __cplusplus"
print "extern \"C\" {"
print "#endif"
}
} else if ($0 ~ /^\/\*TRAILER\*\/$/) {
if (HAVE_SYS_CDEFS_BEGIN_END_DECLS) {
print "__END_DECLS"
} else {
print "#ifdef __cplusplus"
print "} /* extern \"C\" */"
print "#endif"
}
} else {
print;
}
}
|