iter 23.2.1: runtime/str.c with ail_str_eq + unconditional link
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/* AILang Str runtime primitives.
|
||||
*
|
||||
* Provides ABI-stable string operations against the existing
|
||||
* constant-Str layout (NUL-terminated byte buffer, passed as
|
||||
* `ptr` in LLVM IR). Lives separately from runtime/rc.c so that
|
||||
* a future heap-Str ABI milestone can swap the implementations
|
||||
* without touching the RC runtime.
|
||||
*
|
||||
* Linked unconditionally by `ail build` (Gc, Bump, Rc) so that
|
||||
* any program that monomorphises `eq__Str` (auto-loaded from
|
||||
* the prelude) finds the symbol. Programs that never call
|
||||
* `eq` on Str leave @ail_str_eq as a dead-stripped no-op at
|
||||
* link time under clang -O2.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Byte-equality on NUL-terminated strings. Mirrors strcmp(...) == 0
|
||||
* but exposed under a stable AILang-namespaced ABI so the codegen
|
||||
* caller does not assume libc's strcmp shape. Heap-Str ABI milestone
|
||||
* will replace the body with length-prefixed comparison without
|
||||
* changing the signature. */
|
||||
bool ail_str_eq(const char *a, const char *b) {
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
Reference in New Issue
Block a user