summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_prototypes
blob: 5633c3b5140c5d208875e50a5b1d948369281a36 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh

# Build a list of internal function and variable prototypes.
t=__wt.$$
trap 'rm -f $t; exit 0' 0 1 2 3 13 15

# proto --
#	extract public functions.
proto()
{
	sed -n \
	    -e '/^__wt_[a-z]/!{' \
		-e h \
		-e d \
	    -e '}' \
	    -e x \
	    -e '/^static/d' \
	    -e x \
	    -e ': loop' \
	    -e H \
	    -e n \
	    -e '/;/b end' \
	    -e '/^{/!b loop' \
	    -e ': end' \
	    -e x \
	    -e 's/ =.*$//' \
	    -e '/#/!s/\n/ /g' \
	    -e 's/\* /\*/g' \
	    -e 's/  */ /g' \
	    -e 's/^/extern /' \
	    -e 's/WT_GCC_FUNC_ATTRIBUTE/WT_GCC_FUNC_DECL_ATTRIBUTE/g' \
	    -e '# If a line ends in #endif, appending a semicolon will result' \
	    -e '# in an illegal expression, force an appended newline using' \
	    -e '# the H command because substitute may not allow newline in' \
	    -e '# the RHS of the expression.' \
	    -e '/#endif$/{' \
		-e x \
		-e 's/.*//' \
		-e H \
		-e x \
	    -e '}' \
	    -e '# Add the gcc warn_unused_result attribute to any external' \
	    -e '# functions that return an int.' \
	    -e '/^extern int /s/$/ WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result))/' \
	    -e 's/$/;/' \
	    -e p < $1
}

# externs --
#	generate the list of prototypes given a file list
externs()
{
(cat <<EOF
/* DO NOT EDIT: automatically built by dist/s_prototypes. */

EOF
	for i in $l; do
		proto ../$i
	done) > $t
	cmp $t $f > /dev/null 2>&1 ||
	    (echo "Building $f" && rm -f $f && cp $t $f)
}

f=../src/include/extern_win.h
l=`sed \
    -e '/os_win/!d' \
    -e 's/[	 ].*$//' filelist`
externs

f=../src/include/extern_posix.h
l=`sed \
    -e '/os_posix/!d' \
    -e 's/[	 ].*$//' filelist`
externs

f=../src/include/extern.h
l=`sed \
    -e '/^[a-z]/!d' \
    -e '/\/checksum\/arm64/d' \
    -e '/\/checksum\/power8/d' \
    -e '/\/checksum\/zseries/d' \
    -e '/os_posix/d' \
    -e '/os_win/d' \
    -e 's/[	 ].*$//' filelist`
externs