| ... | @@ -240,9 +240,11 @@ pub fn fromWindowsContext(ctx: *const std.os.windows.CONTEXT) Native { | ... | @@ -240,9 +240,11 @@ pub fn fromWindowsContext(ctx: *const std.os.windows.CONTEXT) Native { |
| 240 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 240 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 241 | const Aarch64 = extern struct { | 241 | const Aarch64 = extern struct { |
| 242 | /// The numbered general-purpose registers X0 - X30. | 242 | /// The numbered general-purpose registers X0 - X30. |
| 243 | x: [31]u64, | 243 | x: [31]Gpr, |
| 244 | sp: u64, | 244 | sp: Gpr, |
| 245 | pc: u64, | 245 | pc: Gpr, |
| | 246 | |
| | 247 | pub const Gpr = u64; |
| 246 | | 248 | |
| 247 | pub inline fn current() Aarch64 { | 249 | pub inline fn current() Aarch64 { |
| 248 | var ctx: Aarch64 = undefined; | 250 | var ctx: Aarch64 = undefined; |
| ... | @@ -273,10 +275,10 @@ const Aarch64 = extern struct { | ... | @@ -273,10 +275,10 @@ const Aarch64 = extern struct { |
| 273 | return ctx; | 275 | return ctx; |
| 274 | } | 276 | } |
| 275 | | 277 | |
| 276 | pub fn getFp(ctx: *const Aarch64) u64 { | 278 | pub fn getFp(ctx: *const Aarch64) usize { |
| 277 | return ctx.x[29]; | 279 | return ctx.x[29]; |
| 278 | } | 280 | } |
| 279 | pub fn getPc(ctx: *const Aarch64) u64 { | 281 | pub fn getPc(ctx: *const Aarch64) usize { |
| 280 | return ctx.pc; | 282 | return ctx.pc; |
| 281 | } | 283 | } |
| 282 | | 284 | |
| ... | @@ -308,8 +310,10 @@ const Aarch64 = extern struct { | ... | @@ -308,8 +310,10 @@ const Aarch64 = extern struct { |
| 308 | | 310 | |
| 309 | const Alpha = extern struct { | 311 | const Alpha = extern struct { |
| 310 | /// The numbered general-purpose registers R0 - R31. | 312 | /// The numbered general-purpose registers R0 - R31. |
| 311 | r: [32]u64, | 313 | r: [32]Gpr, |
| 312 | pc: u64, | 314 | pc: Gpr, |
| | 315 | |
| | 316 | pub const Gpr = u64; |
| 313 | | 317 | |
| 314 | pub inline fn current() Alpha { | 318 | pub inline fn current() Alpha { |
| 315 | var ctx: Alpha = undefined; | 319 | var ctx: Alpha = undefined; |
| ... | @@ -355,10 +359,10 @@ const Alpha = extern struct { | ... | @@ -355,10 +359,10 @@ const Alpha = extern struct { |
| 355 | return ctx; | 359 | return ctx; |
| 356 | } | 360 | } |
| 357 | | 361 | |
| 358 | pub fn getFp(ctx: *const Alpha) u64 { | 362 | pub fn getFp(ctx: *const Alpha) usize { |
| 359 | return ctx.r[15]; | 363 | return ctx.r[15]; |
| 360 | } | 364 | } |
| 361 | pub fn getPc(ctx: *const Alpha) u64 { | 365 | pub fn getPc(ctx: *const Alpha) usize { |
| 362 | return ctx.pc; | 366 | return ctx.pc; |
| 363 | } | 367 | } |
| 364 | | 368 | |
| ... | @@ -378,8 +382,10 @@ const Alpha = extern struct { | ... | @@ -378,8 +382,10 @@ const Alpha = extern struct { |
| 378 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 382 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 379 | const Arc = extern struct { | 383 | const Arc = extern struct { |
| 380 | /// The numbered general-purpose registers r0 - r31. | 384 | /// The numbered general-purpose registers r0 - r31. |
| 381 | r: [32]u32, | 385 | r: [32]Gpr, |
| 382 | pcl: u32, | 386 | pcl: Gpr, |
| | 387 | |
| | 388 | pub const Gpr = u32; |
| 383 | | 389 | |
| 384 | pub inline fn current() Arc { | 390 | pub inline fn current() Arc { |
| 385 | var ctx: Arc = undefined; | 391 | var ctx: Arc = undefined; |
| ... | @@ -423,10 +429,10 @@ const Arc = extern struct { | ... | @@ -423,10 +429,10 @@ const Arc = extern struct { |
| 423 | return ctx; | 429 | return ctx; |
| 424 | } | 430 | } |
| 425 | | 431 | |
| 426 | pub fn getFp(ctx: *const Arc) u32 { | 432 | pub fn getFp(ctx: *const Arc) usize { |
| 427 | return ctx.r[27]; | 433 | return ctx.r[27]; |
| 428 | } | 434 | } |
| 429 | pub fn getPc(ctx: *const Arc) u32 { | 435 | pub fn getPc(ctx: *const Arc) usize { |
| 430 | return ctx.pcl; | 436 | return ctx.pcl; |
| 431 | } | 437 | } |
| 432 | | 438 | |
| ... | @@ -446,7 +452,9 @@ const Arc = extern struct { | ... | @@ -446,7 +452,9 @@ const Arc = extern struct { |
| 446 | | 452 | |
| 447 | const Arm = struct { | 453 | const Arm = struct { |
| 448 | /// The numbered general-purpose registers R0 - R15. | 454 | /// The numbered general-purpose registers R0 - R15. |
| 449 | r: [16]u32, | 455 | r: [16]Gpr, |
| | 456 | |
| | 457 | pub const Gpr = u32; |
| 450 | | 458 | |
| 451 | pub inline fn current() Arm { | 459 | pub inline fn current() Arm { |
| 452 | var ctx: Arm = undefined; | 460 | var ctx: Arm = undefined; |
| ... | @@ -462,10 +470,10 @@ const Arm = struct { | ... | @@ -462,10 +470,10 @@ const Arm = struct { |
| 462 | return ctx; | 470 | return ctx; |
| 463 | } | 471 | } |
| 464 | | 472 | |
| 465 | pub fn getFp(ctx: *const Arm) u32 { | 473 | pub fn getFp(ctx: *const Arm) usize { |
| 466 | return ctx.r[11]; | 474 | return ctx.r[11]; |
| 467 | } | 475 | } |
| 468 | pub fn getPc(ctx: *const Arm) u32 { | 476 | pub fn getPc(ctx: *const Arm) usize { |
| 469 | return ctx.r[15]; | 477 | return ctx.r[15]; |
| 470 | } | 478 | } |
| 471 | | 479 | |
| ... | @@ -512,8 +520,10 @@ const Arm = struct { | ... | @@ -512,8 +520,10 @@ const Arm = struct { |
| 512 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 520 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 513 | const Csky = extern struct { | 521 | const Csky = extern struct { |
| 514 | /// The numbered general-purpose registers r0 - r31. | 522 | /// The numbered general-purpose registers r0 - r31. |
| 515 | r: [32]u32, | 523 | r: [32]Gpr, |
| 516 | pc: u32, | 524 | pc: Gpr, |
| | 525 | |
| | 526 | pub const Gpr = u32; |
| 517 | | 527 | |
| 518 | pub inline fn current() Csky { | 528 | pub inline fn current() Csky { |
| 519 | var ctx: Csky = undefined; | 529 | var ctx: Csky = undefined; |
| ... | @@ -528,10 +538,10 @@ const Csky = extern struct { | ... | @@ -528,10 +538,10 @@ const Csky = extern struct { |
| 528 | return ctx; | 538 | return ctx; |
| 529 | } | 539 | } |
| 530 | | 540 | |
| 531 | pub fn getFp(ctx: *const Csky) u32 { | 541 | pub fn getFp(ctx: *const Csky) usize { |
| 532 | return ctx.r[14]; | 542 | return ctx.r[14]; |
| 533 | } | 543 | } |
| 534 | pub fn getPc(ctx: *const Csky) u32 { | 544 | pub fn getPc(ctx: *const Csky) usize { |
| 535 | return ctx.pc; | 545 | return ctx.pc; |
| 536 | } | 546 | } |
| 537 | | 547 | |
| ... | @@ -550,8 +560,10 @@ const Csky = extern struct { | ... | @@ -550,8 +560,10 @@ const Csky = extern struct { |
| 550 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 560 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 551 | const Hexagon = extern struct { | 561 | const Hexagon = extern struct { |
| 552 | /// The numbered general-purpose registers r0 - r31. | 562 | /// The numbered general-purpose registers r0 - r31. |
| 553 | r: [32]u32, | 563 | r: [32]Gpr, |
| 554 | pc: u32, | 564 | pc: Gpr, |
| | 565 | |
| | 566 | pub const Gpr = u32; |
| 555 | | 567 | |
| 556 | pub inline fn current() Hexagon { | 568 | pub inline fn current() Hexagon { |
| 557 | var ctx: Hexagon = undefined; | 569 | var ctx: Hexagon = undefined; |
| ... | @@ -596,10 +608,10 @@ const Hexagon = extern struct { | ... | @@ -596,10 +608,10 @@ const Hexagon = extern struct { |
| 596 | return ctx; | 608 | return ctx; |
| 597 | } | 609 | } |
| 598 | | 610 | |
| 599 | pub fn getFp(ctx: *const Hexagon) u32 { | 611 | pub fn getFp(ctx: *const Hexagon) usize { |
| 600 | return ctx.r[30]; | 612 | return ctx.r[30]; |
| 601 | } | 613 | } |
| 602 | pub fn getPc(ctx: *const Hexagon) u32 { | 614 | pub fn getPc(ctx: *const Hexagon) usize { |
| 603 | return ctx.pc; | 615 | return ctx.pc; |
| 604 | } | 616 | } |
| 605 | | 617 | |
| ... | @@ -623,9 +635,11 @@ const Hexagon = extern struct { | ... | @@ -623,9 +635,11 @@ const Hexagon = extern struct { |
| 623 | | 635 | |
| 624 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 636 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 625 | const Kvx = extern struct { | 637 | const Kvx = extern struct { |
| 626 | r: [64]u64, | 638 | r: [64]Gpr, |
| 627 | ra: u64, | 639 | ra: Gpr, |
| 628 | pc: u64, | 640 | pc: Gpr, |
| | 641 | |
| | 642 | pub const Gpr = u64; |
| 629 | | 643 | |
| 630 | pub inline fn current() Kvx { | 644 | pub inline fn current() Kvx { |
| 631 | var ctx: Kvx = undefined; | 645 | var ctx: Kvx = undefined; |
| ... | @@ -671,10 +685,10 @@ const Kvx = extern struct { | ... | @@ -671,10 +685,10 @@ const Kvx = extern struct { |
| 671 | return ctx; | 685 | return ctx; |
| 672 | } | 686 | } |
| 673 | | 687 | |
| 674 | pub fn getFp(ctx: *const Kvx) u64 { | 688 | pub fn getFp(ctx: *const Kvx) usize { |
| 675 | return ctx.r[14]; | 689 | return ctx.r[14]; |
| 676 | } | 690 | } |
| 677 | pub fn getPc(ctx: *const Kvx) u64 { | 691 | pub fn getPc(ctx: *const Kvx) usize { |
| 678 | return ctx.pc; | 692 | return ctx.pc; |
| 679 | } | 693 | } |
| 680 | | 694 | |
| ... | @@ -695,7 +709,9 @@ const Kvx = extern struct { | ... | @@ -695,7 +709,9 @@ const Kvx = extern struct { |
| 695 | | 709 | |
| 696 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 710 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 697 | const Lanai = extern struct { | 711 | const Lanai = extern struct { |
| 698 | r: [32]u32, | 712 | r: [32]Gpr, |
| | 713 | |
| | 714 | pub const Gpr = u32; |
| 699 | | 715 | |
| 700 | pub inline fn current() Lanai { | 716 | pub inline fn current() Lanai { |
| 701 | var ctx: Lanai = undefined; | 717 | var ctx: Lanai = undefined; |
| ... | @@ -738,10 +754,10 @@ const Lanai = extern struct { | ... | @@ -738,10 +754,10 @@ const Lanai = extern struct { |
| 738 | return ctx; | 754 | return ctx; |
| 739 | } | 755 | } |
| 740 | | 756 | |
| 741 | pub fn getFp(ctx: *const Lanai) u32 { | 757 | pub fn getFp(ctx: *const Lanai) usize { |
| 742 | return ctx.r[5]; | 758 | return ctx.r[5]; |
| 743 | } | 759 | } |
| 744 | pub fn getPc(ctx: *const Lanai) u32 { | 760 | pub fn getPc(ctx: *const Lanai) usize { |
| 745 | return ctx.r[2]; | 761 | return ctx.r[2]; |
| 746 | } | 762 | } |
| 747 | | 763 | |
| ... | @@ -842,10 +858,10 @@ const LoongArch = extern struct { | ... | @@ -842,10 +858,10 @@ const LoongArch = extern struct { |
| 842 | return ctx; | 858 | return ctx; |
| 843 | } | 859 | } |
| 844 | | 860 | |
| 845 | pub fn getFp(ctx: *const LoongArch) Gpr { | 861 | pub fn getFp(ctx: *const LoongArch) usize { |
| 846 | return ctx.r[22]; | 862 | return ctx.r[22]; |
| 847 | } | 863 | } |
| 848 | pub fn getPc(ctx: *const LoongArch) Gpr { | 864 | pub fn getPc(ctx: *const LoongArch) usize { |
| 849 | return ctx.pc; | 865 | return ctx.pc; |
| 850 | } | 866 | } |
| 851 | | 867 | |
| ... | @@ -864,10 +880,12 @@ const LoongArch = extern struct { | ... | @@ -864,10 +880,12 @@ const LoongArch = extern struct { |
| 864 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 880 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 865 | const M68k = extern struct { | 881 | const M68k = extern struct { |
| 866 | /// The numbered data registers d0 - d7. | 882 | /// The numbered data registers d0 - d7. |
| 867 | d: [8]u32, | 883 | d: [8]Gpr, |
| 868 | /// The numbered address registers a0 - a7. | 884 | /// The numbered address registers a0 - a7. |
| 869 | a: [8]u32, | 885 | a: [8]Gpr, |
| 870 | pc: u32, | 886 | pc: Gpr, |
| | 887 | |
| | 888 | pub const Gpr = u32; |
| 871 | | 889 | |
| 872 | pub inline fn current() M68k { | 890 | pub inline fn current() M68k { |
| 873 | var ctx: M68k = undefined; | 891 | var ctx: M68k = undefined; |
| ... | @@ -881,10 +899,10 @@ const M68k = extern struct { | ... | @@ -881,10 +899,10 @@ const M68k = extern struct { |
| 881 | return ctx; | 899 | return ctx; |
| 882 | } | 900 | } |
| 883 | | 901 | |
| 884 | pub fn getFp(ctx: *const M68k) u32 { | 902 | pub fn getFp(ctx: *const M68k) usize { |
| 885 | return ctx.a[6]; | 903 | return ctx.a[6]; |
| 886 | } | 904 | } |
| 887 | pub fn getPc(ctx: *const M68k) u32 { | 905 | pub fn getPc(ctx: *const M68k) usize { |
| 888 | return ctx.pc; | 906 | return ctx.pc; |
| 889 | } | 907 | } |
| 890 | | 908 | |
| ... | @@ -905,8 +923,10 @@ const M68k = extern struct { | ... | @@ -905,8 +923,10 @@ const M68k = extern struct { |
| 905 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 923 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 906 | const M88k = extern struct { | 924 | const M88k = extern struct { |
| 907 | /// The numbered general-purpose registers r0 - r31. | 925 | /// The numbered general-purpose registers r0 - r31. |
| 908 | r: [32]u32, | 926 | r: [32]Gpr, |
| 909 | xip: u32, | 927 | xip: Gpr, |
| | 928 | |
| | 929 | pub const Gpr = u32; |
| 910 | | 930 | |
| 911 | pub inline fn current() M88k { | 931 | pub inline fn current() M88k { |
| 912 | var ctx: M88k = undefined; | 932 | var ctx: M88k = undefined; |
| ... | @@ -952,10 +972,10 @@ const M88k = extern struct { | ... | @@ -952,10 +972,10 @@ const M88k = extern struct { |
| 952 | return ctx; | 972 | return ctx; |
| 953 | } | 973 | } |
| 954 | | 974 | |
| 955 | pub fn getFp(ctx: *const M88k) u32 { | 975 | pub fn getFp(ctx: *const M88k) usize { |
| 956 | return ctx.r[30]; | 976 | return ctx.r[30]; |
| 957 | } | 977 | } |
| 958 | pub fn getPc(ctx: *const M88k) u32 { | 978 | pub fn getPc(ctx: *const M88k) usize { |
| 959 | return ctx.xip; | 979 | return ctx.xip; |
| 960 | } | 980 | } |
| 961 | | 981 | |
| ... | @@ -1103,8 +1123,10 @@ const Mips = extern struct { | ... | @@ -1103,8 +1123,10 @@ const Mips = extern struct { |
| 1103 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 1123 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 1104 | const Or1k = extern struct { | 1124 | const Or1k = extern struct { |
| 1105 | /// The numbered general-purpose registers r0 - r31. | 1125 | /// The numbered general-purpose registers r0 - r31. |
| 1106 | r: [32]u32, | 1126 | r: [32]Gpr, |
| 1107 | pc: u32, | 1127 | pc: Gpr, |
| | 1128 | |
| | 1129 | pub const Gpr = u32; |
| 1108 | | 1130 | |
| 1109 | pub inline fn current() Or1k { | 1131 | pub inline fn current() Or1k { |
| 1110 | var ctx: Or1k = undefined; | 1132 | var ctx: Or1k = undefined; |
| ... | @@ -1150,10 +1172,10 @@ const Or1k = extern struct { | ... | @@ -1150,10 +1172,10 @@ const Or1k = extern struct { |
| 1150 | return ctx; | 1172 | return ctx; |
| 1151 | } | 1173 | } |
| 1152 | | 1174 | |
| 1153 | pub fn getFp(ctx: *const Or1k) u32 { | 1175 | pub fn getFp(ctx: *const Or1k) usize { |
| 1154 | return ctx.r[2]; | 1176 | return ctx.r[2]; |
| 1155 | } | 1177 | } |
| 1156 | pub fn getPc(ctx: *const Or1k) u32 { | 1178 | pub fn getPc(ctx: *const Or1k) usize { |
| 1157 | return ctx.pc; | 1179 | return ctx.pc; |
| 1158 | } | 1180 | } |
| 1159 | | 1181 | |
| ... | @@ -1262,10 +1284,10 @@ const Powerpc = extern struct { | ... | @@ -1262,10 +1284,10 @@ const Powerpc = extern struct { |
| 1262 | return ctx; | 1284 | return ctx; |
| 1263 | } | 1285 | } |
| 1264 | | 1286 | |
| 1265 | pub fn getFp(ctx: *const Powerpc) Gpr { | 1287 | pub fn getFp(ctx: *const Powerpc) usize { |
| 1266 | return ctx.r[1]; | 1288 | return ctx.r[1]; |
| 1267 | } | 1289 | } |
| 1268 | pub fn getPc(ctx: *const Powerpc) Gpr { | 1290 | pub fn getPc(ctx: *const Powerpc) usize { |
| 1269 | return ctx.pc; | 1291 | return ctx.pc; |
| 1270 | } | 1292 | } |
| 1271 | | 1293 | |
| ... | @@ -1415,10 +1437,10 @@ const Riscv = extern struct { | ... | @@ -1415,10 +1437,10 @@ const Riscv = extern struct { |
| 1415 | return ctx; | 1437 | return ctx; |
| 1416 | } | 1438 | } |
| 1417 | | 1439 | |
| 1418 | pub fn getFp(ctx: *const Riscv) Gpr { | 1440 | pub fn getFp(ctx: *const Riscv) usize { |
| 1419 | return ctx.x[8]; | 1441 | return ctx.x[8]; |
| 1420 | } | 1442 | } |
| 1421 | pub fn getPc(ctx: *const Riscv) Gpr { | 1443 | pub fn getPc(ctx: *const Riscv) usize { |
| 1422 | return ctx.pc; | 1444 | return ctx.pc; |
| 1423 | } | 1445 | } |
| 1424 | | 1446 | |
| ... | @@ -1441,13 +1463,15 @@ const Riscv = extern struct { | ... | @@ -1441,13 +1463,15 @@ const Riscv = extern struct { |
| 1441 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 1463 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 1442 | const S390x = extern struct { | 1464 | const S390x = extern struct { |
| 1443 | /// The numbered general-purpose registers r0 - r15. | 1465 | /// The numbered general-purpose registers r0 - r15. |
| 1444 | r: [16]u64, | 1466 | r: [16]Gpr, |
| 1445 | /// The program counter. | 1467 | /// The program counter. |
| 1446 | psw: extern struct { | 1468 | psw: extern struct { |
| 1447 | mask: u64, | 1469 | mask: Gpr, |
| 1448 | addr: u64, | 1470 | addr: Gpr, |
| 1449 | }, | 1471 | }, |
| 1450 | | 1472 | |
| | 1473 | pub const Gpr = u64; |
| | 1474 | |
| 1451 | pub inline fn current() S390x { | 1475 | pub inline fn current() S390x { |
| 1452 | var ctx: S390x = undefined; | 1476 | var ctx: S390x = undefined; |
| 1453 | asm volatile ( | 1477 | asm volatile ( |
| ... | @@ -1462,10 +1486,10 @@ const S390x = extern struct { | ... | @@ -1462,10 +1486,10 @@ const S390x = extern struct { |
| 1462 | return ctx; | 1486 | return ctx; |
| 1463 | } | 1487 | } |
| 1464 | | 1488 | |
| 1465 | pub fn getFp(ctx: *const S390x) u64 { | 1489 | pub fn getFp(ctx: *const S390x) usize { |
| 1466 | return ctx.r[11]; | 1490 | return ctx.r[11]; |
| 1467 | } | 1491 | } |
| 1468 | pub fn getPc(ctx: *const S390x) u64 { | 1492 | pub fn getPc(ctx: *const S390x) usize { |
| 1469 | return ctx.psw.addr; | 1493 | return ctx.psw.addr; |
| 1470 | } | 1494 | } |
| 1471 | | 1495 | |
| ... | @@ -1571,10 +1595,10 @@ const Sparc = extern struct { | ... | @@ -1571,10 +1595,10 @@ const Sparc = extern struct { |
| 1571 | asm volatile ("ta 3" ::: .{ .memory = true }); // ST_FLUSH_WINDOWS | 1595 | asm volatile ("ta 3" ::: .{ .memory = true }); // ST_FLUSH_WINDOWS |
| 1572 | } | 1596 | } |
| 1573 | | 1597 | |
| 1574 | pub fn getFp(ctx: *const Sparc) Gpr { | 1598 | pub fn getFp(ctx: *const Sparc) usize { |
| 1575 | return ctx.i[6]; | 1599 | return ctx.i[6]; |
| 1576 | } | 1600 | } |
| 1577 | pub fn getPc(ctx: *const Sparc) Gpr { | 1601 | pub fn getPc(ctx: *const Sparc) usize { |
| 1578 | return ctx.pc; | 1602 | return ctx.pc; |
| 1579 | } | 1603 | } |
| 1580 | | 1604 | |
| ... | @@ -1593,8 +1617,10 @@ const Sparc = extern struct { | ... | @@ -1593,8 +1617,10 @@ const Sparc = extern struct { |
| 1593 | | 1617 | |
| 1594 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 1618 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 1595 | const Ve = extern struct { | 1619 | const Ve = extern struct { |
| 1596 | s: [64]u64, | 1620 | s: [64]Gpr, |
| 1597 | ic: u64, | 1621 | ic: Gpr, |
| | 1622 | |
| | 1623 | pub const Gpr = u64; |
| 1598 | | 1624 | |
| 1599 | pub inline fn current() Ve { | 1625 | pub inline fn current() Ve { |
| 1600 | var ctx: Ve = undefined; | 1626 | var ctx: Ve = undefined; |
| ... | @@ -1672,10 +1698,10 @@ const Ve = extern struct { | ... | @@ -1672,10 +1698,10 @@ const Ve = extern struct { |
| 1672 | return ctx; | 1698 | return ctx; |
| 1673 | } | 1699 | } |
| 1674 | | 1700 | |
| 1675 | pub fn getFp(ctx: *const Ve) u64 { | 1701 | pub fn getFp(ctx: *const Ve) usize { |
| 1676 | return ctx.s[9]; | 1702 | return ctx.s[9]; |
| 1677 | } | 1703 | } |
| 1678 | pub fn getPc(ctx: *const Ve) u64 { | 1704 | pub fn getPc(ctx: *const Ve) usize { |
| 1679 | return ctx.ic; | 1705 | return ctx.ic; |
| 1680 | } | 1706 | } |
| 1681 | | 1707 | |
| ... | @@ -1693,14 +1719,15 @@ const Ve = extern struct { | ... | @@ -1693,14 +1719,15 @@ const Ve = extern struct { |
| 1693 | }; | 1719 | }; |
| 1694 | | 1720 | |
| 1695 | const X86_16 = struct { | 1721 | const X86_16 = struct { |
| 1696 | pub const Register = enum { | 1722 | regs: std.enums.EnumArray(GprName, Gpr), |
| | 1723 | |
| | 1724 | pub const GprName = enum { |
| 1697 | // zig fmt: off | 1725 | // zig fmt: off |
| 1698 | sp, bp, ss, | 1726 | sp, bp, ss, |
| 1699 | ip, cs, | 1727 | ip, cs, |
| 1700 | // zig fmt: on | 1728 | // zig fmt: on |
| 1701 | }; | 1729 | }; |
| 1702 | | 1730 | pub const Gpr = u16; |
| 1703 | regs: std.enums.EnumArray(Register, u16), | | |
| 1704 | | 1731 | |
| 1705 | pub inline fn current() X86_16 { | 1732 | pub inline fn current() X86_16 { |
| 1706 | var ctx: X86_16 = undefined; | 1733 | var ctx: X86_16 = undefined; |
| ... | @@ -1719,10 +1746,10 @@ const X86_16 = struct { | ... | @@ -1719,10 +1746,10 @@ const X86_16 = struct { |
| 1719 | return ctx; | 1746 | return ctx; |
| 1720 | } | 1747 | } |
| 1721 | | 1748 | |
| 1722 | pub fn getFp(ctx: *const X86_16) u16 { | 1749 | pub fn getFp(ctx: *const X86_16) usize { |
| 1723 | return ctx.regs.get(.bp); | 1750 | return ctx.regs.get(.bp); |
| 1724 | } | 1751 | } |
| 1725 | pub fn getPc(ctx: *const X86_16) u16 { | 1752 | pub fn getPc(ctx: *const X86_16) usize { |
| 1726 | return ctx.regs.get(.ip); | 1753 | return ctx.regs.get(.ip); |
| 1727 | } | 1754 | } |
| 1728 | | 1755 | |
| ... | @@ -1740,17 +1767,19 @@ const X86_16 = struct { | ... | @@ -1740,17 +1767,19 @@ const X86_16 = struct { |
| 1740 | }; | 1767 | }; |
| 1741 | | 1768 | |
| 1742 | const X86 = struct { | 1769 | const X86 = struct { |
| | 1770 | gprs: std.enums.EnumArray(GprName, Gpr), |
| | 1771 | |
| 1743 | /// The first 8 registers here intentionally match the order of registers in the x86 instruction | 1772 | /// The first 8 registers here intentionally match the order of registers in the x86 instruction |
| 1744 | /// encoding. This order is inherited by the PUSHA instruction and the DWARF register mappings, | 1773 | /// encoding. This order is inherited by the PUSHA instruction and the DWARF register mappings, |
| 1745 | /// among other things. | 1774 | /// among other things. |
| 1746 | pub const Gpr = enum { | 1775 | pub const GprName = enum { |
| 1747 | // zig fmt: off | 1776 | // zig fmt: off |
| 1748 | eax, ecx, edx, ebx, | 1777 | eax, ecx, edx, ebx, |
| 1749 | esp, ebp, esi, edi, | 1778 | esp, ebp, esi, edi, |
| 1750 | eip, | 1779 | eip, |
| 1751 | // zig fmt: on | 1780 | // zig fmt: on |
| 1752 | }; | 1781 | }; |
| 1753 | gprs: std.enums.EnumArray(Gpr, u32), | 1782 | pub const Gpr = u32; |
| 1754 | | 1783 | |
| 1755 | pub inline fn current() X86 { | 1784 | pub inline fn current() X86 { |
| 1756 | var ctx: X86 = undefined; | 1785 | var ctx: X86 = undefined; |
| ... | @@ -1772,10 +1801,10 @@ const X86 = struct { | ... | @@ -1772,10 +1801,10 @@ const X86 = struct { |
| 1772 | return ctx; | 1801 | return ctx; |
| 1773 | } | 1802 | } |
| 1774 | | 1803 | |
| 1775 | pub fn getFp(ctx: *const X86) u32 { | 1804 | pub fn getFp(ctx: *const X86) usize { |
| 1776 | return ctx.gprs.get(.ebp); | 1805 | return ctx.gprs.get(.ebp); |
| 1777 | } | 1806 | } |
| 1778 | pub fn getPc(ctx: *const X86) u32 { | 1807 | pub fn getPc(ctx: *const X86) usize { |
| 1779 | return ctx.gprs.get(.eip); | 1808 | return ctx.gprs.get(.eip); |
| 1780 | } | 1809 | } |
| 1781 | | 1810 | |
| ... | @@ -1806,10 +1835,12 @@ const X86 = struct { | ... | @@ -1806,10 +1835,12 @@ const X86 = struct { |
| 1806 | }; | 1835 | }; |
| 1807 | | 1836 | |
| 1808 | const X86_64 = struct { | 1837 | const X86_64 = struct { |
| | 1838 | gprs: std.enums.EnumArray(GprName, Gpr), |
| | 1839 | |
| 1809 | /// The order here intentionally matches the order of the DWARF register mappings. It's unclear | 1840 | /// The order here intentionally matches the order of the DWARF register mappings. It's unclear |
| 1810 | /// where those mappings actually originated from---the ordering of the first 4 registers seems | 1841 | /// where those mappings actually originated from---the ordering of the first 4 registers seems |
| 1811 | /// quite unusual---but it is currently convenient for us to match DWARF. | 1842 | /// quite unusual---but it is currently convenient for us to match DWARF. |
| 1812 | pub const Gpr = enum { | 1843 | pub const GprName = enum { |
| 1813 | // zig fmt: off | 1844 | // zig fmt: off |
| 1814 | rax, rdx, rcx, rbx, | 1845 | rax, rdx, rcx, rbx, |
| 1815 | rsi, rdi, rbp, rsp, | 1846 | rsi, rdi, rbp, rsp, |
| ... | @@ -1818,7 +1849,7 @@ const X86_64 = struct { | ... | @@ -1818,7 +1849,7 @@ const X86_64 = struct { |
| 1818 | rip, | 1849 | rip, |
| 1819 | // zig fmt: on | 1850 | // zig fmt: on |
| 1820 | }; | 1851 | }; |
| 1821 | gprs: std.enums.EnumArray(Gpr, u64), | 1852 | pub const Gpr = u64; |
| 1822 | | 1853 | |
| 1823 | pub inline fn current() X86_64 { | 1854 | pub inline fn current() X86_64 { |
| 1824 | var ctx: X86_64 = undefined; | 1855 | var ctx: X86_64 = undefined; |