mailing list of musl libc
 help / color / mirror / code / Atom feed
From: John Spencer <maillist-musl@barfooze.de>
To: musl@lists.openwall.com
Subject: Re: Discussion of partly-invasive changes needed for x32 port
Date: Mon, 20 Jan 2014 11:12:10 +0100	[thread overview]
Message-ID: <52DCF67A.3020706@barfooze.de> (raw)
In-Reply-To: <1390209922.6398.365.camel@eris.loria.fr>

Jens Gustedt wrote:
> Hi,
> 
> Am Montag, den 20.01.2014, 09:43 +0100 schrieb Luca Barbato:
>> On 20/01/14 08:41, Rich Felker wrote:
>>> Adding the workaround code at every syscall point is ugly, and
>>> possibly error-prone. An alternate possible solution is hacking up the
>>> syscall macros in syscall_arch.h to detect "const struct timespec *"
>>> arguments and auto-wrap them with compound literals that would fix-up
>>> the padding. However this probably requires either C11 or GNU C
>>> extensions. On the positive side, it would only affect x32; no changes
>>> at all would be made to the source files or other archs'
>>> syscall_arch.h logic.
>> Can a compiler supporting x32 be safely expected to support C11 ? If yes
>> sounds the best route.
> 
> I have difficulties in understanding why C11 pops up, here. Compound
> literals are in C since C99. gcc and clang support them since
> ages.
> 

what rich had in mind was usage of _Generic in the x32 __scc 
(syscall-cast) macro:

instead of

#define __scc(X) sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : (long 
long) (X)

something along the lines of
_Generic((X), struct timespec*: &(struct timespec){.sec = (X).sec, .nsec 
= (X).nsec}, default: sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : 
(long long) (X))

however the only available compiler implementing _Generic is Clang.
not even GCC 4.8.2 supports it. however i've seen some pseudo _Generic 
implementation on your blog [1], imo we could use the bits described 
there, namely
"
     __typeof__(EXP) gives the type of the expression EXP
     __builtin_types_compatible_p(T1, T2) is true if the two types are 
compatible
     __builtin_choose_expr(CNTRL, EXP1, EXP2) choose between the two 
expressions at compile time.
"

to implement the above macro, as x32 requires a very recent GCC (>= 4.7) 
anyway, i see no big problem in using those gcc helpers in lieu of _Generic.


[1] 
http://gustedt.wordpress.com/2012/01/02/emulating-c11-compiler-features-with-gcc-_generic/


  reply	other threads:[~2014-01-20 10:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20  7:41 Rich Felker
2014-01-20  8:43 ` Luca Barbato
2014-01-20  9:25   ` Jens Gustedt
2014-01-20 10:12     ` John Spencer [this message]
2014-01-20 10:55       ` Jens Gustedt
2014-01-20 23:57         ` Rich Felker
2014-01-21  8:29           ` Jens Gustedt
2014-01-21 11:33             ` Szabolcs Nagy
2014-01-21 13:59               ` Jens Gustedt
2014-01-21  1:47 ` John Spencer
2014-01-21  2:18   ` Rich Felker
2014-02-02  6:50 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52DCF67A.3020706@barfooze.de \
    --to=maillist-musl@barfooze.de \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).