1#!/usr/bin/perl
2# This file is part of ltrace.
3# Copyright (C) 2006 Heiko Carstens, IBM Corporation
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2 of the
8# License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18# 02110-1301 USA
19
20#
21# Generate syscall table for s390/s390x
22#
23# Use this on arch/s390/kernel/syscall.s after removing the first few
24# nonsyscall lines.
25#
26# cat syscall.s | mksyscallent_s390 > syscalls31.h
27# cat syscall.s | mksyscallent_s390 -x > syscalls64.h
28#
29
30use Getopt::Std;
31use integer;
32getopts('x');
33$i = 0;
34$s390x = 0;
35$opt_x and $s390x = 1;
36
37while (<>) {
38	chomp;
39
40	if ($s390x==1) {
41		   s/^SYSCALL\([^,]*,//;
42	} else {
43	           s/^SYSCALL\(//;
44	}
45
46	s/,.*//;
47	s/^sys_//;
48	s/^s390[x]*_//;
49	s/_glue$//;
50	s/^ni_syscall.*/$i/i;
51	$len = 32 - length();
52	$tab = $len / 8;
53	$space = $len % 8;
54	print "    \"$_\"," ," " x $space , "\t" x $tab, " \/* $i \*\/\n";
55	$i++;
56}
57