Comments (8)
I think i've fixed the accept4 and reallocarray issue, let me know if those warnings/errors now are gone on darwin, thanks!
Regarding endian.h, freebsd has a compatible set of functions in sys/endian.h
, so just adding a check for that should be enough. On darwin however it seems a bit more complex but doable: I'm looking in particular at how darwin is handled in got-portable: https://github.com/ThomasAdam/got-portable/blob/46384c6e760fdd54c263d1af7d6db58cc09a4e51/include/got_compat.h#L11-L30
Just a matter of style however, i don't like how got-portable does some compats: it looks for the operating system instead of checking for the actual presence of the feature, so I'd prefer if we add some checks for the headers (endian.h
, sys/endian.h
and OSByteOrder.h
) and just include the first one found (plus the compats in case of darwin.)
This can be done by using AC_CHECK_HEADER
in configure.ac and then adding the relative includes in compat.h
and then removing all the #include <endian.h>
in the rest of the project; see for e.g. how sys/tree.h
is handled.
Let me know if i can help you with that, I'll be glad to merge a PR for it! Thanks!
from kamid.
Hello!
Yes, I'd be happy to merge a PR to add Darwin support. I don't have a mac, so I can't test it, but I care about portability :)
The oconfigure solution for endian.h seems fine.
Regarding LOGIN_NAME_MAX I was recently bit by it because neither FreeBSD has it. I'll commit something for it soon.
Thanks!
from kamid.
Does 20f7a94 help with LOGIN_NAME_MAX on darwin too?
from kamid.
Thanks. I don't see the error again. Now the compiler can go further it show more error.
control.c:69:42: error: use of undeclared identifier 'SOCK_CLOEXEC'
if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
^
control.c:69:57: error: use of undeclared identifier 'SOCK_NONBLOCK'
if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
^
control.c:138:16: warning: implicit declaration of function 'accept4' is invalid in C99 [-Wimplicit-function-declaration]
if ((connfd = accept4(listenfd, (struct sockaddr *)&sun, &len,
^
I checked Mac header doesn't contain those definition so I will need to fallback to the lass safer accept and fcntl.
Go for instance fallback without those flags set https://android.googlesource.com/platform/prebuilts/go/darwin-x86/+/brillo-m7-release/src/net/sock_cloexec.go
kamid.c:175:3: warning: 'daemon' is deprecated: first deprecated in macOS 10.5 - Use posix_spawn APIs instead. [-Wdeprecated-declarations]
daemon(1, 0);
^
/nix/store/y9cwm5z3wimzf13b207ndyapdlgxm15h-Libsystem-1238.60.2/include/stdlib.h:288:6: note: 'daemon' has been explicitly marked deprecated here
int daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
linux, freebsd, netbsd, openbsd, Darwin have a posix_spawn so we can get everybody happy.
parse.y:452:13: warning: implicit declaration of function 'reallocarray' is invalid in C99 [-Wimplicit-function-declaration]
void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
^
fixable using realloc
from kamid.
Right, darwin still lacks accept4 and the fancy SOCK_* flags; it's not an issue to just use accept
and fcntl to set the nonblock and cloexec flags since kamid is not threaded.
The reallocarray warnings is because i forgot to include a check for it in the configure, i only have recallocarray. I'll fix that too.
Regarding daemon... I know that the posix_spawn APIs are widely available but i personally dislike them (they feel over-enginereed, confusing and plain ugly) so i'll keep using daemon(3). if daemon(3) will be ever removed on darwin, we'll find a way :)
from kamid.
Darwin instead of le64toh
has ntohll
. Can you check in various bsd I think it is in freebsd maybe with _KERNEL guard https://github.com/apple-oss-distributions/Libc/blob/768d166d42689471e1e8fd1ddde5eee25db02381/nls/FreeBSD/msgcat.c#L62
If so I can make a PR with all those change.
from kamid.
I've pushed the endian
branch with changes that should allow to build it on Mac. So far I've only tested on FreeBSD however.
from kamid.
since it fixes the build on FreeBSD (and possibly on NetBSD too) I just merged this in the main branch, let me know if it works on darwin too!
Thanks!
from kamid.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kamid.