gen_bits_syscall_h.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 top_builddir and CC (as used in the Makefiles) to be set in
  11. # the environment, and outputs the appropriate $top_builddir/include/bits/sysnum.h
  12. # corresponding to $top_builddir/include/asm/unistd.h to stdout.
  13. #
  14. # Warning!!! This does _no_ error checking!!!
  15. UNISTD_H_PATH=$top_builddir/include/asm/unistd.h
  16. INCLUDE_OPTS="-I$top_builddir/include"
  17. case $CC in
  18. *icc*) CC_SYSNUM_ARGS="-dM" ;;
  19. *) CC_SYSNUM_ARGS="-dN" ;;
  20. esac
  21. ( echo "#include \"$UNISTD_H_PATH\"" ;
  22. $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS $UNISTD_H_PATH | # needed to strip out any kernel-internal defines
  23. sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp'
  24. ) |
  25. $CC -E $INCLUDE_OPTS - |
  26. ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ; echo ;
  27. echo "#ifndef _BITS_SYSNUM_H" ;
  28. echo "#define _BITS_SYSNUM_H" ;
  29. echo ;
  30. echo "#ifndef _SYSCALL_H" ;
  31. echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
  32. echo "#endif" ; echo ;
  33. sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
  34. #define __NR_\1 \2\
  35. #define SYS_\1 __NR_\1/gp'
  36. echo ;
  37. echo "#endif" ;
  38. )