diff options
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/Makefile | 25 | ||||
-rw-r--r-- | libc/stdlib/abs.c | 13 | ||||
-rw-r--r-- | libc/stdlib/malloc-simple/Makefile | 2 | ||||
-rw-r--r-- | libc/stdlib/malloc-simple/alloc.c | 8 | ||||
-rw-r--r-- | libc/stdlib/malloc/Makefile | 2 | ||||
-rw-r--r-- | libc/stdlib/malloc/malloc.c | 8 |
6 files changed, 46 insertions, 12 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index da402be6c..b4211ecf7 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -24,23 +24,22 @@ TOPDIR=../ include $(TOPDIR)Rules.make LIBC=$(TOPDIR)libc.a -MSRC=aliases.c -MOBJ=abs.o remove.o creat.o bcopy.o bzero.o # raise.o bcmp.o index.o rindex.o +DIRS = $(MALLOC) + MSRC2=atexit.c MOBJ2=on_exit.o atexit.o __do_exit.o exit.o -CSRC=atoi.c atol.c ltoa.c ltostr.c ctype.c qsort.c bsearch.c rand.c lsearch.c \ - getopt.c glob.c fnmatch.c itoa.c strtod.c strtol.c crypt.c sleep.c \ - mkstemp.c mktemp.c realpath.c getenv.c putenv.c popen.c system.c \ - getcwd.c setenv.c execl.c execv.c execlp.c execvp.c execvep.c + +CSRC = abort.c getenv.c mktemp.c qsort.c realpath.c strtod.c strtoul.c \ + abs.c bsearch.c mkstemp.c putenv.c rand.c setenv.c strtol.c system.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(MOBJ) $(MOBJ2) $(COBJS) all: $(OBJS) $(LIBC) -$(LIBC): ar-target +$(LIBC): ar-target subdirs ar-target: $(OBJS) $(AR) $(ARFLAGS) $(LIBC) $(OBJS) @@ -53,6 +52,18 @@ $(MOBJ2): $(MSRC2) $(OBJ): Makefile +subdirs: $(patsubst %, _dir_%, $(DIRS)) +subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) + +$(patsubst %, _dir_%, $(DIRS)) : dummy + $(MAKE) -C $(patsubst _dir_%, %, $@) + +$(patsubst %, _dirclean_%, $(DIRS)) : dummy + $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean + clean: rm -f *.[oa] *~ core +.PHONY: dummy + + diff --git a/libc/stdlib/abs.c b/libc/stdlib/abs.c new file mode 100644 index 000000000..044a334b1 --- /dev/null +++ b/libc/stdlib/abs.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include <unistd.h> +#include <string.h> +#include <sys/types.h> + +int abs(int arg1) +{ + return arg1 > 0 ? arg1 : -arg1; +} + diff --git a/libc/stdlib/malloc-simple/Makefile b/libc/stdlib/malloc-simple/Makefile index c2f8827b5..e46415536 100644 --- a/libc/stdlib/malloc-simple/Makefile +++ b/libc/stdlib/malloc-simple/Makefile @@ -20,7 +20,7 @@ # other sundry sources. Files within this library are copyright by their # respective copyright holders. -TOPDIR=../ +TOPDIR=../../ include $(TOPDIR)Rules.make LIBC=$(TOPDIR)libc.a diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index cf4835c97..f31105d4e 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -67,8 +67,12 @@ void *calloc(size_t num, size_t size) void *malloc(size_t len) { void *result = mmap((void *) 0, len, PROT_READ | PROT_WRITE, - //MAP_SHARED | MAP_ANONYMOUS, 0, 0); - MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); +#ifdef __HAS_NO_MMU__ + MAP_SHARED | MAP_ANONYMOUS, 0, 0 +#else + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0 +#endif + ); if (result == (void *) -1) return 0; diff --git a/libc/stdlib/malloc/Makefile b/libc/stdlib/malloc/Makefile index fe3f8b424..0824e71a8 100644 --- a/libc/stdlib/malloc/Makefile +++ b/libc/stdlib/malloc/Makefile @@ -20,7 +20,7 @@ # other sundry sources. Files within this library are copyright by their # respective copyright holders. -TOPDIR=../ +TOPDIR=../../ include $(TOPDIR)Rules.make LIBC=$(TOPDIR)libc.a diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c index 1a0b61aa5..4ed9fe873 100644 --- a/libc/stdlib/malloc/malloc.c +++ b/libc/stdlib/malloc/malloc.c @@ -190,7 +190,13 @@ static void *hunk_alloc(int size) if ((p = free_h[size]) == NULL) { if ((p = (Hunk_t*)mmap(HUNK_MSTART,HUNK_MSIZE,PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANON,0,0)) == (Hunk_t*)MAP_FAILED) +#ifdef __HAS_NO_MMU__ + MAP_PRIVATE|MAP_ANONYMOUS +#else + + MAP_SHARED|MAP_ANONYMOUS +#endif + ,0,0)) == (Hunk_t*)MAP_FAILED) return NULL; memset(p,0,HUNK_MSIZE); p->id = HUNK_ID; |