summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-05 19:25:08 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-05 19:25:08 +0000
commitca9bd30c262ed788486c1d367ad40550e5d806c2 (patch)
treedaf86037f4b4d34e91c6f147e287fb26694df103 /libc/stdlib
parent9281d180d13057917f618c35ef7433d2e4d4dd86 (diff)
Many bugfixes, header cleanups, etc. Added abort and glob.
It is getting closer... -Erik
Diffstat (limited to 'libc/stdlib')
-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
4 files changed, 57 insertions, 6 deletions
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