]>
Commit | Line | Data |
---|---|---|
aeb72b16 RM |
1 | #! /bin/sh |
2 | ||
795fbc9a | 3 | # Usage: make-syscalls.sh ../sysdeps/unix/common |
aeb72b16 RM |
4 | # Expects $sysdirs in environment. |
5 | ||
aeb72b16 RM |
6 | thisdir=$1; shift |
7 | ||
8 | # Get the list of system calls for this directory. | |
9 | calls=`sed 's/#.*$// | |
57ba7bb4 | 10 | /^[ ]*$/d' $thisdir/syscalls.list` |
aeb72b16 RM |
11 | |
12 | # Check each sysdep dir with higher priority than this one, | |
13 | # and remove from $calls all the functions found in other dirs. | |
14 | for dir in $sysdirs; do | |
15 | ||
16 | # Punt when we reach the directory defining these syscalls. | |
17 | test $dir = $thisdir && break | |
18 | ||
19 | # Remove each syscall that is implemented by a file in $dir. | |
20 | # If a syscall specified a "caller", then only compile that syscall | |
21 | # if the caller function is also implemented in this directory. | |
22 | calls=`echo "$calls" | while read file caller rest; do | |
57ba7bb4 UD |
23 | test -f $dir/$file.c && continue |
24 | test -f $dir/$file.S && continue | |
25 | test -f $dir/$file.s && continue | |
aeb72b16 | 26 | if test x$caller != x-; then |
57ba7bb4 UD |
27 | test -f $dir/$caller.c && continue |
28 | test -f $dir/$caller.S && continue | |
29 | test -f $dir/$caller.s && continue | |
aeb72b16 RM |
30 | fi |
31 | echo $file $caller $rest | |
32 | done` | |
33 | ||
34 | done | |
35 | ||
36 | # Any calls left? | |
37 | test -n "$calls" || exit 0 | |
38 | ||
39 | files= | |
40 | ||
41 | # Emit rules to compile the syscalls remaining in $calls. | |
42 | echo "$calls" | while read file caller syscall nargs strong weak; do | |
43 | ||
44 | # Figure out if $syscall is defined with a number in syscall.h. | |
45 | $asm_CPP - << EOF | grep "^@@@ .*$syscall" >/dev/null && continue | |
46 | #include <sysdep.h> | |
47 | @@@ SYS_ify ($syscall) | |
48 | EOF | |
49 | ||
50 | # Make sure only the first syscall rule is used, if multiple dirs | |
51 | # define the same syscall. | |
52 | echo "ifeq (,\$(filter $file,\$(unix-syscalls)))" | |
53 | ||
54 | # Accumulate the list of syscall files for this directory. | |
55 | echo "unix-syscalls += $file" | |
56 | test x$caller = x- || echo "unix-extra-syscalls += $file" | |
57 | ||
58 | # Emit a compilation rule for this syscall. | |
59 | echo "\ | |
92f1da4d | 60 | \$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \\ |
795fbc9a | 61 | \$(common-objpfx)s-proto.d |
aeb72b16 RM |
62 | (echo '#include <sysdep.h>'; \\ |
63 | echo 'PSEUDO ($strong, $syscall, $nargs)'; \\ | |
84724245 | 64 | echo ' ret'; \\ |
a1470b6f | 65 | echo 'PSEUDO_END($strong)'; \\" |
aeb72b16 | 66 | |
da2d1bc5 UD |
67 | # Append any weak aliases or versions defined for this syscall function. |
68 | ||
69 | # A shortcoming in the current gas is that it will only allow one | |
70 | # version-alias per symbol. So we create new strong aliases as needed. | |
71 | vcount="" | |
72 | ||
aeb72b16 | 73 | for name in $weak; do |
da2d1bc5 UD |
74 | case $name in |
75 | *@@*) | |
dc30f461 UD |
76 | base=`echo $name | sed 's/@@.*//'` |
77 | ver=`echo $name | sed 's/.*@@//'` | |
da2d1bc5 UD |
78 | if test -z "$vcount" ; then |
79 | source=$strong | |
80 | vcount=1 | |
81 | else | |
82 | source="${strong}_${vcount}" | |
83 | vcount=`expr $vcount + 1` | |
84 | echo " echo 'strong_alias ($strong, $source)'; \\" | |
85 | fi | |
86 | echo " echo 'default_symbol_version($source, $base, $ver)'; \\" | |
87 | ;; | |
88 | *@*) | |
89 | base=`echo $name | sed 's/@.*//'` | |
90 | ver=`echo $name | sed 's/.*@//'` | |
91 | if test -z "$vcount" ; then | |
92 | source=$strong | |
93 | vcount=1 | |
94 | else | |
95 | source="${strong}_${vcount}" | |
96 | vcount=`expr $vcount + 1` | |
97 | echo " echo 'strong_alias ($strong, $source)'; \\" | |
98 | fi | |
99 | echo " echo 'symbol_version($source, $base, $ver)'; \\" | |
100 | ;; | |
101 | *) | |
102 | echo " echo 'weak_alias ($strong, $name)'; \\" | |
103 | ;; | |
104 | esac | |
aeb72b16 RM |
105 | done |
106 | ||
107 | # And finally, pipe this all into the compiler. | |
108 | echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -' | |
109 | ||
110 | echo endif | |
111 | ||
112 | done |