summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile46
-rw-r--r--include/fnmatch.h47
-rw-r--r--include/glob.h196
-rw-r--r--include/stdlib.h6
-rw-r--r--include/unistd.h4
-rw-r--r--libc/inet/Makefile1
-rw-r--r--libc/inet/rpc/svc_tcp.c4
-rw-r--r--libc/misc/time/Makefile1
-rw-r--r--libc/pwd_grp/Makefile3
-rw-r--r--libc/stdio/Makefile1
-rw-r--r--libc/stdlib/Makefile4
-rw-r--r--libc/stdlib/abort.c53
-rw-r--r--libc/stdlib/atexit.c1
-rw-r--r--libc/stdlib/malloc/Makefile5
-rw-r--r--libc/string/Makefile1
-rw-r--r--libc/termios/Makefile1
16 files changed, 333 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index b9062156f..6f1765661 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,11 @@
-DIRS = headers error misc stdio2 time getent regexp string termios sysdeps \
-malloc-simple net rpc
+DIRS = headers error getent malloc-simple misc net regexp rpc stdio2 \
+ string sysdeps termios time
all: libc.a
-# crt0.o
libc.a: $(DIRS) dummy
$(CROSS)ranlib $@
-#crt0.o: crt
-
headers: dummy
if [ ! -L "include/asm" ]; then ln -s /usr/src/linux/include/asm include/asm ; fi
if [ ! -L "include/net" ]; then ln -s /usr/src/linux/include/net include/net ; fi
@@ -17,41 +14,38 @@ headers: dummy
error: dummy
make -C error
-misc: dummy
- make -C misc
+getent: dummy
+ make -C getent
-stdio2: dummy
- make -C stdio2
+malloc-simple: dummy
+ make -C malloc-simple
-time: dummy
- make -C time
+misc: dummy
+ make -C misc
-getent: dummy
- make -C getent
+net: dummy
+ make -C net
regexp: dummy
make -C regexp
+rpc: dummy
+ make -C rpc
+
+stdio2: dummy
+ make -C stdio2
+
string: dummy
make -C string
-termios: dummy
- make -C termios
-
sysdeps: dummy
make -C sysdeps
-malloc-simple: dummy
- make -C malloc-simple
-
-net: dummy
- make -C net
-
-rpc: dummy
- make -C rpc
+termios: dummy
+ make -C termios
-crt: dummy
- make -C crt
+time: dummy
+ make -C time
dummy:
diff --git a/include/fnmatch.h b/include/fnmatch.h
new file mode 100644
index 000000000..c89d0ee4b
--- /dev/null
+++ b/include/fnmatch.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _FNMATCH_H
+
+#define _FNMATCH_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Bits set in the FLAGS argument to `fnmatch'. */
+#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
+#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
+
+#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
+#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
+#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+#endif
+
+/* Value returned by `fnmatch' if STRING does not match PATTERN. */
+#define FNM_NOMATCH 1
+
+/* Match STRING against the filename pattern PATTERN,
+ returning zero if it matches, FNM_NOMATCH if not. */
+extern int fnmatch __P ((__const char *__pattern, __const char *__string,
+ int __flags));
+
+__END_DECLS
+
+#endif /* fnmatch.h */
diff --git a/include/glob.h b/include/glob.h
new file mode 100644
index 000000000..c4ad24f17
--- /dev/null
+++ b/include/glob.h
@@ -0,0 +1,196 @@
+/* Copyright (C) 1991, 92, 95, 96, 97, 98, 2000 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _GLOB_H
+#define _GLOB_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef __ptr_t
+#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
+# if !defined __GLIBC__ || !defined __P
+# undef __P
+# undef __PMT
+# define __P(protos) protos
+# define __PMT(protos) protos
+# if !defined __GNUC__ || __GNUC__ < 2
+# undef __const
+# define __const const
+# endif
+# endif
+# define __ptr_t void *
+#else /* Not C++ or ANSI C. */
+# undef __P
+# undef __PMT
+# define __P(protos) ()
+# define __PMT(protos) ()
+# undef __const
+# define __const
+# define __ptr_t char *
+#endif /* C++ or ANSI C. */
+
+/* We need `size_t' for the following definitions. */
+#ifndef __size_t
+# if defined __GNUC__ && __GNUC__ >= 2
+typedef __SIZE_TYPE__ __size_t;
+# ifdef _XOPEN_SOURCE
+typedef __SIZE_TYPE__ size_t;
+# endif
+# else
+/* This is a guess. */
+typedef unsigned long int __size_t;
+# endif
+#else
+/* The GNU CC stddef.h version defines __size_t as empty. We need a real
+ definition. */
+# undef __size_t
+# define __size_t size_t
+#endif
+
+/* Bits set in the FLAGS argument to `glob'. */
+#define GLOB_ERR (1 << 0)/* Return on read errors. */
+#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
+#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
+#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
+#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
+#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
+#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
+#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
+
+#if (!defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _BSD_SOURCE \
+ || defined _GNU_SOURCE)
+# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
+# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
+# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
+# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
+# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
+# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
+# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
+ if the user name is not available. */
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
+ GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
+#else
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD)
+#endif
+
+/* Error returns from `glob'. */
+#define GLOB_NOSPACE 1 /* Ran out of memory. */
+#define GLOB_ABORTED 2 /* Read error. */
+#define GLOB_NOMATCH 3 /* No matches found. */
+#define GLOB_NOSYS 4 /* Not implemented. */
+#ifdef _GNU_SOURCE
+/* Previous versions of this file defined GLOB_ABEND instead of
+ GLOB_ABORTED. Provide a compatibility definition here. */
+# define GLOB_ABEND GLOB_ABORTED
+#endif
+
+/* Structure describing a globbing run. */
+#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
+struct stat;
+#endif
+typedef struct
+ {
+ __size_t gl_pathc; /* Count of paths matched by the pattern. */
+ char **gl_pathv; /* List of matched pathnames. */
+ __size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
+ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) __PMT ((void *));
+ struct dirent *(*gl_readdir) __PMT ((void *));
+ __ptr_t (*gl_opendir) __PMT ((__const char *));
+ int (*gl_lstat) __PMT ((__const char *, struct stat *));
+ int (*gl_stat) __PMT ((__const char *, struct stat *));
+ } glob_t;
+
+#ifdef _LARGEFILE64_SOURCE
+struct stat64;
+typedef struct
+ {
+ __size_t gl_pathc;
+ char **gl_pathv;
+ __size_t gl_offs;
+ int gl_flags;
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) __PMT ((void *));
+ struct dirent64 *(*gl_readdir) __PMT ((void *));
+ __ptr_t (*gl_opendir) __PMT ((__const char *));
+ int (*gl_lstat) __PMT ((__const char *, struct stat64 *));
+ int (*gl_stat) __PMT ((__const char *, struct stat64 *));
+ } glob64_t;
+#endif
+
+/* Do glob searching for PATTERN, placing results in PGLOB.
+ The bits defined above may be set in FLAGS.
+ If a directory cannot be opened or read and ERRFUNC is not nil,
+ it is called with the pathname that caused the error, and the
+ `errno' value from the failing call; if it returns non-zero
+ `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
+ If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
+ Otherwise, `glob' returns zero. */
+#if _FILE_OFFSET_BITS != 64
+extern int glob __P ((__const char *__pattern, int __flags,
+ int (*__errfunc) (__const char *, int),
+ glob_t *__pglob));
+
+/* Free storage allocated in PGLOB by a previous `glob' call. */
+extern void globfree __P ((glob_t *__pglob));
+#else
+# if __GNUC__ >= 2
+extern int glob __P ((__const char *__pattern, int __flags,
+ int (*__errfunc) (__const char *, int),
+ glob_t *__pglob)) __asm__ ("glob64");
+
+extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
+# else
+# define glob glob64
+# define globfree globfree64
+# endif
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+extern int glob64 __P ((__const char *__pattern, int __flags,
+ int (*__errfunc) (__const char *, int),
+ glob64_t *__pglob));
+
+extern void globfree64 __P ((glob64_t *__pglob));
+#endif
+
+
+#ifdef _GNU_SOURCE
+/* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero.
+
+ This function is not part of the interface specified by POSIX.2
+ but several programs want to use it. */
+extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* glob.h */
diff --git a/include/stdlib.h b/include/stdlib.h
index 691a5a537..047300af2 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -14,8 +14,14 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+/* Call all functions registered with `atexit' and `on_exit',
+ * in the reverse of the order in which they were registered
+ * perform stdio cleanup, and terminate program execution with STATUS. */
extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
+/* Register a function to be called when `exit' is called. */
extern int atexit __P ((void (*__func) (void)));
+/* Abort execution and generate a core-dump. */
+extern void abort __P ((void)) __attribute__ ((__noreturn__));
extern void * malloc __P ((size_t));
extern void * calloc __P ((size_t, size_t));
diff --git a/include/unistd.h b/include/unistd.h
index ef67fafc4..3fb2e7f4b 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -14,6 +14,10 @@
#define STDERR_FILENO 2
+/* NULL-terminated array of "NAME=VALUE" environment variables. */
+extern char **__environ;
+extern char **environ;
+
extern int close __P ((int));
extern size_t read __P ((int __fd, char * __buf, size_t __nbytes));
diff --git a/libc/inet/Makefile b/libc/inet/Makefile
index 14afc1763..b73a5499e 100644
--- a/libc/inet/Makefile
+++ b/libc/inet/Makefile
@@ -22,7 +22,6 @@ gethostbyaddr.o
OBJ=$(AOBJ) $(ROBJ)
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
diff --git a/libc/inet/rpc/svc_tcp.c b/libc/inet/rpc/svc_tcp.c
index 2f859476b..837e70c82 100644
--- a/libc/inet/rpc/svc_tcp.c
+++ b/libc/inet/rpc/svc_tcp.c
@@ -41,13 +41,11 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
* and a record/tcp stream.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <errno.h>
-/*#ifndef linux*/
-extern bool_t abort();
-/*#endif*/
extern errno;
/*
diff --git a/libc/misc/time/Makefile b/libc/misc/time/Makefile
index 7d648f867..2ee2a14e0 100644
--- a/libc/misc/time/Makefile
+++ b/libc/misc/time/Makefile
@@ -13,7 +13,6 @@ OBJ=localtime.o gmtime.o asctime.o ctime.o asc_conv.o tm_conv.o mktime.o \
localtime_r.o gmtime_r.o asctime_r.o ctime_r.o
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
diff --git a/libc/pwd_grp/Makefile b/libc/pwd_grp/Makefile
index 8be9015f1..06f1cb7c1 100644
--- a/libc/pwd_grp/Makefile
+++ b/libc/pwd_grp/Makefile
@@ -21,10 +21,11 @@ UOBJ=utent.o
OBJ=$(POBJ) $(GOBJ) $(UOBJ)
all: $(LIBC)($(OBJ))
- @$(RM) $(OBJ)
$(LIBC)($(GOBJ)): config-grp.h
+$(LIBC): $(LIBC)($(OBJ))
+
clean:
rm -f *.o libc.a
diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile
index 1aa8354f4..3357b3a93 100644
--- a/libc/stdio/Makefile
+++ b/libc/stdio/Makefile
@@ -21,7 +21,6 @@ SOBJ=scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o vfscanf.o
OBJ= $(AOBJ) $(POBJ) $(SOBJ) dputs.o
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile
index 61a82a2d6..2c2d0f5fb 100644
--- a/libc/stdlib/Makefile
+++ b/libc/stdlib/Makefile
@@ -17,7 +17,8 @@ EOBJ=on_exit.o atexit.o __do_exit.o exit.o
GOBJ=atoi.o atol.o ltoa.o ltostr.o \
ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \
- itoa.o strtol.o crypt.o sleep.o mkstemp.o mktemp.o
+ glob.o fnmatch.o itoa.o strtol.o crypt.o sleep.o mkstemp.o \
+ mktemp.o
UOBJ=getenv.o putenv.o popen.o system.o getcwd.o setenv.o \
execl.o execv.o execlp.o execvp.o execvep.o
@@ -31,7 +32,6 @@ OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ)
#endif
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
new file mode 100644
index 000000000..3d1c75fe0
--- /dev/null
+++ b/libc/stdlib/abort.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* Hacked up for uC-Libc by Erik Andersen */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+
+typedef void (*vfuncp) ();
+extern vfuncp __cleanup;
+extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
+
+/* Cause an abnormal program termination with core-dump. */
+void
+abort(void)
+{
+ sigset_t sigset;
+
+ if (sigemptyset(&sigset) == 0 &&
+ sigaddset(&sigset, SIGABRT) == 0) {
+ sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL);
+ }
+
+ if (__cleanup)
+ __cleanup();
+
+ while (1)
+ if (raise(SIGABRT))
+ /* If we can't signal ourselves, exit. */
+ _exit(127);
+ /* If we signal ourselves and are still alive,
+ or can't exit, loop forever. */
+}
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index 2a82c6edb..7c6a03af8 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -20,6 +20,7 @@ typedef void (*vfuncp) ();
extern vfuncp __cleanup;
extern void __do_exit();
+extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
extern struct exit_table
{
diff --git a/libc/stdlib/malloc/Makefile b/libc/stdlib/malloc/Makefile
index ece276ba3..b3aca377b 100644
--- a/libc/stdlib/malloc/Makefile
+++ b/libc/stdlib/malloc/Makefile
@@ -10,14 +10,11 @@ LIBC=../libc.a
MSRC=alloc.c
MOBJ=malloc.o realloc.o free.o calloc.o malloc_dbg.o free_dbg.o calloc_dbg.o
-OBJ=$(MOBJ)
-
CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
all: $(LIBC)
- @$(RM) $(OBJ)
-$(LIBC): $(LIBC)($(OBJ))
+$(LIBC): $(LIBC)($(MOBJ))
$(LIBC)($(MOBJ)): $(MSRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
diff --git a/libc/string/Makefile b/libc/string/Makefile
index a64d0b82b..251948183 100644
--- a/libc/string/Makefile
+++ b/libc/string/Makefile
@@ -16,7 +16,6 @@ OBJ=$(SOBJ) strpbrk.o strsep.o strstr.o strtok.o strcspn.o \
strspn.o strcasecmp.o strncasecmp.o config.o
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
diff --git a/libc/termios/Makefile b/libc/termios/Makefile
index a4ff4b7d9..4ab80e9da 100644
--- a/libc/termios/Makefile
+++ b/libc/termios/Makefile
@@ -19,7 +19,6 @@ OBJ=$(TOBJ) ttyname.o
# ttyname.o
all: $(LIBC)
- @$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))