[Mesa-dev] [PATCH 04/18] ralloc: SIZE_MAX is missing on Android

Ian Romanick idr at freedesktop.org
Wed Aug 17 08:31:53 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/16/2011 11:28 PM, Chia-I Wu wrote:
> Define SIZE_MAX to UINT32_MAX for it.
> ---
>  src/glsl/ralloc.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
> index 6a5eac6..757ab5c 100644
> --- a/src/glsl/ralloc.c
> +++ b/src/glsl/ralloc.c
> @@ -46,6 +46,10 @@
>  #endif
>  #endif
>  
> +#ifdef ANDROID
> +#define SIZE_MAX UINT32_MAX
> +#endif
> +

Android doesn't have this in stdint.h?  C99 requires that it be there.
Either way, this assumes that size_t is a uint32_t, which it may not be.
 A better approach might be:

/* C99 requires that SIZE_MAX be at least 65536.  The allocator
 * shouldn't ever need it to be more than 2^32.  Good luck allocating a
 * a single block that big anyway.
 */
#ifndef SIZE_MAX
#  if sizeof(size_t) >= 4
#    define SIZE_MAX UINT32_MAX
#  else
#    define SIZE_MAX 65536
#  endif
#endif


>  #define CANARY 0x5A1106
>  
>  struct ralloc_header
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5L3ukACgkQX1gOwKyEAw/y5ACgk6mFeFzAGYdTrVnOq22wWniO
bWoAn32ToGAv2ZOhes1sEfBpq/IVYUHr
=KQvC
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list