update-mips-syscall-args.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. URL=https://raw.githubusercontent.com/strace/strace/master/src
  3. FILES="sysent.h sysent_shorthand_defs.h linux/mips/syscallent-compat.h \
  4. linux/mips/syscallent-o32.h linux/32/syscallent-common-32.h \
  5. linux/generic/syscallent-common.h"
  6. output="$1"
  7. if [ "$output" = "" ] ; then
  8. output="$PWD"
  9. fi
  10. INC=linux-user/mips/syscall-args-o32.c.inc
  11. TMP=$(mktemp -d)
  12. cd $TMP
  13. for file in $FILES; do
  14. curl --create-dirs $URL/$file -o $TMP/$file
  15. done
  16. > linux/generic/subcallent.h
  17. > linux/32/subcallent.h
  18. cat > gen_mips_o32.c <<EOF
  19. #include <stdio.h>
  20. #define LINUX_MIPSO32
  21. #define MAX_ARGS 7
  22. #include "sysent.h"
  23. #include "sysent_shorthand_defs.h"
  24. #define SEN(syscall_name) 0,0
  25. const struct_sysent sysent0[] = {
  26. #include "syscallent-o32.h"
  27. };
  28. int main(void)
  29. {
  30. int i;
  31. for (i = 4000; i < sizeof(sysent0) / sizeof(struct_sysent); i++) {
  32. if (sysent0[i].sys_name == NULL) {
  33. printf(" [% 4d] = MIPS_SYSCALL_NUMBER_UNUSED,\n", i - 4000);
  34. } else {
  35. printf(" [% 4d] = %d, /* %s */\n", i - 4000,
  36. sysent0[i].nargs, sysent0[i].sys_name);
  37. }
  38. }
  39. return 0;
  40. }
  41. EOF
  42. cc -o gen_mips_o32 -I linux/mips -I linux/generic gen_mips_o32.c && ./gen_mips_o32 > "$output/$INC"
  43. rm -fr "$TMP"