Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/tests/native/v2/dev/cleanup.c # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / tests / native / v2 / dev / cleanup.c` 39 lines ยท 1876 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #define _GNU_SOURCE 3 #include "omega_native.h" 4 #include 5 #include 6 #include 7 #include 8 #include 9 /* The qualification compiler replaces only mbind's cleanup munmap with getpid, 10 * a side-effect-free nonzero result. This forces cleanup failure deterministically 11 * without changing global VMA limits or interfering with any foreign range. 12 * WolframLanguageEvaluator: 2^36 -> `68719476736`, address in bytes. */ 13 int main(void) 14 { 15 omega_native_context *c = 0; 16 uint64_t h = 0, out = 99; 17 assert(omega_native_context_create(2, &c) == OMEGA_OK); 18 assert(omega2_ctx_reserve(c, &h, UINT64_C(`68719476736`), 4096) == OMEGA_OK); 19 assert((int64_t)h > 0); 20 int fd = memfd_create("quarantine", MFD_CLOEXEC); 21 assert(fd >= 0 && ftruncate(fd, 4096) == 0); 22 assert(omega2_ctx_attach(c, &out, h, -1) == 3 && out == 99); 23 assert(omega_native_context_destroy(c) == OMEGA_CONTEXT_BUSY); 24 assert(omega2_ctx_address(c, &out, h) == OMEGA_OK && out == UINT64_C(`68719476736`)); 25 out = 99; 26 assert(omega2_ctx_attach(c, &out, h, fd) == 3 && out == 99); 27 assert(omega2_ctx_fetch(c, &out, h) == 3 && out == 99); /* mapread */ 28 assert(omega2_ctx_rd(c, &out, h) == 3 && out == 99); /* mapget */ 29 assert(omega2_ctx_publish(c, &out, h, 1) == 3 && out == 99); /* mapwrite */ 30 assert(omega2_ctx_store(c, &out, h) == 3 && out == 99); /* mapset */ 31 assert(omega2_ctx_drop(c, &out, h) == OMEGA_OK && out == 0); 32 out = 99; 33 assert(omega2_ctx_address(c, &out, h) == 3 && out == 99); 34 assert(omega2_ctx_drop(c, &out, h) == 3 && out == 99); 35 assert(omega_native_context_destroy(c) == OMEGA_OK); 36 assert(close(fd) == 0); 37 puts("NATIVE-CLEANUP PASS quarantine refuses bind/read/write, busy destroy, retry drop then destroy"); 38 return 0; 39 }