Fix core:c/libc Windows compilation errors by linking to the right libraries.

Fix some name typos and missing types in Windows.
Add explicit cast on MB_CUR_MAX
This commit is contained in:
vassvik
2021-08-28 13:27:41 +02:00
parent b88e945268
commit 102d080a31
14 changed files with 73 additions and 17 deletions

View File

@@ -2,7 +2,11 @@ package libc
// 7.3 Complex arithmetic
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
@(default_calling_convention="c")
foreign libc {

View File

@@ -1,6 +1,10 @@
package libc
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
// 7.4 Character handling

View File

@@ -2,7 +2,11 @@ package libc
// 7.5 Errors
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
// C11 standard only requires the definition of:
// EDOM,

View File

@@ -4,7 +4,11 @@ package libc
import "core:intrinsics"
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
// To support C's tgmath behavior we use Odin's explicit procedure overloading,
// but we cannot use the same names as exported by libc so use @(link_name)

View File

@@ -2,7 +2,11 @@ package libc
// 7.13 Nonlocal jumps
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
@(default_calling_convention="c")
foreign libc {

View File

@@ -2,7 +2,11 @@ package libc
// 7.14 Signal handling
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
sig_atomic_t :: distinct atomic_int;

View File

@@ -1,6 +1,10 @@
package libc
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
// 7.21 Input/output

View File

@@ -2,7 +2,11 @@ package libc
// 7.22 General utilities
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
when ODIN_OS == "windows" {
RAND_MAX :: 0x7fff;
@@ -14,7 +18,7 @@ when ODIN_OS == "windows" {
}
MB_CUR_MAX :: #force_inline proc() -> size_t {
return ___mb_cur_max_func();
return size_t(___mb_cur_max_func());
}
}

View File

@@ -3,7 +3,11 @@ package libc
// 7.24 String handling
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
foreign libc {
// 7.24.2 Copying functions

View File

@@ -6,7 +6,10 @@ thrd_start_t :: proc "c" (rawptr) -> int;
tss_dtor_t :: proc "c" (rawptr);
when ODIN_OS == "windows" {
foreign import libc "system:c"
foreign import libc {
"system:libucrt.lib",
"system:msvcprt.lib"
}
thrd_success :: 0; // _Thrd_success
thrd_nomem :: 1; // _Thrd_nomem
@@ -24,6 +27,7 @@ when ODIN_OS == "windows" {
thrd_t :: struct { _: rawptr, _: uint, } // _Thrd_t
tss_t :: distinct int; // _Tss_imp_t
cnd_t :: distinct rawptr; // _Cnd_imp_t
mtx_t :: distinct rawptr; // _Mtx_imp_t
// MSVCRT does not expose the C11 symbol names as what they are in C11
// because they held off implementing <threads.h> and C11 support for so
@@ -52,9 +56,9 @@ when ODIN_OS == "windows" {
@(link_name="_Mtx_unlock") mtx_unlock :: proc(mtx: ^mtx_t) -> int ---;
// 7.26.5 Thread functions
@(link_name="_Thrd_create") thrd_create :: proc(thr: ^thr_t, func: thrd_start_t, arg: rawptr) -> int ---;
@(link_name="_Thrd_create") thrd_create :: proc(thr: ^thrd_t, func: thrd_start_t, arg: rawptr) -> int ---;
@(link_name="_Thrd_current") thrd_current :: proc() -> thrd_t ---;
@(link_name="_Thrd_detach") thrd_detach :: proc(thr: thr_t) -> int ---;
@(link_name="_Thrd_detach") thrd_detach :: proc(thr: thrd_t) -> int ---;
@(link_name="_Thrd_equal") thrd_equal :: proc(lhs, rhs: thrd_t) -> int ---;
@(link_name="_Thrd_exit") thrd_exit :: proc(res: int) -> ! ---;
@(link_name="_Thrd_join") thrd_join :: proc(thr: thrd_t, res: ^int) -> int ---;

View File

@@ -2,7 +2,11 @@ package libc
// 7.27 Date and time
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
// We enforce 64-bit time_t and timespec as there is no reason to use 32-bit as
// we approach the 2038 problem. Windows has defaulted to this since VC8 (2005).

View File

@@ -2,7 +2,11 @@ package libc
// 7.28 Unicode utilities
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
@(default_calling_convention="c")
foreign libc {

View File

@@ -2,7 +2,11 @@ package libc
// 7.29 Extended multibyte and wide character utilities
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
@(default_calling_convention="c")
foreign libc {

View File

@@ -2,7 +2,11 @@ package libc
// 7.30 Wide character classification and mapping utilities
foreign import libc "system:c"
when ODIN_OS == "windows" {
foreign import libc "system:libucrt.lib"
} else {
foreign import libc "system:c"
}
when ODIN_OS == "windows" {
wctrans_t :: distinct wchar_t;