On Mon, Aug 10, 2020 at 6:50 PM Waldek Kozaczuk <[email protected]>
wrote:

>
> There is one thing to discuss. While I agree that we should use '
> --include libc/*syscall_to*_function.h' for all musl source and have
> compiler detect any undefined individual translation macros (like
> __OSV_TO_FUNCTION_SYS_clock_gettime) which is really nice feature, at the
> same time I am torn whether we should make all translation macros enabled
> by default for all musl sources OR enabled by the #idef switch per file
> (like #ifdef __OSV_SYS_TO_FUNCTION_tmpnam). I am afraid that sometimes we
> will need to add specific #include ... for relevant functions, we translate
> to and that might pollute compiling by causing some collisions.
>

A #define for syscall() may cause problems for including <unistd.h>. Are
there any other problems?
If this is the only problem, then we can easily avoid it: In the top of
libc/syscall_to_function.h, do a "#include <unistd.h>". Before creating a
syscall macro. That's it - unistd.h is protected from being loaded again
with an ifndef, so other code cannot include it again. Yes, it adds a silly
include for unistd.h for source files that didn't need it, but I think
that's ok (hopefully).

Also adding option like 'CFLAGS += -D__OSV_SYS_inline_tmpnam' to specific
> files (there are 12 of them) in the makefile also documents which musl
> files are affected by this translation mechanism which might be helpful to
> understand how all this magic happens, no?
>

I think it only makes it harder. I think it would be even nicer to have
just one "--include libc/syscall_to_function.h" in the Makefile with a
comment in front of it explaining why, or at worst, 12 copies of this for
12 individual source files - but not *also* -D things that makes everything
longer and harder to remember how to do it next time we need to add another
such change.


> BTW I tried to apply ' --include libc/*syscall_to*_function.h' for all
> musl sources files in makefile but then I get these compilation errors
> which are due to some conflicts.
>
> Building into build/release.x64
>   GEN gen/include/osv/version.h
>   CC musl/src/misc/get_current_dir_name.c
>   CC musl/src/misc/nftw.c
>   CC musl/src/multibyte/mbsinit.c
> In file included from <command-line>:
> include/api/unistd.h:179:6: error: ISO C requires a named argument before
> ‘...’
>   179 | long syscall(long, ...);
>       |      ^~~~~~~
>

Of course, this is the unistd.h problem I mentioned above, and proposed a
solution.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjvKEfVWzzbQkTgt4dKDq%3D9KX9S5AHwAjttXBtBJzrCcWQ%40mail.gmail.com.

Reply via email to