Home | History | Annotate | Line # | Download | only in lint1
gcc_attribute_aligned.c revision 1.1
      1  1.1  rillig /*	$NetBSD: gcc_attribute_aligned.c,v 1.1 2021/05/02 20:44:46 rillig Exp $	*/
      2  1.1  rillig # 3 "gcc_attribute_aligned.c"
      3  1.1  rillig 
      4  1.1  rillig /*
      5  1.1  rillig  * Test size computations on aligned and packed structs.
      6  1.1  rillig  */
      7  1.1  rillig 
      8  1.1  rillig typedef unsigned short uint16_t;
      9  1.1  rillig typedef unsigned int uint32_t;
     10  1.1  rillig typedef unsigned long long uint64_t;
     11  1.1  rillig 
     12  1.1  rillig /* from sys/arch/x86/include/cpu_extended_state.h */
     13  1.1  rillig 
     14  1.1  rillig union fp_addr {
     15  1.1  rillig 	uint64_t fa_64;
     16  1.1  rillig 	struct {
     17  1.1  rillig 		uint32_t fa_off;
     18  1.1  rillig 		uint16_t fa_seg;
     19  1.1  rillig 		uint16_t fa_opcode;
     20  1.1  rillig 	} fa_32;
     21  1.1  rillig } __attribute__((packed)) __attribute__((aligned(4)));
     22  1.1  rillig 
     23  1.1  rillig struct fpacc87 {
     24  1.1  rillig 	uint64_t f87_mantissa;
     25  1.1  rillig 	uint16_t f87_exp_sign;
     26  1.1  rillig } __attribute__((packed)) __attribute__((aligned(2)));
     27  1.1  rillig 
     28  1.1  rillig struct save87 {
     29  1.1  rillig 	uint16_t s87_cw __attribute__((aligned(4)));
     30  1.1  rillig 	uint16_t s87_sw __attribute__((aligned(4)));
     31  1.1  rillig 	uint16_t s87_tw __attribute__((aligned(4)));
     32  1.1  rillig 	union fp_addr s87_ip;
     33  1.1  rillig 	union fp_addr s87_dp;
     34  1.1  rillig 	struct fpacc87 s87_ac[8];
     35  1.1  rillig };
     36  1.1  rillig 
     37  1.1  rillig struct {
     38  1.1  rillig 	unsigned int sizeof_fp_addr: sizeof(union fp_addr) == 8 ? 1 : -1;
     39  1.1  rillig 
     40  1.1  rillig 	unsigned int sizeof_fpacc87: sizeof(struct fpacc87) == 10 ? 1 : -1;
     41  1.1  rillig 
     42  1.1  rillig 	/* expect+1: illegal bit-field size: 255 *//*FIXME*/
     43  1.1  rillig 	unsigned int sizeof_save87: sizeof(struct save87) == 108 ? 1 : -1;
     44  1.1  rillig };
     45