* include/cln/exception.h: New file...
* include/cln/cln.h: ...included here...
* include/cln/rational.h: ...and here.
* include/cln/abort.h: Removed.
* include/cln/integer.h (ash_exception, exquo_exception): Add exception
types.
* include/cln/float.h (floating_point_exception,
floating_point_nan_exception, floating_point_overflow_exception,
floating_point_underflow_exception): Likewise.
* include/cln/number_io.h (read_number_exception,
read_number_bad_syntax_exception, read_number_junk_exception,
read_number_eof_exception): Likewise.
* include/cln/object.h (CL_DEFINE_CONVERTER): Replace dynamic assertion
with a compile-time assertion.
* include/cln/GV.h: Replace nonreturning functions with exceptions.
* include/cln/modinteger.h: Likewise.
* include/cln/SV.h: Likewise.
* include/cln/ring.h: Likewise.
* include/cln/string.h: Likewise.
* include/cln/univpoly.h: Likewise.
* src/base/cl_abort.cc: Removed.
* src/base/cl_N_err_d0.cc: Removed.
* src/base/cl_d0_exception.cc: New file.
* src/base/cl_as_err.cc: Removed.
* src/base/cl_as_exception.cc: New file.
* src/base/cl_notreached.cc: Removed.
* src/base/cl_notreached_exception.cc: New file.
* src/base/input/cl_read_err_bad.cc: Removed.
* src/base/input/cl_read_bad_syntax_exception.cc: New file.
* src/base/input/cl_read_err_junk.cc: Removed.
* src/base/input/cl_read_junk_exception.cc: New file.
* src/base/input/cl_read_err_eof.cc: Removed.
* src/base/input/cl_read_eof_exception.cc: New file.
* src/base/cl_N.h (cl_as_error): Removed (see cln/exception.h).
* src/base/macros.h (NOTREACHED): Throw.
* src/base/cl_malloc.cc (xmalloc): Throw.
* src/base/digitseq/cl_2DS_div.cc: Throw.
* src/base/digitseq/cl_DS_div.cc: Throw.
* src/base/digitseq/cl_DS_mul.cc: Throw.
* src/base/digitseq/cl_DS_mul_fftc.h: Throw.
* src/base/digitseq/cl_DS_mul_fftcs.h: Throw.
* src/base/digitseq/cl_DS_mul_fftm.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp3.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp3m.h: Throw.
* src/base/digitseq/cl_DS_mul_fftr.h: Throw.
* src/base/digitseq/cl_DS_mul_nuss.h: Throw.
* src/base/digitseq/cl_DS_recipsqrt.cc: Throw.
* src/base/digitseq/cl_DS_sqrt.cc: Throw.
* src/base/hash/cl_hash.h: Throw.
* src/base/hash/cl_hash1.h: Throw.
* src/base/hash/cl_hash1weak.h: Throw.
* src/base/hash/cl_hash2.h: Throw.
* src/base/hash/cl_hash2weak.h: Throw.
* src/base/hash/cl_hashset.h: Throw.
* src/base/hash/cl_hashuniq.h: Throw.
* src/base/hash/cl_hashuniqweak.h: Throw.
* src/base/proplist/cl_pl_add.cc: Throw.
* src/base/ring/cl_no_ring.cc: Throw.
* src/base/string/cl_spushstring.h: Throw.
* src/base/symbol/cl_symbol.cc: Throw.
* src/integer/bitwise/cl_I_ash.h: Removed (see cln/integer.h.)
* src/integer/bitwise/cl_I_asherr.cc: Removed.
* src/integer/bitwise/cl_I_ash_exception.cc: New file.
* src/integer/division/cl_I_exquoerr.cc: Removed.
* src/integer/division/cl_I_exquo_exception.cc: New file.
* src/integer/cl_I.h: Throw.
* src/integer/division/cl_I_exquopos.cc: Throw.
* src/integer/bitwise/cl_I_logbitp_I.cc: Throw.
* src/integer/bitwise/cl_I_ash.cc: Throw.
* src/integer/bitwise/cl_I_ash_I.cc: Throw.
* src/integer/division/cl_I_exquo.cc: Throw.
* src/integer/gcd/cl_I_gcd_aux2.cc: Throw.
* src/integer/conv/cl_I_to_L.cc: Throw.
* src/integer/conv/cl_I_to_Q.cc: Throw.
* src/integer/conv/cl_I_to_UL.cc: Throw.
* src/integer/conv/cl_I_to_UQ.cc: Throw.
* src/integer/conv/cl_I_to_digits.cc: Throw.
* src/integer/elem/cl_I_div.cc: Throw.
* src/integer/algebraic/cl_I_sqrt.cc: Throw.
* src/integer/input/cl_I_read.cc: Throw.
* src/integer/input/cl_I_read_stream.cc: Throw.
* src/integer/misc/cl_I_as.cc: Throw.
* src/rational/elem/cl_RA_from_I_I_div.cc: Throw.
* src/rational/elem/cl_RA_recip.cc: Throw.
* src/rational/input/cl_RA_read.cc: Throw.
* src/rational/input/cl_RA_read_stream.cc: Throw.
* src/rational/input/cl_RA_readparsed.cc: Throw.
* src/rational/misc/cl_RA_as.cc: Throw.
* src/float/base/cl_F_err_nan.cc: Removed.
* src/float/base/cl_F_nan_exception.cc: New file.
* src/float/base/cl_F_err_un.cc: Removed.
* src/float/base/cl_F_underflow_exception.cc: New file.
* src/float/base/cl_F_err_ov.cc: Removed.
* src/float/base/cl_F_overflow_exception.cc: New file.
* src/float/cl_F.h (cl_error_floating_point_nan,
cl_error_floating_point_overflow, cl_error_floating_point_underflow):
Removed (see cln/float.h.)
* src/float/sfloat/cl_SF.h: Throw.
* src/float/sfloat/elem/cl_SF_div.cc: Throw.
* src/float/sfloat/elem/cl_SF_from_RA.cc: Throw.
* src/float/sfloat/elem/cl_SF_scale.cc: Throw.
* src/float/sfloat/elem/cl_SF_scale_I.cc: Throw.
* src/float/sfloat/misc/cl_SF_as.cc: Throw.
* src/float/ffloat/cl_FF.h: Throw.
* src/float/ffloat/conv/cl_FF_from_float.cc: Throw.
* src/float/ffloat/elem/cl_FF_div.cc: Throw.
* src/float/ffloat/elem/cl_FF_from_RA.cc: Throw.
* src/float/ffloat/elem/cl_FF_scale.cc: Throw.
* src/float/ffloat/elem/cl_FF_scale_I.cc: Throw.
* src/float/ffloat/misc/cl_FF_as.cc: Throw.
* src/float/dfloat/cl_DF.h: Throw.
* src/float/dfloat/conv/cl_DF_from_double.cc: Throw.
* src/float/dfloat/elem/cl_DF_div.cc: Throw.
* src/float/dfloat/elem/cl_DF_from_RA.cc: Throw.
* src/float/dfloat/elem/cl_DF_scale.cc: Throw.
* src/float/dfloat/elem/cl_DF_scale_I.cc: Throw.
* src/float/dfloat/misc/cl_DF_as.cc: Throw.
* src/float/lfloat/algebraic/cl_LF_sqrt.cc: Throw.
* src/float/lfloat/elem/cl_LF_1plus.cc: Throw.
* src/float/lfloat/elem/cl_LF_I_div.cc: Throw.
* src/float/lfloat/elem/cl_LF_I_mul.cc: Throw.
* src/float/lfloat/elem/cl_LF_div.cc: Throw.
* src/float/lfloat/elem/cl_LF_from_I.cc: Throw.
* src/float/lfloat/elem/cl_LF_mul.cc: Throw.
* src/float/lfloat/elem/cl_LF_scale.cc: Throw.
* src/float/lfloat/elem/cl_LF_scale_I.cc: Throw.
* src/float/lfloat/elem/cl_LF_square.cc: Throw.
* src/float/lfloat/misc/cl_LF_as.cc: Throw.
* src/float/lfloat/misc/cl_LF_shorten.cc: Throw.
* src/float/lfloat/misc/cl_LF_shortenrel.cc: Throw.
* src/float/lfloat/misc/cl_LF_shortenwith.cc: Throw.
* src/float/input/cl_F_read.cc: Throw.
* src/float/input/cl_F_read_stream.cc: Throw.
* src/float/misc/cl_F_as.cc: Throw.
* src/float/misc/cl_F_shortenrel.cc: Throw.
* src/float/transcendental/cl_LF_coshsinh_aux.cc: Throw.
* src/float/transcendental/cl_LF_cossin_aux.cc: Throw.
* src/float/transcendental/cl_LF_exp_aux.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_a.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_ab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_b.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_p.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pq.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_q.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pq.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqb.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqd.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc: Throw.
* src/float/transcendental/cl_LF_zeta_int.cc: Throw.
* src/real/elem/cl_R_div.cc: Throw.
* src/real/format-output/cl_fmt_cardinal.cc: Throw.
* src/real/format-output/cl_fmt_newroman.cc: Throw.
* src/real/format-output/cl_fmt_oldroman.cc: Throw.
* src/real/input/cl_R_read.cc: Throw.
* src/real/input/cl_R_read_stream.cc: Throw.
* src/real/misc/cl_R_as.cc: Throw.
* src/real/random/cl_R_random.cc: Throw.
* src/real/transcendental/cl_R_atan2.cc: Throw.
* src/real/transcendental/cl_R_log.cc: Throw.
* src/complex/input/cl_N_read.cc: Throw.
* src/complex/input/cl_N_read_stream.cc: Throw.
* src/complex/misc/cl_N_as.cc: Throw.
* src/complex/transcendental/cl_C_atanh_aux.cc: Throw.
* src/complex/transcendental/cl_C_expt_C.cc: Throw.
* src/complex/transcendental/cl_C_log.cc: Throw.
* src/complex/transcendental/cl_C_log2.cc: Throw.
* src/numtheory/cl_nt_cornacchia1.cc: Throw.
* src/numtheory/cl_nt_cornacchia4.cc: Throw.
* src/numtheory/cl_nt_isprobprime.cc: Throw.
* src/numtheory/cl_nt_jacobi.cc: Throw.
* src/numtheory/cl_nt_jacobi_low.cc: Throw.
* src/numtheory/cl_nt_sqrtmodp.cc: Throw.
* src/modinteger/cl_MI.cc: Throw.
* src/modinteger/cl_MI_int.h: Throw.
* src/modinteger/cl_MI_montgom.h: Throw.
* src/modinteger/cl_MI_pow2.h: Throw.
* src/modinteger/cl_MI_rshift.cc: Throw.
* src/modinteger/cl_MI_std.h: Throw.
* src/polynomial/elem/cl_UP_GF2.h: Throw.
* src/polynomial/elem/cl_UP_MI.h: Throw.
* src/polynomial/elem/cl_UP_gen.h: Throw.
* src/polynomial/elem/cl_UP_named.cc: Throw.
* src/polynomial/elem/cl_UP_no_ring.cc (uninitialized_error,
uninitialized_ring): Removed (see cln/ring.h.)
* src/polynomial/elem/cl_UP_number.h: Throw.
* src/polynomial/elem/cl_UP_unnamed.cc: Throw.
* src/vector/cl_GV_I.cc: Throw.
* src/vector/cl_GV_number.cc: Throw.
* tests/timediv2adic-compare.cc: Use default abort(), not cl_abort().
* tests/timeprint-compare.cc: Likewise.
* tests/timerecip2adic-compare.cc: Likewise.
* doc/cln.tex: Document the exception classes.
* examples/contfrac.cc: Use try/catch instead of setjmp/longjmp.
* INSTALL: undocument -fno-exceptions.
* README: Add exceptions to list of used C++ features.
+2007-07-28 Richard B. Kreckel <kreckel@ginac.de>
+
+ Remove exception hooks in favor of real C++ exceptions:
+ * include/cln/exception.h: New file...
+ * include/cln/cln.h: ...included here...
+ * include/cln/rational.h: ...and here.
+ * include/cln/abort.h: Removed.
+ * include/cln/integer.h (ash_exception, exquo_exception): Add exception
+ types.
+ * include/cln/float.h (floating_point_exception,
+ floating_point_nan_exception, floating_point_overflow_exception,
+ floating_point_underflow_exception): Likewise.
+ * include/cln/number_io.h (read_number_exception,
+ read_number_bad_syntax_exception, read_number_junk_exception,
+ read_number_eof_exception): Likewise.
+ * include/cln/object.h (CL_DEFINE_CONVERTER): Replace dynamic assertion
+ with a compile-time assertion.
+ * include/cln/GV.h: Replace nonreturning functions with exceptions.
+ * include/cln/modinteger.h: Likewise.
+ * include/cln/SV.h: Likewise.
+ * include/cln/ring.h: Likewise.
+ * include/cln/string.h: Likewise.
+ * include/cln/univpoly.h: Likewise.
+ * src/base/cl_abort.cc: Removed.
+ * src/base/cl_N_err_d0.cc: Removed.
+ * src/base/cl_d0_exception.cc: New file.
+ * src/base/cl_as_err.cc: Removed.
+ * src/base/cl_as_exception.cc: New file.
+ * src/base/cl_notreached.cc: Removed.
+ * src/base/cl_notreached_exception.cc: New file.
+ * src/base/input/cl_read_err_bad.cc: Removed.
+ * src/base/input/cl_read_bad_syntax_exception.cc: New file.
+ * src/base/input/cl_read_err_junk.cc: Removed.
+ * src/base/input/cl_read_junk_exception.cc: New file.
+ * src/base/input/cl_read_err_eof.cc: Removed.
+ * src/base/input/cl_read_eof_exception.cc: New file.
+ * src/base/cl_N.h (cl_as_error): Removed (see cln/exception.h).
+ * src/base/macros.h (NOTREACHED): Throw.
+ * src/base/cl_malloc.cc (xmalloc): Throw.
+ * src/base/digitseq/cl_2DS_div.cc: Throw.
+ * src/base/digitseq/cl_DS_div.cc: Throw.
+ * src/base/digitseq/cl_DS_mul.cc: Throw.
+ * src/base/digitseq/cl_DS_mul_fftc.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftcs.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftm.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftp.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftp3.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftp3m.h: Throw.
+ * src/base/digitseq/cl_DS_mul_fftr.h: Throw.
+ * src/base/digitseq/cl_DS_mul_nuss.h: Throw.
+ * src/base/digitseq/cl_DS_recipsqrt.cc: Throw.
+ * src/base/digitseq/cl_DS_sqrt.cc: Throw.
+ * src/base/hash/cl_hash.h: Throw.
+ * src/base/hash/cl_hash1.h: Throw.
+ * src/base/hash/cl_hash1weak.h: Throw.
+ * src/base/hash/cl_hash2.h: Throw.
+ * src/base/hash/cl_hash2weak.h: Throw.
+ * src/base/hash/cl_hashset.h: Throw.
+ * src/base/hash/cl_hashuniq.h: Throw.
+ * src/base/hash/cl_hashuniqweak.h: Throw.
+ * src/base/proplist/cl_pl_add.cc: Throw.
+ * src/base/ring/cl_no_ring.cc: Throw.
+ * src/base/string/cl_spushstring.h: Throw.
+ * src/base/symbol/cl_symbol.cc: Throw.
+ * src/integer/bitwise/cl_I_ash.h: Removed (see cln/integer.h.)
+ * src/integer/bitwise/cl_I_asherr.cc: Removed.
+ * src/integer/bitwise/cl_I_ash_exception.cc: New file.
+ * src/integer/division/cl_I_exquoerr.cc: Removed.
+ * src/integer/division/cl_I_exquo_exception.cc: New file.
+ * src/integer/cl_I.h: Throw.
+ * src/integer/division/cl_I_exquopos.cc: Throw.
+ * src/integer/bitwise/cl_I_logbitp_I.cc: Throw.
+ * src/integer/bitwise/cl_I_ash.cc: Throw.
+ * src/integer/bitwise/cl_I_ash_I.cc: Throw.
+ * src/integer/division/cl_I_exquo.cc: Throw.
+ * src/integer/gcd/cl_I_gcd_aux2.cc: Throw.
+ * src/integer/conv/cl_I_to_L.cc: Throw.
+ * src/integer/conv/cl_I_to_Q.cc: Throw.
+ * src/integer/conv/cl_I_to_UL.cc: Throw.
+ * src/integer/conv/cl_I_to_UQ.cc: Throw.
+ * src/integer/conv/cl_I_to_digits.cc: Throw.
+ * src/integer/elem/cl_I_div.cc: Throw.
+ * src/integer/algebraic/cl_I_sqrt.cc: Throw.
+ * src/integer/input/cl_I_read.cc: Throw.
+ * src/integer/input/cl_I_read_stream.cc: Throw.
+ * src/integer/misc/cl_I_as.cc: Throw.
+ * src/rational/elem/cl_RA_from_I_I_div.cc: Throw.
+ * src/rational/elem/cl_RA_recip.cc: Throw.
+ * src/rational/input/cl_RA_read.cc: Throw.
+ * src/rational/input/cl_RA_read_stream.cc: Throw.
+ * src/rational/input/cl_RA_readparsed.cc: Throw.
+ * src/rational/misc/cl_RA_as.cc: Throw.
+ * src/float/base/cl_F_err_nan.cc: Removed.
+ * src/float/base/cl_F_nan_exception.cc: New file.
+ * src/float/base/cl_F_err_un.cc: Removed.
+ * src/float/base/cl_F_underflow_exception.cc: New file.
+ * src/float/base/cl_F_err_ov.cc: Removed.
+ * src/float/base/cl_F_overflow_exception.cc: New file.
+ * src/float/cl_F.h (cl_error_floating_point_nan,
+ cl_error_floating_point_overflow, cl_error_floating_point_underflow):
+ Removed (see cln/float.h.)
+ * src/float/sfloat/cl_SF.h: Throw.
+ * src/float/sfloat/elem/cl_SF_div.cc: Throw.
+ * src/float/sfloat/elem/cl_SF_from_RA.cc: Throw.
+ * src/float/sfloat/elem/cl_SF_scale.cc: Throw.
+ * src/float/sfloat/elem/cl_SF_scale_I.cc: Throw.
+ * src/float/sfloat/misc/cl_SF_as.cc: Throw.
+ * src/float/ffloat/cl_FF.h: Throw.
+ * src/float/ffloat/conv/cl_FF_from_float.cc: Throw.
+ * src/float/ffloat/elem/cl_FF_div.cc: Throw.
+ * src/float/ffloat/elem/cl_FF_from_RA.cc: Throw.
+ * src/float/ffloat/elem/cl_FF_scale.cc: Throw.
+ * src/float/ffloat/elem/cl_FF_scale_I.cc: Throw.
+ * src/float/ffloat/misc/cl_FF_as.cc: Throw.
+ * src/float/dfloat/cl_DF.h: Throw.
+ * src/float/dfloat/conv/cl_DF_from_double.cc: Throw.
+ * src/float/dfloat/elem/cl_DF_div.cc: Throw.
+ * src/float/dfloat/elem/cl_DF_from_RA.cc: Throw.
+ * src/float/dfloat/elem/cl_DF_scale.cc: Throw.
+ * src/float/dfloat/elem/cl_DF_scale_I.cc: Throw.
+ * src/float/dfloat/misc/cl_DF_as.cc: Throw.
+ * src/float/lfloat/algebraic/cl_LF_sqrt.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_1plus.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_I_div.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_I_mul.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_div.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_from_I.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_mul.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_scale.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_scale_I.cc: Throw.
+ * src/float/lfloat/elem/cl_LF_square.cc: Throw.
+ * src/float/lfloat/misc/cl_LF_as.cc: Throw.
+ * src/float/lfloat/misc/cl_LF_shorten.cc: Throw.
+ * src/float/lfloat/misc/cl_LF_shortenrel.cc: Throw.
+ * src/float/lfloat/misc/cl_LF_shortenwith.cc: Throw.
+ * src/float/input/cl_F_read.cc: Throw.
+ * src/float/input/cl_F_read_stream.cc: Throw.
+ * src/float/misc/cl_F_as.cc: Throw.
+ * src/float/misc/cl_F_shortenrel.cc: Throw.
+ * src/float/transcendental/cl_LF_coshsinh_aux.cc: Throw.
+ * src/float/transcendental/cl_LF_cossin_aux.cc: Throw.
+ * src/float/transcendental/cl_LF_exp_aux.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_a.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_ab.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_b.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_p.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pa.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pab.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pb.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pq.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pqa.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pqab.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_pqb.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_q.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_qa.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_qab.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_qb.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_stream_pq.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_stream_pqa.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_stream_pqab.cc: Throw.
+ * src/float/transcendental/cl_LF_ratseries_stream_pqb.cc: Throw.
+ * src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc: Throw.
+ * src/float/transcendental/cl_LF_ratsumseries_pqd.cc: Throw.
+ * src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc: Throw.
+ * src/float/transcendental/cl_LF_zeta_int.cc: Throw.
+ * src/real/elem/cl_R_div.cc: Throw.
+ * src/real/format-output/cl_fmt_cardinal.cc: Throw.
+ * src/real/format-output/cl_fmt_newroman.cc: Throw.
+ * src/real/format-output/cl_fmt_oldroman.cc: Throw.
+ * src/real/input/cl_R_read.cc: Throw.
+ * src/real/input/cl_R_read_stream.cc: Throw.
+ * src/real/misc/cl_R_as.cc: Throw.
+ * src/real/random/cl_R_random.cc: Throw.
+ * src/real/transcendental/cl_R_atan2.cc: Throw.
+ * src/real/transcendental/cl_R_log.cc: Throw.
+ * src/complex/input/cl_N_read.cc: Throw.
+ * src/complex/input/cl_N_read_stream.cc: Throw.
+ * src/complex/misc/cl_N_as.cc: Throw.
+ * src/complex/transcendental/cl_C_atanh_aux.cc: Throw.
+ * src/complex/transcendental/cl_C_expt_C.cc: Throw.
+ * src/complex/transcendental/cl_C_log.cc: Throw.
+ * src/complex/transcendental/cl_C_log2.cc: Throw.
+ * src/numtheory/cl_nt_cornacchia1.cc: Throw.
+ * src/numtheory/cl_nt_cornacchia4.cc: Throw.
+ * src/numtheory/cl_nt_isprobprime.cc: Throw.
+ * src/numtheory/cl_nt_jacobi.cc: Throw.
+ * src/numtheory/cl_nt_jacobi_low.cc: Throw.
+ * src/numtheory/cl_nt_sqrtmodp.cc: Throw.
+ * src/modinteger/cl_MI.cc: Throw.
+ * src/modinteger/cl_MI_int.h: Throw.
+ * src/modinteger/cl_MI_montgom.h: Throw.
+ * src/modinteger/cl_MI_pow2.h: Throw.
+ * src/modinteger/cl_MI_rshift.cc: Throw.
+ * src/modinteger/cl_MI_std.h: Throw.
+ * src/polynomial/elem/cl_UP_GF2.h: Throw.
+ * src/polynomial/elem/cl_UP_MI.h: Throw.
+ * src/polynomial/elem/cl_UP_gen.h: Throw.
+ * src/polynomial/elem/cl_UP_named.cc: Throw.
+ * src/polynomial/elem/cl_UP_no_ring.cc (uninitialized_error,
+ uninitialized_ring): Removed (see cln/ring.h.)
+ * src/polynomial/elem/cl_UP_number.h: Throw.
+ * src/polynomial/elem/cl_UP_unnamed.cc: Throw.
+ * src/vector/cl_GV_I.cc: Throw.
+ * src/vector/cl_GV_number.cc: Throw.
+ * tests/timediv2adic-compare.cc: Use default abort(), not cl_abort().
+ * tests/timeprint-compare.cc: Likewise.
+ * tests/timerecip2adic-compare.cc: Likewise.
+ * doc/cln.tex: Document the exception classes.
+ * examples/contfrac.cc: Use try/catch instead of setjmp/longjmp.
+ * INSTALL: undocument -fno-exceptions.
+ * README: Add exceptions to list of used C++ features.
+
2007-06-20 Richard B. Kreckel <kreckel@ginac.de>
* cln.spec.in (Source0): Package is bzip2-compressed.
The "make" step takes about 30 minutes, on a P-III / 1 GHz / 512 MB.
-If you use g++ from gcc-3.x, I recommend adding "-fno-exceptions" to the
-CXXFLAGS. This will likely generate better code.
-
If you use g++ from gcc-3.0.4 or older on Sparc, add either "-O", "-O1" or
"-O2 -fno-schedule-insns" to the CXXFLAGS. With full "-O2", g++ miscompiles
the division routines. Do not use gcc-3.0 on Sparc for compiling CLN, it
won't work at all.
-If you use g++ on OSF/1 or Tru64 using gcc-3.0.n with n larger than 1, you
-should not add -fno-exceptions to the CXXFLAGS, since that will generate
-wrong code (gcc-3.1 is okay again, as is gcc-3.0).
-
More detailed installation instructions can be found in the documentation,
in the doc/ directory.
-2006-mm-dd, version 1.2.0
+2007-mm-dd, version 1.2.0
=========================
Implementation changes
----------------------
* Added support for huge numbers...
+* CLN now uses C++ exceptions for error handling.
* Dropped the cln-config script. Please use pkg-config instead.
- Interoperability:
- Garbage collection with no burden on
the main application,
- - hooks for memory allocation and exceptions.
+ - hooks for memory allocation.
Requires: C++ compiler g++.
The following C++ features are used:
classes, member functions, overloading of functions and operators,
constructors and destructors, inline, const, multiple inheritance,
-templates and namespaces.
+templates, namespaces, and exceptions.
The following C++ features are not used:
-new, delete, virtual inheritance, exceptions.
+new, delete, virtual inheritance.
Homepage: <http://www.ginac.de/CLN>
@setfilename cln.info
@settitle CLN, a Class Library for Numbers
@c @setchapternewpage off
-@c For `info' only.
-@paragraphindent 0
-@c For TeX only.
-@iftex
@c I hate putting "@noindent" in front of every paragraph.
-@parindent=0pt
-@end iftex
+@c For `info' and TeX only.
+@paragraphindent 0
@c %**end of header
@direntry
@item
The garbage collection imposes no burden on the main application.
@item
-The library provides hooks for memory allocation and exceptions.
+The library provides hooks for memory allocation and throws exceptions
+in case of errors.
@item
@cindex namespace
All non-macro identifiers are hidden in namespace @code{cln} in
@subsection C++ compiler
To build CLN, you need a C++ compiler.
-Actually, you need GNU @code{g++ 2.95} or newer.
+Actually, you need GNU @code{g++ 3.0.0} or newer.
The following C++ features are used:
classes, member functions, overloading of functions and operators,
templates and namespaces.
The following C++ features are not used:
-@code{new}, @code{delete}, virtual inheritance, exceptions.
+@code{new}, @code{delete}, virtual inheritance.
CLN relies on semi-automatic ordering of initializations of static and
global variables, a feature which I could implement for GNU g++
@example
$ CC="gcc" CFLAGS="-O" CXX="g++" CXXFLAGS="-O" ./configure
-$ CC="gcc -V egcs-2.91.60" CFLAGS="-O -g" \
- CXX="g++ -V egcs-2.91.60" CXXFLAGS="-O -g" ./configure
-$ CC="gcc -V 2.95.2" CFLAGS="-O2 -fno-exceptions" \
- CXX="g++ -V 2.95.2" CFLAGS="-O2 -fno-exceptions" ./configure
-$ CC="gcc -V 3.0.4" CFLAGS="-O2 -finline-limit=1000 -fno-exceptions" \
- CXX="g++ -V 3.0.4" CFLAGS="-O2 -finline-limit=1000 -fno-exceptions" \
+$ CC="gcc -V 3.0.4" CFLAGS="-O2 -finline-limit=1000" \
+ CXX="g++ -V 3.0.4" CXXFLAGS="-O2 -finline-limit=1000" \
./configure
+$ CC="gcc-4.1" CFLAGS="-O2" CXX="g++-4.1" CXXFLAGS="-O2" ./configure
@end example
Note that for these environment variables to take effect, you have to set
If you use @code{g++} 3.x, I recommend adding @samp{-finline-limit=1000}
to the CXXFLAGS. This is essential for good code.
-If you use @code{g++} gcc-2.95.x or gcc-3.x, I recommend adding
-@samp{-fno-exceptions} to the CXXFLAGS. This will likely generate better code.
-
If you use @code{g++} from gcc-3.0.4 or older on Sparc, add either
@samp{-O}, @samp{-O1} or @samp{-O2 -fno-schedule-insns} to the
CXXFLAGS. With full @samp{-O2}, @code{g++} miscompiles the division
-routines. If you use @code{g++} older than 2.95.3 on Sparc you should
-also specify @samp{--disable-shared} because of bad code produced in the
-shared library. Also, do not use gcc-3.0 on Sparc for compiling CLN, it
+routines. Also, do not use gcc-3.0 on Sparc for compiling CLN, it
won't work at all.
-If you use @code{g++} on OSF/1 or Tru64 using gcc-2.95.x, you should
-specify @samp{--disable-shared} because of linker problems with
-duplicate symbols in shared libraries. If you use @code{g++} from
-gcc-3.0.n, with n larger than 1, you should @emph{not} add
-@samp{-fno-exceptions} to the CXXFLAGS, since that will generate wrong
-code (gcc-3.1 is okay again, as is gcc-3.0).
-
Also, please do not compile CLN with @code{g++} using the @code{-O3}
optimization level. This leads to inferior code quality.
an example:
@example
-$ CC="gcc" CFLAGS="-O2" CXX="g++" CXXFLAGS="-O2 -fno-exceptions" \
+$ CC="gcc" CFLAGS="-O2" CXX="g++" CXXFLAGS="-O2" \
CPPFLAGS="-I/opt/gmp/include" LDFLAGS="-L/opt/gmp/lib" ./configure --with-gmp
@end example
@code{NULL}, denoting the entire string, i.e. equivalent to
@code{string_limit = string + strlen(string)}. If @code{end_of_parse} is
@code{NULL}, the string in memory must contain exactly one number and nothing
-more, else a fatal error will be signalled. If @code{end_of_parse}
+more, else an exception will be thrown. If @code{end_of_parse}
is not @code{NULL}, @code{*end_of_parse} will be assigned a pointer past
the last parsed character (i.e. @code{string_limit} if nothing came after
the number). Whitespace is not allowed.
Flags for customizing output operations.
@item <cln/malloc.h>
@code{malloc_hook}, @code{free_hook}.
-@item <cln/abort.h>
-@code{cl_abort}.
+@item <cln/exception.h>
+Exception base class.
@item <cln/condition.h>
-Conditions/exceptions.
+Conditions.
@item <cln/string.h>
Strings.
@item <cln/symbol.h>
@itemize @bullet
@item The library does type checks, range checks, consistency checks at
-many places. When one of these fails, the function @code{cl_abort()} is
-called. Its default implementation is to perform an @code{exit(1)}, so
-you won't have a core dump. But for debugging, it is best to set a
-breakpoint at this function:
+many places. When one of these fails, an exception of a type derived from
+@code{runtime_exception} is thrown. When an exception is cought, the stack
+has already been unwound, so it is may not be possible to tell at which
+point the exception was thrown. For debugging, it is best to set up a
+catchpoint at the event of throwning a C++ exception:
@example
-(gdb) break cl_abort
+(gdb) catch throw
@end example
-When this breakpoint is hit, look at the stack's backtrace:
+When this catchpoint is hit, look at the stack's backtrace:
@example
(gdb) where
@end example
+When control over the type of exception is required, it may be possible
+to set a breakpoint at the @code{g++} runtime library function
+@code{__raise_exception}. Refer to the documentation of GNU @code{gdb}
+for details.
@item The debugger's normal @code{print} command doesn't know about
CLN's types and therefore prints mostly useless hexadecimal addresses.
@cindex customizing
@section Error handling
+@cindex Exception
+@cindex Error handling
+
+@cindex @code{runtime_exception}
+CLN signals abnormal situations by throwning exceptions. All exceptions
+thrown by the library are of type @code{runtime_exception} or of a
+derived type. Class @code{cln::runtime_exception} in turn is derived
+from the C++ standard library class @code{std::runtime_error} and
+inherits the @code{.what()} member function that can be used to query
+details about the cause of error.
-When a fatal error occurs, an error message is output to the standard error
-output stream, and the function @code{cl_abort} is called. The default
-version of this function (provided in the library) terminates the application.
-To catch such a fatal error, you need to define the function @code{cl_abort}
-yourself, with the prototype
+The most important classes thrown by the library are
+
+@cindex @code{floating_point_exception}
+@cindex @code{read_number_exception}
@example
-#include <cln/abort.h>
-void cl_abort (void);
+ Exception base class
+ runtime_exception
+ <cln/exception.h>
+ |
+ +----------------+----------------+
+ | |
+ Malformed number input Floating-point error
+ read_number_exception floating_poing_exception
+ <cln/number_io.h> <cln/float.h>
@end example
-@cindex @code{cl_abort ()}
-This function must not return control to its caller.
+
+CLN has many more exception classes that allow for more fine-grained
+control but I refrain from documenting them all here. They are all
+declared in the public header files and they are all subclasses of the
+above exceptions, so catching those you are always on the safe side.
@section Floating-point underflow
@cindex underflow
-Floating point underflow denotes the situation when a floating-point number
-is to be created which is so close to @code{0} that its exponent is too
-low to be represented internally. By default, this causes a fatal error.
-If you set the global variable
+@cindex @code{floating_point_underflow_exception}
+Floating point underflow denotes the situation when a floating-point
+number is to be created which is so close to @code{0} that its exponent
+is too low to be represented internally. By default, this causes the
+exception @code{floating_point_underflow_exception} (subclass of
+@code{floating_point_exception}) to be thrown. If you set the global
+variable
@example
cl_boolean cl_inhibit_floating_point_underflow
@end example
-to @code{cl_true}, the error will be inhibited, and a floating-point zero
-will be generated instead. The default value of
+to @code{cl_true}, the exception will be inhibited, and a floating-point
+zero will be generated instead. The default value of
@code{cl_inhibit_floating_point_underflow} is @code{cl_false}.
using namespace std;
using namespace cln;
-// Our private error handling: return to the main program.
-#include <csetjmp>
-jmp_buf restartpoint;
-namespace cln {
- void cl_abort (void) { longjmp(restartpoint,1); }
-}
-
int main (int argc, char* argv[])
{
for (int i = 1; i < argc; i++) {
const char * arg = argv[i];
- if (setjmp(restartpoint))
- continue;
- // Convert argument to its internal representation:
- cl_R x = arg;
- // Check sign.
- if (minusp(x)) {
- cout << '-';
- x = -x;
- }
- cout << "[";
- const char* separator = "; ";
- for (;;) {
- // Split x into integral and fractional part.
- cl_R_div_t x_split = floor2(x);
- cout << x_split.quotient;
- x = x_split.remainder;
- if (zerop(x))
- break;
- cout << separator;
- separator = ", ";
- // Invert x.
- x = recip(x);
- }
- cout << ']' << endl;
+ try {
+ // Convert argument to its internal representation:
+ cl_R x = arg;
+ // Check sign.
+ if (minusp(x)) {
+ cout << '-';
+ x = -x;
+ }
+ cout << "[";
+ const char* separator = "; ";
+ for (;;) {
+ // Split x into integral and fractional part.
+ cl_R_div_t x_split = floor2(x);
+ cout << x_split.quotient;
+ x = x_split.remainder;
+ if (zerop(x))
+ break;
+ cout << separator;
+ separator = ", ";
+ // Invert x.
+ x = recip(x);
+ }
+ cout << ']' << endl;
+ } catch ( const runtime_exception& ) {}
}
}
#include "cln/object.h"
#include "cln/V.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include <cstdlib>
namespace cln {
inline cl_GV_index<T>::operator T () const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
return vec->vectorops->element(vec,index);
}
inline void cl_GV_index<T>::operator= (const T& x) const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
vec->vectorops->set_element(vec,index,x);
}
inline cl_GV_constindex<T>::operator T () const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
return vec->vectorops->element(vec,index);
}
const cl_heap_GV<T> * hsrc = (const cl_heap_GV<T> *) src.pointer;
cl_heap_GV<T> * hdest = (cl_heap_GV<T> *) dest.pointer;
if (!(hsrc->v.vectorops == hdest->v.vectorops))
- cl_abort();
+ throw runtime_exception();
hsrc->v.vectorops->copy_elements(&hsrc->v,srcindex,&hdest->v,destindex,count);
}
// Private pointer manipulations.
#include "cln/object.h"
#include "cln/V.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include <cstdlib>
namespace cln {
const T & operator[] (unsigned long index) const
{
#ifndef CL_SV_NO_RANGECHECKS
- if (!(index < length())) cl_abort();
+ if (!(index < length())) throw runtime_exception();
#endif
return data()[index];
}
T & operator[] (unsigned long index)
{
#ifndef CL_SV_NO_RANGECHECKS
- if (!(index < length())) cl_abort();
+ if (!(index < length())) throw runtime_exception();
#endif
return data()[index];
}
+++ /dev/null
-// Abnormal program exit.
-
-#ifndef _CL_ABORT_H
-#define _CL_ABORT_H
-
-namespace cln {
-
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, cl_abort, (void));
-#else
-extern void cl_abort (void);
-#endif
-
-} // namespace cln
-
-#endif /* _CL_ABORT_H */
// Miscellaneous.
#include "cln/random.h"
#include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cln/floatformat.h"
#include "cln/io.h"
#include "cln/condition.h"
--- /dev/null
+// Exception types.
+
+#ifndef _CL_EXCEPTION_H
+#define _CL_EXCEPTION_H
+
+#include <stdexcept>
+
+namespace cln {
+
+// Base class of all exception classes thrown by CLN.
+class runtime_exception : public std::runtime_error {
+public:
+ runtime_exception ()
+ : std::runtime_error(std::string()) {}
+ explicit runtime_exception (const std::string & what)
+ : std::runtime_error(what) {}
+};
+
+// Thrown when an assertion is violated.
+class notreached_exception : public runtime_exception {
+public:
+ notreached_exception (const char* filename, int lineno);
+};
+
+// Thrown when a pole is encountered.
+class division_by_0_exception : public runtime_exception {
+public:
+ division_by_0_exception ();
+};
+
+// Thrown when a conversion with As(TYPE)(VALUE) fails.
+class as_exception : public runtime_exception {
+public:
+ as_exception (const class cl_number& obj, const char * typestring, const char * filename, int line);
+};
+
+} // namespace cln
+
+#endif /* _CL_EXCEPTION_H */
#include "cln/ffloat_class.h"
#include "cln/dfloat_class.h"
#include "cln/lfloat_class.h"
+#include "cln/exception.h"
namespace cln {
inline cl_F& operator/= (cl_F& x, const double y) { return x = x / y; }
#endif
+// Thrown when a floating-point exception occurs.
+class floating_point_exception : public runtime_exception {
+public:
+ explicit floating_point_exception(const std::string & what)
+ : runtime_exception(what) {}
+};
+
+// Thrown when NaN occurs.
+class floating_point_nan_exception : public floating_point_exception {
+public:
+ floating_point_nan_exception();
+};
+
+// Thrown when overflow occurs.
+class floating_point_overflow_exception : public floating_point_exception {
+public:
+ floating_point_overflow_exception();
+};
+
+// Thrown when underflow occurs.
+class floating_point_underflow_exception : public floating_point_exception {
+public:
+ floating_point_underflow_exception();
+};
+
CL_REQUIRE(cl_ieee)
-// If this is true, floating point underflow returns zero instead of an error.
+// If this is true, floating point underflow returns zero instead of throwing an exception.
extern cl_boolean cl_inhibit_floating_point_underflow;
} // namespace cln
#include "cln/number.h"
#include "cln/integer_class.h"
+#include "cln/exception.h"
#include "cln/random.h"
namespace cln {
extern const cl_I ash (const cl_I& x, sintC y);
extern const cl_I ash (const cl_I& x, const cl_I& y);
+// Thrown when shift amount is too large.
+class ash_exception : public runtime_exception {
+public:
+ explicit ash_exception (const cl_I& badamount);
+};
+
// (LOGCOUNT x), wo x ein Integer ist. Ergebnis uintL.
extern uintC logcount (const cl_I& x);
// < ergebnis: Quotient x/y, ein Integer
extern const cl_I exquo (const cl_I& x, const cl_I& y);
+// Thrown when quotient is no integer.
+class exquo_exception : public runtime_exception {
+public:
+ exquo_exception (const cl_I& x, const cl_I& y);
+};
+
// mod(x,y) = (mod x y), wo x,y Integers sind.
extern const cl_I mod (const cl_I& x, const cl_I& y);
#include "cln/io.h"
#include "cln/proplist.h"
#include "cln/condition.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef random // Linux defines random() as a macro!
namespace cln {
cl_MI_x (cl_composite_condition* c) : value (), condition (c) {}
cl_MI_x (const cl_MI& x) : value (x), condition (NULL) {}
// Cast operators.
- //operator cl_MI& () { if (condition) cl_abort(); return value; }
- //operator const cl_MI& () const { if (condition) cl_abort(); return value; }
- operator cl_MI () const { if (condition) cl_abort(); return value; }
+ //operator cl_MI& () { if (condition) throw runtime_exception(); return value; }
+ //operator const cl_MI& () const { if (condition) throw runtime_exception(); return value; }
+ operator cl_MI () const { if (condition) throw runtime_exception(); return value; }
};
// High-level operations.
void fprint (std::ostream& stream, const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_fprint(stream,x);
}
cl_boolean equal (const cl_MI& x, const cl_MI& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return _equal(x,y);
}
const cl_MI random (random_state& randomstate = default_random_state)
}
cl_boolean zerop (const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _zerop(x);
}
const cl_MI plus (const cl_MI& x, const cl_MI& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_MI(this,_plus(x,y));
}
const cl_MI minus (const cl_MI& x, const cl_MI& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_MI(this,_minus(x,y));
}
const cl_MI uminus (const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_MI(this,_uminus(x));
}
const cl_MI one ()
}
const cl_MI mul (const cl_MI& x, const cl_MI& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_MI(this,_mul(x,y));
}
const cl_MI square (const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_MI(this,_square(x));
}
const cl_MI expt_pos (const cl_MI& x, const cl_I& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_MI(this,_expt_pos(x,y));
}
const cl_MI_x recip (const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _recip(x);
}
const cl_MI_x div (const cl_MI& x, const cl_MI& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return _div(x,y);
}
const cl_MI_x expt (const cl_MI& x, const cl_I& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _expt(x,y);
}
const cl_I reduce_modulo (const cl_I& x)
}
const cl_I retract (const cl_MI& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _retract(x);
}
// Miscellaneous.
#include "cln/io.h"
#include "cln/number.h"
+#include "cln/exception.h"
namespace cln {
// Input.
+class read_number_exception : public runtime_exception {
+public:
+ explicit read_number_exception(const std::string & what)
+ : runtime_exception(what) {}
+};
+
// Finish with bad syntax.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_bad_syntax, (const char * string, const char * string_limit));
-#else
-extern void read_number_bad_syntax (const char * string, const char * string_limit);
-#endif
+class read_number_bad_syntax_exception : public read_number_exception {
+public:
+ read_number_bad_syntax_exception(const char * string, const char * string_limit);
+};
// Finish with junk after the number.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_junk, (const char * string_rest, const char * string, const char * string_limit));
-#else
-extern void read_number_junk (const char * string_rest, const char * string, const char * string_limit);
-#endif
-
-// Finish with EOF.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_eof, (void));
-#else
-extern void read_number_eof (void);
-#endif
+class read_number_junk_exception : public read_number_exception {
+public:
+ read_number_junk_exception(const char * string_rest, const char * string, const char * string_limit);
+};
+
+// Finish with premature EOF.
+class read_number_eof_exception : public read_number_exception {
+public:
+ read_number_eof_exception();
+};
struct cl_read_flags;
#define CL_DEFINE_CONVERTER(target_class) \
operator const target_class & () const \
{ \
- if (sizeof(*this) != sizeof(target_class)) cl_abort(); \
+ typedef int assert1 [2*(sizeof(target_class)==sizeof(*this))-1]; \
return * (const target_class *) (void*) this; \
}
#include "cln/number.h"
#include "cln/rational_class.h"
#include "cln/integer_class.h"
+#include "cln/exception.h"
namespace cln {
#include "cln/malloc.h"
#include "cln/proplist.h"
#include "cln/number.h"
+#include "cln/exception.h"
#include "cln/io.h"
namespace cln {
// High-level operations.
void fprint (std::ostream& stream, const cl_ring_element& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_fprint(stream,x);
}
cl_boolean equal (const cl_ring_element& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return _equal(x,y);
}
const cl_ring_element zero ()
}
cl_boolean zerop (const cl_ring_element& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _zerop(x);
}
const cl_ring_element plus (const cl_ring_element& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_plus(x,y));
}
const cl_ring_element minus (const cl_ring_element& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_minus(x,y));
}
const cl_ring_element uminus (const cl_ring_element& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_uminus(x));
}
const cl_ring_element one ()
}
const cl_ring_element mul (const cl_ring_element& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_mul(x,y));
}
const cl_ring_element square (const cl_ring_element& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_square(x));
}
const cl_ring_element expt_pos (const cl_ring_element& x, const cl_I& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_ring_element(this,_expt_pos(x,y));
}
// Property operations.
// Ring of uninitialized elements.
-// Any operation results in a run-time error.
+// Any operation results in an exception being thrown.
+
+// Thrown when an attempt is made to perform an operation on an uninitialized ring.
+class uninitialized_ring_exception : public runtime_exception {
+public:
+ uninitialized_ring_exception ();
+};
+
+// Thrown when a ring element is uninitialized.
+class uninitialized_exception : public runtime_exception {
+public:
+ explicit uninitialized_exception (const _cl_ring_element& obj);
+ uninitialized_exception (const _cl_ring_element& obj_x, const _cl_ring_element& obj_y);
+};
extern const cl_ring cl_no_ring;
extern cl_class cl_class_no_ring;
#include "cln/object.h"
#include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include <cstring>
namespace cln {
unsigned long length; // length (in characters)
char data[1]; // the characters, plus a '\0' at the end
// Standard allocation disabled.
- void* operator new (size_t size) { (void)size; cl_abort(); return (void*)1; }
+ void* operator new (size_t size) { (void)size; throw runtime_exception(); }
// Standard deallocation disabled.
- void operator delete (void* ptr) { (void)ptr; cl_abort(); }
+ void operator delete (void* ptr) { (void)ptr; throw runtime_exception(); }
// No default constructor.
cl_heap_string ();
private:
// Return a specific character.
char operator[] (unsigned long i) const
{
- if (!(i < length())) cl_abort(); // Range check.
+ if (!(i < length())) throw runtime_exception(); // Range check.
return ((cl_heap_string*)pointer)->data[i];
}
// New ANSI C++ compilers also want the following.
// High-level operations.
void fprint (std::ostream& stream, const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_fprint(stream,x);
}
cl_boolean equal (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return _equal(x,y);
}
const cl_UP zero ()
}
cl_boolean zerop (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _zerop(x);
}
const cl_UP plus (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_plus(x,y));
}
const cl_UP minus (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_minus(x,y));
}
const cl_UP uminus (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_uminus(x));
}
const cl_UP one ()
}
const cl_UP mul (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_mul(x,y));
}
const cl_UP square (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_square(x));
}
const cl_UP expt_pos (const cl_UP& x, const cl_I& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_expt_pos(x,y));
}
const cl_UP scalmul (const cl_ring_element& x, const cl_UP& y)
{
- if (!(y.ring() == this)) cl_abort();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_scalmul(x,y));
}
sintL degree (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _degree(x);
}
sintL ldegree (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _ldegree(x);
}
const cl_UP monomial (const cl_ring_element& x, uintL e)
}
const cl_ring_element coeff (const cl_UP& x, uintL index)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _coeff(x,index);
}
const cl_UP create (sintL deg)
}
void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_set_coeff(x,index,y);
}
void finalize (cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_finalize(x);
}
const cl_ring_element eval (const cl_UP& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _eval(x,y);
}
// Property operations.
namespace cln {
-nonreturning_function(extern, cl_error_division_by_0, (void));
-nonreturning_function(extern, cl_as_error, (const cl_number& obj, const char * typestring, const char * filename, int line));
-
// For the equal-invariant hashcode, we take a mixture of exponent, length
// and the most significant 32 bits. To ensure that equal(x,y) implies
// equal_hashcode(x) == equal_hashcode(y) we must make sure that
+++ /dev/null
-// cl_error_division_by_0().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_N.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_error_division_by_0 (void)
-{
- fprint(std::cerr, "Division by zero.\n");
- cl_abort();
-}
-
-} // namespace cln
+++ /dev/null
-// cl_abort().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cln/abort.h"
-
-
-// Implementation.
-
-#include <cstdlib>
-
-namespace cln {
-
-void cl_abort (void)
-{
- exit(1);
-}
-
-} // namespace cln
+++ /dev/null
-// cl_as_error().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_N.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_as_error (const cl_number& obj, const char * typestring, const char * filename, int line)
-{
- fprint(std::cerr, "Type assertion failed: in file ");
- fprint(std::cerr, filename);
- fprint(std::cerr, ", line ");
- fprintdecimal(std::cerr, line);
- fprint(std::cerr, ", not ");
- fprint(std::cerr, typestring);
- fprint(std::cerr, ": ");
-#if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
- fprint(std::cerr, obj);
-#else
- fprint(std::cerr, "@0x");
- fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
- fprint(std::cerr, ": 0x");
- fprinthexadecimal(std::cerr, (unsigned long)obj.word);
-#endif
- fprint(std::cerr, "\n");
- cl_abort();
-}
-
-} // namespace cln
--- /dev/null
+// as_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/exception.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+#include "cl_N.h"
+#include <sstream>
+
+namespace cln {
+
+static inline const std::string
+as_error_msg (const cl_number& obj, const char * typestring, const char * filename, int line)
+{
+ std::ostringstream buf;
+ fprint(buf, "Type assertion failed: in file ");
+ fprint(buf, filename);
+ fprint(buf, ", line ");
+ fprintdecimal(buf, line);
+ fprint(buf, ", not ");
+ fprint(buf, typestring);
+ fprint(buf, ": ");
+#if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
+ fprint(buf, obj);
+#else
+ fprint(buf, "@0x");
+ fprinthexadecimal(buf, (unsigned long)(void*)&obj);
+ fprint(buf, ": 0x");
+ fprinthexadecimal(buf, (unsigned long)obj.word);
+#endif
+ return buf.str();
+}
+
+as_exception::as_exception (const cl_number& obj, const char * typestring, const char * filename, int line)
+ : runtime_exception(as_error_msg(obj, typestring, filename, line))
+{}
+
+} // namespace cln
--- /dev/null
+// division_by_0_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/exception.h"
+
+namespace cln {
+
+division_by_0_exception::division_by_0_exception ()
+ : runtime_exception("Division by zero.")
+{}
+
+} // namespace cln
// Implementation.
#include "cln/io.h"
-#include "cln/abort.h"
namespace cln {
#define _CL_MACROS_H
#include "cln/types.h"
+#include "cln/exception.h"
// Concatenation of macroexpanded tokens.
// Example:
// Denotes a point where control flow can never arrive.
// NOTREACHED
- #define NOTREACHED cl_notreached_abort(__FILE__,__LINE__);
-namespace cln {
- nonreturning_function(extern,cl_notreached_abort, (const char* filename, int lineno));
-} // namespace cln
+ #define NOTREACHED throw notreached_exception(__FILE__,__LINE__);
// Check an arithmetic expression.
// ASSERT(expr)
#include <cstdlib>
#include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#ifndef malloc
extern "C" void* malloc (size_t size);
void* ptr = malloc(size);
if (ptr)
return ptr;
- fprint(std::cerr, "Out of virtual memory.\n");
- cl_abort();
+ throw runtime_exception("Out of virtual memory.");
}
void* (*malloc_hook) (size_t size) = xmalloc;
+++ /dev/null
-// cl_notreached_abort().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_macros.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_notreached_abort (const char* filename, int lineno)
-{
- fprint(std::cerr, "Internal error: statement in file ");
- fprint(std::cerr, filename);
- fprint(std::cerr, ", line ");
- fprintdecimal(std::cerr, lineno);
- fprint(std::cerr, " has been reached!!\n");
- fprint(std::cerr, "Please send the authors of the program a description how you produced this error!\n");
- cl_abort();
-}
-
-} // namespace cln
--- /dev/null
+// cl_notreached_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cl_macros.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+#include <sstream>
+
+namespace cln {
+
+static inline const std::string
+notreached_error_msg (const char* filename, int lineno)
+{
+ std::ostringstream buf;
+ fprint(buf, "Internal error: statement in file ");
+ fprint(buf, filename);
+ fprint(buf, ", line ");
+ fprintdecimal(buf, lineno);
+ fprint(buf, " has been reached!!\n");
+ fprint(buf, "Please send the authors of the program a description how you produced this error!");
+ return buf.str();
+}
+
+notreached_exception::notreached_exception (const char* filename, int lineno)
+ : runtime_exception(notreached_error_msg(filename, lineno))
+{}
+
+} // namespace cln
#include "cl_2D.h"
#include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
cl_UDS_mul(q_LSDptr,b_len,b_LSDptr,b_len,p_LSDptr);
// Überprüfen, daß p == a mod 2^(intDsize*b_len):
if (compare_loop_msp(a_LSDptr lspop b_len,p_LSDptr lspop b_len,b_len))
- cl_abort();
+ throw runtime_exception();
// Quotient q und "Rest" (a-b*q)/2^(intDsize*b_len) ablegen:
copy_loop_lsp(q_LSDptr,dest_LSDptr,b_len);
if (lendiff <= b_len)
// Implementation.
-#include "cl_N.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
while ((a_len>0) && (mspref(a_MSDptr,0)==0)) { msshrink(a_MSDptr); a_len--; }
// b normalisieren (b_MSDptr erhöhen, b_len erniedrigen):
loop
- { if (b_len==0) { cl_error_division_by_0(); }
+ { if (b_len==0) { throw division_by_0_exception(); }
if (mspref(b_MSDptr,0)==0) { msshrink(b_MSDptr); b_len--; }
else break;
}
if (subfrom_loop_lsp(b_LSDptr,p_LSDptr,b_len))
dec_loop_lsp(p_LSDptr lspop b_len,j+2);
if ((mspref(p_MSDptr,0) > 0) || (compare_loop_msp(p_MSDptr mspop 1,r_MSDptr,a_len+1) > 0))
- cl_abort();
+ throw runtime_exception();
} }
// Rest bestimmen:
subfrom_loop_lsp(p_LSDptr,r_LSDptr,a_len+1);
- if (test_loop_msp(r_MSDptr,j)) cl_abort();
+ if (test_loop_msp(r_MSDptr,j)) throw runtime_exception();
r_MSDptr = r_LSDptr lspop b_len; // = r_MSDptr mspop (j+1);
// d ist um höchstens 2 zu klein, muß also evtl. zweimal um 1
// incrementieren, bis der Rest < b wird.
if (subfrom_loop_lsp(b_LSDptr,r_LSDptr,b_len))
lspref(r_LSDptr,b_len) -= 1;
if ((lspref(r_MSDptr,0) > 0) || (compare_loop_msp(r_MSDptr,b_MSDptr,b_len) >= 0))
- cl_abort();
+ throw runtime_exception();
} }
// r ist fertig, q := d.
- if (mspref(d_MSDptr,0) > 0) cl_abort();
+ if (mspref(d_MSDptr,0) > 0) throw runtime_exception();
q_len = j+1; copy_loop_msp(d_MSDptr mspop 1,q_MSDptr,q_len);
}
else
#include "cl_low.h"
#include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
var uintD tmpprod_xxx = cl_alloc_array(uintD,len1+len2);
mulu_xxx(sourceptr1,len1,sourceptr2,len2,arrayLSDptr(tmpprod_xxx,len1+len2));
if (compare_loop_msp(destptr lspop (len1+len2),arrayMSDptr(tmpprod_xxx,len1+len2),len1+len2))
- cl_abort();
+ throw runtime_exception();
}
#endif
}
#include "cln/floatparam.h"
-#include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#if defined(HAVE_LONGDOUBLE) && (long_double_mant_bits > double_mant_bits) && (defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && 0))
// Only these CPUs have fast "long double"s in hardware.
var fftc_complex& w_N = w[N>>1];
part = w_N.re - (fftc_real)(-1.0);
if (part > epsilon || part < -epsilon)
- cl_abort();
+ throw runtime_exception();
part = w_N.im;
if (part > epsilon || part < -epsilon)
- cl_abort();
+ throw runtime_exception();
}
{
var fftc_complex w_N;
var fftc_real part;
part = w_N.re - (fftc_real)1.0;
if (part > epsilon || part < -epsilon)
- cl_abort();
+ throw runtime_exception();
part = w_N.im;
if (part > epsilon || part < -epsilon)
- cl_abort();
+ throw runtime_exception();
}
#endif
var bool squaring = (x == y);
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
- fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
- cl_abort();
+ throw runtime_exception("FFT problem: l > 64 not supported by pow2_table");
}
var fftc_real carry = 0;
var sintL carrybits = 0; // number of bits in carry (>=0, <l)
i++;
}
if (i > N)
- cl_abort();
+ throw runtime_exception();
} else if (max_l(2) >= intDsize && l == intDsize) {
// l = intDsize
if (len > N)
- cl_abort();
+ throw runtime_exception();
for (i = 0; i < len; i++) {
var uintD digit = lsprefnext(sourceptr);
x[i].re = (fftc_real)digit;
}
while (carrybits > 0) {
if (!(i < N))
- cl_abort();
+ throw runtime_exception();
x[i].re = (fftc_real)(carry & l_mask);
x[i].im = (fftc_real)0;
carry >>= l;
i++;
}
if (len > 0)
- cl_abort();
+ throw runtime_exception();
}
for ( ; i < N; i++) {
x[i].re = (fftc_real)0;
if (!(digit >= (fftc_real)0
&& z[i].re > digit - (fftc_real)0.5
&& z[i].re < digit + (fftc_real)0.5))
- cl_abort();
+ throw runtime_exception();
#endif
if (shift > 0)
digit = digit * fftc_pow2_table[shift];
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
- fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
- cl_abort();
+ throw runtime_exception("FFT problem: numbers too big, floating point precision not sufficient");
}
if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k))
break;
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p));
// Fill factor x.
for (var uintC i = 0; i < N; i++) {
if (!(z[i].im > im_lo_limit
&& z[i].im < im_hi_limit))
- cl_abort();
+ throw runtime_exception();
if (!(z[i].re > re_lo_limit
&& z[i].re < re_hi_limit))
- cl_abort();
+ throw runtime_exception();
}
}
#endif
tmpMSDptr - tmpLSDptr;
#endif
if (tmplen > tmpprod_len)
- cl_abort();
+ throw runtime_exception();
// Add result to destptr[-destlen..-1]:
if (tmplen > destlen) {
if (test_loop_msp(tmpMSDptr,tmplen-destlen))
- cl_abort();
+ throw runtime_exception();
tmplen = destlen;
}
if (addto_loop_lsp(tmpLSDptr,destptr,tmplen))
if (inc_loop_lsp(destptr lspop tmplen,destlen-tmplen))
- cl_abort();
+ throw runtime_exception();
}
// Decrement len2.
destptr = destptr lspop len2p;
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftcomplex_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
- fprint(std::cerr, "FFT problem: checksum error\n");
- cl_abort();
+ throw runtime_exception("FFT problem: checksum error");
}
}
#include "cln/floatparam.h"
-#include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#if defined(HAVE_LONGDOUBLE) && (long_double_mant_bits > double_mant_bits) && (defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && 0))
}
x >>= 1;
} while (!(--n == 0));
- cl_abort();
+ throw runtime_exception();
}
#if 0 // unused
}
v <<= 1;
} while (!(--n == 0));
- cl_abort();
+ throw runtime_exception();
}
#endif
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
- fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
- cl_abort();
+ throw runtime_exception("FFT problem: l > 64 not supported by pow2_table");
}
var fftcs_real carry = 0;
var sintL carrybits = 0; // number of bits in carry (>=0, <l)
i++;
}
if (i > N)
- cl_abort();
+ throw runtime_exception();
} else if (max_l(2) >= intDsize && l == intDsize) {
// l = intDsize
if (len > N)
- cl_abort();
+ throw runtime_exception();
for (i = 0; i < len; i++) {
var uintD digit = lsprefnext(sourceptr);
x[i] = (fftcs_real)digit;
}
while (carrybits > 0) {
if (!(i < N))
- cl_abort();
+ throw runtime_exception();
x[i] = (fftcs_real)(carry & l_mask);
carry >>= l;
carrybits -= l;
i++;
}
if (len > 0)
- cl_abort();
+ throw runtime_exception();
}
for ( ; i < N; i++)
x[i] = (fftcs_real)0;
if (!(digit >= (fftcs_real)0
&& z[i] > digit - (fftcs_real)0.5
&& z[i] < digit + (fftcs_real)0.5))
- cl_abort();
+ throw runtime_exception();
#endif
if (shift > 0)
digit = digit * fftcs_pow2_table[shift];
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
- fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
- cl_abort();
+ throw runtime_exception("FFT problem: numbers too big, floating point precision not sufficient");
}
if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k))
break;
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p));
// Fill factor x.
for (var uintC i = 0; i < N; i++)
if (!(z[i] > re_lo_limit
&& z[i] < re_hi_limit))
- cl_abort();
+ throw runtime_exception();
}
#endif
var uintD* tmpLSDptr = arrayLSDptr(tmpprod,tmpprod_len);
tmpMSDptr - tmpLSDptr;
#endif
if (tmplen > tmpprod_len)
- cl_abort();
+ throw runtime_exception();
// Add result to destptr[-destlen..-1]:
if (tmplen > destlen) {
if (test_loop_msp(tmpMSDptr,tmplen-destlen))
- cl_abort();
+ throw runtime_exception();
tmplen = destlen;
}
if (addto_loop_lsp(tmpLSDptr,destptr,tmplen))
if (inc_loop_lsp(destptr lspop tmplen,destlen-tmplen))
- cl_abort();
+ throw runtime_exception();
}
// Decrement len2.
destptr = destptr lspop len2p;
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftcs_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
- fprint(std::cerr, "FFT problem: checksum error\n");
- cl_abort();
+ throw runtime_exception("FFT problem: checksum error");
}
}
var uintC zerodigits = chlen - zchlen;
for (i = 0; i < M; i++)
if (DS_test_loop(Z(i) lspop chlen,zerodigits,Z(i) lspop zchlen))
- cl_abort();
+ throw runtime_exception();
}
#endif
// Put together result.
if (zchlen <= destlen) {
if (addto_loop_lsp(Z(i),destptr,zchlen))
if (inc_loop_lsp(destptr lspop zchlen,destlen-zchlen))
- cl_abort();
+ throw runtime_exception();
} else {
#ifdef DEBUG_FFTM
if (DS_test_loop(Z(i) lspop zchlen,zchlen-destlen,Z(i) lspop destlen))
- cl_abort();
+ throw runtime_exception();
#endif
if (addto_loop_lsp(Z(i),destptr,destlen))
- cl_abort();
+ throw runtime_exception();
}
if (destlen <= k) {
i++;
#ifdef DEBUG_FFTM
// Check that Z(i)..Z(M-1) are all zero.
if (test_loop_up(&arrZ[chlen*i],chlen*(M-i)))
- cl_abort();
+ throw runtime_exception();
#endif
#undef diff
#undef sum
var uintC piecelen2 = (M+1-ceiling(len1,k))*k;
#ifdef DEBUG_FFTM
if ((sintC)piecelen2 <= 0)
- cl_abort();
+ throw runtime_exception();
#endif
return ceiling(len2,piecelen2);
}
}
#ifdef DEBUG_FFTM
if (!(m > 0 && m <= r+1 && okfor(r,m,len1,len1)))
- cl_abort();
+ throw runtime_exception();
#endif
if (okfor(r,m,len1,len2)) {
if ((m <= r) && (r > log2_intDsize+2) && okfor(r-1,m,len1,ceiling(len2,2)))
}
if (addto_loop_lsp(tmpptr,destptr,destlenp))
if (inc_loop_lsp(destptr lspop destlenp,destlen-destlenp))
- cl_abort();
+ throw runtime_exception();
// Decrement len2.
destptr = destptr lspop len2p;
destlen -= len2p;
#ifdef FFTP_EXTERNAL_LOOPS
#ifdef DEBUG_FFTP
if (shiftrightcopy_loop_msp(arrayMSDptr(a._w,3),arrayMSDptr(b._w,3),3,1,0))
- cl_abort();
+ throw runtime_exception();
#else
shiftrightcopy_loop_msp(arrayMSDptr(a._w,3),arrayMSDptr(b._w,3),3,1,0);
#endif
#ifdef DEBUG_FFTP
carry = tmp << 31;
if (carry)
- cl_abort();
+ throw runtime_exception();
#endif
#endif
}
#ifdef DEBUG_FFTP_OPERATIONS
-#define check_fftp_word(x) if (compare_loop_msp(arrayMSDptr((x)._w,3),arrayMSDptr(p._w,3),3) >= 0) cl_abort()
+#define check_fftp_word(x) if (compare_loop_msp(arrayMSDptr((x)._w,3),arrayMSDptr(p._w,3),3) >= 0) throw runtime_exception()
#else
#define check_fftp_word(x)
#endif
// c[0..3] now contains q, c[4..6] contains (c mod 7*2^n).
#ifdef DEBUG_FFTP
if (lspref(cLSDptr,6) > 0)
- cl_abort();
+ throw runtime_exception();
#endif
#if 0
if (compare_loop_msp(cLSDptr lspop 6,arrayMSDptr(p._w,3),3) >= 0) // q >= p ?
#error "mulp not implemented for this prime"
#endif
if ((sint32)r.w2 < 0)
- cl_abort();
+ throw runtime_exception();
check_fftp_word(r);
}
#ifdef DEBUG_FFTP_OPERATIONS
mulp(ma,mb, or);
mulp(a,b, r);
if (compare_loop_msp(arrayMSDptr(r._w,3),arrayMSDptr(or._w,3),3))
- cl_abort();
+ throw runtime_exception();
}
#define mulp mulp_doublecheck
#endif /* DEBUG_FFTP_OPERATIONS */
var fftp_word w_N;
mulp(w[N-1],fftp_roots_of_1[n], w_N);
if (!(w_N.w2 == 0 && w_N.w1 == 0 && w_N.w0 == 1))
- cl_abort();
+ throw runtime_exception();
w_N = w[N>>1];
if (!(w_N.w2 == p.w2 && w_N.w1 == p.w1 && w_N.w0 == p.w0 - 1))
- cl_abort();
+ throw runtime_exception();
}
#endif
var bool squaring = (x == y);
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var uintC destlenp = len1 + len2p - 1;
// destlenp = min(N,destlen-1).
// Check result.
for (i = 0; i < N; i++)
if (!(z[i].w2 < N))
- cl_abort();
+ throw runtime_exception();
#endif
// Add result to destptr[-destlen..-1]:
{
// ac2 = 0.
if (ac1 > 0) {
if (!((i += 2) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
if ((ac0 += tmp) < tmp)
++ac1;
lsshrink(ptr);
if (ac1 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
} else if (ac0 > 0) {
if (!((i += 1) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
ac0 += tmp;
lspref(ptr,0) = ac0;
lsshrink(ptr);
if (ac0 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
}
}
#ifdef DEBUG_FFTP
// If destlenp < N, check that the remaining z[i] are 0.
for (i = destlenp; i < N; i++)
if (z[i].w2 > 0 || z[i].w1 > 0 || z[i].w0 > 0)
- cl_abort();
+ throw runtime_exception();
#endif
}
// Decrement len2.
#define FFTP3_BACKWARD CLEVER
#ifdef DEBUG_FFTP3_OPERATIONS
-#define check_fftp3_word(x) if ((x.w1 >= p1) || (x.w2 >= p2) || (x.w3 >= p3)) cl_abort()
+#define check_fftp3_word(x) if ((x.w1 >= p1) || (x.w2 >= p2) || (x.w3 >= p3)) throw runtime_exception()
#else
#define check_fftp3_word(x)
#endif
mulp3(ma,mb, or);
mulp3(a,b, r);
if (!((r.w1 == or.w1) && (r.w2 == or.w2) && (r.w3 == or.w3)))
- cl_abort();
+ throw runtime_exception();
}
#define mulp3 mulp3_doublecheck
#endif /* DEBUG_FFTP3_OPERATIONS */
var fftp3_word w_N;
mulp3(w[N-1],fftp3_roots_of_1[n], w_N);
if (!(w_N.w1 == 1 && w_N.w2 == 1 && w_N.w3 == 1))
- cl_abort();
+ throw runtime_exception();
w_N = w[N>>1];
if (!(w_N.w1 == p1-1 && w_N.w2 == p2-1 && w_N.w3 == p3-1))
- cl_abort();
+ throw runtime_exception();
}
#endif
var bool squaring = (x == y);
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var uintC destlenp = len1 + len2p - 1;
// destlenp = min(N,destlen-1).
combinep3(z[i],arrayLSDptr(z_i,3));
#ifdef DEBUG_FFTP3
if (!(arrayLSref(z_i,3,2) < N))
- cl_abort();
+ throw runtime_exception();
#endif
// Add z[i] to the accumulator.
tmp = arrayLSref(z_i,3,0);
// ac2 = 0.
if (ac1 > 0) {
if (!((i += 2) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
if ((ac0 += tmp) < tmp)
++ac1;
lsshrink(ptr);
if (ac1 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
} else if (ac0 > 0) {
if (!((i += 1) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
ac0 += tmp;
lspref(ptr,0) = ac0;
lsshrink(ptr);
if (ac0 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
}
}
#ifdef DEBUG_FFTP3
// If destlenp < N, check that the remaining z[i] are 0.
for (i = destlenp; i < N; i++)
if (z[i].w1 > 0 || z[i].w2 > 0 || z[i].w3 > 0)
- cl_abort();
+ throw runtime_exception();
#endif
}
// Decrement len2.
#define FFTP3M_BACKWARD CLEVER
#ifdef DEBUG_FFTP3M_OPERATIONS
-#define check_fftp3m_word(x) if ((x.w1 >= p1) || (x.w2 >= p2) || (x.w3 >= p3)) cl_abort()
+#define check_fftp3m_word(x) if ((x.w1 >= p1) || (x.w2 >= p2) || (x.w3 >= p3)) throw runtime_exception()
#else
#define check_fftp3m_word(x)
#endif
#endif
#ifdef DEBUG_FFTP3M_OPERATIONS
if (compare_loop_msp(sumLSDptr lspop 3,arrayMSDptr(p123,3),3) >= 0)
- cl_abort();
+ throw runtime_exception();
#endif
// Renormalize the division's remainder: shift right by 4 bits.
shiftrightcopy_loop_msp(sumLSDptr lspop 3,resLSDptr lspop 3,3,4,0);
divu_6432_3232(hi,lo,p, ,tmp=); \
if (tmp != 0) { tmp = p-tmp; } \
if (tmp != r) \
- cl_abort(); \
+ throw runtime_exception(); \
* endif DEBUG_FFTP3M_OPERATIONS */ \
result_zuweisung r; \
}
mulp3m(ma,mb, or);
mulp3m(a,b, r);
if (!((r.w1 == or.w1) && (r.w2 == or.w2) && (r.w3 == or.w3)))
- cl_abort();
+ throw runtime_exception();
}
#define mulp3m mulp3m_doublecheck
#endif /* DEBUG_FFTP3M_OPERATIONS */
if (!( w_N.w1 == (uint32)1<<n1
&& w_N.w2 == (uint32)1<<n2
&& w_N.w3 == (uint32)1<<n3))
- cl_abort();
+ throw runtime_exception();
w_N = w[N>>1];
if (!( w_N.w1 == p1-((uint32)1<<n1)
&& w_N.w2 == p2-((uint32)1<<n2)
&& w_N.w3 == p3-((uint32)1<<n3)))
- cl_abort();
+ throw runtime_exception();
}
#endif
var bool squaring = (x == y);
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var uintC destlenp = len1 + len2p - 1;
// destlenp = min(N,destlen-1).
combinep3m(z[i],arrayLSDptr(z_i,3));
#ifdef DEBUG_FFTP3M
if (!(arrayLSref(z_i,3,2) < N))
- cl_abort();
+ throw runtime_exception();
#endif
// Add z[i] to the accumulator.
tmp = arrayLSref(z_i,3,0);
// ac2 = 0.
if (ac1 > 0) {
if (!((i += 2) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
if ((ac0 += tmp) < tmp)
++ac1;
lsshrink(ptr);
if (ac1 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
} else if (ac0 > 0) {
if (!((i += 1) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
ac0 += tmp;
lspref(ptr,0) = ac0;
lsshrink(ptr);
if (ac0 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
}
}
#ifdef DEBUG_FFTP3M
// If destlenp < N, check that the remaining z[i] are 0.
for (i = destlenp; i < N; i++)
if (z[i].w1 > 0 || z[i].w2 > 0 || z[i].w3 > 0)
- cl_abort();
+ throw runtime_exception();
#endif
}
// Decrement len2.
#include "cln/floatparam.h"
-#include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#if defined(HAVE_LONGDOUBLE) && (long_double_mant_bits > double_mant_bits) && (defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && 0))
}
x >>= 1;
} while (!(--n == 0));
- cl_abort();
+ throw runtime_exception();
}
#if 0 // unused
}
v <<= 1;
} while (!(--n == 0));
- cl_abort();
+ throw runtime_exception();
}
#endif
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
- fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
- cl_abort();
+ throw runtime_exception("FFT problem: l > 64 not supported by pow2_table");
}
var fftr_real carry = 0;
var sintL carrybits = 0; // number of bits in carry (>=0, <l)
i++;
}
if (i > N)
- cl_abort();
+ throw runtime_exception();
} else if (max_l(2) >= intDsize && l == intDsize) {
// l = intDsize
if (len > N)
- cl_abort();
+ throw runtime_exception();
for (i = 0; i < len; i++) {
var uintD digit = lsprefnext(sourceptr);
x[i] = (fftr_real)digit;
}
while (carrybits > 0) {
if (!(i < N))
- cl_abort();
+ throw runtime_exception();
x[i] = (fftr_real)(carry & l_mask);
carry >>= l;
carrybits -= l;
i++;
}
if (len > 0)
- cl_abort();
+ throw runtime_exception();
}
for ( ; i < N; i++)
x[i] = (fftr_real)0;
if (!(digit >= (fftr_real)0
&& z[i] > digit - (fftr_real)0.5
&& z[i] < digit + (fftr_real)0.5))
- cl_abort();
+ throw runtime_exception();
#endif
if (shift > 0)
digit = digit * fftr_pow2_table[shift];
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
- fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
- cl_abort();
+ throw runtime_exception("FFT problem: numbers too big, floating point precision not sufficient");
}
if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k))
break;
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p));
// Fill factor x.
for (var uintC i = 0; i < N; i++)
if (!(z[i] > re_lo_limit
&& z[i] < re_hi_limit))
- cl_abort();
+ throw runtime_exception();
}
#endif
var uintD* tmpLSDptr = arrayLSDptr(tmpprod,tmpprod_len);
tmpMSDptr - tmpLSDptr;
#endif
if (tmplen > tmpprod_len)
- cl_abort();
+ throw runtime_exception();
// Add result to destptr[-destlen..-1]:
if (tmplen > destlen) {
if (test_loop_msp(tmpMSDptr,tmplen-destlen))
- cl_abort();
+ throw runtime_exception();
tmplen = destlen;
}
if (addto_loop_lsp(tmpLSDptr,destptr,tmplen))
if (inc_loop_lsp(destptr lspop tmplen,destlen-tmplen))
- cl_abort();
+ throw runtime_exception();
}
// Decrement len2.
destptr = destptr lspop len2p;
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftr_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
- fprint(std::cerr, "FFT problem: checksum error\n");
- cl_abort();
+ throw runtime_exception("FFT problem: checksum error.");
}
}
subfrom_loop_lsp(arrayLSDptr(a._iw,2),arrayLSDptr(or._ow,4) lspop 2,2);
mul(a,b, r);
if (compare_loop_msp(arrayMSDptr(r._ow,4),arrayMSDptr(or._ow,4),4))
- cl_abort();
+ throw runtime_exception();
}
#define mul mul_doublecheck
#endif
#elif defined(NUSS_OUT_EXTERNAL_LOOPS)
#ifdef DEBUG_NUSS
if (shiftrightcopy_loop_msp(arrayMSDptr(a._ow,4),arrayMSDptr(b._ow,4),4,1,mspref(arrayMSDptr(a._ow,4),0)>>31))
- cl_abort();
+ throw runtime_exception();
#else
shiftrightcopy_loop_msp(arrayMSDptr(a._ow,4),arrayMSDptr(b._ow,4),4,1,mspref(arrayMSDptr(a._ow,4),0)>>31);
#endif
#ifdef DEBUG_NUSS
carry = tmp << 31;
if (carry)
- cl_abort();
+ throw runtime_exception();
#endif
#endif
}
#ifdef NUSS_OUT_EXTERNAL_LOOPS
#ifdef DEBUG_NUSS
if (shiftrightcopy_loop_msp(arrayMSDptr(a._ow,3),arrayMSDptr(b._ow,3),3,1,mspref(arrayMSDptr(a._ow,3),0)>>63))
- cl_abort();
+ throw runtime_exception();
#else
shiftrightcopy_loop_msp(arrayMSDptr(a._ow,3),arrayMSDptr(b._ow,3),3,1,mspref(arrayMSDptr(a._ow,3),0)>>63);
#endif
#ifdef DEBUG_NUSS
carry = tmp << 63;
if (carry)
- cl_abort();
+ throw runtime_exception();
#endif
#endif
}
mulu_loop_lsp(lspref(sourceptr2,0),sourceptr1,tmpptr,len1);
if (addto_loop_lsp(tmpptr,destptr,len1+1))
if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1)))
- cl_abort();
+ throw runtime_exception();
} else {
var uintC destlenp = len1 + len2p - 1;
// destlenp = min(N,destlen-1).
// Check result.
for (i = 0; i < N; i++)
if (!(z[i].ow3 == 0))
- cl_abort();
+ throw runtime_exception();
#endif
// Add result to destptr[-destlen..-1]:
{
// ac2 = 0.
if (ac1 > 0) {
if (!((i += 2) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
if ((ac0 += tmp) < tmp)
++ac1;
lsshrink(ptr);
if (ac1 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
} else if (ac0 > 0) {
if (!((i += 1) <= destlen))
- cl_abort();
+ throw runtime_exception();
tmp = lspref(ptr,0);
ac0 += tmp;
lspref(ptr,0) = ac0;
lsshrink(ptr);
if (ac0 < tmp)
if (inc_loop_lsp(ptr,destlen-i))
- cl_abort();
+ throw runtime_exception();
}
}
#ifdef DEBUG_NUSS
// If destlenp < N, check that the remaining z[i] are 0.
for (i = destlenp; i < N; i++)
if (z[i].ow2 > 0 || z[i].ow1 > 0 || z[i].ow0 > 0)
- cl_abort();
+ throw runtime_exception();
#endif
}
// Decrement len2.
// Implementation.
-#include "cln/abort.h"
-
namespace cln {
// Compute the reciprocal value of a digit sequence.
// Implementation.
#include "cl_low.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// xm*yn*yn < 1
{ neg_loop_lsp(y3_MSDptr mspop (m+2),m+2);
mspref(y3_MSDptr,0) += 1;
- if (test_loop_msp(y3_MSDptr,n)) cl_abort(); // check 0 <= y3 < beta^-(n-1)
+ if (test_loop_msp(y3_MSDptr,n)) throw runtime_exception(); // check 0 <= y3 < beta^-(n-1)
cl_UDS_mul(y_MSDptr mspop (n+2),n+2,
y3_MSDptr mspop (m+2),m+2-n,
y4_MSDptr mspop (m+4));
shift1right_loop_msp(y4_MSDptr,m+3-n,0);
if (addto_loop_lsp(y4_MSDptr mspop (m+3-n),y_MSDptr mspop (m+2),m+3-n))
- if ((n<1) || inc_loop_lsp(y_MSDptr mspop (n-1),n-1)) cl_abort();
+ if ((n<1) || inc_loop_lsp(y_MSDptr mspop (n-1),n-1)) throw runtime_exception();
}
else
// xm*yn*yn >= 1 (this can happen since xm >= xn)
{ mspref(y3_MSDptr,0) -= 1;
- if (test_loop_msp(y3_MSDptr,n)) cl_abort(); // check 0 >= y3 > -beta^-(n-1)
+ if (test_loop_msp(y3_MSDptr,n)) throw runtime_exception(); // check 0 >= y3 > -beta^-(n-1)
cl_UDS_mul(y_MSDptr mspop (n+2),n+2,
y3_MSDptr mspop (m+2),m+2-n,
y4_MSDptr mspop (m+4));
shift1right_loop_msp(y4_MSDptr,m+3-n,0);
if (subfrom_loop_lsp(y4_MSDptr mspop (m+3-n),y_MSDptr mspop (m+2),m+3-n))
- if ((n<1) || dec_loop_lsp(y_MSDptr mspop (n-1),n-1)) cl_abort();
+ if ((n<1) || dec_loop_lsp(y_MSDptr mspop (n-1),n-1)) throw runtime_exception();
}
n = m;
// n = ceiling(b_len/2^k) limbs of y have now been computed.
// Implementation.
#include "cl_low.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// 1/4 <= d < 2, | sqrt(a) - d | < beta^-n.
if (mspref(d_MSDptr,0) > 0)
{ dec_loop_lsp(d_MSDptr mspop (n+1),n+1);
- if (mspref(d_MSDptr,0) > 0) cl_abort();
+ if (mspref(d_MSDptr,0) > 0) throw runtime_exception();
}
// D is our guess for B. Square to see how much we have to correct.
cl_UDS_mul_square(d_MSDptr mspop (1+n),n,d2_MSDptr mspop 2*n);
{ dec_loop_lsp(b_->LSDptr,n);
dec_loop_lsp(d_MSDptr mspop (1+n),1+n); // store 2*D+1
if (!addto_loop_lsp(d_MSDptr mspop (1+n),a_MSDptr mspop 2*n,1+n))
- cl_abort();
+ throw runtime_exception();
if (!inc_loop_lsp(a_MSDptr mspop (n-1),n-1))
- cl_abort();
+ throw runtime_exception();
}
else if (test_loop_msp(a_MSDptr,n-1))
// guessed way too low
- cl_abort();
+ throw runtime_exception();
else if (compare_loop_msp(a_MSDptr mspop (n-1),d_MSDptr,1+n) > 0)
// guessed too low, increment D
{ inc_loop_lsp(b_->LSDptr,n);
subfrom_loop_lsp(d_MSDptr mspop (1+n),a_MSDptr mspop 2*n,1+n);
inc_loop_lsp(d_MSDptr mspop (1+n),1+n); // store 2*D
if (compare_loop_msp(a_MSDptr mspop (n-1),d_MSDptr,1+n) > 0)
- cl_abort();
+ throw runtime_exception();
}
else
// guessed ok
#include "cln/object.h"
#include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_iterator.h"
namespace cln {
return index;
}
#if !(defined(__hppa__) && !defined(__GNUC__)) // workaround HP CC problem
- cl_abort();
+ throw runtime_exception();
#endif
return -1; // dummy
}
htentry& next ()
{
if (_index < 0)
- cl_abort();
+ throw runtime_exception();
var long old_index = _index;
do { _index--; }
while (_index >= 0 && _entries[_index].next < 0);
var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key))
return &this->_entries[index].entry.val;
index = this->_entries[index].next - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key)) {
this->_entries[index].entry.val = val;
return;
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key)) {
// Remove _entries[index].entry
*_index = this->_entries[index].next;
ht->remove(entry.key);
if (entry.val.pointer_p()) {
var cl_heap* p = entry.val.heappointer;
- if (!(--p->refcount == 0)) cl_abort();
+ if (!(--p->refcount == 0)) throw runtime_exception();
cl_free_heap_object(p);
}
removed++;
var long index = this->_slots[hashcode(key1,key2) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2))
return &this->_entries[index].entry.val;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2)) {
this->_entries[index].entry.val = val;
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2)) {
// Remove _entries[index].entry
ht->remove(entry.key1,entry.key2);
if (entry.val.pointer_p()) {
var cl_heap* p = entry.val.heappointer;
- if (!(--p->refcount == 0)) cl_abort();
+ if (!(--p->refcount == 0)) throw runtime_exception();
cl_free_heap_object(p);
}
removed++;
var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key))
return true;
index = this->_entries[index].next - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key))
return;
index = this->_entries[index].next - 1;
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,this->_entries[index].entry.key)) {
// Remove _entries[index].entry
*_index = this->_entries[index].next;
var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,hashkey(this->_entries[index].entry.val)))
return &this->_entries[index].entry.val;
index = this->_entries[index].next - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,hashkey(this->_entries[index].entry.val)))
return;
index = this->_entries[index].next - 1;
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < this->_size))
- cl_abort();
+ throw runtime_exception();
if (equal(key,hashkey(this->_entries[index].entry.val))) {
// Remove _entries[index].entry
*_index = this->_entries[index].next;
ht->remove(hashkey(v));
if (v.pointer_p()) {
var cl_heap* p = v.heappointer;
- if (!(--p->refcount == 0)) cl_abort();
+ if (!(--p->refcount == 0)) throw runtime_exception();
cl_free_heap_object(p);
}
removed++;
--- /dev/null
+// read_number_bad_syntax_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/number_io.h"
+
+
+// Implementation.
+
+#include <sstream>
+#include "cln/io.h"
+
+namespace cln {
+
+static inline const std::string
+read_number_bad_syntax_msg (const char * string, const char * string_limit)
+{
+ std::ostringstream buf;
+ fprint(buf, "Illegal number syntax: \"");
+ for (const char * ptr = string; ptr != string_limit; ptr++)
+ fprintchar(buf, *ptr);
+ fprint(buf, "\"");
+ return buf.str();
+}
+
+read_number_bad_syntax_exception::read_number_bad_syntax_exception (const char * string, const char * string_limit)
+ : read_number_exception(read_number_bad_syntax_msg(string, string_limit))
+{}
+
+} // namespace cln
-// read_number_eof().
+// read_number_eof_exception().
// General includes.
#include "cl_sysdep.h"
// Implementation.
#include "cln/io.h"
-#include "cln/abort.h"
namespace cln {
-void read_number_eof (void)
-{
- fprint(std::cerr, "read_number: end of stream encountered\n");
- cl_abort();
-}
+read_number_eof_exception::read_number_eof_exception ()
+ : read_number_exception("read_number: end of stream encountered")
+{}
} // namespace cln
+++ /dev/null
-// read_number_bad_syntax().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cln/number_io.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void read_number_bad_syntax (const char * string, const char * string_limit)
-{
- fprint(std::cerr, "Illegal number syntax: \"");
- for (const char * ptr = string; ptr != string_limit; ptr++)
- fprintchar(std::cerr, *ptr);
- fprint(std::cerr, "\"\n");
- cl_abort();
-}
-
-} // namespace cln
+++ /dev/null
-// read_number_junk().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cln/number_io.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void read_number_junk (const char * string_rest, const char * string, const char * string_limit)
-{
- fprint(std::cerr, "Junk after number: ");
- { for (const char * ptr = string; ptr != string_rest; ptr++)
- fprintchar(std::cerr, *ptr);
- }
- fprint(std::cerr, "\"");
- { for (const char * ptr = string_rest; ptr != string_limit; ptr++)
- fprintchar(std::cerr, *ptr);
- }
- fprint(std::cerr, "\"\n");
- cl_abort();
-}
-
-} // namespace cln
--- /dev/null
+// read_number_junk_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/number_io.h"
+
+
+// Implementation.
+
+#include <sstream>
+#include "cln/io.h"
+
+namespace cln {
+
+static inline const std::string
+read_number_junk_msg (const char * string_rest, const char * string, const char * string_limit)
+{
+ std::ostringstream buf;
+ fprint(buf, "Junk after number: ");
+ { for (const char * ptr = string; ptr != string_rest; ptr++)
+ fprintchar(buf, *ptr);
+ }
+ fprint(buf, "\"");
+ { for (const char * ptr = string_rest; ptr != string_limit; ptr++)
+ fprintchar(buf, *ptr);
+ }
+ fprint(buf, "\"");
+ return buf.str();
+}
+
+read_number_junk_exception::read_number_junk_exception (const char * string_rest, const char * string, const char * string_limit)
+ : read_number_exception(read_number_junk_msg(string_rest, string, string_limit))
+{}
+
+} // namespace cln
// Implementation.
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
void cl_property_list::add_property (cl_property* new_property)
{
if (new_property->next)
- cl_abort();
+ throw runtime_exception();
new_property->next = list;
list = new_property;
}
// Implementation.
+#include <sstream>
#include "cln/io.h"
-#include "cln/abort.h"
namespace cln {
-nonreturning_function(static, uninitialized_ring, (void));
-static void uninitialized_ring ()
+uninitialized_ring_exception::uninitialized_ring_exception ()
+ : runtime_exception("Uninitialized ring operation called.")
+{}
+
+static inline const std::string
+uninitialized_error_msg (const _cl_ring_element& obj)
{
- fprint(std::cerr, "Uninitialized ring operation called\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Uninitialized ring element @0x");
+ fprinthexadecimal(buf, (unsigned long)(void*)&obj);
+ fprint(buf, ": 0x");
+ fprinthexadecimal(buf, (unsigned long)obj.rep.word);
+ return buf.str();
}
-nonreturning_function(static, uninitialized_error, (const _cl_ring_element&));
-static void uninitialized_error (const _cl_ring_element& obj)
+static inline const std::string
+uninitialized_error_msg (const _cl_ring_element& obj_x, const _cl_ring_element& obj_y)
{
- fprint(std::cerr, "Uninitialized ring element @0x");
- fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
- fprint(std::cerr, ": 0x");
- fprinthexadecimal(std::cerr, (unsigned long)obj.rep.word);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Uninitialized ring elements @0x");
+ fprinthexadecimal(buf, (unsigned long)(void*)&obj_x);
+ fprint(buf, ": 0x");
+ fprinthexadecimal(buf, (unsigned long)obj_x.rep.word);
+ fprint(buf, ", @0x");
+ fprinthexadecimal(buf, (unsigned long)(void*)&obj_y);
+ fprint(buf, ": 0x");
+ fprinthexadecimal(buf, (unsigned long)obj_y.rep.word);
+ return buf.str();
}
-#if (defined(__sparc__) && !defined(__GNUC__))
- // avoid Sun C++ 4.1 compiler bug
- #define RETDUMMY return *(_cl_ring_element*)R
-#else
- #define RETDUMMY return *(_cl_ring_element*)0
-#endif
+uninitialized_exception::uninitialized_exception (const _cl_ring_element& obj)
+ : runtime_exception(uninitialized_error_msg(obj))
+{}
+
+uninitialized_exception::uninitialized_exception (const _cl_ring_element& obj_x, const _cl_ring_element& obj_y)
+ : runtime_exception(uninitialized_error_msg(obj_x, obj_y))
+{}
+
static const _cl_ring_element dummy_op0 (cl_heap_ring* R)
{
unused R;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
static const _cl_ring_element dummy_op1 (cl_heap_ring* R, const _cl_ring_element& x)
{
unused R;
- uninitialized_error(x); RETDUMMY;
+ throw uninitialized_exception(x);
}
static const _cl_ring_element dummy_op2 (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
{
unused R;
- uninitialized_error(x); uninitialized_error(y); RETDUMMY;
+ throw uninitialized_exception(x, y);
}
static void dummy_fprint (cl_heap_ring* R, std::ostream& stream, const _cl_ring_element& x)
{
unused R;
unused stream;
- uninitialized_error(x);
+ throw uninitialized_exception(x);
}
static cl_boolean dummy_equal (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
{
unused R;
- uninitialized_error(x); uninitialized_error(y); return cl_false;
+ throw uninitialized_exception(x, y);
}
#define dummy_zero dummy_op0
static cl_boolean dummy_zerop (cl_heap_ring* R, const _cl_ring_element& x)
{
unused R;
- uninitialized_error(x); return cl_false;
+ throw uninitialized_exception(x);
}
#define dummy_plus dummy_op2
#define dummy_minus dummy_op2
{
unused R;
(void)&x; // unused x;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
#define dummy_mul dummy_op2
#define dummy_square dummy_op1
{
unused R;
(void)&y; // unused y;
- uninitialized_error(x); RETDUMMY;
+ throw uninitialized_exception(x);
}
static cl_ring_setops dummy_setops = {
#include "cln/object.h"
#include "cln/malloc.h"
#include "cl_sstring.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
}
inline char cl_spushstring::operator[] (uintL i) const
{
- if (!(i < index)) cl_abort();
+ if (!(i < index)) throw runtime_exception();
return buffer[i];
}
symbol_table.put(s);
sym_in_table = symbol_table.get(s);
if (!sym_in_table)
- cl_abort();
+ throw runtime_exception();
}
var cl_heap* p = sym_in_table->heappointer;
cl_inc_pointer_refcount(p);
// Implementation.
#include <cstring>
+#include <sstream>
#include "cln/input.h"
#include "cln/real_io.h"
#include "cln/float_io.h"
#include "cl_I.h"
#include "cl_F.h"
#include "cl_C.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
if (end_of_parse) \
{ *end_of_parse = (ptr); } \
else \
- { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } }
+ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } }
const cl_N read_complex (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
{
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
- fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
- fprint(std::cerr, base);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Base must be an integer in the range from 2 to 36, not ");
+ fprint(buf, base);
+ throw runtime_exception(buf.str());
}
rational_base = FN_to_UV(base); ptr = base_end_ptr;
break;
*end_of_parse = string;
return 0; // dummy return
}
- read_number_bad_syntax(string,string_limit);
+ throw read_number_bad_syntax_exception(string,string_limit);
}
static const cl_N read_complex_number_rest (const cl_read_flags& flags, const char * string_rest, const char * string, const char * string_limit, const char * * end_of_parse, const cl_R& x)
// Handle syntax error.
syntax1: buffer.push(c);
-syntax: read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+syntax: throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln
// Implementation.
#include "cl_N.h"
+#include "cln/exception.h"
namespace cln {
DeclareType(cl_N,x);
return x;
} else
- cl_as_error(x,"a number",filename,line);
+ throw as_exception(x,"a number",filename,line);
}
} // namespace cln
var cl_R v;
if (!minusp(xx)) {
if (zerop(xx))
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
v = 0;
} else {
// (1+x)/(1-x) < 0 -> Betrag nehmen, Imaginärteil berechnen:
var cl_F num = _1_plus_x*_1_plus_x + yf_2; // (1+x)^2+y^2, ein Float >=0
var cl_F den = _1_minus_x*_1_minus_x + yf_2; // (1-x)^2+y^2, ein Float >=0
if (zerop(den))
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
u = scale_float(ln(num/den),-2);
}
}
if (rationalp(realpart(y))) // Realteil von y >0 exakt.
return 0;
if (!plusp(realpart(y))) // Realteil von y <=0 ?
- cl_error_division_by_0();
+ throw division_by_0_exception();
else {
var cl_R f = contagion(contagion(x),contagion(y));
// ein Float, da sonst x = Fixnum 0 gewesen wäre
// (complex (log (abs x)) (phase x))
var cl_R r = abs(x);
if (zerop(r)) // (abs x) = 0 -> Error
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
return complex(ln(r),phase(x));
}
{
var cl_R angle = phase(a);
if (eq(angle,0)) // = Fixnum 0 <==> (= a 0) -> Error
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
{ DeclareType(cl_F,angle);
var cl_F bf = cl_somefloat(b,angle); // (float b)
im = angle / ln(bf);
+++ /dev/null
-// cl_error_floating_point_overflow().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_F.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_error_floating_point_nan (void)
-{
- fprint(std::cerr, "floating point NaN occurred.\n");
- cl_abort();
-}
-
-} // namespace cln
+++ /dev/null
-// cl_error_floating_point_overflow().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_F.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_error_floating_point_overflow (void)
-{
- fprint(std::cerr, "Floating point overflow.\n");
- cl_abort();
-}
-
-} // namespace cln
+++ /dev/null
-// cl_error_floating_point_underflow().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_F.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_error_floating_point_underflow (void)
-{
- fprint(std::cerr, "Floating point underflow.\n");
- cl_abort();
-}
-
-} // namespace cln
--- /dev/null
+// floating_point_nan_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cl_F.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+
+namespace cln {
+
+floating_point_nan_exception::floating_point_nan_exception ()
+ : floating_point_exception("floating point NaN occurred.")
+{}
+
+} // namespace cln
--- /dev/null
+// floating_point_overflow_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cl_F.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+
+namespace cln {
+
+floating_point_overflow_exception::floating_point_overflow_exception ()
+ : floating_point_exception("floating point overflow.")
+{}
+
+} // namespace cln
--- /dev/null
+// floating_point_underflow_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cl_F.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+
+namespace cln {
+
+floating_point_underflow_exception::floating_point_underflow_exception ()
+ : floating_point_exception("floating point underflow.")
+{}
+
+} // namespace cln
namespace cln {
-nonreturning_function(extern, cl_error_floating_point_overflow, (void));
-nonreturning_function(extern, cl_error_floating_point_underflow, (void));
-
#define underflow_allowed() (! cl_inhibit_floating_point_underflow)
extern const cl_DF cl_LF_to_DF (const cl_LF& x);
-// Fehlermeldung wegen NaN
-nonreturning_function(extern, cl_error_floating_point_nan, (void));
-
-
// Runtime typing support.
extern cl_class cl_class_ffloat;
extern cl_class cl_class_dfloat;
{
if (exp < (sintL)(DF_exp_low-DF_exp_mid))
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; }
}
else
if (exp > (sintL)(DF_exp_high-DF_exp_mid))
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
else
return allocate_dfloat
( ((sint64)sign & bit(63)) /* Vorzeichen */
{
if (exp < (sintL)(DF_exp_low-DF_exp_mid))
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; }
}
else
if (exp > (sintL)(DF_exp_high-DF_exp_mid))
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
else
return allocate_dfloat
( ((sint32)sign & bit(31)) /* Vorzeichen */
) \
&& underflow_allowed() \
) \
- { cl_error_floating_point_underflow(); } /* subnormal oder noch kleiner -> Underflow */\
+ { throw floating_point_underflow_exception(); } /* subnormal oder noch kleiner -> Underflow */\
else \
{ ergebnis_zuweisung cl_DF_0; } /* +/- 0.0 -> 0.0 */ \
} \
&& (((~_erg.eksplicit) & ((uint64)bit(DF_exp_len+DF_mant_len)-bit(DF_mant_len))) == 0) /* e=2047 ? */\
) \
{ if (maybe_nan && !((_erg.eksplicit<<(64-DF_mant_len)) == 0)) \
- { cl_error_division_by_0(); } /* NaN, also Singularität -> "Division durch 0" */\
+ { throw division_by_0_exception(); } /* NaN, also Singularität -> "Division durch 0" */\
else /* Infinity */ \
if (!maybe_overflow || maybe_divide_0) \
- { cl_error_division_by_0(); } /* Infinity, Division durch 0 */\
+ { throw division_by_0_exception(); } /* Infinity, Division durch 0 */\
else \
- { cl_error_floating_point_overflow(); } /* Infinity, Overflow */\
+ { throw floating_point_overflow_exception(); } /* Infinity, Overflow */\
} \
else \
{ ergebnis_zuweisung allocate_dfloat(_erg.eksplicit); } \
) ) \
&& underflow_allowed() \
) \
- { cl_error_floating_point_underflow(); } /* subnormal oder noch kleiner -> Underflow */\
+ { throw floating_point_underflow_exception(); } /* subnormal oder noch kleiner -> Underflow */\
else \
{ ergebnis_zuweisung cl_DF_0; } /* +/- 0.0 -> 0.0 */\
} \
&& (((~_erg.eksplicit.semhi) & ((uint32)bit(DF_exp_len+DF_mant_len-32)-bit(DF_mant_len-32))) == 0) /* e=2047 ? */\
) \
{ if (maybe_nan && !(((_erg.eksplicit.semhi<<(64-DF_mant_len)) == 0) && (_erg.eksplicit.mlo==0))) \
- { cl_error_division_by_0(); } /* NaN, also Singularität -> "Division durch 0" */\
+ { throw division_by_0_exception(); } /* NaN, also Singularität -> "Division durch 0" */\
else /* Infinity */\
if (!maybe_overflow || maybe_divide_0) \
- { cl_error_division_by_0(); } /* Infinity, Division durch 0 */\
+ { throw division_by_0_exception(); } /* Infinity, Division durch 0 */\
else \
- { cl_error_floating_point_overflow(); } /* Infinity, Overflow */\
+ { throw floating_point_overflow_exception(); } /* Infinity, Overflow */\
} \
else \
{ ergebnis_zuweisung allocate_dfloat(_erg.eksplicit.semhi,_erg.eksplicit.mlo); } \
if (exp == 0) // e=0 ?
// vorzeichenbehaftete 0.0 oder subnormale Zahl
{ if (!((val << 1) == 0) && underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; } // +/- 0.0 -> 0.0
}
elif (exp == 2047) // e=2047 ?
{ if (!((val << (64-DF_mant_len)) == 0))
- { cl_error_floating_point_nan(); } // NaN
+ { throw floating_point_nan_exception(); } // NaN
else
- { cl_error_floating_point_overflow(); } // Infinity, Overflow
+ { throw floating_point_overflow_exception(); } // Infinity, Overflow
}
else
{ // Der Exponent muß um DF_exp_mid-1022 erhöht werden.
if ((DF_exp_mid>1022) && (exp > DF_exp_high-DF_exp_mid+1022))
- { cl_error_floating_point_overflow(); } // Overflow
+ { throw floating_point_overflow_exception(); } // Overflow
val += (sint64)(DF_exp_mid - 1022) << DF_mant_len;
return allocate_dfloat(val);
}
if (exp == 0) // e=0 ?
// vorzeichenbehaftete 0.0 oder subnormale Zahl
{ if (!(((val.semhi << 1) == 0) && (val.mlo == 0)) && underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; } // +/- 0.0 -> 0.0
}
elif (exp == 2047) // e=2047 ?
{ if (!(((val.semhi << (64-DF_mant_len)) == 0) && (val.mlo == 0)))
- { cl_error_floating_point_nan(); } // NaN
+ { throw floating_point_nan_exception(); } // NaN
else
- { cl_error_floating_point_overflow(); } // Infinity, Overflow
+ { throw floating_point_overflow_exception(); } // Infinity, Overflow
}
else
{ // Der Exponent muß um DF_exp_mid-1022 erhöht werden.
if ((DF_exp_mid>1022) && (exp > DF_exp_high-DF_exp_mid+1022))
- { cl_error_floating_point_overflow(); } // Overflow
+ { throw floating_point_overflow_exception(); } // Overflow
val.semhi += (sint32)(DF_exp_mid - 1022) << (DF_mant_len-32);
return allocate_dfloat(val.semhi,val.mlo);
}
#if (cl_word_size==64)
var uint64 mantx1;
var uint64 mantx2;
- DF_decode(x2, { cl_error_division_by_0(); }, sign2=,exp2=,mantx2=);
+ DF_decode(x2, { throw division_by_0_exception(); }, sign2=,exp2=,mantx2=);
DF_decode(x1, { return x1; }, sign1=,exp1=,mantx1=);
#else
- DF_decode2(x2, { cl_error_division_by_0(); }, sign2=,exp2=,manthi2=,mantlo2=);
+ DF_decode2(x2, { throw division_by_0_exception(); }, sign2=,exp2=,manthi2=,mantlo2=);
DF_decode2(x1, { return x1; }, sign1=,exp1=,manthi1=,mantlo1=);
#endif
exp1 = exp1 - exp2; // Differenz der Exponenten
var sintC lendiff = (sintC)integer_length(a) // (integer-length a)
- (sintC)integer_length(b); // (integer-length b)
if (lendiff > DF_exp_high-DF_exp_mid) // Exponent >= n-m > Obergrenze ?
- { cl_error_floating_point_overflow(); } // -> Overflow
+ { throw floating_point_overflow_exception(); } // -> Overflow
if (lendiff < DF_exp_low-DF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ?
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); } // -> Underflow
+ { throw floating_point_underflow_exception(); } // -> Underflow
else
{ return cl_DF_0; }
}
#endif
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; }
}
#endif
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_DF_0; }
}
DeclareType(cl_DF,x);
return x;
} else
- cl_as_error(x,"a double-float number",filename,line);
+ throw as_exception(x,"a double-float number",filename,line);
}
} // namespace cln
{
if (exp < (sintL)(FF_exp_low-FF_exp_mid))
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_FF_0; }
}
else
if (exp > (sintL)(FF_exp_high-FF_exp_mid))
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
else
return make_FF(sign, exp+FF_exp_mid, mant & (bit(FF_mant_len)-1));
}
) \
&& underflow_allowed() \
) \
- { cl_error_floating_point_underflow(); } /* subnormal oder noch kleiner -> Underflow */\
+ { throw floating_point_underflow_exception(); } /* subnormal oder noch kleiner -> Underflow */\
else \
{ ergebnis_zuweisung cl_FF_0; } /* +/- 0.0 -> 0.0 */ \
} \
&& (((~_erg.eksplicit) & ((uint32)bit(FF_exp_len+FF_mant_len)-bit(FF_mant_len))) == 0) /* e=255 ? */\
) \
{ if (maybe_nan && !((_erg.eksplicit << (32-FF_mant_len)) == 0)) \
- { cl_error_division_by_0(); } /* NaN, also Singularität -> "Division durch 0" */\
+ { throw division_by_0_exception(); } /* NaN, also Singularität -> "Division durch 0" */\
else /* Infinity */ \
if (!maybe_overflow || maybe_divide_0) \
- { cl_error_division_by_0(); } /* Infinity, Division durch 0 */\
+ { throw division_by_0_exception(); } /* Infinity, Division durch 0 */\
else \
- { cl_error_floating_point_overflow(); } /* Infinity, Overflow */\
+ { throw floating_point_overflow_exception(); } /* Infinity, Overflow */\
} \
else \
{ ergebnis_zuweisung allocate_ffloat(_erg.eksplicit); } \
if (exp == 0) // e=0 ?
// vorzeichenbehaftete 0.0 oder subnormale Zahl
{ if (!((val << 1) == 0) && underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return as_cl_private_thing(cl_FF_0); } // +/- 0.0 -> 0.0
}
elif (exp == 255) // e=255 ?
{ if (!((val << (32-FF_mant_len)) == 0))
- { cl_error_floating_point_nan(); } // NaN
+ { throw floating_point_nan_exception(); } // NaN
else
- { cl_error_floating_point_overflow(); } // Infinity, Overflow
+ { throw floating_point_overflow_exception(); } // Infinity, Overflow
}
else
{ // Der Exponent muß um FF_exp_mid-126 erhöht werden.
if ((FF_exp_mid>126) && (exp > FF_exp_high-FF_exp_mid+126))
- { cl_error_floating_point_overflow(); } // Overflow
+ { throw floating_point_overflow_exception(); } // Overflow
val += (FF_exp_mid - 126) << FF_mant_len;
#if defined(CL_WIDE_POINTERS)
return as_cl_private_thing(allocate_ffloat(val));
var cl_signean sign2;
var sintL exp2;
var uintL mant2;
- FF_decode(x2, { cl_error_division_by_0(); }, sign2=,exp2=,mant2=);
+ FF_decode(x2, { throw division_by_0_exception(); }, sign2=,exp2=,mant2=);
FF_decode(x1, { return x1; }, sign1=,exp1=,mant1=);
exp1 = exp1 - exp2; // Differenz der Exponenten
sign1 = sign1 ^ sign2; // Ergebnis-Vorzeichen
var sintC lendiff = (sintC)integer_length(a) // (integer-length a)
- (sintC)integer_length(b); // (integer-length b)
if (lendiff > FF_exp_high-FF_exp_mid) // Exponent >= n-m > Obergrenze ?
- { cl_error_floating_point_overflow(); } // -> Overflow
+ { throw floating_point_overflow_exception(); } // -> Overflow
if (lendiff < FF_exp_low-FF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ?
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); } // -> Underflow
+ { throw floating_point_underflow_exception(); } // -> Underflow
else
{ return cl_FF_0; }
}
return encode_FF(sign,exp,mant);
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_FF_0; }
}
return encode_FF(sign,exp,mant);
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return cl_FF_0; }
}
DeclareType(cl_FF,x);
return x;
} else
- cl_as_error(x,"a single-float number",filename,line);
+ throw as_exception(x,"a single-float number",filename,line);
}
} // namespace cln
if (end_of_parse) \
{ *end_of_parse = (ptr); } \
else \
- { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } }
+ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } }
const cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
{
*end_of_parse = string;
return cl_F(); // dummy return
}
- read_number_bad_syntax(string,string_limit);
+ throw read_number_bad_syntax_exception(string,string_limit);
}
} // namespace cln
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln
#include "cl_LF_impl.h"
#include "cl_F.h"
#include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
}
else
// �ertrag durch Rundungsfehler
- { if (test_loop_msp(y_mantMSDptr,len)) cl_abort();
+ { if (test_loop_msp(y_mantMSDptr,len)) throw runtime_exception();
mspref(y_mantMSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
(TheLfloat(y)->expo)++; // Exponenten incrementieren
}
{ if ( inc_loop_lsp(ptr,i) )
// Übertrag über das erste Digit hinaus
{ // Exponent von y incrementieren:
- if ( ++(TheLfloat(y)->expo) == LF_exp_high+1 ) { cl_error_floating_point_overflow(); }
+ if ( ++(TheLfloat(y)->expo) == LF_exp_high+1 ) { throw floating_point_overflow_exception(); }
// normalisiere durch Schieben um 1 Bit nach rechts:
{var uintD carry_rechts =
shift1right_loop_msp(y_mantMSDptr,len,~(uintD)0);
if (uexp <= k)
#endif
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
if (uexp <= s)
#endif
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
{ // Übertrag durchs Aufrunden
mspref(y_mantMSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
// Exponent erhöhen:
- if (++(TheLfloat(y)->expo) == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++(TheLfloat(y)->expo) == LF_exp_high+1) { throw floating_point_overflow_exception(); }
}
ab: // abrunden
;
// Else divide the mantissa of x by the absolute value of y, then round.
if (TheLfloat(x)->expo == 0) {
if (zerop(y))
- cl_error_division_by_0();
+ throw division_by_0_exception();
else
return x;
}
var uintE dexp = intDsize*y_len - shiftcount; // >= 0 !
if ((uexp < dexp) || ((uexp = uexp - dexp) < LF_exp_low)) {
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); }
}
// Übertrag durchs Aufrunden
{ mspref(MSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
// Exponenten incrementieren:
- if (++uexp == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++uexp == LF_exp_high+1) { throw floating_point_overflow_exception(); }
} }
return encode_LFu(TheLfloat(x)->sign ^ sign, uexp, MSDptr, len);
}
var uintE iexp = intDsize*y_len - shiftcount; // >= 0 !
uexp = uexp + iexp;
if ((uexp < iexp) || (uexp > LF_exp_high))
- cl_error_floating_point_overflow();
+ throw floating_point_overflow_exception();
// Runden:
var uintD* midptr = prodMSDptr mspop len;
var uintC restlen = prodlen - len;
{ if ( inc_loop_lsp(midptr,len) )
// Übertrag durchs Aufrunden
{ mspref(prodMSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
- if (++uexp == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++uexp == LF_exp_high+1) { throw floating_point_overflow_exception(); }
} }
return encode_LFu(TheLfloat(x)->sign ^ sign, uexp, prodMSDptr, len);
}
var uintC len2 = TheLfloat(x2)->len;
var uintC len = (len1 < len2 ? len1 : len2); // min. Länge n von x1 und x2
var uintE uexp2 = TheLfloat(x2)->expo;
- if (uexp2==0) { cl_error_division_by_0(); } // x2=0.0 -> Error
+ if (uexp2==0) { throw division_by_0_exception(); } // x2=0.0 -> Error
var uintE uexp1 = TheLfloat(x1)->expo;
if (uexp1==0) // x1=0.0 -> Ergebnis 0.0
{ if (len < len1) return shorten(x1,len); else return x1; }
// (uexp1-LF_exp_mid) - (uexp2-LF_exp_mid) = (uexp1-uexp2+LF_exp_mid)-LF_exp_mid
if (uexp1 >= uexp2)
{ uexp1 = uexp1 - uexp2; // kein Carry
- if (uexp1 > LF_exp_high-LF_exp_mid) { cl_error_floating_point_overflow(); }
+ if (uexp1 > LF_exp_high-LF_exp_mid) { throw floating_point_overflow_exception(); }
uexp1 = uexp1 + LF_exp_mid;
}
else
{ uexp1 = uexp1 - uexp2; // Carry
if (uexp1 < (uintE)(LF_exp_low-1-LF_exp_mid))
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
shiftrightcopy_loop_msp(q.MSDptr mspop 1,y_mantMSDptr,len,1,
/* carry links = mspref(q.MSDptr,0) = 1 */ 1 );
// Exponenten incrementieren:
- if (++(TheLfloat(y)->expo) == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++(TheLfloat(y)->expo) == LF_exp_high+1) { throw floating_point_overflow_exception(); }
// Runden:
if ( (carry_rechts == 0) // herausgeschobenes Bit =0 -> abrunden
|| ( (lspref(q.LSDptr,0)==0) // =1 und weitere Bits >0 oder Rest >0 -> aufrunden
// Übertrag durchs Aufrunden
{ mspref(y_mantMSDptr,0) = bit(intDsize-1); // Mantisse := 10...0
// Exponenten incrementieren:
- if (++(TheLfloat(y)->expo) == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++(TheLfloat(y)->expo) == LF_exp_high+1) { throw floating_point_overflow_exception(); }
} }
}
}
// LF_exp_low <= exp <= LF_exp_high sicherstellen:
if (TheLfloat(y)->expo == LF_exp_low-1)
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
)
{} // garantiert exp <= intDsize*2^intCsize-1 <= LF_exp_high-LF_exp_mid
else
- { if (!(exp <= (uintE)(LF_exp_high-LF_exp_mid))) { cl_error_floating_point_overflow(); } }
+ { if (!(exp <= (uintE)(LF_exp_high-LF_exp_mid))) { throw floating_point_overflow_exception(); } }
// Long-Float bauen:
var Lfloat y = allocate_lfloat(len,exp+LF_exp_mid,sign);
var uintD* y_mantMSDptr = arrayMSDptr(TheLfloat(y)->data,len);
// garantiert exp < intDsize*2^intCsize-1 <= LF_exp_high-LF_exp_mid
{ (TheLfloat(y)->expo)++; } // jetzt exp <= LF_exp_high-LF_exp_mid
else
- { if (++(TheLfloat(y)->expo) == LF_exp_high+1) { cl_error_floating_point_overflow(); } }
+ { if (++(TheLfloat(y)->expo) == LF_exp_high+1) { throw floating_point_overflow_exception(); } }
}
ab: // abrunden
;
// kein Carry
{ if (uexp1 < LF_exp_mid+LF_exp_low)
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
} }
else
// Carry
- { if (uexp1 > (uintE)(LF_exp_mid+LF_exp_high+1)) { cl_error_floating_point_overflow(); } }
+ { if (uexp1 > (uintE)(LF_exp_mid+LF_exp_high+1)) { throw floating_point_overflow_exception(); } }
uexp1 = uexp1 - LF_exp_mid;
// Nun ist LF_exp_low <= uexp1 <= LF_exp_high+1.
// neues Long-Float allozieren:
// Exponenten decrementieren:
if (--(TheLfloat(y)->expo) == LF_exp_low-1)
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
(TheLfloat(y)->expo)++; // Exponent wieder zurck-erhhen
} }
// LF_exp_low <= exp <= LF_exp_high sicherstellen:
- if (TheLfloat(y)->expo == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (TheLfloat(y)->expo == LF_exp_high+1) { throw floating_point_overflow_exception(); }
}}
return y;
}
if ( ((uexp = uexp+udelta) < udelta) // Exponent-Überlauf?
|| (uexp > LF_exp_high) // oder Exponent zu groß?
)
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
} else {
// delta <0, udelta = 2^intEsize+delta
if ( ((uintE)(-(uexp = uexp+udelta)) <= (uintE)(-udelta)) // oder Exponent-Unterlauf?
|| (uexp < LF_exp_low) // oder Exponent zu klein?
)
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
}
var uintC len = TheLfloat(x)->len;
return encode_LFu(TheLfloat(x)->sign,uexp,arrayMSDptr(TheLfloat(x)->data,len),len);
|| (uexp > LF_exp_high) // oder Exponent zu groß?
)
overflow:
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
goto ok;
neg: // delta <0, udelta = 2^32+delta
|| (uexp < LF_exp_low) // oder Exponent zu klein?
)
underflow:
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
goto ok;
ok:
{ uexp = 2*uexp;
if (uexp < LF_exp_mid+LF_exp_low)
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
} }
else
// Carry
{ uexp = 2*uexp;
- if (uexp > (uintE)(LF_exp_mid+LF_exp_high+1)) { cl_error_floating_point_overflow(); }
+ if (uexp > (uintE)(LF_exp_mid+LF_exp_high+1)) { throw floating_point_overflow_exception(); }
}
uexp = uexp - LF_exp_mid;
// Nun ist LF_exp_low <= uexp <= LF_exp_high+1.
// Exponenten decrementieren:
if ((TheLfloat(y)->expo)-- == LF_exp_low-1)
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return encode_LF0(len); } // Ergebnis 0.0
}
(TheLfloat(y)->expo)++; // Exponent wieder zurück-erhöhen
} }
// LF_exp_low <= exp <= LF_exp_high sicherstellen:
- if (TheLfloat(y)->expo == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (TheLfloat(y)->expo == LF_exp_high+1) { throw floating_point_overflow_exception(); }
}}
return y;
}
DeclareType(cl_LF,x);
return x;
} else
- cl_as_error(x,"a long-float number",filename,line);
+ throw as_exception(x,"a long-float number",filename,line);
}
} // namespace cln
// Übertrag durch Aufrunden
{ mspref(arrayMSDptr(TheLfloat(y)->data,len),0) = bit(intDsize-1); // Mantisse := 10...0
// Exponent erhöhen:
- if (++(TheLfloat(y)->expo) == LF_exp_high+1) { cl_error_floating_point_overflow(); }
+ if (++(TheLfloat(y)->expo) == LF_exp_high+1) { throw floating_point_overflow_exception(); }
} }
}
return y;
// Implementation.
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef MAYBE_INLINE2
#define MAYBE_INLINE2 inline
var sintE ey = float_exponent(y);
var sintC dy = float_precision(y);
if (dy==0) // zerop(y) ?
- cl_abort();
+ throw runtime_exception();
var sintE ex = float_exponent(x);
var sintC dx = float_precision(x);
if (dx==0) // zerop(x) ?
// Implementation.
-#include "cln/abort.h"
-
#undef MAYBE_INLINE2
#define MAYBE_INLINE2 inline
#include "cl_LF_precision.cc"
DeclareType(cl_F,x);
return x;
} else
- cl_as_error(x,"a floating-point number",filename,line);
+ throw as_exception(x,"a floating-point number",filename,line);
}
} // namespace cln
// Implementation.
#include "cl_LF.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
var sintE ey = float_exponent(y);
var sintC dy = float_precision(y);
if (dy==0) // zerop(y) ?
- cl_abort();
+ throw runtime_exception();
var sintE ex = float_exponent(x);
var sintC dx = float_precision(x);
if (dx==0) // zerop(x) ?
{
if (exp < (sintL)(SF_exp_low-SF_exp_mid))
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return SF_0; }
}
else
if (exp > (sintL)(SF_exp_high-SF_exp_mid))
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
else
return make_SF(sign, exp+SF_exp_mid, mant);
}
var cl_signean sign2;
var sintL exp2;
var uintL mant2;
- SF_decode(x2, { cl_error_division_by_0(); }, sign2=,exp2=,mant2=);
+ SF_decode(x2, { throw division_by_0_exception(); }, sign2=,exp2=,mant2=);
SF_decode(x1, { return x1; }, sign1=,exp1=,mant1=);
exp1 = exp1 - exp2; // Differenz der Exponenten
sign1 = sign1 ^ sign2; // Ergebnis-Vorzeichen
var sintC lendiff = (sintC)integer_length(a) // (integer-length a)
- (sintC)integer_length(b); // (integer-length b)
if (lendiff > SF_exp_high-SF_exp_mid) // Exponent >= n-m > Obergrenze ?
- { cl_error_floating_point_overflow(); } // -> Overflow
+ { throw floating_point_overflow_exception(); } // -> Overflow
if (lendiff < SF_exp_low-SF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ?
{ if (underflow_allowed())
- { cl_error_floating_point_underflow(); } // -> Underflow
+ { throw floating_point_underflow_exception(); } // -> Underflow
else
{ return SF_0; }
}
return encode_SF(sign,exp,mant);
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return SF_0; }
}
return encode_SF(sign,exp,mant);
}
else
- { cl_error_floating_point_overflow(); }
+ { throw floating_point_overflow_exception(); }
}
else
// delta<0
}
else
if (underflow_allowed())
- { cl_error_floating_point_underflow(); }
+ { throw floating_point_underflow_exception(); }
else
{ return SF_0; }
}
DeclareType(cl_SF,x);
return x;
} else
- cl_as_error(x,"a short-float number",filename,line);
+ throw as_exception(x,"a short-float number",filename,line);
}
} // namespace cln
#include "cl_LF.h"
#include "cln/integer.h"
#include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
{
{ Mutable(cl_I,p);
var uintE lp = integer_length(p); // now |p| < 2^lp.
- if (!(lp <= lq)) cl_abort();
+ if (!(lp <= lq)) throw runtime_exception();
lp = lq - lp; // now |p/2^lq| < 2^-lp.
// Minimize lq (saves computation time).
{
#include "cl_LF.h"
#include "cln/integer.h"
#include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
{
{ Mutable(cl_I,p);
var uintE lp = integer_length(p); // now |p| < 2^lp.
- if (!(lp <= lq)) cl_abort();
+ if (!(lp <= lq)) throw runtime_exception();
lp = lq - lp; // now |p/2^lq| < 2^-lp.
// Minimize lq (saves computation time).
{
#include "cl_LF.h"
#include "cln/integer.h"
#include "cl_alloca.h"
-#include "cln/abort.h"
namespace cln {
#include "cl_LF.h"
#include "cln/integer.h"
#include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
{
{ Mutable(cl_I,p);
var uintE lp = integer_length(p); // now |p| < 2^lp.
- if (!(lp <= lq)) cl_abort();
+ if (!(lp <= lq)) throw runtime_exception();
lp = lq - lp; // now |p/2^lq| < 2^-lp.
// Minimize lq (saves computation time).
{
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
#include "cl_LF.h"
namespace cln {
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*T = args.av[N1];
break;
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*B = args.bv[N1];
*T = args.av[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*B = args.bv[N1];
*T = 1;
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*T = args.pv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*T = args.av[N1] * args.pv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*B = args.bv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*B = args.bv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (P) { *P = args.pv[N1]; }
*Q = args.qv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*Q = args.qv[N1];
*T = 1;
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*Q = args.qv[N1];
*T = args.av[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*Q = args.qv[N1];
*B = args.bv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
*Q = args.qv[N1];
*B = args.bv[N1];
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1: {
var cl_pq_series_term v0 = args.next(); // [N1]
if (P) { *P = v0.p; }
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1: {
var cl_pqa_series_term v0 = args.next(); // [N1]
if (P) { *P = v0.p; }
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1: {
var cl_pqab_series_term v0 = args.next(); // [N1]
if (P) { *P = v0.p; }
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_LF.h"
namespace cln {
{
switch (N2 - N1) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1: {
var cl_pqb_series_term v0 = args.next(); // [N1]
if (P) { *P = v0.p; }
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
#include "cl_LF.h"
namespace cln {
// Implementation.
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// N = N2-N1
switch (N) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (!rightmost) { Z.P = args[0].p; }
Z.Q = args[0].q;
#include "cln/lfloat.h"
#include "cln/integer.h"
-#include "cln/abort.h"
#include "cl_LF.h"
namespace cln {
// Implementation.
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// N = N2-N1
switch (N) {
case 0:
- cl_abort(); break;
+ throw runtime_exception(); break;
case 1:
if (!rightmost) { Z.P = args[0].p; }
Z.Q = args[0].q;
#include "cl_LF_tran.h"
#include "cl_LF.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_alloca.h"
namespace cln {
const cl_LF zeta (int s, uintC len)
{
if (!(s > 1))
- cl_abort();
+ throw runtime_exception();
if (len < 280*(uintL)s)
return compute_zeta_cvz1(s,len);
else
#include "cln/number.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_I.h"
#include "cl_DS.h"
+#include <sstream>
namespace cln {
cl_boolean isqrt (const cl_I& x, cl_I* w)
{
if (minusp(x)) {
- fprint(std::cerr, "isqrt: applied to negative number: ");
- fprint(std::cerr, x);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "isqrt: applied to negative number: ");
+ fprint(buf, x);
+ throw runtime_exception(buf.str());
}
CL_ALLOCA_STACK;
var const uintD* x_MSDptr;
#include "cl_I.h"
#include "cl_DS.h"
-#include "cl_I_ash.h"
namespace cln {
var const uintD* x_LSDptr;
I_to_NDS_nocopy(x, ,len=,x_LSDptr=,cl_false,); // DS zu x bilden.
if (k >= (uintC)(~len)) // kann len+k+1 Überlauf geben?
- { cl_ash_error(y); } // ja -> Fehler
+ { throw ash_exception(y); } // ja -> Fehler
num_stack_alloc_1(len+k,,LSDptr=);
LSDptr = clear_loop_lsp(LSDptr,k); // k Nulldigits
{var uintD* MSDptr = copy_loop_lsp(x_LSDptr,LSDptr,len);
+++ /dev/null
-// cl_I internals for ash
-
-#ifndef _CL_I_ASH_H
-#define _CL_I_ASH_H
-
-#include "cln/number.h"
-#include "cln/integer_class.h"
-#include "cl_macros.h"
-
-namespace cln {
-
-nonreturning_function(extern, cl_ash_error, (const cl_I& badamount));
-
-} // namespace cln
-
-#endif /* _CL_I_ASH_H */
#include "cl_I.h"
#include "cl_DS.h"
-#include "cl_I_ash.h"
namespace cln {
if (bignump(y)) {
#if (log2_intDsize+intCsize <= cl_value_len-1)
// y >= 2^(cl_value_len-1) >= intDsize*2^intCsize
- cl_ash_error(y);
+ throw ash_exception(y);
#else
// y >= 2^(cl_value_len-1)
// usable only if y < intDsize*2^intCsize
var cl_heap_bignum* bn = TheBignum(y);
var uintC len = bn->length;
if (len > ceiling(log2_intDsize+intCsize+1,intDsize))
- cl_ash_error(y);
+ throw ash_exception(y);
// bn_minlength <= len <= ceiling(log2_intDsize+intCsize+1,intDsize).
if (bn_minlength == ceiling(log2_intDsize+intCsize+1,intDsize)
|| len == ceiling(log2_intDsize+intCsize+1,intDsize))
if (mspref(arrayMSDptr(bn->data,len),0) >= (uintD)bit((log2_intDsize+intCsize)%intDsize))
- cl_ash_error(y);
+ throw ash_exception(y);
#if (log2_intDsize+intCsize > intDsize)
#define IF_LENGTH(i) \
if (bn_minlength <= i && i <= ceiling(log2_intDsize+intCsize+1,intDsize) && (i == ceiling(log2_intDsize+intCsize+1,intDsize) || len == i))
else IF_LENGTH(5)
k = get_uint4D_Dptr(arrayLSDptr(bn->data,5) lspop 1);
else
- cl_abort();
+ throw runtime_exception();
#undef IF_LENGTH
k = k << (intDsize-log2_intDsize);
#else
var const uintD* x_LSDptr;
I_to_NDS_nocopy(x, ,len=,x_LSDptr=,cl_false,); // DS zu x bilden.
if (k >= (uintC)(~len)) // kann len+k+1 Überlauf geben?
- { cl_ash_error(y); } // ja -> Fehler
+ { throw ash_exception(y); } // ja -> Fehler
num_stack_alloc_1(len+k,,LSDptr=);
LSDptr = clear_loop_lsp(LSDptr,k); // k Nulldigits
var uintD* MSDptr = copy_loop_lsp(x_LSDptr,LSDptr,len);
else IF_LENGTH(5)
k = ~get_sint4D_Dptr(arrayLSDptr(bn->data,5) lspop 1);
else
- cl_abort();
+ throw runtime_exception();
#undef IF_LENGTH
k = k << (intDsize-log2_intDsize);
#else
--- /dev/null
+// ash_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/integer.h"
+
+
+// Implementation.
+#include "cln/io.h"
+#include "cln/integer_io.h"
+#include <sstream>
+
+namespace cln {
+
+static inline const std::string
+ash_error_msg (const cl_I& badamount)
+{
+ std::ostringstream buf;
+ fprint(buf, "ash: too large shift amount: ");
+ fprint(buf, badamount);
+ return buf.str();
+}
+
+ash_exception::ash_exception (const cl_I& badamount)
+ : runtime_exception(ash_error_msg(badamount))
+{}
+
+} // namespace cln
+++ /dev/null
-// cl_ash_error().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_I_ash.h"
-
-
-// Implementation.
-
-#include "cln/number.h"
-#include "cln/io.h"
-#include "cln/integer_io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_ash_error (const cl_I& badamount)
-{
- fprint(std::cerr, "ash: too large shift amount: ");
- fprint(std::cerr, badamount);
- fprint(std::cerr, "\n");
- cl_abort();
-}
-
-} // namespace cln
#include "cl_DS.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
}
else
// x<0
- { fprint(std::cerr, "logbitp: Index is negative: ");
- fprint(std::cerr, x);
- fprint(std::cerr, "\n");
- cl_abort();
+ { std::ostringstream buf;
+ fprint(buf, "logbitp: Index is negative: ");
+ fprint(buf, x);
+ throw runtime_exception(buf.str());
}
}
#include "cln/integer.h"
#include "cl_macros.h"
#include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_offsetof.h"
#include "cl_DS.h"
#if (FN_maxlength==1)
#define FN_LSD0(word) FN_MSD(word)
- #define FN_LSD1(word) (cl_abort(), (uintD)0) // never used
- #define FN_LSD2(word) (cl_abort(), (uintD)0) // never used
- #define FN_LSD3(word) (cl_abort(), (uintD)0) // never used
+ #define FN_LSD1(word) (throw runtime_exception(), (uintD)0) // never used
+ #define FN_LSD2(word) (throw runtime_exception(), (uintD)0) // never used
+ #define FN_LSD3(word) (throw runtime_exception(), (uintD)0) // never used
#endif
#if (FN_maxlength==2)
inline uintD FN_LSD0 (cl_uint word)
return (uintD)(word >> cl_value_shift);
}
#define FN_LSD1(word) FN_MSD(word)
- #define FN_LSD2(word) (cl_abort(), (uintD)0) // never used
- #define FN_LSD3(word) (cl_abort(), (uintD)0) // never used
+ #define FN_LSD2(word) (throw runtime_exception(), (uintD)0) // never used
+ #define FN_LSD3(word) (throw runtime_exception(), (uintD)0) // never used
#endif
#if (FN_maxlength==4)
inline uintD FN_LSD0 (cl_uint word)
// < q,r: Quotient q, Rest r
extern const cl_I_div_t cl_divide (const cl_I& x, const cl_I& y);
-// Fehler, wenn Quotient keine ganze Zahl ist
- nonreturning_function(extern, cl_error_exquo, (const cl_I& x, const cl_I& y));
-
// ggT und kgV von Integers
#include "cl_DS.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
}
}
bad: // unpassendes Objekt
- fprint(std::cerr, "Not a 32-bit integer: ");
- fprint(std::cerr, obj);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Not a 32-bit integer: ");
+ fprint(buf, obj);
+ throw runtime_exception(buf.str());
}
} // namespace cln
#include "cl_DS.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
#undef IF_LENGTH
}
bad: // unpassendes Objekt
- fprint(std::cerr, "Not a 64-bit integer: ");
- fprint(std::cerr, obj);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Not a 64-bit integer: ");
+ fprint(buf, obj);
+ throw runtime_exception(buf.str());
}
}
#include "cl_DS.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
#undef IF_LENGTH
}
bad: // unpassendes Objekt
- fprint(std::cerr, "Not a 32-bit integer: ");
- fprint(std::cerr, obj);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Not a 32-bit integer: ");
+ fprint(buf, obj);
+ throw runtime_exception(buf.str());
}
} // namespace cln
#include "cl_DS.h"
#include "cln/io.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
#undef IF_LENGTH
}
bad: // unpassendes Objekt
- fprint(std::cerr, "Not a 64-bit integer: ");
- fprint(std::cerr, obj);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Not a 64-bit integer: ");
+ fprint(buf, obj);
+ throw runtime_exception(buf.str());
}
} // namespace cln
static inline void I_to_digits_noshrink (const cl_I& X, uintD base, uintC erg_len, cl_digits* erg)
{
I_to_digits(X,base,erg);
- if (erg->len > erg_len) cl_abort();
+ if (erg->len > erg_len) throw runtime_exception();
var uintC count = erg_len - erg->len;
if (count > 0)
{ var uintB* ptr = erg->MSBptr;
// floor(2^ilen_X/B) = floor(floor(2^(2*ilen_B)/B)/2^(2*ilen_B-ilen_X))
var cl_I q = (X * (p->inv_base_pow >> (2*ilen_B-ilen_X))) >> ilen_X;
var cl_I r = X - q * p->base_pow;
- if (r < 0) cl_abort();
+ if (r < 0) throw runtime_exception();
if (r >= p->base_pow)
{ q = q+1; r = r - p->base_pow;
- if (r >= p->base_pow) cl_abort();
+ if (r >= p->base_pow) throw runtime_exception();
}
#else
var cl_I_div_t q_r = floor2(X,p->base_pow);
// Falls r<>0, Error.
// Falls x,y verschiedene Vorzeichen haben, liefere -q, sonst q.
var cl_I_div_t q_r = cl_divide(abs(x),abs(y));
- if (!zerop(q_r.remainder)) { cl_error_exquo(x,y); }
+ if (!zerop(q_r.remainder)) { throw exquo_exception(x,y); }
if (minusp(x) == minusp(y))
{ return q_r.quotient; }
else
--- /dev/null
+// exquo_exception().
+
+// General includes.
+#include "cl_sysdep.h"
+
+// Specification.
+#include "cln/integer.h"
+
+
+// Implementation.
+
+#include "cln/io.h"
+#include "cln/integer_io.h"
+#include <sstream>
+
+namespace cln {
+
+static inline const std::string
+exquo_error_msg (const cl_I& x, const cl_I& y)
+{
+ std::ostringstream buf;
+ fprint(buf, "Quotient ");
+ fprint(buf, x);
+ fprint(buf, " / ");
+ fprint(buf, y);
+ fprint(buf, " is not an integer.");
+ return buf.str();
+}
+
+exquo_exception::exquo_exception (const cl_I& x, const cl_I& y)
+ : runtime_exception(exquo_error_msg(x,y))
+{}
+
+} // namespace cln
+++ /dev/null
-// cl_error_exquo().
-
-// General includes.
-#include "cl_sysdep.h"
-
-// Specification.
-#include "cl_I.h"
-
-
-// Implementation.
-
-#include "cln/io.h"
-#include "cln/integer_io.h"
-#include "cln/abort.h"
-
-namespace cln {
-
-void cl_error_exquo (const cl_I& x, const cl_I& y)
-{
- fprint(std::cerr, "Quotient ");
- fprint(std::cerr, x);
- fprint(std::cerr, " / ");
- fprint(std::cerr, y);
- fprint(std::cerr, " is not an integer.\n");
- cl_abort();
-}
-
-} // namespace cln
// Falls r<>0, Error.
// Liefere q.
var cl_I_div_t q_r = cl_divide(x,y);
- if (!zerop(q_r.remainder)) { cl_error_exquo(x,y); }
+ if (!zerop(q_r.remainder)) { throw exquo_exception(x,y); }
return q_r.quotient;
}
// Implementation.
-#include "cl_N.h"
+#include "cln/exception.h"
namespace cln {
// auch y Fixnum >=0
{ var uintV x_ = FN_to_UV(x);
var uintV y_ = FN_to_UV(y);
- if (y_==0) { cl_error_division_by_0(); }
+ if (y_==0) { throw division_by_0_exception(); }
elif (x_ < y_)
// Trivialfall: q=0, r=x
goto trivial;
var uintDD p = muluDD_unchecked(q,y);
#ifdef DEBUG_GCD
if (x < p)
- cl_abort();
+ throw runtime_exception();
#endif
x -= p;
}
#ifdef DEBUG_GCD
x -= y;
if (x >= y)
- cl_abort();
+ throw runtime_exception();
#endif
}
}
if (x2 > ~x1) goto done;
if (y2 > ~y1) goto done;
#ifdef DEBUG_GCD
- if (z1 < z2) cl_abort();
+ if (z1 < z2) throw runtime_exception();
#endif
// Now really subtract.
x1 += x2;
if (x1 > ~x2) goto done;
if (y1 > ~y2) goto done;
#ifdef DEBUG_GCD
- if (z2 < z1) cl_abort();
+ if (z2 < z1) throw runtime_exception();
#endif
// Now really subtract.
x2 += x1;
muluD(q,yhi, , phi +=);
#ifdef DEBUG_GCD
if ((xhi < phi) || ((xhi == phi) && (xlo < plo)))
- cl_abort();
+ throw runtime_exception();
#endif
xhi = xhi - phi;
if (xlo < plo)
xhi -= 1;
xlo = xlo - ylo;
if ((xhi > yhi) || ((xhi == yhi) && (xlo >= ylo)))
- cl_abort();
+ throw runtime_exception();
#endif
}
}
if (x2 > ~x1) goto done;
if (y2 > ~y1) goto done;
#ifdef DEBUG_GCD
- if (z1hi < z2hi) cl_abort();
- if (z1hi == z2hi) if (z1lo < z2lo) cl_abort();
+ if (z1hi < z2hi) throw runtime_exception();
+ if (z1hi == z2hi) if (z1lo < z2lo) throw runtime_exception();
#endif
// Now really subtract.
x1 += x2;
if (x1 > ~x2) goto done;
if (y1 > ~y2) goto done;
#ifdef DEBUG_GCD
- if (z2hi < z1hi) cl_abort();
- if (z2hi == z1hi) if (z2lo < z1lo) cl_abort();
+ if (z2hi < z1hi) throw runtime_exception();
+ if (z2hi == z1hi) if (z2lo < z1lo) throw runtime_exception();
#endif
// Now really subtract.
x2 += x1;
// Implementation.
#include <cstring>
+#include <sstream>
#include "cln/input.h"
#include "cln/integer.h"
#include "cl_I.h"
-#include "cln/abort.h"
namespace cln {
if (end_of_parse) \
{ *end_of_parse = (ptr); } \
else \
- { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } }
+ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } }
const cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
{
goto not_integer_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
- fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
- fprint(std::cerr, base);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Base must be an integer in the range from 2 to 36, not ");
+ fprint(buf, base);
+ throw runtime_exception(buf.str());
}
rational_base = FN_to_UV(base); ptr = base_end_ptr;
break;
*end_of_parse = string;
return 0; // dummy return
}
- read_number_bad_syntax(string,string_limit);
+ throw read_number_bad_syntax_exception(string,string_limit);
}
} // namespace cln
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln
DeclareType(cl_I,x);
return x;
} else
- cl_as_error(x,"an integer",filename,line);
+ throw as_exception(x,"an integer",filename,line);
}
} // namespace cln
#include "cln/integer_io.h"
#include "cl_N.h"
#include "cl_MI.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_alloca.h"
// MacOS X does "#define _R 0x00040000L"
{
refcount = 0; // will be incremented by the `cl_modint_ring' constructor
type = &cl_class_modint_ring;
- if (minusp(m)) cl_abort();
+ if (minusp(m)) throw runtime_exception();
if (!cln::zerop(m)) {
var uintC b = integer_length(m-1);
// m <= 2^b, hence one needs b bits for a representative mod m.
store_modint_ring(R);
ring_in_table = get_modint_ring(m);
if (!ring_in_table)
- cl_abort();
+ throw runtime_exception();
}
return *ring_in_table;
}}
// Implementation.
#include "cln/io.h"
-#include "cln/abort.h"
namespace cln {
{
unused R;
unused randomstate;
- fprint(std::cerr, "Z / 0 Z not a finite set - no equidistributed random function.\n");
- cl_abort();
+ throw runtime_exception("Z / 0 Z not a finite set - no equidistributed random function.");
#if ((defined(__sparc__) || defined(__sparc64__)) && !defined(__GNUC__)) // Sun CC wants a return value
return _cl_MI(R, 0);
#endif
{
var const cl_I& xr = x.rep;
if (eq(xr,1) || eq(xr,-1)) { return cl_MI(R,x); }
- if (zerop(xr)) { cl_error_division_by_0(); }
+ if (zerop(xr)) { throw division_by_0_exception(); }
return cl_notify_composite(R,xr);
}
var const cl_I& yr = y.rep;
if (eq(yr,1)) { return cl_MI(R,x.rep); }
if (eq(yr,-1)) { return cl_MI(R,-x.rep); }
- if (zerop(yr)) { cl_error_division_by_0(); }
+ if (zerop(yr)) { throw division_by_0_exception(); }
return cl_notify_composite(R,yr);
}
return cl_MI(R,expt_pos(x.rep,y));
}
// y < 0, x nonunit.
- if (zerop(x.rep)) { cl_error_division_by_0(); }
+ if (zerop(x.rep)) { throw division_by_0_exception(); }
return cl_notify_composite(R,x.rep);
}
if (eq(g,1))
return cl_MI(R, mod((minusp(u) ? u + R->modulus : u) << (2*R->n), R->modulus));
if (zerop(xr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
return cl_notify_composite(R,xr);
}
if (eq(g,1))
return cl_MI(R, mod((x.rep * (minusp(u) ? u + R->modulus : u)) << R->n, R->modulus));
if (zerop(yr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
return cl_notify_composite(R,yr);
}
var cl_I U = DS_to_I(U_LSDptr lspop U_len,U_len);
var cl_I V_N = 1 - U*M;
if (ldb_test(V_N,cl_byte(n,0)))
- cl_abort();
+ throw runtime_exception();
var cl_I V = V_N >> n;
return new cl_heap_modint_ring_montgom(M,m,n,V);
}
if (R->m1 == 0)
return cl_MI(R, 0);
if (zerop(xr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
else
return cl_notify_composite(R,xr);
} else
if (R->m1 == 0)
return cl_MI(R, 0);
if (zerop(yr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
else
return cl_notify_composite(R,yr);
} else
// Implementation.
#include "cln/integer.h"
-#include "cl_N.h"
+#include "cln/exception.h"
#include "cl_MI.h"
namespace cln {
var const cl_modint_ring& R = x.ring();
if (!oddp(R->modulus)) {
if (R->modulus == 2)
- cl_error_division_by_0();
+ throw division_by_0_exception();
else
return (cl_MI_x)cl_notify_composite(R,2);
}
// Use algorithm 1 for small y, algorithm 2 for large y.
#if 0
if (y <= 2*R->bits)
- cl_abort(); // not yet implemented
+ throw runtime_exception(); // not yet implemented
else
#endif
return R->div(x, expt_pos(R->canonhom(2), (cl_I)(long)y));
if (eq(g,1))
return cl_MI(R, (minusp(u) ? u + R->modulus : u));
if (zerop(xr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
return cl_notify_composite(R,xr);
}
if (eq(g,1))
return cl_MI(R, mod(x.rep * (minusp(u) ? u + R->modulus : u), R->modulus));
if (zerop(yr))
- cl_error_division_by_0();
+ throw division_by_0_exception();
return cl_notify_composite(R,yr);
}
// Compute a = x^n_digits[nnk-1].
{
var uintL d = n_digits[nnk-1];
- if (d == 0) cl_abort();
+ if (d == 0) throw runtime_exception();
var uintL d2;
if (k <= 8)
d2 = ord2_table[d];
if (d==0 && maxodd > 1 && d2>0) {
a = x2; d2--;
}
- if (!(d2 < k)) cl_abort();
+ if (!(d2 < k)) throw runtime_exception();
for ( ; d2>0; d2--)
a = R->_square(a);
}
} else
d2 = k;
// Square d2 times.
- if (!(d2 <= k)) cl_abort();
+ if (!(d2 <= k)) throw runtime_exception();
for ( ; d2>0; d2--)
a = R->_square(a);
}
if (init.condition)
return init.condition;
if (init.solutions != 2)
- cl_abort();
+ throw runtime_exception();
// Euclidean algorithm.
var cl_I a = p;
var cl_I b = R->retract(init.solution[0]);
if (init.condition)
return init.condition;
if (init.solutions != 2)
- cl_abort();
+ throw runtime_exception();
// Compute x with x^2+d == 0 mod 4*p.
var cl_I x0 = R->retract(init.solution[0]);
if (evenp(x0)) { x0 = p-x0; } // Enforce x0^2+d == 0 mod 4.
// Implementation.
#include "cl_IF.h"
-#include "cln/abort.h"
+#include "cln/integer_io.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
cl_boolean isprobprime (const cl_I& n)
{
- if (!(n > 0))
- cl_abort();
+ if (!(n > 0)) {
+ std::ostringstream buf;
+ fprint(buf, n);
+ fprint(buf, " is not a positive integer.");
+ throw runtime_exception(buf.str());
+ }
// With a Miller-Rabin count = 50 the final error probability is
// 4^-50 < 10^-30.
var int count = 50;
#include "cln/integer.h"
#include "cl_I.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_xmacros.h"
namespace cln {
{
// Check b > 0, b odd.
if (!(b > 0))
- cl_abort();
+ throw runtime_exception();
if (!oddp(b))
- cl_abort();
+ throw runtime_exception();
{ Mutable(cl_I,a);
Mutable(cl_I,b);
// Ensure 0 <= a < b.
// Implementation.
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_xmacros.h"
namespace cln {
switch (b % 4) {
case 1: break;
case 3: v = -v; break;
- default: cl_abort();
+ default: throw runtime_exception();
}
continue;
}
switch (b % 8) {
case 1: case 7: break;
case 3: case 5: v = -v; break;
- default: cl_abort();
+ default: throw runtime_exception();
}
continue;
}
{
// Check b > 0, b odd.
if (!(b > 0))
- cl_abort();
+ throw runtime_exception();
if ((b & 1) == 0)
- cl_abort();
+ throw runtime_exception();
// Ensure 0 <= a < b.
if (a >= 0)
a = (uintV)a % (uintV)b;
// Implementation.
#include "cl_I.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
const sqrt_mod_p_t sqrt_mod_p (const cl_modint_ring& R, const cl_MI& a)
{
- if (!(a.ring() == R)) cl_abort();
+ if (!(a.ring() == R)) throw runtime_exception();
var cl_I& p = R->modulus;
var cl_I aa = R->retract(a);
switch (jacobi(aa,p)) {
#include "cln/modinteger.h"
#include "cln/GV_integer.h"
#include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// Scalar multiplication of GF(2)-polynomials is trivial: 0*y = 0, 1*y = y.
static const _cl_UP gf2_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, const _cl_UP& y)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{
DeclarePoly(_cl_MI,x);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
static const cl_ring_element gf2_eval (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const cl_ring_element& y)
{{
DeclarePoly(cl_GV_MI,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(_cl_MI,y);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
var const cl_heap_GV_I_bits1 * xv = (const cl_heap_GV_I_bits1 *) x.heappointer;
#include "cln/GV_modinteger.h"
#include "cln/modinteger.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// Negate. No normalization necessary, since the degree doesn't change.
var sintL i = xlen-1;
var _cl_MI hicoeff = R->_uminus(x[i]);
- if (R->_zerop(hicoeff)) cl_abort();
+ if (R->_zerop(hicoeff)) throw runtime_exception();
var cl_GV_MI result = cl_GV_MI(xlen,R);
result[i] = hicoeff;
for (i-- ; i >= 0; i--)
}
// Normalize (not necessary in integral domains).
//modint_normalize(R,result,len);
- if (R->_zerop(result[len-1])) cl_abort();
+ if (R->_zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
result[0] = R->_square(x[0]);
// Normalize (not necessary in integral domains).
//modint_normalize(R,result,len);
- if (R->_zerop(result[len-1])) cl_abort();
+ if (R->_zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
static const _cl_UP modint_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, const _cl_UP& y)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{
DeclarePoly(_cl_MI,x);
DeclarePoly(cl_GV_MI,y);
static const _cl_UP modint_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{ DeclarePoly(_cl_MI,x);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
if (R->_zerop(x))
static void modint_set_coeff (cl_heap_univpoly_ring* UPR, _cl_UP& x, uintL index, const cl_ring_element& y)
{{
DeclareMutablePoly(cl_GV_MI,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(_cl_MI,y);
- if (!(index < x.length())) cl_abort();
+ if (!(index < x.length())) throw runtime_exception();
x[index] = y;
}}}
// If y = 0, return x[0].
// Else compute (...(x[len-1]*y+x[len-2])*y ...)*y + x[0].
DeclarePoly(cl_GV_MI,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(_cl_MI,y);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
var uintL len = x.length();
#include "cln/SV_ringelt.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// Negate. No normalization necessary, since the degree doesn't change.
var sintL i = xlen-1;
var _cl_ring_element hicoeff = R->_uminus(x[i]);
- if (R->_zerop(hicoeff)) cl_abort();
+ if (R->_zerop(hicoeff)) throw runtime_exception();
var cl_SV_ringelt result = cl_SV_ringelt(cl_make_heap_SV_ringelt_uninit(xlen));
init1(_cl_ring_element, result[i]) (hicoeff);
for (i-- ; i >= 0; i--)
}
// Normalize (not necessary in integral domains).
//gen_normalize(R,result,len);
- if (R->_zerop(result[len-1])) cl_abort();
+ if (R->_zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
init1(_cl_ring_element, result[0]) (R->_square(x[0]));
// Normalize (not necessary in integral domains).
//gen_normalize(R,result,len);
- if (R->_zerop(result[len-1])) cl_abort();
+ if (R->_zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
static const _cl_UP gen_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, const _cl_UP& y)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{
DeclarePoly(cl_SV_ringelt,y);
var cl_heap_ring* R = TheRing(UPR->basering());
init1(_cl_ring_element, result[i]) (R->_mul(x,y[i]));
// Normalize (not necessary in integral domains).
//gen_normalize(R,result,ylen);
- if (R->_zerop(result[ylen-1])) cl_abort();
+ if (R->_zerop(result[ylen-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
static const _cl_UP gen_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
var cl_heap_ring* R = TheRing(UPR->basering());
if (R->_zerop(x))
return _cl_UP(UPR, cl_null_SV_ringelt);
static void gen_set_coeff (cl_heap_univpoly_ring* UPR, _cl_UP& x, uintL index, const cl_ring_element& y)
{{
DeclareMutablePoly(cl_SV_ringelt,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
- if (!(index < x.length())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
+ if (!(index < x.length())) throw runtime_exception();
x[index] = y;
}}
// Else compute (...(x[len-1]*y+x[len-2])*y ...)*y + x[0].
DeclarePoly(cl_SV_ringelt,x);
var cl_heap_ring* R = TheRing(UPR->basering());
- if (!(y.ring() == R)) cl_abort();
+ if (!(y.ring() == R)) throw runtime_exception();
var uintL len = x.length();
if (len==0)
return R->zero();
store_univpoly_ring(R);
ring_in_table = get_univpoly_ring(r,varname);
if (!ring_in_table)
- cl_abort();
+ throw runtime_exception();
}
return *ring_in_table;
}
// Implementation.
#include "cln/io.h"
-#include "cln/abort.h"
namespace cln {
-nonreturning_function(static, uninitialized_ring, (void));
-static void uninitialized_ring ()
-{
- fprint(std::cerr, "Uninitialized ring operation called\n");
- cl_abort();
-}
-
-nonreturning_function(static, uninitialized_error, (const _cl_UP&));
-static void uninitialized_error (const _cl_UP& obj)
-{
- fprint(std::cerr, "Uninitialized ring element @0x");
- fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
- fprint(std::cerr, ": 0x");
- fprinthexadecimal(std::cerr, (unsigned long)obj.rep.word);
- fprint(std::cerr, "\n");
- cl_abort();
-}
-
-#if ((defined(__sparc__) || defined(__sparc64__)) && !defined(__GNUC__))
- // avoid Sun C++ 4.1 compiler bug
- #define RETDUMMY return *(_cl_UP*)R
-#else
- #define RETDUMMY return *(_cl_UP*)0
-#endif
-
static const _cl_UP dummy_op0 (cl_heap_univpoly_ring* R)
{
unused R;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
static const _cl_UP dummy_op1 (cl_heap_univpoly_ring* R, const _cl_UP& x)
{
unused R;
- uninitialized_error(x); RETDUMMY;
+ throw uninitialized_exception(x);
}
static const _cl_UP dummy_op2 (cl_heap_univpoly_ring* R, const _cl_UP& x, const _cl_UP& y)
{
unused R;
- uninitialized_error(x); uninitialized_error(y); RETDUMMY;
+ throw uninitialized_exception(x, y);
}
static void dummy_fprint (cl_heap_univpoly_ring* R, std::ostream& stream, const _cl_UP& x)
{
unused R;
unused stream;
- uninitialized_error(x);
+ throw uninitialized_exception(x);
}
static cl_boolean dummy_equal (cl_heap_univpoly_ring* R, const _cl_UP& x, const _cl_UP& y)
{
unused R;
- uninitialized_error(x); uninitialized_error(y); return cl_false;
+ throw uninitialized_exception(x, y);
}
#define dummy_zero dummy_op0
static cl_boolean dummy_zerop (cl_heap_univpoly_ring* R, const _cl_UP& x)
{
unused R;
- uninitialized_error(x); return cl_false;
+ throw uninitialized_exception(x);
}
#define dummy_plus dummy_op2
#define dummy_minus dummy_op2
{
unused R;
(void)&x; // unused x;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
#define dummy_mul dummy_op2
#define dummy_square dummy_op1
{
unused R;
(void)&y; // unused y;
- uninitialized_error(x); RETDUMMY;
+ throw uninitialized_exception(x);
}
static const _cl_UP dummy_scalmul (cl_heap_univpoly_ring* R, const cl_ring_element& x, const _cl_UP& y)
{
unused R;
unused x;
- uninitialized_error(y); RETDUMMY;
+ throw uninitialized_exception(y);
}
static sintL dummy_degree (cl_heap_univpoly_ring* R, const _cl_UP& x)
{
unused R;
- uninitialized_error(x); return 0;
+ throw uninitialized_exception(x);
}
static sintL dummy_ldegree (cl_heap_univpoly_ring* R, const _cl_UP& x)
{
unused R;
- uninitialized_error(x); return 0;
+ throw uninitialized_exception(x);
}
static const _cl_UP dummy_monomial (cl_heap_univpoly_ring* R, const cl_ring_element& x, uintL e)
{
unused R;
unused x;
unused e;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
static const cl_ring_element dummy_coeff (cl_heap_univpoly_ring* R, const _cl_UP& x, uintL index)
{
unused R;
unused index;
- uninitialized_error(x); return *(cl_ring_element*)0;
+ throw uninitialized_exception(x);
}
static const _cl_UP dummy_create (cl_heap_univpoly_ring* R, sintL deg)
{
unused R;
unused deg;
- uninitialized_ring(); RETDUMMY;
+ throw uninitialized_ring_exception();
}
static void dummy_set_coeff (cl_heap_univpoly_ring* R, _cl_UP& x, uintL index, const cl_ring_element& y)
{
unused R;
unused index;
unused y;
- uninitialized_error(x);
+ throw uninitialized_exception(x);
}
static void dummy_finalize (cl_heap_univpoly_ring* R, _cl_UP& x)
{
unused R;
- uninitialized_error(x);
+ throw uninitialized_exception(x);
}
static const cl_ring_element dummy_eval (cl_heap_univpoly_ring* R, const _cl_UP& x, const cl_ring_element& y)
{
unused R;
unused y;
- uninitialized_error(x); return *(cl_ring_element*)0;
+ throw uninitialized_exception(x);
}
static cl_univpoly_setops dummy_setops = {
#include "cln/SV_number.h"
#include "cln/number.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
// Negate. No normalization necessary, since the degree doesn't change.
var sintL i = xlen-1;
var cl_number hicoeff = ops.uminus(x[i]);
- if (ops.zerop(hicoeff)) cl_abort();
+ if (ops.zerop(hicoeff)) throw runtime_exception();
var cl_SV_number result = cl_SV_number(cl_make_heap_SV_number_uninit(xlen));
init1(cl_number, result[i]) (hicoeff);
for (i-- ; i >= 0; i--)
}
// Normalize (not necessary in integral domains).
//num_normalize(ops,result,len);
- if (ops.zerop(result[len-1])) cl_abort();
+ if (ops.zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
init1(cl_number, result[0]) (ops.square(x[0]));
// Normalize (not necessary in integral domains).
//num_normalize(ops,result,len);
- if (ops.zerop(result[len-1])) cl_abort();
+ if (ops.zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
static const _cl_UP num_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, const _cl_UP& y)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{
DeclarePoly(cl_number,x);
DeclarePoly(cl_SV_number,y);
static const _cl_UP num_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,x);
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops;
if (ops.zerop(x))
static void num_set_coeff (cl_heap_univpoly_ring* UPR, _cl_UP& x, uintL index, const cl_ring_element& y)
{{
DeclareMutablePoly(cl_SV_number,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,y);
- if (!(index < x.length())) cl_abort();
+ if (!(index < x.length())) throw runtime_exception();
x[index] = y;
}}}
// If y = 0, return x[0].
// Else compute (...(x[len-1]*y+x[len-2])*y ...)*y + x[0].
DeclarePoly(cl_SV_number,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,y);
var cl_heap_number_ring* R = TheNumberRing(UPR->basering());
var cl_number_ring_ops<cl_number>& ops = *R->ops;
store_univpoly_ring(R);
ring_in_table = get_univpoly_ring(r);
if (!ring_in_table)
- cl_abort();
+ throw runtime_exception();
}
return *ring_in_table;
}
// Implementation.
+#include "cln/exception.h"
#include "cl_I.h"
-#include "cl_N.h"
namespace cln {
// Falls b>0: I_posI_div_RA anwenden.
// Falls b<0: I_posI_div_RA auf (- a) und (- b) anwenden.
if (eq(b,0))
- cl_error_division_by_0();
+ throw division_by_0_exception();
if (minusp(b))
return I_posI_div_RA(-a,-b);
else
// Implementation.
+#include "cln/exception.h"
#include "cl_RA.h"
-#include "cl_N.h"
#include "cl_I.h"
namespace cln {
// a>0 -> Ergebnis b/a (mit ggT(b,a)=1).
// a<0 -> Ergebnis (- b)/(- a) (mit ggT(-b,-a)=1).
if (zerop(r))
- cl_error_division_by_0();
+ throw division_by_0_exception();
var cl_I a;
var cl_I b;
RA_numden_I_I(r, a = , b = );
// Implementation.
#include <cstring>
+#include <sstream>
#include "cln/input.h"
#include "cln/integer.h"
#include "cln/integer_io.h"
#include "cl_I.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
if (end_of_parse) \
{ *end_of_parse = (ptr); } \
else \
- { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } }
+ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } }
const cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
{
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
- fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
- fprint(std::cerr, base);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Base must be an integer in the range from 2 to 36, not ");
+ fprint(buf, base);
+ throw runtime_exception(buf.str());
}
rational_base = FN_to_UV(base); ptr = base_end_ptr;
break;
*end_of_parse = string;
return 0; // dummy return
}
- read_number_bad_syntax(string,string_limit);
+ throw read_number_bad_syntax_exception(string,string_limit);
}
} // namespace cln
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln
var cl_I den = // Nenner
digits_to_I(&string[index3_1],index2-index3_1,(uintD)base);
if (zerop(den)) // Division durch 0 abfangen
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
var cl_I num = // Zähler
digits_to_I(&string[index1],index3-index1,(uintD)base);
if (!(sign == 0))
DeclareType(cl_RA,x);
return x;
} else
- cl_as_error(x,"a rational number",filename,line);
+ throw as_exception(x,"a rational number",filename,line);
}
} // namespace cln
if (eq(x,0))
// 0 / y = exakte 0, außer wenn y=0
{ if (zerop(y))
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
else
return 0;
}
// Implementation.
+#include <sstream>
#include "cln/integer.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
var uintL * small_piece_ptr = &small_pieces[0];
do {
if (*illion_ptr == NULL) {
- fprint(std::cerr, "format_cardinal: argument too large: ");
- fprint(std::cerr, argument);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "format_cardinal: argument too large: ");
+ fprint(buf, argument);
+ throw runtime_exception(buf.str());
}
var cl_I_div_t div = floor2(arg,1000);
var const cl_I& thousands = div.quotient;
// Implementation.
+#include <sstream>
#include "cln/integer.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
void format_new_roman (std::ostream& stream, const cl_I& arg)
{
if (!(0 < arg && arg < 4000)) {
- fprint(std::cerr, "format_new_roman: argument should be in the range 1 - 3999, not ");
- fprint(std::cerr, arg);
- fprint(std::cerr, ".\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "format_new_roman: argument should be in the range 1 - 3999, not ");
+ fprint(buf, arg);
+ fprint(buf, ".");
+ throw runtime_exception(buf.str());
}
var uintL value = cl_I_to_UL(arg);
struct roman { char symbol; uintL value; };
// Implementation.
+#include <sstream>
#include "cln/integer.h"
#include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
void format_old_roman (std::ostream& stream, const cl_I& arg)
{
if (!(0 < arg && arg < 5000)) {
- fprint(std::cerr, "format_old_roman: argument should be in the range 1 - 4999, not ");
- fprint(std::cerr, arg);
- fprint(std::cerr, ".\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "format_old_roman: argument should be in the range 1 - 4999, not ");
+ fprint(buf, arg);
+ fprint(buf, "\n");
+ throw runtime_exception(buf.str());
}
var uintL value = cl_I_to_UL(arg);
struct roman { char symbol; uintL value; };
// Implementation.
#include <cstring>
+#include <sstream>
#include "cln/input.h"
#include "cln/rational_io.h"
#include "cln/integer_io.h"
#include "cln/integer.h"
#include "cl_I.h"
#include "cl_F.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#undef floor
#include <cmath>
if (end_of_parse) \
{ *end_of_parse = (ptr); } \
else \
- { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } }
+ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } }
const cl_R read_real (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
{
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
- fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
- fprint(std::cerr, base);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "Base must be an integer in the range from 2 to 36, not ");
+ fprint(buf, base);
+ throw runtime_exception(buf.str());
}
rational_base = FN_to_UV(base); ptr = base_end_ptr;
break;
*end_of_parse = string;
return 0; // dummy return
}
- read_number_bad_syntax(string,string_limit);
+ throw read_number_bad_syntax_exception(string,string_limit);
}
} // namespace cln
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln
DeclareType(cl_R,x);
return x;
} else
- cl_as_error(x,"a real number",filename,line);
+ throw as_exception(x,"a real number",filename,line);
}
} // namespace cln
#include "cl_RA.h"
#include "cln/io.h"
#include "cln/real_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
namespace cln {
}
}
}
- fprint(std::cerr, "random: argument should be positive and an integer or float: ");
- fprint(std::cerr, n);
- fprint(std::cerr, "\n");
- cl_abort();
+ std::ostringstream buf;
+ fprint(buf, "random: argument should be positive and an integer or float: ");
+ fprint(buf, n);
+ throw runtime_exception(buf.str());
}
} // namespace cln
if (eq(y,0)) {
// y=0 (exakt)
if (zerop(x)) // x=0 -> Error
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
if (minusp(x)) // x<0 -> pi in Default-Float-Genauigkeit
{ return pi(); }
return 0; // x>0 -> 0
elif (eq(x,0)) {
// x=0 (exakt)
if (zerop(y)) // y=0 -> Error
- { cl_error_division_by_0(); }
+ { throw division_by_0_exception(); }
if (minusp(y)) // y<0 -> -pi/2
{ return - scale_float(pi(),-1); }
return scale_float(pi(),-1); // y>0 -> pi/2
Mutable(cl_R,b);
if (rationalp(b)) {
// b rational
- if (eq(b,1)) { cl_error_division_by_0(); }
+ if (eq(b,1)) { throw division_by_0_exception(); }
if (rationalp(a)) {
// a,b beide rational
var cl_RA l;
#include "cl_I.h"
#include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_offsetof.h"
namespace cln {
struct cl_heap_GV_I_general : public cl_heap_GV_I {
cl_I data[1];
// Standard allocation disabled.
- void* operator new (size_t size) { unused size; cl_abort(); return (void*)1; }
+ void* operator new (size_t size) { unused size; throw runtime_exception(); }
// Standard deallocation disabled.
- void operator delete (void* ptr) { unused ptr; cl_abort(); }
+ void operator delete (void* ptr) { unused ptr; throw runtime_exception(); }
// No default constructor.
cl_heap_GV_I_general ();
};
var uintC srclen = srcv->v.length();
var uintC destlen = destv->v.length();
if (!(srcindex <= srcindex+count && srcindex+count <= srclen))
- cl_abort();
+ throw runtime_exception();
if (!(destindex <= destindex+count && destindex+count <= destlen))
- cl_abort();
+ throw runtime_exception();
do {
destv->data[destindex++] = srcv->data[srcindex++];
} while (--count > 0);
struct cl_heap_GV_I_bits##m : public cl_heap_GV_I { \
uint_t data[1]; \
/* Standard allocation disabled. */ \
- void* operator new (size_t size) { unused size; cl_abort(); return (void*)1; } \
+ void* operator new (size_t size) { unused size; throw runtime_exception(); } \
/* Standard deallocation disabled. */ \
- void operator delete (void* ptr) { unused ptr; cl_abort(); } \
+ void operator delete (void* ptr) { unused ptr; throw runtime_exception(); } \
/* No default constructor. */ \
cl_heap_GV_I_bits##m (); \
}; \
var uintC srclen = srcv->v.length(); \
var uintC destlen = destv->v.length(); \
if (!(srcindex <= srcindex+count && srcindex+count <= srclen)) \
- cl_abort(); \
+ throw runtime_exception(); \
if (!(destindex <= destindex+count && destindex+count <= destlen)) \
- cl_abort(); \
+ throw runtime_exception(); \
if (m == intDsize) { \
var const uintD* srcptr = &srcv->data[srcindex]; \
var uintD* destptr = &destv->data[destindex]; \
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
// Implementation.
-#include "cln/abort.h"
+#include "cln/exception.h"
#include "cl_offsetof.h"
namespace cln {
struct cl_heap_GV_number_general : public cl_heap_GV_number {
cl_number data[1];
// Standard allocation disabled.
- void* operator new (size_t size) { unused size; cl_abort(); return (void*)1; }
+ void* operator new (size_t size) { unused size; throw runtime_exception(); }
// Standard deallocation disabled.
- void operator delete (void* ptr) { unused ptr; cl_abort(); }
+ void operator delete (void* ptr) { unused ptr; throw runtime_exception(); }
// No default constructor.
cl_heap_GV_number_general ();
};
var uintC srclen = srcv->v.length();
var uintC destlen = destv->v.length();
if (!(srcindex <= srcindex+count && srcindex+count <= srclen))
- cl_abort();
+ throw runtime_exception();
if (!(destindex <= destindex+count && destindex+count <= destlen))
- cl_abort();
+ throw runtime_exception();
do {
destv->data[destindex++] = srcv->data[srcindex++];
} while (--count > 0);
// Implementation.
-#include "cln/abort.h"
-
namespace cln {
static void cl_svector_number_destructor (cl_heap* pointer)
// Implementation.
-#include "cln/abort.h"
-
namespace cln {
static void cl_svector_ringelt_destructor (cl_heap* pointer)
#include "cl_2DS.h"
#include <cln/random.h>
#include "cl_random_impl.h"
-#include <cln/abort.h>
#include <cstdlib>
#include <cstring>
#include <cln/timing.h>
div2adic(a_len,a_LSDptr,b_len,b_LSDptr,q_LSDptr);
div2adic_algo = 1;
div2adic(a_len,a_LSDptr,b_len,b_LSDptr,q1_LSDptr);
- if (compare_loop_msp(q_MSDptr,q1_MSDptr,a_len)) cl_abort();
+ if (compare_loop_msp(q_MSDptr,q1_MSDptr,a_len)) abort();
// Time.
div2adic_algo = 0;
{ CL_TIMING;
#include "cl_2DS.h"
#include <cln/random.h>
#include "cl_random_impl.h"
-#include <cln/abort.h>
#include <cstdlib>
#include <cstring>
#include <cln/timing.h>
#include <cln/timing.h>
#include <cl_print.h>
#include <cln/malloc.h>
-#include <cln/abort.h>
int main (int argc, char * argv[])
{
{
char* p = (cl_digits_algo = 0, cl_decimal_string(a));
char* q = (cl_digits_algo = 1, cl_decimal_string(a));
- if (strcmp(p,q)) cl_abort();
+ if (strcmp(p,q)) abort();
free_hook(p);
free_hook(q);
}
#include <cstring>
#include <cln/timing.h>
#include <cln/malloc.h>
-#include <cln/abort.h>
using namespace cln;
int main (int argc, char * argv[])
#include "cl_2DS.h"
#include <cln/random.h>
#include "cl_random_impl.h"
-#include <cln/abort.h>
#include <cstdlib>
#include <cstring>
#include <cln/timing.h>
recip2adic(len,a_LSDptr,b_LSDptr);
recip2adic_threshold = threshold;
recip2adic(len,a_LSDptr,bn_LSDptr);
- if (compare_loop_msp(b_MSDptr,bn_MSDptr,len)) cl_abort();
+ if (compare_loop_msp(b_MSDptr,bn_MSDptr,len)) abort();
// Time.
recip2adic_threshold = 1000000;
{ CL_TIMING;