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 / counter_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 "counter"): |
| 18 | * reads the hardware counter inline, so no symbol is referenced and a symbol |
| 19 | * scan alone is blind. The instruction scan (at1-eval scan-clock) must reject |
| 20 | * it. Compiled only, never linked or run. */ |
| 21 | #include <stdint.h> |
| 22 | double at1_counter_phase(double x) { |
| 23 | uint64_t t = 0; |
| 24 | #if defined(__aarch64__) |
| 25 | __asm__ volatile("mrs %0, cntvct_el0" : "=r"(t)); |
| 26 | #elif defined(__x86_64__) |
| 27 | uint32_t lo, hi; |
| 28 | __asm__ volatile("rdtsc" : "=a"(lo), "=d"(hi)); |
| 29 | t = ((uint64_t)hi << 32) | lo; |
| 30 | #else |
| 31 | #error "counter_mutant.c: unsupported architecture" |
| 32 | #endif |
| 33 | return x + (double)(t % 7) * 1e-18; |
| 34 | } |