summaryrefslogtreecommitdiff
path: root/gmp-h.in
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-06-17 00:50:39 +0200
committerKevin Ryde <user42@zip.com.au>2001-06-17 00:50:39 +0200
commitaad349c801dc7b017324dcd44507a4c36040dca4 (patch)
tree92ed72db1e44af7e4d9f6d291b859d06d30afd06 /gmp-h.in
parent77d325583e1d61f4b46f547fca55d649ea3b6602 (diff)
downloadgmp-aad349c801dc7b017324dcd44507a4c36040dca4.tar.gz
More of:
* gmp-h.in, gmp-impl.h: Move MPN_CMP to gmp.h as __GMPN_CMP, leave an MPN_CMP alias in gmp-impl.h. * gmp-h.in (mpn_cmp): Add an inline version. * mpn/generic/cmp.c: Use __GMP_FORCE_mpn_cmp to get code from gmp.h. Retain the comment about why simply "x-y" is not used.
Diffstat (limited to 'gmp-h.in')
-rw-r--r--gmp-h.in39
1 files changed, 20 insertions, 19 deletions
diff --git a/gmp-h.in b/gmp-h.in
index 126257340..b8fb0ea9d 100644
--- a/gmp-h.in
+++ b/gmp-h.in
@@ -1373,25 +1373,26 @@ mpf_size (mpf_srcptr f)
/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or
negative. size==0 is allowed. On random data usually only one limb will
need to be examined to get a result, so it's worth having it inline. */
-#define __GMPN_CMP(result, xp, yp, size) \
- do { \
- mp_size_t __i; \
- mp_limb_t __x, __y; \
- \
- /* ASSERT ((size) >= 0); */ \
- \
- (result) = 0; \
- __i = (size); \
- while (--__i >= 0) \
- { \
- __x = (xp)[__i]; \
- __y = (yp)[__i]; \
- if (__x != __y) \
- { \
- (result) = (__x > __y ? 1 : -1); \
- break; \
- } \
- } \
+#define __GMPN_CMP(result, xp, yp, size) \
+ do { \
+ mp_size_t __i; \
+ mp_limb_t __x, __y; \
+ \
+ /* ASSERT ((size) >= 0); */ \
+ \
+ (result) = 0; \
+ __i = (size); \
+ while (--__i >= 0) \
+ { \
+ __x = (xp)[__i]; \
+ __y = (yp)[__i]; \
+ if (__x != __y) \
+ { \
+ /* Cannot use __x - __y, may overflow an "int" */ \
+ (result) = (__x > __y ? 1 : -1); \
+ break; \
+ } \
+ } \
} while (0)
#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_cmp