Re: fontconfig 2.10 and alignof(double) on AIX

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

 



On Wed, Aug 21, 2013 at 01:45:12AM -0400, Behdad Esfahbod wrote:
> On 13-08-21 12:44 AM, Albert Chin wrote:
> > On AIX 32-bit and 64-bit, alignof(double) == 4. This isn't a
> > problem for 32-bit builds of fontconfig but for 64-bit builds, the
> > following assert in src/fcarch.c fails:
> >   FC_ASSERT_STATIC (0x08 + 1*FC_MAX(4,ALIGNOF_DOUBLE) == sizeof (FcValue));
> 
> So, what *is* sizeof(FcValue)?  If alignof(double) is 4, double
> itself is 8, and enum is 4, then sizeof(FcValue) should be 12 which
> is exactly what the assertion is trying to ensure.

This is the offending line above compiled with -E:
  typedef int _static_assert_on_line_59_failed[(((0x08 + 1*((4) > (4) ? (4) : (4)) == sizeof (FcValue))))?1:-1];

sizeof (FcValue) == 16.

typedef struct _FcValue {			// sizeof(type)
    FcType type;				4
    union {
        const FcChar8   *s;			8
        int              i;			4
        FcBool           b;			4
        double           d;			8
        const FcMatrix  *m;			8
        const FcCharSet *c;			8
        void            *f;			8
        const FcLangSet *l;			8
    } u;
} FcValue;					16

AIX has some oddity when it comes to the alignment of aggregates
involving doubles:
  http://pic.dhe.ibm.com/infocenter/comphelp/v111v131/topic/com.ibm.xlcpp111.aix.doc/proguide/aggregate_align.html
  http://peeterjoot.wordpress.com/2009/11/11/c-structure-alignment-padding/
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10645

>From one of the comments in
http://peeterjoot.wordpress.com/2009/11/11/c-structure-alignment-padding/:
  We don’t see the effects of this much anymore since 64-bit AIX
  defaults to -qalign=natural, and we stopped shipping a 32-bit server
  on AIX (32-bit client only).

However, we're using the v11 version of the compiler and it doesn't
seem to default to -qalign=natural:
  $ cat >e.c <<_EOT_
#include <stdio.h>

struct {
  char   c1;
  double d1;
} s1;
struct {
  double d1;
  char   c1;
} s2;

int
main (void) {
  printf ("sizeof (s1): %ld\n", sizeof (s1));
  printf ("sizeof (s2): %ld\n", sizeof (s2));
}
_EOT_
  $ xlc -q64 e.c && ./a.out
sizeof (s1): 12
sizeof (s2): 16
  $ xlc -q64 -qalign=natural e.c && ./a.out
sizeof (s1): 16
sizeof (s2): 16

-- 
albert chin (china@xxxxxxxxxxxxxxxxxx)
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig





[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux