From f22864c24e7aad3103e6e3ac2f6d8f86e3249b60 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sun, 25 Mar 2012 20:57:58 +0200 Subject: [PATCH] get rid of __LONG_LONG_SUPPORTED . also drop minix-specific code in libarchive that was needed for not supporting 64 bit ints --- commands/hexdump/display.c | 8 -- commands/hexdump/hexdump.h | 11 -- commands/hexdump/parse.c | 10 -- include/minix/ansi.h | 4 - include/minix/u64.h | 40 ------- .../archive_write_set_format_ustar.c | 113 +----------------- lib/libarchive/minix_utils.h | 7 -- lib/libminlib/u64util.c | 78 ------------ test/test45.c | 4 - test/test49.c | 2 - 10 files changed, 2 insertions(+), 275 deletions(-) delete mode 100644 lib/libarchive/minix_utils.h diff --git a/commands/hexdump/display.c b/commands/hexdump/display.c index 2b1c91c71..54832f89b 100644 --- a/commands/hexdump/display.c +++ b/commands/hexdump/display.c @@ -128,14 +128,10 @@ 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: @@ -175,12 +171,10 @@ 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: @@ -208,12 +202,10 @@ 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.h b/commands/hexdump/hexdump.h index 0b3dadcf5..e3a086d97 100644 --- a/commands/hexdump/hexdump.h +++ b/commands/hexdump/hexdump.h @@ -68,17 +68,6 @@ 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 f851615f5..cc786f909 100644 --- a/commands/hexdump/parse.c +++ b/commands/hexdump/parse.c @@ -194,11 +194,7 @@ 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; @@ -324,11 +320,9 @@ isint: case 2: pr->bcnt = 2; break; -#ifdef __LONG_LONG_SUPPORTED case 8: pr->bcnt = 8; break; -#endif default: p1[1] = '\0'; badcnt(p1); @@ -337,13 +331,9 @@ 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; diff --git a/include/minix/ansi.h b/include/minix/ansi.h index 7cb98a622..5a88913dc 100644 --- a/include/minix/ansi.h +++ b/include/minix/ansi.h @@ -9,10 +9,6 @@ #define _ANSI 31459 /* gcc conforms enough even in non-ANSI mode */ #endif -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 -#define __LONG_LONG_SUPPORTED 1 -#endif - /* Setting of _POSIX_SOURCE (or _NETBSD_SOURCE) in NBSD headers is * done in */ #include diff --git a/include/minix/u64.h b/include/minix/u64.h index f5619c771..466b73e3f 100644 --- a/include/minix/u64.h +++ b/include/minix/u64.h @@ -9,44 +9,6 @@ #include #endif -#if !defined(__LONG_LONG_SUPPORTED) - -u64_t add64(u64_t i, u64_t j); -u64_t add64u(u64_t i, unsigned j); -u64_t add64ul(u64_t i, unsigned long j); -u64_t sub64(u64_t i, u64_t j); -u64_t sub64u(u64_t i, unsigned j); -u64_t sub64ul(u64_t i, unsigned long j); -int bsr64(u64_t i); -unsigned diff64(u64_t i, u64_t j); -u64_t cvu64(unsigned i); -u64_t cvul64(unsigned long i); -unsigned cv64u(u64_t i); -unsigned long cv64ul(u64_t i); -u64_t div64(u64_t i, u64_t j); -unsigned long div64u(u64_t i, unsigned j); -u64_t div64u64(u64_t i, unsigned j); -u64_t rem64(u64_t i, u64_t j); -unsigned rem64u(u64_t i, unsigned j); -u64_t mul64(u64_t i, u64_t j); -u64_t mul64u(unsigned long i, unsigned j); -int cmp64(u64_t i, u64_t j); -int cmp64u(u64_t i, unsigned j); -int cmp64ul(u64_t i, unsigned long j); -unsigned long ex64lo(u64_t i); -unsigned long ex64hi(u64_t i); -u64_t make64(unsigned long lo, unsigned long hi); - -#define is_zero64(i) ((i).lo == 0 && (i).hi == 0) -#define make_zero64(i) do { (i).lo = (i).hi = 0; } while(0) - -#define neg64(i) do { \ - (i).lo = ~(i).lo; \ - (i).hi = ~(i).hi; \ - (i) = add64u((i), 1); \ - } while(0) -#else - #include #define is_zero64(i) ((i) == 0) @@ -209,8 +171,6 @@ static inline u64_t sub64ul(u64_t i, unsigned long j) return i - j; } -#endif - u64_t rrotate64(u64_t x, unsigned short b); u64_t rshift64(u64_t x, unsigned short b); u64_t xor64(u64_t a, u64_t b); diff --git a/lib/libarchive/archive_write_set_format_ustar.c b/lib/libarchive/archive_write_set_format_ustar.c index 7a3a73de3..1de273fc2 100644 --- a/lib/libarchive/archive_write_set_format_ustar.c +++ b/lib/libarchive/archive_write_set_format_ustar.c @@ -43,21 +43,11 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_ustar.c 191579 #include "archive_private.h" #include "archive_write_private.h" -#ifdef __minix -#include "minix_utils.h" -#endif - -#ifndef __minix struct ustar { uint64_t entry_bytes_remaining; uint64_t entry_padding; }; -#else -struct ustar { - size_t entry_bytes_remaining; - off_t entry_padding; -}; -#endif + /* * Define structure of POSIX 'ustar' tar header. */ @@ -158,15 +148,9 @@ static int archive_write_ustar_finish(struct archive_write *); static int archive_write_ustar_finish_entry(struct archive_write *); static int archive_write_ustar_header(struct archive_write *, struct archive_entry *entry); -#ifndef __minix static int format_256(int64_t, char *, int); static int format_number(int64_t, char *, int size, int max, int strict); static int format_octal(int64_t, char *, int); -#else -static int format_256(int32_t, char *, int); -static int format_number(int32_t, char *, int size, int max, int strict); -static int format_octal(int32_t, char *, int); -#endif static int write_nulls(struct archive_write *a, size_t); /* @@ -255,11 +239,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry) ret = ret2; ustar->entry_bytes_remaining = archive_entry_size(entry); -#ifndef __minix ustar->entry_padding = 0x1ff & (-(int64_t)ustar->entry_bytes_remaining); -#else - ustar->entry_padding = 0x1ff & (-(int32_t)ustar->entry_bytes_remaining); -#endif return (ret); } @@ -460,7 +440,6 @@ __archive_write_format_header_ustar(struct archive_write *a, char h[512], /* * Format a number into a field, with some intelligence. */ -#ifndef __minix static int format_number(int64_t v, char *p, int s, int maxsize, int strict) { @@ -490,54 +469,10 @@ format_number(int64_t v, char *p, int s, int maxsize, int strict) /* Base-256 can handle any number, positive or negative. */ return (format_256(v, p, maxsize)); } -#else -static int -format_number(int32_t v, char *p, int s, int maxsize, int strict) -{ - /* s could be 11 in some cases causing limit to be shifted by - * greater than 32 bits so we need a u64_t here - */ - u64_t limit; - -#if !defined(__LONG_LONG_SUPPORTED) - limit = lshift64(cvu64(1), s*3); -#else - limit = (1ull << (s*3)); -#endif - - /* "Strict" only permits octal values with proper termination. */ - if (strict) - return (format_octal(v, p, s)); - - /* - * In non-strict mode, we allow the number to overwrite one or - * more bytes of the field termination. Even old tar - * implementations should be able to handle this with no - * problem. - */ - if (v >= 0) { - while (s <= maxsize) { - /* if (v < limit) */ - if (cmp64ul(limit, v) > 0) - return (format_octal(v, p, s)); - s++; -#if !defined(__LONG_LONG_SUPPORTED) - limit = lshift64(limit, 3); -#else - limit <<= 3; -#endif - } - } - - /* Base-256 can handle any number, positive or negative. */ - return (format_256(v, p, maxsize)); -} -#endif /* * Format a number into the specified field using base-256. */ -#ifndef __minix static int format_256(int64_t v, char *p, int s) { @@ -549,23 +484,10 @@ format_256(int64_t v, char *p, int s) *p |= 0x80; /* Set the base-256 marker bit. */ return (0); } -#else -static int -format_256(int32_t v, char *p, int s) -{ - p += s; - while (s-- > 0) { - *--p = (char)(v & 0xff); - v >>= 8; - } - *p |= 0x80; /* Set the base-256 marker bit. */ - return (0); -} -#endif + /* * Format a number into the specified field. */ -#ifndef __minix static int format_octal(int64_t v, char *p, int s) { @@ -595,37 +517,6 @@ format_octal(int64_t v, char *p, int s) return (-1); } -#else -static int -format_octal(int32_t v, char *p, int s) -{ - int len; - - len = s; - - /* Octal values can't be negative, so use 0. */ - if (v < 0) { - while (len-- > 0) - *p++ = '0'; - return (-1); - } - - p += s; /* Start at the end and work backwards. */ - while (s-- > 0) { - *--p = (char)('0' + (v & 7)); - v >>= 3; - } - - if (v == 0) - return (0); - - /* If it overflowed, fill field with max value. */ - while (len-- > 0) - *p++ = '7'; - - return (-1); -} -#endif static int archive_write_ustar_finish(struct archive_write *a) diff --git a/lib/libarchive/minix_utils.h b/lib/libarchive/minix_utils.h deleted file mode 100644 index 41c57e4e7..000000000 --- a/lib/libarchive/minix_utils.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef MINIX_UTILS_H -#define MINIX_UTILS_H -#include -#if !defined(__LONG_LONG_SUPPORTED) -u64_t lshift64(u64_t x, unsigned short b); -#endif -#endif diff --git a/lib/libminlib/u64util.c b/lib/libminlib/u64util.c index 05b8436c8..bcddb067f 100644 --- a/lib/libminlib/u64util.c +++ b/lib/libminlib/u64util.c @@ -3,82 +3,6 @@ */ #include -#if !defined(__LONG_LONG_SUPPORTED) -u64_t rrotate64(u64_t x, unsigned short b) -{ - u64_t r, t; - - b %= 64; - - if(b == 32) { - r.lo = x.hi; - r.hi = x.lo; - return r; - }else if(b < 32) { - r.lo = (x.lo >> b) | (x.hi << (32 - b)); - r.hi = (x.hi >> b) | (x.lo << (32 - b)); - return r; - }else { - /* Rotate by 32 bits first then rotate by remaining */ - t.lo = x.hi; - t.hi = x.lo; - b = b - 32; - r.lo = (t.lo >> b) | (t.hi << (32 - b)); - r.hi = (t.hi >> b) | (t.lo << (32 - b)); - return r; - } -} - -u64_t rshift64(u64_t x, unsigned short b) -{ - u64_t r; - - if(b >= 64) - return make64(0,0); - - if(b >= 32) { - r.hi = 0; - r.lo = x.hi >> (b - 32); - }else { - r.lo = (x.lo >> b) | (x.hi << (32 - b)); - r.hi = (x.hi >> b); - } - return r; -} - -u64_t xor64(u64_t a, u64_t b) -{ - u64_t r; - r.hi = a.hi ^ b.hi; - r.lo = a.lo ^ b.lo; - - return r; -} - -u64_t and64(u64_t a, u64_t b) -{ - u64_t r; - r.hi = a.hi & b.hi; - r.lo = a.lo & b.lo; - - return r; -} - -u64_t not64(u64_t a) -{ - u64_t r; - - r.hi = ~a.hi; - r.lo = ~a.lo; - - return r; -} -#else - -#if !defined(__LONG_LONG_SUPPORTED) -#error "ERROR: These functions require long long support" -#endif - u64_t rrotate64(u64_t x, unsigned short b) { b %= 64; @@ -108,5 +32,3 @@ u64_t not64(u64_t a) { return ~a; } -#endif - diff --git a/test/test45.c b/test/test45.c index 65720f9f0..66e04c550 100644 --- a/test/test45.c +++ b/test/test45.c @@ -29,8 +29,6 @@ #undef TYPEU #undef TYPE_FUNC -#ifdef __LONG_LONG_SUPPORTED - /* test strtoll */ #define TYPE long long #define TYPEU unsigned long long @@ -49,8 +47,6 @@ #undef TYPEU #undef TYPE_FUNC -#endif /* defined(__LONG_LONG_SUPPORTED) */ - int main(int argc, char **argv) { start(45); diff --git a/test/test49.c b/test/test49.c index 7c0d28dd4..1fcbeefe2 100755 --- a/test/test49.c +++ b/test/test49.c @@ -6,9 +6,7 @@ #include #include -#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64) #define TEST_64_BIT -#endif #define ERR e(__LINE__)