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