]> www.ginac.de Git - cln.git/commitdiff
Remove exception hooks in favor of real C++ exceptions:
authorRichard Kreckel <kreckel@ginac.de>
Sat, 28 Jul 2007 17:11:46 +0000 (17:11 +0000)
committerRichard Kreckel <kreckel@ginac.de>
Sat, 28 Jul 2007 17:11:46 +0000 (17:11 +0000)
        * 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.

210 files changed:
ChangeLog
INSTALL
NEWS
README
doc/cln.tex
examples/contfrac.cc
include/cln/GV.h
include/cln/SV.h
include/cln/abort.h [deleted file]
include/cln/cln.h
include/cln/exception.h [new file with mode: 0644]
include/cln/float.h
include/cln/integer.h
include/cln/modinteger.h
include/cln/number_io.h
include/cln/object.h
include/cln/rational.h
include/cln/ring.h
include/cln/string.h
include/cln/univpoly.h
src/base/cl_N.h
src/base/cl_N_err_d0.cc [deleted file]
src/base/cl_abort.cc [deleted file]
src/base/cl_as_err.cc [deleted file]
src/base/cl_as_exception.cc [new file with mode: 0644]
src/base/cl_d0_exception.cc [new file with mode: 0644]
src/base/cl_debug.cc
src/base/cl_macros.h
src/base/cl_malloc.cc
src/base/cl_notreached.cc [deleted file]
src/base/cl_notreached_exception.cc [new file with mode: 0644]
src/base/digitseq/cl_2DS_div.cc
src/base/digitseq/cl_DS_div.cc
src/base/digitseq/cl_DS_mul.cc
src/base/digitseq/cl_DS_mul_fftc.h
src/base/digitseq/cl_DS_mul_fftcs.h
src/base/digitseq/cl_DS_mul_fftm.h
src/base/digitseq/cl_DS_mul_fftp.h
src/base/digitseq/cl_DS_mul_fftp3.h
src/base/digitseq/cl_DS_mul_fftp3m.h
src/base/digitseq/cl_DS_mul_fftr.h
src/base/digitseq/cl_DS_mul_nuss.h
src/base/digitseq/cl_DS_recip.cc
src/base/digitseq/cl_DS_recipsqrt.cc
src/base/digitseq/cl_DS_sqrt.cc
src/base/hash/cl_hash.h
src/base/hash/cl_hash1.h
src/base/hash/cl_hash1weak.h
src/base/hash/cl_hash2.h
src/base/hash/cl_hash2weak.h
src/base/hash/cl_hashset.h
src/base/hash/cl_hashuniq.h
src/base/hash/cl_hashuniqweak.h
src/base/input/cl_read_bad_syntax_exception.cc [new file with mode: 0644]
src/base/input/cl_read_eof_exception.cc [moved from src/base/input/cl_read_err_eof.cc with 52% similarity]
src/base/input/cl_read_err_bad.cc [deleted file]
src/base/input/cl_read_err_junk.cc [deleted file]
src/base/input/cl_read_junk_exception.cc [new file with mode: 0644]
src/base/proplist/cl_pl_add.cc
src/base/ring/cl_no_ring.cc
src/base/string/cl_spushstring.h
src/base/symbol/cl_symbol.cc
src/complex/input/cl_N_read.cc
src/complex/input/cl_N_read_stream.cc
src/complex/misc/cl_N_as.cc
src/complex/transcendental/cl_C_atanh_aux.cc
src/complex/transcendental/cl_C_expt_C.cc
src/complex/transcendental/cl_C_log.cc
src/complex/transcendental/cl_C_log2.cc
src/float/base/cl_F_err_nan.cc [deleted file]
src/float/base/cl_F_err_ov.cc [deleted file]
src/float/base/cl_F_err_un.cc [deleted file]
src/float/base/cl_F_nan_exception.cc [new file with mode: 0644]
src/float/base/cl_F_overflow_exception.cc [new file with mode: 0644]
src/float/base/cl_F_underflow_exception.cc [new file with mode: 0644]
src/float/cl_F.h
src/float/dfloat/cl_DF.h
src/float/dfloat/conv/cl_DF_from_double.cc
src/float/dfloat/elem/cl_DF_div.cc
src/float/dfloat/elem/cl_DF_from_RA.cc
src/float/dfloat/elem/cl_DF_scale.cc
src/float/dfloat/elem/cl_DF_scale_I.cc
src/float/dfloat/misc/cl_DF_as.cc
src/float/ffloat/cl_FF.h
src/float/ffloat/conv/cl_FF_from_float.cc
src/float/ffloat/elem/cl_FF_div.cc
src/float/ffloat/elem/cl_FF_from_RA.cc
src/float/ffloat/elem/cl_FF_scale.cc
src/float/ffloat/elem/cl_FF_scale_I.cc
src/float/ffloat/misc/cl_FF_as.cc
src/float/input/cl_F_read.cc
src/float/input/cl_F_read_stream.cc
src/float/lfloat/algebraic/cl_LF_sqrt.cc
src/float/lfloat/elem/cl_LF_1plus.cc
src/float/lfloat/elem/cl_LF_I_div.cc
src/float/lfloat/elem/cl_LF_I_mul.cc
src/float/lfloat/elem/cl_LF_div.cc
src/float/lfloat/elem/cl_LF_from_I.cc
src/float/lfloat/elem/cl_LF_mul.cc
src/float/lfloat/elem/cl_LF_scale.cc
src/float/lfloat/elem/cl_LF_scale_I.cc
src/float/lfloat/elem/cl_LF_square.cc
src/float/lfloat/misc/cl_LF_as.cc
src/float/lfloat/misc/cl_LF_shorten.cc
src/float/lfloat/misc/cl_LF_shortenrel.cc
src/float/lfloat/misc/cl_LF_shortenwith.cc
src/float/misc/cl_F_as.cc
src/float/misc/cl_F_shortenrel.cc
src/float/sfloat/cl_SF.h
src/float/sfloat/elem/cl_SF_div.cc
src/float/sfloat/elem/cl_SF_from_RA.cc
src/float/sfloat/elem/cl_SF_scale.cc
src/float/sfloat/elem/cl_SF_scale_I.cc
src/float/sfloat/misc/cl_SF_as.cc
src/float/transcendental/cl_LF_coshsinh_aux.cc
src/float/transcendental/cl_LF_cossin_aux.cc
src/float/transcendental/cl_LF_eulerconst.cc
src/float/transcendental/cl_LF_exp_aux.cc
src/float/transcendental/cl_LF_ratseries_.cc
src/float/transcendental/cl_LF_ratseries_a.cc
src/float/transcendental/cl_LF_ratseries_ab.cc
src/float/transcendental/cl_LF_ratseries_b.cc
src/float/transcendental/cl_LF_ratseries_p.cc
src/float/transcendental/cl_LF_ratseries_pa.cc
src/float/transcendental/cl_LF_ratseries_pab.cc
src/float/transcendental/cl_LF_ratseries_pb.cc
src/float/transcendental/cl_LF_ratseries_pq.cc
src/float/transcendental/cl_LF_ratseries_pqa.cc
src/float/transcendental/cl_LF_ratseries_pqab.cc
src/float/transcendental/cl_LF_ratseries_pqb.cc
src/float/transcendental/cl_LF_ratseries_q.cc
src/float/transcendental/cl_LF_ratseries_qa.cc
src/float/transcendental/cl_LF_ratseries_qab.cc
src/float/transcendental/cl_LF_ratseries_qb.cc
src/float/transcendental/cl_LF_ratseries_stream_pq.cc
src/float/transcendental/cl_LF_ratseries_stream_pqa.cc
src/float/transcendental/cl_LF_ratseries_stream_pqab.cc
src/float/transcendental/cl_LF_ratseries_stream_pqb.cc
src/float/transcendental/cl_LF_ratsumseries_pqcd.cc
src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc
src/float/transcendental/cl_LF_ratsumseries_pqd.cc
src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc
src/float/transcendental/cl_LF_zeta_int.cc
src/integer/algebraic/cl_I_sqrt.cc
src/integer/bitwise/cl_I_ash.cc
src/integer/bitwise/cl_I_ash.h [deleted file]
src/integer/bitwise/cl_I_ash_I.cc
src/integer/bitwise/cl_I_ash_exception.cc [new file with mode: 0644]
src/integer/bitwise/cl_I_asherr.cc [deleted file]
src/integer/bitwise/cl_I_logbitp_I.cc
src/integer/cl_I.h
src/integer/conv/cl_I_to_L.cc
src/integer/conv/cl_I_to_Q.cc
src/integer/conv/cl_I_to_UL.cc
src/integer/conv/cl_I_to_UQ.cc
src/integer/conv/cl_I_to_digits.cc
src/integer/division/cl_I_exquo.cc
src/integer/division/cl_I_exquo_exception.cc [new file with mode: 0644]
src/integer/division/cl_I_exquoerr.cc [deleted file]
src/integer/division/cl_I_exquopos.cc
src/integer/elem/cl_I_div.cc
src/integer/gcd/cl_I_gcd_aux2.cc
src/integer/input/cl_I_read.cc
src/integer/input/cl_I_read_stream.cc
src/integer/misc/cl_I_as.cc
src/modinteger/cl_MI.cc
src/modinteger/cl_MI_err_comp.cc
src/modinteger/cl_MI_int.h
src/modinteger/cl_MI_montgom.h
src/modinteger/cl_MI_pow2.h
src/modinteger/cl_MI_rshift.cc
src/modinteger/cl_MI_std.h
src/numtheory/cl_nt_cornacchia1.cc
src/numtheory/cl_nt_cornacchia4.cc
src/numtheory/cl_nt_isprobprime.cc
src/numtheory/cl_nt_jacobi.cc
src/numtheory/cl_nt_jacobi_low.cc
src/numtheory/cl_nt_sqrtmodp.cc
src/polynomial/elem/cl_UP_GF2.h
src/polynomial/elem/cl_UP_MI.h
src/polynomial/elem/cl_UP_gen.h
src/polynomial/elem/cl_UP_named.cc
src/polynomial/elem/cl_UP_no_ring.cc
src/polynomial/elem/cl_UP_number.h
src/polynomial/elem/cl_UP_unnamed.cc
src/rational/elem/cl_RA_from_I_I_div.cc
src/rational/elem/cl_RA_recip.cc
src/rational/input/cl_RA_read.cc
src/rational/input/cl_RA_read_stream.cc
src/rational/input/cl_RA_readparsed.cc
src/rational/misc/cl_RA_as.cc
src/real/elem/cl_R_div.cc
src/real/format-output/cl_fmt_cardinal.cc
src/real/format-output/cl_fmt_newroman.cc
src/real/format-output/cl_fmt_oldroman.cc
src/real/input/cl_R_read.cc
src/real/input/cl_R_read_stream.cc
src/real/misc/cl_R_as.cc
src/real/random/cl_R_random.cc
src/real/transcendental/cl_R_atan2.cc
src/real/transcendental/cl_R_log.cc
src/vector/cl_GV_I.cc
src/vector/cl_GV_number.cc
src/vector/cl_SV_number.cc
src/vector/cl_SV_ringelt.cc
tests/timediv2adic-compare.cc
tests/timediv2adic.cc
tests/timeprint-compare.cc
tests/timeprint.cc
tests/timerecip2adic-compare.cc

index 6f29f9bf9158e7856cc47c1b75338340b6642aaa..1efc991c386dab49adab62d12e08331cf13e5a67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,215 @@
+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.
diff --git a/INSTALL b/INSTALL
index 68ce91046c7ca169a603949ecb508dea9a271392..42477cda66dcc372e953eb36a442d00179e7aaf3 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -26,17 +26,10 @@ Known to work with:
 
 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.
diff --git a/NEWS b/NEWS
index 036535c6670afd2692b1c8bcdd1fe2a0f33ef1f7..7732c2d5c47483bc85d8d34329f65c4834cb8fea 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
-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.
 
 
diff --git a/README b/README
index 2f23d0ff4673f11fb066be7a87dc01a95992227e..018972d8aa81b713c9842d1cfc26241a6970ae73 100644 (file)
--- a/README
+++ b/README
@@ -25,14 +25,14 @@ Features:
 - 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>
index 197e9004c3e5e2e4313bd568ccd8d39dca0970ed..8e42b1e253772187201139043685648a7d69780e 100644 (file)
@@ -3,13 +3,9 @@
 @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
@@ -228,7 +224,8 @@ CLN aims at being easily integrated into larger software packages:
 @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 
@@ -246,7 +243,7 @@ This section describes how to install the CLN package on your system.
 @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,
@@ -254,7 +251,7 @@ constructors and destructors, inline, const, multiple inheritance,
 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++
@@ -325,13 +322,10 @@ Examples:
 
 @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
@@ -348,24 +342,12 @@ or no CXXFLAGS at all. (If CXXFLAGS is not set, CLN will use @code{-O}.)
 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.
 
@@ -401,7 +383,7 @@ some place where your compiler cannot find it by default, you must help
 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
 
@@ -2461,7 +2443,7 @@ affect the input syntax. The string starts at @code{string} and ends at
 @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.
@@ -3451,10 +3433,10 @@ Flags for customizing input operations.
 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>
@@ -3604,17 +3586,22 @@ available from the library:
 
 @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.
@@ -3666,32 +3653,54 @@ Unfortunately, this feature does not seem to work under all circumstances.
 @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}.
 
 
index b80c6611676f3f0f8647a60afe2a2204ad3cdf49..8c3b0be075af228b8e2cd3b02cad31e2ea50c908 100644 (file)
 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& ) {}
        }
 }
index e0d6d98e8ea9b4261c2e40055178680289adf00c..4f0a3691b1d0c3b939d866b2696cd449c4bcd960 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "cln/object.h"
 #include "cln/V.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include <cstdlib>
 
 namespace cln {
@@ -172,7 +172,7 @@ template <class T>
 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);
 }
@@ -181,7 +181,7 @@ template <class T>
 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);
 }
@@ -190,7 +190,7 @@ template <class T>
 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);
 }
@@ -255,7 +255,7 @@ public:
                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.
index 011bb13554265679ef72e965ba7b9a441c08af27..5881b6165090bf1eb585d7ca88e58f16ecb04df3 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "cln/object.h"
 #include "cln/V.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include <cstdlib>
 
 namespace cln {
@@ -50,14 +50,14 @@ public:
        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];
        }
diff --git a/include/cln/abort.h b/include/cln/abort.h
deleted file mode 100644 (file)
index 7bbf0ee..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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 */
index a56061a73b39a8bb4274b790bae1ca70264a8d11..4ff7e45a80036a45bc438fa8ad4dbf464583fbd1 100644 (file)
@@ -18,7 +18,7 @@
 // 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"
diff --git a/include/cln/exception.h b/include/cln/exception.h
new file mode 100644 (file)
index 0000000..d9f1a4f
--- /dev/null
@@ -0,0 +1,39 @@
+// 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 */
index abee49b04171ec682997e49bb2c5798a331e1288..383f1f27bf468f29e4b2fe1b394473a7dd4dc930 100644 (file)
@@ -12,6 +12,7 @@
 #include "cln/ffloat_class.h"
 #include "cln/dfloat_class.h"
 #include "cln/lfloat_class.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -733,11 +734,36 @@ inline cl_F& operator/= (cl_F& x, const float y) { return x = x / y; }
 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
index 28d51648802c5d25d0374632b5ecb231b613a510..f470442f9f991820506b0c152ec5d069dfabffbc 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "cln/number.h"
 #include "cln/integer_class.h"
+#include "cln/exception.h"
 #include "cln/random.h"
 
 namespace cln {
@@ -165,6 +166,12 @@ inline cl_boolean evenp (const cl_I& x)
 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);
 
@@ -421,6 +428,12 @@ struct cl_I_div_t {
 // < 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);
 
index 90647caeea4ab9bd03e011680a5ea186fe5d177f..ade02d881e200af7c90ebe6cbf2583dcb2d35942 100644 (file)
@@ -11,7 +11,7 @@
 #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 {
@@ -141,9 +141,9 @@ public:
        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; }
 };
 
 
@@ -253,13 +253,13 @@ public:
        // 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)
@@ -272,24 +272,24 @@ public:
        }
        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 ()
@@ -302,34 +302,34 @@ public:
        }
        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)
@@ -338,7 +338,7 @@ public:
        }
        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.
index bf77a05f4ce18719ff6c287d4d2690f636a3f5ec..aa9f18777b851c9a21a6df7dc8c654f0b5117c4c 100644 (file)
@@ -5,31 +5,35 @@
 
 #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;
 
index 1f660551b7b89cbe3befe62a64a0b3ad9ade774c..52f72ef8b4726bbf9a1d3a1467336cda5429b864 100644 (file)
@@ -554,7 +554,7 @@ inline cl_private_thing as_cl_private_thing (const cl_rcpointer& x)
   #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;                    \
     }
 
index 6b5085574ea1a0ddc81762ca033d278e66c40061..bccce7ff0d82f39c03534c5259c4ec41468e2b99 100644 (file)
@@ -6,6 +6,7 @@
 #include "cln/number.h"
 #include "cln/rational_class.h"
 #include "cln/integer_class.h"
+#include "cln/exception.h"
 
 namespace cln {
 
index b282cf362daba6e77a80204b62b91e8fa834aa06..8c7fbbb7a9546946e3b91f9d0492b7fe32a30b8b 100644 (file)
@@ -7,6 +7,7 @@
 #include "cln/malloc.h"
 #include "cln/proplist.h"
 #include "cln/number.h"
+#include "cln/exception.h"
 #include "cln/io.h"
 
 namespace cln {
@@ -235,13 +236,13 @@ public:
        // 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 ()
@@ -250,24 +251,24 @@ public:
        }
        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 ()
@@ -280,18 +281,18 @@ public:
        }
        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.
@@ -363,7 +364,20 @@ inline const cl_ring_element operator* (const cl_ring_element& x, const cl_I& y)
 
 
 // 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;
index 97703eca7c116d0139a77e9a04d502c0fbb77fe7..c316f04e8a758d1d839c634365c447ada0285a8a 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "cln/object.h"
 #include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include <cstring>
 
 namespace cln {
@@ -18,9 +18,9 @@ private:
        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:
@@ -52,7 +52,7 @@ public:
        // 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.
index 39e1f1e5260aa25bb0392d48c2d4aafad4b5e56d..95d2ea129baf958a4e685d5704c19dbf1101d703 100644 (file)
@@ -231,13 +231,13 @@ public:
        // 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 ()
@@ -246,24 +246,24 @@ public:
        }
        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 ()
@@ -276,33 +276,33 @@ public:
        }
        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)
@@ -311,7 +311,7 @@ public:
        }
        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)
@@ -320,17 +320,17 @@ public:
        }
        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.
index 6acdaba1b3e9e9575e9151bc8af678136fe579aa..cf803e41b553922a82b17e65e474ffb5c7f597eb 100644 (file)
@@ -8,9 +8,6 @@
 
 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
diff --git a/src/base/cl_N_err_d0.cc b/src/base/cl_N_err_d0.cc
deleted file mode 100644 (file)
index 5360d6e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/base/cl_abort.cc b/src/base/cl_abort.cc
deleted file mode 100644 (file)
index 45cb016..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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
diff --git a/src/base/cl_as_err.cc b/src/base/cl_as_err.cc
deleted file mode 100644 (file)
index 2becee8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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
diff --git a/src/base/cl_as_exception.cc b/src/base/cl_as_exception.cc
new file mode 100644 (file)
index 0000000..dcab70e
--- /dev/null
@@ -0,0 +1,44 @@
+// 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
diff --git a/src/base/cl_d0_exception.cc b/src/base/cl_d0_exception.cc
new file mode 100644 (file)
index 0000000..7175709
--- /dev/null
@@ -0,0 +1,15 @@
+// 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
index e5b0f6c038879e0a64a48ba8a49a314ecf883b14..2998b65ea7dcb46bf99088f8ffe028a042eebd71 100644 (file)
@@ -10,7 +10,6 @@
 // Implementation.
 
 #include "cln/io.h"
-#include "cln/abort.h"
 
 namespace cln {
 
index ec4999522c04b658175df14117f3f76e0ccddc37..af93ce1ca0484b6dec3d0ffb3ebd7bd06018013b 100644 (file)
@@ -4,6 +4,7 @@
 #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)
index ef6d8b651ecbb890ba953ad47e393c56c8c98e58..981254e3e8780f680d49dc61b0a2d071fa19bf98 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <cstdlib>
 #include "cln/io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #ifndef malloc
   extern "C" void* malloc (size_t size);
@@ -28,8 +28,7 @@ static void* xmalloc (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;
diff --git a/src/base/cl_notreached.cc b/src/base/cl_notreached.cc
deleted file mode 100644 (file)
index 95b27e5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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
diff --git a/src/base/cl_notreached_exception.cc b/src/base/cl_notreached_exception.cc
new file mode 100644 (file)
index 0000000..a8cc7fe
--- /dev/null
@@ -0,0 +1,34 @@
+// 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
index 5d0738ee3ad32c9e5fd0ced6036065a0cb9c0a2c..997e3964ded3b7a051ca9a0e798e905c31aa49a0 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cl_2D.h"
 #include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -126,7 +126,7 @@ void div2adic (uintC a_len, const uintD* a_LSDptr, uintC b_len, const uintD* b_L
       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)
index 1f850e99d37e84d5d09e79b071e3d497271b51a6..9de5fe1db0da0a35605f5aa5617b60140a786ed8 100644 (file)
@@ -9,8 +9,7 @@
 
 // Implementation.
 
-#include "cl_N.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -173,7 +172,7 @@ 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;
         }
@@ -293,11 +292,11 @@ namespace cln {
                       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.
@@ -310,10 +309,10 @@ namespace cln {
                       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
index 5400e7f25b932c0a5512208f4c307945f232e924..76be717f417f849d9118f76efefa61bb37ba19c9 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cl_low.h"
 #include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -499,7 +499,7 @@ 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
         }
index 5d6eeaefc34f3d243fb92257a0e0ad3e140abf4c..6bd21232177afab32676cd6a185120bfdfe99095 100644 (file)
 
 
 #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.
@@ -447,10 +446,10 @@ static void fftc_convolution (const uintL n, const uintC N, // N = 2^n
                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;
@@ -467,10 +466,10 @@ static void fftc_convolution (const uintL n, const uintC N, // N = 2^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);
@@ -663,8 +662,7 @@ static void fill_factor (uintC N, fftc_complex* x, uintL l,
        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)
@@ -689,11 +687,11 @@ static void fill_factor (uintC N, fftc_complex* x, uintL 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;
@@ -723,7 +721,7 @@ static void fill_factor (uintC N, fftc_complex* x, uintL l,
                }
                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;
@@ -731,7 +729,7 @@ static void fill_factor (uintC N, fftc_complex* x, uintL l,
                        i++;
                }
                if (len > 0)
-                       cl_abort();
+                       throw runtime_exception();
        }
        for ( ; i < N; i++) {
                x[i].re = (fftc_real)0;
@@ -886,7 +884,7 @@ static uintD* unfill_product (uintL n, uintC N, // N = 2^n
                        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];
@@ -944,8 +942,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1,
        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;
@@ -997,7 +994,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1,
                        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.
@@ -1020,10 +1017,10 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1,
                                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
@@ -1036,16 +1033,16 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1,
                            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;
@@ -1100,7 +1097,6 @@ static void mulu_fftcomplex (const uintD* sourceptr1, uintC len1,
        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");
        }
 }
index ed3019d17c8aac994df0dc2af3af4cbca840a28d..6269bf23fb0575079211badba77f1d3555c0e613 100644 (file)
 
 
 #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))
@@ -475,7 +474,7 @@ static uintC shuffle (uintL n, uintC x)
                        }
                x >>= 1;
        } while (!(--n == 0));
-       cl_abort();
+       throw runtime_exception();
 }
 
 #if 0 // unused
@@ -493,7 +492,7 @@ static uintC invshuffle (uintL n, uintC x)
                }
                v <<= 1;
        } while (!(--n == 0));
-       cl_abort();
+       throw runtime_exception();
 }
 #endif
 
@@ -727,8 +726,7 @@ static void fill_factor (uintC N, fftcs_real* x, uintL l,
        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)
@@ -751,11 +749,11 @@ static void fill_factor (uintC N, fftcs_real* x, uintL 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;
@@ -782,14 +780,14 @@ static void fill_factor (uintC N, fftcs_real* x, uintL l,
                }
                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;
@@ -942,7 +940,7 @@ static uintD* unfill_product (uintL n, uintC N, // N = 2^n
                        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];
@@ -1000,8 +998,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1,
        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;
@@ -1053,7 +1050,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1,
                        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.
@@ -1074,7 +1071,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1,
                                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);
@@ -1086,16 +1083,16 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1,
                            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;
@@ -1150,7 +1147,6 @@ static void mulu_fftcs (const uintD* sourceptr1, uintC len1,
        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");
        }
 }
index 9b973647a44077dc33c620a6d6cfc1dd56752275..9c9a5de2b52fa2941e233afa218606e904f16faf 100644 (file)
@@ -469,7 +469,7 @@ static void mulu_fftm (const uintL r, const uintC R, // R = 2^r
                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.
@@ -479,14 +479,14 @@ static void mulu_fftm (const uintL r, const uintC R, // R = 2^r
                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++;
@@ -496,7 +496,7 @@ static void mulu_fftm (const uintL r, const uintC R, // R = 2^r
        #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
@@ -562,7 +562,7 @@ static uintC numpieces (uintL r, uintL m, uintC len1, uintC len2)
        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);
 }
@@ -592,7 +592,7 @@ static void mulu_fft_modm (const uintD* sourceptr1, uintC len1,
        }
        #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)))
@@ -644,7 +644,7 @@ static void mulu_fft_modm (const uintD* sourceptr1, uintC len1,
                }
                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;
index 4743f2fede6d15b4e4d8641c448741e89f8e46bd..94a0197355a0c9048bd65857000b31dd994b54b0 100644 (file)
@@ -283,7 +283,7 @@ static inline void shift (const fftp_word& a, fftp_word& b)
 #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
@@ -301,13 +301,13 @@ static inline void shift (const fftp_word& a, fftp_word& b)
        #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
@@ -394,7 +394,7 @@ static void mulp (const fftp_word& a, const fftp_word& b, fftp_word& r)
        // 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 ?
@@ -407,7 +407,7 @@ static void mulp (const fftp_word& a, const fftp_word& b, fftp_word& r)
 #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
@@ -420,7 +420,7 @@ static void mulp_doublecheck (const fftp_word& a, const fftp_word& b, fftp_word&
        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 */
@@ -483,10 +483,10 @@ static void fftp_convolution (const uintL n, const uintC N, // N = 2^n
                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);
@@ -698,7 +698,7 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1,
                        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).
@@ -738,7 +738,7 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1,
                        // 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]:
                        {
@@ -775,7 +775,7 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1,
                                // ac2 = 0.
                                if (ac1 > 0) {
                                        if (!((i += 2) <= destlen))
-                                               cl_abort();
+                                               throw runtime_exception();
                                        tmp = lspref(ptr,0);
                                        if ((ac0 += tmp) < tmp)
                                                ++ac1;
@@ -787,24 +787,24 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1,
                                        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.
index 0af1353df78ffdbf12146bf338ba6f02f390f6da..d857eea6d51a6eed2384c16ba61328ea5e1920a5 100644 (file)
@@ -86,7 +86,7 @@ static const fftp3_word fftp3_roots_of_1 [27+1] =
 #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
@@ -290,7 +290,7 @@ static void mulp3_doublecheck (const fftp3_word& a, const fftp3_word& b, fftp3_w
        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 */
@@ -350,10 +350,10 @@ static void fftp3_convolution (const uintL n, const uintC N, // N = 2^n
                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);
@@ -565,7 +565,7 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1,
                        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).
@@ -603,7 +603,7 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1,
                                        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);
@@ -631,7 +631,7 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1,
                                // ac2 = 0.
                                if (ac1 > 0) {
                                        if (!((i += 2) <= destlen))
-                                               cl_abort();
+                                               throw runtime_exception();
                                        tmp = lspref(ptr,0);
                                        if ((ac0 += tmp) < tmp)
                                                ++ac1;
@@ -643,24 +643,24 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1,
                                        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.
index 801d171b7c9430317d3eb950139aa90a9d4176a1..0aed00b5a0a326e302e1609c69a6a58e7c29028f 100644 (file)
@@ -222,7 +222,7 @@ static const fftp3m_word fftp3m_roots_of_1 [26+1] =
 #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
@@ -349,7 +349,7 @@ static void combinep3m (const fftp3m_word& r, uintD* resLSDptr)
        #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);
@@ -422,7 +422,7 @@ static void mulp3m (const fftp3m_word& a, const fftp3m_word& b, fftp3m_word& res
                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;                                     \
        }
@@ -465,7 +465,7 @@ static void mulp3m_doublecheck (const fftp3m_word& a, const fftp3m_word& b, fftp
        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 */
@@ -527,12 +527,12 @@ static void fftp3m_convolution (const uintL n, const uintC N, // N = 2^n
                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);
@@ -744,7 +744,7 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1,
                        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).
@@ -782,7 +782,7 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1,
                                        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);
@@ -810,7 +810,7 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1,
                                // ac2 = 0.
                                if (ac1 > 0) {
                                        if (!((i += 2) <= destlen))
-                                               cl_abort();
+                                               throw runtime_exception();
                                        tmp = lspref(ptr,0);
                                        if ((ac0 += tmp) < tmp)
                                                ++ac1;
@@ -822,24 +822,24 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1,
                                        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.
index 588f10212fbdefed36ce5435bd3bd456879debbe..d99da53837a7f1d4a5828ee2434898048b71b0d1 100644 (file)
 
 
 #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))
@@ -413,7 +412,7 @@ static uintC shuffle (uintL n, uintC x)
                        }
                x >>= 1;
        } while (!(--n == 0));
-       cl_abort();
+       throw runtime_exception();
 }
 
 #if 0 // unused
@@ -431,7 +430,7 @@ static uintC invshuffle (uintL n, uintC x)
                }
                v <<= 1;
        } while (!(--n == 0));
-       cl_abort();
+       throw runtime_exception();
 }
 #endif
 
@@ -714,8 +713,7 @@ static void fill_factor (uintC N, fftr_real* x, uintL l,
        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)
@@ -738,11 +736,11 @@ static void fill_factor (uintC N, fftr_real* x, uintL 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;
@@ -769,14 +767,14 @@ static void fill_factor (uintC N, fftr_real* x, uintL l,
                }
                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;
@@ -929,7 +927,7 @@ static uintD* unfill_product (uintL n, uintC N, // N = 2^n
                        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];
@@ -987,8 +985,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1,
        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;
@@ -1040,7 +1037,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1,
                        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.
@@ -1061,7 +1058,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1,
                                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);
@@ -1073,16 +1070,16 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1,
                            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;
@@ -1137,7 +1134,6 @@ static void mulu_fftr (const uintD* sourceptr1, uintC len1,
        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.");
        }
 }
index f6968e38cf6f8f653fb14671f9f6a6e6368d0e01..fb475e5bfd5a7e411555316c92b782893c57b14c 100644 (file)
@@ -409,7 +409,7 @@ static void mul_doublecheck (const nuss_inword& a, const nuss_inword& b, nuss_ou
                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
@@ -739,7 +739,7 @@ static inline void shift (const nuss_outword& a, nuss_outword& b)
 #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
@@ -760,7 +760,7 @@ static inline void shift (const nuss_outword& a, nuss_outword& b)
        #ifdef DEBUG_NUSS
        carry = tmp << 31;
        if (carry)
-               cl_abort();
+               throw runtime_exception();
        #endif
 #endif
 }
@@ -915,7 +915,7 @@ static inline void shift (const nuss_outword& a, nuss_outword& b)
 #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
@@ -933,7 +933,7 @@ static inline void shift (const nuss_outword& a, nuss_outword& b)
        #ifdef DEBUG_NUSS
        carry = tmp << 63;
        if (carry)
-               cl_abort();
+               throw runtime_exception();
        #endif
 #endif
 }
@@ -1390,7 +1390,7 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1,
                        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).
@@ -1426,7 +1426,7 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1,
                        // 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]:
                        {
@@ -1463,7 +1463,7 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1,
                                // ac2 = 0.
                                if (ac1 > 0) {
                                        if (!((i += 2) <= destlen))
-                                               cl_abort();
+                                               throw runtime_exception();
                                        tmp = lspref(ptr,0);
                                        if ((ac0 += tmp) < tmp)
                                                ++ac1;
@@ -1475,24 +1475,24 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1,
                                        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.
index a4ed47a27232f7c86bae97ea3540359ebba82df9..67680ef72654df06a628d1725ebd84301fc78851 100644 (file)
@@ -9,8 +9,6 @@
 
 // Implementation.
 
-#include "cln/abort.h"
-
 namespace cln {
 
 // Compute the reciprocal value of a digit sequence.
index e561c541165f8ad0acb8ec72ecb61673600256f2..d68c5a148cda5771e1162ee6d8e0bc23a51f9056 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cl_low.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -138,24 +138,24 @@ 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.
index 382c391a31bb72b59479844845c2c3eab49cf6ba..d3afef7ba81b01e0e178f62087e2973400cb16a7 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cl_low.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -155,7 +155,7 @@ cl_boolean cl_UDS_sqrt (const uintD* a_MSDptr, uintC a_len, const uintD* a_LSDpt
           // 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);
@@ -171,13 +171,13 @@ cl_boolean cl_UDS_sqrt (const uintD* a_MSDptr, uintC a_len, const uintD* a_LSDpt
             { 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);
@@ -185,7 +185,7 @@ cl_boolean cl_UDS_sqrt (const uintD* a_MSDptr, uintC a_len, const uintD* a_LSDpt
               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
index adf84665900ec5edde4d7db2b5cb994fd0ae94fd..92576f308ce7e840d4910a811ed3cf2ece29f9b3 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "cln/object.h"
 #include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_iterator.h"
 
 namespace cln {
@@ -132,7 +132,7 @@ protected:
             return index;
         }
         #if !(defined(__hppa__) && !defined(__GNUC__)) // workaround HP CC problem
-        cl_abort();
+        throw runtime_exception();
         #endif
         return -1; // dummy
     }
@@ -170,7 +170,7 @@ public:
     htentry& next ()
     {
         if (_index < 0)
-            cl_abort();
+            throw runtime_exception();
         var long old_index = _index;
         do { _index--; }
            while (_index >= 0 && _entries[_index].next < 0);
index 9dd37cfbaab9976b4333c22bd69382dcf9c841c6..06028803a3e62e321b76d0f925e4f83aaffcad64 100644 (file)
@@ -49,7 +49,7 @@ public:
         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;
@@ -65,7 +65,7 @@ public:
             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;
@@ -89,7 +89,7 @@ public:
         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;
index e351332a75f3b317b8d5658fdc65688e92596046..071cf85f8356cbaf89868df96a2a26ab8949935d 100644 (file)
@@ -63,7 +63,7 @@ private:
                                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++;
index 3f7a20fc9fea222358a3a5d0a4e1991c6b92872a..da911a774175dfea30661c0ead01ee27a08d4e80 100644 (file)
@@ -47,7 +47,7 @@ public:
         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;
@@ -64,7 +64,7 @@ public:
             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;
@@ -89,7 +89,7 @@ public:
         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
index c3c4279aeb3d9901bf764c9cb3de9fa332c1c741..f14d58570c22c1bade4962308756b53119477bd0 100644 (file)
@@ -63,7 +63,7 @@ private:
                                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++;
index 2c13e885cb99f0ac485f5cab3a4c360710179f28..15ced7b0887fab673e65a942bfb89ee228fa3e9f 100644 (file)
@@ -38,7 +38,7 @@ public:
         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;
@@ -54,7 +54,7 @@ public:
             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;
@@ -76,7 +76,7 @@ public:
         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;
index 81af352fe0780fb06242d7966ff33b022a6d2919..a5df68b9314a209ecb0e624c62aff7ce05d49e88 100644 (file)
@@ -49,7 +49,7 @@ public:
         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;
@@ -65,7 +65,7 @@ public:
             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;
@@ -87,7 +87,7 @@ public:
         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;
index 7aca1920a76f56d7341587ddf322c5ff130fdbb4..fd1793fded700bdca0e61d2d601675c50ce2eb4e 100644 (file)
@@ -63,7 +63,7 @@ private:
                                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++;
diff --git a/src/base/input/cl_read_bad_syntax_exception.cc b/src/base/input/cl_read_bad_syntax_exception.cc
new file mode 100644 (file)
index 0000000..8b7928f
--- /dev/null
@@ -0,0 +1,32 @@
+// 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
similarity index 52%
rename from src/base/input/cl_read_err_eof.cc
rename to src/base/input/cl_read_eof_exception.cc
index 5fc8318fe73e679059945f767ea519dcca4b648f..db9e202cb67b205ce6c2d8c472bc207ef55141c0 100644 (file)
@@ -1,4 +1,4 @@
-// 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
diff --git a/src/base/input/cl_read_err_bad.cc b/src/base/input/cl_read_err_bad.cc
deleted file mode 100644 (file)
index 023abb8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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
diff --git a/src/base/input/cl_read_err_junk.cc b/src/base/input/cl_read_err_junk.cc
deleted file mode 100644 (file)
index 8e62933..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
diff --git a/src/base/input/cl_read_junk_exception.cc b/src/base/input/cl_read_junk_exception.cc
new file mode 100644 (file)
index 0000000..85640c0
--- /dev/null
@@ -0,0 +1,37 @@
+// 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
index 3de5272acbf9d3759ca85227b63d066730d2b40c..47e88e66f7e5ccb7f99e75b7710ad1d2306adbad 100644 (file)
@@ -9,7 +9,7 @@
 
 // Implementation.
 
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -19,7 +19,7 @@ void cl_property::dummy () {}
 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;
 }
index 86869bdd30da809a62d38cc27182f3a565505cde..6c4f7a004af392c8354a0e396b2d095f9d4dfddf 100644 (file)
@@ -11,71 +11,85 @@ CL_PROVIDE(cl_no_ring)
 
 // 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
@@ -86,7 +100,7 @@ static const _cl_ring_element dummy_canonhom (cl_heap_ring* R, const cl_I& x)
 {
        unused R;
        (void)&x; // unused x;
-       uninitialized_ring(); RETDUMMY;
+       throw uninitialized_ring_exception();
 }
 #define dummy_mul dummy_op2
 #define dummy_square dummy_op1
@@ -94,7 +108,7 @@ static const _cl_ring_element dummy_expt_pos (cl_heap_ring* R, const _cl_ring_el
 {
        unused R;
        (void)&y; // unused y;
-       uninitialized_error(x); RETDUMMY;
+       throw uninitialized_exception(x);
 }
 
 static cl_ring_setops dummy_setops = {
index 0abfa513bd57c73deac831ab43d19c90e56cb07b..eaae52e33d11f9e00cdda7409a4fedc90a5f4e9e 100644 (file)
@@ -6,7 +6,7 @@
 #include "cln/object.h"
 #include "cln/malloc.h"
 #include "cl_sstring.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -56,7 +56,7 @@ inline uintL cl_spushstring::length () const
 }
 inline char cl_spushstring::operator[] (uintL i) const
 {
-       if (!(i < index)) cl_abort();
+       if (!(i < index)) throw runtime_exception();
        return buffer[i];
 }
 
index 01930278f79b1fe596e220679e8e908292d6f059..7e86b796d16c6a7709e98973ae88df704eea55ca 100644 (file)
@@ -92,7 +92,7 @@ cl_symbol::cl_symbol (const cl_string& s)
                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);
index 0c363394cb81d31393e7032cdeb85ef127571470..76fabe2637b99f79c5d51d91cd85ba9ebfed21f3 100644 (file)
@@ -10,6 +10,7 @@
 // Implementation.
 
 #include <cstring>
+#include <sstream>
 #include "cln/input.h"
 #include "cln/real_io.h"
 #include "cln/float_io.h"
@@ -19,7 +20,7 @@
 #include "cl_I.h"
 #include "cl_F.h"
 #include "cl_C.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -59,7 +60,7 @@ static const cl_N read_complex_number_rest (const cl_read_flags& flags, const ch
   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)
 {
@@ -92,10 +93,10 @@ const cl_N read_complex (const cl_read_flags& flags, const char * string, const
                                                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;
@@ -297,7 +298,7 @@ not_complex_syntax:
                *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)
index 7199476a362ee92920f4514accb65096dba3294f..3f119c4147c7a248d57b061e7694d595a7b4792c 100644 (file)
@@ -108,10 +108,10 @@ done:
 
        // 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
index 1b8f41f729c7f319d8db950f8c82dd4735c5780b..15cccfd67042de8b3c53909d5698c7106092c6ed 100644 (file)
@@ -10,6 +10,7 @@
 // Implementation.
 
 #include "cl_N.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -40,7 +41,7 @@ const cl_N& cl_N_As (const cl_number& x, const char * filename, int line)
                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
index 42cae7567fa3c4e28a800a0f8c9b0daf9f5cbf2f..3b3014c5a6a39991c61db715a925a9edc493bd66 100644 (file)
@@ -71,7 +71,7 @@ const cl_C_R atanh (const cl_R& x, const cl_R& y)
                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:
@@ -112,7 +112,7 @@ const cl_C_R atanh (const cl_R& x, const cl_R& y)
                        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);
                }
        }
index 151a9d25fc269af2b596217977247f4625d69c26..5e042c920e098030e59114b5c0b9f87e62272888 100644 (file)
@@ -184,7 +184,7 @@ const cl_N expt (const cl_N& x, const cl_N& y)
                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
index 6e3c6804bcc1453f9ab9105060b746a4b71b8bf2..c96577cb794a8cf3673e3c8f78e7231eb0570a18 100644 (file)
@@ -21,7 +21,7 @@ const cl_N log (const cl_N& x)
 // (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));
 }
 
index 86e22fac2722735bda8b1e9f4e31ee8a49bc02a8..0232c22ef2318edf1e82277744c037defddbecd3 100644 (file)
@@ -55,7 +55,7 @@ const cl_N log (const cl_N& a, const cl_N& b)
                {
                        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);
diff --git a/src/float/base/cl_F_err_nan.cc b/src/float/base/cl_F_err_nan.cc
deleted file mode 100644 (file)
index f616ec5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/float/base/cl_F_err_ov.cc b/src/float/base/cl_F_err_ov.cc
deleted file mode 100644 (file)
index 270b052..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/float/base/cl_F_err_un.cc b/src/float/base/cl_F_err_un.cc
deleted file mode 100644 (file)
index 3ac0dcf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/float/base/cl_F_nan_exception.cc b/src/float/base/cl_F_nan_exception.cc
new file mode 100644 (file)
index 0000000..a1a70d3
--- /dev/null
@@ -0,0 +1,20 @@
+// 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
diff --git a/src/float/base/cl_F_overflow_exception.cc b/src/float/base/cl_F_overflow_exception.cc
new file mode 100644 (file)
index 0000000..f35d7b7
--- /dev/null
@@ -0,0 +1,20 @@
+// 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
diff --git a/src/float/base/cl_F_underflow_exception.cc b/src/float/base/cl_F_underflow_exception.cc
new file mode 100644 (file)
index 0000000..ab717ae
--- /dev/null
@@ -0,0 +1,20 @@
+// 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
index c1406422f84ec8b33206314af3241531691f54f5..a62329ddf1df9022cf63af78f8151ed7042b6969 100644 (file)
@@ -9,9 +9,6 @@
 
 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)
 
 
@@ -72,10 +69,6 @@ extern const cl_FF cl_LF_to_FF (const cl_LF& x);
 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;
index ec81dc1c942c0785ccb628628a8337c8cb5f339b..988553d9f3cd5481dfabc6951253b895fb00929e 100644 (file)
@@ -161,13 +161,13 @@ inline const cl_DF encode_DF (cl_signean sign, sintL exp, uintQ mant)
 {
       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 */
@@ -188,13 +188,13 @@ inline const cl_DF encode_DF (cl_signean sign, sintL exp, uintL manthi, uintL ma
 {
       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 */
@@ -234,7 +234,7 @@ inline double DF_to_double (const cl_DF& obj)
               )                                                                \
               && 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 */       \
         }                                                              \
@@ -242,12 +242,12 @@ inline double DF_to_double (const cl_DF& obj)
             && (((~_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); }                \
@@ -262,7 +262,7 @@ inline double DF_to_double (const cl_DF& obj)
               )   )                                                       \
               && 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           */\
         }                                                                 \
@@ -270,12 +270,12 @@ inline double DF_to_double (const cl_DF& obj)
             && (((~_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); }  \
index f6c46053d84776a87b71e3095597802ee788985b..7e3ffe93b96a67bd33e8f948e2a4e50eef65d578 100644 (file)
@@ -19,20 +19,20 @@ cl_heap_dfloat* cl_double_to_DF_pointer (const dfloatjanus& val_)
       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);
         }
@@ -41,20 +41,20 @@ cl_heap_dfloat* cl_double_to_DF_pointer (const dfloatjanus& 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);
         }
index d5e954193c63a6b8e9044e1ea2d5b0ddf0a844c9..786b866b15cd1cb88c87422943083ca467893999 100644 (file)
@@ -69,10 +69,10 @@ const cl_DF operator/ (const cl_DF& x1, const cl_DF& x2)
       #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
index f05bbc5210f4f9179049e114b816e5c7bc83d7f8..6e9cbf7573e9415eb84667d79e3031197de07a1b 100644 (file)
@@ -44,10 +44,10 @@ const cl_DF cl_RA_to_DF (const cl_RA& x)
       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; }
         }
index b3c1ef02afbf3e048463fa51003cd0f7f647b299..a932408b7892ee0cee1b2eda892c3ded0a62b138 100644 (file)
@@ -43,7 +43,7 @@ const cl_DF scale_float (const cl_DF& x, sintC delta)
 #endif
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -58,7 +58,7 @@ const cl_DF scale_float (const cl_DF& x, sintC delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return cl_DF_0; }
         }
index c0e5682a53dae5382d21854ddc853de2fa9d7b35..1c60c86e67b12088a0862b9baaeffaac0e467116 100644 (file)
@@ -46,7 +46,7 @@ const cl_DF scale_float (const cl_DF& x, const cl_I& delta)
 #endif
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -64,7 +64,7 @@ const cl_DF scale_float (const cl_DF& x, const cl_I& delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return cl_DF_0; }
         }
index d3efc2ddf0337324873f697410a2a549f901491e..f37817082cc3a39a77a22c417b47b3e1cc470deb 100644 (file)
@@ -27,7 +27,7 @@ const cl_DF& cl_DF_As (const cl_number& x, const char * filename, int line)
                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
index a7c5f3b2e5420444a8da178e39a5f2bbdd2fb7c2..ecbc70290544384308b669b38f11636c57dc3f79 100644 (file)
@@ -144,13 +144,13 @@ inline const cl_FF encode_FF (cl_signean sign, sintL exp, uintL mant)
 {
        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));
 }
@@ -191,7 +191,7 @@ inline float FF_to_float (const cl_FF& obj)
               )                                                                \
               && 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 */       \
         }                                                              \
@@ -199,12 +199,12 @@ inline float FF_to_float (const cl_FF& obj)
             && (((~_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); }                \
index 64eda100de34452c5d43cc390d437ef4d0fefcd0..29be439ca7b12a35084e507c17e4fa992ff4af0e 100644 (file)
@@ -17,20 +17,20 @@ cl_private_thing cl_float_to_FF_pointer (const ffloatjanus& val_)
       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));
index b3492b4ac16b7f3fcb53705550e6a8be074cd9f6..bc9f21f7001c5868d071a88787e846557fcca108 100644 (file)
@@ -59,7 +59,7 @@ const cl_FF operator/ (const cl_FF& x1, const cl_FF& x2)
       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
index 40332a82ad737387dc2a06caf1d10c10847a6287..d3c7565c71e9c673f72d06d4cca7c0032e2f4822 100644 (file)
@@ -44,10 +44,10 @@ const cl_FF cl_RA_to_FF (const cl_RA& x)
       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; }
         }
index 8cf7b4d8a51b1df0c09bf460a6690c7d6a0dfeb8..688cf61bc6bd376c7217df15a8e6394bd917160d 100644 (file)
@@ -33,7 +33,7 @@ const cl_FF scale_float (const cl_FF& x, sintC delta)
               return encode_FF(sign,exp,mant);
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -44,7 +44,7 @@ const cl_FF scale_float (const cl_FF& x, sintC delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return cl_FF_0; }
         }
index b11386f7bb776fe65b18317d81f9a3085c95deb8..2f444d7d3afb1955bbb0300692ac6c95e7715c1b 100644 (file)
@@ -36,7 +36,7 @@ const cl_FF scale_float (const cl_FF& x, const cl_I& delta)
               return encode_FF(sign,exp,mant);
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -50,7 +50,7 @@ const cl_FF scale_float (const cl_FF& x, const cl_I& delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return cl_FF_0; }
         }
index e22057fdf141af6f2d08cf4b9dfe95dec29b864d..e9bbfef73ab588313fd64c1d1e8814ad782e3580 100644 (file)
@@ -33,7 +33,7 @@ const cl_FF& cl_FF_As (const cl_number& x, const char * filename, int line)
                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
index 627652d72563db27701046f356374f40238da578..52b3e2b100d0cd05d017628dda53f0dbcead0038 100644 (file)
@@ -51,7 +51,7 @@ static const char * skip_digits (const char * ptr, const char * string_limit, un
   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)
 {
@@ -175,7 +175,7 @@ not_float_syntax:
                *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
index b2daee602a9536b6a59feb5193eb58c240515ffa..d7a4eefe754157cb94746050b2fefd19264f05d8 100644 (file)
@@ -98,10 +98,10 @@ const cl_F read_float (std::istream& stream, const cl_read_flags& flags)
 
        // 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
index 8d53c6a0e7775854b1c9dcb2f30b83b01ab3e955..ae0719429cdc31a3e5fe0849353ebfe9c479cd8a 100644 (file)
@@ -13,7 +13,7 @@
 #include "cl_LF_impl.h"
 #include "cl_F.h"
 #include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -99,7 +99,7 @@ const cl_LF sqrt (const cl_LF& x)
             }
             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
             }
index 2114521667b8a52ca05544f08f6a8d370575925b..596a4dd366fb27260caf648a0f19148c911704c9 100644 (file)
@@ -124,7 +124,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2)
              { 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);
@@ -179,7 +179,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2)
                 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
                   }
@@ -212,7 +212,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2)
                 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
                   }
@@ -232,7 +232,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2)
            { // Ãœ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
          ;
index 139f3e1e153704a1c56b12ba6cf421722046c660..8f3772f7da3dc9db98dff7ff12e752323d9516e6 100644 (file)
@@ -27,7 +27,7 @@ const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y)
 // 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;
        }
@@ -88,7 +88,7 @@ const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y)
        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); }
        }
@@ -107,7 +107,7 @@ const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y)
              // Ãœ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);
 }
index d83424a9ebe73b99059fe99f1b255c68cda696c9..ebcf481e2fb9ddff5717f58747a40f418a5c5b1e 100644 (file)
@@ -64,7 +64,7 @@ const cl_R cl_LF_I_mul (const cl_LF& x, const cl_I& y)
        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;
@@ -82,7 +82,7 @@ const cl_R cl_LF_I_mul (const cl_LF& x, const cl_I& y)
          { 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);
 }
index 318b83d5bbe1170fa3f974b101e3bcd5732859cd..3b9f1fa7f1d969cb065e0bd68dfdc7396a3de1c2 100644 (file)
@@ -42,7 +42,7 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2)
       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; }
@@ -50,14 +50,14 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2)
       // (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
             }
@@ -105,7 +105,7 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2)
              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
@@ -138,14 +138,14 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2)
                  // Ãœ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
         }
index c18e3298c8e7e3ef6a058fd4153ff3880884cc69..9601436e6e506354056649124254b1f352ebd6c4 100644 (file)
@@ -43,7 +43,7 @@ const cl_LF cl_I_to_LF (const cl_I& x, uintC len)
          )
         {} // 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);
@@ -96,7 +96,7 @@ const cl_LF cl_I_to_LF (const cl_I& x, uintC 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
              ;
index 5429a6c4f0adfbe6384578e81db11208cc34d2e8..6132d0516f2fe249f412ffaec0febfac7b29aaee 100644 (file)
@@ -43,13 +43,13 @@ const cl_LF operator* (const cl_LF& x1, const cl_LF& x2)
         // 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:
@@ -77,7 +77,7 @@ const cl_LF operator* (const cl_LF& x1, const cl_LF& x2)
            // 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
              }
@@ -103,7 +103,7 @@ const cl_LF operator* (const cl_LF& x1, const cl_LF& x2)
                 (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;
 }
index 7a2738f2b19b68152f9c2e908dbdaf7a98223fff..9aa98b11169c18468cd8040464b409a694fcf9bb 100644 (file)
@@ -31,13 +31,13 @@ const cl_LF scale_float (const cl_LF& x, sintC delta)
        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);
index 6691fd7b6ce2ec42ee64e377cb5086aaab623812..ef119bd87e4b153d3f66f5fc34b1b45e159e7bac 100644 (file)
@@ -92,7 +92,7 @@ const cl_LF scale_float (const cl_LF& x, const cl_I& delta)
            || (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
@@ -100,7 +100,7 @@ const cl_LF scale_float (const cl_LF& x, const cl_I& delta)
            || (uexp < LF_exp_low) // oder Exponent zu klein?
           )
          underflow:
-         { cl_error_floating_point_underflow(); }
+         { throw floating_point_underflow_exception(); }
        goto ok;
 
       ok:
index 72d582741f0ffd49a0365352998e5377ca5527b8..956dcc96e7d3efa149358af3c38e91215e3a4e56 100644 (file)
@@ -30,14 +30,14 @@ const cl_LF square (const cl_LF& x)
         { 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.
@@ -57,7 +57,7 @@ const cl_LF square (const cl_LF& x)
            // 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
              }
@@ -83,7 +83,7 @@ const cl_LF square (const cl_LF& x)
                 (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;
 }
index 8f84e7a71e20ac3b1cee6fa6bdc8bed966facc93..ef6f527b6ec8401b5d123e3300b6793210d2d83e 100644 (file)
@@ -27,7 +27,7 @@ const cl_LF& cl_LF_As (const cl_number& x, const char * filename, int line)
                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
index 4d9696f7083b5ca460cf6814c5624217bd943cf4..f7e9b42df236756bd6dcc44695b70cba01bf4c02 100644 (file)
@@ -39,7 +39,7 @@ const cl_LF shorten (const cl_LF& x, uintC len)
               // Ãœ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;
index 77d5f756de57744ef6c7b2586950b3657ed798e7..52179670370465d7861094ffe50a3f353c5a1c1c 100644 (file)
@@ -9,7 +9,7 @@
 
 // Implementation.
 
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef MAYBE_INLINE2
 #define MAYBE_INLINE2 inline
@@ -31,7 +31,7 @@ const cl_LF cl_LF_shortenrelative (const cl_LF& x, const cl_LF& y)
        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) ?
index b12156ac79f8296a7e310bf118e00adf2e86bf57..f88a6144a720794742e33fd1a4049f38c180862e 100644 (file)
@@ -9,8 +9,6 @@
 
 // Implementation.
 
-#include "cln/abort.h"
-
 #undef MAYBE_INLINE2
 #define MAYBE_INLINE2 inline
 #include "cl_LF_precision.cc"
index 1f3dfffa84d2bf5e05a2eff1b4019fd36fb8c96b..cd122dc22c222332931e50cd434ca6f2c7f27050 100644 (file)
@@ -35,7 +35,7 @@ const cl_F& cl_F_As (const cl_number& x, const char * filename, int line)
                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
index c0b292f5da9db49a25df26893cc3a697c0c8d155..1f219a014ba59c79dfb879c5e51132160855e745 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cl_LF.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -25,7 +25,7 @@ const cl_F cl_F_shortenrelative (const cl_F& x, const cl_F& y)
        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) ?
index ab0f9f767ece13f724cc69b9bc40069987bafd21..a9c30fabd305bb9c418135278a1e731628de7fee 100644 (file)
@@ -105,13 +105,13 @@ inline const cl_SF encode_SF (cl_signean sign, sintL exp, uintL mant)
 {
        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);
 }
index e71e5deafeb5bb196996659cba184e54e83733ff..39b105ed2649719f828b15dea1c1ef3fb7db2e13 100644 (file)
@@ -42,7 +42,7 @@ const cl_SF operator/ (const cl_SF& x1, const cl_SF& x2)
       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
index fe5eec18a5af632f6939d14c0a1ecc6dd0112d23..e0019f5414b4e2d770d7fa71f0ec36cf2402d3e7 100644 (file)
@@ -43,10 +43,10 @@ const cl_SF cl_RA_to_SF (const cl_RA& x)
       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; }
         }
index e88afdeba19d92872040309bfb6c2c68d039b5b7..842b5faa8fe325a2eb11951cd50396b3e2b17c56 100644 (file)
@@ -33,7 +33,7 @@ const cl_SF scale_float (const cl_SF& x, sintC delta)
               return encode_SF(sign,exp,mant);
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -44,7 +44,7 @@ const cl_SF scale_float (const cl_SF& x, sintC delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return SF_0; }
         }
index f0a9f32651a14e81948c34b472e1ca64d5946613..c11ba5d6cbedc4059a88f6e0a59a895462c1cf61 100644 (file)
@@ -36,7 +36,7 @@ const cl_SF scale_float (const cl_SF& x, const cl_I& delta)
               return encode_SF(sign,exp,mant);
             }
             else
-            { cl_error_floating_point_overflow(); }
+            { throw floating_point_overflow_exception(); }
         }
         else
         // delta<0
@@ -50,7 +50,7 @@ const cl_SF scale_float (const cl_SF& x, const cl_I& delta)
             }
             else
             if (underflow_allowed())
-              { cl_error_floating_point_underflow(); }
+              { throw floating_point_underflow_exception(); }
               else
               { return SF_0; }
         }
index 2f9146a248d20b1426c1f61df1bee513c82ee969..d5a32ffc139f46e4e5ea116ef4b72ec68d39e75c 100644 (file)
@@ -27,7 +27,7 @@ const cl_SF& cl_SF_As (const cl_number& x, const char * filename, int line)
                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
index 5aebbf1743d627dffb764ecbcde92ca0c3b9b4f4..f7c9f57edde3fd960dd6398a7bc2fdcccb21adb7 100644 (file)
@@ -14,7 +14,7 @@
 #include "cl_LF.h"
 #include "cln/integer.h"
 #include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -30,7 +30,7 @@ const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     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).
        {
index 943158be56257ef4e86c750fb3cd0cfbbc46537a..83dafa3249ae897a40da6ee182a9511c1a7edef6 100644 (file)
@@ -14,7 +14,7 @@
 #include "cl_LF.h"
 #include "cln/integer.h"
 #include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -30,7 +30,7 @@ const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     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).
        {
index 3ab99de444e9cd21570cda1466cefcddd99402ba..1258f7566b56e30aba035e41a580944721f35300 100644 (file)
@@ -14,7 +14,6 @@
 #include "cl_LF.h"
 #include "cln/integer.h"
 #include "cl_alloca.h"
-#include "cln/abort.h"
 
 namespace cln {
 
index 3401768a7ac20aaf3ae925e73f4da81c841fea0f..a732bb7aeb9eb16131661bb7d50ba0dfc11548cf 100644 (file)
@@ -14,7 +14,7 @@
 #include "cl_LF.h"
 #include "cln/integer.h"
 #include "cl_alloca.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -26,7 +26,7 @@ const cl_LF cl_exp_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     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).
        {
index 537ea157ed7575a0ba9cd058f890384b57340772..be72ea398f959305faeac53d06d0a284af183e96 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
 #include "cl_LF.h"
 
 namespace cln {
index b8338dabd30196bdb84f7f146163077dbb6782dc..edbe3ce8feae17d43dec3a49d0f5f45af8a69857 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_a_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *T = args.av[N1];
                break;
index e5f50fb1881c0479c8fbbbbaffb733de89b0660e..ed4848996914c4670862dbd68b6d2a973e2b8bfb 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_ab_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *B = args.bv[N1];
                *T = args.av[N1];
index 5c3ce3c9addd7f67a45a7e9348239cbd2ebf6d69..1c5686426e8ec73b69cd89f18746e9b67022af0f 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_b_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *B = args.bv[N1];
                *T = 1;
index 65ef9b5eb8ec4844292c9a7575eb161ea473a9e6..f2562d034c11d5528043d8d3ea210e6e0ea6438f 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_p_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *T = args.pv[N1];
index 6382f8404f16669e0f4c0bb331de19ab78359ff1..196f580458d96d8c5417d98d4e7cfe8b93d845b0 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pa_series_aux (uintC N1, uintC N2,
 {
        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];
index ee97f0652574dc1bfdaee3afea767c66102636a7..67a2b78b4386065d1571c3973bcfb0af92063c6d 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pab_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *B = args.bv[N1];
index eedd587a4d39c652e37640619881c9ffb9adb1c1..27abaabc1e976ac8eb1ff58981ed636019867e3a 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pb_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *B = args.bv[N1];
index ce90e8b2f863d0eafa830ce971a9ffdbca2655b5..4bc195de420e254674e9594044c022ede1ac49d5 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pq_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
@@ -91,7 +91,7 @@ static void eval_pqs_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
index 95c6e03d9ea41da394d07cbe93f6351ff55a45cc..ee0dba17fc6340b23716a70cf253858757b925a4 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pqa_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
@@ -91,7 +91,7 @@ static void eval_pqsa_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
index 1d9ef3e511814eb64d323bbcdf63b128f81455de..2710042a5e3e9000aa0c8714b36895c68f4a167c 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pqab_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
@@ -99,7 +99,7 @@ static void eval_pqsab_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
index 69cf1d2e45bc72208410d5fbd5dc55e1aa39ccd2..2ef3f0c5a7fe5ac3e1fcf1661dd718d6b21be57b 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_pqb_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
@@ -99,7 +99,7 @@ static void eval_pqsb_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                if (P) { *P = args.pv[N1]; }
                *Q = args.qv[N1];
index 7897bb2da0c99705261f8fd4bc824ceb68bd27b4..6e9390933a85f823121efbfc13e90e29a1354bae 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_q_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *Q = args.qv[N1];
                *T = 1;
index f94c7540f9bedf0143055dd21789c1100a4dadcc..306089e77f189485b108ceef76f24d1951861f16 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_qa_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *Q = args.qv[N1];
                *T = args.av[N1];
index 4dadb3bcf6d47b95919030371b0821f3ff98daa5..8ea60c103c422ef94d78237736ada01dfc210cb2 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_qab_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *Q = args.qv[N1];
                *B = args.bv[N1];
index 58ae23e8119df6da283f2196df330e64a2d3bff6..c006f09ac16febbf7921cc936e969550d7d1fadf 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -28,7 +28,7 @@ static void eval_qb_series_aux (uintC N1, uintC N2,
 {
        switch (N2 - N1) {
        case 0:
-               cl_abort(); break;
+               throw runtime_exception(); break;
        case 1:
                *Q = args.qv[N1];
                *B = args.bv[N1];
index 440f85d676151c5165cc186767fb8581999ab765..91b3391baeb9922a73f0f360c9fbf10ff197df37 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -22,7 +22,7 @@ static void eval_pq_series_aux (uintC N1, uintC N2,
 {
        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; }
index 1bc6e3066e03a5777cf37bc045641b1e8005529f..3a2f3f0a4e7f18c93b255b6765ade089303adf7d 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -22,7 +22,7 @@ static void eval_pqa_series_aux (uintC N1, uintC N2,
 {
        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; }
index 376d88ac5a4e6af2ebb8fa7d981bd49749defa83..8203c9fcf0b96833b8bf06cdea26090b24bb4d80 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -22,7 +22,7 @@ static void eval_pqab_series_aux (uintC N1, uintC N2,
 {
        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; }
index 2cfc32a07d6dff3ae342237b17e2fee20efe87f6..12925b7b227d17d2505b3d95903c2705306b7c69 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_LF.h"
 
 namespace cln {
@@ -22,7 +22,7 @@ static void eval_pqb_series_aux (uintC N1, uintC N2,
 {
        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; }
index 7c22c811b10a13f8521dcf2e5479d96c06525f66..009beea2584686685467cbd2b96c2d485b49b99f 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
 #include "cl_LF.h"
 
 namespace cln {
index 232214e75052aecededd849cc07ec51ed8bc312f..0e023ac25ca0d369a05210de697450603c68355e 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -19,7 +19,7 @@ void eval_pqcd_series_aux (uintC N, cl_pqcd_series_term* args, cl_pqcd_series_re
        // 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;
index 7db496c7c8f39d43467538061b442fe2f676cc7a..7d70ad717c52a1c4b1b1a57228ab0d918842e236 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "cln/lfloat.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
 #include "cl_LF.h"
 
 namespace cln {
index 7abf6668780a693451e5bf7bf8b7f58a1d322294..f6886bd15cbb504ba3325a6699cf026102acdc0e 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -19,7 +19,7 @@ void eval_pqd_series_aux (uintC N, cl_pqd_series_term* args, cl_pqd_series_resul
        // 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;
index 6070fd50bd1c899b38016ffd57b3e2402cafd677..3f80cdd084c615f032c6712f658c9f203610c8e9 100644 (file)
@@ -13,7 +13,7 @@
 #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 {
@@ -137,7 +137,7 @@ const cl_LF compute_zeta_cvz2 (int s, uintC len)
 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
index 9de7f748bbf9bd311a7730f5c90d476dd5f8f2da..44a5eb1b6a81a07f166daf828bbeb3a61fad9877 100644 (file)
 #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;
index db355e4a33e085f69e3713faeb3a332742a6f2b4..19c9f1cdcae20c2aa3d7db68c860d2baad39bb8c 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "cl_I.h"
 #include "cl_DS.h"
-#include "cl_I_ash.h"
 
 namespace cln {
 
@@ -42,7 +41,7 @@ const cl_I ash (const cl_I& x, sintC y)
                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);
diff --git a/src/integer/bitwise/cl_I_ash.h b/src/integer/bitwise/cl_I_ash.h
deleted file mode 100644 (file)
index 1a15c60..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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 */
index f10e2e77735f0e27dbf13776ea38c36850595623..cee74a33133f1767f94e4957d0904666d2e3cf7e 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "cl_I.h"
 #include "cl_DS.h"
-#include "cl_I_ash.h"
 
 namespace cln {
 
@@ -39,19 +38,19 @@ const cl_I ash (const cl_I& x, const cl_I& y)
                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))
@@ -66,7 +65,7 @@ const cl_I ash (const cl_I& x, const cl_I& y)
                        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
@@ -87,7 +86,7 @@ const cl_I ash (const cl_I& x, const cl_I& y)
                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);
@@ -143,7 +142,7 @@ const cl_I ash (const cl_I& x, const cl_I& y)
                        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
diff --git a/src/integer/bitwise/cl_I_ash_exception.cc b/src/integer/bitwise/cl_I_ash_exception.cc
new file mode 100644 (file)
index 0000000..c5f00ac
--- /dev/null
@@ -0,0 +1,30 @@
+// 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
diff --git a/src/integer/bitwise/cl_I_asherr.cc b/src/integer/bitwise/cl_I_asherr.cc
deleted file mode 100644 (file)
index 24dda4d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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
index c1b87ad513b6bac2e1ea552e35c78a0d02b66395..bb26201c607fc83a138f3aa21f9be1a2637b851a 100644 (file)
@@ -13,7 +13,8 @@
 #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 {
 
@@ -44,10 +45,10 @@ cl_boolean logbitp (const cl_I& x, const cl_I& y)
         }
         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());
         }
 }
 
index 282aece55a71cab079368188c4766ccd2ae94af1..17bc537313c2c091bd42a1ae7563024202da63a7 100644 (file)
@@ -7,7 +7,7 @@
 #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"
 
@@ -474,9 +474,9 @@ inline sintD FN_MSD (cl_uint word)
 
 #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)
@@ -484,8 +484,8 @@ inline sintD FN_MSD (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)
@@ -656,9 +656,6 @@ inline sintD FN_MSD (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
 
index dc337eb9b075b7b430afeba805e35fe010f6825f..52d59c9d3e53cc4ebdee32331b9d247e89961d4b 100644 (file)
@@ -14,7 +14,8 @@
 #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 {
 
@@ -76,10 +77,10 @@ sint32 cl_I_to_L (const cl_I& obj)
                }
        }
        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
index 99a73442ff8546b1184e8c7d509dab779dcb2d42..13197c3b095f6c95834cfd35b4a546d20791a207 100644 (file)
@@ -15,7 +15,8 @@
 #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 {
 
@@ -131,10 +132,10 @@ sint64 cl_I_to_Q (const cl_I& obj)
                #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());
     }
 }
 
index 2e8d9ea34a6aeb640bc1b8e39f605fb70a55c51f..7ee081deeef4374d44b5657316999e3d680b9d50 100644 (file)
@@ -14,7 +14,8 @@
 #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 {
 
@@ -57,10 +58,10 @@ uint32 cl_I_to_UL (const cl_I& obj)
                #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
index 2dd15ed6c19569a947b07ee7b265b3b27d44200f..5f30e502f9a4550878d9cc86a245b0283325fe27 100644 (file)
@@ -15,7 +15,8 @@
 #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 {
 
@@ -91,10 +92,10 @@ uint64 cl_I_to_UQ (const cl_I& obj)
                #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
index b5d8a849e5b36a4cdb3939e6fbb2801553e4440b..d661b81145f46f5708bdd535ba3aca553220218b 100644 (file)
@@ -49,7 +49,7 @@ 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;
@@ -179,10 +179,10 @@ void I_to_digits (const cl_I& X, uintD base, cl_digits* erg)
           // 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);
index 771eef8b07b5a48d4aacfd90bef6b11d7c48b299..5028e72df8d0b24790f2c04c44f4a9dbb9080ca4 100644 (file)
@@ -21,7 +21,7 @@ const cl_I exquo (const cl_I& x, const cl_I& y)
 // 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
diff --git a/src/integer/division/cl_I_exquo_exception.cc b/src/integer/division/cl_I_exquo_exception.cc
new file mode 100644 (file)
index 0000000..6ac671e
--- /dev/null
@@ -0,0 +1,34 @@
+// 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
diff --git a/src/integer/division/cl_I_exquoerr.cc b/src/integer/division/cl_I_exquoerr.cc
deleted file mode 100644 (file)
index a8198ac..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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
index 5e28f7215c688e467fc88b7a4bc416e732814793..2ec651df001daaa7ac3fd9fea56b6f4934fad0af 100644 (file)
@@ -21,7 +21,7 @@ const cl_I exquopos (const cl_I& x, const cl_I& y)
 // 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;
 }
 
index b0307d78dc246d308e9b19c366eb08791bdf49c4..b88661b884fc599a5954748fed6386a74c71030e 100644 (file)
@@ -9,7 +9,7 @@
 
 // Implementation.
 
-#include "cl_N.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -25,7 +25,7 @@ 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;
index 507220d9836993d8fc4c5640dfa4b579ceca713f..2a4fc030e6282392637bb62b494fbdebc865ca59 100644 (file)
@@ -54,7 +54,7 @@ static uintD floorDD (uintDD x, uintDD y)
                var uintDD p = muluDD_unchecked(q,y);
                #ifdef DEBUG_GCD
                if (x < p)
-                       cl_abort();
+                       throw runtime_exception();
                #endif
                x -= p;
        }
@@ -66,7 +66,7 @@ static uintD floorDD (uintDD x, uintDD y)
                        #ifdef DEBUG_GCD
                        x -= y;
                        if (x >= y)
-                               cl_abort();
+                               throw runtime_exception();
                        #endif
                }
        }
@@ -118,7 +118,7 @@ void partial_gcd (uintDD z1, uintDD z2, partial_gcd_result* erg)
                                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;
@@ -166,7 +166,7 @@ void partial_gcd (uintDD z1, uintDD z2, partial_gcd_result* erg)
                                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;
@@ -219,7 +219,7 @@ static uintD floorDD (uintD xhi, uintD xlo, uintD yhi, uintD ylo)
                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)
@@ -240,7 +240,7 @@ static uintD floorDD (uintD xhi, uintD xlo, uintD yhi, uintD ylo)
                                xhi -= 1;
                        xlo = xlo - ylo;
                        if ((xhi > yhi) || ((xhi == yhi) && (xlo >= ylo)))
-                               cl_abort();
+                               throw runtime_exception();
                        #endif
                }
        }
@@ -316,8 +316,8 @@ void partial_gcd (uintD z1hi, uintD z1lo, uintD z2hi, uintD z2lo, partial_gcd_re
                                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;
@@ -412,8 +412,8 @@ void partial_gcd (uintD z1hi, uintD z1lo, uintD z2hi, uintD z2lo, partial_gcd_re
                                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;
index 430f5688fc626c75473e53aa23e64980e7d3d606..d3faacefc08de9924da92905629bb96ebfae9b69 100644 (file)
 // Implementation.
 
 #include <cstring>
+#include <sstream>
 #include "cln/input.h"
 #include "cln/integer.h"
 #include "cl_I.h"
-#include "cln/abort.h"
 
 namespace cln {
 
@@ -47,7 +47,7 @@ static const char * skip_digits (const char * ptr, const char * string_limit, un
   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)
 {
@@ -81,10 +81,10 @@ const cl_I read_integer (const cl_read_flags& flags, const char * string, const
                                                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;
@@ -127,7 +127,7 @@ not_integer_syntax:
                *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
index 6f6a5c076bd35115e45608f80b049a89511435ce..eeae222731673b4b5eba286e2ef9331651357f35 100644 (file)
@@ -98,10 +98,10 @@ const cl_I read_integer (std::istream& stream, const cl_read_flags& flags)
 
        // 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
index 6759c13fbcbb6022b538bc5cc6c7256b6bb1fb4a..fcbd83976c4c0f1808a609df62a50e966af86e84 100644 (file)
@@ -36,7 +36,7 @@ const cl_I& cl_I_As (const cl_number& x, const char * filename, int line)
                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
index 297718d2eece729e2611d4d275b5e7a9634df87c..071028b6bab3ad5a2115ebb8bcfa2fdba418e532 100644 (file)
@@ -18,7 +18,7 @@ CL_PROVIDE(cl_MI)
 #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"
@@ -42,7 +42,7 @@ cl_heap_modint_ring::cl_heap_modint_ring (cl_I m, cl_modint_setops* setopv, cl_m
 {
        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.
@@ -172,7 +172,7 @@ const cl_modint_ring find_modint_ring (const cl_I& 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;
 }}
index 536cf93be821d4ca6c9161c2724643f82ca4f820..48590617ae1205e558e566c2cdab8ec2b2fb52e9 100644 (file)
@@ -10,7 +10,6 @@
 // Implementation.
 
 #include "cln/io.h"
-#include "cln/abort.h"
 
 namespace cln {
 
index fe70d498efc5df4153fd29cdd93539acf9129e4e..0fbfe5280d8b7f99e8a95c004e5c3cb08b23f5ab 100644 (file)
@@ -31,8 +31,7 @@ static const _cl_MI int_random (cl_heap_modint_ring* R, random_state& randomstat
 {
        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
@@ -83,7 +82,7 @@ static const cl_MI_x int_recip (cl_heap_modint_ring* R, const _cl_MI& x)
 {
        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);
 }
 
@@ -92,7 +91,7 @@ static const cl_MI_x int_div (cl_heap_modint_ring* R, const _cl_MI& x, const _cl
        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);
 }
 
@@ -112,7 +111,7 @@ static const cl_MI_x int_expt (cl_heap_modint_ring* R, const _cl_MI& x, const cl
                        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);
 }
 
index c5c7a4cc1f02f13e87d50c42d105e6af172c0757..0f944c390c4471093b6e499883e62ac8be183a9b 100644 (file)
@@ -135,7 +135,7 @@ static const cl_MI_x montgom_recip (cl_heap_modint_ring* _R, const _cl_MI& x)
        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);
 }
 
@@ -149,7 +149,7 @@ static const cl_MI_x montgom_div (cl_heap_modint_ring* _R, const _cl_MI& x, cons
        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);
 }
 
@@ -230,7 +230,7 @@ static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M)
        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);
 }
index 8511600a874c88b9ebd11149225c421ba0f626e7..c891a1af0339c51797ec695831774263dd189f26 100644 (file)
@@ -85,7 +85,7 @@ static const cl_MI_x pow2_recip (cl_heap_modint_ring* _R, const _cl_MI& x)
                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
@@ -110,7 +110,7 @@ static const cl_MI_x pow2_div (cl_heap_modint_ring* _R, const _cl_MI& x, const _
                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
index 957d170836e0f51a75b655bf93866512814c842e..a5a4ffe8886262bf7c80848ec83e3c4dbea452f8 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cln/integer.h"
-#include "cl_N.h"
+#include "cln/exception.h"
 #include "cl_MI.h"
 
 namespace cln {
@@ -22,7 +22,7 @@ const cl_MI operator>> (const cl_MI& x, sintC y) // assume 0 <= y < 2^(intCsize-
        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);
        }
@@ -37,7 +37,7 @@ const cl_MI operator>> (const cl_MI& x, sintC y) // assume 0 <= y < 2^(intCsize-
        // 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));
index 04fd37bb0c84457d439ce68b5c7e3b7431ddd57d..e704cc8f67e58af1ef0dea5e81c2906bc3f5c83a 100644 (file)
@@ -82,7 +82,7 @@ static const cl_MI_x std_recip (cl_heap_modint_ring* R, const _cl_MI& x)
        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);
 }
 
@@ -95,7 +95,7 @@ static const cl_MI_x std_div (cl_heap_modint_ring* R, const _cl_MI& x, const _cl
        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);
 }
 
@@ -258,7 +258,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const
                // 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];
@@ -271,7 +271,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const
                        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);
                }
@@ -292,7 +292,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const
                        } 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);
                }
index dfdb89f4dbcbf4bf1dffaa6448d3a4a9094fdc9b..e43405acc5a29db027cada283529c9f91d2f3246 100644 (file)
@@ -80,7 +80,7 @@ const cornacchia_t cornacchia1 (const cl_I& d, const cl_I& p)
        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]);
index 0d91abf4bbf718b6f87a0f8f527459d95e1b6ded..38204f3f94a163ef94a267d1ad7b75a012a0a450 100644 (file)
@@ -92,7 +92,7 @@ const cornacchia_t cornacchia4 (const cl_I& d, const cl_I& p)
        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.
index a761cf97e8a25b153c6973bd1fd213752609318a..031fe291dee7bc799b4659ceda82e12c54aa24da 100644 (file)
 // 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;
index 03a116982f375e1a5ba8daf6742c03dfad38f4c8..e4cf10c26c33b9605519655f2f6c02266f41d17e 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "cln/integer.h"
 #include "cl_I.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_xmacros.h"
 
 namespace cln {
@@ -20,9 +20,9 @@ int jacobi (const cl_I& a, const cl_I& b)
 {
        // 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.
index 6a55823c5d9a90cbdaf5adbedec9b1c4a23b0bce..7b706a229a2e9aaa142c0b546cc1443e528a74b4 100644 (file)
@@ -9,7 +9,7 @@
 
 // Implementation.
 
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_xmacros.h"
 
 namespace cln {
@@ -33,7 +33,7 @@ inline int jacobi_aux (uintV a, uintV b)
                        switch (b % 4) {
                                case 1: break;
                                case 3: v = -v; break;
-                               default: cl_abort();
+                               default: throw runtime_exception();
                        }
                        continue;
                }
@@ -44,7 +44,7 @@ inline int jacobi_aux (uintV a, uintV b)
                        switch (b % 8) {
                                case 1: case 7: break;
                                case 3: case 5: v = -v; break;
-                               default: cl_abort();
+                               default: throw runtime_exception();
                        }
                        continue;
                }
@@ -65,9 +65,9 @@ int jacobi (sintV a, sintV b)
 {
        // 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;
index 3b95574e2bd5dc14cdb6a0aa1098f52b58aba363..8c0741e9c7524cb7c6b7316a79bcf887b431e987 100644 (file)
@@ -10,7 +10,7 @@
 // Implementation.
 
 #include "cl_I.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -287,7 +287,7 @@ static const sqrt_mod_p_t tonelli_shanks_sqrt (const cl_modint_ring& R, const cl
 
 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)) {
index fa2c5b123fc9f668ae5e1d0d84554d27af3be4fb..53060308188bdb5fc7addbae6e51939cbd75a47d 100644 (file)
@@ -4,7 +4,7 @@
 #include "cln/modinteger.h"
 #include "cln/GV_integer.h"
 #include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -966,7 +966,7 @@ static const _cl_UP gf2_square (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
 // 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());
@@ -981,7 +981,7 @@ static const _cl_UP gf2_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_eleme
 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;
index 62b2ea6d638b0822e3ecf690524f4f9d3ad4d5a8..f76977a6b1bb7ca17d5fedf62105e69298fbab35 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "cln/GV_modinteger.h"
 #include "cln/modinteger.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -154,7 +154,7 @@ static const _cl_UP modint_uminus (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        // 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--)
@@ -269,7 +269,7 @@ static const _cl_UP modint_mul (cl_heap_univpoly_ring* UPR, const _cl_UP& x, con
        }
        // 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);
 }}
 
@@ -308,7 +308,7 @@ static const _cl_UP modint_square (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        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);
 }}
 
@@ -328,7 +328,7 @@ static const _cl_UP modint_exptpos (cl_heap_univpoly_ring* UPR, const _cl_UP& x,
 
 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);
@@ -367,7 +367,7 @@ static sintL modint_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
 
 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))
@@ -404,9 +404,9 @@ static const _cl_UP modint_create (cl_heap_univpoly_ring* UPR, sintL deg)
 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;
 }}}
 
@@ -426,7 +426,7 @@ static const cl_ring_element modint_eval (cl_heap_univpoly_ring* UPR, const _cl_
        // 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();
index 9c11643d517f154c5815747c889d5d625f891aec..dcfd6c77a890618d55e31565d2d997c90e6e45ac 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "cln/SV_ringelt.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -142,7 +142,7 @@ static const _cl_UP gen_uminus (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        // 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--)
@@ -253,7 +253,7 @@ static const _cl_UP gen_mul (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const
        }
        // 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);
 }}
 
@@ -292,7 +292,7 @@ static const _cl_UP gen_square (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        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);
 }}
 
@@ -312,7 +312,7 @@ static const _cl_UP gen_exptpos (cl_heap_univpoly_ring* UPR, const _cl_UP& x, co
 
 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());
@@ -326,7 +326,7 @@ static const _cl_UP gen_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_eleme
                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);
 }}
 
@@ -350,7 +350,7 @@ static sintL gen_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
 
 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);
@@ -385,8 +385,8 @@ static const _cl_UP gen_create (cl_heap_univpoly_ring* UPR, sintL deg)
 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;
 }}
 
@@ -407,7 +407,7 @@ static const cl_ring_element gen_eval (cl_heap_univpoly_ring* UPR, const _cl_UP&
        // 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();
index 38a299447cab88159fd65d1cce70dcb57c71ddbe..a81adaa254ed889d349116ba007eb20828404e3f 100644 (file)
@@ -70,7 +70,7 @@ const cl_univpoly_ring find_univpoly_ring (const cl_ring& r, const cl_symbol& va
                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;
 }
index f04886e9e37e242d68846290dfefb6bdeb66608c..334f40ca57ba338c375c1645db0c8d3e8fd8d2db 100644 (file)
@@ -12,70 +12,44 @@ CL_PROVIDE(cl_UP_no_ring)
 // 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
@@ -86,7 +60,7 @@ static const _cl_UP dummy_canonhom (cl_heap_univpoly_ring* R, const cl_I& x)
 {
        unused R;
        (void)&x; // unused x;
-       uninitialized_ring(); RETDUMMY;
+       throw uninitialized_ring_exception();
 }
 #define dummy_mul dummy_op2
 #define dummy_square dummy_op1
@@ -94,62 +68,62 @@ static const _cl_UP dummy_expt_pos (cl_heap_univpoly_ring* R, const _cl_UP& x, c
 {
        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 = {
index 4b8e906caeb36d7e39edd998c85c1930b13fc51d..4966ec074399552792276cb932c891cfb529b1f4 100644 (file)
@@ -3,7 +3,7 @@
 #include "cln/SV_number.h"
 #include "cln/number.h"
 #include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -142,7 +142,7 @@ static const _cl_UP num_uminus (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        // 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--)
@@ -251,7 +251,7 @@ static const _cl_UP num_mul (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const
        }
        // 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);
 }}
 
@@ -290,7 +290,7 @@ static const _cl_UP num_square (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
        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);
 }}
 
@@ -310,7 +310,7 @@ static const _cl_UP num_exptpos (cl_heap_univpoly_ring* UPR, const _cl_UP& x, co
 
 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);
@@ -349,7 +349,7 @@ static sintL num_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
 
 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))
@@ -385,9 +385,9 @@ static const _cl_UP num_create (cl_heap_univpoly_ring* UPR, sintL deg)
 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;
 }}}
 
@@ -407,7 +407,7 @@ static const cl_ring_element num_eval (cl_heap_univpoly_ring* UPR, const _cl_UP&
        // 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;
index 5bb8ad60886faacf6eed40a9549b43b7ce0246a0..98d93e37ba065f025d8abe7e60be2757a2d6360d 100644 (file)
@@ -55,7 +55,7 @@ const cl_univpoly_ring find_univpoly_ring (const cl_ring& r)
                store_univpoly_ring(R);
                ring_in_table = get_univpoly_ring(r);
                if (!ring_in_table)
-                       cl_abort();
+                       throw runtime_exception();
        }
        return *ring_in_table;
 }
index 3b7fa35950935a8380f9b385b320d2c0c3527303..823bddb78e71bd1fa2f7199c68095aea1dc5c6c1 100644 (file)
@@ -9,8 +9,8 @@
 
 // Implementation.
 
+#include "cln/exception.h"
 #include "cl_I.h"
-#include "cl_N.h"
 
 namespace cln {
 
@@ -21,7 +21,7 @@ const cl_RA I_I_div_RA (const cl_I& a, const cl_I& b)
 // 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
index 120d2d6b991e6194b285c4360b591e776f356726..bacd0eb6284150ac27f5d8236218fe4b9b7b449a 100644 (file)
@@ -9,8 +9,8 @@
 
 // Implementation.
 
+#include "cln/exception.h"
 #include "cl_RA.h"
-#include "cl_N.h"
 #include "cl_I.h"
 
 namespace cln {
@@ -23,7 +23,7 @@ const cl_RA recip (const cl_RA& r)
 // 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 = );
index 7fae7130dab21ef2ca54ea7d32460b0c1ed9dfdc..6d065223186d3f287151959a0692d2378e3fc10f 100644 (file)
 // 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 {
 
@@ -49,7 +50,7 @@ static const char * skip_digits (const char * ptr, const char * string_limit, un
   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)
 {
@@ -83,10 +84,10 @@ const cl_RA read_rational (const cl_read_flags& flags, const char * string, cons
                                                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;
@@ -146,7 +147,7 @@ not_rational_syntax:
                *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
index a54f861f8981f3aab00bebc225c915b80672f84c..f14ddce2e05f60bdf639f81e05e93acba8719234 100644 (file)
@@ -99,10 +99,10 @@ const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags)
 
        // 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
index 417a8fdf81e0937829f852ff3e4e4daa27a7f8c3..480560ac96db901f9c110ad8d7fc1dddd8c51e16 100644 (file)
@@ -21,7 +21,7 @@ const cl_RA read_rational (unsigned int base, cl_signean sign, const char * stri
        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))
index d9bdea5461d70f7947534234392ff5125c68145a..0a35a8d38d818ab44c910518c01955d8a55b0270 100644 (file)
@@ -36,7 +36,7 @@ const cl_RA& cl_RA_As (const cl_number& x, const char * filename, int line)
                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
index ba65336be4cc73a68bda71ebf68cf3dd6751e0c3..46e6d025fb286062b2596a0daf67b94a6e9f2441 100644 (file)
@@ -34,7 +34,7 @@ const cl_R operator/ (const cl_R& x, const cl_R& y)
        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;
                }
index 220be8b55f2bebe74b700490c743ee2015ec13b2..3580e416c7b9b37ca6d202acfb49236a2e58c699 100644 (file)
@@ -9,9 +9,10 @@
 
 // Implementation.
 
+#include <sstream>
 #include "cln/integer.h"
 #include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 namespace cln {
 
@@ -107,10 +108,10 @@ void format_cardinal (std::ostream& stream, const cl_I& argument)
                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;
index 0732820bde284b78e7b20a38b8efa3b650a8baf0..63e94d562b594029ab544d41f448c50a455c2ca1 100644 (file)
@@ -9,19 +9,21 @@
 
 // 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; };
index b69029bc29da1029f4709250c9babf572f34b1f8..9ca5c6f4bb65f1f6b2fbceb6936e9533987a2612 100644 (file)
@@ -9,19 +9,21 @@
 
 // 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; };
index d31cf69b0720bc4abebdfdd113a2fdf68f844f42..940e9e9cf687fc9a07c6124d1dae05d8c1650e42 100644 (file)
@@ -12,6 +12,7 @@
 // Implementation.
 
 #include <cstring>
+#include <sstream>
 #include "cln/input.h"
 #include "cln/rational_io.h"
 #include "cln/integer_io.h"
@@ -19,7 +20,7 @@
 #include "cln/integer.h"
 #include "cl_I.h"
 #include "cl_F.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 
 #undef floor
 #include <cmath>
@@ -56,7 +57,7 @@ static const char * skip_digits (const char * ptr, const char * string_limit, un
   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)
 {
@@ -90,10 +91,10 @@ const cl_R read_real (const cl_read_flags& flags, const char * string, const cha
                                                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;
@@ -264,7 +265,7 @@ not_float_syntax:
                *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
index e75221d48380a950e74e45cef608fc9b4664ff41..3f5979e580e393742c77213327076c383b71eccb 100644 (file)
@@ -98,10 +98,10 @@ const cl_R read_real (std::istream& stream, const cl_read_flags& flags)
 
        // 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
index fa662005c571970a45e8a61b317ed40fb472a3c8..a219e23ab5faf4765a5c839cf58395f2c21c1457 100644 (file)
@@ -40,7 +40,7 @@ const cl_R& cl_R_As (const cl_number& x, const char * filename, int line)
                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
index 473e897ecb037162fa1b53c788945354e6ce7970..6c4a9b1cedc337b08e1c8e541d2c36e057241370 100644 (file)
@@ -13,7 +13,8 @@
 #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 {
 
@@ -32,10 +33,10 @@ const cl_R random_R (random_state& r, const cl_R& n)
                        }
                }
        }
-       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
index 0546e14e26e53bf6be192c242b755c16d4f844de..a5d72601c5c0115c2c76ea6215bd0866c33ba255 100644 (file)
@@ -34,7 +34,7 @@ const cl_R atan (const cl_R& x, const cl_R& y)
        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
@@ -42,7 +42,7 @@ const cl_R atan (const cl_R& x, const cl_R& y)
        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
index 2834b54ffb24d77738c58137fe6b609ded143028..00d42fe0d3477e1233e201754b8c1959bb650d1d 100644 (file)
@@ -30,7 +30,7 @@ const cl_R log (const cl_R& a, const cl_R& b)
        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;
index 1471cefe903519148894011070bda1135817a804..456388b7c3456a791cc266a97076b6fd13b5e993 100644 (file)
@@ -13,7 +13,7 @@ CL_PROVIDE(cl_GV_I)
 
 #include "cl_I.h"
 #include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_offsetof.h"
 
 namespace cln {
@@ -70,9 +70,9 @@ static inline cl_GV_I_vectorops* outcast (cl_GV_vectorops<cl_I>* vectorops)
 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 ();
 };
@@ -105,9 +105,9 @@ static void general_copy_elements (const cl_GV_inner<cl_I>* srcvec, uintC srcind
                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);
@@ -140,9 +140,9 @@ cl_heap_GV_I* cl_make_heap_GV_I (uintC len)
 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 ();                                        \
 };                                                                     \
@@ -158,9 +158,9 @@ static void bits##m##_copy_elements (const cl_GV_inner<cl_I>* srcvec, uintC srci
                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];           \
@@ -293,7 +293,7 @@ static void bits1_set_element (cl_GV_inner<cl_I>* vec, uintC index, const cl_I&
                        return;
                }
        }
-       cl_abort();
+       throw runtime_exception();
 }
 
 
@@ -315,7 +315,7 @@ static void bits2_set_element (cl_GV_inner<cl_I>* vec, uintC index, const cl_I&
                        return;
                }
        }
-       cl_abort();
+       throw runtime_exception();
 }
 
 
@@ -337,7 +337,7 @@ static void bits4_set_element (cl_GV_inner<cl_I>* vec, uintC index, const cl_I&
                        return;
                }
        }
-       cl_abort();
+       throw runtime_exception();
 }
 
 
@@ -369,7 +369,7 @@ static void bits8_set_element (cl_GV_inner<cl_I>* vec, uintC index, const cl_I&
                        return;
                }
        }
-       cl_abort();
+       throw runtime_exception();
 }
 
 
@@ -401,7 +401,7 @@ static void bits16_set_element (cl_GV_inner<cl_I>* vec, uintC index, const cl_I&
                        return;
                }
        }
-       cl_abort();
+       throw runtime_exception();
 }
 
 
index 20af58ad9e93ad4368c0cc0d17eff8687d2b2e3d..7a65eb910735612c6d717f72c924c4068e84f043 100644 (file)
@@ -11,7 +11,7 @@ CL_PROVIDE(cl_GV_number)
 
 // Implementation.
 
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_offsetof.h"
 
 namespace cln {
@@ -46,9 +46,9 @@ static inline const cl_heap_GV_number * outcast (const cl_GV_inner<cl_number>* v
 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 ();
 };
@@ -81,9 +81,9 @@ static void general_copy_elements (const cl_GV_inner<cl_number>* srcvec, uintC s
                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);
index 80b5a5dd0be38eaa86ecae3b216b1aecf6e2b5c7..55801a493c8071122e52f9b95686f9e91c92b6ef 100644 (file)
@@ -11,8 +11,6 @@ CL_PROVIDE(cl_SV_number)
 
 // Implementation.
 
-#include "cln/abort.h"
-
 namespace cln {
 
 static void cl_svector_number_destructor (cl_heap* pointer)
index 48587aec01528a91b7393c57904ab3af765eef23..b867b727cd896dca1cb379d8672afa97a4ff93af 100644 (file)
@@ -11,8 +11,6 @@ CL_PROVIDE(cl_SV_ringelt)
 
 // Implementation.
 
-#include "cln/abort.h"
-
 namespace cln {
 
 static void cl_svector_ringelt_destructor (cl_heap* pointer)
index a87984a068330a791d385218e05f58c2842009c9..e8dabb076231faa92d2467f208c094ce8f075d58 100644 (file)
@@ -5,7 +5,6 @@
 #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>
@@ -46,7 +45,7 @@ int main (int argc, char * argv[])
        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;
index 4f6896aa9a480d236c3ed0b8a91d5ad08feea4a0..9ccc7778422121e6026641bee240eb68258869b9 100644 (file)
@@ -5,7 +5,6 @@
 #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>
index a231c9c2235fff003340cc51542803df8e419f58..0e4b235d272cad527542d7610623e1283b8d53f5 100644 (file)
@@ -7,7 +7,6 @@
 #include <cln/timing.h>
 #include <cl_print.h>
 #include <cln/malloc.h>
-#include <cln/abort.h>
 
 int main (int argc, char * argv[])
 {
@@ -26,7 +25,7 @@ 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);
        }
index 799872df10862f634933ca553249c8addfdfe820..bc1d224486f232b2150944b59d9470e82befdf20 100644 (file)
@@ -7,7 +7,6 @@
 #include <cstring>
 #include <cln/timing.h>
 #include <cln/malloc.h>
-#include <cln/abort.h>
 using namespace cln;
 
 int main (int argc, char * argv[])
index 6c6e9ef0a3b42098a619a6c710ff690cd1a369f5..4e8857f3b52d35e2f3584f76ad69acbcee6ddc60 100644 (file)
@@ -5,7 +5,6 @@
 #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>
@@ -40,7 +39,7 @@ int main (int argc, char * argv[])
        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;