core/c/libc

libc

Types

102

div_t

div_t :: struct { quot: int, rem: int, }Source

C does not declare which order 'quot' and 'rem' should be for the divide structures. An implementation could put 'rem' first. However, nobody actually does and everyone appears to have agreed upon this layout.

jmp_buf

jmp_buf :: struct { _: [4096]char, }Source

The C99 Rationale describes jmp_buf as being an array type for backward compatibility. Odin does not need to honor this and couldn't as arrays in Odin don't decay to pointers. It is somewhat easy for us to bind this, we just need to ensure the structure contains enough storage with appropriate alignment. Since there are no types in C with an alignment larger than that of max_align_t, which cannot be larger than sizeof(long double) as any other exposed type wouldn't be valid C, the maximum alignment possible in a 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.

lconv

lconv :: struct { decimal_point: cstring, thousand_sep: cstring, grouping: cstring, int_curr_symbol: cstring, currency_symbol: cstring, mon_decimal_points: cstring, mon_thousands_sep: cstring, mon_grouping: cstring, positive_sign: cstring, negative_sign: cstring, int_frac_digits: c.char, frac_digits: c.char, p_cs_precedes: c.char, p_sep_by_space: c.char, n_cs_precedes: c.char, n_sep_by_space: c.char, p_sign_posn: c.char, n_sign_posn: c.char, _int_p_cs_precedes: c.char, _int_n_cs_precedes: c.char, _int_p_sep_by_space: c.char, _int_n_sep_by_space: c.char, _int_p_sign_posn: c.char, _int_n_sign_posn: c.char, }Source

wint_t

wint_t :: u32Source

Odin does not have default argument promotion so the need for a separate type here isn't necessary, though make it distinct just to be safe.

Constants

62

EXIT_SUCCESS

EXIT_SUCCESS :: 0Source

C does not declare what these values should be, as an implementation is free to use any two distinct values it wants to indicate success or failure. However, nobody actually does and everyone appears to have agreed upon these values.

FP_NAN

FP_NAN :: 0Source

Number classification constants. These do not have to match libc since we implement our own classification functions as libc requires they be macros, which means libc does not export standard functions for them.

float_t

float_t :: floatSource

On amd64 Windows and Linux, float_t and double_t are respectively both their usual types. On x86 it's not possible to define these types correctly since they would be long double which Odin does NOT have support for.

Variables

1

Procedures

47

atomic_compare_exchange_strong

atomic_compare_exchange_strong :: proc(object: ^T, expected: ^T, desired: T) -> (bool)Source

C does not allow failure memory order to be order_release or acq_rel. Similarly, it does not allow the failure order to be stronger than success order. Since consume and acquire are both monotonic, we can count them as one, for a total of three memory orders that are relevant in compare exchange.

relaxed, acquire (consume), seq_cst.
The requirement that the failure order cannot be stronger than success limits
the valid combinations for the failure order to this table:
	[success = seq_cst, failure = seq_cst] => _
	[success = acquire, failure = seq_cst] => acq
	[success = release, failure = seq_cst] => rel
	[success = acq_rel, failure = seq_cst] => acqrel
	[success = relaxed, failure = relaxed] => relaxed
	[success = seq_cst, failure = relaxed] => failrelaxed
	[success = seq_cst, failure = acquire] => failacq
	[success = acquire, failure = relaxed] => acq_failrelaxed
	[success = acq_rel, failure = relaxed] => acqrel_failrelaxed

errno

errno :: proc() -> (^int)Source

Odin has no way to make an identifier "errno" behave as a function call to read the value, or to produce an lvalue such that you can assign a different error value to errno. To work around this, just expose it as a function like it actually is.

isgreater

isgreater :: proc(x: T, y: T) -> (bool)Source

These are special in that they avoid float exceptions. They cannot just be implemented as the relational comparisons, as that would produce an invalid "sticky" state that propagates and affects maths results. These need to be implemented natively in Odin assuming isunordered to prevent that.

Procedure Groups

114

acos

acos :: proc{}Source

Emulate tgmath.h behavior with explicit procedure overloading here.

acosf

acosf :: proc{}Source

But retain the 'f' suffix-variant functions as well so they can be used, a trick is used here where we use explicit procedural overloading of one procedure. This is done because the foreign block is marked @(private) and aliasing functions does not remove privateness from the entity.

nan

nan :: proc{}Source

These two functions are special and not made type generic in tgmath.h since they only differ by their return type.

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.