Update Zig bindings to Zig 0.12.0 (#1951)

* update zig bindings to Zig 0.12.0

* support zig package manager

* Fix zig macos ci build

* Make the macos build use 1 process instead of hitting the macos
  process limit immediately, utilize the build.zig `-Dparallel
  false` option for macos ci
* Split the macos ci into a new build stage (out of the ubuntu,
  macos build maxtrix), to allow for multiple architecture builds
  in the future after the zig bindings improve
This commit is contained in:
Jordan Moore
2024-05-06 09:02:24 -04:00
committed by GitHub
parent 751a4d0f03
commit c39e80231c
5 changed files with 200 additions and 131 deletions

View File

@@ -7,4 +7,18 @@ based on [QEMU](http://www.qemu.org/).
## How to use
Add to your project the file `unicorn/unicorn.zig` that will manage all the available architectures.
Using the [Zig Build System](https://ziglang.org/learn/build-system/), you can include
the following into your local `build.zig.zon`
``` zig
.{
.dependencies = .{
.unicorn = .{
.url = "https://github.com/unicorn-engine/unicorn/archive/<ref SHA>.tar.gz",
.hash = "<hash>",
}
},
}
```
Note that currently the only module exported publicly is `unicorn-sys`

View File

@@ -38,8 +38,8 @@ fn hook_code3(uc: ?*unicornC.uc_engine, address: u64, size: u32, user_data: ?*an
fn hook_memalloc(uc: ?*unicornC.uc_engine, @"type": unicornC.uc_mem_type, address: u64, size: u32, user_data: ?*anyopaque) callconv(.C) bool {
_ = user_data;
_ = @"type";
var algined_address = address & 0xFFFFFFFFFFFFF000;
var aligned_size = (@as(u32, @intCast(size / 0x1000)) + 1) * 0x1000;
const algined_address = address & 0xFFFFFFFFFFFFF000;
const aligned_size = (@as(u32, @intCast(size / 0x1000)) + 1) * 0x1000;
log.info(">>> Allocating block at 0x{} (0x{}), block size = 0x{} (0x{})", .{ address, algined_address, size, aligned_size });