about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--manual/arith.texi26
-rw-r--r--manual/time.texi34
-rw-r--r--sysdeps/unix/sysv/linux/ifreq.h103
4 files changed, 159 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index e3e61ea52f..9f56758318 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+1999-10-30  Ulrich Drepper  <drepper@cygnus.com>
+
+	* manual/time.texi (Formatting Date and Time): Revise comments about
+	origins of the formats with ISO C99 references.
+
+1999-10-30  Andreas Jaeger  <aj@suse.de>
+
+	* sysdeps/unix/sysv/linux/ifreq.h: New file.
+
+1999-10-29  Andreas Jaeger  <aj@suse.de>
+
+	* manual/arith.texi (Parsing of Floats): Document the hexadecimal
+	input format; mention that strtof and strtold are part of ISO C99.
+
 1999-10-29  Ulrich Drepper  <drepper@cygnus.com>
 
 	* manual/math.texi (Errors in Math Functions): New section.
diff --git a/manual/arith.texi b/manual/arith.texi
index 1a24beb7ca..11479d618b 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -2101,6 +2101,10 @@ are whitespace is determined by the @code{isspace} function
 @item
 An optional plus or minus sign (@samp{+} or @samp{-}).
 
+@item A floating point number in decimal or hexadecimal format.  The
+decimal format is:
+@itemize @minus
+
 @item
 A nonempty sequence of digits optionally containing a decimal-point
 character---normally @samp{.}, but it depends on the locale
@@ -2110,6 +2114,22 @@ character---normally @samp{.}, but it depends on the locale
 An optional exponent part, consisting of a character @samp{e} or
 @samp{E}, an optional sign, and a sequence of digits.
 
+@end itemize
+
+The hexadecimal format is as follows:
+@itemize @minus
+
+@item
+A 0x or 0X followed by a nonempty sequence of hexadecimal digits
+optionally containing a decimal-point character---normally @samp{.}, but
+it depends on the locale (@pxref{General Numeric}).
+
+@item
+An optional binary-exponent part, consisting of a character @samp{p} or
+@samp{P}, an optional sign, and a sequence of digits.
+
+@end itemize
+
 @item
 Any remaining characters in the string.  If @var{tailptr} is not a null
 pointer, a pointer to this tail of the string is stored in
@@ -2146,10 +2166,10 @@ examining @var{errno} and @var{tailptr}.
 @end deftypefun
 
 @comment stdlib.h
-@comment GNU
+@comment ISO C
 @deftypefun float strtof (const char *@var{string}, char **@var{tailptr})
 @comment stdlib.h
-@comment GNU
+@comment ISO C
 @deftypefunx {long double} strtold (const char *@var{string}, char **@var{tailptr})
 These functions are analogous to @code{strtod}, but return @code{float}
 and @code{long double} values respectively.  They report errors in the
@@ -2158,7 +2178,7 @@ than @code{strtod}, but has less precision; conversely, @code{strtold}
 can be much slower but has more precision (on systems where @code{long
 double} is a separate type).
 
-These functions are GNU extensions.
+These functions have been GNU extensions and are new to @w{ISO C 9x}.
 @end deftypefun
 
 @comment stdlib.h
diff --git a/manual/time.texi b/manual/time.texi
index 852df4355b..8d79a25ef1 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -781,7 +781,7 @@ The preferred date and time representation for the current locale.
 The century of the year.  This is equivalent to the greatest integer not
 greater than the year divided by 100.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %d
 The day of the month as a decimal number (range @code{01} through @code{31}).
@@ -789,19 +789,19 @@ The day of the month as a decimal number (range @code{01} through @code{31}).
 @item %D
 The date using the format @code{%m/%d/%y}.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %e
 The day of the month like with @code{%d}, but padded with blank (range
 @code{ 1} through @code{31}).
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %F
 The date using the format @code{%Y-%m-%d}.  This is the form specified
 in the @w{ISO 8601} standard and is the preferred form for all uses.
 
-This format is a @w{ISO C 9X} extension.
+This format is a @w{ISO C99} extension.
 
 @item %g
 The year corresponding to the ISO week number, but without the century
@@ -809,7 +809,7 @@ The year corresponding to the ISO week number, but without the century
 as @code{%y}, except that if the ISO week number (see @code{%V}) belongs
 to the previous or next year, that year is used instead.
 
-This format is a GNU extension.
+This format was introduced in @w{ISO C99}.
 
 @item %G
 The year corresponding to the ISO week number.  This has the same format
@@ -817,13 +817,14 @@ and value as @code{%Y}, except that if the ISO week number (see
 @code{%V}) belongs to the previous or next year, that year is used
 instead.
 
-This format is a GNU extension.
+This format was introduced in @w{ISO C99} but was previously available
+as a GNU extension.
 
 @item %h
 The abbreviated month name according to the current locale.  The action
 is the same as for @code{%b}.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %H
 The hour as a decimal number, using a 24-hour clock (range @code{00} through
@@ -857,7 +858,7 @@ The minute as a decimal number (range @code{00} through @code{59}).
 @item %n
 A single @samp{\n} (newline) character.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %p
 Either @samp{AM} or @samp{PM}, according to the given time value; or the
@@ -873,17 +874,19 @@ Either @samp{am} or @samp{pm}, according to the given time value; or the
 corresponding strings for the current locale, printed in lowercase
 characters.  Noon is treated as @samp{pm} and midnight as @samp{am}.
 
-This format is a GNU extension.
+This format was introduced in @w{ISO C99} but was previously available
+as a GNU extension.
 
 @item %r
 The complete time using the AM/PM format of the current locale.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %R
 The hour and minute in decimal numbers using the format @code{%H:%M}.
 
-This format is a GNU extension.
+This format was introduced in @w{ISO C99} but was previously available
+as a GNU extension.
 
 @item %s
 The number of seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC.
@@ -897,7 +900,7 @@ The seconds as a decimal number (range @code{00} through @code{60}).
 @item %t
 A single @samp{\t} (tabulator) character.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %T
 The time using decimal numbers using the format @code{%H:%M:%S}.
@@ -908,7 +911,7 @@ This format is a POSIX.2 extension.
 The day of the week as a decimal number (range @code{1} through
 @code{7}), Monday being @code{1}.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %U
 The week number of the current year as a decimal number (range @code{00}
@@ -927,7 +930,7 @@ The week before week @code{01} of a year is the last week (@code{52} or
 @code{53}) of the previous year even if it contains days from the new
 year.
 
-This format is a POSIX.2 extension.
+This format is a POSIX.2 extension and also appears in @w{ISO C99}.
 
 @item %w
 The day of the week as a decimal number (range @code{0} through
@@ -959,7 +962,8 @@ before the year @code{1} are numbered @code{0}, @code{-1}, and so on.
 @code{-0600} or @code{+0100}), or nothing if no time zone is
 determinable.
 
-This format is a GNU extension.
+This format was introduced in @w{ISO C99} but was previously available
+as a GNU extension.
 
 A full @w{RFC 822} timestamp is generated by the format
 @w{@samp{"%a, %d %b %Y %H:%M:%S %z"}} (or the equivalent
diff --git a/sysdeps/unix/sysv/linux/ifreq.h b/sysdeps/unix/sysv/linux/ifreq.h
new file mode 100644
index 0000000000..8c9000551d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ifreq.h
@@ -0,0 +1,103 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   Contributed by Andreas Jaeger <aj@suse.de>.
+
+   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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include "kernel-features.h"
+
+/* Variable to signal whether SIOCGIFCONF is not available.  */
+#if __ASSUME_SIOCGIFNAME == 0
+static int old_siocgifconf;
+#else
+# define old_siocgifconf 0
+#endif
+
+
+static inline void
+__ifreq (struct ifreq **ifreqs, int *num_ifs)
+{
+  int fd = __opensock ();
+  struct ifconf ifc;
+  int rq_len;
+  int nifs;
+# define RQ_IFS	4
+
+  if (fd < 0)
+    {
+      *num_ifs = 0;
+      *ifreqs = NULL;
+      return;
+    }
+  
+  ifc.ifc_buf = NULL;
+
+  /* We may be able to get the needed buffer size directly, rather than
+     guessing.  */
+  if (! old_siocgifconf)
+    {
+      ifc.ifc_buf = NULL;
+      ifc.ifc_len = 0;
+      if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
+	{
+# if __ASSUME_SIOCGIFNAME == 0
+	  old_siocgifconf = 1;
+# endif
+	  rq_len = RQ_IFS * sizeof (struct ifreq);
+	}
+      else
+	rq_len = ifc.ifc_len;
+    }
+  else
+    rq_len = RQ_IFS * sizeof (struct ifreq);
+
+  /* Read all the interfaces out of the kernel.  */
+  do
+    {
+      ifc.ifc_len = rq_len;
+      ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
+      if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
+	{
+	  if (ifc.ifc_buf)
+	    free (ifc.ifc_buf);
+	  
+	  __close (fd);
+
+	  *num_ifs = 0;
+	  *ifreqs = NULL;
+	  return;
+	}
+      rq_len *= 2;
+    }
+  while (ifc.ifc_len == rq_len && old_siocgifconf);
+
+  nifs = ifc.ifc_len / sizeof (struct ifreq);
+  __close (fd);
+
+  *num_ifs = nifs;
+  *ifreqs = realloc (ifc.ifc_buf, nifs * sizeof (struct ifreq));
+}
+
+static inline void
+__if_freereq (struct ifreq *ifreqs)
+{
+  free (ifreqs);
+}