2 /* { dg-require-effective-target int32plus } */
3 /* { dg-options "-O3" } */
5 typedef __INT32_TYPE__
int32_t;
7 #define BIG_ENDIAN __attribute__((scalar_storage_order("big-endian")))
9 /* host order version (little endian)*/
17 typedef struct _ip6_addr t_ip6_addr
;
27 typedef struct _net_addr t_net_addr
;
29 /* big endian version */
36 typedef struct _be_ip6_addr t_be_ip6_addr
;
46 typedef struct _be_net_addr t_be_net_addr
;
49 t_be_ip6_addr
be_ip6_addr(const t_ip6_addr ip6
)
52 .u
.addr8
[0] = ip6
.u
.addr8
[0],
53 .u
.addr8
[1] = ip6
.u
.addr8
[1],
54 .u
.addr8
[2] = ip6
.u
.addr8
[2],
55 .u
.addr8
[3] = ip6
.u
.addr8
[3],
56 .u
.addr8
[4] = ip6
.u
.addr8
[4],
57 .u
.addr8
[5] = ip6
.u
.addr8
[5],
58 .u
.addr8
[6] = ip6
.u
.addr8
[6],
59 .u
.addr8
[7] = ip6
.u
.addr8
[7],
60 .u
.addr8
[8] = ip6
.u
.addr8
[8],
61 .u
.addr8
[9] = ip6
.u
.addr8
[9],
62 .u
.addr8
[10] = ip6
.u
.addr8
[10],
63 .u
.addr8
[11] = ip6
.u
.addr8
[11],
64 .u
.addr8
[12] = ip6
.u
.addr8
[12],
65 .u
.addr8
[13] = ip6
.u
.addr8
[13],
66 .u
.addr8
[14] = ip6
.u
.addr8
[14],
67 .u
.addr8
[15] = ip6
.u
.addr8
[15],
72 t_be_net_addr
__attribute__((noipa
)) be_net_addr(const t_net_addr ip
)
74 t_be_net_addr rc
= {.is_v4
= ip
.is_v4
};
76 rc
.u
.addr
= ip
.u
.addr
;
78 rc
.u
.addr6
= be_ip6_addr(ip
.u
.addr6
);
85 t_be_net_addr out
= { };
90 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
93 out
= be_net_addr(in
);
95 // actually first 4 bytes are swapped
96 if (in
.u
.addr6
.u
.addr8
[0] != out
.u
.addr6
.u
.addr8
[0])