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/cabi/fixture.om # 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 / cabi / fixture.om` 343 lines ยท 8441 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note omega-bridge cabi-1 fixture: an NVML-class library generated from seeded Omega by tools/bridge-seeded lib-c|lib-h|lib-map. 3 note cabi library libombrfx.so.1 header ombrfx.h 4 note cabi lock FxLock process mutex 5 note cabi status nvmlReturn_t nvmlReturn_enum int32 trap 999 6 note cabi value nvmlReturn_t NVML_SUCCESS 0 7 note cabi value nvmlReturn_t NVML_ERROR_INVALID_ARGUMENT 2 8 note cabi value nvmlReturn_t NVML_ERROR_INSUFFICIENT_SIZE 7 9 note cabi value nvmlReturn_t NVML_ERROR_UNKNOWN 999 10 note cabi define NVML_DEVICE_NAME_BUFFER_SIZE 64 11 note cabi aliasguard NVML_NO_UNVERSIONED_FUNC_DEFS 12 note cabi alias nvmlDeviceGetCount nvmlDeviceGetCount_v2 13 note cabi alias nvmlDeviceGetHandleByIndex nvmlDeviceGetHandleByIndex_v2 14 note cabi handle nvmlDevice_t nvmlDevice_st pool FxDevs count 4 lock FxLock 15 note cabi record nvmlMemory_t nvmlMemory_st size 24 align 8 16 note cabi field nvmlMemory_t total uint64 0 17 note cabi field nvmlMemory_t free uint64 8 18 note cabi field nvmlMemory_t used uint64 16 19 note cabi record nvmlProcessInfo_v2_t nvmlProcessInfo_v2_st size 24 align 8 alias nvmlProcessInfo_t 20 note cabi field nvmlProcessInfo_v2_t pid uint32 0 21 note cabi field nvmlProcessInfo_v2_t usedGpuMemory uint64 8 22 note cabi field nvmlProcessInfo_v2_t gpuInstanceId uint32 16 23 note cabi field nvmlProcessInfo_v2_t computeInstanceId uint32 20 24 note cabi state FxState ulong 8 process lock FxLock 25 note cabi state FxBytes uchar 512 process lock FxLock 26 note cabi state FxTexts uchar 128 process lock FxLock 27 note cabi state FxSum ulong 1 process lock FxLock 28 note cabi state FxW ulong 3 process lock FxLock 29 note cabi state FxV ulong 6 process lock FxLock 30 note cabi cstr FxTexts slots 4 width 32 fallback "Unknown Error" lock FxLock 31 note cabi export nvmlDeviceGetCount_v2 fx_count status nvmlReturn_t lock FxLock 32 note cabi bind nvmlDeviceGetCount_v2 st FxState 33 note cabi arg nvmlDeviceGetCount_v2 deviceCount nullable out uint32 commit 0 34 note cabi export nvmlDeviceGetHandleByIndex_v2 fx_handle status nvmlReturn_t lock FxLock 35 note cabi bind nvmlDeviceGetHandleByIndex_v2 st FxState 36 note cabi arg nvmlDeviceGetHandleByIndex_v2 index uint32 37 note cabi arg nvmlDeviceGetHandleByIndex_v2 device nullable out nvmlDevice_t commit 0 38 note cabi export nvmlDeviceGetName fx_name status nvmlReturn_t lock FxLock 39 note cabi bind nvmlDeviceGetName st FxState 40 note cabi bind nvmlDeviceGetName b FxBytes 41 note cabi arg nvmlDeviceGetName device nvmlDevice_t 42 note cabi arg nvmlDeviceGetName name nullable out char length length commit 0 data FxBytes 0 43 note cabi arg nvmlDeviceGetName length uint32 44 note cabi export nvmlDeviceGetMemoryInfo fx_mem status nvmlReturn_t lock FxLock 45 note cabi bind nvmlDeviceGetMemoryInfo st FxState 46 note cabi bind nvmlDeviceGetMemoryInfo b FxBytes 47 note cabi arg nvmlDeviceGetMemoryInfo device nvmlDevice_t 48 note cabi arg nvmlDeviceGetMemoryInfo memory nullable out nvmlMemory_t commit 0 data FxBytes 64 49 note cabi export nvmlDeviceGetComputeRunningProcesses_v2 fx_procs status nvmlReturn_t lock FxLock 50 note cabi bind nvmlDeviceGetComputeRunningProcesses_v2 st FxState 51 note cabi bind nvmlDeviceGetComputeRunningProcesses_v2 b FxBytes 52 note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 device nvmlDevice_t 53 note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 infoCount nullable inout uint32 commit 1 54 note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 infos nullable out nvmlProcessInfo_v2_t count infoCount commit 2 data FxBytes 128 55 note cabi export nvmlErrorString fx_err cstr FxTexts lock FxLock 56 note cabi bind nvmlErrorString t FxTexts 57 note cabi bind nvmlErrorString st FxState 58 note cabi arg nvmlErrorString result nvmlReturn_t 59 note cabi export ombrFxBump fx_bump status nvmlReturn_t lock FxLock 60 note cabi bind ombrFxBump st FxState 61 note cabi arg ombrFxBump value nullable out uint64 commit 0 62 note cabi export ombrFxSum fx_sumx status nvmlReturn_t lock FxLock 63 note cabi bind ombrFxSum b FxBytes 64 note cabi bind ombrFxSum r FxSum 65 note cabi bind ombrFxSum w FxW 66 note cabi bind ombrFxSum v FxV 67 note cabi arg ombrFxSum seed uint64 68 note cabi arg ombrFxSum sum nullable out uint64 commit 0 69 note cabi import fx_ext omega_fx_sum result r span b 0 n value n span w 0 k span v 3 k value k 70 71 fn fx_ext r edit ulong 1 b view uchar 512 n ulong w edit ulong 3 v view ulong 6 k ulong to ulong 72 ret 0 73 end 74 75 note State words: 0 device count, 1 count calls, 3 bump counter, 6 texts ready, 7 initialised. 76 fn fx_init st edit ulong 8 to void 77 if eq get st 7 0 78 put st 0 2 79 put st 7 1 80 end 81 end 82 83 fn fx_count fr edit ulong 4 st edit ulong 8 to ulong 84 fx_init st 85 put st 1 add get st 1 1 86 if eq get fr 2 0 87 put fr 0 2 88 ret 0 89 end 90 put fr 3 get st 0 91 put fr 1 1 92 put fr 0 0 93 ret 0 94 end 95 96 fn fx_handle fr edit ulong 5 st edit ulong 8 to ulong 97 fx_init st 98 if eq get fr 3 0 99 put fr 0 2 100 ret 0 101 end 102 if ge get fr 2 get st 0 103 put fr 0 2 104 ret 0 105 end 106 put fr 4 get fr 2 107 put fr 1 1 108 put fr 0 0 109 ret 0 110 end 111 112 fn fx_gpu b edit uchar 512 d ulong to ulong 113 put b 0 uchar 79 114 put b 1 uchar 109 115 put b 2 uchar 101 116 put b 3 uchar 103 117 put b 4 uchar 97 118 put b 5 uchar 32 119 put b 6 uchar 70 120 put b 7 uchar 105 121 put b 8 uchar 120 122 put b 9 uchar 116 123 put b 10 uchar 117 124 put b 11 uchar 114 125 put b 12 uchar 101 126 put b 13 uchar 32 127 put b 14 uchar 71 128 put b 15 uchar 80 129 put b 16 uchar 85 130 put b 17 uchar 32 131 put b 18 uchar add 48 d 132 put b 19 uchar 0 133 ret 20 134 end 135 136 fn fx_name fr edit ulong 6 st edit ulong 8 b edit uchar 512 to ulong 137 fx_init st 138 if ge get fr 2 get st 0 139 put fr 0 2 140 ret 0 141 end 142 if eq get fr 3 0 143 put fr 0 2 144 ret 0 145 end 146 n = fx_gpu b get fr 2 147 if gt n get fr 5 148 put fr 0 7 149 ret 0 150 end 151 put fr 4 n 152 put fr 1 1 153 put fr 0 0 154 ret 0 155 end 156 157 fn fx_put64 b edit uchar 512 o ulong v ulong to void 158 w = v 159 for j ulong 8 160 put b add o j uchar and w 255 161 w = shr w 8 162 end 163 end 164 165 fn fx_put32 b edit uchar 512 o ulong v ulong to void 166 w = v 167 for j ulong 4 168 put b add o j uchar and w 255 169 w = shr w 8 170 end 171 end 172 173 fn fx_mem fr edit ulong 4 st edit ulong 8 b edit uchar 512 to ulong 174 fx_init st 175 if ge get fr 2 get st 0 176 put fr 0 2 177 ret 0 178 end 179 if eq get fr 3 0 180 put fr 0 2 181 ret 0 182 end 183 t = mul add get fr 2 1 `1073741824` 184 u = mul add get fr 2 1 4096 185 fx_put64 b 64 t 186 fx_put64 b 72 sub t u 187 fx_put64 b 80 u 188 put fr 1 1 189 put fr 0 0 190 ret 0 191 end 192 193 fn fx_proc b edit uchar 512 i ulong d ulong to void 194 o = add 128 mul i 24 195 for j ulong 24 196 put b add o j uchar 0 197 end 198 fx_put64 b o add 1000 add mul d 10 i 199 fx_put64 b add o 8 mul add i 1 `1048576` 200 fx_put32 b add o 16 7 201 fx_put32 b add o 20 9 202 end 203 204 fn fx_procs fr edit ulong 7 st edit ulong 8 b edit uchar 512 to ulong 205 fx_init st 206 if ge get fr 2 get st 0 207 put fr 0 2 208 ret 0 209 end 210 if eq get fr 3 0 211 put fr 0 2 212 ret 0 213 end 214 if lt get fr 4 2 215 put fr 4 2 216 put fr 1 2 217 put fr 0 7 218 ret 0 219 end 220 if eq get fr 5 0 221 put fr 0 2 222 ret 0 223 end 224 fx_proc b 0 get fr 2 225 fx_proc b 1 get fr 2 226 put fr 4 2 227 put fr 6 2 228 put fr 1 6 229 put fr 0 0 230 ret 0 231 end 232 233 fn fx_texts t edit uchar 128 to void 234 put t 0 uchar 83 235 put t 1 uchar 117 236 put t 2 uchar 99 237 put t 3 uchar 99 238 put t 4 uchar 101 239 put t 5 uchar 115 240 put t 6 uchar 115 241 put t 7 uchar 0 242 put t 32 uchar 73 243 put t 33 uchar 110 244 put t 34 uchar 118 245 put t 35 uchar 97 246 put t 36 uchar 108 247 put t 37 uchar 105 248 put t 38 uchar 100 249 put t 39 uchar 32 250 put t 40 uchar 65 251 put t 41 uchar 114 252 put t 42 uchar 103 253 put t 43 uchar 117 254 put t 44 uchar 109 255 put t 45 uchar 101 256 put t 46 uchar 110 257 put t 47 uchar 116 258 put t 48 uchar 0 259 put t 64 uchar 73 260 put t 65 uchar 110 261 put t 66 uchar 115 262 put t 67 uchar 117 263 put t 68 uchar 102 264 put t 69 uchar 102 265 put t 70 uchar 105 266 put t 71 uchar 99 267 put t 72 uchar 105 268 put t 73 uchar 101 269 put t 74 uchar 110 270 put t 75 uchar 116 271 put t 76 uchar 32 272 put t 77 uchar 83 273 put t 78 uchar 105 274 put t 79 uchar 122 275 put t 80 uchar 101 276 put t 81 uchar 0 277 end 278 279 fn fx_err fr edit ulong 3 t edit uchar 128 st edit ulong 8 to ulong 280 if eq get st 6 0 281 fx_texts t 282 put st 6 1 283 end 284 r = get fr 2 285 put fr 0 4 286 put fr 1 0 287 if eq r 0 288 put fr 0 0 289 put fr 1 7 290 end 291 if eq r 2 292 put fr 0 1 293 put fr 1 16 294 end 295 if eq r 7 296 put fr 0 2 297 put fr 1 17 298 end 299 ret 0 300 end 301 302 fn fx_bump fr edit ulong 4 st edit ulong 8 to ulong 303 if eq get fr 2 0 304 put fr 0 2 305 ret 0 306 end 307 v = get st 3 308 w = ulong 0 309 for j ulong 4096 310 w = add w j 311 end 312 put st 3 add v 1 313 put fr 3 add v 1 314 put fr 1 1 315 put fr 0 0 316 ret 0 317 end 318 319 fn fx_sumx fr edit ulong 5 b edit uchar 512 r edit ulong 1 w edit ulong 3 v edit ulong 6 to ulong 320 if eq get fr 3 0 321 put fr 0 2 322 ret 0 323 end 324 for j ulong 512 325 put b j uchar and j 255 326 end 327 for k ulong 6 328 put v k add k 1 329 end 330 put r 0 0 331 c = fx_ext r b 512 w v 3 332 if ne c 0 333 ret 1 334 end 335 s = add get fr 2 get r 0 336 s = add s get w 0 337 s = add s get w 1 338 s = add s get w 2 339 put fr 4 s 340 put fr 1 1 341 put fr 0 0 342 ret 0 343 end