]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/syscalls/update-freebsd.sh
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / syscalls / update-freebsd.sh
CommitLineData
64fdde09
JB
1#! /bin/sh
2
4a94e368 3# Copyright (C) 2018-2022 Free Software Foundation, Inc.
64fdde09
JB
4#
5# This file is part of GDB.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20# Usage: update-freebsd.sh <path-to-syscall.h>
21# Update the freebsd.xml file.
22#
23# FreeBSD uses the same list of system calls on all architectures.
24# The list is defined in the sys/kern/syscalls.master file in the
25# FreeBSD source tree. This file is used as an input to generate
26# several files that are also stored in FreeBSD's source tree. This
27# script parses one of those generated files (sys/sys/syscall.h)
28# rather than syscalls.master as syscall.h is easier to parse.
29
30if [ $# -ne 1 ]; then
31 echo "Error: Path to syscall.h missing. Aborting."
0cf82b81 32 echo "Usage: update-freebsd.sh <path-to-syscall.h>"
64fdde09
JB
33 exit 1
34fi
35
36cat > freebsd.xml.tmp <<EOF
37<?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*- -->
38<!-- vi:set ro: -->
0cf82b81 39<!-- Copyright (C) 2009-2020 Free Software Foundation, Inc.
64fdde09
JB
40
41 Copying and distribution of this file, with or without modification,
42 are permitted in any medium without royalty provided the copyright
43 notice and this notice are preserved. -->
44
45<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
46
47<!-- This file was generated using the following file:
48
49 /usr/src/sys/sys/syscall.h
50
51 The file mentioned above belongs to the FreeBSD Kernel. -->
52
53<syscalls_info>
54EOF
55
56awk '
57/MAXSYSCALL/ {
58 next
59}
60/^#define/ {
61 sub(/^SYS_/,"",$2);
62 printf " <syscall name=\"%s\" number=\"%s\"", $2, $3
63 if (sub(/^freebsd[0-9]*_/,"",$2) != 0)
64 printf " alias=\"%s\"", $2
65 printf "/>\n"
66}
67/\/\* [0-9]* is obsolete [a-z_]* \*\// {
68 printf " <syscall name=\"%s\" number=\"%s\"/>\n", $5, $2
69}
70/\/\* [0-9]* is freebsd[0-9]* [a-z_]* \*\// {
71 printf " <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5
a55e30b5 72}' "$1" >> freebsd.xml.tmp
64fdde09
JB
73
74cat >> freebsd.xml.tmp <<EOF
75</syscalls_info>
76EOF
77
78../../move-if-change freebsd.xml.tmp freebsd.xml