mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add CChar to interop.
This commit is contained in:
@@ -71,7 +71,8 @@ $endif;
|
||||
define CSChar = ichar;
|
||||
define CUChar = char;
|
||||
|
||||
/*
|
||||
define CChar = ${C_CHAR_TYPE};
|
||||
define CSChar = ${C_SCHAR_TYPE};
|
||||
*/
|
||||
$if (${C_CHAR_IS_SIGNED}):
|
||||
define CChar = ichar;
|
||||
$else:
|
||||
define CChar = char;
|
||||
$endif;
|
||||
|
||||
@@ -279,6 +279,7 @@ void compiler_compile(void)
|
||||
setup_int_define("C_INT_SIZE", platform_target.width_c_int);
|
||||
setup_int_define("C_LONG_SIZE", platform_target.width_c_long);
|
||||
setup_int_define("C_LONG_LONG_SIZE", platform_target.width_c_long_long);
|
||||
setup_bool_define("C_CHAR_IS_SIGNED", platform_target.signed_c_char);
|
||||
setup_bool_define("PLATFORM_LITTLE_ENDIAN", platform_target.little_endian);
|
||||
setup_bool_define("PLATFORM_I128_SUPPORTED", platform_target.int128);
|
||||
setup_int_define("COMPILER_OPT_LEVEL", (int)active_target.optimization_level);
|
||||
|
||||
@@ -20,6 +20,7 @@ static unsigned os_target_supports_float128(OsType os, ArchType arch);
|
||||
static unsigned os_target_supports_vec(OsType os, ArchType arch, int bits, bool is_int);
|
||||
static bool os_requires_libc(OsType os);
|
||||
|
||||
|
||||
PlatformTarget platform_target = {};
|
||||
|
||||
int target_alloca_addr_space()
|
||||
@@ -207,6 +208,34 @@ static inline bool os_is_apple(OsType os_type)
|
||||
os_type == OS_TYPE_MACOSX || os_type == OS_TYPE_IOS;
|
||||
}
|
||||
|
||||
static bool os_target_signed_c_char_type(OsType os, ArchType arch)
|
||||
{
|
||||
switch (arch)
|
||||
{
|
||||
case ARCH_TYPE_AARCH64:
|
||||
case ARCH_TYPE_AARCH64_32:
|
||||
case ARCH_TYPE_AARCH64_BE:
|
||||
case ARCH_TYPE_ARM:
|
||||
case ARCH_TYPE_ARMB:
|
||||
case ARCH_TYPE_THUMB:
|
||||
case ARCH_TYPE_THUMBEB:
|
||||
if (os_is_apple(os) || os == OS_TYPE_WIN32) return true;
|
||||
return false;
|
||||
case ARCH_TYPE_PPC:
|
||||
case ARCH_TYPE_PPC64:
|
||||
return os_is_apple(os);
|
||||
case ARCH_TYPE_HEXAGON:
|
||||
case ARCH_TYPE_PPC64LE:
|
||||
case ARCH_TYPE_RISCV32:
|
||||
case ARCH_TYPE_RISCV64:
|
||||
case ARCH_TYPE_SYSTEMZ:
|
||||
case ARCH_TYPE_XCORE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void target_setup_arm_abi(void)
|
||||
{
|
||||
platform_target.abi = ABI_ARM;
|
||||
@@ -1197,7 +1226,7 @@ void target_setup(BuildTarget *target)
|
||||
platform_target.width_c_int = os_target_c_type_bits(platform_target.os, platform_target.arch, CTYPE_INT);
|
||||
platform_target.width_c_long = os_target_c_type_bits(platform_target.os, platform_target.arch, CTYPE_LONG);
|
||||
platform_target.width_c_long_long = os_target_c_type_bits(platform_target.os, platform_target.arch, CTYPE_LONG_LONG);
|
||||
|
||||
platform_target.signed_c_char = os_target_signed_c_char_type(platform_target.os, platform_target.arch);
|
||||
|
||||
/**
|
||||
* x86-64: CMOV, CMPXCHG8B, FPU, FXSR, MMX, FXSR, SCE, SSE, SSE2
|
||||
@@ -1307,3 +1336,4 @@ void target_setup(BuildTarget *target)
|
||||
// TODO remove
|
||||
type_setup(&platform_target);
|
||||
}
|
||||
|
||||
|
||||
@@ -249,6 +249,7 @@ typedef struct
|
||||
PicGeneration pic : 3;
|
||||
PieGeneration pie : 3;
|
||||
bool pic_required : 1;
|
||||
bool signed_c_char : 1;
|
||||
FloatABI float_abi : 3;
|
||||
unsigned default_number_regs_x86 : 8;
|
||||
union
|
||||
|
||||
Reference in New Issue
Block a user