xref: /netbsd-src/lib/libc/arch/or1k/syscallargs.awk (revision abb9139a12332a650defb77c70c46ae7afbc0f2c)
1*abb9139aSmatt# $NetBSD: syscallargs.awk,v 1.1 2014/09/05 18:09:37 matt Exp $
2*abb9139aSmatt#
3*abb9139aSmatt# Copyright (c) 2014 The NetBSD Foundation, Inc.
4*abb9139aSmatt# All rights reserved.
5*abb9139aSmatt#
6*abb9139aSmatt# This code is derived from software contributed to The NetBSD Foundation
7*abb9139aSmatt# by Matt Thomas of 3am Software Foundry.
8*abb9139aSmatt#
9*abb9139aSmatt# Redistribution and use in source and binary forms, with or without
10*abb9139aSmatt# modification, are permitted provided that the following conditions
11*abb9139aSmatt# are met:
12*abb9139aSmatt# 1. Redistributions of source code must retain the above copyright
13*abb9139aSmatt#    notice, this list of conditions and the following disclaimer.
14*abb9139aSmatt# 2. Redistributions in binary form must reproduce the above copyright
15*abb9139aSmatt#    notice, this list of conditions and the following disclaimer in the
16*abb9139aSmatt#    documentation and/or other materials provided with the distribution.
17*abb9139aSmatt#
18*abb9139aSmatt# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19*abb9139aSmatt# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20*abb9139aSmatt# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*abb9139aSmatt# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22*abb9139aSmatt# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*abb9139aSmatt# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*abb9139aSmatt# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*abb9139aSmatt# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*abb9139aSmatt# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*abb9139aSmatt# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*abb9139aSmatt# POSSIBILITY OF SUCH DAMAGE.
29*abb9139aSmatt
30*abb9139aSmattBEGIN {
31*abb9139aSmatt}
32*abb9139aSmatt
33*abb9139aSmatt/#define.SYS_MAXSYS.*/ { next; }
34*abb9139aSmatt
35*abb9139aSmatt/#define.SYS_.*/ {
36*abb9139aSmatt	x = substr($2, 5);
37*abb9139aSmatt	syscall[x] = "0";
38*abb9139aSmatt}
39*abb9139aSmatt
40*abb9139aSmatt/^check_syscall_args/ {
41*abb9139aSmatt	l = length() - 20;
42*abb9139aSmatt	x = substr($0, 20, l);
43*abb9139aSmatt	y = gensub("sys_", "", 1, x);
44*abb9139aSmatt	syscall[y] = sprintf("sizeof(struct %s_args) / sizeof(register_t)", x);
45*abb9139aSmatt}
46*abb9139aSmatt
47*abb9139aSmattEND {
48*abb9139aSmatt	print "include <sys/types.h>"
49*abb9139aSmatt	print "include <sys/lwp.h>"
50*abb9139aSmatt	print "include <sys/ucontext.h>"
51*abb9139aSmatt	print "include <sys/syscallargs.h>"
52*abb9139aSmatt	print;
53*abb9139aSmatt	for (i in syscall) {
54*abb9139aSmatt		printf "define NSYSARGS_%s %s\n", i, syscall[i];
55*abb9139aSmatt	}
56*abb9139aSmatt}
57