glibc/sysdeps/gnu/errlist-compat.awk

130 lines
4.6 KiB
Awk
Raw Normal View History

# awk script to generate errlist-compat.c
# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
#
# This script takes the Versions file as input and looks for #errlist-compat
# magic comments, which have the form:
# #errlist-compat NNN
# where NNN is the number of elements in the sys_errlist for that version set.
# We need the awk variable `maxerr' defined to the current size of sys_errlist.
#
# If there is no magic comment matching the current size, we barf.
# Otherwise we generate code (errlist-compat.c) to define all the
# necessary compatibility symbols for older, smaller versions of sys_errlist.
#
# These two rules catch the Versions file contents.
NF == 2 && $2 == "{" { last_version = $1; next }
$1 == "#errlist-compat" {
Update. * sysdeps/generic/ldsodefs.h (__rtld_global_attribute__): Define. (_rtld_global): Use it. * sysdeps/gnu/Dist: Remove errlist-compat.c. * sysdeps/gnu/Makefile (errlist-compat.c): Build this file in the object directory. Pass all Versions files to the awk script. * sysdeps/gnu/errlist-compat.c: Removed. * sysdeps/gnu/errlist.awk: Use #errlist-compat comments from the first Versions file in the search path which has them. Allow multiple errlist symbol versions to have the same count of errors. * sysdeps/gnu/errlist-compat.awk: Include <errlist-compat.c> instead of "errlist-compat.c". * sysdeps/gnu/errlist.c: Regenerated. * sysdeps/unix/sysv/linux/mips/Versions (libc): Add #errlist-compat comments at GLIBC_2.0, GLIBC_2.1 and GLIBC_2.3. * sysdeps/unix/sysv/linux/alpha/Versions: Likewise. (librt): Add aio_cancel and aio_cancel64 as GLIBC_2.3. * sysdeps/unix/sysv/linux/hppa/Versions: Likewise. * sysdeps/unix/sysv/linux/sparc/Versions: New file. * sysdeps/unix/sysv/linux/alpha/bits/errno.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/errno.h (ECANCELED): Define to ECANCELLED if not defined by kernel headers. * sysdeps/unix/sysv/linux/bits/errno.h: Don't redefine ECANCELED if already defined by kernel headers. * sysdeps/unix/sysv/linux/sparc/bits/errno.h: New file. * sysdeps/pthread/aio_cancel.c: Don't include aio.h and its aio_cancel64 renaming hack nor provide weak_alias if aio_cancel is a macro. * Versions.def (GLIBC_2.3) [librt]: Add. * sysdeps/unix/sysv/linux/alpha/pipe.S: New file. 2002-08-28 Ulrich Drepper <drepper@redhat.com> * include/libc-symbols.h [!__ASSEMBLER__] (declare_symbol_1): Add missing comma to .type directive. 2002-08-28 Jakub Jelinek <jakub@redhat.com>
2002-08-29 02:34:10 +02:00
# Don't process any further Versions files
ARGC = ARGIND + 1;
cnt = $2 + 0;
if (cnt < 100) {
print "*** this line seems bogus:", $0 > "/dev/stderr";
exit 1;
}
Update. * sysdeps/generic/ldsodefs.h (__rtld_global_attribute__): Define. (_rtld_global): Use it. * sysdeps/gnu/Dist: Remove errlist-compat.c. * sysdeps/gnu/Makefile (errlist-compat.c): Build this file in the object directory. Pass all Versions files to the awk script. * sysdeps/gnu/errlist-compat.c: Removed. * sysdeps/gnu/errlist.awk: Use #errlist-compat comments from the first Versions file in the search path which has them. Allow multiple errlist symbol versions to have the same count of errors. * sysdeps/gnu/errlist-compat.awk: Include <errlist-compat.c> instead of "errlist-compat.c". * sysdeps/gnu/errlist.c: Regenerated. * sysdeps/unix/sysv/linux/mips/Versions (libc): Add #errlist-compat comments at GLIBC_2.0, GLIBC_2.1 and GLIBC_2.3. * sysdeps/unix/sysv/linux/alpha/Versions: Likewise. (librt): Add aio_cancel and aio_cancel64 as GLIBC_2.3. * sysdeps/unix/sysv/linux/hppa/Versions: Likewise. * sysdeps/unix/sysv/linux/sparc/Versions: New file. * sysdeps/unix/sysv/linux/alpha/bits/errno.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/errno.h (ECANCELED): Define to ECANCELLED if not defined by kernel headers. * sysdeps/unix/sysv/linux/bits/errno.h: Don't redefine ECANCELED if already defined by kernel headers. * sysdeps/unix/sysv/linux/sparc/bits/errno.h: New file. * sysdeps/pthread/aio_cancel.c: Don't include aio.h and its aio_cancel64 renaming hack nor provide weak_alias if aio_cancel is a macro. * Versions.def (GLIBC_2.3) [librt]: Add. * sysdeps/unix/sysv/linux/alpha/pipe.S: New file. 2002-08-28 Ulrich Drepper <drepper@redhat.com> * include/libc-symbols.h [!__ASSEMBLER__] (declare_symbol_1): Add missing comma to .type directive. 2002-08-28 Jakub Jelinek <jakub@redhat.com>
2002-08-29 02:34:10 +02:00
version[pos + 0] = cnt SUBSEP last_version;
pos++;
if (cnt < highest) {
printf "*** %s #errlist-compat counts are not sorted\n", ARGV[ARGIND];
exit 1;
}
if (cnt > highest)
highest = cnt;
highest_version = last_version;
next;
}
END {
if (! highest_version) {
print "/* No sys_errlist/sys_nerr symbols defined on this platform. */";
exit 0;
}
count = maxerr + 1;
if (highest < count) {
printf "*** errlist.c count %d vs Versions sys_errlist@%s count %d\n", \
Update. * sysdeps/generic/ldsodefs.h (__rtld_global_attribute__): Define. (_rtld_global): Use it. * sysdeps/gnu/Dist: Remove errlist-compat.c. * sysdeps/gnu/Makefile (errlist-compat.c): Build this file in the object directory. Pass all Versions files to the awk script. * sysdeps/gnu/errlist-compat.c: Removed. * sysdeps/gnu/errlist.awk: Use #errlist-compat comments from the first Versions file in the search path which has them. Allow multiple errlist symbol versions to have the same count of errors. * sysdeps/gnu/errlist-compat.awk: Include <errlist-compat.c> instead of "errlist-compat.c". * sysdeps/gnu/errlist.c: Regenerated. * sysdeps/unix/sysv/linux/mips/Versions (libc): Add #errlist-compat comments at GLIBC_2.0, GLIBC_2.1 and GLIBC_2.3. * sysdeps/unix/sysv/linux/alpha/Versions: Likewise. (librt): Add aio_cancel and aio_cancel64 as GLIBC_2.3. * sysdeps/unix/sysv/linux/hppa/Versions: Likewise. * sysdeps/unix/sysv/linux/sparc/Versions: New file. * sysdeps/unix/sysv/linux/alpha/bits/errno.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/errno.h (ECANCELED): Define to ECANCELLED if not defined by kernel headers. * sysdeps/unix/sysv/linux/bits/errno.h: Don't redefine ECANCELED if already defined by kernel headers. * sysdeps/unix/sysv/linux/sparc/bits/errno.h: New file. * sysdeps/pthread/aio_cancel.c: Don't include aio.h and its aio_cancel64 renaming hack nor provide weak_alias if aio_cancel is a macro. * Versions.def (GLIBC_2.3) [librt]: Add. * sysdeps/unix/sysv/linux/alpha/pipe.S: New file. 2002-08-28 Ulrich Drepper <drepper@redhat.com> * include/libc-symbols.h [!__ASSEMBLER__] (declare_symbol_1): Add missing comma to .type directive. 2002-08-28 Jakub Jelinek <jakub@redhat.com>
2002-08-29 02:34:10 +02:00
count, highest_version, highest > "/dev/stderr";
exit 1;
}
lastv = "";
Update. * sysdeps/generic/ldsodefs.h (__rtld_global_attribute__): Define. (_rtld_global): Use it. * sysdeps/gnu/Dist: Remove errlist-compat.c. * sysdeps/gnu/Makefile (errlist-compat.c): Build this file in the object directory. Pass all Versions files to the awk script. * sysdeps/gnu/errlist-compat.c: Removed. * sysdeps/gnu/errlist.awk: Use #errlist-compat comments from the first Versions file in the search path which has them. Allow multiple errlist symbol versions to have the same count of errors. * sysdeps/gnu/errlist-compat.awk: Include <errlist-compat.c> instead of "errlist-compat.c". * sysdeps/gnu/errlist.c: Regenerated. * sysdeps/unix/sysv/linux/mips/Versions (libc): Add #errlist-compat comments at GLIBC_2.0, GLIBC_2.1 and GLIBC_2.3. * sysdeps/unix/sysv/linux/alpha/Versions: Likewise. (librt): Add aio_cancel and aio_cancel64 as GLIBC_2.3. * sysdeps/unix/sysv/linux/hppa/Versions: Likewise. * sysdeps/unix/sysv/linux/sparc/Versions: New file. * sysdeps/unix/sysv/linux/alpha/bits/errno.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/errno.h (ECANCELED): Define to ECANCELLED if not defined by kernel headers. * sysdeps/unix/sysv/linux/bits/errno.h: Don't redefine ECANCELED if already defined by kernel headers. * sysdeps/unix/sysv/linux/sparc/bits/errno.h: New file. * sysdeps/pthread/aio_cancel.c: Don't include aio.h and its aio_cancel64 renaming hack nor provide weak_alias if aio_cancel is a macro. * Versions.def (GLIBC_2.3) [librt]: Add. * sysdeps/unix/sysv/linux/alpha/pipe.S: New file. 2002-08-28 Ulrich Drepper <drepper@redhat.com> * include/libc-symbols.h [!__ASSEMBLER__] (declare_symbol_1): Add missing comma to .type directive. 2002-08-28 Jakub Jelinek <jakub@redhat.com>
2002-08-29 02:34:10 +02:00
for (n = 0; n < pos; ++n) {
split(version[n], t, SUBSEP)
v = t[2];
gsub(/[^A-Z0-9_]/, "_", v);
if (lastv != "")
compat[lastv] = v;
lastv = v;
vcount[v] = t[1];
}
print "/* This file was generated by errlist-compat.awk; DO NOT EDIT! */\n";
print "#include <shlib-compat.h>\n";
if (highest > count) {
printf "*** errlist.c count %d inflated to %s count %d (old errno.h?)\n", \
count, highest_version, highest > "/dev/stderr";
printf "#define ERR_MAX %d\n\n", highest;
}
for (old in compat) {
new = compat[old];
n = vcount[old];
printf "#if SHLIB_COMPAT (libc, %s, %s)\n", old, new;
printf "# include <bits/wordsize.h>\n";
printf "extern const char *const __sys_errlist_%s[%d];\n", old, n;
printf "const int __sys_nerr_%s = %d;\n", old, n;
printf "strong_alias (_sys_errlist_internal, __sys_errlist_%s)\n", old;
printf "declare_symbol (__sys_errlist_%s, object, __WORDSIZE/8*%d)\n", \
old, n;
printf "compat_symbol (libc, __sys_errlist_%s, sys_errlist, %s);\n", \
old, old;
printf "compat_symbol (libc, __sys_nerr_%s, sys_nerr, %s);\n", old, old;
printf "extern const char *const ___sys_errlist_%s[%d];\n", old, n;
printf "extern const int __sys_nerr_%s;\n", old;
printf "strong_alias (__sys_errlist_%s, ___sys_errlist_%s)\n", old, old;
printf "strong_alias (__sys_nerr_%s, ___sys_nerr_%s)\n", old, old;
printf "compat_symbol (libc, ___sys_errlist_%s, _sys_errlist, %s);\n", \
old, old;
printf "compat_symbol (libc, ___sys_nerr_%s, _sys_nerr, %s);\n", old, old;
printf "#endif\n\n";
}
printf "\
extern const char *const __sys_errlist_internal[NERR];\n\
extern const int __sys_nerr_internal;\n\
strong_alias (_sys_errlist_internal, __sys_errlist_internal)\n\
strong_alias (_sys_nerr_internal, __sys_nerr_internal)\n\
extern const char *const sys_errlist[NERR];\n\
versioned_symbol (libc, _sys_errlist_internal, sys_errlist, %s);\n\
versioned_symbol (libc, __sys_errlist_internal, _sys_errlist, %s);\n\
versioned_symbol (libc, _sys_nerr_internal, sys_nerr, %s);\n\
versioned_symbol (libc, __sys_nerr_internal, _sys_nerr, %s);\n", \
lastv, lastv, lastv, lastv;
print "\n\
link_warning (sys_errlist, \"\
`sys_errlist' is deprecated; use `strerror' or `strerror_r' instead\")\n\
link_warning (sys_nerr, \"\
`sys_nerr' is deprecated; use `strerror' or `strerror_r' instead\")";
}