From 89ccf0bbc0e91be3d85574722391d1f41c298479 Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 16 Oct 2024 11:25:05 +0300 Subject: [PATCH] Revert "ip2net: ip6_and use 64-bit and. 128 can cause alignment segfaults" This reverts commit 64b2f940a2f05d9ca2392bc6a77ee579436edd7d. --- ip2net/ip2net.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ip2net/ip2net.c b/ip2net/ip2net.c index cf51a79..793ee72 100644 --- a/ip2net/ip2net.c +++ b/ip2net/ip2net.c @@ -180,15 +180,13 @@ __attribute__((optimize ("no-strict-aliasing"))) #endif static void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result) { - // int 128 can cause alignment segfaults because sin6_addr in struct sockaddr_in6 is 8-byte aligned, not 16-byte - -//#ifdef __SIZEOF_INT128__ -// // gcc and clang have 128 bit int types on some 64-bit archs. take some advantage -// *((unsigned __int128*)result->s6_addr) = *((unsigned __int128*)a->s6_addr) & *((unsigned __int128*)b->s6_addr); -//#else +#ifdef __SIZEOF_INT128__ + // gcc and clang have 128 bit int types on some 64-bit archs. take some advantage + *((unsigned __int128*)result->s6_addr) = *((unsigned __int128*)a->s6_addr) & *((unsigned __int128*)b->s6_addr); +#else ((uint64_t*)result->s6_addr)[0] = ((uint64_t*)a->s6_addr)[0] & ((uint64_t*)b->s6_addr)[0]; ((uint64_t*)result->s6_addr)[1] = ((uint64_t*)a->s6_addr)[1] & ((uint64_t*)b->s6_addr)[1]; -//#endif +#endif } static void rtrim(char *s)