diff options
author | sbruno <sbruno@FreeBSD.org> | 2014-07-24 19:06:15 +0000 |
---|---|---|
committer | sbruno <sbruno@FreeBSD.org> | 2014-07-24 19:06:15 +0000 |
commit | 68a15d81dea2e28ae62170e5a4e23d200d0c3e9f (patch) | |
tree | 1d1dc574d179b50c59a299f8b35cfedb315d7b90 /lib/libstand/quad.h | |
parent | ff70733f8afcb62d47a9060dd77cbfda92924d6e (diff) | |
download | FreeBSD-src-68a15d81dea2e28ae62170e5a4e23d200d0c3e9f.zip FreeBSD-src-68a15d81dea2e28ae62170e5a4e23d200d0c3e9f.tar.gz |
libstand's qdivrem.c assumes that sizeof(int) == sizeof(long), this is not
true on amd64 I'm not quite positive this is the "correct" solution for
this but it does seem to compile and shut up the spew of warnings when
compiling libstand for userboot.
Add two _Static_asserts() so that in the future somebody will get a compile
failure if an architecture develops that violates the assumptions of this
code. (strongly suggested by jmg)
Change commetns to indicate int types instead of long. (noted by ian in
phabric review)
Phabric: https://phabric.freebsd.org/D443
Diffstat (limited to 'lib/libstand/quad.h')
-rw-r--r-- | lib/libstand/quad.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libstand/quad.h b/lib/libstand/quad.h index 0ff27ff..349540a 100644 --- a/lib/libstand/quad.h +++ b/lib/libstand/quad.h @@ -54,6 +54,9 @@ #include <sys/types.h> #include <limits.h> +_Static_assert(sizeof(quad_t) == sizeof(int) * 2, + "Bitwise function in libstand are broken on this architecture\n"); + /* * Depending on the desired operation, we view a `long long' (aka quad_t) in * one or more of the following formats. @@ -61,8 +64,8 @@ union uu { quad_t q; /* as a (signed) quad */ quad_t uq; /* as an unsigned quad */ - long sl[2]; /* as two signed longs */ - u_long ul[2]; /* as two unsigned longs */ + int sl[2]; /* as two signed ints */ + u_int ul[2]; /* as two unsigned ints */ }; /* @@ -77,8 +80,7 @@ union uu { * and assembly. */ #define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) -#define LONG_BITS (sizeof(long) * CHAR_BIT) -#define HALF_BITS (sizeof(long) * CHAR_BIT / 2) +#define HALF_BITS (sizeof(int) * CHAR_BIT / 2) /* * Extract high and low shortwords from longword, and move low shortword of |