Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 20 Jan 2014 11:12:10 +0100
From: John Spencer <>
Subject: Re: Discussion of partly-invasive changes needed for x32 port

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 
     __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.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.