#ifndef _CL_DS_H
#define _CL_DS_H
-#include "cl_types.h"
+#include "cln/types.h"
#include "cl_gmpconfig.h"
#include "cl_D.h"
#include "cl_DS_endian.h"
#include "cl_alloca.h"
+namespace cln {
+
// Digit Sequence (DS)
// a memory range with n digits (n an uintC),
// between two pointers MSDptr and LSDptr.
// Supersede the functions by wrappers around calls to gmp mpn,
// for those functions where gmp is believed to be faster.
+extern "C" {
#include <gmp.h>
+}
#if 0 // not worth it, since gmp's mpn_cmp is not optimized
inline cl_signean compare_loop_down (const uintD* xptr, const uintD* yptr, uintC count)
#define MUL_LOOPS
+inline uintD divu_loop_up (uintD digit, uintD* ptr, uintC len)
+{
+ return mpn_divrem_1(ptr,0,ptr,len,digit);
+}
+
+inline uintD divu_loop_down (uintD digit, uintD* ptr, uintC len)
+{
+ return mpn_divrem_1(ptr-len,0,ptr-len,len,digit);
+}
+
+inline uintD divucopy_loop_up (uintD digit, const uintD* sourceptr, uintD* destptr, uintC len)
+{
+ return mpn_divrem_1(destptr,0,sourceptr,len,digit);
+}
+
+inline uintD divucopy_loop_down (uintD digit, const uintD* sourceptr, uintD* destptr, uintC len)
+{
+ return mpn_divrem_1(destptr-len,0,sourceptr-len,len,digit);
+}
+
+#define DIV_LOOPS
+
#endif // defined(CL_USE_GMP)
extern void cl_UDS_recipsqrt (const uintD* a_MSDptr, uintC a_len,
uintD* b_MSDptr, uintC b_len);
+} // namespace cln
#endif /* _CL_DS_H */