Browse Source

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.
master
Richard Kreckel 18 years ago
parent
commit
c486b78a1a
  1. 212
      ChangeLog
  2. 7
      INSTALL
  3. 3
      NEWS
  4. 6
      README
  5. 117
      doc/cln.tex
  6. 55
      examples/contfrac.cc
  7. 10
      include/cln/GV.h
  8. 6
      include/cln/SV.h
  9. 16
      include/cln/abort.h
  10. 2
      include/cln/cln.h
  11. 39
      include/cln/exception.h
  12. 28
      include/cln/float.h
  13. 13
      include/cln/integer.h
  14. 44
      include/cln/modinteger.h
  15. 38
      include/cln/number_io.h
  16. 2
      include/cln/object.h
  17. 1
      include/cln/rational.h
  18. 42
      include/cln/ring.h
  19. 8
      include/cln/string.h
  20. 40
      include/cln/univpoly.h
  21. 3
      src/base/cl_N.h
  22. 23
      src/base/cl_N_err_d0.cc
  23. 21
      src/base/cl_abort.cc
  24. 38
      src/base/cl_as_err.cc
  25. 44
      src/base/cl_as_exception.cc
  26. 15
      src/base/cl_d0_exception.cc
  27. 1
      src/base/cl_debug.cc
  28. 6
      src/base/cl_macros.h
  29. 5
      src/base/cl_malloc.cc
  30. 28
      src/base/cl_notreached.cc
  31. 34
      src/base/cl_notreached_exception.cc
  32. 4
      src/base/digitseq/cl_2DS_div.cc
  33. 13
      src/base/digitseq/cl_DS_div.cc
  34. 4
      src/base/digitseq/cl_DS_mul.cc
  35. 42
      src/base/digitseq/cl_DS_mul_fftc.h
  36. 36
      src/base/digitseq/cl_DS_mul_fftcs.h
  37. 16
      src/base/digitseq/cl_DS_mul_fftm.h
  38. 30
      src/base/digitseq/cl_DS_mul_fftp.h
  39. 22
      src/base/digitseq/cl_DS_mul_fftp3.h
  40. 26
      src/base/digitseq/cl_DS_mul_fftp3m.h
  41. 36
      src/base/digitseq/cl_DS_mul_fftr.h
  42. 24
      src/base/digitseq/cl_DS_mul_nuss.h
  43. 2
      src/base/digitseq/cl_DS_recip.cc
  44. 10
      src/base/digitseq/cl_DS_recipsqrt.cc
  45. 12
      src/base/digitseq/cl_DS_sqrt.cc
  46. 6
      src/base/hash/cl_hash.h
  47. 6
      src/base/hash/cl_hash1.h
  48. 2
      src/base/hash/cl_hash1weak.h
  49. 6
      src/base/hash/cl_hash2.h
  50. 2
      src/base/hash/cl_hash2weak.h
  51. 6
      src/base/hash/cl_hashset.h
  52. 6
      src/base/hash/cl_hashuniq.h
  53. 2
      src/base/hash/cl_hashuniqweak.h
  54. 32
      src/base/input/cl_read_bad_syntax_exception.cc
  55. 11
      src/base/input/cl_read_eof_exception.cc
  56. 26
      src/base/input/cl_read_err_bad.cc
  57. 31
      src/base/input/cl_read_err_junk.cc
  58. 37
      src/base/input/cl_read_junk_exception.cc
  59. 4
      src/base/proplist/cl_pl_add.cc
  60. 68
      src/base/ring/cl_no_ring.cc
  61. 4
      src/base/string/cl_spushstring.h
  62. 2
      src/base/symbol/cl_symbol.cc
  63. 15
      src/complex/input/cl_N_read.cc
  64. 4
      src/complex/input/cl_N_read_stream.cc
  65. 3
      src/complex/misc/cl_N_as.cc
  66. 4
      src/complex/transcendental/cl_C_atanh_aux.cc
  67. 2
      src/complex/transcendental/cl_C_expt_C.cc
  68. 2
      src/complex/transcendental/cl_C_log.cc
  69. 2
      src/complex/transcendental/cl_C_log2.cc
  70. 23
      src/float/base/cl_F_err_nan.cc
  71. 23
      src/float/base/cl_F_err_ov.cc
  72. 23
      src/float/base/cl_F_err_un.cc
  73. 20
      src/float/base/cl_F_nan_exception.cc
  74. 20
      src/float/base/cl_F_overflow_exception.cc
  75. 20
      src/float/base/cl_F_underflow_exception.cc
  76. 7
      src/float/cl_F.h
  77. 24
      src/float/dfloat/cl_DF.h
  78. 16
      src/float/dfloat/conv/cl_DF_from_double.cc
  79. 4
      src/float/dfloat/elem/cl_DF_div.cc
  80. 4
      src/float/dfloat/elem/cl_DF_from_RA.cc
  81. 4
      src/float/dfloat/elem/cl_DF_scale.cc
  82. 4
      src/float/dfloat/elem/cl_DF_scale_I.cc
  83. 2
      src/float/dfloat/misc/cl_DF_as.cc
  84. 12
      src/float/ffloat/cl_FF.h
  85. 8
      src/float/ffloat/conv/cl_FF_from_float.cc
  86. 2
      src/float/ffloat/elem/cl_FF_div.cc
  87. 4
      src/float/ffloat/elem/cl_FF_from_RA.cc
  88. 4
      src/float/ffloat/elem/cl_FF_scale.cc
  89. 4
      src/float/ffloat/elem/cl_FF_scale_I.cc
  90. 2
      src/float/ffloat/misc/cl_FF_as.cc
  91. 4
      src/float/input/cl_F_read.cc
  92. 4
      src/float/input/cl_F_read_stream.cc
  93. 4
      src/float/lfloat/algebraic/cl_LF_sqrt.cc
  94. 8
      src/float/lfloat/elem/cl_LF_1plus.cc
  95. 6
      src/float/lfloat/elem/cl_LF_I_div.cc
  96. 4
      src/float/lfloat/elem/cl_LF_I_mul.cc
  97. 12
      src/float/lfloat/elem/cl_LF_div.cc
  98. 4
      src/float/lfloat/elem/cl_LF_from_I.cc
  99. 8
      src/float/lfloat/elem/cl_LF_mul.cc
  100. 4
      src/float/lfloat/elem/cl_LF_scale.cc

212
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.

7
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.

3
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.

6
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>

117
doc/cln.tex

@ -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}.

55
examples/contfrac.cc

@ -11,40 +11,33 @@
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& ) {}
}
}

10
include/cln/GV.h

@ -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.

6
include/cln/SV.h

@ -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];
}

16
include/cln/abort.h

@ -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 */

2
include/cln/cln.h

@ -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"

39
include/cln/exception.h

@ -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 */

28
include/cln/float.h

@ -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

13
include/cln/integer.h

@ -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);

44
include/cln/modinteger.h

@ -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.

38
include/cln/number_io.h

@ -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;

2
include/cln/object.h

@ -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; \
}

1
include/cln/rational.h

@ -6,6 +6,7 @@
#include "cln/number.h"
#include "cln/rational_class.h"
#include "cln/integer_class.h"
#include "cln/exception.h"
namespace cln {

42
include/cln/ring.h

@ -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;

8
include/cln/string.h

@ -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.

40
include/cln/univpoly.h

@ -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.

3
src/base/cl_N.h

@ -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

23
src/base/cl_N_err_d0.cc

@ -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

21
src/base/cl_abort.cc

@ -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

38
src/base/cl_as_err.cc

@ -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

44
src/base/cl_as_exception.cc

@ -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

15
src/base/cl_d0_exception.cc

@ -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

1
src/base/cl_debug.cc

@ -10,7 +10,6 @@
// Implementation.
#include "cln/io.h"
#include "cln/abort.h"
namespace cln {

6
src/base/cl_macros.h

@ -4,6 +4,7 @@
#define _CL_MACROS_H
#include "cln/types.h"
#include "cln/exception.h"
// Concatenation of macroexpanded tokens.
// Example:
@ -73,10 +74,7 @@
// 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)

5
src/base/cl_malloc.cc

@ -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;

28
src/base/cl_notreached.cc

@ -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

34
src/base/cl_notreached_exception.cc

@ -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

4
src/base/digitseq/cl_2DS_div.cc

@ -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)

13
src/base/digitseq/cl_DS_div.cc

@ -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

4
src/base/digitseq/cl_DS_mul.cc

@ -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
}

42
src/base/digitseq/cl_DS_mul_fftc.h

@ -157,8 +157,7 @@
#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");
}
}

36
src/base/digitseq/cl_DS_mul_fftcs.h

@ -270,8 +270,7 @@
#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");
}
}

16
src/base/digitseq/cl_DS_mul_fftm.h

@ -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;

30
src/base/digitseq/cl_DS_mul_fftp.h

@ -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.

22
src/base/digitseq/cl_DS_mul_fftp3.h

@ -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.

26
src/base/digitseq/cl_DS_mul_fftp3m.h

@ -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.

36
src/base/digitseq/cl_DS_mul_fftr.h

@ -197,8 +197,7 @@
#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.");
}
}

24
src/base/digitseq/cl_DS_mul_nuss.h

@ -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.

2
src/base/digitseq/cl_DS_recip.cc

@ -9,8 +9,6 @@
// Implementation.
#include "cln/abort.h"
namespace cln {
// Compute the reciprocal value of a digit sequence.

10
src/base/digitseq/cl_DS_recipsqrt.cc

@ -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.

12
src/base/digitseq/cl_DS_sqrt.cc

@ -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

6
src/base/hash/cl_hash.h

@ -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);

6
src/base/hash/cl_hash1.h

@ -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;

2
src/base/hash/cl_hash1weak.h

@ -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++;

6
src/base/hash/cl_hash2.h

@ -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

2
src/base/hash/cl_hash2weak.h

@ -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++;

6
src/base/hash/cl_hashset.h

@ -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;

6
src/base/hash/cl_hashuniq.h

@ -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;

2
src/base/hash/cl_hashuniqweak.h

@ -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++;

32
src/base/input/cl_read_bad_syntax_exception.cc

@ -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

11
src/base/input/cl_read_err_eof.cc → src/base/input/cl_read_eof_exception.cc

@ -1,4 +1,4 @@
// read_number_eof().
// read_number_eof_exception().
// General includes.
#include "cl_sysdep.h"
@ -10,14 +10,11 @@
// 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

26
src/base/input/cl_read_err_bad.cc

@ -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

31
src/base/input/cl_read_err_junk.cc

@ -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

37
src/base/input/cl_read_junk_exception.cc

@ -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

4
src/base/proplist/cl_pl_add.cc

@ -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;
}

68
src/base/ring/cl_no_ring.cc

@ -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 = {

4
src/base/string/cl_spushstring.h

@ -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];
}

2
src/base/symbol/cl_symbol.cc

@ -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);

15
src/complex/input/cl_N_read.cc

@ -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)

4
src/complex/input/cl_N_read_stream.cc

@ -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

3
src/complex/misc/cl_N_as.cc

@ -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

4
src/complex/transcendental/cl_C_atanh_aux.cc

@ -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);
}
}

2
src/complex/transcendental/cl_C_expt_C.cc

@ -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

2
src/complex/transcendental/cl_C_log.cc

@ -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));
}

2
src/complex/transcendental/cl_C_log2.cc

@ -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);

23
src/float/base/cl_F_err_nan.cc

@ -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

23
src/float/base/cl_F_err_ov.cc

@ -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

23
src/float/base/cl_F_err_un.cc

@ -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

20
src/float/base/cl_F_nan_exception.cc

@ -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

20
src/float/base/cl_F_overflow_exception.cc

@ -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

20
src/float/base/cl_F_underflow_exception.cc

@ -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

7
src/float/cl_F.h

@ -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;

24
src/float/dfloat/cl_DF.h

@ -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); } \

16
src/float/dfloat/conv/cl_DF_from_double.cc

@ -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);
}

4
src/float/dfloat/elem/cl_DF_div.cc

@ -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

4
src/float/dfloat/elem/cl_DF_from_RA.cc

@ -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; }
}

4
src/float/dfloat/elem/cl_DF_scale.cc

@ -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; }
}

4
src/float/dfloat/elem/cl_DF_scale_I.cc

@ -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; }
}

2
src/float/dfloat/misc/cl_DF_as.cc

@ -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

12
src/float/ffloat/cl_FF.h

@ -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); } \

8
src/float/ffloat/conv/cl_FF_from_float.cc

@ -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));

2
src/float/ffloat/elem/cl_FF_div.cc

@ -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

4
src/float/ffloat/elem/cl_FF_from_RA.cc

@ -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; }
}

4
src/float/ffloat/elem/cl_FF_scale.cc

@ -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; }
}

4
src/float/ffloat/elem/cl_FF_scale_I.cc

@ -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; }
}

2
src/float/ffloat/misc/cl_FF_as.cc

@ -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

4
src/float/input/cl_F_read.cc

@ -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

4
src/float/input/cl_F_read_stream.cc

@ -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

4
src/float/lfloat/algebraic/cl_LF_sqrt.cc

@ -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
}

8
src/float/lfloat/elem/cl_LF_1plus.cc

@ -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
;

6
src/float/lfloat/elem/cl_LF_I_div.cc

@ -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);
}

4
src/float/lfloat/elem/cl_LF_I_mul.cc

@ -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);
}

12
src/float/lfloat/elem/cl_LF_div.cc

@ -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
}

4
src/float/lfloat/elem/cl_LF_from_I.cc

@ -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
;

8
src/float/lfloat/elem/cl_LF_mul.cc

@ -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;
}

4
src/float/lfloat/elem/cl_LF_scale.cc

@ -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);

Some files were not shown because too many files changed in this diff

|||||||
100:0
Loading…
Cancel
Save