therubyracer 0.5.0-x86-linux → 0.11.0beta5-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

Files changed (721) hide show
  1. data/.gitignore +23 -11
  2. data/.travis.yml +10 -0
  3. data/Changelog.md +242 -0
  4. data/Gemfile +16 -0
  5. data/README.md +185 -0
  6. data/Rakefile +42 -51
  7. data/benchmarks.rb +217 -0
  8. data/ext/v8/accessor.cc +181 -0
  9. data/ext/v8/array.cc +26 -0
  10. data/ext/v8/backref.cc +56 -0
  11. data/ext/v8/build.rb +52 -0
  12. data/ext/v8/constants.cc +34 -0
  13. data/ext/v8/constraints.cc +52 -0
  14. data/ext/v8/context.cc +130 -0
  15. data/ext/v8/date.cc +18 -0
  16. data/ext/v8/exception.cc +38 -0
  17. data/ext/v8/extconf.rb +16 -29
  18. data/ext/v8/external.cc +43 -0
  19. data/ext/v8/function.cc +58 -0
  20. data/ext/v8/gc.cc +43 -0
  21. data/ext/v8/handles.cc +34 -0
  22. data/ext/v8/heap.cc +31 -0
  23. data/ext/v8/init.cc +39 -0
  24. data/ext/v8/init.so +0 -0
  25. data/ext/v8/invocation.cc +86 -0
  26. data/ext/v8/locker.cc +77 -0
  27. data/ext/v8/message.cc +51 -0
  28. data/ext/v8/object.cc +334 -0
  29. data/ext/v8/primitive.cc +8 -0
  30. data/ext/v8/rr.cc +83 -0
  31. data/ext/v8/rr.h +883 -0
  32. data/ext/v8/script.cc +80 -0
  33. data/ext/v8/signature.cc +18 -0
  34. data/ext/v8/stack.cc +75 -0
  35. data/ext/v8/string.cc +47 -0
  36. data/ext/v8/template.cc +175 -0
  37. data/ext/v8/trycatch.cc +86 -0
  38. data/ext/v8/v8.cc +87 -0
  39. data/ext/v8/value.cc +239 -0
  40. data/lib/v8.rb +30 -9
  41. data/lib/v8/access.rb +5 -0
  42. data/lib/v8/access/indices.rb +40 -0
  43. data/lib/v8/access/invocation.rb +47 -0
  44. data/lib/v8/access/names.rb +65 -0
  45. data/lib/v8/array.rb +26 -0
  46. data/lib/v8/context.rb +217 -75
  47. data/lib/v8/conversion.rb +35 -0
  48. data/lib/v8/conversion/array.rb +11 -0
  49. data/lib/v8/conversion/class.rb +120 -0
  50. data/lib/v8/conversion/code.rb +38 -0
  51. data/lib/v8/conversion/fundamental.rb +11 -0
  52. data/lib/v8/conversion/hash.rb +11 -0
  53. data/lib/v8/conversion/indentity.rb +31 -0
  54. data/lib/v8/conversion/method.rb +26 -0
  55. data/lib/v8/conversion/object.rb +28 -0
  56. data/lib/v8/conversion/primitive.rb +7 -0
  57. data/lib/v8/conversion/proc.rb +5 -0
  58. data/lib/v8/conversion/reference.rb +16 -0
  59. data/lib/v8/conversion/string.rb +12 -0
  60. data/lib/v8/conversion/symbol.rb +7 -0
  61. data/lib/v8/conversion/time.rb +13 -0
  62. data/lib/v8/error.rb +25 -0
  63. data/lib/v8/error/protect.rb +20 -0
  64. data/lib/v8/error/try.rb +15 -0
  65. data/lib/v8/function.rb +28 -0
  66. data/lib/v8/object.rb +69 -28
  67. data/lib/v8/util/weakcell.rb +29 -0
  68. data/lib/v8/version.rb +3 -0
  69. data/spec/c/array_spec.rb +17 -0
  70. data/spec/c/constants_spec.rb +20 -0
  71. data/spec/c/exception_spec.rb +26 -0
  72. data/spec/c/external_spec.rb +9 -0
  73. data/spec/c/function_spec.rb +46 -0
  74. data/spec/c/handles_spec.rb +35 -0
  75. data/spec/c/locker_spec.rb +38 -0
  76. data/spec/c/object_spec.rb +46 -0
  77. data/spec/c/script_spec.rb +28 -0
  78. data/spec/c/string_spec.rb +16 -0
  79. data/spec/c/template_spec.rb +30 -0
  80. data/spec/c/trycatch_spec.rb +51 -0
  81. data/spec/mem/blunt_spec.rb +42 -0
  82. data/spec/redjs_spec.rb +10 -0
  83. data/spec/spec_helper.rb +43 -12
  84. data/spec/threading_spec.rb +52 -0
  85. data/spec/v8/context_spec.rb +19 -0
  86. data/spec/v8/conversion_spec.rb +9 -0
  87. data/spec/v8/error_spec.rb +21 -0
  88. data/spec/v8/function_spec.rb +9 -0
  89. data/spec/v8/object_spec.rb +15 -0
  90. data/thefrontside.png +0 -0
  91. data/therubyracer.gemspec +15 -676
  92. metadata +146 -680
  93. data/.gitmodules +0 -3
  94. data/Doxyfile +0 -1514
  95. data/History.txt +0 -51
  96. data/README.rdoc +0 -158
  97. data/docs/data_conversion.txt +0 -18
  98. data/ext/v8/callbacks.cpp +0 -160
  99. data/ext/v8/callbacks.h +0 -14
  100. data/ext/v8/convert_ruby.cpp +0 -8
  101. data/ext/v8/convert_ruby.h +0 -99
  102. data/ext/v8/convert_string.cpp +0 -10
  103. data/ext/v8/convert_string.h +0 -73
  104. data/ext/v8/convert_v8.cpp +0 -9
  105. data/ext/v8/convert_v8.h +0 -121
  106. data/ext/v8/converters.cpp +0 -83
  107. data/ext/v8/converters.h +0 -23
  108. data/ext/v8/upstream/2.0.6/.gitignore +0 -26
  109. data/ext/v8/upstream/2.0.6/AUTHORS +0 -23
  110. data/ext/v8/upstream/2.0.6/ChangeLog +0 -1479
  111. data/ext/v8/upstream/2.0.6/LICENSE +0 -55
  112. data/ext/v8/upstream/2.0.6/SConstruct +0 -1028
  113. data/ext/v8/upstream/2.0.6/include/v8-debug.h +0 -275
  114. data/ext/v8/upstream/2.0.6/include/v8.h +0 -3236
  115. data/ext/v8/upstream/2.0.6/src/SConscript +0 -283
  116. data/ext/v8/upstream/2.0.6/src/accessors.cc +0 -695
  117. data/ext/v8/upstream/2.0.6/src/accessors.h +0 -114
  118. data/ext/v8/upstream/2.0.6/src/allocation.cc +0 -198
  119. data/ext/v8/upstream/2.0.6/src/allocation.h +0 -169
  120. data/ext/v8/upstream/2.0.6/src/api.cc +0 -3831
  121. data/ext/v8/upstream/2.0.6/src/api.h +0 -479
  122. data/ext/v8/upstream/2.0.6/src/apinatives.js +0 -110
  123. data/ext/v8/upstream/2.0.6/src/apiutils.h +0 -69
  124. data/ext/v8/upstream/2.0.6/src/arguments.h +0 -97
  125. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm-inl.h +0 -277
  126. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.cc +0 -1821
  127. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.h +0 -1027
  128. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2-inl.h +0 -267
  129. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.cc +0 -1821
  130. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.h +0 -1027
  131. data/ext/v8/upstream/2.0.6/src/arm/builtins-arm.cc +0 -1271
  132. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm-inl.h +0 -74
  133. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.cc +0 -6682
  134. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.h +0 -535
  135. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.cc +0 -112
  136. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.h +0 -347
  137. data/ext/v8/upstream/2.0.6/src/arm/cpu-arm.cc +0 -132
  138. data/ext/v8/upstream/2.0.6/src/arm/debug-arm.cc +0 -213
  139. data/ext/v8/upstream/2.0.6/src/arm/disasm-arm.cc +0 -1166
  140. data/ext/v8/upstream/2.0.6/src/arm/fast-codegen-arm.cc +0 -1698
  141. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.cc +0 -123
  142. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.h +0 -162
  143. data/ext/v8/upstream/2.0.6/src/arm/ic-arm.cc +0 -849
  144. data/ext/v8/upstream/2.0.6/src/arm/jump-target-arm.cc +0 -238
  145. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.cc +0 -1259
  146. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.h +0 -423
  147. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.cc +0 -1266
  148. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.h +0 -282
  149. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm-inl.h +0 -103
  150. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.cc +0 -59
  151. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.h +0 -43
  152. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.cc +0 -2264
  153. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.h +0 -306
  154. data/ext/v8/upstream/2.0.6/src/arm/stub-cache-arm.cc +0 -1516
  155. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.cc +0 -412
  156. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.h +0 -532
  157. data/ext/v8/upstream/2.0.6/src/array.js +0 -1154
  158. data/ext/v8/upstream/2.0.6/src/assembler.cc +0 -772
  159. data/ext/v8/upstream/2.0.6/src/assembler.h +0 -525
  160. data/ext/v8/upstream/2.0.6/src/ast.cc +0 -512
  161. data/ext/v8/upstream/2.0.6/src/ast.h +0 -1820
  162. data/ext/v8/upstream/2.0.6/src/bootstrapper.cc +0 -1680
  163. data/ext/v8/upstream/2.0.6/src/bootstrapper.h +0 -103
  164. data/ext/v8/upstream/2.0.6/src/builtins.cc +0 -851
  165. data/ext/v8/upstream/2.0.6/src/builtins.h +0 -245
  166. data/ext/v8/upstream/2.0.6/src/bytecodes-irregexp.h +0 -104
  167. data/ext/v8/upstream/2.0.6/src/char-predicates-inl.h +0 -86
  168. data/ext/v8/upstream/2.0.6/src/char-predicates.h +0 -65
  169. data/ext/v8/upstream/2.0.6/src/checks.cc +0 -100
  170. data/ext/v8/upstream/2.0.6/src/checks.h +0 -284
  171. data/ext/v8/upstream/2.0.6/src/code-stubs.cc +0 -164
  172. data/ext/v8/upstream/2.0.6/src/code-stubs.h +0 -164
  173. data/ext/v8/upstream/2.0.6/src/code.h +0 -68
  174. data/ext/v8/upstream/2.0.6/src/codegen-inl.h +0 -88
  175. data/ext/v8/upstream/2.0.6/src/codegen.cc +0 -504
  176. data/ext/v8/upstream/2.0.6/src/codegen.h +0 -522
  177. data/ext/v8/upstream/2.0.6/src/compilation-cache.cc +0 -490
  178. data/ext/v8/upstream/2.0.6/src/compilation-cache.h +0 -98
  179. data/ext/v8/upstream/2.0.6/src/compiler.cc +0 -1132
  180. data/ext/v8/upstream/2.0.6/src/compiler.h +0 -107
  181. data/ext/v8/upstream/2.0.6/src/contexts.cc +0 -256
  182. data/ext/v8/upstream/2.0.6/src/contexts.h +0 -345
  183. data/ext/v8/upstream/2.0.6/src/conversions-inl.h +0 -95
  184. data/ext/v8/upstream/2.0.6/src/conversions.cc +0 -709
  185. data/ext/v8/upstream/2.0.6/src/conversions.h +0 -118
  186. data/ext/v8/upstream/2.0.6/src/counters.cc +0 -78
  187. data/ext/v8/upstream/2.0.6/src/counters.h +0 -239
  188. data/ext/v8/upstream/2.0.6/src/cpu.h +0 -65
  189. data/ext/v8/upstream/2.0.6/src/d8-debug.cc +0 -345
  190. data/ext/v8/upstream/2.0.6/src/d8-debug.h +0 -155
  191. data/ext/v8/upstream/2.0.6/src/d8-posix.cc +0 -675
  192. data/ext/v8/upstream/2.0.6/src/d8-readline.cc +0 -128
  193. data/ext/v8/upstream/2.0.6/src/d8-windows.cc +0 -42
  194. data/ext/v8/upstream/2.0.6/src/d8.cc +0 -776
  195. data/ext/v8/upstream/2.0.6/src/d8.h +0 -225
  196. data/ext/v8/upstream/2.0.6/src/d8.js +0 -1625
  197. data/ext/v8/upstream/2.0.6/src/date-delay.js +0 -1138
  198. data/ext/v8/upstream/2.0.6/src/dateparser-inl.h +0 -114
  199. data/ext/v8/upstream/2.0.6/src/dateparser.cc +0 -186
  200. data/ext/v8/upstream/2.0.6/src/dateparser.h +0 -240
  201. data/ext/v8/upstream/2.0.6/src/debug-agent.cc +0 -425
  202. data/ext/v8/upstream/2.0.6/src/debug-agent.h +0 -129
  203. data/ext/v8/upstream/2.0.6/src/debug-delay.js +0 -2073
  204. data/ext/v8/upstream/2.0.6/src/debug.cc +0 -2751
  205. data/ext/v8/upstream/2.0.6/src/debug.h +0 -866
  206. data/ext/v8/upstream/2.0.6/src/disasm.h +0 -77
  207. data/ext/v8/upstream/2.0.6/src/disassembler.cc +0 -318
  208. data/ext/v8/upstream/2.0.6/src/disassembler.h +0 -56
  209. data/ext/v8/upstream/2.0.6/src/dtoa-config.c +0 -91
  210. data/ext/v8/upstream/2.0.6/src/execution.cc +0 -701
  211. data/ext/v8/upstream/2.0.6/src/execution.h +0 -312
  212. data/ext/v8/upstream/2.0.6/src/factory.cc +0 -957
  213. data/ext/v8/upstream/2.0.6/src/factory.h +0 -393
  214. data/ext/v8/upstream/2.0.6/src/fast-codegen.cc +0 -725
  215. data/ext/v8/upstream/2.0.6/src/fast-codegen.h +0 -371
  216. data/ext/v8/upstream/2.0.6/src/flag-definitions.h +0 -426
  217. data/ext/v8/upstream/2.0.6/src/flags.cc +0 -555
  218. data/ext/v8/upstream/2.0.6/src/flags.h +0 -81
  219. data/ext/v8/upstream/2.0.6/src/frame-element.cc +0 -45
  220. data/ext/v8/upstream/2.0.6/src/frame-element.h +0 -235
  221. data/ext/v8/upstream/2.0.6/src/frames-inl.h +0 -215
  222. data/ext/v8/upstream/2.0.6/src/frames.cc +0 -749
  223. data/ext/v8/upstream/2.0.6/src/frames.h +0 -659
  224. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.cc +0 -76
  225. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.h +0 -135
  226. data/ext/v8/upstream/2.0.6/src/global-handles.cc +0 -516
  227. data/ext/v8/upstream/2.0.6/src/global-handles.h +0 -180
  228. data/ext/v8/upstream/2.0.6/src/globals.h +0 -608
  229. data/ext/v8/upstream/2.0.6/src/handles-inl.h +0 -76
  230. data/ext/v8/upstream/2.0.6/src/handles.cc +0 -811
  231. data/ext/v8/upstream/2.0.6/src/handles.h +0 -367
  232. data/ext/v8/upstream/2.0.6/src/hashmap.cc +0 -226
  233. data/ext/v8/upstream/2.0.6/src/hashmap.h +0 -120
  234. data/ext/v8/upstream/2.0.6/src/heap-inl.h +0 -407
  235. data/ext/v8/upstream/2.0.6/src/heap-profiler.cc +0 -695
  236. data/ext/v8/upstream/2.0.6/src/heap-profiler.h +0 -277
  237. data/ext/v8/upstream/2.0.6/src/heap.cc +0 -4204
  238. data/ext/v8/upstream/2.0.6/src/heap.h +0 -1704
  239. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32-inl.h +0 -325
  240. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.cc +0 -2375
  241. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.h +0 -914
  242. data/ext/v8/upstream/2.0.6/src/ia32/builtins-ia32.cc +0 -1222
  243. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32-inl.h +0 -46
  244. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.cc +0 -9770
  245. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.h +0 -834
  246. data/ext/v8/upstream/2.0.6/src/ia32/cpu-ia32.cc +0 -79
  247. data/ext/v8/upstream/2.0.6/src/ia32/debug-ia32.cc +0 -208
  248. data/ext/v8/upstream/2.0.6/src/ia32/disasm-ia32.cc +0 -1357
  249. data/ext/v8/upstream/2.0.6/src/ia32/fast-codegen-ia32.cc +0 -1813
  250. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.cc +0 -111
  251. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.h +0 -135
  252. data/ext/v8/upstream/2.0.6/src/ia32/ic-ia32.cc +0 -1490
  253. data/ext/v8/upstream/2.0.6/src/ia32/jump-target-ia32.cc +0 -432
  254. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.cc +0 -1517
  255. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.h +0 -528
  256. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.cc +0 -1219
  257. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.h +0 -230
  258. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32-inl.h +0 -82
  259. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.cc +0 -99
  260. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.h +0 -43
  261. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.cc +0 -30
  262. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.h +0 -62
  263. data/ext/v8/upstream/2.0.6/src/ia32/stub-cache-ia32.cc +0 -1961
  264. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.cc +0 -1105
  265. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.h +0 -580
  266. data/ext/v8/upstream/2.0.6/src/ic-inl.h +0 -93
  267. data/ext/v8/upstream/2.0.6/src/ic.cc +0 -1426
  268. data/ext/v8/upstream/2.0.6/src/ic.h +0 -443
  269. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.cc +0 -646
  270. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.h +0 -48
  271. data/ext/v8/upstream/2.0.6/src/json-delay.js +0 -254
  272. data/ext/v8/upstream/2.0.6/src/jsregexp.cc +0 -5234
  273. data/ext/v8/upstream/2.0.6/src/jsregexp.h +0 -1439
  274. data/ext/v8/upstream/2.0.6/src/jump-target-inl.h +0 -49
  275. data/ext/v8/upstream/2.0.6/src/jump-target.cc +0 -383
  276. data/ext/v8/upstream/2.0.6/src/jump-target.h +0 -280
  277. data/ext/v8/upstream/2.0.6/src/list-inl.h +0 -166
  278. data/ext/v8/upstream/2.0.6/src/list.h +0 -158
  279. data/ext/v8/upstream/2.0.6/src/log-inl.h +0 -126
  280. data/ext/v8/upstream/2.0.6/src/log-utils.cc +0 -503
  281. data/ext/v8/upstream/2.0.6/src/log-utils.h +0 -292
  282. data/ext/v8/upstream/2.0.6/src/log.cc +0 -1457
  283. data/ext/v8/upstream/2.0.6/src/log.h +0 -371
  284. data/ext/v8/upstream/2.0.6/src/macro-assembler.h +0 -93
  285. data/ext/v8/upstream/2.0.6/src/macros.py +0 -137
  286. data/ext/v8/upstream/2.0.6/src/mark-compact.cc +0 -2007
  287. data/ext/v8/upstream/2.0.6/src/mark-compact.h +0 -442
  288. data/ext/v8/upstream/2.0.6/src/math.js +0 -263
  289. data/ext/v8/upstream/2.0.6/src/memory.h +0 -74
  290. data/ext/v8/upstream/2.0.6/src/messages.cc +0 -177
  291. data/ext/v8/upstream/2.0.6/src/messages.h +0 -112
  292. data/ext/v8/upstream/2.0.6/src/messages.js +0 -937
  293. data/ext/v8/upstream/2.0.6/src/mirror-delay.js +0 -2332
  294. data/ext/v8/upstream/2.0.6/src/mksnapshot.cc +0 -169
  295. data/ext/v8/upstream/2.0.6/src/natives.h +0 -63
  296. data/ext/v8/upstream/2.0.6/src/objects-debug.cc +0 -1317
  297. data/ext/v8/upstream/2.0.6/src/objects-inl.h +0 -3044
  298. data/ext/v8/upstream/2.0.6/src/objects.cc +0 -8306
  299. data/ext/v8/upstream/2.0.6/src/objects.h +0 -4960
  300. data/ext/v8/upstream/2.0.6/src/oprofile-agent.cc +0 -116
  301. data/ext/v8/upstream/2.0.6/src/oprofile-agent.h +0 -69
  302. data/ext/v8/upstream/2.0.6/src/parser.cc +0 -4810
  303. data/ext/v8/upstream/2.0.6/src/parser.h +0 -195
  304. data/ext/v8/upstream/2.0.6/src/platform-freebsd.cc +0 -645
  305. data/ext/v8/upstream/2.0.6/src/platform-linux.cc +0 -808
  306. data/ext/v8/upstream/2.0.6/src/platform-macos.cc +0 -643
  307. data/ext/v8/upstream/2.0.6/src/platform-nullos.cc +0 -454
  308. data/ext/v8/upstream/2.0.6/src/platform-openbsd.cc +0 -597
  309. data/ext/v8/upstream/2.0.6/src/platform-posix.cc +0 -380
  310. data/ext/v8/upstream/2.0.6/src/platform-win32.cc +0 -1908
  311. data/ext/v8/upstream/2.0.6/src/platform.h +0 -556
  312. data/ext/v8/upstream/2.0.6/src/prettyprinter.cc +0 -1511
  313. data/ext/v8/upstream/2.0.6/src/prettyprinter.h +0 -219
  314. data/ext/v8/upstream/2.0.6/src/property.cc +0 -96
  315. data/ext/v8/upstream/2.0.6/src/property.h +0 -327
  316. data/ext/v8/upstream/2.0.6/src/regexp-delay.js +0 -406
  317. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp-inl.h +0 -78
  318. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.cc +0 -464
  319. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.h +0 -141
  320. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.cc +0 -356
  321. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.h +0 -103
  322. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.cc +0 -240
  323. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.h +0 -220
  324. data/ext/v8/upstream/2.0.6/src/regexp-stack.cc +0 -103
  325. data/ext/v8/upstream/2.0.6/src/regexp-stack.h +0 -123
  326. data/ext/v8/upstream/2.0.6/src/register-allocator-inl.h +0 -74
  327. data/ext/v8/upstream/2.0.6/src/register-allocator.cc +0 -100
  328. data/ext/v8/upstream/2.0.6/src/register-allocator.h +0 -295
  329. data/ext/v8/upstream/2.0.6/src/rewriter.cc +0 -855
  330. data/ext/v8/upstream/2.0.6/src/rewriter.h +0 -54
  331. data/ext/v8/upstream/2.0.6/src/runtime.cc +0 -8163
  332. data/ext/v8/upstream/2.0.6/src/runtime.h +0 -432
  333. data/ext/v8/upstream/2.0.6/src/runtime.js +0 -626
  334. data/ext/v8/upstream/2.0.6/src/scanner.cc +0 -1098
  335. data/ext/v8/upstream/2.0.6/src/scanner.h +0 -425
  336. data/ext/v8/upstream/2.0.6/src/scopeinfo.cc +0 -649
  337. data/ext/v8/upstream/2.0.6/src/scopeinfo.h +0 -236
  338. data/ext/v8/upstream/2.0.6/src/scopes.cc +0 -963
  339. data/ext/v8/upstream/2.0.6/src/scopes.h +0 -401
  340. data/ext/v8/upstream/2.0.6/src/serialize.cc +0 -1260
  341. data/ext/v8/upstream/2.0.6/src/serialize.h +0 -404
  342. data/ext/v8/upstream/2.0.6/src/shell.h +0 -55
  343. data/ext/v8/upstream/2.0.6/src/simulator.h +0 -41
  344. data/ext/v8/upstream/2.0.6/src/smart-pointer.h +0 -109
  345. data/ext/v8/upstream/2.0.6/src/snapshot-common.cc +0 -97
  346. data/ext/v8/upstream/2.0.6/src/snapshot-empty.cc +0 -40
  347. data/ext/v8/upstream/2.0.6/src/snapshot.h +0 -59
  348. data/ext/v8/upstream/2.0.6/src/spaces-inl.h +0 -372
  349. data/ext/v8/upstream/2.0.6/src/spaces.cc +0 -2864
  350. data/ext/v8/upstream/2.0.6/src/spaces.h +0 -2072
  351. data/ext/v8/upstream/2.0.6/src/string-stream.cc +0 -584
  352. data/ext/v8/upstream/2.0.6/src/string-stream.h +0 -189
  353. data/ext/v8/upstream/2.0.6/src/string.js +0 -901
  354. data/ext/v8/upstream/2.0.6/src/stub-cache.cc +0 -1108
  355. data/ext/v8/upstream/2.0.6/src/stub-cache.h +0 -578
  356. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/COPYING +0 -15
  357. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/dtoa.c +0 -3330
  358. data/ext/v8/upstream/2.0.6/src/third_party/valgrind/valgrind.h +0 -3925
  359. data/ext/v8/upstream/2.0.6/src/token.cc +0 -56
  360. data/ext/v8/upstream/2.0.6/src/token.h +0 -270
  361. data/ext/v8/upstream/2.0.6/src/top.cc +0 -991
  362. data/ext/v8/upstream/2.0.6/src/top.h +0 -459
  363. data/ext/v8/upstream/2.0.6/src/unicode-inl.h +0 -238
  364. data/ext/v8/upstream/2.0.6/src/unicode.cc +0 -749
  365. data/ext/v8/upstream/2.0.6/src/unicode.h +0 -279
  366. data/ext/v8/upstream/2.0.6/src/uri.js +0 -415
  367. data/ext/v8/upstream/2.0.6/src/usage-analyzer.cc +0 -426
  368. data/ext/v8/upstream/2.0.6/src/usage-analyzer.h +0 -40
  369. data/ext/v8/upstream/2.0.6/src/utils.cc +0 -322
  370. data/ext/v8/upstream/2.0.6/src/utils.h +0 -592
  371. data/ext/v8/upstream/2.0.6/src/v8-counters.cc +0 -55
  372. data/ext/v8/upstream/2.0.6/src/v8-counters.h +0 -198
  373. data/ext/v8/upstream/2.0.6/src/v8.cc +0 -193
  374. data/ext/v8/upstream/2.0.6/src/v8.h +0 -119
  375. data/ext/v8/upstream/2.0.6/src/v8natives.js +0 -846
  376. data/ext/v8/upstream/2.0.6/src/v8threads.cc +0 -450
  377. data/ext/v8/upstream/2.0.6/src/v8threads.h +0 -144
  378. data/ext/v8/upstream/2.0.6/src/variables.cc +0 -163
  379. data/ext/v8/upstream/2.0.6/src/variables.h +0 -235
  380. data/ext/v8/upstream/2.0.6/src/version.cc +0 -88
  381. data/ext/v8/upstream/2.0.6/src/version.h +0 -64
  382. data/ext/v8/upstream/2.0.6/src/virtual-frame.cc +0 -381
  383. data/ext/v8/upstream/2.0.6/src/virtual-frame.h +0 -44
  384. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64-inl.h +0 -352
  385. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.cc +0 -2539
  386. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.h +0 -1399
  387. data/ext/v8/upstream/2.0.6/src/x64/builtins-x64.cc +0 -1255
  388. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64-inl.h +0 -46
  389. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.cc +0 -8223
  390. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.h +0 -785
  391. data/ext/v8/upstream/2.0.6/src/x64/cpu-x64.cc +0 -79
  392. data/ext/v8/upstream/2.0.6/src/x64/debug-x64.cc +0 -202
  393. data/ext/v8/upstream/2.0.6/src/x64/disasm-x64.cc +0 -1596
  394. data/ext/v8/upstream/2.0.6/src/x64/fast-codegen-x64.cc +0 -1820
  395. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.cc +0 -109
  396. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.h +0 -121
  397. data/ext/v8/upstream/2.0.6/src/x64/ic-x64.cc +0 -1392
  398. data/ext/v8/upstream/2.0.6/src/x64/jump-target-x64.cc +0 -432
  399. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.cc +0 -2409
  400. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.h +0 -765
  401. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.cc +0 -1337
  402. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.h +0 -295
  403. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64-inl.h +0 -86
  404. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.cc +0 -84
  405. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.h +0 -43
  406. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.cc +0 -27
  407. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.h +0 -63
  408. data/ext/v8/upstream/2.0.6/src/x64/stub-cache-x64.cc +0 -1884
  409. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.cc +0 -1089
  410. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.h +0 -560
  411. data/ext/v8/upstream/2.0.6/src/zone-inl.h +0 -297
  412. data/ext/v8/upstream/2.0.6/src/zone.cc +0 -193
  413. data/ext/v8/upstream/2.0.6/src/zone.h +0 -305
  414. data/ext/v8/upstream/2.0.6/tools/codemap.js +0 -258
  415. data/ext/v8/upstream/2.0.6/tools/consarray.js +0 -93
  416. data/ext/v8/upstream/2.0.6/tools/csvparser.js +0 -98
  417. data/ext/v8/upstream/2.0.6/tools/gyp/v8.gyp +0 -620
  418. data/ext/v8/upstream/2.0.6/tools/js2c.py +0 -376
  419. data/ext/v8/upstream/2.0.6/tools/jsmin.py +0 -280
  420. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor +0 -24
  421. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor.py +0 -78
  422. data/ext/v8/upstream/2.0.6/tools/logreader.js +0 -320
  423. data/ext/v8/upstream/2.0.6/tools/mac-nm +0 -18
  424. data/ext/v8/upstream/2.0.6/tools/mac-tick-processor +0 -6
  425. data/ext/v8/upstream/2.0.6/tools/oprofile/annotate +0 -7
  426. data/ext/v8/upstream/2.0.6/tools/oprofile/common +0 -19
  427. data/ext/v8/upstream/2.0.6/tools/oprofile/dump +0 -7
  428. data/ext/v8/upstream/2.0.6/tools/oprofile/report +0 -7
  429. data/ext/v8/upstream/2.0.6/tools/oprofile/reset +0 -7
  430. data/ext/v8/upstream/2.0.6/tools/oprofile/run +0 -14
  431. data/ext/v8/upstream/2.0.6/tools/oprofile/shutdown +0 -7
  432. data/ext/v8/upstream/2.0.6/tools/oprofile/start +0 -7
  433. data/ext/v8/upstream/2.0.6/tools/presubmit.py +0 -299
  434. data/ext/v8/upstream/2.0.6/tools/process-heap-prof.py +0 -120
  435. data/ext/v8/upstream/2.0.6/tools/profile.js +0 -621
  436. data/ext/v8/upstream/2.0.6/tools/profile_view.js +0 -224
  437. data/ext/v8/upstream/2.0.6/tools/run-valgrind.py +0 -77
  438. data/ext/v8/upstream/2.0.6/tools/splaytree.js +0 -322
  439. data/ext/v8/upstream/2.0.6/tools/splaytree.py +0 -226
  440. data/ext/v8/upstream/2.0.6/tools/stats-viewer.py +0 -456
  441. data/ext/v8/upstream/2.0.6/tools/test.py +0 -1370
  442. data/ext/v8/upstream/2.0.6/tools/tickprocessor-driver.js +0 -53
  443. data/ext/v8/upstream/2.0.6/tools/tickprocessor.js +0 -731
  444. data/ext/v8/upstream/2.0.6/tools/tickprocessor.py +0 -535
  445. data/ext/v8/upstream/2.0.6/tools/utils.py +0 -82
  446. data/ext/v8/upstream/2.0.6/tools/visual_studio/README.txt +0 -71
  447. data/ext/v8/upstream/2.0.6/tools/visual_studio/arm.vsprops +0 -14
  448. data/ext/v8/upstream/2.0.6/tools/visual_studio/common.vsprops +0 -35
  449. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8.vcproj +0 -199
  450. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_arm.vcproj +0 -199
  451. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_x64.vcproj +0 -201
  452. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8js2c.cmd +0 -6
  453. data/ext/v8/upstream/2.0.6/tools/visual_studio/debug.vsprops +0 -17
  454. data/ext/v8/upstream/2.0.6/tools/visual_studio/ia32.vsprops +0 -13
  455. data/ext/v8/upstream/2.0.6/tools/visual_studio/js2c.cmd +0 -6
  456. data/ext/v8/upstream/2.0.6/tools/visual_studio/release.vsprops +0 -24
  457. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.sln +0 -101
  458. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.vcproj +0 -223
  459. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.sln +0 -74
  460. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.vcproj +0 -223
  461. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base.vcproj +0 -971
  462. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_arm.vcproj +0 -983
  463. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_x64.vcproj +0 -959
  464. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest.vcproj +0 -255
  465. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_arm.vcproj +0 -243
  466. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_x64.vcproj +0 -257
  467. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot.vcproj +0 -151
  468. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -151
  469. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample.vcproj +0 -151
  470. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_arm.vcproj +0 -151
  471. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_x64.vcproj +0 -151
  472. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample.vcproj +0 -151
  473. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -151
  474. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -153
  475. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot.vcproj +0 -142
  476. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc.vcproj +0 -92
  477. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -92
  478. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_x64.vcproj +0 -142
  479. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.sln +0 -101
  480. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.vcproj +0 -223
  481. data/ext/v8/upstream/2.0.6/tools/visual_studio/x64.vsprops +0 -13
  482. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.bat +0 -5
  483. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.py +0 -137
  484. data/ext/v8/upstream/Makefile +0 -32
  485. data/ext/v8/upstream/fpic-on-linux-amd64.patch +0 -13
  486. data/ext/v8/upstream/no-strict-aliasing.patch +0 -13
  487. data/ext/v8/upstream/scons/CHANGES.txt +0 -5183
  488. data/ext/v8/upstream/scons/LICENSE.txt +0 -20
  489. data/ext/v8/upstream/scons/MANIFEST +0 -202
  490. data/ext/v8/upstream/scons/PKG-INFO +0 -13
  491. data/ext/v8/upstream/scons/README.txt +0 -273
  492. data/ext/v8/upstream/scons/RELEASE.txt +0 -1040
  493. data/ext/v8/upstream/scons/engine/SCons/Action.py +0 -1256
  494. data/ext/v8/upstream/scons/engine/SCons/Builder.py +0 -868
  495. data/ext/v8/upstream/scons/engine/SCons/CacheDir.py +0 -217
  496. data/ext/v8/upstream/scons/engine/SCons/Conftest.py +0 -794
  497. data/ext/v8/upstream/scons/engine/SCons/Debug.py +0 -237
  498. data/ext/v8/upstream/scons/engine/SCons/Defaults.py +0 -485
  499. data/ext/v8/upstream/scons/engine/SCons/Environment.py +0 -2327
  500. data/ext/v8/upstream/scons/engine/SCons/Errors.py +0 -207
  501. data/ext/v8/upstream/scons/engine/SCons/Executor.py +0 -636
  502. data/ext/v8/upstream/scons/engine/SCons/Job.py +0 -435
  503. data/ext/v8/upstream/scons/engine/SCons/Memoize.py +0 -292
  504. data/ext/v8/upstream/scons/engine/SCons/Node/Alias.py +0 -153
  505. data/ext/v8/upstream/scons/engine/SCons/Node/FS.py +0 -3220
  506. data/ext/v8/upstream/scons/engine/SCons/Node/Python.py +0 -128
  507. data/ext/v8/upstream/scons/engine/SCons/Node/__init__.py +0 -1341
  508. data/ext/v8/upstream/scons/engine/SCons/Options/BoolOption.py +0 -50
  509. data/ext/v8/upstream/scons/engine/SCons/Options/EnumOption.py +0 -50
  510. data/ext/v8/upstream/scons/engine/SCons/Options/ListOption.py +0 -50
  511. data/ext/v8/upstream/scons/engine/SCons/Options/PackageOption.py +0 -50
  512. data/ext/v8/upstream/scons/engine/SCons/Options/PathOption.py +0 -76
  513. data/ext/v8/upstream/scons/engine/SCons/Options/__init__.py +0 -74
  514. data/ext/v8/upstream/scons/engine/SCons/PathList.py +0 -232
  515. data/ext/v8/upstream/scons/engine/SCons/Platform/__init__.py +0 -236
  516. data/ext/v8/upstream/scons/engine/SCons/Platform/aix.py +0 -70
  517. data/ext/v8/upstream/scons/engine/SCons/Platform/cygwin.py +0 -55
  518. data/ext/v8/upstream/scons/engine/SCons/Platform/darwin.py +0 -46
  519. data/ext/v8/upstream/scons/engine/SCons/Platform/hpux.py +0 -46
  520. data/ext/v8/upstream/scons/engine/SCons/Platform/irix.py +0 -44
  521. data/ext/v8/upstream/scons/engine/SCons/Platform/os2.py +0 -58
  522. data/ext/v8/upstream/scons/engine/SCons/Platform/posix.py +0 -264
  523. data/ext/v8/upstream/scons/engine/SCons/Platform/sunos.py +0 -50
  524. data/ext/v8/upstream/scons/engine/SCons/Platform/win32.py +0 -386
  525. data/ext/v8/upstream/scons/engine/SCons/SConf.py +0 -1038
  526. data/ext/v8/upstream/scons/engine/SCons/SConsign.py +0 -381
  527. data/ext/v8/upstream/scons/engine/SCons/Scanner/C.py +0 -132
  528. data/ext/v8/upstream/scons/engine/SCons/Scanner/D.py +0 -74
  529. data/ext/v8/upstream/scons/engine/SCons/Scanner/Dir.py +0 -111
  530. data/ext/v8/upstream/scons/engine/SCons/Scanner/Fortran.py +0 -320
  531. data/ext/v8/upstream/scons/engine/SCons/Scanner/IDL.py +0 -48
  532. data/ext/v8/upstream/scons/engine/SCons/Scanner/LaTeX.py +0 -378
  533. data/ext/v8/upstream/scons/engine/SCons/Scanner/Prog.py +0 -103
  534. data/ext/v8/upstream/scons/engine/SCons/Scanner/RC.py +0 -55
  535. data/ext/v8/upstream/scons/engine/SCons/Scanner/__init__.py +0 -415
  536. data/ext/v8/upstream/scons/engine/SCons/Script/Interactive.py +0 -386
  537. data/ext/v8/upstream/scons/engine/SCons/Script/Main.py +0 -1360
  538. data/ext/v8/upstream/scons/engine/SCons/Script/SConsOptions.py +0 -944
  539. data/ext/v8/upstream/scons/engine/SCons/Script/SConscript.py +0 -642
  540. data/ext/v8/upstream/scons/engine/SCons/Script/__init__.py +0 -414
  541. data/ext/v8/upstream/scons/engine/SCons/Sig.py +0 -63
  542. data/ext/v8/upstream/scons/engine/SCons/Subst.py +0 -911
  543. data/ext/v8/upstream/scons/engine/SCons/Taskmaster.py +0 -1030
  544. data/ext/v8/upstream/scons/engine/SCons/Tool/386asm.py +0 -61
  545. data/ext/v8/upstream/scons/engine/SCons/Tool/BitKeeper.py +0 -65
  546. data/ext/v8/upstream/scons/engine/SCons/Tool/CVS.py +0 -73
  547. data/ext/v8/upstream/scons/engine/SCons/Tool/FortranCommon.py +0 -247
  548. data/ext/v8/upstream/scons/engine/SCons/Tool/JavaCommon.py +0 -324
  549. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/__init__.py +0 -56
  550. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/arch.py +0 -61
  551. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/common.py +0 -210
  552. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/netframework.py +0 -84
  553. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/sdk.py +0 -321
  554. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vc.py +0 -367
  555. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vs.py +0 -497
  556. data/ext/v8/upstream/scons/engine/SCons/Tool/Perforce.py +0 -104
  557. data/ext/v8/upstream/scons/engine/SCons/Tool/PharLapCommon.py +0 -138
  558. data/ext/v8/upstream/scons/engine/SCons/Tool/RCS.py +0 -64
  559. data/ext/v8/upstream/scons/engine/SCons/Tool/SCCS.py +0 -64
  560. data/ext/v8/upstream/scons/engine/SCons/Tool/Subversion.py +0 -71
  561. data/ext/v8/upstream/scons/engine/SCons/Tool/__init__.py +0 -675
  562. data/ext/v8/upstream/scons/engine/SCons/Tool/aixc++.py +0 -82
  563. data/ext/v8/upstream/scons/engine/SCons/Tool/aixcc.py +0 -74
  564. data/ext/v8/upstream/scons/engine/SCons/Tool/aixf77.py +0 -80
  565. data/ext/v8/upstream/scons/engine/SCons/Tool/aixlink.py +0 -76
  566. data/ext/v8/upstream/scons/engine/SCons/Tool/applelink.py +0 -71
  567. data/ext/v8/upstream/scons/engine/SCons/Tool/ar.py +0 -63
  568. data/ext/v8/upstream/scons/engine/SCons/Tool/as.py +0 -78
  569. data/ext/v8/upstream/scons/engine/SCons/Tool/bcc32.py +0 -82
  570. data/ext/v8/upstream/scons/engine/SCons/Tool/c++.py +0 -99
  571. data/ext/v8/upstream/scons/engine/SCons/Tool/cc.py +0 -114
  572. data/ext/v8/upstream/scons/engine/SCons/Tool/cvf.py +0 -58
  573. data/ext/v8/upstream/scons/engine/SCons/Tool/default.py +0 -50
  574. data/ext/v8/upstream/scons/engine/SCons/Tool/dmd.py +0 -224
  575. data/ext/v8/upstream/scons/engine/SCons/Tool/dvi.py +0 -64
  576. data/ext/v8/upstream/scons/engine/SCons/Tool/dvipdf.py +0 -125
  577. data/ext/v8/upstream/scons/engine/SCons/Tool/dvips.py +0 -94
  578. data/ext/v8/upstream/scons/engine/SCons/Tool/f77.py +0 -62
  579. data/ext/v8/upstream/scons/engine/SCons/Tool/f90.py +0 -62
  580. data/ext/v8/upstream/scons/engine/SCons/Tool/f95.py +0 -63
  581. data/ext/v8/upstream/scons/engine/SCons/Tool/filesystem.py +0 -98
  582. data/ext/v8/upstream/scons/engine/SCons/Tool/fortran.py +0 -63
  583. data/ext/v8/upstream/scons/engine/SCons/Tool/g++.py +0 -90
  584. data/ext/v8/upstream/scons/engine/SCons/Tool/g77.py +0 -73
  585. data/ext/v8/upstream/scons/engine/SCons/Tool/gas.py +0 -53
  586. data/ext/v8/upstream/scons/engine/SCons/Tool/gcc.py +0 -80
  587. data/ext/v8/upstream/scons/engine/SCons/Tool/gfortran.py +0 -64
  588. data/ext/v8/upstream/scons/engine/SCons/Tool/gnulink.py +0 -63
  589. data/ext/v8/upstream/scons/engine/SCons/Tool/gs.py +0 -81
  590. data/ext/v8/upstream/scons/engine/SCons/Tool/hpc++.py +0 -85
  591. data/ext/v8/upstream/scons/engine/SCons/Tool/hpcc.py +0 -53
  592. data/ext/v8/upstream/scons/engine/SCons/Tool/hplink.py +0 -77
  593. data/ext/v8/upstream/scons/engine/SCons/Tool/icc.py +0 -59
  594. data/ext/v8/upstream/scons/engine/SCons/Tool/icl.py +0 -52
  595. data/ext/v8/upstream/scons/engine/SCons/Tool/ifl.py +0 -72
  596. data/ext/v8/upstream/scons/engine/SCons/Tool/ifort.py +0 -90
  597. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink.py +0 -59
  598. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink32.py +0 -60
  599. data/ext/v8/upstream/scons/engine/SCons/Tool/install.py +0 -229
  600. data/ext/v8/upstream/scons/engine/SCons/Tool/intelc.py +0 -490
  601. data/ext/v8/upstream/scons/engine/SCons/Tool/ipkg.py +0 -71
  602. data/ext/v8/upstream/scons/engine/SCons/Tool/jar.py +0 -110
  603. data/ext/v8/upstream/scons/engine/SCons/Tool/javac.py +0 -234
  604. data/ext/v8/upstream/scons/engine/SCons/Tool/javah.py +0 -138
  605. data/ext/v8/upstream/scons/engine/SCons/Tool/latex.py +0 -79
  606. data/ext/v8/upstream/scons/engine/SCons/Tool/lex.py +0 -99
  607. data/ext/v8/upstream/scons/engine/SCons/Tool/link.py +0 -121
  608. data/ext/v8/upstream/scons/engine/SCons/Tool/linkloc.py +0 -112
  609. data/ext/v8/upstream/scons/engine/SCons/Tool/m4.py +0 -63
  610. data/ext/v8/upstream/scons/engine/SCons/Tool/masm.py +0 -77
  611. data/ext/v8/upstream/scons/engine/SCons/Tool/midl.py +0 -90
  612. data/ext/v8/upstream/scons/engine/SCons/Tool/mingw.py +0 -159
  613. data/ext/v8/upstream/scons/engine/SCons/Tool/mslib.py +0 -64
  614. data/ext/v8/upstream/scons/engine/SCons/Tool/mslink.py +0 -266
  615. data/ext/v8/upstream/scons/engine/SCons/Tool/mssdk.py +0 -50
  616. data/ext/v8/upstream/scons/engine/SCons/Tool/msvc.py +0 -269
  617. data/ext/v8/upstream/scons/engine/SCons/Tool/msvs.py +0 -1439
  618. data/ext/v8/upstream/scons/engine/SCons/Tool/mwcc.py +0 -208
  619. data/ext/v8/upstream/scons/engine/SCons/Tool/mwld.py +0 -107
  620. data/ext/v8/upstream/scons/engine/SCons/Tool/nasm.py +0 -72
  621. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/__init__.py +0 -314
  622. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/ipk.py +0 -185
  623. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/msi.py +0 -526
  624. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/rpm.py +0 -367
  625. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_tarbz2.py +0 -43
  626. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_targz.py +0 -43
  627. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_zip.py +0 -43
  628. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/tarbz2.py +0 -44
  629. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/targz.py +0 -44
  630. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/zip.py +0 -44
  631. data/ext/v8/upstream/scons/engine/SCons/Tool/pdf.py +0 -78
  632. data/ext/v8/upstream/scons/engine/SCons/Tool/pdflatex.py +0 -83
  633. data/ext/v8/upstream/scons/engine/SCons/Tool/pdftex.py +0 -108
  634. data/ext/v8/upstream/scons/engine/SCons/Tool/qt.py +0 -336
  635. data/ext/v8/upstream/scons/engine/SCons/Tool/rmic.py +0 -121
  636. data/ext/v8/upstream/scons/engine/SCons/Tool/rpcgen.py +0 -70
  637. data/ext/v8/upstream/scons/engine/SCons/Tool/rpm.py +0 -132
  638. data/ext/v8/upstream/scons/engine/SCons/Tool/sgiar.py +0 -68
  639. data/ext/v8/upstream/scons/engine/SCons/Tool/sgic++.py +0 -58
  640. data/ext/v8/upstream/scons/engine/SCons/Tool/sgicc.py +0 -53
  641. data/ext/v8/upstream/scons/engine/SCons/Tool/sgilink.py +0 -63
  642. data/ext/v8/upstream/scons/engine/SCons/Tool/sunar.py +0 -67
  643. data/ext/v8/upstream/scons/engine/SCons/Tool/sunc++.py +0 -142
  644. data/ext/v8/upstream/scons/engine/SCons/Tool/suncc.py +0 -58
  645. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf77.py +0 -63
  646. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf90.py +0 -64
  647. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf95.py +0 -64
  648. data/ext/v8/upstream/scons/engine/SCons/Tool/sunlink.py +0 -77
  649. data/ext/v8/upstream/scons/engine/SCons/Tool/swig.py +0 -186
  650. data/ext/v8/upstream/scons/engine/SCons/Tool/tar.py +0 -73
  651. data/ext/v8/upstream/scons/engine/SCons/Tool/tex.py +0 -805
  652. data/ext/v8/upstream/scons/engine/SCons/Tool/textfile.py +0 -175
  653. data/ext/v8/upstream/scons/engine/SCons/Tool/tlib.py +0 -53
  654. data/ext/v8/upstream/scons/engine/SCons/Tool/wix.py +0 -100
  655. data/ext/v8/upstream/scons/engine/SCons/Tool/yacc.py +0 -131
  656. data/ext/v8/upstream/scons/engine/SCons/Tool/zip.py +0 -100
  657. data/ext/v8/upstream/scons/engine/SCons/Util.py +0 -1645
  658. data/ext/v8/upstream/scons/engine/SCons/Variables/BoolVariable.py +0 -91
  659. data/ext/v8/upstream/scons/engine/SCons/Variables/EnumVariable.py +0 -107
  660. data/ext/v8/upstream/scons/engine/SCons/Variables/ListVariable.py +0 -139
  661. data/ext/v8/upstream/scons/engine/SCons/Variables/PackageVariable.py +0 -109
  662. data/ext/v8/upstream/scons/engine/SCons/Variables/PathVariable.py +0 -147
  663. data/ext/v8/upstream/scons/engine/SCons/Variables/__init__.py +0 -317
  664. data/ext/v8/upstream/scons/engine/SCons/Warnings.py +0 -228
  665. data/ext/v8/upstream/scons/engine/SCons/__init__.py +0 -49
  666. data/ext/v8/upstream/scons/engine/SCons/compat/__init__.py +0 -302
  667. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_UserString.py +0 -98
  668. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_hashlib.py +0 -91
  669. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_itertools.py +0 -124
  670. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_optparse.py +0 -1725
  671. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets.py +0 -583
  672. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets15.py +0 -176
  673. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_shlex.py +0 -325
  674. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_subprocess.py +0 -1296
  675. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_textwrap.py +0 -382
  676. data/ext/v8/upstream/scons/engine/SCons/compat/builtins.py +0 -187
  677. data/ext/v8/upstream/scons/engine/SCons/cpp.py +0 -598
  678. data/ext/v8/upstream/scons/engine/SCons/dblite.py +0 -248
  679. data/ext/v8/upstream/scons/engine/SCons/exitfuncs.py +0 -77
  680. data/ext/v8/upstream/scons/os_spawnv_fix.diff +0 -83
  681. data/ext/v8/upstream/scons/scons-time.1 +0 -1017
  682. data/ext/v8/upstream/scons/scons.1 +0 -15179
  683. data/ext/v8/upstream/scons/sconsign.1 +0 -208
  684. data/ext/v8/upstream/scons/script/scons +0 -184
  685. data/ext/v8/upstream/scons/script/scons-time +0 -1529
  686. data/ext/v8/upstream/scons/script/scons.bat +0 -31
  687. data/ext/v8/upstream/scons/script/sconsign +0 -508
  688. data/ext/v8/upstream/scons/setup.cfg +0 -6
  689. data/ext/v8/upstream/scons/setup.py +0 -427
  690. data/ext/v8/v8.cpp +0 -89
  691. data/ext/v8/v8_cxt.cpp +0 -92
  692. data/ext/v8/v8_cxt.h +0 -20
  693. data/ext/v8/v8_func.cpp +0 -10
  694. data/ext/v8/v8_func.h +0 -11
  695. data/ext/v8/v8_msg.cpp +0 -54
  696. data/ext/v8/v8_msg.h +0 -18
  697. data/ext/v8/v8_obj.cpp +0 -52
  698. data/ext/v8/v8_obj.h +0 -13
  699. data/ext/v8/v8_ref.cpp +0 -26
  700. data/ext/v8/v8_ref.h +0 -31
  701. data/ext/v8/v8_script.cpp +0 -20
  702. data/ext/v8/v8_script.h +0 -8
  703. data/ext/v8/v8_standalone.cpp +0 -69
  704. data/ext/v8/v8_standalone.h +0 -31
  705. data/ext/v8/v8_str.cpp +0 -17
  706. data/ext/v8/v8_str.h +0 -9
  707. data/ext/v8/v8_template.cpp +0 -53
  708. data/ext/v8/v8_template.h +0 -13
  709. data/lib/v8/to.rb +0 -33
  710. data/lib/v8/v8.so +0 -0
  711. data/script/console +0 -10
  712. data/script/destroy +0 -14
  713. data/script/generate +0 -14
  714. data/spec/ext/cxt_spec.rb +0 -25
  715. data/spec/ext/obj_spec.rb +0 -13
  716. data/spec/redjs/jsapi_spec.rb +0 -405
  717. data/spec/redjs/tap.rb +0 -8
  718. data/spec/redjs_helper.rb +0 -3
  719. data/spec/spec.opts +0 -1
  720. data/spec/v8/to_spec.rb +0 -15
  721. data/tasks/rspec.rake +0 -21
@@ -1,15 +0,0 @@
1
- The author of this software is David M. Gay.
2
-
3
- Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
4
-
5
- Permission to use, copy, modify, and distribute this software for any
6
- purpose without fee is hereby granted, provided that this entire
7
- notice is included in all copies of any software which is or includes
8
- a copy or modification of this software and in all copies of the
9
- supporting documentation for such software.
10
-
11
- THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
12
- IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES
13
- ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
14
- MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
15
- PURPOSE.
@@ -1,3330 +0,0 @@
1
- /****************************************************************
2
- *
3
- * The author of this software is David M. Gay.
4
- *
5
- * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
6
- *
7
- * Permission to use, copy, modify, and distribute this software for any
8
- * purpose without fee is hereby granted, provided that this entire notice
9
- * is included in all copies of any software which is or includes a copy
10
- * or modification of this software and in all copies of the supporting
11
- * documentation for such software.
12
- *
13
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
14
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
15
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
16
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
17
- *
18
- ***************************************************************/
19
-
20
- /* Please send bug reports to David M. Gay (dmg at acm dot org,
21
- * with " at " changed at "@" and " dot " changed to "."). */
22
-
23
- /* On a machine with IEEE extended-precision registers, it is
24
- * necessary to specify double-precision (53-bit) rounding precision
25
- * before invoking strtod or dtoa. If the machine uses (the equivalent
26
- * of) Intel 80x87 arithmetic, the call
27
- * _control87(PC_53, MCW_PC);
28
- * does this with many compilers. Whether this or another call is
29
- * appropriate depends on the compiler; for this to work, it may be
30
- * necessary to #include "float.h" or another system-dependent header
31
- * file.
32
- */
33
-
34
- /* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
35
- *
36
- * This strtod returns a nearest machine number to the input decimal
37
- * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
38
- * broken by the IEEE round-even rule. Otherwise ties are broken by
39
- * biased rounding (add half and chop).
40
- *
41
- * Inspired loosely by William D. Clinger's paper "How to Read Floating
42
- * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
43
- *
44
- * Modifications:
45
- *
46
- * 1. We only require IEEE, IBM, or VAX double-precision
47
- * arithmetic (not IEEE double-extended).
48
- * 2. We get by with floating-point arithmetic in a case that
49
- * Clinger missed -- when we're computing d * 10^n
50
- * for a small integer d and the integer n is not too
51
- * much larger than 22 (the maximum integer k for which
52
- * we can represent 10^k exactly), we may be able to
53
- * compute (d*10^k) * 10^(e-k) with just one roundoff.
54
- * 3. Rather than a bit-at-a-time adjustment of the binary
55
- * result in the hard case, we use floating-point
56
- * arithmetic to determine the adjustment to within
57
- * one bit; only in really hard cases do we need to
58
- * compute a second residual.
59
- * 4. Because of 3., we don't need a large table of powers of 10
60
- * for ten-to-e (just some small tables, e.g. of 10^k
61
- * for 0 <= k <= 22).
62
- */
63
-
64
- /*
65
- * #define IEEE_8087 for IEEE-arithmetic machines where the least
66
- * significant byte has the lowest address.
67
- * #define IEEE_MC68k for IEEE-arithmetic machines where the most
68
- * significant byte has the lowest address.
69
- * #define Long int on machines with 32-bit ints and 64-bit longs.
70
- * #define IBM for IBM mainframe-style floating-point arithmetic.
71
- * #define VAX for VAX-style floating-point arithmetic (D_floating).
72
- * #define No_leftright to omit left-right logic in fast floating-point
73
- * computation of dtoa.
74
- * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
75
- * and strtod and dtoa should round accordingly.
76
- * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
77
- * and Honor_FLT_ROUNDS is not #defined.
78
- * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
79
- * that use extended-precision instructions to compute rounded
80
- * products and quotients) with IBM.
81
- * #define ROUND_BIASED for IEEE-format with biased rounding.
82
- * #define Inaccurate_Divide for IEEE-format with correctly rounded
83
- * products but inaccurate quotients, e.g., for Intel i860.
84
- * #define NO_LONG_LONG on machines that do not have a "long long"
85
- * integer type (of >= 64 bits). On such machines, you can
86
- * #define Just_16 to store 16 bits per 32-bit Long when doing
87
- * high-precision integer arithmetic. Whether this speeds things
88
- * up or slows things down depends on the machine and the number
89
- * being converted. If long long is available and the name is
90
- * something other than "long long", #define Llong to be the name,
91
- * and if "unsigned Llong" does not work as an unsigned version of
92
- * Llong, #define #ULLong to be the corresponding unsigned type.
93
- * #define KR_headers for old-style C function headers.
94
- * #define Bad_float_h if your system lacks a float.h or if it does not
95
- * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
96
- * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
97
- * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
98
- * if memory is available and otherwise does something you deem
99
- * appropriate. If MALLOC is undefined, malloc will be invoked
100
- * directly -- and assumed always to succeed.
101
- * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
102
- * memory allocations from a private pool of memory when possible.
103
- * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
104
- * unless #defined to be a different length. This default length
105
- * suffices to get rid of MALLOC calls except for unusual cases,
106
- * such as decimal-to-binary conversion of a very long string of
107
- * digits. The longest string dtoa can return is about 751 bytes
108
- * long. For conversions by strtod of strings of 800 digits and
109
- * all dtoa conversions in single-threaded executions with 8-byte
110
- * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
111
- * pointers, PRIVATE_MEM >= 7112 appears adequate.
112
- * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
113
- * Infinity and NaN (case insensitively). On some systems (e.g.,
114
- * some HP systems), it may be necessary to #define NAN_WORD0
115
- * appropriately -- to the most significant word of a quiet NaN.
116
- * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
117
- * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
118
- * strtod also accepts (case insensitively) strings of the form
119
- * NaN(x), where x is a string of hexadecimal digits and spaces;
120
- * if there is only one string of hexadecimal digits, it is taken
121
- * for the 52 fraction bits of the resulting NaN; if there are two
122
- * or more strings of hex digits, the first is for the high 20 bits,
123
- * the second and subsequent for the low 32 bits, with intervening
124
- * white space ignored; but if this results in none of the 52
125
- * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0
126
- * and NAN_WORD1 are used instead.
127
- * #define MULTIPLE_THREADS if the system offers preemptively scheduled
128
- * multiple threads. In this case, you must provide (or suitably
129
- * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
130
- * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
131
- * in pow5mult, ensures lazy evaluation of only one copy of high
132
- * powers of 5; omitting this lock would introduce a small
133
- * probability of wasting memory, but would otherwise be harmless.)
134
- * You must also invoke freedtoa(s) to free the value s returned by
135
- * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
136
- * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that
137
- * avoids underflows on inputs whose result does not underflow.
138
- * If you #define NO_IEEE_Scale on a machine that uses IEEE-format
139
- * floating-point numbers and flushes underflows to zero rather
140
- * than implementing gradual underflow, then you must also #define
141
- * Sudden_Underflow.
142
- * #define YES_ALIAS to permit aliasing certain double values with
143
- * arrays of ULongs. This leads to slightly better code with
144
- * some compilers and was always used prior to 19990916, but it
145
- * is not strictly legal and can cause trouble with aggressively
146
- * optimizing compilers (e.g., gcc 2.95.1 under -O2).
147
- * #define USE_LOCALE to use the current locale's decimal_point value.
148
- * #define SET_INEXACT if IEEE arithmetic is being used and extra
149
- * computation should be done to set the inexact flag when the
150
- * result is inexact and avoid setting inexact when the result
151
- * is exact. In this case, dtoa.c must be compiled in
152
- * an environment, perhaps provided by #include "dtoa.c" in a
153
- * suitable wrapper, that defines two functions,
154
- * int get_inexact(void);
155
- * void clear_inexact(void);
156
- * such that get_inexact() returns a nonzero value if the
157
- * inexact bit is already set, and clear_inexact() sets the
158
- * inexact bit to 0. When SET_INEXACT is #defined, strtod
159
- * also does extra computations to set the underflow and overflow
160
- * flags when appropriate (i.e., when the result is tiny and
161
- * inexact or when it is a numeric value rounded to +-infinity).
162
- * #define NO_ERRNO if strtod should not assign errno = ERANGE when
163
- * the result overflows to +-Infinity or underflows to 0.
164
- */
165
-
166
- #ifndef Long
167
- #define Long long
168
- #endif
169
- #ifndef ULong
170
- typedef unsigned Long ULong;
171
- #endif
172
-
173
- #ifdef DEBUG
174
- #include "stdio.h"
175
- #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
176
- #endif
177
-
178
- #include "stdlib.h"
179
- #include "string.h"
180
-
181
- #ifdef USE_LOCALE
182
- #include "locale.h"
183
- #endif
184
-
185
- #ifdef MALLOC
186
- #ifdef KR_headers
187
- extern char *MALLOC();
188
- #else
189
- extern void *MALLOC(size_t);
190
- #endif
191
- #else
192
- #define MALLOC malloc
193
- #endif
194
-
195
- #ifndef Omit_Private_Memory
196
- #ifndef PRIVATE_MEM
197
- #define PRIVATE_MEM 2304
198
- #endif
199
- #define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
200
- static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
201
- #endif
202
-
203
- #undef IEEE_Arith
204
- #undef Avoid_Underflow
205
- #ifdef IEEE_MC68k
206
- #define IEEE_Arith
207
- #endif
208
- #ifdef IEEE_8087
209
- #define IEEE_Arith
210
- #endif
211
-
212
- #include "errno.h"
213
-
214
- #ifdef Bad_float_h
215
-
216
- #ifdef IEEE_Arith
217
- #define DBL_DIG 15
218
- #define DBL_MAX_10_EXP 308
219
- #define DBL_MAX_EXP 1024
220
- #define FLT_RADIX 2
221
- #endif /*IEEE_Arith*/
222
-
223
- #ifdef IBM
224
- #define DBL_DIG 16
225
- #define DBL_MAX_10_EXP 75
226
- #define DBL_MAX_EXP 63
227
- #define FLT_RADIX 16
228
- #define DBL_MAX 7.2370055773322621e+75
229
- #endif
230
-
231
- #ifdef VAX
232
- #define DBL_DIG 16
233
- #define DBL_MAX_10_EXP 38
234
- #define DBL_MAX_EXP 127
235
- #define FLT_RADIX 2
236
- #define DBL_MAX 1.7014118346046923e+38
237
- #endif
238
-
239
- #ifndef LONG_MAX
240
- #define LONG_MAX 2147483647
241
- #endif
242
-
243
- #else /* ifndef Bad_float_h */
244
- #include "float.h"
245
- #endif /* Bad_float_h */
246
-
247
- #ifndef __MATH_H__
248
- #include "math.h"
249
- #endif
250
-
251
- #ifdef __cplusplus
252
- extern "C" {
253
- #endif
254
-
255
- #ifndef CONST
256
- #ifdef KR_headers
257
- #define CONST /* blank */
258
- #else
259
- #define CONST const
260
- #endif
261
- #endif
262
-
263
- #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
264
- Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
265
- #endif
266
-
267
- typedef union { double d; ULong L[2]; } U;
268
-
269
- #ifdef YES_ALIAS
270
- #define dval(x) x
271
- #ifdef IEEE_8087
272
- #define word0(x) ((ULong *)&x)[1]
273
- #define word1(x) ((ULong *)&x)[0]
274
- #else
275
- #define word0(x) ((ULong *)&x)[0]
276
- #define word1(x) ((ULong *)&x)[1]
277
- #endif
278
- #else
279
- #ifdef IEEE_8087
280
- #define word0(x) ((U*)&x)->L[1]
281
- #define word1(x) ((U*)&x)->L[0]
282
- #else
283
- #define word0(x) ((U*)&x)->L[0]
284
- #define word1(x) ((U*)&x)->L[1]
285
- #endif
286
- #define dval(x) ((U*)&x)->d
287
- #endif
288
-
289
- /* The following definition of Storeinc is appropriate for MIPS processors.
290
- * An alternative that might be better on some machines is
291
- * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
292
- */
293
- #if defined(IEEE_8087) + defined(VAX)
294
- #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
295
- ((unsigned short *)a)[0] = (unsigned short)c, a++)
296
- #else
297
- #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
298
- ((unsigned short *)a)[1] = (unsigned short)c, a++)
299
- #endif
300
-
301
- /* #define P DBL_MANT_DIG */
302
- /* Ten_pmax = floor(P*log(2)/log(5)) */
303
- /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
304
- /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
305
- /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
306
-
307
- #ifdef IEEE_Arith
308
- #define Exp_shift 20
309
- #define Exp_shift1 20
310
- #define Exp_msk1 0x100000
311
- #define Exp_msk11 0x100000
312
- #define Exp_mask 0x7ff00000
313
- #define P 53
314
- #define Bias 1023
315
- #define Emin (-1022)
316
- #define Exp_1 0x3ff00000
317
- #define Exp_11 0x3ff00000
318
- #define Ebits 11
319
- #define Frac_mask 0xfffff
320
- #define Frac_mask1 0xfffff
321
- #define Ten_pmax 22
322
- #define Bletch 0x10
323
- #define Bndry_mask 0xfffff
324
- #define Bndry_mask1 0xfffff
325
- #define LSB 1
326
- #define Sign_bit 0x80000000
327
- #define Log2P 1
328
- #define Tiny0 0
329
- #define Tiny1 1
330
- #define Quick_max 14
331
- #define Int_max 14
332
- #ifndef NO_IEEE_Scale
333
- #define Avoid_Underflow
334
- #ifdef Flush_Denorm /* debugging option */
335
- #undef Sudden_Underflow
336
- #endif
337
- #endif
338
-
339
- #ifndef Flt_Rounds
340
- #ifdef FLT_ROUNDS
341
- #define Flt_Rounds FLT_ROUNDS
342
- #else
343
- #define Flt_Rounds 1
344
- #endif
345
- #endif /*Flt_Rounds*/
346
-
347
- #ifdef Honor_FLT_ROUNDS
348
- #define Rounding rounding
349
- #undef Check_FLT_ROUNDS
350
- #define Check_FLT_ROUNDS
351
- #else
352
- #define Rounding Flt_Rounds
353
- #endif
354
-
355
- #else /* ifndef IEEE_Arith */
356
- #undef Check_FLT_ROUNDS
357
- #undef Honor_FLT_ROUNDS
358
- #undef SET_INEXACT
359
- #undef Sudden_Underflow
360
- #define Sudden_Underflow
361
- #ifdef IBM
362
- #undef Flt_Rounds
363
- #define Flt_Rounds 0
364
- #define Exp_shift 24
365
- #define Exp_shift1 24
366
- #define Exp_msk1 0x1000000
367
- #define Exp_msk11 0x1000000
368
- #define Exp_mask 0x7f000000
369
- #define P 14
370
- #define Bias 65
371
- #define Exp_1 0x41000000
372
- #define Exp_11 0x41000000
373
- #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
374
- #define Frac_mask 0xffffff
375
- #define Frac_mask1 0xffffff
376
- #define Bletch 4
377
- #define Ten_pmax 22
378
- #define Bndry_mask 0xefffff
379
- #define Bndry_mask1 0xffffff
380
- #define LSB 1
381
- #define Sign_bit 0x80000000
382
- #define Log2P 4
383
- #define Tiny0 0x100000
384
- #define Tiny1 0
385
- #define Quick_max 14
386
- #define Int_max 15
387
- #else /* VAX */
388
- #undef Flt_Rounds
389
- #define Flt_Rounds 1
390
- #define Exp_shift 23
391
- #define Exp_shift1 7
392
- #define Exp_msk1 0x80
393
- #define Exp_msk11 0x800000
394
- #define Exp_mask 0x7f80
395
- #define P 56
396
- #define Bias 129
397
- #define Exp_1 0x40800000
398
- #define Exp_11 0x4080
399
- #define Ebits 8
400
- #define Frac_mask 0x7fffff
401
- #define Frac_mask1 0xffff007f
402
- #define Ten_pmax 24
403
- #define Bletch 2
404
- #define Bndry_mask 0xffff007f
405
- #define Bndry_mask1 0xffff007f
406
- #define LSB 0x10000
407
- #define Sign_bit 0x8000
408
- #define Log2P 1
409
- #define Tiny0 0x80
410
- #define Tiny1 0
411
- #define Quick_max 15
412
- #define Int_max 15
413
- #endif /* IBM, VAX */
414
- #endif /* IEEE_Arith */
415
-
416
- #ifndef IEEE_Arith
417
- #define ROUND_BIASED
418
- #endif
419
-
420
- #ifdef RND_PRODQUOT
421
- #define rounded_product(a,b) a = rnd_prod(a, b)
422
- #define rounded_quotient(a,b) a = rnd_quot(a, b)
423
- #ifdef KR_headers
424
- extern double rnd_prod(), rnd_quot();
425
- #else
426
- extern double rnd_prod(double, double), rnd_quot(double, double);
427
- #endif
428
- #else
429
- #define rounded_product(a,b) a *= b
430
- #define rounded_quotient(a,b) a /= b
431
- #endif
432
-
433
- #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
434
- #define Big1 0xffffffff
435
-
436
- #ifndef Pack_32
437
- #define Pack_32
438
- #endif
439
-
440
- #ifdef KR_headers
441
- #define FFFFFFFF ((((unsigned long)0xffff)<<16)|(unsigned long)0xffff)
442
- #else
443
- #define FFFFFFFF 0xffffffffUL
444
- #endif
445
-
446
- #ifdef NO_LONG_LONG
447
- #undef ULLong
448
- #ifdef Just_16
449
- #undef Pack_32
450
- /* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
451
- * This makes some inner loops simpler and sometimes saves work
452
- * during multiplications, but it often seems to make things slightly
453
- * slower. Hence the default is now to store 32 bits per Long.
454
- */
455
- #endif
456
- #else /* long long available */
457
- #ifndef Llong
458
- #define Llong long long
459
- #endif
460
- #ifndef ULLong
461
- #define ULLong unsigned Llong
462
- #endif
463
- #endif /* NO_LONG_LONG */
464
-
465
- #ifndef MULTIPLE_THREADS
466
- #define ACQUIRE_DTOA_LOCK(n) /*nothing*/
467
- #define FREE_DTOA_LOCK(n) /*nothing*/
468
- #endif
469
-
470
- #define Kmax 15
471
-
472
- #ifdef __cplusplus
473
- extern "C" double strtod(const char *s00, char **se);
474
- extern "C" char *dtoa(double d, int mode, int ndigits,
475
- int *decpt, int *sign, char **rve);
476
- #endif
477
-
478
- struct
479
- Bigint {
480
- struct Bigint *next;
481
- int k, maxwds, sign, wds;
482
- ULong x[1];
483
- };
484
-
485
- typedef struct Bigint Bigint;
486
-
487
- static Bigint *freelist[Kmax+1];
488
-
489
- static Bigint *
490
- Balloc
491
- #ifdef KR_headers
492
- (k) int k;
493
- #else
494
- (int k)
495
- #endif
496
- {
497
- int x;
498
- Bigint *rv;
499
- #ifndef Omit_Private_Memory
500
- unsigned int len;
501
- #endif
502
-
503
- ACQUIRE_DTOA_LOCK(0);
504
- /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0). */
505
- /* but this case seems very unlikely. */
506
- if (k <= Kmax && (rv = freelist[k])) {
507
- freelist[k] = rv->next;
508
- }
509
- else {
510
- x = 1 << k;
511
- #ifdef Omit_Private_Memory
512
- rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
513
- #else
514
- len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
515
- /sizeof(double);
516
- if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
517
- rv = (Bigint*)pmem_next;
518
- pmem_next += len;
519
- }
520
- else
521
- rv = (Bigint*)MALLOC(len*sizeof(double));
522
- #endif
523
- rv->k = k;
524
- rv->maxwds = x;
525
- }
526
- FREE_DTOA_LOCK(0);
527
- rv->sign = rv->wds = 0;
528
- return rv;
529
- }
530
-
531
- static void
532
- Bfree
533
- #ifdef KR_headers
534
- (v) Bigint *v;
535
- #else
536
- (Bigint *v)
537
- #endif
538
- {
539
- if (v) {
540
- if (v->k > Kmax)
541
- free((void*)v);
542
- else {
543
- ACQUIRE_DTOA_LOCK(0);
544
- v->next = freelist[v->k];
545
- freelist[v->k] = v;
546
- FREE_DTOA_LOCK(0);
547
- }
548
- }
549
- }
550
-
551
- #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
552
- y->wds*sizeof(Long) + 2*sizeof(int))
553
-
554
- static Bigint *
555
- multadd
556
- #ifdef KR_headers
557
- (b, m, a) Bigint *b; int m, a;
558
- #else
559
- (Bigint *b, int m, int a) /* multiply by m and add a */
560
- #endif
561
- {
562
- int i, wds;
563
- #ifdef ULLong
564
- ULong *x;
565
- ULLong carry, y;
566
- #else
567
- ULong carry, *x, y;
568
- #ifdef Pack_32
569
- ULong xi, z;
570
- #endif
571
- #endif
572
- Bigint *b1;
573
-
574
- wds = b->wds;
575
- x = b->x;
576
- i = 0;
577
- carry = a;
578
- do {
579
- #ifdef ULLong
580
- y = *x * (ULLong)m + carry;
581
- carry = y >> 32;
582
- *x++ = y & FFFFFFFF;
583
- #else
584
- #ifdef Pack_32
585
- xi = *x;
586
- y = (xi & 0xffff) * m + carry;
587
- z = (xi >> 16) * m + (y >> 16);
588
- carry = z >> 16;
589
- *x++ = (z << 16) + (y & 0xffff);
590
- #else
591
- y = *x * m + carry;
592
- carry = y >> 16;
593
- *x++ = y & 0xffff;
594
- #endif
595
- #endif
596
- }
597
- while(++i < wds);
598
- if (carry) {
599
- if (wds >= b->maxwds) {
600
- b1 = Balloc(b->k+1);
601
- Bcopy(b1, b);
602
- Bfree(b);
603
- b = b1;
604
- }
605
- b->x[wds++] = carry;
606
- b->wds = wds;
607
- }
608
- return b;
609
- }
610
-
611
- static Bigint *
612
- s2b
613
- #ifdef KR_headers
614
- (s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9;
615
- #else
616
- (CONST char *s, int nd0, int nd, ULong y9)
617
- #endif
618
- {
619
- Bigint *b;
620
- int i, k;
621
- Long x, y;
622
-
623
- x = (nd + 8) / 9;
624
- for(k = 0, y = 1; x > y; y <<= 1, k++) ;
625
- #ifdef Pack_32
626
- b = Balloc(k);
627
- b->x[0] = y9;
628
- b->wds = 1;
629
- #else
630
- b = Balloc(k+1);
631
- b->x[0] = y9 & 0xffff;
632
- b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
633
- #endif
634
-
635
- i = 9;
636
- if (9 < nd0) {
637
- s += 9;
638
- do b = multadd(b, 10, *s++ - '0');
639
- while(++i < nd0);
640
- s++;
641
- }
642
- else
643
- s += 10;
644
- for(; i < nd; i++)
645
- b = multadd(b, 10, *s++ - '0');
646
- return b;
647
- }
648
-
649
- static int
650
- hi0bits
651
- #ifdef KR_headers
652
- (x) register ULong x;
653
- #else
654
- (register ULong x)
655
- #endif
656
- {
657
- register int k = 0;
658
-
659
- if (!(x & 0xffff0000)) {
660
- k = 16;
661
- x <<= 16;
662
- }
663
- if (!(x & 0xff000000)) {
664
- k += 8;
665
- x <<= 8;
666
- }
667
- if (!(x & 0xf0000000)) {
668
- k += 4;
669
- x <<= 4;
670
- }
671
- if (!(x & 0xc0000000)) {
672
- k += 2;
673
- x <<= 2;
674
- }
675
- if (!(x & 0x80000000)) {
676
- k++;
677
- if (!(x & 0x40000000))
678
- return 32;
679
- }
680
- return k;
681
- }
682
-
683
- static int
684
- lo0bits
685
- #ifdef KR_headers
686
- (y) ULong *y;
687
- #else
688
- (ULong *y)
689
- #endif
690
- {
691
- register int k;
692
- register ULong x = *y;
693
-
694
- if (x & 7) {
695
- if (x & 1)
696
- return 0;
697
- if (x & 2) {
698
- *y = x >> 1;
699
- return 1;
700
- }
701
- *y = x >> 2;
702
- return 2;
703
- }
704
- k = 0;
705
- if (!(x & 0xffff)) {
706
- k = 16;
707
- x >>= 16;
708
- }
709
- if (!(x & 0xff)) {
710
- k += 8;
711
- x >>= 8;
712
- }
713
- if (!(x & 0xf)) {
714
- k += 4;
715
- x >>= 4;
716
- }
717
- if (!(x & 0x3)) {
718
- k += 2;
719
- x >>= 2;
720
- }
721
- if (!(x & 1)) {
722
- k++;
723
- x >>= 1;
724
- if (!x)
725
- return 32;
726
- }
727
- *y = x;
728
- return k;
729
- }
730
-
731
- static Bigint *
732
- i2b
733
- #ifdef KR_headers
734
- (i) int i;
735
- #else
736
- (int i)
737
- #endif
738
- {
739
- Bigint *b;
740
-
741
- b = Balloc(1);
742
- b->x[0] = i;
743
- b->wds = 1;
744
- return b;
745
- }
746
-
747
- static Bigint *
748
- mult
749
- #ifdef KR_headers
750
- (a, b) Bigint *a, *b;
751
- #else
752
- (Bigint *a, Bigint *b)
753
- #endif
754
- {
755
- Bigint *c;
756
- int k, wa, wb, wc;
757
- ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
758
- ULong y;
759
- #ifdef ULLong
760
- ULLong carry, z;
761
- #else
762
- ULong carry, z;
763
- #ifdef Pack_32
764
- ULong z2;
765
- #endif
766
- #endif
767
-
768
- if (a->wds < b->wds) {
769
- c = a;
770
- a = b;
771
- b = c;
772
- }
773
- k = a->k;
774
- wa = a->wds;
775
- wb = b->wds;
776
- wc = wa + wb;
777
- if (wc > a->maxwds)
778
- k++;
779
- c = Balloc(k);
780
- for(x = c->x, xa = x + wc; x < xa; x++)
781
- *x = 0;
782
- xa = a->x;
783
- xae = xa + wa;
784
- xb = b->x;
785
- xbe = xb + wb;
786
- xc0 = c->x;
787
- #ifdef ULLong
788
- for(; xb < xbe; xc0++) {
789
- if ((y = *xb++)) {
790
- x = xa;
791
- xc = xc0;
792
- carry = 0;
793
- do {
794
- z = *x++ * (ULLong)y + *xc + carry;
795
- carry = z >> 32;
796
- *xc++ = z & FFFFFFFF;
797
- }
798
- while(x < xae);
799
- *xc = carry;
800
- }
801
- }
802
- #else
803
- #ifdef Pack_32
804
- for(; xb < xbe; xb++, xc0++) {
805
- if (y = *xb & 0xffff) {
806
- x = xa;
807
- xc = xc0;
808
- carry = 0;
809
- do {
810
- z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
811
- carry = z >> 16;
812
- z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
813
- carry = z2 >> 16;
814
- Storeinc(xc, z2, z);
815
- }
816
- while(x < xae);
817
- *xc = carry;
818
- }
819
- if (y = *xb >> 16) {
820
- x = xa;
821
- xc = xc0;
822
- carry = 0;
823
- z2 = *xc;
824
- do {
825
- z = (*x & 0xffff) * y + (*xc >> 16) + carry;
826
- carry = z >> 16;
827
- Storeinc(xc, z, z2);
828
- z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
829
- carry = z2 >> 16;
830
- }
831
- while(x < xae);
832
- *xc = z2;
833
- }
834
- }
835
- #else
836
- for(; xb < xbe; xc0++) {
837
- if (y = *xb++) {
838
- x = xa;
839
- xc = xc0;
840
- carry = 0;
841
- do {
842
- z = *x++ * y + *xc + carry;
843
- carry = z >> 16;
844
- *xc++ = z & 0xffff;
845
- }
846
- while(x < xae);
847
- *xc = carry;
848
- }
849
- }
850
- #endif
851
- #endif
852
- for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
853
- c->wds = wc;
854
- return c;
855
- }
856
-
857
- static Bigint *p5s;
858
-
859
- static Bigint *
860
- pow5mult
861
- #ifdef KR_headers
862
- (b, k) Bigint *b; int k;
863
- #else
864
- (Bigint *b, int k)
865
- #endif
866
- {
867
- Bigint *b1, *p5, *p51;
868
- int i;
869
- static int p05[3] = { 5, 25, 125 };
870
-
871
- if ((i = k & 3))
872
- b = multadd(b, p05[i-1], 0);
873
-
874
- if (!(k >>= 2))
875
- return b;
876
- if (!(p5 = p5s)) {
877
- /* first time */
878
- #ifdef MULTIPLE_THREADS
879
- ACQUIRE_DTOA_LOCK(1);
880
- if (!(p5 = p5s)) {
881
- p5 = p5s = i2b(625);
882
- p5->next = 0;
883
- }
884
- FREE_DTOA_LOCK(1);
885
- #else
886
- p5 = p5s = i2b(625);
887
- p5->next = 0;
888
- #endif
889
- }
890
- for(;;) {
891
- if (k & 1) {
892
- b1 = mult(b, p5);
893
- Bfree(b);
894
- b = b1;
895
- }
896
- if (!(k >>= 1))
897
- break;
898
- if (!(p51 = p5->next)) {
899
- #ifdef MULTIPLE_THREADS
900
- ACQUIRE_DTOA_LOCK(1);
901
- if (!(p51 = p5->next)) {
902
- p51 = p5->next = mult(p5,p5);
903
- p51->next = 0;
904
- }
905
- FREE_DTOA_LOCK(1);
906
- #else
907
- p51 = p5->next = mult(p5,p5);
908
- p51->next = 0;
909
- #endif
910
- }
911
- p5 = p51;
912
- }
913
- return b;
914
- }
915
-
916
- static Bigint *
917
- lshift
918
- #ifdef KR_headers
919
- (b, k) Bigint *b; int k;
920
- #else
921
- (Bigint *b, int k)
922
- #endif
923
- {
924
- int i, k1, n, n1;
925
- Bigint *b1;
926
- ULong *x, *x1, *xe, z;
927
-
928
- #ifdef Pack_32
929
- n = k >> 5;
930
- #else
931
- n = k >> 4;
932
- #endif
933
- k1 = b->k;
934
- n1 = n + b->wds + 1;
935
- for(i = b->maxwds; n1 > i; i <<= 1)
936
- k1++;
937
- b1 = Balloc(k1);
938
- x1 = b1->x;
939
- for(i = 0; i < n; i++)
940
- *x1++ = 0;
941
- x = b->x;
942
- xe = x + b->wds;
943
- #ifdef Pack_32
944
- if (k &= 0x1f) {
945
- k1 = 32 - k;
946
- z = 0;
947
- do {
948
- *x1++ = *x << k | z;
949
- z = *x++ >> k1;
950
- }
951
- while(x < xe);
952
- if ((*x1 = z))
953
- ++n1;
954
- }
955
- #else
956
- if (k &= 0xf) {
957
- k1 = 16 - k;
958
- z = 0;
959
- do {
960
- *x1++ = *x << k & 0xffff | z;
961
- z = *x++ >> k1;
962
- }
963
- while(x < xe);
964
- if (*x1 = z)
965
- ++n1;
966
- }
967
- #endif
968
- else do
969
- *x1++ = *x++;
970
- while(x < xe);
971
- b1->wds = n1 - 1;
972
- Bfree(b);
973
- return b1;
974
- }
975
-
976
- static int
977
- cmp
978
- #ifdef KR_headers
979
- (a, b) Bigint *a, *b;
980
- #else
981
- (Bigint *a, Bigint *b)
982
- #endif
983
- {
984
- ULong *xa, *xa0, *xb, *xb0;
985
- int i, j;
986
-
987
- i = a->wds;
988
- j = b->wds;
989
- #ifdef DEBUG
990
- if (i > 1 && !a->x[i-1])
991
- Bug("cmp called with a->x[a->wds-1] == 0");
992
- if (j > 1 && !b->x[j-1])
993
- Bug("cmp called with b->x[b->wds-1] == 0");
994
- #endif
995
- if (i -= j)
996
- return i;
997
- xa0 = a->x;
998
- xa = xa0 + j;
999
- xb0 = b->x;
1000
- xb = xb0 + j;
1001
- for(;;) {
1002
- if (*--xa != *--xb)
1003
- return *xa < *xb ? -1 : 1;
1004
- if (xa <= xa0)
1005
- break;
1006
- }
1007
- return 0;
1008
- }
1009
-
1010
- static Bigint *
1011
- diff
1012
- #ifdef KR_headers
1013
- (a, b) Bigint *a, *b;
1014
- #else
1015
- (Bigint *a, Bigint *b)
1016
- #endif
1017
- {
1018
- Bigint *c;
1019
- int i, wa, wb;
1020
- ULong *xa, *xae, *xb, *xbe, *xc;
1021
- #ifdef ULLong
1022
- ULLong borrow, y;
1023
- #else
1024
- ULong borrow, y;
1025
- #ifdef Pack_32
1026
- ULong z;
1027
- #endif
1028
- #endif
1029
-
1030
- i = cmp(a,b);
1031
- if (!i) {
1032
- c = Balloc(0);
1033
- c->wds = 1;
1034
- c->x[0] = 0;
1035
- return c;
1036
- }
1037
- if (i < 0) {
1038
- c = a;
1039
- a = b;
1040
- b = c;
1041
- i = 1;
1042
- }
1043
- else
1044
- i = 0;
1045
- c = Balloc(a->k);
1046
- c->sign = i;
1047
- wa = a->wds;
1048
- xa = a->x;
1049
- xae = xa + wa;
1050
- wb = b->wds;
1051
- xb = b->x;
1052
- xbe = xb + wb;
1053
- xc = c->x;
1054
- borrow = 0;
1055
- #ifdef ULLong
1056
- do {
1057
- y = (ULLong)*xa++ - *xb++ - borrow;
1058
- borrow = y >> 32 & (ULong)1;
1059
- *xc++ = y & FFFFFFFF;
1060
- }
1061
- while(xb < xbe);
1062
- while(xa < xae) {
1063
- y = *xa++ - borrow;
1064
- borrow = y >> 32 & (ULong)1;
1065
- *xc++ = y & FFFFFFFF;
1066
- }
1067
- #else
1068
- #ifdef Pack_32
1069
- do {
1070
- y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
1071
- borrow = (y & 0x10000) >> 16;
1072
- z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
1073
- borrow = (z & 0x10000) >> 16;
1074
- Storeinc(xc, z, y);
1075
- }
1076
- while(xb < xbe);
1077
- while(xa < xae) {
1078
- y = (*xa & 0xffff) - borrow;
1079
- borrow = (y & 0x10000) >> 16;
1080
- z = (*xa++ >> 16) - borrow;
1081
- borrow = (z & 0x10000) >> 16;
1082
- Storeinc(xc, z, y);
1083
- }
1084
- #else
1085
- do {
1086
- y = *xa++ - *xb++ - borrow;
1087
- borrow = (y & 0x10000) >> 16;
1088
- *xc++ = y & 0xffff;
1089
- }
1090
- while(xb < xbe);
1091
- while(xa < xae) {
1092
- y = *xa++ - borrow;
1093
- borrow = (y & 0x10000) >> 16;
1094
- *xc++ = y & 0xffff;
1095
- }
1096
- #endif
1097
- #endif
1098
- while(!*--xc)
1099
- wa--;
1100
- c->wds = wa;
1101
- return c;
1102
- }
1103
-
1104
- static double
1105
- ulp
1106
- #ifdef KR_headers
1107
- (x) double x;
1108
- #else
1109
- (double x)
1110
- #endif
1111
- {
1112
- register Long L;
1113
- double a;
1114
-
1115
- L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
1116
- #ifndef Avoid_Underflow
1117
- #ifndef Sudden_Underflow
1118
- if (L > 0) {
1119
- #endif
1120
- #endif
1121
- #ifdef IBM
1122
- L |= Exp_msk1 >> 4;
1123
- #endif
1124
- word0(a) = L;
1125
- word1(a) = 0;
1126
- #ifndef Avoid_Underflow
1127
- #ifndef Sudden_Underflow
1128
- }
1129
- else {
1130
- L = -L >> Exp_shift;
1131
- if (L < Exp_shift) {
1132
- word0(a) = 0x80000 >> L;
1133
- word1(a) = 0;
1134
- }
1135
- else {
1136
- word0(a) = 0;
1137
- L -= Exp_shift;
1138
- word1(a) = L >= 31 ? 1 : 1 << 31 - L;
1139
- }
1140
- }
1141
- #endif
1142
- #endif
1143
- return dval(a);
1144
- }
1145
-
1146
- static double
1147
- b2d
1148
- #ifdef KR_headers
1149
- (a, e) Bigint *a; int *e;
1150
- #else
1151
- (Bigint *a, int *e)
1152
- #endif
1153
- {
1154
- ULong *xa, *xa0, w, y, z;
1155
- int k;
1156
- double d;
1157
- #ifdef VAX
1158
- ULong d0, d1;
1159
- #else
1160
- #define d0 word0(d)
1161
- #define d1 word1(d)
1162
- #endif
1163
-
1164
- xa0 = a->x;
1165
- xa = xa0 + a->wds;
1166
- y = *--xa;
1167
- #ifdef DEBUG
1168
- if (!y) Bug("zero y in b2d");
1169
- #endif
1170
- k = hi0bits(y);
1171
- *e = 32 - k;
1172
- #ifdef Pack_32
1173
- if (k < Ebits) {
1174
- d0 = Exp_1 | (y >> (Ebits - k));
1175
- w = xa > xa0 ? *--xa : 0;
1176
- d1 = (y << ((32-Ebits) + k)) | (w >> (Ebits - k));
1177
- goto ret_d;
1178
- }
1179
- z = xa > xa0 ? *--xa : 0;
1180
- if (k -= Ebits) {
1181
- d0 = Exp_1 | (y << k) | (z >> (32 - k));
1182
- y = xa > xa0 ? *--xa : 0;
1183
- d1 = (z << k) | (y >> (32 - k));
1184
- }
1185
- else {
1186
- d0 = Exp_1 | y;
1187
- d1 = z;
1188
- }
1189
- #else
1190
- if (k < Ebits + 16) {
1191
- z = xa > xa0 ? *--xa : 0;
1192
- d0 = Exp_1 | (y << (k - Ebits)) | (z >> (Ebits + 16 - k));
1193
- w = xa > xa0 ? *--xa : 0;
1194
- y = xa > xa0 ? *--xa : 0;
1195
- d1 = (z << (k + 16 - Ebits)) | (w << (k - Ebits)) | (y >> (16 + Ebits - k));
1196
- goto ret_d;
1197
- }
1198
- z = xa > xa0 ? *--xa : 0;
1199
- w = xa > xa0 ? *--xa : 0;
1200
- k -= Ebits + 16;
1201
- d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
1202
- y = xa > xa0 ? *--xa : 0;
1203
- d1 = w << k + 16 | y << k;
1204
- #endif
1205
- ret_d:
1206
- #ifdef VAX
1207
- word0(d) = d0 >> 16 | d0 << 16;
1208
- word1(d) = d1 >> 16 | d1 << 16;
1209
- #else
1210
- #undef d0
1211
- #undef d1
1212
- #endif
1213
- return dval(d);
1214
- }
1215
-
1216
- static Bigint *
1217
- d2b
1218
- #ifdef KR_headers
1219
- (d, e, bits) double d; int *e, *bits;
1220
- #else
1221
- (double d, int *e, int *bits)
1222
- #endif
1223
- {
1224
- Bigint *b;
1225
- int de, k;
1226
- ULong *x, y, z;
1227
- #ifndef Sudden_Underflow
1228
- int i;
1229
- #endif
1230
- #ifdef VAX
1231
- ULong d0, d1;
1232
- d0 = word0(d) >> 16 | word0(d) << 16;
1233
- d1 = word1(d) >> 16 | word1(d) << 16;
1234
- #else
1235
- #define d0 word0(d)
1236
- #define d1 word1(d)
1237
- #endif
1238
-
1239
- #ifdef Pack_32
1240
- b = Balloc(1);
1241
- #else
1242
- b = Balloc(2);
1243
- #endif
1244
- x = b->x;
1245
-
1246
- z = d0 & Frac_mask;
1247
- d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
1248
- #ifdef Sudden_Underflow
1249
- de = (int)(d0 >> Exp_shift);
1250
- #ifndef IBM
1251
- z |= Exp_msk11;
1252
- #endif
1253
- #else
1254
- if ((de = (int)(d0 >> Exp_shift)))
1255
- z |= Exp_msk1;
1256
- #endif
1257
- #ifdef Pack_32
1258
- if ((y = d1)) {
1259
- if ((k = lo0bits(&y))) {
1260
- x[0] = y | (z << (32 - k));
1261
- z >>= k;
1262
- }
1263
- else
1264
- x[0] = y;
1265
- #ifndef Sudden_Underflow
1266
- i =
1267
- #endif
1268
- b->wds = (x[1] = z) ? 2 : 1;
1269
- }
1270
- else {
1271
- /* This assertion fails for "1e-500" and other very
1272
- * small numbers. It provides the right result (0)
1273
- * though. This assert has also been removed from KJS's
1274
- * version of dtoa.c.
1275
- *
1276
- * #ifdef DEBUG
1277
- * if (!z) Bug("zero z in b2d");
1278
- * #endif
1279
- */
1280
- k = lo0bits(&z);
1281
- x[0] = z;
1282
- #ifndef Sudden_Underflow
1283
- i =
1284
- #endif
1285
- b->wds = 1;
1286
- k += 32;
1287
- }
1288
- #else
1289
- if (y = d1) {
1290
- if (k = lo0bits(&y))
1291
- if (k >= 16) {
1292
- x[0] = y | z << 32 - k & 0xffff;
1293
- x[1] = z >> k - 16 & 0xffff;
1294
- x[2] = z >> k;
1295
- i = 2;
1296
- }
1297
- else {
1298
- x[0] = y & 0xffff;
1299
- x[1] = y >> 16 | z << 16 - k & 0xffff;
1300
- x[2] = z >> k & 0xffff;
1301
- x[3] = z >> k+16;
1302
- i = 3;
1303
- }
1304
- else {
1305
- x[0] = y & 0xffff;
1306
- x[1] = y >> 16;
1307
- x[2] = z & 0xffff;
1308
- x[3] = z >> 16;
1309
- i = 3;
1310
- }
1311
- }
1312
- else {
1313
- #ifdef DEBUG
1314
- if (!z)
1315
- Bug("Zero passed to d2b");
1316
- #endif
1317
- k = lo0bits(&z);
1318
- if (k >= 16) {
1319
- x[0] = z;
1320
- i = 0;
1321
- }
1322
- else {
1323
- x[0] = z & 0xffff;
1324
- x[1] = z >> 16;
1325
- i = 1;
1326
- }
1327
- k += 32;
1328
- }
1329
- while(!x[i])
1330
- --i;
1331
- b->wds = i + 1;
1332
- #endif
1333
- #ifndef Sudden_Underflow
1334
- if (de) {
1335
- #endif
1336
- #ifdef IBM
1337
- *e = (de - Bias - (P-1) << 2) + k;
1338
- *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
1339
- #else
1340
- *e = de - Bias - (P-1) + k;
1341
- *bits = P - k;
1342
- #endif
1343
- #ifndef Sudden_Underflow
1344
- }
1345
- else {
1346
- *e = de - Bias - (P-1) + 1 + k;
1347
- #ifdef Pack_32
1348
- *bits = 32*i - hi0bits(x[i-1]);
1349
- #else
1350
- *bits = (i+2)*16 - hi0bits(x[i]);
1351
- #endif
1352
- }
1353
- #endif
1354
- return b;
1355
- }
1356
- #undef d0
1357
- #undef d1
1358
-
1359
- static double
1360
- ratio
1361
- #ifdef KR_headers
1362
- (a, b) Bigint *a, *b;
1363
- #else
1364
- (Bigint *a, Bigint *b)
1365
- #endif
1366
- {
1367
- double da, db;
1368
- int k, ka, kb;
1369
-
1370
- dval(da) = b2d(a, &ka);
1371
- dval(db) = b2d(b, &kb);
1372
- #ifdef Pack_32
1373
- k = ka - kb + 32*(a->wds - b->wds);
1374
- #else
1375
- k = ka - kb + 16*(a->wds - b->wds);
1376
- #endif
1377
- #ifdef IBM
1378
- if (k > 0) {
1379
- word0(da) += (k >> 2)*Exp_msk1;
1380
- if (k &= 3)
1381
- dval(da) *= 1 << k;
1382
- }
1383
- else {
1384
- k = -k;
1385
- word0(db) += (k >> 2)*Exp_msk1;
1386
- if (k &= 3)
1387
- dval(db) *= 1 << k;
1388
- }
1389
- #else
1390
- if (k > 0)
1391
- word0(da) += k*Exp_msk1;
1392
- else {
1393
- k = -k;
1394
- word0(db) += k*Exp_msk1;
1395
- }
1396
- #endif
1397
- return dval(da) / dval(db);
1398
- }
1399
-
1400
- static CONST double
1401
- tens[] = {
1402
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1403
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1404
- 1e20, 1e21, 1e22
1405
- #ifdef VAX
1406
- , 1e23, 1e24
1407
- #endif
1408
- };
1409
-
1410
- static CONST double
1411
- #ifdef IEEE_Arith
1412
- bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
1413
- static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
1414
- #ifdef Avoid_Underflow
1415
- 9007199254740992.*9007199254740992.e-256
1416
- /* = 2^106 * 1e-53 */
1417
- #else
1418
- 1e-256
1419
- #endif
1420
- };
1421
- /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
1422
- /* flag unnecessarily. It leads to a song and dance at the end of strtod. */
1423
- #define Scale_Bit 0x10
1424
- #define n_bigtens 5
1425
- #else
1426
- #ifdef IBM
1427
- bigtens[] = { 1e16, 1e32, 1e64 };
1428
- static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };
1429
- #define n_bigtens 3
1430
- #else
1431
- bigtens[] = { 1e16, 1e32 };
1432
- static CONST double tinytens[] = { 1e-16, 1e-32 };
1433
- #define n_bigtens 2
1434
- #endif
1435
- #endif
1436
-
1437
- #ifndef IEEE_Arith
1438
- #undef INFNAN_CHECK
1439
- #endif
1440
-
1441
- #ifdef INFNAN_CHECK
1442
-
1443
- #ifndef NAN_WORD0
1444
- #define NAN_WORD0 0x7ff80000
1445
- #endif
1446
-
1447
- #ifndef NAN_WORD1
1448
- #define NAN_WORD1 0
1449
- #endif
1450
-
1451
- static int
1452
- match
1453
- #ifdef KR_headers
1454
- (sp, t) char **sp, *t;
1455
- #else
1456
- (CONST char **sp, char *t)
1457
- #endif
1458
- {
1459
- int c, d;
1460
- CONST char *s = *sp;
1461
-
1462
- while(d = *t++) {
1463
- if ((c = *++s) >= 'A' && c <= 'Z')
1464
- c += 'a' - 'A';
1465
- if (c != d)
1466
- return 0;
1467
- }
1468
- *sp = s + 1;
1469
- return 1;
1470
- }
1471
-
1472
- #ifndef No_Hex_NaN
1473
- static void
1474
- hexnan
1475
- #ifdef KR_headers
1476
- (rvp, sp) double *rvp; CONST char **sp;
1477
- #else
1478
- (double *rvp, CONST char **sp)
1479
- #endif
1480
- {
1481
- ULong c, x[2];
1482
- CONST char *s;
1483
- int havedig, udx0, xshift;
1484
-
1485
- x[0] = x[1] = 0;
1486
- havedig = xshift = 0;
1487
- udx0 = 1;
1488
- s = *sp;
1489
- while(c = *(CONST unsigned char*)++s) {
1490
- if (c >= '0' && c <= '9')
1491
- c -= '0';
1492
- else if (c >= 'a' && c <= 'f')
1493
- c += 10 - 'a';
1494
- else if (c >= 'A' && c <= 'F')
1495
- c += 10 - 'A';
1496
- else if (c <= ' ') {
1497
- if (udx0 && havedig) {
1498
- udx0 = 0;
1499
- xshift = 1;
1500
- }
1501
- continue;
1502
- }
1503
- else if (/*(*/ c == ')' && havedig) {
1504
- *sp = s + 1;
1505
- break;
1506
- }
1507
- else
1508
- return; /* invalid form: don't change *sp */
1509
- havedig = 1;
1510
- if (xshift) {
1511
- xshift = 0;
1512
- x[0] = x[1];
1513
- x[1] = 0;
1514
- }
1515
- if (udx0)
1516
- x[0] = (x[0] << 4) | (x[1] >> 28);
1517
- x[1] = (x[1] << 4) | c;
1518
- }
1519
- if ((x[0] &= 0xfffff) || x[1]) {
1520
- word0(*rvp) = Exp_mask | x[0];
1521
- word1(*rvp) = x[1];
1522
- }
1523
- }
1524
- #endif /*No_Hex_NaN*/
1525
- #endif /* INFNAN_CHECK */
1526
-
1527
- double
1528
- strtod
1529
- #ifdef KR_headers
1530
- (s00, se) CONST char *s00; char **se;
1531
- #else
1532
- (CONST char *s00, char **se)
1533
- #endif
1534
- {
1535
- #ifdef Avoid_Underflow
1536
- int scale;
1537
- #endif
1538
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
1539
- e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
1540
- CONST char *s, *s0, *s1;
1541
- double aadj, aadj1, adj, rv, rv0;
1542
- Long L;
1543
- ULong y, z;
1544
- Bigint *bb = NULL, *bb1, *bd = NULL, *bd0, *bs = NULL, *delta = NULL;
1545
- #ifdef SET_INEXACT
1546
- int inexact, oldinexact;
1547
- #endif
1548
- #ifdef Honor_FLT_ROUNDS
1549
- int rounding;
1550
- #endif
1551
- #ifdef USE_LOCALE
1552
- CONST char *s2;
1553
- #endif
1554
-
1555
- sign = nz0 = nz = 0;
1556
- dval(rv) = 0.;
1557
- for(s = s00;;s++) switch(*s) {
1558
- case '-':
1559
- sign = 1;
1560
- /* no break */
1561
- case '+':
1562
- if (*++s)
1563
- goto break2;
1564
- /* no break */
1565
- case 0:
1566
- goto ret0;
1567
- case '\t':
1568
- case '\n':
1569
- case '\v':
1570
- case '\f':
1571
- case '\r':
1572
- case ' ':
1573
- continue;
1574
- default:
1575
- goto break2;
1576
- }
1577
- break2:
1578
- if (*s == '0') {
1579
- nz0 = 1;
1580
- while(*++s == '0') ;
1581
- if (!*s)
1582
- goto ret;
1583
- }
1584
- s0 = s;
1585
- y = z = 0;
1586
- for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
1587
- if (nd < 9)
1588
- y = 10*y + c - '0';
1589
- else if (nd < 16)
1590
- z = 10*z + c - '0';
1591
- nd0 = nd;
1592
- #ifdef USE_LOCALE
1593
- s1 = localeconv()->decimal_point;
1594
- if (c == *s1) {
1595
- c = '.';
1596
- if (*++s1) {
1597
- s2 = s;
1598
- for(;;) {
1599
- if (*++s2 != *s1) {
1600
- c = 0;
1601
- break;
1602
- }
1603
- if (!*++s1) {
1604
- s = s2;
1605
- break;
1606
- }
1607
- }
1608
- }
1609
- }
1610
- #endif
1611
- if (c == '.') {
1612
- c = *++s;
1613
- if (!nd) {
1614
- for(; c == '0'; c = *++s)
1615
- nz++;
1616
- if (c > '0' && c <= '9') {
1617
- s0 = s;
1618
- nf += nz;
1619
- nz = 0;
1620
- goto have_dig;
1621
- }
1622
- goto dig_done;
1623
- }
1624
- for(; c >= '0' && c <= '9'; c = *++s) {
1625
- have_dig:
1626
- nz++;
1627
- if (c -= '0') {
1628
- nf += nz;
1629
- for(i = 1; i < nz; i++)
1630
- if (nd++ < 9)
1631
- y *= 10;
1632
- else if (nd <= DBL_DIG + 1)
1633
- z *= 10;
1634
- if (nd++ < 9)
1635
- y = 10*y + c;
1636
- else if (nd <= DBL_DIG + 1)
1637
- z = 10*z + c;
1638
- nz = 0;
1639
- }
1640
- }
1641
- }
1642
- dig_done:
1643
- e = 0;
1644
- if (c == 'e' || c == 'E') {
1645
- if (!nd && !nz && !nz0) {
1646
- goto ret0;
1647
- }
1648
- s00 = s;
1649
- esign = 0;
1650
- switch(c = *++s) {
1651
- case '-':
1652
- esign = 1;
1653
- case '+':
1654
- c = *++s;
1655
- }
1656
- if (c >= '0' && c <= '9') {
1657
- while(c == '0')
1658
- c = *++s;
1659
- if (c > '0' && c <= '9') {
1660
- L = c - '0';
1661
- s1 = s;
1662
- while((c = *++s) >= '0' && c <= '9')
1663
- L = 10*L + c - '0';
1664
- if (s - s1 > 8 || L > 19999)
1665
- /* Avoid confusion from exponents
1666
- * so large that e might overflow.
1667
- */
1668
- e = 19999; /* safe for 16 bit ints */
1669
- else
1670
- e = (int)L;
1671
- if (esign)
1672
- e = -e;
1673
- }
1674
- else
1675
- e = 0;
1676
- }
1677
- else
1678
- s = s00;
1679
- }
1680
- if (!nd) {
1681
- if (!nz && !nz0) {
1682
- #ifdef INFNAN_CHECK
1683
- /* Check for Nan and Infinity */
1684
- switch(c) {
1685
- case 'i':
1686
- case 'I':
1687
- if (match(&s,"nf")) {
1688
- --s;
1689
- if (!match(&s,"inity"))
1690
- ++s;
1691
- word0(rv) = 0x7ff00000;
1692
- word1(rv) = 0;
1693
- goto ret;
1694
- }
1695
- break;
1696
- case 'n':
1697
- case 'N':
1698
- if (match(&s, "an")) {
1699
- word0(rv) = NAN_WORD0;
1700
- word1(rv) = NAN_WORD1;
1701
- #ifndef No_Hex_NaN
1702
- if (*s == '(') /*)*/
1703
- hexnan(&rv, &s);
1704
- #endif
1705
- goto ret;
1706
- }
1707
- }
1708
- #endif /* INFNAN_CHECK */
1709
- ret0:
1710
- s = s00;
1711
- sign = 0;
1712
- }
1713
- goto ret;
1714
- }
1715
- e1 = e -= nf;
1716
-
1717
- /* Now we have nd0 digits, starting at s0, followed by a
1718
- * decimal point, followed by nd-nd0 digits. The number we're
1719
- * after is the integer represented by those digits times
1720
- * 10**e */
1721
-
1722
- if (!nd0)
1723
- nd0 = nd;
1724
- k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
1725
- dval(rv) = y;
1726
- if (k > 9) {
1727
- #ifdef SET_INEXACT
1728
- if (k > DBL_DIG)
1729
- oldinexact = get_inexact();
1730
- #endif
1731
- dval(rv) = tens[k - 9] * dval(rv) + z;
1732
- }
1733
- bd0 = 0;
1734
- if (nd <= DBL_DIG
1735
- #ifndef RND_PRODQUOT
1736
- #ifndef Honor_FLT_ROUNDS
1737
- && Flt_Rounds == 1
1738
- #endif
1739
- #endif
1740
- ) {
1741
- if (!e)
1742
- goto ret;
1743
- if (e > 0) {
1744
- if (e <= Ten_pmax) {
1745
- #ifdef VAX
1746
- goto vax_ovfl_check;
1747
- #else
1748
- #ifdef Honor_FLT_ROUNDS
1749
- /* round correctly FLT_ROUNDS = 2 or 3 */
1750
- if (sign) {
1751
- rv = -rv;
1752
- sign = 0;
1753
- }
1754
- #endif
1755
- /* rv = */ rounded_product(dval(rv), tens[e]);
1756
- goto ret;
1757
- #endif
1758
- }
1759
- i = DBL_DIG - nd;
1760
- if (e <= Ten_pmax + i) {
1761
- /* A fancier test would sometimes let us do
1762
- * this for larger i values.
1763
- */
1764
- #ifdef Honor_FLT_ROUNDS
1765
- /* round correctly FLT_ROUNDS = 2 or 3 */
1766
- if (sign) {
1767
- rv = -rv;
1768
- sign = 0;
1769
- }
1770
- #endif
1771
- e -= i;
1772
- dval(rv) *= tens[i];
1773
- #ifdef VAX
1774
- /* VAX exponent range is so narrow we must
1775
- * worry about overflow here...
1776
- */
1777
- vax_ovfl_check:
1778
- word0(rv) -= P*Exp_msk1;
1779
- /* rv = */ rounded_product(dval(rv), tens[e]);
1780
- if ((word0(rv) & Exp_mask)
1781
- > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
1782
- goto ovfl;
1783
- word0(rv) += P*Exp_msk1;
1784
- #else
1785
- /* rv = */ rounded_product(dval(rv), tens[e]);
1786
- #endif
1787
- goto ret;
1788
- }
1789
- }
1790
- #ifndef Inaccurate_Divide
1791
- else if (e >= -Ten_pmax) {
1792
- #ifdef Honor_FLT_ROUNDS
1793
- /* round correctly FLT_ROUNDS = 2 or 3 */
1794
- if (sign) {
1795
- rv = -rv;
1796
- sign = 0;
1797
- }
1798
- #endif
1799
- /* rv = */ rounded_quotient(dval(rv), tens[-e]);
1800
- goto ret;
1801
- }
1802
- #endif
1803
- }
1804
- e1 += nd - k;
1805
-
1806
- #ifdef IEEE_Arith
1807
- #ifdef SET_INEXACT
1808
- inexact = 1;
1809
- if (k <= DBL_DIG)
1810
- oldinexact = get_inexact();
1811
- #endif
1812
- #ifdef Avoid_Underflow
1813
- scale = 0;
1814
- #endif
1815
- #ifdef Honor_FLT_ROUNDS
1816
- if ((rounding = Flt_Rounds) >= 2) {
1817
- if (sign)
1818
- rounding = rounding == 2 ? 0 : 2;
1819
- else
1820
- if (rounding != 2)
1821
- rounding = 0;
1822
- }
1823
- #endif
1824
- #endif /*IEEE_Arith*/
1825
-
1826
- /* Get starting approximation = rv * 10**e1 */
1827
-
1828
- if (e1 > 0) {
1829
- if ((i = e1 & 15))
1830
- dval(rv) *= tens[i];
1831
- if (e1 &= ~15) {
1832
- if (e1 > DBL_MAX_10_EXP) {
1833
- ovfl:
1834
- #ifndef NO_ERRNO
1835
- errno = ERANGE;
1836
- #endif
1837
- /* Can't trust HUGE_VAL */
1838
- #ifdef IEEE_Arith
1839
- #ifdef Honor_FLT_ROUNDS
1840
- switch(rounding) {
1841
- case 0: /* toward 0 */
1842
- case 3: /* toward -infinity */
1843
- word0(rv) = Big0;
1844
- word1(rv) = Big1;
1845
- break;
1846
- default:
1847
- word0(rv) = Exp_mask;
1848
- word1(rv) = 0;
1849
- }
1850
- #else /*Honor_FLT_ROUNDS*/
1851
- word0(rv) = Exp_mask;
1852
- word1(rv) = 0;
1853
- #endif /*Honor_FLT_ROUNDS*/
1854
- #ifdef SET_INEXACT
1855
- /* set overflow bit */
1856
- dval(rv0) = 1e300;
1857
- dval(rv0) *= dval(rv0);
1858
- #endif
1859
- #else /*IEEE_Arith*/
1860
- word0(rv) = Big0;
1861
- word1(rv) = Big1;
1862
- #endif /*IEEE_Arith*/
1863
- if (bd0)
1864
- goto retfree;
1865
- goto ret;
1866
- }
1867
- e1 >>= 4;
1868
- for(j = 0; e1 > 1; j++, e1 >>= 1)
1869
- if (e1 & 1)
1870
- dval(rv) *= bigtens[j];
1871
- /* The last multiplication could overflow. */
1872
- word0(rv) -= P*Exp_msk1;
1873
- dval(rv) *= bigtens[j];
1874
- if ((z = word0(rv) & Exp_mask)
1875
- > Exp_msk1*(DBL_MAX_EXP+Bias-P))
1876
- goto ovfl;
1877
- if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
1878
- /* set to largest number */
1879
- /* (Can't trust DBL_MAX) */
1880
- word0(rv) = Big0;
1881
- word1(rv) = Big1;
1882
- }
1883
- else
1884
- word0(rv) += P*Exp_msk1;
1885
- }
1886
- }
1887
- else if (e1 < 0) {
1888
- e1 = -e1;
1889
- if ((i = e1 & 15))
1890
- dval(rv) /= tens[i];
1891
- if (e1 >>= 4) {
1892
- if (e1 >= 1 << n_bigtens)
1893
- goto undfl;
1894
- #ifdef Avoid_Underflow
1895
- if (e1 & Scale_Bit)
1896
- scale = 2*P;
1897
- for(j = 0; e1 > 0; j++, e1 >>= 1)
1898
- if (e1 & 1)
1899
- dval(rv) *= tinytens[j];
1900
- if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
1901
- >> Exp_shift)) > 0) {
1902
- /* scaled rv is denormal; zap j low bits */
1903
- if (j >= 32) {
1904
- word1(rv) = 0;
1905
- if (j >= 53)
1906
- word0(rv) = (P+2)*Exp_msk1;
1907
- else
1908
- word0(rv) &= 0xffffffff << (j-32);
1909
- }
1910
- else
1911
- word1(rv) &= 0xffffffff << j;
1912
- }
1913
- #else
1914
- for(j = 0; e1 > 1; j++, e1 >>= 1)
1915
- if (e1 & 1)
1916
- dval(rv) *= tinytens[j];
1917
- /* The last multiplication could underflow. */
1918
- dval(rv0) = dval(rv);
1919
- dval(rv) *= tinytens[j];
1920
- if (!dval(rv)) {
1921
- dval(rv) = 2.*dval(rv0);
1922
- dval(rv) *= tinytens[j];
1923
- #endif
1924
- if (!dval(rv)) {
1925
- undfl:
1926
- dval(rv) = 0.;
1927
- #ifndef NO_ERRNO
1928
- errno = ERANGE;
1929
- #endif
1930
- if (bd0)
1931
- goto retfree;
1932
- goto ret;
1933
- }
1934
- #ifndef Avoid_Underflow
1935
- word0(rv) = Tiny0;
1936
- word1(rv) = Tiny1;
1937
- /* The refinement below will clean
1938
- * this approximation up.
1939
- */
1940
- }
1941
- #endif
1942
- }
1943
- }
1944
-
1945
- /* Now the hard part -- adjusting rv to the correct value.*/
1946
-
1947
- /* Put digits into bd: true value = bd * 10^e */
1948
-
1949
- bd0 = s2b(s0, nd0, nd, y);
1950
-
1951
- for(;;) {
1952
- bd = Balloc(bd0->k);
1953
- Bcopy(bd, bd0);
1954
- bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
1955
- bs = i2b(1);
1956
-
1957
- if (e >= 0) {
1958
- bb2 = bb5 = 0;
1959
- bd2 = bd5 = e;
1960
- }
1961
- else {
1962
- bb2 = bb5 = -e;
1963
- bd2 = bd5 = 0;
1964
- }
1965
- if (bbe >= 0)
1966
- bb2 += bbe;
1967
- else
1968
- bd2 -= bbe;
1969
- bs2 = bb2;
1970
- #ifdef Honor_FLT_ROUNDS
1971
- if (rounding != 1)
1972
- bs2++;
1973
- #endif
1974
- #ifdef Avoid_Underflow
1975
- j = bbe - scale;
1976
- i = j + bbbits - 1; /* logb(rv) */
1977
- if (i < Emin) /* denormal */
1978
- j += P - Emin;
1979
- else
1980
- j = P + 1 - bbbits;
1981
- #else /*Avoid_Underflow*/
1982
- #ifdef Sudden_Underflow
1983
- #ifdef IBM
1984
- j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
1985
- #else
1986
- j = P + 1 - bbbits;
1987
- #endif
1988
- #else /*Sudden_Underflow*/
1989
- j = bbe;
1990
- i = j + bbbits - 1; /* logb(rv) */
1991
- if (i < Emin) /* denormal */
1992
- j += P - Emin;
1993
- else
1994
- j = P + 1 - bbbits;
1995
- #endif /*Sudden_Underflow*/
1996
- #endif /*Avoid_Underflow*/
1997
- bb2 += j;
1998
- bd2 += j;
1999
- #ifdef Avoid_Underflow
2000
- bd2 += scale;
2001
- #endif
2002
- i = bb2 < bd2 ? bb2 : bd2;
2003
- if (i > bs2)
2004
- i = bs2;
2005
- if (i > 0) {
2006
- bb2 -= i;
2007
- bd2 -= i;
2008
- bs2 -= i;
2009
- }
2010
- if (bb5 > 0) {
2011
- bs = pow5mult(bs, bb5);
2012
- bb1 = mult(bs, bb);
2013
- Bfree(bb);
2014
- bb = bb1;
2015
- }
2016
- if (bb2 > 0)
2017
- bb = lshift(bb, bb2);
2018
- if (bd5 > 0)
2019
- bd = pow5mult(bd, bd5);
2020
- if (bd2 > 0)
2021
- bd = lshift(bd, bd2);
2022
- if (bs2 > 0)
2023
- bs = lshift(bs, bs2);
2024
- delta = diff(bb, bd);
2025
- dsign = delta->sign;
2026
- delta->sign = 0;
2027
- i = cmp(delta, bs);
2028
- #ifdef Honor_FLT_ROUNDS
2029
- if (rounding != 1) {
2030
- if (i < 0) {
2031
- /* Error is less than an ulp */
2032
- if (!delta->x[0] && delta->wds <= 1) {
2033
- /* exact */
2034
- #ifdef SET_INEXACT
2035
- inexact = 0;
2036
- #endif
2037
- break;
2038
- }
2039
- if (rounding) {
2040
- if (dsign) {
2041
- adj = 1.;
2042
- goto apply_adj;
2043
- }
2044
- }
2045
- else if (!dsign) {
2046
- adj = -1.;
2047
- if (!word1(rv)
2048
- && !(word0(rv) & Frac_mask)) {
2049
- y = word0(rv) & Exp_mask;
2050
- #ifdef Avoid_Underflow
2051
- if (!scale || y > 2*P*Exp_msk1)
2052
- #else
2053
- if (y)
2054
- #endif
2055
- {
2056
- delta = lshift(delta,Log2P);
2057
- if (cmp(delta, bs) <= 0)
2058
- adj = -0.5;
2059
- }
2060
- }
2061
- apply_adj:
2062
- #ifdef Avoid_Underflow
2063
- if (scale && (y = word0(rv) & Exp_mask)
2064
- <= 2*P*Exp_msk1)
2065
- word0(adj) += (2*P+1)*Exp_msk1 - y;
2066
- #else
2067
- #ifdef Sudden_Underflow
2068
- if ((word0(rv) & Exp_mask) <=
2069
- P*Exp_msk1) {
2070
- word0(rv) += P*Exp_msk1;
2071
- dval(rv) += adj*ulp(dval(rv));
2072
- word0(rv) -= P*Exp_msk1;
2073
- }
2074
- else
2075
- #endif /*Sudden_Underflow*/
2076
- #endif /*Avoid_Underflow*/
2077
- dval(rv) += adj*ulp(dval(rv));
2078
- }
2079
- break;
2080
- }
2081
- adj = ratio(delta, bs);
2082
- if (adj < 1.)
2083
- adj = 1.;
2084
- if (adj <= 0x7ffffffe) {
2085
- /* adj = rounding ? ceil(adj) : floor(adj); */
2086
- y = adj;
2087
- if (y != adj) {
2088
- if (!((rounding>>1) ^ dsign))
2089
- y++;
2090
- adj = y;
2091
- }
2092
- }
2093
- #ifdef Avoid_Underflow
2094
- if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
2095
- word0(adj) += (2*P+1)*Exp_msk1 - y;
2096
- #else
2097
- #ifdef Sudden_Underflow
2098
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
2099
- word0(rv) += P*Exp_msk1;
2100
- adj *= ulp(dval(rv));
2101
- if (dsign)
2102
- dval(rv) += adj;
2103
- else
2104
- dval(rv) -= adj;
2105
- word0(rv) -= P*Exp_msk1;
2106
- goto cont;
2107
- }
2108
- #endif /*Sudden_Underflow*/
2109
- #endif /*Avoid_Underflow*/
2110
- adj *= ulp(dval(rv));
2111
- if (dsign)
2112
- dval(rv) += adj;
2113
- else
2114
- dval(rv) -= adj;
2115
- goto cont;
2116
- }
2117
- #endif /*Honor_FLT_ROUNDS*/
2118
-
2119
- if (i < 0) {
2120
- /* Error is less than half an ulp -- check for
2121
- * special case of mantissa a power of two.
2122
- */
2123
- if (dsign || word1(rv) || word0(rv) & Bndry_mask
2124
- #ifdef IEEE_Arith
2125
- #ifdef Avoid_Underflow
2126
- || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
2127
- #else
2128
- || (word0(rv) & Exp_mask) <= Exp_msk1
2129
- #endif
2130
- #endif
2131
- ) {
2132
- #ifdef SET_INEXACT
2133
- if (!delta->x[0] && delta->wds <= 1)
2134
- inexact = 0;
2135
- #endif
2136
- break;
2137
- }
2138
- if (!delta->x[0] && delta->wds <= 1) {
2139
- /* exact result */
2140
- #ifdef SET_INEXACT
2141
- inexact = 0;
2142
- #endif
2143
- break;
2144
- }
2145
- delta = lshift(delta,Log2P);
2146
- if (cmp(delta, bs) > 0)
2147
- goto drop_down;
2148
- break;
2149
- }
2150
- if (i == 0) {
2151
- /* exactly half-way between */
2152
- if (dsign) {
2153
- if ((word0(rv) & Bndry_mask1) == Bndry_mask1
2154
- && word1(rv) == (
2155
- #ifdef Avoid_Underflow
2156
- (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
2157
- ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
2158
- #endif
2159
- 0xffffffff)) {
2160
- /*boundary case -- increment exponent*/
2161
- word0(rv) = (word0(rv) & Exp_mask)
2162
- + Exp_msk1
2163
- #ifdef IBM
2164
- | Exp_msk1 >> 4
2165
- #endif
2166
- ;
2167
- word1(rv) = 0;
2168
- #ifdef Avoid_Underflow
2169
- dsign = 0;
2170
- #endif
2171
- break;
2172
- }
2173
- }
2174
- else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
2175
- drop_down:
2176
- /* boundary case -- decrement exponent */
2177
- #ifdef Sudden_Underflow /*{{*/
2178
- L = word0(rv) & Exp_mask;
2179
- #ifdef IBM
2180
- if (L < Exp_msk1)
2181
- #else
2182
- #ifdef Avoid_Underflow
2183
- if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
2184
- #else
2185
- if (L <= Exp_msk1)
2186
- #endif /*Avoid_Underflow*/
2187
- #endif /*IBM*/
2188
- goto undfl;
2189
- L -= Exp_msk1;
2190
- #else /*Sudden_Underflow}{*/
2191
- #ifdef Avoid_Underflow
2192
- if (scale) {
2193
- L = word0(rv) & Exp_mask;
2194
- if (L <= (2*P+1)*Exp_msk1) {
2195
- if (L > (P+2)*Exp_msk1)
2196
- /* round even ==> */
2197
- /* accept rv */
2198
- break;
2199
- /* rv = smallest denormal */
2200
- goto undfl;
2201
- }
2202
- }
2203
- #endif /*Avoid_Underflow*/
2204
- L = (word0(rv) & Exp_mask) - Exp_msk1;
2205
- #endif /*Sudden_Underflow}}*/
2206
- word0(rv) = L | Bndry_mask1;
2207
- word1(rv) = 0xffffffff;
2208
- #ifdef IBM
2209
- goto cont;
2210
- #else
2211
- break;
2212
- #endif
2213
- }
2214
- #ifndef ROUND_BIASED
2215
- if (!(word1(rv) & LSB))
2216
- break;
2217
- #endif
2218
- if (dsign)
2219
- dval(rv) += ulp(dval(rv));
2220
- #ifndef ROUND_BIASED
2221
- else {
2222
- dval(rv) -= ulp(dval(rv));
2223
- #ifndef Sudden_Underflow
2224
- if (!dval(rv))
2225
- goto undfl;
2226
- #endif
2227
- }
2228
- #ifdef Avoid_Underflow
2229
- dsign = 1 - dsign;
2230
- #endif
2231
- #endif
2232
- break;
2233
- }
2234
- if ((aadj = ratio(delta, bs)) <= 2.) {
2235
- if (dsign)
2236
- aadj = aadj1 = 1.;
2237
- else if (word1(rv) || word0(rv) & Bndry_mask) {
2238
- #ifndef Sudden_Underflow
2239
- if (word1(rv) == Tiny1 && !word0(rv))
2240
- goto undfl;
2241
- #endif
2242
- aadj = 1.;
2243
- aadj1 = -1.;
2244
- }
2245
- else {
2246
- /* special case -- power of FLT_RADIX to be */
2247
- /* rounded down... */
2248
-
2249
- if (aadj < 2./FLT_RADIX)
2250
- aadj = 1./FLT_RADIX;
2251
- else
2252
- aadj *= 0.5;
2253
- aadj1 = -aadj;
2254
- }
2255
- }
2256
- else {
2257
- aadj *= 0.5;
2258
- aadj1 = dsign ? aadj : -aadj;
2259
- #ifdef Check_FLT_ROUNDS
2260
- switch(Rounding) {
2261
- case 2: /* towards +infinity */
2262
- aadj1 -= 0.5;
2263
- break;
2264
- case 0: /* towards 0 */
2265
- case 3: /* towards -infinity */
2266
- aadj1 += 0.5;
2267
- }
2268
- #else
2269
- if (Flt_Rounds == 0)
2270
- aadj1 += 0.5;
2271
- #endif /*Check_FLT_ROUNDS*/
2272
- }
2273
- y = word0(rv) & Exp_mask;
2274
-
2275
- /* Check for overflow */
2276
-
2277
- if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
2278
- dval(rv0) = dval(rv);
2279
- word0(rv) -= P*Exp_msk1;
2280
- adj = aadj1 * ulp(dval(rv));
2281
- dval(rv) += adj;
2282
- if ((word0(rv) & Exp_mask) >=
2283
- Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
2284
- if (word0(rv0) == Big0 && word1(rv0) == Big1)
2285
- goto ovfl;
2286
- word0(rv) = Big0;
2287
- word1(rv) = Big1;
2288
- goto cont;
2289
- }
2290
- else
2291
- word0(rv) += P*Exp_msk1;
2292
- }
2293
- else {
2294
- #ifdef Avoid_Underflow
2295
- if (scale && y <= 2*P*Exp_msk1) {
2296
- if (aadj <= 0x7fffffff) {
2297
- if ((z = aadj) <= 0)
2298
- z = 1;
2299
- aadj = z;
2300
- aadj1 = dsign ? aadj : -aadj;
2301
- }
2302
- word0(aadj1) += (2*P+1)*Exp_msk1 - y;
2303
- }
2304
- adj = aadj1 * ulp(dval(rv));
2305
- dval(rv) += adj;
2306
- #else
2307
- #ifdef Sudden_Underflow
2308
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
2309
- dval(rv0) = dval(rv);
2310
- word0(rv) += P*Exp_msk1;
2311
- adj = aadj1 * ulp(dval(rv));
2312
- dval(rv) += adj;
2313
- #ifdef IBM
2314
- if ((word0(rv) & Exp_mask) < P*Exp_msk1)
2315
- #else
2316
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
2317
- #endif
2318
- {
2319
- if (word0(rv0) == Tiny0
2320
- && word1(rv0) == Tiny1)
2321
- goto undfl;
2322
- word0(rv) = Tiny0;
2323
- word1(rv) = Tiny1;
2324
- goto cont;
2325
- }
2326
- else
2327
- word0(rv) -= P*Exp_msk1;
2328
- }
2329
- else {
2330
- adj = aadj1 * ulp(dval(rv));
2331
- dval(rv) += adj;
2332
- }
2333
- #else /*Sudden_Underflow*/
2334
- /* Compute adj so that the IEEE rounding rules will
2335
- * correctly round rv + adj in some half-way cases.
2336
- * If rv * ulp(rv) is denormalized (i.e.,
2337
- * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
2338
- * trouble from bits lost to denormalization;
2339
- * example: 1.2e-307 .
2340
- */
2341
- if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
2342
- aadj1 = (double)(int)(aadj + 0.5);
2343
- if (!dsign)
2344
- aadj1 = -aadj1;
2345
- }
2346
- adj = aadj1 * ulp(dval(rv));
2347
- dval(rv) += adj;
2348
- #endif /*Sudden_Underflow*/
2349
- #endif /*Avoid_Underflow*/
2350
- }
2351
- z = word0(rv) & Exp_mask;
2352
- #ifndef SET_INEXACT
2353
- #ifdef Avoid_Underflow
2354
- if (!scale)
2355
- #endif
2356
- if (y == z) {
2357
- /* Can we stop now? */
2358
- L = (Long)aadj;
2359
- aadj -= L;
2360
- /* The tolerances below are conservative. */
2361
- if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
2362
- if (aadj < .4999999 || aadj > .5000001)
2363
- break;
2364
- }
2365
- else if (aadj < .4999999/FLT_RADIX)
2366
- break;
2367
- }
2368
- #endif
2369
- cont:
2370
- Bfree(bb);
2371
- Bfree(bd);
2372
- Bfree(bs);
2373
- Bfree(delta);
2374
- }
2375
- #ifdef SET_INEXACT
2376
- if (inexact) {
2377
- if (!oldinexact) {
2378
- word0(rv0) = Exp_1 + (70 << Exp_shift);
2379
- word1(rv0) = 0;
2380
- dval(rv0) += 1.;
2381
- }
2382
- }
2383
- else if (!oldinexact)
2384
- clear_inexact();
2385
- #endif
2386
- #ifdef Avoid_Underflow
2387
- if (scale) {
2388
- word0(rv0) = Exp_1 - 2*P*Exp_msk1;
2389
- word1(rv0) = 0;
2390
- dval(rv) *= dval(rv0);
2391
- #ifndef NO_ERRNO
2392
- /* try to avoid the bug of testing an 8087 register value */
2393
- if (word0(rv) == 0 && word1(rv) == 0)
2394
- errno = ERANGE;
2395
- #endif
2396
- }
2397
- #endif /* Avoid_Underflow */
2398
- #ifdef SET_INEXACT
2399
- if (inexact && !(word0(rv) & Exp_mask)) {
2400
- /* set underflow bit */
2401
- dval(rv0) = 1e-300;
2402
- dval(rv0) *= dval(rv0);
2403
- }
2404
- #endif
2405
- retfree:
2406
- Bfree(bb);
2407
- Bfree(bd);
2408
- Bfree(bs);
2409
- Bfree(bd0);
2410
- Bfree(delta);
2411
- ret:
2412
- if (se)
2413
- *se = (char *)s;
2414
- return sign ? -dval(rv) : dval(rv);
2415
- }
2416
-
2417
- static int
2418
- quorem
2419
- #ifdef KR_headers
2420
- (b, S) Bigint *b, *S;
2421
- #else
2422
- (Bigint *b, Bigint *S)
2423
- #endif
2424
- {
2425
- int n;
2426
- ULong *bx, *bxe, q, *sx, *sxe;
2427
- #ifdef ULLong
2428
- ULLong borrow, carry, y, ys;
2429
- #else
2430
- ULong borrow, carry, y, ys;
2431
- #ifdef Pack_32
2432
- ULong si, z, zs;
2433
- #endif
2434
- #endif
2435
-
2436
- n = S->wds;
2437
- #ifdef DEBUG
2438
- /*debug*/ if (b->wds > n)
2439
- /*debug*/ Bug("oversize b in quorem");
2440
- #endif
2441
- if (b->wds < n)
2442
- return 0;
2443
- sx = S->x;
2444
- sxe = sx + --n;
2445
- bx = b->x;
2446
- bxe = bx + n;
2447
- q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
2448
- #ifdef DEBUG
2449
- /*debug*/ if (q > 9)
2450
- /*debug*/ Bug("oversized quotient in quorem");
2451
- #endif
2452
- if (q) {
2453
- borrow = 0;
2454
- carry = 0;
2455
- do {
2456
- #ifdef ULLong
2457
- ys = *sx++ * (ULLong)q + carry;
2458
- carry = ys >> 32;
2459
- y = *bx - (ys & FFFFFFFF) - borrow;
2460
- borrow = y >> 32 & (ULong)1;
2461
- *bx++ = y & FFFFFFFF;
2462
- #else
2463
- #ifdef Pack_32
2464
- si = *sx++;
2465
- ys = (si & 0xffff) * q + carry;
2466
- zs = (si >> 16) * q + (ys >> 16);
2467
- carry = zs >> 16;
2468
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
2469
- borrow = (y & 0x10000) >> 16;
2470
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
2471
- borrow = (z & 0x10000) >> 16;
2472
- Storeinc(bx, z, y);
2473
- #else
2474
- ys = *sx++ * q + carry;
2475
- carry = ys >> 16;
2476
- y = *bx - (ys & 0xffff) - borrow;
2477
- borrow = (y & 0x10000) >> 16;
2478
- *bx++ = y & 0xffff;
2479
- #endif
2480
- #endif
2481
- }
2482
- while(sx <= sxe);
2483
- if (!*bxe) {
2484
- bx = b->x;
2485
- while(--bxe > bx && !*bxe)
2486
- --n;
2487
- b->wds = n;
2488
- }
2489
- }
2490
- if (cmp(b, S) >= 0) {
2491
- q++;
2492
- borrow = 0;
2493
- carry = 0;
2494
- bx = b->x;
2495
- sx = S->x;
2496
- do {
2497
- #ifdef ULLong
2498
- ys = *sx++ + carry;
2499
- carry = ys >> 32;
2500
- y = *bx - (ys & FFFFFFFF) - borrow;
2501
- borrow = y >> 32 & (ULong)1;
2502
- *bx++ = y & FFFFFFFF;
2503
- #else
2504
- #ifdef Pack_32
2505
- si = *sx++;
2506
- ys = (si & 0xffff) + carry;
2507
- zs = (si >> 16) + (ys >> 16);
2508
- carry = zs >> 16;
2509
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
2510
- borrow = (y & 0x10000) >> 16;
2511
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
2512
- borrow = (z & 0x10000) >> 16;
2513
- Storeinc(bx, z, y);
2514
- #else
2515
- ys = *sx++ + carry;
2516
- carry = ys >> 16;
2517
- y = *bx - (ys & 0xffff) - borrow;
2518
- borrow = (y & 0x10000) >> 16;
2519
- *bx++ = y & 0xffff;
2520
- #endif
2521
- #endif
2522
- }
2523
- while(sx <= sxe);
2524
- bx = b->x;
2525
- bxe = bx + n;
2526
- if (!*bxe) {
2527
- while(--bxe > bx && !*bxe)
2528
- --n;
2529
- b->wds = n;
2530
- }
2531
- }
2532
- return q;
2533
- }
2534
-
2535
- #ifndef MULTIPLE_THREADS
2536
- static char *dtoa_result;
2537
- #endif
2538
-
2539
- static char *
2540
- #ifdef KR_headers
2541
- rv_alloc(i) int i;
2542
- #else
2543
- rv_alloc(int i)
2544
- #endif
2545
- {
2546
- int j, k, *r;
2547
-
2548
- j = sizeof(ULong);
2549
- for(k = 0;
2550
- sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
2551
- j <<= 1)
2552
- k++;
2553
- r = (int*)Balloc(k);
2554
- *r = k;
2555
- return
2556
- #ifndef MULTIPLE_THREADS
2557
- dtoa_result =
2558
- #endif
2559
- (char *)(r+1);
2560
- }
2561
-
2562
- static char *
2563
- #ifdef KR_headers
2564
- nrv_alloc(s, rve, n) char *s, **rve; int n;
2565
- #else
2566
- nrv_alloc(const char *s, char **rve, int n)
2567
- #endif
2568
- {
2569
- char *rv, *t;
2570
-
2571
- t = rv = rv_alloc(n);
2572
- while ((*t = *s++)) t++;
2573
- if (rve)
2574
- *rve = t;
2575
- return rv;
2576
- }
2577
-
2578
- /* freedtoa(s) must be used to free values s returned by dtoa
2579
- * when MULTIPLE_THREADS is #defined. It should be used in all cases,
2580
- * but for consistency with earlier versions of dtoa, it is optional
2581
- * when MULTIPLE_THREADS is not defined.
2582
- */
2583
-
2584
- void
2585
- #ifdef KR_headers
2586
- freedtoa(s) char *s;
2587
- #else
2588
- freedtoa(char *s)
2589
- #endif
2590
- {
2591
- Bigint *b = (Bigint *)((int *)s - 1);
2592
- b->maxwds = 1 << (b->k = *(int*)b);
2593
- Bfree(b);
2594
- #ifndef MULTIPLE_THREADS
2595
- if (s == dtoa_result)
2596
- dtoa_result = 0;
2597
- #endif
2598
- }
2599
-
2600
- /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
2601
- *
2602
- * Inspired by "How to Print Floating-Point Numbers Accurately" by
2603
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
2604
- *
2605
- * Modifications:
2606
- * 1. Rather than iterating, we use a simple numeric overestimate
2607
- * to determine k = floor(log10(d)). We scale relevant
2608
- * quantities using O(log2(k)) rather than O(k) multiplications.
2609
- * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
2610
- * try to generate digits strictly left to right. Instead, we
2611
- * compute with fewer bits and propagate the carry if necessary
2612
- * when rounding the final digit up. This is often faster.
2613
- * 3. Under the assumption that input will be rounded nearest,
2614
- * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
2615
- * That is, we allow equality in stopping tests when the
2616
- * round-nearest rule will give the same floating-point value
2617
- * as would satisfaction of the stopping test with strict
2618
- * inequality.
2619
- * 4. We remove common factors of powers of 2 from relevant
2620
- * quantities.
2621
- * 5. When converting floating-point integers less than 1e16,
2622
- * we use floating-point arithmetic rather than resorting
2623
- * to multiple-precision integers.
2624
- * 6. When asked to produce fewer than 15 digits, we first try
2625
- * to get by with floating-point arithmetic; we resort to
2626
- * multiple-precision integer arithmetic only if we cannot
2627
- * guarantee that the floating-point calculation has given
2628
- * the correctly rounded result. For k requested digits and
2629
- * "uniformly" distributed input, the probability is
2630
- * something like 10^(k-15) that we must resort to the Long
2631
- * calculation.
2632
- */
2633
-
2634
- char *
2635
- dtoa
2636
- #ifdef KR_headers
2637
- (d, mode, ndigits, decpt, sign, rve)
2638
- double d; int mode, ndigits, *decpt, *sign; char **rve;
2639
- #else
2640
- (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
2641
- #endif
2642
- {
2643
- /* Arguments ndigits, decpt, sign are similar to those
2644
- of ecvt and fcvt; trailing zeros are suppressed from
2645
- the returned string. If not null, *rve is set to point
2646
- to the end of the return value. If d is +-Infinity or NaN,
2647
- then *decpt is set to 9999.
2648
-
2649
- mode:
2650
- 0 ==> shortest string that yields d when read in
2651
- and rounded to nearest.
2652
- 1 ==> like 0, but with Steele & White stopping rule;
2653
- e.g. with IEEE P754 arithmetic , mode 0 gives
2654
- 1e23 whereas mode 1 gives 9.999999999999999e22.
2655
- 2 ==> max(1,ndigits) significant digits. This gives a
2656
- return value similar to that of ecvt, except
2657
- that trailing zeros are suppressed.
2658
- 3 ==> through ndigits past the decimal point. This
2659
- gives a return value similar to that from fcvt,
2660
- except that trailing zeros are suppressed, and
2661
- ndigits can be negative.
2662
- 4,5 ==> similar to 2 and 3, respectively, but (in
2663
- round-nearest mode) with the tests of mode 0 to
2664
- possibly return a shorter string that rounds to d.
2665
- With IEEE arithmetic and compilation with
2666
- -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
2667
- as modes 2 and 3 when FLT_ROUNDS != 1.
2668
- 6-9 ==> Debugging modes similar to mode - 4: don't try
2669
- fast floating-point estimate (if applicable).
2670
-
2671
- Values of mode other than 0-9 are treated as mode 0.
2672
-
2673
- Sufficient space is allocated to the return value
2674
- to hold the suppressed trailing zeros.
2675
- */
2676
-
2677
- int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
2678
- j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
2679
- spec_case, try_quick, bias_round_up;
2680
- Long L;
2681
- #ifndef Sudden_Underflow
2682
- int denorm;
2683
- ULong x;
2684
- #endif
2685
- Bigint *b, *b1, *delta, *mlo, *mhi, *S;
2686
- double d2, ds, eps;
2687
- char *s, *s0;
2688
- #ifdef Honor_FLT_ROUNDS
2689
- int rounding;
2690
- #endif
2691
- #ifdef SET_INEXACT
2692
- int inexact, oldinexact;
2693
- #endif
2694
-
2695
- /* In mode 2 and 3 we bias rounding up when there are ties. */
2696
- bias_round_up = mode == 2 || mode == 3;
2697
-
2698
- ilim = ilim1 = 0; /* to avoid Google3 compiler warnings */
2699
-
2700
- #ifndef MULTIPLE_THREADS
2701
- if (dtoa_result) {
2702
- freedtoa(dtoa_result);
2703
- dtoa_result = 0;
2704
- }
2705
- #endif
2706
-
2707
- if (word0(d) & Sign_bit) {
2708
- /* set sign for everything, including 0's and NaNs */
2709
- *sign = 1;
2710
- word0(d) &= ~Sign_bit; /* clear sign bit */
2711
- }
2712
- else
2713
- *sign = 0;
2714
-
2715
- #if defined(IEEE_Arith) + defined(VAX)
2716
- #ifdef IEEE_Arith
2717
- if ((word0(d) & Exp_mask) == Exp_mask)
2718
- #else
2719
- if (word0(d) == 0x8000)
2720
- #endif
2721
- {
2722
- /* Infinity or NaN */
2723
- *decpt = 9999;
2724
- #ifdef IEEE_Arith
2725
- if (!word1(d) && !(word0(d) & 0xfffff))
2726
- return nrv_alloc("Infinity", rve, 8);
2727
- #endif
2728
- return nrv_alloc("NaN", rve, 3);
2729
- }
2730
- #endif
2731
- #ifdef IBM
2732
- dval(d) += 0; /* normalize */
2733
- #endif
2734
- if (!dval(d)) {
2735
- *decpt = 1;
2736
- return nrv_alloc("0", rve, 1);
2737
- }
2738
-
2739
- #ifdef SET_INEXACT
2740
- try_quick = oldinexact = get_inexact();
2741
- inexact = 1;
2742
- #endif
2743
- #ifdef Honor_FLT_ROUNDS
2744
- if ((rounding = Flt_Rounds) >= 2) {
2745
- if (*sign)
2746
- rounding = rounding == 2 ? 0 : 2;
2747
- else
2748
- if (rounding != 2)
2749
- rounding = 0;
2750
- }
2751
- #endif
2752
-
2753
- b = d2b(dval(d), &be, &bbits);
2754
- #ifdef Sudden_Underflow
2755
- i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
2756
- #else
2757
- if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) {
2758
- #endif
2759
- dval(d2) = dval(d);
2760
- word0(d2) &= Frac_mask1;
2761
- word0(d2) |= Exp_11;
2762
- #ifdef IBM
2763
- if (j = 11 - hi0bits(word0(d2) & Frac_mask))
2764
- dval(d2) /= 1 << j;
2765
- #endif
2766
-
2767
- /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
2768
- * log10(x) = log(x) / log(10)
2769
- * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
2770
- * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
2771
- *
2772
- * This suggests computing an approximation k to log10(d) by
2773
- *
2774
- * k = (i - Bias)*0.301029995663981
2775
- * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
2776
- *
2777
- * We want k to be too large rather than too small.
2778
- * The error in the first-order Taylor series approximation
2779
- * is in our favor, so we just round up the constant enough
2780
- * to compensate for any error in the multiplication of
2781
- * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
2782
- * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
2783
- * adding 1e-13 to the constant term more than suffices.
2784
- * Hence we adjust the constant term to 0.1760912590558.
2785
- * (We could get a more accurate k by invoking log10,
2786
- * but this is probably not worthwhile.)
2787
- */
2788
-
2789
- i -= Bias;
2790
- #ifdef IBM
2791
- i <<= 2;
2792
- i += j;
2793
- #endif
2794
- #ifndef Sudden_Underflow
2795
- denorm = 0;
2796
- }
2797
- else {
2798
- /* d is denormalized */
2799
-
2800
- i = bbits + be + (Bias + (P-1) - 1);
2801
- x = i > 32 ? (word0(d) << (64 - i)) | (word1(d) >> (i - 32))
2802
- : word1(d) << (32 - i);
2803
- dval(d2) = x;
2804
- word0(d2) -= 31*Exp_msk1; /* adjust exponent */
2805
- i -= (Bias + (P-1) - 1) + 1;
2806
- denorm = 1;
2807
- }
2808
- #endif
2809
- ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
2810
- k = (int)ds;
2811
- if (ds < 0. && ds != k)
2812
- k--; /* want k = floor(ds) */
2813
- k_check = 1;
2814
- if (k >= 0 && k <= Ten_pmax) {
2815
- if (dval(d) < tens[k])
2816
- k--;
2817
- k_check = 0;
2818
- }
2819
- j = bbits - i - 1;
2820
- if (j >= 0) {
2821
- b2 = 0;
2822
- s2 = j;
2823
- }
2824
- else {
2825
- b2 = -j;
2826
- s2 = 0;
2827
- }
2828
- if (k >= 0) {
2829
- b5 = 0;
2830
- s5 = k;
2831
- s2 += k;
2832
- }
2833
- else {
2834
- b2 -= k;
2835
- b5 = -k;
2836
- s5 = 0;
2837
- }
2838
- if (mode < 0 || mode > 9)
2839
- mode = 0;
2840
-
2841
- #ifndef SET_INEXACT
2842
- #ifdef Check_FLT_ROUNDS
2843
- try_quick = Rounding == 1;
2844
- #else
2845
- try_quick = 1;
2846
- #endif
2847
- #endif /*SET_INEXACT*/
2848
-
2849
- if (mode > 5) {
2850
- mode -= 4;
2851
- try_quick = 0;
2852
- }
2853
- leftright = 1;
2854
- switch(mode) {
2855
- case 0:
2856
- case 1:
2857
- ilim = ilim1 = -1;
2858
- i = 18;
2859
- ndigits = 0;
2860
- break;
2861
- case 2:
2862
- leftright = 0;
2863
- /* no break */
2864
- case 4:
2865
- if (ndigits <= 0)
2866
- ndigits = 1;
2867
- ilim = ilim1 = i = ndigits;
2868
- break;
2869
- case 3:
2870
- leftright = 0;
2871
- /* no break */
2872
- case 5:
2873
- i = ndigits + k + 1;
2874
- ilim = i;
2875
- ilim1 = i - 1;
2876
- if (i <= 0)
2877
- i = 1;
2878
- }
2879
- s = s0 = rv_alloc(i);
2880
-
2881
- #ifdef Honor_FLT_ROUNDS
2882
- if (mode > 1 && rounding != 1)
2883
- leftright = 0;
2884
- #endif
2885
-
2886
- if (ilim >= 0 && ilim <= Quick_max && try_quick) {
2887
-
2888
- /* Try to get by with floating-point arithmetic. */
2889
-
2890
- i = 0;
2891
- dval(d2) = dval(d);
2892
- k0 = k;
2893
- ilim0 = ilim;
2894
- ieps = 2; /* conservative */
2895
- if (k > 0) {
2896
- ds = tens[k&0xf];
2897
- j = k >> 4;
2898
- if (j & Bletch) {
2899
- /* prevent overflows */
2900
- j &= Bletch - 1;
2901
- dval(d) /= bigtens[n_bigtens-1];
2902
- ieps++;
2903
- }
2904
- for(; j; j >>= 1, i++)
2905
- if (j & 1) {
2906
- ieps++;
2907
- ds *= bigtens[i];
2908
- }
2909
- dval(d) /= ds;
2910
- }
2911
- else if ((j1 = -k)) {
2912
- dval(d) *= tens[j1 & 0xf];
2913
- for(j = j1 >> 4; j; j >>= 1, i++)
2914
- if (j & 1) {
2915
- ieps++;
2916
- dval(d) *= bigtens[i];
2917
- }
2918
- }
2919
- if (k_check && dval(d) < 1. && ilim > 0) {
2920
- if (ilim1 <= 0)
2921
- goto fast_failed;
2922
- ilim = ilim1;
2923
- k--;
2924
- dval(d) *= 10.;
2925
- ieps++;
2926
- }
2927
- dval(eps) = ieps*dval(d) + 7.;
2928
- word0(eps) -= (P-1)*Exp_msk1;
2929
- if (ilim == 0) {
2930
- S = mhi = 0;
2931
- dval(d) -= 5.;
2932
- if (dval(d) > dval(eps))
2933
- goto one_digit;
2934
- if (dval(d) < -dval(eps))
2935
- goto no_digits;
2936
- goto fast_failed;
2937
- }
2938
- #ifndef No_leftright
2939
- if (leftright) {
2940
- /* Use Steele & White method of only
2941
- * generating digits needed.
2942
- */
2943
- dval(eps) = 0.5/tens[ilim-1] - dval(eps);
2944
- for(i = 0;;) {
2945
- L = dval(d);
2946
- dval(d) -= L;
2947
- *s++ = '0' + (int)L;
2948
- if (dval(d) < dval(eps))
2949
- goto ret1;
2950
- if (1. - dval(d) < dval(eps))
2951
- goto bump_up;
2952
- if (++i >= ilim)
2953
- break;
2954
- dval(eps) *= 10.;
2955
- dval(d) *= 10.;
2956
- }
2957
- }
2958
- else {
2959
- #endif
2960
- /* Generate ilim digits, then fix them up. */
2961
- dval(eps) *= tens[ilim-1];
2962
- for(i = 1;; i++, dval(d) *= 10.) {
2963
- L = (Long)(dval(d));
2964
- if (!(dval(d) -= L))
2965
- ilim = i;
2966
- *s++ = '0' + (int)L;
2967
- if (i == ilim) {
2968
- if (dval(d) > 0.5 + dval(eps))
2969
- goto bump_up;
2970
- else if (dval(d) < 0.5 - dval(eps)) {
2971
- while(*--s == '0');
2972
- s++;
2973
- goto ret1;
2974
- }
2975
- break;
2976
- }
2977
- }
2978
- #ifndef No_leftright
2979
- }
2980
- #endif
2981
- fast_failed:
2982
- s = s0;
2983
- dval(d) = dval(d2);
2984
- k = k0;
2985
- ilim = ilim0;
2986
- }
2987
-
2988
- /* Do we have a "small" integer? */
2989
-
2990
- if (be >= 0 && k <= Int_max) {
2991
- /* Yes. */
2992
- ds = tens[k];
2993
- if (ndigits < 0 && ilim <= 0) {
2994
- S = mhi = 0;
2995
- if (ilim < 0 || dval(d) < 5*ds || ((dval(d) == 5*ds) && !bias_round_up))
2996
- goto no_digits;
2997
- goto one_digit;
2998
- }
2999
-
3000
- /* Limit looping by the number of digits to produce.
3001
- * Firefox had a crash bug because some plugins reduce
3002
- * the precision of double arithmetic. With reduced
3003
- * precision "dval(d) -= L*ds" might be imprecise and
3004
- * d might not become zero and the loop might not
3005
- * terminate.
3006
- *
3007
- * See https://bugzilla.mozilla.org/show_bug.cgi?id=358569
3008
- */
3009
- for(i = 1; i <= k+1; i++, dval(d) *= 10.) {
3010
- L = (Long)(dval(d) / ds);
3011
- dval(d) -= L*ds;
3012
- #ifdef Check_FLT_ROUNDS
3013
- /* If FLT_ROUNDS == 2, L will usually be high by 1 */
3014
- if (dval(d) < 0) {
3015
- L--;
3016
- dval(d) += ds;
3017
- }
3018
- #endif
3019
- *s++ = '0' + (int)L;
3020
- if (!dval(d)) {
3021
- #ifdef SET_INEXACT
3022
- inexact = 0;
3023
- #endif
3024
- break;
3025
- }
3026
- if (i == ilim) {
3027
- #ifdef Honor_FLT_ROUNDS
3028
- if (mode > 1)
3029
- switch(rounding) {
3030
- case 0: goto ret1;
3031
- case 2: goto bump_up;
3032
- }
3033
- #endif
3034
- dval(d) += dval(d);
3035
- if (dval(d) > ds || (dval(d) == ds && ((L & 1) || bias_round_up))) {
3036
- bump_up:
3037
- while(*--s == '9')
3038
- if (s == s0) {
3039
- k++;
3040
- *s = '0';
3041
- break;
3042
- }
3043
- ++*s++;
3044
- }
3045
- break;
3046
- }
3047
- }
3048
- goto ret1;
3049
- }
3050
-
3051
- m2 = b2;
3052
- m5 = b5;
3053
- mhi = mlo = 0;
3054
- if (leftright) {
3055
- i =
3056
- #ifndef Sudden_Underflow
3057
- denorm ? be + (Bias + (P-1) - 1 + 1) :
3058
- #endif
3059
- #ifdef IBM
3060
- 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
3061
- #else
3062
- 1 + P - bbits;
3063
- #endif
3064
- b2 += i;
3065
- s2 += i;
3066
- mhi = i2b(1);
3067
- }
3068
- if (m2 > 0 && s2 > 0) {
3069
- i = m2 < s2 ? m2 : s2;
3070
- b2 -= i;
3071
- m2 -= i;
3072
- s2 -= i;
3073
- }
3074
- if (b5 > 0) {
3075
- if (leftright) {
3076
- if (m5 > 0) {
3077
- mhi = pow5mult(mhi, m5);
3078
- b1 = mult(mhi, b);
3079
- Bfree(b);
3080
- b = b1;
3081
- }
3082
- if ((j = b5 - m5))
3083
- b = pow5mult(b, j);
3084
- }
3085
- else
3086
- b = pow5mult(b, b5);
3087
- }
3088
- S = i2b(1);
3089
- if (s5 > 0)
3090
- S = pow5mult(S, s5);
3091
-
3092
- /* Check for special case that d is a normalized power of 2. */
3093
-
3094
- spec_case = 0;
3095
- if ((mode < 2 || leftright)
3096
- #ifdef Honor_FLT_ROUNDS
3097
- && rounding == 1
3098
- #endif
3099
- ) {
3100
- if (!word1(d) && !(word0(d) & Bndry_mask)
3101
- #ifndef Sudden_Underflow
3102
- && word0(d) & (Exp_mask & ~Exp_msk1)
3103
- #endif
3104
- ) {
3105
- /* The special case */
3106
- b2 += Log2P;
3107
- s2 += Log2P;
3108
- spec_case = 1;
3109
- }
3110
- }
3111
-
3112
- /* Arrange for convenient computation of quotients:
3113
- * shift left if necessary so divisor has 4 leading 0 bits.
3114
- *
3115
- * Perhaps we should just compute leading 28 bits of S once
3116
- * and for all and pass them and a shift to quorem, so it
3117
- * can do shifts and ors to compute the numerator for q.
3118
- */
3119
- #ifdef Pack_32
3120
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
3121
- i = 32 - i;
3122
- #else
3123
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf))
3124
- i = 16 - i;
3125
- #endif
3126
- if (i > 4) {
3127
- i -= 4;
3128
- b2 += i;
3129
- m2 += i;
3130
- s2 += i;
3131
- }
3132
- else if (i < 4) {
3133
- i += 28;
3134
- b2 += i;
3135
- m2 += i;
3136
- s2 += i;
3137
- }
3138
- if (b2 > 0)
3139
- b = lshift(b, b2);
3140
- if (s2 > 0)
3141
- S = lshift(S, s2);
3142
- if (k_check) {
3143
- if (cmp(b,S) < 0) {
3144
- k--;
3145
- b = multadd(b, 10, 0); /* we botched the k estimate */
3146
- if (leftright)
3147
- mhi = multadd(mhi, 10, 0);
3148
- ilim = ilim1;
3149
- }
3150
- }
3151
- if (ilim <= 0 && (mode == 3 || mode == 5)) {
3152
- S = multadd(S, 5, 0);
3153
- if (ilim < 0 || cmp(b, S) < 0 || ((cmp(b, S) == 0) && !bias_round_up)) {
3154
- /* no digits, fcvt style */
3155
- no_digits:
3156
- k = -1 - ndigits;
3157
- goto ret;
3158
- }
3159
- one_digit:
3160
- *s++ = '1';
3161
- k++;
3162
- goto ret;
3163
- }
3164
- if (leftright) {
3165
- if (m2 > 0)
3166
- mhi = lshift(mhi, m2);
3167
-
3168
- /* Compute mlo -- check for special case
3169
- * that d is a normalized power of 2.
3170
- */
3171
-
3172
- mlo = mhi;
3173
- if (spec_case) {
3174
- mhi = Balloc(mhi->k);
3175
- Bcopy(mhi, mlo);
3176
- mhi = lshift(mhi, Log2P);
3177
- }
3178
-
3179
- for(i = 1;;i++) {
3180
- dig = quorem(b,S) + '0';
3181
- /* Do we yet have the shortest decimal string
3182
- * that will round to d?
3183
- */
3184
- j = cmp(b, mlo);
3185
- delta = diff(S, mhi);
3186
- j1 = delta->sign ? 1 : cmp(b, delta);
3187
- Bfree(delta);
3188
- #ifndef ROUND_BIASED
3189
- if (j1 == 0 && mode != 1 && !(word1(d) & 1)
3190
- #ifdef Honor_FLT_ROUNDS
3191
- && rounding >= 1
3192
- #endif
3193
- ) {
3194
- if (dig == '9')
3195
- goto round_9_up;
3196
- if (j > 0)
3197
- dig++;
3198
- #ifdef SET_INEXACT
3199
- else if (!b->x[0] && b->wds <= 1)
3200
- inexact = 0;
3201
- #endif
3202
- *s++ = dig;
3203
- goto ret;
3204
- }
3205
- #endif
3206
- if (j < 0 || (j == 0 && mode != 1
3207
- #ifndef ROUND_BIASED
3208
- && !(word1(d) & 1)
3209
- #endif
3210
- )) {
3211
- if (!b->x[0] && b->wds <= 1) {
3212
- #ifdef SET_INEXACT
3213
- inexact = 0;
3214
- #endif
3215
- goto accept_dig;
3216
- }
3217
- #ifdef Honor_FLT_ROUNDS
3218
- if (mode > 1)
3219
- switch(rounding) {
3220
- case 0: goto accept_dig;
3221
- case 2: goto keep_dig;
3222
- }
3223
- #endif /*Honor_FLT_ROUNDS*/
3224
- if (j1 > 0) {
3225
- b = lshift(b, 1);
3226
- j1 = cmp(b, S);
3227
- if ((j1 > 0 || (j1 == 0 && ((dig & 1) || bias_round_up)))
3228
- && dig++ == '9')
3229
- goto round_9_up;
3230
- }
3231
- accept_dig:
3232
- *s++ = dig;
3233
- goto ret;
3234
- }
3235
- if (j1 > 0) {
3236
- #ifdef Honor_FLT_ROUNDS
3237
- if (!rounding)
3238
- goto accept_dig;
3239
- #endif
3240
- if (dig == '9') { /* possible if i == 1 */
3241
- round_9_up:
3242
- *s++ = '9';
3243
- goto roundoff;
3244
- }
3245
- *s++ = dig + 1;
3246
- goto ret;
3247
- }
3248
- #ifdef Honor_FLT_ROUNDS
3249
- keep_dig:
3250
- #endif
3251
- *s++ = dig;
3252
- if (i == ilim)
3253
- break;
3254
- b = multadd(b, 10, 0);
3255
- if (mlo == mhi)
3256
- mlo = mhi = multadd(mhi, 10, 0);
3257
- else {
3258
- mlo = multadd(mlo, 10, 0);
3259
- mhi = multadd(mhi, 10, 0);
3260
- }
3261
- }
3262
- }
3263
- else
3264
- for(i = 1;; i++) {
3265
- *s++ = dig = quorem(b,S) + '0';
3266
- if (!b->x[0] && b->wds <= 1) {
3267
- #ifdef SET_INEXACT
3268
- inexact = 0;
3269
- #endif
3270
- goto ret;
3271
- }
3272
- if (i >= ilim)
3273
- break;
3274
- b = multadd(b, 10, 0);
3275
- }
3276
-
3277
- /* Round off last digit */
3278
-
3279
- #ifdef Honor_FLT_ROUNDS
3280
- switch(rounding) {
3281
- case 0: goto trimzeros;
3282
- case 2: goto roundoff;
3283
- }
3284
- #endif
3285
- b = lshift(b, 1);
3286
- j = cmp(b, S);
3287
- if (j > 0 || (j == 0 && ((dig & 1) || bias_round_up))) {
3288
- roundoff:
3289
- while(*--s == '9')
3290
- if (s == s0) {
3291
- k++;
3292
- *s++ = '1';
3293
- goto ret;
3294
- }
3295
- ++*s++;
3296
- }
3297
- else {
3298
- /* trimzeros: (never used) */
3299
- while(*--s == '0');
3300
- s++;
3301
- }
3302
- ret:
3303
- Bfree(S);
3304
- if (mhi) {
3305
- if (mlo && mlo != mhi)
3306
- Bfree(mlo);
3307
- Bfree(mhi);
3308
- }
3309
- ret1:
3310
- #ifdef SET_INEXACT
3311
- if (inexact) {
3312
- if (!oldinexact) {
3313
- word0(d) = Exp_1 + (70 << Exp_shift);
3314
- word1(d) = 0;
3315
- dval(d) += 1.;
3316
- }
3317
- }
3318
- else if (!oldinexact)
3319
- clear_inexact();
3320
- #endif
3321
- Bfree(b);
3322
- *s = 0;
3323
- *decpt = k + 1;
3324
- if (rve)
3325
- *rve = s;
3326
- return s0;
3327
- }
3328
- #ifdef __cplusplus
3329
- }
3330
- #endif