gen_bits_syscall_h.sh 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. #
  3. # June 27, 2001 Manuel Novoa III
  4. #
  5. # This script expects TOPDIR and CC (as used in the Makefiles) to be set in
  6. # the environment, and outputs the appropriate $TOPDIR/include/bits/sysnum.h
  7. # corresponding to $TOPDIR/include/asm/unistd.h to stdout.
  8. #
  9. # Warning!!! This does _no_ error checking!!!
  10. UNISTD_H_PATH=$TOPDIR/include/asm/unistd.h
  11. INCLUDE_OPTS="-I$TOPDIR/include"
  12. ( echo "#include \"$UNISTD_H_PATH\"" ;
  13. $CC -E -dN $INCLUDE_OPTS $UNISTD_H_PATH | # needed to strip out any kernel-internal defines
  14. sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp'
  15. ) |
  16. $CC -E $INCLUDE_OPTS - |
  17. ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ; echo ;
  18. echo "#ifndef _BITS_SYSNUM_H" ;
  19. echo "#define _BITS_SYSNUM_H" ;
  20. echo ;
  21. echo "#ifndef _SYSCALL_H" ;
  22. echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
  23. echo "#endif" ; echo ;
  24. sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
  25. #define __NR_\1 \2\
  26. #define SYS_\1 __NR_\1/gp'
  27. echo ;
  28. echo "#endif" ;
  29. )