Update.
[glibc.git] / sysdeps / unix / make-syscalls.sh
blobc7ddb889994bf8a72a26231dbbd0490d3d96f846
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 case $weak in
51 *@*)
52 # The versioned symbols are only in the shared library.
53 echo "ifneq (,\$(filter .os,\$(object-suffixes)))"
55 esac
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.
66 case $weak in
67 *@*)
68 # The versioned symbols are only in the shared library.
69 echo "\
70 \$(objpfx)${file}.o: \$(common-objpfx)empty.o
71 rm -f \$@
72 ln \$< \$@
73 \$(objpfx)${file}.op: \$(common-objpfx)empty.op
74 rm -f \$@
75 ln \$< \$@
76 \$(objpfx)${file}.os: \\"
79 echo "\
80 \$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \\"
82 esac
83 echo "\$(common-objpfx)s-proto.d
84 (echo '#include <sysdep.h>'; \\
85 echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
86 echo ' ret'; \\
87 echo 'PSEUDO_END($strong)'; \\"
89 # Append any weak aliases or versions defined for this syscall function.
91 # A shortcoming in the current gas is that it will only allow one
92 # version-alias per symbol. So we create new strong aliases as needed.
93 vcount=""
95 for name in $weak; do
96 case $name in
97 *@@*)
98 base=`echo $name | sed 's/@@.*//'`
99 ver=`echo $name | sed 's/.*@@//'`
100 if test -z "$vcount" ; then
101 source=$strong
102 vcount=1
103 else
104 source="${strong}_${vcount}"
105 vcount=`expr $vcount + 1`
106 echo " echo 'strong_alias ($strong, $source)'; \\"
108 echo " echo 'default_symbol_version($source, $base, $ver)'; \\"
110 *@*)
111 base=`echo $name | sed 's/@.*//'`
112 ver=`echo $name | sed 's/.*@//'`
113 if test -z "$vcount" ; then
114 source=$strong
115 vcount=1
116 else
117 source="${strong}_${vcount}"
118 vcount=`expr $vcount + 1`
119 echo " echo 'strong_alias ($strong, $source)'; \\"
121 echo " echo 'symbol_version($source, $base, $ver)'; \\"
124 echo " echo 'weak_alias ($strong, $name)'; \\"
126 esac
127 done
129 # And finally, pipe this all into the compiler.
130 echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
132 echo endif
134 case $weak in
135 *@*)
136 # The versioned symbols are only in the shared library.
137 echo endif
139 esac
141 done