author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-10-01 08:14:53 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-10-14 20:11:19 UTC |
parent | f80ba9f4dfdf9d8a6ee5d724a8aa3f7c4c107fbc |
preload/posix/modules/posix.custom.c | +5 | -5 |
diff --git a/preload/posix/modules/posix.custom.c b/preload/posix/modules/posix.custom.c index 32b5cc8..18d01d0 100644 --- a/preload/posix/modules/posix.custom.c +++ b/preload/posix/modules/posix.custom.c @@ -6,6 +6,7 @@ #include "codegen.h" #include "hash.h" +#include <inttypes.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> @@ -212,14 +213,13 @@ static void constructor_attr(200) _fiu_init_ferror_hash_table(void) } /* Our hash table uses character keys, to convert stream to keys we just get - * the hexadecimal representation via %p. - * 64 bit pointers fit in 18 characters, use 20 so we have room for \0 and - * more practical alignment. */ -#define STREAM_KEY_SIZE 20 + * the hexadecimal representation via PRIxPTR (%p is implementation + * dependent). */ +#define STREAM_KEY_SIZE (sizeof(uintptr_t) * 2 + 1) static void stream_to_key(void *stream, char key[STREAM_KEY_SIZE]) { - snprintf(key, STREAM_KEY_SIZE, "%p", stream); + snprintf(key, STREAM_KEY_SIZE, "%" PRIxPTR, (uintptr_t) stream); } void set_ferror(void * stream)