From patchwork Thu Apr 17 13:49:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 339937 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 3F84D14008F for ; Fri, 18 Apr 2014 00:02:24 +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=Wc1cCvFdaxoC0bgQtFsD4QHCtiOuJUImJU699j18+JQ4cRSBcwQ+c D6kmxv6zy2Od5uJTc90oN6Jn2OqNRpwq8ABjpoQwROvSkvUAoEsZ8zasJ2Fj1KbA bRKACMornfg6OY3hzaQpn7W9VAWJxu7mYMYk+XdXaqZrXycCS6AF1M= 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=WtkEo4QymhZ+CwK08hfnyjoMfWo=; b=xi5Yj4013eMOO+udQj4d h1cDVBiwwdWG8CtpBcCM+Qz0aAu4r83gDy5nlCl3I7xUurFdyvNUosaJVeCh+LmT 0fT2xy0X6xJoTYpNFReir9K/In1WVFZ9KPVMtujnGTMesHNf1kgUleywlxll+A4z uhrJxG/tAUYOWz+7j3z4Uo8= Received: (qmail 31478 invoked by alias); 17 Apr 2014 14:01:57 -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 31430 invoked by uid 89); 17 Apr 2014 14:01:56 -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, FREEMAIL_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: grace.univie.ac.at Received: from grace.univie.ac.at (HELO grace.univie.ac.at) (131.130.3.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 17 Apr 2014 14:01:51 +0000 Received: from justin.univie.ac.at ([131.130.3.111] helo=justin.univie.ac.at) by grace.univie.ac.at with esmtp (Exim 4.82) (envelope-from ) id 1Wamst-0003eH-R8; Thu, 17 Apr 2014 16:01:47 +0200 Received: from [2001:62a:4:203:2e59:e5ff:feb9:72ed] (helo=nbbrfq.loc) by justin.univie.ac.at with esmtps (TLSv1.2:DHE-RSA-AES256-SHA256:256) (Exim 4.82) (envelope-from ) id 1Wamst-0004wV-Pt; Thu, 17 Apr 2014 16:01:47 +0200 Received: from b by nbbrfq.loc with local (Exim 4.82) (envelope-from ) id 1WamhE-0005x5-KV; Thu, 17 Apr 2014 15:49:44 +0200 From: Bernhard Reutner-Fischer To: Konstantin Serebryany Cc: Bernhard Reutner-Fischer , Jakub Jelinek , GCC Patches , Dodji Seketeli , Kostya Serebryany , Dmitry Vyukov Subject: [PATCH 1/3] libsanitizer: Fix !statfs64 builds Date: Thu, 17 Apr 2014 15:49:35 +0200 Message-Id: <1397742577-22841-2-git-send-email-rep.dot.nop@gmail.com> In-Reply-To: <1397742577-22841-1-git-send-email-rep.dot.nop@gmail.com> References: <20130405094956.GB20334@tucnak.redhat.com> <1397742577-22841-1-git-send-email-rep.dot.nop@gmail.com> X-Univie-Virus-Scan: scanned by ClamAV on justin.univie.ac.at X-IsSubscribed: yes libsanitizer/ChangeLog 2014-04-02 Bernhard Reutner-Fischer * configure.ac: Check for sizeof(struct statfs64). * configure, config.h.in: Regenerate. * sanitizer_common/sanitizer_platform_interceptors.h (SANITIZER_INTERCEPT_STATFS64): Make conditional on SIZEOF_STRUCT_STATFS64 being not 0. * sanitizer_common/sanitizer_platform_limits_linux.cc (namespace __sanitizer): Make unsigned struct_statfs64_sz conditional on SANITIZER_INTERCEPT_STATFS64. Signed-off-by: Bernhard Reutner-Fischer --- libsanitizer/config.h.in | 9 +++ libsanitizer/configure | 69 ++++++++++++++++++++++ libsanitizer/configure.ac | 15 +++++ .../sanitizer_platform_interceptors.h | 4 +- .../sanitizer_platform_limits_linux.cc | 2 + 5 files changed, 98 insertions(+), 1 deletion(-) diff --git a/libsanitizer/config.h.in b/libsanitizer/config.h.in index e4b2786..4bd6a7f 100644 --- a/libsanitizer/config.h.in +++ b/libsanitizer/config.h.in @@ -61,12 +61,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -107,6 +113,9 @@ /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT +/* The size of `struct statfs64', as computed by sizeof. */ +#undef SIZEOF_STRUCT_STATFS64 + /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P diff --git a/libsanitizer/configure b/libsanitizer/configure index 5e4840f..c636212 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -15463,6 +15463,75 @@ _ACEOF +for ac_header in sys/statfs.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/statfs.h" "ac_cv_header_sys_statfs_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_statfs_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_STATFS_H 1 +_ACEOF + +fi + +done + +if test "$ac_cv_header_sys_statfs_h" = "no"; then + for ac_header in sys/vfs.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/vfs.h" "ac_cv_header_sys_vfs_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_vfs_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_VFS_H 1 +_ACEOF + +fi + +done + +fi +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct statfs64" >&5 +$as_echo_n "checking size of struct statfs64... " >&6; } +if test "${ac_cv_sizeof_struct_statfs64+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct statfs64))" "ac_cv_sizeof_struct_statfs64" " +#ifdef HAVE_SYS_STATFS_H +# include +#endif +#ifdef HAVE_SYS_VFS_H +# include +#endif + +"; then : + +else + if test "$ac_cv_type_struct_statfs64" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "cannot compute sizeof (struct statfs64) +See \`config.log' for more details." "$LINENO" 5; }; } + else + ac_cv_sizeof_struct_statfs64=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_statfs64" >&5 +$as_echo "$ac_cv_sizeof_struct_statfs64" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_STRUCT_STATFS64 $ac_cv_sizeof_struct_statfs64 +_ACEOF + + + if test "${multilib}" = "yes"; then multilib_arg="--enable-multilib" else diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index e672131..746c216 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -78,6 +78,21 @@ AC_SUBST(enable_static) AC_CHECK_SIZEOF([void *]) +dnl Careful, this breaks on glibc for e.g. dirent.d_ino being 64bit +dnl AC_SYS_LARGEFILE +AC_CHECK_HEADERS(sys/statfs.h) +if test "$ac_cv_header_sys_statfs_h" = "no"; then + AC_CHECK_HEADERS(sys/vfs.h) +fi +AC_CHECK_SIZEOF([struct statfs64],[],[ +#ifdef HAVE_SYS_STATFS_H +# include +#endif +#ifdef HAVE_SYS_VFS_H +# include +#endif +]) + if test "${multilib}" = "yes"; then multilib_arg="--enable-multilib" else diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h index f37d84b..b9ebd5c 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h @@ -137,7 +137,9 @@ # define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID # define SANITIZER_INTERCEPT_STATFS SI_NOT_WINDOWS # define SANITIZER_INTERCEPT_STATFS64 \ - (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID + SIZEOF_STRUCT_STATFS64 && ( \ + (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID \ + ) # define SANITIZER_INTERCEPT_STATVFS SI_LINUX_NOT_ANDROID # define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID # define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc index bc37df0..637ac1d 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc @@ -59,7 +59,9 @@ #endif namespace __sanitizer { +#if SANITIZER_INTERCEPT_STATFS64 unsigned struct_statfs64_sz = sizeof(struct statfs64); +#endif } // namespace __sanitizer #if !defined(__powerpc64__) && !defined(__x86_64__)