aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-04-07 09:21:28 +0000
committerUlrich Drepper <drepper@redhat.com>1998-04-07 09:21:28 +0000
commit4bca4c174852bfc348f99e85684fc8f65631d125 (patch)
treea5779cb83844d32d94557e4b8613278d7d877c9b
parent91641c65220646ae2ad8b4ec6972adc7e6720d36 (diff)
downloadglibc-4bca4c174852bfc348f99e85684fc8f65631d125.tar
glibc-4bca4c174852bfc348f99e85684fc8f65631d125.tar.gz
glibc-4bca4c174852bfc348f99e85684fc8f65631d125.tar.bz2
glibc-4bca4c174852bfc348f99e85684fc8f65631d125.zip
Update.
1998-04-07 08:51 Ulrich Drepper <drepper@cygnus.com> * iconv/gconv.c: Take care for NULL arguments. * iconv/gconv_dl.c: Make find_func function global. * iconv/gconv_int.h: Add prototype for __gconv_find_func. Add prototypes for ASCII conversion functions. * iconv/gconv_simple.c: Add ASCII conversion functions. * locale/C-ctype.c: Correct charset name. * wcsmbs/Makefile (distribute): Add wcsmbsload.h. (routines): Remove wmemrtowcs and wmemrtombs, add wcsnlen and wcsmbsload. * wcsmbs/btowc.c: Rewrite to use iconv functionality. * wcsmbs/mbrtowc.c: Likewise. * wcsmbs/mbsnrtowcs.c: Likewise. * wcsmbs/mbsrtowcs.c: Likewise. * wcsmbs/wcrtomb.c: Likewise. * wcsmbs/wcsnrtombs.c: Likewise. * wcsmbs/wcsrtombs.c: Likewise. * wcsmbs/wctob.c: Likewise. * wcsmbs/wchar.h: Add prototype for __wcslen, wcsnlen. Remove prototypes for wmemr*. * wcsmbs/wcslen.c: Rename to __wcslen and make wcslen weak alias. * wcsmbs/wcsnlen.c: New file. * wcsmbs/wcsmbsload.c: New file. * wcsmbs/wcsmbsload.h: New file. * manual/filesys.texi: Mention risks of tmpnam and mktemp. * manual/install.texi: Describe some more critical points. * string/string.h: Add prototype for __strnlen. * string/strnlen.c: Rename to __strnlen and make strnlen weak alias. * sysdeps/posix/mktemp.c: Rewrite to allow many more files and much less predictable names. * sysdeps/posix/mkstemp.c: Likewise. 1998-04-05 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/libc.texinfo (Top): Change "file namespace" to "local namespace". * manual/socket.texi: Change file namespace to local namespace. (Out-of-Band Data): Remove unneeded variable link. (Host Address Functions): Use uint32_t consequently and add a number of clarifications for IPv4/IPv6, classless addresses. (Internet Namespace): Added some paragraphs about IPv6. Based on suggestions by Francesco Potorti` <F.Potorti@cnuce.cnr.it>. 1998-04-05 Philip Blundell <Philip.Blundell@pobox.com> Update for draft-ietf-ipngwg-bsd-api-new-01.txt: * resolv/netdb.h (getnameinfo): Use `socklen_t' not `size_t'. (NI_NUMERICHOST, et al.): Tidy up and add comments. (AI_NUMERICHOST): Define. (getnodebyname): New prototype. (AI_V4MAPPED, et al.): New constants. * sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h (SA_LEN): New macro.< * sysdeps/generic/bits/sockaddr.h (SA_LEN): Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add sa_len for socket. * sysdeps/unix/sysv/linux/sa_len.c: New file. * sysdeps/unix/sysv/linux/Dist: Add sa_len.c. * sysdeps/unix/sysv/linux/bits/socket.h: Make multiple #inclusion safe. * sysdeps/generic/bits/sockunion.h: New file, defining sockaddr_union. * sysdeps/unix/sysv/linux/bits/sockunion.h: Likewise. * socket/Makefile (headers): Add bits/sockunion.h. * socket/sys/socket.h: Include <bits/sockunion.h> * inet/netinet/in.h: Include <bits/sockaddr.h> rather than <sys/socket.h>, to avoid getting sockaddr_union defined. * sysdeps/generic/bits/socket.h: Allow inclusion from netinet.in.h. * sysdeps/unix/sysv/linux/bits/socket.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/socket.h: Likewise. * sysdeps/unix/sysv/linux/if_index.c: Remove use of SIOCGIFCOUNT (2.2.x kernels won't have it). 1998-04-06 21:21 Ulrich Drepper <drepper@cygnus.com> * sysdeps/mach/hurd/bits/ioctls.h: Allow inclusion from hurd/ioctl.h. * sysdeps/mach/hurd/dl-sysdep.c: Use __ptr_t not caddr_t. * iconv/gconv_conf.c: Define MAXPATHLEN if not available before. Patches by UCHIYAMA Yasushi <uch@nop.or.jp>. 1998-04-05 Philip Blundell <Philip.Blundell@pobox.com> * manual/socket.texi (Socket Addresses): Fix a typo. (Interface Naming): New section. 1998-04-05 23:29 Zack Weinberg <zack@rabi.phys.columbia.edu> * configure.in: Check for CC using $ac_tool_prefix, to handle cross-compilation. Use AC_CHECK_TOOL to find MiG. * config.make.in: Add MIG to be substituted. * mach/Machrules: Don't define MIG variable. Patch by Gordon Matzigkeit <gord@profitpress.com>. 1998-04-05 Mark Kettenis <kettenis@phys.uva.nl> * elf/dl-load.c (decompose_rpath): Use local_strdup instead of strdupa to copy rpath. 1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * configure.in: Fix gcc version check. * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less confusing. 1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * configure.in: Fix gcc version check. * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less confusing. 1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * configure.in: Fix gcc version check. * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less confusing. 1998-03-31 Mark Kettenis <kettenis@phys.uva.nl> * sysdeps/unix/bsd/unlockpt.c (unlockpt): Call __ptsname_r instead of ptsname_r. * stdlib/stdlib.h: Change prototype of ptsname_r to make it more like ttyname_r. * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Likewise. * sysdeps/generic/ptsname.c (__ptsname_r): Likewise. * sysdeps/unix/grantpt.c (grantpt): Change check of return value of __ptsname_r accordingly. * login/openpty.c (openpty): Likewise. 1998-06-04 18:47 H.J. Lu <hjl@gnu.org> * libio/fileops.c (_IO_file_xsgetn): Adjust pointers. 1998-04-06 13:58 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig (libtypes): Redo H.J. Lu's change of 1998-03-27. * Makerules: Readd missing rule for $(objpfx)stamp.oS. 1998-04-06 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/ypclnt.c: Don't give YPERR_RPC back, use the do_ypcall return value for better error checking.
-rw-r--r--ChangeLog156
-rw-r--r--Makerules7
-rw-r--r--aclocal.m461
-rw-r--r--bits/sockaddr.h5
-rw-r--r--bits/socket.h4
-rw-r--r--config.make.in1
-rwxr-xr-xconfigure486
-rw-r--r--configure.in21
-rw-r--r--elf/dl-load.c2
-rw-r--r--iconv/gconv.c17
-rw-r--r--iconv/gconv_conf.c4
-rw-r--r--iconv/gconv_dl.c12
-rw-r--r--iconv/gconv_int.h6
-rw-r--r--iconv/gconv_simple.c228
-rw-r--r--inet/netinet/in.h2
-rw-r--r--libio/fileops.c12
-rw-r--r--linuxthreads/Makefile2
-rw-r--r--locale/C-ctype.c4
-rw-r--r--login/openpty.c2
-rw-r--r--mach/Machrules5
-rw-r--r--manual/filesys.texi14
-rw-r--r--manual/install.texi19
-rw-r--r--manual/libc.texinfo10
-rw-r--r--manual/socket.texi469
-rw-r--r--nis/ypclnt.c20
-rw-r--r--resolv/netdb.h29
-rw-r--r--socket/Makefile5
-rw-r--r--socket/sys/socket.h3
-rw-r--r--stdlib/stdlib.h14
-rw-r--r--string/string.h1
-rw-r--r--string/strnlen.c5
-rw-r--r--sysdeps/generic/bits/sockaddr.h5
-rw-r--r--sysdeps/generic/bits/socket.h4
-rw-r--r--sysdeps/generic/bits/sockunion.h40
-rw-r--r--sysdeps/generic/ptsname.c9
-rw-r--r--sysdeps/mach/hurd/bits/ioctls.h6
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c6
-rw-r--r--sysdeps/posix/mkstemp.c42
-rw-r--r--sysdeps/posix/mktemp.c46
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h4
-rw-r--r--sysdeps/unix/bsd/unlockpt.c2
-rw-r--r--sysdeps/unix/grantpt.c4
-rw-r--r--sysdeps/unix/sysv/linux/Dist1
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/arm/profil-counter.h51
-rw-r--r--sysdeps/unix/sysv/linux/bits/socket.h7
-rw-r--r--sysdeps/unix/sysv/linux/bits/sockunion.h46
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c44
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/socket.h2
-rw-r--r--sysdeps/unix/sysv/linux/ptsname.c84
-rw-r--r--sysdeps/unix/sysv/linux/sa_len.c46
-rw-r--r--wcsmbs/Makefile9
-rw-r--r--wcsmbs/btowc.c46
-rw-r--r--wcsmbs/mbrtowc.c144
-rw-r--r--wcsmbs/mbsnrtowcs.c193
-rw-r--r--wcsmbs/mbsrtowcs.c172
-rw-r--r--wcsmbs/wchar.h29
-rw-r--r--wcsmbs/wcrtomb.c109
-rw-r--r--wcsmbs/wcslen.c5
-rw-r--r--wcsmbs/wcsmbsload.c132
-rw-r--r--wcsmbs/wcsmbsload.h52
-rw-r--r--wcsmbs/wcsnlen.c44
-rw-r--r--wcsmbs/wcsnrtombs.c155
-rw-r--r--wcsmbs/wcsrtombs.c157
-rw-r--r--wcsmbs/wctob.c41
65 files changed, 2269 insertions, 1096 deletions
diff --git a/ChangeLog b/ChangeLog
index 835f751cbb..f677d89046 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,159 @@
+1998-04-07 08:51 Ulrich Drepper <drepper@cygnus.com>
+
+ * iconv/gconv.c: Take care for NULL arguments.
+ * iconv/gconv_dl.c: Make find_func function global.
+ * iconv/gconv_int.h: Add prototype for __gconv_find_func.
+ Add prototypes for ASCII conversion functions.
+ * iconv/gconv_simple.c: Add ASCII conversion functions.
+ * locale/C-ctype.c: Correct charset name.
+
+ * wcsmbs/Makefile (distribute): Add wcsmbsload.h.
+ (routines): Remove wmemrtowcs and wmemrtombs, add wcsnlen and
+ wcsmbsload.
+ * wcsmbs/btowc.c: Rewrite to use iconv functionality.
+ * wcsmbs/mbrtowc.c: Likewise.
+ * wcsmbs/mbsnrtowcs.c: Likewise.
+ * wcsmbs/mbsrtowcs.c: Likewise.
+ * wcsmbs/wcrtomb.c: Likewise.
+ * wcsmbs/wcsnrtombs.c: Likewise.
+ * wcsmbs/wcsrtombs.c: Likewise.
+ * wcsmbs/wctob.c: Likewise.
+ * wcsmbs/wchar.h: Add prototype for __wcslen, wcsnlen. Remove
+ prototypes for wmemr*.
+ * wcsmbs/wcslen.c: Rename to __wcslen and make wcslen weak alias.
+ * wcsmbs/wcsnlen.c: New file.
+ * wcsmbs/wcsmbsload.c: New file.
+ * wcsmbs/wcsmbsload.h: New file.
+
+ * manual/filesys.texi: Mention risks of tmpnam and mktemp.
+
+ * manual/install.texi: Describe some more critical points.
+
+ * string/string.h: Add prototype for __strnlen.
+ * string/strnlen.c: Rename to __strnlen and make strnlen weak alias.
+
+ * sysdeps/posix/mktemp.c: Rewrite to allow many more files and
+ much less predictable names.
+ * sysdeps/posix/mkstemp.c: Likewise.
+
+1998-04-05 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * manual/libc.texinfo (Top): Change "file namespace" to "local
+ namespace".
+
+ * manual/socket.texi: Change file namespace to local namespace.
+ (Out-of-Band Data): Remove unneeded variable link.
+ (Host Address Functions): Use uint32_t consequently and add a
+ number of clarifications for IPv4/IPv6, classless addresses.
+ (Internet Namespace): Added some paragraphs about IPv6.
+ Based on suggestions by Francesco Potorti` <F.Potorti@cnuce.cnr.it>.
+
+1998-04-05 Philip Blundell <Philip.Blundell@pobox.com>
+
+ Update for draft-ietf-ipngwg-bsd-api-new-01.txt:
+
+ * resolv/netdb.h (getnameinfo): Use `socklen_t' not `size_t'.
+ (NI_NUMERICHOST, et al.): Tidy up and add comments.
+ (AI_NUMERICHOST): Define.
+ (getnodebyname): New prototype.
+ (AI_V4MAPPED, et al.): New constants.
+
+ * sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h (SA_LEN): New macro.<
+ * sysdeps/generic/bits/sockaddr.h (SA_LEN): Likewise.
+ * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add sa_len
+ for socket.
+ * sysdeps/unix/sysv/linux/sa_len.c: New file.
+ * sysdeps/unix/sysv/linux/Dist: Add sa_len.c.
+
+ * sysdeps/unix/sysv/linux/bits/socket.h: Make multiple #inclusion safe.
+
+ * sysdeps/generic/bits/sockunion.h: New file, defining sockaddr_union.
+ * sysdeps/unix/sysv/linux/bits/sockunion.h: Likewise.
+ * socket/Makefile (headers): Add bits/sockunion.h.
+ * socket/sys/socket.h: Include <bits/sockunion.h>
+ * inet/netinet/in.h: Include <bits/sockaddr.h> rather than
+ <sys/socket.h>, to avoid getting sockaddr_union defined.
+ * sysdeps/generic/bits/socket.h: Allow inclusion from netinet.in.h.
+ * sysdeps/unix/sysv/linux/bits/socket.h: Likewise.
+ * sysdeps/unix/sysv/linux/mips/bits/socket.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/if_index.c: Remove use of SIOCGIFCOUNT
+ (2.2.x kernels won't have it).
+
+1998-04-06 21:21 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/mach/hurd/bits/ioctls.h: Allow inclusion from hurd/ioctl.h.
+ * sysdeps/mach/hurd/dl-sysdep.c: Use __ptr_t not caddr_t.
+ * iconv/gconv_conf.c: Define MAXPATHLEN if not available before.
+ Patches by UCHIYAMA Yasushi <uch@nop.or.jp>.
+
+1998-04-05 Philip Blundell <Philip.Blundell@pobox.com>
+
+ * manual/socket.texi (Socket Addresses): Fix a typo.
+ (Interface Naming): New section.
+
+1998-04-05 23:29 Zack Weinberg <zack@rabi.phys.columbia.edu>
+
+ * configure.in: Check for CC using $ac_tool_prefix, to handle
+ cross-compilation. Use AC_CHECK_TOOL to find MiG.
+ * config.make.in: Add MIG to be substituted.
+ * mach/Machrules: Don't define MIG variable.
+
+ Patch by Gordon Matzigkeit <gord@profitpress.com>.
+
+1998-04-05 Mark Kettenis <kettenis@phys.uva.nl>
+
+ * elf/dl-load.c (decompose_rpath): Use local_strdup instead of
+ strdupa to copy rpath.
+
+1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in: Fix gcc version check.
+
+ * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less confusing.
+
+1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in: Fix gcc version check.
+
+ * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less
+ confusing.
+
+1998-04-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in: Fix gcc version check.
+
+ * aclocal.m4 (AC_PROG_CHECK_VER): Rewritten to make less
+ confusing.
+
+1998-03-31 Mark Kettenis <kettenis@phys.uva.nl>
+
+ * sysdeps/unix/bsd/unlockpt.c (unlockpt): Call __ptsname_r instead
+ of ptsname_r.
+
+ * stdlib/stdlib.h: Change prototype of ptsname_r to make it more
+ like ttyname_r.
+ * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Likewise.
+ * sysdeps/generic/ptsname.c (__ptsname_r): Likewise.
+ * sysdeps/unix/grantpt.c (grantpt): Change check of return value
+ of __ptsname_r accordingly.
+ * login/openpty.c (openpty): Likewise.
+
+1998-06-04 18:47 H.J. Lu <hjl@gnu.org>
+
+ * libio/fileops.c (_IO_file_xsgetn): Adjust pointers.
+
+1998-04-06 13:58 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makeconfig (libtypes): Redo H.J. Lu's change of 1998-03-27.
+
+ * Makerules: Readd missing rule for $(objpfx)stamp.oS.
+
+1998-04-06 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
+
+ * nis/ypclnt.c: Don't give YPERR_RPC back, use the do_ypcall
+ return value for better error checking.
+
1998-04-06 Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>
* elf/dl-runtime.c (fixup, profile_fixup): The final arg to
diff --git a/Makerules b/Makerules
index 094706bff2..9d0a9faa58 100644
--- a/Makerules
+++ b/Makerules
@@ -582,6 +582,13 @@ touch $@
endef
O%-lib = $(..)$(patsubst %,$(libtype$*),c)
+ifndef static-only-routines
+subdir_lib: $(objpfx)stamp.oS
+$(objpfx)stamp.oS:
+ $(make-target-directory)
+ rm -f $@; > $@
+endif
+
endif
# Rules to update the $(ar-symtab-name) member with ranlib,
diff --git a/aclocal.m4 b/aclocal.m4
index 1bb0b4a92c..c9a1a906f2 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -34,54 +34,31 @@ dnl
dnl Locate a program and check that its version is acceptable.
dnl AC_PROG_CHECK_VER(var, namelist, version-switch,
-dnl [version-extract-regexp], version-glob, fatal)
+dnl [version-extract-regexp], version-glob [, do-if-fail])
AC_DEFUN(AC_CHECK_PROG_VER,
-[# Prepare to iterate over the program-name list.
-set dummy $2; shift
-AC_MSG_CHECKING([for [$]1])
-AC_CACHE_VAL(ac_cv_prog_$1, [dnl
-if test -n "[$]$1"; then
- ac_cv_prog_$1="[$]$1" # Let the user override the test.
+[AC_CHECK_PROGS([$1], [$2])
+if test -z "[$]$1"; then
+ ac_verc_fail=yes
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_word; do
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_$1="$ac_word"
- break
- fi
- done
- test -n "$ac_cv_prog_$1" && break
- done
- IFS="$ac_save_ifs"
-fi])dnl
-if test -z "$ac_cv_prog_$1"; then
- AC_MSG_RESULT(no)
- $1=:
- ac_verc_fail=t; ifelse([$6],,,[ac_verc_fatal=$6])
-else
-# Found it, now check the version.
-ac_word=$ac_cv_prog_$1
-dnl Do this by hand to avoid "(cached) (cached)".
- if test "[$]{ac_cv_prog_$1_ver+set}" != set; then
+ # Found it, now check the version.
+ AC_MSG_CHECKING([version of [$]$1])
changequote(<<,>>)dnl
- ac_cv_prog_$1_ver=`$ac_word $3 2>&1 ifelse(<<$4>>,,,<<| sed -n 's/^.*$4.*$/\1/p'>>)`
- fi
- if test -n "$ac_cv_prog_$1_ver"; then
- case $ac_cv_prog_$1_ver in
- <<$5>>) ac_vers_ok=", ok"; $1=$ac_cv_prog_$1;;
+ ac_prog_version=`<<$>>$1 $3 2>&1 ifelse(<<$4>>,,,
+ <<| sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'>>)`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ <<$5>>)
changequote([,])dnl
- *) ac_vers_ok=", bad"; $1=:
- ac_verc_fail=t; ifelse([$6],,,[ac_verc_fatal=$6]);;
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
esac
- else
- ac_vers_ok="v. ?.??, bad"; $1=:
- ac_verc_fail=t; ifelse([$6],,,[ac_verc_fatal=$6])
- fi
-AC_MSG_RESULT($ac_word $ac_cv_prog_$1_ver$ac_vers_ok)
+ AC_MSG_RESULT([$ac_prog_version])
fi
-AC_SUBST($1)dnl
+ifelse([$6],,,
+[if test $ac_verc_fail = yes; then
+ $6
+fi])
])
dnl These modifications are to allow for an empty cross compiler tree.
diff --git a/bits/sockaddr.h b/bits/sockaddr.h
index 73a0e26ec4..1c523444ba 100644
--- a/bits/sockaddr.h
+++ b/bits/sockaddr.h
@@ -1,5 +1,5 @@
/* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 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
@@ -37,5 +37,8 @@ typedef unsigned short int sa_family_t;
#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))
+/* Return the length of a `sockaddr' structure. */
+#define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
+extern int __libc_sa_len __P ((sa_family_t __af));
#endif /* bits/sockaddr.h */
diff --git a/bits/socket.h b/bits/socket.h
index a2858b8de8..5dc1e65370 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -1,5 +1,5 @@
/* System-specific socket constants and types. Generic/4.3 BSD version.
- Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 94, 95, 96, 97, 98 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
@@ -17,7 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _SYS_SOCKET_H
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
diff --git a/config.make.in b/config.make.in
index 4c989c8335..27d1e6e455 100644
--- a/config.make.in
+++ b/config.make.in
@@ -64,6 +64,7 @@ AR = @AR@
RANLIB = @RANLIB@
MAKEINFO = @MAKEINFO@
AS = $(CC) -c
+MIG = @MIG@
# Installation tools.
INSTALL = @INSTALL@
diff --git a/configure b/configure
index 76bd9e6631..eba8edfc6d 100755
--- a/configure
+++ b/configure
@@ -1187,208 +1187,258 @@ fi
# These programs are version sensitive.
-# Prepare to iterate over the program-name list.
-set dummy gcc cc; shift
-echo $ac_n "checking for $1""... $ac_c" 1>&6
-echo "configure:1194: checking for $1" >&5
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:1192: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`$ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+if test $host != $build; then
+ ac_tool_prefix=${host_alias}-
+else
+ ac_tool_prefix=
+fi
+
+for ac_prog in ${ac_tool_prefix}gcc ${ac_tool_prefix}cc
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1220: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_word; do
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="$ac_word"
- break
- fi
- done
- test -n "$ac_cv_prog_CC" && break
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="$ac_prog"
+ break
+ fi
done
IFS="$ac_save_ifs"
fi
fi
-if test -z "$ac_cv_prog_CC"; then
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
echo "$ac_t""no" 1>&6
- CC=:
- ac_verc_fail=t; ac_verc_fatal=t
+fi
+
+test -n "$CC" && break
+done
+
+if test -z "$CC"; then
+ ac_verc_fail=yes
else
-# Found it, now check the version.
-ac_word=$ac_cv_prog_CC
- if test "${ac_cv_prog_CC_ver+set}" != set; then
- ac_cv_prog_CC_ver=`$ac_word -v 2>&1 | sed -n 's/^.*version \([egcs0-9.-]*\).*$/\1/p'`
- fi
- if test -n "$ac_cv_prog_CC_ver"; then
- case $ac_cv_prog_CC_ver in
- egcs-2.91.*|egcs-2.90.2[789]|egcs-2.90.[3-9][0-9]|2.8.[1-9]*|2.9.[0-9]*) ac_vers_ok=", ok"; CC=$ac_cv_prog_CC;;
- *) ac_vers_ok=", bad"; CC=:
- ac_verc_fail=t; ac_verc_fatal=t;;
+ # Found it, now check the version.
+ echo $ac_n "checking version of $CC""... $ac_c" 1>&6
+echo "configure:1253: checking version of $CC" >&5
+ ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcst0-9.-]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ egcs-2.91.*|egcs-2.90.2[789]|egcs-2.90.[3-9][0-9]|*2.8.[1-9]*|*2.9.[0-9]*)
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
esac
- else
- ac_vers_ok="v. ?.??, bad"; CC=:
- ac_verc_fail=t; ac_verc_fatal=t
- fi
-echo "$ac_t""$ac_word $ac_cv_prog_CC_ver$ac_vers_ok" 1>&6
+ echo "$ac_t""$ac_prog_version" 1>&6
+fi
+if test $ac_verc_fail = yes; then
+ critic_missing=t
fi
-# Prepare to iterate over the program-name list.
-set dummy make gmake; shift
-echo $ac_n "checking for $1""... $ac_c" 1>&6
-echo "configure:1241: checking for $1" >&5
+for ac_prog in make gmake
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1273: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MAKE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MAKE"; then
ac_cv_prog_MAKE="$MAKE" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_word; do
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_MAKE="$ac_word"
- break
- fi
- done
- test -n "$ac_cv_prog_MAKE" && break
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_MAKE="$ac_prog"
+ break
+ fi
done
IFS="$ac_save_ifs"
fi
fi
-if test -z "$ac_cv_prog_MAKE"; then
+MAKE="$ac_cv_prog_MAKE"
+if test -n "$MAKE"; then
+ echo "$ac_t""$MAKE" 1>&6
+else
echo "$ac_t""no" 1>&6
- MAKE=:
- ac_verc_fail=t; ac_verc_fatal=t
+fi
+
+test -n "$MAKE" && break
+done
+
+if test -z "$MAKE"; then
+ ac_verc_fail=yes
else
-# Found it, now check the version.
-ac_word=$ac_cv_prog_MAKE
- if test "${ac_cv_prog_MAKE_ver+set}" != set; then
- ac_cv_prog_MAKE_ver=`$ac_word --version 2>&1 | sed -n 's/^.*version \([0-9][0-9.]*\), by.*$/\1/p'`
- fi
- if test -n "$ac_cv_prog_MAKE_ver"; then
- case $ac_cv_prog_MAKE_ver in
- 3.75 | 3.76.[2-9] | 3.7[789]* | 3.[89]*) ac_vers_ok=", ok"; MAKE=$ac_cv_prog_MAKE;;
- *) ac_vers_ok=", bad"; MAKE=:
- ac_verc_fail=t; ac_verc_fatal=t;;
+ # Found it, now check the version.
+ echo $ac_n "checking version of $MAKE""... $ac_c" 1>&6
+echo "configure:1306: checking version of $MAKE" >&5
+ ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*version \([0-9][0-9.]*\), by.*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 3.75 | 3.76.[1-9] | 3.7[789]* | 3.[89]*)
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
esac
- else
- ac_vers_ok="v. ?.??, bad"; MAKE=:
- ac_verc_fail=t; ac_verc_fatal=t
- fi
-echo "$ac_t""$ac_word $ac_cv_prog_MAKE_ver$ac_vers_ok" 1>&6
+ echo "$ac_t""$ac_prog_version" 1>&6
+fi
+if test $ac_verc_fail = yes; then
+ critic_missing=t
fi
-# Prepare to iterate over the program-name list.
-set dummy msgfmt gmsgfmt; shift
-echo $ac_n "checking for $1""... $ac_c" 1>&6
-echo "configure:1289: checking for $1" >&5
+for ac_prog in msgfmt gmsgfmt
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1327: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MSGFMT"; then
ac_cv_prog_MSGFMT="$MSGFMT" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_word; do
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_MSGFMT="$ac_word"
- break
- fi
- done
- test -n "$ac_cv_prog_MSGFMT" && break
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_MSGFMT="$ac_prog"
+ break
+ fi
done
IFS="$ac_save_ifs"
fi
fi
-if test -z "$ac_cv_prog_MSGFMT"; then
+MSGFMT="$ac_cv_prog_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
echo "$ac_t""no" 1>&6
- MSGFMT=:
- ac_verc_fail=t;
+fi
+
+test -n "$MSGFMT" && break
+done
+
+if test -z "$MSGFMT"; then
+ ac_verc_fail=yes
else
-# Found it, now check the version.
-ac_word=$ac_cv_prog_MSGFMT
- if test "${ac_cv_prog_MSGFMT_ver+set}" != set; then
- ac_cv_prog_MSGFMT_ver=`$ac_word --version 2>&1 | sed -n 's/^.*GNU gettext.*\([0-9][0-9]*\.[0-9]*\).*$/\1/p'`
- fi
- if test -n "$ac_cv_prog_MSGFMT_ver"; then
- case $ac_cv_prog_MSGFMT_ver in
- 0.[1-9][0-9] | [1-9].*) ac_vers_ok=", ok"; MSGFMT=$ac_cv_prog_MSGFMT;;
- *) ac_vers_ok=", bad"; MSGFMT=:
- ac_verc_fail=t; ;;
+ # Found it, now check the version.
+ echo $ac_n "checking version of $MSGFMT""... $ac_c" 1>&6
+echo "configure:1360: checking version of $MSGFMT" >&5
+ ac_prog_version=`$MSGFMT --version 2>&1 | sed -n 's/^.*GNU gettext.*\([0-9][0-9]*\.[0-9]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 0.[1-9][0-9] | [1-9].*)
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
esac
- else
- ac_vers_ok="v. ?.??, bad"; MSGFMT=:
- ac_verc_fail=t;
- fi
-echo "$ac_t""$ac_word $ac_cv_prog_MSGFMT_ver$ac_vers_ok" 1>&6
+ echo "$ac_t""$ac_prog_version" 1>&6
+fi
+if test $ac_verc_fail = yes; then
+ MSGFMT=: aux_missing=t
fi
-# Prepare to iterate over the program-name list.
-set dummy makeinfo; shift
-echo $ac_n "checking for $1""... $ac_c" 1>&6
-echo "configure:1336: checking for $1" >&5
+for ac_prog in makeinfo
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1380: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MAKEINFO"; then
ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_word; do
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_MAKEINFO="$ac_word"
- break
- fi
- done
- test -n "$ac_cv_prog_MAKEINFO" && break
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_MAKEINFO="$ac_prog"
+ break
+ fi
done
IFS="$ac_save_ifs"
fi
fi
-if test -z "$ac_cv_prog_MAKEINFO"; then
+MAKEINFO="$ac_cv_prog_MAKEINFO"
+if test -n "$MAKEINFO"; then
+ echo "$ac_t""$MAKEINFO" 1>&6
+else
echo "$ac_t""no" 1>&6
- MAKEINFO=:
- ac_verc_fail=t;
+fi
+
+test -n "$MAKEINFO" && break
+done
+
+if test -z "$MAKEINFO"; then
+ ac_verc_fail=yes
else
-# Found it, now check the version.
-ac_word=$ac_cv_prog_MAKEINFO
- if test "${ac_cv_prog_MAKEINFO_ver+set}" != set; then
- ac_cv_prog_MAKEINFO_ver=`$ac_word --version 2>&1 | sed -n 's/^.*GNU texinfo \([0-9][0-9.]*\).*$/\1/p'`
- fi
- if test -n "$ac_cv_prog_MAKEINFO_ver"; then
- case $ac_cv_prog_MAKEINFO_ver in
- 3.1[1-9] | 3.[2-9][0-9]) ac_vers_ok=", ok"; MAKEINFO=$ac_cv_prog_MAKEINFO;;
- *) ac_vers_ok=", bad"; MAKEINFO=:
- ac_verc_fail=t; ;;
+ # Found it, now check the version.
+ echo $ac_n "checking version of $MAKEINFO""... $ac_c" 1>&6
+echo "configure:1413: checking version of $MAKEINFO" >&5
+ ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo \([0-9][0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 3.1[1-9] | 3.[2-9][0-9])
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
esac
- else
- ac_vers_ok="v. ?.??, bad"; MAKEINFO=:
- ac_verc_fail=t;
- fi
-echo "$ac_t""$ac_word $ac_cv_prog_MAKEINFO_ver$ac_vers_ok" 1>&6
+ echo "$ac_t""$ac_prog_version" 1>&6
+fi
+if test $ac_verc_fail = yes; then
+ MAKEINFO=: aux_missing=t
fi
-test -n "$ac_verc_fatal" && { echo "configure: error:
+if test -n "$critic_missing"; then
+{ echo "configure: error:
*** Some critical program is missing or too old.
*** Check the INSTALL file for required versions." 1>&2; exit 1; }
+fi
-test -n "$ac_verc_fail" && echo "configure: warning:
+test -n "$aux_missing" && echo "configure: warning:
*** An auxiliary program is missing or too old;
*** some features will be disabled.
*** Check the INSTALL file for required versions." 1>&2
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1392: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1442: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1401,11 +1451,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
-#line 1405 "configure"
+#line 1455 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:1409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -1430,7 +1480,7 @@ else
cross_linkable=yes
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1434: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1484: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_cross'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1442,7 +1492,7 @@ echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1446: checking whether we are using GNU C" >&5
+echo "configure:1496: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1451,7 +1501,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1505: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -1464,7 +1514,7 @@ if test $ac_cv_prog_gcc != yes; then
fi
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1468: checking build system type" >&5
+echo "configure:1518: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -1487,7 +1537,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1491: checking for $ac_word" >&5
+echo "configure:1541: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_BUILD_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1518,7 +1568,7 @@ done
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1522: checking how to run the C preprocessor" >&5
+echo "configure:1572: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1533,13 +1583,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1537 "configure"
+#line 1587 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1543: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1593: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -1550,13 +1600,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1604 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1560: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -1589,7 +1639,7 @@ LD=`$CC -print-file-name=ld`
# Determine whether we are using GNU binutils.
echo $ac_n "checking whether $AS is GNU as""... $ac_c" 1>&6
-echo "configure:1593: checking whether $AS is GNU as" >&5
+echo "configure:1643: checking whether $AS is GNU as" >&5
if eval "test \"`echo '$''{'libc_cv_prog_as_gnu'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1607,7 +1657,7 @@ rm -f a.out
gnu_as=$libc_cv_prog_as_gnu
echo $ac_n "checking whether $LD is GNU ld""... $ac_c" 1>&6
-echo "configure:1611: checking whether $LD is GNU ld" >&5
+echo "configure:1661: checking whether $LD is GNU ld" >&5
if eval "test \"`echo '$''{'libc_cv_prog_ld_gnu'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1623,16 +1673,10 @@ fi
echo "$ac_t""$libc_cv_prog_ld_gnu" 1>&6
gnu_ld=$libc_cv_prog_ld_gnu
-if test $host != $build; then
- ac_tool_prefix=${host_alias}-
-else
- ac_tool_prefix=
-fi
-
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1636: checking for $ac_word" >&5
+echo "configure:1680: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1663,7 +1707,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1667: checking for $ac_word" >&5
+echo "configure:1711: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1694,7 +1738,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1698: checking for $ac_word" >&5
+echo "configure:1742: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1725,10 +1769,41 @@ else
fi
fi
+# Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mig; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1776: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_MIG'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$MIG"; then
+ ac_cv_prog_MIG="$MIG" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_MIG="${ac_tool_prefix}mig"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_MIG" && ac_cv_prog_MIG="mig"
+fi
+fi
+MIG="$ac_cv_prog_MIG"
+if test -n "$MIG"; then
+ echo "$ac_t""$MIG" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
# check if ar takes S
echo $ac_n "checking for ar S""... $ac_c" 1>&6
-echo "configure:1732: checking for ar S" >&5
+echo "configure:1807: checking for ar S" >&5
if eval "test \"`echo '$''{'libc_cv_ar_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1736,7 +1811,7 @@ else
tmplib=lib$$.a
rm -f $tmpo $tmplib
touch $tmpo
-if { ac_try='${AR-ar} rcuS $tmplib $tmpo > /dev/null 2>&1'; { (eval echo configure:1740: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+if { ac_try='${AR-ar} rcuS $tmplib $tmpo > /dev/null 2>&1'; { (eval echo configure:1815: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ar_S=yes
else
libc_cv_ar_S=no
@@ -1754,7 +1829,7 @@ echo "$ac_t""$libc_cv_ar_S" 1>&6
# - two terminals occur directly after each other
# - the path contains an element with a dot in it
echo $ac_n "checking LD_LIBRARY_PATH variable""... $ac_c" 1>&6
-echo "configure:1758: checking LD_LIBRARY_PATH variable" >&5
+echo "configure:1833: checking LD_LIBRARY_PATH variable" >&5
case ${LD_LIBRARY_PATH} in
[:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
ld_library_path_setting="contains current directory"
@@ -1774,7 +1849,7 @@ fi
# Extract the first word of "bash", so it can be a program name with args.
set dummy bash; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1778: checking for $ac_word" >&5
+echo "configure:1853: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_BASH'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1816,7 +1891,7 @@ if test "$BASH" = no; then
# Extract the first word of "ksh", so it can be a program name with args.
set dummy ksh; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1820: checking for $ac_word" >&5
+echo "configure:1895: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_KSH'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1862,7 +1937,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1866: checking for $ac_word" >&5
+echo "configure:1941: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1897,7 +1972,7 @@ test -n "$PERL" || PERL="no"
echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6
-echo "configure:1901: checking for signed size_t type" >&5
+echo "configure:1976: checking for signed size_t type" >&5
if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1921,12 +1996,12 @@ EOF
fi
echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6
-echo "configure:1925: checking for libc-friendly stddef.h" >&5
+echo "configure:2000: checking for libc-friendly stddef.h" >&5
if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1930 "configure"
+#line 2005 "configure"
#include "confdefs.h"
#define __need_size_t
#define __need_wchar_t
@@ -1941,7 +2016,7 @@ size_t size; wchar_t wchar;
if (&size == NULL || &wchar == NULL) abort ();
; return 0; }
EOF
-if { (eval echo configure:1945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2020: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_friendly_stddef=yes
else
@@ -1960,7 +2035,7 @@ override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
fi
echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6
-echo "configure:1964: checking whether we need to use -P to assemble .S files" >&5
+echo "configure:2039: checking whether we need to use -P to assemble .S files" >&5
if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1983,7 +2058,7 @@ asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
fi
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6
-echo "configure:1987: checking for assembler global-symbol directive" >&5
+echo "configure:2062: checking for assembler global-symbol directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2013,7 +2088,7 @@ EOF
fi
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6
-echo "configure:2017: checking for .set assembler directive" >&5
+echo "configure:2092: checking for .set assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2047,7 +2122,7 @@ EOF
fi
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6
-echo "configure:2051: checking for .symver assembler directive" >&5
+echo "configure:2126: checking for .symver assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2066,7 +2141,7 @@ fi
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6
-echo "configure:2070: checking for ld --version-script" >&5
+echo "configure:2145: checking for ld --version-script" >&5
if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2089,7 +2164,7 @@ EOF
if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o
-nostartfiles -nostdlib
-Wl,--version-script,conftest.map
- 1>&5'; { (eval echo configure:2093: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+ 1>&5'; { (eval echo configure:2168: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_ld_version_script_option=yes
else
@@ -2127,7 +2202,7 @@ if test $VERSIONING = no; then
fi
if test $elf = yes; then
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6
-echo "configure:2131: checking for .previous assembler directive" >&5
+echo "configure:2206: checking for .previous assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2135,7 +2210,7 @@ else
.section foo_section
.previous
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_previous_directive=yes
else
libc_cv_asm_previous_directive=no
@@ -2151,7 +2226,7 @@ EOF
else
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6
-echo "configure:2155: checking for .popsection assembler directive" >&5
+echo "configure:2230: checking for .popsection assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2159,7 +2234,7 @@ else
.pushsection foo_section
.popsection
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_popsection_directive=yes
else
libc_cv_asm_popsection_directive=no
@@ -2179,12 +2254,12 @@ fi
if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
-echo "configure:2183: checking for .init and .fini sections" >&5
+echo "configure:2258: checking for .init and .fini sections" >&5
if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2188 "configure"
+#line 2263 "configure"
#include "confdefs.h"
int main() {
@@ -2193,7 +2268,7 @@ asm (".section .init");
asm (".text");
; return 0; }
EOF
-if { (eval echo configure:2197: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_have_initfini=yes
else
@@ -2221,19 +2296,19 @@ if test $elf = yes; then
else
if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2225: checking for _ prefix on C symbol names" >&5
+echo "configure:2300: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2230 "configure"
+#line 2305 "configure"
#include "confdefs.h"
asm ("_glibc_foobar:");
int main() {
glibc_foobar ();
; return 0; }
EOF
-if { (eval echo configure:2237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
libc_cv_asm_underscores=yes
else
@@ -2248,17 +2323,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2252: checking for _ prefix on C symbol names" >&5
+echo "configure:2327: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2257 "configure"
+#line 2332 "configure"
#include "confdefs.h"
void underscore_test(void) {
return; }
EOF
-if { (eval echo configure:2262: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2337: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if grep _underscore_test conftest* >/dev/null; then
rm -f conftest*
libc_cv_asm_underscores=yes
@@ -2290,7 +2365,7 @@ if test $elf = yes; then
fi
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
-echo "configure:2294: checking for assembler .weak directive" >&5
+echo "configure:2369: checking for assembler .weak directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2313,7 +2388,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
-echo "configure:2317: checking for assembler .weakext directive" >&5
+echo "configure:2392: checking for assembler .weakext directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2351,7 +2426,7 @@ EOF
fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
-echo "configure:2355: checking for ld --no-whole-archive" >&5
+echo "configure:2430: checking for ld --no-whole-archive" >&5
if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2362,7 +2437,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive
- -o conftest conftest.c 1>&5'; { (eval echo configure:2366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2441: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ld_no_whole_archive=yes
else
libc_cv_ld_no_whole_archive=no
@@ -2373,7 +2448,7 @@ fi
echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6
echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6
-echo "configure:2377: checking for gcc -fno-exceptions" >&5
+echo "configure:2452: checking for gcc -fno-exceptions" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2384,7 +2459,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fno-exceptions
- -o conftest conftest.c 1>&5'; { (eval echo configure:2388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_no_exceptions=yes
else
libc_cv_gcc_no_exceptions=no
@@ -2396,14 +2471,14 @@ echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6
if test "$base_machine" = alpha ; then
echo $ac_n "checking for function ..ng prefix""... $ac_c" 1>&6
-echo "configure:2400: checking for function ..ng prefix" >&5
+echo "configure:2475: checking for function ..ng prefix" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_alpha_ng_prefix'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<\EOF
foo () { }
EOF
-if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2407: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2482: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_gcc_alpha_ng_prefix=yes
else
@@ -2427,12 +2502,12 @@ fi
fi
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6
-echo "configure:2431: checking for DWARF2 unwind info support" >&5
+echo "configure:2506: checking for DWARF2 unwind info support" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
-#line 2436 "configure"
+#line 2511 "configure"
static char __EH_FRAME_BEGIN__;
_start ()
{
@@ -2459,7 +2534,7 @@ __bzero () {}
EOF
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame_info
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2538: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=static
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2467,7 +2542,7 @@ fi
if test $libc_cv_gcc_dwarf2_unwind_info = no; then
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2546: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=yes
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2541,7 +2616,7 @@ if test "$uname" = "sysdeps/generic"; then
fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
-echo "configure:2545: checking OS release for uname" >&5
+echo "configure:2620: checking OS release for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2563,7 +2638,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
-echo "configure:2567: checking OS version for uname" >&5
+echo "configure:2642: checking OS version for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2585,7 +2660,7 @@ else
fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6
-echo "configure:2589: checking stdio selection" >&5
+echo "configure:2664: checking stdio selection" >&5
case $stdio in
libio) cat >> confdefs.h <<\EOF
@@ -2597,7 +2672,7 @@ esac
echo "$ac_t""$stdio" 1>&6
echo $ac_n "checking ldap selection""... $ac_c" 1>&6
-echo "configure:2601: checking ldap selection" >&5
+echo "configure:2676: checking ldap selection" >&5
case $add_ons in
*ldap*)
@@ -2660,7 +2735,7 @@ if test $static = no && test $shared = yes; then
fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
-echo "configure:2664: checking whether -fPIC is default" >&5
+echo "configure:2739: checking whether -fPIC is default" >&5
if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2839,21 +2914,22 @@ s%@sysnames@%$sysnames%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@LN_S@%$LN_S%g
-s%@CC@%$CC%g
-s%@MAKE@%$MAKE%g
-s%@MSGFMT@%$MSGFMT%g
-s%@MAKEINFO@%$MAKEINFO%g
-s%@cross_linkable@%$cross_linkable%g
s%@build@%$build%g
s%@build_alias@%$build_alias%g
s%@build_cpu@%$build_cpu%g
s%@build_vendor@%$build_vendor%g
s%@build_os@%$build_os%g
+s%@CC@%$CC%g
+s%@MAKE@%$MAKE%g
+s%@MSGFMT@%$MSGFMT%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@cross_linkable@%$cross_linkable%g
s%@BUILD_CC@%$BUILD_CC%g
s%@cross_compiling@%$cross_compiling%g
s%@CPP@%$CPP%g
s%@AR@%$AR%g
s%@RANLIB@%$RANLIB%g
+s%@MIG@%$MIG%g
s%@libc_cv_ar_S@%$libc_cv_ar_S%g
s%@BASH@%$BASH%g
s%@libc_cv_have_bash2@%$libc_cv_have_bash2%g
diff --git a/configure.in b/configure.in
index f698710ce1..9d12825264 100644
--- a/configure.in
+++ b/configure.in
@@ -431,25 +431,29 @@ fi
AC_PROG_LN_S
# These programs are version sensitive.
-AC_CHECK_PROG_VER(CC, gcc cc, -v,
- [version \([egcs0-9.-]*\)],
- [egcs-2.91.*|egcs-2.90.2[789]|egcs-2.90.[3-9][0-9]|2.8.[1-9]*|2.9.[0-9]*], t)
+AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
+AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v,
+ [version \([egcst0-9.-]*\)],
+ [egcs-2.91.*|egcs-2.90.2[789]|egcs-2.90.[3-9][0-9]|*2.8.[1-9]*|*2.9.[0-9]*],
+ critic_missing=t)
AC_CHECK_PROG_VER(MAKE, make gmake, --version,
[version \([0-9][0-9.]*\), by],
- [3.75 | 3.76.[2-9] | 3.7[789]* | 3.[89]*], t)
+ [3.75 | 3.76.[1-9] | 3.7[789]* | 3.[89]*], critic_missing=t)
AC_CHECK_PROG_VER(MSGFMT, msgfmt gmsgfmt, --version,
[GNU gettext.*\([0-9][0-9]*\.[0-9]*\)],
- [0.[1-9][0-9] | [1-9].*])
+ [0.[1-9][0-9] | [1-9].*], MSGFMT=: aux_missing=t)
AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
[GNU texinfo \([0-9][0-9.]*\)],
- [3.1[1-9] | 3.[2-9][0-9]])
+ [3.1[1-9] | 3.[2-9][0-9]], MAKEINFO=: aux_missing=t)
-test -n "$ac_verc_fatal" && AC_MSG_ERROR([
+if test -n "$critic_missing"; then
+AC_MSG_ERROR([
*** Some critical program is missing or too old.
*** Check the INSTALL file for required versions.])
+fi
-test -n "$ac_verc_fail" && AC_MSG_WARN([
+test -n "$aux_missing" && AC_MSG_WARN([
*** An auxiliary program is missing or too old;
*** some features will be disabled.
*** Check the INSTALL file for required versions.])
@@ -464,6 +468,7 @@ AC_PROG_CPP
LIBC_PROG_BINUTILS
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(MIG, mig)
# check if ar takes S
AC_CACHE_CHECK(for ar S, libc_cv_ar_S, [dnl
diff --git a/elf/dl-load.c b/elf/dl-load.c
index de940b2122..edaa2cc8c5 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -280,7 +280,7 @@ decompose_rpath (const char *rpath, size_t additional_room,
const char *what, const char *where)
{
/* Make a copy we can work with. */
- char *copy = strdupa (rpath);
+ char *copy = local_strdup (rpath);
char *cp;
struct r_search_path_elem **result;
/* First count the number of necessary elements in the result array. */
diff --git a/iconv/gconv.c b/iconv/gconv.c
index 71d87ae1f6..f8b7c8050d 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -1,6 +1,6 @@
/* Convert characters in input buffer using conversion descriptor to
output buffer.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -34,19 +34,24 @@ __gconv (gconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
if (cd == (gconv_t) -1L)
return GCONV_ILLEGAL_DESCRIPTOR;
- cd->data[last_step].outbuf = *outbuf;
+ cd->data[last_step].outbuf = outbuf ? *outbuf : NULL;
cd->data[last_step].outbufavail = 0;
cd->data[last_step].outbufsize = *outbytesleft;
if (converted != NULL)
*converted = 0;
- result = (*cd->steps->fct) (cd->steps, cd->data, *inbuf, inbytesleft,
+ result = (*cd->steps->fct) (cd->steps, cd->data,
+ inbuf ? *inbuf : NULL, inbytesleft,
converted, inbuf == NULL || *inbuf == NULL);
- *inbuf += oldinbytes - *inbytesleft;
- *outbuf += cd->data[last_step].outbufavail;
- *outbytesleft -= cd->data[last_step].outbufavail;
+ if (inbuf != NULL && *inbuf != NULL)
+ *inbuf += oldinbytes - *inbytesleft;
+ if (outbuf != NULL && *outbuf != NULL)
+ {
+ *outbuf += cd->data[last_step].outbufavail;
+ *outbytesleft -= cd->data[last_step].outbufavail;
+ }
return result;
}
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index c448a160d2..7765efb6d5 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -398,6 +398,10 @@ __gconv_read_conf (void)
elem = strtok_r (gconv_path, ":", &gconv_path);
while (elem != NULL)
{
+#ifndef MAXPATHLEN
+ /* We define a reasonable limit. */
+# define 4096
+#endif
char real_elem[MAXPATHLEN];
if (realpath (elem, real_elem) != NULL)
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index b11e156a03..9e80158f43 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -108,9 +108,9 @@ get_sym (void *a)
}
-static void *
+void *
internal_function
-find_func (void *handle, const char *name)
+__gconv_find_func (void *handle, const char *name)
{
struct get_sym_args args;
@@ -170,7 +170,7 @@ __gconv_find_shlib (const char *name)
{
if (dlerror_run (do_open, found) == 0)
{
- found->fct = find_func (found->handle, "gconv");
+ found->fct = __gconv_find_func (found->handle, "gconv");
if (found->fct == NULL)
{
/* Argh, no conversion function. There is something
@@ -180,8 +180,10 @@ __gconv_find_shlib (const char *name)
}
else
{
- found->init_fct = find_func (found->handle, "gconv_init");
- found->end_fct = find_func (found->handle, "gconv_end");
+ found->init_fct = __gconv_find_func (found->handle,
+ "gconv_init");
+ found->end_fct = __gconv_find_func (found->handle,
+ "gconv_end");
/* We have succeeded in loading the shared object. */
found->counter = 1;
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index 5e0723ed34..35ec31a7b8 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -129,6 +129,10 @@ extern int __gconv_close_transform (struct gconv_step *__steps,
extern struct gconv_loaded_object *__gconv_find_shlib (const char *__name)
internal_function;
+/* Find function named NAME in shared object referenced by HANDLE. */
+void *__gconv_find_func (void *handle, const char *name)
+ internal_function;
+
/* Release shared object. If no further reference is available unload
the object. */
extern int __gconv_release_shlib (struct gconv_loaded_object *__handle)
@@ -149,6 +153,8 @@ extern void __gconv_get_builtin_trans (const char *__name,
int __do_flush)
__BUILTIN_TRANS (__gconv_transform_dummy);
+__BUILTIN_TRANS (__gconv_transform_ascii_ucs4);
+__BUILTIN_TRANS (__gconv_transform_ucs4_ascii);
__BUILTIN_TRANS (__gconv_transform_ucs4_utf8);
__BUILTIN_TRANS (__gconv_transform_utf8_ucs4);
__BUILTIN_TRANS (__gconv_transform_ucs2_ucs4);
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index 197a3d1e9c..478c0dc8fe 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -76,6 +76,234 @@ __gconv_transform_dummy (struct gconv_step *step, struct gconv_step_data *data,
}
+/* Convert from ISO 646-IRV to ISO 10646/UCS4. */
+int
+__gconv_transform_ascii_ucs4 (struct gconv_step *step,
+ struct gconv_step_data *data, const char *inbuf,
+ size_t *inlen, size_t *written, int do_flush)
+{
+ struct gconv_step *next_step = step + 1;
+ struct gconv_step_data *next_data = data + 1;
+ gconv_fct fct = next_step->fct;
+ size_t do_write;
+ int result;
+
+ /* If the function is called with no input this means we have to reset
+ to the initial state. The possibly partly converted input is
+ dropped. */
+ if (do_flush)
+ {
+ /* Clear the state. */
+ memset (data->statep, '\0', sizeof (mbstate_t));
+ do_write = 0;
+
+ /* Call the steps down the chain if there are any. */
+ if (data->is_last)
+ result = GCONV_OK;
+ else
+ {
+ struct gconv_step *next_step = step + 1;
+ struct gconv_step_data *next_data = data + 1;
+
+ result = (*fct) (next_step, next_data, NULL, 0, written, 1);
+
+ /* Clear output buffer. */
+ data->outbufavail = 0;
+ }
+ }
+ else
+ {
+ int save_errno = errno;
+ do_write = 0;
+
+ result = GCONV_OK;
+ do
+ {
+ const unsigned char *newinbuf = inbuf;
+ size_t actually = 0;
+ size_t cnt = 0;
+
+ while (data->outbufavail + sizeof (wchar_t) <= data->outbufsize
+ && cnt < *inlen)
+ {
+ if (*newinbuf > '\x7f')
+ {
+ /* This is no correct ANSI_X3.4-1968 character. */
+ result = GCONV_ILLEGAL_INPUT;
+ break;
+ }
+
+ /* It's an one byte sequence. */
+ *(wchar_t *) &data->outbuf[data->outbufavail++]
+ = (wchar_t) *newinbuf;
+ ++actually;
+
+ ++newinbuf;
+ ++cnt;
+ }
+
+ /* Remember how much we converted. */
+ do_write += cnt * sizeof (wchar_t);
+ *inlen -= cnt;
+
+ /* Check whether an illegal character appeared. */
+ if (result != GCONV_OK)
+ break;
+
+ if (data->is_last)
+ {
+ /* This is the last step. */
+ result = (*inlen == 0 ? GCONV_EMPTY_INPUT : GCONV_FULL_OUTPUT);
+ break;
+ }
+
+ /* Status so far. */
+ result = GCONV_EMPTY_INPUT;
+
+ if (data->outbufavail > 0)
+ {
+ /* Call the functions below in the chain. */
+ size_t newavail = data->outbufavail;
+
+ result = (*fct) (next_step, next_data, data->outbuf, &newavail,
+ written, 0);
+
+ /* Correct the output buffer. */
+ if (newavail != data->outbufavail && newavail > 0)
+ {
+ memmove (data->outbuf,
+ &data->outbuf[data->outbufavail - newavail],
+ newavail);
+ data->outbufavail = newavail;
+ }
+ }
+ }
+ while (*inlen > 0 && result == GCONV_EMPTY_INPUT);
+
+ __set_errno (save_errno);
+ }
+
+ if (written != NULL && data->is_last)
+ *written = do_write / sizeof (wchar_t);
+
+ return result;
+}
+
+
+/* Convert from ISO 10646/UCS to ISO 646-IRV. */
+int
+__gconv_transform_ucs4_ascii (struct gconv_step *step,
+ struct gconv_step_data *data, const char *inbuf,
+ size_t *inlen, size_t *written, int do_flush)
+{
+ struct gconv_step *next_step = step + 1;
+ struct gconv_step_data *next_data = data + 1;
+ gconv_fct fct = next_step->fct;
+ size_t do_write;
+ int result;
+
+ /* If the function is called with no input this means we have to reset
+ to the initial state. The possibly partly converted input is
+ dropped. */
+ if (do_flush)
+ {
+ /* Clear the state. */
+ memset (data->statep, '\0', sizeof (mbstate_t));
+ do_write = 0;
+
+ /* Call the steps down the chain if there are any. */
+ if (data->is_last)
+ result = GCONV_OK;
+ else
+ {
+ struct gconv_step *next_step = step + 1;
+ struct gconv_step_data *next_data = data + 1;
+
+ result = (*fct) (next_step, next_data, NULL, 0, written, 1);
+
+ /* Clear output buffer. */
+ data->outbufavail = 0;
+ }
+ }
+ else
+ {
+ int save_errno = errno;
+ do_write = 0;
+
+ result = GCONV_OK;
+ do
+ {
+ const wchar_t *newinbuf = (const wchar_t *) inbuf;
+ size_t actually = 0;
+ size_t cnt = 0;
+
+ while (data->outbufavail < data->outbufsize
+ && cnt + sizeof (wchar_t) <= *inlen)
+ {
+ if (*newinbuf < L'\0' || *newinbuf > L'\x7f')
+ {
+ /* This is no correct ANSI_X3.4-1968 character. */
+ result = GCONV_ILLEGAL_INPUT;
+ break;
+ }
+
+ /* It's an one byte sequence. */
+ data->outbuf[data->outbufavail++] = (char) *newinbuf;
+ ++actually;
+
+ ++newinbuf;
+ ++cnt;
+ }
+
+ /* Remember how much we converted. */
+ do_write += cnt;
+ *inlen -= cnt * sizeof (wchar_t);
+
+ /* Check whether an illegal character appeared. */
+ if (result != GCONV_OK)
+ break;
+
+ if (data->is_last)
+ {
+ /* This is the last step. */
+ result = (*inlen < sizeof (wchar_t)
+ ? GCONV_EMPTY_INPUT : GCONV_FULL_OUTPUT);
+ break;
+ }
+
+ /* Status so far. */
+ result = GCONV_EMPTY_INPUT;
+
+ if (data->outbufavail > 0)
+ {
+ /* Call the functions below in the chain. */
+ size_t newavail = data->outbufavail;
+
+ result = (*fct) (next_step, next_data, data->outbuf, &newavail,
+ written, 0);
+
+ /* Correct the output buffer. */
+ if (newavail != data->outbufavail && newavail > 0)
+ {
+ memmove (data->outbuf,
+ &data->outbuf[data->outbufavail - newavail],
+ newavail);
+ data->outbufavail = newavail;
+ }
+ }
+ }
+ while (*inlen > 0 && result == GCONV_EMPTY_INPUT);
+
+ __set_errno (save_errno);
+ }
+
+ if (written != NULL && data->is_last)
+ *written = do_write;
+
+ return result;
+}
+
+
int
__gconv_transform_ucs4_utf8 (struct gconv_step *step,
struct gconv_step_data *data, const char *inbuf,
diff --git a/inet/netinet/in.h b/inet/netinet/in.h
index a856a2976d..ff8476e5c7 100644
--- a/inet/netinet/in.h
+++ b/inet/netinet/in.h
@@ -22,8 +22,8 @@
#include <features.h>
#include <stdint.h>
-#include <sys/socket.h>
#include <sys/types.h>
+#include <bits/socket.h>
__BEGIN_DECLS
diff --git a/libio/fileops.c b/libio/fileops.c
index c75accdaf8..15e30a43c8 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -781,7 +781,8 @@ _IO_file_xsgetn (fp, data, n)
void *data;
_IO_size_t n;
{
- register _IO_size_t want, have, count;
+ register _IO_size_t want, have;
+ register _IO_ssize_t count;
register char *s = data;
want = n;
@@ -815,7 +816,7 @@ _IO_file_xsgetn (fp, data, n)
/* If we now want less than a buffer, underflow and repeat
the copy. Otherwise, _IO_SYSREAD directly to
the user buffer. */
- if (fp->_IO_buf_base && want < fp->_IO_buf_end - fp->_IO_buf_base)
+ if (fp->_IO_buf_base && want <= fp->_IO_buf_end - fp->_IO_buf_base)
{
if (__underflow (fp) == EOF)
break;
@@ -823,6 +824,11 @@ _IO_file_xsgetn (fp, data, n)
continue;
}
+ /* These must be set before the sysread as we might longjmp out
+ waiting for input. */
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+
count = _IO_SYSREAD (fp, s, want);
if (count <= 0)
{
@@ -836,6 +842,8 @@ _IO_file_xsgetn (fp, data, n)
s += count;
want -= count;
+ if (fp->_offset != _IO_pos_BAD)
+ _IO_pos_adjust (fp->_offset, count);
}
}
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index c4eddef3a5..8813ae110f 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -21,7 +21,7 @@
#
subdir := linuxthreads
-linuxthreads-version=0.7
+libpthread-version=0.7
headers := pthread.h semaphore.h bits/semaphore.h
distribute := internals.h queue.h restart.h spinlock.h
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index 851b95fd98..0ea0310093 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@@ -368,6 +368,6 @@ const struct locale_data _nl_C_LC_CTYPE =
{ string: "tolower\0" "toupper\0" },
{ string: _nl_C_LC_CTYPE_width },
{ word: 2 },
- { string: "ISO_646.IRV" }
+ { string: "ANSI_X3.4-1968" }
}
};
diff --git a/login/openpty.c b/login/openpty.c
index 12e82072bc..8c843847f1 100644
--- a/login/openpty.c
+++ b/login/openpty.c
@@ -48,7 +48,7 @@ openpty (pmast, pslave, pname, tio, wins)
if (unlockpt (pfd))
goto bail;
- if (!ptsname_r (pfd, name, PTYNAMELEN))
+ if (ptsname_r (pfd, name, PTYNAMELEN) != 0)
goto bail;
tfd = open (name, O_RDWR);
diff --git a/mach/Machrules b/mach/Machrules
index ef2d306b80..c5e234ec9b 100644
--- a/mach/Machrules
+++ b/mach/Machrules
@@ -1,6 +1,6 @@
# Rules for MiG interfaces that want to go into the C library.
-# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96, 98 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
@@ -44,9 +44,6 @@ endif
include ../Makeconfig
-ifndef MIG
-MIG = mig
-endif
MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \
$(+includes) $(migdefines) -subrprefix __
diff --git a/manual/filesys.texi b/manual/filesys.texi
index c3ab7c562a..4ae13dc8dd 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -2345,6 +2345,13 @@ It is possible for @code{tmpnam} to fail if you call it too many times
without removing previously created files. This is because the fixed
length of a temporary file name gives room for only a finite number of
different names. If @code{tmpnam} fails, it returns a null pointer.
+
+@strong{Warning:} Since between the time the pathname is constructed and
+the file is created another process might have created a file with this
+name using @code{tmpnam} is a possible security hole. The
+implementation generates names which hardly can be predicted but opening
+the file in any case should use the @code{O_EXCL} flag. Using
+@code{tmpfile} is a safe way to avoid this problem.
@end deftypefun
@comment stdio.h
@@ -2445,6 +2452,13 @@ The @code{mktemp} function generates a unique file name by modifying
name, it makes @var{template} an empty string and returns that. If
@var{template} does not end with @samp{XXXXXX}, @code{mktemp} returns a
null pointer.
+
+@strong{Warning:} Since between the time the pathname is constructed and
+the file is created another process might have created a file with this
+name using @code{mktemp} is a possible security hole. The
+implementation generates names which hardly can be predicted but opening
+the file in any case should use the @code{O_EXCL} flag. Using
+@code{mkstemp} is a safe way to avoid this problem.
@end deftypefun
@comment unistd.h
diff --git a/manual/install.texi b/manual/install.texi
index 35e257e7bc..f57bb17d71 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -171,6 +171,25 @@ value for the Makefile variable @code{install_root} on the command line.
This is useful to create chroot'ed environment or to prepare binary
releases.@refill
+For now (in this alpha version, and at least on RedHat Linux), if you
+are trying to install this as your default libraries, a different
+installation method is recommended. Move @file{/usr/include} out of the
+way, create a new @file{/usr/include} directory (don't forget the
+symlinks @file{/usr/include/asm} and @file{/usr/include/linux}, that
+should point to @file{/usr/src/linux/include/asm} and
+@file{/usr/src/linux/include/linux} -or wherever you keep your kernel
+sources-respectively), build normally and install into somewhere else
+via @code{install_root}. Then move your @code{/usr/include} back, and
+copy the newly created stuff by hand over the old. Remember to copy
+programs and shared libraries into @file{FILENAME.new} and then move
+@file{FILENAME.new} to @file{FILENAME}, as the files might be in
+use. You will have to @code{ranlib} your copies of the static libraries
+@file{/usr/lib/libNAME.a}. You will see that @file{libbsd-compat.a},
+@file{libieee.a}, and @file{libmcheck.a} are just object files, not
+archives. This is normal. Copy the new header files over the old ones
+by something like @w{@code{cd /usr; (cd INSTALL_ROOT; tar cf - include) |
+tar xf -}}.
+
@node Tools for Installation
@appendixsec Recommended Tools to Install the GNU C Library
@cindex installation tools
diff --git a/manual/libc.texinfo b/manual/libc.texinfo
index cf25e251d3..1e92d52456 100644
--- a/manual/libc.texinfo
+++ b/manual/libc.texinfo
@@ -19,7 +19,7 @@
@c sold 0.06/1.09, print run out 21may96
@set EDITION 0.07 DRAFT
@set VERSION 2.00 Beta
-@set UPDATED 04 Aug 1997
+@set UPDATED 03 Apr 1998
@set ISBN 1-882114-53-1
@ifinfo
@@ -28,7 +28,7 @@ This file documents the GNU C library.
This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}.
-Copyright (C) 1993, '94, '95, '96, '97 Free Software Foundation, Inc.
+Copyright (C) 1993, '94, '95, '96, '97, '98 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -74,7 +74,7 @@ Foundation.
@center for version @value{VERSION}
@page
@vskip 0pt plus 1filll
-Copyright @copyright{} 1993, '94, '95, '96, '97 Free Software Foundation, Inc.
+Copyright @copyright{} 1993, '94, '95, '96, '97, '98 Free Software Foundation, Inc.
@sp 2
Published by the Free Software Foundation @*
59 Temple Place -- Suite 330, @*
@@ -507,7 +507,7 @@ Sockets
* Socket Concepts:: Basic concepts you need to know about.
* Communication Styles:: Stream communication, datagrams, and others.
* Socket Addresses:: How socket names (``addresses'') work.
-* File Namespace:: Details about the file namespace.
+* Local Namespace:: Details about the local namespace.
* Internet Namespace:: Details about the Internet namespace.
* Open/Close Sockets:: Creating sockets and destroying them.
* Connections:: Operations on sockets with connection state.
@@ -570,7 +570,7 @@ Datagrams
* Sending Datagrams:: Sending packets on a datagram socket.
* Receiving Datagrams:: Receiving packets on a datagram socket.
* Datagram Example:: An example program: packets sent over a
- datagram stream in the file namespace.
+ datagram stream in the local namespace.
* Example Receiver:: Another program, that receives those packets.
Socket Options
diff --git a/manual/socket.texi b/manual/socket.texi
index cc8496995d..954d598dd4 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -21,13 +21,16 @@ system, and the socket functions always exist, but if the system does
not really support sockets, these functions always fail.
@strong{Incomplete:} We do not currently document the facilities for
-broadcast messages or for configuring Internet interfaces.
+broadcast messages or for configuring Internet interfaces. The
+reentrant functions and some newer functions that are related to IPv6
+aren't documented either so far.
@menu
* Socket Concepts:: Basic concepts you need to know about.
* Communication Styles::Stream communication, datagrams, and other styles.
* Socket Addresses:: How socket names (``addresses'') work.
-* File Namespace:: Details about the file namespace.
+* Interface Naming:: Identifying specific network interfaces.
+* Local Namespace:: Details about the local namespace.
* Internet Namespace:: Details about the Internet namespace.
* Misc Namespaces:: Other namespaces not documented fully here.
* Open/Close Sockets:: Creating sockets and destroying them.
@@ -141,13 +144,13 @@ But now the POSIX people came and unified the interface with their words
@code{size_t} is 64 bits wide and so variable references are not anymore
possible.
-A solution provides the Unix98 specification which finally introduces a
-type @code{socklen_t}. This type is used in all of the cases that were
-previously changed to use @code{size_t}. The only requirement of this
-type is that it is an unsigned type of at least 32 bits. Therefore,
-implementations which require references to 32 bit variables be passed
-can be as happy as implementations which use right from the start 64 bit
-values.
+A solution is provided by the Unix98 specification which finally
+introduces a type @code{socklen_t}. This type is used in all of the
+cases that were previously changed to use @code{size_t}. The only
+requirement of this type is that it is an unsigned type of at least 32
+bits. Therefore, implementations which require references to 32 bit
+variables be passed can be as happy as implementations which use right
+from the start 64 bit values.
@node Communication Styles
@@ -260,11 +263,11 @@ system assigns an address automatically if you have not specified one.
Occasionally a client needs to specify an address because the server
discriminates based on addresses; for example, the rsh and rlogin
-protocols look at the client's socket address and don't bypass password
-checking unless it is less than @code{IPPORT_RESERVED} (@pxref{Ports}).
+protocols look at the client's socket address and only bypass password
+checking if it is less than @code{IPPORT_RESERVED} (@pxref{Ports}).
The details of socket addresses vary depending on what namespace you are
-using. @xref{File Namespace}, or @ref{Internet Namespace}, for specific
+using. @xref{Local Namespace}, or @ref{Internet Namespace}, for specific
information.
Regardless of the namespace, you use the same functions @code{bind} and
@@ -304,7 +307,7 @@ The symbols in this section are defined in the header file
@comment sys/socket.h
@comment BSD
-@deftp {Date Type} {struct sockaddr}
+@deftp {Data Type} {struct sockaddr}
The @code{struct sockaddr} type itself has the following members:
@table @code
@@ -329,7 +332,7 @@ corresponding namespace. Here is a list of address format names:
@item AF_FILE
@vindex AF_FILE
This designates the address format that goes with the file namespace.
-(@code{PF_FILE} is the name of that namespace.) @xref{File Namespace
+(@code{PF_FILE} is the name of that namespace.) @xref{Local Namespace
Details}, for information about this address format.
@comment sys/socket.h
@@ -341,6 +344,14 @@ This is a synonym for @code{AF_FILE}, for compatibility.
@comment sys/socket.h
@comment BSD
+@item AF_UNIX
+@vindex AF_LOCAL
+This is another synonym for @code{AF_FILE}, for compatibility.
+(@code{PF_LOCAL} is likewise a synonym for @code{PF_FILE}.)
+@strong{POSIX? XXX}
+
+@comment sys/socket.h
+@comment BSD
@item AF_INET
@vindex AF_INET
This designates the address format that goes with the Internet
@@ -376,7 +387,7 @@ information about how to use them.
@pindex sys/socket.h
Use the @code{bind} function to assign an address to a socket. The
prototype for @code{bind} is in the header file @file{sys/socket.h}.
-For examples of use, see @ref{File Namespace}, or see @ref{Inet Example}.
+For examples of use, see @ref{Local Socket Example}, or see @ref{Inet Example}.
@comment sys/socket.h
@comment BSD
@@ -462,29 +473,107 @@ You can't read the address of a socket in the file namespace. This is
consistent with the rest of the system; in general, there's no way to
find a file's name from a descriptor for that file.
-@node File Namespace
-@section The File Namespace
-@cindex file namespace, for sockets
+@node Interface Naming
+@section Interface Naming
+
+Each network interface has a name. This usually consists of a few
+letters that relate to the type of interface, which may be followed by a
+number if there is more than one interface of that type. Examples
+might be @code{lo} (the loopback interface) and @code{eth0} (the first
+Ethernet interface).
+
+Although such names are convenient for humans, it would be clumsy to
+have to use them whenever a program needed to refer to an interface. In
+such situations an interface is referred to by its @dfn{index}, which is
+an arbitrarily-assigned small positive integer.
+
+The following functions, constants and data types are declared in the
+header file @file{net/if.h}.
+
+@comment net/if.h
+@deftypevr Constant size_t IFNAMSIZ
+This constant defines the maximum buffer size needed to hold an
+interface name, including its terminating zero byte.
+@end deftypevr
+
+@comment net/if.h
+@comment IPv6 basic API
+@deftypefun unsigned int if_nametoindex (const char *ifname)
+This function yields the interface index corresponding to a particular
+name. If no interface exists with the name given, it returns 0.
+@end deftypefun
+
+@comment net/if.h
+@comment IPv6 basic API
+@deftypefun char *if_indextoname (unsigned int ifindex, char *ifname)
+This function maps an interface index to its corresponding name. The
+returned name is placed in the buffer pointed to by @code{ifname}, which
+must be at least @code{IFNAMSIZE} bytes in length. If the index was
+invalid, the function's return value is a null pointer, otherwise it is
+@code{ifname}.
+@end deftypefun
+
+@comment net/if.h
+@comment IPv6 basic API
+@deftp {Data Type} {struct if_nameindex}
+This data type is used to hold the information about a single
+interface. It has the following members:
+
+@table @code
+@item unsigned int if_index;
+This is the interface index.
+
+@item char *if_name
+This is the null-terminated index name.
+
+@end table
+@end deftp
+
+@comment net/if.h
+@comment IPv6 basic API
+@deftypefun struct if_nameindex *if_nameindex (void)
+This function returns an array of @code{if_nameindex} structures, one
+for every interface that is present. The end of the list is indicated
+by a structure with an interface of 0 and a null name pointer. If an
+error occurs, this function returns a null pointer.
+
+The returned structure must be freed with @code{if_freenameindex} after
+use.
+@end deftypefun
+
+@comment net/if.h
+@comment IPv6 basic API
+@deftypefun void if_freenameindex (struct if_nameindex *ptr)
+This function frees the structure returned by an earlier call to
+@code{if_nameindex}.
+@end deftypefun
+
+@node Local Namespace
+@section The Local Namespace
+@cindex local namespace, for sockets
-This section describes the details of the file namespace, whose
-symbolic name (required when you create a socket) is @code{PF_FILE}.
+This section describes the details of the local namespace, whose
+symbolic name (required when you create a socket) is @code{PF_LOCAL}.
+The local namespace is also known as ``Unix domain sockets''. Another
+name is file namespace since socket addresses are normally implemented
+as file names.
@menu
-* Concepts: File Namespace Concepts. What you need to understand.
-* Details: File Namespace Details. Address format, symbolic names, etc.
-* Example: File Socket Example. Example of creating a socket.
+* Concepts: Local Namespace Concepts. What you need to understand.
+* Details: Local Namespace Details. Address format, symbolic names, etc.
+* Example: Local Socket Example. Example of creating a socket.
@end menu
-@node File Namespace Concepts
-@subsection File Namespace Concepts
+@node Local Namespace Concepts
+@subsection Local Namespace Concepts
-In the file namespace, socket addresses are file names. You can specify
+In the local namespace, socket addresses are file names. You can specify
any file name you want as the address of the socket, but you must have
write permission on the directory containing it. In order to connect to
a socket, you must have read permission for it. It's common to put
these files in the @file{/tmp} directory.
-One peculiarity of the file namespace is that the name is only used when
+One peculiarity of the local namespace is that the name is only used when
opening the connection; once that is over with, the address is not
meaningful and may not exist.
@@ -494,53 +583,60 @@ which contains the name of the socket. You can see the socket in a
directory listing, but connecting to it never succeeds. Some programs
take advantage of this, such as by asking the client to send its own
process ID, and using the process IDs to distinguish between clients.
-However, we recommend you not use this method in protocols you design,
+However, we recommend you not to use this method in protocols you design,
as we might someday permit connections from other machines that mount
the same file systems. Instead, send each new client an identifying
number if you want it to have one.
-After you close a socket in the file namespace, you should delete the
+After you close a socket in the local namespace, you should delete the
file name from the file system. Use @code{unlink} or @code{remove} to
do this; see @ref{Deleting Files}.
-The file namespace supports just one protocol for any communication
+The local namespace supports just one protocol for any communication
style; it is protocol number @code{0}.
-@node File Namespace Details
-@subsection Details of File Namespace
+@node Local Namespace Details
+@subsection Details of Local Namespace
@pindex sys/socket.h
-To create a socket in the file namespace, use the constant
-@code{PF_FILE} as the @var{namespace} argument to @code{socket} or
+To create a socket in the local namespace, use the constant
+@code{PF_LOCAL} as the @var{namespace} argument to @code{socket} or
@code{socketpair}. This constant is defined in @file{sys/socket.h}.
@comment sys/socket.h
-@comment GNU
-@deftypevr Macro int PF_FILE
-This designates the file namespace, in which socket addresses are file
-names, and its associated family of protocols.
+@comment POSIX
+@deftypevr Macro int PF_LOCAL
+This designates the local namespace, in which socket addresses are local
+names, and its associated family of protocols. @code{PF_Local} is the
+macro used by Posix.1g.
@end deftypevr
@comment sys/socket.h
@comment BSD
@deftypevr Macro int PF_UNIX
-This is a synonym for @code{PF_FILE}, for compatibility's sake.
+This is a synonym for @code{PF_LOCAL}, for compatibility's sake.
@end deftypevr
-The structure for specifying socket names in the file namespace is
+@comment sys/socket.h
+@comment GNU
+@deftypevr Macro int PF_FILE
+This is a synonym for @code{PF_LOCAL}, for compatibility's sake.
+@end deftypevr
+
+The structure for specifying socket names in the local namespace is
defined in the header file @file{sys/un.h}:
@pindex sys/un.h
@comment sys/un.h
@comment BSD
@deftp {Data Type} {struct sockaddr_un}
-This structure is used to specify file namespace socket addresses. It has
+This structure is used to specify local namespace socket addresses. It has
the following members:
@table @code
@item short int sun_family
This identifies the address family or format of the socket address.
-You should store the value @code{AF_FILE} to designate the file
+You should store the value @code{AF_LOCAL} to designate the local
namespace. @xref{Socket Addresses}.
@item char sun_path[108]
@@ -554,14 +650,20 @@ the length of the filename.
@end deftp
You should compute the @var{length} parameter for a socket address in
-the file namespace as the sum of the size of the @code{sun_family}
+the local namespace as the sum of the size of the @code{sun_family}
component and the string length (@emph{not} the allocation size!) of
-the file name string.
+the file name string. This can be done using the macro @code{SUN_LEN}:
-@node File Socket Example
-@subsection Example of File-Namespace Sockets
+@comment sys/un.h
+@comment BSD
+@deftypefn {Macro} int SUNLEN (@emph{struct sockaddr_un *} @var{ptr})
+The macro computes the length of socket address in the local namespace.
+@end deftypefn
-Here is an example showing how to create and name a socket in the file
+@node Local Socket Example
+@subsection Example of Local-Namespace Sockets
+
+Here is an example showing how to create and name a socket in the local
namespace.
@smallexample
@@ -572,19 +674,30 @@ namespace.
@section The Internet Namespace
@cindex Internet namespace, for sockets
-This section describes the details the protocols and socket naming
+This section describes the details of the protocols and socket naming
conventions used in the Internet namespace.
-To create a socket in the Internet namespace, use the symbolic name
+Originaly the Internet namespace used only IP version 4 (IPv4). With
+the growing number of hosts on the Internet, a new protocol with a
+larger address space was neccessary: IP version 6 (IPv6). IPv6
+introduces besides 128bit addresses (IPv4 has 32bit addresses) also
+other features and will eventually replace IPv4.
+
+To create a socket in the IPv4 Internet namespace, use the symbolic name
@code{PF_INET} of this namespace as the @var{namespace} argument to
-@code{socket} or @code{socketpair}. This macro is defined in
-@file{sys/socket.h}.
+@code{socket} or @code{socketpair}. For IPv6 addresses, you need the
+macro @code{PF_INET6}. These macros are defined in @file{sys/socket.h}.
@pindex sys/socket.h
@comment sys/socket.h
@comment BSD
@deftypevr Macro int PF_INET
-This designates the Internet namespace and associated family of
+This designates the IPv4 Internet namespace and associated family of
+protocols.
+@end deftypevr
+
+@deftypevr Macro int AF_INET6
+This designates the IPv6 Internet namespace and associated family of
protocols.
@end deftypevr
@@ -637,7 +750,7 @@ This is the data type used to represent socket addresses in the
Internet namespace. It has the following members:
@table @code
-@item short int sin_family
+@item sa_family_t sin_family
This identifies the address family or format of the socket address.
You should store the value of @code{AF_INET} in this member.
@xref{Socket Addresses}.
@@ -654,14 +767,14 @@ This is the port number. @xref{Ports}.
When you call @code{bind} or @code{getsockname}, you should specify
@code{sizeof (struct sockaddr_in)} as the @var{length} parameter if
-you are using an Internet namespace socket address.
+you are using an IPv4 Internet namespace socket address.
@deftp {Data Type} {struct sockaddr_in6}
This is the data type used to represent socket addresses in the IPv6
namespace. It has the following members:
@table @code
-@item short int sin6_family
+@item sa_family_t sin6_family
This identifies the address family or format of the socket address.
You should store the value of @code{AF_INET6} in this member.
@xref{Socket Addresses}.
@@ -691,7 +804,7 @@ numeric host addresses as sequences of up to eight numbers separated by
colons, as in @samp{5f03:1200:836f:c100::1}.
Each computer also has one or more @dfn{host names}, which are strings
-of words separated by periods, as in @samp{churchy.gnu.ai.mit.edu}.
+of words separated by periods, as in @samp{mescaline.gnu.org}.
Programs that let the user specify a host typically accept both numeric
addresses and host names. But the program needs a numeric address to
@@ -715,18 +828,21 @@ Each computer on the Internet has one or more Internet addresses,
numbers which identify that computer among all those on the Internet.
@end ifinfo
-@c I think this whole section could possibly be removed. It is slightly
-@c misleading these days.
-
@cindex network number
@cindex local network address number
-An Internet host address is a number containing four bytes of data.
-These are divided into two parts, a @dfn{network number} and a
-@dfn{local network address number} within that network. The network
-number consists of the first one, two or three bytes; the rest of the
-bytes are the local address.
-
-Network numbers are registered with the Network Information Center
+An IPv4 Internet host address is a number containing four bytes of data.
+Historically these are divided into two parts, a @dfn{network number} and a
+@dfn{local network address number} within that network. In the
+mid-1990s classless address were introduced which changed the
+behaviour. Since some functions implicitly expect the old definitions,
+we first describe the class based network and will then describe
+classless addresses. IPv6 uses only classless adresses and therefore
+the following paragraphs don't apply.
+
+The class based IPv4 network number consists of the first one, two or
+three bytes; the rest of the bytes are the local address.
+
+IPv4 network numbers are registered with the Network Information Center
(NIC), and are divided into three classes---A, B, and C. The local
network address numbers of individual machines are registered with the
administrator of the particular network.
@@ -742,7 +858,8 @@ Internet address specify the address within that network.
The Class A network 0 is reserved for broadcast to all networks. In
addition, the host number 0 within each network is reserved for broadcast
-to all hosts in that network.
+to all hosts in that network. These uses are obsolete now but out of
+compatibility reasons you shouldn't use network 0 and host number 0.
The Class A network 127 is reserved for loopback; you can always use
the Internet address @samp{127.0.0.1} to refer to the host machine.
@@ -752,6 +869,7 @@ have multiple Internet host addresses. However, there is never
supposed to be more than one machine with the same host address.
@c !!! this section could document the IN_CLASS* macros in <netinet/in.h>.
+@c No, it shouldn't since they're obsolete.
@cindex standard dot notation, for Internet addresses
@cindex dot notation, for Internet addresses
@@ -760,7 +878,8 @@ for Internet addresses:
@table @code
@item @var{a}.@var{b}.@var{c}.@var{d}
-This specifies all four bytes of the address individually.
+This specifies all four bytes of the address individually and is the
+commonly used representation.
@item @var{a}.@var{b}.@var{c}
The last part of the address, @var{c}, is interpreted as a 2-byte quantity.
@@ -768,7 +887,7 @@ This is useful for specifying host addresses in a Class B network with
network address number @code{@var{a}.@var{b}}.
@item @var{a}.@var{b}
-The last part of the address, @var{c}, is interpreted as a 3-byte quantity.
+The last part of the address, @var{b}, is interpreted as a 3-byte quantity.
This is useful for specifying host addresses in a Class A network with
network address number @var{a}.
@@ -782,15 +901,50 @@ the radix apply. In other words, a leading @samp{0x} or @samp{0X} implies
hexadecimal radix; a leading @samp{0} implies octal; and otherwise decimal
radix is assumed.
+@subsubheading Classless Addresses
+
+IPv4 addresses (and IPv6 addresses also) are now considered as
+classless. The distinction between classes A, B, and C can be ignored.
+Instead a IPv4 host adddress consists of a 32-bit address and a 32-bit
+mask. The mask contains bits of 1 for the network part and bits of 0
+for the host part. The 1-bits are contigous from the leftmost bit, the
+0-bits are contigous from the rightmost bit so that the netmask can also
+be written as a prefix length of bits of 1. Classes A, B and C are just
+special cases of this general rule. For example, class A addresses have
+a netmask of @samp{255.0.0.0} or a prefix length of 8.
+
+Classless IPv4 network addresses are written in numbers-and-dots
+notation with the prefix length appended and a slash as separator. For
+example the class A network 10 is written as @samp{10.0.0.0/8}.
+
+@subsubheading IPv6 Addresses
+
+IPv6 addresses contain 128 bits (IPv4 has 32 bits) of data. A host
+address is usually written as eight 16-bit hexadecimal numbers that are
+separated by colons. Two colons are used to appreviated strings of
+consecutive zeros. For example the IPv6 loopback address which is
+@samp{0:0:0:0:0:0:0:1} can be just written as @samp{::1}.
+
@node Host Address Data Type
@subsubsection Host Address Data Type
-Internet host addresses are represented in some contexts as integers
-(type @code{unsigned long int}). In other contexts, the integer is
+IPv4 Internet host addresses are represented in some contexts as integers
+(type @code{uint32_t}). In other contexts, the integer is
packaged inside a structure of type @code{struct in_addr}. It would
be better if the usage were made consistent, but it is not hard to extract
the integer from the structure or put the integer into a structure.
+You will find older code that uses @code{unsigned long int} for
+IPv4 Internet host addresses instead of @code{uint32_t} or @code{struct
+in_addr}. Historically @code{unsigned long int} was a 32 bit number but
+with 64 bit machines this has changed. Using @code{unsigned long int}
+might break the code if it is used on machines where this type doesn't
+have 32 bits. @code{uint32_t} is specified by Unix98 and guaranteed to have
+32 bits.
+
+IPv6 Internet host addresses have 128 bits and are packaged inside a
+structure of type @code{struct in6_addr}.
+
The following basic definitions for Internet addresses are declared in
the header file @file{netinet/in.h}:
@pindex netinet/in.h
@@ -798,16 +952,16 @@ the header file @file{netinet/in.h}:
@comment netinet/in.h
@comment BSD
@deftp {Data Type} {struct in_addr}
-This data type is used in certain contexts to contain an Internet host
-address. It has just one field, named @code{s_addr}, which records the
-host address number as an @code{unsigned long int}.
+This data type is used in certain contexts to contain an IPv4 Internet
+host address. It has just one field, named @code{s_addr}, which records
+the host address number as an @code{uint32_t}.
@end deftp
@comment netinet/in.h
@comment BSD
-@deftypevr Macro {unsigned int} INADDR_LOOPBACK
+@deftypevr Macro {uint32_t} INADDR_LOOPBACK
You can use this constant to stand for ``the address of this machine,''
-instead of finding its actual address. It is the Internet address
+instead of finding its actual address. It is the IPv4 Internet address
@samp{127.0.0.1}, which is usually called @samp{localhost}. This
special constant saves you the trouble of looking up the address of your
own machine. Also, the system usually implements @code{INADDR_LOOPBACK}
@@ -817,7 +971,7 @@ talking to itself.
@comment netinet/in.h
@comment BSD
-@deftypevr Macro {unsigned int} INADDR_ANY
+@deftypevr Macro {uint32_t} INADDR_ANY
You can use this constant to stand for ``any incoming address,'' when
binding to an address. @xref{Setting Address}. This is the usual
address to give in the @code{sin_addr} member of @w{@code{struct
@@ -826,14 +980,14 @@ sockaddr_in}} when you want to accept Internet connections.
@comment netinet/in.h
@comment BSD
-@deftypevr Macro {unsigned int} INADDR_BROADCAST
+@deftypevr Macro {uint32_t} INADDR_BROADCAST
This constant is the address you use to send a broadcast message.
@c !!! broadcast needs further documented
@end deftypevr
@comment netinet/in.h
@comment BSD
-@deftypevr Macro {unsigned int} INADDR_NONE
+@deftypevr Macro {uint32_t} INADDR_NONE
This constant is returned by some functions to indicate an error.
@end deftypevr
@@ -876,7 +1030,7 @@ Order}, for an explanation of network and host byte order.
@comment arpa/inet.h
@comment BSD
@deftypefun int inet_aton (const char *@var{name}, struct in_addr *@var{addr})
-This function converts the Internet host address @var{name}
+This function converts the IPv4 Internet host address @var{name}
from the standard numbers-and-dots notation into binary data and stores
it in the @code{struct in_addr} that @var{addr} points to.
@code{inet_aton} returns nonzero if the address is valid, zero if not.
@@ -884,8 +1038,8 @@ it in the @code{struct in_addr} that @var{addr} points to.
@comment arpa/inet.h
@comment BSD
-@deftypefun {unsigned long int} inet_addr (const char *@var{name})
-This function converts the Internet host address @var{name} from the
+@deftypefun {uint32_t} inet_addr (const char *@var{name})
+This function converts the IPv4 Internet host address @var{name} from the
standard numbers-and-dots notation into binary data. If the input is
not valid, @code{inet_addr} returns @code{INADDR_NONE}. This is an
obsolete interface to @code{inet_aton}, described immediately above; it
@@ -896,17 +1050,21 @@ indicate error return.
@comment arpa/inet.h
@comment BSD
-@deftypefun {unsigned long int} inet_network (const char *@var{name})
+@deftypefun {uint32_t} inet_network (const char *@var{name})
This function extracts the network number from the address @var{name},
given in the standard numbers-and-dots notation. The returned address is
in host order. If the input is not valid, @code{inet_network} returns
@code{-1}.
+
+The function works only with traditional IPv4 class A,B and C network
+types. It doesn't work with classless addresses and shouldn't be used
+anymore.
@end deftypefun
@comment arpa/inet.h
@comment BSD
@deftypefun {char *} inet_ntoa (struct in_addr @var{addr})
-This function converts the Internet host address @var{addr} to a
+This function converts the IPv4 Internet host address @var{addr} to a
string in the standard numbers-and-dots notation. The return value is
a pointer into a statically-allocated buffer. Subsequent calls will
overwrite the same buffer, so you should copy the string if you need
@@ -915,28 +1073,40 @@ to save it.
In multi-threaded programs each thread has an own statically-allocated
buffer. But still subsequent calls of @code{inet_ntoa} in the same
thread will overwrite the result of the last call.
+
+Instead of @code{inet_ntoa} the newer function @code{inet_ntop} which is
+described below should be used since it handles both IPv4 and IPv6
+addresses.
@end deftypefun
@comment arpa/inet.h
@comment BSD
-@deftypefun {struct in_addr} inet_makeaddr (int @var{net}, int @var{local})
-This function makes an Internet host address by combining the network
+@deftypefun {struct in_addr} inet_makeaddr (uint32_t @var{net}, uint32_t @var{local})
+This function makes an IPv4 Internet host address by combining the network
number @var{net} with the local-address-within-network number
@var{local}.
@end deftypefun
@comment arpa/inet.h
@comment BSD
-@deftypefun int inet_lnaof (struct in_addr @var{addr})
+@deftypefun uint32_t inet_lnaof (struct in_addr @var{addr})
This function returns the local-address-within-network part of the
Internet host address @var{addr}.
+
+The function works only with traditional IPv4 class A,B and C network
+types. It doesn't work with classless addresses and shouldn't be used
+anymore.
@end deftypefun
@comment arpa/inet.h
@comment BSD
-@deftypefun int inet_netof (struct in_addr @var{addr})
+@deftypefun uint32_t inet_netof (struct in_addr @var{addr})
This function returns the network number part of the Internet host
address @var{addr}.
+
+The function works only with traditional IPv4 class A,B and C network
+types. It doesn't work with classless addresses and shouldn't be used
+anymore.
@end deftypefun
@comment arpa/inet.h
@@ -952,7 +1122,7 @@ responsibility to make sure the buffer is large enough.
@comment arpa/inet.h
@comment IPv6 basic API
-@deftypefun {char *} inet_ntop (int @var{af}, const void *@var{cp}, char *@var{buf}, size_t @var{len})
+@deftypefun {const char *} inet_ntop (int @var{af}, const void *@var{cp}, char *@var{buf}, size_t @var{len})
This function converts an Internet address (either IPv4 or IPv6) from
network (binary) to presentation (textual) form. @var{af} should be
either @code{AF_INET} or @code{AF_INET6}, as appropriate. @var{cp} is a
@@ -970,9 +1140,9 @@ buffer. The return value from the function will be this buffer address.
Besides the standard numbers-and-dots notation for Internet addresses,
you can also refer to a host by a symbolic name. The advantage of a
symbolic name is that it is usually easier to remember. For example,
-the machine with Internet address @samp{128.52.46.32} is also known as
-@samp{churchy.gnu.ai.mit.edu}; and other machines in the @samp{gnu.ai.mit.edu}
-domain can refer to it simply as @samp{churchy}.
+the machine with Internet address @samp{158.121.106.19} is also known as
+@samp{alpha.gnu.org}; and other machines in the @samp{gnu.org}
+domain can refer to it simply as @samp{alpha}.
@pindex /etc/hosts
@pindex netdb.h
@@ -1021,9 +1191,10 @@ first host address.
As far as the host database is concerned, each address is just a block
of memory @code{h_length} bytes long. But in other contexts there is an
-implicit assumption that you can convert this to a @code{struct in_addr} or
-an @code{unsigned long int}. Host addresses in a @code{struct hostent}
-structure are always given in network byte order; see @ref{Byte Order}.
+implicit assumption that you can convert IPv4 addresses to a
+@code{struct in_addr} or an @code{uint32_t}. Host addresses in
+a @code{struct hostent} structure are always given in network byte
+order; see @ref{Byte Order}.
You can use @code{gethostbyname}, @code{gethostbyname2} or
@code{gethostbyaddr} to search the hosts database for information about
@@ -1051,10 +1222,12 @@ allows the caller to specify the desired address family (e.g.@:
@comment BSD
@deftypefun {struct hostent *} gethostbyaddr (const char *@var{addr}, int @var{length}, int @var{format})
The @code{gethostbyaddr} function returns information about the host
-with Internet address @var{addr}. The @var{length} argument is the
-size (in bytes) of the address at @var{addr}. @var{format} specifies
-the address format; for an Internet address, specify a value of
-@code{AF_INET}.
+with Internet address @var{addr}. The parameter @var{addr} is not
+really a pointer to char - it can be a pointer to an IPv4 or an IPv6
+address. The @var{length} argument is the size (in bytes) of the address
+at @var{addr}. @var{format} specifies the address format; for an IPv4
+Internet address, specify a value of @code{AF_INET}; for an IPv6
+Internet address, use @code{AF_INET6}.
If the lookup fails, @code{gethostbyaddr} returns a null pointer.
@end deftypefun
@@ -1122,14 +1295,14 @@ reopening the database for each call.
@comment netdb.h
@comment BSD
-@deftypefun {struct hostent *} gethostent ()
+@deftypefun {struct hostent *} gethostent (void)
This function returns the next entry in the hosts database. It
returns a null pointer if there are no more entries.
@end deftypefun
@comment netdb.h
@comment BSD
-@deftypefun void endhostent ()
+@deftypefun void endhostent (void)
This function closes the hosts database.
@end deftypefun
@@ -1306,40 +1479,44 @@ If you use @code{getservbyname} and @code{gethostbyname} or
already in the network byte order, and you can copy them directly into
the @code{sockaddr_in} structure.
-Otherwise, you have to convert the values explicitly. Use
-@code{htons} and @code{ntohs} to convert values for the @code{sin_port}
-member. Use @code{htonl} and @code{ntohl} to convert values for the
+Otherwise, you have to convert the values explicitly. Use @code{htons}
+and @code{ntohs} to convert values for the @code{sin_port} member. Use
+@code{htonl} and @code{ntohl} to convert IPv4 addresses for the
@code{sin_addr} member. (Remember, @code{struct in_addr} is equivalent
-to @code{unsigned long int}.) These functions are declared in
+to @code{uint32_t}.) These functions are declared in
@file{netinet/in.h}.
@pindex netinet/in.h
@comment netinet/in.h
@comment BSD
-@deftypefun {unsigned short int} htons (unsigned short int @var{hostshort})
-This function converts the @code{short} integer @var{hostshort} from
+@deftypefun {uint16_t} htons (uint16_t @var{hostshort})
+This function converts the @code{uint16_t} integer @var{hostshort} from
host byte order to network byte order.
@end deftypefun
@comment netinet/in.h
@comment BSD
-@deftypefun {unsigned short int} ntohs (unsigned short int @var{netshort})
-This function converts the @code{short} integer @var{netshort} from
+@deftypefun {uint16_t} ntohs (uint16_t @var{netshort})
+This function converts the @code{uint16_t} integer @var{netshort} from
network byte order to host byte order.
@end deftypefun
@comment netinet/in.h
@comment BSD
-@deftypefun {unsigned long int} htonl (unsigned long int @var{hostlong})
-This function converts the @code{long} integer @var{hostlong} from
+@deftypefun {uint32_t} htonl (uint32_t @var{hostlong})
+This function converts the @code{uint32_t} integer @var{hostlong} from
host byte order to network byte order.
+
+This is used for IPv4 internet addresses.
@end deftypefun
@comment netinet/in.h
@comment BSD
-@deftypefun {unsigned long int} ntohl (unsigned long int @var{netlong})
-This function converts the @code{long} integer @var{netlong} from
+@deftypefun {uint32_t} ntohl (uint32_t @var{netlong})
+This function converts the @code{uint32_t} integer @var{netlong} from
network byte order to host byte order.
+
+This is used for IPv4 internet addresses.
@end deftypefun
@node Protocols Database
@@ -1511,7 +1688,7 @@ declared in @file{sys/socket.h}.
This function creates a socket and specifies communication style
@var{style}, which should be one of the socket styles listed in
@ref{Communication Styles}. The @var{namespace} argument specifies
-the namespace; it must be @code{PF_FILE} (@pxref{File Namespace}) or
+the namespace; it must be @code{PF_LOCAL} (@pxref{Local Namespace}) or
@code{PF_INET} (@pxref{Internet Namespace}). @var{protocol}
designates the specific protocol (@pxref{Socket Concepts}); zero is
usually right for @var{protocol}.
@@ -1545,7 +1722,7 @@ positioning operations.
@end deftypefun
For examples of how to call the @code{socket} function,
-see @ref{File Namespace}, or @ref{Inet Example}.
+see @ref{Local Socket Example}, or @ref{Inet Example}.
@node Closing a Socket
@@ -1630,7 +1807,7 @@ The @var{namespace}, @var{style}, and @var{protocol} arguments are
interpreted as for the @code{socket} function. @var{style} should be
one of the communication styles listed in @ref{Communication Styles}.
The @var{namespace} argument specifies the namespace, which must be
-@code{AF_FILE} (@pxref{File Namespace}); @var{protocol} specifies the
+@code{AF_LOCAL} (@pxref{Local Namespace}); @var{protocol} specifies the
communications protocol, but zero is the only meaningful value.
If @var{style} specifies a connectionless communication style, then
@@ -1807,7 +1984,7 @@ your server, make it examine the addresses associated with connection
requests or implement some other handshaking or identification
protocol.
-In the File namespace, the ordinary file protection bits control who has
+In the local namespace, the ordinary file protection bits control who has
access to connect to the socket.
@comment sys/socket.h
@@ -1910,7 +2087,7 @@ connections immediately available.
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@@ -1922,7 +2099,7 @@ connectionless communication styles.
@comment sys/socket.h
@comment BSD
-@deftypefun int getpeername (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr})
+@deftypefun int getpeername (int @var{socket}, struct sockaddr *@var{addr}, socklen_t *@var{length-ptr})
The @code{getpeername} function returns the address of the socket that
@var{socket} is connected to; it stores the address in the memory space
specified by @var{addr} and @var{length-ptr}. It stores the length of
@@ -2042,7 +2219,7 @@ signal is ignored or blocked, or if its handler returns, then
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@@ -2060,7 +2237,7 @@ Primitives}.
@deftypefun int recv (int @var{socket}, void *@var{buffer}, size_t @var{size}, int @var{flags})
The @code{recv} function is like @code{read}, but with the additional
flags @var{flags}. The possible values of @var{flags} are described
-In @ref{Socket Data Options}.
+in @ref{Socket Data Options}.
If nonblocking mode is set for @var{socket}, and no data is available to
be read, @code{recv} fails immediately rather than waiting. @xref{File
@@ -2092,7 +2269,7 @@ You never connected this socket.
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@@ -2135,6 +2312,9 @@ stream socket in the Internet namespace. It doesn't do anything
particularly interesting once it has connected to the server; it just
sends a text string to the server and exits.
+This program uses @code{init_sockaddr} to set up the socket address; see
+@ref{Inet Example}.
+
@smallexample
@include inetcli.c.texi
@end smallexample
@@ -2155,8 +2335,8 @@ gotten a message from a client. It does close the socket for that
client when it detects an end-of-file condition (resulting from the
client shutting down its end of the connection).
-This program uses @code{make_socket} and @code{init_sockaddr} to set
-up the socket address; see @ref{Inet Example}.
+This program uses @code{make_socket} to set up the socket address; see
+@ref{Inet Example}.
@smallexample
@include inetsrv.c.texi
@@ -2208,9 +2388,15 @@ in the receiving process, whether any ordinary data was sent before
the mark:
@smallexample
-success = ioctl (socket, SIOCATMARK, &result);
+success = ioctl (socket, SIOCATMARK, &atmark);
@end smallexample
+The @code{integer} variable @var{atmark} is set to a nonzero value if
+the socket's read pointer has reached the ``mark''.
+
+@c Posix 1.g specifies sockatmark for this ioctl. sockatmark is not
+@c implemented yet.
+
Here's a function to discard any ordinary data preceding the
out-of-band mark:
@@ -2222,10 +2408,10 @@ discard_until_mark (int socket)
@{
/* @r{This is not an arbitrary limit; any size will do.} */
char buffer[1024];
- int result, success;
+ int atmark, success;
/* @r{If we have reached the mark, return.} */
- success = ioctl (socket, SIOCATMARK, &result);
+ success = ioctl (socket, SIOCATMARK, &atmark);
if (success < 0)
perror ("ioctl");
if (result)
@@ -2276,9 +2462,8 @@ read_oob (int socket)
/* @r{This is an arbitrary limit.}
@r{Does anyone know how to do this without a limit?} */
char *buffer = (char *) xmalloc (1024);
- struct buffer *link;
int success;
- int result;
+ int atmark;
/* @r{Try again to read the out-of-band data.} */
success = recv (socket, buffer, sizeof buffer, MSG_OOB);
@@ -2294,10 +2479,10 @@ read_oob (int socket)
@}
/* @r{If we fail, see if we are at the mark.} */
- success = ioctl (socket, SIOCATMARK, &result);
+ success = ioctl (socket, SIOCATMARK, &atmark);
if (success < 0)
perror ("ioctl");
- if (result)
+ if (atmark)
@{
/* @r{At the mark; skipping past more ordinary data cannot help.}
@r{So just wait a while.} */
@@ -2351,7 +2536,7 @@ sockets using connectionless communication styles.
* Sending Datagrams:: Sending packets on a datagram socket.
* Receiving Datagrams:: Receiving packets on a datagram socket.
* Datagram Example:: An example program: packets sent over a
- datagram socket in the file namespace.
+ datagram socket in the local namespace.
* Example Receiver:: Another program, that receives those packets.
@end menu
@@ -2397,7 +2582,7 @@ due to a problem related to a previous call.
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@@ -2423,8 +2608,8 @@ packet protocol, you must always know how long a packet to expect.
The @var{addr} and @var{length-ptr} arguments are used to return the
address where the packet came from. @xref{Socket Addresses}. For a
-socket in the file domain, the address information won't be meaningful,
-since you can't read the address of such a socket (@pxref{File
+socket in the local domain, the address information won't be meaningful,
+since you can't read the address of such a socket (@pxref{Local
Namespace}). You can specify a null pointer as the @var{addr} argument
if you are not interested in this information.
@@ -2435,7 +2620,7 @@ are also the same as for @code{recv}.
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@@ -2474,7 +2659,7 @@ semaphores or whatever) are freed even if the thread is cancel.
This function is defined as a cancelation point in multi-threaded
programs. So one has to be prepared for this and make sure that
possibly allocated resources (like memory, files descriptors,
-semaphores or whatever) are freed even if the thread is cancel.
+semaphores or whatever) are freed even if the thread is canceled.
@c @xref{pthread_cleanup_push}, for a method how to do this.
@end deftypefun
@end ignore
@@ -2483,9 +2668,9 @@ semaphores or whatever) are freed even if the thread is cancel.
@subsection Datagram Socket Example
Here is a set of example programs that send messages over a datagram
-stream in the file namespace. Both the client and server programs use the
-@code{make_named_socket} function that was presented in @ref{File
-Namespace}, to create and name their sockets.
+stream in the local namespace. Both the client and server programs use
+the @code{make_named_socket} function that was presented in @ref{Local
+Socket Example}, to create and name their sockets.
First, here is the server program. It sits in a loop waiting for
messages to arrive, bouncing each message back to the sender.
@@ -2741,7 +2926,7 @@ this option, you can actually have two sockets with the same Internet
port number; but the system won't allow you to use the two
identically-named sockets in a way that would confuse the Internet. The
reason for this option is that some higher-level Internet protocols,
-including FTP, require you to keep reusing the same socket number.
+including FTP, require you to keep reusing the same port number.
The value has type @code{int}; a nonzero value means ``yes''.
@@ -2890,7 +3075,7 @@ network.
@comment netdb.h
@comment BSD
-@deftypefun {struct netent *} getnetbyaddr (long @var{net}, int @var{type})
+@deftypefun {struct netent *} getnetbyaddr (unsigned long int @var{net}, int @var{type})
The @code{getnetbyaddr} function returns information about the network
of type @var{type} with number @var{net}. You should specify a value of
@code{AF_INET} for the @var{type} argument for Internet networks.
diff --git a/nis/ypclnt.c b/nis/ypclnt.c
index ceaaa710b7..2d76daded9 100644
--- a/nis/ypclnt.c
+++ b/nis/ypclnt.c
@@ -435,8 +435,8 @@ yp_match (const char *indomain, const char *inmap, const char *inkey,
(caddr_t) & req, (xdrproc_t) xdr_ypresp_val,
(caddr_t) & resp);
- if (result != RPC_SUCCESS)
- return YPERR_RPC;
+ if (result != YPERR_SUCCESS)
+ return result;
if (resp.stat != YP_TRUE)
return ypprot_err (resp.stat);
@@ -519,8 +519,8 @@ yp_next (const char *indomain, const char *inmap, const char *inkey,
(caddr_t) & req, (xdrproc_t) xdr_ypresp_key_val,
(caddr_t) & resp);
- if (result != RPC_SUCCESS)
- return YPERR_RPC;
+ if (result != YPERR_SUCCESS)
+ return result;
if (resp.stat != YP_TRUE)
return ypprot_err (resp.stat);
@@ -557,8 +557,8 @@ yp_master (const char *indomain, const char *inmap, char **outname)
result = do_ypcall (indomain, YPPROC_MASTER, (xdrproc_t) xdr_ypreq_nokey,
(caddr_t) & req, (xdrproc_t) xdr_ypresp_master, (caddr_t) & resp);
- if (result != RPC_SUCCESS)
- return YPERR_RPC;
+ if (result != YPERR_SUCCESS)
+ return result;
if (resp.stat != YP_TRUE)
return ypprot_err (resp.stat);
@@ -587,8 +587,8 @@ yp_order (const char *indomain, const char *inmap, unsigned int *outorder)
result = do_ypcall (indomain, YPPROC_ORDER, (xdrproc_t) xdr_ypreq_nokey,
(caddr_t) & req, (xdrproc_t) xdr_ypresp_order, (caddr_t) & resp);
- if (result != RPC_SUCCESS)
- return YPERR_RPC;
+ if (result != YPERR_SUCCESS)
+ return result;
if (resp.stat != YP_TRUE)
return ypprot_err (resp.stat);
@@ -743,8 +743,8 @@ yp_maplist (const char *indomain, struct ypmaplist **outmaplist)
result = do_ypcall (indomain, YPPROC_MAPLIST, (xdrproc_t) xdr_domainname,
(caddr_t) & indomain, (xdrproc_t) xdr_ypresp_maplist, (caddr_t) & resp);
- if (result != RPC_SUCCESS)
- return YPERR_RPC;
+ if (result != YPERR_SUCCESS)
+ return result;
if (resp.stat != YP_TRUE)
return ypprot_err (resp.stat);
diff --git a/resolv/netdb.h b/resolv/netdb.h
index 9282be334a..3365e5e24a 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h
@@ -28,6 +28,7 @@
/* This is necessary to make this include file properly replace the
Sun version. */
#include <rpc/netdb.h>
+#include <sys/socket.h> /* need socklen_t */
#define __need_size_t
#include <stddef.h>
@@ -119,7 +120,7 @@ extern struct hostent *gethostbyaddr __P ((__const char *__addr, int __len,
extern struct hostent *gethostbyname __P ((__const char *__name));
/* Return entry from host data base for host with NAME. AF must be
- set to the address type which as `AF_INET' for IPv4 or `AF_INET6'
+ set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
for IPv6. */
extern struct hostent *gethostbyname2 __P ((__const char *__name, int __af));
@@ -165,6 +166,19 @@ extern int gethostbyname2_r __P ((__const char *__name, int __af,
#endif /* misc */
+/* Return entry from host data base for host with NAME. AF must be
+ set to the desired address type (either `AF_INET' or `AF_INET6').
+ FLAGS is some combination of the following AI_* values. */
+extern struct hostent *getnodebyname __P ((__const char *__name, int __af,
+ int __flags));
+
+#define AI_V4MAPPED 1 /* IPv4-mapped addresses are acceptable. */
+#define AI_ALL 2 /* Return both IPv4 and IPv6 addresses. */
+#define AI_ADDRCONFIG 4 /* Use configuration of this host to choose
+ returned address type. */
+#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
+
+
/* Description of data base entry for a single network. NOTE: here a
poor assumption is made. The network number is expected to fit
into an unsigned long int variable. */
@@ -413,6 +427,7 @@ struct addrinfo
/* Possible values for `ai_flags' field in `addrinfo' structure. */
# define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
# define AI_CANONNAME 2 /* Request for canonical name. */
+# define AI_NUMERICHOST 3 /* Don't use name resolution. */
/* Error values for `getaddrinfo' function. */
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
@@ -430,11 +445,11 @@ struct addrinfo
# define NI_MAXHOST 1025
# define NI_MAXSERV 32
-# define NI_NUMERICHOST 1
-# define NI_NUMERICSERV 2
-# define NI_NOFQDN 4
-# define NI_NAMEREQD 8
-# define NI_DGRAM 16
+# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
+# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
+# define NI_NOFQDN 4 /* Only return nodename portion. */
+# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
+# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
/* Translate name of a service location and/or a service name to set of
socket addresses. */
@@ -449,7 +464,7 @@ extern void freeaddrinfo __P ((struct addrinfo *__ai));
extern char *gai_strerror __P ((int __ecode));
/* Translate a socket address to a location and service name. */
-extern int getnameinfo __P ((__const struct sockaddr *__sa, size_t __salen,
+extern int getnameinfo __P ((__const struct sockaddr *__sa, socklen_t __salen,
char *__host, size_t __hostlen,
char *__serv, size_t __servlen,
int __flags));
diff --git a/socket/Makefile b/socket/Makefile
index 1651b75e1c..9a36da19d2 100644
--- a/socket/Makefile
+++ b/socket/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1991, 1995, 1996, 1997, 1998 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
@@ -21,7 +21,8 @@
#
subdir := socket
-headers := sys/socket.h sys/un.h bits/sockaddr.h bits/socket.h
+headers := sys/socket.h sys/un.h bits/sockaddr.h bits/socket.h \
+ bits/sockunion.h
routines := accept bind connect getpeername getsockname getsockopt \
listen recv recvfrom recvmsg send sendmsg sendto \
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 2358ab5582..e94f56f0fa 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -33,6 +33,9 @@ __BEGIN_DECLS
`struct msghdr', and `struct linger' types. */
#include <bits/socket.h>
+/* Get the definition of `sockaddr_union'. */
+#include <bits/sockunion.h>
+
#ifdef __USE_BSD
/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire
format in the grotty old 4.3 `talk' protocol. */
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index eb9d25ec6f..bf7b2638d2 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -733,16 +733,20 @@ extern int grantpt __P ((int __fd));
Call after grantpt(). */
extern int unlockpt __P ((int __fd));
-/* Get the name of the slave. */
+/* Return the pathname of the pseudo terminal slave assoicated with
+ the master FD is open on, or NULL on errors.
+ The returned storage is good until the next call to this function. */
extern char *ptsname __P ((int __fd));
#endif
#ifdef __USE_GNU
-/* Reentrant version of ptsname. */
-extern char *__ptsname_r __P ((int __fd, char *__buf, unsigned int __len));
-extern char *ptsname_r __P ((int __fd, char *__buf, unsigned int __len));
+/* Store at most BUFLEN characters of the pathname of the slave pseudo
+ terminal associated with the master FD is open on in BUF.
+ Return 0 on success, otherwise an error number. */
+extern int __ptsname_r __P ((int __fd, char *__buf, size_t __buflen));
+extern int ptsname_r __P ((int __fd, char *__buf, size_t __buflen));
-/* Open a master pseudo tty and return its file descriptor. */
+/* Open a master pseudo terminal and return its file descriptor. */
extern int __getpt __P ((void));
extern int getpt __P ((void));
#endif
diff --git a/string/string.h b/string/string.h
index b8c33b00b1..15491f8629 100644
--- a/string/string.h
+++ b/string/string.h
@@ -198,6 +198,7 @@ extern size_t strlen __P ((__const char *__s));
#ifdef __USE_GNU
/* Find the length of STRING, but scan at most MAXLEN characters.
If no '\0' terminator is found in that many characters, return MAXLEN. */
+extern size_t __strnlen __P ((__const char *__string, size_t __maxlen));
extern size_t strnlen __P ((__const char *__string, size_t __maxlen));
#endif
diff --git a/string/strnlen.c b/string/strnlen.c
index ab95d17096..17b1193f0b 100644
--- a/string/strnlen.c
+++ b/string/strnlen.c
@@ -1,5 +1,5 @@
/* Find the length of STRING, but scan at most MAXLEN characters.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 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
@@ -23,8 +23,9 @@
If no '\0' terminator is found in that many characters, return MAXLEN. */
size_t
-strnlen (const char *string, size_t maxlen)
+__strnlen (const char *string, size_t maxlen)
{
const char *end = memchr (string, '\0', maxlen);
return end ? end - string : maxlen;
}
+weak_alias (__strnlen, strnlen)
diff --git a/sysdeps/generic/bits/sockaddr.h b/sysdeps/generic/bits/sockaddr.h
index 73a0e26ec4..1c523444ba 100644
--- a/sysdeps/generic/bits/sockaddr.h
+++ b/sysdeps/generic/bits/sockaddr.h
@@ -1,5 +1,5 @@
/* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 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
@@ -37,5 +37,8 @@ typedef unsigned short int sa_family_t;
#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))
+/* Return the length of a `sockaddr' structure. */
+#define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
+extern int __libc_sa_len __P ((sa_family_t __af));
#endif /* bits/sockaddr.h */
diff --git a/sysdeps/generic/bits/socket.h b/sysdeps/generic/bits/socket.h
index a2858b8de8..5dc1e65370 100644
--- a/sysdeps/generic/bits/socket.h
+++ b/sysdeps/generic/bits/socket.h
@@ -1,5 +1,5 @@
/* System-specific socket constants and types. Generic/4.3 BSD version.
- Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 94, 95, 96, 97, 98 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
@@ -17,7 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _SYS_SOCKET_H
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
diff --git a/sysdeps/generic/bits/sockunion.h b/sysdeps/generic/bits/sockunion.h
new file mode 100644
index 0000000000..8f82ce0c20
--- /dev/null
+++ b/sysdeps/generic/bits/sockunion.h
@@ -0,0 +1,40 @@
+/* Definition of `sockaddr_union'. Generic/4.2 BSD version.
+ Copyright (C) 1998 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Never include this file directly; use <sys/socket.h> instead.
+ */
+
+#ifndef _BITS_SOCKUNION_H
+#define _BITS_SOCKUNION_H 1
+
+#include <netinet/in.h>
+#include <sys/un.h>
+
+/* Union of all sockaddr types (required by IPv6 Basic API). */
+union sockaddr_union
+ {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_un sun;
+ char __maxsize[128];
+ };
+
+#endif /* bits/sockunion.h */
diff --git a/sysdeps/generic/ptsname.c b/sysdeps/generic/ptsname.c
index 7a442d0d69..1a2e61f03c 100644
--- a/sysdeps/generic/ptsname.c
+++ b/sysdeps/generic/ptsname.c
@@ -17,8 +17,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdlib.h>
#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
/* Given the file descriptor of a master pty, return the pathname
of the associated slave. */
@@ -28,14 +29,14 @@ ptsname (fd)
int fd __attribute__ ((unused));
{
__set_errno (ENOSYS);
- return 0;
+ return NULL;
}
-char *
+int
__ptsname_r (fd, buf, len)
int fd __attribute__ ((unused));
char *buf __attribute__ ((unused));
- unsigned int len __attribute__ ((unused));
+ size_t len __attribute__ ((unused));
{
__set_errno (ENOSYS);
return 0;
diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h
index a5dc446c67..1145560ab9 100644
--- a/sysdeps/mach/hurd/bits/ioctls.h
+++ b/sysdeps/mach/hurd/bits/ioctls.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1996, 1997, 1998 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
@@ -16,8 +16,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _SYS_IOCTL_H
-# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
+#if !defined _HURD_IOCTL_H && !defined _SYS_IOCTLS_H
+# error "Never use <bits/ioctls.h> directly; include <hurd/ioctl.h> instead."
#endif
/* These macros are also defined in <bits/termios.h> (with numerically
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 7c936e9466..6fd6ea356f 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -546,8 +546,8 @@ __close (int fd)
return 0;
}
-caddr_t weak_function
-__mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+__ptr_t weak_function
+__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
{
error_t err;
vm_prot_t vmprot;
@@ -656,7 +656,7 @@ _dl_sysdep_message (const char *msg, ...)
? VM_INHERIT_SHARE : VM_INHERIT_COPY);
}
- return err ? (caddr_t) __hurd_fail (err) : (caddr_t) mapaddr;
+ return err ? (__ptr_t) __hurd_fail (err) : (__ptr_t) mapaddr;
}
void weak_function
diff --git a/sysdeps/posix/mkstemp.c b/sysdeps/posix/mkstemp.c
index 3765488f73..fceb59b4be 100644
--- a/sysdeps/posix/mkstemp.c
+++ b/sysdeps/posix/mkstemp.c
@@ -19,9 +19,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/time.h>
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
@@ -33,30 +35,54 @@ mkstemp (template)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ static uint32_t value;
+ struct timeval tv;
+ char *XXXXXX;
size_t len;
- size_t i;
+ int count;
len = strlen (template);
if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
{
__set_errno (EINVAL);
- return -1;
+ return NULL;
}
- if (sprintf (&template[len - 5], "%.5u",
- (unsigned int) getpid () % 100000) != 5)
- /* Inconceivable lossage. */
- return -1;
+ /* This is where the Xs start. */
+ XXXXXX = &template[len - 6];
- for (i = 0; i < sizeof (letters); ++i)
+ /* Get some more or less random data. */
+ __gettimeofday (&tv, NULL);
+ value += tv.tv_usec | getpid ();
+
+ for (count = 0; count < TMP_MAX; ++count)
{
+ struct stat ignored;
+ uint32_t v = value;
int fd;
- template[len - 6] = letters[i];
+ /* Fill in the random bits. */
+ XXXXXX[0] = letters[v % 62];
+ v /= 62;
+ XXXXXX[1] = letters[v % 62];
+ v /= 62;
+ XXXXXX[2] = letters[v % 62];
+ v /= 62;
+ XXXXXX[3] = letters[v % 62];
+ v /= 62;
+ XXXXXX[4] = letters[v % 62];
+ v /= 62;
+ XXXXXX[5] = letters[v % 62];
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
if (fd >= 0)
+ /* The file does not exist. */
return fd;
+
+ /* This is a random value. It is only necessary that the next
+ TMP_MAX values generated by adding 7777 to VALUE are different
+ with (module 2^32). */
+ value += 7777;
}
/* We return the null string if we can't find a unique file name. */
diff --git a/sysdeps/posix/mktemp.c b/sysdeps/posix/mktemp.c
index f7a1783c8f..6bbc4c0ce9 100644
--- a/sysdeps/posix/mktemp.c
+++ b/sysdeps/posix/mktemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996, 1998 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
@@ -16,13 +16,15 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
@@ -33,8 +35,11 @@ mktemp (template)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ static uint32_t value;
+ struct timeval tv;
+ char *XXXXXX;
size_t len;
- size_t i;
+ int count;
len = strlen (template);
if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
@@ -43,20 +48,39 @@ mktemp (template)
return NULL;
}
- if (sprintf (&template[len - 5], "%.5u",
- (unsigned int) getpid () % 100000) != 5)
- /* Inconceivable lossage. */
- return NULL;
+ /* This is where the Xs start. */
+ XXXXXX = &template[len - 6];
- for (i = 0; i < sizeof (letters); ++i)
+ /* Get some more or less random data. */
+ __gettimeofday (&tv, NULL);
+ value += tv.tv_usec | getpid ();
+
+ for (count = 0; count < TMP_MAX; ++count)
{
struct stat ignored;
+ uint32_t v = value;
- template[len - 6] = letters[i];
+ /* Fill in the random bits. */
+ XXXXXX[0] = letters[v % 62];
+ v /= 62;
+ XXXXXX[1] = letters[v % 62];
+ v /= 62;
+ XXXXXX[2] = letters[v % 62];
+ v /= 62;
+ XXXXXX[3] = letters[v % 62];
+ v /= 62;
+ XXXXXX[4] = letters[v % 62];
+ v /= 62;
+ XXXXXX[5] = letters[v % 62];
if (stat (template, &ignored) < 0 && errno == ENOENT)
/* The file does not exist. So return this name. */
return template;
+
+ /* This is a random value. It is only necessary that the next
+ TMP_MAX values generated by adding 7777 to VALUE are different
+ with (module 2^32). */
+ value += 7777;
}
/* We return the null string if we can't find a unique file name. */
diff --git a/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h b/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h
index d70dfe4031..4d5fa1d33a 100644
--- a/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h
@@ -1,5 +1,5 @@
/* Definition of `struct sockaddr_*' common members. 4.4 BSD version.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 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
@@ -38,5 +38,7 @@ typedef unsigned char sa_family_t;
#define __SOCKADDR_COMMON_SIZE (2 * sizeof (unsigned char))
+/* Return the length of a `sockaddr' structure. */
+#define SA_LEN(_x) ((_x)->sa_len)
#endif /* bits/sockaddr.h */
diff --git a/sysdeps/unix/bsd/unlockpt.c b/sysdeps/unix/bsd/unlockpt.c
index 3de46eeda9..b25231c865 100644
--- a/sysdeps/unix/bsd/unlockpt.c
+++ b/sysdeps/unix/bsd/unlockpt.c
@@ -34,7 +34,7 @@ unlockpt (fd)
{
char buf[PTYNAMELEN];
- if (ptsname_r (fd, buf, PTYNAMELEN))
+ if (__ptsname_r (fd, buf, PTYNAMELEN))
return -1;
return revoke (buf);
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index 65a0d98a73..24f0e17792 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -47,9 +47,9 @@ grantpt (fd)
char namebuf[PTYNAMELEN];
/* Some systems do it for us. */
- if (__ptsname_r (fd, namebuf, PTYNAMELEN) == NULL)
+ if (__ptsname_r (fd, namebuf, PTYNAMELEN) != 0)
return -1;
- if (stat (namebuf, &st))
+ if (__xstat (_STAT_VER, namebuf, &st) != 0)
return -1;
if (st.st_uid == getuid ())
diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist
index 181ac53d5e..b938504627 100644
--- a/sysdeps/unix/sysv/linux/Dist
+++ b/sysdeps/unix/sysv/linux/Dist
@@ -46,6 +46,7 @@ rt_sigqueueinfo.c
rt_sigreturn.c
rt_sigsuspend.c
rt_sigtimedwait.c
+sa_len.c
scsi/sg.h
scsi/scsi.h
sys/acct.h
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 2bc194384a..9abab1e1ce 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -58,7 +58,7 @@ ifeq ($(subdir),socket)
sysdep_headers += net/if.h net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h
-sysdep_routines += cmsg_nxthdr
+sysdep_routines += cmsg_nxthdr sa_len
endif
ifeq ($(subdir),sunrpc)
diff --git a/sysdeps/unix/sysv/linux/arm/profil-counter.h b/sysdeps/unix/sysv/linux/arm/profil-counter.h
index d84e70e7ff..0d5024fa47 100644
--- a/sysdeps/unix/sysv/linux/arm/profil-counter.h
+++ b/sysdeps/unix/sysv/linux/arm/profil-counter.h
@@ -1,5 +1,5 @@
/* Low-level statistical profiling support function. Linux/ARM version.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 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
@@ -18,9 +18,54 @@
Boston, MA 02111-1307, USA. */
#include <signal.h>
+#include <asm/ptrace.h>
+
+union k_sigcontext
+ {
+ struct
+ {
+ unsigned long int trap_no;
+ unsigned long int error_code;
+ unsigned long int oldmask;
+ unsigned long int arm_r0;
+ unsigned long int arm_r1;
+ unsigned long int arm_r2;
+ unsigned long int arm_r3;
+ unsigned long int arm_r4;
+ unsigned long int arm_r5;
+ unsigned long int arm_r6;
+ unsigned long int arm_r7;
+ unsigned long int arm_r8;
+ unsigned long int arm_r9;
+ unsigned long int arm_r10;
+ unsigned long int arm_fp;
+ unsigned long int arm_ip;
+ unsigned long int arm_sp;
+ unsigned long int arm_lr;
+ unsigned long int arm_pc;
+ unsigned long int arm_cpsr;
+ } v21;
+ struct
+ {
+ unsigned long int magic;
+ struct pt_regs reg;
+ unsigned long int trap_no;
+ unsigned long int error_code;
+ unsigned long int oldmask;
+ } v20;
+};
void
-profil_counter (int signo, struct sigcontext sc)
+profil_counter (int signo, int _a2, int _a3, int _a4, union k_sigcontext sc)
{
- profil_count ((void *) sc.reg.ARM_pc);
+ /* The format of struct sigcontext changed between 2.0 and 2.1 kernels.
+ Fortunately 2.0 puts a magic number in the first word and this is not
+ a legal value for `trap_no', so we can tell them apart. */
+
+ void *pc;
+ if (sc.v20.magic == 0x4B534154)
+ pc = (void *) sc.v20.reg.ARM_pc;
+ else
+ pc = (void *) sc.v21.arm_pc;
+ profil_count (pc);
}
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 0938a17a81..e74b011c1d 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -17,7 +17,10 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _SYS_SOCKET_H
+#ifndef __BITS_SOCKET_H
+#define __BITS_SOCKET_H
+
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
@@ -230,3 +233,5 @@ struct linger
int l_onoff; /* Nonzero to linger on close. */
int l_linger; /* Time to linger. */
};
+
+#endif /* bits/socket.h */
diff --git a/sysdeps/unix/sysv/linux/bits/sockunion.h b/sysdeps/unix/sysv/linux/bits/sockunion.h
new file mode 100644
index 0000000000..b66ac41f23
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/sockunion.h
@@ -0,0 +1,46 @@
+/* Definition of `sockaddr_union'. Linux version.
+ Copyright (C) 1998 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
+#include <netash/ash.h>
+#include <netatalk/at.h>
+#include <netax25/ax25.h>
+#include <netinet/in.h>
+#include <netipx/ipx.h>
+#include <netrose/rose.h>
+#include <sys/un.h>
+
+/* Union of all sockaddr types (required by IPv6 Basic API). This is
+ somewhat evil. */
+union sockaddr_union
+ {
+ struct sockaddr sa;
+ struct sockaddr_ash sash;
+ struct sockaddr_at sat;
+ struct sockaddr_ax25 sax25;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_ipx sipx;
+ struct sockaddr_rose rose;
+ struct sockaddr_un sun;
+ char __maxsize[128];
+ };
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 9d9bf0e0b2..de66b5cb21 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -117,52 +117,46 @@ if_nameindex (void)
#else
int fd = opensock ();
struct ifconf ifc;
- unsigned int rq_ifs = 4, nifs, i;
+ unsigned int nifs, i;
int rq_len;
struct if_nameindex *idx = NULL;
-#ifdef SIOCGIFCOUNT
- static int siocgifcount_works = 1;
-#endif
+ static int new_siocgifconf = 1;
+#define RQ_IFS 4
if (fd < 0)
return NULL;
-#ifdef SIOCGIFCOUNT
- /* We may be able to find out how many interfaces really exist, rather
- than guessing. This ioctl is not present in kernels before version
- 2.1.50. */
- if (siocgifcount_works)
- {
- int serrno = errno;
+ ifc.ifc_buf = NULL;
- if (ioctl (fd, SIOCGIFCOUNT, &nifs) < 0)
+ /* We may be able to get the needed buffer size directly, rather than
+ guessing. */
+ if (new_siocgifconf)
+ {
+ ifc.ifc_buf = NULL;
+ ifc.ifc_len = 0;
+ if (ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
{
- if (errno == EINVAL)
- {
- siocgifcount_works = 0;
- __set_errno (serrno);
- }
+ new_siocgifconf = 0;
+ rq_len = RQ_IFS * sizeof (struct ifreq);
}
else
- rq_ifs = nifs + 1;
+ rq_len = ifc.ifc_len;
}
-#endif
-
- ifc.ifc_buf = NULL;
+ else
+ rq_len = RQ_IFS * sizeof (struct ifreq);
/* Read all the interfaces out of the kernel. */
do
{
- rq_len = ifc.ifc_len = rq_ifs * sizeof (struct ifreq);
- ifc.ifc_buf = alloca (ifc.ifc_len);
+ ifc.ifc_buf = alloca (ifc.ifc_len = rq_len);
if ((ifc.ifc_buf == NULL) || (ioctl (fd, SIOCGIFCONF, &ifc) < 0))
{
close (fd);
return NULL;
}
- rq_ifs *= 2;
+ rq_len *= 2;
}
- while (ifc.ifc_len == rq_len);
+ while (ifc.ifc_len == rq_len && new_siocgifconf == 0);
nifs = ifc.ifc_len / sizeof (struct ifreq);
diff --git a/sysdeps/unix/sysv/linux/mips/bits/socket.h b/sysdeps/unix/sysv/linux/mips/bits/socket.h
index f481a478b2..75ed54fc56 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/socket.h
@@ -17,7 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _SYS_STAT_H
+#if !defined _SYS_STAT_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
index 77b6d80ac8..c81f23504c 100644
--- a/sysdeps/unix/sysv/linux/ptsname.c
+++ b/sysdeps/unix/sysv/linux/ptsname.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
+#include <unistd.h>
#include "pty-internal.h"
@@ -40,21 +41,38 @@ char *
ptsname (fd)
int fd;
{
- return __ptsname_r (fd, namebuf, PTYNAMELEN);
+ return __ptsname_r (fd, namebuf, PTYNAMELEN) != 0 ? NULL : namebuf;
}
-char *
-__ptsname_r (fd, buf, len)
+int
+__ptsname_r (fd, buf, buflen)
int fd;
char *buf;
- unsigned int len;
+ size_t buflen;
{
- char nbuf[PTYNAMELEN], idbuf[6];
- int ptyno;
struct stat st;
+ int save = errno;
+ int ptyno;
+ char nbuf[PTYNAMELEN], idbuf[6];
+ char *cp;
#ifdef TIOCGPTN
static int tiocgptn_works = 1;
+#endif
+
+ if (!buf)
+ {
+ __set_errno (EINVAL);
+ return EINVAL;
+ }
+
+ if (!__isatty (fd))
+ {
+ __set_errno (ENOTTY);
+ return ENOTTY;
+ }
+
+#ifdef TIOCGPTN
if (tiocgptn_works)
{
if (ioctl (fd, TIOCGPTN, &ptyno) == 0)
@@ -62,23 +80,21 @@ __ptsname_r (fd, buf, len)
else
{
if(errno != EINVAL)
- return 0;
+ return errno;
else
tiocgptn_works = 0;
}
}
#endif
- /* /dev/ptmx will make it into the kernel before 32 bit dev_t, so
- this should be safe. */
- if (__fxstat (_STAT_VER, fd, &st))
- return 0;
+ if (__fxstat (_STAT_VER, fd, &st) < 0)
+ return errno;
ptyno = minor (st.st_rdev);
if (major (st.st_rdev) == 4)
ptyno -= 128;
#ifdef TIOCGPTN
-gotit:
+ gotit:
#endif
/* Two different possible naming schemes for pty slaves:
the SVr4 way. */
@@ -86,22 +102,32 @@ gotit:
idbuf[5] = '\0';
__stpcpy (__stpcpy (nbuf, "/dev/pts/"),
_itoa_word (ptyno, &idbuf[4], 10, 0));
- if (!__xstat (_STAT_VER, nbuf, &st))
- return strncpy (buf, nbuf, len);
- else
- if (errno != ENOENT)
- return NULL;
-
- /* ...and the BSD way. */
- nbuf[5] = 't';
- nbuf[7] = 'y';
- nbuf[8] = __ptyname1[ptyno / 16];
- nbuf[9] = __ptyname2[ptyno % 16];
- nbuf[10] = '\0';
-
- if (__xstat (_STAT_VER, nbuf, &st))
- return NULL;
-
- return strncpy (buf, nbuf, len);
+ if (__xstat (_STAT_VER, nbuf, &st) < 0)
+ {
+ if (errno != ENOENT)
+ return errno;
+
+ /* ...and the BSD way. */
+ nbuf[5] = 't';
+ nbuf[7] = 'y';
+ nbuf[8] = __ptyname1[ptyno / 16];
+ nbuf[9] = __ptyname2[ptyno % 16];
+ nbuf[10] = '\0';
+
+ if (__xstat (_STAT_VER, nbuf, &st) < 0)
+ return errno;
+ }
+
+ if (buflen < strlen (nbuf) + 1)
+ {
+ __set_errno (ERANGE);
+ return ERANGE;
+ }
+
+ cp = __stpncpy (buf, nbuf, buflen);
+ cp[0] = '\0';
+
+ __set_errno (save);
+ return 0;
}
weak_alias (__ptsname_r, ptsname_r)
diff --git a/sysdeps/unix/sysv/linux/sa_len.c b/sysdeps/unix/sysv/linux/sa_len.c
new file mode 100644
index 0000000000..3c66040238
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sa_len.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1998 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sys/socket.h>
+
+#include <netatalk/at.h>
+#include <netax25/ax25.h>
+#include <netinet/in.h>
+#include <netipx/ipx.h>
+#include <netrose/rose.h>
+
+int
+__libc_sa_len (sa_family_t af)
+{
+ switch (af)
+ {
+ case AF_APPLETALK:
+ return sizeof (struct sockaddr_at);
+ case AF_AX25:
+ return sizeof (struct sockaddr_ax25);
+ case AF_INET:
+ return sizeof (struct sockaddr_in);
+ case AF_INET6:
+ return sizeof (struct sockaddr_in6);
+ case AF_IPX:
+ return sizeof (struct sockaddr_ipx);
+ case AF_ROSE:
+ return sizeof (struct sockaddr_rose);
+ }
+ return 0;
+}
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index 5dd46da551..a601489652 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1995, 1996, 1997, 1998 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
@@ -22,21 +22,22 @@
subdir := wcsmbs
headers := wchar.h
-distribute := wcwidth.h
+distribute := wcwidth.h wcsmbsload.h
routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy \
btowc wctob mbsinit \
mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \
- mbsnrtowcs wcsnrtombs wmemrtowcs wmemrtombs \
+ mbsnrtowcs wcsnrtombs wcsnlen \
wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \
wcstol_l wcstoul_l wcstoll_l wcstoull_l \
wcstod_l wcstold_l wcstof_l \
wcscoll wcsxfrm \
wcwidth wcswidth \
wcscoll_l wcsxfrm_l \
- wcscasecmp wcsncase wcscasecmp_l wcsncase_l
+ wcscasecmp wcsncase wcscasecmp_l wcsncase_l \
+ wcsmbsload
tests := tst-wcstof
diff --git a/wcsmbs/btowc.c b/wcsmbs/btowc.c
index 4c2f9df215..268b1f2378 100644
--- a/wcsmbs/btowc.c
+++ b/wcsmbs/btowc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
@@ -17,18 +17,52 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <gconv.h>
#include <stdio.h>
+#include <string.h>
#include <wchar.h>
+#include <wcsmbsload.h>
-/* We use UTF8 encoding for multibyte strings and therefore a valid
- one byte multibyte string only can have a value from 0 to 0x7f. */
wint_t
btowc (c)
int c;
{
- if (WEOF != (wint_t) EOF || c < 0 || c > 0x7f)
+ char buf[sizeof (wchar_t)];
+ struct gconv_step_data data;
+ char inbuf[1];
+ size_t inbytes;
+ size_t converted;
+ int status;
+
+ /* If the parameter does not fit into one byte or it is the EOF value
+ we can give the answer now. */
+ if (c < -128 || c > 127 || c == EOF)
+ return WEOF;
+
+ /* Tell where we want the result. */
+ data.outbuf = (char *) buf;
+ data.outbufavail = 0;
+ data.outbufsize = sizeof (wchar_t);
+ data.is_last = 1;
+ data.statep = &data.__state;
+
+ /* Make sure we start in the initial state. */
+ memset (&data.__state, '\0', sizeof (mbstate_t));
+
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
+
+ /* Create the input string. */
+ inbuf[0] = c;
+ inbytes = 1;
+
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, inbuf, &inbytes,
+ &converted, 0);
+ /* The conversion failed. */
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT)
return WEOF;
- else
- return (wint_t) c;
+
+ return *(wchar_t *)buf;
}
diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c
index cf0bbd6ce2..99bc5a4797 100644
--- a/wcsmbs/mbrtowc.c
+++ b/wcsmbs/mbrtowc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,113 +18,77 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <gconv.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
size_t
__mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
- size_t used = 0;
-
- if (ps == NULL)
- ps = &internal;
-
+ wchar_t buf[1];
+ struct gconv_step_data data;
+ size_t inbytes;
+ int status;
+ size_t result;
+
+ /* Tell where we want the result. */
+ data.outbuf = (char *) (pwc ?: buf);
+ data.outbufavail = 0;
+ data.outbufsize = sizeof (wchar_t);
+ data.is_last = 1;
+ data.statep = ps ?: &state;
+
+ /* A first special case is if S is NULL. This means put PS in the
+ initial state. */
if (s == NULL)
{
- /* See first paragraph of description in 7.16.6.3.2. */
- ps->count = 0;
- return 0;
+ data.outbuf = (char *) buf;
+ s = "";
+ n = 1;
}
- if (n > 0)
- {
- if (ps->count == 0)
- {
- unsigned char byte = (unsigned char) *s++;
- ++used;
-
- /* We must look for a possible first byte of a UTF8 sequence. */
- if (byte < 0x80)
- {
- /* One byte sequence. */
- if (pwc != NULL)
- *pwc = (wchar_t) byte;
- return byte ? used : 0;
- }
-
- if ((byte & 0xc0) == 0x80 || (byte & 0xfe) == 0xfe)
- {
- /* Oh, oh. An encoding error. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
-
- if ((byte & 0xe0) == 0xc0)
- {
- /* We expect two bytes. */
- ps->count = 1;
- ps->value = byte & 0x1f;
- }
- else if ((byte & 0xf0) == 0xe0)
- {
- /* We expect three bytes. */
- ps->count = 2;
- ps->value = byte & 0x0f;
- }
- else if ((byte & 0xf8) == 0xf0)
- {
- /* We expect four bytes. */
- ps->count = 3;
- ps->value = byte & 0x07;
- }
- else if ((byte & 0xfc) == 0xf8)
- {
- /* We expect five bytes. */
- ps->count = 4;
- ps->value = byte & 0x03;
- }
- else
- {
- /* We expect six bytes. */
- ps->count = 5;
- ps->value = byte & 0x01;
- }
- }
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
- /* We know we have to handle a multibyte character and there are
- some more bytes to read. */
- while (used < n)
+ /* Do a normal conversion. */
+ inbytes = n;
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, s, &inbytes, NULL, 0);
+
+ /* There must not be any problems with the conversion but illegal input
+ characters. The output buffer must be large enough, otherwise the
+ definition of MB_CUR_MAX is not correct. All the other possible
+ errors also must not happen. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT);
+
+ if (status == GCONV_OK)
+ {
+ if (*(wchar_t *)data.outbuf == L'\0')
{
- /* The second to sixths byte must be of the form 10xxxxxx. */
- unsigned char byte = (unsigned char) *s++;
- ++used;
-
- if ((byte & 0xc0) != 0x80)
- {
- /* Oh, oh. An encoding error. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
-
- ps->value <<= 6;
- ps->value |= byte & 0x3f;
-
- if (--ps->count == 0)
- {
- /* The character is finished. */
- if (pwc != NULL)
- *pwc = (wchar_t) ps->value;
- return ps->value ? used : 0;
- }
+ /* The converted character is the NUL character. */
+ assert (mbsinit (data.statep));
+ result = 0;
}
+ else
+ result = n - inbytes;
+ }
+ else
+ {
+ result = status == GCONV_INCOMPLETE_INPUT ? (size_t) -2 : (size_t) -1;
+ __set_errno (EILSEQ);
}
- return (size_t) -2;
+ return result;
}
weak_alias (__mbrtowc, mbrtowc)
diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c
index db67d5c1bb..ded15e4299 100644
--- a/wcsmbs/mbsnrtowcs.c
+++ b/wcsmbs/mbsnrtowcs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,16 +18,20 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <gconv.h>
+#include <string.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-/* We don't need the state really because we don't have shift states
- to maintain between calls to this function. */
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
/* This is a non-standard function but it is very useful in the
implementation of stdio because we have to deal with unterminated
@@ -40,128 +44,89 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
size_t len;
mbstate_t *ps;
{
- size_t written = 0;
- const char *run = *src;
- const char *last = run + nmc;
- wchar_t value;
- size_t count;
+ size_t inbytes_in;
+ struct gconv_step_data data;
+ size_t result = 0;
+ int status;
- if (ps == NULL)
- ps = &internal;
+ /* Tell where we want the result. */
+ data.is_last = 1;
+ data.statep = ps ?: &state;
- /* Get information from last use of this state. */
- count = ps->count;
- value = ps->value;
+ if (nmc == 0)
+ return 0;
+ inbytes_in = __strnlen (*src, nmc - 1) + 1;
- if (dst == NULL)
- /* The LEN parameter has to be ignored if we don't actually write
- anything. */
- len = ~0;
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
- /* Copy all words. */
- while (written < len && run < last)
+ /* We have to handle DST == NULL special. */
+ if (dst == NULL)
{
- unsigned char byte;
-
- /* Store address of next byte to process. */
- *src = run;
-
- /* Start reading a new character only if we are in the initial
- state. */
- if (count == 0)
- {
- byte = *run++;
-
- /* We expect a start of a new multibyte character. */
- if (byte < 0x80)
- {
- /* One byte sequence. */
- count = 0;
- value = byte;
- }
- else if ((byte & 0xe0) == 0xc0)
- {
- count = 1;
- value = byte & 0x1f;
- }
- else if ((byte & 0xf0) == 0xe0)
- {
- /* We expect three bytes. */
- count = 2;
- value = byte & 0x0f;
- }
- else if ((byte & 0xf8) == 0xf0)
- {
- /* We expect four bytes. */
- count = 3;
- value = byte & 0x07;
- }
- else if ((byte & 0xfc) == 0xf8)
- {
- /* We expect five bytes. */
- count = 4;
- value = byte & 0x03;
- }
- else if ((byte & 0xfe) == 0xfc)
- {
- /* We expect six bytes. */
- count = 5;
- value = byte & 0x01;
- }
- else
- {
- /* This is an illegal encoding. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
- }
-
- /* Read the possible remaining bytes. */
- while (run < last && count > 0)
- {
- byte = *run++;
- --count;
-
- if ((byte & 0xc0) != 0x80)
- {
- /* This is an illegal encoding. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
-
- value <<= 6;
- value |= byte & 0x3f;
- }
-
- /* If this character is only partially available remember this. */
- if (run == last && count != 0)
+ wchar_t buf[64]; /* Just an arbitrary size. */
+ size_t inbytes = inbytes_in;
+ const char *inbuf = *src;
+ size_t written;
+
+ data.outbuf = (char *) buf;
+ data.outbufsize = sizeof (buf);
+ do
{
- ps->count = count;
- ps->value = value;
- break;
+ inbuf += inbytes_in - inbytes;
+ inbytes_in = inbytes;
+ data.outbufavail = 0;
+ written = 0;
+
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, inbuf, &inbytes,
+ &written, 0);
+ result += written;
}
+ while (status == GCONV_FULL_OUTPUT);
- /* Store value is required. */
- if (dst != NULL)
- *dst++ = value;
-
- /* The whole sequence is read. Check whether end of string is
- reached. */
- if (value == L'\0')
+ if (status == GCONV_OK && ((wchar_t *) dst)[written - 1] == L'\0')
+ /* Don't count the NUL character in. */
+ --result;
+ }
+ else
+ {
+ /* This code is based on the safe assumption that all internal
+ multi-byte encodings use the NUL byte only to mark the end
+ of the string. */
+ size_t inbytes = inbytes_in;
+
+ data.outbuf = (char *) dst;
+ data.outbufsize = len * sizeof (wchar_t);
+ data.outbufavail = 0;
+
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, *src, &inbytes,
+ &result, 0);
+
+ /* We have to determine whether the last character converted
+ is the NUL character. */
+ if (status == GCONV_OK && ((wchar_t *) dst)[result - 1] == L'\0')
{
- /* Found the end of the string. */
+ assert (result > 0);
+ assert (mbsinit (data.statep));
*src = NULL;
- ps->count = 0;
- return written;
+ --result;
}
-
- /* Increment counter of produced words. */
- ++written;
+ else
+ *src += inbytes_in - inbytes;
}
- /* Store address of next byte to process. */
- *src = run;
+ /* There must not be any problems with the conversion but illegal input
+ characters. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT);
+
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT)
+ {
+ result = (size_t) -1;
+ __set_errno (EILSEQ);
+ }
- return written;
+ return result;
}
weak_alias (__mbsnrtowcs, mbsnrtowcs)
diff --git a/wcsmbs/mbsrtowcs.c b/wcsmbs/mbsrtowcs.c
index 84d4cbf66d..d0af40fb54 100644
--- a/wcsmbs/mbsrtowcs.c
+++ b/wcsmbs/mbsrtowcs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,16 +18,20 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <gconv.h>
+#include <string.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-/* We don't need the state really because we don't have shift states
- to maintain between calls to this function. */
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
size_t
__mbsrtowcs (dst, src, len, ps)
@@ -36,108 +40,86 @@ __mbsrtowcs (dst, src, len, ps)
size_t len;
mbstate_t *ps;
{
- size_t written = 0;
- const char *run = *src;
+ struct gconv_step_data data;
+ size_t result = 0;
+ int status;
- if (ps == NULL)
- ps = &internal;
+ /* Tell where we want the result. */
+ data.is_last = 1;
+ data.statep = ps ?: &state;
- if (dst == NULL)
- /* The LEN parameter has to be ignored if we don't actually write
- anything. */
- len = ~0;
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
- /* Copy all words. */
- while (written < len)
+ /* We have to handle DST == NULL special. */
+ if (dst == NULL)
{
- wchar_t value;
- size_t count;
- unsigned char byte;
-
- /* Store address of next byte to process. */
- *src = run;
-
- byte = *run++;
-
- /* We expect a start of a new multibyte character. */
- if (byte < 0x80)
- {
- /* One byte sequence. */
- count = 0;
- value = byte;
- }
- else if ((byte & 0xe0) == 0xc0)
- {
- count = 1;
- value = byte & 0x1f;
- }
- else if ((byte & 0xf0) == 0xe0)
- {
- /* We expect three bytes. */
- count = 2;
- value = byte & 0x0f;
- }
- else if ((byte & 0xf8) == 0xf0)
- {
- /* We expect four bytes. */
- count = 3;
- value = byte & 0x07;
- }
- else if ((byte & 0xfc) == 0xf8)
- {
- /* We expect five bytes. */
- count = 4;
- value = byte & 0x03;
- }
- else if ((byte & 0xfe) == 0xfc)
+ wchar_t buf[64]; /* Just an arbitrary size. */
+ size_t inbytes_in = strlen (*src) + 1;
+ size_t inbytes = inbytes_in;
+ const char *inbuf = *src;
+ size_t written;
+
+ data.outbuf = (char *) buf;
+ data.outbufsize = sizeof (buf);
+ do
{
- /* We expect six bytes. */
- count = 5;
- value = byte & 0x01;
- }
- else
- {
- /* This is an illegal encoding. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
-
- /* Read the possible remaining bytes. */
- while (count-- > 0)
- {
- byte = *run++;
-
- if ((byte & 0xc0) != 0x80)
- {
- /* This is an illegal encoding. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
-
- value <<= 6;
- value |= byte & 0x3f;
+ inbuf += inbytes_in - inbytes;
+ inbytes_in = inbytes;
+ data.outbufavail = 0;
+ written = 0;
+
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, inbuf, &inbytes,
+ &written, 0);
+ result += written;
}
+ while (status == GCONV_FULL_OUTPUT);
- /* Store value is required. */
- if (dst != NULL)
- *dst++ = value;
-
- /* The whole sequence is read. Check whether end of string is
- reached. */
- if (value == L'\0')
+ if (status == GCONV_OK && ((wchar_t *) dst)[written - 1] == L'\0')
+ /* Don't count the NUL character in. */
+ --result;
+ }
+ else
+ {
+ /* This code is based on the safe assumption that all internal
+ multi-byte encodings use the NUL byte only to mark the end
+ of the string. */
+ size_t inbytes_in = __strnlen (*src, len * MB_CUR_MAX) + 1;
+ size_t inbytes = inbytes_in;
+
+ data.outbuf = (char *) dst;
+ data.outbufsize = len * sizeof (wchar_t);
+ data.outbufavail = 0;
+
+ status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
+ &data, *src, &inbytes,
+ &result, 0);
+
+ /* We have to determine whether the last character converted
+ is the NUL character. */
+ if (status == GCONV_OK && ((wchar_t *) dst)[result - 1] == L'\0')
{
- /* Found the end of the string. */
+ assert (result > 0);
+ assert (mbsinit (data.statep));
*src = NULL;
- return written;
+ --result;
}
-
- /* Increment counter of produced words. */
- ++written;
+ else
+ *src += inbytes_in - inbytes;
}
- /* Store address of next byte to process. */
- *src = run;
+ /* There must not be any problems with the conversion but illegal input
+ characters. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT);
+
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT)
+ {
+ result = (size_t) -1;
+ __set_errno (EILSEQ);
+ }
- return written;
+ return result;
}
weak_alias (__mbsrtowcs, mbsrtowcs)
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 4bba959387..719de26e37 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 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
@@ -166,8 +166,15 @@ extern wchar_t *wcstok __P ((wchar_t *__restrict __s,
wchar_t **__restrict __ptr));
/* Return the number of wide characters in S. */
+extern size_t __wcslen __P ((__const wchar_t *__s));
extern size_t wcslen __P ((__const wchar_t *__s));
+#ifdef __USE_GNU
+/* Return the number of wide characters in S, but at most MAXLEN. */
+extern size_t __wcsnlen __P ((__const wchar_t *__s, size_t __maxlen));
+extern size_t wcsnlen __P ((__const wchar_t *__s, size_t __maxlen));
+#endif
+
/* Search N wide characters of S for C. */
extern wchar_t *wmemchr __P ((__const wchar_t *__s, wchar_t __c, size_t __n));
@@ -260,16 +267,6 @@ extern size_t mbsnrtowcs __P ((wchar_t *__restrict __dst,
__const char **__restrict __src, size_t __nmc,
size_t __len, mbstate_t *__restrict __ps));
-/* Similar function to the above but this does not stop at NUL bytes. */
-extern size_t __wmemrtowcs __P ((wchar_t *__restrict __dst,
- __const char **__restrict __src,
- size_t __nmc, size_t __len,
- mbstate_t *__restrict __ps));
-extern size_t wmemrtowcs __P ((wchar_t *__restrict __dst,
- __const char **__restrict __src,
- size_t __nmc, size_t __len,
- mbstate_t *__restrict __ps));
-
/* Write multibyte character representation of at most NWC characters
from the wide character string SRC to DST. */
extern size_t __wcsnrtombs __P ((char *__restrict __dst,
@@ -280,16 +277,6 @@ extern size_t wcsnrtombs __P ((char *__restrict __dst,
__const wchar_t **__restrict __src,
size_t __nwc, size_t __len,
mbstate_t *__restrict __ps));
-
-/* Similar function to the above but this does not stop at NUL bytes. */
-extern size_t __wmemrtombs __P ((char *__restrict __dst,
- __const wchar_t **__restrict __src,
- size_t __nwc, size_t len,
- mbstate_t *__restrict __ps));
-extern size_t wmemrtombs __P ((char *__restrict __dst,
- __const wchar_t **__restrict __src,
- size_t __nwc, size_t len,
- mbstate_t *__restrict __ps));
#endif /* use GNU */
diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c
index 63859e158a..d45ae444bb 100644
--- a/wcsmbs/wcrtomb.c
+++ b/wcsmbs/wcrtomb.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,77 +18,86 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <gconv.h>
+#include <stdlib.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-static const wchar_t encoding_mask[] =
-{
- ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
-};
-
-static const unsigned char encoding_byte[] =
-{
- 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
-};
-/* The state is for this UTF8 encoding not used. */
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
size_t
__wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
{
- size_t written = 0;
-
- if (ps == NULL)
- ps = &internal;
-
+ char buf[MB_CUR_MAX];
+ struct gconv_step_data data;
+ int status;
+ size_t result;
+
+ /* Tell where we want the result. */
+ data.outbuf = s;
+ data.outbufavail = 0;
+ data.outbufsize = MB_CUR_MAX;
+ data.is_last = 1;
+ data.statep = ps ?: &state;
+
+ /* A first special case is if S is NULL. This means put PS in the
+ initial state. */
if (s == NULL)
{
- /* This is equivalent to wcrtomb (<<internal>, L'\0', ps). We
- only have to reset the state. */
- ps->count = 0;
- return 1;
+ data.outbuf = buf;
+ wc = L'\0';
}
- /* Store the UTF8 representation of WC. */
- if (wc < 0 || wc > 0x7fffffff)
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
+
+ /* If WC is the NUL character we write into the output buffer the byte
+ sequence necessary for PS to get into the initial state, followed
+ by a NUL byte. */
+ if (wc == L'\0')
{
- /* This is no correct ISO 10646 character. */
- __set_errno (EILSEQ);
- return (size_t) -1;
- }
+ size_t inbytes = 0;
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data, NULL, &inbytes,
+ NULL, 1);
- if (wc < 0x80)
+ if (status == GCONV_OK)
+ data.outbuf[data.outbufavail++] = '\0';
+ }
+ else
{
- /* It's a one byte sequence. */
- if (s != NULL)
- *s = (char) wc;
- ps->count = 0;
- return 1;
+ /* Do a normal conversion. */
+ size_t inbytes = sizeof (wchar_t);
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data, (char *) &wc, &inbytes,
+ NULL, 0);
}
- for (written = 2; written < 6; ++written)
- if ((wc & encoding_mask[written - 2]) == 0)
- break;
+ /* There must not be any problems with the conversion but illegal input
+ characters. The output buffer must be large enough, otherwise the
+ definition of MB_CUR_MAX is not correct. All the other possible
+ errors also must not happen. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT);
- if (s != NULL)
+ if (status == GCONV_OK)
+ result = data.outbufavail;
+ else
{
- size_t cnt = written;
- s[0] = encoding_byte[cnt - 2];
-
- --cnt;
- do
- {
- s[cnt] = 0x80 | (wc & 0x3f);
- wc >>= 6;
- }
- while (--cnt > 0);
- s[0] |= wc;
+ result = (size_t) -1;
+ __set_errno (EILSEQ);
}
- return written;
+ return result;
}
weak_alias (__wcrtomb, wcrtomb)
diff --git a/wcsmbs/wcslen.c b/wcsmbs/wcslen.c
index 113bc2a113..b0f1d29a27 100644
--- a/wcsmbs/wcslen.c
+++ b/wcsmbs/wcslen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@@ -22,7 +22,7 @@
/* Copy SRC to DEST. */
size_t
-wcslen (s)
+__wcslen (s)
const wchar_t *s;
{
size_t len = 0;
@@ -40,3 +40,4 @@ wcslen (s)
return len;
}
+weak_alias (__wcslen, wcslen)
diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c
new file mode 100644
index 0000000000..cf854d9125
--- /dev/null
+++ b/wcsmbs/wcsmbsload.c
@@ -0,0 +1,132 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <langinfo.h>
+#include <limits.h>
+
+#include <wcsmbsload.h>
+#include <bits/libc-lock.h>
+#include <iconv/gconv_int.h>
+
+
+/* Last loaded locale for LC_CTYPE. We initialize for the C locale
+ which is enabled at startup. */
+extern const struct locale_data _nl_C_LC_CTYPE;
+const struct locale_data *__wcsmbs_last_locale = &_nl_C_LC_CTYPE;
+
+
+/* These are the descriptions for the default conversion functions. */
+static struct gconv_step to_wc =
+{
+ shlib_handle: NULL,
+ modname: NULL,
+ counter: INT_MAX,
+ from_name: "ANSI_X3.4-1968",
+ to_name: "ISO-10646/UCS4/",
+ fct: __gconv_transform_ascii_ucs4,
+ init_fct: NULL,
+ end_fct: NULL,
+ data: NULL
+};
+
+static struct gconv_step to_mb =
+{
+ shlib_handle: NULL,
+ modname: NULL,
+ counter: INT_MAX,
+ from_name: "ISO-10646/UCS4/",
+ to_name: "ANSI_X3.4-1968",
+ fct: __gconv_transform_ucs4_ascii,
+ init_fct: NULL,
+ end_fct: NULL,
+ data: NULL
+};
+
+
+/* For the default locale we only have to handle ANSI_X3.4-1968. */
+struct gconv_fcts __wcsmbs_gconv_fcts =
+{
+ towc: &to_wc,
+ tomb: &to_mb
+};
+
+
+static inline struct gconv_step *
+getfct (const char *to, const char *from)
+{
+ size_t nsteps;
+ struct gconv_step *result;
+
+ if (__gconv_find_transform (to, from, &result, &nsteps) != GCONV_OK)
+ /* Loading the conversion step is not possible. */
+ return NULL;
+
+ /* We must only have one step in this conversion. */
+ if (nsteps != 1)
+ return NULL;
+
+ return result;
+}
+
+
+/* Load conversion functions for the currently selected locale. */
+void
+__wcsmbs_load_conv (const struct locale_data *new_category)
+{
+ /* We must modify global data. */
+ __libc_lock_define_initialized (static, lock)
+
+ /* Acquire the lock. */
+ __libc_lock_lock (lock);
+
+ /* We should repest the test since while we waited some other thread
+ might have run this function. */
+ if (__wcsmbs_last_locale != new_category)
+ {
+ if (new_category->name == _nl_C_name) /* Yes, pointer comparison. */
+ {
+ failed:
+ __wcsmbs_gconv_fcts.towc = &to_wc;
+ __wcsmbs_gconv_fcts.tomb = &to_mb;
+ }
+ else
+ {
+ /* We must find the real functions. */
+ const char *charset_name;
+
+ /* Get name of charset of the locale. */
+ charset_name = new_category->values[_NL_ITEM_INDEX(CODESET)].string;
+
+ __wcsmbs_gconv_fcts.tomb = getfct (charset_name, "ISO-10646/UCS4/");
+ __wcsmbs_gconv_fcts.towc = getfct ("ISO-10646/UCS4/", charset_name);
+
+ /* If any of the conversion functions is not available we don't
+ use any since this would mean we cannot convert back and
+ forth.*/
+ if (__wcsmbs_gconv_fcts.towc == NULL
+ || __wcsmbs_gconv_fcts.tomb == NULL)
+ goto failed;
+ }
+
+ /* Set last-used variable for current locale. */
+ __wcsmbs_last_locale = new_category;
+ }
+
+ __libc_lock_unlock (lock);
+}
diff --git a/wcsmbs/wcsmbsload.h b/wcsmbs/wcsmbsload.h
new file mode 100644
index 0000000000..df0ba7b796
--- /dev/null
+++ b/wcsmbs/wcsmbsload.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <locale.h>
+#include <wchar.h>
+#include <locale/localeinfo.h>
+
+
+/* Contains pointers to the used functions in the `gconv' modules. */
+struct gconv_fcts
+ {
+ struct gconv_step *towc;
+ struct gconv_step *tomb;
+ };
+
+/* Set of currently active conversion functions. */
+extern struct gconv_fcts __wcsmbs_gconv_fcts;
+
+
+/* Last loaded locale for LC_CTYPE. */
+extern const struct locale_data *__wcsmbs_last_locale;
+
+
+/* Load conversion functions for the currently selected locale. */
+extern void __wcsmbs_load_conv (const struct locale_data *new_category)
+ internal_function;
+
+
+/* Check whether the LC_CTYPE locale changed since the last call.
+ Update the pointers appropriately. */
+static inline void
+update_conversion_ptrs (void)
+{
+ if (__wcsmbs_last_locale != _nl_current_LC_CTYPE)
+ __wcsmbs_load_conv (_nl_current_LC_CTYPE);
+}
diff --git a/wcsmbs/wcsnlen.c b/wcsmbs/wcsnlen.c
new file mode 100644
index 0000000000..5264a66d05
--- /dev/null
+++ b/wcsmbs/wcsnlen.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <wchar.h>
+
+
+/* Copy SRC to DEST. */
+size_t
+__wcsnlen (s, maxlen)
+ const wchar_t *s;
+ size_t maxlen;
+{
+ size_t len = 0;
+
+ while (s[len] != L'\0' && maxlen > 0)
+ {
+ if (s[++len] == L'\0' || --maxlen == 0)
+ return len;
+ if (s[++len] == L'\0' || --maxlen == 0)
+ return len;
+ if (s[++len] == L'\0' || --maxlen == 0)
+ return len;
+ ++len;
+ }
+
+ return len;
+}
+weak_alias (__wcsnlen, wcsnlen)
diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c
index f6c8048295..2dd9f7c17e 100644
--- a/wcsmbs/wcsnrtombs.c
+++ b/wcsmbs/wcsnrtombs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,26 +18,19 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <gconv.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-static const wchar_t encoding_mask[] =
-{
- ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
-};
-
-static const unsigned char encoding_byte[] =
-{
- 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
-};
-
-/* We don't need the state really because we don't have shift states
- to maintain between calls to this function. */
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
/* This is a non-standard function but it is very useful in the
implementation of stdio because we have to deal with unterminated
@@ -50,85 +43,91 @@ __wcsnrtombs (dst, src, nwc, len, ps)
size_t len;
mbstate_t *ps;
{
- size_t written = 0;
- const wchar_t *run = *src;
+ struct gconv_step_data data;
+ size_t inbytes_in;
+ int status;
+ size_t result;
- if (ps == NULL)
- ps = &internal;
+ /* Tell where we want the result. */
+ data.is_last = 1;
+ data.statep = ps ?: &state;
- if (dst == NULL)
- /* The LEN parameter has to be ignored if we don't actually write
- anything. */
- len = ~0;
+ if (nwc == 0)
+ return 0;
+ inbytes_in = __wcsnlen (*src, nwc - 1) + 1;
- while (written < len && nwc-- > 0)
- {
- wchar_t wc;
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
- /* Store position of first unprocessed word. */
- *src = run;
+ /* We have to handle DST == NULL special. */
+ if (dst == NULL)
+ {
+ char buf[256]; /* Just an arbitrary value. */
+ size_t inbytes = inbytes_in;
+ const wchar_t *inbuf = *src;
+ size_t written;
- wc = *run++;
+ data.outbuf = buf;
+ data.outbufsize = sizeof (buf);
- if (wc < 0 || wc > 0x7fffffff)
+ do
{
- /* This is no correct ISO 10646 character. */
- __set_errno (EILSEQ);
- return (size_t) -1;
+ inbuf += (inbytes_in - inbytes) / sizeof (wchar_t);
+ inbytes_in = inbytes;
+ data.outbufavail = 0;
+ written = 0;
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data,
+ (const char *) inbuf,
+ &inbytes, &written, 0);
+ result += written;
}
+ while (status == GCONV_FULL_OUTPUT);
- if (wc == L'\0')
+ if (status == GCONV_OK && dst[data.outbufavail - 1] == '\0')
+ /* Don't count the NUL character in. */
+ --result;
+ }
+ else
+ {
+ /* This code is based on the safe assumption that all internal
+ multi-byte encodings use the NUL byte only to mark the end
+ of the string. */
+ size_t inbytes = inbytes_in;
+
+ data.outbuf = dst;
+ data.outbufavail = 0;
+ data.outbufsize = len;
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data, (const char *) *src,
+ &inbytes, &result, 0);
+
+ /* We have to determine whether the last character converted
+ is the NUL character. */
+ if (status == GCONV_OK && dst[data.outbufavail - 1] == '\0')
{
- /* Found the end. */
- if (dst != NULL)
- *dst = '\0';
+ assert (data.outbufavail > 0);
+ assert (mbsinit (data.statep));
*src = NULL;
- return written;
- }
- else if (wc < 0x80)
- {
- /* It's an one byte sequence. */
- if (dst != NULL)
- *dst++ = (char) wc;
- ++written;
+ --result;
}
else
- {
- size_t step;
-
- for (step = 2; step < 6; ++step)
- if ((wc & encoding_mask[step - 2]) == 0)
- break;
-
- if (written + step >= len)
- /* Too long. */
- break;
-
- if (dst != NULL)
- {
- size_t cnt = step;
-
- dst[0] = encoding_byte[cnt - 2];
-
- --cnt;
- do
- {
- dst[cnt] = 0x80 | (wc & 0x3f);
- wc >>= 6;
- }
- while (--cnt > 0);
- dst[0] |= wc;
+ *src += result;
+ }
- dst += step;
- }
+ /* There must not be any problems with the conversion but illegal input
+ characters. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT);
- written += step;
- }
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT)
+ {
+ result = (size_t) -1;
+ __set_errno (EILSEQ);
}
- /* Store position of first unprocessed word. */
- *src = run;
-
- return written;
+ return result;
}
weak_alias (__wcsnrtombs, wcsnrtombs)
diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c
index cc21a51eb3..35bb58e977 100644
--- a/wcsmbs/wcsrtombs.c
+++ b/wcsmbs/wcsrtombs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -18,26 +18,20 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <stdlib.h>
+#include <gconv.h>
#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <assert.h>
#ifndef EILSEQ
-#define EILSEQ EINVAL
+# define EILSEQ EINVAL
#endif
-static const wchar_t encoding_mask[] =
-{
- ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
-};
-
-static const unsigned char encoding_byte[] =
-{
- 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
-};
-
-/* We don't need the state really because we don't have shift states
- to maintain between calls to this function. */
-static mbstate_t internal;
+/* This is the private state used if PS is NULL. */
+static mbstate_t state;
size_t
__wcsrtombs (dst, src, len, ps)
@@ -46,89 +40,88 @@ __wcsrtombs (dst, src, len, ps)
size_t len;
mbstate_t *ps;
{
- size_t written = 0;
- const wchar_t *run = *src;
+ struct gconv_step_data data;
+ int status;
+ size_t result;
- if (ps == NULL)
- ps = &internal;
+ /* Tell where we want the result. */
+ data.is_last = 1;
+ data.statep = ps ?: &state;
- if (dst == NULL)
- /* The LEN parameter has to be ignored if we don't actually write
- anything. */
- len = ~0;
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
- while (written < len)
+ /* We have to handle DST == NULL special. */
+ if (dst == NULL)
{
- wchar_t wc;
-
- /* Store position of first unprocessed word. */
- *src = run;
+ char buf[256]; /* Just an arbitrary value. */
+ size_t inbytes_in = __wcslen (*src) + 1;
+ size_t inbytes = inbytes_in;
+ const wchar_t *inbuf = *src;
+ size_t written;
- wc = *run++;
+ data.outbuf = buf;
+ data.outbufsize = sizeof (buf);
- if (wc < 0 || wc > 0x7fffffff)
+ do
{
- /* This is no correct ISO 10646 character. */
- __set_errno (EILSEQ);
- return (size_t) -1;
+ inbuf += (inbytes_in - inbytes) / sizeof (wchar_t);
+ inbytes_in = inbytes;
+ data.outbufavail = 0;
+ written = 0;
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data,
+ (const char *) inbuf,
+ &inbytes, &written, 0);
+ result += written;
}
+ while (status == GCONV_FULL_OUTPUT);
- if (wc == L'\0')
+ if (status == GCONV_OK && dst[data.outbufavail - 1] == '\0')
+ /* Don't count the NUL character in. */
+ --result;
+ }
+ else
+ {
+ /* This code is based on the safe assumption that all internal
+ multi-byte encodings use the NUL byte only to mark the end
+ of the string. */
+ size_t inbytes_in = __wcsnlen (*src, len * MB_CUR_MAX) + 1;
+ size_t inbytes = inbytes_in;
+
+ data.outbuf = dst;
+ data.outbufavail = 0;
+ data.outbufsize = len;
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
+ &data, (const char *) *src,
+ &inbytes, &result, 0);
+
+ /* We have to determine whether the last character converted
+ is the NUL character. */
+ if (status == GCONV_OK && dst[data.outbufavail - 1] == '\0')
{
- /* Found the end. */
- if (dst != NULL)
- *dst = '\0';
- ps->count = 0;
+ assert (data.outbufavail > 0);
+ assert (mbsinit (data.statep));
*src = NULL;
- return written;
- }
- else if (wc < 0x80)
- {
- /* It's an one byte sequence. */
- if (dst != NULL)
- *dst++ = (char) wc;
- ++written;
+ --result;
}
else
- {
- size_t step;
-
- for (step = 2; step < 6; ++step)
- if ((wc & encoding_mask[step - 2]) == 0)
- break;
-
- if (written + step >= len)
- /* Too long. */
- break;
-
- if (dst != NULL)
- {
- size_t cnt = step;
-
- dst[0] = encoding_byte[cnt - 2];
-
- --cnt;
- do
- {
- dst[cnt] = 0x80 | (wc & 0x3f);
- wc >>= 6;
- }
- while (--cnt > 0);
- dst[0] |= wc;
-
- dst += step;
- }
-
- written += step;
- }
+ *src += result;
}
- /* Store position of first unprocessed word. */
- *src = run;
+ /* There must not be any problems with the conversion but illegal input
+ characters. */
+ assert (status == GCONV_OK || status == GCONV_ILLEGAL_INPUT
+ || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT);
- /* Signal that we finished correctly. */
- ps->count = 0;
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT)
+ {
+ result = (size_t) -1;
+ __set_errno (EILSEQ);
+ }
- return written;
+ return result;
}
weak_alias (__wcsrtombs, wcsrtombs)
diff --git a/wcsmbs/wctob.c b/wcsmbs/wctob.c
index ce1063a1ec..0461877d32 100644
--- a/wcsmbs/wctob.c
+++ b/wcsmbs/wctob.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -17,15 +17,48 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <gconv.h>
#include <stdio.h>
+#include <string.h>
#include <wchar.h>
+#include <wcsmbsload.h>
-/* We use UTF8 encoding for multibyte strings and therefore a valid
- one byte multibyte string only can have a value from 0 to 0x7f. */
int
wctob (c)
wint_t c;
{
- return (c >= 0 && c <= 0x7f) ? c : EOF;
+ char buf[MB_LEN_MAX];
+ struct gconv_step_data data;
+ wchar_t inbuf[1];
+ size_t inbytes;
+ size_t converted;
+ int status;
+
+ /* Tell where we want the result. */
+ data.outbuf = (char *) buf;
+ data.outbufavail = 0;
+ data.outbufsize = MB_LEN_MAX;
+ data.is_last = 1;
+ data.statep = &data.__state;
+
+ /* Make sure we start in the initial state. */
+ memset (&data.__state, '\0', sizeof (mbstate_t));
+
+ /* Make sure we use the correct function. */
+ update_conversion_ptrs ();
+
+ /* Create the input string. */
+ inbuf[0] = c;
+ inbytes = sizeof (wchar_t);
+
+ status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, &data,
+ (const char *) inbuf, &inbytes,
+ &converted, 0);
+ /* The conversion failed or the output is too long. */
+ if (status != GCONV_OK && status != GCONV_FULL_OUTPUT
+ || data.outbufavail != 1)
+ return WEOF;
+
+ return buf[0];
}