gen_bits_syscall_h.sh 1.2 KB

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