Skip to content

Commit

Permalink
get everything building with Cosmo
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholatian committed Feb 19, 2021
1 parent e091044 commit 06cee63
Show file tree
Hide file tree
Showing 27 changed files with 318 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"CFG_LILENDIAN",
"__VSCODE_INTELLISENSE__"
],
"forcedInclude": [
"${workspaceFolder}/common/build/cosmo/cosmopolitan.h"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c89",
"cppStandard": "c++11",
Expand Down
9 changes: 9 additions & 0 deletions arr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_arr
Expand Down Expand Up @@ -54,5 +57,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
1 change: 0 additions & 1 deletion arr/src/arr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "arr.h"

#include <stdarg.h>
#include <uni/err.h>
#include <uni/memory.h>

Expand Down
9 changes: 9 additions & 0 deletions chkmath/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_chkmath
Expand Down Expand Up @@ -50,5 +53,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
9 changes: 9 additions & 0 deletions clarg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_clarg
Expand Down Expand Up @@ -52,5 +55,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
2 changes: 1 addition & 1 deletion clarg/include/uni/clarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum /* uni_clarg_tmpl_flags */
enum /* uni_clarg_tmpl_masks */
{
UNI_CLARG_TMPL_MASK_TAKESVAL = 1 << UNI_CLARG_TMPL_FLAG_TAKESVAL,
UNI_CLARG_TMPL_MASK_VALREQD = 1 << UNI_CLARG_TMPL_FLAG_VALREQD
UNI_CLARG_TMPL_MASK_VALREQD = 1 << UNI_CLARG_TMPL_FLAG_VALREQD
};

struct uni_clarg_tmpl;
Expand Down
9 changes: 9 additions & 0 deletions decl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_decl
Expand Down Expand Up @@ -58,5 +61,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
8 changes: 7 additions & 1 deletion decl/include/uni/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#ifndef INC_API__UNI_DECL_H
#define INC_API__UNI_DECL_H

#ifdef __cplusplus
#if !defined( UNI_C_API )
#if defined( __cplusplus )
#define UNI_C_API extern "C"
#else
#define UNI_C_API
#endif
#endif /* !defined( UNI_C_API ) */

#if !defined( UNI_DEPRECATED )
#if !defined( UNI_NODEPREC )
Expand All @@ -30,8 +32,12 @@
#endif /* !defined( UNI_NODEPREC ) */
#endif /* !defined( UNI_DEPRECATED ) */

#if !defined( UNI_PACKED )
#define UNI_PACKED __attribute__( ( packed ) )
#endif /* !defined( UNI_PACKED ) */

#if !defined( UNI_ALIGN )
#define UNI_ALIGN( _x ) __attribute__( ( aligned( _x ) ) )
#endif /* !defined( UNI_ALIGN ) */

#endif /* INC_API__UNI_DECL_H */
18 changes: 5 additions & 13 deletions decl/include/uni/types/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,13 @@
#endif /* !defined( UNI_NODEPREC ) */
#endif /* defined( UNI_DEPRECATED ) */

/* VS Code complains that __fp16 is undefined... */
#if defined( __clang__ ) && !defined( __VSCODE_INTELLISENSE__ )
#if( defined( __arm__ ) || defined( __aarch64__ ) )
typedef _Float16 f16;
#else
/* this is unsupported outside ARM because of ABIs */
typedef __fp16 f16;
#endif
#else
typedef float f16;
#endif
typedef float f16 UNI_DEPRECATED;

typedef float f32;
typedef double f64;
typedef long double f80 UNI_DEPRECATED;
typedef long double fbig;
typedef __float80 f80;
typedef __float128 f128;

typedef __float128 fbig UNI_DEPRECATED;

#endif /* INC_API__UNI_TYPES_FLOAT_H */
71 changes: 55 additions & 16 deletions decl/include/uni/types/int.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,73 @@
#ifndef INC_API__UNI_TYPES_INT_H
#define INC_API__UNI_TYPES_INT_H

#if defined( NULL )
#undef NULL
#endif /* defined( NULL ) */

#define NULL 0
/* XXX: Copied from <uni/decl.h> */
#if !defined( UNI_DEPRECATED )
#if !defined( UNI_NODEPREC )
#if defined( __GNUC__ ) || defined( __clang__ )
#define UNI_DEPRECATED __attribute__( ( deprecated ) )
#elif defined( _MSC_VER )
#define UNI_DEPRECATED __declspec( deprecated )
#else
#pragma message( \
"WARNING: You need to implement UNI_DEPRECATED for this compiler" )
#define UNI_DEPRECATED
#endif
#else
#define UNI_DEPRECATED
#endif /* !defined( UNI_NODEPREC ) */
#endif /* !defined( UNI_DEPRECATED ) */

enum
{
SIZEOF_CHAR = 1,
SIZEOF_PTR = 8,
S8_MIN = -128,
S8_MAX = 127,
S16_MIN = -32768,
S16_MAX = 32767,
SIZEOF_PTR = 8,
S8_MIN = -128,
S8_MAX = 127,
S16_MIN = -32768,
S16_MAX = 32767,
U8_MAX = 255,
U16_MAX = 65535
};

enum
{
S32_MIN = -2147483648,
S32_MAX = 2147483647,
S64_MIN = -9223372036854775808,
S64_MAX = 9223372036854775807,
U8_MAX = 255,
U16_MAX = 65535,
U32_MAX = 4294967295,
U64_MAX = 18446744073709551615,
};

enum
{
U32_MAX = 4294967295U
};

enum
{
U64_MAX = 18446744073709551615UL,
PTRI_MAX = U64_MAX
};

enum
{
S64_MIN = -9223372036854775808LL,
S64_MAX = 9223372036854775807LL,
OFFS_MIN = S64_MIN,
OFFS_MAX = S64_MAX
};

#define U128_MAX ( ( ( U64_MAX + 1 ) * ( U64_MAX + 1 ) ) - 1 )
#define S128_MIN ( ( ( S64_MIN * -1 ) * ( S64_MIN * -1 ) ) * -1 )
#define S128_MAX ( ( ( S64_MAX + 1 ) * ( S64_MAX + 1 ) ) - 1 )

#if defined( __clang__ ) || defined( __GNUC__ )
#define UNI_HAVE_S128( ) 1
typedef __int128_t s128;
typedef __INT64_TYPE__ s64;
typedef __INT32_TYPE__ s32;
typedef __INT16_TYPE__ s16;
typedef __INT8_TYPE__ s8;
#define UNI_HAVE_U128( ) 1
typedef __uint128_t u128;
typedef __UINT64_TYPE__ u64;
typedef __UINT32_TYPE__ u32;
typedef __UINT16_TYPE__ u16;
Expand All @@ -46,10 +83,12 @@ typedef __UINTPTR_TYPE__ ptri;
typedef __INTPTR_TYPE__ offs;
#elif defined( __TINYC__ )
#include <stdint.h>
#define UNI_HAVE_S128( ) 0
typedef int64_t s64;
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;
#define UNI_HAVE_U128( ) 0
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
Expand Down
3 changes: 3 additions & 0 deletions decl/include/uni/types/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ UNI_DECL_OPT( s16 );
UNI_DECL_OPT( s32 );
UNI_DECL_OPT( s64 );
UNI_DECL_OPT( ptri );
UNI_DECL_OPT( offs );

UNI_DECL_OPT( f16 );
UNI_DECL_OPT( f32 );
UNI_DECL_OPT( f64 );
UNI_DECL_OPT( f80 );
UNI_DECL_OPT( f128 );
UNI_DECL_OPT( fbig );

UNI_DECL_OPT_S( point2 );
Expand Down
9 changes: 9 additions & 0 deletions endian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_endian
Expand Down Expand Up @@ -50,5 +53,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
9 changes: 9 additions & 0 deletions err/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_err
Expand Down Expand Up @@ -51,5 +54,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
4 changes: 4 additions & 0 deletions err/include/uni/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ enum /* err */
: uni_assert_fail( #cnd, __FILE__, __LINE__, __func__ ) )
#endif /* defined(NDEBUG) */

#if !defined( ASSERT )
#define ASSERT( cnd ) UNI_DEPRECATED UNI_ASSERT( cnd )
#endif /* !defined( ASSERT ) */

#if 0
#define ASSERT_RET( cnd ) \
do \
Expand Down
11 changes: 2 additions & 9 deletions err/src/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@

#include <uni/log.h>

void abort( void );

void uni_die( void )
{
abort( );
}

void __assert_fail(const char *, const char *, int);
void uni_die( void ) { abort( ); }

void uni_assert_fail( const char * expr,
const char * file,
unsigned line,
const char * func )
{
__assert_fail(expr, file, line);
__assert_fail( expr, file, line );
}
9 changes: 9 additions & 0 deletions futils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ifeq ($(strip $(AQ)),)
$(error "AQ was not found in your environment. You need to install the Slick Makefiles from github.com/aquefir/slick to continue.")
endif

# Target APE only
TP := APE

include $(AQ)/lib/slick/base.mk

PROJECT := uni_futils
Expand Down Expand Up @@ -52,5 +55,11 @@ TES_CPPFILES :=
TES_PUBHFILES :=
TES_PRVHFILES :=

APE_LDSCR := ../common/build/cosmo/ape.lds
APE_AFILE := ../common/build/cosmo/cosmopolitan.a
APE_HFILE := ../common/build/cosmo/cosmopolitan.h
APE_APEO := ../common/build/cosmo/ape.o
APE_CRTO := ../common/build/cosmo/crt.o

# this defines all our usual targets
include $(AQ)/lib/slick/targets.mk
Loading

0 comments on commit 06cee63

Please sign in to comment.