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/private_symbols.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 / private_symbols.c` 48 lines ยท 1599 bytes Raw Blame History 1 /* Independently generated bindings must retain private runtime and thread state. 2 * Values and overflow case reuse the qualified vectors in caller.c. */ 3 #include 4 #include 5 #include 6 7 uint32_t omega_madd(uint64_t *, uint64_t, uint64_t, uint64_t); 8 uint32_t omega_smadd(uint64_t *, uint64_t, uint64_t, uint64_t); 9 static pthread_barrier_t ready; 10 11 static void *exercise(void *arg) 12 { 13 int *failed = arg; 14 int rc = pthread_barrier_wait(&ready); 15 if (rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD) { 16 *failed = 1; 17 return NULL; 18 } 19 for (unsigned i = 0; i < 10000; ++i) { 20 uint64_t r = UINT64_C(`6148914691236517205`); 21 if (omega_smadd(&r, UINT64_C(`4611686018427387904`), 4, 0) != 1 || 22 r != UINT64_C(`6148914691236517205`)) 23 *failed = 1; 24 if (omega_madd(&r, 3, 5, 7) != 0 || r != 22) 25 *failed = 1; 26 if (omega_smadd(&r, (uint64_t)(int64_t)-3, 5, 2) != 0 || (int64_t)r != -13) 27 *failed = 1; 28 } 29 return NULL; 30 } 31 32 int main(void) 33 { 34 pthread_t threads[4]; 35 int failed[4] = {0}; 36 if (pthread_barrier_init(&ready, NULL, 4) != 0) 37 return 1; 38 for (unsigned i = 0; i < 4; ++i) 39 if (pthread_create(&threads[i], NULL, exercise, &failed[i]) != 0) 40 return 1; 41 for (unsigned i = 0; i < 4; ++i) 42 if (pthread_join(threads[i], NULL) != 0 || failed[i]) 43 return 1; 44 if (pthread_barrier_destroy(&ready) != 0) 45 return 1; 46 puts("PRIVATE-SYMBOLS PASS: distinct bindings, trap recovery and concurrent threads"); 47 return 0; 48 }