Skip to content

Commit 33a66dd

Browse files
committed
Add APIs that use task_id_token_t
1 parent 3950f43 commit 33a66dd

File tree

8 files changed

+26
-8
lines changed

8 files changed

+26
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/header-translator/configs/libc.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ watchos = "2.0"
1414
visionos = "1.0"
1515
gnustep = true
1616

17-
# HACK: Define `task_port_t` in the using crate (it's a simple alias to `task_t`).
17+
# HACK: Define `task_port_t` and `task_id_token_t` in the using crate
18+
# These are simple aliases to `task_t` and `mach_port_t` respectively.
1819
external.task_port_t.module = "__builtin__"
20+
external.task_id_token_t.module = "__builtin__"
1921

2022
# Redefined by CoreFoundation with a name that makes it hard to see
2123
# that this is `libc::malloc_zone_t`.

framework-crates/objc2-io-surface/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ pub use self::io_surface::IOSurfaceRef;
3030
pub(crate) type Boolean = u8;
3131
#[allow(dead_code)]
3232
pub(crate) type OSType = u32;
33+
34+
// mach/mach_types.h
35+
#[allow(dead_code, non_camel_case_types)]
36+
#[cfg(feature = "libc")]
37+
pub(crate) type task_id_token_t = libc::mach_port_t;

framework-crates/objc2-io-surface/translation-config.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ visionos = "1.0"
1616
fn.IOSurfaceCreateXPCObject.skipped = true
1717
fn.IOSurfaceLookupFromXPCObject.skipped = true
1818

19-
# Needs task_id_token_t
20-
fn.IOSurfaceSetOwnershipIdentity.skipped = true
21-
2219
# Defined in other crates too, so needs manual definition
2320
typedef.IOSurfaceRef.renamed = "IOSurfaceRef" # TODO: Merge IOSurface and IOSurfaceRef somehow
2421
typedef.IOSurfaceRef.skipped = true
@@ -39,3 +36,7 @@ class.IOSurface.methods."unlockWithOptions:seed:".unsafe = false
3936
# TODO(breaking): Maybe mark as `unsafe`? Takes `AnyObject` generic.
4037
class.IOSurface.methods."initWithProperties:".unsafe = false
4138
class.IOSurface.methods."setAllAttachments:".unsafe = false
39+
40+
# Unsure if `task_id_token_t` means that this remaps the underlying memory
41+
# somehow?
42+
fn.IOSurfaceSetOwnershipIdentity.unsafe = true

framework-crates/objc2-metal/Cargo.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework-crates/objc2-metal/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@ pub use self::slice::MTLRenderCommandEncoderSliceExt;
128128
pub use self::texture::*;
129129
#[cfg(feature = "MTLTypes")]
130130
pub use self::types::MTLResourceID;
131+
132+
// mach/mach_types.h
133+
#[allow(dead_code, non_camel_case_types)]
134+
#[cfg(feature = "libc")]
135+
pub(crate) type task_id_token_t = libc::mach_port_t;

framework-crates/objc2-metal/translation-config.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ class.MTLRasterizationRateLayerDescriptor.methods.sampleCount.skipped = true
1515
# Swift also handles this differently.
1616
class.MTLRasterizationRateMapDescriptor.methods."rasterizationRateMapDescriptorWithScreenSize:layerCount:layers:".arguments.2.bounds = { counted-by = "layerCount" }
1717

18-
# Needs mach / kernel types
19-
protocol.MTLResource.methods."setOwnerWithIdentity:".skipped = true
20-
2118
# Has a union field, but we'd rather have it as just a struct
2219
struct._MTLPackedFloat3.skipped = true
2320
typedef.MTLPackedFloat3.skipped = true
@@ -284,3 +281,7 @@ class.MTLTextureDescriptor.methods."setSampleCount:".unsafe = true
284281
class.MTLTextureDescriptor.methods."setArrayLength:".unsafe = true
285282
class.MTLComputePipelineDescriptor.methods."setThreadGroupSizeIsMultipleOfThreadExecutionWidth:".unsafe = true
286283
protocol.MTLComputePipelineState.methods."imageblockMemoryLengthForDimensions:".unsafe = true
284+
285+
# Documentation says something about memory ownership, which might not be safe
286+
# from Rust's AM?
287+
protocol.MTLResource.methods."setOwnerWithIdentity:".unsafe = true

0 commit comments

Comments
 (0)