Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions elks/include/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions libc/c86.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion libc/c86.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root
ifeq "$(TOPDIR)" "/Users/greg/net/elks-gh"
cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root
endif

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion libc/include/arpa/inet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/socket.h>

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);
Expand Down
161 changes: 161 additions & 0 deletions libc/include/c86/stdint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/***************************************************************************
* FILE: stdint.h (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.
*
* 26 Dec 24 Greg Haerr ported from OWC for C86 compiler
***************************************************************************/
#ifndef _STDINT_H_INCLUDED
#define _STDINT_H_INCLUDED

/* 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
#define UINT16_MAX 65535U
#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
#define UINT_LEAST16_MAX 65535U
#define UINT_LEAST32_MAX 4294967295UL
#define UINT_LEAST64_MAX 18446744073709551615ULL

/* Fast minimum-width types. */
#define INT_FAST8_MIN (-32767-1)
#define INT_FAST8_MAX 32767
#define INT_FAST16_MIN (-32767-1)
#define INT_FAST16_MAX 32767
#define INT_FAST32_MIN (-2147483647L-1)
#define INT_FAST32_MAX 2147483647L
#define INT_FAST64_MIN (-9223372036854775807LL-1)
#define INT_FAST64_MAX 9223372036854775807LL

#define UINT_FAST8_MAX 65535U
#define UINT_FAST16_MAX 65535U
#define UINT_FAST16_MAX 4294967295U
#define UINT_FAST32_MAX 4294967295UL
#define UINT_FAST64_MAX 18446744073709551615ULL

/* Integer types able to hold object pointers. */
#define INTPTR_MIN (-32767-1)
#define INTPTR_MAX 32767
#define UINTPTR_MAX 65535U

/* Greatest-width types. */
#define INTMAX_MIN (-2147483647L-1)
#define INTMAX_MAX 2147483647L
#define UINTMAX_MAX 4294967295U

/* 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. */
#define PTRDIFF_MIN (-32767-1)
#define PTRDIFF_MAX 32767
#define SIG_ATOMIC_MIN (-32767-1)
#define SIG_ATOMIC_MAX 32767
#define SIZE_MAX 65535U

/* 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
typedef int intptr_t;
typedef intptr_t __w_intptr_t;
#endif
/* Unsigned integer type able to hold pointers. */
#ifndef _UINTPTR_T_DEFINED
#define _UINTPTR_T_DEFINED
typedef unsigned int uintptr_t;
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;
typedef long int32_t;
typedef unsigned long uint32_t;
//typedef long long int64_t; /* defined in elks/include/arch/types.h */
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 intmax_t;
typedef unsigned long uintmax_t;

#endif
4 changes: 4 additions & 0 deletions libc/include/stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <watcom/stdint.h>
#endif

#ifdef __C86__
#include <c86/stdint.h>
#endif

#ifdef __GNUC__
#include <stdint-gcc.h>
#endif
14 changes: 7 additions & 7 deletions libc/include/sys/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 8 additions & 12 deletions libc/malloc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \
Expand All @@ -39,14 +39,10 @@ OBJS = \
fmemalloc.o \
dprintf.o \

OBJS += $(DEFAULT_MALLOC_OBJS)
# default and debug mallocs for all compilers
OBJS += $(DEFAULT_MALLOC_OBJS) $(DEBUG_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
Expand Down
4 changes: 4 additions & 0 deletions libc/malloc/v7malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
#include <unistd.h>
#include <errno.h>
#include <sys/sysctl.h>
#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
Expand Down
2 changes: 1 addition & 1 deletion libc/math/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 1 addition & 3 deletions libc/misc/qsort.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifndef __C86__
/*
* NEATLIBC C STANDARD LIBRARY
*
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions libc/net/getsocknam.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <sys/socket.h>

/* 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);
}
4 changes: 2 additions & 2 deletions libc/net/in_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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;
sighandler_t old;

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;
Expand Down
5 changes: 2 additions & 3 deletions libc/regex/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 != &regdummy)
*regcode++ = b;
Expand Down
2 changes: 1 addition & 1 deletion libc/stdio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIB ?= out.a

include $(TOPDIR)/libc/$(COMPILER).inc

CFLAGS += -DL_ftell
DEFINES += -DL_ftell

OBJS = \
init.o \
Expand Down
2 changes: 1 addition & 1 deletion libc/system/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading