This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
final argp patch
- From: Simon Josefsson <jas at extundo dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 03 Oct 2003 02:15:24 +0200
- Subject: final argp patch
This add ELIDE_CODE a'la obstack or getopt to argp.
I have not tested this completely, here's what I've tested:
* Standalone compile (with gnulib) works on >20 systems.
* Standalone compile (with gnulib) on a Debian box result in empty
object code with CFLAGS=-D_GNU_ARGP_INTERFACE_VERSION=1.
I can imagine a few potential problems:
* The patch somehow break the libc build.
* The patch somehow remove argp symbols from libc.
There could be other problems as well, so I'd appreciate a review.
Thanks.
2003-10-03 Simon Josefsson <jas@extundo.com>
* argp/argp-ba.c:
* argp/argp-eexst.c:
* argp/argp-fs-xinl.c:
* argp/argp-pv.c:
* argp/argp-pvh.c:
* argp/argp-xinl.c: Include argp-namefrob.h.
* argp/argp-ba.c:
* argp/argp-eexst.c:
* argp/argp-fmtstream.c:
* argp/argp-fs-xinl.c:
* argp/argp-help.c:
* argp/argp-parse.c:
* argp/argp-pv.c:
* argp/argp-pvh.c:
* argp/argp-xinl.c: Wrap code around '#ifndef ELIDE_CODE'.
* argp/argp-namefrob.h: Define ARGP_INTERFACE_VERSION to 1.
Include stdio.h for __GNU_LIBRARY__.
[!_LIBC && __GNU_LIBRARY__ && __GNU_LIBRARY > 1]: Include
gnu-versions.h.
[!_LIBC && __GNU_LIBRARY__ && __GNU_LIBRARY > 1 &&
_GNU_ARGP_INTERFACE_VERSION == ARGP_INTERFACE_VERSION]: Define
ELIDE_CODE.
* include/gnu-versions.h (_GNU_ARGP_INTERFACE_VERSION): Add (with
value 1).
Index: argp/argp-ba.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-ba.c,v
retrieving revision 1.4
diff -u -p -r1.4 argp-ba.c
--- argp/argp-ba.c 6 Jul 2001 04:54:44 -0000 1.4
+++ argp/argp-ba.c 2 Oct 2003 23:53:39 -0000
@@ -18,9 +18,16 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
/* If set by the user program, it should point to string that is the
bug-reporting address for the program. It will be printed by argp_help if
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */
const char *argp_program_bug_address;
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-eexst.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-eexst.c,v
retrieving revision 1.3
diff -u -p -r1.3 argp-eexst.c
--- argp/argp-eexst.c 6 Jul 2001 04:54:44 -0000 1.3
+++ argp/argp-eexst.c 2 Oct 2003 23:53:39 -0000
@@ -22,6 +22,11 @@
#include <config.h>
#endif
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
#include <sysexits.h>
#include "argp.h"
@@ -30,3 +35,5 @@
If not defined or set by the user program, this defaults to EX_USAGE from
<sysexits.h>. */
error_t argp_err_exit_status = EX_USAGE;
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-fmtstream.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-fmtstream.c,v
retrieving revision 1.15
diff -u -p -r1.15 argp-fmtstream.c
--- argp/argp-fmtstream.c 25 Sep 2003 05:34:28 -0000 1.15
+++ argp/argp-fmtstream.c 2 Oct 2003 23:53:39 -0000
@@ -34,6 +34,8 @@
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
+#ifndef ELIDE_CODE
+
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
#ifndef isblank
@@ -439,3 +441,5 @@ weak_alias (__argp_fmtstream_printf, arg
#endif
#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-fs-xinl.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-fs-xinl.c,v
retrieving revision 1.3
diff -u -p -r1.3 argp-fs-xinl.c
--- argp/argp-fs-xinl.c 8 Jan 2003 06:32:39 -0000 1.3
+++ argp/argp-fs-xinl.c 2 Oct 2003 23:53:39 -0000
@@ -22,6 +22,11 @@
#include <config.h>
#endif
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
#define ARGP_FS_EI
#undef __OPTIMIZE__
#define __OPTIMIZE__
@@ -42,3 +47,5 @@ weak_alias (__argp_fmtstream_point, argp
#endif
#endif
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-help.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-help.c,v
retrieving revision 1.39
diff -u -p -r1.39 argp-help.c
--- argp/argp-help.c 2 Oct 2003 22:53:15 -0000 1.39
+++ argp/argp-help.c 2 Oct 2003 23:53:40 -0000
@@ -85,6 +85,8 @@ char *strerror (int errnum);
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
+#ifndef ELIDE_CODE
+
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif
@@ -1903,3 +1905,5 @@ __argp_failure (const struct argp_state
#ifdef weak_alias
weak_alias (__argp_failure, argp_failure)
#endif
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-namefrob.h
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-namefrob.h,v
retrieving revision 1.4
diff -u -p -r1.4 argp-namefrob.h
--- argp/argp-namefrob.h 2 Oct 2003 22:53:31 -0000 1.4
+++ argp/argp-namefrob.h 2 Oct 2003 23:53:40 -0000
@@ -145,3 +145,27 @@ extern char *__argp_short_program_name (
#ifndef __set_errno
#define __set_errno(e) (errno = (e))
#endif
+
+/* NOTE BEFORE MODIFYING ARGP: This version number must be
+ incremented whenever callers compiled using an old argp.h can no
+ longer properly call the functions in this argp*.c. */
+#define ARGP_INTERFACE_VERSION 1
+
+/* Get __GNU_LIBRARY__. */
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself, and the installed library
+ supports the same library interface we do. This code is part of the GNU
+ C Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object
+ files, it is simpler to just do this in the source for each such file. */
+
+#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
+# include <gnu-versions.h>
+# if _GNU_ARGP_INTERFACE_VERSION == ARGP_INTERFACE_VERSION
+# define ELIDE_CODE
+# endif
+#endif
Index: argp/argp-parse.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-parse.c,v
retrieving revision 1.18
diff -u -p -r1.18 argp-parse.c
--- argp/argp-parse.c 2 Oct 2003 22:53:45 -0000 1.18
+++ argp/argp-parse.c 2 Oct 2003 23:53:41 -0000
@@ -58,6 +58,8 @@
#include "argp.h"
#include "argp-namefrob.h"
+#ifndef ELIDE_CODE
+
/* Getopt return values. */
#define KEY_END (-1) /* The end of the options. */
#define KEY_ARG 1 /* A non-option argument. */
@@ -975,3 +977,5 @@ __argp_input (const struct argp *argp, c
#ifdef weak_alias
weak_alias (__argp_input, _argp_input)
#endif
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-pv.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-pv.c,v
retrieving revision 1.4
diff -u -p -r1.4 argp-pv.c
--- argp/argp-pv.c 6 Jul 2001 04:54:44 -0000 1.4
+++ argp/argp-pv.c 2 Oct 2003 23:53:41 -0000
@@ -18,8 +18,15 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
/* If set by the user program to a non-zero value, then a default option
--version is added (unless the ARGP_NO_HELP flag is used), which will
print this this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
const char *argp_program_version;
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-pvh.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-pvh.c,v
retrieving revision 1.3
diff -u -p -r1.3 argp-pvh.c
--- argp/argp-pvh.c 6 Jul 2001 04:54:44 -0000 1.3
+++ argp/argp-pvh.c 2 Oct 2003 23:53:41 -0000
@@ -22,6 +22,11 @@
#include <config.h>
#endif
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
#include "argp.h"
/* If set by the user program to a non-zero value, then a default option
@@ -30,3 +35,5 @@
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state);
+
+#endif /* !ELIDE_CODE */
Index: argp/argp-xinl.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-xinl.c,v
retrieving revision 1.4
diff -u -p -r1.4 argp-xinl.c
--- argp/argp-xinl.c 2 Oct 2003 22:53:55 -0000 1.4
+++ argp/argp-xinl.c 2 Oct 2003 23:53:41 -0000
@@ -22,6 +22,11 @@
#include <config.h>
#endif
+/* Get ELIDE_CODE. */
+#include "argp-namefrob.h"
+
+#ifndef ELIDE_CODE
+
#if defined _LIBC || defined HAVE_FEATURES_H
# include <features.h>
#endif
@@ -42,3 +47,5 @@ weak_alias (__option_is_short, _option_i
weak_alias (__option_is_end, _option_is_end)
#endif
+
+#endif /* !ELIDE_CODE */
Index: include/gnu-versions.h
===================================================================
RCS file: /cvs/glibc/libc/include/gnu-versions.h,v
retrieving revision 1.3
diff -u -p -r1.3 gnu-versions.h
--- include/gnu-versions.h 6 Jul 2001 04:54:52 -0000 1.3
+++ include/gnu-versions.h 2 Oct 2003 23:53:41 -0000
@@ -49,5 +49,6 @@
#define _GNU_GLOB_INTERFACE_VERSION 1 /* vs posix/glob.c */
#define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and
posix/getopt1.c */
+#define _GNU_ARGP_INTERFACE_VERSION 1 /* vs argp/argp*.c */
#endif /* gnu-versions.h */