* sysdeps/gnu/errlist-compat.awk: Include <bits/wordsize.h> in output.
[glibc.git] / sysdeps / gnu / errlist-compat.awk
blob88b4d4f126e3a422409135744c0fa5cf12e5fb34
1 # awk script to generate errlist-compat.c
2 # Copyright (C) 2002 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
21 # This script takes the Versions file as input and looks for #errlist-compat
22 # magic comments, which have the form:
23 # #errlist-compat NNN
24 # where NNN is the number of elements in the sys_errlist for that version set.
25 # We need the awk variable `maxerr' defined to the current size of sys_errlist.
27 # If there is no magic comment matching the current size, we barf.
28 # Otherwise we generate code (errlist-compat.c) to define all the
29 # necessary compatibility symbols for older, smaller versions of sys_errlist.
32 BEGIN { highest = 0 }
34 # These two rules catch the Versions file contents.
35 NF == 2 && $2 == "{" { last_version = $1; next }
36 $1 == "#errlist-compat" {
37 n = $2 + 0;
38 if (n < 100) {
39 print "*** this line seems bogus:", $0 > "/dev/stderr";
40 exit 1;
42 version[n] = last_version;
43 if (n > highest)
44 highest = n;
45 next;
48 END {
49 count = maxerr + 1;
51 if (highest != count) {
52 printf "*** errlist.c count %d vs Versions sys_errlist@%s count %d\n", \
53 count, version[highest], highest > "/dev/stderr";
54 exit 1;
57 lastv = "";
58 for (n = 0; n <= count; ++n)
59 if (n in version) {
60 v = version[n];
61 gsub(/[^A-Z0-9_]/, "_", v);
62 if (lastv != "")
63 compat[lastv] = v;
64 lastv = v;
65 vcount[v] = n;
68 print "/* This file was generated by errlist-compat.awk; DO NOT EDIT! */\n";
69 print "#include <shlib-compat.h>\n";
71 for (old in compat) {
72 new = compat[old];
73 n = vcount[old];
74 printf "#if SHLIB_COMPAT (libc, %s, %s)\n", old, new;
75 printf "# include <bits/wordsize.h>\n";
76 printf "extern const char *const __sys_errlist_%s[];\n", old;
77 printf "const int __sys_nerr_%s = %d;\n", old, n;
78 printf "strong_alias (_sys_errlist_internal, __sys_errlist_%s)\n", old;
79 printf "declare_symbol (__sys_errlist_%s, object, __WORDSIZE/8*%d)\n", \
80 old, n;
81 printf "compat_symbol (libc, __sys_errlist_%s, sys_errlist, %s);\n", \
82 old, old;
83 printf "compat_symbol (libc, __sys_nerr_%s, sys_nerr, %s);\n", old, old;
85 printf "extern const char *const ___sys_errlist_%s[];\n", old;
86 printf "extern const int __sys_nerr_%s;\n", old;
87 printf "strong_alias (__sys_errlist_%s, ___sys_errlist_%s)\n", old, old;
88 printf "strong_alias (__sys_nerr_%s, ___sys_nerr_%s)\n", old, old;
89 printf "compat_symbol (libc, ___sys_errlist_%s, _sys_errlist, %s);\n", \
90 old, old;
91 printf "compat_symbol (libc, ___sys_nerr_%s, _sys_nerr, %s);\n", old, old;
92 printf "#endif\n\n";
95 printf "\
96 extern const char *const __sys_errlist_internal[];\n\
97 extern const int __sys_nerr_internal;\n\
98 strong_alias (_sys_errlist_internal, __sys_errlist_internal)\n\
99 strong_alias (_sys_nerr_internal, __sys_nerr_internal)\n\
100 versioned_symbol (libc, _sys_errlist_internal, sys_errlist, %s);\n\
101 versioned_symbol (libc, __sys_errlist_internal, _sys_errlist, %s);\n\
102 versioned_symbol (libc, _sys_nerr_internal, sys_nerr, %s);\n\
103 versioned_symbol (libc, __sys_nerr_internal, _sys_nerr, %s);\n", \
104 lastv, lastv, lastv, lastv;