[Mesa-dev] [PATCH] nir: Use PRIi64 and PRIu64 instead of %ld and %lu.

Jason Ekstrand jason at jlekstrand.net
Mon Apr 4 05:37:02 UTC 2016


On Apr 3, 2016 7:51 PM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:
>
> %ld and %lu aren't the right format specifiers for int64_t and uint64_t
> on 32-bit (x86) systems.  They're %zu on Linux and %Iu on Windows.
>
> Use the standard C99 macros in hopes that they work everywhere.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/nir/nir_search.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
> index 6e63063..c17d47b 100644
> --- a/src/compiler/nir/nir_search.c
> +++ b/src/compiler/nir/nir_search.c
> @@ -25,6 +25,7 @@
>   *
>   */
>
> +#include <inttypes.h>
>  #include "nir_search.h"
>
>  struct match_state {
> @@ -483,7 +484,7 @@ construct_value(const nir_search_value *value,
>           break;
>
>        case nir_type_int:
> -         load->def.name = ralloc_asprintf(load, "%ld", c->data.i);
> +         load->def.name = ralloc_asprintf(load, "%" PRIi64, c->data.i);

Another option is to simply use lld and llu.  That should be 64-bits on all
the platforms we care about.

>           switch (bitsize->dest_size) {
>           case 32:
>              load->value.i32[0] = c->data.i;
> @@ -497,7 +498,7 @@ construct_value(const nir_search_value *value,
>           break;
>
>        case nir_type_uint:
> -         load->def.name = ralloc_asprintf(load, "%lu", c->data.u);
> +         load->def.name = ralloc_asprintf(load, "%" PRIu64, c->data.u);
>           switch (bitsize->dest_size) {
>           case 32:
>              load->value.u32[0] = c->data.u;
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160403/1c6ee7cd/attachment.html>


More information about the mesa-dev mailing list