This commit is contained in:
Dale Weiler
2021-08-22 10:05:27 -04:00
parent b39a4f3e3b
commit 791d7f764b
18 changed files with 19 additions and 21 deletions

View File

@@ -44,9 +44,6 @@ As Odin lacks a means to interact with `long double` in it's foreign interface,
### `<complex.h>`
The special values `_Complex_I`, `_Imaginary_I` and the appropriate definition of `I` cannot be realized with the same type in Odin as it would be in C. The literal `1i` is tempting to use for these definitions but the semantics differ from C and would be confusing to use.
### `<inttypes.h>`
The `{int,uint}_fast{8,16,32,64}_t` integer types are not defined as there's no reliable way to query these types. Not only are they dependent
### `<math.h>`
The classification functions, e.g: `fpclassify` are required by C to be implemented as macros, meaning no implementation would expose functions in their library we could bind. Instead, we provide native Odin implementations with functionally equivalent semantics and behavior as the C ones. Unfortunately, since classification returns unspecified constant values this may be an ABI break where the value of those constants enter and exit native C code.
@@ -64,7 +61,8 @@ C has some strange promotion and type-coercion behavior for `<tgmath.h>` which i
In addition to limitations, there are some minor caveats you should be aware when using this projection.
* `errno()` is a function which returns `^int` rather than a macro.
* `MB_CUR_MAX` is a function which return `size_t` rather than a macro.
* `MB_CUR_MAX()` is a function which return `size_t` rather than a macro.
* Currently only works on Windows (MSVCRT) and Linux (GLIBC or MUSL)
## License
Every file within this directory is made available under Odin's BSD-2 license

View File

@@ -75,4 +75,4 @@ CMPLX :: #force_inline proc(x, y: double) -> complex_double {
CMPLXF :: #force_inline proc(x, y: float) -> complex_float {
return builtin.complex(x, y);
}
}

View File

@@ -23,4 +23,4 @@ foreign libc {
// 7.4.2 Character case mapping functions
tolower :: proc(c: int) -> int ---;
toupper :: proc(c: int) -> int ---;
}
}

View File

@@ -40,4 +40,4 @@ when ODIN_OS == "windows" {
// it actually is.
errno :: #force_inline proc() -> ^int {
return _get_errno();
}
}

View File

@@ -393,4 +393,4 @@ fmaf :: proc{libc_fmaf};
// These two functions are special and not made type generic in tgmath.h since
// they only differ by their return type.
nan :: proc{libc_nan};
nanf :: proc{libc_nanf};
nanf :: proc{libc_nanf};

View File

@@ -28,4 +28,4 @@ foreign libc {
// strictly conformant C implementation is 16 on the platforms we care about.
// The choice of 4096 bytes for storage of this type is more than enough on all
// relevant platforms.
jmp_buf :: struct #align 16 { _: [4096]char, };
jmp_buf :: struct #align 16 { _: [4096]char, };

View File

@@ -36,4 +36,4 @@ when ODIN_OS == "linux" || ODIN_OS == "freebsd" || ODIN_OS == "darwin" {
SIGINT :: 2;
SIGSEGV :: 11;
SIGTERM :: 15;
}
}

View File

@@ -40,4 +40,4 @@ va_copy :: #force_inline proc(dst, src: ^va_list) {
// in Odin which take variable arguments the C way. The #c_vararg attribute only
// exists for foreign imports. That being said, being able to copy a va_list,
// as well as start and end one is necessary in some functions, the va_list
// taking functions in libc as an example.
// taking functions in libc as an example.

View File

@@ -413,4 +413,4 @@ atomic_flag_clear :: #force_inline proc(flag: ^atomic_flag) {
atomic_flag_clear_explicit :: #force_inline proc(flag: ^atomic_flag, order: memory_order) {
atomic_store_explicit(flag, atomic_flag(false), order);
}
}

View File

@@ -128,4 +128,4 @@ foreign libc {
feof :: proc(stream: ^FILE) -> int ---;
ferror :: proc(stream: ^FILE) -> int ---;
perror :: proc(s: cstring) ---;
}
}

View File

@@ -102,4 +102,4 @@ foreign libc {
// 7.22.8 Multibyte/wide string conversion functions
mbstowcs :: proc(pwcs: ^wchar_t, s: cstring, n: size_t) -> size_t ---;
wcstombs :: proc(s: ^char, pwcs: ^wchar_t, n: size_t) -> size_t ---;
}
}

View File

@@ -36,4 +36,4 @@ foreign libc {
memset :: proc(s: rawptr, c: int, n: size_t) -> rawptr ---;
strerror :: proc(errnum: int) -> ^char ---;
strlen :: proc(s: cstring) -> size_t ---;
}
}

View File

@@ -131,4 +131,4 @@ when ODIN_OS == "linux" {
tss_get :: proc(key: tss_t) -> rawptr ---;
tss_set :: proc(key: tss_t, val: rawptr) -> int ---;
}
}
}

View File

@@ -74,4 +74,4 @@ when ODIN_OS == "linux" || ODIN_OS == "freebsd" {
_: long,
_: rawptr,
}
}
}

View File

@@ -79,4 +79,4 @@ INT64_MIN :: ~INT64_MAX;
NULL :: rawptr(uintptr(0));
NDEBUG :: !ODIN_DEBUG;
NDEBUG :: !ODIN_DEBUG;

View File

@@ -14,4 +14,4 @@ foreign libc {
}
char16_t :: uint_least16_t;
char32_t :: uint_least32_t;
char32_t :: uint_least32_t;

View File

@@ -101,4 +101,4 @@ wint_t :: distinct wchar_t;
// Calculate these values correctly regardless of what type wchar_t actually is.
WINT_MIN :: 0;
WINT_MAX :: 1 << (size_of(wint_t) * 8);
WEOF :: ~wint_t(0);
WEOF :: ~wint_t(0);

View File

@@ -41,4 +41,4 @@ foreign libc {
// 7.30.3.2 Extensible wide character case mapping functions
towctrans :: proc(wc: wint_t, desc: wctrans_t) -> wint_t ---;
wctrans :: proc(property: cstring) -> wctrans_t ---;
}
}