Update.
[glibc/history.git] / sysdeps / unix / make-syscalls.sh
blob93a73802f7b606b18aa2f5b45e7c1736eac80e03
1 #! /bin/sh
3 # Usage: make-syscalls.sh ../sysdeps/unix/common
4 # Expects $sysdirs in environment.
6 thisdir=$1; shift
8 # Get the list of system calls for this directory.
9 calls=`sed 's/#.*$//
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
32 done`
34 done
36 # Any calls left?
37 test -n "$calls" || exit 0
39 files=
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
46 #include <sysdep.h>
47 @@@ SYS_ify ($syscall)
48 EOF
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)))"
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"
58 # Emit a compilation rule for this syscall.
59 echo "\
60 \$(foreach o,\$(all-object-suffixes),\$(objpfx)$file\$o): \\
61 \$(common-objpfx)s-proto.d
62 (echo '#include <sysdep.h>'; \\
63 echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
64 echo ' ret'; \\
65 echo 'PSEUDO_END($strong)'; \\"
67 # Append any weak aliases defined for this syscall function.
68 for name in $weak; do
69 echo " echo 'weak_alias ($strong, $name)'; \\"
70 done
72 # And finally, pipe this all into the compiler.
73 echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
75 echo endif
77 done