File: update-mips-syscall-args.sh

package info (click to toggle)
qemu 1%3A10.0.3%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 413,680 kB
  • sloc: ansic: 4,733,433; pascal: 114,769; python: 105,506; asm: 68,431; sh: 52,881; makefile: 27,469; perl: 18,778; cpp: 11,435; xml: 3,404; objc: 2,877; yacc: 2,505; php: 1,299; tcl: 1,296; lex: 1,110; sql: 71; awk: 43; sed: 35; javascript: 7
file content (58 lines) | stat: -rwxr-xr-x 1,273 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

URL=https://raw.githubusercontent.com/strace/strace/master/src
FILES="sysent.h sysent_shorthand_defs.h linux/mips/syscallent-compat.h \
       linux/mips/syscallent-o32.h linux/32/syscallent-common-32.h \
       linux/generic/syscallent-common.h"

output="$1"
if [ "$output" = "" ] ; then
    output="$PWD"
fi

INC=linux-user/mips/syscall-args-o32.c.inc

TMP=$(mktemp -d)
cd $TMP

for file in $FILES; do
    curl --create-dirs $URL/$file -o $TMP/$file
done

> linux/generic/subcallent.h
> linux/32/subcallent.h

cat > gen_mips_o32.c <<EOF
#include <stdio.h>

#define LINUX_MIPSO32
#define MAX_ARGS 7

#include "sysent.h"
#include "sysent_shorthand_defs.h"

#define SEN(syscall_name) 0,0
const struct_sysent sysent0[] = {
#include  "syscallent-o32.h"
};

int main(void)
{
    int i;

    for (i = 4000; i < sizeof(sysent0) / sizeof(struct_sysent); i++) {
        if (sysent0[i].sys_name == NULL) {
            printf("    [% 4d] = MIPS_SYSCALL_NUMBER_UNUSED,\n", i - 4000);
        } else {
            printf("    [% 4d] = %d, /* %s */\n", i - 4000,
                   sysent0[i].nargs, sysent0[i].sys_name);
        }
    }

    return 0;
}
EOF

cc -o gen_mips_o32 -I linux/mips -I linux/generic gen_mips_o32.c && ./gen_mips_o32 > "$output/$INC"

rm -fr "$TMP"