gen_bits_syscall_h.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
  16. case $CC in
  17. *icc*) CC_SYSNUM_ARGS="-dM" ;;
  18. *) CC_SYSNUM_ARGS="-dN" ;;
  19. esac
  20. ( echo "#include <asm/unistd.h>";
  21. echo "#include <asm/unistd.h>" |
  22. $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
  23. sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp' \
  24. -e 's/^[ ]*#undef[ ]*__NR_\([A-Za-z0-9_]*\).*/UNDEFUCLIBC_\1 __NR_\1/gp' # needed to strip out any kernel-internal defines
  25. ) |
  26. $CC -E $INCLUDE_OPTS - |
  27. ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ; echo ;
  28. echo "#ifndef _BITS_SYSNUM_H" ;
  29. echo "#define _BITS_SYSNUM_H" ;
  30. echo ;
  31. echo "#ifndef _SYSCALL_H" ;
  32. echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
  33. echo "#endif" ; echo ;
  34. sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
  35. #define __NR_\1 \2\
  36. #define SYS_\1 __NR_\1/gp' \
  37. -e 's/^UNDEFUCLIBC_\([A-Za-z0-9_]*\).*/#undef __NR_\1/gp'
  38. echo ;
  39. echo "#endif" ;
  40. )