From baf57cf02a8522d7909bc96a058ef95a6c432426 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 19:26:06 -0700 Subject: [PATCH 1/6] More fixes for C86 C library --- libc/c86.inc | 6 ++++-- libc/include/arpa/inet.h | 2 +- libc/include/sys/socket.h | 14 +++++++------- libc/malloc/Makefile | 18 +++++++----------- libc/malloc/v7malloc.c | 4 ++++ libc/math/Makefile | 2 +- libc/net/getsocknam.c | 10 +++++----- libc/net/in_connect.c | 4 ++-- libc/regex/regex.c | 5 ++--- libc/stdio/Makefile | 2 +- libc/system/time.c | 2 +- libc/system/wait.c | 2 +- libc/termcap/Makefile | 8 ++++---- libc/termios/Makefile | 4 ++-- 14 files changed, 42 insertions(+), 41 deletions(-) diff --git a/libc/c86.inc b/libc/c86.inc index 3155b9c31..fb69530c4 100644 --- a/libc/c86.inc +++ b/libc/c86.inc @@ -13,12 +13,14 @@ INCLUDES += -I$(C86)/libc/include DEFINES = -D__LIBC__ -D__HAS_NO_FLOATS__=1 -D__HAS_NO_LONGLONG__ LIBOBJS=$(OBJS:.o=.ocj) -CPP86FLAGS=\ +CPP86FLAGS =\ -0 \ +C86UNUSED =\ + -v \ + C86FLAGS =\ -g \ - -v \ -O \ -bas86 \ -warn=4 \ diff --git a/libc/include/arpa/inet.h b/libc/include/arpa/inet.h index 25e9f9f7f..eb3fa069a 100644 --- a/libc/include/arpa/inet.h +++ b/libc/include/arpa/inet.h @@ -2,7 +2,7 @@ #include ipaddr_t in_aton(const char *str); -int in_connect(int socket, const struct sockaddr *address, socklen_t address_len, +int in_connect(int sock, const struct sockaddr *address, socklen_t address_len, int secs); ipaddr_t in_gethostbyname(const char *str); char * in_ntoa(ipaddr_t in); diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h index 21087b5fe..4ef27b28e 100644 --- a/libc/include/sys/socket.h +++ b/libc/include/sys/socket.h @@ -6,16 +6,16 @@ typedef unsigned int socklen_t; -int accept (int socket, struct sockaddr * restrict address, socklen_t * restrict address_len); -int bind (int socket, const struct sockaddr * address, socklen_t address_len); -int connect (int socket, const struct sockaddr * address, socklen_t address_len); -int listen (int socket, int backlog); +int accept (int sock, struct sockaddr * restrict address, socklen_t * restrict address_len); +int bind (int sock, const struct sockaddr * address, socklen_t address_len); +int connect (int sock, const struct sockaddr * address, socklen_t address_len); +int listen (int sock, int backlog); int socket (int domain, int type, int protocol); -int setsockopt(int socket, int level, int option_name, const void *option_value, +int setsockopt(int sock, int level, int option_name, const void *option_value, socklen_t option_len); -int getsockname (int socket, struct sockaddr * restrict address, +int getsockname (int sock, struct sockaddr * restrict address, socklen_t * restrict address_len); -int getpeername (int socket, struct sockaddr * restrict address, +int getpeername (int sock, struct sockaddr * restrict address, socklen_t * restrict address_len); #endif diff --git a/libc/malloc/Makefile b/libc/malloc/Makefile index 29e467061..f224383dc 100644 --- a/libc/malloc/Makefile +++ b/libc/malloc/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/libc/$(COMPILER).inc # options for default malloc (dev86) only: # allocations smaller than MCHUNK words (not bytes) are rounded up, # larger requests are allocated from heap as is. -CFLAGS += -DMCHUNK=16 -#CFLAGS += -DVERBOSE=1 -#CFLAGS += -DMINALLOC -#CFLAGS += -DLAZY_FREE -#CFLAGS += -DL_alloca +DEFINES += -DMCHUNK=16 +#DEFINES += -DVERBOSE=1 +#DEFINES += -DMINALLOC +#DEFINES += -DLAZY_FREE +#DEFINES += -DL_alloca # default malloc (dev86) DEFAULT_MALLOC_OBJS = \ @@ -39,14 +39,10 @@ OBJS = \ fmemalloc.o \ dprintf.o \ +# debug malloc for all compilers OBJS += $(DEFAULT_MALLOC_OBJS) -# debug mallocs available for ia16 and OWC -ifneq "$(COMPILER)" "c86" -OBJS += $(DEBUG_MALLOC_OBJS) -endif - -# arena malloc for OWC only for now +# arena malloc works with OWC only for now ifeq "$(COMPILER)" "watcom" OBJS += $(ARENA_MALLOC_OBJS) endif diff --git a/libc/malloc/v7malloc.c b/libc/malloc/v7malloc.c index dfdfa6979..aafc0641c 100644 --- a/libc/malloc/v7malloc.c +++ b/libc/malloc/v7malloc.c @@ -13,7 +13,11 @@ #include #include #include +#ifdef __C86__ +#define DEBUG 0 +#else #define DEBUG 1 /* =1 use sysctl, =2 debug output, =3 show heap */ +#endif /* C storage allocator * circular first-fit strategy diff --git a/libc/math/Makefile b/libc/math/Makefile index 8bde53646..a3eea8a84 100644 --- a/libc/math/Makefile +++ b/libc/math/Makefile @@ -5,7 +5,7 @@ LIB ?= out.a include $(TOPDIR)/libc/$(COMPILER).inc -CFLAGS += -I$(TOPDIR)/libc/math -D__BSD_VISIBLE -Wno-type-limits +DEFINES += -I$(TOPDIR)/libc/math -D__BSD_VISIBLE -Wno-type-limits DOUBLE = \ s_floor.o \ diff --git a/libc/net/getsocknam.c b/libc/net/getsocknam.c index a2d5280a1..7a051313d 100644 --- a/libc/net/getsocknam.c +++ b/libc/net/getsocknam.c @@ -1,17 +1,17 @@ #include /* actual system call */ -extern int getsocknam(int socket, struct sockaddr * restrict address, +extern int getsocknam(int sock, struct sockaddr * restrict address, socklen_t * restrict address_len, int peer); -int getsockname(int socket, struct sockaddr * restrict address, +int getsockname(int sock, struct sockaddr * restrict address, socklen_t * restrict address_len) { - return getsocknam(socket, address, address_len, 0); + return getsocknam(sock, address, address_len, 0); } -int getpeername(int socket, struct sockaddr * restrict address, +int getpeername(int sock, struct sockaddr * restrict address, socklen_t * restrict address_len) { - return getsocknam(socket, address, address_len, 1); + return getsocknam(sock, address, address_len, 1); } diff --git a/libc/net/in_connect.c b/libc/net/in_connect.c index 30148814f..607c02494 100644 --- a/libc/net/in_connect.c +++ b/libc/net/in_connect.c @@ -15,7 +15,7 @@ static void alarm_cb(int sig) /* no action */ } -int in_connect(int socket, const struct sockaddr *address, socklen_t address_len, +int in_connect(int sock, const struct sockaddr *address, socklen_t address_len, int secs) { int ret; @@ -23,7 +23,7 @@ int in_connect(int socket, const struct sockaddr *address, socklen_t address_len old = signal(SIGALRM, alarm_cb); alarm(secs); - ret = connect(socket, address, address_len); + ret = connect(sock, address, address_len); alarm(0); signal(SIGALRM, old); return ret; diff --git a/libc/regex/regex.c b/libc/regex/regex.c index d2c8ba2a1..ed81c4dc8 100644 --- a/libc/regex/regex.c +++ b/libc/regex/regex.c @@ -164,7 +164,7 @@ STATIC char *regpiece(); STATIC char *regatom(); STATIC char *regnode(); STATIC char *regnext(); -STATIC void regc(); +STATIC void regc(char); STATIC void reginsert(); STATIC void regtail(); STATIC void regoptail(); @@ -584,8 +584,7 @@ char op; - regc - emit (if appropriate) a byte of code */ static void -regc(b) -char b; +regc(char b) { if (regcode != ®dummy) *regcode++ = b; diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile index 36c9a5f1c..ad23beffe 100644 --- a/libc/stdio/Makefile +++ b/libc/stdio/Makefile @@ -5,7 +5,7 @@ LIB ?= out.a include $(TOPDIR)/libc/$(COMPILER).inc -CFLAGS += -DL_ftell +DEFINES += -DL_ftell OBJS = \ init.o \ diff --git a/libc/system/time.c b/libc/system/time.c index 45ffe230f..6f9f63db4 100644 --- a/libc/system/time.c +++ b/libc/system/time.c @@ -6,7 +6,7 @@ time(time_t *where) struct timeval rv; if(gettimeofday(&rv, (void*)0) < 0 ) - return -1; + return (time_t)-1; if(where) *where = rv.tv_sec; diff --git a/libc/system/wait.c b/libc/system/wait.c index db9b2a83f..c8d653187 100644 --- a/libc/system/wait.c +++ b/libc/system/wait.c @@ -4,5 +4,5 @@ pid_t wait(int * status) { - return wait4(-1, status, 0, NULL); + return wait4((pid_t) -1, status, 0, NULL); } diff --git a/libc/termcap/Makefile b/libc/termcap/Makefile index 3b7eec84c..e7edc871a 100644 --- a/libc/termcap/Makefile +++ b/libc/termcap/Makefile @@ -21,10 +21,10 @@ OBJS = \ xmalloc.o \ xrealloc.o \ -#CFLAGS += -DDEBUG -#CFLAGS += -DTIOCGWINSZ -#CFLAGS += -DNO_ARG_ARRAY -#CFLAGS += -DHAVE_CONFIG_H +#DEFINES += -DDEBUG +#DEFINES += -DTIOCGWINSZ +#DEFINES += -DNO_ARG_ARRAY +#DEFINES += -DHAVE_CONFIG_H all: $(LIB) diff --git a/libc/termios/Makefile b/libc/termios/Makefile index 2a304994a..090284fce 100644 --- a/libc/termios/Makefile +++ b/libc/termios/Makefile @@ -6,10 +6,10 @@ LIB ?= out.a include $(TOPDIR)/libc/$(COMPILER).inc # these are unimplemented -#CFLAGS += -DL_tcdrain -DL_tcflow -DL_tcgetpgrp -DL_cfmakeraw +#DEFINES += -DL_tcdrain -DL_tcflow -DL_tcgetpgrp -DL_cfmakeraw # TCSBRK is unimplemented except for with elksemu -CFLAGS += -DL_tcsendbreak +DEFINES += -DL_tcsendbreak OBJS = \ cfgetispeed.o \ From e9460670b714ade07c22215658db7456069683c4 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 19:26:54 -0700 Subject: [PATCH 2/6] Add stdint.h from OWC for C86 --- libc/include/c86/stdint.h | 289 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 289 insertions(+) create mode 100644 libc/include/c86/stdint.h diff --git a/libc/include/c86/stdint.h b/libc/include/c86/stdint.h new file mode 100644 index 000000000..c1633d5eb --- /dev/null +++ b/libc/include/c86/stdint.h @@ -0,0 +1,289 @@ +/*************************************************************************** + * FILE: stdint.h/cstdint (Various integer type definitions) + * + * ========================================================================= + * + * Open Watcom Project + * + * Copyright (c) 2004-2024 The Open Watcom Contributors. All Rights Reserved. + * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. + * + * This file is automatically generated. Do not edit directly. + * + * ========================================================================= + * + * Description: This header is part of the C99/C++ standard library. It + * describes a number of useful integer types. + ***************************************************************************/ +#ifndef _STDINT_H_INCLUDED +#define _STDINT_H_INCLUDED + +#ifndef _ENABLE_AUTODEPEND + #pragma read_only_file +#endif + +#ifdef __cplusplus + +#include + +using std::int8_t; +using std::uint8_t; +using std::int16_t; +using std::uint16_t; +using std::int32_t; +using std::uint32_t; +using std::int64_t; +using std::uint64_t; +using std::int_least8_t; +using std::uint_least8_t; +using std::int_least16_t; +using std::uint_least16_t; +using std::int_least32_t; +using std::uint_least32_t; +using std::int_least64_t; +using std::uint_least64_t; +using std::int_fast8_t; +using std::uint_fast8_t; +using std::int_fast16_t; +using std::uint_fast16_t; +using std::int_fast32_t; +using std::uint_fast32_t; +using std::int_fast64_t; +using std::uint_fast64_t; +using std::intptr_t; +using std::uintptr_t; +using std::intmax_t; +using std::uintmax_t; + +#else /* __cplusplus not defined */ + +/* Limit macros */ + +/* Exact-width types. */ +#define INT8_MIN (-128) +#define INT8_MAX 127 +#define INT16_MIN (-32767-1) +#define INT16_MAX 32767 +#define INT32_MIN (-2147483647L-1) +#define INT32_MAX 2147483647L +#define INT64_MIN (-9223372036854775807LL-1) +#define INT64_MAX 9223372036854775807LL + +#define UINT8_MAX 255 +#ifdef _M_I86 + #define UINT16_MAX 65535U +#else + #define UINT16_MAX 65535 +#endif +#define UINT32_MAX 4294967295UL +#define UINT64_MAX 18446744073709551615ULL + +/* Minimum-width types. */ +#define INT_LEAST8_MIN (-128) +#define INT_LEAST8_MAX 127 +#define INT_LEAST16_MIN (-32767-1) +#define INT_LEAST16_MAX 32767 +#define INT_LEAST32_MIN (-2147483647L-1) +#define INT_LEAST32_MAX 2147483647L +#define INT_LEAST64_MIN (-9223372036854775807LL-1) +#define INT_LEAST64_MAX 9223372036854775807LL + +#define UINT_LEAST8_MAX 255 +#ifdef _M_I86 + #define UINT_LEAST16_MAX 65535U +#else + #define UINT_LEAST16_MAX 65535 +#endif +#define UINT_LEAST32_MAX 4294967295UL +#define UINT_LEAST64_MAX 18446744073709551615ULL + +/* Fast minimum-width types. */ +#ifdef _M_I86 + #define INT_FAST8_MIN (-32767-1) + #define INT_FAST8_MAX 32767 + #define INT_FAST16_MIN (-32767-1) + #define INT_FAST16_MAX 32767 +#else + #define INT_FAST8_MIN (-2147483647-1) + #define INT_FAST8_MAX 2147483647 + #define INT_FAST16_MIN (-2147483647-1) + #define INT_FAST16_MAX 2147483647 +#endif +#define INT_FAST32_MIN (-2147483647L-1) +#define INT_FAST32_MAX 2147483647L +#define INT_FAST64_MIN (-9223372036854775807LL-1) +#define INT_FAST64_MAX 9223372036854775807LL + +#ifdef _M_I86 + #define UINT_FAST8_MAX 65535U + #define UINT_FAST16_MAX 65535U +#else + #define UINT_FAST8_MAX 4294967295U + #define UINT_FAST16_MAX 4294967295U +#endif +#define UINT_FAST32_MAX 4294967295UL +#define UINT_FAST64_MAX 18446744073709551615ULL + +/* Integer types able to hold object pointers. */ +#ifdef _M_I86 + #if defined(__SMALL__) || defined(__MEDIUM__) + #define INTPTR_MIN (-32767-1) + #define INTPTR_MAX 32767 + #define UINTPTR_MAX 65535U + #else + #define INTPTR_MIN (-2147483647L-1) + #define INTPTR_MAX 2147483647L + #define UINTPTR_MAX 4294967295UL + #endif +#else /* 32 bit */ + #if defined(__COMPACT__) || defined(__LARGE__) + #define INTPTR_MIN (-9223372036854775807LL-1) + #define INTPTR_MAX 9223372036854775807LL + #define UINTPTR_MAX 18446744073709551615ULL + #else + #define INTPTR_MIN (-2147483647L-1) + #define INTPTR_MAX 2147483647L + #define UINTPTR_MAX 4294967295UL + #endif +#endif + +/* Greatest-width types. */ +#define INTMAX_MIN (-9223372036854775807LL-1) +#define INTMAX_MAX 9223372036854775807LL +#define UINTMAX_MAX 18446744073709551615ULL + +/* Limits of wide character types */ +#define WCHAR_MIN 0 +#define WCHAR_MAX 65535U +#define WINT_MIN WCHAR_MIN +#define WINT_MAX WCHAR_MAX + +/* Limits of other integer types. */ +#ifdef _M_I86 + #ifdef __HUGE__ + #define PTRDIFF_MIN (-2147483647L-1) + #define PTRDIFF_MAX 2147483647L + #else + #define PTRDIFF_MIN (-32767-1) + #define PTRDIFF_MAX 32767 + #endif + #define SIG_ATOMIC_MIN (-32767-1) + #define SIG_ATOMIC_MAX 32767 + #define SIZE_MAX 65535U +#else /* 32 bit */ + #define PTRDIFF_MIN (-2147483647-1) + #define PTRDIFF_MAX 2147483647 + #define SIG_ATOMIC_MIN (-2147483647-1) + #define SIG_ATOMIC_MAX 2147483647 + #define SIZE_MAX 4294967295U +#endif + +/* Constant macros */ + +#define INT8_C(__x) (__x) +#define INT16_C(__x) (__x) +#define INT32_C(__x) (__x + (INT32_MAX - INT32_MAX)) +#define INT64_C(__x) (__x + (INT64_MAX - INT64_MAX)) + +#define UINT8_C(__x) (__x) +#define UINT16_C(__x) (__x) +#define UINT32_C(__x) (__x + (UINT32_MAX - UINT32_MAX)) +#define UINT64_C(__x) (__x + (UINT64_MAX - UINT64_MAX)) + +#define INTMAX_C(__x) (__x + (INT64_MAX - INT64_MAX)) +#define UINTMAX_C(__x) (__x + (UINT64_MAX - UINT64_MAX)) + +/* Signed integer type able to hold pointers. */ + #ifndef _INTPTR_T_DEFINED + #define _INTPTR_T_DEFINED + #ifdef _M_I86 + #if defined(__SMALL__) || defined(__MEDIUM__) + typedef int intptr_t; + #else + typedef long intptr_t; + #endif + #else /* 32 bit */ + #if defined(__COMPACT__) || defined(__LARGE__) + typedef long long intptr_t; + #else + typedef long intptr_t; + #endif + #endif + typedef intptr_t __w_intptr_t; + #endif +/* Unsigned integer type able to hold pointers. */ + #ifndef _UINTPTR_T_DEFINED + #define _UINTPTR_T_DEFINED + #ifdef _M_I86 + #if defined(__SMALL__) || defined(__MEDIUM__) + typedef unsigned int uintptr_t; + #else + typedef unsigned long uintptr_t; + #endif + #else /* 32 bit */ + #if defined(__COMPACT__) || defined(__LARGE__) + typedef unsigned long long uintptr_t; + #else + typedef unsigned long uintptr_t; + #endif + #endif + typedef uintptr_t __w_uintptr_t; + #endif + +/* Exact-width types. */ +#ifndef _EXACT_WIDTH_INTS + #define _EXACT_WIDTH_INTS + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; +#ifdef _M_I86 + typedef long int32_t; + typedef unsigned long uint32_t; +#else + typedef int int32_t; + typedef unsigned int uint32_t; +#endif + typedef long long int64_t; + typedef unsigned long long uint64_t; +#endif /* _EXACT_WIDTH_INTS */ + +/* Minimum-width types. */ +typedef signed char int_least8_t; +typedef signed short int_least16_t; +typedef signed long int_least32_t; +typedef signed long long int_least64_t; + +typedef unsigned char uint_least8_t; +typedef unsigned short uint_least16_t; +typedef unsigned long uint_least32_t; +typedef unsigned long long uint_least64_t; + +/* Fastest minimum-width types. */ +typedef signed int int_fast8_t; +typedef signed int int_fast16_t; +typedef signed long int_fast32_t; +typedef signed long long int_fast64_t; + +typedef unsigned int uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef unsigned long uint_fast32_t; +typedef unsigned long long uint_fast64_t; + +/* Greatest-width types. */ +typedef long long intmax_t; +typedef unsigned long long uintmax_t; + +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1 + +#if SIZE_MAX > 65535U + #define RSIZE_MAX (SIZE_MAX >> 1) +#else + #define RSIZE_MAX SIZE_MAX +#endif + +#endif /* __STDC_WANT_LIB_EXT1__ */ + +#endif /* __cplusplus not defined */ + +#endif From fcc255f421a3ea20742861408e5239d88e980a3a Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 19:38:52 -0700 Subject: [PATCH 3/6] Port stdint.h to C86 --- elks/include/arch/types.h | 10 ++- libc/include/c86/stdint.h | 146 +++----------------------------------- libc/include/stdint.h | 4 ++ 3 files changed, 21 insertions(+), 139 deletions(-) diff --git a/elks/include/arch/types.h b/elks/include/arch/types.h index 55177ca9c..f52dba32b 100644 --- a/elks/include/arch/types.h +++ b/elks/include/arch/types.h @@ -79,8 +79,14 @@ typedef unsigned int uintptr_t; #endif #ifdef __C86__ -typedef int intptr_t; -typedef unsigned int uintptr_t; + #ifndef _INTPTR_T_DEFINED + #define _INTPTR_T_DEFINED + typedef int intptr_t; + #endif +#ifndef _UINTPTR_T_DEFINED + #define _UINTPTR_T_DEFINED + typedef unsigned int uintptr_t; + #endif #endif #endif diff --git a/libc/include/c86/stdint.h b/libc/include/c86/stdint.h index c1633d5eb..7747eebd7 100644 --- a/libc/include/c86/stdint.h +++ b/libc/include/c86/stdint.h @@ -1,5 +1,5 @@ /*************************************************************************** - * FILE: stdint.h/cstdint (Various integer type definitions) + * FILE: stdint.h (Various integer type definitions) * * ========================================================================= * @@ -14,49 +14,12 @@ * * Description: This header is part of the C99/C++ standard library. It * describes a number of useful integer types. + * + * 26 Dec 24 Greg Haerr ported from OWC for C86 compiler ***************************************************************************/ #ifndef _STDINT_H_INCLUDED #define _STDINT_H_INCLUDED -#ifndef _ENABLE_AUTODEPEND - #pragma read_only_file -#endif - -#ifdef __cplusplus - -#include - -using std::int8_t; -using std::uint8_t; -using std::int16_t; -using std::uint16_t; -using std::int32_t; -using std::uint32_t; -using std::int64_t; -using std::uint64_t; -using std::int_least8_t; -using std::uint_least8_t; -using std::int_least16_t; -using std::uint_least16_t; -using std::int_least32_t; -using std::uint_least32_t; -using std::int_least64_t; -using std::uint_least64_t; -using std::int_fast8_t; -using std::uint_fast8_t; -using std::int_fast16_t; -using std::uint_fast16_t; -using std::int_fast32_t; -using std::uint_fast32_t; -using std::int_fast64_t; -using std::uint_fast64_t; -using std::intptr_t; -using std::uintptr_t; -using std::intmax_t; -using std::uintmax_t; - -#else /* __cplusplus not defined */ - /* Limit macros */ /* Exact-width types. */ @@ -70,11 +33,7 @@ using std::uintmax_t; #define INT64_MAX 9223372036854775807LL #define UINT8_MAX 255 -#ifdef _M_I86 #define UINT16_MAX 65535U -#else - #define UINT16_MAX 65535 -#endif #define UINT32_MAX 4294967295UL #define UINT64_MAX 18446744073709551615ULL @@ -89,68 +48,35 @@ using std::uintmax_t; #define INT_LEAST64_MAX 9223372036854775807LL #define UINT_LEAST8_MAX 255 -#ifdef _M_I86 #define UINT_LEAST16_MAX 65535U -#else - #define UINT_LEAST16_MAX 65535 -#endif #define UINT_LEAST32_MAX 4294967295UL #define UINT_LEAST64_MAX 18446744073709551615ULL /* Fast minimum-width types. */ -#ifdef _M_I86 #define INT_FAST8_MIN (-32767-1) #define INT_FAST8_MAX 32767 #define INT_FAST16_MIN (-32767-1) #define INT_FAST16_MAX 32767 -#else - #define INT_FAST8_MIN (-2147483647-1) - #define INT_FAST8_MAX 2147483647 - #define INT_FAST16_MIN (-2147483647-1) - #define INT_FAST16_MAX 2147483647 -#endif #define INT_FAST32_MIN (-2147483647L-1) #define INT_FAST32_MAX 2147483647L #define INT_FAST64_MIN (-9223372036854775807LL-1) #define INT_FAST64_MAX 9223372036854775807LL -#ifdef _M_I86 #define UINT_FAST8_MAX 65535U #define UINT_FAST16_MAX 65535U -#else - #define UINT_FAST8_MAX 4294967295U #define UINT_FAST16_MAX 4294967295U -#endif #define UINT_FAST32_MAX 4294967295UL #define UINT_FAST64_MAX 18446744073709551615ULL /* Integer types able to hold object pointers. */ -#ifdef _M_I86 - #if defined(__SMALL__) || defined(__MEDIUM__) #define INTPTR_MIN (-32767-1) #define INTPTR_MAX 32767 #define UINTPTR_MAX 65535U - #else - #define INTPTR_MIN (-2147483647L-1) - #define INTPTR_MAX 2147483647L - #define UINTPTR_MAX 4294967295UL - #endif -#else /* 32 bit */ - #if defined(__COMPACT__) || defined(__LARGE__) - #define INTPTR_MIN (-9223372036854775807LL-1) - #define INTPTR_MAX 9223372036854775807LL - #define UINTPTR_MAX 18446744073709551615ULL - #else - #define INTPTR_MIN (-2147483647L-1) - #define INTPTR_MAX 2147483647L - #define UINTPTR_MAX 4294967295UL - #endif -#endif /* Greatest-width types. */ -#define INTMAX_MIN (-9223372036854775807LL-1) -#define INTMAX_MAX 9223372036854775807LL -#define UINTMAX_MAX 18446744073709551615ULL +#define INTMAX_MIN (-2147483647L-1) +#define INTMAX_MAX 2147483647L +#define UINTMAX_MAX 4294967295U /* Limits of wide character types */ #define WCHAR_MIN 0 @@ -159,24 +85,11 @@ using std::uintmax_t; #define WINT_MAX WCHAR_MAX /* Limits of other integer types. */ -#ifdef _M_I86 - #ifdef __HUGE__ - #define PTRDIFF_MIN (-2147483647L-1) - #define PTRDIFF_MAX 2147483647L - #else #define PTRDIFF_MIN (-32767-1) #define PTRDIFF_MAX 32767 - #endif #define SIG_ATOMIC_MIN (-32767-1) #define SIG_ATOMIC_MAX 32767 #define SIZE_MAX 65535U -#else /* 32 bit */ - #define PTRDIFF_MIN (-2147483647-1) - #define PTRDIFF_MAX 2147483647 - #define SIG_ATOMIC_MIN (-2147483647-1) - #define SIG_ATOMIC_MAX 2147483647 - #define SIZE_MAX 4294967295U -#endif /* Constant macros */ @@ -196,37 +109,13 @@ using std::uintmax_t; /* Signed integer type able to hold pointers. */ #ifndef _INTPTR_T_DEFINED #define _INTPTR_T_DEFINED - #ifdef _M_I86 - #if defined(__SMALL__) || defined(__MEDIUM__) typedef int intptr_t; - #else - typedef long intptr_t; - #endif - #else /* 32 bit */ - #if defined(__COMPACT__) || defined(__LARGE__) - typedef long long intptr_t; - #else - typedef long intptr_t; - #endif - #endif typedef intptr_t __w_intptr_t; #endif /* Unsigned integer type able to hold pointers. */ #ifndef _UINTPTR_T_DEFINED #define _UINTPTR_T_DEFINED - #ifdef _M_I86 - #if defined(__SMALL__) || defined(__MEDIUM__) typedef unsigned int uintptr_t; - #else - typedef unsigned long uintptr_t; - #endif - #else /* 32 bit */ - #if defined(__COMPACT__) || defined(__LARGE__) - typedef unsigned long long uintptr_t; - #else - typedef unsigned long uintptr_t; - #endif - #endif typedef uintptr_t __w_uintptr_t; #endif @@ -237,14 +126,9 @@ using std::uintmax_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; -#ifdef _M_I86 typedef long int32_t; typedef unsigned long uint32_t; -#else - typedef int int32_t; - typedef unsigned int uint32_t; -#endif - typedef long long int64_t; +//typedef long long int64_t; /* defined in elks/include/arch/types.h */ typedef unsigned long long uint64_t; #endif /* _EXACT_WIDTH_INTS */ @@ -271,19 +155,7 @@ typedef unsigned long uint_fast32_t; typedef unsigned long long uint_fast64_t; /* Greatest-width types. */ -typedef long long intmax_t; -typedef unsigned long long uintmax_t; - -#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1 - -#if SIZE_MAX > 65535U - #define RSIZE_MAX (SIZE_MAX >> 1) -#else - #define RSIZE_MAX SIZE_MAX -#endif - -#endif /* __STDC_WANT_LIB_EXT1__ */ - -#endif /* __cplusplus not defined */ +typedef long intmax_t; +typedef unsigned long uintmax_t; #endif diff --git a/libc/include/stdint.h b/libc/include/stdint.h index 53f3dc6c4..bbd28fdd3 100644 --- a/libc/include/stdint.h +++ b/libc/include/stdint.h @@ -4,6 +4,10 @@ #include #endif +#ifdef __C86__ +#include +#endif + #ifdef __GNUC__ #include #endif From 72fcced7c659ee4206fb9e0a5e6895606d0e1805 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 19:47:52 -0700 Subject: [PATCH 4/6] Add qsort back in, fix OWC and C86 library builds subsequently to each other --- libc/c86.mk | 2 +- libc/misc/qsort.c | 4 +--- libc/watcom.mk | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libc/c86.mk b/libc/c86.mk index 311fe3d1e..a8dbbda16 100644 --- a/libc/c86.mk +++ b/libc/c86.mk @@ -30,7 +30,7 @@ all: $(MAKE) -C system -f out.mk COMPILER=c86 LIB=out.lib for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR COMPILER=c86 LIB=out.lib || exit 1; done $(AR) $(ARFLAGS_SUB) libc86.a */*.lib - cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root + cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root .PHONY: clean clean: diff --git a/libc/misc/qsort.c b/libc/misc/qsort.c index aa5812981..7093d9a4e 100644 --- a/libc/misc/qsort.c +++ b/libc/misc/qsort.c @@ -1,4 +1,3 @@ -#ifndef __C86__ /* * NEATLIBC C STANDARD LIBRARY * @@ -62,8 +61,7 @@ void qsort(void *a, size_t n, size_t width, int (*cmp)(void *, void *)) for (i = (n + 1) >> 1; i; i--) fix(a, i - 1, n - 1, width, cmp); for (i = n - 1; i; i--) { - swap(a, a + i * width, width); + swap(a, ((char *)a) + i * width, width); fix(a, 0, i - 1, width, cmp); } } -#endif diff --git a/libc/watcom.mk b/libc/watcom.mk index 88aabd928..63e21492f 100644 --- a/libc/watcom.mk +++ b/libc/watcom.mk @@ -29,6 +29,7 @@ SUBDIRS = \ all: $(MAKE) -C system -f out.mk COMPILER=watcom LIB=out.lib for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR COMPILER=watcom LIB=out.lib || exit 1; done + rm -f c86/out.lib wlib -l=libc.lst -c -n -q -b -fo libc.lib */*.lib watcom/*/*.lib .PHONY: clean From f5f186417e4c1012154d6e75579bc71586ccdf0c Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 20:00:57 -0700 Subject: [PATCH 5/6] Copy libc86.a only for me --- libc/c86.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc/c86.mk b/libc/c86.mk index a8dbbda16..b1be37311 100644 --- a/libc/c86.mk +++ b/libc/c86.mk @@ -30,7 +30,9 @@ all: $(MAKE) -C system -f out.mk COMPILER=c86 LIB=out.lib for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR COMPILER=c86 LIB=out.lib || exit 1; done $(AR) $(ARFLAGS_SUB) libc86.a */*.lib +ifeq "$(TOPDIR)" "/Users/greg/net/elks-gh" cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root +endif .PHONY: clean clean: From 0212d531f499ee08f222bad652f8947c45422e7f Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Thu, 26 Dec 2024 20:14:23 -0700 Subject: [PATCH 6/6] Fix debug/default malloc inclusion --- libc/malloc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/malloc/Makefile b/libc/malloc/Makefile index f224383dc..5cb926e1d 100644 --- a/libc/malloc/Makefile +++ b/libc/malloc/Makefile @@ -39,8 +39,8 @@ OBJS = \ fmemalloc.o \ dprintf.o \ -# debug malloc for all compilers -OBJS += $(DEFAULT_MALLOC_OBJS) +# default and debug mallocs for all compilers +OBJS += $(DEFAULT_MALLOC_OBJS) $(DEBUG_MALLOC_OBJS) # arena malloc works with OWC only for now ifeq "$(COMPILER)" "watcom"