From owner-svn-src-vendor@FreeBSD.ORG Mon Nov 25 18:28:35 2013 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12901666; Mon, 25 Nov 2013 18:28:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DC6CD2E32; Mon, 25 Nov 2013 18:28:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAPISYO6075477; Mon, 25 Nov 2013 18:28:34 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAPISYuV075476; Mon, 25 Nov 2013 18:28:34 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201311251828.rAPISYuV075476@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 25 Nov 2013 18:28:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r258571 - vendor/tcpdump/dist X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Nov 2013 18:28:35 -0000 Author: pfg Date: Mon Nov 25 18:28:34 2013 New Revision: 258571 URL: http://svnweb.freebsd.org/changeset/base/258571 Log: tcpdump Bring change from upstream. commit 772d6fbcf592209aa1ab1b61714e8ae72a5b1698 Author: Dmitrij Tejblum Date: Sun Jun 2 13:48:44 2013 +0400 Convert some versions of EXTRACT_{16,32,64}BITS() to inline functions. It removes the vast majority of strict-aliasing warnings from GCC. Modified: vendor/tcpdump/dist/extract.h Modified: vendor/tcpdump/dist/extract.h ============================================================================== --- vendor/tcpdump/dist/extract.h Mon Nov 25 18:11:55 2013 (r258570) +++ vendor/tcpdump/dist/extract.h Mon Nov 25 18:28:34 2013 (r258571) @@ -51,13 +51,25 @@ typedef struct { u_int32_t val; } __attribute__((packed)) unaligned_u_int32_t; -#define EXTRACT_16BITS(p) \ - ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val)) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val)) -#define EXTRACT_64BITS(p) \ - ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \ - ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0)) +static inline u_int16_t +EXTRACT_16BITS(const void *p) +{ + return ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val)); +} + +static inline u_int32_t +EXTRACT_32BITS(const void *p) +{ + return ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val)); +} + +static inline u_int64_t +EXTRACT_64BITS(const void *p) +{ + return ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \ + ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0)); + +} #else /* HAVE___ATTRIBUTE__ */ /* @@ -88,13 +100,26 @@ typedef struct { * The processor natively handles unaligned loads, so we can just * cast the pointer and fetch through it. */ -#define EXTRACT_16BITS(p) \ - ((u_int16_t)ntohs(*(const u_int16_t *)(p))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)ntohl(*(const u_int32_t *)(p))) -#define EXTRACT_64BITS(p) \ - ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \ - ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0)) +static inline u_int16_t +EXTRACT_16BITS(const void *p) +{ + return ((u_int16_t)ntohs(*(const u_int16_t *)(p))); +} + +static inline u_int32_t +EXTRACT_32BITS(const void *p) +{ + return ((u_int32_t)ntohl(*(const u_int32_t *)(p))); +} + +static inline u_int64_t +EXTRACT_64BITS(const void *p) +{ + return ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \ + ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0)); + +} + #endif /* LBL_ALIGN */ #define EXTRACT_24BITS(p) \