From 18ad0b52d3592360bcbef9845589a489c839da4a Mon Sep 17 00:00:00 2001 From: Erik van der Kouwe Date: Fri, 3 Sep 2010 07:37:31 +0000 Subject: [PATCH] Make hexdump ACK-compilable and add it to the base system --- commands/Makefile | 7 +------ commands/hexdump/display.c | 8 ++++++++ commands/hexdump/hexdump.1 | 4 ++++ commands/hexdump/hexdump.h | 11 +++++++++++ commands/hexdump/parse.c | 10 ++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/commands/Makefile b/commands/Makefile index 3f84bd2e8..f999cd57e 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -12,7 +12,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \ dhrystone diff dirname dis88 diskctl du dumpcore \ ed eject elle elvis env expand factor file \ find finger fingerd fix fold format fortune fsck.mfs \ - fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head host \ + fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head hexdump host \ hostaddr id ifconfig ifdef indent install \ intr ipcrm ipcs irdpd isoread join kill last leave \ less lex life loadkeys loadramdisk logger login look lp \ @@ -41,9 +41,4 @@ SUBDIR+= atnormalize dosread fdisk loadfont \ SUBDIR+= acd asmconv gas2ack .endif -# Build only with clang and GCC -.if ${COMPILER_TYPE} == "gnu" -SUBDIR+= hexdump -.endif - .include diff --git a/commands/hexdump/display.c b/commands/hexdump/display.c index 54832f89b..2b1c91c71 100644 --- a/commands/hexdump/display.c +++ b/commands/hexdump/display.c @@ -128,10 +128,14 @@ print(PR *pr, u_char *bp) float f4; int16_t s2; int32_t s4; +#ifdef __LONG_LONG_SUPPORTED int64_t s8; +#endif uint16_t u2; uint32_t u4; +#ifdef __LONG_LONG_SUPPORTED uint64_t u8; +#endif switch(pr->flags) { case F_ADDRESS: @@ -171,10 +175,12 @@ print(PR *pr, u_char *bp) memmove(&s4, bp, sizeof(s4)); (void)printf(pr->fmt, (int64_t)s4); break; +#ifdef __LONG_LONG_SUPPORTED case 8: memmove(&s8, bp, sizeof(s8)); (void)printf(pr->fmt, (int64_t)s8); break; +#endif } break; case F_P: @@ -202,10 +208,12 @@ print(PR *pr, u_char *bp) memmove(&u4, bp, sizeof(u4)); (void)printf(pr->fmt, (uint64_t)u4); break; +#ifdef __LONG_LONG_SUPPORTED case 8: memmove(&u8, bp, sizeof(u8)); (void)printf(pr->fmt, (uint64_t)u8); break; +#endif } break; } diff --git a/commands/hexdump/hexdump.1 b/commands/hexdump/hexdump.1 index b415bddf2..c4684f218 100644 --- a/commands/hexdump/hexdump.1 +++ b/commands/hexdump/hexdump.1 @@ -310,6 +310,10 @@ option. .Pp .Nm exits 0 on success and \*[Gt]0 if an error occurred. +.Sh MINIX-SPECIFIC notes +If hexdump is compiled on a compiler that does not support long long (that is, +ACK), 64-bit (8 byte) integer formats are not supported. Conversions where this +is the default are changed to use a 32-bit 4 byte) default instead. .Sh EXAMPLES Display the input in perusal format: .Bd -literal -offset indent diff --git a/commands/hexdump/hexdump.h b/commands/hexdump/hexdump.h index e3a086d97..0b3dadcf5 100644 --- a/commands/hexdump/hexdump.h +++ b/commands/hexdump/hexdump.h @@ -68,6 +68,17 @@ typedef struct _fs { /* format strings */ int bcnt; } FS; +#ifdef __minix +#define inline + +#ifndef __LONG_LONG_SUPPORTED +#include +typedef long int64_t; +typedef unsigned long uint64_t; +#define PRId64 "ld" +#endif +#endif + enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */ extern int blocksize; /* data block size */ diff --git a/commands/hexdump/parse.c b/commands/hexdump/parse.c index cc786f909..f851615f5 100644 --- a/commands/hexdump/parse.c +++ b/commands/hexdump/parse.c @@ -194,7 +194,11 @@ size(FS *fs) bcnt += 4; break; case 'e': case 'E': case 'f': case 'g': case 'G': +#ifdef __LONG_LONG_SUPPORTED bcnt += 8; +#else + bcnt += 4; +#endif break; case 's': bcnt += prec; @@ -320,9 +324,11 @@ isint: case 2: pr->bcnt = 2; break; +#ifdef __LONG_LONG_SUPPORTED case 8: pr->bcnt = 8; break; +#endif default: p1[1] = '\0'; badcnt(p1); @@ -331,9 +337,13 @@ isint: case 'e': case 'E': case 'f': case 'g': case 'G': pr->flags = F_DBL; switch(fu->bcnt) { +#ifdef __LONG_LONG_SUPPORTED case 0: case 8: pr->bcnt = 8; break; +#else + case 0: +#endif case 4: pr->bcnt = 4; break;