omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / research / atemporal / at1 / evaluator / gates / raw_syscall_mutant.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* Positive control for gates/isolation.sh (AT-1 G2, charter mutant |
| 18 | * "raw-syscall"): asks the kernel for the time with an inline system call, so |
| 19 | * no libc symbol is referenced. The instruction scan (at1-eval scan-clock) |
| 20 | * must reject it. Compiled only, never linked or run. |
| 21 | * Linux aarch64: svc #0 with x8 = 113 (clock_gettime) |
| 22 | * macOS arm64: svc #0x80 with x16 = 116 (gettimeofday) |
| 23 | * Linux x86_64: syscall with rax = 228 (clock_gettime) */ |
| 24 | #include <stdint.h> |
| 25 | struct at1_ts { int64_t s, ns; }; |
| 26 | double at1_raw_syscall_phase(double x) { |
| 27 | struct at1_ts ts = { 0, 0 }; |
| 28 | #if defined(__aarch64__) && defined(__linux__) |
| 29 | register long r0 __asm__("x0") = 0; |
| 30 | register long r1 __asm__("x1") = (long)&ts; |
| 31 | register long r8 __asm__("x8") = 113; |
| 32 | __asm__ volatile("svc #0" : "+r"(r0) : "r"(r1), "r"(r8) : "memory"); |
| 33 | #elif defined(__aarch64__) && defined(__APPLE__) |
| 34 | register long r0 __asm__("x0") = (long)&ts; |
| 35 | register long r1 __asm__("x1") = 0; |
| 36 | register long r16 __asm__("x16") = 116; |
| 37 | __asm__ volatile("svc #0x80" : "+r"(r0) : "r"(r1), "r"(r16) : "memory", "cc"); |
| 38 | #elif defined(__x86_64__) && defined(__linux__) |
| 39 | long ret; |
| 40 | __asm__ volatile("syscall" : "=a"(ret) : "a"(228L), "D"(0L), "S"(&ts) : "rcx", "r11", "memory"); |
| 41 | (void)ret; |
| 42 | #else |
| 43 | #error "raw_syscall_mutant.c: unsupported platform" |
| 44 | #endif |
| 45 | return x + (double)(ts.ns % 7) * 1e-18; |
| 46 | } |