Skip to content

Commit

Permalink
Merge pull request #2158 from ghaerr/watcom
Browse files Browse the repository at this point in the history
[OWC libc] Add Watcom headers to libc, add 'make owc c86'
  • Loading branch information
ghaerr authored Dec 28, 2024
2 parents b2ade70 + a5f8d79 commit f42f9a9
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
198 changes: 198 additions & 0 deletions libc/include/watcom/_comdef.h
Original file line number Diff line number Diff line change
@@ -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
140 changes: 140 additions & 0 deletions libc/include/watcom/stdarg.h
Original file line number Diff line number Diff line change
@@ -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 <cstdarg>

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
Loading

0 comments on commit f42f9a9

Please sign in to comment.