get rid of __LONG_LONG_SUPPORTED

. also drop minix-specific code in libarchive
	  that was needed for not supporting 64 bit ints
This commit is contained in:
Ben Gras 2012-03-25 20:57:58 +02:00
parent 23df780120
commit f22864c24e
10 changed files with 2 additions and 275 deletions

View file

@ -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;
}

View file

@ -68,17 +68,6 @@ 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 */

View file

@ -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;

View file

@ -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 <sys/featuretest.h> */
#include <sys/featuretest.h>

View file

@ -9,44 +9,6 @@
#include <minix/types.h>
#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 <limits.h>
#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);

View file

@ -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)

View file

@ -1,7 +0,0 @@
#ifndef MINIX_UTILS_H
#define MINIX_UTILS_H
#include <minix/u64.h>
#if !defined(__LONG_LONG_SUPPORTED)
u64_t lshift64(u64_t x, unsigned short b);
#endif
#endif

View file

@ -3,82 +3,6 @@
*/
#include <minix/u64.h>
#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

View file

@ -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);

View file

@ -6,9 +6,7 @@
#include <string.h>
#include <unistd.h>
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
#define TEST_64_BIT
#endif
#define ERR e(__LINE__)