[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r7777 - in /trunk/libc: ChangeLog.eglibc posix/Makefile posix/confstr.c posix/confstr.inc posix/cross-getconf.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r7777 - in /trunk/libc: ChangeLog.eglibc posix/Makefile posix/confstr.c posix/confstr.inc posix/cross-getconf.c
- From: maxim@xxxxxxxxxx
- Date: Thu, 22 Jan 2009 21:28:46 -0000
Author: maxim
Date: Thu Jan 22 13:28:46 2009
New Revision: 7777
Log:
Cross-getconf.
* posix/confstr.c (confstr): Move code for case
_CS_V6_WIDTH_RESTRICTED_ENVS to ...
* posix/confstr.inc: New file.
* posix/cross-getconf.c: New utility to mimic getconf for the
purposes of cross-compiling EGLIBC.
* posix/Makefile: Build cross-getconf and use it when cross-building
EGLIBC.
Added:
trunk/libc/posix/confstr.inc
trunk/libc/posix/cross-getconf.c
Modified:
trunk/libc/ChangeLog.eglibc
trunk/libc/posix/Makefile
trunk/libc/posix/confstr.c
Modified: trunk/libc/ChangeLog.eglibc
==============================================================================
--- trunk/libc/ChangeLog.eglibc (original)
+++ trunk/libc/ChangeLog.eglibc Thu Jan 22 13:28:46 2009
@@ -1,3 +1,15 @@
+2009-01-22 Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
+
+ Cross-getconf.
+
+ * posix/confstr.c (confstr): Move code for case
+ _CS_V6_WIDTH_RESTRICTED_ENVS to ...
+ * posix/confstr.inc: New file.
+ * posix/cross-getconf.c: New utility to mimic getconf for the
+ purposes of cross-compiling EGLIBC.
+ * posix/Makefile: Build cross-getconf and use it when cross-building
+ EGLIBC.
+
2009-01-22 Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Handle
Modified: trunk/libc/posix/Makefile
==============================================================================
--- trunk/libc/posix/Makefile (original)
+++ trunk/libc/posix/Makefile Thu Jan 22 13:28:46 2009
@@ -341,11 +341,32 @@
mv -f $@/$$spec.new $@/$$spec; \
done < $(objpfx)getconf.speclist
-$(objpfx)getconf.speclist: $(objpfx)getconf
+# eglibc: If we are cross-compiling, build cross-getconf utility and use it
+# instead of getconf.
+
+# We moved a piece of confstr.c to confstr.inc to share the later with
+# cross-getconf.c.
+confstr.c: confstr.inc
+
ifeq (no,$(cross-compiling))
+getconf-dep = $(objpfx)getconf
+getconf-cmd = $(run-program-prefix) $(objpfx)getconf
+else
+getconf-dep = $(objpfx)cross-getconf
+getconf-cmd = $(objpfx)cross-getconf
+
+# Get configuration defines for cross-getconf by preprocessing confstr.c.
+$(objpfx)cross-getconf.h: confstr.c
+ $(compile.c) -E -dM -o - | grep "define _POSIX_V6_ILP32_OFF32\|define _POSIX_V6_ILP32_OFFBIG\|define _POSIX_V6_LP64_OFF64\|define _POSIX_V6_LPBIG_OFFBIG" > $(objpfx)cross-getconf.h
+
+cross-getconf-CFLAGS = -O -I$(objpfx)
+
+$(objpfx)cross-getconf: cross-getconf.c $(objpfx)cross-getconf.h
+ $(native-compile)
+endif
+
+$(objpfx)getconf.speclist: $(getconf-dep)
LC_ALL=C GETCONF_DIR=/dev/null \
- $(run-program-prefix) $< _POSIX_V6_WIDTH_RESTRICTED_ENVS > $@.new
-else
- > $@.new
-endif
+ $(getconf-cmd) _POSIX_V6_WIDTH_RESTRICTED_ENVS > $@.new
mv -f $@.new $@
+# eglibc: end.
Modified: trunk/libc/posix/confstr.c
==============================================================================
--- trunk/libc/posix/confstr.c (original)
+++ trunk/libc/posix/confstr.c Thu Jan 22 13:28:46 2009
@@ -47,66 +47,9 @@
break;
case _CS_V6_WIDTH_RESTRICTED_ENVS:
- /* We have to return a newline-separated list of named of
- programming environements in which the widths of blksize_t,
- cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
- ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
- wint_t types are no greater than the width of type long.
-
- Currently this means all environment which the system allows. */
- {
- char restenvs[4 * sizeof "POSIX_V6_LPBIG_OFFBIG"];
-
- string_len = 0;
-#ifndef _POSIX_V6_ILP32_OFF32
- if (__sysconf (_SC_V6_ILP32_OFF32) > 0)
-#endif
-#if !defined _POSIX_V6_ILP32_OFF32 || _POSIX_V6_ILP32_OFF32 > 0
- {
- memcpy (restenvs + string_len, "POSIX_V6_ILP32_OFF32",
- sizeof "POSIX_V6_ILP32_OFF32" - 1);
- string_len += sizeof "POSIX_V6_ILP32_OFF32" - 1;
- }
-#endif
-#ifndef _POSIX_V6_ILP32_OFFBIG
- if (__sysconf (_SC_V6_ILP32_OFFBIG) > 0)
-#endif
-#if !defined _POSIX_V6_ILP32_OFFBIG || _POSIX_V6_ILP32_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V6_ILP32_OFFBIG",
- sizeof "POSIX_V6_ILP32_OFFBIG" - 1);
- string_len += sizeof "POSIX_V6_ILP32_OFFBIG" - 1;
- }
-#endif
-#ifndef _POSIX_V6_LP64_OFF64
- if (__sysconf (_SC_V6_LP64_OFF64) > 0)
-#endif
-#if !defined _POSIX_V6_LP64_OFF64 || _POSIX_V6_LP64_OFF64 > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V6_LP64_OFF64",
- sizeof "POSIX_V6_LP64_OFF64" - 1);
- string_len += sizeof "POSIX_V6_LP64_OFF64" - 1;
- }
-#endif
-#ifndef _POSIX_V6_LPBIG_OFFBIG
- if (__sysconf (_SC_V6_LPBIG_OFFBIG) > 0)
-#endif
-#if !defined _POSIX_V6_LPBIG_OFFBIG || _POSIX_V6_LPBIG_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V6_LPBIG_OFFBIG",
- sizeof "POSIX_V6_LPBIG_OFFBIG" - 1);
- string_len += sizeof "POSIX_V6_LPBIG_OFFBIG" - 1;
- }
-#endif
- restenvs[string_len++] = '\0';
- string = restenvs;
- }
+ /* eglibc: We share code in confstr.inc with cross-getconf.c. */
+#include "confstr.inc"
+ /* eglibc: end. */
break;
case _CS_XBS5_ILP32_OFF32_CFLAGS:
Added: trunk/libc/posix/confstr.inc
==============================================================================
--- trunk/libc/posix/confstr.inc (added)
+++ trunk/libc/posix/confstr.inc Thu Jan 22 13:28:46 2009
@@ -1,0 +1,82 @@
+/* Copyright (C) 2008
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* eglibc: The following piece of code was extracted from
+ confstr.c to share it with cross-getconf.c. */
+
+ /* We have to return a newline-separated list of named of
+ programming environements in which the widths of blksize_t,
+ cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
+ ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
+ wint_t types are no greater than the width of type long.
+
+ Currently this means all environment which the system allows. */
+ {
+ char restenvs[4 * sizeof "POSIX_V6_LPBIG_OFFBIG"];
+
+ string_len = 0;
+#ifndef _POSIX_V6_ILP32_OFF32
+ if (__sysconf (_SC_V6_ILP32_OFF32) > 0)
+#endif
+#if !defined _POSIX_V6_ILP32_OFF32 || _POSIX_V6_ILP32_OFF32 > 0
+ {
+ memcpy (restenvs + string_len, "POSIX_V6_ILP32_OFF32",
+ sizeof "POSIX_V6_ILP32_OFF32" - 1);
+ string_len += sizeof "POSIX_V6_ILP32_OFF32" - 1;
+ }
+#endif
+#ifndef _POSIX_V6_ILP32_OFFBIG
+ if (__sysconf (_SC_V6_ILP32_OFFBIG) > 0)
+#endif
+#if !defined _POSIX_V6_ILP32_OFFBIG || _POSIX_V6_ILP32_OFFBIG > 0
+ {
+ if (string_len)
+ restenvs[string_len++] = '\n';
+ memcpy (restenvs + string_len, "POSIX_V6_ILP32_OFFBIG",
+ sizeof "POSIX_V6_ILP32_OFFBIG" - 1);
+ string_len += sizeof "POSIX_V6_ILP32_OFFBIG" - 1;
+ }
+#endif
+#ifndef _POSIX_V6_LP64_OFF64
+ if (__sysconf (_SC_V6_LP64_OFF64) > 0)
+#endif
+#if !defined _POSIX_V6_LP64_OFF64 || _POSIX_V6_LP64_OFF64 > 0
+ {
+ if (string_len)
+ restenvs[string_len++] = '\n';
+ memcpy (restenvs + string_len, "POSIX_V6_LP64_OFF64",
+ sizeof "POSIX_V6_LP64_OFF64" - 1);
+ string_len += sizeof "POSIX_V6_LP64_OFF64" - 1;
+ }
+#endif
+#ifndef _POSIX_V6_LPBIG_OFFBIG
+ if (__sysconf (_SC_V6_LPBIG_OFFBIG) > 0)
+#endif
+#if !defined _POSIX_V6_LPBIG_OFFBIG || _POSIX_V6_LPBIG_OFFBIG > 0
+ {
+ if (string_len)
+ restenvs[string_len++] = '\n';
+ memcpy (restenvs + string_len, "POSIX_V6_LPBIG_OFFBIG",
+ sizeof "POSIX_V6_LPBIG_OFFBIG" - 1);
+ string_len += sizeof "POSIX_V6_LPBIG_OFFBIG" - 1;
+ }
+#endif
+ restenvs[string_len++] = '\0';
+ string = restenvs;
+ }
Added: trunk/libc/posix/cross-getconf.c
==============================================================================
--- trunk/libc/posix/cross-getconf.c (added)
+++ trunk/libc/posix/cross-getconf.c Thu Jan 22 13:28:46 2009
@@ -1,0 +1,83 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Undefine macros that should be defined in cross-getconf.h. */
+#undef _POSIX_V6_ILP32_OFF32
+#undef _POSIX_V6_ILP32_OFFBIG
+#undef _POSIX_V6_LP64_OFF64
+#undef _POSIX_V6_LPBIG_OFFBIG
+
+#include "cross-getconf.h"
+
+/* Define macros cross-getconf.h doesn't define to (-1).
+ This will prevent using host's __sysconf in confstr.inc. */
+#ifndef _POSIX_V6_ILP32_OFF32
+# define _POSIX_V6_ILP32_OFF32 (-1)
+#endif
+#ifndef _POSIX_V6_ILP32_OFFBIG
+# define _POSIX_V6_ILP32_OFFBIG (-1)
+#endif
+#ifndef _POSIX_V6_LP64_OFF64
+# define _POSIX_V6_LP64_OFF64 (-1)
+#endif
+#ifndef _POSIX_V6_LPBIG_OFFBIG
+# define _POSIX_V6_LPBIG_OFFBIG (-1)
+#endif
+
+/* Cross-getconf is a very simple program that assumes fixed
+ input and produces fixed output. It handles only cases
+ that are necessary to cross-compile EGLIBC. */
+
+void
+cross_getconf (void)
+{
+ const char *string = "";
+ size_t string_len = 1;
+
+#include "confstr.inc"
+
+ printf ("%.*s\n", (int) string_len, string);
+}
+
+int
+main (int argc, char *argv[])
+{
+ const char *getconf_dir;
+
+ if (argc != 2 || strcmp (argv[1], "_POSIX_V6_WIDTH_RESTRICTED_ENVS") != 0)
+ {
+ fprintf (stderr,
+ "%s: the only supported argument value is "
+ "_POSIX_V6_WIDTH_RESTRICTED_ENVS", argv[0]);
+ return 1;
+ }
+
+ getconf_dir = getenv ("GETCONF_DIR");
+ if (getconf_dir == NULL
+ || strcmp (getconf_dir, "/dev/null") != 0)
+ {
+ fprintf (stderr, "%s: GETCONF_DIR should be /dev/null\n", argv[0]);
+ return 1;
+ }
+
+ cross_getconf ();
+ return 0;
+}