X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=mhexdump.c;h=36e1f0281d03ce1ac4a903e7f7251644da96c4c7;hb=HEAD;hp=5d927f7aac615e9da078ef13840084000d0dce6c;hpb=efa545d64b910923248233618e774ca3b87efebb;p=tfcrypt.git diff --git a/mhexdump.c b/mhexdump.c index 5d927f7..36e1f02 100644 --- a/mhexdump.c +++ b/mhexdump.c @@ -2,7 +2,7 @@ * tfcrypt -- high security Threefish encryption tool. * * tfcrypt is copyrighted: - * Copyright (C) 2012-2018 Andrey Rys. All rights reserved. + * Copyright (C) 2012-2019 Andrey Rys. All rights reserved. * * tfcrypt is licensed to you under the terms of std. MIT/X11 license: * @@ -33,6 +33,18 @@ #include #include +#undef MACHINE_16BIT +#undef MACHINE_32BIT +#undef MACHINE_64BIT + +#if UINTPTR_MAX == UINT32_MAX +#define MACHINE_32BIT +#elif UINTPTR_MAX == UINT64_MAX +#define MACHINE_64BIT +#elif UINTPTR_MAX == UINT16_MAX +#define MACHINE_16BIT +#endif + struct mhexdump_args { const void *data; size_t szdata; @@ -45,12 +57,17 @@ struct mhexdump_args { int closef; }; -#if SIZE_MAX == 0xffffffff +#if defined(MACHINE_32BIT) #define ADDRFMT "%08x: " #define paddr (mha->addaddr == 2 ? (uint32_t)P+(x*mha->group) : (x*mha->group)) -#else +#elif defined(MACHINE_64BIT) #define ADDRFMT "%016lx: " #define paddr (mha->addaddr == 2 ? (uint64_t)P+(x*mha->group) : (x*mha->group)) +#elif defined(MACHINE_16BIT) +#define ADDRFMT "%04x: " +#define paddr (mha->addaddr == 2 ? (uint16_t)P+(x*mha->group) : (x*mha->group)) +#else +#error No machine word size detected! #endif #define BYTEOUT ((unsigned char)P[y+(x*mha->group)])