diff --git a/Makefile b/Makefile index a122176fb..5c61312b4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ endif include $(TOPDIR)/Make.defs -.PHONY: all clean libc kconfig defconfig config menuconfig image images kclean +.PHONY: all clean libc kconfig defconfig config menuconfig image images \ + kimage kernel kclean owc c86 all: .config include/autoconf.h $(MAKE) -C libc all @@ -34,6 +35,8 @@ kclean: clean: $(MAKE) -C libc clean + $(MAKE) -C libc -f watcom.mk clean + $(MAKE) -C libc -f c86.mk $(MAKE) -C libc DESTDIR='$(TOPDIR)/cross' uninstall $(MAKE) -C elks clean $(MAKE) -C bootblocks clean @@ -54,6 +57,14 @@ libc: $(MAKE) -C libc all $(MAKE) -C libc DESTDIR='$(TOPDIR)/cross' install +owc: + $(MAKE) -C libc -f watcom.mk clean + $(MAKE) -C libc -f watcom.mk + +c86: + $(MAKE) -C libc -f c86.mk clean + $(MAKE) -C libc -f c86.mk + elks/arch/i86/drivers/char/KeyMaps/config.in: $(MAKE) -C elks/arch/i86/drivers/char/KeyMaps config.in diff --git a/libc/include/watcom/_comdef.h b/libc/include/watcom/_comdef.h new file mode 100644 index 000000000..0845d6457 --- /dev/null +++ b/libc/include/watcom/_comdef.h @@ -0,0 +1,198 @@ +/* + * _comdef.h Common Macro 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. + * + * ========================================================================= + */ +#ifndef __COMDEF_H_INCLUDED +#define __COMDEF_H_INCLUDED + +#ifndef _ENABLE_AUTODEPEND + #pragma read_only_file +#endif + + #ifdef _WCDATA + #error The macro _WCDATA is reserved for use by the runtime library. + #endif + #ifdef _WCNEAR + #error The macro _WCNEAR is reserved for use by the runtime library. + #endif + #ifdef _WCFAR + #error The macro _WCFAR is reserved for use by the runtime library. + #endif + #ifdef _WCHUGE + #error The macro _WCHUGE is reserved for use by the runtime library. + #endif + #ifdef _WCI86NEAR + #error The macro _WCI86NEAR is reserved for use by the runtime library. + #endif + #ifdef _WCI86FAR + #error The macro _WCI86FAR is reserved for use by the runtime library. + #endif + #ifdef _WCI86HUGE + #error The macro _WCI86HUGE is reserved for use by the runtime library. + #endif + #ifdef _WCINTERRUPT + #error The macro _WCINTERRUPT is reserved for use by the runtime library. + #endif + #ifdef _WCUNALIGNED + #error The macro _WCUNALIGNED is reserved for use by the runtime library. + #endif + #ifdef _WCNORETURN + #error The macro _WCNORETURN is reserved for use by the runtime library. + #endif + #ifdef _WCCALLBACK + #error The macro _WCCALLBACK is reserved for use by the runtime library. + #endif + #ifdef _WCHANDLER + #error The macro _WCHANDLER is reserved for use by the runtime library. + #endif + #define _WRTLFCONV __declspec(__watcall) + #define _WRTLDCONV __declspec(__watcall) + #ifdef _M_IX86 + #define _WCCALLBACK __watcall + #define _WCNORETURN __declspec(aborts) + #define _WCNEAR __near + #define _WCFAR __far + #define _WCHUGE __huge + #define _WCINTERRUPT __interrupt + #define _WCUNALIGNED + #ifdef _M_I86 + #define _WCI86NEAR __near + #define _WCI86FAR __far + #define _WCI86HUGE __huge + #else + #define _WCI86NEAR + #define _WCI86FAR + #define _WCI86HUGE + #endif + #elif defined(__AXP__) + #define _WCCALLBACK + #define _WCNORETURN __declspec(aborts) + #define _WCNEAR + #define _WCFAR + #define _WCHUGE + #define _WCI86NEAR + #define _WCI86FAR + #define _WCI86HUGE + #define _WCINTERRUPT + #define _WCUNALIGNED __unaligned + #elif defined(__PPC__) + #define _WCCALLBACK + #define _WCNORETURN __declspec(aborts) + #define _WCNEAR + #define _WCFAR + #define _WCHUGE + #define _WCI86NEAR + #define _WCI86FAR + #define _WCI86HUGE + #define _WCINTERRUPT + #define _WCUNALIGNED __unaligned + #elif defined(__MIPS__) + #define _WCCALLBACK + #define _WCNORETURN __declspec(aborts) + #define _WCNEAR + #define _WCFAR + #define _WCHUGE + #define _WCI86NEAR + #define _WCI86FAR + #define _WCI86HUGE + #define _WCINTERRUPT + #define _WCUNALIGNED __unaligned + #else + #define _WCCALLBACK + #define _WCNORETURN + #define _WCNEAR + #define _WCFAR + #define _WCHUGE + #define _WCI86NEAR + #define _WCI86FAR + #define _WCI86HUGE + #define _WCINTERRUPT + #define _WCUNALIGNED + #endif + #if defined( _M_I86 ) && defined( __HUGE__ ) + #define _WCDATA _WCFAR + #elif defined(__SW_ND) || defined(__FUNCTION_DATA_ACCESS) + #define _WCDATA + #else + #define _WCDATA _WCNEAR + #endif + #ifdef __SW_BR + #ifdef __NT__ + #define _WCRTLINK __declspec(dllimport) _WRTLFCONV + #define _WCRTDATA __declspec(dllimport) _WRTLDCONV + #define _WMRTLINK __declspec(dllimport) _WRTLFCONV + #define _WMRTDATA __declspec(dllimport) _WRTLDCONV + #define _WPRTLINK __declspec(dllimport) _WRTLFCONV + #define _WPRTDATA __declspec(dllimport) _WRTLDCONV + #define _WCHANDLER __declspec(dllimport) __declspec(_WCCALLBACK) + #else + #define _WCRTLINK _WRTLFCONV + #define _WCRTDATA _WRTLDCONV + #define _WMRTLINK _WRTLFCONV + #define _WMRTDATA _WRTLDCONV + #define _WPRTLINK _WRTLFCONV + #define _WPRTDATA _WRTLDCONV + #define _WCHANDLER __declspec(_WCCALLBACK) + #endif + #else + #ifndef _WCRTLINK + #define _WCRTLINK _WRTLFCONV + #endif + #ifndef _WCRTDATA + #define _WCRTDATA _WRTLDCONV + #endif + #ifndef _WMRTLINK + #define _WMRTLINK _WRTLFCONV + #endif + #ifndef _WMRTDATA + #define _WMRTDATA _WRTLDCONV + #endif + #ifndef _WPRTLINK + #define _WPRTLINK _WRTLFCONV + #endif + #ifndef _WPRTDATA + #define _WPRTDATA _WRTLDCONV + #endif + #ifndef _WCHANDLER + #define _WCHANDLER __declspec(_WCCALLBACK) + #endif + #endif + /* control import modifier on intrinsic functions */ + #ifndef _WCIRTLINK + #ifdef __INLINE_FUNCTIONS__ + #define _WCIRTLINK _WRTLFCONV + #else + #define _WCIRTLINK _WCRTLINK + #endif + #endif + #ifndef _WMIRTLINK + #if defined(__NO_MATH_OPS) || defined(__AXP__) || defined(__PPC__) || defined(__MIPS__) + #define _WMIRTLINK _WMRTLINK + #else + #define _WMIRTLINK _WRTLFCONV + #endif + #endif + #ifndef _WPIRTLINK + #define _WPIRTLINK _WPRTLINK + #endif + /* for MS compatibility */ + #ifndef _CRTAPI1 + #define _CRTAPI1 + #endif + #ifndef _CRTAPI2 + #define _CRTAPI2 + #endif + #ifndef _CRTIMP + #define _CRTIMP _WCRTLINK + #endif +#endif diff --git a/libc/include/watcom/stdarg.h b/libc/include/watcom/stdarg.h new file mode 100644 index 000000000..bbf471644 --- /dev/null +++ b/libc/include/watcom/stdarg.h @@ -0,0 +1,140 @@ +/*************************************************************************** + * FILE: stdarg.h/cstdarg (Macros for use with variable argument lists) + * + * ========================================================================= + * + * 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 C/C++ standard library. It + * contains macros for use in variable length argument + * lists. + ***************************************************************************/ +#ifndef _STDARG_H_INCLUDED +#define _STDARG_H_INCLUDED + +#ifndef _ENABLE_AUTODEPEND + #pragma read_only_file +#endif + +#ifdef __cplusplus + +#include + +using std::va_list; + +#else /* __cplusplus not defined */ + +#ifndef __COMDEF_H_INCLUDED + #include <_comdef.h> +#endif + +#ifndef ___VA_LIST_DEFINED +#define ___VA_LIST_DEFINED + #ifdef __PPC__ + #ifdef __NT__ + typedef char *__va_list; + #else + typedef struct { + char __gpr; + char __fpr; + char __reserved[2]; + char *__input_arg_area; + char *__reg_save_area; + } __va_list; + #endif + #elif defined(__AXP__) + typedef struct { + char *__base; + int __offset; + } __va_list; + #elif defined(__MIPS__) + typedef struct { + char *__base; + int __offset; + } __va_list; + #elif defined(_M_IX86) + #if defined(__HUGE__) || defined(__SW_ZU) + typedef char _WCFAR *__va_list; + #else + typedef char *__va_list; + #endif + #endif +#endif + +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED + typedef __va_list va_list; +#endif + +#ifdef __AXP__ + #define _AXP_WORD_SIZE 8 + #define _AXP_FLOAT_SIZE 8 + #define _AXP_FLOAT_REGS 6 + extern void *__builtin_va_start(__va_list*, ...); + #pragma intrinsic(__builtin_va_start) + #define va_start(__ap,__pn) (__builtin_va_start(&__ap,__pn,1)) + #define va_arg(__ap,__type) ((__ap).__offset+=\ + ((sizeof(__type)+_AXP_WORD_SIZE-1)&~(_AXP_WORD_SIZE-1)),\ + (*(__type *)((__ap).__base+(__ap).__offset-\ + ((__builtin_isfloat(__type)&&(__ap).__offset <=\ + (_AXP_FLOAT_REGS*_AXP_FLOAT_SIZE)) ?\ + (_AXP_FLOAT_REGS*_AXP_FLOAT_SIZE)+_AXP_FLOAT_SIZE :\ + ((sizeof(__type)+_AXP_WORD_SIZE-1)&~(_AXP_WORD_SIZE-1)))))) + #define va_end(__ap) ((void)0) +#elif defined(__PPC__) + #ifdef __NT__ + #define _INTSIZEOF(__n) ((sizeof(__n) + sizeof(int) - 1) & ~(sizeof(int) - 1)) + #define _ALIGNIT(__ap,__t) ((((int)(__ap))+(sizeof(__t)<8?3:7)) & (sizeof(__t)<8?~3:~7)) + #define va_start(__ap,__v) (__ap = (__va_list)&__v + _INTSIZEOF(__v)) + #define va_arg(__ap,__t) (*(__t *)((__ap = (char *)(_ALIGNIT(__ap,__t) + _INTSIZEOF(__t))) - _INTSIZEOF(__t))) + #define va_end(__ap) (__ap = (__va_list)0) + #else + extern void *__builtin_va_start( __va_list *, ...); + #pragma intrinsic(__builtin_va_start) + #define va_start(__ap,__pn) (__builtin_va_start(&__ap,__pn,1)) + #define va_arg(__ap,__type) (__builtin_va_arg(&__ap,__type)) + #endif +#elif defined(__MIPS__) + #define _MIPS_WORD_SIZE 4 + extern void *__builtin_va_start(__va_list*, ...); + #pragma intrinsic(__builtin_va_start) + #define va_start(__ap,__pn) (__builtin_va_start(&__ap,__pn,1)) + #define va_arg(__ap,__type) ((__ap).__offset+=\ + ((sizeof(__type)+_MIPS_WORD_SIZE-1)&~(_MIPS_WORD_SIZE-1)),\ + (*(__type *)((__ap).__base+(__ap).__offset-\ + (((sizeof(__type)+_MIPS_WORD_SIZE-1)&~(_MIPS_WORD_SIZE-1)))))) + #define va_end(__ap) ((void)0) +#elif defined(_M_IX86) + #if defined(__HUGE__) || defined(__SW_ZU) + #define va_start(__ap,__pn) (__ap=(char _WCFAR*)&__pn+\ + ((sizeof(__pn)+sizeof(int)-1)&~(sizeof(int)-1)),(void)0) + #define va_arg(__ap,__type) (__ap+=\ + ((sizeof(__type)+sizeof(int)-1)&~(sizeof(int)-1)),\ + (*(__type _WCFAR*)(__ap-((sizeof(__type)+sizeof(int)-1)&~(sizeof(int)-1))))) + #define va_end(__ap) (__ap=0,(void)0) + #else + #define va_start(__ap,__pn) (__ap=(char *)&__pn+\ + ((sizeof(__pn)+sizeof(int)-1)&~(sizeof(int)-1)),(void)0) + #define va_arg(__ap,__type) (__ap+=\ + ((sizeof(__type)+sizeof(int)-1)&~(sizeof(int)-1)),\ + (*(__type *)(__ap-((sizeof(__type)+sizeof(int)-1)&~(sizeof(int)-1))))) + #define va_end(__ap) (__ap=0,(void)0) + #endif +#endif + +#define __va_copy(__dest,__src) ((__dest)=(__src),(void)0) + +#if !defined( _NO_EXT_KEYS ) || __STDC_VERSION__ >= 199901L /* extensions enabled or C99 */ +#define va_copy(__dest,__src) __va_copy(__dest,__src) +#endif /* extensions enabled */ + +#endif /* __cplusplus not defined */ + +#endif diff --git a/libc/include/watcom/stdbool.h b/libc/include/watcom/stdbool.h new file mode 100644 index 000000000..8399c9eed --- /dev/null +++ b/libc/include/watcom/stdbool.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * FILE: stdbool.h/cstdbool (Macros to simulate the 'bool' type in C) + * + * ========================================================================= + * + * 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 + * provides a way for the programmer, at his/her option + * to introduce the type 'bool' into a C program. + ***************************************************************************/ +#ifndef _STDBOOL_H_INCLUDED +#define _STDBOOL_H_INCLUDED + +#ifndef _ENABLE_AUTODEPEND + #pragma read_only_file +#endif + +#ifdef __cplusplus + +#include + +#else /* __cplusplus not defined */ + + #define bool _Bool + #define true 1 + #define false 0 + #if __STDC_VERSION__ < 199901L + typedef unsigned char _Bool; + #endif + + #define __bool_true_false_are_defined 1 + +#endif /* __cplusplus not defined */ + +#endif diff --git a/libc/watcom.inc b/libc/watcom.inc index 3f33c2036..a4ccbb0e5 100644 --- a/libc/watcom.inc +++ b/libc/watcom.inc @@ -9,7 +9,11 @@ $(error WATCOM environment variable not set) endif INCLUDES = -I$(TOPDIR)/libc/include -I$(TOPDIR)/elks/include -INCLUDES += -I$(WATCOM)/h +# Watcom headers now included in libc/include/watcom +INCLUDES += -I$(TOPDIR)/libc/include/watcom +# Don't pull in headers from Watcom installation +#INCLUDES += -I$(WATCOM)/h + DEFINES = -D__LIBC__ LIBOBJS=$(OBJS:.o=.obj)