]> Zhao Yanbai Git Server - minix.git/commitdiff
Make hexdump ACK-compilable and add it to the base system
authorErik van der Kouwe <erik@minix3.org>
Fri, 3 Sep 2010 07:37:31 +0000 (07:37 +0000)
committerErik van der Kouwe <erik@minix3.org>
Fri, 3 Sep 2010 07:37:31 +0000 (07:37 +0000)
commands/Makefile
commands/hexdump/display.c
commands/hexdump/hexdump.1
commands/hexdump/hexdump.h
commands/hexdump/parse.c

index 3f84bd2e8949c0f180a35fef15c2f45aba9fc1fb..f999cd57ea735f70c6476945c1947e35f2e818ec 100644 (file)
@@ -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 <bsd.subdir.mk>
index 54832f89bc51c0aa1c94820fd849ebf63f4c3412..2b1c91c716e467ef27ffb24884ff1654f5cde200 100644 (file)
@@ -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;
        }
index b415bddf2fe6dcd19b4cfc42686cf62e11ec5c44..c4684f218895b04e0a2932d36891f8a5270cd367 100644 (file)
@@ -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
index e3a086d979fb0249acfb0da4e73c977647f629f5..0b3dadcf511adc4eea4c834187c7001733b8530a 100644 (file)
@@ -68,6 +68,17 @@ typedef struct _fs {                 /* format strings */
        int bcnt;
 } FS;
 
+#ifdef __minix
+#define inline
+
+#ifndef __LONG_LONG_SUPPORTED
+#include <minix/u64.h>
+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 */
index cc786f9090ded05dade6c207a8aea3f5fc8b88de..f851615f52810e6b8ccc424cc8a6996717494f3d 100644 (file)
@@ -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;