microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
9.74k stars 791 forks source link

`unix/prim.c` uses deprecated Apple `TARGET_` symbols #879

Closed freakboy3742 closed 1 month ago

freakboy3742 commented 2 months ago

The file src/prim/unix/prim.c references 2 preprocessor symbols TARGET_IOS_IPHONE and TARGET_IOS_SIMULATOR.

These symbols don't exist in the macOS 14 or iOS 17 SDKs. I suspect they should be TARGET_OS_IPHONE and TARGET_OS_SIMULATOR.

Alternatively, if the intention is to only include the header on macOS, #if !defined(TARGET_OS_OSX) || TARGET_OS_OSX would allow an explicit check that the platform is macOS (rather than "not not iPhone"), allowing for older macOS SDKs that predate the introduction of TARGET_OS_OSX.

That said, it's also not clear to me that the branch is needed at all, as mach/vm_statistics.h exists in the iOS 17 SDK. However, I'm not sufficiently familiar with what the code is doing in this case to comment. I'm not sure if this wasn't the case on older iOS SDKs.

daanx commented 2 months ago

Thanks for finding this -- I used your suggested fix and documented why we include mach/vm_statistics.h (a header file from 1991 :-) ). We need it mostly for large OS pages and tagging mimalloc memory but it is not essential so can be left out if the OS variant does not support that.