about summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-12-20 18:05:57 +0000
committerJakub Jelinek <jakub@redhat.com>2005-12-20 18:05:57 +0000
commit2bf037b4e8e189e910a41744d79404b94235ab8b (patch)
treeec0234c3f56396c982e3ed5a77780423502a111f /sysdeps/posix
parent20a911071d1cfaf7d20d088efe9ede27c5809c09 (diff)
downloadglibc-2bf037b4e8e189e910a41744d79404b94235ab8b.tar.gz
glibc-2bf037b4e8e189e910a41744d79404b94235ab8b.tar.xz
glibc-2bf037b4e8e189e910a41744d79404b94235ab8b.zip
Updated to fedora-glibc-20051220T1751 cvs/fedora-glibc-2_3_90-21
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/Dist1
-rw-r--r--sysdeps/posix/gai_strerror-strs.h17
-rw-r--r--sysdeps/posix/gai_strerror.c70
-rw-r--r--sysdeps/posix/getaddrinfo.c5
4 files changed, 61 insertions, 32 deletions
diff --git a/sysdeps/posix/Dist b/sysdeps/posix/Dist
new file mode 100644
index 0000000000..7f0fb706a7
--- /dev/null
+++ b/sysdeps/posix/Dist
@@ -0,0 +1 @@
+gai_strerror-strs.h
diff --git a/sysdeps/posix/gai_strerror-strs.h b/sysdeps/posix/gai_strerror-strs.h
new file mode 100644
index 0000000000..19040a5138
--- /dev/null
+++ b/sysdeps/posix/gai_strerror-strs.h
@@ -0,0 +1,17 @@
+_S(EAI_ADDRFAMILY, N_("Address family for hostname not supported"))
+_S(EAI_AGAIN, N_("Temporary failure in name resolution"))
+_S(EAI_BADFLAGS, N_("Bad value for ai_flags"))
+_S(EAI_FAIL, N_("Non-recoverable failure in name resolution"))
+_S(EAI_FAMILY, N_("ai_family not supported"))
+_S(EAI_MEMORY, N_("Memory allocation failure"))
+_S(EAI_NODATA, N_("No address associated with hostname"))
+_S(EAI_NONAME, N_("Name or service not known"))
+_S(EAI_SERVICE, N_("Servname not supported for ai_socktype"))
+_S(EAI_SOCKTYPE, N_("ai_socktype not supported"))
+_S(EAI_SYSTEM, N_("System error"))
+_S(EAI_INPROGRESS, N_("Processing request in progress"))
+_S(EAI_CANCELED, N_("Request canceled"))
+_S(EAI_NOTCANCELED, N_("Request not canceled"))
+_S(EAI_ALLDONE, N_("All requests done"))
+_S(EAI_INTR, N_("Interrupted by a signal"))
+_S(EAI_IDN_ENCODE, N_("Parameter string not correctly encoded"))
diff --git a/sysdeps/posix/gai_strerror.c b/sysdeps/posix/gai_strerror.c
index e2835a5674..cc13dd4dab 100644
--- a/sysdeps/posix/gai_strerror.c
+++ b/sysdeps/posix/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
 
@@ -17,44 +17,54 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <stdio.h>
-#include <netdb.h>
 #include <libintl.h>
+#include <netdb.h>
+#include <stdint.h>
+#include <stdio.h>
+
 
-static struct
+#define MSGSTRFIELD(line) MSGSTRFIELD1 (line)
+#define MSGSTRFIELD1(line) str##line
+static const union msgstr_t
+{
+  struct
   {
-    int code;
-    const char *msg;
-  }
-values[] =
+#define _S(n, s) char MSGSTRFIELD(__LINE__)[sizeof (s)];
+#include "gai_strerror-strs.h"
+#undef _S
+  };
+  char str[0];
+} msgstr =
   {
-    { EAI_ADDRFAMILY, N_("Address family for hostname not supported") },
-    { EAI_AGAIN, N_("Temporary failure in name resolution") },
-    { EAI_BADFLAGS, N_("Bad value for ai_flags") },
-    { EAI_FAIL, N_("Non-recoverable failure in name resolution") },
-    { EAI_FAMILY, N_("ai_family not supported") },
-    { EAI_MEMORY, N_("Memory allocation failure") },
-    { EAI_NODATA, N_("No address associated with hostname") },
-    { EAI_NONAME, N_("Name or service not known") },
-    { EAI_SERVICE, N_("Servname not supported for ai_socktype") },
-    { EAI_SOCKTYPE, N_("ai_socktype not supported") },
-    { EAI_SYSTEM, N_("System error") },
-    { EAI_INPROGRESS, N_("Processing request in progress") },
-    { EAI_CANCELED, N_("Request canceled") },
-    { EAI_NOTCANCELED, N_("Request not canceled") },
-    { EAI_ALLDONE, N_("All requests done") },
-    { EAI_INTR, N_("Interrupted by a signal") },
-    { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") }
+    {
+#define _S(n, s) s,
+#include "gai_strerror-strs.h"
+#undef _S
+    }
   };
+static const struct
+{
+  int16_t code;
+  uint16_t idx;
+} msgidx[] =
+  {
+#define _S(n, s) { n, offsetof (union msgstr_t, MSGSTRFIELD (__LINE__)) },
+#include "gai_strerror-strs.h"
+#undef _S
+  };
+
 
 const char *
 gai_strerror (int code)
 {
-  size_t i;
-  for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
-    if (values[i].code == code)
-      return _(values[i].msg);
+  const char *result = "Unknown error";
+  for (size_t i = 0; i < sizeof (msgidx) / sizeof (msgidx[0]); ++i)
+    if (msgidx[i].code == code)
+      {
+	result = msgstr.str + msgidx[i].idx;
+	break;
+      }
 
-  return _("Unknown error");
+  return _(result);
 }
 libc_hidden_def (gai_strerror)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index b9819bfc0a..46c66a8f7e 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1098,7 +1098,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
   return 0;
 }
 
-static struct gaih gaih[] =
+static const struct gaih gaih[] =
   {
     { PF_INET6, gaih_inet },
     { PF_INET, gaih_inet },
@@ -1461,7 +1461,8 @@ getaddrinfo (const char *name, const char *service,
   int i = 0, j = 0, last_i = 0;
   int nresults = 0;
   struct addrinfo *p = NULL, **end;
-  struct gaih *g = gaih, *pg = NULL;
+  const struct gaih *g = gaih;
+  const struct gaih *pg = NULL;
   struct gaih_service gaih_service, *pservice;
   struct addrinfo local_hints;