mirror of https://github.com/flysand7/ciabatta.git
Add data model macro setting
This commit is contained in:
parent
2166660b93
commit
8efd9b7c7a
|
@ -2,6 +2,7 @@
|
||||||
/lib
|
/lib
|
||||||
/a
|
/a
|
||||||
/src/ciabatta.c
|
/src/ciabatta.c
|
||||||
|
/src/include/conf.h
|
||||||
a.out
|
a.out
|
||||||
*.a
|
*.a
|
||||||
*.so
|
*.so
|
||||||
|
|
17
build.py
17
build.py
|
@ -62,7 +62,7 @@ dependencies.append(args.compiler)
|
||||||
|
|
||||||
|
|
||||||
# Figure out the flags
|
# Figure out the flags
|
||||||
includes = ['include']
|
includes = ['src/include']
|
||||||
cc = args.compiler
|
cc = args.compiler
|
||||||
cc_defines = []
|
cc_defines = []
|
||||||
cc_flags = ['-nostdlib']
|
cc_flags = ['-nostdlib']
|
||||||
|
@ -77,7 +77,6 @@ else: # 'debug'
|
||||||
cc_defines.append('_DEBUG')
|
cc_defines.append('_DEBUG')
|
||||||
if target != 'windows':
|
if target != 'windows':
|
||||||
cc_flags.append('-fpic')
|
cc_flags.append('-fpic')
|
||||||
cc_defines.append(f'_CIA_OS_{target.upper()}')
|
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
print(colors.grey, '==> Checking dependencies...', colors.reset, end='', sep='')
|
print(colors.grey, '==> Checking dependencies...', colors.reset, end='', sep='')
|
||||||
|
@ -188,6 +187,8 @@ except Exception as error:
|
||||||
print(colors.red, f" ERROR writing file '{ciabatta_header_path}':", sep='')
|
print(colors.red, f" ERROR writing file '{ciabatta_header_path}':", sep='')
|
||||||
print(f" {error}", colors.reset)
|
print(f" {error}", colors.reset)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
print(colors.grey, f"==> Generating cia-conf.h", colors.reset, sep='')
|
||||||
|
|
||||||
|
|
||||||
def quote(s):
|
def quote(s):
|
||||||
return '"' + s + '"'
|
return '"' + s + '"'
|
||||||
|
@ -202,6 +203,18 @@ cc_flags_str = ' '.join(
|
||||||
list(map(prefix_quote('-I '), includes)))
|
list(map(prefix_quote('-I '), includes)))
|
||||||
|
|
||||||
print(colors.grey, f"==> Compiling {lib_file}", colors.reset, sep='')
|
print(colors.grey, f"==> Compiling {lib_file}", colors.reset, sep='')
|
||||||
|
try:
|
||||||
|
with open(os.path.join('src', 'include', 'cia-conf.h'), 'w') as conf_file:
|
||||||
|
os_config = open(os.path.join('src', target, 'conf.h'))
|
||||||
|
conf_file.write('\n')
|
||||||
|
conf_file.write('// This file is AUTO-GENERATED\n')
|
||||||
|
conf_file.write('// See os folder (e.g. src/linux) for conf.h file\n')
|
||||||
|
conf_file.write(os_config.read())
|
||||||
|
os_config.close()
|
||||||
|
except Exception as error:
|
||||||
|
print(colors.red, f" ERROR writing file '{ciabatta_header_path}':", sep='')
|
||||||
|
print(f" {error}", colors.reset)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def assemble(src, out):
|
def assemble(src, out):
|
||||||
format = 'elf64'
|
format = 'elf64'
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
// This file is AUTO-GENERATED
|
||||||
|
// See os folder (e.g. src/linux) for conf.h file
|
||||||
|
|
||||||
|
#define _CIA_OS_LINUX
|
||||||
|
#define _CIA_DATA_LP64
|
|
@ -1,13 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Since we're re-defining noreturn below, this would mess
|
// Include platform stuff
|
||||||
// with __declspec(noreturn) in windows headers, which
|
#include <cia-conf.h>
|
||||||
// is hidden behind a define. Good thing, because now we
|
|
||||||
// can override that define over here.
|
|
||||||
#if defined(_CIA_OS_WINDOWS)
|
|
||||||
#define DECLSPEC_NORETURN __declspec("noreturn")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pre-C23 keyword macros and stddef
|
// Pre-C23 keyword macros and stddef
|
||||||
#define static_assert _Static_assert
|
#define static_assert _Static_assert
|
|
@ -5,9 +5,9 @@ static_assert(sizeof(char) == 1, "Char isn't 1 bytes long");
|
||||||
static_assert(sizeof(short) == 2, "Short isn't 2 bytes long");
|
static_assert(sizeof(short) == 2, "Short isn't 2 bytes long");
|
||||||
static_assert(sizeof(int) == 4, "Int isn't 4 bytes long");
|
static_assert(sizeof(int) == 4, "Int isn't 4 bytes long");
|
||||||
static_assert(sizeof(long long int) == 8, "Long long isn't 8 bytes long");
|
static_assert(sizeof(long long int) == 8, "Long long isn't 8 bytes long");
|
||||||
#if defined(_CIA_OS_LINUX)
|
#if defined(_CIA_DATA_LP64)
|
||||||
static_assert(sizeof(long) == 8, "Long on linux isn't 8 bytes");
|
static_assert(sizeof(long) == 8, "Long on linux isn't 8 bytes");
|
||||||
#elif defined(_CIA_OS_WINDOWS)
|
#elif defined(_CIA_DATA_LLP64)
|
||||||
static_assert(sizeof(long) == 4, "Long on windows isn't 4 bytes");
|
static_assert(sizeof(long) == 4, "Long on windows isn't 4 bytes");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ typedef signed short int16_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
typedef signed int int32_t;
|
typedef signed int int32_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
#if defined(_CIA_OS_LINUX)
|
#if defined(_CIA_DATA_LP64)
|
||||||
typedef signed long int64_t;
|
typedef signed long int64_t;
|
||||||
typedef unsigned long uint64_t;
|
typedef unsigned long uint64_t;
|
||||||
#elif defined(_CIA_OS_WINDOWS)
|
#elif defined(_CIA_DATA_LLP64)
|
||||||
typedef signed long long int64_t;
|
typedef signed long long int64_t;
|
||||||
typedef unsigned long long uint64_t;
|
typedef unsigned long long uint64_t;
|
||||||
#else
|
#else
|
||||||
#error "Platform not implemented"
|
#error "Data model not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int8_t int_fast8_t, int_least8_t;
|
typedef int8_t int_fast8_t, int_least8_t;
|
||||||
|
@ -50,18 +50,18 @@ typedef uint64_t uintptr_t;
|
||||||
#define UINT16_C(n) (n)
|
#define UINT16_C(n) (n)
|
||||||
#define UINT32_C(n) (n)
|
#define UINT32_C(n) (n)
|
||||||
|
|
||||||
#if defined(_CIA_OS_LINUX)
|
#if defined(_CIA_DATA_LP64)
|
||||||
#define INT64_C(n) (n ## L)
|
#define INT64_C(n) (n ## L)
|
||||||
#define INTMAX_C(n) (n ## L)
|
#define INTMAX_C(n) (n ## L)
|
||||||
#define UINT64_C(n) (n ## UL)
|
#define UINT64_C(n) (n ## UL)
|
||||||
#define UINTMAX_C(n) (n ## UL)
|
#define UINTMAX_C(n) (n ## UL)
|
||||||
#elif defined(_CIA_OS_WINDOWS)
|
#elif defined(_CIA_DATA_LLP64)
|
||||||
#define INT64_C(n) (n ## LL)
|
#define INT64_C(n) (n ## LL)
|
||||||
#define INTMAX_C(n) (n ## LL)
|
#define INTMAX_C(n) (n ## LL)
|
||||||
#define UINT64_C(n) (n ## ULL)
|
#define UINT64_C(n) (n ## ULL)
|
||||||
#define UINTMAX_C(n) (n ## ULL)
|
#define UINTMAX_C(n) (n ## ULL)
|
||||||
#else
|
#else
|
||||||
#error "Platform functionality not defined"
|
#error "Data model not defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INT8_WIDTH 8
|
#define INT8_WIDTH 8
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
#define _CIA_OS_LINUX
|
||||||
|
#define _CIA_DATA_LP64
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
#define _CIA_OS_WINDOWS
|
||||||
|
#define _CIA_DATA_LLP64
|
Loading…
Reference in New Issue