aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--Makerules6
-rw-r--r--sysdeps/unix/Makefile33
-rw-r--r--sysdeps/unix/make-syscalls.sh76
4 files changed, 122 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8f68509..d1b456f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Jan 18 00:32:43 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
+
+ * Makerules (COMPILE.s): New variable.
+
+ * sysdeps/unix/Makefile (sysd-syscalls): New target; generate with
+ make-syscalls.sh and include it.
+ [$(subdir)=misc] (sysdep_routines): Append extra syscalls from
+ sysd-syscalls.
+ * sysdeps/unix/make-syscalls.sh: New file.
+
+ * Makerules (COMPILE.S): New variable.
+
Wed Jan 17 11:04:58 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/unix/sysv/linux/statbuf.h (_STAT_VER_LINUX,
diff --git a/Makerules b/Makerules
index 530b1ac..0013b53 100644
--- a/Makerules
+++ b/Makerules
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -253,8 +253,10 @@ compile-command.c = $(compile.c) $(OUTPUT_OPTION)
endif
# GCC can grok options after the file name, and it looks nicer that way.
-compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
+compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
+COMPILE.S = $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
+COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
# We need this for the output to go in the right place. It will default to
# empty if make was configured to work with a cc that can't grok -c and -o
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index 9ffb344..a09ea4f 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -85,7 +85,7 @@ ifndef no_deps
include $(common-objpfx)param.h.dep
endif
-# Don't preempt our own headers.
+# Don't preempt our own headers.
sys/param.h-includes := \
$(filter-out $(patsubst $(..)%,%,\
$(wildcard $(addprefix $(..),\
@@ -130,7 +130,7 @@ ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
# These need to exist before any compiling is done,
# so cpp doesn't instead find the stub versions.
-before-compile := $(before-compile) $(common-objpfx)errnos.h
+before-compile := $(before-compile) $(common-objpfx)errnos.h
$(common-objpfx)errnos.h: $(common-objpfx)make-errnos
$(dir $<)$(notdir $<) > $@-tmp
@@ -266,3 +266,30 @@ common-generated := $(common-generated) syscall.h
endif
endif
+
+ifndef inhibit-unix-syscalls
+
+# Sysdep dirs unix/... can contain a file syscalls.list,
+# which specifies objects to be compiled as simple Unix system calls.
+
+-include $(objpfx)sysd-syscalls
+omit-deps += $(unix-syscalls)
+
+ifeq (misc,$(subdir))
+sysdep_routines += $(unix-extra-syscalls)
+endif
+
+export sysdirs
+export asm_CPP := $(COMPILE.S) -E -x assembler-with-cpp
+
+$(objpfx)sysd-syscalls: $(..)sysdeps/unix/make-syscalls.sh \
+ $(wildcard $(+sysdep_dirs:%=%/syscalls.list))
+ for dir in $$sysdirs; do \
+ test -f $(..)sysdeps/$$dir/syscalls.list && \
+ { $(SHELL) $(dir $<)$(notdir $<) \
+ $(..)sysdeps $$dir $(object-suffixes) || exit 1; }; \
+ test $$dir = unix && break; \
+ done > $@T
+ mv -f $@T $@
+
+endif
diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh
new file mode 100644
index 0000000..ff4b082
--- /dev/null
+++ b/sysdeps/unix/make-syscalls.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+
+# Usage: make-syscalls.sh ../sysdeps unix/common
+# Expects $sysdirs in environment.
+
+sysbase=$1; shift
+thisdir=$1; shift
+
+# Get the list of system calls for this directory.
+calls=`sed 's/#.*$//
+/^[ ]*$/d' $sysbase/$thisdir/syscalls.list`
+
+# Check each sysdep dir with higher priority than this one,
+# and remove from $calls all the functions found in other dirs.
+for dir in $sysdirs; do
+
+ # Punt when we reach the directory defining these syscalls.
+ test $dir = $thisdir && break
+
+ # Remove each syscall that is implemented by a file in $dir.
+ # If a syscall specified a "caller", then only compile that syscall
+ # if the caller function is also implemented in this directory.
+ calls=`echo "$calls" | while read file caller rest; do
+ test -f $sysbase/$dir/$file.c && continue
+ test -f $sysbase/$dir/$file.S && continue
+ test -f $sysbase/$dir/$file.s && continue
+ if test x$caller != x-; then
+ test -f $sysbase/$dir/$caller.c && continue
+ test -f $sysbase/$dir/$caller.S && continue
+ test -f $sysbase/$dir/$caller.s && continue
+ fi
+ echo $file $caller $rest
+ done`
+
+done
+
+# Any calls left?
+test -n "$calls" || exit 0
+
+files=
+
+# Emit rules to compile the syscalls remaining in $calls.
+echo "$calls" | while read file caller syscall nargs strong weak; do
+
+ # Figure out if $syscall is defined with a number in syscall.h.
+ $asm_CPP - << EOF | grep "^@@@ .*$syscall" >/dev/null && continue
+#include <sysdep.h>
+@@@ SYS_ify ($syscall)
+EOF
+
+ # Make sure only the first syscall rule is used, if multiple dirs
+ # define the same syscall.
+ echo "ifeq (,\$(filter $file,\$(unix-syscalls)))"
+
+ # Accumulate the list of syscall files for this directory.
+ echo "unix-syscalls += $file"
+ test x$caller = x- || echo "unix-extra-syscalls += $file"
+
+ # Emit a compilation rule for this syscall.
+ echo "\
+\$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \$(objpfx)s-proto.d
+ (echo '#include <sysdep.h>'; \\
+ echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
+ echo ' ret'; \\"
+
+ # Append any weak aliases defined for this syscall function.
+ for name in $weak; do
+ echo " echo 'weak_alias ($strong, $name)'; \\"
+ done
+
+ # And finally, pipe this all into the compiler.
+ echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
+
+ echo endif
+
+done