From patchwork Tue Aug 26 16:02:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 383169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1DA291400D7 for ; Wed, 27 Aug 2014 02:03:27 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=cciWgmRuF2lVVJPcx941QLatfriuFtF4sNZ3vU9TWvDWhiLN9ws+d dZWB3KBejk6Cle8hWfe8gAF0810iyQkxMQf8F0njGgFtcYAIzmF5OPReKwtzDcoL e3PeEnPD1Fogu/ze7er6J6JJqlbYRmG/b7Gre1g269R8xsOFMAOUl8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=ALt4A9s628DcNVQq51oOHgqNCYw=; b=ir2s7INBzOs+bx82XLPP A/+Efstg48WMuUbueRFS/4ka3WoWL7LO+YWKbjxuj7tTjKagFW+oUX91aBrpZsGH q1X0ZiXwES6k9wlyuc0O+cjrsym5h6chjr5nQ5iLdc/6IotaFT8eHfGjNNwQKdSY YCmw9GiSt1PbuXbJG+QSucw= Received: (qmail 580 invoked by alias); 26 Aug 2014 16:02:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 384 invoked by uid 89); 26 Aug 2014 16:02:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f173.google.com Received: from mail-we0-f173.google.com (HELO mail-we0-f173.google.com) (74.125.82.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 26 Aug 2014 16:02:44 +0000 Received: by mail-we0-f173.google.com with SMTP id q58so14990001wes.4 for ; Tue, 26 Aug 2014 09:02:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CmW7RPeU26YSsYaHsHzBNZzLE5GHm+8uNTwjkROxj/o=; b=XrC+fWFsroJM2XxUkDXV/5ukW7viRzcoTC61q4BGLrZLSuzO4IsGhtKpEEpuJKvUvF sz4uJUCFCI2jI5AFKoGRgRlKD8INWf5FZypwbOymUuGIEcDwxCTRub2A9O/oD3HoL5mz HuaYgNDQD1DMjzAte+BWenGc91+sRVBBWUIvPppCFFb8tTEE/H1Fo4fCo0vnpK0ZOoNa rky4Kt/RNSBVKeWsCPJsqYxHKW5KPfmRrqZY2rwtmlXLOvPVvVFrOPHRKQYqDYeWruL3 o3Dc1dGpMjnDYVu87dpXp6pLYWFaYFepv+dzktUTgdNdLZ+cqntmNCihBFf2Cvyp6hqt 2hGA== X-Gm-Message-State: ALoCoQnmaL8trhKaW9Pi+B57YQA8iE4cvrJDIOcqJ/7YWMFuQTMYuDiMnmaU079gCKQbBN60hq0p X-Received: by 10.194.158.226 with SMTP id wx2mr3911966wjb.107.1409068961697; Tue, 26 Aug 2014 09:02:41 -0700 (PDT) Received: from localhost.localdomain (host81-133-133-27.in-addr.btopenworld.com. [81.133.133.27]) by mx.google.com with ESMTPSA id fh5sm3820369wib.5.2014.08.26.09.02.40 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Aug 2014 09:02:41 -0700 (PDT) From: James Clarke To: gcc-patches@gcc.gnu.org Cc: James Clarke Subject: [PATCH v2 2/2] Fixed dirent sanitizer for 32-bit OS X builds Date: Tue, 26 Aug 2014 17:02:19 +0100 Message-Id: <1409068939-58268-3-git-send-email-jrtc27@jrtc27.com> In-Reply-To: <1409068939-58268-1-git-send-email-jrtc27@jrtc27.com> References: <1409068939-58268-1-git-send-email-jrtc27@jrtc27.com> The __DARWIN_64_BIT_INO_T macro is used to indicate whether dirent.d_ino is 64-bit or not, and so should be sized appropriately. Additionally, dirent.d_seekoff should only be defined/checked when __DARWIN_64_BIT_INO_T is defined. libsanitizer/ChangeLog: * sanitizer_common/sanitizer_platform_limits_posix.cc: Only check dirent.d_seekoff on OS X when performing a 64-bit build. * sanitizer_common/sanitizer_platform_limits_posix.h: Only define dirent.d_seekoff on OS X when performing a 64-bit build, and make dirent.d_ino the correct size (32-bit) when performing a 32-bit build. --- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc | 3 ++- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc index a93d38d..0d1870b 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -940,7 +940,8 @@ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); CHECK_SIZE_AND_OFFSET(dirent, d_ino); -#if SANITIZER_MAC +#if SANITIZER_MAC && __DARWIN_64_BIT_INO_T +// The 'd_seekoff' field is only present on OS X for 64-bit builds CHECK_SIZE_AND_OFFSET(dirent, d_seekoff); #elif SANITIZER_FREEBSD // There is no 'd_off' field on FreeBSD. diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h index dece2d3..73a4c3f 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h @@ -392,12 +392,21 @@ namespace __sanitizer { #endif #if SANITIZER_MAC +# if __DARWIN_64_BIT_INO_T struct __sanitizer_dirent { unsigned long long d_ino; unsigned long long d_seekoff; unsigned short d_reclen; // more fields that we don't care about }; +# else + struct __sanitizer_dirent { + unsigned int d_ino; + // No d_seekoff for 32-bit + unsigned short d_reclen; + // more fields that we don't care about + }; +# endif #elif SANITIZER_FREEBSD struct __sanitizer_dirent { unsigned int d_fileno;