From d68bc3f41ad8a750eda9c50878c6728a84ad3097 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 15 Jan 2014 06:12:10 +0100 Subject: Add Alignof constant to get the alignment of a type. --- ortho/gcc/ortho-lang.c | 6 ++++++ ortho/gcc/ortho_gcc.ads | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'ortho/gcc') diff --git a/ortho/gcc/ortho-lang.c b/ortho/gcc/ortho-lang.c index 370bdd633..900ca17ae 100644 --- a/ortho/gcc/ortho-lang.c +++ b/ortho/gcc/ortho-lang.c @@ -1431,6 +1431,12 @@ new_sizeof (tree atype, tree rtype) return fold (build1 (NOP_EXPR, rtype, size)); } +tree +new_alignof (tree atype, tree rtype) +{ + return build_int_cstu (rtype, TYPE_ALIGN_UNIT (atype)); +} + /* Convert the array expression EXP to a pointer. */ static tree array_to_pointer_conversion (tree exp); diff --git a/ortho/gcc/ortho_gcc.ads b/ortho/gcc/ortho_gcc.ads index 9b5356863..31005ae6c 100644 --- a/ortho/gcc/ortho_gcc.ads +++ b/ortho/gcc/ortho_gcc.ads @@ -233,6 +233,10 @@ package Ortho_Gcc is -- ATYPE cannot be an unconstrained array type. function New_Sizeof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode; + -- Returns the alignment in bytes for ATYPE. The result is a literal of + -- unsgined type RTYPE. + function New_Alignof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode; + -- Returns the offset of FIELD in its record. The result is a literal -- of unsigned type RTYPE. function New_Offsetof (Field : O_Fnode; Rtype : O_Tnode) return O_Cnode; @@ -598,6 +602,7 @@ private pragma Import (C, New_Access_Element); pragma Import (C, New_Sizeof); + pragma Import (C, New_Alignof); pragma Import (C, New_Offsetof); pragma Import (C, New_Address); -- cgit v1.2.3