};
#endif
+STATIC_ASSERT(sizeof(struct ether_header) == 14, "ether_header has incorrect size");
+
#ifndef HAVE_STRUCT_ARPHDR
struct arphdr {
uint16_t ar_hrd;
#define ARPOP_NAK 10
#endif
+STATIC_ASSERT(sizeof(struct arphdr) == 8, "arphdr has incorrect size");
+
#ifndef HAVE_STRUCT_ETHER_ARP
struct ether_arp {
struct arphdr ea_hdr;
#define arp_op ea_hdr.ar_op
#endif
+STATIC_ASSERT(sizeof(struct ether_arp) == 28, "ether_arp has incorrect size");
+
#endif
#include <math.h>
#include <time.h>
+#ifdef HAVE_STATIC_ASSERT
+#define STATIC_ASSERT(expr, msg) _Static_assert((expr), msg)
+#else
+#define STATIC_ASSERT(check, msg)
+#endif
+
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#elif defined(HAVE_NETBSD)
};
#endif
+STATIC_ASSERT(sizeof(struct ip) == 20, "ip has incorrect size");
+
#ifndef IP_OFFMASK
#define IP_OFFMASK 0x1fff
#endif
};
#endif
+STATIC_ASSERT(sizeof(struct icmp) == 28, "icmp has incorrect size");
+
#endif
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
#endif
+STATIC_ASSERT(sizeof(struct ip6_hdr) == 40, "ip6_hdr has incorrect size");
+
#ifndef HAVE_STRUCT_ICMP6_HDR
struct icmp6_hdr {
uint8_t icmp6_type;
#define icmp6_mtu icmp6_data32[0]
#endif
+STATIC_ASSERT(sizeof(struct icmp6_hdr) == 8, "icmp6_hdr has incorrect size");
+
#ifndef HAVE_STRUCT_ND_NEIGHBOR_SOLICIT
struct nd_neighbor_solicit {
struct icmp6_hdr nd_ns_hdr;
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
#endif
+STATIC_ASSERT(sizeof(struct nd_neighbor_solicit) == 24, "nd_neighbor_solicit has incorrect size");
+
#ifndef HAVE_STRUCT_ND_OPT_HDR
struct nd_opt_hdr {
uint8_t nd_opt_type;
};
#endif
+STATIC_ASSERT(sizeof(struct nd_opt_hdr) == 2, "nd_opt_hdr has incorrect size");
+
#endif
cc.has_function_attribute(attr)
endforeach
+if cc.compiles('''
+ _Static_assert(1, "ok");
+ int main(void) { return 0; }
+''')
+ cdata.set('HAVE_STATIC_ASSERT', 1,
+ description: 'C11 _Static_assert()')
+endif
+
check_headers = [
'alloca.h',
'arpa/inet.h',