tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Please do not yell at people for trying to help you.

On Sat, 13 Nov 2010, Valeriy E. Ushakov wrote:

>     #define htole64(x)              \


>     // just to exercise it a bit
>     struct s {
>         uint64_t foo[12];
>     };
>     uint64_t
>     foo(struct s *s)
>     {
>         return s->foo[10] + htole64(s->foo[11]);
>     }
> compiles to pretty sane:
> foo:
>         ldx     [%o0+80], %g1
>         ldxa    [%o0+88] ASI_LITLE, %o0
>         jmp     %o7+8
>          add    %o0, %g1, %o0

Rather than continue this discussion deeper down the rathole, I just want 
make sure people understand what I'm trying to say which doesn't appear to 
be the case from the responses.  

This could work, with the proper constraints, in most cases, for letoh64() 
where you marshall in.  It does not work to marshall out a value, where 
you neeed a macro of the form:

#define htole64(x, v)   (*(x)) = bswap64(v)

foo(struct s *s, uint64_t v)
    htole64(&(s->foo[10]), s->foo[11]);

(Assembly language implemenation left to the user.)

As for modifying gcc, I have long conemplated adding some sort of pragma 
or storage specifier extension to the language so specific data structures 
can indicate they are in a specific endianness.  However, that would be a 
heck of a lot of work for what is probably very little gain and change the 
language's syntax so the code would no longer be standard ANSI or ISO C.


Home | Main Index | Thread Index | Old Index