projects
/
tfcrypt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2666891
)
fix mhexdump machine detection.
author
Andrey Rys
<rys@lynxlynx.ru>
Thu, 21 Mar 2019 09:27:16 +0000
(16:27 +0700)
committer
Andrey Rys
<rys@lynxlynx.ru>
Thu, 21 Mar 2019 09:34:47 +0000
(16:34 +0700)
VERSION
patch
|
blob
|
history
mhexdump.c
patch
|
blob
|
history
diff --git
a/VERSION
b/VERSION
index b6a7d89c68e0ca66e96a9a51892cc33db66fb8a3..98d9bcb75a685dfbfd60f611c309410152935b3d 100644
(file)
--- a/
VERSION
+++ b/
VERSION
@@
-1
+1
@@
-1
6
+1
7
diff --git
a/mhexdump.c
b/mhexdump.c
index 5d927f7aac615e9da078ef13840084000d0dce6c..f8e13005c53c95f970549d494d439e999383477f 100644
(file)
--- a/
mhexdump.c
+++ b/
mhexdump.c
@@
-33,6
+33,18
@@
#include <ctype.h>
#include <stdint.h>
#include <ctype.h>
#include <stdint.h>
+#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;
struct mhexdump_args {
const void *data;
size_t szdata;
@@
-45,12
+57,17
@@
struct mhexdump_args {
int closef;
};
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))
#define ADDRFMT "%08x: "
#define paddr (mha->addaddr == 2 ? (uint32_t)P+(x*mha->group) : (x*mha->group))
-#el
se
+#el
if defined(MACHINE_64BIT)
#define ADDRFMT "%016lx: "
#define paddr (mha->addaddr == 2 ? (uint64_t)P+(x*mha->group) : (x*mha->group))
#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)])
#endif
#define BYTEOUT ((unsigned char)P[y+(x*mha->group)])