Please note that this fixes PR 61407 (forgot to add it to 
libsanitizer/ChangeLog).

James Clarke

> On 25 Aug 2014, at 19:03, James Clarke <jrt...@jrtc27.com> wrote:
> 
> 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;
> -- 
> 2.1.0
> 

Reply via email to