tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Alignment issue


From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] Alignment issue
Date: Wed, 24 Sep 2014 22:56:49 +0800
User-agent: KMail/4.14 (Linux/3.14-2-amd64; KDE/4.14.1; x86_64; ; )

Le lundi 22 septembre 2014, 07:50:33 Daniel Fiala a écrit :
> Hello.It seems that alignment in tcc is not working properly. I tried
> following program:
> 
> 
> #include <stdio.h>
> 
> 
> static float x[4] = { 1, 2, 3, 4 };
> static float y[4] __attribute__((aligned(32))) = { 4, 5, 6, 7 };
> 
> 
> int
> main(void) {
>         fprintf(stderr, "%p\n", x);
>         fprintf(stderr, "%p\n", y);
> 
> 
>         return 0;
> }
> 
> 
> 
> I compiled it with tcc 0.9.5 under Ubuntu 14.04 and I got following output:
> 
> 
> 0x8049544
> 0x8049554
> 
> 
> 
> It looks that address is not aligned. :-(

From tcc.h:

struct Attribute {
    unsigned
        func_call     : 3, /* calling convention (0..5), see below */
        aligned       : 5, /* alignement (0..16) */
        packed        : 1,
        func_export   : 1,
        func_import   : 1,
        func_args     : 5,
        func_proto    : 1,
        mode          : 4,
        weak          : 1,
        visibility    : 2,
        fill          : 8; // 8 bits left to fit well in union below
};

You get the picture I think. Aligned should probably be a separate field of 
type unsigned char (so alignment from 0 to 64 (size of most cacheline). If 
more is necessary we can bump to an unsigned short instead.

Feel free to do the change.

Best regards,

Thomas

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]