larmel / lacc

A simple, self-hosting C compiler
MIT License
872 stars 64 forks source link

Compile static inline is failing #31

Closed arteze closed 2 years ago

arteze commented 3 years ago

I'm trying to compile something what do you need __builtin_bswap32:

dst[i] = __builtin_bswap32(src[i]);

For this, I include linux/swab.h:

#include <linux/swab.h>

Error:

(/usr/include/asm/swab.h, 7) error: Expected ; but got __u32.

/usr/include/asm/swab.h:7

static __inline__  __u32 __arch_swab32(__u32 val)
{
    __asm__("bswapl %0" : "=r" (val) : "0" (val));
    return val;
}

I imagine that this appears because don't support static __inline__

larmel commented 2 years ago

The actual problem here is that __inline__ was not recognized as a keyword. I have added it, together with some other extension keywords.

Another problem I encountered trying to include this header myself was __builtin_constant_p, which I also implemented. These linux headers assume lots of non-standard stuff, so I expect there to be more issues. For example, the inline instruction "bswapl" as shown is not implemented yet.

Thanks for reporting!