GCC/clang: int64 routines in C

This commit is contained in:
Arun Thomas
2010-11-12 18:38:10 +00:00
parent afeb246328
commit f0ab18377d
14 changed files with 411 additions and 13 deletions

View File

@@ -69,7 +69,9 @@ typedef u8_t u_int8_t; /* 1-byte (8-bits) */
typedef u32_t u_int32_t; /* 4-bytes (32-bits) */
typedef u64_t u_int64_t; /* 8-bytes (64-bits) */
#if !defined(__LONG_LONG_SUPPORTED)
#define MINIX_64BIT 1
#endif
#define SHA2_BYTE_ORDER 0x04030201
#define SHA2_LITTLE_ENDIAN 0x04030201

View File

@@ -26,10 +26,18 @@ typedef unsigned long u32_t; /* 32 bit type */
typedef long i32_t; /* 32 bit signed type */
#endif
#if !defined(__LONG_LONG_SUPPORTED)
typedef struct {
u32_t lo;
u32_t hi;
} u64_t;
#else
#if __SIZEOF_LONG__ > 4
typedef unsigned long u64_t;
#else
typedef unsigned long long u64_t;
#endif
#endif
/* some Minix specific types that do not conflict with posix */
typedef u32_t zone_t; /* zone number */

View File

@@ -40,6 +40,7 @@ u64_t xor64(u64_t a, u64_t b);
u64_t and64(u64_t a, u64_t b);
u64_t not64(u64_t a);
#if !defined(__LONG_LONG_SUPPORTED)
#define is_zero64(i) ((i).lo == 0 && (i).hi == 0)
#define make_zero64(i) do { (i).lo = (i).hi = 0; } while(0)
@@ -48,5 +49,10 @@ u64_t not64(u64_t a);
(i).hi = ~(i).hi; \
(i) = add64u((i), 1); \
} while(0)
#else
#define is_zero64(i) ((i) == 0)
#define make_zero64(i) ((i) = 0)
#define neg64(i) ((i) = -(i))
#endif
#endif /* _MINIX__U64_H */