aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / allen / tests / presentation-mutants.om
| 1 | note Reuses L748 native mutation builder; selector0 stale-event,1 input-tail. |
| 2 | global Mutbuf uchar 262144 |
| 3 | global Mutrep uchar 128 |
| 4 | global Mutmode uchar 1 |
| 5 | text Mutold0 "\nif not appreceive now\nret false\nend\nb = dpresent\n" |
| 6 | text Mutnew0 "\nb = appreceive now\nb = dpresent\n" |
| 7 | text Mutold1 "\nfor i ulong 8192\nput In i get Din i\nend\n" |
| 8 | text Mutnew1 "\nfor i ulong n\nput In i get Din i\nend\n" |
| 9 | fn mutmatch at ulong mode uchar to bool |
| 10 | if eq mode 48 |
| 11 | for i ulong len Mutold0 |
| 12 | if ne get Mutbuf add at i get Mutold0 i |
| 13 | ret false |
| 14 | end |
| 15 | end |
| 16 | else |
| 17 | for i ulong len Mutold1 |
| 18 | if ne get Mutbuf add at i get Mutold1 i |
| 19 | ret false |
| 20 | end |
| 21 | end |
| 22 | end |
| 23 | ret true |
| 24 | end |
| 25 | fn mutwrite at ulong size ulong to bool |
| 26 | p = ulong 0 |
| 27 | while lt p size |
| 28 | n = write 1 Mutbuf add at p sub size p |
| 29 | if le n 0 |
| 30 | ret false |
| 31 | end |
| 32 | p = add p ulong n |
| 33 | end |
| 34 | ret true |
| 35 | end |
| 36 | fn mutout n ulong mode uchar to int |
| 37 | old = len Mutold0 |
| 38 | size = len Mutnew0 |
| 39 | if eq mode 49 |
| 40 | old = len Mutold1 |
| 41 | size = len Mutnew1 |
| 42 | end |
| 43 | if lt n old |
| 44 | ret 65 |
| 45 | end |
| 46 | found = ulong 0 |
| 47 | at = ulong 0 |
| 48 | for i ulong add sub n old 1 |
| 49 | if mutmatch i mode |
| 50 | found = add found 1 |
| 51 | at = i |
| 52 | end |
| 53 | end |
| 54 | if ne found 1 |
| 55 | ret 65 |
| 56 | end |
| 57 | for i ulong size |
| 58 | if eq mode 48 |
| 59 | put Mutrep i get Mutnew0 i |
| 60 | else |
| 61 | put Mutrep i get Mutnew1 i |
| 62 | end |
| 63 | end |
| 64 | if not mutwrite 0 at |
| 65 | ret 74 |
| 66 | end |
| 67 | p = ulong 0 |
| 68 | while lt p size |
| 69 | r = write 1 Mutrep p sub size p |
| 70 | if le r 0 |
| 71 | ret 74 |
| 72 | end |
| 73 | p = add p ulong r |
| 74 | end |
| 75 | if not mutwrite add at old sub n add at old |
| 76 | ret 74 |
| 77 | end |
| 78 | ret 0 |
| 79 | end |
| 80 | fn main to int |
| 81 | r = read 0 Mutmode 0 1 |
| 82 | if ne r 1 |
| 83 | ret 65 |
| 84 | end |
| 85 | mode = get Mutmode 0 |
| 86 | if and ne mode 48 ne mode 49 |
| 87 | ret 65 |
| 88 | end |
| 89 | n = ulong 0 |
| 90 | while lt n len Mutbuf |
| 91 | r = read 0 Mutbuf n sub len Mutbuf n |
| 92 | if lt r 0 |
| 93 | ret 74 |
| 94 | end |
| 95 | if eq r 0 |
| 96 | ret mutout n mode |
| 97 | end |
| 98 | n = add n ulong r |
| 99 | end |
| 100 | ret 65 |
| 101 | end |