From beba34dc223aa0dcf3e5f696966c5e8408b022c3 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Sat, 24 Jan 2004 16:27:32 +0100 Subject: Import Dev86src-0.16.15.tar.gz --- libc/Makefile | 12 +++++++----- libc/error/Makefile | 13 +++++++++++-- libc/error/README | 9 +++++---- libc/error/error.c | 2 +- libc/error/error2.c | 21 +++++++++++++++++++++ libc/error/mktab.sh | 25 +++++++++++++++++++++++++ libc/error/sys_errlist.c | 2 +- libc/include/linux/stat.h | 1 - libc/include/linux/types.h | 2 +- libc/malloc/malloc.c | 3 +++ 10 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 libc/error/error2.c create mode 100644 libc/error/mktab.sh (limited to 'libc') diff --git a/libc/Makefile b/libc/Makefile index a9a5460..481c034 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -20,6 +20,8 @@ include VERSION endif CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) +USERID=$(shell id -gn) +GROUPID=$(shell id -un) ############################################################################ @@ -74,11 +76,11 @@ clean: ############################################################################ install_incl: transfer - install -d $(BCCHOME)/include - rm -f $(BCCHOME)/include/linuxmt $(BCCHOME)/include/arch ||: - cp -Lpr include/* $(BCCHOME)/include - -chown -R root:root $(BCCHOME)/include - -chmod -R u=rwX,og=rX $(BCCHOME)/include + install -d $(DISTINCL)/include + rm -f $(DISTINCL)/include/linuxmt $(DISTINCL)/include/arch ||: + cp -LpR include/* $(DISTINCL)/include + -chown -R $(USERID):$(GROUPID) $(DISTINCL)/include + -chmod -R ugo-x,u=rwX,og=rX $(DISTINCL)/include ############################################################################ diff --git a/libc/error/Makefile b/libc/error/Makefile index f14e956..01a488f 100644 --- a/libc/error/Makefile +++ b/libc/error/Makefile @@ -4,14 +4,23 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) -ifeq ($(LIB_OS),ELKS) +ifeq ($(PLATFORM),i86-FAST) OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o else +ifeq ($(LIB_OS),ELKS) +OBJ=error2.o perror.o sys_siglist.o __assert.o +else OBJ=__assert.o endif +endif all: $(LIBC)($(OBJ)) @$(RM) $(OBJ) clean: - rm -f *.o libc.a + rm -f *.o libc.a error_list.h + +$(LIBC)(error2.o): error_list.h + +error_list.h: liberror.txt + sh mktab.sh diff --git a/libc/error/README b/libc/error/README index 02c123f..3165722 100644 --- a/libc/error/README +++ b/libc/error/README @@ -1,10 +1,11 @@ -Copyright (C) 1996 Robert de Bath +Copyright (C) 1996,2004 Robert de Bath This file is part of the Linux-8086 C library and is distributed under the GNU Library General Public License. -These routines assume the existance of a file /usr/lib/liberror.txt, -this file contains the actual error messages. One useful feature, -the language of the error messages can be easily changed. +The file "liberror.txt" is the master list of errors for ELKS only. +WARNING: + If you use the -Mf compile style this file must be in the filessystem + as "/lib/liberror.txt" unless you're using elksemu. -Robert diff --git a/libc/error/error.c b/libc/error/error.c index 3695719..4be2a56 100644 --- a/libc/error/error.c +++ b/libc/error/error.c @@ -24,7 +24,7 @@ int err; } if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */ - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) goto unknown; while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) diff --git a/libc/error/error2.c b/libc/error/error2.c new file mode 100644 index 0000000..4ad2892 --- /dev/null +++ b/libc/error/error2.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1996,2004 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include + +#include "error_list.h" + +char * +strerror(err) +int err; +{ + static char retbuf[20]; + + if( err > 0 && err <= sys_nerr ) + return sys_errlist[err]; + + strcpy(retbuf, "Error "); + strcpy(retbuf+6, itoa(err)); + return retbuf; +} diff --git a/libc/error/mktab.sh b/libc/error/mktab.sh new file mode 100644 index 0000000..b5afcc4 --- /dev/null +++ b/libc/error/mktab.sh @@ -0,0 +1,25 @@ +#!/bin/sh - + +awk '{ + e=$0; + sub("^[^ ]* ", "", e); + sub(" [^ ]*$", "", e); + n=0+$1; + if (!(n in errlist)) + errlist[n] = e; + if(n > maxerr) maxerr=n; +} +END{ + printf ("#define NR_ERRORS\t%d\n", maxerr+1); + printf ("int sys_nerr = NR_ERRORS;\n"); + printf ("char *sys_errlist[NR_ERRORS] = {\n"); + + for(i=0; i<=maxerr; i++) { + if (errlist[i] == "") + printf(" \"Error %d\"", i); + else + printf(" \"%s\"", errlist[i]); + if (i != maxerr) printf(",\n"); else printf("\n"); + } + printf ("};\n"); +}' < liberror.txt > error_list.h diff --git a/libc/error/sys_errlist.c b/libc/error/sys_errlist.c index 48aa6a3..8dfa3ec 100644 --- a/libc/error/sys_errlist.c +++ b/libc/error/sys_errlist.c @@ -42,7 +42,7 @@ static void init_vars() int i, cc, fd, err, len, bufoff=0; char * ptr; - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) return; for(i=0; i