switchbrew / libnx

Library for Switch Homebrew
https://switchbrew.github.io/libnx/
ISC License
1.27k stars 174 forks source link

Added some definitions to /sys/socket.h #605

Closed XITRIX closed 1 year ago

XITRIX commented 1 year ago

Latest version of Moonlight-common-c library uses this definitions, so it is impossible to compile app without them.

To be honest I am not fully understand what they are doing, I've just copy-pasted them from Apple's /sys/socket.h file with some changes, cause it uses some Darwin types which of course not presented on Switch.

Anyway after these changes I was able to compile Moonlight it it worked perfectly.

ghost commented 1 year ago

Such macro definitions you should ad to your project and not to common library, because they not used anywhere in the library.

WinterMute commented 1 year ago

~Such macro definitions you should ad to your project and not to common library, because they not used anywhere in the library.~

On the contrary, macro definitions contained in equivalent headers for other platforms can and should be considered for inclusion given the utility in porting work. Please don't comment here with misinformation like this.

WinterMute commented 1 year ago

@XITRIX The Apple headers appear to be all rights reserved so we can't take definitions from there. We can take definitions from openbsd though see https://github.com/openbsd/src/blob/master/sys/sys/socket.h#L514

XITRIX commented 1 year ago

Apple's header was almost identical to bsd's one, I've changed it a bit to be more bsd like.

But I'm not really confident about __ALIGNBYTES32 stuff, looks like it differs between different CPU architectures, and looks like it should not be in socket.h header. Anyway I've compiled it to my Switch, looks like it works, but still ...