Hey guys
Hey guys,
I am playing with libc bridging on Android and iOS. I was able to use it on Android as follow:
const LibC = '/system/lib/libc.so';
function gethostname(name: MarshaledAString; len: NativeUInt): Int32; cdecl; external LibC;
However I don't know where is the libc library on iPhone devices and simulator. The LibC constant only works for Android now as I don't know what I put on it for iOS, where ia stored the libc on iOS? Can you help me?
Thanks in advance :D
I am playing with libc bridging on Android and iOS. I was able to use it on Android as follow:
const LibC = '/system/lib/libc.so';
function gethostname(name: MarshaledAString; len: NativeUInt): Int32; cdecl; external LibC;
However I don't know where is the libc library on iPhone devices and simulator. The LibC constant only works for Android now as I don't know what I put on it for iOS, where ia stored the libc on iOS? Can you help me?
Thanks in advance :D
Posix.Unistd.gethostname(); ?
ReplyDeleteAFAIR there is no "libc" under iOS, but their own set of libc-like low-level APIs.
ReplyDeleteA. Bouchez Yeah :D But I don`t know where it is to reference on LibC variable :(
ReplyDeleteAllen Bauer Can you help me? Many thanks :D What is the path for libc on iOS? :D
ReplyDeleteHorácio Filho There is NO libc library, as I wrote. So you have to access directly the dedicated API, as Alexey Kazantsev wrote above.
ReplyDeleteHorácio Filho Also note that last time I've checked, Android does not have a the whole glibc, but only a dedicated subset, named "Bionic" - https://en.wikipedia.org/wiki/Bionic_(software) - so some libc entries may not be there.
ReplyDeleteA. Bouchez My idea is rewrote the POSIX Unistd library, I want to know how to play with native APIs :D just for studies :D, but I don't know what I should write after external keyword for iOS in order to access the native gesthostname function.
ReplyDeleteAlexey Kazantsev Exactly this :D
ReplyDeletefunction gethostname(name : pointer; namelen : size_t) : integer; cdecl; external '/usr/lib/libc.dylib' name 'gethostname';
ReplyDeleteThanks a lot Alexey Kazantsev :D There is a bit of problem on this function declaration, this call will work only on iOS 32-bit and 64-bit compilers, the iPhone Simulator compiler requires using the underscore prefix before the function name, you have to check the compiler directive UNDERSCOREIMPORTNAME to do that :D
ReplyDeleteAlexey Kazantsev I came with this version function gethostname(name: PUTF8Char; len: NativeUInt): Int32; cdecl; external LibCPath name Prefix + 'gethostname'; :D
ReplyDelete