3 # Usage: make-syscalls.sh ../sysdeps/unix/common
4 # Expects $sysdirs in environment.
8 # Get the list of system calls for this directory.
10 /^[ ]*$/d' $thisdir/syscalls.list`
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
16 # Punt when we reach the directory defining these syscalls.
17 test $dir = $thisdir && break
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
23 test -f $dir/$file.c && continue
24 test -f $dir/$file.S && continue
25 test -f $dir/$file.s && continue
26 if test x$caller != x-; then
27 test -f $dir/$caller.c && continue
28 test -f $dir/$caller.S && continue
29 test -f $dir/$caller.s && continue
31 echo $file $caller $rest
37 test -n "$calls" ||
exit 0
41 # Emit rules to compile the syscalls remaining in $calls.
42 echo "$calls" |
while read file caller syscall nargs strong weak
; do
44 # Figure out if $syscall is defined with a number in syscall.h.
45 $asm_CPP - << EOF | grep "^@@@ .*$syscall" >/dev/null && continue
47 @@@ SYS_ify ($syscall)
52 # The versioned symbols are only in the shared library.
53 echo "ifneq (,\$(filter .os,\$(object-suffixes)))"
57 # Make sure only the first syscall rule is used, if multiple dirs
58 # define the same syscall.
59 echo "ifeq (,\$(filter $file,\$(unix-syscalls)))"
61 # Accumulate the list of syscall files for this directory.
62 echo "unix-syscalls += $file"
63 test x
$caller = x- ||
echo "unix-extra-syscalls += $file"
65 # Emit a compilation rule for this syscall.
68 # The versioned symbols are only in the shared library.
70 shared-only-routines += $file
71 \$(objpfx)${file}.os: \\"
75 \$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \\"
78 echo "\$(common-objpfx)s-proto.d
79 (echo '#include <sysdep.h>'; \\
80 echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
82 echo 'PSEUDO_END($strong)'; \\"
84 # Append any weak aliases or versions defined for this syscall function.
86 # A shortcoming in the current gas is that it will only allow one
87 # version-alias per symbol. So we create new strong aliases as needed.
93 base
=`echo $name | sed 's/@@.*//'`
94 ver
=`echo $name | sed 's/.*@@//'`
95 if test -z "$vcount" ; then
99 source="${strong}_${vcount}"
100 vcount
=`expr $vcount + 1`
101 echo " echo 'strong_alias ($strong, $source)'; \\"
103 echo " echo 'default_symbol_version($source, $base, $ver)'; \\"
106 base
=`echo $name | sed 's/@.*//'`
107 ver
=`echo $name | sed 's/.*@//'`
108 if test -z "$vcount" ; then
112 source="${strong}_${vcount}"
113 vcount
=`expr $vcount + 1`
114 echo " echo 'strong_alias ($strong, $source)'; \\"
116 echo " echo 'symbol_version($source, $base, $ver)'; \\"
119 echo " echo 'weak_alias ($strong, $name)'; \\"
124 # And finally, pipe this all into the compiler.
125 echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
131 # The versioned symbols are only in the shared library.