Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2008-03-07 21:16:35 +0300
committerJeff Johnston <jjohnstn@redhat.com>2008-03-07 21:16:35 +0300
commitc622842865283fd7b684683b1f12a6ab1519b09b (patch)
tree16eb24e8ff8dc0d12bae5ad4e9582cde361ed3b5 /newlib
parent0382d26727416adf62287dfc0ce66aa9a38db95b (diff)
2008-03-07 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/getopt.h: Hide newlib extensions under the __need_getopt_newlib flag. * libc/stdlib/getopt.c: #define __need_getopt_newlib before including getopt.h. Put entire code under !HAVE_GETOPT to support platforms with their own getopt implementation. * configure.host: Specify HAVE_GETOPT for x86-linux.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog9
-rw-r--r--newlib/configure.host1
-rw-r--r--newlib/libc/include/getopt.h42
-rw-r--r--newlib/libc/stdlib/getopt.c4
4 files changed, 39 insertions, 17 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 04526b07e..0a8a9d0a9 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,5 +1,14 @@
2008-03-07 Jeff Johnston <jjohnstn@redhat.com>
+ * libc/include/getopt.h: Hide newlib extensions under
+ the __need_getopt_newlib flag.
+ * libc/stdlib/getopt.c: #define __need_getopt_newlib before including
+ getopt.h. Put entire code under !HAVE_GETOPT to support platforms
+ with their own getopt implementation.
+ * configure.host: Specify HAVE_GETOPT for x86-linux.
+
+2008-03-07 Jeff Johnston <jjohnstn@redhat.com>
+
* libc/include/sys/reent.h(_REENT_SMALL_CHECK_INIT): Specify
this macro completely instead of referring to CHECK_STD_INIT which
is only found in libc/stdio/local.h.
diff --git a/newlib/configure.host b/newlib/configure.host
index 259e204b0..bbdfff31f 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -414,6 +414,7 @@ case "${host}" in
newlib_cflags="${newlib_cflags} -Wall"
newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
+ newlib_cflags="${newlib_cflags} -DHAVE_GETOPT"
# --- Required when building a shared library ------------------------
newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
# --- The three lines below are optional ------------------------------
diff --git a/newlib/libc/include/getopt.h b/newlib/libc/include/getopt.h
index f91875714..13cf99c5f 100644
--- a/newlib/libc/include/getopt.h
+++ b/newlib/libc/include/getopt.h
@@ -82,6 +82,7 @@ Gregory Pietsch's current e-mail address:
gpietsch@comcast.net
****************************************************************************/
+/* This is a glibc-extension header file. */
#ifndef GETOPT_H
#define GETOPT_H
@@ -90,23 +91,9 @@ gpietsch@comcast.net
/* include files needed by this include file */
-/* macros defined by this include file */
-#define NO_ARG 0
-#define REQUIRED_ARG 1
-#define OPTIONAL_ARG 2
-
-/* For glibc compatibility. */
-#define no_argument NO_ARG
-#define required_argument REQUIRED_ARG
-#define optional_argument OPTIONAL_ARG
-
- /* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically-
- allocated variable of type struct getopt_data. */
-#define GETOPT_DATA_INITIALIZER {0,0,0,0,0}
- /* These #defines are to keep the namespace clear... */
-#define getopt_r __getopt_r
-#define getopt_long_r __getopt_long_r
-#define getopt_long_only_r __getopt_long_only_r
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
#ifdef __cplusplus
extern "C"
@@ -130,6 +117,25 @@ extern "C"
};
+/* While getopt.h is a glibc extension, the following are newlib extensions.
+ * They are optionally included via the __need_getopt_newlib flag. */
+
+#ifdef __need_getopt_newlib
+
+ /* macros defined by this include file */
+ #define NO_ARG no_argument
+ #define REQUIRED_ARG required_argument
+ #define OPTIONAL_ARG optional_argument
+
+ /* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically-
+ allocated variable of type struct getopt_data. */
+ #define GETOPT_DATA_INITIALIZER {0,0,0,0,0}
+
+ /* These #defines are to make accessing the reentrant functions easier. */
+ #define getopt_r __getopt_r
+ #define getopt_long_r __getopt_long_r
+ #define getopt_long_only_r __getopt_long_only_r
+
/* The getopt_data structure is for reentrancy. Its members are similar to
the externally-defined variables. */
typedef struct getopt_data
@@ -138,6 +144,8 @@ extern "C"
int optind, opterr, optopt, optwhere;
} getopt_data;
+#endif /* __need_getopt_newlib */
+
/* externally-defined variables */
extern char *optarg;
extern int optind;
diff --git a/newlib/libc/stdlib/getopt.c b/newlib/libc/stdlib/getopt.c
index eb0a08284..944214d5f 100644
--- a/newlib/libc/stdlib/getopt.c
+++ b/newlib/libc/stdlib/getopt.c
@@ -83,11 +83,13 @@ Gregory Pietsch's current e-mail address:
gpietsch@comcast.net
****************************************************************************/
+#ifndef HAVE_GETOPT
/* include files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#define __need_getopt_newlib
#include <getopt.h>
/* macros */
@@ -472,4 +474,6 @@ __getopt_long_only_r (int argc, char *const argv[], const char *shortopts,
return getopt_internal (argc, argv, shortopts, longopts, longind, 1, data);
}
+#endif /* !HAVE_GETOPT */
+
/* end of file GETOPT.C */