1 #!/bin/sh
2 # $NetBSD: makemachservices.sh,v 1.7 2005/12/11 12:20:20 christos Exp $
3 #
4 # Copyright (c) 2003 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by Emmanuel Dreyfus.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. All advertising materials mentioning features or use of this software
18 # must display the following acknowledgement:
19 # This product includes software developed by the NetBSD
20 # Foundation, Inc. and its contributors.
21 # 4. The name of the author may not be used to endorse or promote products
22 # derived from this software without specific prior written permission
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35 master="mach_services.master"
36 table="mach_services.c"
37 headers="mach_services.h"
38 names="mach_services_names.c"
39
40 sed -e '
41 :join
42 /\\$/{a\
43
44 N
45 s/\\\n//
46 b join
47 }
48 ' $master | awk '
49 BEGIN{
50 intable = 0;
51 table = "'$table'";
52 headers = "'$headers'";
53 names = "'$names'";
54
55 printf("/* \$NetBSD\$ *\/\n\n") > table;
56 printf("/*\n * Mach services table.\n *\n") > table;
57 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
58 table;
59
60 printf("/* \$NetBSD\$ *\/\n\n") > headers;
61 printf("/*\n * Mach services prototypes.\n *\n") > headers;
62 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
63 headers;
64
65 printf("/* \$NetBSD\$ *\/\n\n") > names;
66 printf("/*\n * Mach services names. This file is not built\n") > names;
67 printf(" * by the kernel, it is included by kdump sources.\n *\n") > \
68 names;
69 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
70 names;
71 }
72 (NR == 1) {
73 gsub(/^[^\$]*\$/, "", $0);
74 gsub(/\$.*$/, "", $0);
75 sub(/ $/, "");
76 printf(" * created from %s\n */\n\n", $0) > table;
77 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
78 "\"\$NetBSD\$\");\n\n") > table;
79
80 printf(" * created from %s\n */\n\n", $0) > headers;
81 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
82 "\"\$NetBSD\$\");\n\n") > headers;
83 printf("#include <compat/mach/mach_types.h>\n") > headers;
84 printf("#include <compat/mach/mach_message.h>\n") > headers;
85
86 printf(" * created from %s\n */\n\n", $0) > names;
87 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
88 "\"\$NetBSD\$\");\n\n") > names;
89 printf("struct mach_service_name {\n") > names;
90 printf(" int srv_id;\n") > names;
91 printf(" const char *srv_name;\n") > names;
92 printf("};\n\n") > names;
93 next;
94 }
95 (NF == 0 || $1 ~ /^;/) {
96 next;
97 }
98 ($0 ~ /^%%$/) {
99 intable = 1;
100 printf("\nstruct mach_service mach_services_table[] = {\n") > table;
101 printf("\n") > headers;
102 printf("struct mach_service_name mach_services_names[] = {\n") > names;
103 next;
104 }
105 (!intable) {
106 printf("%s\n", $0) > table;
107 next;
108 }
109 (intable && $2 == "STD") {
110 printf(" {%d, mach_%s, \"%s\", " \
111 "sizeof(mach_%s_request_t), sizeof(mach_%s_reply_t)},\n", \
112 $1, $3, $3, $3, $3) > table;
113 printf("int mach_%s(struct mach_trap_args *);\n", $3) > headers;
114 printf(" {%d, \"%s\"},\n", $1, $3) > names;
115 }
116 (intable && $2 == "NODEF") {
117 printf(" {%d, NULL, \"%s\", 0, 0},\n", \
118 $1, $3, $3, $3, $3) > table;
119 printf(" {%d, \"%s\"},\n", $1, $3) > names;
120 }
121 (intable && $2 == "UNIMPL") {
122 printf(" {%d, NULL, \"unimpl. %s\", 0, 0},\n", \
123 $1, $3, $3, $3, $3) > table;
124 printf(" {%d, \"unimpl. %s\"},\n", $1, $3) > names;
125 }
126 (intable && $2 == "OBSOL") {
127 printf(" {%d, NULL, \"obsolete %s\", 0, 0},\n", \
128 $1, $3, $3, $3, $3) > table;
129 printf(" {%d, \"obsolete %s\"},\n", $1, $3) > names;
130 }
131 END {
132 printf(" {0, NULL, NULL, 0, 0}\n") > table;
133 printf("};\n") > table;
134
135 printf(" {0, NULL}\n") > names;
136 printf("};\n") > names;
137 }
138 '
Cache object: 4dcd01c23beb60d665dab2eb8c86c982
|