From 9b022d6db80564cfc10c7f18e5d05cedb32f6375 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Fri, 19 Jul 2002 20:36:09 +0000 Subject: [PATCH] * libc/argz/argz_replace.c: Include buf_findstr.h. * libc/argz/buf_findstr.c: Likewise. * libc/argz/envz_entry.c: Include buf_findstr.h. Cast return value to (char *). * libc/argz/envz_get.c: Likewise. * libc/include/sys/unistd.h: Add getopt and getsubopt declarations. * libc/stdlib/Makefile.am (LIB_SOURCES): Add getsubopt.c. * libc/stdlib/getsubopt.3: New file. * libc/stdlib/getsubopt.c: New file. * libc/sys/linux/machine/i386/socketcall.h (__sockcall_base): Change esp to ebp. --- newlib/ChangeLog | 14 ++ newlib/configure.host | 2 +- newlib/libc/argz/Makefile.in | 2 + newlib/libc/argz/argz_replace.c | 6 +- newlib/libc/argz/buf_findstr.c | 4 +- newlib/libc/argz/buf_findstr.h | 12 ++ newlib/libc/argz/envz_entry.c | 8 +- newlib/libc/argz/envz_get.c | 8 +- newlib/libc/argz/envz_merge.c | 2 +- newlib/libc/ctype/Makefile.in | 2 + newlib/libc/errno/Makefile.in | 2 + newlib/libc/include/machine/ieeefp.h | 2 +- newlib/libc/include/sys/unistd.h | 8 + newlib/libc/locale/Makefile.in | 2 + newlib/libc/misc/Makefile.in | 2 + newlib/libc/posix/Makefile.in | 2 + newlib/libc/search/Makefile.in | 2 + newlib/libc/signal/Makefile.in | 2 + newlib/libc/stdio/Makefile.in | 2 + newlib/libc/stdio64/Makefile.in | 18 ++- newlib/libc/stdlib/Makefile.am | 1 + newlib/libc/stdlib/Makefile.in | 42 ++--- newlib/libc/stdlib/getsubopt.3 | 149 ++++++++++++++++++ newlib/libc/stdlib/getsubopt.c | 101 ++++++++++++ newlib/libc/string/Makefile.in | 2 + .../libc/sys/linux/machine/i386/socketcall.h | 2 +- newlib/libc/syscalls/Makefile.in | 2 + newlib/libc/time/Makefile.in | 2 + newlib/libc/unix/Makefile.in | 2 + 29 files changed, 366 insertions(+), 39 deletions(-) create mode 100644 newlib/libc/argz/buf_findstr.h create mode 100644 newlib/libc/stdlib/getsubopt.3 create mode 100644 newlib/libc/stdlib/getsubopt.c diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 9d297d033..3c0069d66 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,17 @@ +2002-07-19 Thomas Fitzsimmons + + * libc/argz/argz_replace.c: Include buf_findstr.h. + * libc/argz/buf_findstr.c: Likewise. + * libc/argz/envz_entry.c: Include buf_findstr.h. Cast return + value to (char *). + * libc/argz/envz_get.c: Likewise. + * libc/include/sys/unistd.h: Add getopt and getsubopt declarations. + * libc/stdlib/Makefile.am (LIB_SOURCES): Add getsubopt.c. + * libc/stdlib/getsubopt.3: New file. + * libc/stdlib/getsubopt.c: New file. + * libc/sys/linux/machine/i386/socketcall.h (__sockcall_base): + Change esp to ebp. + 2002-07-17 Jeff Johnston * configure.host(stdio64_dir): New setting that is used to diff --git a/newlib/configure.host b/newlib/configure.host index 4cb7bbab7..0cec5e8bf 100644 --- a/newlib/configure.host +++ b/newlib/configure.host @@ -30,7 +30,7 @@ # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory # posix_dir "posix" to build libc/posix, "" otherwise # signal_dir "signal" to build libc/signal, "" otherwise -# stdio64_dir "stdio64" to build libc/stdio64, "" otherwise +# stdio64_dir "stdio64" to build libc/stdio64, "" otherwise # syscall_dir "syscalls" to build libc/syscalls, "" otherwise # unix_dir "unix" to build libc/unix, "" otherwise # use_libtool flag: use libtool to build newlib? diff --git a/newlib/libc/argz/Makefile.in b/newlib/libc/argz/Makefile.in index 69332c88c..888cfca66 100644 --- a/newlib/libc/argz/Makefile.in +++ b/newlib/libc/argz/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/argz/argz_replace.c b/newlib/libc/argz/argz_replace.c index 92979e6f5..cc0d78f5a 100644 --- a/newlib/libc/argz/argz_replace.c +++ b/newlib/libc/argz/argz_replace.c @@ -10,7 +10,7 @@ #include #include -extern int buf_findstr(const char *str, char **buf, size_t *buf_len); +#include "buf_findstr.h" error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count) @@ -31,7 +31,7 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, while(buf_len) { - if(buf_findstr(str, &buf_iter, &buf_len)) + if(_buf_findstr(str, &buf_iter, &buf_len)) { *replace_count += 1; new_argz_len += len_diff; @@ -49,7 +49,7 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, while(buf_len) { - if (buf_findstr(str, &buf_iter, &buf_len)) + if (_buf_findstr(str, &buf_iter, &buf_len)) { /* copy everything up to, but not including str, from old argz to new argz. */ diff --git a/newlib/libc/argz/buf_findstr.c b/newlib/libc/argz/buf_findstr.c index 792706e88..aeb32a943 100644 --- a/newlib/libc/argz/buf_findstr.c +++ b/newlib/libc/argz/buf_findstr.c @@ -9,10 +9,12 @@ #include #include +#include "buf_findstr.h" + /* Find string str in buffer buf of length buf_len. Point buf to character after string, or set it to NULL if end of buffer is reached. Return 1 if found, 0 if not. */ int -buf_findstr(const char *str, const char **buf, size_t *buf_len) +_buf_findstr(const char *str, char **buf, size_t *buf_len) { int i = 0; int j = 0; diff --git a/newlib/libc/argz/buf_findstr.h b/newlib/libc/argz/buf_findstr.h new file mode 100644 index 000000000..d6cef7c15 --- /dev/null +++ b/newlib/libc/argz/buf_findstr.h @@ -0,0 +1,12 @@ +/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +#include + +/* Find string str in buffer buf of length buf_len. Point buf to + character after string, or set it to NULL if end of buffer is + reached. Return 1 if found, 0 if not. */ +int _buf_findstr(const char *str, char **buf, size_t *buf_len); diff --git a/newlib/libc/argz/envz_entry.c b/newlib/libc/argz/envz_entry.c index 4c06f0f40..300aec9d5 100644 --- a/newlib/libc/argz/envz_entry.c +++ b/newlib/libc/argz/envz_entry.c @@ -10,17 +10,17 @@ #include #include -extern int buf_findstr(const char *str, char **buf, size_t *buf_len); +#include "buf_findstr.h" char * envz_entry (const char *envz, size_t envz_len, const char *name) { - const char *buf_ptr = envz; + char *buf_ptr = (char *)envz; size_t buf_len = envz_len; while(buf_len) { - if (buf_findstr(name, &buf_ptr, &buf_len)) + if (_buf_findstr(name, &buf_ptr, &buf_len)) { if (buf_ptr) { @@ -34,7 +34,7 @@ envz_entry (const char *envz, size_t envz_len, const char *name) if(*buf_ptr == '\0') buf_ptr++; - return buf_ptr; + return (char *)buf_ptr; } } } diff --git a/newlib/libc/argz/envz_get.c b/newlib/libc/argz/envz_get.c index dae51bed7..718806ec5 100644 --- a/newlib/libc/argz/envz_get.c +++ b/newlib/libc/argz/envz_get.c @@ -10,22 +10,22 @@ #include #include -extern int buf_findstr(const char *str, char **buf, size_t *buf_len); +#include "buf_findstr.h" char * envz_get (const char *envz, size_t envz_len, const char *name) { - const char *buf_ptr = envz; + char *buf_ptr = (char *)envz; size_t buf_len = envz_len; while(buf_len) { - if (buf_findstr(name, &buf_ptr, &buf_len)) + if (_buf_findstr(name, &buf_ptr, &buf_len)) { if (*buf_ptr == '=') { buf_ptr++; - return buf_ptr; + return (char *)buf_ptr; } else { diff --git a/newlib/libc/argz/envz_merge.c b/newlib/libc/argz/envz_merge.c index b01733017..da2d8cb08 100644 --- a/newlib/libc/argz/envz_merge.c +++ b/newlib/libc/argz/envz_merge.c @@ -20,7 +20,7 @@ envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, char *name_iter = NULL; int retval = 0; - while((entry = argz_next(envz2, envz2_len, entry)) && !retval) + while((entry = argz_next((char *)envz2, envz2_len, entry)) && !retval) { if (!override) { diff --git a/newlib/libc/ctype/Makefile.in b/newlib/libc/ctype/Makefile.in index 05d8810a0..5878fae65 100644 --- a/newlib/libc/ctype/Makefile.in +++ b/newlib/libc/ctype/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/errno/Makefile.in b/newlib/libc/errno/Makefile.in index a5b2b49dc..6cb5349e2 100644 --- a/newlib/libc/errno/Makefile.in +++ b/newlib/libc/errno/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index b0e4536a2..ffde3ffd4 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -50,7 +50,7 @@ */ -#if defined(__arm__) || defined(__thumb__) +#if (defined(__arm__) || defined(__thumb__)) /* ARM always has big-endian words. Within those words the byte ordering will be big or little endian depending upon the target. */ #define __IEEE_BIG_ENDIAN diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index ac39a59a6..df824d88d 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -118,8 +118,16 @@ int _EXFUN(unlink, (const char *__path )); int _EXFUN(vhangup, (void )); _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); +extern char *optarg; /* getopt(3) external variables */ +extern int optind, opterr, optopt; +int getopt(int, char * const [], const char *); +extern int optreset; /* getopt(3) external variable */ + #ifndef _POSIX_SOURCE pid_t _EXFUN(vfork, (void )); + +extern char *suboptarg; /* getsubopt(3) external variable */ +int getsubopt(char **, char * const *, char **); #endif /* _POSIX_SOURCE */ /* Provide prototypes for most of the _ names that are diff --git a/newlib/libc/locale/Makefile.in b/newlib/libc/locale/Makefile.in index 3d0762c57..c640e460f 100644 --- a/newlib/libc/locale/Makefile.in +++ b/newlib/libc/locale/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/misc/Makefile.in b/newlib/libc/misc/Makefile.in index 9e0185118..6c66bbbc9 100644 --- a/newlib/libc/misc/Makefile.in +++ b/newlib/libc/misc/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in index 338a2ed70..c2f6359f9 100644 --- a/newlib/libc/posix/Makefile.in +++ b/newlib/libc/posix/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/search/Makefile.in b/newlib/libc/search/Makefile.in index 6d7c0c114..7a9247e19 100644 --- a/newlib/libc/search/Makefile.in +++ b/newlib/libc/search/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/signal/Makefile.in b/newlib/libc/signal/Makefile.in index 26435c47b..d8bb20bba 100644 --- a/newlib/libc/signal/Makefile.in +++ b/newlib/libc/signal/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index 35178a89a..c973eec8c 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/stdio64/Makefile.in b/newlib/libc/stdio64/Makefile.in index 7d57f4d0d..e452ae241 100644 --- a/newlib/libc/stdio64/Makefile.in +++ b/newlib/libc/stdio64/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ @@ -114,7 +116,10 @@ LIB_SOURCES = \ freopen64.c \ fseeko64.c \ fsetpos64.c \ + fstat64r.c \ ftello64.c \ + lseek64r.c \ + open64r.c \ stdio64.c \ tmpfile64.c @@ -138,7 +143,10 @@ CHEWOUT_FILES = \ freopen64.def \ fseeko64.def \ fsetpos64.def \ + fstat64r.def \ ftello64.def \ + lseek64r.def \ + open64r.def \ tmpfile64.def @@ -161,14 +169,16 @@ lib_a_LIBADD = @USE_LIBTOOL_FALSE@lib_a_OBJECTS = fgetpos64.$(OBJEXT) \ @USE_LIBTOOL_FALSE@fopen64.$(OBJEXT) freopen64.$(OBJEXT) \ @USE_LIBTOOL_FALSE@fseeko64.$(OBJEXT) fsetpos64.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@ftello64.$(OBJEXT) stdio64.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@tmpfile64.$(OBJEXT) +@USE_LIBTOOL_FALSE@fstat64r.$(OBJEXT) ftello64.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@lseek64r.$(OBJEXT) open64r.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@stdio64.$(OBJEXT) tmpfile64.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) libstdio64_la_LIBADD = @USE_LIBTOOL_TRUE@libstdio64_la_OBJECTS = fgetpos64.lo fopen64.lo \ -@USE_LIBTOOL_TRUE@freopen64.lo fseeko64.lo fsetpos64.lo ftello64.lo \ -@USE_LIBTOOL_TRUE@stdio64.lo tmpfile64.lo +@USE_LIBTOOL_TRUE@freopen64.lo fseeko64.lo fsetpos64.lo fstat64r.lo \ +@USE_LIBTOOL_TRUE@ftello64.lo lseek64r.lo open64r.lo stdio64.lo \ +@USE_LIBTOOL_TRUE@tmpfile64.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am index 574ac2ab6..4aee696a4 100644 --- a/newlib/libc/stdlib/Makefile.am +++ b/newlib/libc/stdlib/Makefile.am @@ -33,6 +33,7 @@ LIB_SOURCES = \ getenv.c \ getenv_r.c \ getopt.c \ + getsubopt.c \ jrand48.c \ l64a.c \ labs.c \ diff --git a/newlib/libc/stdlib/Makefile.in b/newlib/libc/stdlib/Makefile.in index bdadd2961..6e731b415 100644 --- a/newlib/libc/stdlib/Makefile.in +++ b/newlib/libc/stdlib/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ @@ -137,6 +139,7 @@ LIB_SOURCES = \ getenv.c \ getenv_r.c \ getopt.c \ + getsubopt.c \ jrand48.c \ l64a.c \ labs.c \ @@ -275,17 +278,18 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@efgcvt.$(OBJEXT) environ.$(OBJEXT) envlock.$(OBJEXT) \ @USE_LIBTOOL_FALSE@eprintf.$(OBJEXT) erand48.$(OBJEXT) exit.$(OBJEXT) \ @USE_LIBTOOL_FALSE@getenv.$(OBJEXT) getenv_r.$(OBJEXT) getopt.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@jrand48.$(OBJEXT) l64a.$(OBJEXT) labs.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@lcong48.$(OBJEXT) ldiv.$(OBJEXT) ldtoa.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@lrand48.$(OBJEXT) malign.$(OBJEXT) malloc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mblen.$(OBJEXT) mblen_r.$(OBJEXT) mbstowcs.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mbstowcs_r.$(OBJEXT) mbtowc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mbtowc_r.$(OBJEXT) mlock.$(OBJEXT) mprec.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mrand48.$(OBJEXT) msize.$(OBJEXT) mstats.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mtrim.$(OBJEXT) nrand48.$(OBJEXT) on_exit.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@putenv.$(OBJEXT) putenv_r.$(OBJEXT) rand.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@rand48.$(OBJEXT) rand_r.$(OBJEXT) realloc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@seed48.$(OBJEXT) setenv.$(OBJEXT) setenv_r.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getsubopt.$(OBJEXT) jrand48.$(OBJEXT) l64a.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@labs.$(OBJEXT) lcong48.$(OBJEXT) ldiv.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@ldtoa.$(OBJEXT) lrand48.$(OBJEXT) malign.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@malloc.$(OBJEXT) mblen.$(OBJEXT) mblen_r.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mbstowcs.$(OBJEXT) mbstowcs_r.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mbtowc.$(OBJEXT) mbtowc_r.$(OBJEXT) mlock.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mprec.$(OBJEXT) mrand48.$(OBJEXT) msize.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mstats.$(OBJEXT) mtrim.$(OBJEXT) nrand48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@on_exit.$(OBJEXT) putenv.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@putenv_r.$(OBJEXT) rand.$(OBJEXT) rand48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@rand_r.$(OBJEXT) realloc.$(OBJEXT) seed48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@setenv.$(OBJEXT) setenv_r.$(OBJEXT) \ @USE_LIBTOOL_FALSE@srand48.$(OBJEXT) strdup.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strdup_r.$(OBJEXT) strtod.$(OBJEXT) strtol.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strtoll.$(OBJEXT) strtoll_r.$(OBJEXT) \ @@ -307,14 +311,14 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@calloc.lo div.lo drand48.lo dtoa.lo dtoastub.lo \ @USE_LIBTOOL_TRUE@ecvtbuf.lo efgcvt.lo environ.lo envlock.lo eprintf.lo \ @USE_LIBTOOL_TRUE@erand48.lo exit.lo getenv.lo getenv_r.lo getopt.lo \ -@USE_LIBTOOL_TRUE@jrand48.lo l64a.lo labs.lo lcong48.lo ldiv.lo \ -@USE_LIBTOOL_TRUE@ldtoa.lo lrand48.lo malign.lo malloc.lo mblen.lo \ -@USE_LIBTOOL_TRUE@mblen_r.lo mbstowcs.lo mbstowcs_r.lo mbtowc.lo \ -@USE_LIBTOOL_TRUE@mbtowc_r.lo mlock.lo mprec.lo mrand48.lo msize.lo \ -@USE_LIBTOOL_TRUE@mstats.lo mtrim.lo nrand48.lo on_exit.lo putenv.lo \ -@USE_LIBTOOL_TRUE@putenv_r.lo rand.lo rand48.lo rand_r.lo realloc.lo \ -@USE_LIBTOOL_TRUE@seed48.lo setenv.lo setenv_r.lo srand48.lo strdup.lo \ -@USE_LIBTOOL_TRUE@strdup_r.lo strtod.lo strtol.lo strtoll.lo \ +@USE_LIBTOOL_TRUE@getsubopt.lo jrand48.lo l64a.lo labs.lo lcong48.lo \ +@USE_LIBTOOL_TRUE@ldiv.lo ldtoa.lo lrand48.lo malign.lo malloc.lo \ +@USE_LIBTOOL_TRUE@mblen.lo mblen_r.lo mbstowcs.lo mbstowcs_r.lo \ +@USE_LIBTOOL_TRUE@mbtowc.lo mbtowc_r.lo mlock.lo mprec.lo mrand48.lo \ +@USE_LIBTOOL_TRUE@msize.lo mstats.lo mtrim.lo nrand48.lo on_exit.lo \ +@USE_LIBTOOL_TRUE@putenv.lo putenv_r.lo rand.lo rand48.lo rand_r.lo \ +@USE_LIBTOOL_TRUE@realloc.lo seed48.lo setenv.lo setenv_r.lo srand48.lo \ +@USE_LIBTOOL_TRUE@strdup.lo strdup_r.lo strtod.lo strtol.lo strtoll.lo \ @USE_LIBTOOL_TRUE@strtoll_r.lo strtoul.lo strtoull.lo strtoull_r.lo \ @USE_LIBTOOL_TRUE@system.lo valloc.lo wcstombs.lo wcstombs_r.lo \ @USE_LIBTOOL_TRUE@wctomb.lo wctomb_r.lo diff --git a/newlib/libc/stdlib/getsubopt.3 b/newlib/libc/stdlib/getsubopt.3 new file mode 100644 index 000000000..83c5f7c6b --- /dev/null +++ b/newlib/libc/stdlib/getsubopt.3 @@ -0,0 +1,149 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/stdlib/getsubopt.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 9, 1993 +.Dt GETSUBOPT 3 +.Os +.Sh NAME +.Nm getsubopt +.Nd get sub options from an argument +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Vt extern char *suboptarg ; +.Ft int +.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep" +.Sh DESCRIPTION +The +.Fn getsubopt +function +parses a string containing tokens delimited by one or more tab, space or +comma +.Pq Ql \&, +characters. +It is intended for use in parsing groups of option arguments provided +as part of a utility command line. +.Pp +The argument +.Fa optionp +is a pointer to a pointer to the string. +The argument +.Fa tokens +is a pointer to a +.Dv NULL Ns -terminated +array of pointers to strings. +.Pp +The +.Fn getsubopt +function +returns the zero-based offset of the pointer in the +.Fa tokens +array referencing a string which matches the first token +in the string, or, \-1 if the string contains no tokens or +.Fa tokens +does not contain a matching string. +.Pp +If the token is of the form ``name=value'', the location referenced by +.Fa valuep +will be set to point to the start of the ``value'' portion of the token. +.Pp +On return from +.Fn getsubopt , +.Fa optionp +will be set to point to the start of the next token in the string, +or the null at the end of the string if no more tokens are present. +The external variable +.Fa suboptarg +will be set to point to the start of the current token, or +.Dv NULL +if no +tokens were present. +The argument +.Fa valuep +will be set to point to the ``value'' portion of the token, or +.Dv NULL +if no ``value'' portion was present. +.Sh EXAMPLES +.Bd -literal -compact +char *tokens[] = { + #define ONE 0 + "one", + #define TWO 1 + "two", + NULL +}; + +\&... + +extern char *optarg, *suboptarg; +char *options, *value; + +while ((ch = getopt(argc, argv, "ab:")) != \-1) { + switch(ch) { + case 'a': + /* process ``a'' option */ + break; + case 'b': + options = optarg; + while (*options) { + switch(getsubopt(&options, tokens, &value)) { + case ONE: + /* process ``one'' sub option */ + break; + case TWO: + /* process ``two'' sub option */ + if (!value) + error("no value for two"); + i = atoi(value); + break; + case \-1: + if (suboptarg) + error("illegal sub option %s", + suboptarg); + else + error("missing sub option"); + break; + } + break; + } +.Ed +.Sh SEE ALSO +.Xr getopt 3 , +.Xr strsep 3 +.Sh HISTORY +The +.Fn getsubopt +function first appeared in +.Bx 4.4 . diff --git a/newlib/libc/stdlib/getsubopt.c b/newlib/libc/stdlib/getsubopt.c new file mode 100644 index 000000000..250e73d2c --- /dev/null +++ b/newlib/libc/stdlib/getsubopt.c @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#include + +#include +#include +#include + +/* + * The SVID interface to getsubopt provides no way of figuring out which + * part of the suboptions list wasn't matched. This makes error messages + * tricky... The extern variable suboptarg is a pointer to the token + * which didn't match. + */ +char *suboptarg; + +int +getsubopt(optionp, tokens, valuep) + char **optionp, **valuep; + char * const *tokens; +{ + int cnt; + char *p; + + suboptarg = *valuep = NULL; + + if (!optionp || !*optionp) + return(-1); + + /* skip leading white-space, commas */ + for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); + + if (!*p) { + *optionp = p; + return(-1); + } + + /* save the start of the token, and skip the rest of the token. */ + for (suboptarg = p; + *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';); + + if (*p) { + /* + * If there's an equals sign, set the value pointer, and + * skip over the value part of the token. Terminate the + * token. + */ + if (*p == '=') { + *p = '\0'; + for (*valuep = ++p; + *p && *p != ',' && *p != ' ' && *p != '\t'; ++p); + if (*p) + *p++ = '\0'; + } else + *p++ = '\0'; + /* Skip any whitespace or commas after this token. */ + for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); + } + + /* set optionp for next round. */ + *optionp = p; + + for (cnt = 0; *tokens; ++tokens, ++cnt) + if (!strcmp(suboptarg, *tokens)) + return(cnt); + return(-1); +} diff --git a/newlib/libc/string/Makefile.in b/newlib/libc/string/Makefile.in index 6bfe74c73..32073c400 100644 --- a/newlib/libc/string/Makefile.in +++ b/newlib/libc/string/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/sys/linux/machine/i386/socketcall.h b/newlib/libc/sys/linux/machine/i386/socketcall.h index bd83d5175..07908767f 100644 --- a/newlib/libc/sys/linux/machine/i386/socketcall.h +++ b/newlib/libc/sys/linux/machine/i386/socketcall.h @@ -18,7 +18,7 @@ #define __sockcall_base(type, name) \ { \ long __res; \ -__asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%esp),%%ecx; int $0x80; pop %%ebx" \ +__asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%ebp),%%ecx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_socketcall),"r" (SOCK_##name)); \ __syscall_return(type,__res); \ diff --git a/newlib/libc/syscalls/Makefile.in b/newlib/libc/syscalls/Makefile.in index 49934f939..68f389257 100644 --- a/newlib/libc/syscalls/Makefile.in +++ b/newlib/libc/syscalls/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/time/Makefile.in b/newlib/libc/time/Makefile.in index 0c4fb0443..8fe997b28 100644 --- a/newlib/libc/time/Makefile.in +++ b/newlib/libc/time/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ diff --git a/newlib/libc/unix/Makefile.in b/newlib/libc/unix/Makefile.in index a9074cb0d..60a069d55 100644 --- a/newlib/libc/unix/Makefile.in +++ b/newlib/libc/unix/Makefile.in @@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@