summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-13 10:00:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-13 10:00:43 (GMT)
commitb9e6ad8c30d7f7b336d09a55bfa1fbcf0ad6d034 (patch)
tree69d60a122f7e49529a41dbbbff1a808319dc1318
parente1bed6530aea1d09e8256dd2fa27f5682d04a72e (diff)
parent9f8e844f9c423ce1ff450461016db86873db4a45 (diff)
downloadtcl-tkt3328635_posix_monotonic_clock.zip
tcl-tkt3328635_posix_monotonic_clock.tar.gz
tcl-tkt3328635_posix_monotonic_clock.tar.bz2
-rw-r--r--.fossil-settings/binary-glob8
-rw-r--r--.fossil-settings/crlf-glob14
-rw-r--r--.fossil-settings/crnl-glob8
-rw-r--r--.fossil-settings/encoding-glob3
-rw-r--r--.fossil-settings/ignore-glob22
-rw-r--r--ChangeLog.20002
-rw-r--r--ChangeLog.20026
-rw-r--r--ChangeLog.20034
-rw-r--r--ChangeLog.20042
-rw-r--r--compat/opendir.c2
-rw-r--r--compat/waitpid.c2
-rw-r--r--compat/zlib/CMakeLists.txt2
-rw-r--r--compat/zlib/ChangeLog55
-rw-r--r--compat/zlib/Makefile.in232
-rw-r--r--compat/zlib/README6
-rw-r--r--compat/zlib/adler32.c21
-rw-r--r--compat/zlib/as400/bndsrc215
-rw-r--r--compat/zlib/as400/compile.clp110
-rw-r--r--compat/zlib/as400/readme.txt115
-rw-r--r--compat/zlib/compress.c42
-rwxr-xr-xcompat/zlib/configure134
-rw-r--r--compat/zlib/contrib/README.contrib4
-rw-r--r--compat/zlib/contrib/ada/zlib-streams.ads6
-rw-r--r--compat/zlib/contrib/ada/zlib-thin.ads2
-rw-r--r--compat/zlib/contrib/blast/blast.c46
-rw-r--r--compat/zlib/contrib/blast/blast.h14
-rw-r--r--compat/zlib/contrib/delphi/ZLib.pas2
-rw-r--r--compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs2
-rw-r--r--compat/zlib/contrib/infback9/inftree9.c6
-rw-r--r--compat/zlib/contrib/minizip/configure.ac2
-rw-r--r--compat/zlib/contrib/minizip/iowin32.c7
-rw-r--r--compat/zlib/contrib/minizip/unzip.c2
-rw-r--r--compat/zlib/contrib/minizip/zip.c22
-rw-r--r--compat/zlib/contrib/pascal/zlibpas.pas4
-rw-r--r--compat/zlib/contrib/puff/puff.c2
-rw-r--r--compat/zlib/contrib/vstudio/readme.txt21
-rw-r--r--compat/zlib/contrib/vstudio/vc10/zlib.rc8
-rw-r--r--compat/zlib/contrib/vstudio/vc10/zlibvc.def12
-rw-r--r--compat/zlib/contrib/vstudio/vc11/zlib.rc8
-rw-r--r--compat/zlib/contrib/vstudio/vc11/zlibvc.def12
-rw-r--r--compat/zlib/contrib/vstudio/vc12/miniunz.vcxproj316
-rw-r--r--compat/zlib/contrib/vstudio/vc12/minizip.vcxproj313
-rw-r--r--compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj430
-rw-r--r--compat/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj316
-rw-r--r--compat/zlib/contrib/vstudio/vc12/zlib.rc32
-rw-r--r--compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj467
-rw-r--r--compat/zlib/contrib/vstudio/vc12/zlibvc.def153
-rw-r--r--compat/zlib/contrib/vstudio/vc12/zlibvc.sln119
-rw-r--r--compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj692
-rw-r--r--compat/zlib/contrib/vstudio/vc14/miniunz.vcxproj316
-rw-r--r--compat/zlib/contrib/vstudio/vc14/minizip.vcxproj313
-rw-r--r--compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj430
-rw-r--r--compat/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj316
-rw-r--r--compat/zlib/contrib/vstudio/vc14/zlib.rc32
-rw-r--r--compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj467
-rw-r--r--compat/zlib/contrib/vstudio/vc14/zlibvc.def153
-rw-r--r--compat/zlib/contrib/vstudio/vc14/zlibvc.sln119
-rw-r--r--compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj692
-rw-r--r--compat/zlib/contrib/vstudio/vc9/zlib.rc8
-rw-r--r--compat/zlib/contrib/vstudio/vc9/zlibvc.def12
-rw-r--r--compat/zlib/crc32.c41
-rw-r--r--compat/zlib/deflate.c802
-rw-r--r--compat/zlib/deflate.h35
-rw-r--r--compat/zlib/doc/algorithm.txt209
-rw-r--r--compat/zlib/doc/rfc1950.txt619
-rw-r--r--compat/zlib/doc/rfc1951.txt955
-rw-r--r--compat/zlib/doc/rfc1952.txt675
-rw-r--r--compat/zlib/doc/txtvsbin.txt107
-rw-r--r--compat/zlib/examples/gun.c2
-rw-r--r--compat/zlib/examples/gzlog.c4
-rw-r--r--compat/zlib/examples/zran.c2
-rw-r--r--compat/zlib/gzguts.h23
-rw-r--r--compat/zlib/gzlib.c31
-rw-r--r--compat/zlib/gzread.c156
-rw-r--r--compat/zlib/gzwrite.c332
-rw-r--r--compat/zlib/infback.c4
-rw-r--r--compat/zlib/inffast.c85
-rw-r--r--compat/zlib/inflate.c123
-rw-r--r--compat/zlib/inflate.h11
-rw-r--r--compat/zlib/inftrees.c26
-rw-r--r--compat/zlib/msdos/Makefile.dj22
-rw-r--r--compat/zlib/msdos/Makefile.emx2
-rw-r--r--compat/zlib/old/Makefile.emx2
-rw-r--r--compat/zlib/old/os2/Makefile.os22
-rw-r--r--compat/zlib/os400/README40048
-rw-r--r--compat/zlib/os400/bndsrc119
-rw-r--r--compat/zlib/os400/make.sh366
-rw-r--r--compat/zlib/os400/zlib.inc (renamed from compat/zlib/as400/zlib.inc)90
-rw-r--r--compat/zlib/qnx/package.qpg10
-rw-r--r--compat/zlib/test/example.c17
-rw-r--r--compat/zlib/test/infcover.c18
-rw-r--r--compat/zlib/test/minigzip.c12
-rw-r--r--compat/zlib/treebuild.xml6
-rw-r--r--compat/zlib/trees.c99
-rw-r--r--compat/zlib/uncompr.c98
-rw-r--r--compat/zlib/win32/Makefile.gcc2
-rw-r--r--compat/zlib/win32/Makefile.msc2
-rw-r--r--compat/zlib/win32/README-WIN32.txt6
-rw-r--r--compat/zlib/win32/README.txt8
-rw-r--r--compat/zlib/win32/USAGE.txt12
-rw-r--r--compat/zlib/win32/VisualC.txt2
-rwxr-xr-x[-rw-r--r--]compat/zlib/win32/zdll.libbin15658 -> 17152 bytes
-rw-r--r--compat/zlib/win32/zlib.def180
-rwxr-xr-xcompat/zlib/win32/zlib1.dllbin107520 -> 105472 bytes
-rw-r--r--compat/zlib/win32/zlib1.rc2
-rw-r--r--compat/zlib/win64/libz.dll.abin46874 -> 51638 bytes
-rw-r--r--compat/zlib/win64/zdll.libbin15288 -> 16740 bytes
-rwxr-xr-xcompat/zlib/win64/zlib1.dllbin112640 -> 116736 bytes
-rw-r--r--compat/zlib/zconf.h41
-rw-r--r--compat/zlib/zconf.h.cmakein41
-rw-r--r--compat/zlib/zconf.h.in41
-rw-r--r--compat/zlib/zlib.372
-rw-r--r--compat/zlib/zlib.3.pdfbin8734 -> 19318 bytes
-rw-r--r--compat/zlib/zlib.h452
-rw-r--r--compat/zlib/zlib.map177
-rwxr-xr-x[-rw-r--r--]compat/zlib/zlib2ansi0
-rw-r--r--compat/zlib/zutil.c49
-rw-r--r--compat/zlib/zutil.h52
-rw-r--r--doc/Eval.32
-rw-r--r--doc/GetInt.331
-rw-r--r--doc/InitStubs.36
-rw-r--r--doc/IntObj.32
-rw-r--r--doc/LinkVar.348
-rw-r--r--doc/OpenTcp.318
-rw-r--r--doc/RecEvalObj.32
-rw-r--r--doc/concat.n1
-rw-r--r--doc/expr.n389
-rw-r--r--doc/file.n2
-rw-r--r--doc/http.n5
-rw-r--r--doc/info.n7
-rw-r--r--doc/lsort.n3
-rw-r--r--doc/package.n8
-rw-r--r--doc/re_syntax.n6
-rw-r--r--doc/scan.n4
-rw-r--r--doc/socket.n10
-rw-r--r--doc/variable.n7
-rw-r--r--generic/regc_lex.c6
-rw-r--r--generic/regc_locale.c2
-rw-r--r--generic/regc_nfa.c4
-rw-r--r--generic/regcomp.c12
-rw-r--r--generic/regcustom.h7
-rw-r--r--generic/regexec.c4
-rw-r--r--generic/regguts.h34
-rw-r--r--generic/tcl.decls13
-rw-r--r--generic/tcl.h59
-rw-r--r--generic/tclAlloc.c44
-rw-r--r--generic/tclAssembly.c62
-rw-r--r--generic/tclBasic.c120
-rw-r--r--generic/tclBinary.c176
-rw-r--r--generic/tclCkalloc.c100
-rw-r--r--generic/tclClock.c29
-rw-r--r--generic/tclCmdAH.c409
-rw-r--r--generic/tclCmdIL.c61
-rw-r--r--generic/tclCmdMZ.c264
-rw-r--r--generic/tclCompCmds.c110
-rw-r--r--generic/tclCompCmdsSZ.c8
-rw-r--r--generic/tclCompile.c24
-rw-r--r--generic/tclCompile.h8
-rw-r--r--generic/tclConfig.c8
-rw-r--r--generic/tclDecls.h71
-rw-r--r--generic/tclDictObj.c65
-rw-r--r--generic/tclDisassemble.c12
-rw-r--r--generic/tclEncoding.c33
-rw-r--r--generic/tclEnsemble.c16
-rw-r--r--generic/tclEvent.c4
-rw-r--r--generic/tclExecute.c422
-rw-r--r--generic/tclHash.c4
-rw-r--r--generic/tclHistory.c5
-rw-r--r--generic/tclIO.c778
-rw-r--r--generic/tclIO.h2
-rw-r--r--generic/tclIOCmd.c102
-rw-r--r--generic/tclIOGT.c4
-rw-r--r--generic/tclIORChan.c83
-rw-r--r--generic/tclIORTrans.c28
-rw-r--r--generic/tclIOSock.c97
-rw-r--r--generic/tclIOUtil.c58
-rw-r--r--generic/tclIndexObj.c2
-rw-r--r--generic/tclInt.decls2
-rw-r--r--generic/tclInt.h130
-rw-r--r--generic/tclIntPlatDecls.h12
-rw-r--r--generic/tclInterp.c34
-rw-r--r--generic/tclLink.c208
-rw-r--r--generic/tclListObj.c32
-rw-r--r--generic/tclLoad.c57
-rw-r--r--generic/tclNamesp.c12
-rw-r--r--generic/tclOOCall.c2
-rw-r--r--generic/tclOODefineCmds.c12
-rw-r--r--generic/tclOOInt.h2
-rw-r--r--generic/tclObj.c89
-rw-r--r--generic/tclParse.c5
-rw-r--r--generic/tclPathObj.c2
-rw-r--r--generic/tclPipe.c2
-rw-r--r--generic/tclPkg.c144
-rw-r--r--generic/tclPreserve.c10
-rw-r--r--generic/tclProc.c10
-rw-r--r--generic/tclRegexp.c17
-rw-r--r--generic/tclRegexp.h2
-rw-r--r--generic/tclResult.c59
-rw-r--r--generic/tclStrToD.c40
-rw-r--r--generic/tclStringObj.c728
-rw-r--r--generic/tclStringRep.h10
-rw-r--r--generic/tclStubInit.c114
-rw-r--r--generic/tclStubLib.c16
-rw-r--r--generic/tclTest.c229
-rw-r--r--generic/tclTestObj.c51
-rw-r--r--generic/tclThreadAlloc.c51
-rw-r--r--generic/tclThreadTest.c4
-rw-r--r--generic/tclTimer.c12
-rw-r--r--generic/tclTomMath.decls9
-rw-r--r--generic/tclTomMath.h272
-rw-r--r--generic/tclTomMathDecls.h16
-rw-r--r--generic/tclTrace.c8
-rw-r--r--generic/tclUtil.c54
-rw-r--r--generic/tclVar.c20
-rw-r--r--generic/tclZlib.c157
-rw-r--r--[-rwxr-xr-x]library/clock.tcl0
-rw-r--r--library/history.tcl24
-rw-r--r--library/http/http.tcl40
-rw-r--r--library/http/pkgIndex.tcl4
-rw-r--r--library/init.tcl37
-rw-r--r--library/msgcat/msgcat.tcl2
-rw-r--r--library/package.tcl6
-rw-r--r--library/tclIndex132
-rw-r--r--library/tcltest/tcltest.tcl2
-rw-r--r--library/tzdata/Africa/Accra94
-rw-r--r--library/tzdata/Africa/Bissau2
-rw-r--r--library/tzdata/Africa/Ceuta12
-rw-r--r--library/tzdata/Africa/El_Aaiun2
-rw-r--r--library/tzdata/Africa/Monrovia4
-rw-r--r--library/tzdata/Africa/Nairobi4
-rw-r--r--library/tzdata/Africa/Windhoek2
-rw-r--r--library/tzdata/America/Anchorage11
-rw-r--r--library/tzdata/America/Araguaina110
-rw-r--r--library/tzdata/America/Argentina/Buenos_Aires122
-rw-r--r--library/tzdata/America/Argentina/Catamarca124
-rw-r--r--library/tzdata/America/Argentina/Cordoba122
-rw-r--r--library/tzdata/America/Argentina/Jujuy122
-rw-r--r--library/tzdata/America/Argentina/La_Rioja126
-rw-r--r--library/tzdata/America/Argentina/Mendoza124
-rw-r--r--library/tzdata/America/Argentina/Rio_Gallegos124
-rw-r--r--library/tzdata/America/Argentina/Salta120
-rw-r--r--library/tzdata/America/Argentina/San_Juan126
-rw-r--r--library/tzdata/America/Argentina/San_Luis124
-rw-r--r--library/tzdata/America/Argentina/Tucuman126
-rw-r--r--library/tzdata/America/Argentina/Ushuaia124
-rw-r--r--library/tzdata/America/Asuncion506
-rw-r--r--library/tzdata/America/Bahia126
-rw-r--r--library/tzdata/America/Belem60
-rw-r--r--library/tzdata/America/Belize50
-rw-r--r--library/tzdata/America/Boa_Vista70
-rw-r--r--library/tzdata/America/Bogota6
-rw-r--r--library/tzdata/America/Campo_Grande504
-rw-r--r--library/tzdata/America/Caracas8
-rw-r--r--library/tzdata/America/Cayenne4
-rw-r--r--library/tzdata/America/Cuiaba504
-rw-r--r--library/tzdata/America/Curacao2
-rw-r--r--library/tzdata/America/Danmarkshavn66
-rw-r--r--library/tzdata/America/Eirunepe72
-rw-r--r--library/tzdata/America/Fortaleza86
-rw-r--r--library/tzdata/America/Godthab482
-rw-r--r--library/tzdata/America/Guayaquil4
-rw-r--r--library/tzdata/America/Guyana7
-rw-r--r--library/tzdata/America/La_Paz2
-rw-r--r--library/tzdata/America/Lima20
-rw-r--r--library/tzdata/America/Los_Angeles36
-rw-r--r--library/tzdata/America/Maceio94
-rw-r--r--library/tzdata/America/Manaus68
-rw-r--r--library/tzdata/America/Miquelon456
-rw-r--r--library/tzdata/America/Montevideo176
-rw-r--r--library/tzdata/America/Noronha86
-rw-r--r--library/tzdata/America/Paramaribo5
-rw-r--r--library/tzdata/America/Port-au-Prince166
-rw-r--r--library/tzdata/America/Porto_Velho60
-rw-r--r--library/tzdata/America/Punta_Arenas122
-rw-r--r--library/tzdata/America/Recife86
-rw-r--r--library/tzdata/America/Rio_Branco64
-rw-r--r--library/tzdata/America/Santarem62
-rw-r--r--library/tzdata/America/Santiago562
-rw-r--r--library/tzdata/America/Santo_Domingo10
-rw-r--r--library/tzdata/America/Sao_Paulo506
-rw-r--r--library/tzdata/America/Scoresbysund482
-rw-r--r--library/tzdata/America/Tijuana14
-rw-r--r--library/tzdata/Antarctica/Casey11
-rw-r--r--library/tzdata/Antarctica/Davis12
-rw-r--r--library/tzdata/Antarctica/DumontDUrville4
-rw-r--r--library/tzdata/Antarctica/Macquarie2
-rw-r--r--library/tzdata/Antarctica/Mawson4
-rw-r--r--library/tzdata/Antarctica/Palmer329
-rw-r--r--library/tzdata/Antarctica/Rothera2
-rw-r--r--library/tzdata/Antarctica/Syowa2
-rw-r--r--library/tzdata/Antarctica/Troll382
-rw-r--r--library/tzdata/Antarctica/Vostok2
-rw-r--r--library/tzdata/Asia/Anadyr134
-rw-r--r--library/tzdata/Asia/Aqtau1
-rw-r--r--library/tzdata/Asia/Ashgabat52
-rw-r--r--library/tzdata/Asia/Atyrau58
-rw-r--r--library/tzdata/Asia/Baghdad106
-rw-r--r--library/tzdata/Asia/Baku138
-rw-r--r--library/tzdata/Asia/Bangkok2
-rw-r--r--library/tzdata/Asia/Bishkek105
-rw-r--r--library/tzdata/Asia/Brunei4
-rw-r--r--library/tzdata/Asia/Chita134
-rw-r--r--library/tzdata/Asia/Choibalsan268
-rw-r--r--library/tzdata/Asia/Colombo14
-rw-r--r--library/tzdata/Asia/Dhaka15
-rw-r--r--library/tzdata/Asia/Dili9
-rw-r--r--library/tzdata/Asia/Dubai2
-rw-r--r--library/tzdata/Asia/Dushanbe48
-rw-r--r--library/tzdata/Asia/Famagusta91
-rw-r--r--library/tzdata/Asia/Gaza190
-rw-r--r--library/tzdata/Asia/Hebron190
-rw-r--r--library/tzdata/Asia/Ho_Chi_Minh16
-rw-r--r--library/tzdata/Asia/Hovd266
-rw-r--r--library/tzdata/Asia/Irkutsk132
-rw-r--r--library/tzdata/Asia/Jakarta12
-rw-r--r--library/tzdata/Asia/Jayapura4
-rw-r--r--library/tzdata/Asia/Kabul4
-rw-r--r--library/tzdata/Asia/Kamchatka132
-rw-r--r--library/tzdata/Asia/Karachi8
-rw-r--r--library/tzdata/Asia/Kathmandu4
-rw-r--r--library/tzdata/Asia/Khandyga136
-rw-r--r--library/tzdata/Asia/Kolkata4
-rw-r--r--library/tzdata/Asia/Krasnoyarsk132
-rw-r--r--library/tzdata/Asia/Kuala_Lumpur14
-rw-r--r--library/tzdata/Asia/Kuching37
-rw-r--r--library/tzdata/Asia/Macau82
-rw-r--r--library/tzdata/Asia/Magadan134
-rw-r--r--library/tzdata/Asia/Makassar4
-rw-r--r--library/tzdata/Asia/Manila18
-rw-r--r--library/tzdata/Asia/Omsk132
-rw-r--r--library/tzdata/Asia/Oral4
-rw-r--r--library/tzdata/Asia/Pontianak10
-rw-r--r--library/tzdata/Asia/Pyongyang3
-rw-r--r--library/tzdata/Asia/Qatar4
-rw-r--r--library/tzdata/Asia/Rangoon10
-rw-r--r--library/tzdata/Asia/Riyadh2
-rw-r--r--library/tzdata/Asia/Sakhalin137
-rw-r--r--library/tzdata/Asia/Samarkand53
-rw-r--r--library/tzdata/Asia/Seoul3
-rw-r--r--library/tzdata/Asia/Singapore15
-rw-r--r--library/tzdata/Asia/Srednekolymsk132
-rw-r--r--library/tzdata/Asia/Taipei2
-rw-r--r--library/tzdata/Asia/Tashkent53
-rw-r--r--library/tzdata/Asia/Tbilisi108
-rw-r--r--library/tzdata/Asia/Tehran446
-rw-r--r--library/tzdata/Asia/Thimphu4
-rw-r--r--library/tzdata/Asia/Tokyo2
-rw-r--r--library/tzdata/Asia/Ulaanbaatar266
-rw-r--r--library/tzdata/Asia/Urumqi2
-rw-r--r--library/tzdata/Asia/Ust-Nera132
-rw-r--r--library/tzdata/Asia/Vladivostok132
-rw-r--r--library/tzdata/Asia/Yakutsk132
-rw-r--r--library/tzdata/Asia/Yangon9
-rw-r--r--library/tzdata/Asia/Yekaterinburg132
-rw-r--r--library/tzdata/Asia/Yerevan129
-rw-r--r--library/tzdata/Atlantic/Azores682
-rw-r--r--library/tzdata/Atlantic/Canary2
-rw-r--r--library/tzdata/Atlantic/Cape_Verde8
-rw-r--r--library/tzdata/Atlantic/Madeira190
-rw-r--r--library/tzdata/Atlantic/Reykjavik134
-rw-r--r--library/tzdata/Atlantic/South_Georgia2
-rw-r--r--library/tzdata/Atlantic/Stanley138
-rw-r--r--library/tzdata/Australia/Eucla40
-rw-r--r--library/tzdata/Australia/Lord_Howe477
-rw-r--r--library/tzdata/Etc/GMT+12
-rw-r--r--library/tzdata/Etc/GMT+102
-rw-r--r--library/tzdata/Etc/GMT+112
-rw-r--r--library/tzdata/Etc/GMT+122
-rw-r--r--library/tzdata/Etc/GMT+22
-rw-r--r--library/tzdata/Etc/GMT+32
-rw-r--r--library/tzdata/Etc/GMT+42
-rw-r--r--library/tzdata/Etc/GMT+52
-rw-r--r--library/tzdata/Etc/GMT+62
-rw-r--r--library/tzdata/Etc/GMT+72
-rw-r--r--library/tzdata/Etc/GMT+82
-rw-r--r--library/tzdata/Etc/GMT+92
-rw-r--r--library/tzdata/Etc/GMT-12
-rw-r--r--library/tzdata/Etc/GMT-102
-rw-r--r--library/tzdata/Etc/GMT-112
-rw-r--r--library/tzdata/Etc/GMT-122
-rw-r--r--library/tzdata/Etc/GMT-132
-rw-r--r--library/tzdata/Etc/GMT-142
-rw-r--r--library/tzdata/Etc/GMT-22
-rw-r--r--library/tzdata/Etc/GMT-32
-rw-r--r--library/tzdata/Etc/GMT-42
-rw-r--r--library/tzdata/Etc/GMT-52
-rw-r--r--library/tzdata/Etc/GMT-62
-rw-r--r--library/tzdata/Etc/GMT-72
-rw-r--r--library/tzdata/Etc/GMT-82
-rw-r--r--library/tzdata/Etc/GMT-92
-rw-r--r--library/tzdata/Europe/Amsterdam12
-rw-r--r--library/tzdata/Europe/Istanbul212
-rw-r--r--library/tzdata/Europe/Kaliningrad2
-rw-r--r--library/tzdata/Europe/Kirov2
-rw-r--r--library/tzdata/Europe/Madrid64
-rw-r--r--library/tzdata/Europe/Malta28
-rw-r--r--library/tzdata/Europe/Minsk3
-rw-r--r--library/tzdata/Europe/Moscow4
-rw-r--r--library/tzdata/Europe/Rome33
-rw-r--r--library/tzdata/Europe/Samara136
-rw-r--r--library/tzdata/Europe/Saratov71
-rw-r--r--library/tzdata/Europe/Ulyanovsk2
-rw-r--r--library/tzdata/Europe/Volgograd133
-rw-r--r--library/tzdata/Europe/Zaporozhye2
-rw-r--r--library/tzdata/Indian/Chagos4
-rw-r--r--library/tzdata/Indian/Christmas2
-rw-r--r--library/tzdata/Indian/Cocos2
-rw-r--r--library/tzdata/Indian/Kerguelen2
-rw-r--r--library/tzdata/Indian/Mahe2
-rw-r--r--library/tzdata/Indian/Maldives2
-rw-r--r--library/tzdata/Indian/Mauritius10
-rw-r--r--library/tzdata/Indian/Reunion2
-rw-r--r--library/tzdata/Pacific/Apia364
-rw-r--r--library/tzdata/Pacific/Bougainville8
-rw-r--r--library/tzdata/Pacific/Chatham506
-rw-r--r--library/tzdata/Pacific/Chuuk2
-rw-r--r--library/tzdata/Pacific/Easter524
-rw-r--r--library/tzdata/Pacific/Efate42
-rw-r--r--library/tzdata/Pacific/Enderbury6
-rw-r--r--library/tzdata/Pacific/Fakaofo4
-rw-r--r--library/tzdata/Pacific/Fiji372
-rw-r--r--library/tzdata/Pacific/Funafuti2
-rw-r--r--library/tzdata/Pacific/Galapagos6
-rw-r--r--library/tzdata/Pacific/Gambier2
-rw-r--r--library/tzdata/Pacific/Guadalcanal2
-rw-r--r--library/tzdata/Pacific/Kiritimati6
-rw-r--r--library/tzdata/Pacific/Kosrae6
-rw-r--r--library/tzdata/Pacific/Kwajalein6
-rw-r--r--library/tzdata/Pacific/Majuro4
-rw-r--r--library/tzdata/Pacific/Marquesas2
-rw-r--r--library/tzdata/Pacific/Nauru8
-rw-r--r--library/tzdata/Pacific/Niue6
-rw-r--r--library/tzdata/Pacific/Norfolk10
-rw-r--r--library/tzdata/Pacific/Noumea14
-rw-r--r--library/tzdata/Pacific/Pago_Pago4
-rw-r--r--library/tzdata/Pacific/Palau2
-rw-r--r--library/tzdata/Pacific/Pitcairn4
-rw-r--r--library/tzdata/Pacific/Pohnpei2
-rw-r--r--library/tzdata/Pacific/Port_Moresby2
-rw-r--r--library/tzdata/Pacific/Rarotonga54
-rw-r--r--library/tzdata/Pacific/Tahiti2
-rw-r--r--library/tzdata/Pacific/Tarawa2
-rw-r--r--library/tzdata/Pacific/Tongatapu185
-rw-r--r--library/tzdata/Pacific/Wake2
-rw-r--r--library/tzdata/Pacific/Wallis2
-rw-r--r--libtommath/LICENSE29
-rw-r--r--libtommath/bn.ilg6
-rw-r--r--libtommath/bn.ind82
-rw-r--r--libtommath/bn.pdfbin340921 -> 0 bytes
-rw-r--r--libtommath/bn.tex1835
-rw-r--r--libtommath/bn_error.c12
-rw-r--r--libtommath/bn_fast_mp_invmod.c20
-rw-r--r--libtommath/bn_fast_mp_montgomery_reduce.c32
-rw-r--r--libtommath/bn_fast_s_mp_mul_digs.c16
-rw-r--r--libtommath/bn_fast_s_mp_mul_high_digs.c10
-rw-r--r--libtommath/bn_fast_s_mp_sqr.c10
-rw-r--r--libtommath/bn_mp_2expt.c12
-rw-r--r--libtommath/bn_mp_abs.c8
-rw-r--r--libtommath/bn_mp_add.c8
-rw-r--r--libtommath/bn_mp_add_d.c17
-rw-r--r--libtommath/bn_mp_addmod.c8
-rw-r--r--libtommath/bn_mp_and.c8
-rw-r--r--libtommath/bn_mp_clamp.c10
-rw-r--r--libtommath/bn_mp_clear.c8
-rw-r--r--libtommath/bn_mp_clear_multi.c8
-rw-r--r--libtommath/bn_mp_cmp.c8
-rw-r--r--libtommath/bn_mp_cmp_d.c8
-rw-r--r--libtommath/bn_mp_cmp_mag.c8
-rw-r--r--libtommath/bn_mp_cnt_lsb.c12
-rw-r--r--libtommath/bn_mp_copy.c10
-rw-r--r--libtommath/bn_mp_count_bits.c8
-rw-r--r--libtommath/bn_mp_div.c81
-rw-r--r--libtommath/bn_mp_div_2.c10
-rw-r--r--libtommath/bn_mp_div_2d.c10
-rw-r--r--libtommath/bn_mp_div_3.c8
-rw-r--r--libtommath/bn_mp_div_d.c12
-rw-r--r--libtommath/bn_mp_dr_is_modulus.c8
-rw-r--r--libtommath/bn_mp_dr_reduce.c16
-rw-r--r--libtommath/bn_mp_dr_setup.c8
-rw-r--r--libtommath/bn_mp_exch.c8
-rw-r--r--libtommath/bn_mp_export.c88
-rw-r--r--libtommath/bn_mp_expt_d.c43
-rw-r--r--libtommath/bn_mp_expt_d_ex.c83
-rw-r--r--libtommath/bn_mp_exptmod.c10
-rw-r--r--libtommath/bn_mp_exptmod_fast.c19
-rw-r--r--libtommath/bn_mp_exteuclid.c16
-rw-r--r--libtommath/bn_mp_fread.c8
-rw-r--r--libtommath/bn_mp_fwrite.c8
-rw-r--r--libtommath/bn_mp_gcd.c10
-rw-r--r--libtommath/bn_mp_get_int.c16
-rw-r--r--libtommath/bn_mp_get_long.c41
-rw-r--r--libtommath/bn_mp_get_long_long.c41
-rw-r--r--libtommath/bn_mp_grow.c8
-rw-r--r--libtommath/bn_mp_import.c73
-rw-r--r--libtommath/bn_mp_init.c8
-rw-r--r--libtommath/bn_mp_init_copy.c12
-rw-r--r--libtommath/bn_mp_init_multi.c10
-rw-r--r--libtommath/bn_mp_init_set.c8
-rw-r--r--libtommath/bn_mp_init_set_int.c8
-rw-r--r--libtommath/bn_mp_init_size.c8
-rw-r--r--libtommath/bn_mp_invmod.c16
-rw-r--r--libtommath/bn_mp_invmod_slow.c22
-rw-r--r--libtommath/bn_mp_is_square.c22
-rw-r--r--libtommath/bn_mp_jacobi.c44
-rw-r--r--libtommath/bn_mp_karatsuba_mul.c12
-rw-r--r--libtommath/bn_mp_karatsuba_sqr.c12
-rw-r--r--libtommath/bn_mp_lcm.c8
-rw-r--r--libtommath/bn_mp_lshd.c14
-rw-r--r--libtommath/bn_mp_mod.c16
-rw-r--r--libtommath/bn_mp_mod_2d.c10
-rw-r--r--libtommath/bn_mp_mod_d.c8
-rw-r--r--libtommath/bn_mp_montgomery_calc_normalization.c10
-rw-r--r--libtommath/bn_mp_montgomery_reduce.c28
-rw-r--r--libtommath/bn_mp_montgomery_setup.c18
-rw-r--r--libtommath/bn_mp_mul.c15
-rw-r--r--libtommath/bn_mp_mul_2.c12
-rw-r--r--libtommath/bn_mp_mul_2d.c16
-rw-r--r--libtommath/bn_mp_mul_d.c12
-rw-r--r--libtommath/bn_mp_mulmod.c8
-rw-r--r--libtommath/bn_mp_n_root.c118
-rw-r--r--libtommath/bn_mp_n_root_ex.c132
-rw-r--r--libtommath/bn_mp_neg.c8
-rw-r--r--libtommath/bn_mp_or.c8
-rw-r--r--libtommath/bn_mp_prime_fermat.c8
-rw-r--r--libtommath/bn_mp_prime_is_divisible.c8
-rw-r--r--libtommath/bn_mp_prime_is_prime.c10
-rw-r--r--libtommath/bn_mp_prime_miller_rabin.c12
-rw-r--r--libtommath/bn_mp_prime_next_prime.c18
-rw-r--r--libtommath/bn_mp_prime_rabin_miller_trials.c8
-rw-r--r--libtommath/bn_mp_prime_random_ex.c21
-rw-r--r--libtommath/bn_mp_radix_size.c37
-rw-r--r--libtommath/bn_mp_radix_smap.c8
-rw-r--r--libtommath/bn_mp_rand.c12
-rw-r--r--libtommath/bn_mp_read_radix.c18
-rw-r--r--libtommath/bn_mp_read_signed_bin.c8
-rw-r--r--libtommath/bn_mp_read_unsigned_bin.c18
-rw-r--r--libtommath/bn_mp_reduce.c22
-rw-r--r--libtommath/bn_mp_reduce_2k.c28
-rw-r--r--libtommath/bn_mp_reduce_2k_l.c30
-rw-r--r--libtommath/bn_mp_reduce_2k_setup.c8
-rw-r--r--libtommath/bn_mp_reduce_2k_setup_l.c8
-rw-r--r--libtommath/bn_mp_reduce_is_2k.c8
-rw-r--r--libtommath/bn_mp_reduce_is_2k_l.c8
-rw-r--r--libtommath/bn_mp_reduce_setup.c8
-rw-r--r--libtommath/bn_mp_rshd.c10
-rw-r--r--libtommath/bn_mp_set.c8
-rw-r--r--libtommath/bn_mp_set_int.c8
-rw-r--r--libtommath/bn_mp_set_long.c24
-rw-r--r--libtommath/bn_mp_set_long_long.c24
-rw-r--r--libtommath/bn_mp_shrink.c11
-rw-r--r--libtommath/bn_mp_signed_bin_size.c8
-rw-r--r--libtommath/bn_mp_sqr.c18
-rw-r--r--libtommath/bn_mp_sqrmod.c8
-rw-r--r--libtommath/bn_mp_sqrt.c9
-rw-r--r--libtommath/bn_mp_sqrtmod_prime.c124
-rw-r--r--libtommath/bn_mp_sub.c8
-rw-r--r--libtommath/bn_mp_sub_d.c16
-rw-r--r--libtommath/bn_mp_submod.c8
-rw-r--r--libtommath/bn_mp_to_signed_bin.c10
-rw-r--r--libtommath/bn_mp_to_signed_bin_n.c8
-rw-r--r--libtommath/bn_mp_to_unsigned_bin.c10
-rw-r--r--libtommath/bn_mp_to_unsigned_bin_n.c8
-rw-r--r--libtommath/bn_mp_toom_mul.c276
-rw-r--r--libtommath/bn_mp_toom_sqr.c212
-rw-r--r--libtommath/bn_mp_toradix.c14
-rw-r--r--libtommath/bn_mp_toradix_n.c12
-rw-r--r--libtommath/bn_mp_unsigned_bin_size.c10
-rw-r--r--libtommath/bn_mp_xor.c8
-rw-r--r--libtommath/bn_mp_zero.c8
-rw-r--r--libtommath/bn_prime_tab.c8
-rw-r--r--libtommath/bn_reverse.c8
-rw-r--r--libtommath/bn_s_mp_add.c14
-rw-r--r--libtommath/bn_s_mp_exptmod.c14
-rw-r--r--libtommath/bn_s_mp_mul_digs.c20
-rw-r--r--libtommath/bn_s_mp_mul_high_digs.c16
-rw-r--r--libtommath/bn_s_mp_sqr.c18
-rw-r--r--libtommath/bn_s_mp_sub.c18
-rw-r--r--libtommath/bncore.c8
-rw-r--r--libtommath/booker.pl265
-rw-r--r--libtommath/callgraph.txt12047
-rw-r--r--libtommath/changes.txt45
-rw-r--r--libtommath/demo/demo.c736
-rw-r--r--libtommath/demo/timing.c315
-rw-r--r--libtommath/dep.pl123
-rw-r--r--libtommath/etc/2kprime.12
-rw-r--r--libtommath/etc/2kprime.c75
-rw-r--r--libtommath/etc/drprime.c59
-rw-r--r--libtommath/etc/drprimes.2825
-rw-r--r--libtommath/etc/drprimes.txt9
-rw-r--r--libtommath/etc/makefile50
-rw-r--r--libtommath/etc/makefile.icc67
-rw-r--r--libtommath/etc/makefile.msvc23
-rw-r--r--libtommath/etc/mersenne.c140
-rw-r--r--libtommath/etc/mont.c41
-rw-r--r--libtommath/etc/pprime.c396
-rw-r--r--libtommath/etc/prime.1024414
-rw-r--r--libtommath/etc/prime.512205
-rw-r--r--libtommath/etc/timer.asm37
-rw-r--r--libtommath/etc/tune.c138
-rw-r--r--libtommath/gen.pl17
-rw-r--r--libtommath/logs/README13
-rw-r--r--libtommath/logs/add.log16
-rw-r--r--libtommath/logs/addsub.pngbin6253 -> 0 bytes
-rw-r--r--libtommath/logs/expt.log7
-rw-r--r--libtommath/logs/expt.pngbin6604 -> 0 bytes
-rw-r--r--libtommath/logs/expt_2k.log5
-rw-r--r--libtommath/logs/expt_2kl.log4
-rw-r--r--libtommath/logs/expt_dr.log7
-rw-r--r--libtommath/logs/graphs.dem17
-rw-r--r--libtommath/logs/index.html24
-rw-r--r--libtommath/logs/invmod.log0
-rw-r--r--libtommath/logs/invmod.pngbin4917 -> 0 bytes
-rw-r--r--libtommath/logs/mult.log84
-rw-r--r--libtommath/logs/mult.pngbin6769 -> 0 bytes
-rw-r--r--libtommath/logs/mult_kara.log84
-rw-r--r--libtommath/logs/sqr.log84
-rw-r--r--libtommath/logs/sqr_kara.log84
-rw-r--r--libtommath/logs/sub.log16
-rw-r--r--libtommath/makefile217
-rw-r--r--libtommath/makefile.bcc56
-rw-r--r--libtommath/makefile.cygwin_dll58
-rw-r--r--libtommath/makefile.icc71
-rw-r--r--libtommath/makefile.include105
-rw-r--r--libtommath/makefile.msvc54
-rw-r--r--libtommath/makefile.shared137
-rw-r--r--libtommath/mess.sh4
-rw-r--r--libtommath/mtest/logtab.h19
-rw-r--r--libtommath/mtest/mpi-config.h85
-rw-r--r--libtommath/mtest/mpi-types.h15
-rw-r--r--libtommath/mtest/mpi.c3979
-rw-r--r--libtommath/mtest/mpi.h225
-rw-r--r--libtommath/mtest/mtest.c304
-rw-r--r--libtommath/pics/design_process.sxdbin6950 -> 0 bytes
-rw-r--r--libtommath/pics/design_process.tifbin79042 -> 0 bytes
-rw-r--r--libtommath/pics/expt_state.sxdbin6869 -> 0 bytes
-rw-r--r--libtommath/pics/expt_state.tifbin87540 -> 0 bytes
-rw-r--r--libtommath/pics/makefile35
-rw-r--r--libtommath/pics/primality.tifbin85512 -> 0 bytes
-rw-r--r--libtommath/pics/radix.sxdbin6181 -> 0 bytes
-rw-r--r--libtommath/pics/sliding_window.sxdbin6787 -> 0 bytes
-rw-r--r--libtommath/pics/sliding_window.tifbin53880 -> 0 bytes
-rw-r--r--libtommath/poster.out0
-rw-r--r--libtommath/poster.pdfbin37822 -> 0 bytes
-rw-r--r--libtommath/poster.tex35
-rw-r--r--libtommath/pre_gen/mpi.c9048
-rw-r--r--libtommath/pretty.build66
-rw-r--r--libtommath/tombc/grammar.txt35
-rw-r--r--libtommath/tommath.h218
-rw-r--r--libtommath/tommath.out139
-rw-r--r--libtommath/tommath.pdfbin1194158 -> 0 bytes
-rw-r--r--libtommath/tommath.src6350
-rw-r--r--libtommath/tommath.tex6691
-rw-r--r--libtommath/tommath_class.h80
-rw-r--r--libtommath/tommath_private.h125
-rw-r--r--libtommath/tommath_superclass.h8
-rw-r--r--macosx/Tcl-Common.xcconfig2
-rw-r--r--macosx/Tcl.xcode/project.pbxproj5
-rw-r--r--macosx/Tcl.xcodeproj/project.pbxproj8
-rw-r--r--macosx/tclMacOSXFCmd.c6
-rw-r--r--macosx/tclMacOSXNotify.c5
-rw-r--r--tests/all.tcl2
-rw-r--r--tests/binary.test13
-rw-r--r--tests/case.test5
-rw-r--r--tests/chanio.test2
-rw-r--r--tests/clock.test4
-rw-r--r--tests/cmdAH.test4
-rw-r--r--tests/cmdMZ.test2
-rw-r--r--tests/coroutine.test39
-rw-r--r--tests/expr.test9
-rw-r--r--tests/fCmd.test16
-rw-r--r--tests/format.test32
-rw-r--r--tests/get.test22
-rw-r--r--tests/history.test58
-rw-r--r--tests/http.test16
-rw-r--r--tests/httpd11
-rw-r--r--tests/httpd11.tcl2
-rw-r--r--tests/httpold.test6
-rw-r--r--tests/incr.test12
-rw-r--r--tests/info.test4
-rw-r--r--tests/interp.test15
-rw-r--r--tests/link.test84
-rw-r--r--tests/load.test25
-rw-r--r--tests/main.test2
-rw-r--r--tests/msgcat.test2
-rw-r--r--tests/nre.test6
-rw-r--r--tests/obj.test13
-rw-r--r--tests/oo.test38
-rw-r--r--tests/package.test2
-rw-r--r--tests/parseExpr.test5
-rw-r--r--tests/registry.test8
-rw-r--r--tests/result.test4
-rw-r--r--tests/safe.test2
-rw-r--r--tests/scan.test6
-rw-r--r--tests/set-old.test7
-rw-r--r--tests/socket.test84
-rw-r--r--tests/string.test8
-rw-r--r--tests/stringComp.test3
-rw-r--r--tests/tm.test2
-rw-r--r--tests/util.test49
-rw-r--r--tests/winFCmd.test72
-rw-r--r--tests/winFile.test18
-rw-r--r--tests/winPipe.test6
-rw-r--r--tests/zlib.test83
-rwxr-xr-xtools/configure2
-rw-r--r--tools/genStubs.tcl18
-rw-r--r--tools/tcltk-man2html-utils.tcl14
-rwxr-xr-xtools/tcltk-man2html.tcl4
-rw-r--r--tools/tsdPerf.c2
-rw-r--r--unix/Makefile.in10
-rwxr-xr-xunix/configure5
-rw-r--r--unix/configure.ac1
-rw-r--r--unix/dltest/pkga.c2
-rw-r--r--unix/dltest/pkgc.c4
-rw-r--r--unix/dltest/pkgd.c4
-rw-r--r--unix/dltest/pkge.c2
-rw-r--r--unix/dltest/pkgooa.c2
-rw-r--r--unix/dltest/pkgua.c2
-rw-r--r--unix/tcl.m44
-rw-r--r--unix/tclConfig.h.in3
-rw-r--r--unix/tclUnixCompat.c4
-rw-r--r--unix/tclUnixFCmd.c28
-rw-r--r--unix/tclUnixFile.c15
-rw-r--r--unix/tclUnixInit.c11
-rw-r--r--unix/tclUnixNotfy.c8
-rw-r--r--unix/tclUnixSock.c402
-rw-r--r--unix/tclUnixThrd.c14
-rw-r--r--unix/tclUnixTime.c9
-rw-r--r--unix/tclXtTest.c2
-rw-r--r--win/Makefile.in9
-rwxr-xr-xwin/configure2
-rw-r--r--win/makefile.bc594
-rw-r--r--win/makefile.vc7
-rw-r--r--win/nmakehlp.c24
-rw-r--r--win/rules.vc15
-rw-r--r--win/tcl.dsp20
-rw-r--r--win/tcl.m42
-rw-r--r--win/tclWin32Dll.c6
-rw-r--r--win/tclWinFCmd.c14
-rw-r--r--[-rwxr-xr-x]win/tclWinFile.c24
-rw-r--r--win/tclWinInit.c17
-rw-r--r--win/tclWinPort.h2
-rw-r--r--win/tclWinSock.c742
-rw-r--r--win/tclWinThrd.c8
-rw-r--r--win/tclWinTime.c72
744 files changed, 32805 insertions, 56136 deletions
diff --git a/.fossil-settings/binary-glob b/.fossil-settings/binary-glob
index ca85874..ec574be 100644
--- a/.fossil-settings/binary-glob
+++ b/.fossil-settings/binary-glob
@@ -1,3 +1,9 @@
+compat/zlib/win32/zdll.lib
+compat/zlib/win32/zlib1.dll
+compat/zlib/win64/zdll.lib
+compat/zlib/win64/zlib1.dll
+compat/zlib/win64/libz.dll.a
+compat/zlib/zlib.3.pdf
*.bmp
*.gif
-*.png
+*.png \ No newline at end of file
diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob
new file mode 100644
index 0000000..f219a75
--- /dev/null
+++ b/.fossil-settings/crlf-glob
@@ -0,0 +1,14 @@
+compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
+compat/zlib/contrib/vstudio/readme.txt
+compat/zlib/contrib/vstudio/*/zlib.rc
+compat/zlib/win32/*.txt
+compat/zlib/win64/*.txt
+tools/tcl.hpj.in
+tools/tcl.wse.in
+win/buildall.vc.bat
+win/coffbase.txt
+win/makefile.vc
+win/rules.vc
+win/tcl.dsp
+win/tcl.dsw
+win/tcl.hpj.in \ No newline at end of file
diff --git a/.fossil-settings/crnl-glob b/.fossil-settings/crnl-glob
index c014320..f219a75 100644
--- a/.fossil-settings/crnl-glob
+++ b/.fossil-settings/crnl-glob
@@ -1,10 +1,14 @@
+compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
+compat/zlib/contrib/vstudio/readme.txt
+compat/zlib/contrib/vstudio/*/zlib.rc
+compat/zlib/win32/*.txt
+compat/zlib/win64/*.txt
tools/tcl.hpj.in
tools/tcl.wse.in
win/buildall.vc.bat
win/coffbase.txt
-win/makefile.bc
win/makefile.vc
win/rules.vc
win/tcl.dsp
win/tcl.dsw
-win/tcl.hpj.in
+win/tcl.hpj.in \ No newline at end of file
diff --git a/.fossil-settings/encoding-glob b/.fossil-settings/encoding-glob
index c014320..8582dd4 100644
--- a/.fossil-settings/encoding-glob
+++ b/.fossil-settings/encoding-glob
@@ -2,9 +2,8 @@ tools/tcl.hpj.in
tools/tcl.wse.in
win/buildall.vc.bat
win/coffbase.txt
-win/makefile.bc
win/makefile.vc
win/rules.vc
win/tcl.dsp
win/tcl.dsw
-win/tcl.hpj.in
+win/tcl.hpj.in \ No newline at end of file
diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob
index 51ca1e2..08d388d 100644
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -6,6 +6,7 @@
*.lib
*.o
*.obj
+*.pdb
*.res
*.sl
*.so
@@ -17,10 +18,29 @@
*/tclsh*
*/tcltest*
*/versions.vc
+html
+libtommath/bn.ilg
+libtommath/bn.ind
+libtommath/pretty.build
+libtommath/tommath.src
+libtommath/*.pdf
+libtommath/*.pl
+libtommath/*.sh
+libtommath/tombc/*
+libtommath/pre_gen/*
+libtommath/pics/*
+libtommath/mtest/*
+libtommath/logs/*
+libtommath/etc/*
+libtommath/demo/*
+libtommath/*.out
+libtommath/*.tex
unix/autoMkindex.tcl
unix/dltest.marker
unix/tcl.pc
unix/tclIndex
unix/pkgs/*
+win/Debug_VC*
+win/Release_VC*
win/pkgs/*
-win/tcl.hpj
+win/tcl.hpj \ No newline at end of file
diff --git a/ChangeLog.2000 b/ChangeLog.2000
index 0d20eaf..5b62351 100644
--- a/ChangeLog.2000
+++ b/ChangeLog.2000
@@ -414,7 +414,7 @@
Tcl_IsChannelExisting, and Tcl_ClearChannelHandlers to conform to the
new stacked channel implementation. Their stub slots were also moved
to give preference to the new 8.3.2 stub functions. This will cause an
- incompatability with 8.4a1 only.
+ incompatibility with 8.4a1 only.
(StopCopy): fixed a bug introduced by a partial fix in 8.3.2 that
didn't set nonBlocking correctly when resetting the flags for the
write side. [Bug: 6261]
diff --git a/ChangeLog.2002 b/ChangeLog.2002
index 30b8b17..9931657 100644
--- a/ChangeLog.2002
+++ b/ChangeLog.2002
@@ -847,7 +847,7 @@
exit.
* tests/exec.test: marked exec-18.1 unixOnly until the Windows
- incompatability (in the test, not the core) can be resolved.
+ incompatibility (in the test, not the core) can be resolved.
* tests/http.test (http-3.11): added close $fp that was causing an
error on Windows because the file was not closed before deleting.
@@ -3642,7 +3642,7 @@
* compat/strtoll.c (strtoll):
* compat/strtoull.c (strtoull):
* unix/tclUnixPort.h:
- * win/tclWinPort.h: Const-ing 64-bit compatability declarations. Note
+ * win/tclWinPort.h: Const-ing 64-bit compatibility declarations. Note
that the return pointer is non-const because it is entirely legal for
the functions to be called from somewhere that owns the string being
passed. Fixes problem reported by Larry Virden.
@@ -3779,7 +3779,7 @@
There are a lot of changes from this TIP, so please see
http://purl.org/tcl/tip/72.html for discussion of
- backward-compatability issues, but the main ones modifications are in:
+ backward-compatibility issues, but the main ones modifications are in:
* generic/tcl.h: New types.
* generic/tcl.decls: New public functions.
diff --git a/ChangeLog.2003 b/ChangeLog.2003
index c586ba9..3c3ee11 100644
--- a/ChangeLog.2003
+++ b/ChangeLog.2003
@@ -947,7 +947,7 @@
declarations match and will end up using the declarations in the
public code from now on because of #include ordering. Keeping the old
declarations in tclInt.decls; there's no need to gratuitously break
- compatability for those extensions which are already clients of the
+ compatibility for those extensions which are already clients of the
namespace code.
2003-08-23 Zoran Vasiljevic <zoran@archiwrae.com>
@@ -1278,7 +1278,7 @@
* generic/tclVar.c (Tcl_ArrayObjCmd, TclArraySet): Made [array get]
and [array set] work with dictionaries, producing them and consuming
- them. Note that for compatability reasons, you will never get a dict
+ them. Note that for compatibility reasons, you will never get a dict
from feeding a string literal to [array set] since that alters the
trace behaviour of "multi-key" sets. [Bug 759935]
diff --git a/ChangeLog.2004 b/ChangeLog.2004
index 82acd5c..daf124f 100644
--- a/ChangeLog.2004
+++ b/ChangeLog.2004
@@ -1356,7 +1356,7 @@
2004-10-07 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* *.3: Convert CONST to const and VOID to void so we document how
- people should actually use the Tcl API and not the compatability hacks
+ people should actually use the Tcl API and not the compatibility hacks
that it has to have.
* doc/man.macros, *.3: Update .AS macro so it can know how wide to
diff --git a/compat/opendir.c b/compat/opendir.c
index 22e8a3a..7a49566 100644
--- a/compat/opendir.c
+++ b/compat/opendir.c
@@ -106,5 +106,5 @@ closedir(
close(dirp->dd_fd);
dirp->dd_fd = -1;
dirp->dd_loc = 0;
- ckfree((char *) dirp);
+ ckfree(dirp);
}
diff --git a/compat/waitpid.c b/compat/waitpid.c
index e03275a..d4473a8 100644
--- a/compat/waitpid.c
+++ b/compat/waitpid.c
@@ -100,7 +100,7 @@ waitpid(
} else {
prevPtr->nextPtr = waitPtr->nextPtr;
}
- ckfree((char *) waitPtr);
+ ckfree(waitPtr);
return result;
}
diff --git a/compat/zlib/CMakeLists.txt b/compat/zlib/CMakeLists.txt
index 0c0247c..0fe939d 100644
--- a/compat/zlib/CMakeLists.txt
+++ b/compat/zlib/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)
-set(VERSION "1.2.8")
+set(VERSION "1.2.11")
option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
diff --git a/compat/zlib/ChangeLog b/compat/zlib/ChangeLog
index f22aaba..30199a6 100644
--- a/compat/zlib/ChangeLog
+++ b/compat/zlib/ChangeLog
@@ -1,10 +1,53 @@
ChangeLog file for zlib
+Changes in 1.2.11 (15 Jan 2017)
+- Fix deflate stored bug when pulling last block from window
+- Permit immediate deflateParams changes before any deflate input
+
+Changes in 1.2.10 (2 Jan 2017)
+- Avoid warnings on snprintf() return value
+- Fix bug in deflate_stored() for zero-length input
+- Fix bug in gzwrite.c that produced corrupt gzip files
+- Remove files to be installed before copying them in Makefile.in
+- Add warnings when compiling with assembler code
+
+Changes in 1.2.9 (31 Dec 2016)
+- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
+- Improve contrib/blast to return unused bytes
+- Assure that gzoffset() is correct when appending
+- Improve compress() and uncompress() to support large lengths
+- Fix bug in test/example.c where error code not saved
+- Remedy Coverity warning [Randers-Pehrson]
+- Improve speed of gzprintf() in transparent mode
+- Fix inflateInit2() bug when windowBits is 16 or 32
+- Change DEBUG macro to ZLIB_DEBUG
+- Avoid uninitialized access by gzclose_w()
+- Allow building zlib outside of the source directory
+- Fix bug that accepted invalid zlib header when windowBits is zero
+- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
+- Loop on write() calls in gzwrite.c in case of non-blocking I/O
+- Add --warn (-w) option to ./configure for more compiler warnings
+- Reject a window size of 256 bytes if not using the zlib wrapper
+- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
+- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
+- Fix bugs in creating a very large gzip header
+- Add uncompress2() function, which returns the input size used
+- Assure that deflateParams() will not switch functions mid-block
+- Dramatically speed up deflation for level 0 (storing)
+- Add gzfread(), duplicating the interface of fread()
+- Add gzfwrite(), duplicating the interface of fwrite()
+- Add deflateGetDictionary() function
+- Use snprintf() for later versions of Microsoft C
+- Fix *Init macros to use z_ prefix when requested
+- Replace as400 with os400 for OS/400 support [Monnerat]
+- Add crc32_z() and adler32_z() functions with size_t lengths
+- Update Visual Studio project files [AraHaan]
+
Changes in 1.2.8 (28 Apr 2013)
- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
- Do not force Z_CONST for C++
-- Clean up contrib/vstudio [Ro§]
+- Clean up contrib/vstudio [Roß]
- Correct spelling error in zlib.h
- Fix mixed line endings in contrib/vstudio
@@ -34,7 +77,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
- Clean up the usage of z_const and respect const usage within zlib
- Clean up examples/gzlog.[ch] comparisons of different types
- Avoid shift equal to bits in type (caused endless loop)
-- Fix unintialized value bug in gzputc() introduced by const patches
+- Fix uninitialized value bug in gzputc() introduced by const patches
- Fix memory allocation error in examples/zran.c [Nor]
- Fix bug where gzopen(), gzclose() would write an empty file
- Fix bug in gzclose() when gzwrite() runs out of memory
@@ -194,7 +237,7 @@ Changes in 1.2.5.2 (17 Dec 2011)
- Add a transparent write mode to gzopen() when 'T' is in the mode
- Update python link in zlib man page
- Get inffixed.h and MAKEFIXED result to match
-- Add a ./config --solo option to make zlib subset with no libary use
+- Add a ./config --solo option to make zlib subset with no library use
- Add undocumented inflateResetKeep() function for CAB file decoding
- Add --cover option to ./configure for gcc coverage testing
- Add #define ZLIB_CONST option to use const in the z_stream interface
@@ -564,7 +607,7 @@ Changes in 1.2.3.1 (16 August 2006)
- Update make_vms.com [Zinser]
- Use -fPIC for shared build in configure [Teredesai, Nicholson]
- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
-- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck]
+- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
- Add some FAQ entries about the contrib directory
- Update the MVS question in the FAQ
- Avoid extraneous reads after EOF in gzio.c [Brown]
@@ -1178,7 +1221,7 @@ Changes in 1.0.6 (19 Jan 1998)
386 asm code replacing longest_match().
contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
A C++ I/O streams interface to the zlib gz* functions
- contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
+ contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
Another C++ I/O streams interface
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
A very simple tar.gz file extractor using zlib
@@ -1267,7 +1310,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
- fix array overlay in deflate.c which sometimes caused bad compressed data
- fix inflate bug with empty stored block
- fix MSDOS medium model which was broken in 0.99
-- fix deflateParams() which could generated bad compressed data.
+- fix deflateParams() which could generate bad compressed data.
- Bytef is define'd instead of typedef'ed (work around Borland bug)
- added an INDEX file
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
diff --git a/compat/zlib/Makefile.in b/compat/zlib/Makefile.in
index c61aa30..5a77949 100644
--- a/compat/zlib/Makefile.in
+++ b/compat/zlib/Makefile.in
@@ -1,5 +1,5 @@
# Makefile for zlib
-# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
+# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
@@ -20,7 +20,7 @@ CC=cc
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
+#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
@@ -32,7 +32,7 @@ CPP=$(CC) -E
STATICLIB=libz.a
SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.8
+SHAREDLIBV=libz.so.1.2.11
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV)
@@ -53,6 +53,9 @@ includedir = ${prefix}/include
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
pkgconfigdir = ${libdir}/pkgconfig
+SRCDIR=
+ZINC=
+ZINCOUT=-I.
OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
@@ -113,8 +116,8 @@ test64: all64
fi; \
rm -f $$TMP64
-infcover.o: test/infcover.c zlib.h zconf.h
- $(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
+infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
+ $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
infcover: infcover.o libz.a
$(CC) $(CFLAGS) -o $@ infcover.o libz.a
@@ -140,24 +143,140 @@ match.lo: match.S
mv _match.o match.lo
rm -f _match.s
-example.o: test/example.c zlib.h zconf.h
- $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
+example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
+ $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c
-minigzip.o: test/minigzip.c zlib.h zconf.h
- $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
+minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
+ $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c
-example64.o: test/example.c zlib.h zconf.h
- $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
+example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
+ $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c
-minigzip64.o: test/minigzip.c zlib.h zconf.h
- $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
+minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
+ $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c
-.SUFFIXES: .lo
-.c.lo:
+adler32.o: $(SRCDIR)adler32.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c
+
+crc32.o: $(SRCDIR)crc32.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c
+
+deflate.o: $(SRCDIR)deflate.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c
+
+infback.o: $(SRCDIR)infback.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c
+
+inffast.o: $(SRCDIR)inffast.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c
+
+inflate.o: $(SRCDIR)inflate.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c
+
+inftrees.o: $(SRCDIR)inftrees.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c
+
+trees.o: $(SRCDIR)trees.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
+
+zutil.o: $(SRCDIR)zutil.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
+
+compress.o: $(SRCDIR)compress.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c
+
+uncompr.o: $(SRCDIR)uncompr.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c
+
+gzclose.o: $(SRCDIR)gzclose.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c
+
+gzlib.o: $(SRCDIR)gzlib.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c
+
+gzread.o: $(SRCDIR)gzread.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c
+
+gzwrite.o: $(SRCDIR)gzwrite.c
+ $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c
+
+
+adler32.lo: $(SRCDIR)adler32.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/adler32.o $(SRCDIR)adler32.c
+ -@mv objs/adler32.o $@
+
+crc32.lo: $(SRCDIR)crc32.c
-@mkdir objs 2>/dev/null || test -d objs
- $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
- -@mv objs/$*.o $@
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c
+ -@mv objs/crc32.o $@
+
+deflate.lo: $(SRCDIR)deflate.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c
+ -@mv objs/deflate.o $@
+
+infback.lo: $(SRCDIR)infback.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/infback.o $(SRCDIR)infback.c
+ -@mv objs/infback.o $@
+
+inffast.lo: $(SRCDIR)inffast.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inffast.o $(SRCDIR)inffast.c
+ -@mv objs/inffast.o $@
+
+inflate.lo: $(SRCDIR)inflate.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inflate.o $(SRCDIR)inflate.c
+ -@mv objs/inflate.o $@
+
+inftrees.lo: $(SRCDIR)inftrees.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c
+ -@mv objs/inftrees.o $@
+
+trees.lo: $(SRCDIR)trees.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
+ -@mv objs/trees.o $@
+
+zutil.lo: $(SRCDIR)zutil.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
+ -@mv objs/zutil.o $@
+
+compress.lo: $(SRCDIR)compress.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/compress.o $(SRCDIR)compress.c
+ -@mv objs/compress.o $@
+
+uncompr.lo: $(SRCDIR)uncompr.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c
+ -@mv objs/uncompr.o $@
+
+gzclose.lo: $(SRCDIR)gzclose.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c
+ -@mv objs/gzclose.o $@
+
+gzlib.lo: $(SRCDIR)gzlib.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c
+ -@mv objs/gzlib.o $@
+
+gzread.lo: $(SRCDIR)gzread.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzread.o $(SRCDIR)gzread.c
+ -@mv objs/gzread.o $@
+
+gzwrite.lo: $(SRCDIR)gzwrite.c
+ -@mkdir objs 2>/dev/null || test -d objs
+ $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
+ -@mv objs/gzwrite.o $@
+
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
@@ -190,10 +309,12 @@ install-libs: $(LIBS)
-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
+ rm -f $(DESTDIR)$(libdir)/$(STATICLIB)
cp $(STATICLIB) $(DESTDIR)$(libdir)
chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
-@if test -n "$(SHAREDLIBV)"; then \
+ rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
@@ -203,8 +324,10 @@ install-libs: $(LIBS)
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
($(LDCONFIG) || true) >/dev/null 2>&1; \
fi
- cp zlib.3 $(DESTDIR)$(man3dir)
+ rm -f $(DESTDIR)$(man3dir)/zlib.3
+ cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir)
chmod 644 $(DESTDIR)$(man3dir)/zlib.3
+ rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc
cp zlib.pc $(DESTDIR)$(pkgconfigdir)
chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
# The ranlib in install is needed on NeXTSTEP which checks file times
@@ -212,7 +335,8 @@ install-libs: $(LIBS)
install: install-libs
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
- cp zlib.h zconf.h $(DESTDIR)$(includedir)
+ rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
+ cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir)
chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
uninstall:
@@ -226,18 +350,18 @@ uninstall:
docs: zlib.3.pdf
-zlib.3.pdf: zlib.3
- groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
+zlib.3.pdf: $(SRCDIR)zlib.3
+ groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
-zconf.h.cmakein: zconf.h.in
+zconf.h.cmakein: $(SRCDIR)zconf.h.in
-@ TEMPFILE=zconfh_$$; \
echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
- sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
- touch -r zconf.h.in zconf.h.cmakein &&\
+ sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
+ touch -r $(SRCDIR)zconf.h.in $@ &&\
rm $$TEMPFILE
-zconf: zconf.h.in
- cp -p zconf.h.in zconf.h
+zconf: $(SRCDIR)zconf.h.in
+ cp -p $(SRCDIR)zconf.h.in zconf.h
mostlyclean: clean
clean:
@@ -255,34 +379,32 @@ maintainer-clean: distclean
distclean: clean zconf zconf.h.cmakein docs
rm -f Makefile zlib.pc configure.log
-@rm -f .DS_Store
- -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile
- -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
- -@touch -r Makefile.in Makefile
+ @if [ -f Makefile.in ]; then \
+ printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \
+ printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \
+ touch -r $(SRCDIR)Makefile.in Makefile ; fi
+ @if [ ! -f zconf.h.in ]; then rm -f zconf.h zconf.h.cmakein ; fi
+ @if [ ! -f zlib.3 ]; then rm -f zlib.3.pdf ; fi
tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o zutil.o: zutil.h zlib.h zconf.h
-gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
-compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
-crc32.o: zutil.h zlib.h zconf.h crc32.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-
-adler32.lo zutil.lo: zutil.h zlib.h zconf.h
-gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
-compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
-crc32.lo: zutil.h zlib.h zconf.h crc32.h
-deflate.lo: deflate.h zutil.h zlib.h zconf.h
-infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
-trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h
+ etags $(SRCDIR)*.[ch]
+
+adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
+gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
+compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h
+crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
+deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
+infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
+inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
+inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
+trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
+
+adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
+gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
+compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h
+crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
+deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
+infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
+inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
+inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
+trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
diff --git a/compat/zlib/README b/compat/zlib/README
index 5ca9d12..51106de 100644
--- a/compat/zlib/README
+++ b/compat/zlib/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.8 is a general purpose data compression library. All the code is
+zlib 1.2.11 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ .
-The changes made in version 1.2.8 are documented in the file ChangeLog.
+The changes made in version 1.2.11 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
@@ -84,7 +84,7 @@ Acknowledgments:
Copyright notice:
- (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/compat/zlib/adler32.c b/compat/zlib/adler32.c
index a868f07..d0be438 100644
--- a/compat/zlib/adler32.c
+++ b/compat/zlib/adler32.c
@@ -1,5 +1,5 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2011 Mark Adler
+ * Copyright (C) 1995-2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -7,11 +7,9 @@
#include "zutil.h"
-#define local static
-
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
-#define BASE 65521 /* largest prime smaller than 65536 */
+#define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -62,10 +60,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#endif
/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
+uLong ZEXPORT adler32_z(adler, buf, len)
uLong adler;
const Bytef *buf;
- uInt len;
+ z_size_t len;
{
unsigned long sum2;
unsigned n;
@@ -133,6 +131,15 @@ uLong ZEXPORT adler32(adler, buf, len)
}
/* ========================================================================= */
+uLong ZEXPORT adler32(adler, buf, len)
+ uLong adler;
+ const Bytef *buf;
+ uInt len;
+{
+ return adler32_z(adler, buf, len);
+}
+
+/* ========================================================================= */
local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
@@ -156,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE;
- if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+ if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
diff --git a/compat/zlib/as400/bndsrc b/compat/zlib/as400/bndsrc
deleted file mode 100644
index 98814fd..0000000
--- a/compat/zlib/as400/bndsrc
+++ /dev/null
@@ -1,215 +0,0 @@
-STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.1.3 entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("adler32")
-
-/********************************************************************/
-/* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("compress")
- EXPORT SYMBOL("compress2")
-
-/********************************************************************/
-/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("crc32")
- EXPORT SYMBOL("get_crc_table")
-
-/********************************************************************/
-/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("deflate")
- EXPORT SYMBOL("deflateEnd")
- EXPORT SYMBOL("deflateSetDictionary")
- EXPORT SYMBOL("deflateCopy")
- EXPORT SYMBOL("deflateReset")
- EXPORT SYMBOL("deflateParams")
- EXPORT SYMBOL("deflatePrime")
- EXPORT SYMBOL("deflateInit_")
- EXPORT SYMBOL("deflateInit2_")
-
-/********************************************************************/
-/* *MODULE GZIO ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzopen")
- EXPORT SYMBOL("gzdopen")
- EXPORT SYMBOL("gzsetparams")
- EXPORT SYMBOL("gzread")
- EXPORT SYMBOL("gzwrite")
- EXPORT SYMBOL("gzprintf")
- EXPORT SYMBOL("gzputs")
- EXPORT SYMBOL("gzgets")
- EXPORT SYMBOL("gzputc")
- EXPORT SYMBOL("gzgetc")
- EXPORT SYMBOL("gzflush")
- EXPORT SYMBOL("gzseek")
- EXPORT SYMBOL("gzrewind")
- EXPORT SYMBOL("gztell")
- EXPORT SYMBOL("gzeof")
- EXPORT SYMBOL("gzclose")
- EXPORT SYMBOL("gzerror")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflate")
- EXPORT SYMBOL("inflateEnd")
- EXPORT SYMBOL("inflateSetDictionary")
- EXPORT SYMBOL("inflateSync")
- EXPORT SYMBOL("inflateReset")
- EXPORT SYMBOL("inflateInit_")
- EXPORT SYMBOL("inflateInit2_")
- EXPORT SYMBOL("inflateSyncPoint")
-
-/********************************************************************/
-/* *MODULE UNCOMPR ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("uncompress")
-
-/********************************************************************/
-/* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("zlibVersion")
- EXPORT SYMBOL("zError")
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.2.1 additional entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("compressBound")
-
-/********************************************************************/
-/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("deflateBound")
-
-/********************************************************************/
-/* *MODULE GZIO ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzungetc")
- EXPORT SYMBOL("gzclearerr")
-
-/********************************************************************/
-/* *MODULE INFBACK ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateBack")
- EXPORT SYMBOL("inflateBackEnd")
- EXPORT SYMBOL("inflateBackInit_")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateCopy")
-
-/********************************************************************/
-/* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("zlibCompileFlags")
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.2.5 additional entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("adler32_combine")
- EXPORT SYMBOL("adler32_combine64")
-
-/********************************************************************/
-/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("crc32_combine")
- EXPORT SYMBOL("crc32_combine64")
-
-/********************************************************************/
-/* *MODULE GZLIB ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzbuffer")
- EXPORT SYMBOL("gzoffset")
- EXPORT SYMBOL("gzoffset64")
- EXPORT SYMBOL("gzopen64")
- EXPORT SYMBOL("gzseek64")
- EXPORT SYMBOL("gztell64")
-
-/********************************************************************/
-/* *MODULE GZREAD ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzclose_r")
-
-/********************************************************************/
-/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzclose_w")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateMark")
- EXPORT SYMBOL("inflatePrime")
- EXPORT SYMBOL("inflateReset2")
- EXPORT SYMBOL("inflateUndermine")
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.2.6 additional entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("deflateResetKeep")
- EXPORT SYMBOL("deflatePending")
-
-/********************************************************************/
-/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzgetc_")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateResetKeep")
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.2.8 additional entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateGetDictionary")
-
-ENDPGMEXP
diff --git a/compat/zlib/as400/compile.clp b/compat/zlib/as400/compile.clp
deleted file mode 100644
index e3f47c6..0000000
--- a/compat/zlib/as400/compile.clp
+++ /dev/null
@@ -1,110 +0,0 @@
-/******************************************************************************/
-/* */
-/* ZLIB */
-/* */
-/* Compile sources into modules and link them into a service program. */
-/* */
-/******************************************************************************/
-
- PGM
-
-/* Configuration adjustable parameters. */
-
- DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
- VALUE('ZLIB') /* Source library. */
- DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
- VALUE('SOURCES') /* Source member file. */
- DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
- VALUE('TOOLS') /* Control member file. */
-
- DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
- VALUE('ZLIB') /* Module library. */
-
- DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
- VALUE('LGPL') /* Service program library. */
-
- DCL VAR(&CFLAGS) TYPE(*CHAR) +
- VALUE('OPTIMIZE(40)') /* Compile options. */
-
- DCL VAR(&TGTRLS) TYPE(*CHAR) +
- VALUE('V5R3M0') /* Target release. */
-
-
-/* Working storage. */
-
- DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
- DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
- DCL VAR(&FIXDCMD) TYPE(*CHAR) LEN(512)
-
-
-/* Compile sources into modules. */
-
- CHGVAR VAR(&FIXDCMD) VALUE('CRTCMOD' *BCAT &CFLAGS *BCAT +
- 'SYSIFCOPT(*IFS64IO)' *BCAT +
- 'DEFINE(''_LARGEFILE64_SOURCE''' *BCAT +
- '''_LFS64_LARGEFILE=1'') TGTRLS(' *TCAT &TGTRLS *TCAT +
- ') SRCFILE(' *TCAT &SRCLIB *TCAT '/' *TCAT +
- &SRCFILE *TCAT ') MODULE(' *TCAT &MODLIB *TCAT '/')
-
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ADLER32)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'COMPRESS)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'CRC32)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'DEFLATE)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZCLOSE)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZLIB)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZREAD)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZWRITE)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFBACK)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFFAST)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFLATE)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFTREES)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'TREES)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'UNCOMPR)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ZUTIL)')
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
-
-/* Link modules into a service program. */
-
- CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
- MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
- &MODLIB/CRC32 &MODLIB/DEFLATE +
- &MODLIB/GZCLOSE &MODLIB/GZLIB +
- &MODLIB/GZREAD &MODLIB/GZWRITE +
- &MODLIB/INFBACK &MODLIB/INFFAST +
- &MODLIB/INFLATE &MODLIB/INFTREES +
- &MODLIB/TREES &MODLIB/UNCOMPR +
- &MODLIB/ZUTIL) +
- SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
- TEXT('ZLIB 1.2.8') TGTRLS(&TGTRLS)
-
- ENDPGM
diff --git a/compat/zlib/as400/readme.txt b/compat/zlib/as400/readme.txt
deleted file mode 100644
index 7b5d93b..0000000
--- a/compat/zlib/as400/readme.txt
+++ /dev/null
@@ -1,115 +0,0 @@
- ZLIB version 1.2.8 for AS400 installation instructions
-
-I) From an AS400 *SAVF file:
-
-1) Unpacking archive to an AS400 save file
-
-On the AS400:
-
-_ Create the ZLIB AS400 library:
-
- CRTLIB LIB(ZLIB) TYPE(*PROD) TEXT('ZLIB compression API library')
-
-_ Create a work save file, for example:
-
- CRTSAVF FILE(ZLIB/ZLIBSAVF)
-
-On a PC connected to the target AS400:
-
-_ Unpack the save file image to a PC file "ZLIBSAVF"
-_ Upload this file into the save file on the AS400, for example
- using ftp in BINARY mode.
-
-
-2) Populating the ZLIB AS400 source library
-
-On the AS400:
-
-_ Extract the saved objects into the ZLIB AS400 library using:
-
-RSTOBJ OBJ(*ALL) SAVLIB(ZLIB) DEV(*SAVF) SAVF(ZLIB/ZLIBSAVF) RSTLIB(ZLIB)
-
-
-3) Customize installation:
-
-_ Edit CL member ZLIB/TOOLS(COMPILE) and change parameters if needed,
- according to the comments.
-
-_ Compile this member with:
-
- CRTCLPGM PGM(ZLIB/COMPILE) SRCFILE(ZLIB/TOOLS) SRCMBR(COMPILE)
-
-
-4) Compile and generate the service program:
-
-_ This can now be done by executing:
-
- CALL PGM(ZLIB/COMPILE)
-
-
-
-II) From the original source distribution:
-
-1) On the AS400, create the source library:
-
- CRTLIB LIB(ZLIB) TYPE(*PROD) TEXT('ZLIB compression API library')
-
-2) Create the source files:
-
- CRTSRCPF FILE(ZLIB/SOURCES) RCDLEN(112) TEXT('ZLIB library modules')
- CRTSRCPF FILE(ZLIB/H) RCDLEN(112) TEXT('ZLIB library includes')
- CRTSRCPF FILE(ZLIB/TOOLS) RCDLEN(112) TEXT('ZLIB library control utilities')
-
-3) From the machine hosting the distribution files, upload them (with
- FTP in text mode, for example) according to the following table:
-
- Original AS400 AS400 AS400 AS400
- file file member type description
- SOURCES Original ZLIB C subprogram sources
- adler32.c ADLER32 C ZLIB - Compute the Adler-32 checksum of a dta strm
- compress.c COMPRESS C ZLIB - Compress a memory buffer
- crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream
- deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm
- gzclose.c GZCLOSE C ZLIB - Close .gz files
- gzlib.c GZLIB C ZLIB - Miscellaneous .gz files IO support
- gzread.c GZREAD C ZLIB - Read .gz files
- gzwrite.c GZWRITE C ZLIB - Write .gz files
- infback.c INFBACK C ZLIB - Inflate using a callback interface
- inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs
- inflate.c INFLATE C ZLIB - Interface to inflate modules
- inftrees.c INFTREES C ZLIB - Generate Huffman trees for efficient decode
- trees.c TREES C ZLIB - Output deflated data using Huffman coding
- uncompr.c UNCOMPR C ZLIB - Decompress a memory buffer
- zutil.c ZUTIL C ZLIB - Target dependent utility functions
- H Original ZLIB C and ILE/RPG include files
- crc32.h CRC32 C ZLIB - CRC32 tables
- deflate.h DEFLATE C ZLIB - Internal compression state
- gzguts.h GZGUTS C ZLIB - Definitions for the gzclose module
- inffast.h INFFAST C ZLIB - Header to use inffast.c
- inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes
- inflate.h INFLATE C ZLIB - Internal inflate state definitions
- inftrees.h INFTREES C ZLIB - Header to use inftrees.c
- trees.h TREES C ZLIB - Created automatically with -DGEN_TREES_H
- zconf.h ZCONF C ZLIB - Compression library configuration
- zlib.h ZLIB C ZLIB - Compression library C user interface
- as400/zlib.inc ZLIB.INC RPGLE ZLIB - Compression library ILE RPG user interface
- zutil.h ZUTIL C ZLIB - Internal interface and configuration
- TOOLS Building source software & AS/400 README
- as400/bndsrc BNDSRC Entry point exportation list
- as400/compile.clp COMPILE CLP Compile sources & generate service program
- as400/readme.txt README TXT Installation instructions
-
-4) Continue as in I)3).
-
-
-
-
-Notes: For AS400 ILE RPG programmers, a /copy member defining the ZLIB
- API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC).
- Please read comments in this member for more information.
-
- Remember that most foreign textual data are ASCII coded: this
- implementation does not handle conversion from/to ASCII, so
- text data code conversions must be done explicitely.
-
- Mainly for the reason above, always open zipped files in binary mode.
diff --git a/compat/zlib/compress.c b/compat/zlib/compress.c
index 6e97626..e2db404 100644
--- a/compat/zlib/compress.c
+++ b/compat/zlib/compress.c
@@ -1,5 +1,5 @@
/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -28,16 +28,11 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
{
z_stream stream;
int err;
+ const uInt max = (uInt)-1;
+ uLong left;
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+ left = *destLen;
+ *destLen = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
@@ -46,15 +41,26 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
+ stream.next_out = dest;
+ stream.avail_out = 0;
+ stream.next_in = (z_const Bytef *)source;
+ stream.avail_in = 0;
+
+ do {
+ if (stream.avail_out == 0) {
+ stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ left -= stream.avail_out;
+ }
+ if (stream.avail_in == 0) {
+ stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
+ sourceLen -= stream.avail_in;
+ }
+ err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
+ } while (err == Z_OK);
- err = deflateEnd(&stream);
- return err;
+ *destLen = stream.total_out;
+ deflateEnd(&stream);
+ return err == Z_STREAM_END ? Z_OK : err;
}
/* ===========================================================================
diff --git a/compat/zlib/configure b/compat/zlib/configure
index b77a8a8..e974d1f 100755
--- a/compat/zlib/configure
+++ b/compat/zlib/configure
@@ -18,6 +18,18 @@ echo -------------------- >> configure.log
echo $0 $* >> configure.log
date >> configure.log
+# get source directory
+SRCDIR=`dirname $0`
+if test $SRCDIR = "."; then
+ ZINC=""
+ ZINCOUT="-I."
+ SRCDIR=""
+else
+ ZINC='-include zconf.h'
+ ZINCOUT='-I. -I$(SRCDIR)'
+ SRCDIR="$SRCDIR/"
+fi
+
# set command prefix for cross-compilation
if [ -n "${CHOST}" ]; then
uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
@@ -28,10 +40,10 @@ fi
STATICLIB=libz.a
# extract zlib version numbers from zlib.h
-VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
-VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
-VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
-VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
+VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
+VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
+VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
+VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
# establish commands for library building
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
@@ -73,6 +85,8 @@ zprefix=0
zconst=0
build64=0
gcc=0
+warn=0
+debug=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
@@ -121,6 +135,8 @@ case "$1" in
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
-c* | --const) zconst=1; shift ;;
+ -w* | --warn) warn=1; shift ;;
+ -d* | --debug) debug=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
@@ -159,34 +175,42 @@ case "$cc" in
esac
case `$cc -v 2>&1` in
*gcc*) gcc=1 ;;
+ *clang*) gcc=1 ;;
esac
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
echo ... using gcc >> configure.log
CC="$cc"
- CFLAGS="${CFLAGS--O3} ${ARCHS}"
+ CFLAGS="${CFLAGS--O3}"
SFLAGS="${CFLAGS--O3} -fPIC"
- LDFLAGS="${LDFLAGS} ${ARCHS}"
+ if test "$ARCHS"; then
+ CFLAGS="${CFLAGS} ${ARCHS}"
+ LDFLAGS="${LDFLAGS} ${ARCHS}"
+ fi
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
fi
- if test "${ZLIBGCCWARN}" = "YES"; then
+ if test "$warn" -eq 1; then
if test "$zconst" -eq 1; then
CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
else
CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
fi
fi
+ if test $debug -eq 1; then
+ CFLAGS="${CFLAGS} -DZLIB_DEBUG"
+ SFLAGS="${SFLAGS} -DZLIB_DEBUG"
+ fi
if test -z "$uname"; then
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
Linux* | linux* | GNU | GNU/* | solaris*)
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
*BSD | *bsd* | DragonFly)
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
LDCONFIG="ldconfig -m" ;;
CYGWIN* | Cygwin* | cygwin* | OS/2*)
EXE='.exe' ;;
@@ -287,6 +311,9 @@ else
esac
fi
fi
+ if test -n "$ZINC"; then
+ ZINC='-I- -I. -I$(SRCDIR)'
+ fi
;;
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
CFLAGS=${CFLAGS-"-O2"}
@@ -337,16 +364,16 @@ if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
}
echo - using any output from compiler to indicate an error >> configure.log
else
-try()
-{
- show $*
- ( $* ) >> configure.log 2>&1
- ret=$?
- if test $ret -ne 0; then
- echo "(exit code "$ret")" >> configure.log
- fi
- return $ret
-}
+ try()
+ {
+ show $*
+ ( $* ) >> configure.log 2>&1
+ ret=$?
+ if test $ret -ne 0; then
+ echo "(exit code "$ret")" >> configure.log
+ fi
+ return $ret
+ }
fi
tryboth()
@@ -422,6 +449,65 @@ esac
echo >> configure.log
+# check for size_t
+cat > $test.c <<EOF
+#include <stdio.h>
+#include <stdlib.h>
+size_t dummy = 0;
+EOF
+if try $CC -c $CFLAGS $test.c; then
+ echo "Checking for size_t... Yes." | tee -a configure.log
+ need_sizet=0
+else
+ echo "Checking for size_t... No." | tee -a configure.log
+ need_sizet=1
+fi
+
+echo >> configure.log
+
+# find the size_t integer type, if needed
+if test $need_sizet -eq 1; then
+ cat > $test.c <<EOF
+long long dummy = 0;
+EOF
+ if try $CC -c $CFLAGS $test.c; then
+ echo "Checking for long long... Yes." | tee -a configure.log
+ cat > $test.c <<EOF
+#include <stdio.h>
+int main(void) {
+ if (sizeof(void *) <= sizeof(int)) puts("int");
+ else if (sizeof(void *) <= sizeof(long)) puts("long");
+ else puts("z_longlong");
+ return 0;
+}
+EOF
+ else
+ echo "Checking for long long... No." | tee -a configure.log
+ cat > $test.c <<EOF
+#include <stdio.h>
+int main(void) {
+ if (sizeof(void *) <= sizeof(int)) puts("int");
+ else puts("long");
+ return 0;
+}
+EOF
+ fi
+ if try $CC $CFLAGS -o $test $test.c; then
+ sizet=`./$test`
+ echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
+ else
+ echo "Failed to find a pointer-size integer type." | tee -a configure.log
+ leave 1
+ fi
+fi
+
+if test $need_sizet -eq 1; then
+ CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
+ SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
+fi
+
+echo >> configure.log
+
# check for large file support, and if none, check for fseeko()
cat > $test.c <<EOF
#include <sys/types.h>
@@ -470,7 +556,7 @@ else
fi
# copy clean zconf.h for subsequent edits
-cp -p zconf.h.in zconf.h
+cp -p ${SRCDIR}zconf.h.in zconf.h
echo >> configure.log
@@ -764,6 +850,7 @@ echo STATICLIB = $STATICLIB >> configure.log
echo TEST = $TEST >> configure.log
echo VER = $VER >> configure.log
echo Z_U4 = $Z_U4 >> configure.log
+echo SRCDIR = $SRCDIR >> configure.log
echo exec_prefix = $exec_prefix >> configure.log
echo includedir = $includedir >> configure.log
echo libdir = $libdir >> configure.log
@@ -773,7 +860,7 @@ echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
# udpate Makefile with the configure results
-sed < Makefile.in "
+sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
@@ -790,6 +877,9 @@ sed < Makefile.in "
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
/^EXE *=/s#=.*#=$EXE#
+/^SRCDIR *=/s#=.*#=$SRCDIR#
+/^ZINC *=/s#=.*#=$ZINC#
+/^ZINCOUT *=/s#=.*#=$ZINCOUT#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
@@ -803,7 +893,7 @@ sed < Makefile.in "
" > Makefile
# create zlib.pc with the configure results
-sed < zlib.pc.in "
+sed < ${SRCDIR}zlib.pc.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
diff --git a/compat/zlib/contrib/README.contrib b/compat/zlib/contrib/README.contrib
index c66349b..a411d5c 100644
--- a/compat/zlib/contrib/README.contrib
+++ b/compat/zlib/contrib/README.contrib
@@ -38,7 +38,7 @@ inflate86/ by Chris Anderson <christop@charm.net>
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
A C++ I/O streams interface to the zlib gz* functions
-iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
+iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
Another C++ I/O streams interface
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
@@ -58,7 +58,7 @@ masmx86/ by Gilles Vollant <info@winimage.com>
minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
- See http://www.winimage.com/zLibDll/unzip.html
+ See http://www.winimage.com/zLibDll/minizip.html
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
Support for Pascal
diff --git a/compat/zlib/contrib/ada/zlib-streams.ads b/compat/zlib/contrib/ada/zlib-streams.ads
index f0193c6b..8e26cd4 100644
--- a/compat/zlib/contrib/ada/zlib-streams.ads
+++ b/compat/zlib/contrib/ada/zlib-streams.ads
@@ -31,7 +31,7 @@ package ZLib.Streams is
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
- -- Should not be used untill necessary, becouse it is decreasing
+ -- Should not be used until necessary, because it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
@@ -97,13 +97,13 @@ private
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
- -- becouse not all read data from back stream
+ -- because not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
- -- in the record becouse all data could be
+ -- in the record because all data could be
-- processed in the write operation.
Back : Stream_Access;
diff --git a/compat/zlib/contrib/ada/zlib-thin.ads b/compat/zlib/contrib/ada/zlib-thin.ads
index d4407eb..810173c 100644
--- a/compat/zlib/contrib/ada/zlib-thin.ads
+++ b/compat/zlib/contrib/ada/zlib-thin.ads
@@ -436,7 +436,7 @@ private
pragma Import (C, inflateBackInit, "inflateBackInit_");
- -- I stopped binding the inflateBack routines, becouse realize that
+ -- I stopped binding the inflateBack routines, because realize that
-- it does not support zlib and gzip headers for now, and have no
-- symmetric deflateBack routines.
-- ZLib-Ada is symmetric regarding deflate/inflate data transformation
diff --git a/compat/zlib/contrib/blast/blast.c b/compat/zlib/contrib/blast/blast.c
index 69ef0fe..e6e6590 100644
--- a/compat/zlib/contrib/blast/blast.c
+++ b/compat/zlib/contrib/blast/blast.c
@@ -1,7 +1,7 @@
/* blast.c
- * Copyright (C) 2003, 2012 Mark Adler
+ * Copyright (C) 2003, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in blast.h
- * version 1.2, 24 Oct 2012
+ * version 1.3, 24 Aug 2013
*
* blast.c decompresses data compressed by the PKWare Compression Library.
* This function provides functionality similar to the explode() function of
@@ -24,8 +24,12 @@
* 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data
* 1.2 24 Oct 2012 - Add note about using binary mode in stdio
* - Fix comparisons of differently signed integers
+ * 1.3 24 Aug 2013 - Return unused input from blast()
+ * - Fix test code to correctly report unused input
+ * - Enable the provision of initial input to blast()
*/
+#include <stddef.h> /* for NULL */
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
#include "blast.h" /* prototype for blast() */
@@ -256,7 +260,7 @@ local int construct(struct huffman *h, const unsigned char *rep, int n)
* next, 0 for literals, 1 for length/distance.
*
* - If literals are uncoded, then the next eight bits are the literal, in the
- * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly,
+ * normal bit order in the stream, i.e. no bit-reversal is needed. Similarly,
* no bit reversal is needed for either the length extra bits or the distance
* extra bits.
*
@@ -376,7 +380,8 @@ local int decomp(struct state *s)
}
/* See comments in blast.h */
-int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
+int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
+ unsigned *left, unsigned char **in)
{
struct state s; /* input/output state */
int err; /* return value */
@@ -384,7 +389,12 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
/* initialize input state */
s.infun = infun;
s.inhow = inhow;
- s.left = 0;
+ if (left != NULL && *left) {
+ s.left = *left;
+ s.in = *in;
+ }
+ else
+ s.left = 0;
s.bitbuf = 0;
s.bitcnt = 0;
@@ -400,6 +410,12 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
else
err = decomp(&s); /* decompress */
+ /* return unused input */
+ if (left != NULL)
+ *left = s.left;
+ if (in != NULL)
+ *in = s.left ? s.in : NULL;
+
/* write any leftover output and update the error code if needed */
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
err = 1;
@@ -429,16 +445,20 @@ local int outf(void *how, unsigned char *buf, unsigned len)
/* Decompress a PKWare Compression Library stream from stdin to stdout */
int main(void)
{
- int ret, n;
+ int ret;
+ unsigned left;
/* decompress to stdout */
- ret = blast(inf, stdin, outf, stdout);
- if (ret != 0) fprintf(stderr, "blast error: %d\n", ret);
-
- /* see if there are any leftover bytes */
- n = 0;
- while (getchar() != EOF) n++;
- if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n);
+ left = 0;
+ ret = blast(inf, stdin, outf, stdout, &left, NULL);
+ if (ret != 0)
+ fprintf(stderr, "blast error: %d\n", ret);
+
+ /* count any leftover bytes */
+ while (getchar() != EOF)
+ left++;
+ if (left)
+ fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
/* return blast() error code */
return ret;
diff --git a/compat/zlib/contrib/blast/blast.h b/compat/zlib/contrib/blast/blast.h
index 658cfd3..6cf65ed 100644
--- a/compat/zlib/contrib/blast/blast.h
+++ b/compat/zlib/contrib/blast/blast.h
@@ -1,6 +1,6 @@
/* blast.h -- interface for blast.c
- Copyright (C) 2003, 2012 Mark Adler
- version 1.2, 24 Oct 2012
+ Copyright (C) 2003, 2012, 2013 Mark Adler
+ version 1.3, 24 Aug 2013
This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
@@ -42,7 +42,8 @@ typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
*/
-int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow);
+int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
+ unsigned *left, unsigned char **in);
/* Decompress input to output using the provided infun() and outfun() calls.
* On success, the return value of blast() is zero. If there is an error in
* the source data, i.e. it is not in the proper format, then a negative value
@@ -55,12 +56,19 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow);
* an input error. (blast() only asks for input if it needs it.) inhow is for
* use by the application to pass an input descriptor to infun(), if desired.
*
+ * If left and in are not NULL and *left is not zero when blast() is called,
+ * then the *left bytes are *in are consumed for input before infun() is used.
+ *
* The output function is invoked: err = outfun(how, buf, len), where the bytes
* to be written are buf[0..len-1]. If err is not zero, then blast() returns
* with an output error. outfun() is always called with len <= 4096. outhow
* is for use by the application to pass an output descriptor to outfun(), if
* desired.
*
+ * If there is any unused input, *left is set to the number of bytes that were
+ * read and *in points to them. Otherwise *left is set to zero and *in is set
+ * to NULL. If left or in are NULL, then they are not set.
+ *
* The return codes are:
*
* 2: ran out of input before completing decompression
diff --git a/compat/zlib/contrib/delphi/ZLib.pas b/compat/zlib/contrib/delphi/ZLib.pas
index a579974..060e199 100644
--- a/compat/zlib/contrib/delphi/ZLib.pas
+++ b/compat/zlib/contrib/delphi/ZLib.pas
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
- zlib_version = '1.2.8';
+ zlib_version = '1.2.11';
type
EZlibError = class(Exception);
diff --git a/compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
index b273d54..44f7633 100644
--- a/compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
+++ b/compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
@@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version()
{
Info info = new Info();
- Assert.AreEqual("1.2.8", Info.Version);
+ Assert.AreEqual("1.2.11", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
diff --git a/compat/zlib/contrib/infback9/inftree9.c b/compat/zlib/contrib/infback9/inftree9.c
index 4a73ad2..5f4a767 100644
--- a/compat/zlib/contrib/infback9/inftree9.c
+++ b/compat/zlib/contrib/infback9/inftree9.c
@@ -1,5 +1,5 @@
/* inftree9.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2013 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate9_copyright[] =
- " inflate9 1.2.8 Copyright 1995-2013 Mark Adler ";
+ " inflate9 1.2.11 Copyright 1995-2017 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -64,7 +64,7 @@ unsigned short FAR *work;
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
- 133, 133, 133, 133, 144, 72, 78};
+ 133, 133, 133, 133, 144, 77, 202};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/compat/zlib/contrib/minizip/configure.ac b/compat/zlib/contrib/minizip/configure.ac
index 827a4e0..5b11970 100644
--- a/compat/zlib/contrib/minizip/configure.ac
+++ b/compat/zlib/contrib/minizip/configure.ac
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com])
+AC_INIT([minizip], [1.2.11], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
diff --git a/compat/zlib/contrib/minizip/iowin32.c b/compat/zlib/contrib/minizip/iowin32.c
index a46d96c..274f39e 100644
--- a/compat/zlib/contrib/minizip/iowin32.c
+++ b/compat/zlib/contrib/minizip/iowin32.c
@@ -26,8 +26,9 @@
#endif
+// see Include/shared/winapifamily.h in the Windows Kit
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
#define IOWIN32_USING_WINRT_API 1
#endif
#endif
@@ -243,7 +244,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
#else
LONG lHigh = pos.HighPart;
- DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT);
+ DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod);
BOOL fOk = TRUE;
if (dwNewPos == 0xFFFFFFFF)
if (GetLastError() != NO_ERROR)
@@ -370,7 +371,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off
{
LARGE_INTEGER pos;
pos.QuadPart = offset;
- if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT))
+ if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
{
DWORD dwErr = GetLastError();
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
diff --git a/compat/zlib/contrib/minizip/unzip.c b/compat/zlib/contrib/minizip/unzip.c
index 9093504..bcfb941 100644
--- a/compat/zlib/contrib/minizip/unzip.c
+++ b/compat/zlib/contrib/minizip/unzip.c
@@ -200,7 +200,7 @@ typedef struct
/* ===========================================================================
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
+ IN assertion: the stream s has been successfully opened for reading.
*/
diff --git a/compat/zlib/contrib/minizip/zip.c b/compat/zlib/contrib/minizip/zip.c
index ea54853..44e88a9 100644
--- a/compat/zlib/contrib/minizip/zip.c
+++ b/compat/zlib/contrib/minizip/zip.c
@@ -15,7 +15,7 @@
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
It is used when recreting zip archive with RAW when deleting items from a zip.
- ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed.
+ ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
@@ -116,7 +116,7 @@ typedef struct linkedlist_datablock_internal_s
struct linkedlist_datablock_internal_s* next_datablock;
uLong avail_in_this_block;
uLong filled_in_this_block;
- uLong unused; /* for future use and alignement */
+ uLong unused; /* for future use and alignment */
unsigned char data[SIZEDATA_INDATABLOCK];
} linkedlist_datablock_internal;
@@ -171,7 +171,7 @@ typedef struct
curfile64_info ci; /* info on the file curretly writing */
ZPOS64_T begin_pos; /* position of the beginning of the zipfile */
- ZPOS64_T add_position_when_writting_offset;
+ ZPOS64_T add_position_when_writing_offset;
ZPOS64_T number_entry;
#ifndef NO_ADDFILEINEXISTINGZIP
@@ -807,7 +807,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
}
byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);
- pziinit->add_position_when_writting_offset = byte_before_the_zipfile;
+ pziinit->add_position_when_writing_offset = byte_before_the_zipfile;
{
ZPOS64_T size_central_dir_to_read = size_central_dir;
@@ -875,7 +875,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
ziinit.in_opened_file_inzip = 0;
ziinit.ci.stream_initialised = 0;
ziinit.number_entry = 0;
- ziinit.add_position_when_writting_offset = 0;
+ ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir));
@@ -1164,7 +1164,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
if(zi->ci.pos_local_header >= 0xffffffff)
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4);
else
- zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writting_offset,4);
+ zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writing_offset,4);
for (i=0;i<size_filename;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
@@ -1755,7 +1755,7 @@ extern int ZEXPORT zipCloseFileInZip (zipFile file)
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
{
int err = ZIP_OK;
- ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset;
+ ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4);
@@ -1808,7 +1808,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
{
- ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
+ ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8);
}
return err;
@@ -1849,13 +1849,13 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
{
- ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
+ ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff)
{
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
}
else
- err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
+ err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4);
}
return err;
@@ -1921,7 +1921,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
}
free_linkedlist(&(zi->central_dir));
- pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
+ pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
{
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
diff --git a/compat/zlib/contrib/pascal/zlibpas.pas b/compat/zlib/contrib/pascal/zlibpas.pas
index e6a0782..a0dff11 100644
--- a/compat/zlib/contrib/pascal/zlibpas.pas
+++ b/compat/zlib/contrib/pascal/zlibpas.pas
@@ -10,8 +10,8 @@ unit zlibpas;
interface
const
- ZLIB_VERSION = '1.2.8';
- ZLIB_VERNUM = $1280;
+ ZLIB_VERSION = '1.2.11';
+ ZLIB_VERNUM = $12a0;
type
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
diff --git a/compat/zlib/contrib/puff/puff.c b/compat/zlib/contrib/puff/puff.c
index ba58483..c6c90d7 100644
--- a/compat/zlib/contrib/puff/puff.c
+++ b/compat/zlib/contrib/puff/puff.c
@@ -17,7 +17,7 @@
* All dynamically allocated memory comes from the stack. The stack required
* is less than 2K bytes. This code is compatible with 16-bit int's and
* assumes that long's are at least 32 bits. puff.c uses the short data type,
- * assumed to be 16 bits, for arrays in order to to conserve memory. The code
+ * assumed to be 16 bits, for arrays in order to conserve memory. The code
* works whether integers are stored big endian or little endian.
*
* In the comments below are "Format notes" that describe the inflate process
diff --git a/compat/zlib/contrib/vstudio/readme.txt b/compat/zlib/contrib/vstudio/readme.txt
index bfdcd9d..f67eae8 100644
--- a/compat/zlib/contrib/vstudio/readme.txt
+++ b/compat/zlib/contrib/vstudio/readme.txt
@@ -1,4 +1,4 @@
-Building instructions for the DLL versions of Zlib 1.2.8
+Building instructions for the DLL versions of Zlib 1.2.11
========================================================
This directory contains projects that build zlib and minizip using
@@ -16,7 +16,7 @@ More information can be found at this site.
Build instructions for Visual Studio 2008 (32 bits or 64 bits)
--------------------------------------------------------------
-- Uncompress current zlib, including all contrib/* files
+- Decompress current zlib, including all contrib/* files
- Compile assembly code (with Visual Studio Command Prompt) by running:
bld_ml64.bat (in contrib\masmx64)
bld_ml32.bat (in contrib\masmx86)
@@ -25,14 +25,24 @@ Build instructions for Visual Studio 2008 (32 bits or 64 bits)
Build instructions for Visual Studio 2010 (32 bits or 64 bits)
--------------------------------------------------------------
-- Uncompress current zlib, including all contrib/* files
+- Decompress current zlib, including all contrib/* files
- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010
Build instructions for Visual Studio 2012 (32 bits or 64 bits)
--------------------------------------------------------------
-- Uncompress current zlib, including all contrib/* files
+- Decompress current zlib, including all contrib/* files
- Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012
+Build instructions for Visual Studio 2013 (32 bits or 64 bits)
+--------------------------------------------------------------
+- Decompress current zlib, including all contrib/* files
+- Open contrib\vstudio\vc12\zlibvc.sln with Microsoft Visual C++ 2013
+
+Build instructions for Visual Studio 2015 (32 bits or 64 bits)
+--------------------------------------------------------------
+- Decompress current zlib, including all contrib/* files
+- Open contrib\vstudio\vc14\zlibvc.sln with Microsoft Visual C++ 2015
+
Important
---------
@@ -63,3 +73,6 @@ Additional notes
Gilles Vollant
info@winimage.com
+
+Visual Studio 2013 and 2015 Projects from Sean Hunt
+seandhunt_7@yahoo.com
diff --git a/compat/zlib/contrib/vstudio/vc10/zlib.rc b/compat/zlib/contrib/vstudio/vc10/zlib.rc
index 73f6476..fee177a 100644
--- a/compat/zlib/contrib/vstudio/vc10/zlib.rc
+++ b/compat/zlib/contrib/vstudio/vc10/zlib.rc
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,8,0
- PRODUCTVERSION 1,2,8,0
+ FILEVERSION 1, 2, 11, 0
+ PRODUCTVERSION 1, 2, 11, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
- VALUE "FileVersion", "1.2.8\0"
+ VALUE "FileVersion", "1.2.11\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
diff --git a/compat/zlib/contrib/vstudio/vc10/zlibvc.def b/compat/zlib/contrib/vstudio/vc10/zlibvc.def
index 6367046..54e683d 100644
--- a/compat/zlib/contrib/vstudio/vc10/zlibvc.def
+++ b/compat/zlib/contrib/vstudio/vc10/zlibvc.def
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
-VERSION 1.2.8
+VERSION 1.2
EXPORTS
adler32 @1
@@ -141,3 +141,13 @@ EXPORTS
; zlib1 v1.2.8 added:
inflateGetDictionary @166
gzvprintf @167
+
+; zlib1 v1.2.9 added:
+ inflateCodesUsed @168
+ inflateValidate @169
+ uncompress2 @170
+ gzfread @171
+ gzfwrite @172
+ deflateGetDictionary @173
+ adler32_z @174
+ crc32_z @175
diff --git a/compat/zlib/contrib/vstudio/vc11/zlib.rc b/compat/zlib/contrib/vstudio/vc11/zlib.rc
index 73f6476..fee177a 100644
--- a/compat/zlib/contrib/vstudio/vc11/zlib.rc
+++ b/compat/zlib/contrib/vstudio/vc11/zlib.rc
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,8,0
- PRODUCTVERSION 1,2,8,0
+ FILEVERSION 1, 2, 11, 0
+ PRODUCTVERSION 1, 2, 11, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
- VALUE "FileVersion", "1.2.8\0"
+ VALUE "FileVersion", "1.2.11\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
diff --git a/compat/zlib/contrib/vstudio/vc11/zlibvc.def b/compat/zlib/contrib/vstudio/vc11/zlibvc.def
index 6367046..54e683d 100644
--- a/compat/zlib/contrib/vstudio/vc11/zlibvc.def
+++ b/compat/zlib/contrib/vstudio/vc11/zlibvc.def
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
-VERSION 1.2.8
+VERSION 1.2
EXPORTS
adler32 @1
@@ -141,3 +141,13 @@ EXPORTS
; zlib1 v1.2.8 added:
inflateGetDictionary @166
gzvprintf @167
+
+; zlib1 v1.2.9 added:
+ inflateCodesUsed @168
+ inflateValidate @169
+ uncompress2 @170
+ gzfread @171
+ gzfwrite @172
+ deflateGetDictionary @173
+ adler32_z @174
+ crc32_z @175
diff --git a/compat/zlib/contrib/vstudio/vc12/miniunz.vcxproj b/compat/zlib/contrib/vstudio/vc12/miniunz.vcxproj
new file mode 100644
index 0000000..d88ac7f
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/miniunz.vcxproj
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C52F9E7B-498A-42BE-8DB4-85A15694382A}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\minizip\miniunz.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc12/minizip.vcxproj b/compat/zlib/contrib/vstudio/vc12/minizip.vcxproj
new file mode 100644
index 0000000..f1f239c
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/minizip.vcxproj
@@ -0,0 +1,313 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniZip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniZip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniZip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniZip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\minizip\minizip.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj b/compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj
new file mode 100644
index 0000000..64b2cbe
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj
@@ -0,0 +1,430 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}</ProjectGuid>
+ <RootNamespace>testzlib</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\testzlib\testzlib.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj b/compat/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj
new file mode 100644
index 0000000..c66573a
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C52F9E7B-498A-42BE-8DB4-85A15694366A}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\testzlib\testzlib.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc12/zlib.rc b/compat/zlib/contrib/vstudio/vc12/zlib.rc
new file mode 100644
index 0000000..c4e4b01
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/zlib.rc
@@ -0,0 +1,32 @@
+#include <windows.h>
+
+#define IDR_VERSION1 1
+IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
+ FILEVERSION 1, 2, 11, 0
+ PRODUCTVERSION 1, 2, 11, 0
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS 0
+ FILEOS VOS_DOS_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0 // not used
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ //language ID = U.S. English, char set = Windows, Multilingual
+
+ BEGIN
+ VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
+ VALUE "FileVersion", "1.2.11\0"
+ VALUE "InternalName", "zlib\0"
+ VALUE "OriginalFilename", "zlibwapi.dll\0"
+ VALUE "ProductName", "ZLib.DLL\0"
+ VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409, 1252
+ END
+END
diff --git a/compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj b/compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj
new file mode 100644
index 0000000..3fdee7c
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj
@@ -0,0 +1,467 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\gzclose.c" />
+ <ClCompile Include="..\..\..\gzlib.c" />
+ <ClCompile Include="..\..\..\gzread.c" />
+ <ClCompile Include="..\..\..\gzwrite.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\minizip\ioapi.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\minizip\unzip.c" />
+ <ClCompile Include="..\..\minizip\zip.c" />
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="zlib.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="zlibvc.def" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc12/zlibvc.def b/compat/zlib/contrib/vstudio/vc12/zlibvc.def
new file mode 100644
index 0000000..54e683d
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/zlibvc.def
@@ -0,0 +1,153 @@
+LIBRARY
+; zlib data compression and ZIP file I/O library
+
+VERSION 1.2
+
+EXPORTS
+ adler32 @1
+ compress @2
+ crc32 @3
+ deflate @4
+ deflateCopy @5
+ deflateEnd @6
+ deflateInit2_ @7
+ deflateInit_ @8
+ deflateParams @9
+ deflateReset @10
+ deflateSetDictionary @11
+ gzclose @12
+ gzdopen @13
+ gzerror @14
+ gzflush @15
+ gzopen @16
+ gzread @17
+ gzwrite @18
+ inflate @19
+ inflateEnd @20
+ inflateInit2_ @21
+ inflateInit_ @22
+ inflateReset @23
+ inflateSetDictionary @24
+ inflateSync @25
+ uncompress @26
+ zlibVersion @27
+ gzprintf @28
+ gzputc @29
+ gzgetc @30
+ gzseek @31
+ gzrewind @32
+ gztell @33
+ gzeof @34
+ gzsetparams @35
+ zError @36
+ inflateSyncPoint @37
+ get_crc_table @38
+ compress2 @39
+ gzputs @40
+ gzgets @41
+ inflateCopy @42
+ inflateBackInit_ @43
+ inflateBack @44
+ inflateBackEnd @45
+ compressBound @46
+ deflateBound @47
+ gzclearerr @48
+ gzungetc @49
+ zlibCompileFlags @50
+ deflatePrime @51
+ deflatePending @52
+
+ unzOpen @61
+ unzClose @62
+ unzGetGlobalInfo @63
+ unzGetCurrentFileInfo @64
+ unzGoToFirstFile @65
+ unzGoToNextFile @66
+ unzOpenCurrentFile @67
+ unzReadCurrentFile @68
+ unzOpenCurrentFile3 @69
+ unztell @70
+ unzeof @71
+ unzCloseCurrentFile @72
+ unzGetGlobalComment @73
+ unzStringFileNameCompare @74
+ unzLocateFile @75
+ unzGetLocalExtrafield @76
+ unzOpen2 @77
+ unzOpenCurrentFile2 @78
+ unzOpenCurrentFilePassword @79
+
+ zipOpen @80
+ zipOpenNewFileInZip @81
+ zipWriteInFileInZip @82
+ zipCloseFileInZip @83
+ zipClose @84
+ zipOpenNewFileInZip2 @86
+ zipCloseFileInZipRaw @87
+ zipOpen2 @88
+ zipOpenNewFileInZip3 @89
+
+ unzGetFilePos @100
+ unzGoToFilePos @101
+
+ fill_win32_filefunc @110
+
+; zlibwapi v1.2.4 added:
+ fill_win32_filefunc64 @111
+ fill_win32_filefunc64A @112
+ fill_win32_filefunc64W @113
+
+ unzOpen64 @120
+ unzOpen2_64 @121
+ unzGetGlobalInfo64 @122
+ unzGetCurrentFileInfo64 @124
+ unzGetCurrentFileZStreamPos64 @125
+ unztell64 @126
+ unzGetFilePos64 @127
+ unzGoToFilePos64 @128
+
+ zipOpen64 @130
+ zipOpen2_64 @131
+ zipOpenNewFileInZip64 @132
+ zipOpenNewFileInZip2_64 @133
+ zipOpenNewFileInZip3_64 @134
+ zipOpenNewFileInZip4_64 @135
+ zipCloseFileInZipRaw64 @136
+
+; zlib1 v1.2.4 added:
+ adler32_combine @140
+ crc32_combine @142
+ deflateSetHeader @144
+ deflateTune @145
+ gzbuffer @146
+ gzclose_r @147
+ gzclose_w @148
+ gzdirect @149
+ gzoffset @150
+ inflateGetHeader @156
+ inflateMark @157
+ inflatePrime @158
+ inflateReset2 @159
+ inflateUndermine @160
+
+; zlib1 v1.2.6 added:
+ gzgetc_ @161
+ inflateResetKeep @163
+ deflateResetKeep @164
+
+; zlib1 v1.2.7 added:
+ gzopen_w @165
+
+; zlib1 v1.2.8 added:
+ inflateGetDictionary @166
+ gzvprintf @167
+
+; zlib1 v1.2.9 added:
+ inflateCodesUsed @168
+ inflateValidate @169
+ uncompress2 @170
+ gzfread @171
+ gzfwrite @172
+ deflateGetDictionary @173
+ adler32_z @174
+ crc32_z @175
diff --git a/compat/zlib/contrib/vstudio/vc12/zlibvc.sln b/compat/zlib/contrib/vstudio/vc12/zlibvc.sln
new file mode 100644
index 0000000..dcda229
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/zlibvc.sln
@@ -0,0 +1,119 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Itanium = Debug|Itanium
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Itanium = Release|Itanium
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium
+ ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32
+ ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj b/compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj
new file mode 100644
index 0000000..ab2b6c3
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj
@@ -0,0 +1,692 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8FD826F8-3739-44E6-8CC8-997122E53B8D}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">zlibwapi</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx86
+bld_ml32.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx86
+bld_ml32.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\contrib\masmx64
+bld_ml64.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx64
+bld_ml64.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\gzclose.c" />
+ <ClCompile Include="..\..\..\gzlib.c" />
+ <ClCompile Include="..\..\..\gzread.c" />
+ <ClCompile Include="..\..\..\gzwrite.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\minizip\ioapi.c" />
+ <ClCompile Include="..\..\minizip\iowin32.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\minizip\unzip.c">
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="..\..\minizip\zip.c">
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="zlib.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="zlibvc.def" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\deflate.h" />
+ <ClInclude Include="..\..\..\infblock.h" />
+ <ClInclude Include="..\..\..\infcodes.h" />
+ <ClInclude Include="..\..\..\inffast.h" />
+ <ClInclude Include="..\..\..\inftrees.h" />
+ <ClInclude Include="..\..\..\infutil.h" />
+ <ClInclude Include="..\..\..\zconf.h" />
+ <ClInclude Include="..\..\..\zlib.h" />
+ <ClInclude Include="..\..\..\zutil.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/miniunz.vcxproj b/compat/zlib/contrib/vstudio/vc14/miniunz.vcxproj
new file mode 100644
index 0000000..9b5c075
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/miniunz.vcxproj
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C52F9E7B-498A-42BE-8DB4-85A15694382A}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\MiniUnzip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\MiniUnzip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)miniunz.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)miniunz.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\minizip\miniunz.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/minizip.vcxproj b/compat/zlib/contrib/vstudio/vc14/minizip.vcxproj
new file mode 100644
index 0000000..968a410
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/minizip.vcxproj
@@ -0,0 +1,313 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniZip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\MiniZip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniZip$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\MiniZip$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)minizip.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)minizip.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\minizip\minizip.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj b/compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj
new file mode 100644
index 0000000..2c37125
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj
@@ -0,0 +1,430 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}</ProjectGuid>
+ <RootNamespace>testzlib</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlib$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlib$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)testzlib.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\testzlib\testzlib.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj b/compat/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj
new file mode 100644
index 0000000..d87474d
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C52F9E7B-498A-42BE-8DB4-85A15694366A}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\TestZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\..;..\..\minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\testzlib\testzlib.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="zlibvc.vcxproj">
+ <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/zlib.rc b/compat/zlib/contrib/vstudio/vc14/zlib.rc
new file mode 100644
index 0000000..c4e4b01
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/zlib.rc
@@ -0,0 +1,32 @@
+#include <windows.h>
+
+#define IDR_VERSION1 1
+IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
+ FILEVERSION 1, 2, 11, 0
+ PRODUCTVERSION 1, 2, 11, 0
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS 0
+ FILEOS VOS_DOS_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0 // not used
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ //language ID = U.S. English, char set = Windows, Multilingual
+
+ BEGIN
+ VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
+ VALUE "FileVersion", "1.2.11\0"
+ VALUE "InternalName", "zlib\0"
+ VALUE "OriginalFilename", "zlibwapi.dll\0"
+ VALUE "ProductName", "ZLib.DLL\0"
+ VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409, 1252
+ END
+END
diff --git a/compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj b/compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj
new file mode 100644
index 0000000..3e4b986
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj
@@ -0,0 +1,467 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibStat$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibStat$(Configuration)\Tmp\</IntDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalOptions>/MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibstat.lib</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\gzclose.c" />
+ <ClCompile Include="..\..\..\gzlib.c" />
+ <ClCompile Include="..\..\..\gzread.c" />
+ <ClCompile Include="..\..\..\gzwrite.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\minizip\ioapi.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\minizip\unzip.c" />
+ <ClCompile Include="..\..\minizip\zip.c" />
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="zlib.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="zlibvc.def" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc14/zlibvc.def b/compat/zlib/contrib/vstudio/vc14/zlibvc.def
new file mode 100644
index 0000000..54e683d
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/zlibvc.def
@@ -0,0 +1,153 @@
+LIBRARY
+; zlib data compression and ZIP file I/O library
+
+VERSION 1.2
+
+EXPORTS
+ adler32 @1
+ compress @2
+ crc32 @3
+ deflate @4
+ deflateCopy @5
+ deflateEnd @6
+ deflateInit2_ @7
+ deflateInit_ @8
+ deflateParams @9
+ deflateReset @10
+ deflateSetDictionary @11
+ gzclose @12
+ gzdopen @13
+ gzerror @14
+ gzflush @15
+ gzopen @16
+ gzread @17
+ gzwrite @18
+ inflate @19
+ inflateEnd @20
+ inflateInit2_ @21
+ inflateInit_ @22
+ inflateReset @23
+ inflateSetDictionary @24
+ inflateSync @25
+ uncompress @26
+ zlibVersion @27
+ gzprintf @28
+ gzputc @29
+ gzgetc @30
+ gzseek @31
+ gzrewind @32
+ gztell @33
+ gzeof @34
+ gzsetparams @35
+ zError @36
+ inflateSyncPoint @37
+ get_crc_table @38
+ compress2 @39
+ gzputs @40
+ gzgets @41
+ inflateCopy @42
+ inflateBackInit_ @43
+ inflateBack @44
+ inflateBackEnd @45
+ compressBound @46
+ deflateBound @47
+ gzclearerr @48
+ gzungetc @49
+ zlibCompileFlags @50
+ deflatePrime @51
+ deflatePending @52
+
+ unzOpen @61
+ unzClose @62
+ unzGetGlobalInfo @63
+ unzGetCurrentFileInfo @64
+ unzGoToFirstFile @65
+ unzGoToNextFile @66
+ unzOpenCurrentFile @67
+ unzReadCurrentFile @68
+ unzOpenCurrentFile3 @69
+ unztell @70
+ unzeof @71
+ unzCloseCurrentFile @72
+ unzGetGlobalComment @73
+ unzStringFileNameCompare @74
+ unzLocateFile @75
+ unzGetLocalExtrafield @76
+ unzOpen2 @77
+ unzOpenCurrentFile2 @78
+ unzOpenCurrentFilePassword @79
+
+ zipOpen @80
+ zipOpenNewFileInZip @81
+ zipWriteInFileInZip @82
+ zipCloseFileInZip @83
+ zipClose @84
+ zipOpenNewFileInZip2 @86
+ zipCloseFileInZipRaw @87
+ zipOpen2 @88
+ zipOpenNewFileInZip3 @89
+
+ unzGetFilePos @100
+ unzGoToFilePos @101
+
+ fill_win32_filefunc @110
+
+; zlibwapi v1.2.4 added:
+ fill_win32_filefunc64 @111
+ fill_win32_filefunc64A @112
+ fill_win32_filefunc64W @113
+
+ unzOpen64 @120
+ unzOpen2_64 @121
+ unzGetGlobalInfo64 @122
+ unzGetCurrentFileInfo64 @124
+ unzGetCurrentFileZStreamPos64 @125
+ unztell64 @126
+ unzGetFilePos64 @127
+ unzGoToFilePos64 @128
+
+ zipOpen64 @130
+ zipOpen2_64 @131
+ zipOpenNewFileInZip64 @132
+ zipOpenNewFileInZip2_64 @133
+ zipOpenNewFileInZip3_64 @134
+ zipOpenNewFileInZip4_64 @135
+ zipCloseFileInZipRaw64 @136
+
+; zlib1 v1.2.4 added:
+ adler32_combine @140
+ crc32_combine @142
+ deflateSetHeader @144
+ deflateTune @145
+ gzbuffer @146
+ gzclose_r @147
+ gzclose_w @148
+ gzdirect @149
+ gzoffset @150
+ inflateGetHeader @156
+ inflateMark @157
+ inflatePrime @158
+ inflateReset2 @159
+ inflateUndermine @160
+
+; zlib1 v1.2.6 added:
+ gzgetc_ @161
+ inflateResetKeep @163
+ deflateResetKeep @164
+
+; zlib1 v1.2.7 added:
+ gzopen_w @165
+
+; zlib1 v1.2.8 added:
+ inflateGetDictionary @166
+ gzvprintf @167
+
+; zlib1 v1.2.9 added:
+ inflateCodesUsed @168
+ inflateValidate @169
+ uncompress2 @170
+ gzfread @171
+ gzfwrite @172
+ deflateGetDictionary @173
+ adler32_z @174
+ crc32_z @175
diff --git a/compat/zlib/contrib/vstudio/vc14/zlibvc.sln b/compat/zlib/contrib/vstudio/vc14/zlibvc.sln
new file mode 100644
index 0000000..6f4a107
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/zlibvc.sln
@@ -0,0 +1,119 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Itanium = Debug|Itanium
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Itanium = Release|Itanium
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium
+ ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32
+ ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
+ {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32
+ {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj b/compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj
new file mode 100644
index 0000000..f8f673c
--- /dev/null
+++ b/compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj
@@ -0,0 +1,692 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Itanium">
+ <Configuration>Debug</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Itanium">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|Win32">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="ReleaseWithoutAsm|x64">
+ <Configuration>ReleaseWithoutAsm</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Itanium">
+ <Configuration>Release</Configuration>
+ <Platform>Itanium</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8FD826F8-3739-44E6-8CC8-997122E53B8D}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">x64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibDll$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ia64\ZlibDll$(Configuration)\Tmp\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">false</GenerateManifest>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">zlibwapi</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">zlibwapi</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx86
+bld_ml32.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx86
+bld_ml32.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\contrib\masmx64
+bld_ml64.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <PreBuildEvent>
+ <Command>cd ..\..\masmx64
+bld_ml64.bat</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Itanium</TargetEnvironment>
+ <TypeLibraryName>$(OutDir)zlibvc.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeaderOutputFile>$(IntDir)zlibvc.pch</PrecompiledHeaderOutputFile>
+ <AssemblerOutput>All</AssemblerOutput>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)</ProgramDataBaseFileName>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x040c</Culture>
+ </ResourceCompile>
+ <Link>
+ <OutputFile>$(OutDir)zlibwapi.dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <ModuleDefinitionFile>.\zlibvc.def</ModuleDefinitionFile>
+ <ProgramDatabaseFile>$(OutDir)zlibwapi.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapFileName>$(OutDir)zlibwapi.map</MapFileName>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
+ <TargetMachine>MachineIA64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\adler32.c" />
+ <ClCompile Include="..\..\..\compress.c" />
+ <ClCompile Include="..\..\..\crc32.c" />
+ <ClCompile Include="..\..\..\deflate.c" />
+ <ClCompile Include="..\..\..\gzclose.c" />
+ <ClCompile Include="..\..\..\gzlib.c" />
+ <ClCompile Include="..\..\..\gzread.c" />
+ <ClCompile Include="..\..\..\gzwrite.c" />
+ <ClCompile Include="..\..\..\infback.c" />
+ <ClCompile Include="..\..\masmx64\inffas8664.c">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\inffast.c" />
+ <ClCompile Include="..\..\..\inflate.c" />
+ <ClCompile Include="..\..\..\inftrees.c" />
+ <ClCompile Include="..\..\minizip\ioapi.c" />
+ <ClCompile Include="..\..\minizip\iowin32.c" />
+ <ClCompile Include="..\..\..\trees.c" />
+ <ClCompile Include="..\..\..\uncompr.c" />
+ <ClCompile Include="..\..\minizip\unzip.c">
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="..\..\minizip\zip.c">
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ZLIB_INTERNAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="..\..\..\zutil.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="zlib.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="zlibvc.def" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\deflate.h" />
+ <ClInclude Include="..\..\..\infblock.h" />
+ <ClInclude Include="..\..\..\infcodes.h" />
+ <ClInclude Include="..\..\..\inffast.h" />
+ <ClInclude Include="..\..\..\inftrees.h" />
+ <ClInclude Include="..\..\..\infutil.h" />
+ <ClInclude Include="..\..\..\zconf.h" />
+ <ClInclude Include="..\..\..\zlib.h" />
+ <ClInclude Include="..\..\..\zutil.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/compat/zlib/contrib/vstudio/vc9/zlib.rc b/compat/zlib/contrib/vstudio/vc9/zlib.rc
index 73f6476..fee177a 100644
--- a/compat/zlib/contrib/vstudio/vc9/zlib.rc
+++ b/compat/zlib/contrib/vstudio/vc9/zlib.rc
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,8,0
- PRODUCTVERSION 1,2,8,0
+ FILEVERSION 1, 2, 11, 0
+ PRODUCTVERSION 1, 2, 11, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
- VALUE "FileVersion", "1.2.8\0"
+ VALUE "FileVersion", "1.2.11\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
diff --git a/compat/zlib/contrib/vstudio/vc9/zlibvc.def b/compat/zlib/contrib/vstudio/vc9/zlibvc.def
index 6367046..54e683d 100644
--- a/compat/zlib/contrib/vstudio/vc9/zlibvc.def
+++ b/compat/zlib/contrib/vstudio/vc9/zlibvc.def
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
-VERSION 1.2.8
+VERSION 1.2
EXPORTS
adler32 @1
@@ -141,3 +141,13 @@ EXPORTS
; zlib1 v1.2.8 added:
inflateGetDictionary @166
gzvprintf @167
+
+; zlib1 v1.2.9 added:
+ inflateCodesUsed @168
+ inflateValidate @169
+ uncompress2 @170
+ gzfread @171
+ gzfwrite @172
+ deflateGetDictionary @173
+ adler32_z @174
+ crc32_z @175
diff --git a/compat/zlib/crc32.c b/compat/zlib/crc32.c
index 979a719..9580440 100644
--- a/compat/zlib/crc32.c
+++ b/compat/zlib/crc32.c
@@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -30,17 +30,15 @@
#include "zutil.h" /* for STDC and FAR definitions */
-#define local static
-
/* Definitions for doing the crc four data bytes at a time. */
#if !defined(NOBYFOUR) && defined(Z_U4)
# define BYFOUR
#endif
#ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
+ const unsigned char FAR *, z_size_t));
local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
+ const unsigned char FAR *, z_size_t));
# define TBLS 8
#else
# define TBLS 1
@@ -201,10 +199,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
+unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- uInt len;
+ z_size_t len;
{
if (buf == Z_NULL) return 0UL;
@@ -235,8 +233,29 @@ unsigned long ZEXPORT crc32(crc, buf, len)
return crc ^ 0xffffffffUL;
}
+/* ========================================================================= */
+unsigned long ZEXPORT crc32(crc, buf, len)
+ unsigned long crc;
+ const unsigned char FAR *buf;
+ uInt len;
+{
+ return crc32_z(crc, buf, len);
+}
+
#ifdef BYFOUR
+/*
+ This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
+ integer pointer type. This violates the strict aliasing rule, where a
+ compiler can assume, for optimization purposes, that two pointers to
+ fundamentally different types won't ever point to the same memory. This can
+ manifest as a problem only if one of the pointers is written to. This code
+ only reads from those pointers. So long as this code remains isolated in
+ this compilation unit, there won't be a problem. For this reason, this code
+ should not be copied and pasted into a compilation unit in which other code
+ writes to the buffer that is passed to these routines.
+ */
+
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
@@ -247,7 +266,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- unsigned len;
+ z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
@@ -278,7 +297,7 @@ local unsigned long crc32_little(crc, buf, len)
}
/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
+#define DOBIG4 c ^= *buf4++; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
@@ -287,7 +306,7 @@ local unsigned long crc32_little(crc, buf, len)
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- unsigned len;
+ z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
@@ -300,7 +319,6 @@ local unsigned long crc32_big(crc, buf, len)
}
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
- buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
@@ -309,7 +327,6 @@ local unsigned long crc32_big(crc, buf, len)
DOBIG4;
len -= 4;
}
- buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do {
diff --git a/compat/zlib/deflate.c b/compat/zlib/deflate.c
index 6969577..1ec7614 100644
--- a/compat/zlib/deflate.c
+++ b/compat/zlib/deflate.c
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -73,6 +73,8 @@ typedef enum {
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
/* Compression function. Returns the block state after the call. */
+local int deflateStateCheck OF((z_streamp strm));
+local void slide_hash OF((deflate_state *s));
local void fill_window OF((deflate_state *s));
local block_state deflate_stored OF((deflate_state *s, int flush));
local block_state deflate_fast OF((deflate_state *s, int flush));
@@ -84,15 +86,16 @@ local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
+local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
#ifdef ASMV
+# pragma message("Assembler code may have bugs -- use at your own risk")
void match_init OF((void)); /* asm code initialization */
uInt longest_match OF((deflate_state *s, IPos cur_match));
#else
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
int length));
#endif
@@ -148,21 +151,14 @@ local const config configuration_table[10] = {
* meaning.
*/
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
-#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
+#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
/* ===========================================================================
* Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
+ * IN assertion: all calls to UPDATE_HASH are made with consecutive input
+ * characters, so that a running hash key can be computed from the previous
+ * key instead of complete recalculation each time.
*/
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
@@ -173,9 +169,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
* the previous length of the hash chain.
* If this file is compiled with -DFASTEST, the compression level is forced
* to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
+ * IN assertion: all calls to INSERT_STRING are made with consecutive input
+ * characters and the first MIN_MATCH bytes of str are valid (except for
+ * the last MIN_MATCH-1 bytes of the input file).
*/
#ifdef FASTEST
#define INSERT_STRING(s, str, match_head) \
@@ -197,6 +193,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
s->head[s->hash_size-1] = NIL; \
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+/* ===========================================================================
+ * Slide the hash table when sliding the window down (could be avoided with 32
+ * bit values at the expense of memory usage). We slide even when level == 0 to
+ * keep the hash table consistent if we switch back to level > 0 later.
+ */
+local void slide_hash(s)
+ deflate_state *s;
+{
+ unsigned n, m;
+ Posf *p;
+ uInt wsize = s->w_size;
+
+ n = s->hash_size;
+ p = &s->head[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m - wsize : NIL);
+ } while (--n);
+ n = wsize;
+#ifndef FASTEST
+ p = &s->prev[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m - wsize : NIL);
+ /* If n is not on any hash chain, prev[n] is garbage but
+ * its value will never be used.
+ */
+ } while (--n);
+#endif
+}
+
/* ========================================================================= */
int ZEXPORT deflateInit_(strm, level, version, stream_size)
z_streamp strm;
@@ -270,7 +297,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
#endif
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
+ strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
return Z_STREAM_ERROR;
}
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
@@ -278,14 +305,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
if (s == Z_NULL) return Z_MEM_ERROR;
strm->state = (struct internal_state FAR *)s;
s->strm = strm;
+ s->status = INIT_STATE; /* to pass state test in deflateReset() */
s->wrap = wrap;
s->gzhead = Z_NULL;
- s->w_bits = windowBits;
+ s->w_bits = (uInt)windowBits;
s->w_size = 1 << s->w_bits;
s->w_mask = s->w_size - 1;
- s->hash_bits = memLevel + 7;
+ s->hash_bits = (uInt)memLevel + 7;
s->hash_size = 1 << s->hash_bits;
s->hash_mask = s->hash_size - 1;
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
@@ -319,6 +347,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
return deflateReset(strm);
}
+/* =========================================================================
+ * Check for a valid deflate stream state. Return 0 if ok, 1 if not.
+ */
+local int deflateStateCheck (strm)
+ z_streamp strm;
+{
+ deflate_state *s;
+ if (strm == Z_NULL ||
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
+ return 1;
+ s = strm->state;
+ if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
+#ifdef GZIP
+ s->status != GZIP_STATE &&
+#endif
+ s->status != EXTRA_STATE &&
+ s->status != NAME_STATE &&
+ s->status != COMMENT_STATE &&
+ s->status != HCRC_STATE &&
+ s->status != BUSY_STATE &&
+ s->status != FINISH_STATE))
+ return 1;
+ return 0;
+}
+
/* ========================================================================= */
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
z_streamp strm;
@@ -331,7 +384,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
unsigned avail;
z_const unsigned char *next;
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
+ if (deflateStateCheck(strm) || dictionary == Z_NULL)
return Z_STREAM_ERROR;
s = strm->state;
wrap = s->wrap;
@@ -389,13 +442,34 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
}
/* ========================================================================= */
+int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
+ z_streamp strm;
+ Bytef *dictionary;
+ uInt *dictLength;
+{
+ deflate_state *s;
+ uInt len;
+
+ if (deflateStateCheck(strm))
+ return Z_STREAM_ERROR;
+ s = strm->state;
+ len = s->strstart + s->lookahead;
+ if (len > s->w_size)
+ len = s->w_size;
+ if (dictionary != Z_NULL && len)
+ zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
+ if (dictLength != Z_NULL)
+ *dictLength = len;
+ return Z_OK;
+}
+
+/* ========================================================================= */
int ZEXPORT deflateResetKeep (strm)
z_streamp strm;
{
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+ if (deflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
@@ -410,7 +484,11 @@ int ZEXPORT deflateResetKeep (strm)
if (s->wrap < 0) {
s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
}
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
+ s->status =
+#ifdef GZIP
+ s->wrap == 2 ? GZIP_STATE :
+#endif
+ s->wrap ? INIT_STATE : BUSY_STATE;
strm->adler =
#ifdef GZIP
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
@@ -440,8 +518,8 @@ int ZEXPORT deflateSetHeader (strm, head)
z_streamp strm;
gz_headerp head;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm) || strm->state->wrap != 2)
+ return Z_STREAM_ERROR;
strm->state->gzhead = head;
return Z_OK;
}
@@ -452,7 +530,7 @@ int ZEXPORT deflatePending (strm, pending, bits)
int *bits;
z_streamp strm;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (pending != Z_NULL)
*pending = strm->state->pending;
if (bits != Z_NULL)
@@ -469,7 +547,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
deflate_state *s;
int put;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
return Z_BUF_ERROR;
@@ -494,9 +572,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
{
deflate_state *s;
compress_func func;
- int err = Z_OK;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
#ifdef FASTEST
@@ -510,13 +587,22 @@ int ZEXPORT deflateParams(strm, level, strategy)
func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func) &&
- strm->total_in != 0) {
+ s->high_water) {
/* Flush the last buffer: */
- err = deflate(strm, Z_BLOCK);
- if (err == Z_BUF_ERROR && s->pending == 0)
- err = Z_OK;
+ int err = deflate(strm, Z_BLOCK);
+ if (err == Z_STREAM_ERROR)
+ return err;
+ if (strm->avail_out == 0)
+ return Z_BUF_ERROR;
}
if (s->level != level) {
+ if (s->level == 0 && s->matches != 0) {
+ if (s->matches == 1)
+ slide_hash(s);
+ else
+ CLEAR_HASH(s);
+ s->matches = 0;
+ }
s->level = level;
s->max_lazy_match = configuration_table[level].max_lazy;
s->good_match = configuration_table[level].good_length;
@@ -524,7 +610,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
s->max_chain_length = configuration_table[level].max_chain;
}
s->strategy = strategy;
- return err;
+ return Z_OK;
}
/* ========================================================================= */
@@ -537,12 +623,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
{
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
+ s->good_match = (uInt)good_length;
+ s->max_lazy_match = (uInt)max_lazy;
s->nice_match = nice_length;
- s->max_chain_length = max_chain;
+ s->max_chain_length = (uInt)max_chain;
return Z_OK;
}
@@ -569,14 +655,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
{
deflate_state *s;
uLong complen, wraplen;
- Bytef *str;
/* conservative upper bound for compressed data */
complen = sourceLen +
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
/* if can't get parameters, return conservative bound plus zlib wrapper */
- if (strm == Z_NULL || strm->state == Z_NULL)
+ if (deflateStateCheck(strm))
return complen + 6;
/* compute wrapper length */
@@ -588,9 +673,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
case 1: /* zlib wrapper */
wraplen = 6 + (s->strstart ? 4 : 0);
break;
+#ifdef GZIP
case 2: /* gzip wrapper */
wraplen = 18;
if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
+ Bytef *str;
if (s->gzhead->extra != Z_NULL)
wraplen += 2 + s->gzhead->extra_len;
str = s->gzhead->name;
@@ -607,6 +694,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
wraplen += 2;
}
break;
+#endif
default: /* for compiler happiness */
wraplen = 6;
}
@@ -634,10 +722,10 @@ local void putShortMSB (s, b)
}
/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
+ * Flush as much pending output as possible. All deflate() output, except for
+ * some deflate_stored() output, goes through this function so some
+ * applications may wish to modify it to avoid allocating a large
+ * strm->next_out buffer and copying into it. (See also read_buf()).
*/
local void flush_pending(strm)
z_streamp strm;
@@ -654,13 +742,23 @@ local void flush_pending(strm)
strm->next_out += len;
s->pending_out += len;
strm->total_out += len;
- strm->avail_out -= len;
- s->pending -= len;
+ strm->avail_out -= len;
+ s->pending -= len;
if (s->pending == 0) {
s->pending_out = s->pending_buf;
}
}
+/* ===========================================================================
+ * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].
+ */
+#define HCRC_UPDATE(beg) \
+ do { \
+ if (s->gzhead->hcrc && s->pending > (beg)) \
+ strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
+ s->pending - (beg)); \
+ } while (0)
+
/* ========================================================================= */
int ZEXPORT deflate (strm, flush)
z_streamp strm;
@@ -669,230 +767,229 @@ int ZEXPORT deflate (strm, flush)
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_BLOCK || flush < 0) {
+ if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
+ (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
(s->status == FINISH_STATE && flush != Z_FINISH)) {
ERR_RETURN(strm, Z_STREAM_ERROR);
}
if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
- s->strm = strm; /* just in case */
old_flush = s->last_flush;
s->last_flush = flush;
+ /* Flush as much pending output as possible */
+ if (s->pending != 0) {
+ flush_pending(strm);
+ if (strm->avail_out == 0) {
+ /* Since avail_out is 0, deflate will be called again with
+ * more output space, but possibly with both pending and
+ * avail_in equal to zero. There won't be anything to do,
+ * but this is not an error situation so make sure we
+ * return OK instead of BUF_ERROR at next call of deflate:
+ */
+ s->last_flush = -1;
+ return Z_OK;
+ }
+
+ /* Make sure there is something to do and avoid duplicate consecutive
+ * flushes. For repeated and useless calls with Z_FINISH, we keep
+ * returning Z_STREAM_END instead of Z_BUF_ERROR.
+ */
+ } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
+ flush != Z_FINISH) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
+ /* User must not provide more input after the first FINISH: */
+ if (s->status == FINISH_STATE && strm->avail_in != 0) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
/* Write the header */
if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == Z_NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != Z_NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
+ /* zlib header */
+ uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
+ uInt level_flags;
+
+ if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
+ level_flags = 0;
+ else if (s->level < 6)
+ level_flags = 1;
+ else if (s->level == 6)
+ level_flags = 2;
else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
+ level_flags = 3;
+ header |= (level_flags << 6);
+ if (s->strstart != 0) header |= PRESET_DICT;
+ header += 31 - (header % 31);
+
+ putShortMSB(s, header);
+ /* Save the adler32 of the preset dictionary: */
+ if (s->strstart != 0) {
+ putShortMSB(s, (uInt)(strm->adler >> 16));
+ putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ }
+ strm->adler = adler32(0L, Z_NULL, 0);
+ s->status = BUSY_STATE;
+
+ /* Compression must start with an empty pending buffer */
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
+ }
+#ifdef GZIP
+ if (s->status == GZIP_STATE) {
+ /* gzip header */
+ strm->adler = crc32(0L, Z_NULL, 0);
+ put_byte(s, 31);
+ put_byte(s, 139);
+ put_byte(s, 8);
+ if (s->gzhead == Z_NULL) {
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, OS_CODE);
s->status = BUSY_STATE;
- putShortMSB(s, header);
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ /* Compression must start with an empty pending buffer */
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
+ }
+ else {
+ put_byte(s, (s->gzhead->text ? 1 : 0) +
+ (s->gzhead->hcrc ? 2 : 0) +
+ (s->gzhead->extra == Z_NULL ? 0 : 4) +
+ (s->gzhead->name == Z_NULL ? 0 : 8) +
+ (s->gzhead->comment == Z_NULL ? 0 : 16)
+ );
+ put_byte(s, (Byte)(s->gzhead->time & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, s->gzhead->os & 0xff);
+ if (s->gzhead->extra != Z_NULL) {
+ put_byte(s, s->gzhead->extra_len & 0xff);
+ put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
}
- strm->adler = adler32(0L, Z_NULL, 0);
+ if (s->gzhead->hcrc)
+ strm->adler = crc32(strm->adler, s->pending_buf,
+ s->pending);
+ s->gzindex = 0;
+ s->status = EXTRA_STATE;
}
}
-#ifdef GZIP
if (s->status == EXTRA_STATE) {
if (s->gzhead->extra != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
+ ulg beg = s->pending; /* start of bytes to update crc */
+ uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
+ while (s->pending + left > s->pending_buf_size) {
+ uInt copy = s->pending_buf_size - s->pending;
+ zmemcpy(s->pending_buf + s->pending,
+ s->gzhead->extra + s->gzindex, copy);
+ s->pending = s->pending_buf_size;
+ HCRC_UPDATE(beg);
+ s->gzindex += copy;
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
+ beg = 0;
+ left -= copy;
}
+ zmemcpy(s->pending_buf + s->pending,
+ s->gzhead->extra + s->gzindex, left);
+ s->pending += left;
+ HCRC_UPDATE(beg);
+ s->gzindex = 0;
}
- else
- s->status = NAME_STATE;
+ s->status = NAME_STATE;
}
if (s->status == NAME_STATE) {
if (s->gzhead->name != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ ulg beg = s->pending; /* start of bytes to update crc */
int val;
-
do {
if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
+ HCRC_UPDATE(beg);
flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
+ beg = 0;
}
val = s->gzhead->name[s->gzindex++];
put_byte(s, val);
} while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
+ HCRC_UPDATE(beg);
+ s->gzindex = 0;
}
- else
- s->status = COMMENT_STATE;
+ s->status = COMMENT_STATE;
}
if (s->status == COMMENT_STATE) {
if (s->gzhead->comment != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ ulg beg = s->pending; /* start of bytes to update crc */
int val;
-
do {
if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
+ HCRC_UPDATE(beg);
flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
+ beg = 0;
}
val = s->gzhead->comment[s->gzindex++];
put_byte(s, val);
} while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
+ HCRC_UPDATE(beg);
}
- else
- s->status = HCRC_STATE;
+ s->status = HCRC_STATE;
}
if (s->status == HCRC_STATE) {
if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
+ if (s->pending + 2 > s->pending_buf_size) {
flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
}
+ put_byte(s, (Byte)(strm->adler & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
+ strm->adler = crc32(0L, Z_NULL, 0);
}
- else
- s->status = BUSY_STATE;
- }
-#endif
+ s->status = BUSY_STATE;
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
+ /* Compression must start with an empty pending buffer */
flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
+ if (s->pending != 0) {
s->last_flush = -1;
return Z_OK;
}
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
}
+#endif
/* Start a new block or continue the current one.
*/
@@ -900,9 +997,10 @@ int ZEXPORT deflate (strm, flush)
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
- bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
- (s->strategy == Z_RLE ? deflate_rle(s, flush) :
- (*(configuration_table[s->level].func))(s, flush));
+ bstate = s->level == 0 ? deflate_stored(s, flush) :
+ s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
+ s->strategy == Z_RLE ? deflate_rle(s, flush) :
+ (*(configuration_table[s->level].func))(s, flush);
if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
@@ -944,7 +1042,6 @@ int ZEXPORT deflate (strm, flush)
}
}
}
- Assert(strm->avail_out > 0, "bug2");
if (flush != Z_FINISH) return Z_OK;
if (s->wrap <= 0) return Z_STREAM_END;
@@ -981,18 +1078,9 @@ int ZEXPORT deflateEnd (strm)
{
int status;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
/* Deallocate in reverse order of allocations: */
TRY_FREE(strm, strm->state->pending_buf);
@@ -1023,7 +1111,7 @@ int ZEXPORT deflateCopy (dest, source)
ushf *overlay;
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
+ if (deflateStateCheck(source) || dest == Z_NULL) {
return Z_STREAM_ERROR;
}
@@ -1073,7 +1161,7 @@ int ZEXPORT deflateCopy (dest, source)
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
-local int read_buf(strm, buf, size)
+local unsigned read_buf(strm, buf, size)
z_streamp strm;
Bytef *buf;
unsigned size;
@@ -1097,7 +1185,7 @@ local int read_buf(strm, buf, size)
strm->next_in += len;
strm->total_in += len;
- return (int)len;
+ return len;
}
/* ===========================================================================
@@ -1151,9 +1239,9 @@ local uInt longest_match(s, cur_match)
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
+ register Bytef *match; /* matched string */
register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
+ int best_len = (int)s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
s->strstart - (IPos)MAX_DIST(s) : NIL;
@@ -1188,7 +1276,7 @@ local uInt longest_match(s, cur_match)
/* Do not look for matches beyond the end of the input. This is necessary
* to make deflate deterministic.
*/
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+ if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
@@ -1349,7 +1437,11 @@ local uInt longest_match(s, cur_match)
#endif /* FASTEST */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
+
+#define EQUAL 0
+/* result of memcmp for equal strings */
+
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
@@ -1375,7 +1467,7 @@ local void check_match(s, start, match, length)
}
#else
# define check_match(s, start, match, length)
-#endif /* DEBUG */
+#endif /* ZLIB_DEBUG */
/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
@@ -1390,8 +1482,7 @@ local void check_match(s, start, match, length)
local void fill_window(s)
deflate_state *s;
{
- register unsigned n, m;
- register Posf *p;
+ unsigned n;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
@@ -1418,35 +1509,11 @@ local void fill_window(s)
*/
if (s->strstart >= wsize+MAX_DIST(s)) {
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
+ zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
+ slide_hash(s);
more += wsize;
}
if (s->strm->avail_in == 0) break;
@@ -1552,70 +1619,199 @@ local void fill_window(s)
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
+/* Maximum stored block length in deflate format (not including header). */
+#define MAX_STORED 65535
+
+/* Minimum of a and b. */
+#define MIN(a, b) ((a) > (b) ? (b) : (a))
+
/* ===========================================================================
* Copy without compression as much as possible from the input stream, return
* the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
+ *
+ * In case deflateParams() is used to later switch to a non-zero compression
+ * level, s->matches (otherwise unused when storing) keeps track of the number
+ * of hash table slides to perform. If s->matches is 1, then one hash table
+ * slide will be done when switching. If s->matches is 2, the maximum value
+ * allowed here, then the hash table will be cleared, since two or more slides
+ * is the same as a clear.
+ *
+ * deflate_stored() is written to minimize the number of times an input byte is
+ * copied. It is most efficient with large input and output buffers, which
+ * maximizes the opportunites to have a single copy from next_in to next_out.
*/
local block_state deflate_stored(s, flush)
deflate_state *s;
int flush;
{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
+ /* Smallest worthy block size when not flushing or finishing. By default
+ * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
+ * large input and output buffers, the stored block size will be larger.
*/
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
+ unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
+ /* Copy as many min_block or larger stored blocks directly to next_out as
+ * possible. If flushing, copy the remaining available input to next_out as
+ * stored blocks, if there is enough space.
+ */
+ unsigned len, left, have, last = 0;
+ unsigned used = s->strm->avail_in;
+ do {
+ /* Set len to the maximum size block that we can copy directly with the
+ * available input data and output space. Set left to how much of that
+ * would be copied from what's left in the window.
+ */
+ len = MAX_STORED; /* maximum deflate stored block length */
+ have = (s->bi_valid + 42) >> 3; /* number of header bytes */
+ if (s->strm->avail_out < have) /* need room for header */
+ break;
+ /* maximum stored block length that will fit in avail_out: */
+ have = s->strm->avail_out - have;
+ left = s->strstart - s->block_start; /* bytes left in window */
+ if (len > (ulg)left + s->strm->avail_in)
+ len = left + s->strm->avail_in; /* limit len to the input */
+ if (len > have)
+ len = have; /* limit len to the output */
+
+ /* If the stored block would be less than min_block in length, or if
+ * unable to copy all of the available input when flushing, then try
+ * copying to the window and the pending buffer instead. Also don't
+ * write an empty block when flushing -- deflate() does that.
+ */
+ if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
+ flush == Z_NO_FLUSH ||
+ len != left + s->strm->avail_in))
+ break;
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
+ /* Make a dummy stored block in pending to get the header bytes,
+ * including any pending bits. This also updates the debugging counts.
+ */
+ last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
+ _tr_stored_block(s, (char *)0, 0L, last);
+
+ /* Replace the lengths in the dummy stored block with len. */
+ s->pending_buf[s->pending - 4] = len;
+ s->pending_buf[s->pending - 3] = len >> 8;
+ s->pending_buf[s->pending - 2] = ~len;
+ s->pending_buf[s->pending - 1] = ~len >> 8;
+
+ /* Write the stored block header bytes. */
+ flush_pending(s->strm);
+
+#ifdef ZLIB_DEBUG
+ /* Update debugging counts for the data about to be copied. */
+ s->compressed_len += len << 3;
+ s->bits_sent += len << 3;
+#endif
- if (s->lookahead == 0) break; /* flush the current block */
+ /* Copy uncompressed bytes from the window to next_out. */
+ if (left) {
+ if (left > len)
+ left = len;
+ zmemcpy(s->strm->next_out, s->window + s->block_start, left);
+ s->strm->next_out += left;
+ s->strm->avail_out -= left;
+ s->strm->total_out += left;
+ s->block_start += left;
+ len -= left;
}
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
+
+ /* Copy uncompressed bytes directly from next_in to next_out, updating
+ * the check value.
+ */
+ if (len) {
+ read_buf(s->strm, s->strm->next_out, len);
+ s->strm->next_out += len;
+ s->strm->avail_out -= len;
+ s->strm->total_out += len;
}
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
+ } while (last == 0);
+
+ /* Update the sliding window with the last s->w_size bytes of the copied
+ * data, or append all of the copied data to the existing window if less
+ * than s->w_size bytes were copied. Also update the number of bytes to
+ * insert in the hash tables, in the event that deflateParams() switches to
+ * a non-zero compression level.
+ */
+ used -= s->strm->avail_in; /* number of input bytes directly copied */
+ if (used) {
+ /* If any input was used, then no unused input remains in the window,
+ * therefore s->block_start == s->strstart.
*/
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
+ if (used >= s->w_size) { /* supplant the previous history */
+ s->matches = 2; /* clear hash */
+ zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
+ s->strstart = s->w_size;
}
+ else {
+ if (s->window_size - s->strstart <= used) {
+ /* Slide the window down. */
+ s->strstart -= s->w_size;
+ zmemcpy(s->window, s->window + s->w_size, s->strstart);
+ if (s->matches < 2)
+ s->matches++; /* add a pending slide_hash() */
+ }
+ zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
+ s->strstart += used;
+ }
+ s->block_start = s->strstart;
+ s->insert += MIN(used, s->w_size - s->insert);
}
- s->insert = 0;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
+
+ /* If the last block was written to next_out, then done. */
+ if (last)
return finish_done;
+
+ /* If flushing and all input has been consumed, then done. */
+ if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
+ s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
+ return block_done;
+
+ /* Fill the window with any remaining input. */
+ have = s->window_size - s->strstart - 1;
+ if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
+ /* Slide the window down. */
+ s->block_start -= s->w_size;
+ s->strstart -= s->w_size;
+ zmemcpy(s->window, s->window + s->w_size, s->strstart);
+ if (s->matches < 2)
+ s->matches++; /* add a pending slide_hash() */
+ have += s->w_size; /* more space now */
}
- if ((long)s->strstart > s->block_start)
- FLUSH_BLOCK(s, 0);
- return block_done;
+ if (have > s->strm->avail_in)
+ have = s->strm->avail_in;
+ if (have) {
+ read_buf(s->strm, s->window + s->strstart, have);
+ s->strstart += have;
+ }
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
+
+ /* There was not enough avail_out to write a complete worthy or flushed
+ * stored block to next_out. Write a stored block to pending instead, if we
+ * have enough input for a worthy block, or if flushing and there is enough
+ * room for the remaining input as a stored block in the pending buffer.
+ */
+ have = (s->bi_valid + 42) >> 3; /* number of header bytes */
+ /* maximum stored block length that will fit in pending: */
+ have = MIN(s->pending_buf_size - have, MAX_STORED);
+ min_block = MIN(have, s->w_size);
+ left = s->strstart - s->block_start;
+ if (left >= min_block ||
+ ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
+ s->strm->avail_in == 0 && left <= have)) {
+ len = MIN(left, have);
+ last = flush == Z_FINISH && s->strm->avail_in == 0 &&
+ len == left ? 1 : 0;
+ _tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
+ s->block_start += len;
+ flush_pending(s->strm);
+ }
+
+ /* We've done all we can with the available input and output. */
+ return last ? finish_started : need_more;
}
/* ===========================================================================
@@ -1892,7 +2088,7 @@ local block_state deflate_rle(s, flush)
prev == *++scan && prev == *++scan &&
prev == *++scan && prev == *++scan &&
scan < strend);
- s->match_length = MAX_MATCH - (int)(strend - scan);
+ s->match_length = MAX_MATCH - (uInt)(strend - scan);
if (s->match_length > s->lookahead)
s->match_length = s->lookahead;
}
diff --git a/compat/zlib/deflate.h b/compat/zlib/deflate.h
index ce0299e..23ecdd3 100644
--- a/compat/zlib/deflate.h
+++ b/compat/zlib/deflate.h
@@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
- * Copyright (C) 1995-2012 Jean-loup Gailly
+ * Copyright (C) 1995-2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -51,13 +51,16 @@
#define Buf_size 16
/* size of bit buffer in bi_buf */
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
+#define INIT_STATE 42 /* zlib header -> BUSY_STATE */
+#ifdef GZIP
+# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */
+#endif
+#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */
+#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */
+#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */
+#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */
+#define BUSY_STATE 113 /* deflate -> FINISH_STATE */
+#define FINISH_STATE 666 /* stream complete */
/* Stream status */
@@ -83,7 +86,7 @@ typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
+ const static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
@@ -100,10 +103,10 @@ typedef struct internal_state {
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
+ ulg pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
+ ulg gzindex; /* where in extra, name, or comment */
Byte method; /* can only be DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
@@ -249,7 +252,7 @@ typedef struct internal_state {
uInt matches; /* number of string matches in current block */
uInt insert; /* bytes at end of window left to insert */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
@@ -275,7 +278,7 @@ typedef struct internal_state {
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
+#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
@@ -309,7 +312,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
* used.
*/
-#ifndef DEBUG
+#ifndef ZLIB_DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
@@ -328,8 +331,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
+ { uch len = (uch)(length); \
+ ush dist = (ush)(distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
diff --git a/compat/zlib/doc/algorithm.txt b/compat/zlib/doc/algorithm.txt
deleted file mode 100644
index c97f495..0000000
--- a/compat/zlib/doc/algorithm.txt
+++ /dev/null
@@ -1,209 +0,0 @@
-1. Compression algorithm (deflate)
-
-The deflation algorithm used by gzip (also zip and zlib) is a variation of
-LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
-the input data. The second occurrence of a string is replaced by a
-pointer to the previous string, in the form of a pair (distance,
-length). Distances are limited to 32K bytes, and lengths are limited
-to 258 bytes. When a string does not occur anywhere in the previous
-32K bytes, it is emitted as a sequence of literal bytes. (In this
-description, `string' must be taken as an arbitrary sequence of bytes,
-and is not restricted to printable characters.)
-
-Literals or match lengths are compressed with one Huffman tree, and
-match distances are compressed with another tree. The trees are stored
-in a compact form at the start of each block. The blocks can have any
-size (except that the compressed data for one block must fit in
-available memory). A block is terminated when deflate() determines that
-it would be useful to start another block with fresh trees. (This is
-somewhat similar to the behavior of LZW-based _compress_.)
-
-Duplicated strings are found using a hash table. All input strings of
-length 3 are inserted in the hash table. A hash index is computed for
-the next 3 bytes. If the hash chain for this index is not empty, all
-strings in the chain are compared with the current input string, and
-the longest match is selected.
-
-The hash chains are searched starting with the most recent strings, to
-favor small distances and thus take advantage of the Huffman encoding.
-The hash chains are singly linked. There are no deletions from the
-hash chains, the algorithm simply discards matches that are too old.
-
-To avoid a worst-case situation, very long hash chains are arbitrarily
-truncated at a certain length, determined by a runtime option (level
-parameter of deflateInit). So deflate() does not always find the longest
-possible match but generally finds a match which is long enough.
-
-deflate() also defers the selection of matches with a lazy evaluation
-mechanism. After a match of length N has been found, deflate() searches for
-a longer match at the next input byte. If a longer match is found, the
-previous match is truncated to a length of one (thus producing a single
-literal byte) and the process of lazy evaluation begins again. Otherwise,
-the original match is kept, and the next match search is attempted only N
-steps later.
-
-The lazy match evaluation is also subject to a runtime parameter. If
-the current match is long enough, deflate() reduces the search for a longer
-match, thus speeding up the whole process. If compression ratio is more
-important than speed, deflate() attempts a complete second search even if
-the first match is already long enough.
-
-The lazy match evaluation is not performed for the fastest compression
-modes (level parameter 1 to 3). For these fast modes, new strings
-are inserted in the hash table only when no match was found, or
-when the match is not too long. This degrades the compression ratio
-but saves time since there are both fewer insertions and fewer searches.
-
-
-2. Decompression algorithm (inflate)
-
-2.1 Introduction
-
-The key question is how to represent a Huffman code (or any prefix code) so
-that you can decode fast. The most important characteristic is that shorter
-codes are much more common than longer codes, so pay attention to decoding the
-short codes fast, and let the long codes take longer to decode.
-
-inflate() sets up a first level table that covers some number of bits of
-input less than the length of longest code. It gets that many bits from the
-stream, and looks it up in the table. The table will tell if the next
-code is that many bits or less and how many, and if it is, it will tell
-the value, else it will point to the next level table for which inflate()
-grabs more bits and tries to decode a longer code.
-
-How many bits to make the first lookup is a tradeoff between the time it
-takes to decode and the time it takes to build the table. If building the
-table took no time (and if you had infinite memory), then there would only
-be a first level table to cover all the way to the longest code. However,
-building the table ends up taking a lot longer for more bits since short
-codes are replicated many times in such a table. What inflate() does is
-simply to make the number of bits in the first table a variable, and then
-to set that variable for the maximum speed.
-
-For inflate, which has 286 possible codes for the literal/length tree, the size
-of the first table is nine bits. Also the distance trees have 30 possible
-values, and the size of the first table is six bits. Note that for each of
-those cases, the table ended up one bit longer than the ``average'' code
-length, i.e. the code length of an approximately flat code which would be a
-little more than eight bits for 286 symbols and a little less than five bits
-for 30 symbols.
-
-
-2.2 More details on the inflate table lookup
-
-Ok, you want to know what this cleverly obfuscated inflate tree actually
-looks like. You are correct that it's not a Huffman tree. It is simply a
-lookup table for the first, let's say, nine bits of a Huffman symbol. The
-symbol could be as short as one bit or as long as 15 bits. If a particular
-symbol is shorter than nine bits, then that symbol's translation is duplicated
-in all those entries that start with that symbol's bits. For example, if the
-symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a
-symbol is nine bits long, it appears in the table once.
-
-If the symbol is longer than nine bits, then that entry in the table points
-to another similar table for the remaining bits. Again, there are duplicated
-entries as needed. The idea is that most of the time the symbol will be short
-and there will only be one table look up. (That's whole idea behind data
-compression in the first place.) For the less frequent long symbols, there
-will be two lookups. If you had a compression method with really long
-symbols, you could have as many levels of lookups as is efficient. For
-inflate, two is enough.
-
-So a table entry either points to another table (in which case nine bits in
-the above example are gobbled), or it contains the translation for the symbol
-and the number of bits to gobble. Then you start again with the next
-ungobbled bit.
-
-You may wonder: why not just have one lookup table for how ever many bits the
-longest symbol is? The reason is that if you do that, you end up spending
-more time filling in duplicate symbol entries than you do actually decoding.
-At least for deflate's output that generates new trees every several 10's of
-kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
-would take too long if you're only decoding several thousand symbols. At the
-other extreme, you could make a new table for every bit in the code. In fact,
-that's essentially a Huffman tree. But then you spend too much time
-traversing the tree while decoding, even for short symbols.
-
-So the number of bits for the first lookup table is a trade of the time to
-fill out the table vs. the time spent looking at the second level and above of
-the table.
-
-Here is an example, scaled down:
-
-The code being decoded, with 10 symbols, from 1 to 6 bits long:
-
-A: 0
-B: 10
-C: 1100
-D: 11010
-E: 11011
-F: 11100
-G: 11101
-H: 11110
-I: 111110
-J: 111111
-
-Let's make the first table three bits long (eight entries):
-
-000: A,1
-001: A,1
-010: A,1
-011: A,1
-100: B,2
-101: B,2
-110: -> table X (gobble 3 bits)
-111: -> table Y (gobble 3 bits)
-
-Each entry is what the bits decode as and how many bits that is, i.e. how
-many bits to gobble. Or the entry points to another table, with the number of
-bits to gobble implicit in the size of the table.
-
-Table X is two bits long since the longest code starting with 110 is five bits
-long:
-
-00: C,1
-01: C,1
-10: D,2
-11: E,2
-
-Table Y is three bits long since the longest code starting with 111 is six
-bits long:
-
-000: F,2
-001: F,2
-010: G,2
-011: G,2
-100: H,2
-101: H,2
-110: I,3
-111: J,3
-
-So what we have here are three tables with a total of 20 entries that had to
-be constructed. That's compared to 64 entries for a single table. Or
-compared to 16 entries for a Huffman tree (six two entry tables and one four
-entry table). Assuming that the code ideally represents the probability of
-the symbols, it takes on the average 1.25 lookups per symbol. That's compared
-to one lookup for the single table, or 1.66 lookups per symbol for the
-Huffman tree.
-
-There, I think that gives you a picture of what's going on. For inflate, the
-meaning of a particular symbol is often more than just a letter. It can be a
-byte (a "literal"), or it can be either a length or a distance which
-indicates a base value and a number of bits to fetch after the code that is
-added to the base value. Or it might be the special end-of-block code. The
-data structures created in inftrees.c try to encode all that information
-compactly in the tables.
-
-
-Jean-loup Gailly Mark Adler
-jloup@gzip.org madler@alumni.caltech.edu
-
-
-References:
-
-[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
-Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
-pp. 337-343.
-
-``DEFLATE Compressed Data Format Specification'' available in
-http://tools.ietf.org/html/rfc1951
diff --git a/compat/zlib/doc/rfc1950.txt b/compat/zlib/doc/rfc1950.txt
deleted file mode 100644
index ce6428a..0000000
--- a/compat/zlib/doc/rfc1950.txt
+++ /dev/null
@@ -1,619 +0,0 @@
-
-
-
-
-
-
-Network Working Group P. Deutsch
-Request for Comments: 1950 Aladdin Enterprises
-Category: Informational J-L. Gailly
- Info-ZIP
- May 1996
-
-
- ZLIB Compressed Data Format Specification version 3.3
-
-Status of This Memo
-
- This memo provides information for the Internet community. This memo
- does not specify an Internet standard of any kind. Distribution of
- this memo is unlimited.
-
-IESG Note:
-
- The IESG takes no position on the validity of any Intellectual
- Property Rights statements contained in this document.
-
-Notices
-
- Copyright (c) 1996 L. Peter Deutsch and Jean-Loup Gailly
-
- Permission is granted to copy and distribute this document for any
- purpose and without charge, including translations into other
- languages and incorporation into compilations, provided that the
- copyright notice and this notice are preserved, and that any
- substantive changes or deletions from the original are clearly
- marked.
-
- A pointer to the latest version of this and related documentation in
- HTML format can be found at the URL
- <ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html>.
-
-Abstract
-
- This specification defines a lossless compressed data format. The
- data can be produced or consumed, even for an arbitrarily long
- sequentially presented input data stream, using only an a priori
- bounded amount of intermediate storage. The format presently uses
- the DEFLATE compression method but can be easily extended to use
- other compression methods. It can be implemented readily in a manner
- not covered by patents. This specification also defines the ADLER-32
- checksum (an extension and improvement of the Fletcher checksum),
- used for detection of data corruption, and provides an algorithm for
- computing it.
-
-
-
-
-Deutsch & Gailly Informational [Page 1]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
-Table of Contents
-
- 1. Introduction ................................................... 2
- 1.1. Purpose ................................................... 2
- 1.2. Intended audience ......................................... 3
- 1.3. Scope ..................................................... 3
- 1.4. Compliance ................................................ 3
- 1.5. Definitions of terms and conventions used ................ 3
- 1.6. Changes from previous versions ............................ 3
- 2. Detailed specification ......................................... 3
- 2.1. Overall conventions ....................................... 3
- 2.2. Data format ............................................... 4
- 2.3. Compliance ................................................ 7
- 3. References ..................................................... 7
- 4. Source code .................................................... 8
- 5. Security Considerations ........................................ 8
- 6. Acknowledgements ............................................... 8
- 7. Authors' Addresses ............................................. 8
- 8. Appendix: Rationale ............................................ 9
- 9. Appendix: Sample code ..........................................10
-
-1. Introduction
-
- 1.1. Purpose
-
- The purpose of this specification is to define a lossless
- compressed data format that:
-
- * Is independent of CPU type, operating system, file system,
- and character set, and hence can be used for interchange;
-
- * Can be produced or consumed, even for an arbitrarily long
- sequentially presented input data stream, using only an a
- priori bounded amount of intermediate storage, and hence can
- be used in data communications or similar structures such as
- Unix filters;
-
- * Can use a number of different compression methods;
-
- * Can be implemented readily in a manner not covered by
- patents, and hence can be practiced freely.
-
- The data format defined by this specification does not attempt to
- allow random access to compressed data.
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 2]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- 1.2. Intended audience
-
- This specification is intended for use by implementors of software
- to compress data into zlib format and/or decompress data from zlib
- format.
-
- The text of the specification assumes a basic background in
- programming at the level of bits and other primitive data
- representations.
-
- 1.3. Scope
-
- The specification specifies a compressed data format that can be
- used for in-memory compression of a sequence of arbitrary bytes.
-
- 1.4. Compliance
-
- Unless otherwise indicated below, a compliant decompressor must be
- able to accept and decompress any data set that conforms to all
- the specifications presented here; a compliant compressor must
- produce data sets that conform to all the specifications presented
- here.
-
- 1.5. Definitions of terms and conventions used
-
- byte: 8 bits stored or transmitted as a unit (same as an octet).
- (For this specification, a byte is exactly 8 bits, even on
- machines which store a character on a number of bits different
- from 8.) See below, for the numbering of bits within a byte.
-
- 1.6. Changes from previous versions
-
- Version 3.1 was the first public release of this specification.
- In version 3.2, some terminology was changed and the Adler-32
- sample code was rewritten for clarity. In version 3.3, the
- support for a preset dictionary was introduced, and the
- specification was converted to RFC style.
-
-2. Detailed specification
-
- 2.1. Overall conventions
-
- In the diagrams below, a box like this:
-
- +---+
- | | <-- the vertical bars might be missing
- +---+
-
-
-
-
-Deutsch & Gailly Informational [Page 3]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- represents one byte; a box like this:
-
- +==============+
- | |
- +==============+
-
- represents a variable number of bytes.
-
- Bytes stored within a computer do not have a "bit order", since
- they are always treated as a unit. However, a byte considered as
- an integer between 0 and 255 does have a most- and least-
- significant bit, and since we write numbers with the most-
- significant digit on the left, we also write bytes with the most-
- significant bit on the left. In the diagrams below, we number the
- bits of a byte so that bit 0 is the least-significant bit, i.e.,
- the bits are numbered:
-
- +--------+
- |76543210|
- +--------+
-
- Within a computer, a number may occupy multiple bytes. All
- multi-byte numbers in the format described here are stored with
- the MOST-significant byte first (at the lower memory address).
- For example, the decimal number 520 is stored as:
-
- 0 1
- +--------+--------+
- |00000010|00001000|
- +--------+--------+
- ^ ^
- | |
- | + less significant byte = 8
- + more significant byte = 2 x 256
-
- 2.2. Data format
-
- A zlib stream has the following structure:
-
- 0 1
- +---+---+
- |CMF|FLG| (more-->)
- +---+---+
-
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 4]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- (if FLG.FDICT set)
-
- 0 1 2 3
- +---+---+---+---+
- | DICTID | (more-->)
- +---+---+---+---+
-
- +=====================+---+---+---+---+
- |...compressed data...| ADLER32 |
- +=====================+---+---+---+---+
-
- Any data which may appear after ADLER32 are not part of the zlib
- stream.
-
- CMF (Compression Method and flags)
- This byte is divided into a 4-bit compression method and a 4-
- bit information field depending on the compression method.
-
- bits 0 to 3 CM Compression method
- bits 4 to 7 CINFO Compression info
-
- CM (Compression method)
- This identifies the compression method used in the file. CM = 8
- denotes the "deflate" compression method with a window size up
- to 32K. This is the method used by gzip and PNG (see
- references [1] and [2] in Chapter 3, below, for the reference
- documents). CM = 15 is reserved. It might be used in a future
- version of this specification to indicate the presence of an
- extra field before the compressed data.
-
- CINFO (Compression info)
- For CM = 8, CINFO is the base-2 logarithm of the LZ77 window
- size, minus eight (CINFO=7 indicates a 32K window size). Values
- of CINFO above 7 are not allowed in this version of the
- specification. CINFO is not defined in this specification for
- CM not equal to 8.
-
- FLG (FLaGs)
- This flag byte is divided as follows:
-
- bits 0 to 4 FCHECK (check bits for CMF and FLG)
- bit 5 FDICT (preset dictionary)
- bits 6 to 7 FLEVEL (compression level)
-
- The FCHECK value must be such that CMF and FLG, when viewed as
- a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG),
- is a multiple of 31.
-
-
-
-
-Deutsch & Gailly Informational [Page 5]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- FDICT (Preset dictionary)
- If FDICT is set, a DICT dictionary identifier is present
- immediately after the FLG byte. The dictionary is a sequence of
- bytes which are initially fed to the compressor without
- producing any compressed output. DICT is the Adler-32 checksum
- of this sequence of bytes (see the definition of ADLER32
- below). The decompressor can use this identifier to determine
- which dictionary has been used by the compressor.
-
- FLEVEL (Compression level)
- These flags are available for use by specific compression
- methods. The "deflate" method (CM = 8) sets these flags as
- follows:
-
- 0 - compressor used fastest algorithm
- 1 - compressor used fast algorithm
- 2 - compressor used default algorithm
- 3 - compressor used maximum compression, slowest algorithm
-
- The information in FLEVEL is not needed for decompression; it
- is there to indicate if recompression might be worthwhile.
-
- compressed data
- For compression method 8, the compressed data is stored in the
- deflate compressed data format as described in the document
- "DEFLATE Compressed Data Format Specification" by L. Peter
- Deutsch. (See reference [3] in Chapter 3, below)
-
- Other compressed data formats are not specified in this version
- of the zlib specification.
-
- ADLER32 (Adler-32 checksum)
- This contains a checksum value of the uncompressed data
- (excluding any dictionary data) computed according to Adler-32
- algorithm. This algorithm is a 32-bit extension and improvement
- of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073
- standard. See references [4] and [5] in Chapter 3, below)
-
- Adler-32 is composed of two sums accumulated per byte: s1 is
- the sum of all bytes, s2 is the sum of all s1 values. Both sums
- are done modulo 65521. s1 is initialized to 1, s2 to zero. The
- Adler-32 checksum is stored as s2*65536 + s1 in most-
- significant-byte first (network) order.
-
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 6]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- 2.3. Compliance
-
- A compliant compressor must produce streams with correct CMF, FLG
- and ADLER32, but need not support preset dictionaries. When the
- zlib data format is used as part of another standard data format,
- the compressor may use only preset dictionaries that are specified
- by this other data format. If this other format does not use the
- preset dictionary feature, the compressor must not set the FDICT
- flag.
-
- A compliant decompressor must check CMF, FLG, and ADLER32, and
- provide an error indication if any of these have incorrect values.
- A compliant decompressor must give an error indication if CM is
- not one of the values defined in this specification (only the
- value 8 is permitted in this version), since another value could
- indicate the presence of new features that would cause subsequent
- data to be interpreted incorrectly. A compliant decompressor must
- give an error indication if FDICT is set and DICTID is not the
- identifier of a known preset dictionary. A decompressor may
- ignore FLEVEL and still be compliant. When the zlib data format
- is being used as a part of another standard format, a compliant
- decompressor must support all the preset dictionaries specified by
- the other format. When the other format does not use the preset
- dictionary feature, a compliant decompressor must reject any
- stream in which the FDICT flag is set.
-
-3. References
-
- [1] Deutsch, L.P.,"GZIP Compressed Data Format Specification",
- available in ftp://ftp.uu.net/pub/archiving/zip/doc/
-
- [2] Thomas Boutell, "PNG (Portable Network Graphics) specification",
- available in ftp://ftp.uu.net/graphics/png/documents/
-
- [3] Deutsch, L.P.,"DEFLATE Compressed Data Format Specification",
- available in ftp://ftp.uu.net/pub/archiving/zip/doc/
-
- [4] Fletcher, J. G., "An Arithmetic Checksum for Serial
- Transmissions," IEEE Transactions on Communications, Vol. COM-30,
- No. 1, January 1982, pp. 247-252.
-
- [5] ITU-T Recommendation X.224, Annex D, "Checksum Algorithms,"
- November, 1993, pp. 144, 145. (Available from
- gopher://info.itu.ch). ITU-T X.244 is also the same as ISO 8073.
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 7]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
-4. Source code
-
- Source code for a C language implementation of a "zlib" compliant
- library is available at ftp://ftp.uu.net/pub/archiving/zip/zlib/.
-
-5. Security Considerations
-
- A decoder that fails to check the ADLER32 checksum value may be
- subject to undetected data corruption.
-
-6. Acknowledgements
-
- Trademarks cited in this document are the property of their
- respective owners.
-
- Jean-Loup Gailly and Mark Adler designed the zlib format and wrote
- the related software described in this specification. Glenn
- Randers-Pehrson converted this document to RFC and HTML format.
-
-7. Authors' Addresses
-
- L. Peter Deutsch
- Aladdin Enterprises
- 203 Santa Margarita Ave.
- Menlo Park, CA 94025
-
- Phone: (415) 322-0103 (AM only)
- FAX: (415) 322-1734
- EMail: <ghost@aladdin.com>
-
-
- Jean-Loup Gailly
-
- EMail: <gzip@prep.ai.mit.edu>
-
- Questions about the technical content of this specification can be
- sent by email to
-
- Jean-Loup Gailly <gzip@prep.ai.mit.edu> and
- Mark Adler <madler@alumni.caltech.edu>
-
- Editorial comments on this specification can be sent by email to
-
- L. Peter Deutsch <ghost@aladdin.com> and
- Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 8]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
-8. Appendix: Rationale
-
- 8.1. Preset dictionaries
-
- A preset dictionary is specially useful to compress short input
- sequences. The compressor can take advantage of the dictionary
- context to encode the input in a more compact manner. The
- decompressor can be initialized with the appropriate context by
- virtually decompressing a compressed version of the dictionary
- without producing any output. However for certain compression
- algorithms such as the deflate algorithm this operation can be
- achieved without actually performing any decompression.
-
- The compressor and the decompressor must use exactly the same
- dictionary. The dictionary may be fixed or may be chosen among a
- certain number of predefined dictionaries, according to the kind
- of input data. The decompressor can determine which dictionary has
- been chosen by the compressor by checking the dictionary
- identifier. This document does not specify the contents of
- predefined dictionaries, since the optimal dictionaries are
- application specific. Standard data formats using this feature of
- the zlib specification must precisely define the allowed
- dictionaries.
-
- 8.2. The Adler-32 algorithm
-
- The Adler-32 algorithm is much faster than the CRC32 algorithm yet
- still provides an extremely low probability of undetected errors.
-
- The modulo on unsigned long accumulators can be delayed for 5552
- bytes, so the modulo operation time is negligible. If the bytes
- are a, b, c, the second sum is 3a + 2b + c + 3, and so is position
- and order sensitive, unlike the first sum, which is just a
- checksum. That 65521 is prime is important to avoid a possible
- large class of two-byte errors that leave the check unchanged.
- (The Fletcher checksum uses 255, which is not prime and which also
- makes the Fletcher check insensitive to single byte changes 0 <->
- 255.)
-
- The sum s1 is initialized to 1 instead of zero to make the length
- of the sequence part of s2, so that the length does not have to be
- checked separately. (Any sequence of zeroes has a Fletcher
- checksum of zero.)
-
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 9]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
-9. Appendix: Sample code
-
- The following C code computes the Adler-32 checksum of a data buffer.
- It is written for clarity, not for speed. The sample code is in the
- ANSI C programming language. Non C users may find it easier to read
- with these hints:
-
- & Bitwise AND operator.
- >> Bitwise right shift operator. When applied to an
- unsigned quantity, as here, right shift inserts zero bit(s)
- at the left.
- << Bitwise left shift operator. Left shift inserts zero
- bit(s) at the right.
- ++ "n++" increments the variable n.
- % modulo operator: a % b is the remainder of a divided by b.
-
- #define BASE 65521 /* largest prime smaller than 65536 */
-
- /*
- Update a running Adler-32 checksum with the bytes buf[0..len-1]
- and return the updated checksum. The Adler-32 checksum should be
- initialized to 1.
-
- Usage example:
-
- unsigned long adler = 1L;
-
- while (read_buffer(buffer, length) != EOF) {
- adler = update_adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
- */
- unsigned long update_adler32(unsigned long adler,
- unsigned char *buf, int len)
- {
- unsigned long s1 = adler & 0xffff;
- unsigned long s2 = (adler >> 16) & 0xffff;
- int n;
-
- for (n = 0; n < len; n++) {
- s1 = (s1 + buf[n]) % BASE;
- s2 = (s2 + s1) % BASE;
- }
- return (s2 << 16) + s1;
- }
-
- /* Return the adler32 of the bytes buf[0..len-1] */
-
-
-
-
-Deutsch & Gailly Informational [Page 10]
-
-RFC 1950 ZLIB Compressed Data Format Specification May 1996
-
-
- unsigned long adler32(unsigned char *buf, int len)
- {
- return update_adler32(1L, buf, len);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Deutsch & Gailly Informational [Page 11]
-
diff --git a/compat/zlib/doc/rfc1951.txt b/compat/zlib/doc/rfc1951.txt
deleted file mode 100644
index 403c8c7..0000000
--- a/compat/zlib/doc/rfc1951.txt
+++ /dev/null
@@ -1,955 +0,0 @@
-
-
-
-
-
-
-Network Working Group P. Deutsch
-Request for Comments: 1951 Aladdin Enterprises
-Category: Informational May 1996
-
-
- DEFLATE Compressed Data Format Specification version 1.3
-
-Status of This Memo
-
- This memo provides information for the Internet community. This memo
- does not specify an Internet standard of any kind. Distribution of
- this memo is unlimited.
-
-IESG Note:
-
- The IESG takes no position on the validity of any Intellectual
- Property Rights statements contained in this document.
-
-Notices
-
- Copyright (c) 1996 L. Peter Deutsch
-
- Permission is granted to copy and distribute this document for any
- purpose and without charge, including translations into other
- languages and incorporation into compilations, provided that the
- copyright notice and this notice are preserved, and that any
- substantive changes or deletions from the original are clearly
- marked.
-
- A pointer to the latest version of this and related documentation in
- HTML format can be found at the URL
- <ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html>.
-
-Abstract
-
- This specification defines a lossless compressed data format that
- compresses data using a combination of the LZ77 algorithm and Huffman
- coding, with efficiency comparable to the best currently available
- general-purpose compression methods. The data can be produced or
- consumed, even for an arbitrarily long sequentially presented input
- data stream, using only an a priori bounded amount of intermediate
- storage. The format can be implemented readily in a manner not
- covered by patents.
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 1]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
-Table of Contents
-
- 1. Introduction ................................................... 2
- 1.1. Purpose ................................................... 2
- 1.2. Intended audience ......................................... 3
- 1.3. Scope ..................................................... 3
- 1.4. Compliance ................................................ 3
- 1.5. Definitions of terms and conventions used ................ 3
- 1.6. Changes from previous versions ............................ 4
- 2. Compressed representation overview ............................. 4
- 3. Detailed specification ......................................... 5
- 3.1. Overall conventions ....................................... 5
- 3.1.1. Packing into bytes .................................. 5
- 3.2. Compressed block format ................................... 6
- 3.2.1. Synopsis of prefix and Huffman coding ............... 6
- 3.2.2. Use of Huffman coding in the "deflate" format ....... 7
- 3.2.3. Details of block format ............................. 9
- 3.2.4. Non-compressed blocks (BTYPE=00) ................... 11
- 3.2.5. Compressed blocks (length and distance codes) ...... 11
- 3.2.6. Compression with fixed Huffman codes (BTYPE=01) .... 12
- 3.2.7. Compression with dynamic Huffman codes (BTYPE=10) .. 13
- 3.3. Compliance ............................................... 14
- 4. Compression algorithm details ................................. 14
- 5. References .................................................... 16
- 6. Security Considerations ....................................... 16
- 7. Source code ................................................... 16
- 8. Acknowledgements .............................................. 16
- 9. Author's Address .............................................. 17
-
-1. Introduction
-
- 1.1. Purpose
-
- The purpose of this specification is to define a lossless
- compressed data format that:
- * Is independent of CPU type, operating system, file system,
- and character set, and hence can be used for interchange;
- * Can be produced or consumed, even for an arbitrarily long
- sequentially presented input data stream, using only an a
- priori bounded amount of intermediate storage, and hence
- can be used in data communications or similar structures
- such as Unix filters;
- * Compresses data with efficiency comparable to the best
- currently available general-purpose compression methods,
- and in particular considerably better than the "compress"
- program;
- * Can be implemented readily in a manner not covered by
- patents, and hence can be practiced freely;
-
-
-
-Deutsch Informational [Page 2]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- * Is compatible with the file format produced by the current
- widely used gzip utility, in that conforming decompressors
- will be able to read data produced by the existing gzip
- compressor.
-
- The data format defined by this specification does not attempt to:
-
- * Allow random access to compressed data;
- * Compress specialized data (e.g., raster graphics) as well
- as the best currently available specialized algorithms.
-
- A simple counting argument shows that no lossless compression
- algorithm can compress every possible input data set. For the
- format defined here, the worst case expansion is 5 bytes per 32K-
- byte block, i.e., a size increase of 0.015% for large data sets.
- English text usually compresses by a factor of 2.5 to 3;
- executable files usually compress somewhat less; graphical data
- such as raster images may compress much more.
-
- 1.2. Intended audience
-
- This specification is intended for use by implementors of software
- to compress data into "deflate" format and/or decompress data from
- "deflate" format.
-
- The text of the specification assumes a basic background in
- programming at the level of bits and other primitive data
- representations. Familiarity with the technique of Huffman coding
- is helpful but not required.
-
- 1.3. Scope
-
- The specification specifies a method for representing a sequence
- of bytes as a (usually shorter) sequence of bits, and a method for
- packing the latter bit sequence into bytes.
-
- 1.4. Compliance
-
- Unless otherwise indicated below, a compliant decompressor must be
- able to accept and decompress any data set that conforms to all
- the specifications presented here; a compliant compressor must
- produce data sets that conform to all the specifications presented
- here.
-
- 1.5. Definitions of terms and conventions used
-
- Byte: 8 bits stored or transmitted as a unit (same as an octet).
- For this specification, a byte is exactly 8 bits, even on machines
-
-
-
-Deutsch Informational [Page 3]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- which store a character on a number of bits different from eight.
- See below, for the numbering of bits within a byte.
-
- String: a sequence of arbitrary bytes.
-
- 1.6. Changes from previous versions
-
- There have been no technical changes to the deflate format since
- version 1.1 of this specification. In version 1.2, some
- terminology was changed. Version 1.3 is a conversion of the
- specification to RFC style.
-
-2. Compressed representation overview
-
- A compressed data set consists of a series of blocks, corresponding
- to successive blocks of input data. The block sizes are arbitrary,
- except that non-compressible blocks are limited to 65,535 bytes.
-
- Each block is compressed using a combination of the LZ77 algorithm
- and Huffman coding. The Huffman trees for each block are independent
- of those for previous or subsequent blocks; the LZ77 algorithm may
- use a reference to a duplicated string occurring in a previous block,
- up to 32K input bytes before.
-
- Each block consists of two parts: a pair of Huffman code trees that
- describe the representation of the compressed data part, and a
- compressed data part. (The Huffman trees themselves are compressed
- using Huffman encoding.) The compressed data consists of a series of
- elements of two types: literal bytes (of strings that have not been
- detected as duplicated within the previous 32K input bytes), and
- pointers to duplicated strings, where a pointer is represented as a
- pair <length, backward distance>. The representation used in the
- "deflate" format limits distances to 32K bytes and lengths to 258
- bytes, but does not limit the size of a block, except for
- uncompressible blocks, which are limited as noted above.
-
- Each type of value (literals, distances, and lengths) in the
- compressed data is represented using a Huffman code, using one code
- tree for literals and lengths and a separate code tree for distances.
- The code trees for each block appear in a compact form just before
- the compressed data for that block.
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 4]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
-3. Detailed specification
-
- 3.1. Overall conventions In the diagrams below, a box like this:
-
- +---+
- | | <-- the vertical bars might be missing
- +---+
-
- represents one byte; a box like this:
-
- +==============+
- | |
- +==============+
-
- represents a variable number of bytes.
-
- Bytes stored within a computer do not have a "bit order", since
- they are always treated as a unit. However, a byte considered as
- an integer between 0 and 255 does have a most- and least-
- significant bit, and since we write numbers with the most-
- significant digit on the left, we also write bytes with the most-
- significant bit on the left. In the diagrams below, we number the
- bits of a byte so that bit 0 is the least-significant bit, i.e.,
- the bits are numbered:
-
- +--------+
- |76543210|
- +--------+
-
- Within a computer, a number may occupy multiple bytes. All
- multi-byte numbers in the format described here are stored with
- the least-significant byte first (at the lower memory address).
- For example, the decimal number 520 is stored as:
-
- 0 1
- +--------+--------+
- |00001000|00000010|
- +--------+--------+
- ^ ^
- | |
- | + more significant byte = 2 x 256
- + less significant byte = 8
-
- 3.1.1. Packing into bytes
-
- This document does not address the issue of the order in which
- bits of a byte are transmitted on a bit-sequential medium,
- since the final data format described here is byte- rather than
-
-
-
-Deutsch Informational [Page 5]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- bit-oriented. However, we describe the compressed block format
- in below, as a sequence of data elements of various bit
- lengths, not a sequence of bytes. We must therefore specify
- how to pack these data elements into bytes to form the final
- compressed byte sequence:
-
- * Data elements are packed into bytes in order of
- increasing bit number within the byte, i.e., starting
- with the least-significant bit of the byte.
- * Data elements other than Huffman codes are packed
- starting with the least-significant bit of the data
- element.
- * Huffman codes are packed starting with the most-
- significant bit of the code.
-
- In other words, if one were to print out the compressed data as
- a sequence of bytes, starting with the first byte at the
- *right* margin and proceeding to the *left*, with the most-
- significant bit of each byte on the left as usual, one would be
- able to parse the result from right to left, with fixed-width
- elements in the correct MSB-to-LSB order and Huffman codes in
- bit-reversed order (i.e., with the first bit of the code in the
- relative LSB position).
-
- 3.2. Compressed block format
-
- 3.2.1. Synopsis of prefix and Huffman coding
-
- Prefix coding represents symbols from an a priori known
- alphabet by bit sequences (codes), one code for each symbol, in
- a manner such that different symbols may be represented by bit
- sequences of different lengths, but a parser can always parse
- an encoded string unambiguously symbol-by-symbol.
-
- We define a prefix code in terms of a binary tree in which the
- two edges descending from each non-leaf node are labeled 0 and
- 1 and in which the leaf nodes correspond one-for-one with (are
- labeled with) the symbols of the alphabet; then the code for a
- symbol is the sequence of 0's and 1's on the edges leading from
- the root to the leaf labeled with that symbol. For example:
-
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 6]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- /\ Symbol Code
- 0 1 ------ ----
- / \ A 00
- /\ B B 1
- 0 1 C 011
- / \ D 010
- A /\
- 0 1
- / \
- D C
-
- A parser can decode the next symbol from an encoded input
- stream by walking down the tree from the root, at each step
- choosing the edge corresponding to the next input bit.
-
- Given an alphabet with known symbol frequencies, the Huffman
- algorithm allows the construction of an optimal prefix code
- (one which represents strings with those symbol frequencies
- using the fewest bits of any possible prefix codes for that
- alphabet). Such a code is called a Huffman code. (See
- reference [1] in Chapter 5, references for additional
- information on Huffman codes.)
-
- Note that in the "deflate" format, the Huffman codes for the
- various alphabets must not exceed certain maximum code lengths.
- This constraint complicates the algorithm for computing code
- lengths from symbol frequencies. Again, see Chapter 5,
- references for details.
-
- 3.2.2. Use of Huffman coding in the "deflate" format
-
- The Huffman codes used for each alphabet in the "deflate"
- format have two additional rules:
-
- * All codes of a given bit length have lexicographically
- consecutive values, in the same order as the symbols
- they represent;
-
- * Shorter codes lexicographically precede longer codes.
-
-
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 7]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- We could recode the example above to follow this rule as
- follows, assuming that the order of the alphabet is ABCD:
-
- Symbol Code
- ------ ----
- A 10
- B 0
- C 110
- D 111
-
- I.e., 0 precedes 10 which precedes 11x, and 110 and 111 are
- lexicographically consecutive.
-
- Given this rule, we can define the Huffman code for an alphabet
- just by giving the bit lengths of the codes for each symbol of
- the alphabet in order; this is sufficient to determine the
- actual codes. In our example, the code is completely defined
- by the sequence of bit lengths (2, 1, 3, 3). The following
- algorithm generates the codes as integers, intended to be read
- from most- to least-significant bit. The code lengths are
- initially in tree[I].Len; the codes are produced in
- tree[I].Code.
-
- 1) Count the number of codes for each code length. Let
- bl_count[N] be the number of codes of length N, N >= 1.
-
- 2) Find the numerical value of the smallest code for each
- code length:
-
- code = 0;
- bl_count[0] = 0;
- for (bits = 1; bits <= MAX_BITS; bits++) {
- code = (code + bl_count[bits-1]) << 1;
- next_code[bits] = code;
- }
-
- 3) Assign numerical values to all codes, using consecutive
- values for all codes of the same length with the base
- values determined at step 2. Codes that are never used
- (which have a bit length of zero) must not be assigned a
- value.
-
- for (n = 0; n <= max_code; n++) {
- len = tree[n].Len;
- if (len != 0) {
- tree[n].Code = next_code[len];
- next_code[len]++;
- }
-
-
-
-Deutsch Informational [Page 8]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- }
-
- Example:
-
- Consider the alphabet ABCDEFGH, with bit lengths (3, 3, 3, 3,
- 3, 2, 4, 4). After step 1, we have:
-
- N bl_count[N]
- - -----------
- 2 1
- 3 5
- 4 2
-
- Step 2 computes the following next_code values:
-
- N next_code[N]
- - ------------
- 1 0
- 2 0
- 3 2
- 4 14
-
- Step 3 produces the following code values:
-
- Symbol Length Code
- ------ ------ ----
- A 3 010
- B 3 011
- C 3 100
- D 3 101
- E 3 110
- F 2 00
- G 4 1110
- H 4 1111
-
- 3.2.3. Details of block format
-
- Each block of compressed data begins with 3 header bits
- containing the following data:
-
- first bit BFINAL
- next 2 bits BTYPE
-
- Note that the header bits do not necessarily begin on a byte
- boundary, since a block does not necessarily occupy an integral
- number of bytes.
-
-
-
-
-
-Deutsch Informational [Page 9]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- BFINAL is set if and only if this is the last block of the data
- set.
-
- BTYPE specifies how the data are compressed, as follows:
-
- 00 - no compression
- 01 - compressed with fixed Huffman codes
- 10 - compressed with dynamic Huffman codes
- 11 - reserved (error)
-
- The only difference between the two compressed cases is how the
- Huffman codes for the literal/length and distance alphabets are
- defined.
-
- In all cases, the decoding algorithm for the actual data is as
- follows:
-
- do
- read block header from input stream.
- if stored with no compression
- skip any remaining bits in current partially
- processed byte
- read LEN and NLEN (see next section)
- copy LEN bytes of data to output
- otherwise
- if compressed with dynamic Huffman codes
- read representation of code trees (see
- subsection below)
- loop (until end of block code recognized)
- decode literal/length value from input stream
- if value < 256
- copy value (literal byte) to output stream
- otherwise
- if value = end of block (256)
- break from loop
- otherwise (value = 257..285)
- decode distance from input stream
-
- move backwards distance bytes in the output
- stream, and copy length bytes from this
- position to the output stream.
- end loop
- while not last block
-
- Note that a duplicated string reference may refer to a string
- in a previous block; i.e., the backward distance may cross one
- or more block boundaries. However a distance cannot refer past
- the beginning of the output stream. (An application using a
-
-
-
-Deutsch Informational [Page 10]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- preset dictionary might discard part of the output stream; a
- distance can refer to that part of the output stream anyway)
- Note also that the referenced string may overlap the current
- position; for example, if the last 2 bytes decoded have values
- X and Y, a string reference with <length = 5, distance = 2>
- adds X,Y,X,Y,X to the output stream.
-
- We now specify each compression method in turn.
-
- 3.2.4. Non-compressed blocks (BTYPE=00)
-
- Any bits of input up to the next byte boundary are ignored.
- The rest of the block consists of the following information:
-
- 0 1 2 3 4...
- +---+---+---+---+================================+
- | LEN | NLEN |... LEN bytes of literal data...|
- +---+---+---+---+================================+
-
- LEN is the number of data bytes in the block. NLEN is the
- one's complement of LEN.
-
- 3.2.5. Compressed blocks (length and distance codes)
-
- As noted above, encoded data blocks in the "deflate" format
- consist of sequences of symbols drawn from three conceptually
- distinct alphabets: either literal bytes, from the alphabet of
- byte values (0..255), or <length, backward distance> pairs,
- where the length is drawn from (3..258) and the distance is
- drawn from (1..32,768). In fact, the literal and length
- alphabets are merged into a single alphabet (0..285), where
- values 0..255 represent literal bytes, the value 256 indicates
- end-of-block, and values 257..285 represent length codes
- (possibly in conjunction with extra bits following the symbol
- code) as follows:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 11]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- Extra Extra Extra
- Code Bits Length(s) Code Bits Lengths Code Bits Length(s)
- ---- ---- ------ ---- ---- ------- ---- ---- -------
- 257 0 3 267 1 15,16 277 4 67-82
- 258 0 4 268 1 17,18 278 4 83-98
- 259 0 5 269 2 19-22 279 4 99-114
- 260 0 6 270 2 23-26 280 4 115-130
- 261 0 7 271 2 27-30 281 5 131-162
- 262 0 8 272 2 31-34 282 5 163-194
- 263 0 9 273 3 35-42 283 5 195-226
- 264 0 10 274 3 43-50 284 5 227-257
- 265 1 11,12 275 3 51-58 285 0 258
- 266 1 13,14 276 3 59-66
-
- The extra bits should be interpreted as a machine integer
- stored with the most-significant bit first, e.g., bits 1110
- represent the value 14.
-
- Extra Extra Extra
- Code Bits Dist Code Bits Dist Code Bits Distance
- ---- ---- ---- ---- ---- ------ ---- ---- --------
- 0 0 1 10 4 33-48 20 9 1025-1536
- 1 0 2 11 4 49-64 21 9 1537-2048
- 2 0 3 12 5 65-96 22 10 2049-3072
- 3 0 4 13 5 97-128 23 10 3073-4096
- 4 1 5,6 14 6 129-192 24 11 4097-6144
- 5 1 7,8 15 6 193-256 25 11 6145-8192
- 6 2 9-12 16 7 257-384 26 12 8193-12288
- 7 2 13-16 17 7 385-512 27 12 12289-16384
- 8 3 17-24 18 8 513-768 28 13 16385-24576
- 9 3 25-32 19 8 769-1024 29 13 24577-32768
-
- 3.2.6. Compression with fixed Huffman codes (BTYPE=01)
-
- The Huffman codes for the two alphabets are fixed, and are not
- represented explicitly in the data. The Huffman code lengths
- for the literal/length alphabet are:
-
- Lit Value Bits Codes
- --------- ---- -----
- 0 - 143 8 00110000 through
- 10111111
- 144 - 255 9 110010000 through
- 111111111
- 256 - 279 7 0000000 through
- 0010111
- 280 - 287 8 11000000 through
- 11000111
-
-
-
-Deutsch Informational [Page 12]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- The code lengths are sufficient to generate the actual codes,
- as described above; we show the codes in the table for added
- clarity. Literal/length values 286-287 will never actually
- occur in the compressed data, but participate in the code
- construction.
-
- Distance codes 0-31 are represented by (fixed-length) 5-bit
- codes, with possible additional bits as shown in the table
- shown in Paragraph 3.2.5, above. Note that distance codes 30-
- 31 will never actually occur in the compressed data.
-
- 3.2.7. Compression with dynamic Huffman codes (BTYPE=10)
-
- The Huffman codes for the two alphabets appear in the block
- immediately after the header bits and before the actual
- compressed data, first the literal/length code and then the
- distance code. Each code is defined by a sequence of code
- lengths, as discussed in Paragraph 3.2.2, above. For even
- greater compactness, the code length sequences themselves are
- compressed using a Huffman code. The alphabet for code lengths
- is as follows:
-
- 0 - 15: Represent code lengths of 0 - 15
- 16: Copy the previous code length 3 - 6 times.
- The next 2 bits indicate repeat length
- (0 = 3, ... , 3 = 6)
- Example: Codes 8, 16 (+2 bits 11),
- 16 (+2 bits 10) will expand to
- 12 code lengths of 8 (1 + 6 + 5)
- 17: Repeat a code length of 0 for 3 - 10 times.
- (3 bits of length)
- 18: Repeat a code length of 0 for 11 - 138 times
- (7 bits of length)
-
- A code length of 0 indicates that the corresponding symbol in
- the literal/length or distance alphabet will not occur in the
- block, and should not participate in the Huffman code
- construction algorithm given earlier. If only one distance
- code is used, it is encoded using one bit, not zero bits; in
- this case there is a single code length of one, with one unused
- code. One distance code of zero bits means that there are no
- distance codes used at all (the data is all literals).
-
- We can now define the format of the block:
-
- 5 Bits: HLIT, # of Literal/Length codes - 257 (257 - 286)
- 5 Bits: HDIST, # of Distance codes - 1 (1 - 32)
- 4 Bits: HCLEN, # of Code Length codes - 4 (4 - 19)
-
-
-
-Deutsch Informational [Page 13]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- (HCLEN + 4) x 3 bits: code lengths for the code length
- alphabet given just above, in the order: 16, 17, 18,
- 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
-
- These code lengths are interpreted as 3-bit integers
- (0-7); as above, a code length of 0 means the
- corresponding symbol (literal/length or distance code
- length) is not used.
-
- HLIT + 257 code lengths for the literal/length alphabet,
- encoded using the code length Huffman code
-
- HDIST + 1 code lengths for the distance alphabet,
- encoded using the code length Huffman code
-
- The actual compressed data of the block,
- encoded using the literal/length and distance Huffman
- codes
-
- The literal/length symbol 256 (end of data),
- encoded using the literal/length Huffman code
-
- The code length repeat codes can cross from HLIT + 257 to the
- HDIST + 1 code lengths. In other words, all code lengths form
- a single sequence of HLIT + HDIST + 258 values.
-
- 3.3. Compliance
-
- A compressor may limit further the ranges of values specified in
- the previous section and still be compliant; for example, it may
- limit the range of backward pointers to some value smaller than
- 32K. Similarly, a compressor may limit the size of blocks so that
- a compressible block fits in memory.
-
- A compliant decompressor must accept the full range of possible
- values defined in the previous section, and must accept blocks of
- arbitrary size.
-
-4. Compression algorithm details
-
- While it is the intent of this document to define the "deflate"
- compressed data format without reference to any particular
- compression algorithm, the format is related to the compressed
- formats produced by LZ77 (Lempel-Ziv 1977, see reference [2] below);
- since many variations of LZ77 are patented, it is strongly
- recommended that the implementor of a compressor follow the general
- algorithm presented here, which is known not to be patented per se.
- The material in this section is not part of the definition of the
-
-
-
-Deutsch Informational [Page 14]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
- specification per se, and a compressor need not follow it in order to
- be compliant.
-
- The compressor terminates a block when it determines that starting a
- new block with fresh trees would be useful, or when the block size
- fills up the compressor's block buffer.
-
- The compressor uses a chained hash table to find duplicated strings,
- using a hash function that operates on 3-byte sequences. At any
- given point during compression, let XYZ be the next 3 input bytes to
- be examined (not necessarily all different, of course). First, the
- compressor examines the hash chain for XYZ. If the chain is empty,
- the compressor simply writes out X as a literal byte and advances one
- byte in the input. If the hash chain is not empty, indicating that
- the sequence XYZ (or, if we are unlucky, some other 3 bytes with the
- same hash function value) has occurred recently, the compressor
- compares all strings on the XYZ hash chain with the actual input data
- sequence starting at the current point, and selects the longest
- match.
-
- The compressor searches the hash chains starting with the most recent
- strings, to favor small distances and thus take advantage of the
- Huffman encoding. The hash chains are singly linked. There are no
- deletions from the hash chains; the algorithm simply discards matches
- that are too old. To avoid a worst-case situation, very long hash
- chains are arbitrarily truncated at a certain length, determined by a
- run-time parameter.
-
- To improve overall compression, the compressor optionally defers the
- selection of matches ("lazy matching"): after a match of length N has
- been found, the compressor searches for a longer match starting at
- the next input byte. If it finds a longer match, it truncates the
- previous match to a length of one (thus producing a single literal
- byte) and then emits the longer match. Otherwise, it emits the
- original match, and, as described above, advances N bytes before
- continuing.
-
- Run-time parameters also control this "lazy match" procedure. If
- compression ratio is most important, the compressor attempts a
- complete second search regardless of the length of the first match.
- In the normal case, if the current match is "long enough", the
- compressor reduces the search for a longer match, thus speeding up
- the process. If speed is most important, the compressor inserts new
- strings in the hash table only when no match was found, or when the
- match is not "too long". This degrades the compression ratio but
- saves time since there are both fewer insertions and fewer searches.
-
-
-
-
-
-Deutsch Informational [Page 15]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
-5. References
-
- [1] Huffman, D. A., "A Method for the Construction of Minimum
- Redundancy Codes", Proceedings of the Institute of Radio
- Engineers, September 1952, Volume 40, Number 9, pp. 1098-1101.
-
- [2] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data
- Compression", IEEE Transactions on Information Theory, Vol. 23,
- No. 3, pp. 337-343.
-
- [3] Gailly, J.-L., and Adler, M., ZLIB documentation and sources,
- available in ftp://ftp.uu.net/pub/archiving/zip/doc/
-
- [4] Gailly, J.-L., and Adler, M., GZIP documentation and sources,
- available as gzip-*.tar in ftp://prep.ai.mit.edu/pub/gnu/
-
- [5] Schwartz, E. S., and Kallick, B. "Generating a canonical prefix
- encoding." Comm. ACM, 7,3 (Mar. 1964), pp. 166-169.
-
- [6] Hirschberg and Lelewer, "Efficient decoding of prefix codes,"
- Comm. ACM, 33,4, April 1990, pp. 449-459.
-
-6. Security Considerations
-
- Any data compression method involves the reduction of redundancy in
- the data. Consequently, any corruption of the data is likely to have
- severe effects and be difficult to correct. Uncompressed text, on
- the other hand, will probably still be readable despite the presence
- of some corrupted bytes.
-
- It is recommended that systems using this data format provide some
- means of validating the integrity of the compressed data. See
- reference [3], for example.
-
-7. Source code
-
- Source code for a C language implementation of a "deflate" compliant
- compressor and decompressor is available within the zlib package at
- ftp://ftp.uu.net/pub/archiving/zip/zlib/.
-
-8. Acknowledgements
-
- Trademarks cited in this document are the property of their
- respective owners.
-
- Phil Katz designed the deflate format. Jean-Loup Gailly and Mark
- Adler wrote the related software described in this specification.
- Glenn Randers-Pehrson converted this document to RFC and HTML format.
-
-
-
-Deutsch Informational [Page 16]
-
-RFC 1951 DEFLATE Compressed Data Format Specification May 1996
-
-
-9. Author's Address
-
- L. Peter Deutsch
- Aladdin Enterprises
- 203 Santa Margarita Ave.
- Menlo Park, CA 94025
-
- Phone: (415) 322-0103 (AM only)
- FAX: (415) 322-1734
- EMail: <ghost@aladdin.com>
-
- Questions about the technical content of this specification can be
- sent by email to:
-
- Jean-Loup Gailly <gzip@prep.ai.mit.edu> and
- Mark Adler <madler@alumni.caltech.edu>
-
- Editorial comments on this specification can be sent by email to:
-
- L. Peter Deutsch <ghost@aladdin.com> and
- Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 17]
-
diff --git a/compat/zlib/doc/rfc1952.txt b/compat/zlib/doc/rfc1952.txt
deleted file mode 100644
index a8e51b4..0000000
--- a/compat/zlib/doc/rfc1952.txt
+++ /dev/null
@@ -1,675 +0,0 @@
-
-
-
-
-
-
-Network Working Group P. Deutsch
-Request for Comments: 1952 Aladdin Enterprises
-Category: Informational May 1996
-
-
- GZIP file format specification version 4.3
-
-Status of This Memo
-
- This memo provides information for the Internet community. This memo
- does not specify an Internet standard of any kind. Distribution of
- this memo is unlimited.
-
-IESG Note:
-
- The IESG takes no position on the validity of any Intellectual
- Property Rights statements contained in this document.
-
-Notices
-
- Copyright (c) 1996 L. Peter Deutsch
-
- Permission is granted to copy and distribute this document for any
- purpose and without charge, including translations into other
- languages and incorporation into compilations, provided that the
- copyright notice and this notice are preserved, and that any
- substantive changes or deletions from the original are clearly
- marked.
-
- A pointer to the latest version of this and related documentation in
- HTML format can be found at the URL
- <ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html>.
-
-Abstract
-
- This specification defines a lossless compressed data format that is
- compatible with the widely used GZIP utility. The format includes a
- cyclic redundancy check value for detecting data corruption. The
- format presently uses the DEFLATE method of compression but can be
- easily extended to use other compression methods. The format can be
- implemented readily in a manner not covered by patents.
-
-
-
-
-
-
-
-
-
-
-Deutsch Informational [Page 1]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
-Table of Contents
-
- 1. Introduction ................................................... 2
- 1.1. Purpose ................................................... 2
- 1.2. Intended audience ......................................... 3
- 1.3. Scope ..................................................... 3
- 1.4. Compliance ................................................ 3
- 1.5. Definitions of terms and conventions used ................. 3
- 1.6. Changes from previous versions ............................ 3
- 2. Detailed specification ......................................... 4
- 2.1. Overall conventions ....................................... 4
- 2.2. File format ............................................... 5
- 2.3. Member format ............................................. 5
- 2.3.1. Member header and trailer ........................... 6
- 2.3.1.1. Extra field ................................... 8
- 2.3.1.2. Compliance .................................... 9
- 3. References .................................................. 9
- 4. Security Considerations .................................... 10
- 5. Acknowledgements ........................................... 10
- 6. Author's Address ........................................... 10
- 7. Appendix: Jean-Loup Gailly's gzip utility .................. 11
- 8. Appendix: Sample CRC Code .................................. 11
-
-1. Introduction
-
- 1.1. Purpose
-
- The purpose of this specification is to define a lossless
- compressed data format that:
-
- * Is independent of CPU type, operating system, file system,
- and character set, and hence can be used for interchange;
- * Can compress or decompress a data stream (as opposed to a
- randomly accessible file) to produce another data stream,
- using only an a priori bounded amount of intermediate
- storage, and hence can be used in data communications or
- similar structures such as Unix filters;
- * Compresses data with efficiency comparable to the best
- currently available general-purpose compression methods,
- and in particular considerably better than the "compress"
- program;
- * Can be implemented readily in a manner not covered by
- patents, and hence can be practiced freely;
- * Is compatible with the file format produced by the current
- widely used gzip utility, in that conforming decompressors
- will be able to read data produced by the existing gzip
- compressor.
-
-
-
-
-Deutsch Informational [Page 2]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- The data format defined by this specification does not attempt to:
-
- * Provide random access to compressed data;
- * Compress specialized data (e.g., raster graphics) as well as
- the best currently available specialized algorithms.
-
- 1.2. Intended audience
-
- This specification is intended for use by implementors of software
- to compress data into gzip format and/or decompress data from gzip
- format.
-
- The text of the specification assumes a basic background in
- programming at the level of bits and other primitive data
- representations.
-
- 1.3. Scope
-
- The specification specifies a compression method and a file format
- (the latter assuming only that a file can store a sequence of
- arbitrary bytes). It does not specify any particular interface to
- a file system or anything about character sets or encodings
- (except for file names and comments, which are optional).
-
- 1.4. Compliance
-
- Unless otherwise indicated below, a compliant decompressor must be
- able to accept and decompress any file that conforms to all the
- specifications presented here; a compliant compressor must produce
- files that conform to all the specifications presented here. The
- material in the appendices is not part of the specification per se
- and is not relevant to compliance.
-
- 1.5. Definitions of terms and conventions used
-
- byte: 8 bits stored or transmitted as a unit (same as an octet).
- (For this specification, a byte is exactly 8 bits, even on
- machines which store a character on a number of bits different
- from 8.) See below for the numbering of bits within a byte.
-
- 1.6. Changes from previous versions
-
- There have been no technical changes to the gzip format since
- version 4.1 of this specification. In version 4.2, some
- terminology was changed, and the sample CRC code was rewritten for
- clarity and to eliminate the requirement for the caller to do pre-
- and post-conditioning. Version 4.3 is a conversion of the
- specification to RFC style.
-
-
-
-Deutsch Informational [Page 3]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
-2. Detailed specification
-
- 2.1. Overall conventions
-
- In the diagrams below, a box like this:
-
- +---+
- | | <-- the vertical bars might be missing
- +---+
-
- represents one byte; a box like this:
-
- +==============+
- | |
- +==============+
-
- represents a variable number of bytes.
-
- Bytes stored within a computer do not have a "bit order", since
- they are always treated as a unit. However, a byte considered as
- an integer between 0 and 255 does have a most- and least-
- significant bit, and since we write numbers with the most-
- significant digit on the left, we also write bytes with the most-
- significant bit on the left. In the diagrams below, we number the
- bits of a byte so that bit 0 is the least-significant bit, i.e.,
- the bits are numbered:
-
- +--------+
- |76543210|
- +--------+
-
- This document does not address the issue of the order in which
- bits of a byte are transmitted on a bit-sequential medium, since
- the data format described here is byte- rather than bit-oriented.
-
- Within a computer, a number may occupy multiple bytes. All
- multi-byte numbers in the format described here are stored with
- the least-significant byte first (at the lower memory address).
- For example, the decimal number 520 is stored as:
-
- 0 1
- +--------+--------+
- |00001000|00000010|
- +--------+--------+
- ^ ^
- | |
- | + more significant byte = 2 x 256
- + less significant byte = 8
-
-
-
-Deutsch Informational [Page 4]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- 2.2. File format
-
- A gzip file consists of a series of "members" (compressed data
- sets). The format of each member is specified in the following
- section. The members simply appear one after another in the file,
- with no additional information before, between, or after them.
-
- 2.3. Member format
-
- Each member has the following structure:
-
- +---+---+---+---+---+---+---+---+---+---+
- |ID1|ID2|CM |FLG| MTIME |XFL|OS | (more-->)
- +---+---+---+---+---+---+---+---+---+---+
-
- (if FLG.FEXTRA set)
-
- +---+---+=================================+
- | XLEN |...XLEN bytes of "extra field"...| (more-->)
- +---+---+=================================+
-
- (if FLG.FNAME set)
-
- +=========================================+
- |...original file name, zero-terminated...| (more-->)
- +=========================================+
-
- (if FLG.FCOMMENT set)
-
- +===================================+
- |...file comment, zero-terminated...| (more-->)
- +===================================+
-
- (if FLG.FHCRC set)
-
- +---+---+
- | CRC16 |
- +---+---+
-
- +=======================+
- |...compressed blocks...| (more-->)
- +=======================+
-
- 0 1 2 3 4 5 6 7
- +---+---+---+---+---+---+---+---+
- | CRC32 | ISIZE |
- +---+---+---+---+---+---+---+---+
-
-
-
-
-Deutsch Informational [Page 5]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- 2.3.1. Member header and trailer
-
- ID1 (IDentification 1)
- ID2 (IDentification 2)
- These have the fixed values ID1 = 31 (0x1f, \037), ID2 = 139
- (0x8b, \213), to identify the file as being in gzip format.
-
- CM (Compression Method)
- This identifies the compression method used in the file. CM
- = 0-7 are reserved. CM = 8 denotes the "deflate"
- compression method, which is the one customarily used by
- gzip and which is documented elsewhere.
-
- FLG (FLaGs)
- This flag byte is divided into individual bits as follows:
-
- bit 0 FTEXT
- bit 1 FHCRC
- bit 2 FEXTRA
- bit 3 FNAME
- bit 4 FCOMMENT
- bit 5 reserved
- bit 6 reserved
- bit 7 reserved
-
- If FTEXT is set, the file is probably ASCII text. This is
- an optional indication, which the compressor may set by
- checking a small amount of the input data to see whether any
- non-ASCII characters are present. In case of doubt, FTEXT
- is cleared, indicating binary data. For systems which have
- different file formats for ascii text and binary data, the
- decompressor can use FTEXT to choose the appropriate format.
- We deliberately do not specify the algorithm used to set
- this bit, since a compressor always has the option of
- leaving it cleared and a decompressor always has the option
- of ignoring it and letting some other program handle issues
- of data conversion.
-
- If FHCRC is set, a CRC16 for the gzip header is present,
- immediately before the compressed data. The CRC16 consists
- of the two least significant bytes of the CRC32 for all
- bytes of the gzip header up to and not including the CRC16.
- [The FHCRC bit was never set by versions of gzip up to
- 1.2.4, even though it was documented with a different
- meaning in gzip 1.2.4.]
-
- If FEXTRA is set, optional extra fields are present, as
- described in a following section.
-
-
-
-Deutsch Informational [Page 6]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- If FNAME is set, an original file name is present,
- terminated by a zero byte. The name must consist of ISO
- 8859-1 (LATIN-1) characters; on operating systems using
- EBCDIC or any other character set for file names, the name
- must be translated to the ISO LATIN-1 character set. This
- is the original name of the file being compressed, with any
- directory components removed, and, if the file being
- compressed is on a file system with case insensitive names,
- forced to lower case. There is no original file name if the
- data was compressed from a source other than a named file;
- for example, if the source was stdin on a Unix system, there
- is no file name.
-
- If FCOMMENT is set, a zero-terminated file comment is
- present. This comment is not interpreted; it is only
- intended for human consumption. The comment must consist of
- ISO 8859-1 (LATIN-1) characters. Line breaks should be
- denoted by a single line feed character (10 decimal).
-
- Reserved FLG bits must be zero.
-
- MTIME (Modification TIME)
- This gives the most recent modification time of the original
- file being compressed. The time is in Unix format, i.e.,
- seconds since 00:00:00 GMT, Jan. 1, 1970. (Note that this
- may cause problems for MS-DOS and other systems that use
- local rather than Universal time.) If the compressed data
- did not come from a file, MTIME is set to the time at which
- compression started. MTIME = 0 means no time stamp is
- available.
-
- XFL (eXtra FLags)
- These flags are available for use by specific compression
- methods. The "deflate" method (CM = 8) sets these flags as
- follows:
-
- XFL = 2 - compressor used maximum compression,
- slowest algorithm
- XFL = 4 - compressor used fastest algorithm
-
- OS (Operating System)
- This identifies the type of file system on which compression
- took place. This may be useful in determining end-of-line
- convention for text files. The currently defined values are
- as follows:
-
-
-
-
-
-
-Deutsch Informational [Page 7]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- 0 - FAT filesystem (MS-DOS, OS/2, NT/Win32)
- 1 - Amiga
- 2 - VMS (or OpenVMS)
- 3 - Unix
- 4 - VM/CMS
- 5 - Atari TOS
- 6 - HPFS filesystem (OS/2, NT)
- 7 - Macintosh
- 8 - Z-System
- 9 - CP/M
- 10 - TOPS-20
- 11 - NTFS filesystem (NT)
- 12 - QDOS
- 13 - Acorn RISCOS
- 255 - unknown
-
- XLEN (eXtra LENgth)
- If FLG.FEXTRA is set, this gives the length of the optional
- extra field. See below for details.
-
- CRC32 (CRC-32)
- This contains a Cyclic Redundancy Check value of the
- uncompressed data computed according to CRC-32 algorithm
- used in the ISO 3309 standard and in section 8.1.1.6.2 of
- ITU-T recommendation V.42. (See http://www.iso.ch for
- ordering ISO documents. See gopher://info.itu.ch for an
- online version of ITU-T V.42.)
-
- ISIZE (Input SIZE)
- This contains the size of the original (uncompressed) input
- data modulo 2^32.
-
- 2.3.1.1. Extra field
-
- If the FLG.FEXTRA bit is set, an "extra field" is present in
- the header, with total length XLEN bytes. It consists of a
- series of subfields, each of the form:
-
- +---+---+---+---+==================================+
- |SI1|SI2| LEN |... LEN bytes of subfield data ...|
- +---+---+---+---+==================================+
-
- SI1 and SI2 provide a subfield ID, typically two ASCII letters
- with some mnemonic value. Jean-Loup Gailly
- <gzip@prep.ai.mit.edu> is maintaining a registry of subfield
- IDs; please send him any subfield ID you wish to use. Subfield
- IDs with SI2 = 0 are reserved for future use. The following
- IDs are currently defined:
-
-
-
-Deutsch Informational [Page 8]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- SI1 SI2 Data
- ---------- ---------- ----
- 0x41 ('A') 0x70 ('P') Apollo file type information
-
- LEN gives the length of the subfield data, excluding the 4
- initial bytes.
-
- 2.3.1.2. Compliance
-
- A compliant compressor must produce files with correct ID1,
- ID2, CM, CRC32, and ISIZE, but may set all the other fields in
- the fixed-length part of the header to default values (255 for
- OS, 0 for all others). The compressor must set all reserved
- bits to zero.
-
- A compliant decompressor must check ID1, ID2, and CM, and
- provide an error indication if any of these have incorrect
- values. It must examine FEXTRA/XLEN, FNAME, FCOMMENT and FHCRC
- at least so it can skip over the optional fields if they are
- present. It need not examine any other part of the header or
- trailer; in particular, a decompressor may ignore FTEXT and OS
- and always produce binary output, and still be compliant. A
- compliant decompressor must give an error indication if any
- reserved bit is non-zero, since such a bit could indicate the
- presence of a new field that would cause subsequent data to be
- interpreted incorrectly.
-
-3. References
-
- [1] "Information Processing - 8-bit single-byte coded graphic
- character sets - Part 1: Latin alphabet No.1" (ISO 8859-1:1987).
- The ISO 8859-1 (Latin-1) character set is a superset of 7-bit
- ASCII. Files defining this character set are available as
- iso_8859-1.* in ftp://ftp.uu.net/graphics/png/documents/
-
- [2] ISO 3309
-
- [3] ITU-T recommendation V.42
-
- [4] Deutsch, L.P.,"DEFLATE Compressed Data Format Specification",
- available in ftp://ftp.uu.net/pub/archiving/zip/doc/
-
- [5] Gailly, J.-L., GZIP documentation, available as gzip-*.tar in
- ftp://prep.ai.mit.edu/pub/gnu/
-
- [6] Sarwate, D.V., "Computation of Cyclic Redundancy Checks via Table
- Look-Up", Communications of the ACM, 31(8), pp.1008-1013.
-
-
-
-
-Deutsch Informational [Page 9]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- [7] Schwaderer, W.D., "CRC Calculation", April 85 PC Tech Journal,
- pp.118-133.
-
- [8] ftp://ftp.adelaide.edu.au/pub/rocksoft/papers/crc_v3.txt,
- describing the CRC concept.
-
-4. Security Considerations
-
- Any data compression method involves the reduction of redundancy in
- the data. Consequently, any corruption of the data is likely to have
- severe effects and be difficult to correct. Uncompressed text, on
- the other hand, will probably still be readable despite the presence
- of some corrupted bytes.
-
- It is recommended that systems using this data format provide some
- means of validating the integrity of the compressed data, such as by
- setting and checking the CRC-32 check value.
-
-5. Acknowledgements
-
- Trademarks cited in this document are the property of their
- respective owners.
-
- Jean-Loup Gailly designed the gzip format and wrote, with Mark Adler,
- the related software described in this specification. Glenn
- Randers-Pehrson converted this document to RFC and HTML format.
-
-6. Author's Address
-
- L. Peter Deutsch
- Aladdin Enterprises
- 203 Santa Margarita Ave.
- Menlo Park, CA 94025
-
- Phone: (415) 322-0103 (AM only)
- FAX: (415) 322-1734
- EMail: <ghost@aladdin.com>
-
- Questions about the technical content of this specification can be
- sent by email to:
-
- Jean-Loup Gailly <gzip@prep.ai.mit.edu> and
- Mark Adler <madler@alumni.caltech.edu>
-
- Editorial comments on this specification can be sent by email to:
-
- L. Peter Deutsch <ghost@aladdin.com> and
- Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
-
-
-
-Deutsch Informational [Page 10]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
-7. Appendix: Jean-Loup Gailly's gzip utility
-
- The most widely used implementation of gzip compression, and the
- original documentation on which this specification is based, were
- created by Jean-Loup Gailly <gzip@prep.ai.mit.edu>. Since this
- implementation is a de facto standard, we mention some more of its
- features here. Again, the material in this section is not part of
- the specification per se, and implementations need not follow it to
- be compliant.
-
- When compressing or decompressing a file, gzip preserves the
- protection, ownership, and modification time attributes on the local
- file system, since there is no provision for representing protection
- attributes in the gzip file format itself. Since the file format
- includes a modification time, the gzip decompressor provides a
- command line switch that assigns the modification time from the file,
- rather than the local modification time of the compressed input, to
- the decompressed output.
-
-8. Appendix: Sample CRC Code
-
- The following sample code represents a practical implementation of
- the CRC (Cyclic Redundancy Check). (See also ISO 3309 and ITU-T V.42
- for a formal specification.)
-
- The sample code is in the ANSI C programming language. Non C users
- may find it easier to read with these hints:
-
- & Bitwise AND operator.
- ^ Bitwise exclusive-OR operator.
- >> Bitwise right shift operator. When applied to an
- unsigned quantity, as here, right shift inserts zero
- bit(s) at the left.
- ! Logical NOT operator.
- ++ "n++" increments the variable n.
- 0xNNN 0x introduces a hexadecimal (base 16) constant.
- Suffix L indicates a long value (at least 32 bits).
-
- /* Table of CRCs of all 8-bit messages. */
- unsigned long crc_table[256];
-
- /* Flag: has the table been computed? Initially false. */
- int crc_table_computed = 0;
-
- /* Make the table for a fast CRC. */
- void make_crc_table(void)
- {
- unsigned long c;
-
-
-
-Deutsch Informational [Page 11]
-
-RFC 1952 GZIP File Format Specification May 1996
-
-
- int n, k;
- for (n = 0; n < 256; n++) {
- c = (unsigned long) n;
- for (k = 0; k < 8; k++) {
- if (c & 1) {
- c = 0xedb88320L ^ (c >> 1);
- } else {
- c = c >> 1;
- }
- }
- crc_table[n] = c;
- }
- crc_table_computed = 1;
- }
-
- /*
- Update a running crc with the bytes buf[0..len-1] and return
- the updated crc. The crc should be initialized to zero. Pre- and
- post-conditioning (one's complement) is performed within this
- function so it shouldn't be done by the caller. Usage example:
-
- unsigned long crc = 0L;
-
- while (read_buffer(buffer, length) != EOF) {
- crc = update_crc(crc, buffer, length);
- }
- if (crc != original_crc) error();
- */
- unsigned long update_crc(unsigned long crc,
- unsigned char *buf, int len)
- {
- unsigned long c = crc ^ 0xffffffffL;
- int n;
-
- if (!crc_table_computed)
- make_crc_table();
- for (n = 0; n < len; n++) {
- c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
- }
- return c ^ 0xffffffffL;
- }
-
- /* Return the CRC of the bytes buf[0..len-1]. */
- unsigned long crc(unsigned char *buf, int len)
- {
- return update_crc(0L, buf, len);
- }
-
-
-
-
-Deutsch Informational [Page 12]
-
diff --git a/compat/zlib/doc/txtvsbin.txt b/compat/zlib/doc/txtvsbin.txt
deleted file mode 100644
index 3d0f063..0000000
--- a/compat/zlib/doc/txtvsbin.txt
+++ /dev/null
@@ -1,107 +0,0 @@
-A Fast Method for Identifying Plain Text Files
-==============================================
-
-
-Introduction
-------------
-
-Given a file coming from an unknown source, it is sometimes desirable
-to find out whether the format of that file is plain text. Although
-this may appear like a simple task, a fully accurate detection of the
-file type requires heavy-duty semantic analysis on the file contents.
-It is, however, possible to obtain satisfactory results by employing
-various heuristics.
-
-Previous versions of PKZip and other zip-compatible compression tools
-were using a crude detection scheme: if more than 80% (4/5) of the bytes
-found in a certain buffer are within the range [7..127], the file is
-labeled as plain text, otherwise it is labeled as binary. A prominent
-limitation of this scheme is the restriction to Latin-based alphabets.
-Other alphabets, like Greek, Cyrillic or Asian, make extensive use of
-the bytes within the range [128..255], and texts using these alphabets
-are most often misidentified by this scheme; in other words, the rate
-of false negatives is sometimes too high, which means that the recall
-is low. Another weakness of this scheme is a reduced precision, due to
-the false positives that may occur when binary files containing large
-amounts of textual characters are misidentified as plain text.
-
-In this article we propose a new, simple detection scheme that features
-a much increased precision and a near-100% recall. This scheme is
-designed to work on ASCII, Unicode and other ASCII-derived alphabets,
-and it handles single-byte encodings (ISO-8859, MacRoman, KOI8, etc.)
-and variable-sized encodings (ISO-2022, UTF-8, etc.). Wider encodings
-(UCS-2/UTF-16 and UCS-4/UTF-32) are not handled, however.
-
-
-The Algorithm
--------------
-
-The algorithm works by dividing the set of bytecodes [0..255] into three
-categories:
-- The white list of textual bytecodes:
- 9 (TAB), 10 (LF), 13 (CR), 32 (SPACE) to 255.
-- The gray list of tolerated bytecodes:
- 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB), 27 (ESC).
-- The black list of undesired, non-textual bytecodes:
- 0 (NUL) to 6, 14 to 31.
-
-If a file contains at least one byte that belongs to the white list and
-no byte that belongs to the black list, then the file is categorized as
-plain text; otherwise, it is categorized as binary. (The boundary case,
-when the file is empty, automatically falls into the latter category.)
-
-
-Rationale
----------
-
-The idea behind this algorithm relies on two observations.
-
-The first observation is that, although the full range of 7-bit codes
-[0..127] is properly specified by the ASCII standard, most control
-characters in the range [0..31] are not used in practice. The only
-widely-used, almost universally-portable control codes are 9 (TAB),
-10 (LF) and 13 (CR). There are a few more control codes that are
-recognized on a reduced range of platforms and text viewers/editors:
-7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB) and 27 (ESC); but these
-codes are rarely (if ever) used alone, without being accompanied by
-some printable text. Even the newer, portable text formats such as
-XML avoid using control characters outside the list mentioned here.
-
-The second observation is that most of the binary files tend to contain
-control characters, especially 0 (NUL). Even though the older text
-detection schemes observe the presence of non-ASCII codes from the range
-[128..255], the precision rarely has to suffer if this upper range is
-labeled as textual, because the files that are genuinely binary tend to
-contain both control characters and codes from the upper range. On the
-other hand, the upper range needs to be labeled as textual, because it
-is used by virtually all ASCII extensions. In particular, this range is
-used for encoding non-Latin scripts.
-
-Since there is no counting involved, other than simply observing the
-presence or the absence of some byte values, the algorithm produces
-consistent results, regardless what alphabet encoding is being used.
-(If counting were involved, it could be possible to obtain different
-results on a text encoded, say, using ISO-8859-16 versus UTF-8.)
-
-There is an extra category of plain text files that are "polluted" with
-one or more black-listed codes, either by mistake or by peculiar design
-considerations. In such cases, a scheme that tolerates a small fraction
-of black-listed codes would provide an increased recall (i.e. more true
-positives). This, however, incurs a reduced precision overall, since
-false positives are more likely to appear in binary files that contain
-large chunks of textual data. Furthermore, "polluted" plain text should
-be regarded as binary by general-purpose text detection schemes, because
-general-purpose text processing algorithms might not be applicable.
-Under this premise, it is safe to say that our detection method provides
-a near-100% recall.
-
-Experiments have been run on many files coming from various platforms
-and applications. We tried plain text files, system logs, source code,
-formatted office documents, compiled object code, etc. The results
-confirm the optimistic assumptions about the capabilities of this
-algorithm.
-
-
---
-Cosmin Truta
-Last updated: 2006-May-28
diff --git a/compat/zlib/examples/gun.c b/compat/zlib/examples/gun.c
index 89e484f..be44fa5 100644
--- a/compat/zlib/examples/gun.c
+++ b/compat/zlib/examples/gun.c
@@ -46,7 +46,7 @@
end-of-file, they cannot be concantenated. If a Unix compress stream is
encountered in an input file, it is the last stream in that file.
- Like gunzip and uncompress, the file attributes of the orignal compressed
+ Like gunzip and uncompress, the file attributes of the original compressed
file are maintained in the final uncompressed file, to the extent that the
user permissions allow it.
diff --git a/compat/zlib/examples/gzlog.c b/compat/zlib/examples/gzlog.c
index 922f878..b8c2927 100644
--- a/compat/zlib/examples/gzlog.c
+++ b/compat/zlib/examples/gzlog.c
@@ -1,6 +1,6 @@
/*
* gzlog.c
- * Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved
+ * Copyright (C) 2004, 2008, 2012, 2016 Mark Adler, all rights reserved
* For conditions of distribution and use, see copyright notice in gzlog.h
* version 2.2, 14 Aug 2012
*/
@@ -243,7 +243,7 @@ typedef unsigned int uint;
typedef unsigned long ulong;
/* Macro for debugging to deterministically force recovery operations */
-#ifdef DEBUG
+#ifdef GZLOG_DEBUG
#include <setjmp.h> /* longjmp */
jmp_buf gzlog_jump; /* where to go back to */
int gzlog_bail = 0; /* which point to bail at (1..8) */
diff --git a/compat/zlib/examples/zran.c b/compat/zlib/examples/zran.c
index 278f9ad..4fec659 100644
--- a/compat/zlib/examples/zran.c
+++ b/compat/zlib/examples/zran.c
@@ -27,7 +27,7 @@
grows as needed to accommodate the points.
To use the index, an offset in the uncompressed data is provided, for which
- the latest accees point at or preceding that offset is located in the index.
+ the latest access point at or preceding that offset is located in the index.
The input file is positioned to the specified location in the index, and if
necessary the first few bits of the compressed data is read from the file.
inflate is initialized with those bits and the 32K of uncompressed data, and
diff --git a/compat/zlib/gzguts.h b/compat/zlib/gzguts.h
index d87659d..990a4d2 100644
--- a/compat/zlib/gzguts.h
+++ b/compat/zlib/gzguts.h
@@ -1,5 +1,5 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -25,6 +25,10 @@
# include <stdlib.h>
# include <limits.h>
#endif
+
+#ifndef _POSIX_SOURCE
+# define _POSIX_SOURCE
+#endif
#include <fcntl.h>
#ifdef _WIN32
@@ -35,6 +39,10 @@
# include <io.h>
#endif
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define WIDECHAR
+#endif
+
#ifdef WINAPI_FAMILY
# define open _open
# define read _read
@@ -95,18 +103,19 @@
# endif
#endif
-/* unlike snprintf (which is required in C99, yet still not supported by
- Microsoft more than a decade later!), _snprintf does not guarantee null
- termination of the result -- however this is only used in gzlib.c where
+/* unlike snprintf (which is required in C99), _snprintf does not guarantee
+ null termination of the result -- however this is only used in gzlib.c where
the result is assured to fit in the space provided */
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif
#ifndef local
# define local static
#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
+/* since "static" is used to mean two completely different things in C, we
+ define "local" for the non-static meaning of "static", for readability
+ (compile with -Dlocal if your debugger can't find static symbols) */
/* gz* functions always use library allocation functions */
#ifndef STDC
@@ -170,7 +179,7 @@ typedef struct {
char *path; /* path or fd for error messages */
unsigned size; /* buffer size, zero if not allocated yet */
unsigned want; /* requested buffer size, default is GZBUFSIZE */
- unsigned char *in; /* input buffer */
+ unsigned char *in; /* input buffer (double-sized when writing) */
unsigned char *out; /* output buffer (double-sized when reading) */
int direct; /* 0 if processing gzip, 1 if transparent */
/* just for reading */
diff --git a/compat/zlib/gzlib.c b/compat/zlib/gzlib.c
index fae202e..4105e6a 100644
--- a/compat/zlib/gzlib.c
+++ b/compat/zlib/gzlib.c
@@ -1,11 +1,11 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -94,7 +94,7 @@ local gzFile gz_open(path, fd, mode)
const char *mode;
{
gz_statep state;
- size_t len;
+ z_size_t len;
int oflag;
#ifdef O_CLOEXEC
int cloexec = 0;
@@ -188,10 +188,10 @@ local gzFile gz_open(path, fd, mode)
}
/* save the path name for error messages */
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
- if (len == (size_t)-1)
+ if (len == (z_size_t)-1)
len = 0;
}
else
@@ -202,7 +202,7 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
@@ -211,7 +211,7 @@ local gzFile gz_open(path, fd, mode)
else
#endif
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(state->path, len + 1, "%s", (const char *)path);
+ (void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
strcpy(state->path, path);
#endif
@@ -239,7 +239,7 @@ local gzFile gz_open(path, fd, mode)
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
-#ifdef _WIN32
+#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
@@ -248,8 +248,10 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
- if (state->mode == GZ_APPEND)
+ if (state->mode == GZ_APPEND) {
+ LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */
state->mode = GZ_WRITE; /* simplify later checks */
+ }
/* save the current position for rewinding (only if reading) */
if (state->mode == GZ_READ) {
@@ -291,7 +293,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
+ (void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd);
#else
sprintf(path, "<fd:%d>", fd); /* for debugging */
#endif
@@ -301,7 +303,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
}
/* -- see zlib.h -- */
-#ifdef _WIN32
+#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;
@@ -329,6 +331,8 @@ int ZEXPORT gzbuffer(file, size)
return -1;
/* check and set requested size */
+ if ((size << 1) < size)
+ return -1; /* need to be able to double it */
if (size < 2)
size = 2; /* need two bytes to check magic header */
state->want = size;
@@ -604,14 +608,13 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
return;
}
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
- "%s%s%s", state->path, ": ", msg);
+ (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
+ "%s%s%s", state->path, ": ", msg);
#else
strcpy(state->msg, state->path);
strcat(state->msg, ": ");
strcat(state->msg, msg);
#endif
- return;
}
#ifndef INT_MAX
diff --git a/compat/zlib/gzread.c b/compat/zlib/gzread.c
index bf4538e..956b91e 100644
--- a/compat/zlib/gzread.c
+++ b/compat/zlib/gzread.c
@@ -1,5 +1,5 @@
/* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -12,6 +12,7 @@ local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep));
local int gz_fetch OF((gz_statep));
local int gz_skip OF((gz_statep, z_off64_t));
+local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state->fd, and update state->eof, state->err, and state->msg as appropriate.
@@ -24,13 +25,17 @@ local int gz_load(state, buf, len, have)
unsigned *have;
{
int ret;
+ unsigned get, max = ((unsigned)-1 >> 2) + 1;
*have = 0;
do {
- ret = read(state->fd, buf + *have, len - *have);
+ get = len - *have;
+ if (get > max)
+ get = max;
+ ret = read(state->fd, buf + *have, get);
if (ret <= 0)
break;
- *have += ret;
+ *have += (unsigned)ret;
} while (*have < len);
if (ret < 0) {
gz_error(state, Z_ERRNO, zstrerror());
@@ -94,10 +99,8 @@ local int gz_look(state)
state->in = (unsigned char *)malloc(state->want);
state->out = (unsigned char *)malloc(state->want << 1);
if (state->in == NULL || state->out == NULL) {
- if (state->out != NULL)
- free(state->out);
- if (state->in != NULL)
- free(state->in);
+ free(state->out);
+ free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
@@ -284,33 +287,17 @@ local int gz_skip(state, len)
return 0;
}
-/* -- see zlib.h -- */
-int ZEXPORT gzread(file, buf, len)
- gzFile file;
+/* Read len bytes into buf from file, or less than len up to the end of the
+ input. Return the number of bytes read. If zero is returned, either the
+ end of file was reached, or there was an error. state->err must be
+ consulted in that case to determine which. */
+local z_size_t gz_read(state, buf, len)
+ gz_statep state;
voidp buf;
- unsigned len;
+ z_size_t len;
{
- unsigned got, n;
- gz_statep state;
- z_streamp strm;
-
- /* get internal structure */
- if (file == NULL)
- return -1;
- state = (gz_statep)file;
- strm = &(state->strm);
-
- /* check that we're reading and that there's no (serious) error */
- if (state->mode != GZ_READ ||
- (state->err != Z_OK && state->err != Z_BUF_ERROR))
- return -1;
-
- /* since an int is returned, make sure len fits in one, otherwise return
- with an error (this avoids the flaw in the interface) */
- if ((int)len < 0) {
- gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
- return -1;
- }
+ z_size_t got;
+ unsigned n;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
@@ -320,32 +307,38 @@ int ZEXPORT gzread(file, buf, len)
if (state->seek) {
state->seek = 0;
if (gz_skip(state, state->skip) == -1)
- return -1;
+ return 0;
}
/* get len bytes to buf, or less than len if at the end */
got = 0;
do {
+ /* set n to the maximum amount of len that fits in an unsigned int */
+ n = -1;
+ if (n > len)
+ n = len;
+
/* first just try copying data from the output buffer */
if (state->x.have) {
- n = state->x.have > len ? len : state->x.have;
+ if (state->x.have < n)
+ n = state->x.have;
memcpy(buf, state->x.next, n);
state->x.next += n;
state->x.have -= n;
}
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && strm->avail_in == 0) {
+ else if (state->eof && state->strm.avail_in == 0) {
state->past = 1; /* tried to read past end */
break;
}
/* need output data -- for small len or new stream load up our output
buffer */
- else if (state->how == LOOK || len < (state->size << 1)) {
+ else if (state->how == LOOK || n < (state->size << 1)) {
/* get more output, looking for header if required */
if (gz_fetch(state) == -1)
- return -1;
+ return 0;
continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */
@@ -353,16 +346,16 @@ int ZEXPORT gzread(file, buf, len)
/* large len -- read directly into user buffer */
else if (state->how == COPY) { /* read directly */
- if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
- return -1;
+ if (gz_load(state, (unsigned char *)buf, n, &n) == -1)
+ return 0;
}
/* large len -- decompress directly into user buffer */
else { /* state->how == GZIP */
- strm->avail_out = len;
- strm->next_out = (unsigned char *)buf;
+ state->strm.avail_out = n;
+ state->strm.next_out = (unsigned char *)buf;
if (gz_decomp(state) == -1)
- return -1;
+ return 0;
n = state->x.have;
state->x.have = 0;
}
@@ -374,8 +367,75 @@ int ZEXPORT gzread(file, buf, len)
state->x.pos += n;
} while (len);
- /* return number of bytes read into user buffer (will fit in int) */
- return (int)got;
+ /* return number of bytes read into user buffer */
+ return got;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzread(file, buf, len)
+ gzFile file;
+ voidp buf;
+ unsigned len;
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no (serious) error */
+ if (state->mode != GZ_READ ||
+ (state->err != Z_OK && state->err != Z_BUF_ERROR))
+ return -1;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids a flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
+ return -1;
+ }
+
+ /* read len or fewer bytes to buf */
+ len = gz_read(state, buf, len);
+
+ /* check for an error */
+ if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
+ return -1;
+
+ /* return the number of bytes read (this is assured to fit in an int) */
+ return (int)len;
+}
+
+/* -- see zlib.h -- */
+z_size_t ZEXPORT gzfread(buf, size, nitems, file)
+ voidp buf;
+ z_size_t size;
+ z_size_t nitems;
+ gzFile file;
+{
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no (serious) error */
+ if (state->mode != GZ_READ ||
+ (state->err != Z_OK && state->err != Z_BUF_ERROR))
+ return 0;
+
+ /* compute bytes to read -- error on overflow */
+ len = nitems * size;
+ if (size && len / size != nitems) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
+ return 0;
+ }
+
+ /* read len or fewer bytes to buf, return the number of full items read */
+ return len ? gz_read(state, buf, len) / size : 0;
}
/* -- see zlib.h -- */
@@ -408,8 +468,8 @@ int ZEXPORT gzgetc(file)
return *(state->x.next)++;
}
- /* nothing there -- try gzread() */
- ret = gzread(file, buf, 1);
+ /* nothing there -- try gz_read() */
+ ret = gz_read(state, buf, 1);
return ret < 1 ? -1 : buf[0];
}
@@ -451,7 +511,7 @@ int ZEXPORT gzungetc(c, file)
if (state->x.have == 0) {
state->x.have = 1;
state->x.next = state->out + (state->size << 1) - 1;
- state->x.next[0] = c;
+ state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
@@ -473,7 +533,7 @@ int ZEXPORT gzungetc(c, file)
}
state->x.have++;
state->x.next--;
- state->x.next[0] = c;
+ state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
diff --git a/compat/zlib/gzwrite.c b/compat/zlib/gzwrite.c
index aa767fb..c7b5651 100644
--- a/compat/zlib/gzwrite.c
+++ b/compat/zlib/gzwrite.c
@@ -1,5 +1,5 @@
/* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,17 +9,19 @@
local int gz_init OF((gz_statep));
local int gz_comp OF((gz_statep, int));
local int gz_zero OF((gz_statep, z_off64_t));
+local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
/* Initialize state for writing a gzip file. Mark initialization by setting
- state->size to non-zero. Return -1 on failure or 0 on success. */
+ state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
+ success. */
local int gz_init(state)
gz_statep state;
{
int ret;
z_streamp strm = &(state->strm);
- /* allocate input buffer */
- state->in = (unsigned char *)malloc(state->want);
+ /* allocate input buffer (double size for gzprintf) */
+ state->in = (unsigned char *)malloc(state->want << 1);
if (state->in == NULL) {
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
@@ -47,6 +49,7 @@ local int gz_init(state)
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
+ strm->next_in = NULL;
}
/* mark state as initialized */
@@ -62,17 +65,17 @@ local int gz_init(state)
}
/* Compress whatever is at avail_in and next_in and write to the output file.
- Return -1 if there is an error writing to the output file, otherwise 0.
- flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
- then the deflate() state is reset to start a new gzip stream. If gz->direct
- is true, then simply write to the output file without compressing, and
- ignore flush. */
+ Return -1 if there is an error writing to the output file or if gz_init()
+ fails to allocate memory, otherwise 0. flush is assumed to be a valid
+ deflate() flush value. If flush is Z_FINISH, then the deflate() state is
+ reset to start a new gzip stream. If gz->direct is true, then simply write
+ to the output file without compressing, and ignore flush. */
local int gz_comp(state, flush)
gz_statep state;
int flush;
{
- int ret, got;
- unsigned have;
+ int ret, writ;
+ unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
z_streamp strm = &(state->strm);
/* allocate memory if this is the first time through */
@@ -81,12 +84,16 @@ local int gz_comp(state, flush)
/* write directly if requested */
if (state->direct) {
- got = write(state->fd, strm->next_in, strm->avail_in);
- if (got < 0 || (unsigned)got != strm->avail_in) {
- gz_error(state, Z_ERRNO, zstrerror());
- return -1;
+ while (strm->avail_in) {
+ put = strm->avail_in > max ? max : strm->avail_in;
+ writ = write(state->fd, strm->next_in, put);
+ if (writ < 0) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ strm->avail_in -= (unsigned)writ;
+ strm->next_in += writ;
}
- strm->avail_in = 0;
return 0;
}
@@ -97,17 +104,21 @@ local int gz_comp(state, flush)
doing Z_FINISH then don't write until we get to Z_STREAM_END */
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
(flush != Z_FINISH || ret == Z_STREAM_END))) {
- have = (unsigned)(strm->next_out - state->x.next);
- if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
- (unsigned)got != have)) {
- gz_error(state, Z_ERRNO, zstrerror());
- return -1;
+ while (strm->next_out > state->x.next) {
+ put = strm->next_out - state->x.next > (int)max ? max :
+ (unsigned)(strm->next_out - state->x.next);
+ writ = write(state->fd, state->x.next, put);
+ if (writ < 0) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ state->x.next += writ;
}
if (strm->avail_out == 0) {
strm->avail_out = state->size;
strm->next_out = state->out;
+ state->x.next = state->out;
}
- state->x.next = strm->next_out;
}
/* compress */
@@ -129,7 +140,8 @@ local int gz_comp(state, flush)
return 0;
}
-/* Compress len zeros to output. Return -1 on error, 0 on success. */
+/* Compress len zeros to output. Return -1 on a write error or memory
+ allocation failure by gz_comp(), or 0 on success. */
local int gz_zero(state, len)
gz_statep state;
z_off64_t len;
@@ -161,32 +173,14 @@ local int gz_zero(state, len)
return 0;
}
-/* -- see zlib.h -- */
-int ZEXPORT gzwrite(file, buf, len)
- gzFile file;
+/* Write len bytes from buf to file. Return the number of bytes written. If
+ the returned value is less than len, then there was an error. */
+local z_size_t gz_write(state, buf, len)
+ gz_statep state;
voidpc buf;
- unsigned len;
+ z_size_t len;
{
- unsigned put = len;
- gz_statep state;
- z_streamp strm;
-
- /* get internal structure */
- if (file == NULL)
- return 0;
- state = (gz_statep)file;
- strm = &(state->strm);
-
- /* check that we're writing and that there's no error */
- if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
-
- /* since an int is returned, make sure len fits in one, otherwise return
- with an error (this avoids the flaw in the interface) */
- if ((int)len < 0) {
- gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
- return 0;
- }
+ z_size_t put = len;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
@@ -209,14 +203,15 @@ int ZEXPORT gzwrite(file, buf, len)
do {
unsigned have, copy;
- if (strm->avail_in == 0)
- strm->next_in = state->in;
- have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
+ if (state->strm.avail_in == 0)
+ state->strm.next_in = state->in;
+ have = (unsigned)((state->strm.next_in + state->strm.avail_in) -
+ state->in);
copy = state->size - have;
if (copy > len)
copy = len;
memcpy(state->in + have, buf, copy);
- strm->avail_in += copy;
+ state->strm.avail_in += copy;
state->x.pos += copy;
buf = (const char *)buf + copy;
len -= copy;
@@ -226,19 +221,83 @@ int ZEXPORT gzwrite(file, buf, len)
}
else {
/* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
/* directly compress user buffer to file */
- strm->avail_in = len;
- strm->next_in = (z_const Bytef *)buf;
- state->x.pos += len;
- if (gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
+ state->strm.next_in = (z_const Bytef *)buf;
+ do {
+ unsigned n = (unsigned)-1;
+ if (n > len)
+ n = len;
+ state->strm.avail_in = n;
+ state->x.pos += n;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+ len -= n;
+ } while (len);
+ }
+
+ /* input was all buffered or compressed */
+ return put;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzwrite(file, buf, len)
+ gzFile file;
+ voidpc buf;
+ unsigned len;
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids a flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
+ return 0;
+ }
+
+ /* write len bytes from buf (the return value will fit in an int) */
+ return (int)gz_write(state, buf, len);
+}
+
+/* -- see zlib.h -- */
+z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
+ voidpc buf;
+ z_size_t size;
+ z_size_t nitems;
+ gzFile file;
+{
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* compute bytes to read -- error on overflow */
+ len = nitems * size;
+ if (size && len / size != nitems) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
+ return 0;
}
- /* input was all buffered or compressed (put will fit in int) */
- return (int)put;
+ /* write len bytes to buf, return the number of full items written */
+ return len ? gz_write(state, buf, len) / size : 0;
}
/* -- see zlib.h -- */
@@ -275,7 +334,7 @@ int ZEXPORT gzputc(file, c)
strm->next_in = state->in;
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
if (have < state->size) {
- state->in[have] = c;
+ state->in[have] = (unsigned char)c;
strm->avail_in++;
state->x.pos++;
return c & 0xff;
@@ -283,8 +342,8 @@ int ZEXPORT gzputc(file, c)
}
/* no room in buffer or not initialized, use gz_write() */
- buf[0] = c;
- if (gzwrite(file, buf, 1) != 1)
+ buf[0] = (unsigned char)c;
+ if (gz_write(state, buf, 1) != 1)
return -1;
return c & 0xff;
}
@@ -295,11 +354,21 @@ int ZEXPORT gzputs(file, str)
const char *str;
{
int ret;
- unsigned len;
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return -1;
/* write string */
- len = (unsigned)strlen(str);
- ret = gzwrite(file, str, len);
+ len = strlen(str);
+ ret = gz_write(state, str, len);
return ret == 0 && len != 0 ? -1 : ret;
}
@@ -309,63 +378,73 @@ int ZEXPORT gzputs(file, str)
/* -- see zlib.h -- */
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
{
- int size, len;
+ int len;
+ unsigned left;
+ char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
+ return Z_STREAM_ERROR;
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
- return 0;
+ return state->err;
/* check for seek request */
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return 0;
+ return state->err;
}
- /* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
-
- /* do the printf() into the input buffer, put length in len */
- size = (int)(state->size);
- state->in[size - 1] = 0;
+ /* do the printf() into the input buffer, put length in len -- the input
+ buffer is double-sized just for this function, so there is guaranteed to
+ be state->size bytes available after the current contents */
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
+ next[state->size - 1] = 0;
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
- (void)vsprintf((char *)(state->in), format, va);
- for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
+ (void)vsprintf(next, format, va);
+ for (len = 0; len < state->size; len++)
+ if (next[len] == 0) break;
# else
- len = vsprintf((char *)(state->in), format, va);
+ len = vsprintf(next, format, va);
# endif
#else
# ifdef HAS_vsnprintf_void
- (void)vsnprintf((char *)(state->in), size, format, va);
- len = strlen((char *)(state->in));
+ (void)vsnprintf(next, state->size, format, va);
+ len = strlen(next);
# else
- len = vsnprintf((char *)(state->in), size, format, va);
+ len = vsnprintf(next, state->size, format, va);
# endif
#endif
/* check that printf() results fit in buffer */
- if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
return 0;
- /* update buffer and position, defer compression until needed */
- strm->avail_in = (unsigned)len;
- strm->next_in = state->in;
+ /* update buffer and position, compress first half if past that */
+ strm->avail_in += (unsigned)len;
state->x.pos += len;
+ if (strm->avail_in >= state->size) {
+ left = strm->avail_in - state->size;
+ strm->avail_in = state->size;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return state->err;
+ memcpy(state->in, state->in + state->size, left);
+ strm->next_in = state->in;
+ strm->avail_in = left;
+ }
return len;
}
@@ -390,73 +469,82 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
- int size, len;
+ unsigned len, left;
+ char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *))
- return 0;
+ return Z_STREAM_ERROR;
/* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
+ return Z_STREAM_ERROR;
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
- return 0;
+ return state->error;
/* check for seek request */
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return 0;
+ return state->error;
}
- /* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
-
- /* do the printf() into the input buffer, put length in len */
- size = (int)(state->size);
- state->in[size - 1] = 0;
+ /* do the printf() into the input buffer, put length in len -- the input
+ buffer is double-sized just for this function, so there is guaranteed to
+ be state->size bytes available after the current contents */
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ next = (char *)(strm->next_in + strm->avail_in);
+ next[state->size - 1] = 0;
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
- sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
+ a13, a14, a15, a16, a17, a18, a19, a20);
for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
+ if (next[len] == 0)
+ break;
# else
- len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
+ a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#else
# ifdef HAS_snprintf_void
- snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen((char *)(state->in));
+ snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ len = strlen(next);
# else
- len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
- a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
- a19, a20);
+ len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#endif
/* check that printf() results fit in buffer */
- if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ if (len == 0 || len >= state->size || next[state->size - 1] != 0)
return 0;
- /* update buffer and position, defer compression until needed */
- strm->avail_in = (unsigned)len;
- strm->next_in = state->in;
+ /* update buffer and position, compress first half if past that */
+ strm->avail_in += len;
state->x.pos += len;
- return len;
+ if (strm->avail_in >= state->size) {
+ left = strm->avail_in - state->size;
+ strm->avail_in = state->size;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return state->err;
+ memcpy(state->in, state->in + state->size, left);
+ strm->next_in = state->in;
+ strm->avail_in = left;
+ }
+ return (int)len;
}
#endif
@@ -470,7 +558,7 @@ int ZEXPORT gzflush(file, flush)
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
/* check that we're writing and that there's no error */
@@ -485,11 +573,11 @@ int ZEXPORT gzflush(file, flush)
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return -1;
+ return state->err;
}
/* compress remaining data with requested flush */
- gz_comp(state, flush);
+ (void)gz_comp(state, flush);
return state->err;
}
@@ -520,13 +608,13 @@ int ZEXPORT gzsetparams(file, level, strategy)
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return -1;
+ return state->err;
}
/* change compression parameters for subsequent input */
if (state->size) {
/* flush previous input with previous parameters before changing */
- if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
+ if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
return state->err;
deflateParams(strm, level, strategy);
}
diff --git a/compat/zlib/infback.c b/compat/zlib/infback.c
index f3833c2..59679ec 100644
--- a/compat/zlib/infback.c
+++ b/compat/zlib/infback.c
@@ -1,5 +1,5 @@
/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2011 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -61,7 +61,7 @@ int stream_size;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
state->dmax = 32768U;
- state->wbits = windowBits;
+ state->wbits = (uInt)windowBits;
state->wsize = 1U << windowBits;
state->window = window;
state->wnext = 0;
diff --git a/compat/zlib/inffast.c b/compat/zlib/inffast.c
index bda59ce..0dbd1db 100644
--- a/compat/zlib/inffast.c
+++ b/compat/zlib/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,26 +8,9 @@
#include "inflate.h"
#include "inffast.h"
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
+#ifdef ASMINF
+# pragma message("Assembler code may have bugs -- use at your own risk")
#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
/*
Decode literal, length, and distance codes and write out the resulting
@@ -96,9 +79,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
+ in = strm->next_in;
last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
+ out = strm->next_out;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
#ifdef INFLATE_STRICT
@@ -119,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
input data or output space */
do {
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
here = lcode[hold & lmask];
@@ -134,14 +117,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", here.val));
- PUP(out) = (unsigned char)(here.val);
+ *out++ = (unsigned char)(here.val);
}
else if (op & 16) { /* length base */
len = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
len += (unsigned)hold & ((1U << op) - 1);
@@ -150,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
here = dcode[hold & dmask];
@@ -165,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
}
@@ -196,30 +179,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
if (len <= op - whave) {
do {
- PUP(out) = 0;
+ *out++ = 0;
} while (--len);
continue;
}
len -= op - whave;
do {
- PUP(out) = 0;
+ *out++ = 0;
} while (--op > whave);
if (op == 0) {
from = out - dist;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--len);
continue;
}
#endif
}
- from = window - OFF;
+ from = window;
if (wnext == 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
@@ -230,14 +213,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (op < len) { /* some from end of window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
- from = window - OFF;
+ from = window;
if (wnext < len) { /* some from start of window */
op = wnext;
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
@@ -248,35 +231,35 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (op < len) { /* some from window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
}
while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
+ *out++ = *from++;
+ *out++ = *from++;
+ *out++ = *from++;
len -= 3;
}
if (len) {
- PUP(out) = PUP(from);
+ *out++ = *from++;
if (len > 1)
- PUP(out) = PUP(from);
+ *out++ = *from++;
}
}
else {
from = out - dist; /* copy direct from output */
do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
+ *out++ = *from++;
+ *out++ = *from++;
+ *out++ = *from++;
len -= 3;
} while (len > 2);
if (len) {
- PUP(out) = PUP(from);
+ *out++ = *from++;
if (len > 1)
- PUP(out) = PUP(from);
+ *out++ = *from++;
}
}
}
@@ -313,8 +296,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold &= (1U << bits) - 1;
/* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
+ strm->next_in = in;
+ strm->next_out = out;
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
strm->avail_out = (unsigned)(out < end ?
257 + (end - out) : 257 - (out - end));
diff --git a/compat/zlib/inflate.c b/compat/zlib/inflate.c
index 870f89b..ac333e8 100644
--- a/compat/zlib/inflate.c
+++ b/compat/zlib/inflate.c
@@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2012 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -92,6 +92,7 @@
#endif
/* function prototypes */
+local int inflateStateCheck OF((z_streamp strm));
local void fixedtables OF((struct inflate_state FAR *state));
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
unsigned copy));
@@ -101,12 +102,26 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
unsigned len));
+local int inflateStateCheck(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+ if (strm == Z_NULL ||
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
+ return 1;
+ state = (struct inflate_state FAR *)strm->state;
+ if (state == Z_NULL || state->strm != strm ||
+ state->mode < HEAD || state->mode > SYNC)
+ return 1;
+ return 0;
+}
+
int ZEXPORT inflateResetKeep(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
@@ -131,7 +146,7 @@ z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
state->wsize = 0;
state->whave = 0;
@@ -147,7 +162,7 @@ int windowBits;
struct inflate_state FAR *state;
/* get the state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
/* extract wrap request from windowBits parameter */
@@ -156,7 +171,7 @@ int windowBits;
windowBits = -windowBits;
}
else {
- wrap = (windowBits >> 4) + 1;
+ wrap = (windowBits >> 4) + 5;
#ifdef GUNZIP
if (windowBits < 48)
windowBits &= 15;
@@ -210,7 +225,9 @@ int stream_size;
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
+ state->strm = strm;
state->window = Z_NULL;
+ state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
ZFREE(strm, state);
@@ -234,17 +251,17 @@ int value;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (bits < 0) {
state->hold = 0;
state->bits = 0;
return Z_OK;
}
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+ if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
+ state->hold += (unsigned)value << state->bits;
+ state->bits += (uInt)bits;
return Z_OK;
}
@@ -625,7 +642,7 @@ int flush;
static const unsigned short order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
+ if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
(strm->next_in == Z_NULL && strm->avail_in != 0))
return Z_STREAM_ERROR;
@@ -645,6 +662,8 @@ int flush;
NEEDBITS(16);
#ifdef GUNZIP
if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
+ if (state->wbits == 0)
+ state->wbits = 15;
state->check = crc32(0L, Z_NULL, 0);
CRC2(state->check, hold);
INITBITS();
@@ -672,7 +691,7 @@ int flush;
len = BITS(4) + 8;
if (state->wbits == 0)
state->wbits = len;
- else if (len > state->wbits) {
+ if (len > 15 || len > state->wbits) {
strm->msg = (char *)"invalid window size";
state->mode = BAD;
break;
@@ -699,14 +718,16 @@ int flush;
}
if (state->head != Z_NULL)
state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
state->mode = TIME;
case TIME:
NEEDBITS(32);
if (state->head != Z_NULL)
state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC4(state->check, hold);
INITBITS();
state->mode = OS;
case OS:
@@ -715,7 +736,8 @@ int flush;
state->head->xflags = (int)(hold & 0xff);
state->head->os = (int)(hold >> 8);
}
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
state->mode = EXLEN;
case EXLEN:
@@ -724,7 +746,8 @@ int flush;
state->length = (unsigned)(hold);
if (state->head != Z_NULL)
state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
}
else if (state->head != Z_NULL)
@@ -742,7 +765,7 @@ int flush;
len + copy > state->head->extra_max ?
state->head->extra_max - len : copy);
}
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -761,9 +784,9 @@ int flush;
if (state->head != Z_NULL &&
state->head->name != Z_NULL &&
state->length < state->head->name_max)
- state->head->name[state->length++] = len;
+ state->head->name[state->length++] = (Bytef)len;
} while (len && copy < have);
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -782,9 +805,9 @@ int flush;
if (state->head != Z_NULL &&
state->head->comment != Z_NULL &&
state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
+ state->head->comment[state->length++] = (Bytef)len;
} while (len && copy < have);
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -796,7 +819,7 @@ int flush;
case HCRC:
if (state->flags & 0x0200) {
NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
+ if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
strm->msg = (char *)"header crc mismatch";
state->mode = BAD;
break;
@@ -1177,11 +1200,11 @@ int flush;
out -= left;
strm->total_out += out;
state->total += out;
- if (out)
+ if ((state->wrap & 4) && out)
strm->adler = state->check =
UPDATE(state->check, put - out, out);
out = left;
- if ((
+ if ((state->wrap & 4) && (
#ifdef GUNZIP
state->flags ? hold :
#endif
@@ -1240,10 +1263,10 @@ int flush;
strm->total_in += in;
strm->total_out += out;
state->total += out;
- if (state->wrap && out)
+ if ((state->wrap & 4) && out)
strm->adler = state->check =
UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
+ strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
(state->mode == TYPE ? 128 : 0) +
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
@@ -1255,7 +1278,7 @@ int ZEXPORT inflateEnd(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ if (inflateStateCheck(strm))
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->window != Z_NULL) ZFREE(strm, state->window);
@@ -1273,7 +1296,7 @@ uInt *dictLength;
struct inflate_state FAR *state;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
/* copy dictionary */
@@ -1298,7 +1321,7 @@ uInt dictLength;
int ret;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->wrap != 0 && state->mode != DICT)
return Z_STREAM_ERROR;
@@ -1330,7 +1353,7 @@ gz_headerp head;
struct inflate_state FAR *state;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
@@ -1383,7 +1406,7 @@ z_streamp strm;
struct inflate_state FAR *state;
/* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
@@ -1430,7 +1453,7 @@ z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
return state->mode == STORED && state->bits == 0;
}
@@ -1445,8 +1468,7 @@ z_streamp source;
unsigned wsize;
/* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
+ if (inflateStateCheck(source) || dest == Z_NULL)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)source->state;
@@ -1467,6 +1489,7 @@ z_streamp source;
/* copy state */
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
+ copy->strm = dest;
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes);
@@ -1488,25 +1511,51 @@ int subvert;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
- state->sane = !subvert;
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ state->sane = !subvert;
return Z_OK;
#else
+ (void)subvert;
state->sane = 1;
return Z_DATA_ERROR;
#endif
}
+int ZEXPORT inflateValidate(strm, check)
+z_streamp strm;
+int check;
+{
+ struct inflate_state FAR *state;
+
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (check)
+ state->wrap |= 4;
+ else
+ state->wrap &= ~4;
+ return Z_OK;
+}
+
long ZEXPORT inflateMark(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+ if (inflateStateCheck(strm))
+ return -(1L << 16);
state = (struct inflate_state FAR *)strm->state;
- return ((long)(state->back) << 16) +
+ return (long)(((unsigned long)((long)state->back)) << 16) +
(state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0));
}
+
+unsigned long ZEXPORT inflateCodesUsed(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+ if (inflateStateCheck(strm)) return (unsigned long)-1;
+ state = (struct inflate_state FAR *)strm->state;
+ return (unsigned long)(state->next - state->codes);
+}
diff --git a/compat/zlib/inflate.h b/compat/zlib/inflate.h
index 95f4986..a46cce6 100644
--- a/compat/zlib/inflate.h
+++ b/compat/zlib/inflate.h
@@ -1,5 +1,5 @@
/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2009 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -18,7 +18,7 @@
/* Possible inflate modes between inflate() calls */
typedef enum {
- HEAD, /* i: waiting for magic header */
+ HEAD = 16180, /* i: waiting for magic header */
FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */
OS, /* i: waiting for extra flags and operating system (gzip) */
@@ -77,11 +77,14 @@ typedef enum {
CHECK -> LENGTH -> DONE
*/
-/* state maintained between inflate() calls. Approximately 10K bytes. */
+/* State maintained between inflate() calls -- approximately 7K bytes, not
+ including the allocated sliding window, which is up to 32K bytes. */
struct inflate_state {
+ z_streamp strm; /* pointer back to this zlib stream */
inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
+ bit 2 true to validate check value */
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
diff --git a/compat/zlib/inftrees.c b/compat/zlib/inftrees.c
index 44d89cf..2ea08fc 100644
--- a/compat/zlib/inftrees.c
+++ b/compat/zlib/inftrees.c
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2013 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
+ " inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -54,7 +54,7 @@ unsigned short FAR *work;
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
+ unsigned match; /* use base and extra for symbol >= match */
unsigned short count[MAXBITS+1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -181,19 +181,17 @@ unsigned short FAR *work;
switch (type) {
case CODES:
base = extra = work; /* dummy value--not used */
- end = 19;
+ match = 20;
break;
case LENS:
base = lbase;
- base -= 257;
extra = lext;
- extra -= 257;
- end = 256;
+ match = 257;
break;
- default: /* DISTS */
+ default: /* DISTS */
base = dbase;
extra = dext;
- end = -1;
+ match = 0;
}
/* initialize state for loop */
@@ -216,13 +214,13 @@ unsigned short FAR *work;
for (;;) {
/* create table entry */
here.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
+ if (work[sym] + 1U < match) {
here.op = (unsigned char)0;
here.val = work[sym];
}
- else if ((int)(work[sym]) > end) {
- here.op = (unsigned char)(extra[work[sym]]);
- here.val = base[work[sym]];
+ else if (work[sym] >= match) {
+ here.op = (unsigned char)(extra[work[sym] - match]);
+ here.val = base[work[sym] - match];
}
else {
here.op = (unsigned char)(32 + 64); /* end of block */
diff --git a/compat/zlib/msdos/Makefile.dj2 b/compat/zlib/msdos/Makefile.dj2
index 29b0395..59d2037 100644
--- a/compat/zlib/msdos/Makefile.dj2
+++ b/compat/zlib/msdos/Makefile.dj2
@@ -29,7 +29,7 @@ CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
+#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
diff --git a/compat/zlib/msdos/Makefile.emx b/compat/zlib/msdos/Makefile.emx
index 9c1b57a..e30f67b 100644
--- a/compat/zlib/msdos/Makefile.emx
+++ b/compat/zlib/msdos/Makefile.emx
@@ -11,7 +11,7 @@ CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
+#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
diff --git a/compat/zlib/old/Makefile.emx b/compat/zlib/old/Makefile.emx
index 4d6ab0e..612b037 100644
--- a/compat/zlib/old/Makefile.emx
+++ b/compat/zlib/old/Makefile.emx
@@ -11,7 +11,7 @@ CC=gcc -Zwin32
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
+#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
diff --git a/compat/zlib/old/os2/Makefile.os2 b/compat/zlib/old/os2/Makefile.os2
index a105aaa..bb426c0 100644
--- a/compat/zlib/old/os2/Makefile.os2
+++ b/compat/zlib/old/os2/Makefile.os2
@@ -14,7 +14,7 @@ CC=gcc -Zomf -s
CFLAGS=-O6 -Wall
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
+#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
diff --git a/compat/zlib/os400/README400 b/compat/zlib/os400/README400
new file mode 100644
index 0000000..4f98334
--- /dev/null
+++ b/compat/zlib/os400/README400
@@ -0,0 +1,48 @@
+ ZLIB version 1.2.11 for OS/400 installation instructions
+
+1) Download and unpack the zlib tarball to some IFS directory.
+ (i.e.: /path/to/the/zlib/ifs/source/directory)
+
+ If the installed IFS command suppors gzip format, this is straightforward,
+else you have to unpack first to some directory on a system supporting it,
+then move the whole directory to the IFS via the network (via SMB or FTP).
+
+2) Edit the configuration parameters in the compilation script.
+
+ EDTF STMF('/path/to/the/zlib/ifs/source/directory/os400/make.sh')
+
+Tune the parameters according to your needs if not matching the defaults.
+Save the file and exit after edition.
+
+3) Enter qshell, then work in the zlib OS/400 specific directory.
+
+ QSH
+ cd /path/to/the/zlib/ifs/source/directory/os400
+
+4) Compile and install
+
+ sh make.sh
+
+The script will:
+- create the libraries, objects and IFS directories for the zlib environment,
+- compile all modules,
+- create a service program,
+- create a static and a dynamic binding directory,
+- install header files for C/C++ and for ILE/RPG, both for compilation in
+ DB2 and IFS environments.
+
+That's all.
+
+
+Notes: For OS/400 ILE RPG programmers, a /copy member defining the ZLIB
+ API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC).
+ In the ILE environment, the same definitions are available from
+ file zlib.inc located in the same IFS include directory as the
+ C/C++ header files.
+ Please read comments in this member for more information.
+
+ Remember that most foreign textual data are ASCII coded: this
+ implementation does not handle conversion from/to ASCII, so
+ text data code conversions must be done explicitely.
+
+ Mainly for the reason above, always open zipped files in binary mode.
diff --git a/compat/zlib/os400/bndsrc b/compat/zlib/os400/bndsrc
new file mode 100644
index 0000000..5e6e0a2
--- /dev/null
+++ b/compat/zlib/os400/bndsrc
@@ -0,0 +1,119 @@
+STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.1.3 entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("adler32")
+ EXPORT SYMBOL("compress")
+ EXPORT SYMBOL("compress2")
+ EXPORT SYMBOL("crc32")
+ EXPORT SYMBOL("get_crc_table")
+ EXPORT SYMBOL("deflate")
+ EXPORT SYMBOL("deflateEnd")
+ EXPORT SYMBOL("deflateSetDictionary")
+ EXPORT SYMBOL("deflateCopy")
+ EXPORT SYMBOL("deflateReset")
+ EXPORT SYMBOL("deflateParams")
+ EXPORT SYMBOL("deflatePrime")
+ EXPORT SYMBOL("deflateInit_")
+ EXPORT SYMBOL("deflateInit2_")
+ EXPORT SYMBOL("gzopen")
+ EXPORT SYMBOL("gzdopen")
+ EXPORT SYMBOL("gzsetparams")
+ EXPORT SYMBOL("gzread")
+ EXPORT SYMBOL("gzwrite")
+ EXPORT SYMBOL("gzprintf")
+ EXPORT SYMBOL("gzputs")
+ EXPORT SYMBOL("gzgets")
+ EXPORT SYMBOL("gzputc")
+ EXPORT SYMBOL("gzgetc")
+ EXPORT SYMBOL("gzflush")
+ EXPORT SYMBOL("gzseek")
+ EXPORT SYMBOL("gzrewind")
+ EXPORT SYMBOL("gztell")
+ EXPORT SYMBOL("gzeof")
+ EXPORT SYMBOL("gzclose")
+ EXPORT SYMBOL("gzerror")
+ EXPORT SYMBOL("inflate")
+ EXPORT SYMBOL("inflateEnd")
+ EXPORT SYMBOL("inflateSetDictionary")
+ EXPORT SYMBOL("inflateSync")
+ EXPORT SYMBOL("inflateReset")
+ EXPORT SYMBOL("inflateInit_")
+ EXPORT SYMBOL("inflateInit2_")
+ EXPORT SYMBOL("inflateSyncPoint")
+ EXPORT SYMBOL("uncompress")
+ EXPORT SYMBOL("zlibVersion")
+ EXPORT SYMBOL("zError")
+ EXPORT SYMBOL("z_errmsg")
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.2.1 additional entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("compressBound")
+ EXPORT SYMBOL("deflateBound")
+ EXPORT SYMBOL("deflatePending")
+ EXPORT SYMBOL("gzungetc")
+ EXPORT SYMBOL("gzclearerr")
+ EXPORT SYMBOL("inflateBack")
+ EXPORT SYMBOL("inflateBackEnd")
+ EXPORT SYMBOL("inflateBackInit_")
+ EXPORT SYMBOL("inflateCopy")
+ EXPORT SYMBOL("zlibCompileFlags")
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.2.4 additional entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("adler32_combine")
+ EXPORT SYMBOL("adler32_combine64")
+ EXPORT SYMBOL("crc32_combine")
+ EXPORT SYMBOL("crc32_combine64")
+ EXPORT SYMBOL("deflateSetHeader")
+ EXPORT SYMBOL("deflateTune")
+ EXPORT SYMBOL("gzbuffer")
+ EXPORT SYMBOL("gzclose_r")
+ EXPORT SYMBOL("gzclose_w")
+ EXPORT SYMBOL("gzdirect")
+ EXPORT SYMBOL("gzoffset")
+ EXPORT SYMBOL("gzoffset64")
+ EXPORT SYMBOL("gzopen64")
+ EXPORT SYMBOL("gzseek64")
+ EXPORT SYMBOL("gztell64")
+ EXPORT SYMBOL("inflateGetHeader")
+ EXPORT SYMBOL("inflateMark")
+ EXPORT SYMBOL("inflatePrime")
+ EXPORT SYMBOL("inflateReset2")
+ EXPORT SYMBOL("inflateUndermine")
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.2.6 additional entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("deflateResetKeep")
+ EXPORT SYMBOL("gzgetc_")
+ EXPORT SYMBOL("inflateResetKeep")
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.2.8 additional entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("gzvprintf")
+ EXPORT SYMBOL("inflateGetDictionary")
+
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+/* Version 1.2.9 additional entry points. */
+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ EXPORT SYMBOL("adler32_z")
+ EXPORT SYMBOL("crc32_z")
+ EXPORT SYMBOL("deflateGetDictionary")
+ EXPORT SYMBOL("gzfread")
+ EXPORT SYMBOL("gzfwrite")
+ EXPORT SYMBOL("inflateCodesUsed")
+ EXPORT SYMBOL("inflateValidate")
+ EXPORT SYMBOL("uncompress2")
+
+ENDPGMEXP
diff --git a/compat/zlib/os400/make.sh b/compat/zlib/os400/make.sh
new file mode 100644
index 0000000..19eec11
--- /dev/null
+++ b/compat/zlib/os400/make.sh
@@ -0,0 +1,366 @@
+#!/bin/sh
+#
+# ZLIB compilation script for the OS/400.
+#
+#
+# This is a shell script since make is not a standard component of OS/400.
+
+
+################################################################################
+#
+# Tunable configuration parameters.
+#
+################################################################################
+
+TARGETLIB='ZLIB' # Target OS/400 program library
+STATBNDDIR='ZLIB_A' # Static binding directory.
+DYNBNDDIR='ZLIB' # Dynamic binding directory.
+SRVPGM="ZLIB" # Service program.
+IFSDIR='/zlib' # IFS support base directory.
+TGTCCSID='500' # Target CCSID of objects
+DEBUG='*NONE' # Debug level
+OPTIMIZE='40' # Optimisation level
+OUTPUT='*NONE' # Compilation output option.
+TGTRLS='V6R1M0' # Target OS release
+
+export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR
+export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS
+
+
+################################################################################
+#
+# OS/400 specific definitions.
+#
+################################################################################
+
+LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
+
+
+################################################################################
+#
+# Procedures.
+#
+################################################################################
+
+# action_needed dest [src]
+#
+# dest is an object to build
+# if specified, src is an object on which dest depends.
+#
+# exit 0 (succeeds) if some action has to be taken, else 1.
+
+action_needed()
+
+{
+ [ ! -e "${1}" ] && return 0
+ [ "${2}" ] || return 1
+ [ "${1}" -ot "${2}" ] && return 0
+ return 1
+}
+
+
+# make_module module_name source_name [additional_definitions]
+#
+# Compile source name into module if needed.
+# As side effect, append the module name to variable MODULES.
+# Set LINK to "YES" if the module has been compiled.
+
+make_module()
+
+{
+ MODULES="${MODULES} ${1}"
+ MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
+ CSRC="`basename \"${2}\"`"
+
+ if action_needed "${MODIFSNAME}" "${2}"
+ then :
+ elif [ ! "`sed -e \"/<source name=\\\"${CSRC}\\\">/,/<\\\\/source>/!d\" \
+ -e '/<depend /!d' \
+ -e 's/.* name=\"\\([^\"]*\\)\".*/\\1/' < \"${TOPDIR}/treebuild.xml\" |
+ while read HDR
+ do if action_needed \"${MODIFSNAME}\" \"${IFSDIR}/include/${HDR}\"
+ then echo recompile
+ break
+ fi
+ done`" ]
+ then return 0
+ fi
+
+ CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('${2}')"
+ CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
+ CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
+ CMD="${CMD} INCDIR('${IFSDIR}/include' ${INCLUDES})"
+ CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
+ CMD="${CMD} OUTPUT(${OUTPUT})"
+ CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
+ CMD="${CMD} DBGVIEW(${DEBUG})"
+ system "${CMD}"
+ LINK=YES
+}
+
+
+# Determine DB2 object name from IFS name.
+
+db2_name()
+
+{
+ basename "${1}" |
+ tr 'a-z-' 'A-Z_' |
+ sed -e 's/\..*//' \
+ -e 's/^\(.\).*\(.........\)$/\1\2/'
+}
+
+
+# Force enumeration types to be the same size as integers.
+
+copy_hfile()
+
+{
+ sed -e '1i\
+#pragma enum(int)\
+' "${@}" -e '$a\
+#pragma enum(pop)\
+'
+}
+
+
+################################################################################
+#
+# Script initialization.
+#
+################################################################################
+
+SCRIPTDIR=`dirname "${0}"`
+
+case "${SCRIPTDIR}" in
+/*) ;;
+*) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
+esac
+
+while true
+do case "${SCRIPTDIR}" in
+ */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
+ *) break;;
+ esac
+done
+
+# The script directory is supposed to be in ${TOPDIR}/os400.
+
+TOPDIR=`dirname "${SCRIPTDIR}"`
+export SCRIPTDIR TOPDIR
+cd "${TOPDIR}"
+
+
+# Extract the version from the master compilation XML file.
+
+VERSION=`sed -e '/^<package /!d' \
+ -e 's/^.* version="\([0-9.]*\)".*$/\1/' -e 'q' \
+ < treebuild.xml`
+export VERSION
+
+################################################################################
+
+
+# Create the OS/400 library if it does not exist.
+
+if action_needed "${LIBIFSNAME}"
+then CMD="CRTLIB LIB(${TARGETLIB}) TEXT('ZLIB: Data compression API')"
+ system "${CMD}"
+fi
+
+
+# Create the DOCS source file if it does not exist.
+
+if action_needed "${LIBIFSNAME}/DOCS.FILE"
+then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(112)"
+ CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
+ system "${CMD}"
+fi
+
+# Copy some documentation files if needed.
+
+for TEXT in "${TOPDIR}/ChangeLog" "${TOPDIR}/FAQ" \
+ "${TOPDIR}/README" "${SCRIPTDIR}/README400"
+do MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${TEXT}\"`.MBR"
+
+ if action_needed "${MEMBER}" "${TEXT}"
+ then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
+ CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
+ system "${CMD}"
+ fi
+done
+
+
+# Create the OS/400 source program file for the C header files.
+
+SRCPF="${LIBIFSNAME}/H.FILE"
+
+if action_needed "${SRCPF}"
+then CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
+ CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: C/C++ header files')"
+ system "${CMD}"
+fi
+
+
+# Create the IFS directory for the C header files.
+
+if action_needed "${IFSDIR}/include"
+then mkdir -p "${IFSDIR}/include"
+fi
+
+# Copy the header files to DB2 library. Link from IFS include directory.
+
+for HFILE in "${TOPDIR}/"*.h
+do DEST="${SRCPF}/`db2_name \"${HFILE}\"`.MBR"
+
+ if action_needed "${DEST}" "${HFILE}"
+ then copy_hfile < "${HFILE}" > tmphdrfile
+
+ # Need to translate to target CCSID.
+
+ CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
+ CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
+ system "${CMD}"
+ # touch -r "${HFILE}" "${DEST}"
+ rm -f tmphdrfile
+ fi
+
+ IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"
+
+ if action_needed "${IFSFILE}" "${DEST}"
+ then rm -f "${IFSFILE}"
+ ln -s "${DEST}" "${IFSFILE}"
+ fi
+done
+
+
+# Install the ILE/RPG header file.
+
+
+HFILE="${SCRIPTDIR}/zlib.inc"
+DEST="${SRCPF}/ZLIB.INC.MBR"
+
+if action_needed "${DEST}" "${HFILE}"
+then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')"
+ CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
+ system "${CMD}"
+ # touch -r "${HFILE}" "${DEST}"
+fi
+
+IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"
+
+if action_needed "${IFSFILE}" "${DEST}"
+then rm -f "${IFSFILE}"
+ ln -s "${DEST}" "${IFSFILE}"
+fi
+
+
+# Create and compile the identification source file.
+
+echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c
+echo '#pragma comment(user, __DATE__)' >> os400.c
+echo '#pragma comment(user, __TIME__)' >> os400.c
+echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c
+make_module OS400 os400.c
+LINK= # No need to rebuild service program yet.
+MODULES=
+
+
+# Get source list.
+
+CSOURCES=`sed -e '/<source name="/!d' \
+ -e 's/.* name="\([^"]*\)".*/\1/' < treebuild.xml`
+
+# Compile the sources into modules.
+
+for SRC in ${CSOURCES}
+do MODULE=`db2_name "${SRC}"`
+ make_module "${MODULE}" "${SRC}"
+done
+
+
+# If needed, (re)create the static binding directory.
+
+if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
+then LINK=YES
+fi
+
+if [ "${LINK}" ]
+then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
+ CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
+ CMD="${CMD} TEXT('ZLIB static binding directory')"
+ system "${CMD}"
+
+ for MODULE in ${MODULES}
+ do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
+ CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
+ system "${CMD}"
+ done
+fi
+
+
+# The exportation file for service program creation must be in a DB2
+# source file, so make sure it exists.
+
+if action_needed "${LIBIFSNAME}/TOOLS.FILE"
+then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
+ CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: build tools')"
+ system "${CMD}"
+fi
+
+
+DEST="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
+
+if action_needed "${SCRIPTDIR}/bndsrc" "${DEST}"
+then CMD="CPY OBJ('${SCRIPTDIR}/bndsrc') TOOBJ('${DEST}')"
+ CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
+ system "${CMD}"
+ # touch -r "${SCRIPTDIR}/bndsrc" "${DEST}"
+ LINK=YES
+fi
+
+
+# Build the service program if needed.
+
+if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
+then LINK=YES
+fi
+
+if [ "${LINK}" ]
+then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
+ CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
+ CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
+ CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR})"
+ CMD="${CMD} TEXT('ZLIB ${VERSION} dynamic library')"
+ CMD="${CMD} TGTRLS(${TGTRLS})"
+ system "${CMD}"
+ LINK=YES
+
+ # Duplicate the service program for a versioned backup.
+
+ BACKUP=`echo "${SRVPGM}${VERSION}" |
+ sed -e 's/.*\(..........\)$/\1/' -e 's/\./_/g'`
+ BACKUP="`db2_name \"${BACKUP}\"`"
+ BKUPIFSNAME="${LIBIFSNAME}/${BACKUP}.SRVPGM"
+ rm -f "${BKUPIFSNAME}"
+ CMD="CRTDUPOBJ OBJ(${SRVPGM}) FROMLIB(${TARGETLIB})"
+ CMD="${CMD} OBJTYPE(*SRVPGM) NEWOBJ(${BACKUP})"
+ system "${CMD}"
+fi
+
+
+# If needed, (re)create the dynamic binding directory.
+
+if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
+then LINK=YES
+fi
+
+if [ "${LINK}" ]
+then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
+ CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
+ CMD="${CMD} TEXT('ZLIB dynamic binding directory')"
+ system "${CMD}"
+ CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
+ CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
+ system "${CMD}"
+fi
diff --git a/compat/zlib/as400/zlib.inc b/compat/zlib/os400/zlib.inc
index 7341a6d..c6aca2c 100644
--- a/compat/zlib/as400/zlib.inc
+++ b/compat/zlib/os400/zlib.inc
@@ -1,7 +1,7 @@
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
- * Version 1.2.8
+ * Version 1.2.11
*
*
* WARNING:
@@ -22,12 +22,12 @@
*
* Versioning information.
*
- D ZLIB_VERSION C '1.2.8'
- D ZLIB_VERNUM C X'1280'
+ D ZLIB_VERSION C '1.2.11'
+ D ZLIB_VERNUM C X'12a0'
D ZLIB_VER_MAJOR C 1
D ZLIB_VER_MINOR C 2
D ZLIB_VER_REVISION...
- D C 8
+ D C 11
D ZLIB_VER_SUBREVISION...
D C 0
*
@@ -50,7 +50,7 @@
D Z_DATA_ERROR C -3
D Z_MEM_ERROR C -4
D Z_BUF_ERROR C -5
- DZ_VERSION_ERROR C -6
+ D Z_VERSION_ERROR C -6
*
D Z_NO_COMPRESSION...
D C 0
@@ -80,6 +80,7 @@
*
D z_streamp S * Stream struct ptr
D gzFile S * File pointer
+ D gz_headerp S *
D z_off_t S 10i 0 Stream offsets
D z_off64_t S 20i 0 Stream offsets
*
@@ -132,6 +133,12 @@
D source 65535 const options(*varsize) Source buffer
D sourceLen 10U 0 value Source length
*
+ D uncompress2 PR 10I 0 extproc('uncompress2')
+ D dest 65535 options(*varsize) Destination buffer
+ D destLen 10U 0 Destination length
+ D source 65535 const options(*varsize) Source buffer
+ D sourceLen 10U 0 Source length
+ *
/if not defined(LARGE_FILES)
D gzopen PR extproc('gzopen')
D like(gzFile)
@@ -168,11 +175,23 @@
D buf 65535 options(*varsize) Buffer
D len 10u 0 value Buffer length
*
+ D gzfread PR 20I 0 extproc('gzfread')
+ D buf 65535 options(*varsize) Buffer
+ D size 20u 0 value Buffer length
+ D nitems 20u 0 value Buffer length
+ D file value like(gzFile) File pointer
+ *
D gzwrite PR 10I 0 extproc('gzwrite')
D file value like(gzFile) File pointer
D buf 65535 const options(*varsize) Buffer
D len 10u 0 value Buffer length
*
+ D gzfwrite PR 20I 0 extproc('gzfwrite')
+ D buf 65535 options(*varsize) Buffer
+ D size 20u 0 value Buffer length
+ D nitems 20u 0 value Buffer length
+ D file value like(gzFile) File pointer
+ *
D gzputs PR 10I 0 extproc('gzputs')
D file value like(gzFile) File pointer
D s * value options(*string) String to output
@@ -254,6 +273,9 @@
D gzeof PR 10i 0 extproc('gzeof')
D file value like(gzFile) File pointer
*
+ D gzdirect PR 10i 0 extproc('gzdirect')
+ D file value like(gzFile) File pointer
+ *
D gzclose_r PR 10i 0 extproc('gzclose_r')
D file value like(gzFile) File pointer
*
@@ -311,7 +333,7 @@
D method 10I 0 value Compression method
D windowBits 10I 0 value log2(window size)
D memLevel 10I 0 value Mem/cmpress tradeoff
- D strategy 10I 0 value Compression stategy
+ D strategy 10I 0 value Compression strategy
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
@@ -331,7 +353,14 @@
D deflateParams PR 10I 0 extproc('deflateParams') Change level & strat
D strm like(z_stream) Compression stream
D level 10I 0 value Compression level
- D strategy 10I 0 value Compression stategy
+ D strategy 10I 0 value Compression strategy
+ *
+ D deflateTune PR 10I 0 extproc('deflateTune')
+ D strm like(z_stream) Compression stream
+ D good 10I 0 value
+ D lazy 10I 0 value
+ D nice 10I 0 value
+ D chain 10I 0 value
*
D deflateBound PR 10U 0 extproc('deflateBound') Change level & strat
D strm like(z_stream) Compression stream
@@ -365,6 +394,12 @@
D dictionary 65535 options(*varsize) Dictionary bytes
D dictLength 10U 0 Dictionary length
*
+ D deflateGetDictionary...
+ D PR 10I 0 extproc('deflateGetDictionary') Get dictionary
+ D strm like(z_stream) Expansion stream
+ D dictionary 65535 options(*varsize) Dictionary bytes
+ D dictLength 10U 0 Dictionary length
+ *
D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion
D strm like(z_stream) Expansion stream
*
@@ -387,6 +422,25 @@
D inflateMark PR 10I 0 extproc('inflateMark') Get inflate info
D strm like(z_stream) Expansion stream
*
+ D inflateCodesUsed...
+ PR 20U 0 extproc('inflateCodesUsed')
+ D strm like(z_stream) Expansion stream
+ *
+ D inflateValidate...
+ PR 20U 0 extproc('inflateValidate')
+ D strm like(z_stream) Expansion stream
+ D check 10I 0 value
+ *
+ D inflateGetHeader...
+ PR 10U 0 extproc('inflateGetHeader')
+ D strm like(z_stream) Expansion stream
+ D head like(gz_headerp)
+ *
+ D deflateSetHeader...
+ PR 10U 0 extproc('deflateSetHeader')
+ D strm like(z_stream) Expansion stream
+ D head like(gz_headerp)
+ *
D inflateBackInit...
D PR 10I 0 extproc('inflateBackInit_')
D strm like(z_stream) Expansion stream
@@ -417,11 +471,33 @@
D buf 65535 const options(*varsize) Bytes to accumulate
D len 10U 0 value Buffer length
*
+ D adler32_combine...
+ PR 10U 0 extproc('adler32_combine') New checksum
+ D adler1 10U 0 value Old checksum
+ D adler2 10U 0 value Old checksum
+ D len2 20U 0 value Buffer length
+ *
+ D adler32_z PR 10U 0 extproc('adler32_z') New checksum
+ D adler 10U 0 value Old checksum
+ D buf 65535 const options(*varsize) Bytes to accumulate
+ D len 20U 0 value Buffer length
+ *
D crc32 PR 10U 0 extproc('crc32') New checksum
D crc 10U 0 value Old checksum
D buf 65535 const options(*varsize) Bytes to accumulate
D len 10U 0 value Buffer length
*
+ D crc32_combine...
+ PR 10U 0 extproc('crc32_combine') New checksum
+ D crc1 10U 0 value Old checksum
+ D crc2 10U 0 value Old checksum
+ D len2 20U 0 value Buffer length
+ *
+ D crc32_z PR 10U 0 extproc('crc32_z') New checksum
+ D crc 10U 0 value Old checksum
+ D buf 65535 const options(*varsize) Bytes to accumulate
+ D len 20U 0 value Buffer length
+ *
**************************************************************************
* Miscellaneous function prototypes
**************************************************************************
diff --git a/compat/zlib/qnx/package.qpg b/compat/zlib/qnx/package.qpg
index aebf6e3..31e8e90 100644
--- a/compat/zlib/qnx/package.qpg
+++ b/compat/zlib/qnx/package.qpg
@@ -25,10 +25,10 @@
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
- <QPG:Add file="../libz.so.1.2.8" install="/opt/lib/" user="root:bin" permission="644"/>
- <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.8"/>
- <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.8"/>
- <QPG:Add file="../libz.so.1.2.8" install="/opt/lib/" component="slib"/>
+ <QPG:Add file="../libz.so.1.2.11" install="/opt/lib/" user="root:bin" permission="644"/>
+ <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.11"/>
+ <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.11"/>
+ <QPG:Add file="../libz.so.1.2.11" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
@@ -63,7 +63,7 @@
</QPM:ProductDescription>
<QPM:ReleaseDescription>
- <QPM:ReleaseVersion>1.2.8</QPM:ReleaseVersion>
+ <QPM:ReleaseVersion>1.2.11</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
diff --git a/compat/zlib/test/example.c b/compat/zlib/test/example.c
index 138a699..eee17ce 100644
--- a/compat/zlib/test/example.c
+++ b/compat/zlib/test/example.c
@@ -1,5 +1,5 @@
/* example.c -- usage example of the zlib compression library
- * Copyright (C) 1995-2006, 2011 Jean-loup Gailly.
+ * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -26,13 +26,13 @@
} \
}
-z_const char hello[] = "hello, hello!";
+static z_const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
-const char dictionary[] = "hello";
-uLong dictId; /* Adler32 value of the dictionary */
+static const char dictionary[] = "hello";
+static uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
@@ -59,13 +59,13 @@ void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
- q = Z_NULL;
+ (void)q;
return calloc(n, m);
}
void myfree(void *q, void *p)
{
- q = Z_NULL;
+ (void)q;
free(p);
}
@@ -432,7 +432,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
- inflate(&d_stream, Z_NO_FLUSH);
+ err = inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
@@ -573,7 +573,8 @@ int main(argc, argv)
}
#ifdef Z_SOLO
- argc = strlen(argv[0]);
+ (void)argc;
+ (void)argv;
#else
test_compress(compr, comprLen, uncompr, uncomprLen);
diff --git a/compat/zlib/test/infcover.c b/compat/zlib/test/infcover.c
index fe3d920..2be0164 100644
--- a/compat/zlib/test/infcover.c
+++ b/compat/zlib/test/infcover.c
@@ -1,5 +1,5 @@
/* infcover.c -- test zlib's inflate routines with full code coverage
- * Copyright (C) 2011 Mark Adler
+ * Copyright (C) 2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -237,14 +237,14 @@ local void mem_done(z_stream *strm, char *prefix)
/* Decode a hexadecimal string, set *len to length, in[] to the bytes. This
decodes liberally, in that hex digits can be adjacent, in which case two in
- a row writes a byte. Or they can delimited by any non-hex character, where
- the delimiters are ignored except when a single hex digit is followed by a
- delimiter in which case that single digit writes a byte. The returned
- data is allocated and must eventually be freed. NULL is returned if out of
- memory. If the length is not needed, then len can be NULL. */
+ a row writes a byte. Or they can be delimited by any non-hex character,
+ where the delimiters are ignored except when a single hex digit is followed
+ by a delimiter, where that single digit writes a byte. The returned data is
+ allocated and must eventually be freed. NULL is returned if out of memory.
+ If the length is not needed, then len can be NULL. */
local unsigned char *h2b(const char *hex, unsigned *len)
{
- unsigned char *in;
+ unsigned char *in, *re;
unsigned next, val;
in = malloc((strlen(hex) + 1) >> 1);
@@ -268,8 +268,8 @@ local unsigned char *h2b(const char *hex, unsigned *len)
} while (*hex++); /* go through the loop with the terminating null */
if (len != NULL)
*len = next;
- in = reallocf(in, next);
- return in;
+ re = realloc(in, next);
+ return re == NULL ? in : re;
}
/* generic inflate() run, where hex is the hexadecimal input data, what is the
diff --git a/compat/zlib/test/minigzip.c b/compat/zlib/test/minigzip.c
index b3025a4..e22fb08 100644
--- a/compat/zlib/test/minigzip.c
+++ b/compat/zlib/test/minigzip.c
@@ -1,5 +1,5 @@
/* minigzip.c -- simulate gzip using the zlib compression library
- * Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly.
+ * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -40,7 +40,7 @@
# define SET_BINARY_MODE(file)
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif
@@ -156,14 +156,14 @@ void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
- q = Z_NULL;
+ (void)q;
return calloc(n, m);
}
void myfree(q, p)
void *q, *p;
{
- q = Z_NULL;
+ (void)q;
free(p);
}
@@ -333,7 +333,7 @@ const char *gzerror(gz, err)
#endif
-char *prog;
+static char *prog;
void error OF((const char *msg));
void gz_compress OF((FILE *in, gzFile out));
@@ -500,7 +500,7 @@ void file_uncompress(file)
char *infile, *outfile;
FILE *out;
gzFile in;
- size_t len = strlen(file);
+ unsigned len = strlen(file);
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
fprintf(stderr, "%s: filename too long\n", prog);
diff --git a/compat/zlib/treebuild.xml b/compat/zlib/treebuild.xml
index 38d29d7..fd75525 100644
--- a/compat/zlib/treebuild.xml
+++ b/compat/zlib/treebuild.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
-<package name="zlib" version="1.2.8">
- <library name="zlib" dlversion="1.2.8" dlname="z">
+<package name="zlib" version="1.2.11">
+ <library name="zlib" dlversion="1.2.11" dlname="z">
<property name="description"> zip compression library </property>
<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />
@@ -101,7 +101,7 @@
<!--
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
+#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
diff --git a/compat/zlib/trees.c b/compat/zlib/trees.c
index 1fd7759..50cf4b4 100644
--- a/compat/zlib/trees.c
+++ b/compat/zlib/trees.c
@@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2012 Jean-loup Gailly
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -36,7 +36,7 @@
#include "deflate.h"
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
# include <ctype.h>
#endif
@@ -122,13 +122,13 @@ struct static_tree_desc_s {
int max_length; /* max bit length for the codes */
};
-local static_tree_desc static_l_desc =
+local const static_tree_desc static_l_desc =
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-local static_tree_desc static_d_desc =
+local const static_tree_desc static_d_desc =
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-local static_tree_desc static_bl_desc =
+local const static_tree_desc static_bl_desc =
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
/* ===========================================================================
@@ -152,18 +152,16 @@ local int detect_data_type OF((deflate_state *s));
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
#ifdef GEN_TREES_H
local void gen_trees_header OF((void));
#endif
-#ifndef DEBUG
+#ifndef ZLIB_DEBUG
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */
-#else /* DEBUG */
+#else /* !ZLIB_DEBUG */
# define send_code(s, c, tree) \
{ if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
send_bits(s, tree[c].Code, tree[c].Len); }
@@ -182,7 +180,7 @@ local void gen_trees_header OF((void));
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length)
@@ -208,12 +206,12 @@ local void send_bits(s, value, length)
s->bi_valid += length;
}
}
-#else /* !DEBUG */
+#else /* !ZLIB_DEBUG */
#define send_bits(s, value, length) \
{ int len = length;\
if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
+ int val = (int)value;\
s->bi_buf |= (ush)val << s->bi_valid;\
put_short(s, s->bi_buf);\
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
@@ -223,7 +221,7 @@ local void send_bits(s, value, length)
s->bi_valid += len;\
}\
}
-#endif /* DEBUG */
+#endif /* ZLIB_DEBUG */
/* the arguments must not have side effects */
@@ -317,7 +315,7 @@ local void tr_static_init()
* Genererate the file trees.h describing the static trees.
*/
#ifdef GEN_TREES_H
-# ifndef DEBUG
+# ifndef ZLIB_DEBUG
# include <stdio.h>
# endif
@@ -394,7 +392,7 @@ void ZLIB_INTERNAL _tr_init(s)
s->bi_buf = 0;
s->bi_valid = 0;
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
@@ -522,12 +520,12 @@ local void gen_bitlen(s, desc)
xbits = 0;
if (n >= base) xbits = extra[n-base];
f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
+ s->opt_len += (ulg)f * (unsigned)(bits + xbits);
+ if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
}
if (overflow == 0) return;
- Trace((stderr,"\nbit length overflow\n"));
+ Tracev((stderr,"\nbit length overflow\n"));
/* This happens for example on obj2 and pic of the Calgary corpus */
/* Find the first bit length which could increase: */
@@ -554,9 +552,8 @@ local void gen_bitlen(s, desc)
m = s->heap[--h];
if (m > max_code) continue;
if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
+ Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
+ s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;
tree[m].Len = (ush)bits;
}
n--;
@@ -578,7 +575,7 @@ local void gen_codes (tree, max_code, bl_count)
ushf *bl_count; /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
+ unsigned code = 0; /* running code value */
int bits; /* bit index */
int n; /* code index */
@@ -586,7 +583,8 @@ local void gen_codes (tree, max_code, bl_count)
* without bit reversal.
*/
for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
+ code = (code + bl_count[bits-1]) << 1;
+ next_code[bits] = (ush)code;
}
/* Check that the bit counts in bl_count are consistent. The last code
* must be all ones.
@@ -599,7 +597,7 @@ local void gen_codes (tree, max_code, bl_count)
int len = tree[n].Len;
if (len == 0) continue;
/* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
+ tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
@@ -821,7 +819,7 @@ local int build_bl_tree(s)
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
}
/* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
+ s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
s->opt_len, s->static_len));
@@ -869,11 +867,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
int last; /* one if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
-#ifdef DEBUG
+ bi_windup(s); /* align on byte boundary */
+ put_short(s, (ush)stored_len);
+ put_short(s, (ush)~stored_len);
+ zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
+ s->pending += stored_len;
+#ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3;
+ s->bits_sent += 2*16;
+ s->bits_sent += stored_len<<3;
#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
}
/* ===========================================================================
@@ -894,7 +898,7 @@ void ZLIB_INTERNAL _tr_align(s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif
bi_flush(s);
@@ -902,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s)
/* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
+ * trees or store, and write out the encoded block.
*/
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
deflate_state *s;
@@ -974,7 +978,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
send_bits(s, (STATIC_TREES<<1)+last, 3);
compress_block(s, (const ct_data *)static_ltree,
(const ct_data *)static_dtree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->static_len;
#endif
} else {
@@ -983,7 +987,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
max_blindex+1);
compress_block(s, (const ct_data *)s->dyn_ltree,
(const ct_data *)s->dyn_dtree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->opt_len;
#endif
}
@@ -995,7 +999,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
if (last) {
bi_windup(s);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
@@ -1090,7 +1094,7 @@ local void compress_block(s, ltree, dtree)
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
- dist -= base_dist[code];
+ dist -= (unsigned)base_dist[code];
send_bits(s, dist, extra); /* send the extra distance bits */
}
} /* literal or match pair ? */
@@ -1193,34 +1197,7 @@ local void bi_windup(s)
}
s->bi_buf = 0;
s->bi_valid = 0;
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent+7) & ~7;
#endif
}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff --git a/compat/zlib/uncompr.c b/compat/zlib/uncompr.c
index 242e949..f03a1a8 100644
--- a/compat/zlib/uncompr.c
+++ b/compat/zlib/uncompr.c
@@ -1,5 +1,5 @@
/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
+ * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,51 +9,85 @@
#include "zlib.h"
/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
+ Decompresses the source buffer into the destination buffer. *sourceLen is
+ the byte length of the source buffer. Upon entry, *destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit,
+ *destLen is the size of the decompressed data and *sourceLen is the number
+ of source bytes consumed. Upon return, source + *sourceLen points to the
+ first unused input byte.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
+ Z_DATA_ERROR if the input data was corrupted, including if the input data is
+ an incomplete zlib stream.
*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
+int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
- uLong sourceLen;
+ uLong *sourceLen;
{
z_stream stream;
int err;
+ const uInt max = (uInt)-1;
+ uLong len, left;
+ Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+ len = *sourceLen;
+ if (*destLen) {
+ left = *destLen;
+ *destLen = 0;
+ }
+ else {
+ left = 1;
+ dest = buf;
+ }
+ stream.next_in = (z_const Bytef *)source;
+ stream.avail_in = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
+ stream.opaque = (voidpf)0;
err = inflateInit(&stream);
if (err != Z_OK) return err;
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
+ stream.next_out = dest;
+ stream.avail_out = 0;
- err = inflateEnd(&stream);
- return err;
+ do {
+ if (stream.avail_out == 0) {
+ stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ left -= stream.avail_out;
+ }
+ if (stream.avail_in == 0) {
+ stream.avail_in = len > (uLong)max ? max : (uInt)len;
+ len -= stream.avail_in;
+ }
+ err = inflate(&stream, Z_NO_FLUSH);
+ } while (err == Z_OK);
+
+ *sourceLen -= len + stream.avail_in;
+ if (dest != buf)
+ *destLen = stream.total_out;
+ else if (stream.total_out && err == Z_BUF_ERROR)
+ left = 1;
+
+ inflateEnd(&stream);
+ return err == Z_STREAM_END ? Z_OK :
+ err == Z_NEED_DICT ? Z_DATA_ERROR :
+ err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
+ err;
+}
+
+int ZEXPORT uncompress (dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+{
+ return uncompress2(dest, destLen, source, &sourceLen);
}
diff --git a/compat/zlib/win32/Makefile.gcc b/compat/zlib/win32/Makefile.gcc
index 6d1ded6..305be50 100644
--- a/compat/zlib/win32/Makefile.gcc
+++ b/compat/zlib/win32/Makefile.gcc
@@ -39,7 +39,7 @@ IMPLIB = libz.dll.a
SHARED_MODE=0
#LOC = -DASMV
-#LOC = -DDEBUG -g
+#LOC = -DZLIB_DEBUG -g
PREFIX =
CC = $(PREFIX)gcc
diff --git a/compat/zlib/win32/Makefile.msc b/compat/zlib/win32/Makefile.msc
index 67b7731..6831882 100644
--- a/compat/zlib/win32/Makefile.msc
+++ b/compat/zlib/win32/Makefile.msc
@@ -1,5 +1,5 @@
# Makefile for zlib using Microsoft (Visual) C
-# zlib is copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler
+# zlib is copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
#
# Usage:
# nmake -f win32/Makefile.msc (standard build)
diff --git a/compat/zlib/win32/README-WIN32.txt b/compat/zlib/win32/README-WIN32.txt
index 3d77d52..df7ab7f 100644
--- a/compat/zlib/win32/README-WIN32.txt
+++ b/compat/zlib/win32/README-WIN32.txt
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.8 is a general purpose data compression library. All the code is
+zlib 1.2.11 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -22,7 +22,7 @@ before asking for help.
Manifest:
-The package zlib-1.2.8-win32-x86.zip will contain the following files:
+The package zlib-1.2.11-win32-x86.zip will contain the following files:
README-WIN32.txt This document
ChangeLog Changes since previous zlib packages
@@ -72,7 +72,7 @@ are too numerous to cite here.
Copyright notice:
- (C) 1995-2012 Jean-loup Gailly and Mark Adler
+ (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/compat/zlib/win32/README.txt b/compat/zlib/win32/README.txt
index 34a13b3..bd3d18d 100644
--- a/compat/zlib/win32/README.txt
+++ b/compat/zlib/win32/README.txt
@@ -6,7 +6,7 @@ What's here
Source
======
- zlib version 1.2.8
+ zlib version 1.2.11
available at http://www.gzip.org/zlib/
@@ -25,9 +25,9 @@ Build info
Contributed by Jan Nijtmans.
Compiler:
- i686-w64-mingw32-gcc (GCC) 4.5.3
+ i686-w64-mingw32-gcc (GCC) 5.4.0
Library:
- mingw64-i686-runtime/headers: 3.0b_svn5747-1
+ mingw64-i686-runtime/headers: 5.0.0
Build commands:
i686-w64-mingw32-gcc -c -DASMV contrib/asm686/match.S
i686-w64-mingw32-gcc -c -DASMINF -I. -O3 contrib/inflate86/inffas86.c
@@ -37,7 +37,7 @@ Build info
Copyright notice
================
- Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/compat/zlib/win32/USAGE.txt b/compat/zlib/win32/USAGE.txt
index 48e594e..22829eb 100644
--- a/compat/zlib/win32/USAGE.txt
+++ b/compat/zlib/win32/USAGE.txt
@@ -2,6 +2,9 @@
Installing ZLIB1.DLL
====================
Copy ZLIB1.DLL to the SYSTEM or the SYSTEM32 directory.
+
+ If you want to install the 32-bit dll on a 64-bit
+ machine, use the SysWOW64 directory instead.
Using ZLIB1.DLL with Microsoft Visual C++
@@ -20,12 +23,17 @@ Using ZLIB1.DLL with gcc/MinGW
1. Install the supplied header files "zlib.h" and "zconf.h"
into the INCLUDE directory.
- 2. Copy the supplied library file "zdll.lib" to "libzdll.a":
+ 2. (32-bit): Copy the supplied library file "zdll.lib" to "libzdll.a":
cp lib/zdll.lib lib/libzdll.a
OR
- 2' Build the import library from the supplied "zlib.def":
+ 2'. (64-bit): Copy the supplied library file "libz.dll.a" to "libzdll.a":
+ cp lib/libz.dll.a lib/libzdll.a
+
+ OR
+
+ 2'' Build the import library from the supplied "zlib.def":
dlltool -D zlib1.dll -d lib/zlib.def -l lib/libzdll.a
3. Install "libzdll.a" into the LIB directory.
diff --git a/compat/zlib/win32/VisualC.txt b/compat/zlib/win32/VisualC.txt
index 579a5fc..1005b21 100644
--- a/compat/zlib/win32/VisualC.txt
+++ b/compat/zlib/win32/VisualC.txt
@@ -1,3 +1,3 @@
To build zlib using the Microsoft Visual C++ environment,
-use the appropriate project from the projects/ directory.
+use the appropriate project from the contrib/vstudio/ directory.
diff --git a/compat/zlib/win32/zdll.lib b/compat/zlib/win32/zdll.lib
index 8e6f719..a3e9a39 100644..100755
--- a/compat/zlib/win32/zdll.lib
+++ b/compat/zlib/win32/zdll.lib
Binary files differ
diff --git a/compat/zlib/win32/zlib.def b/compat/zlib/win32/zlib.def
index face655..784b138 100644
--- a/compat/zlib/win32/zlib.def
+++ b/compat/zlib/win32/zlib.def
@@ -1,86 +1,94 @@
-; zlib data compression library
-EXPORTS
-; basic functions
- zlibVersion
- deflate
- deflateEnd
- inflate
- inflateEnd
-; advanced functions
- deflateSetDictionary
- deflateCopy
- deflateReset
- deflateParams
- deflateTune
- deflateBound
- deflatePending
- deflatePrime
- deflateSetHeader
- inflateSetDictionary
- inflateGetDictionary
- inflateSync
- inflateCopy
- inflateReset
- inflateReset2
- inflatePrime
- inflateMark
- inflateGetHeader
- inflateBack
- inflateBackEnd
- zlibCompileFlags
-; utility functions
- compress
- compress2
- compressBound
- uncompress
- gzopen
- gzdopen
- gzbuffer
- gzsetparams
- gzread
- gzwrite
- gzprintf
- gzvprintf
- gzputs
- gzgets
- gzputc
- gzgetc
- gzungetc
- gzflush
- gzseek
- gzrewind
- gztell
- gzoffset
- gzeof
- gzdirect
- gzclose
- gzclose_r
- gzclose_w
- gzerror
- gzclearerr
-; large file functions
- gzopen64
- gzseek64
- gztell64
- gzoffset64
- adler32_combine64
- crc32_combine64
-; checksum functions
- adler32
- crc32
- adler32_combine
- crc32_combine
-; various hacks, don't look :)
- deflateInit_
- deflateInit2_
- inflateInit_
- inflateInit2_
- inflateBackInit_
- gzgetc_
- zError
- inflateSyncPoint
- get_crc_table
- inflateUndermine
- inflateResetKeep
- deflateResetKeep
- gzopen_w
+; zlib data compression library
+EXPORTS
+; basic functions
+ zlibVersion
+ deflate
+ deflateEnd
+ inflate
+ inflateEnd
+; advanced functions
+ deflateSetDictionary
+ deflateGetDictionary
+ deflateCopy
+ deflateReset
+ deflateParams
+ deflateTune
+ deflateBound
+ deflatePending
+ deflatePrime
+ deflateSetHeader
+ inflateSetDictionary
+ inflateGetDictionary
+ inflateSync
+ inflateCopy
+ inflateReset
+ inflateReset2
+ inflatePrime
+ inflateMark
+ inflateGetHeader
+ inflateBack
+ inflateBackEnd
+ zlibCompileFlags
+; utility functions
+ compress
+ compress2
+ compressBound
+ uncompress
+ uncompress2
+ gzopen
+ gzdopen
+ gzbuffer
+ gzsetparams
+ gzread
+ gzfread
+ gzwrite
+ gzfwrite
+ gzprintf
+ gzvprintf
+ gzputs
+ gzgets
+ gzputc
+ gzgetc
+ gzungetc
+ gzflush
+ gzseek
+ gzrewind
+ gztell
+ gzoffset
+ gzeof
+ gzdirect
+ gzclose
+ gzclose_r
+ gzclose_w
+ gzerror
+ gzclearerr
+; large file functions
+ gzopen64
+ gzseek64
+ gztell64
+ gzoffset64
+ adler32_combine64
+ crc32_combine64
+; checksum functions
+ adler32
+ adler32_z
+ crc32
+ crc32_z
+ adler32_combine
+ crc32_combine
+; various hacks, don't look :)
+ deflateInit_
+ deflateInit2_
+ inflateInit_
+ inflateInit2_
+ inflateBackInit_
+ gzgetc_
+ zError
+ inflateSyncPoint
+ get_crc_table
+ inflateUndermine
+ inflateValidate
+ inflateCodesUsed
+ inflateResetKeep
+ deflateResetKeep
+ gzopen_w
diff --git a/compat/zlib/win32/zlib1.dll b/compat/zlib/win32/zlib1.dll
index 9ea38d5..3196f4a 100755
--- a/compat/zlib/win32/zlib1.dll
+++ b/compat/zlib/win32/zlib1.dll
Binary files differ
diff --git a/compat/zlib/win32/zlib1.rc b/compat/zlib/win32/zlib1.rc
index 5c0feed..234e641 100644
--- a/compat/zlib/win32/zlib1.rc
+++ b/compat/zlib/win32/zlib1.rc
@@ -26,7 +26,7 @@ BEGIN
VALUE "FileDescription", "zlib data compression library\0"
VALUE "FileVersion", ZLIB_VERSION "\0"
VALUE "InternalName", "zlib1.dll\0"
- VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0"
+ VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
VALUE "OriginalFilename", "zlib1.dll\0"
VALUE "ProductName", "zlib\0"
VALUE "ProductVersion", ZLIB_VERSION "\0"
diff --git a/compat/zlib/win64/libz.dll.a b/compat/zlib/win64/libz.dll.a
index a3ae403..93be06e 100644
--- a/compat/zlib/win64/libz.dll.a
+++ b/compat/zlib/win64/libz.dll.a
Binary files differ
diff --git a/compat/zlib/win64/zdll.lib b/compat/zlib/win64/zdll.lib
index ac9ffc9..c1be098 100644
--- a/compat/zlib/win64/zdll.lib
+++ b/compat/zlib/win64/zdll.lib
Binary files differ
diff --git a/compat/zlib/win64/zlib1.dll b/compat/zlib/win64/zlib1.dll
index bd1dbc6..81195c3 100755
--- a/compat/zlib/win64/zlib1.dll
+++ b/compat/zlib/win64/zlib1.dll
Binary files differ
diff --git a/compat/zlib/zconf.h b/compat/zlib/zconf.h
index 9987a77..5e1d68a 100644
--- a/compat/zlib/zconf.h
+++ b/compat/zlib/zconf.h
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -17,7 +17,7 @@
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
-/* all linked symbols */
+/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
@@ -29,6 +29,7 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
@@ -37,10 +38,14 @@
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
@@ -67,6 +72,8 @@
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
@@ -78,7 +85,6 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -89,32 +95,39 @@
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
+# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
@@ -224,9 +237,19 @@
# define z_const
#endif
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
@@ -256,7 +279,7 @@
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
diff --git a/compat/zlib/zconf.h.cmakein b/compat/zlib/zconf.h.cmakein
index 043019c..a7f24cc 100644
--- a/compat/zlib/zconf.h.cmakein
+++ b/compat/zlib/zconf.h.cmakein
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -19,7 +19,7 @@
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
-/* all linked symbols */
+/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
@@ -31,6 +31,7 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
@@ -39,10 +40,14 @@
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
@@ -69,6 +74,8 @@
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
@@ -80,7 +87,6 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -91,32 +97,39 @@
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
+# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
@@ -226,9 +239,19 @@
# define z_const
#endif
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
@@ -258,7 +281,7 @@
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
diff --git a/compat/zlib/zconf.h.in b/compat/zlib/zconf.h.in
index 9987a77..5e1d68a 100644
--- a/compat/zlib/zconf.h.in
+++ b/compat/zlib/zconf.h.in
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -17,7 +17,7 @@
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
-/* all linked symbols */
+/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
@@ -29,6 +29,7 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
@@ -37,10 +38,14 @@
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
@@ -67,6 +72,8 @@
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
@@ -78,7 +85,6 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -89,32 +95,39 @@
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
+# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
@@ -224,9 +237,19 @@
# define z_const
#endif
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
@@ -256,7 +279,7 @@
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
diff --git a/compat/zlib/zlib.3 b/compat/zlib/zlib.3
index 0160e62..bda4eb0 100644
--- a/compat/zlib/zlib.3
+++ b/compat/zlib/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "28 Apr 2013"
+.TH ZLIB 3 "15 Jan 2017"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -48,32 +48,10 @@ Changes to this version are documented in the file
that accompanies the source.
.LP
.I zlib
-is available in Java using the java.util.zip package:
-.IP
-http://java.sun.com/developer/technicalArticles/Programming/compression/
-.LP
-A Perl interface to
-.IR zlib ,
-written by Paul Marquess (pmqs@cpan.org),
-is available at CPAN (Comprehensive Perl Archive Network) sites,
-including:
-.IP
-http://search.cpan.org/~pmqs/IO-Compress-Zlib/
-.LP
-A Python interface to
-.IR zlib ,
-written by A.M. Kuchling (amk@magnet.com),
-is available in Python 1.5 and later versions:
-.IP
-http://docs.python.org/library/zlib.html
-.LP
-.I zlib
-is built into
-.IR tcl:
-.IP
-http://wiki.tcl.tk/4610
+is built in to many languages and operating systems, including but not limited to
+Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go.
.LP
-An experimental package to read and write files in .zip format,
+An experimental package to read and write files in the .zip format,
written on top of
.I zlib
by Gilles Vollant (info@winimage.com),
@@ -92,7 +70,9 @@ web site can be found at:
.IP
http://zlib.net/
.LP
-The data format used by the zlib library is described by RFC
+The data format used by the
+.I zlib
+library is described by RFC
(Request for Comments) 1950 to 1952 in the files:
.IP
http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format)
@@ -124,17 +104,35 @@ http://zlib.net/zlib_faq.html
before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
-.SH AUTHORS
-Version 1.2.8
-Copyright (C) 1995-2013 Jean-loup Gailly (jloup@gzip.org)
-and Mark Adler (madler@alumni.caltech.edu).
-.LP
-This software is provided "as-is,"
-without any express or implied warranty.
-In no event will the authors be held liable for any damages
+.SH AUTHORS AND LICENSE
+Version 1.2.11
+.LP
+Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+.LP
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
-See the distribution directory with respect to requirements
-governing redistribution.
+.LP
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+.LP
+.nr step 1 1
+.IP \n[step]. 3
+The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+.IP \n+[step].
+Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+.IP \n+[step].
+This notice may not be removed or altered from any source distribution.
+.LP
+Jean-loup Gailly Mark Adler
+.br
+jloup@gzip.org madler@alumni.caltech.edu
+.LP
The deflate format used by
.I zlib
was defined by Phil Katz.
diff --git a/compat/zlib/zlib.3.pdf b/compat/zlib/zlib.3.pdf
index a346b5d..6fa519c 100644
--- a/compat/zlib/zlib.3.pdf
+++ b/compat/zlib/zlib.3.pdf
Binary files differ
diff --git a/compat/zlib/zlib.h b/compat/zlib/zlib.h
index 3e0c767..f09cdaf 100644
--- a/compat/zlib/zlib.h
+++ b/compat/zlib/zlib.h
@@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.8, April 28th, 2013
+ version 1.2.11, January 15th, 2017
- Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -37,11 +37,11 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.8"
-#define ZLIB_VERNUM 0x1280
+#define ZLIB_VERSION "1.2.11"
+#define ZLIB_VERNUM 0x12b0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 8
+#define ZLIB_VER_REVISION 11
#define ZLIB_VER_SUBREVISION 0
/*
@@ -65,7 +65,8 @@ extern "C" {
with "gz". The gzip format is different from the zlib format. gzip is a
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
- This library can optionally read and write gzip streams in memory as well.
+ This library can optionally read and write gzip and raw deflate streams in
+ memory as well.
The zlib format was designed to be compact and fast for use in memory
and on communications channels. The gzip format was designed for single-
@@ -74,7 +75,7 @@ extern "C" {
The library does not install any signal handler. The decoder checks
the consistency of the compressed data, so the library should never crash
- even in case of corrupted input.
+ even in the case of corrupted input.
*/
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
@@ -87,7 +88,7 @@ typedef struct z_stream_s {
uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total number of input bytes read so far */
- Bytef *next_out; /* next output byte should be put there */
+ Bytef *next_out; /* next output byte will go here */
uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total number of bytes output so far */
@@ -98,8 +99,9 @@ typedef struct z_stream_s {
free_func zfree; /* used to free the internal state */
voidpf opaque; /* private data object passed to zalloc and zfree */
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
+ int data_type; /* best guess about the data type: binary or text
+ for deflate, or the decoding state for inflate */
+ uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */
uLong reserved; /* reserved for future use */
} z_stream;
@@ -142,7 +144,9 @@ typedef gz_header FAR *gz_headerp;
zalloc must return Z_NULL if there is not enough memory for the object.
If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
+ thread safe. In that case, zlib is thread-safe. When zalloc and zfree are
+ Z_NULL on entry to the initialization function, they are set to internal
+ routines that use the standard library functions malloc() and free().
On 16-bit systems, the functions zalloc and zfree must be able to allocate
exactly 65536 bytes, but will not be required to allocate more than this if
@@ -155,7 +159,7 @@ typedef gz_header FAR *gz_headerp;
The fields total_in and total_out can be used for statistics or progress
reports. After compression, total_in holds the total size of the
- uncompressed data and may be saved for use in the decompressor (particularly
+ uncompressed data and may be saved for use by the decompressor (particularly
if the decompressor wants to decompress everything in a single step).
*/
@@ -200,7 +204,7 @@ typedef gz_header FAR *gz_headerp;
#define Z_TEXT 1
#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
+/* Possible values of the data_type field for deflate() */
#define Z_DEFLATED 8
/* The deflate compression method (the only one supported in this version) */
@@ -258,11 +262,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
enough room in the output buffer), next_in and avail_in are updated and
processing will resume at this point for the next call of deflate().
- - Provide more output starting at next_out and update next_out and avail_out
+ - Generate more output starting at next_out and update next_out and avail_out
accordingly. This action is forced if the parameter flush is non zero.
Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications). Some
- output may be provided even if flush is not set.
+ should be set only when necessary. Some output may be provided even if
+ flush is zero.
Before the call of deflate(), the application should ensure that at least
one of the actions is possible, by providing more input and/or consuming more
@@ -271,7 +275,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
output when it wants, for example when the output buffer is full (avail_out
== 0), or after each call of deflate(). If deflate returns Z_OK and with
zero avail_out, it must be called again after making room in the output
- buffer because there might be more output pending.
+ buffer because there might be more output pending. See deflatePending(),
+ which can be used if desired to determine whether or not there is more ouput
+ in that case.
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
decide how much data to accumulate before producing output, in order to
@@ -292,8 +298,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
This completes the current deflate block and follows it with an empty fixed
codes block that is 10 bits long. This assures that enough bytes are output
- in order for the decompressor to finish the block before the empty fixed code
- block.
+ in order for the decompressor to finish the block before the empty fixed
+ codes block.
If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
@@ -319,34 +325,38 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
If the parameter flush is set to Z_FINISH, pending input is processed,
pending output is flushed and deflate returns with Z_STREAM_END if there was
- enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the stream
- are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least the
- value returned by deflateBound (see below). Then deflate is guaranteed to
- return Z_STREAM_END. If not enough output space is provided, deflate will
- not return Z_STREAM_END, and it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
+ enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this
+ function must be called again with Z_FINISH and more output space (updated
+ avail_out) but no more input data, until it returns with Z_STREAM_END or an
+ error. After deflate has returned Z_STREAM_END, the only possible operations
+ on the stream are deflateReset or deflateEnd.
+
+ Z_FINISH can be used in the first deflate call after deflateInit if all the
+ compression is to be done in a single step. In order to complete in one
+ call, avail_out must be at least the value returned by deflateBound (see
+ below). Then deflate is guaranteed to return Z_STREAM_END. If not enough
+ output space is provided, deflate will not return Z_STREAM_END, and it must
+ be called again as described above.
+
+ deflate() sets strm->adler to the Adler-32 checksum of all input read
+ so far (that is, total_in bytes). If a gzip stream is being generated, then
+ strm->adler will be the CRC-32 checksum of the input read so far. (See
+ deflateInit2 below.)
deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect the
- compression algorithm in any manner.
+ the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is
+ considered binary. This field is only for information purposes and does not
+ affect the compression algorithm in any manner.
deflate() returns Z_OK if some progress has been made (more input
processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
+ if next_in or next_out was Z_NULL or the state was inadvertently written over
+ by the application), or Z_BUF_ERROR if no progress is possible (for example
+ avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and
+ deflate() can be called again with more input and more output space to
+ continue compressing.
*/
@@ -369,23 +379,21 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
Initializes the internal stream state for decompression. The fields
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the
- exact value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
+ the caller. In the current version of inflate, the provided input is not
+ read or consumed. The allocation of a sliding window will be deferred to
+ the first call of inflate (if the decompression does not complete on the
+ first call). If zalloc and zfree are set to Z_NULL, inflateInit updates
+ them to use default allocation functions.
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
version assumed by the caller, or Z_STREAM_ERROR if the parameters are
invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit() does not process any header information -- that is deferred
- until inflate() is called.
+ there is no error message. inflateInit does not perform any decompression.
+ Actual decompression will be done by inflate(). So next_in, and avail_in,
+ next_out, and avail_out are unused and unchanged. The current
+ implementation of inflateInit() does not process any header information --
+ that is deferred until inflate() is called.
*/
@@ -401,17 +409,20 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
- Decompress more input starting at next_in and update next_in and avail_in
accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing will
- resume at this point for the next call of inflate().
+ enough room in the output buffer), then next_in and avail_in are updated
+ accordingly, and processing will resume at this point for the next call of
+ inflate().
- - Provide more output starting at next_out and update next_out and avail_out
+ - Generate more output starting at next_out and update next_out and avail_out
accordingly. inflate() provides as much output as possible, until there is
no more input data or no more space in the output buffer (see below about
the flush parameter).
Before the call of inflate(), the application should ensure that at least
one of the actions is possible, by providing more input and/or consuming more
- output, and updating the next_* and avail_* values accordingly. The
+ output, and updating the next_* and avail_* values accordingly. If the
+ caller of inflate() does not provide both available input and available
+ output space, it is possible that there will be no progress made. The
application can consume the uncompressed output when it wants, for example
when the output buffer is full (avail_out == 0), or after each call of
inflate(). If inflate returns Z_OK and with zero avail_out, it must be
@@ -428,7 +439,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
gets to the end of that block, or when it runs out of data.
The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
+ To assist in this, on return inflate() always sets strm->data_type to the
number of unused bits in the last byte taken from strm->next_in, plus 64 if
inflate() is currently decoding the last block in the deflate stream, plus
128 if inflate() returned immediately after decoding an end-of-block code or
@@ -454,7 +465,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
this case all pending input is processed and all pending output is flushed;
avail_out must be large enough to hold all of the uncompressed data for the
operation to complete. (The size of the uncompressed data may have been
- saved by the compressor for this purpose.) The use of Z_FINISH is not
+ saved by the compressor for this purpose.) The use of Z_FINISH is not
required to perform an inflation in one step. However it may be used to
inform inflate that a faster approach can be used for the single inflate()
call. Z_FINISH also informs inflate to not maintain a sliding window if the
@@ -476,32 +487,33 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
strm->adler to the Adler-32 checksum of all output produced so far (that is,
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
+ below. At the end of the stream, inflate() checks that its computed Adler-32
checksum is equal to that saved by the compressor and returns Z_STREAM_END
only if the checksum is correct.
inflate() can decompress and check either zlib-wrapped or gzip-wrapped
deflate data. The header type is detected automatically, if requested when
initializing with inflateInit2(). Any information contained in the gzip
- header is not retained, so applications that need that information should
- instead use raw inflate, see inflateInit2() below, or inflateBack() and
- perform their own processing of the gzip header and trailer. When processing
+ header is not retained unless inflateGetHeader() is used. When processing
gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
- producted so far. The CRC-32 is checked against the gzip trailer.
+ produced so far. The CRC-32 is checked against the gzip trailer, as is the
+ uncompressed length, modulo 2^32.
inflate() returns Z_OK if some progress has been made (more input processed
or more output produced), Z_STREAM_END if the end of the compressed data has
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ value, in which case strm->msg points to a string with a more specific
+ error), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+ next_in or next_out was Z_NULL, or the state was inadvertently written over
+ by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR
+ if no progress was possible or if there was not enough room in the output
+ buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
inflate() can be called again with more input and more output space to
continue decompressing. If Z_DATA_ERROR is returned, the application may
then call inflateSync() to look for a good compression block if a partial
- recovery of the data is desired.
+ recovery of the data is to be attempted.
*/
@@ -511,9 +523,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
This function discards any unprocessed input and does not flush any pending
output.
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
+ inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state
+ was inconsistent.
*/
@@ -544,16 +555,29 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
compression at the expense of memory usage. The default value is 15 if
deflateInit is used instead.
+ For the current implementation of deflate(), a windowBits value of 8 (a
+ window size of 256 bytes) is not supported. As a result, a request for 8
+ will result in 9 (a 512-byte window). In that case, providing 8 to
+ inflateInit2() will result in an error when the zlib header with 9 is
+ checked against the initialization of inflate(). The remedy is to not use 8
+ with deflateInit2() with this initialization, or at least in that case use 9
+ with inflateInit2().
+
windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
+ with no zlib header or trailer, and will not compute a check value.
windowBits can also be greater than 15 for optional gzip encoding. Add
16 to windowBits to write a simple gzip header and trailer around the
compressed data instead of a zlib wrapper. The gzip header will have no
file name, no extra data, no comment, no modification time (set to zero), no
- header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+ header crc, and the operating system will be set to the appropriate value,
+ if the operating system was determined at compile time. If a gzip stream is
+ being written, strm->adler is a CRC-32 instead of an Adler-32.
+
+ For raw deflate or gzip encoding, a request for a 256-byte window is
+ rejected as invalid, since only the zlib header provides a means of
+ transmitting the window size to the decompressor.
The memLevel parameter specifies how much memory should be allocated
for the internal compression state. memLevel=1 uses minimum memory but is
@@ -614,12 +638,12 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
addition, the current implementation of deflate will use at most the window
size minus 262 bytes of the provided dictionary.
- Upon return of this function, strm->adler is set to the adler32 value
+ Upon return of this function, strm->adler is set to the Adler-32 value
of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
+ which dictionary has been used by the compressor. (The Adler-32 value
applies to the whole dictionary even if only a subset of the dictionary is
actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
+ Adler-32 value is not computed and strm->adler is not set.
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
@@ -628,6 +652,28 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
not perform any compression: this will be done by deflate().
*/
+ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength));
+/*
+ Returns the sliding dictionary being maintained by deflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If deflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ deflateGetDictionary() may return a length less than the window size, even
+ when more than the window size in input has been provided. It may return up
+ to 258 bytes less in that case, due to how zlib's implementation of deflate
+ manages the sliding window and lookahead for matches, where matches can be
+ up to 258 bytes long. If the application needs the last window-size bytes of
+ input, then that would need to be saved by the application outside of zlib.
+
+ deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
z_streamp source));
/*
@@ -648,10 +694,10 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state. The
- stream will keep the same compression level and any other attributes that
- may have been set by deflateInit2.
+ This function is equivalent to deflateEnd followed by deflateInit, but
+ does not free and reallocate the internal compression state. The stream
+ will leave the compression level and any other attributes that may have been
+ set unchanged.
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent (such as zalloc or state being Z_NULL).
@@ -662,20 +708,36 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
int strategy));
/*
Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
+ interpretation of level and strategy is as in deflateInit2(). This can be
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
- If the compression level is changed, the input available so far is
- compressed with the old level (and may be flushed); the new level will take
- effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to be
- compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
- strm->avail_out was zero.
+ If the compression approach (which is a function of the level) or the
+ strategy is changed, and if any input has been consumed in a previous
+ deflate() call, then the input available so far is compressed with the old
+ level and strategy using deflate(strm, Z_BLOCK). There are three approaches
+ for the compression levels 0, 1..3, and 4..9 respectively. The new level
+ and strategy will take effect at the next call of deflate().
+
+ If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
+ not have enough output space to complete, then the parameter change will not
+ take effect. In this case, deflateParams() can be called again with the
+ same parameters and more output space to try again.
+
+ In order to assure a change in the parameters on the first try, the
+ deflate stream should be flushed using deflate() with Z_BLOCK or other flush
+ request until strm.avail_out is not zero, before calling deflateParams().
+ Then no more input data should be provided before the deflateParams() call.
+ If this is done, the old level and strategy will be applied to the data
+ compressed before deflateParams(), and the new level and strategy will be
+ applied to the the data compressed after deflateParams().
+
+ deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
+ state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
+ there was not enough output space to complete the compression of the
+ available input data before a change in the strategy or approach. Note that
+ in the case of a Z_BUF_ERROR, the parameters are not changed. A return
+ value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be
+ retried with more output space.
*/
ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
@@ -793,7 +855,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
is for use with other formats that use the deflate compressed data format
such as zip. Those formats provide their own check values. If a custom
format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
+ recommended that a check value such as an Adler-32 or a CRC-32 be applied to
the uncompressed data as is done in the zlib, gzip, and zip formats. For
most applications, the zlib format should be used as is. Note that comments
above on the use in deflateInit2() applies to the magnitude of windowBits.
@@ -802,7 +864,10 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
- crc32 instead of an adler32.
+ CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
+ below), inflate() will not automatically decode concatenated gzip streams.
+ inflate() will return Z_STREAM_END at the end of the gzip stream. The state
+ would need to be reset to continue decoding a subsequent gzip stream.
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
@@ -823,7 +888,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate,
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
+ can be determined from the Adler-32 value returned by that call of inflate.
The compressor and decompressor must use exactly the same dictionary (see
deflateSetDictionary). For raw inflate, this function can be called at any
time to set the dictionary. If the provided dictionary is smaller than the
@@ -834,7 +899,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
+ expected one (incorrect Adler-32 value). inflateSetDictionary does not
perform any decompression: this will be done by subsequent calls of
inflate().
*/
@@ -892,7 +957,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state. The
+ but does not free and reallocate the internal decompression state. The
stream will keep attributes that may have been set by inflateInit2.
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
@@ -904,7 +969,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
/*
This function is the same as inflateReset, but it also permits changing
the wrap and window size requests. The windowBits parameter is interpreted
- the same as it is for inflateInit2.
+ the same as it is for inflateInit2. If the window size is changed, then the
+ memory allocated for the window is freed, and the window will be reallocated
+ by inflate() if needed.
inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent (such as zalloc or state being Z_NULL), or if
@@ -956,7 +1023,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
location in the input stream can be determined from avail_in and data_type
as noted in the description for the Z_BLOCK flush parameter for inflate.
- inflateMark returns the value noted above or -1 << 16 if the provided
+ inflateMark returns the value noted above, or -65536 if the provided
source stream state was inconsistent.
*/
@@ -1048,9 +1115,9 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
This routine would normally be used in a utility that reads zip or gzip
files and writes out uncompressed files. The utility would decode the
header and process the trailer on its own, hence this routine expects only
- the raw deflate stream to decompress. This is different from the normal
- behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
+ the raw deflate stream to decompress. This is different from the default
+ behavior of inflate(), which expects a zlib header and trailer around the
+ deflate stream.
inflateBack() uses two subroutines supplied by the caller that are then
called by inflateBack() for input and output. inflateBack() calls those
@@ -1059,12 +1126,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
parameters and return types are defined above in the in_func and out_func
typedefs. inflateBack() will call in(in_desc, &buf) which should return the
number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
+ there is no input available, in() must return zero -- buf is ignored in that
+ case -- and inflateBack() will return a buffer error. inflateBack() will
+ call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
+ out() should return zero on success, or non-zero on failure. If out()
+ returns non-zero, inflateBack() will return with an error. Neither in() nor
+ out() are permitted to change the contents of the window provided to
inflateBackInit(), which is also the buffer that out() uses to write from.
The length written by out() will be at most the window size. Any non-zero
amount of input may be provided by in().
@@ -1092,7 +1159,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
using strm->next_in which will be Z_NULL only if in() returned an error. If
strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
non-zero. (in() will always be called before out(), so strm->next_in is
- assured to be defined if out() returns non-zero.) Note that inflateBack()
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
cannot return Z_OK.
*/
@@ -1114,7 +1181,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
7.6: size of z_off_t
Compiler, assembler, and debug options:
- 8: DEBUG
+ 8: ZLIB_DEBUG
9: ASMV or ASMINF -- use ASM code
10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
11: 0 (reserved)
@@ -1164,7 +1231,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
the byte length of the source buffer. Upon entry, destLen is the total size
of the destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
+ compressed data. compress() is equivalent to compress2() with a level
+ parameter of Z_DEFAULT_COMPRESSION.
compress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
@@ -1180,7 +1248,7 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
+ compressed data.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
@@ -1203,7 +1271,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
uncompressed data. (The size of the uncompressed data must have been saved
previously by the compressor and transmitted to the decompressor by some
mechanism outside the scope of this compression library.) Upon exit, destLen
- is the actual size of the uncompressed buffer.
+ is the actual size of the uncompressed data.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
@@ -1212,6 +1280,14 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
buffer with the uncompressed data up to that point.
*/
+ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen));
+/*
+ Same as uncompress, except that sourceLen is a pointer, where the
+ length of the source is *sourceLen. On return, *sourceLen is the number of
+ source bytes consumed.
+*/
+
/* gzip file access functions */
/*
@@ -1290,10 +1366,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
default buffer size is 8192 bytes. This function must be called after
gzopen() or gzdopen(), and before any other calls that read or write the
file. The buffer memory allocation is always deferred to the first read or
- write. Two buffers are allocated, either both of the specified size when
- writing, or one of the specified size and the other twice that size when
- reading. A larger buffer size of, for example, 64K or 128K bytes will
- noticeably increase the speed of decompression (reading).
+ write. Three times that size in buffer space is allocated. A larger buffer
+ size of, for example, 64K or 128K bytes will noticeably increase the speed
+ of decompression (reading).
The new buffer size also affects the maximum length for gzprintf().
@@ -1304,10 +1379,12 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
+ of deflateInit2 for the meaning of these parameters. Previously provided
+ data is flushed before the parameter change.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
+ gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
+ opened for writing, Z_ERRNO if there is an error writing the flushed data,
+ or Z_MEM_ERROR if there is a memory allocation error.
*/
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
@@ -1335,7 +1412,35 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
case.
gzread returns the number of uncompressed bytes actually read, less than
- len for end of file, or -1 for error.
+ len for end of file, or -1 for error. If len is too large to fit in an int,
+ then nothing is read, -1 is returned, and the error state is set to
+ Z_STREAM_ERROR.
+*/
+
+ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
+ gzFile file));
+/*
+ Read up to nitems items of size size from file to buf, otherwise operating
+ as gzread() does. This duplicates the interface of stdio's fread(), with
+ size_t request and return types. If the library defines size_t, then
+ z_size_t is identical to size_t. If not, then z_size_t is an unsigned
+ integer type that can contain a pointer.
+
+ gzfread() returns the number of full items read of size size, or zero if
+ the end of the file was reached and a full item could not be read, or if
+ there was an error. gzerror() must be consulted if zero is returned in
+ order to determine if there was an error. If the multiplication of size and
+ nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
+ is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
+
+ In the event that the end of file is reached and only a partial item is
+ available at the end, i.e. the remaining uncompressed data length is not a
+ multiple of size, then the final partial item is nevetheless read into buf
+ and the end-of-file flag is set. The length of the partial item read is not
+ provided, but could be inferred from the result of gztell(). This behavior
+ is the same as the behavior of fread() implementations in common libraries,
+ but it prevents the direct use of gzfread() to read a concurrently written
+ file, reseting and retrying on end-of-file, when size is not 1.
*/
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
@@ -1346,19 +1451,33 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
error.
*/
+ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
+ z_size_t nitems, gzFile file));
+/*
+ gzfwrite() writes nitems items of size size from buf to file, duplicating
+ the interface of stdio's fwrite(), with size_t request and return types. If
+ the library defines size_t, then z_size_t is identical to size_t. If not,
+ then z_size_t is an unsigned integer type that can contain a pointer.
+
+ gzfwrite() returns the number of full items written of size size, or zero
+ if there was an error. If the multiplication of size and nitems overflows,
+ i.e. the product does not fit in a z_size_t, then nothing is written, zero
+ is returned, and the error state is set to Z_STREAM_ERROR.
+*/
+
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written, or 0 in case of error. The number of
- uncompressed bytes written is limited to 8191, or one less than the buffer
- size given to gzbuffer(). The caller should assure that this limit is not
- exceeded. If it is exceeded, then gzprintf() will return an error (0) with
- nothing written. In this case, there may also be a buffer overflow with
- unpredictable consequences, which is possible only if zlib was compiled with
- the insecure functions sprintf() or vsprintf() because the secure snprintf()
- or vsnprintf() functions were not available. This can be determined using
- zlibCompileFlags().
+ uncompressed bytes actually written, or a negative zlib error code in case
+ of error. The number of uncompressed bytes written is limited to 8191, or
+ one less than the buffer size given to gzbuffer(). The caller should assure
+ that this limit is not exceeded. If it is exceeded, then gzprintf() will
+ return an error (0) with nothing written. In this case, there may also be a
+ buffer overflow with unpredictable consequences, which is possible only if
+ zlib was compiled with the insecure functions sprintf() or vsprintf()
+ because the secure snprintf() or vsnprintf() functions were not available.
+ This can be determined using zlibCompileFlags().
*/
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
@@ -1418,7 +1537,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
If the flush parameter is Z_FINISH, the remaining data is written and the
gzip stream is completed in the output. If gzwrite() is called again, a new
gzip stream will be started in the output. gzread() is able to read such
- concatented gzip streams.
+ concatenated gzip streams.
gzflush should be called only when strictly necessary because it will
degrade compression if called too often.
@@ -1572,7 +1691,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
return the updated checksum. If buf is Z_NULL, this function returns the
required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
much faster.
Usage example:
@@ -1585,6 +1704,12 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error();
*/
+ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len));
+/*
+ Same as adler32(), but with a size_t length.
+*/
+
/*
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
z_off_t len2));
@@ -1614,6 +1739,12 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len));
+/*
+ Same as crc32(), but with a size_t length.
+*/
+
/*
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
@@ -1644,19 +1775,35 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
unsigned char FAR *window,
const char *version,
int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
- (int)sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, (int)sizeof(z_stream))
+#ifdef Z_PREFIX_SET
+# define z_deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define z_inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#else
+# define deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#endif
#ifndef Z_SOLO
@@ -1676,10 +1823,10 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#ifdef Z_PREFIX_SET
# undef z_gzgetc
# define z_gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
#else
# define gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
#endif
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
@@ -1737,19 +1884,16 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#endif /* !Z_SOLO */
-/* hack for buggy compilers */
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;};
-#endif
-
/* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
+ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
+ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
-#if defined(_WIN32) && !defined(Z_SOLO)
+#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif
diff --git a/compat/zlib/zlib.map b/compat/zlib/zlib.map
index 55c6647..40fa9db 100644
--- a/compat/zlib/zlib.map
+++ b/compat/zlib/zlib.map
@@ -1,83 +1,94 @@
-ZLIB_1.2.0 {
- global:
- compressBound;
- deflateBound;
- inflateBack;
- inflateBackEnd;
- inflateBackInit_;
- inflateCopy;
- local:
- deflate_copyright;
- inflate_copyright;
- inflate_fast;
- inflate_table;
- zcalloc;
- zcfree;
- z_errmsg;
- gz_error;
- gz_intmax;
- _*;
-};
-
-ZLIB_1.2.0.2 {
- gzclearerr;
- gzungetc;
- zlibCompileFlags;
-} ZLIB_1.2.0;
-
-ZLIB_1.2.0.8 {
- deflatePrime;
-} ZLIB_1.2.0.2;
-
-ZLIB_1.2.2 {
- adler32_combine;
- crc32_combine;
- deflateSetHeader;
- inflateGetHeader;
-} ZLIB_1.2.0.8;
-
-ZLIB_1.2.2.3 {
- deflateTune;
- gzdirect;
-} ZLIB_1.2.2;
-
-ZLIB_1.2.2.4 {
- inflatePrime;
-} ZLIB_1.2.2.3;
-
-ZLIB_1.2.3.3 {
- adler32_combine64;
- crc32_combine64;
- gzopen64;
- gzseek64;
- gztell64;
- inflateUndermine;
-} ZLIB_1.2.2.4;
-
-ZLIB_1.2.3.4 {
- inflateReset2;
- inflateMark;
-} ZLIB_1.2.3.3;
-
-ZLIB_1.2.3.5 {
- gzbuffer;
- gzoffset;
- gzoffset64;
- gzclose_r;
- gzclose_w;
-} ZLIB_1.2.3.4;
-
-ZLIB_1.2.5.1 {
- deflatePending;
-} ZLIB_1.2.3.5;
-
-ZLIB_1.2.5.2 {
- deflateResetKeep;
- gzgetc_;
- inflateResetKeep;
-} ZLIB_1.2.5.1;
-
-ZLIB_1.2.7.1 {
- inflateGetDictionary;
- gzvprintf;
-} ZLIB_1.2.5.2;
+ZLIB_1.2.0 {
+ global:
+ compressBound;
+ deflateBound;
+ inflateBack;
+ inflateBackEnd;
+ inflateBackInit_;
+ inflateCopy;
+ local:
+ deflate_copyright;
+ inflate_copyright;
+ inflate_fast;
+ inflate_table;
+ zcalloc;
+ zcfree;
+ z_errmsg;
+ gz_error;
+ gz_intmax;
+ _*;
+};
+
+ZLIB_1.2.0.2 {
+ gzclearerr;
+ gzungetc;
+ zlibCompileFlags;
+} ZLIB_1.2.0;
+
+ZLIB_1.2.0.8 {
+ deflatePrime;
+} ZLIB_1.2.0.2;
+
+ZLIB_1.2.2 {
+ adler32_combine;
+ crc32_combine;
+ deflateSetHeader;
+ inflateGetHeader;
+} ZLIB_1.2.0.8;
+
+ZLIB_1.2.2.3 {
+ deflateTune;
+ gzdirect;
+} ZLIB_1.2.2;
+
+ZLIB_1.2.2.4 {
+ inflatePrime;
+} ZLIB_1.2.2.3;
+
+ZLIB_1.2.3.3 {
+ adler32_combine64;
+ crc32_combine64;
+ gzopen64;
+ gzseek64;
+ gztell64;
+ inflateUndermine;
+} ZLIB_1.2.2.4;
+
+ZLIB_1.2.3.4 {
+ inflateReset2;
+ inflateMark;
+} ZLIB_1.2.3.3;
+
+ZLIB_1.2.3.5 {
+ gzbuffer;
+ gzoffset;
+ gzoffset64;
+ gzclose_r;
+ gzclose_w;
+} ZLIB_1.2.3.4;
+
+ZLIB_1.2.5.1 {
+ deflatePending;
+} ZLIB_1.2.3.5;
+
+ZLIB_1.2.5.2 {
+ deflateResetKeep;
+ gzgetc_;
+ inflateResetKeep;
+} ZLIB_1.2.5.1;
+
+ZLIB_1.2.7.1 {
+ inflateGetDictionary;
+ gzvprintf;
+} ZLIB_1.2.5.2;
+
+ZLIB_1.2.9 {
+ inflateCodesUsed;
+ inflateValidate;
+ uncompress2;
+ gzfread;
+ gzfwrite;
+ deflateGetDictionary;
+ adler32_z;
+ crc32_z;
+} ZLIB_1.2.7.1;
diff --git a/compat/zlib/zlib2ansi b/compat/zlib/zlib2ansi
index 15e3e16..15e3e16 100644..100755
--- a/compat/zlib/zlib2ansi
+++ b/compat/zlib/zlib2ansi
diff --git a/compat/zlib/zutil.c b/compat/zlib/zutil.c
index 23d2ebe..a76c6b0 100644
--- a/compat/zlib/zutil.c
+++ b/compat/zlib/zutil.c
@@ -1,5 +1,5 @@
/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -10,21 +10,18 @@
# include "gzguts.h"
#endif
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
z_const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
+ (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
+ (z_const char *)"stream end", /* Z_STREAM_END 1 */
+ (z_const char *)"", /* Z_OK 0 */
+ (z_const char *)"file error", /* Z_ERRNO (-1) */
+ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
+ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */
+ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
+ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
+ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
+ (z_const char *)""
+};
const char * ZEXPORT zlibVersion()
@@ -61,7 +58,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 6; break;
default: flags += 3 << 6;
}
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
flags += 1 << 8;
#endif
#if defined(ASMV) || defined(ASMINF)
@@ -115,8 +112,8 @@ uLong ZEXPORT zlibCompileFlags()
return flags;
}
-#ifdef DEBUG
-
+#ifdef ZLIB_DEBUG
+#include <stdlib.h>
# ifndef verbose
# define verbose 0
# endif
@@ -219,9 +216,11 @@ local ptr_table table[MAX_PTR];
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
{
- voidpf buf = opaque; /* just to make some compilers happy */
+ voidpf buf;
ulg bsize = (ulg)items*size;
+ (void)opaque;
+
/* If we allocate less than 65520 bytes, we assume that farmalloc
* will return a usable pointer which doesn't have to be normalized.
*/
@@ -244,6 +243,9 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
int n;
+
+ (void)opaque;
+
if (*(ush*)&ptr != 0) { /* object < 64K */
farfree(ptr);
return;
@@ -259,7 +261,6 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
next_ptr--;
return;
}
- ptr = opaque; /* just to make some compilers happy */
Assert(0, "zcfree: ptr not found");
}
@@ -278,13 +279,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ (void)opaque;
return _halloc((long)items, size);
}
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ (void)opaque;
_hfree(ptr);
}
@@ -306,7 +307,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
unsigned items;
unsigned size;
{
- if (opaque) items += size - size; /* make compiler happy */
+ (void)opaque;
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}
@@ -315,8 +316,8 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
voidpf opaque;
voidpf ptr;
{
+ (void)opaque;
free(ptr);
- if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */
diff --git a/compat/zlib/zutil.h b/compat/zlib/zutil.h
index 24ab06b..b079ea6 100644
--- a/compat/zlib/zutil.h
+++ b/compat/zlib/zutil.h
@@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -36,7 +36,9 @@
#ifndef local
# define local static
#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
+/* since "static" is used to mean two completely different things in C, we
+ define "local" for the non-static meaning of "static", for readability
+ (compile with -Dlocal if your debugger can't find static symbols) */
typedef unsigned char uch;
typedef uch FAR uchf;
@@ -98,28 +100,38 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
#ifdef AMIGA
-# define OS_CODE 0x01
+# define OS_CODE 1
#endif
#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
+# define OS_CODE 2
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
+#ifdef __370__
+# if __TARGET_LIB__ < 0x20000000
+# define OS_CODE 4
+# elif __TARGET_LIB__ < 0x40000000
+# define OS_CODE 11
+# else
+# define OS_CODE 8
+# endif
+#endif
+
#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
+# define OS_CODE 5
#endif
#ifdef OS2
-# define OS_CODE 0x06
+# define OS_CODE 6
# if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
+# define OS_CODE 7
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
@@ -131,18 +143,24 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif
-#ifdef TOPS20
-# define OS_CODE 0x0a
+#ifdef __acorn
+# define OS_CODE 13
#endif
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
+#if defined(WIN32) && !defined(__CYGWIN__)
+# define OS_CODE 10
+#endif
+
+#ifdef _BEOS_
+# define OS_CODE 16
+#endif
+
+#ifdef __TOS_OS400__
+# define OS_CODE 18
#endif
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
+#ifdef __APPLE__
+# define OS_CODE 19
#endif
#if defined(_BEOS_) || defined(RISCOS)
@@ -177,7 +195,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* common defaults */
#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
+# define OS_CODE 3 /* assume Unix */
#endif
#ifndef F_OPEN
@@ -216,7 +234,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
/* Diagnostic functions */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
# include <stdio.h>
extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m));
diff --git a/doc/Eval.3 b/doc/Eval.3
index 8661923..191bace 100644
--- a/doc/Eval.3
+++ b/doc/Eval.3
@@ -205,7 +205,7 @@ and sets \fIinterp\fR's result to an error message indicating that
the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
invoked in an inappropriate place.
This means that top-level applications should never see a return code
-from \fBTcl_EvalObjEx\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
+from \fBTcl_EvalObjEx\fR other than \fBTCL_OK\fR or \fBTCL_ERROR\fR.
.SH KEYWORDS
execute, file, global, result, script, value
diff --git a/doc/GetInt.3 b/doc/GetInt.3
index 871f483..5a3304a 100644
--- a/doc/GetInt.3
+++ b/doc/GetInt.3
@@ -51,27 +51,42 @@ in the interpreter's result, and nothing is stored at *\fIintPtr\fR
or *\fIdoublePtr\fR or *\fIboolPtr\fR.
.PP
\fBTcl_GetInt\fR expects \fIsrc\fR to consist of a collection
-of integer digits, optionally signed and optionally preceded by
-white space. If the first two characters of \fIsrc\fR
+of integer digits, optionally signed and optionally preceded and
+followed by white space. If the first two characters of \fIsrc\fR
after the optional white space and sign are
-.QW 0x
+.QW \fB0x\fR
then \fIsrc\fR is expected to be in hexadecimal form; otherwise,
+if the first such characters are
+.QW \fB0o\fR
+then \fIsrc\fR is expected to be in octal form; otherwise,
+if the first such characters are
+.QW \fB0b\fR
+then \fIsrc\fR is expected to be in binary form; otherwise,
if the first such character is
-.QW 0
+.QW \fB0\fR
then \fIsrc\fR
is expected to be in octal form; otherwise, \fIsrc\fR is
expected to be in decimal form.
.PP
\fBTcl_GetDouble\fR expects \fIsrc\fR to consist of a floating-point
number, which is: white space; a sign; a sequence of digits; a
-decimal point; a sequence of digits; the letter
-.QW e ;
+decimal point
+.QW \fB.\fR ;
+a sequence of digits; the letter
+.QW \fBe\fR ;
a signed decimal exponent; and more white space.
Any of the fields may be omitted, except that
the digits either before or after the decimal point must be present
and if the
-.QW e
-is present then it must be followed by the exponent number.
+.QW \fBe\fR
+is present then it must be followed by the exponent number. If there
+are no fields apart from the sign and initial sequence of digits
+(i.e., no decimal point or exponent indicator), that
+initial sequence of digits should take one of the forms that
+\fBTcl_GetInt\fR supports, described above. The use of
+.QW \fB,\fR
+as a decimal point is not supported nor should any other sort of
+inter-digit separator be present.
.PP
\fBTcl_GetBoolean\fR expects \fIsrc\fR to specify a boolean
value. If \fIsrc\fR is any of \fB0\fR, \fBfalse\fR,
diff --git a/doc/InitStubs.3 b/doc/InitStubs.3
index fbb3f56..4423666 100644
--- a/doc/InitStubs.3
+++ b/doc/InitStubs.3
@@ -23,11 +23,11 @@ Tcl interpreter handle.
A version string consisting of one or more decimal numbers
separated by dots.
.AP int exact in
-Non-zero means that only the particular version specified by
+1 means that only the particular version specified by
\fIversion\fR is acceptable.
-Zero means that versions newer than \fIversion\fR are also
+0 means that versions newer than \fIversion\fR are also
acceptable as long as they have the same major version number
-as \fIversion\fR.
+as \fIversion\fR. Other bits have no effect.
.BE
.SH INTRODUCTION
.PP
diff --git a/doc/IntObj.3 b/doc/IntObj.3
index dc62642..2acb446 100644
--- a/doc/IntObj.3
+++ b/doc/IntObj.3
@@ -97,7 +97,7 @@ are provided by the C language standard. The \fBTcl_WideInt\fR type is a
typedef defined to be whatever signed integral type covers at least the
64-bit integer range (-9223372036854775808 to 9223372036854775807). Depending
on the platform and the C compiler, the actual type might be
-\fBlong int\fR, \fBlong long int\fR, \fBint64\fR, or something else.
+\fBlong int\fR, \fBlong long int\fR, \fB__int64\fR, or something else.
The \fBmp_int\fR type is a multiple-precision integer type defined
by the LibTomMath multiple-precision integer library.
.PP
diff --git a/doc/LinkVar.3 b/doc/LinkVar.3
index a77fe21..c80d30d 100644
--- a/doc/LinkVar.3
+++ b/doc/LinkVar.3
@@ -61,7 +61,9 @@ The C variable is of type \fBint\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR; attempts to write
non-integer values into \fIvarName\fR will be rejected with
-Tcl errors.
+Tcl errors. Incomplete integer representations (like the empty
+string, '+', '-' or the hex/octal/binary prefix) are accepted
+as if they are valid too.
.TP
\fBTCL_LINK_UINT\fR
The C variable is of type \fBunsigned int\fR.
@@ -69,14 +71,18 @@ Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
platform's defined range for the \fBunsigned int\fR type; attempts to
write non-integer values (or values outside the range) into
-\fIvarName\fR will be rejected with Tcl errors.
+\fIvarName\fR will be rejected with Tcl errors. Incomplete integer
+representations (like the empty string, '+', '-' or the hex/octal/binary
+prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_CHAR\fR
The C variable is of type \fBchar\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
\fBchar\fR datatype; attempts to write non-integer or out-of-range
-values into \fIvarName\fR will be rejected with Tcl errors.
+values into \fIvarName\fR will be rejected with Tcl errors. Incomplete
+integer representations (like the empty string, '+', '-' or the
+hex/octal/binary prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_UCHAR\fR
The C variable is of type \fBunsigned char\fR.
@@ -84,14 +90,18 @@ Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
platform's defined range for the \fBunsigned char\fR type; attempts to
write non-integer values (or values outside the range) into
-\fIvarName\fR will be rejected with Tcl errors.
+\fIvarName\fR will be rejected with Tcl errors. Incomplete integer
+representations (like the empty string, '+', '-' or the hex/octal/binary
+prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_SHORT\fR
The C variable is of type \fBshort\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
\fBshort\fR datatype; attempts to write non-integer or out-of-range
-values into \fIvarName\fR will be rejected with Tcl errors.
+values into \fIvarName\fR will be rejected with Tcl errors. Incomplete
+integer representations (like the empty string, '+', '-' or the
+hex/octal/binary prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_USHORT\fR
The C variable is of type \fBunsigned short\fR.
@@ -99,14 +109,18 @@ Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
platform's defined range for the \fBunsigned short\fR type; attempts to
write non-integer values (or values outside the range) into
-\fIvarName\fR will be rejected with Tcl errors.
+\fIvarName\fR will be rejected with Tcl errors. Incomplete integer
+representations (like the empty string, '+', '-' or the hex/octal/binary
+prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_LONG\fR
The C variable is of type \fBlong\fR.
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetLongFromObj\fR; attempts to write
non-integer or out-of-range
-values into \fIvarName\fR will be rejected with Tcl errors.
+values into \fIvarName\fR will be rejected with Tcl errors. Incomplete
+integer representations (like the empty string, '+', '-' or the
+hex/octal/binary prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_ULONG\fR
The C variable is of type \fBunsigned long\fR.
@@ -114,14 +128,18 @@ Any value written into the Tcl variable must have a proper unsigned
integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
platform's defined range for the \fBunsigned long\fR type; attempts to
write non-integer values (or values outside the range) into
-\fIvarName\fR will be rejected with Tcl errors.
+\fIvarName\fR will be rejected with Tcl errors. Incomplete integer
+representations (like the empty string, '+', '-' or the hex/octal/binary
+prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_DOUBLE\fR
The C variable is of type \fBdouble\fR.
Any value written into the Tcl variable must have a proper real
form acceptable to \fBTcl_GetDoubleFromObj\fR; attempts to write
non-real values into \fIvarName\fR will be rejected with
-Tcl errors.
+Tcl errors. Incomplete integer or real representations (like the
+empty string, '.', '+', '-' or the hex/octal/binary prefix) are
+accepted as if they are valid too.
.TP
\fBTCL_LINK_FLOAT\fR
The C variable is of type \fBfloat\fR.
@@ -129,7 +147,9 @@ Any value written into the Tcl variable must have a proper real
form acceptable to \fBTcl_GetDoubleFromObj\fR and must be within the
range acceptable for a \fBfloat\fR; attempts to
write non-real values (or values outside the range) into
-\fIvarName\fR will be rejected with Tcl errors.
+\fIvarName\fR will be rejected with Tcl errors. Incomplete integer
+or real representations (like the empty string, '.', '+', '-' or
+the hex/octal/binary prefix) are accepted as if they are valid too.
.TP
\fBTCL_LINK_WIDE_INT\fR
The C variable is of type \fBTcl_WideInt\fR (which is an integer type
@@ -137,7 +157,9 @@ at least 64-bits wide on all platforms that can support it.)
Any value written into the Tcl variable must have a proper integer
form acceptable to \fBTcl_GetWideIntFromObj\fR; attempts to write
non-integer values into \fIvarName\fR will be rejected with
-Tcl errors.
+Tcl errors. Incomplete integer representations (like the empty
+string, '+', '-' or the hex/octal/binary prefix) are accepted
+as if they are valid too.
.TP
\fBTCL_LINK_WIDE_UINT\fR
The C variable is of type \fBTcl_WideUInt\fR (which is an unsigned
@@ -148,7 +170,9 @@ integer form acceptable to \fBTcl_GetWideIntFromObj\fR (it will be
cast to unsigned);
.\" FIXME! Use bignums instead.
attempts to write non-integer values into \fIvarName\fR will be
-rejected with Tcl errors.
+rejected with Tcl errors. Incomplete integer representations (like
+the empty string, '+', '-' or the hex/octal/binary prefix) are accepted
+as if they are valid too.
.TP
\fBTCL_LINK_BOOLEAN\fR
The C variable is of type \fBint\fR.
diff --git a/doc/OpenTcp.3 b/doc/OpenTcp.3
index 4a7dc1e..5b941dc 100644
--- a/doc/OpenTcp.3
+++ b/doc/OpenTcp.3
@@ -4,12 +4,12 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-.TH Tcl_OpenTcpClient 3 8.0 Tcl "Tcl Library Procedures"
+.TH Tcl_OpenTcpClient 3 8.7 Tcl "Tcl Library Procedures"
.so man.macros
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
-Tcl_OpenTcpClient, Tcl_MakeTcpClientChannel, Tcl_OpenTcpServer \- procedures to open channels using TCP sockets
+Tcl_OpenTcpClient, Tcl_MakeTcpClientChannel, Tcl_OpenTcpServer, Tcl_OpenTcpServerEx \- procedures to open channels using TCP sockets
.SH SYNOPSIS
.nf
\fB#include <tcl.h> \fR
@@ -23,6 +23,9 @@ Tcl_Channel
Tcl_Channel
\fBTcl_OpenTcpServer\fR(\fIinterp, port, myaddr, proc, clientData\fR)
.sp
+Tcl_Channel
+\fBTcl_OpenTcpServerEx\fR(\fIinterp, service, myaddr, flags, proc, clientData\fR)
+.sp
.SH ARGUMENTS
.AS Tcl_TcpAcceptProc clientData
.AP Tcl_Interp *interp in
@@ -30,6 +33,9 @@ Tcl interpreter to use for error reporting. If non-NULL and an
error occurs, an error message is left in the interpreter's result.
.AP int port in
A port number to connect to as a client or to listen on as a server.
+.AP "const char" *service in
+A string specifying the port number to connect to as a client or to listen on as
+ a server.
.AP "const char" *host in
A string specifying a host name or address for the remote end of the connection.
.AP int myport in
@@ -41,6 +47,9 @@ for the local end of the connection. If NULL, a default interface is
chosen.
.AP int async in
If nonzero, the client socket is connected asynchronously to the server.
+.AP "unsigned int" flags in
+ORed combination of \fBTCL_TCPSERVER\fR flags that specify additional
+informations about the socket being created.
.AP ClientData sock in
Platform-specific handle for client TCP socket.
.AP Tcl_TcpAcceptProc *proc in
@@ -158,6 +167,11 @@ register it, use \fBTcl_RegisterChannel\fR.
If one of the standard channels, \fBstdin\fR, \fBstdout\fR or \fBstderr\fR was
previously closed, the act of creating the new channel also assigns it as a
replacement for the standard channel.
+.SS TCL_OPENTCPSERVEREX
+.PP
+\fBTcl_OpenTcpServerEx\fR behaviour is identical to \fBTcl_OpenTcpServer\fR but
+gives more flexibility to the user by providing a mean to further customize some
+aspects of the socket via the \fIflags\fR parameter.
.SH "PLATFORM ISSUES"
.PP
On Unix platforms, the socket handle is a Unix file descriptor as
diff --git a/doc/RecEvalObj.3 b/doc/RecEvalObj.3
index 1b0f292..f9550a2 100644
--- a/doc/RecEvalObj.3
+++ b/doc/RecEvalObj.3
@@ -32,8 +32,6 @@ the command at global level instead of the current stack level.
.PP
\fBTcl_RecordAndEvalObj\fR is invoked to record a command as an event
on the history list and then execute it using \fBTcl_EvalObjEx\fR
-(or \fBTcl_GlobalEvalObj\fR if the \fBTCL_EVAL_GLOBAL\fR bit is set
-in \fIflags\fR).
It returns a completion code such as \fBTCL_OK\fR just like \fBTcl_EvalObjEx\fR,
as well as a result value containing additional information
(a result value or error message)
diff --git a/doc/concat.n b/doc/concat.n
index 9fe7908..d10f092 100644
--- a/doc/concat.n
+++ b/doc/concat.n
@@ -20,6 +20,7 @@ This command joins each of its arguments together with spaces after
trimming leading and trailing white-space from each of them. If all of the
arguments are lists, this has the same effect as concatenating them
into a single list.
+Arguments that are empty (after trimming) are ignored entirely.
It permits any number of arguments;
if no \fIarg\fRs are supplied, the result is an empty string.
.SH EXAMPLES
diff --git a/doc/expr.n b/doc/expr.n
index b76b6a2..cbb2395 100644
--- a/doc/expr.n
+++ b/doc/expr.n
@@ -17,14 +17,14 @@ expr \- Evaluate an expression
.BE
.SH DESCRIPTION
.PP
-Concatenates \fIarg\fRs (adding separator spaces between them),
-evaluates the result as a Tcl expression, and returns the value.
-The operators permitted in Tcl expressions include a subset of
+Concatenates \fIarg\fRs, separated by a space, into an expression, and evaluates
+that expression, returning its value.
+The operators permitted in an expression include a subset of
the operators permitted in C expressions. For those operators
common to both Tcl and C, Tcl applies the same meaning and precedence
as the corresponding C operators.
-Expressions almost always yield numeric results
-(integer or floating-point values).
+The value of an expression is often a numeric result, either an integer or a
+floating-point value, but may also be a non-numeric value.
For example, the expression
.PP
.CS
@@ -32,78 +32,68 @@ For example, the expression
.CE
.PP
evaluates to 14.2.
-Tcl expressions differ from C expressions in the way that
-operands are specified. Also, Tcl expressions support
-non-numeric operands and string comparisons, as well as some
+Expressions differ from C expressions in the way that
+operands are specified. Expressions also support
+non-numeric operands, string comparisons, and some
additional operators not found in C.
+.PP
+When an expression evaluates to an integer, the value is the decimal form of
+the integer, and when an expression evaluates to a floating-point number, the
+value is the form produced by the \fB%g\fR format specifier of Tcl's
+\fBformat\fR command.
.SS OPERANDS
.PP
-A Tcl expression consists of a combination of operands, operators,
-parentheses and commas.
-White space may be used between the operands and operators and
-parentheses (or commas); it is ignored by the expression's instructions.
-Where possible, operands are interpreted as integer values.
-Integer values may be specified in decimal (the normal case), in binary
-(if the first two characters of the operand are \fB0b\fR), in octal
-(if the first two characters of the operand are \fB0o\fR), or in hexadecimal
-(if the first two characters of the operand are \fB0x\fR). For
-compatibility with older Tcl releases, an octal integer value is also
-indicated simply when the first character of the operand is \fB0\fR,
-whether or not the second character is also \fBo\fR.
-If an operand does not have one of the integer formats given
-above, then it is treated as a floating-point number if that is
-possible. Floating-point numbers may be specified in any of several
-common formats making use of the decimal digits, the decimal point \fB.\fR,
-the characters \fBe\fR or \fBE\fR indicating scientific notation, and
-the sign characters \fB+\fR or \fB\-\fR. For example, all of the
-following are valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16.
-Also recognized as floating point values are the strings \fBInf\fR
-and \fBNaN\fR making use of any case for each character.
-If no numeric interpretation is possible (note that all literal
-operands that are not numeric or boolean must be quoted with either
-braces or with double quotes), then an operand is left as a string
-(and only a limited set of operators may be applied to it).
-.PP
-Operands may be specified in any of the following ways:
+An expression consists of a combination of operands, operators, parentheses and
+commas, possibly with whitespace between any of these elements, which is
+ignored.
+An integer operand may be specified in decimal, binary
+(the first two characters are \fB0b\fR), octal
+(the first two characters are \fB0o\fR), or hexadecimal
+(the first two characters are \fB0x\fR) form. For
+compatibility with older Tcl releases, an operand that begins with \fB0\fR is
+interpreted as an octal integer even if the second character is not \fBo\fR.
+A floating-point number may be specified in any of several
+common decimal formats, and may use the decimal point \fB.\fR,
+\fBe\fR or \fBE\fR for scientific notation, and
+the sign characters \fB+\fR and \fB\-\fR. The
+following are all valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16.
+The strings \fBInf\fR
+and \fBNaN\fR, in any combination of case, are also recognized as floating point
+values. An operand that doesn't have a numeric interpretation must be quoted
+with either braces or with double quotes.
+.PP
+An operand may be specified in any of the following ways:
.IP [1]
As a numeric value, either integer or floating-point.
.IP [2]
As a boolean value, using any form understood by \fBstring is\fR
\fBboolean\fR.
.IP [3]
-As a Tcl variable, using standard \fB$\fR notation.
-The variable's value will be used as the operand.
+As a variable, using standard \fB$\fR notation.
+The value of the variable is then the value of the operand.
.IP [4]
As a string enclosed in double-quotes.
-The expression parser will perform backslash, variable, and
-command substitutions on the information between the quotes,
-and use the resulting value as the operand
+Backslash, variable, and command substitution are performed as described in
+\fBTcl\fR.
.IP [5]
As a string enclosed in braces.
-The characters between the open brace and matching close brace
-will be used as the operand without any substitutions.
+The operand is treated as a braced value as described in \fBTcl\fR.
.IP [6]
As a Tcl command enclosed in brackets.
-The command will be executed and its result will be used as
-the operand.
+Command substitution is performed as described in \fBTcl\fR.
.IP [7]
-As a mathematical function whose arguments have any of the above
-forms for operands, such as \fBsin($x)\fR. See \fBMATH FUNCTIONS\fR below for
+As a mathematical function such as \fBsin($x)\fR, whose arguments have any of the above
+forms for operands. See \fBMATH FUNCTIONS\fR below for
a discussion of how mathematical functions are handled.
.PP
-Where the above substitutions occur (e.g. inside quoted strings), they
-are performed by the expression's instructions.
-However, the command parser may already have performed one round of
-substitution before the expression processor was called.
-As discussed below, it is usually best to enclose expressions
-in braces to prevent the command parser from performing substitutions
-on the contents.
+Because \fBexpr\fR parses and performs substitutions on values that have
+already been parsed and substituted by \fBTcl\fR, it is usually best to enclose
+expressions in braces to avoid the first round of substitutions by
+\fBTcl\fR.
.PP
-For some examples of simple expressions, suppose the variable
-\fBa\fR has the value 3 and
-the variable \fBb\fR has the value 6.
-Then the command on the left side of each of the lines below
-will produce the value on the right side of the line:
+Below are some examples of simple expressions where the value of \fBa\fR is 3
+and the value of \fBb\fR is 6. The command on the left side of each line
+produces the value on the right side.
.PP
.CS
.ta 6c
@@ -114,34 +104,41 @@ will produce the value on the right side of the line:
.CE
.SS OPERATORS
.PP
-The valid operators (most of which are also available as commands in
-the \fBtcl::mathop\fR namespace; see the \fBmathop\fR(n) manual page
-for details) are listed below, grouped in decreasing order of precedence:
+For operators having both a numeric mode and a string mode, the numeric mode is
+chosen when all operands have a numeric interpretation. The integer
+interpretation of an operand is preferred over the floating-point
+interpretation. To ensure string operations on arbitrary values it is generally a
+good idea to use \fBeq\fR, \fBne\fR, or the \fBstring\fR command instead of
+more versatile operators such as \fB==\fR.
+.PP
+Unless otherwise specified, operators accept non-numeric operands. The value
+of a boolean operation is 1 if true, 0 otherwise. See also \fBstring is\fR
+\fBboolean\fR. The valid operators, most of which are also available as
+commands in the \fBtcl::mathop\fR namespace (see \fBmathop\fR(n)), are listed
+below, grouped in decreasing order of precedence:
.TP 20
\fB\-\0\0+\0\0~\0\0!\fR
.
-Unary minus, unary plus, bit-wise NOT, logical NOT. None of these operators
-may be applied to string operands, and bit-wise NOT may be
-applied only to integers.
+Unary minus, unary plus, bit-wise NOT, logical NOT. These operators
+may only be applied to numeric operands, and bit-wise NOT may only be
+applied to integers.
.TP 20
\fB**\fR
.
-Exponentiation. Valid for any numeric operands.
+Exponentiation. Valid for numeric operands.
.TP 20
\fB*\0\0/\0\0%\fR
.
-Multiply, divide, remainder. None of these operators may be
-applied to string operands, and remainder may be applied only
-to integers.
-The remainder will always have the same sign as the divisor and
-an absolute value smaller than the absolute value of the divisor.
+Multiply and divide, which are valid for numeric operands, and remainder, which
+is valid for integers. The remainder, an absolute value smaller than the
+absolute value of the divisor, has the same sign as the divisor.
.RS
.PP
-When applied to integers, the division and remainder operators can be
-considered to partition the number line into a sequence of equal-sized
-adjacent non-overlapping pieces where each piece is the size of the divisor;
-the division result identifies which piece the divisor lay within, and the
-remainder result identifies where within that piece the divisor lay. A
+When applied to integers, division and remainder can be
+considered to partition the number line into a sequence of
+adjacent non-overlapping pieces, where each piece is the size of the divisor;
+the quotient identifies which piece the dividend lies within, and the
+remainder identifies where within that piece the dividend lies. A
consequence of this is that the result of
.QW "-57 \fB/\fR 10"
is always -6, and the result of
@@ -151,177 +148,157 @@ is always 3.
.TP 20
\fB+\0\0\-\fR
.
-Add and subtract. Valid for any numeric operands.
+Add and subtract. Valid for numeric operands.
.TP 20
\fB<<\0\0>>\fR
.
-Left and right shift. Valid for integer operands only.
+Left and right shift. Valid for integers.
A right shift always propagates the sign bit.
.TP 20
\fB<\0\0>\0\0<=\0\0>=\fR
.
-Boolean less, greater, less than or equal, and greater than or equal.
-Each operator produces 1 if the condition is true, 0 otherwise.
-These operators may be applied to strings as well as numeric operands,
-in which case string comparison is used.
+Boolean less than, greater than, less than or equal, and greater than or equal.
.TP 20
\fB==\0\0!=\fR
.
-Boolean equal and not equal. Each operator produces a zero/one result.
-Valid for all operand types.
+Boolean equal and not equal.
.TP 20
\fBeq\0\0ne\fR
.
-Boolean string equal and string not equal. Each operator produces a
-zero/one result. The operand types are interpreted only as strings.
+Boolean string equal and string not equal.
.TP 20
\fBin\0\0ni\fR
.
-List containment and negated list containment. Each operator produces
-a zero/one result and treats its first argument as a string and its
-second argument as a Tcl list. The \fBin\fR operator indicates
-whether the first argument is a member of the second argument list;
-the \fBni\fR operator inverts the sense of the result.
+List containment and negated list containment. The first argument is
+interpreted as a string, the second as a list. \fBin\fR tests for membership
+in the list, and \fBni\fR is the inverse.
.TP 20
\fB&\fR
.
-Bit-wise AND. Valid for integer operands only.
+Bit-wise AND. Valid for integer operands.
.TP 20
\fB^\fR
.
-Bit-wise exclusive OR. Valid for integer operands only.
+Bit-wise exclusive OR. Valid for integer operands.
.TP 20
\fB|\fR
.
-Bit-wise OR. Valid for integer operands only.
+Bit-wise OR. Valid for integer operands.
.TP 20
\fB&&\fR
.
-Logical AND. Produces a 1 result if both operands are non-zero,
-0 otherwise.
-Valid for boolean and numeric (integers or floating-point) operands only.
+Logical AND. If both operands are true, the result is 1, or 0 otherwise.
+
.TP 20
\fB||\fR
.
-Logical OR. Produces a 0 result if both operands are zero, 1 otherwise.
-Valid for boolean and numeric (integers or floating-point) operands only.
+Logical OR. If both operands are false, the result is 0, or 1 otherwise.
.TP 20
\fIx\fB?\fIy\fB:\fIz\fR
.
-If-then-else, as in C. If \fIx\fR
-evaluates to non-zero, then the result is the value of \fIy\fR.
-Otherwise the result is the value of \fIz\fR.
-The \fIx\fR operand must have a boolean or numeric value.
-.PP
-See the C manual for more details on the results
-produced by each operator.
-The exponentiation operator promotes types like the multiply and
-divide operators, and produces a result that is the same as the output
-of the \fBpow\fR function (after any type conversions.)
-All of the binary operators but exponentiation group left-to-right
-within the same precedence level; exponentiation groups right-to-left. For example, the command
+If-then-else, as in C. If \fIx\fR is false , the result is the value of
+\fIy\fR. Otherwise the result is the value of \fIz\fR.
+.PP
+The exponentiation operator promotes types in the same way that the multiply
+and divide operators do, and the result is is the same as the result of
+\fBpow\fR.
+Exponentiation groups right-to-left within a precedence level. Other binary
+operators group left-to-right. For example, the value of
.PP
.CS
\fBexpr\fR {4*2 < 7}
.CE
.PP
-returns 0, while
+is 0, while the value of
.PP
.CS
\fBexpr\fR {2**3**2}
.CE
.PP
-returns 512.
+is 512.
.PP
-The \fB&&\fR, \fB||\fR, and \fB?:\fR operators have
+As in C, \fB&&\fR, \fB||\fR, and \fB?:\fR feature
.QW "lazy evaluation" ,
-just as in C, which means that operands are not evaluated if they are
-not needed to determine the outcome. For example, in the command
+which means that operands are not evaluated if they are
+not needed to determine the outcome. For example, in
.PP
.CS
\fBexpr\fR {$v ? [a] : [b]}
.CE
.PP
-only one of
-.QW \fB[a]\fR
-or
-.QW \fB[b]\fR
-will actually be evaluated,
-depending on the value of \fB$v\fR. Note, however, that this is
-only true if the entire expression is enclosed in braces; otherwise
-the Tcl parser will evaluate both
-.QW \fB[a]\fR
-and
-.QW \fB[b]\fR
-before invoking the \fBexpr\fR command.
+only one of \fB[a]\fR or \fB[b]\fR is evaluated,
+depending on the value of \fB$v\fR. This is not true of the normal Tcl parser,
+so it is normally recommended to enclose the arguments to \fBexpr\fR in braces.
+Without braces, as in
+\fBexpr\fR $v ? [a] : [b]
+both \fB[a]\fR and \fB[b]\fR are evaluated before \fBexpr\fR is even called.
+.PP
+For more details on the results
+produced by each operator, see the documentation for C.
.SS "MATH FUNCTIONS"
.PP
-When the expression parser encounters a mathematical function
-such as \fBsin($x)\fR, it replaces it with a call to an ordinary
-Tcl function in the \fBtcl::mathfunc\fR namespace. The processing
-of an expression such as:
+A mathematical function such as \fBsin($x)\fR is replaced with a call to an ordinary
+Tcl command in the \fBtcl::mathfunc\fR namespace. The evaluation
+of an expression such as
.PP
.CS
\fBexpr\fR {sin($x+$y)}
.CE
.PP
-is the same in every way as the processing of:
+is the same in every way as the evaluation of
.PP
.CS
\fBexpr\fR {[tcl::mathfunc::sin [\fBexpr\fR {$x+$y}]]}
.CE
.PP
-which in turn is the same as the processing of:
+which in turn is the same as the evaluation of
.PP
.CS
tcl::mathfunc::sin [\fBexpr\fR {$x+$y}]
.CE
.PP
-The executor will search for \fBtcl::mathfunc::sin\fR using the usual
-rules for resolving functions in namespaces. Either
-\fB::tcl::mathfunc::sin\fR or \fB[namespace
-current]::tcl::mathfunc::sin\fR will satisfy the request, and others
-may as well (depending on the current \fBnamespace path\fR setting).
+\fBtcl::mathfunc::sin\fR is resolved as described in
+\fBNAMESPACE RESOLUTION\fR in the \fBnamespace\fR(n) documentation. Given the
+default value of \fBnamespace path\fR, \fB[namespace
+current]::tcl::mathfunc::sin\fR or \fB::tcl::mathfunc::sin\fR are the typical
+resolutions.
.PP
-Some mathematical functions have several arguments, separated by commas like in C. Thus:
+As in C, a mathematical function may accept multiple arguments separated by commas. Thus,
.PP
.CS
\fBexpr\fR {hypot($x,$y)}
.CE
.PP
-ends up as
+becomes
.PP
.CS
tcl::mathfunc::hypot $x $y
.CE
.PP
-See the \fBmathfunc\fR(n) manual page for the math functions that are
+See the \fBmathfunc\fR(n) documentation for the math functions that are
available by default.
.SS "TYPES, OVERFLOW, AND PRECISION"
.PP
-All internal computations involving integers are done calling on the
-LibTomMath multiple precision integer library as required so that all
-integer calculations are performed exactly. Note that in Tcl releases
-prior to 8.5, integer calculations were performed with one of the C types
+When needed to guarantee exact performance, internal computations involving
+integers use the LibTomMath multiple precision integer library. In Tcl releases
+prior to 8.5, integer calculations were performed using one of the C types
\fIlong int\fR or \fITcl_WideInt\fR, causing implicit range truncation
in those calculations where values overflowed the range of those types.
-Any code that relied on these implicit truncations will need to explicitly
-add \fBint()\fR or \fBwide()\fR function calls to expressions at the points
-where such truncation is required to take place.
+Any code that relied on these implicit truncations should instead call
+\fBint()\fR or \fBwide()\fR, which do truncate.
.PP
-All internal computations involving floating-point are
-done with the C type \fIdouble\fR.
-When converting a string to floating-point, exponent overflow is
+Internal floating-point computations are
+performed using the \fIdouble\fR C type.
+When converting a string to floating-point value, exponent overflow is
detected and results in the \fIdouble\fR value of \fBInf\fR or
\fB\-Inf\fR as appropriate. Floating-point overflow and underflow
are detected to the degree supported by the hardware, which is generally
-pretty reliable.
+fairly reliable.
.PP
-Conversion among internal representations for integer, floating-point,
-and string operands is done automatically as needed.
-For arithmetic computations, integers are used until some
-floating-point number is introduced, after which floating-point is used.
-For example,
+Conversion among internal representations for integer, floating-point, and
+string operands is done automatically as needed. For arithmetic computations,
+integers are used until some floating-point number is introduced, after which
+floating-point values are used. For example,
.PP
.CS
\fBexpr\fR {5 / 4}
@@ -335,82 +312,62 @@ returns 1, while
.CE
.PP
both return 1.25.
-Floating-point values are always returned with a
+A floating-point result can be distinguished from an integer result by the
+presence of either
.QW \fB.\fR
-or an
+or
.QW \fBe\fR
-so that they will not look like integer values. For example,
+.PP
+. For example,
.PP
.CS
\fBexpr\fR {20.0/5.0}
.CE
.PP
returns \fB4.0\fR, not \fB4\fR.
-.SS "STRING OPERATIONS"
-.PP
-String values may be used as operands of the comparison operators,
-although the expression evaluator tries to do comparisons as integer
-or floating-point when it can,
-i.e., when all arguments to the operator allow numeric interpretations,
-except in the case of the \fBeq\fR and \fBne\fR operators.
-If one of the operands of a comparison is a string and the other
-has a numeric value, a canonical string representation of the numeric
-operand value is generated to compare with the string operand.
-Canonical string representation for integer values is a decimal string
-format. Canonical string representation for floating-point values
-is that produced by the \fB%g\fR format specifier of Tcl's
-\fBformat\fR command. For example, the commands
-.PP
-.CS
-\fBexpr\fR {"0x03" > "2"}
-\fBexpr\fR {"0y" > "0x12"}
-.CE
-.PP
-both return 1. The first comparison is done using integer
-comparison, and the second is done using string comparison.
-Because of Tcl's tendency to treat values as numbers whenever
-possible, it is not generally a good idea to use operators like \fB==\fR
-when you really want string comparison and the values of the
-operands could be arbitrary; it is better in these cases to use
-the \fBeq\fR or \fBne\fR operators, or the \fBstring\fR command instead.
.SH "PERFORMANCE CONSIDERATIONS"
.PP
-Enclose expressions in braces for the best speed and the smallest
-storage requirements.
-This allows the Tcl bytecode compiler to generate the best code.
-.PP
-As mentioned above, expressions are substituted twice:
-once by the Tcl parser and once by the \fBexpr\fR command.
-For example, the commands
+Where an expression contains syntax that Tcl would otherwise perform
+substitutions on, enclosing an expression in braces or otherwise quoting it
+so that it's a static value allows the Tcl compiler to generate bytecode for
+the expression, resulting in better speed and smaller storage requirements.
+This also avoids issues that can arise if Tcl is allowed to perform
+substitution on the value before \fBexpr\fR is called.
.PP
+In the following example, the value of the expression is 11 because the Tcl parser first
+substitutes \fB$b\fR and \fBexpr\fR then substitutes \fB$a\fR. Enclosing the
+expression in braces would result in a syntax error.
.CS
set a 3
set b {$a + 2}
\fBexpr\fR $b*4
.CE
.PP
-return 11, not a multiple of 4.
-This is because the Tcl parser will first substitute \fB$a + 2\fR for
-the variable \fBb\fR,
-then the \fBexpr\fR command will evaluate the expression \fB$a + 2*4\fR.
-.PP
-Most expressions do not require a second round of substitutions.
-Either they are enclosed in braces or, if not,
-their variable and command substitutions yield numbers or strings
-that do not themselves require substitutions.
-However, because a few unbraced expressions
-need two rounds of substitutions,
-the bytecode compiler must emit
-additional instructions to handle this situation.
-The most expensive code is required for
-unbraced expressions that contain command substitutions.
-These expressions must be implemented by generating new code
-each time the expression is executed.
-When the expression is unbraced to allow the substitution of a function or
-operator, consider using the commands documented in the \fBmathfunc\fR(n) or
-\fBmathop\fR(n) manual pages directly instead.
+
+When an expression is generated at runtime, like the one above is, the bytcode
+compiler must ensure that new code is generated each time the expression
+is evaluated. This is the most costly kind of expression from a performance
+perspective. In such cases, consider directly using the commands described in
+the \fBmathfunc\fR(n) or \fBmathop\fR(n) documentation instead of \fBexpr\fR.
+
+Most expressions are not formed at runtime, but are literal strings or contain
+substitutions that don't introduce other substitutions. To allow the bytecode
+compiler to work with an expression as a string literal at compilation time,
+ensure that it contains no substitutions or that it is enclosed in braces or
+otherwise quoted to prevent Tcl from performing substitutions, allowing
+\fBexpr\fR to perform them instead.
.SH EXAMPLES
.PP
+A numeric comparison whose result is 1:
+.CS
+\fBexpr\fR {"0x03" > "2"}
+.CE
+.PP
+A string comparison whose result is 1:
+.CS
+\fBexpr\fR {"0y" > "0x12"}
+.CE
+.PP
Define a procedure that computes an
.QW interesting
mathematical function:
@@ -444,8 +401,8 @@ each other:
puts "a and b are [\fBexpr\fR {$a eq $b ? {equal} : {different}}]"
.CE
.PP
-Set a variable to whether an environment variable is both defined at
-all and also set to a true boolean value:
+Set a variable indicating whether an environment variable is defined and has
+value of true:
.PP
.CS
set isTrue [\fBexpr\fR {
diff --git a/doc/file.n b/doc/file.n
index 2f8b70c..ad35dd5 100644
--- a/doc/file.n
+++ b/doc/file.n
@@ -390,7 +390,7 @@ that use the third component do not attempt to perform tilde
substitution.
.RE
.TP
-\fBfile stat \fIname varName\fR
+\fBfile stat \fIname varName\fR
.
Invokes the \fBstat\fR kernel call on \fIname\fR, and uses the variable
given by \fIvarName\fR to hold information returned from the kernel call.
diff --git a/doc/http.n b/doc/http.n
index 80ae044..40ced23 100644
--- a/doc/http.n
+++ b/doc/http.n
@@ -418,7 +418,10 @@ set token [::http::geturl https://my.secure.site/]
\fB::http::unregister\fR \fIproto\fR
.
This procedure unregisters a protocol handler that was previously
-registered via \fB::http::register\fR.
+registered via \fB::http::register\fR, returning a two-item list of
+the default port and handler command that was previously installed
+(via \fB::http::register\fR) if there was such a handler, and an error if
+there was no such handler.
.SH ERRORS
The \fB::http::geturl\fR procedure will raise errors in the following cases:
invalid command line options,
diff --git a/doc/info.n b/doc/info.n
index 477e272..c3a62c9 100644
--- a/doc/info.n
+++ b/doc/info.n
@@ -297,10 +297,11 @@ scripts are stored.
This is actually the value of the \fBtcl_library\fR
variable and may be changed by setting \fBtcl_library\fR.
.TP
-\fBinfo loaded \fR?\fIinterp\fR?
+\fBinfo loaded \fR?\fIinterp\fR? ?\fIpackage\fR?
.
-Returns a list describing all of the packages that have been loaded into
-\fIinterp\fR with the \fBload\fR command.
+Returns the filename loaded as part of \fIpackage\fR. If \fIpackage\fR
+is not specified, returns a list describing all of the packages
+that have been loaded into \fIinterp\fR with the \fBload\fR command.
Each list element is a sub-list with two elements consisting of the
name of the file from which the package was loaded and the name of
the package.
diff --git a/doc/lsort.n b/doc/lsort.n
index b0f7973..c3245b2 100644
--- a/doc/lsort.n
+++ b/doc/lsort.n
@@ -40,7 +40,8 @@ except (a) case is ignored except as a tie-breaker and (b) if two
strings contain embedded numbers, the numbers compare as integers,
not characters. For example, in \fB\-dictionary\fR mode, \fBbigBoy\fR
sorts between \fBbigbang\fR and \fBbigboy\fR, and \fBx10y\fR
-sorts between \fBx9y\fR and \fBx11y\fR.
+sorts between \fBx9y\fR and \fBx11y\fR. Overrides the \fB\-nocase\fR
+option.
.TP
\fB\-integer\fR
.
diff --git a/doc/package.n b/doc/package.n
index 47b2aa6..5687480 100644
--- a/doc/package.n
+++ b/doc/package.n
@@ -12,6 +12,7 @@
package \- Facilities for package loading and version control
.SH SYNOPSIS
.nf
+\fBpackage files\fR \fIpackage\fR
\fBpackage forget\fR ?\fIpackage package ...\fR?
\fBpackage ifneeded \fIpackage version\fR ?\fIscript\fR?
\fBpackage names\fR
@@ -43,6 +44,13 @@ primarily by system scripts that maintain the package database.
The behavior of the \fBpackage\fR command is determined by its first argument.
The following forms are permitted:
.TP
+\fBpackage files\fR \fIpackage\fR
+.
+Lists all files forming part of \fIpackage\fR. Auto-loaded files are not
+included in this list, only files which were directly sourced during package
+initialization. The list order corresponds with the order in which the
+files were sourced.
+.TP
\fBpackage forget\fR ?\fIpackage package ...\fR?
.
Removes all information about each specified package from this interpreter,
diff --git a/doc/re_syntax.n b/doc/re_syntax.n
index 7988071..8d732ed 100644
--- a/doc/re_syntax.n
+++ b/doc/re_syntax.n
@@ -293,12 +293,12 @@ treatment is as if the enclosing delimiters were
.QW \fB[.\fR \&
and
.QW \fB.]\fR .)
-For example, if \fBo\fR and \fB\*(qo\fR are the members of an
+For example, if \fBo\fR and \fB\[^o]\fR are the members of an
equivalence class, then
.QW \fB[[=o=]]\fR ,
-.QW \fB[[=\*(qo=]]\fR ,
+.QW \fB[[=\[^o]=]]\fR ,
and
-.QW \fB[o\*(qo]\fR \&
+.QW \fB[o\[^o]]\fR \&
are all synonymous. An equivalence class may not be an endpoint of a range.
.RS
.PP
diff --git a/doc/scan.n b/doc/scan.n
index d963d6c..0c24fea 100644
--- a/doc/scan.n
+++ b/doc/scan.n
@@ -123,9 +123,7 @@ with conversion character \fBu\fR.
.TP
\fBi\fR
.
-The input substring must be an integer. The base (i.e. decimal, binary,
-octal, or hexadecimal) is determined in the same fashion as described in
-\fBexpr\fR. The integer value is stored in the variable,
+The input substring must be an integer. The base (i.e. decimal, octal, or hexadecimal) is determined by the C convention (leading 0 for octal; prefix 0x for hexadecimal). The integer value is stored in the variable,
truncated as required by the size modifier value.
.TP
\fBc\fR
diff --git a/doc/socket.n b/doc/socket.n
index 3efdb37..823dbd5 100644
--- a/doc/socket.n
+++ b/doc/socket.n
@@ -131,6 +131,16 @@ wildcard address so that it can accept connections from any
interface. If \fIaddr\fR is a domain name that resolves to multiple IP
addresses that are available on the local machine, the socket will
listen on all of them.
+.TP
+\fB\-reuseaddr\fI boolean\fR
+.
+Tells the kernel whether to reuse the local address if there is no socket
+actively listening on it. This is the default on Windows.
+.TP
+\fB\-reuseport\fI boolean\fR
+.
+Tells the kernel whether to allow the binding of multiple sockets to the same
+address and port.
.PP
Server channels cannot be used for input or output; their sole use is to
accept new client connections. The channels created for each incoming
diff --git a/doc/variable.n b/doc/variable.n
index a6e545f..8228859 100644
--- a/doc/variable.n
+++ b/doc/variable.n
@@ -45,7 +45,8 @@ linked to the corresponding namespace variables (and therefore these
variables are listed by \fBinfo vars\fR.)
In this way the \fBvariable\fR command resembles the \fBglobal\fR command,
although the \fBglobal\fR command
-only links to variables in the global namespace.
+resolves variable names with respect to the global namespace instead
+of the current namespace of the procedure.
If any \fIvalue\fRs are given,
they are used to modify the values of the associated namespace variables.
If a namespace variable does not exist,
@@ -98,3 +99,7 @@ namespace eval foo {
global(n), namespace(n), upvar(n)
.SH KEYWORDS
global, namespace, procedure, variable
+.\" Local variables:
+.\" mode: nroff
+.\" fill-column: 78
+.\" End:
diff --git a/generic/regc_lex.c b/generic/regc_lex.c
index affcb48..4c8f15f 100644
--- a/generic/regc_lex.c
+++ b/generic/regc_lex.c
@@ -457,7 +457,7 @@ next(
if (ATEOS()) {
FAILW(REG_EESCAPE);
}
- (DISCARD)lexescape(v);
+ (void)lexescape(v);
switch (v->nexttype) { /* not all escapes okay here */
case PLAIN:
return 1;
@@ -716,7 +716,7 @@ next(
}
RETV(PLAIN, *v->now++);
}
- (DISCARD)lexescape(v);
+ (void)lexescape(v);
if (ISERR()) {
FAILW(REG_EESCAPE);
}
@@ -1143,7 +1143,7 @@ skip(
/*
- newline - return the chr for a newline
* This helps confine use of CHR to this source file.
- ^ static chr newline(NOPARMS);
+ ^ static chr newline(void);
*/
static chr
newline(void)
diff --git a/generic/regc_locale.c b/generic/regc_locale.c
index a6958fe..ab3b7f1 100644
--- a/generic/regc_locale.c
+++ b/generic/regc_locale.c
@@ -1227,7 +1227,7 @@ cmp(
const chr *x, const chr *y, /* strings to compare */
size_t len) /* exact length of comparison */
{
- return memcmp(VS(x), VS(y), len*sizeof(chr));
+ return memcmp((void*)(x), (void*)(y), len*sizeof(chr));
}
/*
diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c
index 088c6c0..240fcfe 100644
--- a/generic/regc_nfa.c
+++ b/generic/regc_nfa.c
@@ -843,7 +843,7 @@ moveins(
/*
- copyins - copy in arcs of a state to another state
- ^ static VOID copyins(struct nfa *, struct state *, struct state *, int);
+ ^ static void copyins(struct nfa *, struct state *, struct state *, int);
*/
static void
copyins(
@@ -1100,7 +1100,7 @@ moveouts(
/*
- copyouts - copy out arcs of a state to another state
- ^ static VOID copyouts(struct nfa *, struct state *, struct state *, int);
+ ^ static void copyouts(struct nfa *, struct state *, struct state *, int);
*/
static void
copyouts(
diff --git a/generic/regcomp.c b/generic/regcomp.c
index 211cd70..58d55fb 100644
--- a/generic/regcomp.c
+++ b/generic/regcomp.c
@@ -82,7 +82,7 @@ static int lexescape(struct vars *);
static int lexdigits(struct vars *, int, int, int);
static int brenext(struct vars *, pchr);
static void skip(struct vars *);
-static chr newline(NOPARMS);
+static chr newline(void);
static chr chrnamed(struct vars *, const chr *, const chr *, pchr);
/* === regc_color.c === */
static void initcm(struct vars *, struct colormap *);
@@ -341,13 +341,13 @@ compile(
re->re_info = 0; /* bits get set during parse */
re->re_csize = sizeof(chr);
re->re_guts = NULL;
- re->re_fns = VS(&functions);
+ re->re_fns = (void*)(&functions);
/*
* More complex setup, malloced things.
*/
- re->re_guts = VS(MALLOC(sizeof(struct guts)));
+ re->re_guts = (void*)(MALLOC(sizeof(struct guts)));
if (re->re_guts == NULL) {
return freev(v, REG_ESPACE);
}
@@ -434,7 +434,7 @@ compile(
* Can sacrifice main NFA now, so use it as work area.
*/
- (DISCARD) optimize(v->nfa, debug);
+ (void) optimize(v->nfa, debug);
CNOERR();
makesearch(v, v->nfa);
CNOERR();
@@ -1920,10 +1920,10 @@ nfatree(
assert(t != NULL && t->begin != NULL);
if (t->left != NULL) {
- (DISCARD) nfatree(v, t->left, f);
+ (void) nfatree(v, t->left, f);
}
if (t->right != NULL) {
- (DISCARD) nfatree(v, t->right, f);
+ (void) nfatree(v, t->right, f);
}
return nfanode(v, t, f);
diff --git a/generic/regcustom.h b/generic/regcustom.h
index 681b97d..c4dbc73 100644
--- a/generic/regcustom.h
+++ b/generic/regcustom.h
@@ -36,10 +36,9 @@
* Overrides for regguts.h definitions, if any.
*/
-#define FUNCPTR(name, args) (*name)args
-#define MALLOC(n) VS(attemptckalloc(n))
-#define FREE(p) ckfree(VS(p))
-#define REALLOC(p,n) VS(attemptckrealloc(VS(p),n))
+#define MALLOC(n) (void*)(attemptckalloc(n))
+#define FREE(p) ckfree((void*)(p))
+#define REALLOC(p,n) (void*)(attemptckrealloc((void*)(p),n))
/*
* Do not insert extras between the "begin" and "end" lines - this chunk is
diff --git a/generic/regexec.c b/generic/regexec.c
index 6d12827..128d439 100644
--- a/generic/regexec.c
+++ b/generic/regexec.c
@@ -44,7 +44,7 @@ struct sset { /* state set */
unsigned hash; /* hash of bitvector */
#define HASH(bv, nw) (((nw) == 1) ? *(bv) : hash(bv, nw))
#define HIT(h,bv,ss,nw) ((ss)->hash == (h) && ((nw) == 1 || \
- memcmp(VS(bv), VS((ss)->states), (nw)*sizeof(unsigned)) == 0))
+ memcmp((void*)(bv), (void*)((ss)->states), (nw)*sizeof(unsigned)) == 0))
int flags;
#define STARTER 01 /* the initial state set */
#define POSTSTATE 02 /* includes the goal state */
@@ -268,7 +268,7 @@ exec(
if (st == REG_OKAY && v->pmatch != pmatch && nmatch > 0) {
zapallsubs(pmatch, nmatch);
n = (nmatch < v->nmatch) ? nmatch : v->nmatch;
- memcpy(VS(pmatch), VS(v->pmatch), n*sizeof(regmatch_t));
+ memcpy((void*)(pmatch), (void*)(v->pmatch), n*sizeof(regmatch_t));
}
/*
diff --git a/generic/regguts.h b/generic/regguts.h
index 1ac2465..ad9d5b9 100644
--- a/generic/regguts.h
+++ b/generic/regguts.h
@@ -49,41 +49,15 @@
#include <assert.h>
#endif
-/* voids */
-#ifndef VOID
-#define VOID void /* for function return values */
-#endif
-#ifndef DISCARD
-#define DISCARD void /* for throwing values away */
-#endif
-#ifndef PVOID
-#define PVOID void * /* generic pointer */
-#endif
-#ifndef VS
-#define VS(x) ((void*)(x)) /* cast something to generic ptr */
-#endif
-#ifndef NOPARMS
-#define NOPARMS void /* for empty parm lists */
-#endif
-
-/* function-pointer declarator */
-#ifndef FUNCPTR
-#if __STDC__ >= 1
-#define FUNCPTR(name, args) (*name)args
-#else
-#define FUNCPTR(name, args) (*name)()
-#endif
-#endif
-
/* memory allocation */
#ifndef MALLOC
#define MALLOC(n) malloc(n)
#endif
#ifndef REALLOC
-#define REALLOC(p, n) realloc(VS(p), n)
+#define REALLOC(p, n) realloc(p, n)
#endif
#ifndef FREE
-#define FREE(p) free(VS(p))
+#define FREE(p) free(p)
#endif
/* want size of a char in bits, and max value in bounded quantifiers */
@@ -408,7 +382,7 @@ struct subre {
*/
struct fns {
- void FUNCPTR(free, (regex_t *));
+ void (*free) (regex_t *);
};
/*
@@ -425,7 +399,7 @@ struct guts {
struct cnfa search; /* for fast preliminary search */
int ntree; /* number of subre's, plus one */
struct colormap cmap;
- int FUNCPTR(compare, (const chr *, const chr *, size_t));
+ int (*compare) (const chr *, const chr *, size_t);
struct subre *lacons; /* lookahead-constraint vector */
int nlacons; /* size of lacons */
};
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 574b49b..b2b91a9 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -1059,7 +1059,7 @@ declare 293 {
int Tcl_EvalObjEx(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags)
}
declare 294 {
- void Tcl_ExitThread(int status)
+ TCL_NORETURN void Tcl_ExitThread(int status)
}
declare 295 {
int Tcl_ExternalToUtf(Tcl_Interp *interp, Tcl_Encoding encoding,
@@ -2326,6 +2326,17 @@ declare 630 {
# ----- BASELINE -- FOR -- 8.6.0 ----- #
+# TIP #456
+declare 631 {
+ Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp, const char *service,
+ const char *host, unsigned int flags, Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData)
+}
+
+# ----- BASELINE -- FOR -- 8.7.0 ----- #
+
+
+
##############################################################################
# Define the platform specific public Tcl interface. These functions are only
diff --git a/generic/tcl.h b/generic/tcl.h
index ded8d0b..6ec47c6 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -41,7 +41,6 @@ extern "C" {
* unix/configure.ac (2 LOC Major, 2 LOC minor, 1 LOC patch)
* win/configure.ac (as above)
* win/tcl.m4 (not patchlevel)
- * win/makefile.bc (not patchlevel) 2 LOC
* README (sections 0 and 2, with and without separator)
* macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 1 LOC
* macosx/Tcl.pbproj/default.pbxuser (not patchlevel) 1 LOC
@@ -376,8 +375,8 @@ typedef long LONG;
* we have one, we can have the other.)
*
* Also defines the following macros:
- * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a real
- * 64-bit system.)
+ * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a
+ * LP64 system such as modern Solaris or Linux ... not including Win64)
* Tcl_WideAsLong - forgetful converter from wideInt to long.
* Tcl_LongAsWide - sign-extending converter from long to wideInt.
* Tcl_WideAsDouble - converter from wideInt to double.
@@ -394,11 +393,7 @@ typedef long LONG;
#if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
# if defined(_WIN32)
# define TCL_WIDE_INT_TYPE __int64
-# ifdef __BORLANDC__
-# define TCL_LL_MODIFIER "L"
-# else /* __BORLANDC__ */
-# define TCL_LL_MODIFIER "I64"
-# endif /* __BORLANDC__ */
+# define TCL_LL_MODIFIER "I64"
# elif defined(__GNUC__)
# define TCL_WIDE_INT_TYPE long long
# define TCL_LL_MODIFIER "ll"
@@ -424,10 +419,6 @@ typedef TCL_WIDE_INT_TYPE Tcl_WideInt;
typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
#ifdef TCL_WIDE_INT_IS_LONG
-# define Tcl_WideAsLong(val) ((long)(val))
-# define Tcl_LongAsWide(val) ((long)(val))
-# define Tcl_WideAsDouble(val) ((double)((long)(val)))
-# define Tcl_DoubleAsWide(val) ((long)((double)(val)))
# ifndef TCL_LL_MODIFIER
# define TCL_LL_MODIFIER "l"
# endif /* !TCL_LL_MODIFIER */
@@ -439,12 +430,13 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
# ifndef TCL_LL_MODIFIER
# define TCL_LL_MODIFIER "ll"
# endif /* !TCL_LL_MODIFIER */
-# define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val)))
-# define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val)))
-# define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
-# define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))
#endif /* TCL_WIDE_INT_IS_LONG */
+#define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val)))
+#define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val)))
+#define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
+#define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))
+
#if defined(_WIN32)
# ifdef __BORLANDC__
typedef struct stati64 Tcl_StatBuf;
@@ -831,19 +823,20 @@ typedef struct Tcl_Obj {
union { /* The internal representation: */
long longValue; /* - an long integer value. */
double doubleValue; /* - a double-precision floating value. */
- void *otherValuePtr; /* - another, type-specific value,
- not used internally any more. */
+ void *otherValuePtr; /* - another, type-specific value, not used
+ * internally any more. */
Tcl_WideInt wideValue; /* - a long long value. */
struct { /* - internal rep as two pointers.
- * the main use of which is a bignum's
+ * Many uses in Tcl, including a bignum's
* tightly packed fields, where the alloc,
* used and signum flags are packed into
- * ptr2 with everything else hung off ptr1. */
+ * ptr2 with everything else hung off
+ * ptr1. */
void *ptr1;
void *ptr2;
} twoPtrValue;
struct { /* - internal rep as a pointer and a long,
- not used internally any more. */
+ * not used internally any more. */
void *ptr;
unsigned long value;
} ptrAndLongRep;
@@ -1146,8 +1139,13 @@ typedef struct Tcl_DString {
#define TCL_LINK_SHORT 8
#define TCL_LINK_USHORT 9
#define TCL_LINK_UINT 10
+#if defined(TCL_WIDE_INT_IS_LONG) || defined(_WIN32) || defined(__CYGWIN__)
+#define TCL_LINK_LONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_INT : TCL_LINK_INT)
+#define TCL_LINK_ULONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_UINT : TCL_LINK_UINT)
+#else
#define TCL_LINK_LONG 11
#define TCL_LINK_ULONG 12
+#endif
#define TCL_LINK_FLOAT 13
#define TCL_LINK_WIDE_UINT 14
#define TCL_LINK_READ_ONLY 0x80
@@ -1319,9 +1317,9 @@ typedef struct Tcl_HashSearch {
* TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the
* pointer is stored in the entry.
*
- * While maintaining binary compatability the above have to be distinct values
+ * While maintaining binary compatibility the above have to be distinct values
* as they are used to differentiate between old versions of the hash table
- * which don't have a typePtr and new ones which do. Once binary compatability
+ * which don't have a typePtr and new ones which do. Once binary compatibility
* is discarded in favour of making more wide spread changes TCL_STRING_KEYS
* can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the
* same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is
@@ -2371,6 +2369,13 @@ typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp,
/*
*----------------------------------------------------------------------------
+ * Definitions needed for the Tcl_OpenTcpServerEx function. [TIP #456]
+ */
+#define TCL_TCPSERVER_REUSEADDR (1<<0)
+#define TCL_TCPSERVER_REUSEPORT (1<<1)
+
+/*
+ *----------------------------------------------------------------------------
* Single public declaration for NRE.
*/
@@ -2409,10 +2414,6 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
#endif
/*
- * TODO - tommath stubs export goes here!
- */
-
-/*
* Public functions that are not accessible via the stubs table.
* Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
*/
@@ -2530,7 +2531,7 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
Tcl_DbNewBignumObj(val, __FILE__, __LINE__)
# undef Tcl_NewBooleanObj
# define Tcl_NewBooleanObj(val) \
- Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
+ Tcl_DbNewLongObj((val)!=0, __FILE__, __LINE__)
# undef Tcl_NewByteArrayObj
# define Tcl_NewByteArrayObj(bytes, len) \
Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
@@ -2619,7 +2620,9 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
# define Tcl_Ckrealloc Tcl_Realloc
# define Tcl_Return Tcl_SetResult
# define Tcl_TildeSubst Tcl_TranslateFileName
+#if !defined(__APPLE__) /* On OSX, there is a conflict with "mach/mach.h" */
# define panic Tcl_Panic
+#endif
# define panicVA Tcl_PanicVA
#endif /* !TCL_NO_DEPRECATED */
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index cda1f38..64df1a2 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -32,7 +32,7 @@
*/
#if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__)
-typedef unsigned long caddr_t;
+typedef size_t caddr_t;
#endif
/*
@@ -56,7 +56,7 @@ union overhead {
unsigned char magic1; /* other magic number */
#ifndef NDEBUG
unsigned short rmagic; /* range magic number */
- unsigned long size; /* actual block size */
+ size_t size; /* actual block size */
unsigned short unused2; /* padding to 8-byte align */
#endif
} ovu;
@@ -133,7 +133,7 @@ static int allocInit = 0;
* a given block size.
*/
-static unsigned int numMallocs[NBUCKETS+1];
+static size_t numMallocs[NBUCKETS+1];
#endif
#if !defined(NDEBUG)
@@ -148,7 +148,7 @@ static unsigned int numMallocs[NBUCKETS+1];
* Prototypes for functions used only in this file.
*/
-static void MoreCore(int bucket);
+static void MoreCore(size_t bucket);
/*
*-------------------------------------------------------------------------
@@ -254,7 +254,7 @@ TclpAlloc(
unsigned int numBytes) /* Number of bytes to allocate. */
{
register union overhead *overPtr;
- register long bucket;
+ register size_t bucket;
register unsigned amount;
struct block *bigBlockPtr = NULL;
@@ -385,12 +385,12 @@ TclpAlloc(
static void
MoreCore(
- int bucket) /* What bucket to allocat to. */
+ size_t bucket) /* What bucket to allocate to. */
{
register union overhead *overPtr;
- register long size; /* size of desired block */
- long amount; /* amount to allocate */
- int numBlocks; /* how many blocks we get */
+ register size_t size; /* size of desired block */
+ size_t amount; /* amount to allocate */
+ size_t numBlocks; /* how many blocks we get */
struct block *blockPtr;
/*
@@ -398,14 +398,14 @@ MoreCore(
* VAX, I think) or for a negative arg.
*/
- size = 1 << (bucket + 3);
+ size = ((size_t)1) << (bucket + 3);
ASSERT(size > 0);
amount = MAXMALLOC;
numBlocks = amount / size;
ASSERT(numBlocks*size == amount);
- blockPtr = (struct block *) TclpSysAlloc((unsigned)
+ blockPtr = (struct block *) TclpSysAlloc(
(sizeof(struct block) + amount), 1);
/* no more room! */
if (blockPtr == NULL) {
@@ -448,7 +448,7 @@ void
TclpFree(
char *oldPtr) /* Pointer to memory to free. */
{
- register long size;
+ register size_t size;
register union overhead *overPtr;
struct block *bigBlockPtr;
@@ -518,7 +518,7 @@ TclpRealloc(
union overhead *overPtr;
struct block *bigBlockPtr;
int expensive;
- unsigned long maxSize;
+ size_t maxSize;
if (oldPtr == NULL) {
return TclpAlloc(numBytes);
@@ -645,30 +645,30 @@ void
mstats(
char *s) /* Where to write info. */
{
- register int i, j;
+ register unsigned int i, j;
register union overhead *overPtr;
- int totalFree = 0, totalUsed = 0;
+ size_t totalFree = 0, totalUsed = 0;
Tcl_MutexLock(allocMutexPtr);
fprintf(stderr, "Memory allocation statistics %s\nTclpFree:\t", s);
for (i = 0; i < NBUCKETS; i++) {
for (j=0, overPtr=nextf[i]; overPtr; overPtr=overPtr->next, j++) {
- fprintf(stderr, " %d", j);
+ fprintf(stderr, " %u", j);
}
- totalFree += j * (1 << (i + 3));
+ totalFree += ((size_t)j) * (1 << (i + 3));
}
fprintf(stderr, "\nused:\t");
for (i = 0; i < NBUCKETS; i++) {
- fprintf(stderr, " %d", numMallocs[i]);
+ fprintf(stderr, " %" TCL_LL_MODIFIER "d", (Tcl_WideInt)numMallocs[i]);
totalUsed += numMallocs[i] * (1 << (i + 3));
}
- fprintf(stderr, "\n\tTotal small in use: %d, total free: %d\n",
- totalUsed, totalFree);
- fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %d\n",
- MAXMALLOC, numMallocs[NBUCKETS]);
+ fprintf(stderr, "\n\tTotal small in use: %" TCL_LL_MODIFIER "d, total free: %" TCL_LL_MODIFIER "d\n",
+ (Tcl_WideInt)totalUsed, (Tcl_WideInt)totalFree);
+ fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %" TCL_LL_MODIFIER "d\n",
+ MAXMALLOC, (Tcl_WideInt)numMallocs[NBUCKETS]);
Tcl_MutexUnlock(allocMutexPtr);
}
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 06f277f..4c5ae68 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -137,6 +137,8 @@ typedef enum TalInstType {
* ranges */
ASSEM_BOOL, /* One Boolean operand */
ASSEM_BOOL_LVT4, /* One Boolean, one 4-byte LVT ref. */
+ ASSEM_CLOCK_READ, /* 1-byte unsigned-integer case number, in the
+ * range 0-3 */
ASSEM_CONCAT1, /* 1-byte unsigned-integer operand count, must
* be strictly positive, consumes N, produces
* 1 */
@@ -350,6 +352,7 @@ static const TalInstDesc TalInstructionTable[] = {
{"bitnot", ASSEM_1BYTE, INST_BITNOT, 1, 1},
{"bitor", ASSEM_1BYTE, INST_BITOR, 2, 1},
{"bitxor", ASSEM_1BYTE, INST_BITXOR, 2, 1},
+ {"clockRead", ASSEM_CLOCK_READ, INST_CLOCK_READ, 0, 1},
{"concat", ASSEM_CONCAT1, INST_STR_CONCAT1, INT_MIN,1},
{"concatStk", ASSEM_LIST, INST_CONCAT_STK, INT_MIN,1},
{"coroName", ASSEM_1BYTE, INST_COROUTINE_NAME, 0, 1},
@@ -1361,6 +1364,23 @@ AssembleOneLine(
TclEmitInt4(localVar, envPtr);
break;
+ case ASSEM_CLOCK_READ:
+ if (parsePtr->numWords != 2) {
+ Tcl_WrongNumArgs(interp, 1, &instNameObj, "imm8");
+ goto cleanup;
+ }
+ if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
+ goto cleanup;
+ }
+ if (opnd < 0 || opnd > 3) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("operand must be [0..3]", -1));
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND<0,>3", NULL);
+ goto cleanup;
+ }
+ BBEmitInstInt1(assemEnvPtr, tblIdx, opnd, opnd);
+ break;
+
case ASSEM_CONCAT1:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "imm8");
@@ -1543,7 +1563,7 @@ AssembleOneLine(
* Add the (label_name, address) pair to the hash table.
*/
- if (DefineLabel(assemEnvPtr, Tcl_GetString(operand1Obj)) != TCL_OK) {
+ if (DefineLabel(assemEnvPtr, TclGetString(operand1Obj)) != TCL_OK) {
goto cleanup;
}
break;
@@ -1722,7 +1742,7 @@ AssembleOneLine(
default:
Tcl_Panic("Instruction \"%s\" could not be found, can't happen\n",
- Tcl_GetString(instNameObj));
+ TclGetString(instNameObj));
}
status = TCL_OK;
@@ -1985,15 +2005,15 @@ CreateMirrorJumpTable(
DEBUG_PRINT("jump table {\n");
for (i = 0; i < objc; i+=2) {
- DEBUG_PRINT(" %s -> %s\n", Tcl_GetString(objv[i]),
- Tcl_GetString(objv[i+1]));
- hashEntry = Tcl_CreateHashEntry(jtHashPtr, Tcl_GetString(objv[i]),
+ DEBUG_PRINT(" %s -> %s\n", TclGetString(objv[i]),
+ TclGetString(objv[i+1]));
+ hashEntry = Tcl_CreateHashEntry(jtHashPtr, TclGetString(objv[i]),
&isNew);
if (!isNew) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"duplicate entry in jump table for \"%s\"",
- Tcl_GetString(objv[i])));
+ TclGetString(objv[i])));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "DUPJUMPTABLEENTRY");
DeleteMirrorJumpTable(jtPtr);
return TCL_ERROR;
@@ -2801,7 +2821,7 @@ CalculateJumpRelocations(
if (bbPtr->jumpTarget != NULL) {
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(bbPtr->jumpTarget));
+ TclGetString(bbPtr->jumpTarget));
if (entry == NULL) {
ReportUndefinedLabel(assemEnvPtr, bbPtr,
bbPtr->jumpTarget);
@@ -2882,10 +2902,10 @@ CheckJumpTableLabels(
symEntryPtr = Tcl_NextHashEntry(&search)) {
symbolObj = Tcl_GetHashValue(symEntryPtr);
valEntryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(symbolObj));
+ TclGetString(symbolObj));
DEBUG_PRINT(" %s -> %s (%d)\n",
(char*) Tcl_GetHashKey(symHash, symEntryPtr),
- Tcl_GetString(symbolObj), (valEntryPtr != NULL));
+ TclGetString(symbolObj), (valEntryPtr != NULL));
if (valEntryPtr == NULL) {
ReportUndefinedLabel(assemEnvPtr, bbPtr, symbolObj);
return TCL_ERROR;
@@ -2923,9 +2943,9 @@ ReportUndefinedLabel(
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "undefined label \"%s\"", Tcl_GetString(jumpTarget)));
+ "undefined label \"%s\"", TclGetString(jumpTarget)));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOLABEL",
- Tcl_GetString(jumpTarget), NULL);
+ TclGetString(jumpTarget), NULL);
Tcl_SetErrorLine(interp, bbPtr->jumpLine);
}
}
@@ -3008,7 +3028,7 @@ FillInJumpOffsets(
bbPtr = bbPtr->successor1) {
if (bbPtr->jumpTarget != NULL) {
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(bbPtr->jumpTarget));
+ TclGetString(bbPtr->jumpTarget));
jumpTarget = Tcl_GetHashValue(entry);
fromOffset = bbPtr->jumpOffset;
targetOffset = jumpTarget->startOffset;
@@ -3080,17 +3100,17 @@ ResolveJumpTableTargets(
symEntryPtr != NULL;
symEntryPtr = Tcl_NextHashEntry(&search)) {
symbolObj = Tcl_GetHashValue(symEntryPtr);
- DEBUG_PRINT(" symbol %s\n", Tcl_GetString(symbolObj));
+ DEBUG_PRINT(" symbol %s\n", TclGetString(symbolObj));
valEntryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(symbolObj));
+ TclGetString(symbolObj));
jumpTargetBBPtr = Tcl_GetHashValue(valEntryPtr);
realJumpEntryPtr = Tcl_CreateHashEntry(realJumpHashPtr,
Tcl_GetHashKey(symHash, symEntryPtr), &junk);
DEBUG_PRINT(" %s -> %s -> bb %p (pc %d) hash entry %p\n",
(char*) Tcl_GetHashKey(symHash, symEntryPtr),
- Tcl_GetString(symbolObj), jumpTargetBBPtr,
+ TclGetString(symbolObj), jumpTargetBBPtr,
jumpTargetBBPtr->startOffset, realJumpEntryPtr);
Tcl_SetHashValue(realJumpEntryPtr,
@@ -3462,7 +3482,7 @@ StackCheckBasicBlock(
if (result == TCL_OK && blockPtr->jumpTarget != NULL) {
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(blockPtr->jumpTarget));
+ TclGetString(blockPtr->jumpTarget));
jumpTarget = Tcl_GetHashValue(entry);
result = StackCheckBasicBlock(assemEnvPtr, jumpTarget, blockPtr,
stackDepth);
@@ -3479,7 +3499,7 @@ StackCheckBasicBlock(
jtEntry = Tcl_NextHashEntry(&jtSearch)) {
targetLabel = Tcl_GetHashValue(jtEntry);
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(targetLabel));
+ TclGetString(targetLabel));
jumpTarget = Tcl_GetHashValue(entry);
result = StackCheckBasicBlock(assemEnvPtr, jumpTarget,
blockPtr, stackDepth);
@@ -3784,7 +3804,7 @@ ProcessCatchesInBasicBlock(
}
if (result == TCL_OK && bbPtr->jumpTarget != NULL) {
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(bbPtr->jumpTarget));
+ TclGetString(bbPtr->jumpTarget));
jumpTarget = Tcl_GetHashValue(entry);
result = ProcessCatchesInBasicBlock(assemEnvPtr, jumpTarget,
jumpEnclosing, jumpState, catchDepth);
@@ -3800,7 +3820,7 @@ ProcessCatchesInBasicBlock(
jtEntry = Tcl_NextHashEntry(&jtSearch)) {
targetLabel = Tcl_GetHashValue(jtEntry);
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(targetLabel));
+ TclGetString(targetLabel));
jumpTarget = Tcl_GetHashValue(entry);
result = ProcessCatchesInBasicBlock(assemEnvPtr, jumpTarget,
jumpEnclosing, jumpState, catchDepth);
@@ -4104,7 +4124,7 @@ StackFreshCatches(
range->codeOffset = bbPtr->startOffset;
entryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
- Tcl_GetString(catch->jumpTarget));
+ TclGetString(catch->jumpTarget));
if (entryPtr == NULL) {
Tcl_Panic("undefined label in tclAssembly.c:"
"BuildExceptionRanges, can't happen");
@@ -4246,7 +4266,7 @@ AddBasicBlockRangeToErrorInfo(
Tcl_AppendObjToErrorInfo(interp, lineNo);
Tcl_AddErrorInfo(interp, " and ");
if (bbPtr->successor1 != NULL) {
- Tcl_SetIntObj(lineNo, bbPtr->successor1->startLine);
+ TclSetLongObj(lineNo, bbPtr->successor1->startLine);
Tcl_AppendObjToErrorInfo(interp, lineNo);
} else {
Tcl_AddErrorInfo(interp, "end of assembly code");
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 53023d8..c6784a0 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -203,7 +203,7 @@ static const CmdInfo builtInCmds[] = {
{"append", Tcl_AppendObjCmd, TclCompileAppendCmd, NULL, CMD_IS_SAFE},
{"apply", Tcl_ApplyObjCmd, NULL, TclNRApplyObjCmd, CMD_IS_SAFE},
{"break", Tcl_BreakObjCmd, TclCompileBreakCmd, NULL, CMD_IS_SAFE},
-#ifndef EXCLUDE_OBSOLETE_COMMANDS
+#ifndef TCL_NO_DEPRECATED
{"case", Tcl_CaseObjCmd, NULL, NULL, CMD_IS_SAFE},
#endif
{"catch", Tcl_CatchObjCmd, TclCompileCatchCmd, TclNRCatchObjCmd, CMD_IS_SAFE},
@@ -265,7 +265,6 @@ static const CmdInfo builtInCmds[] = {
{"cd", Tcl_CdObjCmd, NULL, NULL, 0},
{"close", Tcl_CloseObjCmd, NULL, NULL, CMD_IS_SAFE},
{"eof", Tcl_EofObjCmd, NULL, NULL, CMD_IS_SAFE},
- {"encoding", Tcl_EncodingObjCmd, NULL, NULL, 0},
{"exec", Tcl_ExecObjCmd, NULL, NULL, 0},
{"exit", Tcl_ExitObjCmd, NULL, NULL, 0},
{"fblocked", Tcl_FblockedObjCmd, NULL, NULL, CMD_IS_SAFE},
@@ -511,7 +510,11 @@ Tcl_CreateInterp(void)
iPtr = ckalloc(sizeof(Interp));
interp = (Tcl_Interp *) iPtr;
+#ifdef TCL_NO_DEPRECATED
+ iPtr->result = &tclEmptyString;
+#else
iPtr->result = iPtr->resultSpace;
+#endif
iPtr->freeProc = NULL;
iPtr->errorLine = 0;
iPtr->objResultPtr = Tcl_NewObj();
@@ -571,9 +574,11 @@ Tcl_CreateInterp(void)
iPtr->rootFramePtr = NULL; /* Initialise as soon as :: is available */
iPtr->lookupNsPtr = NULL;
+#ifndef TCL_NO_DEPRECATED
iPtr->appendResult = NULL;
iPtr->appendAvl = 0;
iPtr->appendUsed = 0;
+#endif
Tcl_InitHashTable(&iPtr->packageTable, TCL_STRING_KEYS);
iPtr->packageUnknown = NULL;
@@ -588,7 +593,7 @@ Tcl_CreateInterp(void)
iPtr->cmdCount = 0;
TclInitLiteralTable(&iPtr->literalTable);
- iPtr->compileEpoch = 0;
+ iPtr->compileEpoch = 1;
iPtr->compiledProcPtr = NULL;
iPtr->resolverPtr = NULL;
iPtr->evalFlags = 0;
@@ -603,7 +608,9 @@ Tcl_CreateInterp(void)
iPtr->emptyObjPtr = Tcl_NewObj();
/* Another empty object. */
Tcl_IncrRefCount(iPtr->emptyObjPtr);
+#ifndef TCL_NO_DEPRECATED
iPtr->resultSpace[0] = 0;
+#endif
iPtr->threadId = Tcl_GetCurrentThread();
/* TIP #378 */
@@ -790,16 +797,17 @@ Tcl_CreateInterp(void)
}
/*
- * Create the "array", "binary", "chan", "dict", "file", "info",
- * "namespace" and "string" ensembles. Note that all these commands (and
- * their subcommands that are not present in the global namespace) are
- * wholly safe *except* for "file".
+ * Create the "array", "binary", "chan", "clock", "dict", "encoding",
+ * "file", "info", "namespace" and "string" ensembles. Note that all these
+ * commands (and their subcommands that are not present in the global
+ * namespace) are wholly safe *except* for "clock", "encoding" and "file".
*/
TclInitArrayCmd(interp);
TclInitBinaryCmd(interp);
TclInitChanCmd(interp);
TclInitDictCmd(interp);
+ TclInitEncodingCmd(interp);
TclInitFileCmd(interp);
TclInitInfoCmd(interp);
TclInitNamespaceCmd(interp);
@@ -966,11 +974,11 @@ Tcl_CreateInterp(void)
Tcl_PkgProvideEx(interp, "Tcl", TCL_PATCH_LEVEL, &tclStubs);
if (TclTommath_Init(interp) != TCL_OK) {
- Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
+ Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
}
if (TclOOInit(interp) != TCL_OK) {
- Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
+ Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
}
/*
@@ -980,7 +988,7 @@ Tcl_CreateInterp(void)
#ifdef HAVE_ZLIB
if (TclZlibInit(interp) != TCL_OK) {
- Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
+ Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
}
#endif
@@ -1027,6 +1035,7 @@ TclHideUnsafeCommands(
Tcl_HideCommand(interp, cmdInfoPtr->name, cmdInfoPtr->name);
}
}
+ TclMakeEncodingCommandSafe(interp); /* Ugh! */
TclMakeFileCommandSafe(interp); /* Ugh! */
return TCL_OK;
}
@@ -1062,7 +1071,7 @@ Tcl_CallWhenDeleted(
Interp *iPtr = (Interp *) interp;
static Tcl_ThreadDataKey assocDataCounterKey;
int *assocDataCounterPtr =
- Tcl_GetThreadData(&assocDataCounterKey, (int)sizeof(int));
+ Tcl_GetThreadData(&assocDataCounterKey, sizeof(int));
int isNew;
char buffer[32 + TCL_INTEGER_SPACE];
AssocData *dPtr = ckalloc(sizeof(AssocData));
@@ -1534,10 +1543,12 @@ DeleteInterpProc(
if (iPtr->returnOpts) {
Tcl_DecrRefCount(iPtr->returnOpts);
}
+#ifndef TCL_NO_DEPRECATED
if (iPtr->appendResult != NULL) {
ckfree(iPtr->appendResult);
iPtr->appendResult = NULL;
}
+#endif
TclFreePackageInfo(iPtr);
while (iPtr->tracePtr != NULL) {
Tcl_DeleteTrace((Tcl_Interp *) iPtr, (Tcl_Trace) iPtr->tracePtr);
@@ -1635,7 +1646,7 @@ DeleteInterpProc(
}
Tcl_DeleteHashTable(iPtr->lineLAPtr);
- ckfree((char *) iPtr->lineLAPtr);
+ ckfree(iPtr->lineLAPtr);
iPtr->lineLAPtr = NULL;
if (iPtr->lineLABCPtr->numEntries && !TclInExit()) {
@@ -2403,7 +2414,7 @@ TclInvokeStringCommand(
TclStackAlloc(interp, (unsigned)(objc + 1) * sizeof(char *));
for (i = 0; i < objc; i++) {
- argv[i] = Tcl_GetString(objv[i]);
+ argv[i] = TclGetString(objv[i]);
}
argv[objc] = 0;
@@ -2657,7 +2668,7 @@ TclRenameCommand(
}
Tcl_DStringAppend(&newFullName, newTail, -1);
cmdPtr->refCount++;
- CallCommandTraces(iPtr, cmdPtr, Tcl_GetString(oldFullName),
+ CallCommandTraces(iPtr, cmdPtr, TclGetString(oldFullName),
Tcl_DStringValue(&newFullName), TCL_TRACE_RENAME);
Tcl_DStringFree(&newFullName);
@@ -3024,13 +3035,6 @@ Tcl_DeleteCommandFromToken(
Tcl_Command importCmd;
/*
- * Bump the command epoch counter. This will invalidate all cached
- * references that point to this command.
- */
-
- cmdPtr->cmdEpoch++;
-
- /*
* The code here is tricky. We can't delete the hash table entry before
* invoking the deletion callback because there are cases where the
* deletion callback needs to invoke the command (e.g. object systems such
@@ -3052,6 +3056,14 @@ Tcl_DeleteCommandFromToken(
Tcl_DeleteHashEntry(cmdPtr->hPtr);
cmdPtr->hPtr = NULL;
}
+
+ /*
+ * Bump the command epoch counter. This will invalidate all cached
+ * references that point to this command.
+ */
+
+ cmdPtr->cmdEpoch++;
+
return 0;
}
@@ -3154,6 +3166,13 @@ Tcl_DeleteCommandFromToken(
if (cmdPtr->hPtr != NULL) {
Tcl_DeleteHashEntry(cmdPtr->hPtr);
cmdPtr->hPtr = NULL;
+
+ /*
+ * Bump the command epoch counter. This will invalidate all cached
+ * references that point to this command.
+ */
+
+ cmdPtr->cmdEpoch++;
}
/*
@@ -3400,8 +3419,7 @@ TclCleanupCommand(
register Command *cmdPtr) /* Points to the Command structure to
* be freed. */
{
- cmdPtr->refCount--;
- if (cmdPtr->refCount <= 0) {
+ if (cmdPtr->refCount-- <= 1) {
ckfree(cmdPtr);
}
}
@@ -3523,7 +3541,7 @@ OldMathFuncProc(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"argument to math function didn't have numeric value",
-1));
- TclCheckBadOctal(interp, Tcl_GetString(valuePtr));
+ TclCheckBadOctal(interp, TclGetString(valuePtr));
ckfree(args);
return TCL_ERROR;
}
@@ -4698,7 +4716,7 @@ TEOV_RunEnterTraces(
{
Interp *iPtr = (Interp *) interp;
Command *cmdPtr = *cmdPtrPtr;
- int newEpoch, cmdEpoch = cmdPtr->cmdEpoch;
+ size_t newEpoch, cmdEpoch = cmdPtr->cmdEpoch;
int length, traceCode = TCL_OK;
const char *command = TclGetStringFromObj(commandPtr, &length);
@@ -5578,8 +5596,7 @@ TclArgumentRelease(
}
cfwPtr = Tcl_GetHashValue(hPtr);
- cfwPtr->refCount--;
- if (cfwPtr->refCount > 0) {
+ if (cfwPtr->refCount-- > 1) {
continue;
}
@@ -5844,6 +5861,7 @@ TclArgumentGet(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_Eval
int
Tcl_Eval(
@@ -5896,6 +5914,7 @@ Tcl_GlobalEvalObj(
{
return Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_GLOBAL);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -6049,7 +6068,7 @@ TclNREvalObjEx(
TclNRAddCallback(interp, TEOEx_ListCallback, listPtr, eoFramePtr,
objPtr, NULL);
- ListObjGetElements(listPtr, objc, objv);
+ TclListObjGetElements(NULL, listPtr, &objc, &objv);
return TclNREvalObjv(interp, objc, objv, flags, NULL);
}
@@ -6696,11 +6715,10 @@ Tcl_AppendObjToErrorInfo(
* pertains. */
Tcl_Obj *objPtr) /* Message to record. */
{
- int length;
- const char *message = TclGetStringFromObj(objPtr, &length);
+ const char *message = TclGetString(objPtr);
Tcl_IncrRefCount(objPtr);
- Tcl_AddObjErrorInfo(interp, message, length);
+ Tcl_AddObjErrorInfo(interp, message, objPtr->length);
Tcl_DecrRefCount(objPtr);
}
@@ -6723,6 +6741,7 @@ Tcl_AppendObjToErrorInfo(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_AddErrorInfo
void
Tcl_AddErrorInfo(
@@ -6732,6 +6751,7 @@ Tcl_AddErrorInfo(
{
Tcl_AddObjErrorInfo(interp, message, -1);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -6904,6 +6924,7 @@ Tcl_VarEval(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_GlobalEval
int
Tcl_GlobalEval(
@@ -6921,6 +6942,7 @@ Tcl_GlobalEval(
iPtr->varFramePtr = savedVarFramePtr;
return result;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -7884,7 +7906,7 @@ MathFuncWrongNumArgs(
int found, /* Actual parameter count. */
Tcl_Obj *const *objv) /* Actual parameter vector. */
{
- const char *name = Tcl_GetString(objv[0]);
+ const char *name = TclGetString(objv[0]);
const char *tail = name + strlen(name);
while (tail > name+1) {
@@ -8748,6 +8770,35 @@ TclNRCoroutineActivateCallback(
/*
*----------------------------------------------------------------------
*
+ * TclNREvalList --
+ *
+ * Callback to invoke command as list, used in order to delayed
+ * processing of canonical list command in sane environment.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TclNREvalList(
+ ClientData data[],
+ Tcl_Interp *interp,
+ int result)
+{
+ int objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *listPtr = data[0];
+
+ Tcl_IncrRefCount(listPtr);
+
+ TclMarkTailcall(interp);
+ TclNRAddCallback(interp, TclNRReleaseValues, listPtr, NULL, NULL,NULL);
+ TclListObjGetElements(NULL, listPtr, &objc, &objv);
+ return TclNREvalObjv(interp, objc, objv, 0, NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* NRCoroInjectObjCmd --
*
* Implementation of [::tcl::unsupported::inject] command.
@@ -8799,7 +8850,8 @@ NRCoroInjectObjCmd(
*/
iPtr->execEnvPtr = corPtr->eePtr;
- TclNREvalObjEx(interp, Tcl_NewListObj(objc-2, objv+2), 0, NULL, INT_MIN);
+ TclNRAddCallback(interp, TclNREvalList, Tcl_NewListObj(objc-2, objv+2),
+ NULL, NULL, NULL);
iPtr->execEnvPtr = savedEEPtr;
return TCL_OK;
@@ -8817,7 +8869,7 @@ TclNRInterpCoroutine(
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"coroutine \"%s\" is already running",
- Tcl_GetString(objv[0])));
+ TclGetString(objv[0])));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BUSY", NULL);
return TCL_ERROR;
}
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 9a5771e..a3e5071 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -155,35 +155,108 @@ static const EnsembleImplMap decodeMap[] = {
};
/*
- * The following object type represents an array of bytes. An array of bytes
- * is not equivalent to an internationalized string. Conceptually, a string is
- * an array of 16-bit quantities organized as a sequence of properly formed
- * UTF-8 characters, while a ByteArray is an array of 8-bit quantities.
- * Accessor functions are provided to convert a ByteArray to a String or a
- * String to a ByteArray. Two or more consecutive bytes in an array of bytes
- * may look like a single UTF-8 character if the array is casually treated as
- * a string. But obtaining the String from a ByteArray is guaranteed to
- * produced properly formed UTF-8 sequences so that there is a one-to-one map
- * between bytes and characters.
- *
- * Converting a ByteArray to a String proceeds by casting each byte in the
- * array to a 16-bit quantity, treating that number as a Unicode character,
- * and storing the UTF-8 version of that Unicode character in the String. For
- * ByteArrays consisting entirely of values 1..127, the corresponding String
- * representation is the same as the ByteArray representation.
- *
- * Converting a String to a ByteArray proceeds by getting the Unicode
- * representation of each character in the String, casting it to a byte by
- * truncating the upper 8 bits, and then storing the byte in the ByteArray.
- * Converting from ByteArray to String and back to ByteArray is not lossy, but
- * converting an arbitrary String to a ByteArray may be.
+ * The following object types represent an array of bytes. The intent is
+ * to allow arbitrary binary data to pass through Tcl as a Tcl value
+ * without loss or damage. Such values are useful for things like
+ * encoded strings or Tk images to name just two.
+ *
+ * It's strange to have two Tcl_ObjTypes in place for this task when
+ * one would do, so a bit of detail and history how we got to this point
+ * and where we might go from here.
+ *
+ * A bytearray is an ordered sequence of bytes. Each byte is an integer
+ * value in the range [0-255]. To be a Tcl value type, we need a way to
+ * encode each value in the value set as a Tcl string. The simplest
+ * encoding is to represent each byte value as the same codepoint value.
+ * A bytearray of N bytes is encoded into a Tcl string of N characters
+ * where the codepoint of each character is the value of corresponding byte.
+ * This approach creates a one-to-one map between all bytearray values
+ * and a subset of Tcl string values.
+ *
+ * When converting a Tcl string value to the bytearray internal rep, the
+ * question arises what to do with strings outside that subset? That is,
+ * those Tcl strings containing at least one codepoint greater than 255?
+ * The obviously correct answer is to raise an error! That string value
+ * does not represent any valid bytearray value. Full Stop. The
+ * setFromAnyProc signature has a completion code return value for just
+ * this reason, to reject invalid inputs.
+ *
+ * Unfortunately this was not the path taken by the authors of the
+ * original tclByteArrayType. They chose to accept all Tcl string values
+ * as acceptable string encodings of the bytearray values that result
+ * from masking away the high bits of any codepoint value at all. This
+ * meant that every bytearray value had multiple accepted string
+ * representations.
+ *
+ * The implications of this choice are truly ugly. When a Tcl value has
+ * a string representation, we are required to accept that as the true
+ * value. Bytearray values that possess a string representation cannot
+ * be processed as bytearrays because we cannot know which true value
+ * that bytearray represents. The consequence is that we drag around
+ * an internal rep that we cannot make any use of. This painful price
+ * is extracted at any point after a string rep happens to be generated
+ * for the value. This happens even when the troublesome codepoints
+ * outside the byte range never show up. This happens rather routinely
+ * in normal Tcl operations unless we burden the script writer with the
+ * cognitive burden of avoiding it. The price is also paid by callers
+ * of the C interface. The routine
+ *
+ * unsigned char *Tcl_GetByteArrayFromObj(objPtr, lenPtr)
+ *
+ * has a guarantee to always return a non-NULL value, but that value
+ * points to a byte sequence that cannot be used by the caller to
+ * process the Tcl value absent some sideband testing that objPtr
+ * is "pure". Tcl offers no public interface to perform this test,
+ * so callers either break encapsulation or are unavoidably buggy. Tcl
+ * has defined a public interface that cannot be used correctly. The
+ * Tcl source code itself suffers the same problem, and has been buggy,
+ * but progressively less so as more and more portions of the code have
+ * been retrofitted with the required "purity testing". The set of values
+ * able to pass the purity test can be increased via the introduction of
+ * a "canonical" flag marker, but the only way the broken interface itself
+ * can be discarded is to start over and define the Tcl_ObjType properly.
+ * Bytearrays should simply be usable as bytearrays without a kabuki
+ * dance of testing.
+ *
+ * The Tcl_ObjType "properByteArrayType" is (nearly) a correct
+ * implementation of bytearrays. Any Tcl value with the type
+ * properByteArrayType can have its bytearray value fetched and
+ * used with confidence that acting on that value is equivalent to
+ * acting on the true Tcl string value. This still implies a side
+ * testing burden -- past mistakes will not let us avoid that
+ * immediately, but it is at least a conventional test of type, and
+ * can be implemented entirely by examining the objPtr fields, with
+ * no need to query the intrep, as a canonical flag would require.
+ *
+ * Until Tcl_GetByteArrayFromObj() and Tcl_SetByteArrayLength() can
+ * be revised to admit the possibility of returning NULL when the true
+ * value is not a valid bytearray, we need a mechanism to retain
+ * compatibility with the deployed callers of the broken interface.
+ * That's what the retained "tclByteArrayType" provides. In those
+ * unusual circumstances where we convert an invalid bytearray value
+ * to a bytearray type, it is to this legacy type. Essentially any
+ * time this legacy type gets used, it's a signal of a bug being ignored.
+ * A TIP should be drafted to remove this connection to the broken past
+ * so that Tcl 9 will no longer have any trace of it. Prescribing a
+ * migration path will be the key element of that work. The internal
+ * changes now in place are the limit of what can be done short of
+ * interface repair. They provide a great expansion of the histories
+ * over which bytearray values can be useful in the meanwhile.
*/
-const Tcl_ObjType tclByteArrayType = {
+static const Tcl_ObjType properByteArrayType = {
"bytearray",
FreeByteArrayInternalRep,
DupByteArrayInternalRep,
UpdateStringOfByteArray,
+ NULL
+};
+
+const Tcl_ObjType tclByteArrayType = {
+ "bytearray",
+ FreeByteArrayInternalRep,
+ DupByteArrayInternalRep,
+ NULL,
SetByteArrayFromAny
};
@@ -211,6 +284,12 @@ typedef struct ByteArray {
#define SET_BYTEARRAY(objPtr, baPtr) \
(objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (baPtr)
+int
+TclIsPureByteArray(
+ Tcl_Obj * objPtr)
+{
+ return (objPtr->typePtr == &properByteArrayType);
+}
/*
*----------------------------------------------------------------------
@@ -341,7 +420,7 @@ Tcl_SetByteArrayObj(
if ((bytes != NULL) && (length > 0)) {
memcpy(byteArrayPtr->bytes, bytes, (size_t) length);
}
- objPtr->typePtr = &tclByteArrayType;
+ objPtr->typePtr = &properByteArrayType;
SET_BYTEARRAY(objPtr, byteArrayPtr);
}
@@ -371,7 +450,8 @@ Tcl_GetByteArrayFromObj(
{
ByteArray *baPtr;
- if (objPtr->typePtr != &tclByteArrayType) {
+ if ((objPtr->typePtr != &properByteArrayType)
+ && (objPtr->typePtr != &tclByteArrayType)) {
SetByteArrayFromAny(NULL, objPtr);
}
baPtr = GET_BYTEARRAY(objPtr);
@@ -414,7 +494,8 @@ Tcl_SetByteArrayLength(
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
}
- if (objPtr->typePtr != &tclByteArrayType) {
+ if ((objPtr->typePtr != &properByteArrayType)
+ && (objPtr->typePtr != &tclByteArrayType)) {
SetByteArrayFromAny(NULL, objPtr);
}
@@ -450,29 +531,37 @@ SetByteArrayFromAny(
Tcl_Interp *interp, /* Not used. */
Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */
{
- int length;
+ size_t length;
+ int improper = 0;
const char *src, *srcEnd;
unsigned char *dst;
ByteArray *byteArrayPtr;
Tcl_UniChar ch;
- if (objPtr->typePtr != &tclByteArrayType) {
- src = TclGetStringFromObj(objPtr, &length);
- srcEnd = src + length;
-
- byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
- for (dst = byteArrayPtr->bytes; src < srcEnd; ) {
- src += Tcl_UtfToUniChar(src, &ch);
- *dst++ = UCHAR(ch);
- }
+ if (objPtr->typePtr == &properByteArrayType) {
+ return TCL_OK;
+ }
+ if (objPtr->typePtr == &tclByteArrayType) {
+ return TCL_OK;
+ }
- byteArrayPtr->used = dst - byteArrayPtr->bytes;
- byteArrayPtr->allocated = length;
+ src = TclGetString(objPtr);
+ length = objPtr->length;
+ srcEnd = src + length;
- TclFreeIntRep(objPtr);
- objPtr->typePtr = &tclByteArrayType;
- SET_BYTEARRAY(objPtr, byteArrayPtr);
+ byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
+ for (dst = byteArrayPtr->bytes; src < srcEnd; ) {
+ src += Tcl_UtfToUniChar(src, &ch);
+ improper = improper || (ch > 255);
+ *dst++ = UCHAR(ch);
}
+
+ byteArrayPtr->used = dst - byteArrayPtr->bytes;
+ byteArrayPtr->allocated = length;
+
+ TclFreeIntRep(objPtr);
+ objPtr->typePtr = improper ? &tclByteArrayType : &properByteArrayType;
+ SET_BYTEARRAY(objPtr, byteArrayPtr);
return TCL_OK;
}
@@ -535,7 +624,7 @@ DupByteArrayInternalRep(
memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, (size_t) length);
SET_BYTEARRAY(copyPtr, copyArrayPtr);
- copyPtr->typePtr = &tclByteArrayType;
+ copyPtr->typePtr = srcPtr->typePtr;
}
/*
@@ -642,7 +731,8 @@ TclAppendBytesToByteArray(
/* Append zero bytes is a no-op. */
return;
}
- if (objPtr->typePtr != &tclByteArrayType) {
+ if ((objPtr->typePtr != &properByteArrayType)
+ && (objPtr->typePtr != &tclByteArrayType)) {
SetByteArrayFromAny(NULL, objPtr);
}
byteArrayPtr = GET_BYTEARRAY(objPtr);
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index 70e64f0..123d872 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -34,14 +34,14 @@
*/
typedef struct MemTag {
- int refCount; /* Number of mem_headers referencing this
+ size_t refCount; /* Number of mem_headers referencing this
* tag. */
char string[1]; /* Actual size of string will be as large as
* needed for actual tag. This must be the
* last field in the structure. */
} MemTag;
-#define TAG_SIZE(bytesInString) ((unsigned) ((TclOffset(MemTag, string) + 1) + bytesInString))
+#define TAG_SIZE(bytesInString) ((TclOffset(MemTag, string) + 1) + bytesInString)
static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set
* by "memory tag" command). */
@@ -52,14 +52,14 @@ static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set
* to help detect chunk under-runs.
*/
-#define LOW_GUARD_SIZE (8 + (32 - (sizeof(long) + sizeof(int)))%8)
+#define LOW_GUARD_SIZE (8 + (32 - (sizeof(size_t) + sizeof(int)))%8)
struct mem_header {
struct mem_header *flink;
struct mem_header *blink;
MemTag *tagPtr; /* Tag from "memory tag" command; may be
* NULL. */
const char *file;
- long length;
+ size_t length;
int line;
unsigned char low_guard[LOW_GUARD_SIZE];
/* Aligns body on 8-byte boundary, plus
@@ -89,14 +89,14 @@ static struct mem_header *allocHead = NULL; /* List of allocated structures */
#define BODY_OFFSET \
((size_t) (&((struct mem_header *) 0)->body))
-static int total_mallocs = 0;
-static int total_frees = 0;
+static unsigned int total_mallocs = 0;
+static unsigned int total_frees = 0;
static size_t current_bytes_malloced = 0;
static size_t maximum_bytes_malloced = 0;
-static int current_malloc_packets = 0;
-static int maximum_malloc_packets = 0;
-static int break_on_malloc = 0;
-static int trace_on_at_malloc = 0;
+static unsigned int current_malloc_packets = 0;
+static unsigned int maximum_malloc_packets = 0;
+static unsigned int break_on_malloc = 0;
+static unsigned int trace_on_at_malloc = 0;
static int alloc_tracing = FALSE;
static int init_malloced_bodies = TRUE;
#ifdef MEM_VALIDATE
@@ -184,18 +184,18 @@ TclDumpMemoryInfo(
return 0;
}
sprintf(buf,
- "total mallocs %10d\n"
- "total frees %10d\n"
- "current packets allocated %10d\n"
- "current bytes allocated %10lu\n"
- "maximum packets allocated %10d\n"
- "maximum bytes allocated %10lu\n",
+ "total mallocs %10u\n"
+ "total frees %10u\n"
+ "current packets allocated %10u\n"
+ "current bytes allocated %10" TCL_LL_MODIFIER "u\n"
+ "maximum packets allocated %10u\n"
+ "maximum bytes allocated %10" TCL_LL_MODIFIER "u\n",
total_mallocs,
total_frees,
current_malloc_packets,
- (unsigned long)current_bytes_malloced,
+ (Tcl_WideInt)current_bytes_malloced,
maximum_malloc_packets,
- (unsigned long)maximum_bytes_malloced);
+ (Tcl_WideInt)maximum_bytes_malloced);
if (flags == 0) {
fprintf((FILE *)clientData, "%s", buf);
} else {
@@ -251,10 +251,10 @@ ValidateMemory(
}
if (guard_failed) {
TclDumpMemoryInfo((ClientData) stderr, 0);
- fprintf(stderr, "low guard failed at %lx, %s %d\n",
- (long unsigned) memHeaderP->body, file, line);
+ fprintf(stderr, "low guard failed at %p, %s %d\n",
+ memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
- fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length,
+ fprintf(stderr, "%" TCL_LL_MODIFIER "d bytes allocated at (%s %d)\n", (Tcl_WideInt) memHeaderP->length,
memHeaderP->file, memHeaderP->line);
Tcl_Panic("Memory validation failure");
}
@@ -273,11 +273,11 @@ ValidateMemory(
if (guard_failed) {
TclDumpMemoryInfo((ClientData) stderr, 0);
- fprintf(stderr, "high guard failed at %lx, %s %d\n",
- (long unsigned) memHeaderP->body, file, line);
+ fprintf(stderr, "high guard failed at %p, %s %d\n",
+ memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
- fprintf(stderr, "%ld bytes allocated at (%s %d)\n",
- memHeaderP->length, memHeaderP->file,
+ fprintf(stderr, "%" TCL_LL_MODIFIER "d bytes allocated at (%s %d)\n",
+ (Tcl_WideInt)memHeaderP->length, memHeaderP->file,
memHeaderP->line);
Tcl_Panic("Memory validation failure");
}
@@ -359,10 +359,9 @@ Tcl_DumpActiveMemory(
Tcl_MutexLock(ckallocMutexPtr);
for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) {
address = &memScanP->body[0];
- fprintf(fileP, "%8lx - %8lx %7ld @ %s %d %s",
- (long unsigned) address,
- (long unsigned) address + memScanP->length - 1,
- memScanP->length, memScanP->file, memScanP->line,
+ fprintf(fileP, "%p - %p %" TCL_LL_MODIFIER "d @ %s %d %s",
+ address, address + memScanP->length - 1,
+ (Tcl_WideInt)memScanP->length, memScanP->file, memScanP->line,
(memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string);
(void) fputc('\n', fileP);
}
@@ -450,7 +449,7 @@ Tcl_DbCkalloc(
total_mallocs++;
if (trace_on_at_malloc && (total_mallocs >= trace_on_at_malloc)) {
(void) fflush(stdout);
- fprintf(stderr, "reached malloc trace enable point (%d)\n",
+ fprintf(stderr, "reached malloc trace enable point (%u)\n",
total_mallocs);
fflush(stderr);
alloc_tracing = TRUE;
@@ -458,14 +457,14 @@ Tcl_DbCkalloc(
}
if (alloc_tracing) {
- fprintf(stderr,"ckalloc %lx %u %s %d\n",
- (long unsigned int) result->body, size, file, line);
+ fprintf(stderr,"ckalloc %p %u %s %d\n",
+ result->body, size, file, line);
}
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
break_on_malloc = 0;
(void) fflush(stdout);
- Tcl_Panic("reached malloc break limit (%d)", total_mallocs);
+ Tcl_Panic("reached malloc break limit (%u)", total_mallocs);
}
current_malloc_packets++;
@@ -547,8 +546,8 @@ Tcl_AttemptDbCkalloc(
}
if (alloc_tracing) {
- fprintf(stderr,"ckalloc %lx %u %s %d\n",
- (long unsigned int) result->body, size, file, line);
+ fprintf(stderr,"ckalloc %p %u %s %d\n",
+ result->body, size, file, line);
}
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
@@ -612,8 +611,8 @@ Tcl_DbCkfree(
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
if (alloc_tracing) {
- fprintf(stderr, "ckfree %lx %ld %s %d\n",
- (long unsigned int) memp->body, memp->length, file, line);
+ fprintf(stderr, "ckfree %p %" TCL_LL_MODIFIER "d %s %d\n",
+ memp->body, (Tcl_WideInt) memp->length, file, line);
}
if (validate_memory) {
@@ -623,7 +622,7 @@ Tcl_DbCkfree(
Tcl_MutexLock(ckallocMutexPtr);
ValidateMemory(memp, file, line, TRUE);
if (init_malloced_bodies) {
- memset(ptr, GUARD_VALUE, (size_t) memp->length);
+ memset(ptr, GUARD_VALUE, memp->length);
}
total_frees++;
@@ -631,8 +630,7 @@ Tcl_DbCkfree(
current_bytes_malloced -= memp->length;
if (memp->tagPtr != NULL) {
- memp->tagPtr->refCount--;
- if ((memp->tagPtr->refCount == 0) && (curTagPtr != memp->tagPtr)) {
+ if ((memp->tagPtr->refCount-- <= 1) && (curTagPtr != memp->tagPtr)) {
TclpFree((char *) memp->tagPtr);
}
}
@@ -675,7 +673,7 @@ Tcl_DbCkrealloc(
int line)
{
char *newPtr;
- unsigned int copySize;
+ size_t copySize;
struct mem_header *memp;
if (ptr == NULL) {
@@ -689,7 +687,7 @@ Tcl_DbCkrealloc(
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
copySize = size;
- if (copySize > (unsigned int) memp->length) {
+ if (copySize > memp->length) {
copySize = memp->length;
}
newPtr = Tcl_DbCkalloc(size, file, line);
@@ -706,7 +704,7 @@ Tcl_AttemptDbCkrealloc(
int line)
{
char *newPtr;
- unsigned int copySize;
+ size_t copySize;
struct mem_header *memp;
if (ptr == NULL) {
@@ -720,7 +718,7 @@ Tcl_AttemptDbCkrealloc(
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
copySize = size;
- if (copySize > (unsigned int) memp->length) {
+ if (copySize > memp->length) {
copySize = memp->length;
}
newPtr = Tcl_AttemptDbCkalloc(size, file, line);
@@ -849,22 +847,24 @@ MemoryCmd(
return TCL_OK;
}
if (strcmp(argv[1],"break_on_malloc") == 0) {
+ int value;
if (argc != 3) {
goto argError;
}
- if (Tcl_GetInt(interp, argv[2], &break_on_malloc) != TCL_OK) {
+ if (Tcl_GetInt(interp, argv[2], &value) != TCL_OK) {
return TCL_ERROR;
}
+ break_on_malloc = (unsigned int) value;
return TCL_OK;
}
if (strcmp(argv[1],"info") == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "%-25s %10d\n%-25s %10d\n%-25s %10d\n%-25s %10lu\n%-25s %10d\n%-25s %10lu\n",
+ "%-25s %10u\n%-25s %10u\n%-25s %10u\n%-25s %10" TCL_LL_MODIFIER"d\n%-25s %10u\n%-25s %10" TCL_LL_MODIFIER "d\n",
"total mallocs", total_mallocs, "total frees", total_frees,
"current packets allocated", current_malloc_packets,
- "current bytes allocated", (unsigned long)current_bytes_malloced,
+ "current bytes allocated", (Tcl_WideInt)current_bytes_malloced,
"maximum packets allocated", maximum_malloc_packets,
- "maximum bytes allocated", (unsigned long)maximum_bytes_malloced));
+ "maximum bytes allocated", (Tcl_WideInt)maximum_bytes_malloced));
return TCL_OK;
}
if (strcmp(argv[1], "init") == 0) {
@@ -935,12 +935,14 @@ MemoryCmd(
}
if (strcmp(argv[1],"trace_on_at_malloc") == 0) {
+ int value;
if (argc != 3) {
goto argError;
}
- if (Tcl_GetInt(interp, argv[2], &trace_on_at_malloc) != TCL_OK) {
+ if (Tcl_GetInt(interp, argv[2], &value) != TCL_OK) {
return TCL_ERROR;
}
+ trace_on_at_malloc = value;
return TCL_OK;
}
if (strcmp(argv[1],"validate") == 0) {
diff --git a/generic/tclClock.c b/generic/tclClock.c
index c3b29e9..d44e9dc 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -92,7 +92,7 @@ static const char *const literals[] = {
*/
typedef struct ClockClientData {
- int refCount; /* Number of live references. */
+ size_t refCount; /* Number of live references. */
Tcl_Obj **literals; /* Pool of object literals. */
} ClockClientData;
@@ -208,11 +208,7 @@ struct ClockCommand {
};
static const struct ClockCommand clockCommands[] = {
- { "clicks", ClockClicksObjCmd },
{ "getenv", ClockGetenvObjCmd },
- { "microseconds", ClockMicrosecondsObjCmd },
- { "milliseconds", ClockMillisecondsObjCmd },
- { "seconds", ClockSecondsObjCmd },
{ "Oldscan", TclClockOldscanObjCmd },
{ "ConvertLocalToUTC", ClockConvertlocaltoutcObjCmd },
{ "GetDateFields", ClockGetdatefieldsObjCmd },
@@ -253,6 +249,19 @@ TclClockInit(
ClockClientData *data;
int i;
+ /* Structure of the 'clock' ensemble */
+
+ static const EnsembleImplMap clockImplMap[] = {
+ {"add", NULL, TclCompileBasicMin1ArgCmd, NULL, NULL, 0},
+ {"clicks", ClockClicksObjCmd, TclCompileClockClicksCmd, NULL, NULL, 0},
+ {"format", NULL, TclCompileBasicMin1ArgCmd, NULL, NULL, 0},
+ {"microseconds", ClockMicrosecondsObjCmd, TclCompileClockReadingCmd, NULL, INT2PTR(1), 0},
+ {"milliseconds", ClockMillisecondsObjCmd, TclCompileClockReadingCmd, NULL, INT2PTR(2), 0},
+ {"scan", NULL, TclCompileBasicMin1ArgCmd, NULL, NULL , 0},
+ {"seconds", ClockSecondsObjCmd, TclCompileClockReadingCmd, NULL, INT2PTR(3), 0},
+ {NULL, NULL, NULL, NULL, NULL, 0}
+ };
+
/*
* Safe interps get [::clock] as alias to a master, so do not need their
* own copies of the support routines.
@@ -276,6 +285,7 @@ TclClockInit(
/*
* Install the commands.
+ * TODO - Let Tcl_MakeEnsemble do this?
*/
#define TCL_CLOCK_PREFIX_LEN 14 /* == strlen("::tcl::clock::") */
@@ -286,6 +296,10 @@ TclClockInit(
Tcl_CreateObjCommand(interp, cmdName, clockCmdPtr->objCmdProc, data,
ClockDeleteCmdProc);
}
+
+ /* Make the clock ensemble */
+
+ TclMakeEnsemble(interp, "clock", clockImplMap);
}
/*
@@ -1680,7 +1694,7 @@ ThreadSafeLocalTime(
* Get a thread-local buffer to hold the returned time.
*/
- struct tm *tmPtr = Tcl_GetThreadData(&tmKey, (int) sizeof(struct tm));
+ struct tm *tmPtr = Tcl_GetThreadData(&tmKey, sizeof(struct tm));
#ifdef HAVE_LOCALTIME_R
localtime_r(timePtr, tmPtr);
#else
@@ -2060,8 +2074,7 @@ ClockDeleteCmdProc(
ClockClientData *data = clientData;
int i;
- data->refCount--;
- if (data->refCount == 0) {
+ if (data->refCount-- <= 1) {
for (i = 0; i < LIT__END; ++i) {
Tcl_DecrRefCount(data->literals[i]);
}
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 4c299f8..807a1ac 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -46,9 +46,24 @@ struct ForeachState {
static int CheckAccess(Tcl_Interp *interp, Tcl_Obj *pathPtr,
int mode);
+static int BadEncodingSubcommand(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
+static int EncodingConvertfromObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
+static int EncodingConverttoObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static int EncodingDirsObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+static int EncodingNamesObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
+static int EncodingSystemObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static inline int ForeachAssignments(Tcl_Interp *interp,
struct ForeachState *statePtr);
static inline void ForeachCleanup(Tcl_Interp *interp,
@@ -149,7 +164,7 @@ Tcl_BreakObjCmd(
*
*----------------------------------------------------------------------
*/
-
+#ifndef TCL_NO_DEPRECATED
/* ARGSUSED */
int
Tcl_CaseObjCmd(
@@ -267,6 +282,7 @@ Tcl_CaseObjCmd(
return TCL_OK;
}
+#endif /* !TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -541,79 +557,280 @@ Tcl_EncodingObjCmd(
switch ((enum options) index) {
case ENC_CONVERTTO:
- case ENC_CONVERTFROM: {
- Tcl_Obj *data;
- Tcl_DString ds;
- Tcl_Encoding encoding;
- int length;
- const char *stringPtr;
-
- if (objc == 3) {
- encoding = Tcl_GetEncoding(interp, NULL);
- data = objv[2];
- } else if (objc == 4) {
- if (Tcl_GetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) {
- return TCL_ERROR;
- }
- data = objv[3];
- } else {
- Tcl_WrongNumArgs(interp, 2, objv, "?encoding? data");
- return TCL_ERROR;
- }
+ return EncodingConverttoObjCmd(dummy, interp, objc, objv);
+ case ENC_CONVERTFROM:
+ return EncodingConvertfromObjCmd(dummy, interp, objc, objv);
+ case ENC_DIRS:
+ return EncodingDirsObjCmd(dummy, interp, objc, objv);
+ case ENC_NAMES:
+ return EncodingNamesObjCmd(dummy, interp, objc, objv);
+ case ENC_SYSTEM:
+ return EncodingSystemObjCmd(dummy, interp, objc, objv);
+ }
+ return TCL_OK;
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * TclInitEncodingCmd --
+ *
+ * This function creates the 'encoding' ensemble.
+ *
+ * Results:
+ * Returns the Tcl_Command so created.
+ *
+ * Side effects:
+ * The ensemble is initialized.
+ *
+ * This command is hidden in a safe interpreter.
+ */
- if ((enum options) index == ENC_CONVERTFROM) {
- /*
- * Treat the string as binary data.
- */
+Tcl_Command
+TclInitEncodingCmd(
+ Tcl_Interp* interp) /* Tcl interpreter */
+{
+ static const EnsembleImplMap encodingImplMap[] = {
+ {"convertfrom", EncodingConvertfromObjCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
+ {"convertto", EncodingConverttoObjCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
+ {"dirs", EncodingDirsObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
+ {"names", EncodingNamesObjCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
+ {"system", EncodingSystemObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
+ {NULL, NULL, NULL, NULL, NULL, 0}
+ };
- stringPtr = (char *) Tcl_GetByteArrayFromObj(data, &length);
- Tcl_ExternalToUtfDString(encoding, stringPtr, length, &ds);
+ return TclMakeEnsemble(interp, "encoding", encodingImplMap);
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * TclMakeEncodingCommandSafe --
+ *
+ * This function hides the unsafe 'dirs' and 'system' subcommands of
+ * the "encoding" Tcl command ensemble. It must be called only from
+ * TclHideUnsafeCommands.
+ *
+ * Results:
+ * A standard Tcl result
+ *
+ * Side effects:
+ * Adds commands to the table of hidden commands.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+TclMakeEncodingCommandSafe(
+ Tcl_Interp* interp) /* Tcl interpreter */
+{
+ static const struct {
+ const char *cmdName;
+ int unsafe;
+ } unsafeInfo[] = {
+ {"convertfrom", 0},
+ {"convertto", 0},
+ {"dirs", 1},
+ {"names", 0},
+ {"system", 0},
+ {NULL, 0}
+ };
- /*
- * Note that we cannot use Tcl_DStringResult here because it will
- * truncate the string at the first null byte.
- */
+ int i;
+ Tcl_DString oldBuf, newBuf;
- Tcl_SetObjResult(interp, TclDStringToObj(&ds));
- } else {
- /*
- * Store the result as binary data.
- */
-
- stringPtr = TclGetStringFromObj(data, &length);
- Tcl_UtfToExternalDString(encoding, stringPtr, length, &ds);
- Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(
- (unsigned char *) Tcl_DStringValue(&ds),
- Tcl_DStringLength(&ds)));
- Tcl_DStringFree(&ds);
+ Tcl_DStringInit(&oldBuf);
+ TclDStringAppendLiteral(&oldBuf, "::tcl::encoding::");
+ Tcl_DStringInit(&newBuf);
+ TclDStringAppendLiteral(&newBuf, "tcl:encoding:");
+ for (i=0 ; unsafeInfo[i].cmdName != NULL ; i++) {
+ if (unsafeInfo[i].unsafe) {
+ const char *oldName, *newName;
+
+ Tcl_DStringSetLength(&oldBuf, 17);
+ oldName = Tcl_DStringAppend(&oldBuf, unsafeInfo[i].cmdName, -1);
+ Tcl_DStringSetLength(&newBuf, 13);
+ newName = Tcl_DStringAppend(&newBuf, unsafeInfo[i].cmdName, -1);
+ if (TclRenameCommand(interp, oldName, "___tmp") != TCL_OK
+ || Tcl_HideCommand(interp, "___tmp", newName) != TCL_OK) {
+ Tcl_Panic("problem making 'encoding %s' safe: %s",
+ unsafeInfo[i].cmdName,
+ Tcl_GetString(Tcl_GetObjResult(interp)));
+ }
+ Tcl_CreateObjCommand(interp, oldName, BadEncodingSubcommand,
+ (ClientData) unsafeInfo[i].cmdName, NULL);
}
+ }
+ Tcl_DStringFree(&oldBuf);
+ Tcl_DStringFree(&newBuf);
- Tcl_FreeEncoding(encoding);
- break;
+ /*
+ * Ugh. The [encoding] command is now actually safe, but it is assumed by
+ * scripts that it is not, which messes up security policies.
+ */
+
+ if (Tcl_HideCommand(interp, "encoding", "encoding") != TCL_OK) {
+ Tcl_Panic("problem making 'encoding' safe: %s",
+ Tcl_GetString(Tcl_GetObjResult(interp)));
}
- case ENC_DIRS:
- return EncodingDirsObjCmd(dummy, interp, objc, objv);
- case ENC_NAMES:
- if (objc > 2) {
- Tcl_WrongNumArgs(interp, 2, objv, NULL);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * BadEncodingSubcommand --
+ *
+ * Command used to act as a backstop implementation when subcommands of
+ * "encoding" are unsafe (the real implementations of the subcommands are
+ * hidden). The clientData is always the full official subcommand name.
+ *
+ * Results:
+ * A standard Tcl result (always a TCL_ERROR).
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+BadEncodingSubcommand(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ const char *subcommandName = (const char *) clientData;
+
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "not allowed to invoke subcommand %s of encoding", subcommandName));
+ Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", NULL);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * EncodingConvertfromObjCmd --
+ *
+ * This command converts a byte array in an external encoding into a
+ * Tcl string
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+EncodingConvertfromObjCmd(
+ ClientData dummy, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
+{
+ Tcl_Obj *data; /* Byte array to convert */
+ Tcl_DString ds; /* Buffer to hold the string */
+ Tcl_Encoding encoding; /* Encoding to use */
+ int length; /* Length of the byte array being converted */
+ const char *bytesPtr; /* Pointer to the first byte of the array */
+
+ if (objc == 2) {
+ encoding = Tcl_GetEncoding(interp, NULL);
+ data = objv[1];
+ } else if (objc == 3) {
+ if (Tcl_GetEncodingFromObj(interp, objv[1], &encoding) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_GetEncodingNames(interp);
- break;
- case ENC_SYSTEM:
- if (objc > 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?encoding?");
+ data = objv[2];
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data");
+ return TCL_ERROR;
+ }
+
+ /*
+ * Convert the string into a byte array in 'ds'
+ */
+ bytesPtr = (char *) Tcl_GetByteArrayFromObj(data, &length);
+ Tcl_ExternalToUtfDString(encoding, bytesPtr, length, &ds);
+
+ /*
+ * Note that we cannot use Tcl_DStringResult here because it will
+ * truncate the string at the first null byte.
+ */
+
+ Tcl_SetObjResult(interp, TclDStringToObj(&ds));
+
+ /*
+ * We're done with the encoding
+ */
+
+ Tcl_FreeEncoding(encoding);
+ return TCL_OK;
+
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * EncodingConverttoObjCmd --
+ *
+ * This command converts a Tcl string into a byte array that
+ * encodes the string according to some encoding.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+EncodingConverttoObjCmd(
+ ClientData dummy, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
+{
+ Tcl_Obj *data; /* String to convert */
+ Tcl_DString ds; /* Buffer to hold the byte array */
+ Tcl_Encoding encoding; /* Encoding to use */
+ int length; /* Length of the string being converted */
+ const char *stringPtr; /* Pointer to the first byte of the string */
+
+ /* TODO - ADJUST OBJ INDICES WHEN ENSEMBLIFYING THIS */
+
+ if (objc == 2) {
+ encoding = Tcl_GetEncoding(interp, NULL);
+ data = objv[1];
+ } else if (objc == 3) {
+ if (Tcl_GetEncodingFromObj(interp, objv[1], &encoding) != TCL_OK) {
return TCL_ERROR;
}
- if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- Tcl_GetEncodingName(NULL), -1));
- } else {
- return Tcl_SetSystemEncoding(interp, TclGetString(objv[2]));
- }
- break;
+ data = objv[2];
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data");
+ return TCL_ERROR;
}
+
+ /*
+ * Convert the string to a byte array in 'ds'
+ */
+
+ stringPtr = TclGetStringFromObj(data, &length);
+ Tcl_UtfToExternalDString(encoding, stringPtr, length, &ds);
+ Tcl_SetObjResult(interp,
+ Tcl_NewByteArrayObj((unsigned char*) Tcl_DStringValue(&ds),
+ Tcl_DStringLength(&ds)));
+ Tcl_DStringFree(&ds);
+
+ /*
+ * We're done with the encoding
+ */
+
+ Tcl_FreeEncoding(encoding);
return TCL_OK;
+
}
/*
@@ -641,16 +858,16 @@ EncodingDirsObjCmd(
{
Tcl_Obj *dirListObj;
- if (objc > 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?dirList?");
+ if (objc > 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?dirList?");
return TCL_ERROR;
}
- if (objc == 2) {
+ if (objc == 1) {
Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath());
return TCL_OK;
}
- dirListObj = objv[2];
+ dirListObj = objv[1];
if (Tcl_SetEncodingSearchPath(dirListObj) == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected directory list but got \"%s\"",
@@ -664,6 +881,68 @@ EncodingDirsObjCmd(
}
/*
+ *-----------------------------------------------------------------------------
+ *
+ * EncodingNamesObjCmd --
+ *
+ * This command returns a list of the available encoding names
+ *
+ * Results:
+ * Returns a standard Tcl result
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+EncodingNamesObjCmd(ClientData dummy, /* Unused */
+ Tcl_Interp* interp, /* Tcl interpreter */
+ int objc, /* Number of command line args */
+ Tcl_Obj* const objv[]) /* Vector of command line args */
+{
+ if (objc > 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
+ Tcl_GetEncodingNames(interp);
+ return TCL_OK;
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * EncodingSystemObjCmd --
+ *
+ * This command retrieves or changes the system encoding
+ *
+ * Results:
+ * Returns a standard Tcl result
+ *
+ * Side effects:
+ * May change the system encoding.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+EncodingSystemObjCmd(ClientData dummy, /* Unused */
+ Tcl_Interp* interp, /* Tcl interpreter */
+ int objc, /* Number of command line args */
+ Tcl_Obj* const objv[]) /* Vector of command line args */
+{
+ if (objc > 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?encoding?");
+ return TCL_ERROR;
+ }
+ if (objc == 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(Tcl_GetEncodingName(NULL), -1));
+ } else {
+ return Tcl_SetSystemEncoding(interp, TclGetString(objv[1]));
+ }
+ return TCL_OK;
+}
+
+/*
*----------------------------------------------------------------------
*
* Tcl_ErrorObjCmd --
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 7420538..a7a5f43 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -1717,19 +1717,24 @@ InfoLoadedCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- const char *interpName;
+ const char *interpName, *packageName;
- if ((objc != 1) && (objc != 2)) {
- Tcl_WrongNumArgs(interp, 1, objv, "?interp?");
+ if (objc > 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?interp? ?packageName?");
return TCL_ERROR;
}
- if (objc == 1) { /* Get loaded pkgs in all interpreters. */
+ if (objc < 2) { /* Get loaded pkgs in all interpreters. */
interpName = NULL;
} else { /* Get pkgs just in specified interp. */
interpName = TclGetString(objv[1]);
}
- return TclGetLoadedPackages(interp, interpName);
+ if (objc < 3) { /* Get loaded files in all packages. */
+ packageName = NULL;
+ } else { /* Get pkgs just in specified interp. */
+ packageName = TclGetString(objv[2]);
+ }
+ return TclGetLoadedPackagesEx(interp, interpName, packageName);
}
/*
@@ -2155,8 +2160,8 @@ Tcl_JoinObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
- int listLen, i;
- Tcl_Obj *resObjPtr, *joinObjPtr, **elemPtrs;
+ int listLen;
+ Tcl_Obj *resObjPtr = NULL, *joinObjPtr, **elemPtrs;
if ((objc < 2) || (objc > 3)) {
Tcl_WrongNumArgs(interp, 1, objv, "list ?joinString?");
@@ -2173,19 +2178,47 @@ Tcl_JoinObjCmd(
return TCL_ERROR;
}
+ if (listLen == 0) {
+ /* No elements to join; default empty result is correct. */
+ return TCL_OK;
+ }
+ if (listLen == 1) {
+ /* One element; return it */
+ Tcl_SetObjResult(interp, elemPtrs[0]);
+ return TCL_OK;
+ }
+
joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2];
Tcl_IncrRefCount(joinObjPtr);
- resObjPtr = Tcl_NewObj();
- for (i = 0; i < listLen; i++) {
- if (i > 0) {
- Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
+ if (Tcl_GetCharLength(joinObjPtr) == 0) {
+ TclStringCatObjv(interp, /* inPlace */ 0, listLen, elemPtrs,
+ &resObjPtr);
+ } else {
+ int i;
+
+ resObjPtr = Tcl_NewObj();
+ for (i = 0; i < listLen; i++) {
+ if (i > 0) {
+
+ /*
+ * NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
+ * to shimmer joinObjPtr. If it did, then the case where
+ * objv[1] and objv[2] are the same value would not be safe.
+ * Accessing elemPtrs would crash.
+ */
+
+ Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
+ }
+ Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
}
- Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
}
Tcl_DecrRefCount(joinObjPtr);
- Tcl_SetObjResult(interp, resObjPtr);
- return TCL_OK;
+ if (resObjPtr) {
+ Tcl_SetObjResult(interp, resObjPtr);
+ return TCL_OK;
+ }
+ return TCL_ERROR;
}
/*
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index cf7c686..ddb57b0 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -323,7 +323,7 @@ Tcl_RegexpObjCmd(
if (match == 0) {
/*
- * We want to set the value of the intepreter result only when
+ * We want to set the value of the interpreter result only when
* this is the first time through the loop.
*/
@@ -989,8 +989,11 @@ TclNRSourceObjCmd(
{
const char *encodingName = NULL;
Tcl_Obj *fileName;
+ int result;
+ void **pkgFiles = NULL;
+ void *names = NULL;
- if (objc != 2 && objc !=4) {
+ if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "?-encoding name? fileName");
return TCL_ERROR;
}
@@ -1008,9 +1011,30 @@ TclNRSourceObjCmd(
return TCL_ERROR;
}
encodingName = TclGetString(objv[2]);
- }
+ } else if (objc == 3) {
+ /* Handle undocumented -nopkg option. This should only be
+ * used by the internal ::tcl::Pkg::source utility function. */
+ static const char *const nopkgoptions[] = {
+ "-nopkg", NULL
+ };
+ int index;
- return TclNREvalFile(interp, fileName, encodingName);
+ if (TCL_ERROR == Tcl_GetIndexFromObj(interp, objv[1], nopkgoptions,
+ "option", TCL_EXACT, &index)) {
+ return TCL_ERROR;
+ }
+ pkgFiles = Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
+ /* Make sure that during the following TclNREvalFile no filenames
+ * are recorded for inclusion in the "package files" command */
+ names = *pkgFiles;
+ *pkgFiles = NULL;
+ }
+ result = TclNREvalFile(interp, fileName, encodingName);
+ if (pkgFiles) {
+ /* restore "tclPkgFiles" assocdata to how it was. */
+ *pkgFiles = names;
+ }
+ return result;
}
/*
@@ -1176,8 +1200,7 @@ StringFirstCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tcl_UniChar *needleStr, *haystackStr;
- int match, start, needleLen, haystackLen;
+ int start = 0;
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv,
@@ -1185,82 +1208,23 @@ StringFirstCmd(
return TCL_ERROR;
}
- /*
- * We are searching haystackStr for the sequence needleStr.
- */
-
- match = -1;
- start = 0;
- haystackLen = -1;
-
- needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
- haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
-
if (objc == 4) {
- /*
- * If a startIndex is specified, we will need to fast forward to that
- * point in the string before we think about a match.
- */
+ int size = Tcl_GetCharLength(objv[2]);
- if (TclGetIntForIndexM(interp, objv[3], haystackLen-1,
- &start) != TCL_OK){
+ if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &start)) {
return TCL_ERROR;
}
- /*
- * Reread to prevent shimmering problems.
- */
-
- needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
- haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
-
- if (start >= haystackLen) {
- goto str_first_done;
- } else if (start > 0) {
- haystackStr += start;
- haystackLen -= start;
- } else if (start < 0) {
- /*
- * Invalid start index mapped to string start; Bug #423581
- */
-
+ if (start < 0) {
start = 0;
}
- }
-
- /*
- * If the length of the needle is more than the length of the haystack, it
- * cannot be contained in there so we can avoid searching. [Bug 2960021]
- */
-
- if (needleLen > 0 && needleLen <= haystackLen) {
- register Tcl_UniChar *p, *end;
-
- end = haystackStr + haystackLen - needleLen + 1;
- for (p = haystackStr; p < end; p++) {
- /*
- * Scan forward to find the first character.
- */
-
- if ((*p == *needleStr) && (TclUniCharNcmp(needleStr, p,
- (unsigned long) needleLen) == 0)) {
- match = p - haystackStr;
- break;
- }
+ if (start >= size) {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
+ return TCL_OK;
}
}
-
- /*
- * Compute the character index of the matching string by counting the
- * number of characters before the match.
- */
-
- if ((match != -1) && (objc == 4)) {
- match += start;
- }
-
- str_first_done:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(match));
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(TclStringFind(objv[1],
+ objv[2], start)));
return TCL_OK;
}
@@ -1289,76 +1253,31 @@ StringLastCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tcl_UniChar *needleStr, *haystackStr, *p;
- int match, start, needleLen, haystackLen;
+ int last = INT_MAX - 1;
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv,
- "needleString haystackString ?startIndex?");
+ "needleString haystackString ?lastIndex?");
return TCL_ERROR;
}
- /*
- * We are searching haystackString for the sequence needleString.
- */
-
- match = -1;
- start = 0;
- haystackLen = -1;
-
- needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
- haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
-
if (objc == 4) {
- /*
- * If a startIndex is specified, we will need to restrict the string
- * range to that char index in the string
- */
+ int size = Tcl_GetCharLength(objv[2]);
- if (TclGetIntForIndexM(interp, objv[3], haystackLen-1,
- &start) != TCL_OK){
+ if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &last)) {
return TCL_ERROR;
}
- /*
- * Reread to prevent shimmering problems.
- */
-
- needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
- haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
-
- if (start < 0) {
- goto str_last_done;
- } else if (start < haystackLen) {
- p = haystackStr + start + 1 - needleLen;
- } else {
- p = haystackStr + haystackLen - needleLen;
+ if (last < 0) {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
+ return TCL_OK;
}
- } else {
- p = haystackStr + haystackLen - needleLen;
- }
-
- /*
- * If the length of the needle is more than the length of the haystack, it
- * cannot be contained in there so we can avoid searching. [Bug 2960021]
- */
-
- if (needleLen > 0 && needleLen <= haystackLen) {
- for (; p >= haystackStr; p--) {
- /*
- * Scan backwards to find the first character.
- */
-
- if ((*p == *needleStr) && !memcmp(needleStr, p,
- sizeof(Tcl_UniChar) * (size_t)needleLen)) {
- match = p - haystackStr;
- break;
- }
+ if (last >= size) {
+ last = size - 1;
}
}
-
- str_last_done:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(match));
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(TclStringLast(objv[1],
+ objv[2], last)));
return TCL_OK;
}
@@ -1873,7 +1792,7 @@ StringMapCmd(
/*
* This test is tricky, but has to be that way or you get other strange
- * inconsistencies (see test string-10.20 for illustration why!)
+ * inconsistencies (see test string-10.20.1 for illustration why!)
*/
if (objv[objc-2]->typePtr == &tclDictType && objv[objc-2]->bytes == NULL){
@@ -2223,9 +2142,7 @@ StringReptCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- const char *string1;
- char *string2;
- int count, index, length1, length2;
+ int count;
Tcl_Obj *resultPtr;
if (objc != 3) {
@@ -2243,70 +2160,15 @@ StringReptCmd(
if (count == 1) {
Tcl_SetObjResult(interp, objv[1]);
- goto done;
+ return TCL_OK;
} else if (count < 1) {
- goto done;
- }
- string1 = TclGetStringFromObj(objv[1], &length1);
- if (length1 <= 0) {
- goto done;
- }
-
- /*
- * Only build up a string that has data. Instead of building it up with
- * repeated appends, we just allocate the necessary space once and copy
- * the string value in.
- *
- * We have to worry about overflow [Bugs 714106, 2561746].
- * At this point we know 1 <= length1 <= INT_MAX and 2 <= count <= INT_MAX.
- * We need to keep 2 <= length2 <= INT_MAX.
- */
-
- if (count > INT_MAX/length1) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "result exceeds max size for a Tcl value (%d bytes)",
- INT_MAX));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
- return TCL_ERROR;
+ return TCL_OK;
}
- length2 = length1 * count;
- /*
- * Include space for the NUL.
- */
-
- string2 = attemptckalloc((unsigned) length2 + 1);
- if (string2 == NULL) {
- /*
- * Alloc failed. Note that in this case we try to do an error message
- * since this is a case that's most likely when the alloc is large and
- * that's easy to do with this API. Note that if we fail allocating a
- * short string, this will likely keel over too (and fatally).
- */
-
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "string size overflow, out of memory allocating %u bytes",
- length2 + 1));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ if (TCL_OK != TclStringRepeat(interp, objv[1], count, &resultPtr)) {
return TCL_ERROR;
}
- for (index = 0; index < count; index++) {
- memcpy(string2 + (length1 * index), string1, (size_t) length1);
- }
- string2[length2] = '\0';
-
- /*
- * We have to directly assign this instead of using Tcl_SetStringObj (and
- * indirectly TclInitStringRep) because that makes another copy of the
- * data.
- */
-
- TclNewObj(resultPtr);
- resultPtr->bytes = string2;
- resultPtr->length = length2;
Tcl_SetObjResult(interp, resultPtr);
-
- done:
return TCL_OK;
}
@@ -2855,7 +2717,7 @@ StringCatCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int i;
+ int code;
Tcl_Obj *objResultPtr;
if (objc < 2) {
@@ -2872,16 +2734,16 @@ StringCatCmd(
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
- objResultPtr = objv[1];
- if (Tcl_IsShared(objResultPtr)) {
- objResultPtr = Tcl_DuplicateObj(objResultPtr);
- }
- for(i = 2;i < objc;i++) {
- Tcl_AppendObjToObj(objResultPtr, objv[i]);
+
+ code = TclStringCatObjv(interp, /* inPlace */ 1, objc-1, objv+1,
+ &objResultPtr);
+
+ if (code == TCL_OK) {
+ Tcl_SetObjResult(interp, objResultPtr);
+ return TCL_OK;
}
- Tcl_SetObjResult(interp, objResultPtr);
- return TCL_OK;
+ return code;
}
/*
@@ -4319,7 +4181,7 @@ TclNRTryObjCmd(
}
info[0] = objv[i]; /* type */
- TclNewIntObj(info[1], code); /* returnCode */
+ TclNewLongObj(info[1], code); /* returnCode */
if (info[2] == NULL) { /* errorCodePrefix */
TclNewObj(info[2]);
}
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index bce17dc..b9bc228 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -734,6 +734,105 @@ TclCompileCatchCmd(
return TCL_OK;
}
+/*----------------------------------------------------------------------
+ *
+ * TclCompileClockClicksCmd --
+ *
+ * Procedure called to compile the "tcl::clock::clicks" command.
+ *
+ * Results:
+ * Returns TCL_OK for a successful compile. Returns TCL_ERROR to defer
+ * evaluation to run time.
+ *
+ * Side effects:
+ * Instructions are added to envPtr to execute the "clock clicks"
+ * command at runtime.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclCompileClockClicksCmd(
+ Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Parse *parsePtr, /* Points to a parse structure for the command
+ * created by Tcl_ParseCommand. */
+ Command *cmdPtr, /* Points to defintion of command being
+ * compiled. */
+ CompileEnv *envPtr) /* Holds resulting instructions. */
+{
+ Tcl_Token* tokenPtr;
+
+ switch (parsePtr->numWords) {
+ case 1:
+ /*
+ * No args
+ */
+ TclEmitInstInt1(INST_CLOCK_READ, 0, envPtr);
+ break;
+ case 2:
+ /*
+ * -milliseconds or -microseconds
+ */
+ tokenPtr = TokenAfter(parsePtr->tokenPtr);
+ if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD
+ || tokenPtr[1].size < 4
+ || tokenPtr[1].size > 13) {
+ return TCL_ERROR;
+ } else if (!strncmp(tokenPtr[1].start, "-microseconds",
+ tokenPtr[1].size)) {
+ TclEmitInstInt1(INST_CLOCK_READ, 1, envPtr);
+ break;
+ } else if (!strncmp(tokenPtr[1].start, "-milliseconds",
+ tokenPtr[1].size)) {
+ TclEmitInstInt1(INST_CLOCK_READ, 2, envPtr);
+ break;
+ } else {
+ return TCL_ERROR;
+ }
+ default:
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
+
+
+/*----------------------------------------------------------------------
+ *
+ * TclCompileClockReadingCmd --
+ *
+ * Procedure called to compile the "tcl::clock::microseconds",
+ * "tcl::clock::milliseconds" and "tcl::clock::seconds" commands.
+ *
+ * Results:
+ * Returns TCL_OK for a successful compile. Returns TCL_ERROR to defer
+ * evaluation to run time.
+ *
+ * Side effects:
+ * Instructions are added to envPtr to execute the "clock clicks"
+ * command at runtime.
+ *
+ * Client data is 1 for microseconds, 2 for milliseconds, 3 for seconds.
+ *----------------------------------------------------------------------
+ */
+
+int
+TclCompileClockReadingCmd(
+ Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Parse *parsePtr, /* Points to a parse structure for the command
+ * created by Tcl_ParseCommand. */
+ Command *cmdPtr, /* Points to defintion of command being
+ * compiled. */
+ CompileEnv *envPtr) /* Holds resulting instructions. */
+{
+ if (parsePtr->numWords != 1) {
+ return TCL_ERROR;
+ }
+
+ TclEmitInstInt1(INST_CLOCK_READ, PTR2INT(cmdPtr->objClientData), envPtr);
+
+ return TCL_OK;
+}
+
/*
*----------------------------------------------------------------------
*
@@ -3206,17 +3305,6 @@ TclCompileFormatCmd(
*/
TclEmitInstInt1(INST_STR_CONCAT1, i, envPtr);
- } else {
- /*
- * EVIL HACK! Force there to be a string representation in the case
- * where there's just a "%s" in the format; case covered by the test
- * format-20.1 (and it is horrible...)
- */
-
- TclEmitOpcode(INST_DUP, envPtr);
- PushStringLiteral(envPtr, "");
- TclEmitOpcode(INST_STR_EQ, envPtr);
- TclEmitOpcode(INST_POP, envPtr);
}
return TCL_OK;
}
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 10b3cc8..25d10d6 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -1902,10 +1902,10 @@ TclCompileSwitchCmd(
}
if (numWords % 2) {
abort:
- ckfree((char *) bodyToken);
- ckfree((char *) bodyTokenArray);
- ckfree((char *) bodyLines);
- ckfree((char *) bodyContLines);
+ ckfree(bodyToken);
+ ckfree(bodyTokenArray);
+ ckfree(bodyLines);
+ ckfree(bodyContLines);
return TCL_ERROR;
}
} else if (numWords % 2 || numWords == 0) {
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index c588731..b5de230 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -654,6 +654,11 @@ InstructionDesc const tclInstructionTable[] = {
/* Lappend list to general variable.
* Stack: ... varName list => ... listVarContents */
+ {"clockRead", 2, +1, 1, {OPERAND_UINT1}},
+ /* Read clock out to the stack. Operand is which clock to read
+ * 0=clicks, 1=microseconds, 2=milliseconds, 3=seconds.
+ * Stack: ... => ... time */
+
{NULL, 0, 0, 0, {OPERAND_NONE}}
};
@@ -765,7 +770,8 @@ TclSetByteCodeFromAny(
Interp *iPtr = (Interp *) interp;
CompileEnv compEnv; /* Compilation environment structure allocated
* in frame. */
- int length, result = TCL_OK;
+ size_t length;
+ int result = TCL_OK;
const char *stringPtr;
Proc *procPtr = iPtr->compiledProcPtr;
ContLineLoc *clLocPtr;
@@ -780,7 +786,8 @@ TclSetByteCodeFromAny(
}
#endif
- stringPtr = TclGetStringFromObj(objPtr, &length);
+ stringPtr = TclGetString(objPtr);
+ length = objPtr->length;
/*
* TIP #280: Pick up the CmdFrame in which the BC compiler was invoked and
@@ -1002,7 +1009,7 @@ void
TclReleaseByteCode(
register ByteCode *codePtr)
{
- if (--codePtr->refCount) {
+ if (codePtr->refCount-- > 1) {
return;
}
@@ -1380,14 +1387,14 @@ ReleaseCmdWordData(
Tcl_DecrRefCount(eclPtr->path);
}
for (i=0 ; i<eclPtr->nuloc ; i++) {
- ckfree((char *) eclPtr->loc[i].line);
+ ckfree(eclPtr->loc[i].line);
}
if (eclPtr->loc != NULL) {
- ckfree((char *) eclPtr->loc);
+ ckfree(eclPtr->loc);
}
- ckfree((char *) eclPtr);
+ ckfree(eclPtr);
}
/*
@@ -1801,7 +1808,7 @@ CompileCmdLiteral(
extraLiteralFlags |= LITERAL_UNSHARED;
}
- bytes = Tcl_GetStringFromObj(cmdObj, &numBytes);
+ bytes = TclGetStringFromObj(cmdObj, &numBytes);
cmdLitIdx = TclRegisterLiteral(envPtr, bytes, numBytes, extraLiteralFlags);
if (cmdPtr) {
@@ -2976,7 +2983,8 @@ TclFindCompiledLocal(
varNamePtr = &cachePtr->varName0;
for (i=0; i < cachePtr->numVars; varNamePtr++, i++) {
if (*varNamePtr) {
- localName = TclGetStringFromObj(*varNamePtr, &len);
+ localName = TclGetString(*varNamePtr);
+ len = (*varNamePtr)->length;
if ((len == nameBytes) && !strncmp(name, localName, len)) {
return i;
}
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 89cdc59..46e447f 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -417,7 +417,7 @@ typedef struct ByteCode {
* procs are specific to an interpreter so the
* code emitted will depend on the
* interpreter. */
- int compileEpoch; /* Value of iPtr->compileEpoch when this
+ unsigned int compileEpoch; /* Value of iPtr->compileEpoch when this
* ByteCode was compiled. Used to invalidate
* code when, e.g., commands with compile
* procs are redefined. */
@@ -425,7 +425,7 @@ typedef struct ByteCode {
* compiled. If the code is executed if a
* different namespace, it must be
* recompiled. */
- int nsEpoch; /* Value of nsPtr->resolverEpoch when this
+ size_t nsEpoch; /* Value of nsPtr->resolverEpoch when this
* ByteCode was compiled. Used to invalidate
* code when new namespace resolution rules
* are put into effect. */
@@ -821,8 +821,10 @@ typedef struct ByteCode {
#define INST_LAPPEND_LIST_ARRAY_STK 187
#define INST_LAPPEND_LIST_STK 188
+#define INST_CLOCK_READ 189
+
/* The last opcode */
-#define LAST_INST_OPCODE 188
+#define LAST_INST_OPCODE 189
/*
* Table describing the Tcl bytecode instructions: their name (for displaying
diff --git a/generic/tclConfig.c b/generic/tclConfig.c
index 2fb3e92..eb6807c 100644
--- a/generic/tclConfig.c
+++ b/generic/tclConfig.c
@@ -232,7 +232,7 @@ QueryConfigObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj("package not known", -1));
Tcl_SetErrorCode(interp, "TCL", "FATAL", "PKGCFG_BASE",
- Tcl_GetString(pkgName), NULL);
+ TclGetString(pkgName), NULL);
return TCL_ERROR;
}
@@ -247,7 +247,7 @@ QueryConfigObjCmd(
|| val == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("key not known", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONFIG",
- Tcl_GetString(objv[2]), NULL);
+ TclGetString(objv[2]), NULL);
return TCL_ERROR;
}
@@ -333,9 +333,9 @@ QueryConfigDelete(
Tcl_DictObjRemove(NULL, pDB, pkgName);
Tcl_DecrRefCount(pkgName);
if (cdPtr->encoding) {
- ckfree((char *)cdPtr->encoding);
+ ckfree(cdPtr->encoding);
}
- ckfree((char *)cdPtr);
+ ckfree(cdPtr);
}
/*
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index b022d3c..d543238 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -878,7 +878,7 @@ EXTERN int Tcl_EvalObjv(Tcl_Interp *interp, int objc,
EXTERN int Tcl_EvalObjEx(Tcl_Interp *interp, Tcl_Obj *objPtr,
int flags);
/* 294 */
-EXTERN void Tcl_ExitThread(int status);
+EXTERN TCL_NORETURN void Tcl_ExitThread(int status);
/* 295 */
EXTERN int Tcl_ExternalToUtf(Tcl_Interp *interp,
Tcl_Encoding encoding, const char *src,
@@ -1816,6 +1816,12 @@ EXTERN int Tcl_FSUnloadFile(Tcl_Interp *interp,
EXTERN void Tcl_ZlibStreamSetCompressionDictionary(
Tcl_ZlibStream zhandle,
Tcl_Obj *compressionDictionaryObj);
+/* 631 */
+EXTERN Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp,
+ const char *service, const char *host,
+ unsigned int flags,
+ Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData);
typedef struct {
const struct TclPlatStubs *tclPlatStubs;
@@ -2145,7 +2151,7 @@ typedef struct TclStubs {
int (*tcl_EvalEx) (Tcl_Interp *interp, const char *script, int numBytes, int flags); /* 291 */
int (*tcl_EvalObjv) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], int flags); /* 292 */
int (*tcl_EvalObjEx) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); /* 293 */
- void (*tcl_ExitThread) (int status); /* 294 */
+ TCL_NORETURN1 void (*tcl_ExitThread) (int status); /* 294 */
int (*tcl_ExternalToUtf) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); /* 295 */
char * (*tcl_ExternalToUtfDString) (Tcl_Encoding encoding, const char *src, int srcLen, Tcl_DString *dsPtr); /* 296 */
void (*tcl_FinalizeThread) (void); /* 297 */
@@ -2482,6 +2488,7 @@ typedef struct TclStubs {
void * (*tcl_FindSymbol) (Tcl_Interp *interp, Tcl_LoadHandle handle, const char *symbol); /* 628 */
int (*tcl_FSUnloadFile) (Tcl_Interp *interp, Tcl_LoadHandle handlePtr); /* 629 */
void (*tcl_ZlibStreamSetCompressionDictionary) (Tcl_ZlibStream zhandle, Tcl_Obj *compressionDictionaryObj); /* 630 */
+ Tcl_Channel (*tcl_OpenTcpServerEx) (Tcl_Interp *interp, const char *service, const char *host, unsigned int flags, Tcl_TcpAcceptProc *acceptProc, ClientData callbackData); /* 631 */
} TclStubs;
extern const TclStubs *tclStubsPtr;
@@ -3774,6 +3781,8 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_FSUnloadFile) /* 629 */
#define Tcl_ZlibStreamSetCompressionDictionary \
(tclStubsPtr->tcl_ZlibStreamSetCompressionDictionary) /* 630 */
+#define Tcl_OpenTcpServerEx \
+ (tclStubsPtr->tcl_OpenTcpServerEx) /* 631 */
#endif /* defined(USE_TCL_STUBS) */
@@ -3788,7 +3797,6 @@ extern const TclStubs *tclStubsPtr;
# undef Tcl_SetVar
# undef Tcl_ObjSetVar2
# undef Tcl_StaticPackage
-# undef TclFSGetNativePath
# define Tcl_CreateInterp() (tclStubsPtr->tcl_CreateInterp())
# define Tcl_GetStringResult(interp) (tclStubsPtr->tcl_GetStringResult(interp))
# define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp))
@@ -3827,13 +3835,13 @@ extern const TclStubs *tclStubsPtr;
sizeof(char *), msg, flags, indexPtr)
#undef Tcl_NewBooleanObj
#define Tcl_NewBooleanObj(boolValue) \
- Tcl_NewIntObj((boolValue)!=0)
+ Tcl_NewLongObj((boolValue)!=0)
#undef Tcl_DbNewBooleanObj
#define Tcl_DbNewBooleanObj(boolValue, file, line) \
Tcl_DbNewLongObj((boolValue)!=0, file, line)
#undef Tcl_SetBooleanObj
#define Tcl_SetBooleanObj(objPtr, boolValue) \
- Tcl_SetIntObj((objPtr), (boolValue)!=0)
+ Tcl_SetLongObj(objPtr, (boolValue)!=0)
#undef Tcl_SetVar
#define Tcl_SetVar(interp, varName, newValue, flags) \
Tcl_SetVar2(interp, varName, NULL, newValue, flags)
@@ -3855,6 +3863,51 @@ extern const TclStubs *tclStubsPtr;
#undef Tcl_UpVar
#define Tcl_UpVar(interp, frameName, varName, localName, flags) \
Tcl_UpVar2(interp, frameName, varName, NULL, localName, flags)
+#undef Tcl_AddErrorInfo
+#define Tcl_AddErrorInfo(interp, message) \
+ Tcl_AppendObjToErrorInfo(interp, Tcl_NewStringObj(message, -1))
+#undef Tcl_AddObjErrorInfo
+#define Tcl_AddObjErrorInfo(interp, message, length) \
+ Tcl_AppendObjToErrorInfo(interp, Tcl_NewStringObj(message, length))
+#ifdef TCL_NO_DEPRECATED
+#undef Tcl_Eval
+#define Tcl_Eval(interp, objPtr) \
+ Tcl_EvalEx(interp, objPtr, -1, 0)
+#undef Tcl_GlobalEval
+#define Tcl_GlobalEval(interp, objPtr) \
+ Tcl_EvalEx(interp, objPtr, -1, TCL_EVAL_GLOBAL)
+#undef Tcl_SaveResult
+#define Tcl_SaveResult(interp, statePtr) \
+ do { \
+ (statePtr)->objResultPtr = Tcl_GetObjResult(interp); \
+ Tcl_IncrRefCount((statePtr)->objResultPtr); \
+ Tcl_SetObjResult(interp, Tcl_NewObj()); \
+ } while(0)
+#undef Tcl_RestoreResult
+#define Tcl_RestoreResult(interp, statePtr) \
+ do { \
+ Tcl_ResetResult(interp); \
+ Tcl_SetObjResult(interp, (statePtr)->objResultPtr); \
+ Tcl_DecrRefCount((statePtr)->objResultPtr); \
+ } while(0)
+#undef Tcl_DiscardResult
+#define Tcl_DiscardResult(statePtr) \
+ Tcl_DecrRefCount((statePtr)->objResultPtr)
+#undef Tcl_SetResult
+#define Tcl_SetResult(interp, result, freeProc) \
+ do { \
+ char *__result = result; \
+ Tcl_FreeProc *__freeProc = freeProc; \
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(__result, -1)); \
+ if (__result != NULL && __freeProc != NULL && __freeProc != TCL_VOLATILE) { \
+ if (__freeProc == TCL_DYNAMIC) { \
+ ckfree(__result); \
+ } else { \
+ (*__freeProc)(__result); \
+ } \
+ } \
+ } while(0)
+#endif /* TCL_NO_DEPRECATED */
#if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
# if defined(__CYGWIN__) && defined(TCL_WIDE_INT_IS_LONG)
@@ -3909,10 +3962,10 @@ extern const TclStubs *tclStubsPtr;
*/
#undef Tcl_EvalObj
-#define Tcl_EvalObj(interp,objPtr) \
- Tcl_EvalObjEx((interp),(objPtr),0)
+#define Tcl_EvalObj(interp, objPtr) \
+ Tcl_EvalObjEx(interp, objPtr, 0)
#undef Tcl_GlobalEvalObj
-#define Tcl_GlobalEvalObj(interp,objPtr) \
- Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
+#define Tcl_GlobalEvalObj(interp, objPtr) \
+ Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_GLOBAL)
#endif /* _TCLDECLS */
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 428173d..970978f 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -142,7 +142,7 @@ typedef struct Dict {
* the entries in the order that they are
* created. */
int epoch; /* Epoch counter */
- int refcount; /* Reference counter (see above) */
+ size_t refCount; /* Reference counter (see above) */
Tcl_Obj *chain; /* Linked list used for invalidating the
* string representations of updated nested
* dictionaries. */
@@ -392,7 +392,7 @@ DupDictInternalRep(
newDict->epoch = 0;
newDict->chain = NULL;
- newDict->refcount = 1;
+ newDict->refCount = 1;
/*
* Store in the object.
@@ -427,8 +427,7 @@ FreeDictInternalRep(
{
Dict *dict = DICT(dictPtr);
- dict->refcount--;
- if (dict->refcount <= 0) {
+ if (dict->refCount-- <= 1) {
DeleteDict(dict);
}
dictPtr->typePtr = NULL;
@@ -507,7 +506,7 @@ UpdateStringOfDict(
/* Handle empty list case first, simplifies what follows */
if (numElems == 0) {
- dictPtr->bytes = tclEmptyStringRep;
+ dictPtr->bytes = &tclEmptyString;
dictPtr->length = 0;
return;
}
@@ -713,7 +712,7 @@ SetDictFromAny(
TclFreeIntRep(objPtr);
dict->epoch = 0;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(objPtr) = dict;
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
objPtr->typePtr = &tclDictType;
@@ -1117,7 +1116,7 @@ Tcl_DictObjFirst(
searchPtr->dictionaryPtr = (Tcl_Dict) dict;
searchPtr->epoch = dict->epoch;
searchPtr->next = cPtr->nextPtr;
- dict->refcount++;
+ dict->refCount++;
if (keyPtrPtr != NULL) {
*keyPtrPtr = Tcl_GetHashKey(&dict->table, &cPtr->entry);
}
@@ -1231,8 +1230,7 @@ Tcl_DictObjDone(
if (searchPtr->epoch != -1) {
searchPtr->epoch = -1;
dict = (Dict *) searchPtr->dictionaryPtr;
- dict->refcount--;
- if (dict->refcount <= 0) {
+ if (dict->refCount-- <= 1) {
DeleteDict(dict);
}
}
@@ -1384,7 +1382,7 @@ Tcl_NewDictObj(void)
InitChainTable(dict);
dict->epoch = 0;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(dictPtr) = dict;
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
dictPtr->typePtr = &tclDictType;
@@ -1434,7 +1432,7 @@ Tcl_DbNewDictObj(
InitChainTable(dict);
dict->epoch = 0;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(dictPtr) = dict;
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
dictPtr->typePtr = &tclDictType;
@@ -2282,7 +2280,7 @@ DictAppendCmd(
Tcl_Obj *const *objv)
{
Tcl_Obj *dictPtr, *valuePtr, *resultPtr;
- int i, allocatedDict = 0;
+ int allocatedDict = 0;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "dictVarName key ?value ...?");
@@ -2305,17 +2303,44 @@ DictAppendCmd(
return TCL_ERROR;
}
- if (valuePtr == NULL) {
- TclNewObj(valuePtr);
- } else if (Tcl_IsShared(valuePtr)) {
- valuePtr = Tcl_DuplicateObj(valuePtr);
- }
+ if ((objc > 3) || (valuePtr == NULL)) {
+ /* Only go through append activites when something will change. */
+ Tcl_Obj *appendObjPtr = NULL;
- for (i=3 ; i<objc ; i++) {
- Tcl_AppendObjToObj(valuePtr, objv[i]);
+ if (objc > 3) {
+ /* Something to append */
+
+ if (objc == 4) {
+ appendObjPtr = objv[3];
+ } else if (TCL_OK != TclStringCatObjv(interp, /* inPlace */ 1,
+ objc-3, objv+3, &appendObjPtr)) {
+ return TCL_ERROR;
+ }
+ }
+
+ if (appendObjPtr == NULL) {
+ /* => (objc == 3) => (valuePtr == NULL) */
+ TclNewObj(valuePtr);
+ } else if (valuePtr == NULL) {
+ valuePtr = appendObjPtr;
+ appendObjPtr = NULL;
+ }
+
+ if (appendObjPtr) {
+ if (Tcl_IsShared(valuePtr)) {
+ valuePtr = Tcl_DuplicateObj(valuePtr);
+ }
+
+ Tcl_AppendObjToObj(valuePtr, appendObjPtr);
+ }
+
+ Tcl_DictObjPut(NULL, dictPtr, objv[2], valuePtr);
}
- Tcl_DictObjPut(NULL, dictPtr, objv[2], valuePtr);
+ /*
+ * Even if nothing changed, we still overwrite so that variable
+ * trace expectations are met.
+ */
resultPtr = Tcl_ObjSetVar2(interp, objv[1], NULL, dictPtr,
TCL_LEAVE_ERR_MSG);
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 0d6da8e..5e977e6 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -254,7 +254,6 @@ DisassembleByteCodeObj(
int codeOffset, codeLen, srcOffset, srcLen, numCmds, delta, i, line;
Interp *iPtr = (Interp *) *codePtr->interpHandle;
Tcl_Obj *bufferObj, *fileObj;
- char ptrBuf1[20], ptrBuf2[20];
TclNewObj(bufferObj);
if (codePtr->refCount <= 0) {
@@ -269,11 +268,9 @@ DisassembleByteCodeObj(
* Print header lines describing the ByteCode.
*/
- sprintf(ptrBuf1, "%p", codePtr);
- sprintf(ptrBuf2, "%p", iPtr);
Tcl_AppendPrintfToObj(bufferObj,
- "ByteCode 0x%s, refCt %u, epoch %u, interp 0x%s (epoch %u)\n",
- ptrBuf1, codePtr->refCount, codePtr->compileEpoch, ptrBuf2,
+ "ByteCode %p, refCt %u, epoch %u, interp %p (epoch %u)\n",
+ codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr,
iPtr->compileEpoch);
Tcl_AppendToObj(bufferObj, " Source ", -1);
PrintSourceToObj(bufferObj, codePtr->source,
@@ -316,10 +313,9 @@ DisassembleByteCodeObj(
Proc *procPtr = codePtr->procPtr;
int numCompiledLocals = procPtr->numCompiledLocals;
- sprintf(ptrBuf1, "%p", procPtr);
Tcl_AppendPrintfToObj(bufferObj,
- " Proc 0x%s, refCt %d, args %d, compiled locals %d\n",
- ptrBuf1, procPtr->refCount, procPtr->numArgs,
+ " Proc %p, refCt %d, args %d, compiled locals %d\n",
+ procPtr, procPtr->refCount, procPtr->numArgs,
numCompiledLocals);
if (numCompiledLocals > 0) {
CompiledLocal *localPtr = procPtr->firstLocalPtr;
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 99cb315..91c2278 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -46,7 +46,7 @@ typedef struct Encoding {
* nullSize is 2, this is a function that
* returns the number of bytes in a 0x0000
* terminated string. */
- int refCount; /* Number of uses of this structure. */
+ size_t refCount; /* Number of uses of this structure. */
Tcl_HashEntry *hPtr; /* Hash table entry that owns this encoding. */
} Encoding;
@@ -305,7 +305,7 @@ Tcl_GetEncodingFromObj(
Tcl_Obj *objPtr,
Tcl_Encoding *encodingPtr)
{
- const char *name = Tcl_GetString(objPtr);
+ const char *name = TclGetString(objPtr);
if (objPtr->typePtr != &encodingType) {
Tcl_Encoding encoding = Tcl_GetEncoding(interp, name);
@@ -705,7 +705,7 @@ Tcl_GetDefaultEncodingDir(void)
}
Tcl_ListObjIndex(NULL, searchPath, 0, &first);
- return Tcl_GetString(first);
+ return TclGetString(first);
}
/*
@@ -844,11 +844,7 @@ FreeEncoding(
if (encodingPtr == NULL) {
return;
}
- if (encodingPtr->refCount<=0) {
- Tcl_Panic("FreeEncoding: refcount problem !!!");
- }
- encodingPtr->refCount--;
- if (encodingPtr->refCount == 0) {
+ if (encodingPtr->refCount-- <= 1) {
if (encodingPtr->freeProc != NULL) {
encodingPtr->freeProc(encodingPtr->clientData);
}
@@ -977,7 +973,7 @@ Tcl_GetEncodingNames(
* Side effects:
* The reference count of the new system encoding is incremented. The
* reference count of the old system encoding is decremented and it may
- * be freed.
+ * be freed. All VFS cached information is invalidated.
*
*------------------------------------------------------------------------
*/
@@ -1008,6 +1004,7 @@ Tcl_SetSystemEncoding(
FreeEncoding(systemEncoding);
systemEncoding = encoding;
Tcl_MutexUnlock(&encodingMutex);
+ Tcl_FSMountsChanged(NULL);
return TCL_OK;
}
@@ -1518,10 +1515,10 @@ OpenEncodingFileChannel(
}
}
if (!verified) {
- const char *dirString = Tcl_GetString(directory);
+ const char *dirString = TclGetString(directory);
for (i=0; i<numDirs && !verified; i++) {
- if (strcmp(dirString, Tcl_GetString(dir[i])) == 0) {
+ if (strcmp(dirString, TclGetString(dir[i])) == 0) {
verified = 1;
}
}
@@ -1762,7 +1759,7 @@ LoadTableEncoding(
const char *p;
Tcl_ReadChars(chan, objPtr, 3 + 16 * (16 * 4 + 1), 0);
- p = Tcl_GetString(objPtr);
+ p = TclGetString(objPtr);
hi = (staticHex[UCHAR(p[0])] << 4) + staticHex[UCHAR(p[1])];
dataPtr->toUnicode[hi] = pageMemPtr;
p += 2;
@@ -3599,11 +3596,11 @@ unilen(
static void
InitializeEncodingSearchPath(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
const char *bytes;
- int i, numDirs, numBytes;
+ int i, numDirs;
Tcl_Obj *libPathObj, *encodingObj, *searchPathObj;
TclNewLiteralStringObj(encodingObj, "encoding");
@@ -3633,11 +3630,11 @@ InitializeEncodingSearchPath(
if (*encodingPtr) {
((Encoding *)(*encodingPtr))->refCount++;
}
- bytes = TclGetStringFromObj(searchPathObj, &numBytes);
+ bytes = TclGetString(searchPathObj);
- *lengthPtr = numBytes;
- *valuePtr = ckalloc(numBytes + 1);
- memcpy(*valuePtr, bytes, (size_t) numBytes + 1);
+ *lengthPtr = searchPathObj->length;
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, bytes, *lengthPtr + 1);
Tcl_DecrRefCount(searchPathObj);
}
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 43813f1..f3e8187 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -92,7 +92,7 @@ static const Tcl_ObjType ensembleCmdType = {
*/
typedef struct {
- int epoch; /* Used to confirm when the data in this
+ size_t epoch; /* Used to confirm when the data in this
* really structure matches up with the
* ensemble. */
Command *token; /* Reference to the command for which this
@@ -1605,7 +1605,7 @@ TclMakeEnsemble(
Tcl_DStringFree(&buf);
Tcl_DStringFree(&hiddenBuf);
if (nameParts != NULL) {
- ckfree((char *) nameParts);
+ ckfree(nameParts);
}
return ensemble;
}
@@ -3135,7 +3135,7 @@ TclCompileEnsemble(
* any extra elements that might have been appended by failing
* pathways above.
*/
- (void) Tcl_ListObjReplace(NULL, replaced, depth-1, INT_MAX, 0, NULL);
+ (void) Tcl_ListObjReplace(NULL, replaced, depth-1, LIST_MAX, 0, NULL);
/*
* TODO: Reconsider whether we ought to call CompileToInvokedCommand()
@@ -3306,7 +3306,7 @@ CompileToInvokedCommand(
Tcl_Token *tokPtr;
Tcl_Obj *objPtr, **words;
char *bytes;
- int length, i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
+ int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
DefineLineInformation;
/*
@@ -3319,8 +3319,8 @@ CompileToInvokedCommand(
for (i = 0, tokPtr = parsePtr->tokenPtr; i < parsePtr->numWords;
i++, tokPtr = TokenAfter(tokPtr)) {
if (i > 0 && i < numWords+1) {
- bytes = TclGetStringFromObj(words[i-1], &length);
- PushLiteral(envPtr, bytes, length);
+ bytes = TclGetString(words[i-1]);
+ PushLiteral(envPtr, bytes, words[i-1]->length);
continue;
}
@@ -3348,11 +3348,11 @@ CompileToInvokedCommand(
objPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr);
- bytes = Tcl_GetStringFromObj(objPtr, &length);
+ bytes = TclGetString(objPtr);
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
extraLiteralFlags |= LITERAL_UNSHARED;
}
- cmdLit = TclRegisterLiteral(envPtr, bytes, length, extraLiteralFlags);
+ cmdLit = TclRegisterLiteral(envPtr, bytes, objPtr->length, extraLiteralFlags);
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLit), cmdPtr);
TclEmitPush(cmdLit, envPtr);
TclDecrRefCount(objPtr);
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 0eabc13..49fd2ae 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -37,7 +37,7 @@ typedef struct BgError {
* pending background errors for the interpreter.
*/
-typedef struct ErrAssocData {
+typedef struct {
Tcl_Interp *interp; /* Interpreter in which error occurred. */
Tcl_Obj *cmdPrefix; /* First word(s) of the handler command */
BgError *firstBgPtr; /* First in list of all background errors
@@ -1044,7 +1044,7 @@ TclInitSubsystems(void)
TclInitAlloc(); /* Process wide mutex init */
#endif
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
- TclpInitAllocCache();
+ TclInitThreadAlloc(); /* Setup thread allocator caches */
#endif
#ifdef TCL_MEM_DEBUG
TclInitDbCkalloc(); /* Process wide mutex init */
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index df36958..ad80b28 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -19,7 +19,6 @@
#include "tclCompile.h"
#include "tclOOInt.h"
#include "tommath.h"
-#include "tclStringRep.h"
#include <math.h>
#include <assert.h>
@@ -326,7 +325,7 @@ VarHashCreateVar(
NEXT_INST_F(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
default: \
if ((condition) < 0) { \
- TclNewIntObj(objResultPtr, -1); \
+ TclNewLongObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -347,7 +346,7 @@ VarHashCreateVar(
NEXT_INST_V(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
default: \
if ((condition) < 0) { \
- TclNewIntObj(objResultPtr, -1); \
+ TclNewLongObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -358,7 +357,7 @@ VarHashCreateVar(
#define JUMP_PEEPHOLE_F(condition, pcAdjustment, cleanup) \
do{ \
if ((condition) < 0) { \
- TclNewIntObj(objResultPtr, -1); \
+ TclNewLongObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -367,7 +366,7 @@ VarHashCreateVar(
#define JUMP_PEEPHOLE_V(condition, pcAdjustment, cleanup) \
do{ \
if ((condition) < 0) { \
- TclNewIntObj(objResultPtr, -1); \
+ TclNewLongObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -513,7 +512,7 @@ VarHashCreateVar(
(&((objPtr)->internalRep.doubleValue)), TCL_OK) : \
((((objPtr)->typePtr == NULL) && ((objPtr)->bytes == NULL)) || \
(((objPtr)->bytes != NULL) && ((objPtr)->length == 0))) \
- ? (*(tPtr) = TCL_NUMBER_LONG),TCL_ERROR : \
+ ? TCL_ERROR : \
TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
#else /* !TCL_WIDE_INT_IS_LONG */
#define GetNumberFromObj(interp, objPtr, ptrPtr, tPtr) \
@@ -533,7 +532,7 @@ VarHashCreateVar(
(&((objPtr)->internalRep.doubleValue)), TCL_OK) : \
((((objPtr)->typePtr == NULL) && ((objPtr)->bytes == NULL)) || \
(((objPtr)->bytes != NULL) && ((objPtr)->length == 0))) \
- ? (*(tPtr) = TCL_NUMBER_LONG),TCL_ERROR : \
+ ? TCL_ERROR : \
TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
#endif /* TCL_WIDE_INT_IS_LONG */
@@ -911,9 +910,9 @@ TclCreateExecEnv(
+ (size_t) (size-1) * sizeof(Tcl_Obj *));
eePtr->execStackPtr = esPtr;
- TclNewBooleanObj(eePtr->constants[0], 0);
+ TclNewLongObj(eePtr->constants[0], 0);
Tcl_IncrRefCount(eePtr->constants[0]);
- TclNewBooleanObj(eePtr->constants[1], 1);
+ TclNewLongObj(eePtr->constants[1], 1);
Tcl_IncrRefCount(eePtr->constants[1]);
eePtr->interp = interp;
eePtr->callbackPtr = NULL;
@@ -1275,7 +1274,7 @@ TclStackFree(
Tcl_Obj **markerPtr, *marker;
if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
- ckfree((char *) freePtr);
+ ckfree(freePtr);
return;
}
@@ -1542,11 +1541,10 @@ CompileExprObj(
* TIP #280: No invoker (yet) - Expression compilation.
*/
- int length;
- const char *string = TclGetStringFromObj(objPtr, &length);
+ const char *string = TclGetString(objPtr);
- TclInitCompileEnv(interp, &compEnv, string, length, NULL, 0);
- TclCompileExpr(interp, string, length, &compEnv, 0);
+ TclInitCompileEnv(interp, &compEnv, string, objPtr->length, NULL, 0);
+ TclCompileExpr(interp, string, objPtr->length, &compEnv, 0);
/*
* Successful compilation. If the expression yielded no instructions,
@@ -2538,7 +2536,7 @@ TEBCresume(
/* FIXME: What is the right thing to trace? */
fprintf(stdout, "%d: (%u) yielding to [%.30s]\n",
iPtr->numLevels, (unsigned)(pc - codePtr->codeStart),
- Tcl_GetString(valuePtr));
+ TclGetString(valuePtr));
}
fflush(stdout);
}
@@ -2685,154 +2683,18 @@ TEBCresume(
NEXT_INST_F(5, 0, 0);
}
- case INST_STR_CONCAT1: {
- int appendLen = 0;
- char *bytes, *p;
- Tcl_Obj **currPtr;
- int onlyb = 1;
+ case INST_STR_CONCAT1:
opnd = TclGetUInt1AtPtr(pc+1);
- /*
- * Detect only-bytearray-or-null case.
- */
-
- for (currPtr=&OBJ_AT_DEPTH(opnd-1); currPtr<=&OBJ_AT_TOS; currPtr++) {
- if (((*currPtr)->typePtr != &tclByteArrayType)
- && ((*currPtr)->bytes != tclEmptyStringRep)) {
- onlyb = 0;
- break;
- } else if (((*currPtr)->typePtr == &tclByteArrayType) &&
- ((*currPtr)->bytes != NULL)) {
- onlyb = 0;
- break;
- }
- }
-
- /*
- * Compute the length to be appended.
- */
-
- if (onlyb) {
- for (currPtr = &OBJ_AT_DEPTH(opnd-2);
- appendLen >= 0 && currPtr <= &OBJ_AT_TOS; currPtr++) {
- if ((*currPtr)->bytes != tclEmptyStringRep) {
- Tcl_GetByteArrayFromObj(*currPtr, &length);
- appendLen += length;
- }
- }
- } else {
- for (currPtr = &OBJ_AT_DEPTH(opnd-2);
- appendLen >= 0 && currPtr <= &OBJ_AT_TOS; currPtr++) {
- bytes = TclGetStringFromObj(*currPtr, &length);
- if (bytes != NULL) {
- appendLen += length;
- }
- }
- }
-
- if (appendLen < 0) {
- /* TODO: convert panic to error ? */
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
- }
-
- /*
- * If nothing is to be appended, just return the first object by
- * dropping all the others from the stack; this saves both the
- * computation and copy of the string rep of the first object,
- * enabling the fast '$x[set x {}]' idiom for 'K $x [set x {}]'.
- */
-
- if (appendLen == 0) {
- TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
- NEXT_INST_V(2, (opnd-1), 0);
- }
-
- /*
- * If the first object is shared, we need a new obj for the result;
- * otherwise, we can reuse the first object. In any case, make sure it
- * has enough room to accomodate all the concatenated bytes. Note that
- * if it is unshared its bytes are copied by ckrealloc, so that we set
- * the loop parameters to avoid copying them again: p points to the
- * end of the already copied bytes, currPtr to the second object.
- */
-
- objResultPtr = OBJ_AT_DEPTH(opnd-1);
- if (!onlyb) {
- bytes = TclGetStringFromObj(objResultPtr, &length);
- if (length + appendLen < 0) {
- /* TODO: convert panic to error ? */
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded",
- INT_MAX);
- }
-#ifndef TCL_COMPILE_DEBUG
- if (bytes != tclEmptyStringRep && !Tcl_IsShared(objResultPtr)) {
- TclFreeIntRep(objResultPtr);
- objResultPtr->bytes = ckrealloc(bytes, length+appendLen+1);
- objResultPtr->length = length + appendLen;
- p = TclGetString(objResultPtr) + length;
- currPtr = &OBJ_AT_DEPTH(opnd - 2);
- } else
-#endif
- {
- p = ckalloc(length + appendLen + 1);
- TclNewObj(objResultPtr);
- objResultPtr->bytes = p;
- objResultPtr->length = length + appendLen;
- currPtr = &OBJ_AT_DEPTH(opnd - 1);
- }
-
- /*
- * Append the remaining characters.
- */
-
- for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
- bytes = TclGetStringFromObj(*currPtr, &length);
- if (bytes != NULL) {
- memcpy(p, bytes, (size_t) length);
- p += length;
- }
- }
- *p = '\0';
- } else {
- bytes = (char *) Tcl_GetByteArrayFromObj(objResultPtr, &length);
- if (length + appendLen < 0) {
- /* TODO: convert panic to error ? */
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded",
- INT_MAX);
- }
-#ifndef TCL_COMPILE_DEBUG
- if (!Tcl_IsShared(objResultPtr)) {
- bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
- length + appendLen);
- p = bytes + length;
- currPtr = &OBJ_AT_DEPTH(opnd - 2);
- } else
-#endif
- {
- TclNewObj(objResultPtr);
- bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
- length + appendLen);
- p = bytes;
- currPtr = &OBJ_AT_DEPTH(opnd - 1);
- }
-
- /*
- * Append the remaining characters.
- */
-
- for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
- if ((*currPtr)->bytes != tclEmptyStringRep) {
- bytes = (char *) Tcl_GetByteArrayFromObj(*currPtr,&length);
- memcpy(p, bytes, (size_t) length);
- p += length;
- }
- }
+ if (TCL_OK != TclStringCatObjv(interp, /* inPlace */ 1,
+ opnd, &OBJ_AT_DEPTH(opnd-1), &objResultPtr)) {
+ TRACE_ERROR(interp);
+ goto gotError;
}
TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
NEXT_INST_V(2, opnd, 1);
- }
case INST_CONCAT_STK:
/*
@@ -4666,7 +4528,7 @@ TEBCresume(
NEXT_INST_F(1, 0, 1);
}
case INST_INFO_LEVEL_NUM:
- TclNewIntObj(objResultPtr, iPtr->varFramePtr->level);
+ TclNewLongObj(objResultPtr, iPtr->varFramePtr->level);
TRACE_WITH_OBJ(("=> "), objResultPtr);
NEXT_INST_F(1, 0, 1);
case INST_INFO_LEVEL_ARGS: {
@@ -5035,7 +4897,7 @@ TEBCresume(
TRACE_ERROR(interp);
goto gotError;
}
- TclNewIntObj(objResultPtr, length);
+ TclNewLongObj(objResultPtr, length);
TRACE_APPEND(("%d\n", length));
NEXT_INST_F(1, 1, 1);
@@ -5506,7 +5368,7 @@ TEBCresume(
case INST_STR_LEN:
valuePtr = OBJ_AT_TOS;
length = Tcl_GetCharLength(valuePtr);
- TclNewIntObj(objResultPtr, length);
+ TclNewLongObj(objResultPtr, length);
TRACE(("\"%.20s\" => %d\n", O2S(valuePtr), length));
NEXT_INST_F(1, 1, 1);
@@ -5712,17 +5574,6 @@ TEBCresume(
length3 = Tcl_GetCharLength(value3Ptr);
/*
- * Remove substring. In-place.
- */
-
- if (length3 == 0 && !Tcl_IsShared(valuePtr) && toIdx == length) {
- TclDecrRefCount(value3Ptr);
- Tcl_SetObjLength(valuePtr, fromIdx);
- TRACE_APPEND(("\"%.30s\"\n", O2S(valuePtr)));
- NEXT_INST_F(1, 0, 0);
- }
-
- /*
* See if we can splice in place. This happens when the number of
* characters being replaced is the same as the number of characters
* in the string to be inserted.
@@ -5731,51 +5582,29 @@ TEBCresume(
if (length3 - 1 == toIdx - fromIdx) {
unsigned char *bytes1, *bytes2;
- /*
- * Flush the info in the string internal rep that refers to the
- * about-to-be-invalidated UTF-8 rep. This indicates that a new
- * buffer needs to be allocated, and assumes that the value is
- * already of tclStringTypePtr type, which should be true provided
- * we call it after Tcl_GetUnicodeFromObj.
- */
-#define MarkStringInternalRepForFlush(objPtr) \
- (GET_STRING(objPtr)->allocated = 0)
-
if (Tcl_IsShared(valuePtr)) {
objResultPtr = Tcl_DuplicateObj(valuePtr);
- if (TclIsPureByteArray(objResultPtr)
- && TclIsPureByteArray(value3Ptr)) {
- bytes1 = Tcl_GetByteArrayFromObj(objResultPtr, NULL);
- bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
- memcpy(bytes1 + fromIdx, bytes2, length3);
- } else {
- ustring1 = Tcl_GetUnicodeFromObj(objResultPtr, NULL);
- ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
- memcpy(ustring1 + fromIdx, ustring2,
- length3 * sizeof(Tcl_UniChar));
- MarkStringInternalRepForFlush(objResultPtr);
- }
- Tcl_InvalidateStringRep(objResultPtr);
- TclDecrRefCount(value3Ptr);
- TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
- NEXT_INST_F(1, 1, 1);
} else {
- if (TclIsPureByteArray(valuePtr)
- && TclIsPureByteArray(value3Ptr)) {
- bytes1 = Tcl_GetByteArrayFromObj(valuePtr, NULL);
- bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
- memcpy(bytes1 + fromIdx, bytes2, length3);
- } else {
- ustring1 = Tcl_GetUnicodeFromObj(valuePtr, NULL);
- ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
- memcpy(ustring1 + fromIdx, ustring2,
- length3 * sizeof(Tcl_UniChar));
- MarkStringInternalRepForFlush(valuePtr);
- }
- Tcl_InvalidateStringRep(valuePtr);
- TclDecrRefCount(value3Ptr);
- TRACE_APPEND(("\"%.30s\"\n", O2S(valuePtr)));
+ objResultPtr = valuePtr;
+ }
+ if (TclIsPureByteArray(objResultPtr)
+ && TclIsPureByteArray(value3Ptr)) {
+ bytes1 = Tcl_GetByteArrayFromObj(objResultPtr, NULL);
+ bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
+ memcpy(bytes1 + fromIdx, bytes2, length3);
+ } else {
+ ustring1 = Tcl_GetUnicodeFromObj(objResultPtr, NULL);
+ ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
+ memcpy(ustring1 + fromIdx, ustring2,
+ length3 * sizeof(Tcl_UniChar));
+ }
+ Tcl_InvalidateStringRep(objResultPtr);
+ TclDecrRefCount(value3Ptr);
+ TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
+ if (objResultPtr == valuePtr) {
NEXT_INST_F(1, 0, 0);
+ } else {
+ NEXT_INST_F(1, 1, 1);
}
}
@@ -5791,54 +5620,38 @@ TEBCresume(
* Remove substring using copying.
*/
- if (length3 == 0) {
- if (fromIdx > 0) {
- objResultPtr = Tcl_NewUnicodeObj(ustring1, fromIdx);
- if (toIdx < length) {
- Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
- length - toIdx);
- }
- } else {
- objResultPtr = Tcl_NewUnicodeObj(ustring1 + toIdx + 1,
- length - toIdx);
- }
- TclDecrRefCount(value3Ptr);
- TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
- NEXT_INST_F(1, 1, 1);
- }
-
- /*
- * Splice string pieces by full copying.
- */
-
+ objResultPtr = NULL;
if (fromIdx > 0) {
objResultPtr = Tcl_NewUnicodeObj(ustring1, fromIdx);
- Tcl_AppendObjToObj(objResultPtr, value3Ptr);
- if (toIdx < length) {
- Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
- length - toIdx);
+ }
+ if (length3 > 0) {
+ if (objResultPtr) {
+ Tcl_AppendObjToObj(objResultPtr, value3Ptr);
+ } else if (Tcl_IsShared(value3Ptr)) {
+ objResultPtr = Tcl_DuplicateObj(value3Ptr);
+ } else {
+ objResultPtr = value3Ptr;
}
- } else if (Tcl_IsShared(value3Ptr)) {
- objResultPtr = Tcl_DuplicateObj(value3Ptr);
- if (toIdx < length) {
+ }
+ if (toIdx < length) {
+ if (objResultPtr) {
Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
length - toIdx);
- }
- } else {
- /*
- * Be careful with splicing the stack in this case; we have a
- * refCount:1 object in value3Ptr and we want to append to it and
- * make it be the refCount:1 object at the top of the stack
- * afterwards. [Bug 82e7f67325]
- */
-
- if (toIdx < length) {
- Tcl_AppendUnicodeToObj(value3Ptr, ustring1 + toIdx + 1,
+ } else {
+ objResultPtr = Tcl_NewUnicodeObj(ustring1 + toIdx + 1,
length - toIdx);
}
+ }
+ if (objResultPtr == NULL) {
+ /* This has to be the case [string replace $s 0 end {}] */
+ /* which has result {} which is same as value3Ptr. */
+ objResultPtr = value3Ptr;
+ }
+ if (objResultPtr == value3Ptr) {
+ /* See [Bug 82e7f67325] */
+ TclDecrRefCount(OBJ_AT_TOS);
+ OBJ_AT_TOS = value3Ptr;
TRACE_APPEND(("\"%.30s\"\n", O2S(value3Ptr)));
- TclDecrRefCount(valuePtr);
- OBJ_AT_TOS = value3Ptr; /* Tricky! */
NEXT_INST_F(1, 0, 0);
}
TclDecrRefCount(value3Ptr);
@@ -5906,45 +5719,19 @@ TEBCresume(
NEXT_INST_V(1, 3, 1);
case INST_STR_FIND:
- ustring1 = Tcl_GetUnicodeFromObj(OBJ_AT_TOS, &length); /* Haystack */
- ustring2 = Tcl_GetUnicodeFromObj(OBJ_UNDER_TOS, &length2);/* Needle */
-
- match = -1;
- if (length2 > 0 && length2 <= length) {
- end = ustring1 + length - length2 + 1;
- for (p=ustring1 ; p<end ; p++) {
- if ((*p == *ustring2) &&
- memcmp(ustring2,p,sizeof(Tcl_UniChar)*length2) == 0) {
- match = p - ustring1;
- break;
- }
- }
- }
+ match = TclStringFind(OBJ_UNDER_TOS, OBJ_AT_TOS, 0);
TRACE(("%.20s %.20s => %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
- TclNewIntObj(objResultPtr, match);
+ TclNewLongObj(objResultPtr, match);
NEXT_INST_F(1, 2, 1);
case INST_STR_FIND_LAST:
- ustring1 = Tcl_GetUnicodeFromObj(OBJ_AT_TOS, &length); /* Haystack */
- ustring2 = Tcl_GetUnicodeFromObj(OBJ_UNDER_TOS, &length2);/* Needle */
-
- match = -1;
- if (length2 > 0 && length2 <= length) {
- for (p=ustring1+length-length2 ; p>=ustring1 ; p--) {
- if ((*p == *ustring2) &&
- memcmp(ustring2,p,sizeof(Tcl_UniChar)*length2) == 0) {
- match = p - ustring1;
- break;
- }
- }
- }
+ match = TclStringLast(OBJ_UNDER_TOS, OBJ_AT_TOS, INT_MAX - 1);
TRACE(("%.20s %.20s => %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
-
- TclNewIntObj(objResultPtr, match);
+ TclNewLongObj(objResultPtr, match);
NEXT_INST_F(1, 2, 1);
case INST_STR_CLASS:
@@ -6148,7 +5935,7 @@ TEBCresume(
type1 = TCL_NUMBER_WIDE;
}
}
- TclNewIntObj(objResultPtr, type1);
+ TclNewLongObj(objResultPtr, type1);
TRACE(("\"%.20s\" => %d\n", O2S(OBJ_AT_TOS), type1));
NEXT_INST_F(1, 1, 1);
@@ -6163,16 +5950,17 @@ TEBCresume(
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
- if (GetNumberFromObj(NULL, valuePtr, &ptr1, &type1) != TCL_OK) {
+ if (GetNumberFromObj(NULL, valuePtr, &ptr1, &type1) != TCL_OK
+ || GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2) != TCL_OK) {
/*
* At least one non-numeric argument - compare as strings.
*/
goto stringCompare;
}
- if (type1 == TCL_NUMBER_NAN) {
+ if (type1 == TCL_NUMBER_NAN || type2 == TCL_NUMBER_NAN) {
/*
- * NaN first arg: NaN != to everything, other compares are false.
+ * NaN arg: NaN != to everything, other compares are false.
*/
iResult = (*pc == INST_NEQ);
@@ -6182,21 +5970,6 @@ TEBCresume(
compare = MP_EQ;
goto convertComparison;
}
- if (GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2) != TCL_OK) {
- /*
- * At least one non-numeric argument - compare as strings.
- */
-
- goto stringCompare;
- }
- if (type2 == TCL_NUMBER_NAN) {
- /*
- * NaN 2nd arg: NaN != to everything, other compares are false.
- */
-
- iResult = (*pc == INST_NEQ);
- goto foundResult;
- }
if ((type1 == TCL_NUMBER_LONG) && (type2 == TCL_NUMBER_LONG)) {
l1 = *((const long *)ptr1);
l2 = *((const long *)ptr2);
@@ -6355,7 +6128,7 @@ TEBCresume(
if (l1 > 0L) {
objResultPtr = TCONST(0);
} else {
- TclNewIntObj(objResultPtr, -1);
+ TclNewLongObj(objResultPtr, -1);
}
TRACE(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 2, 1);
@@ -7255,7 +7028,7 @@ TEBCresume(
NEXT_INST_F(1, 0, -1);
case INST_PUSH_RETURN_CODE:
- TclNewIntObj(objResultPtr, result);
+ TclNewLongObj(objResultPtr, result);
TRACE(("=> %u\n", result));
NEXT_INST_F(1, 0, 1);
@@ -7891,6 +7664,39 @@ TEBCresume(
* -----------------------------------------------------------------
*/
+ case INST_CLOCK_READ:
+ { /* Read the wall clock */
+ Tcl_WideInt wval;
+ Tcl_Time now;
+ switch(TclGetUInt1AtPtr(pc+1)) {
+ case 0: /* clicks */
+#ifdef TCL_WIDE_CLICKS
+ wval = TclpGetWideClicks();
+#else
+ wval = (Tcl_WideInt) TclpGetClicks();
+#endif
+ break;
+ case 1: /* microseconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec * 1000000 + now.usec;
+ break;
+ case 2: /* milliseconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec * 1000 + now.usec / 1000;
+ break;
+ case 3: /* seconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec;
+ break;
+ default:
+ Tcl_Panic("clockRead instruction with unknown clock#");
+ }
+ /* TclNewWideObj(objResultPtr, wval); doesn't exist */
+ objResultPtr = Tcl_NewWideIntObj(wval);
+ TRACE_WITH_OBJ(("=> "), objResultPtr);
+ NEXT_INST_F(2, 0, 1);
+ }
+
default:
Tcl_Panic("TclNRExecuteByteCode: unrecognized opCode %u", *pc);
} /* end of switch on opCode */
@@ -9147,7 +8953,7 @@ ExecuteExtendedBinaryMathOp(
}
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
mp_init(&bigResult);
- mp_expt_d(&big1, big2.dp[0], &bigResult);
+ mp_expt_d_ex(&big1, big2.dp[0], &bigResult, 1);
mp_clear(&big1);
mp_clear(&big2);
BIG_RESULT(&bigResult);
@@ -9671,9 +9477,9 @@ PrintByteCodeInfo(
Proc *procPtr = codePtr->procPtr;
Interp *iPtr = (Interp *) *codePtr->interpHandle;
- fprintf(stdout, "\nExecuting ByteCode 0x%p, refCt %u, epoch %u, interp 0x%p (epoch %u)\n",
- codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr,
- iPtr->compileEpoch);
+ fprintf(stdout, "\nExecuting ByteCode 0x%p, refCt %" TCL_LL_MODIFIER "u, epoch %" TCL_LL_MODIFIER "u, interp 0x%p (epoch %" TCL_LL_MODIFIER "u)\n",
+ codePtr, (Tcl_WideInt)codePtr->refCount, (Tcl_WideInt)codePtr->compileEpoch, iPtr,
+ (Tcl_WideInt)iPtr->compileEpoch);
fprintf(stdout, " Source: ");
TclPrintSource(stdout, codePtr->source, 60);
@@ -9770,7 +9576,7 @@ ValidatePcAndStackTop(
TclNewLiteralStringObj(message, "\n executing ");
Tcl_IncrRefCount(message);
Tcl_AppendLimitedToObj(message, cmd, numChars, 100, NULL);
- fprintf(stderr,"%s\n", Tcl_GetString(message));
+ fprintf(stderr,"%s\n", TclGetString(message));
Tcl_DecrRefCount(message);
} else {
fprintf(stderr, "\n");
@@ -10233,7 +10039,7 @@ TclExprFloatError(
"unknown floating-point error, errno = %d", errno);
Tcl_SetErrorCode(interp, "ARITH", "UNKNOWN",
- Tcl_GetString(objPtr), NULL);
+ TclGetString(objPtr), NULL);
Tcl_SetObjResult(interp, objPtr);
}
}
diff --git a/generic/tclHash.c b/generic/tclHash.c
index ac9d40e..78ad514 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -924,7 +924,7 @@ HashStringKey(
*
* BogusFind --
*
- * This function is invoked when an Tcl_FindHashEntry is called on a
+ * This function is invoked when Tcl_FindHashEntry is called on a
* table that has been deleted.
*
* Results:
@@ -951,7 +951,7 @@ BogusFind(
*
* BogusCreate --
*
- * This function is invoked when an Tcl_CreateHashEntry is called on a
+ * This function is invoked when Tcl_CreateHashEntry is called on a
* table that has been deleted.
*
* Results:
diff --git a/generic/tclHistory.c b/generic/tclHistory.c
index b08e352..47806d4 100644
--- a/generic/tclHistory.c
+++ b/generic/tclHistory.c
@@ -62,15 +62,14 @@ Tcl_RecordAndEval(
* instead of Tcl_Eval. */
{
register Tcl_Obj *cmdPtr;
- int length = strlen(cmd);
int result;
- if (length > 0) {
+ if (cmd[0]) {
/*
* Call Tcl_RecordAndEvalObj to do the actual work.
*/
- cmdPtr = Tcl_NewStringObj(cmd, length);
+ cmdPtr = Tcl_NewStringObj(cmd, -1);
Tcl_IncrRefCount(cmdPtr);
result = Tcl_RecordAndEvalObj(interp, cmdPtr, flags);
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 80f6fa4..1460392 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -116,7 +116,7 @@ typedef struct CopyState {
* The structure defined below is used in this file only.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
NextChannelHandler *nestedHandlerPtr;
/* This variable holds the list of nested
* Tcl_NotifyChannel invocations. */
@@ -321,9 +321,9 @@ static int WillRead(Channel *chanPtr);
typedef struct ResolvedChanName {
ChannelState *statePtr; /* The saved lookup result */
Tcl_Interp *interp; /* The interp in which the lookup was done. */
- int epoch; /* The epoch of the channel when the lookup
+ size_t epoch; /* The epoch of the channel when the lookup
* was done. Use to verify validity. */
- int refCount; /* Share this struct among many Tcl_Obj. */
+ size_t refCount; /* Share this struct among many Tcl_Obj. */
} ResolvedChanName;
static void DupChannelIntRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr);
@@ -381,20 +381,20 @@ ChanCloseHalf(
*
* ChanRead --
*
- * Read up to dstSize bytes using the inputProc of chanPtr, store
- * them at dst, and return the number of bytes stored.
+ * Read up to dstSize bytes using the inputProc of chanPtr, store them at
+ * dst, and return the number of bytes stored.
*
* Results:
* The return value of the driver inputProc,
* - number of bytes stored at dst, ot
- * - -1 on error, with a Posix error code available to the
- * caller by calling Tcl_GetErrno().
+ * - -1 on error, with a Posix error code available to the caller by
+ * calling Tcl_GetErrno().
*
* Side effects:
- * The CHANNEL_BLOCKED and CHANNEL_EOF flags of the channel state are
- * set as appropriate.
- * On EOF, the inputEncodingFlags are set to perform ending operations
- * on decoding.
+ * The CHANNEL_BLOCKED and CHANNEL_EOF flags of the channel state are set
+ * as appropriate. On EOF, the inputEncodingFlags are set to perform
+ * ending operations on decoding.
+ *
* TODO - Is this really the right place for that?
*
*---------------------------------------------------------------------------
@@ -408,15 +408,17 @@ ChanRead(
int bytesRead, result;
/*
- * If the caller asked for zero bytes, we'd force the inputProc
- * to return zero bytes, and then misinterpret that as EOF.
+ * If the caller asked for zero bytes, we'd force the inputProc to return
+ * zero bytes, and then misinterpret that as EOF.
*/
+
assert(dstSize > 0);
/*
* Each read op must set the blocked and eof states anew, not let
* the effect of prior reads leak through.
*/
+
if (GotFlag(chanPtr->state, CHANNEL_EOF)) {
chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START;
}
@@ -429,7 +431,10 @@ ChanRead(
bytesRead = chanPtr->typePtr->inputProc(chanPtr->instanceData,
dst, dstSize, &result);
- /* Stop any flag leakage through stacked channel levels */
+ /*
+ * Stop any flag leakage through stacked channel levels.
+ */
+
if (GotFlag(chanPtr->state, CHANNEL_EOF)) {
chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START;
}
@@ -437,10 +442,10 @@ ChanRead(
chanPtr->state->inputEncodingFlags &= ~TCL_ENCODING_END;
if (bytesRead > 0) {
/*
- * If we get a short read, signal up that we may be BLOCKED.
- * We should avoid calling the driver because on some
- * platforms we will block in the low level reading code even
- * though the channel is set into nonblocking mode.
+ * If we get a short read, signal up that we may be BLOCKED. We should
+ * avoid calling the driver because on some platforms we will block in
+ * the low level reading code even though the channel is set into
+ * nonblocking mode.
*/
if (bytesRead < dstSize) {
@@ -574,7 +579,10 @@ TclFinalizeIOSubsystem(void)
int active = 1; /* Flag == 1 while there's still work to do */
int doflushnb;
- /* Fetch the pre-TIP#398 compatibility flag */
+ /*
+ * Fetch the pre-TIP#398 compatibility flag.
+ */
+
{
const char *s;
Tcl_DString ds;
@@ -619,18 +627,20 @@ TclFinalizeIOSubsystem(void)
*/
if (active) {
-
TclChannelPreserve((Tcl_Channel)chanPtr);
+
/*
- * TIP #398: by default, we no longer set the channel back into
- * blocking mode. To restore the old blocking behavior, the
- * environment variable TCL_FLUSH_NONBLOCKING_ON_EXIT must be set
+ * TIP #398: by default, we no longer set the channel back into
+ * blocking mode. To restore the old blocking behavior, the
+ * environment variable TCL_FLUSH_NONBLOCKING_ON_EXIT must be set
* and not be "0".
*/
+
if (doflushnb) {
- /* Set the channel back into blocking mode to ensure that we wait
- * for all data to flush out.
- */
+ /*
+ * Set the channel back into blocking mode to ensure that we
+ * wait for all data to flush out.
+ */
(void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr,
"-blocking", "on");
@@ -1511,8 +1521,10 @@ TclGetChannelFromObj(
if ((resPtr->interp == interp) /* Same interp context */
/* No epoch change in channel since lookup */
&& (resPtr->epoch == statePtr->epoch)) {
+ /*
+ * Have a valid saved lookup. Jump to end to return it.
+ */
- /* Have a valid saved lookup. Jump to end to return it. */
goto valid;
}
}
@@ -1527,7 +1539,10 @@ TclGetChannelFromObj(
}
if (resPtr && resPtr->refCount == 1) {
- /* Re-use the ResolvedCmdName struct */
+ /*
+ * Re-use the ResolvedCmdName struct.
+ */
+
Tcl_Release((ClientData) resPtr->statePtr);
} else {
@@ -1671,7 +1686,7 @@ Tcl_CreateChannel(
* Set the channel up initially in AUTO input translation mode to accept
* "\n", "\r" and "\r\n". Output translation mode is set to a platform
* specific default value. The eofChar is set to 0 for both input and
- * output, so that Tcl does not look for an in-file EOF indicator (e.g.
+ * output, so that Tcl does not look for an in-file EOF indicator (e.g.,
* ^Z) and does not append an EOF indicator to files.
*/
@@ -1899,7 +1914,6 @@ Tcl_StackChannel(
*/
if (((mask & TCL_READABLE) != 0) && (statePtr->inQueueHead != NULL)) {
-
/*
* When statePtr->inQueueHead is not NULL, we know
* prevChanPtr->inQueueHead must be NULL.
@@ -2031,9 +2045,7 @@ Tcl_UnstackChannel(
* of registered channels we wind down the state of the
* transformation, and then restore the state of underlying channel
* into the old structure.
- */
-
- /*
+ *
* TODO: Figure out how to handle the situation where the chan
* operations called below by this unstacking operation cause
* another unstacking recursively. In that case the downChanPtr
@@ -2511,6 +2523,7 @@ RecycleBuffer(
/*
* Do we have to free the buffer to the OS?
*/
+
if (IsShared(bufPtr)) {
mustDiscard = 1;
}
@@ -2521,9 +2534,8 @@ RecycleBuffer(
}
/*
- * Only save buffers which have the requested buffersize for the
- * channel. This is to honor dynamic changes of the buffersize
- * made by the user.
+ * Only save buffers which have the requested buffersize for the channel.
+ * This is to honor dynamic changes of the buffersize made by the user.
*/
if ((bufPtr->bufLength - BUFFER_PADDING) != statePtr->bufSize) {
@@ -2693,14 +2705,18 @@ FlushChannel(
/*
* Should we shift the current output buffer over to the output queue?
* First check that there are bytes in it. If so then...
- * If the output queue is empty, then yes, trusting the caller called
- * us only when written bytes ought to be flushed.
- * If the current output buffer is full, then yes, so we can meet
- * the post-condition that on a successful return to caller we've
- * left space in the current output buffer for more writing (the flush
- * call was to make new room).
- * If the channel is blocking, then yes, so we guarantee that
- * blocking flushes actually flush all pending data.
+ *
+ * If the output queue is empty, then yes, trusting the caller called us
+ * only when written bytes ought to be flushed.
+ *
+ * If the current output buffer is full, then yes, so we can meet the
+ * post-condition that on a successful return to caller we've left space
+ * in the current output buffer for more writing (the flush call was to
+ * make new room).
+ *
+ * If the channel is blocking, then yes, so we guarantee that blocking
+ * flushes actually flush all pending data.
+ *
* Otherwise, no. Keep the current output buffer where it is so more
* can be written to it, possibly filling it, to promote more efficient
* buffer usage.
@@ -2794,8 +2810,8 @@ FlushChannel(
/*
* TIP #219, Tcl Channel Reflection API.
* When defering the error copy a message from the bypass into
- * the unreported area. Or discard it if the new error is to be
- * ignored in favor of an earlier defered error.
+ * the unreported area. Or discard it if the new error is to
+ * be ignored in favor of an earlier defered error.
*/
Tcl_Obj *msg = statePtr->chanMsg;
@@ -2847,8 +2863,11 @@ FlushChannel(
ReleaseChannelBuffer(bufPtr);
break;
} else {
- /* TODO: Consider detecting and reacting to short writes
- * on blocking channels. Ought not happen. See iocmd-24.2. */
+ /*
+ * TODO: Consider detecting and reacting to short writes on
+ * blocking channels. Ought not happen. See iocmd-24.2.
+ */
+
wroteSome = 1;
}
@@ -2882,7 +2901,6 @@ FlushChannel(
ResetFlag(statePtr, BG_FLUSH_SCHEDULED);
ChanWatch(chanPtr, statePtr->interestMask);
} else {
-
/*
* When we are calledFromAsyncFlush, that means a writable
* state on the channel triggered the call, so we should be
@@ -2927,7 +2945,8 @@ FlushChannel(
(statePtr->outQueueHead == NULL) &&
((statePtr->curOutPtr == NULL) ||
IsBufferEmpty(statePtr->curOutPtr))) {
- errorCode = CloseChannelPart(interp, chanPtr, errorCode, TCL_CLOSE_WRITE);
+ errorCode = CloseChannelPart(interp, chanPtr, errorCode,
+ TCL_CLOSE_WRITE);
goto done;
}
@@ -3398,7 +3417,6 @@ Tcl_Close(
if (GotFlag(statePtr, TCL_WRITABLE) && (statePtr->encoding != NULL)
&& !(statePtr->outputEncodingFlags & TCL_ENCODING_START)) {
-
int code = CheckChannelErrors(statePtr, TCL_WRITABLE);
if (code == 0) {
@@ -3488,12 +3506,14 @@ Tcl_Close(
}
return TCL_ERROR;
}
+
/*
* Bug 97069ea11a: set error message if a flush code is set and no error
* message set up to now.
*/
+
if (flushcode != 0 && interp != NULL
- && 0 == Tcl_GetCharLength(Tcl_GetObjResult(interp)) ) {
+ && 0 == Tcl_GetCharLength(Tcl_GetObjResult(interp))) {
Tcl_SetErrno(flushcode);
Tcl_SetObjResult(interp,
Tcl_NewStringObj(Tcl_PosixError(interp), -1));
@@ -3588,8 +3608,8 @@ Tcl_CloseEx(
}
/*
- * A user may try to call half-close from within a channel close
- * handler. That won't do.
+ * A user may try to call half-close from within a channel close handler.
+ * That won't do.
*/
if (statePtr->flags & CHANNEL_INCLOSE) {
@@ -3660,9 +3680,12 @@ CloseWrite(
* closed. May still be used by some
* interpreter */
{
- /* Notes: clear-channel-handlers - write side only ? or keep around, just
- * not called. */
- /* No close cllbacks are run - channel is still open (read side) */
+ /*
+ * Notes: clear-channel-handlers - write side only ? or keep around, just
+ * not called.
+ *
+ * No close callbacks are run - channel is still open (read side)
+ */
ChannelState *statePtr = chanPtr->state;
/* State of real IO channel. */
@@ -3687,9 +3710,9 @@ CloseWrite(
* Notes: Due to the assertion of CHANNEL_CLOSEDWRITE in the flags
* FlushChannel() has called CloseChannelPart(). While we can still access
* "chan" (no structures were freed), the only place which may still
- * contain a message is the interpreter itself, and "CloseChannelPart" made
- * sure to lift any channel message it generated into it. Hence the NULL
- * argument in the call below.
+ * contain a message is the interpreter itself, and "CloseChannelPart"
+ * made sure to lift any channel message it generated into it. Hence the
+ * NULL argument in the call below.
*/
if (TclChanCaughtErrorBypass(interp, NULL)) {
@@ -3913,10 +3936,10 @@ Tcl_ClearChannelHandlers(
StopCopy(statePtr->csPtrW);
/*
- * Must set the interest mask now to 0, otherwise infinite loops
- * will occur if Tcl_DoOneEvent is called before the channel is
- * finally deleted in FlushChannel. This can happen if the channel
- * has a background flush active.
+ * Must set the interest mask now to 0, otherwise infinite loops will
+ * occur if Tcl_DoOneEvent is called before the channel is finally deleted
+ * in FlushChannel. This can happen if the channel has a background flush
+ * active.
*/
statePtr->interestMask = 0;
@@ -4185,22 +4208,24 @@ WillRead(
Channel *chanPtr)
{
if (chanPtr->typePtr == NULL) {
- /* Prevent read attempts on a closed channel */
+ /*
+ * Prevent read attempts on a closed channel.
+ */
+
DiscardInputQueued(chanPtr->state, 0);
Tcl_SetErrno(EINVAL);
return -1;
}
if ((chanPtr->typePtr->seekProc != NULL)
&& (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) {
-
/*
- * CAVEAT - The assumption here is that FlushChannel() will
- * push out the bytes of any writes that are in progress.
- * Since this is a seekable channel, we assume it is not one
- * that can block and force bg flushing. Channels we know that
- * can do that -- sockets, pipes -- are not seekable. If the
- * assumption is wrong, more drastic measures may be required here
- * like temporarily setting the channel into blocking mode.
+ * CAVEAT - The assumption here is that FlushChannel() will push out
+ * the bytes of any writes that are in progress. Since this is a
+ * seekable channel, we assume it is not one that can block and force
+ * bg flushing. Channels we know that can do that - sockets, pipes -
+ * are not seekable. If the assumption is wrong, more drastic measures
+ * may be required here like temporarily setting the channel into
+ * blocking mode.
*/
if (FlushChannel(NULL, chanPtr, 0) != 0) {
@@ -4292,11 +4317,17 @@ Write(
&statePtr->outputEncodingState, dst,
dstLen + BUFFER_PADDING, &srcRead, &dstWrote, NULL);
- /* See chan-io-1.[89]. Tcl Bug 506297. */
+ /*
+ * See chan-io-1.[89]. Tcl Bug 506297.
+ */
+
statePtr->outputEncodingFlags &= ~TCL_ENCODING_START;
if ((result != TCL_OK) && (srcRead + dstWrote == 0)) {
- /* We're reading from invalid/incomplete UTF-8 */
+ /*
+ * We're reading from invalid/incomplete UTF-8.
+ */
+
ReleaseChannelBuffer(bufPtr);
if (total == 0) {
Tcl_SetErrno(EINVAL);
@@ -4336,11 +4367,10 @@ Write(
}
result |= Tcl_UtfToExternal(NULL, encoding, nl, nlLen,
- statePtr->outputEncodingFlags,
- &statePtr->outputEncodingState, dst,
- dstLen + BUFFER_PADDING, &srcRead, &dstWrote, NULL);
-
- assert (srcRead == nlLen);
+ statePtr->outputEncodingFlags,
+ &statePtr->outputEncodingState, dst,
+ dstLen + BUFFER_PADDING, &srcRead, &dstWrote, NULL);
+ assert(srcRead == nlLen);
bufPtr->nextAdded += dstWrote;
src++;
@@ -4354,11 +4384,11 @@ Write(
if (IsBufferOverflowing(bufPtr)) {
/*
- * When translating from UTF-8 to external encoding, we
- * allowed the translation to produce a character that crossed
- * the end of the output buffer, so that we would get a
- * completely full buffer before flushing it. The extra bytes
- * will be moved to the beginning of the next buffer.
+ * When translating from UTF-8 to external encoding, we allowed
+ * the translation to produce a character that crossed the end of
+ * the output buffer, so that we would get a completely full
+ * buffer before flushing it. The extra bytes will be moved to the
+ * beginning of the next buffer.
*/
saved = -SpaceLeft(bufPtr);
@@ -4378,15 +4408,16 @@ Write(
flushed += statePtr->bufSize;
/*
- * We just flushed. So if we have needNlFlush set to record
- * that we need to flush because theres a (translated) newline
- * in the buffer, that's likely not true any more. But there
- * is a tricky exception. If we have saved bytes that did not
- * really get flushed and those bytes came from a translation
- * of a newline as the last thing taken from the src array,
- * then needNlFlush needs to remain set to flag that the
- * next buffer still needs a newline flush.
+ * We just flushed. So if we have needNlFlush set to record that
+ * we need to flush because theres a (translated) newline in the
+ * buffer, that's likely not true any more. But there is a tricky
+ * exception. If we have saved bytes that did not really get
+ * flushed and those bytes came from a translation of a newline as
+ * the last thing taken from the src array, then needNlFlush needs
+ * to remain set to flag that the next buffer still needs a
+ * newline flush.
*/
+
if (needNlFlush && (saved == 0 || src[-1] != '\n')) {
needNlFlush = 0;
}
@@ -4492,8 +4523,8 @@ Tcl_GetsObj(
if (GotFlag(statePtr, CHANNEL_STICKY_EOF)) {
SetFlag(statePtr, CHANNEL_EOF);
- assert( statePtr->inputEncodingFlags & TCL_ENCODING_END );
- assert( !GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR) );
+ assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
+ assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
/* TODO: Do we need this? */
UpdateInterest(chanPtr);
@@ -4833,17 +4864,17 @@ Tcl_GetsObj(
*/
done:
- assert(!GotFlag(statePtr, CHANNEL_EOF)
- || GotFlag(statePtr, CHANNEL_STICKY_EOF)
- || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
-
- assert( !(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
- == (CHANNEL_EOF|CHANNEL_BLOCKED)) );
+ assert(!GotFlag(statePtr, CHANNEL_EOF)
+ || GotFlag(statePtr, CHANNEL_STICKY_EOF)
+ || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
+ assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
+ == (CHANNEL_EOF|CHANNEL_BLOCKED)));
/*
* Regenerate the top channel, in case it was changed due to
* self-modifying reflected transforms.
*/
+
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
@@ -4863,10 +4894,9 @@ Tcl_GetsObj(
* end-of-line or end-of-file has been seen. Bytes read from the input
* channel return as a ByteArray obj.
*
- * WARNING! The notion of "binary" used here is different from
- * notions of "binary" used in other places. In particular, this
- * "binary" routine may be called when an -eofchar is set on the
- * channel.
+ * WARNING! The notion of "binary" used here is different from notions
+ * of "binary" used in other places. In particular, this "binary" routine
+ * may be called when an -eofchar is set on the channel.
*
* Results:
* Number of characters accumulated in the object or -1 if error,
@@ -4932,8 +4962,8 @@ TclGetsObjBinary(
ResetFlag(statePtr, CHANNEL_BLOCKED);
while (1) {
/*
- * Subtract the number of bytes that were removed from channel
- * buffer during last call.
+ * Subtract the number of bytes that were removed from channel buffer
+ * during last call.
*/
if (bufPtr != NULL) {
@@ -4945,10 +4975,11 @@ TclGetsObjBinary(
if ((bufPtr == NULL) || (bufPtr->nextAdded == BUFFER_PADDING)) {
/*
- * All channel buffers were exhausted and the caller still
- * hasn't seen EOL. Need to read more bytes from the channel
- * device. Side effect is to allocate another channel buffer.
+ * All channel buffers were exhausted and the caller still hasn't
+ * seen EOL. Need to read more bytes from the channel device. Side
+ * effect is to allocate another channel buffer.
*/
+
if (GetInput(chanPtr) != 0) {
goto restore;
}
@@ -4958,15 +4989,15 @@ TclGetsObjBinary(
}
} else {
/*
- * Incoming CHANNEL_STICKY_EOF is filtered out on entry.
- * A new CHANNEL_STICKY_EOF set in this routine leads to
- * return before coming back here. When we are not dealing
- * with CHANNEL_STICKY_EOF, a CHANNEL_EOF implies an
- * empty buffer. Here the buffer is non-empty so we know
- * we're a non-EOF */
+ * Incoming CHANNEL_STICKY_EOF is filtered out on entry. A new
+ * CHANNEL_STICKY_EOF set in this routine leads to return before
+ * coming back here. When we are not dealing with
+ * CHANNEL_STICKY_EOF, a CHANNEL_EOF implies an empty buffer.
+ * Here the buffer is non-empty so we know we're a non-EOF.
+ */
- assert ( !GotFlag(statePtr, CHANNEL_STICKY_EOF) );
- assert ( !GotFlag(statePtr, CHANNEL_EOF) );
+ assert(!GotFlag(statePtr, CHANNEL_STICKY_EOF));
+ assert(!GotFlag(statePtr, CHANNEL_EOF));
}
dst = (unsigned char *) RemovePoint(bufPtr);
@@ -5033,8 +5064,8 @@ TclGetsObjBinary(
}
/*
- * Copy bytes from the channel buffer to the ByteArray.
- * This may realloc space, so keep track of result.
+ * Copy bytes from the channel buffer to the ByteArray. This may
+ * realloc space, so keep track of result.
*/
rawLen = dstEnd - dst;
@@ -5118,11 +5149,11 @@ TclGetsObjBinary(
*/
done:
- assert(!GotFlag(statePtr, CHANNEL_EOF)
- || GotFlag(statePtr, CHANNEL_STICKY_EOF)
- || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
- assert( !(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
- == (CHANNEL_EOF|CHANNEL_BLOCKED)) );
+ assert(!GotFlag(statePtr, CHANNEL_EOF)
+ || GotFlag(statePtr, CHANNEL_STICKY_EOF)
+ || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
+ assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
+ == (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return copiedTotal;
@@ -5255,15 +5286,15 @@ FilterInputBytes(
}
} else {
/*
- * Incoming CHANNEL_STICKY_EOF is filtered out on entry.
- * A new CHANNEL_STICKY_EOF set in this routine leads to
- * return before coming back here. When we are not dealing
- * with CHANNEL_STICKY_EOF, a CHANNEL_EOF implies an
- * empty buffer. Here the buffer is non-empty so we know
- * we're a non-EOF */
+ * Incoming CHANNEL_STICKY_EOF is filtered out on entry. A new
+ * CHANNEL_STICKY_EOF set in this routine leads to return before
+ * coming back here. When we are not dealing with CHANNEL_STICKY_EOF,
+ * a CHANNEL_EOF implies an empty buffer. Here the buffer is
+ * non-empty so we know we're a non-EOF.
+ */
- assert ( !GotFlag(statePtr, CHANNEL_STICKY_EOF) );
- assert ( !GotFlag(statePtr, CHANNEL_EOF) );
+ assert(!GotFlag(statePtr, CHANNEL_STICKY_EOF));
+ assert(!GotFlag(statePtr, CHANNEL_EOF));
}
/*
@@ -5593,7 +5624,9 @@ Tcl_ReadRaw(
return -1;
}
- /* First read bytes from the push-back buffers. */
+ /*
+ * First read bytes from the push-back buffers.
+ */
while (chanPtr->inQueueHead && bytesToRead > 0) {
ChannelBuffer *bufPtr = chanPtr->inQueueHead;
@@ -5601,7 +5634,9 @@ Tcl_ReadRaw(
int toCopy = (bytesInBuffer < bytesToRead) ? bytesInBuffer
: bytesToRead;
- /* Copy the current chunk into the read buffer. */
+ /*
+ * Copy the current chunk into the read buffer.
+ */
memcpy(readBuf, RemovePoint(bufPtr), (size_t) toCopy);
bufPtr->nextRemoved += toCopy;
@@ -5609,7 +5644,9 @@ Tcl_ReadRaw(
readBuf += toCopy;
bytesToRead -= toCopy;
- /* If the current buffer is empty recycle it. */
+ /*
+ * If the current buffer is empty recycle it.
+ */
if (IsBufferEmpty(bufPtr)) {
chanPtr->inQueueHead = bufPtr->nextPtr;
@@ -5621,37 +5658,40 @@ Tcl_ReadRaw(
}
/*
- * Go to the driver only if we got nothing from pushback.
- * Have to do it this way to avoid EOF mis-timings when we
- * consider the ability that EOF may not be a permanent
- * condition in the driver, and in that case we have to
- * synchronize.
+ * Go to the driver only if we got nothing from pushback. Have to do it
+ * this way to avoid EOF mis-timings when we consider the ability that EOF
+ * may not be a permanent condition in the driver, and in that case we
+ * have to synchronize.
*/
if (copied) {
return copied;
}
- /* This test not needed. */
- if (bytesToRead > 0) {
+ /*
+ * This test not needed.
+ */
+ if (bytesToRead > 0) {
int nread = ChanRead(chanPtr, readBuf, bytesToRead);
if (nread > 0) {
- /* Successful read (short is OK) - add to bytes copied */
+ /*
+ * Successful read (short is OK) - add to bytes copied.
+ */
+
copied += nread;
} else if (nread < 0) {
/*
- * An error signaled. If CHANNEL_BLOCKED, then the error
- * is not real, but an indication of blocked state. In
- * that case, retain the flag and let caller receive the
- * short read of copied bytes from the pushback.
- * HOWEVER, if copied==0 bytes from pushback then repeat
- * signalling the blocked state as an error to caller so
- * there is no false report of an EOF.
- * When !CHANNEL_BLOCKED, the error is real and passes on
- * to caller.
+ * An error signaled. If CHANNEL_BLOCKED, then the error is not
+ * real, but an indication of blocked state. In that case, retain
+ * the flag and let caller receive the short read of copied bytes
+ * from the pushback. HOWEVER, if copied==0 bytes from pushback
+ * then repeat signalling the blocked state as an error to caller
+ * so there is no false report of an EOF. When !CHANNEL_BLOCKED,
+ * the error is real and passes on to caller.
*/
+
if (!GotFlag(statePtr, CHANNEL_BLOCKED) || copied == 0) {
copied = -1;
}
@@ -5788,21 +5828,23 @@ DoReadChars(
/*
* Early out when next read will see eofchar.
*
- * NOTE: See DoRead for argument that it's a bug (one we're keeping)
- * to have this escape before the one for zero-char read request.
+ * NOTE: See DoRead for argument that it's a bug (one we're keeping) to
+ * have this escape before the one for zero-char read request.
*/
if (GotFlag(statePtr, CHANNEL_STICKY_EOF)) {
SetFlag(statePtr, CHANNEL_EOF);
- assert( statePtr->inputEncodingFlags & TCL_ENCODING_END );
- assert( !GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR) );
+ assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
+ assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
/* TODO: We don't need this call? */
UpdateInterest(chanPtr);
return 0;
}
- /* Special handling for zero-char read request. */
+ /*
+ * Special handling for zero-char read request.
+ */
if (toRead == 0) {
if (GotFlag(statePtr, CHANNEL_EOF)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_START;
@@ -5821,7 +5863,10 @@ DoReadChars(
chanPtr = statePtr->topChanPtr;
TclChannelPreserve((Tcl_Channel)chanPtr);
- /* Must clear the BLOCKED|EOF flags here since we check before reading */
+ /*
+ * Must clear the BLOCKED|EOF flags here since we check before reading.
+ */
+
if (GotFlag(statePtr, CHANNEL_EOF)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_START;
}
@@ -5879,10 +5924,11 @@ DoReadChars(
}
/*
- * Failure to fill a channel buffer may have left channel reporting
- * a "blocked" state, but so long as we fulfilled the request here,
- * the caller does not consider us blocked.
+ * Failure to fill a channel buffer may have left channel reporting a
+ * "blocked" state, but so long as we fulfilled the request here, the
+ * caller does not consider us blocked.
*/
+
if (toRead == 0) {
ResetFlag(statePtr, CHANNEL_BLOCKED);
}
@@ -5891,6 +5937,7 @@ DoReadChars(
* Regenerate the top channel, in case it was changed due to
* self-modifying reflected transforms.
*/
+
if (chanPtr != statePtr->topChanPtr) {
TclChannelRelease((Tcl_Channel)chanPtr);
chanPtr = statePtr->topChanPtr;
@@ -5901,11 +5948,12 @@ DoReadChars(
* Update the notifier state so we don't block while there is still data
* in the buffers.
*/
- assert(!GotFlag(statePtr, CHANNEL_EOF)
- || GotFlag(statePtr, CHANNEL_STICKY_EOF)
- || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
- assert( !(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
- == (CHANNEL_EOF|CHANNEL_BLOCKED)) );
+
+ assert(!GotFlag(statePtr, CHANNEL_EOF)
+ || GotFlag(statePtr, CHANNEL_STICKY_EOF)
+ || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
+ assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
+ == (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return copied;
@@ -6022,11 +6070,10 @@ ReadChars(
int numBytes, srcLen = BytesLeft(bufPtr);
/*
- * One src byte can yield at most one character. So when the
- * number of src bytes we plan to read is less than the limit on
- * character count to be read, clearly we will remain within that
- * limit, and we can use the value of "srcLen" as a tighter limit
- * for sizing receiving buffers.
+ * One src byte can yield at most one character. So when the number of
+ * src bytes we plan to read is less than the limit on character count to
+ * be read, clearly we will remain within that limit, and we can use the
+ * value of "srcLen" as a tighter limit for sizing receiving buffers.
*/
int toRead = ((charsToRead<0)||(charsToRead > srcLen)) ? srcLen : charsToRead;
@@ -6044,6 +6091,7 @@ ReadChars(
Tcl_AppendToObj(objPtr, NULL, dstLimit);
if (toRead == srcLen) {
unsigned int size;
+
dst = TclGetStringStorage(objPtr, &size) + numBytes;
dstLimit = size - numBytes;
} else {
@@ -6051,19 +6099,18 @@ ReadChars(
}
/*
- * This routine is burdened with satisfying several constraints.
- * It cannot append more than 'charsToRead` chars onto objPtr.
- * This is measured after encoding and translation transformations
- * are completed. There is no precise number of src bytes that can
- * be associated with the limit. Yet, when we are done, we must know
- * precisely the number of src bytes that were consumed to produce
- * the appended chars, so that all subsequent bytes are left in
- * the buffers for future read operations.
+ * This routine is burdened with satisfying several constraints. It cannot
+ * append more than 'charsToRead` chars onto objPtr. This is measured
+ * after encoding and translation transformations are completed. There is
+ * no precise number of src bytes that can be associated with the limit.
+ * Yet, when we are done, we must know precisely the number of src bytes
+ * that were consumed to produce the appended chars, so that all
+ * subsequent bytes are left in the buffers for future read operations.
*
- * The consequence is that we have no choice but to implement a
- * "trial and error" approach, where in general we may need to
- * perform transformations and copies multiple times to achieve
- * a consistent set of results. This takes the shape of a loop.
+ * The consequence is that we have no choice but to implement a "trial and
+ * error" approach, where in general we may need to perform
+ * transformations and copies multiple times to achieve a consistent set
+ * of results. This takes the shape of a loop.
*/
while (1) {
@@ -6076,18 +6123,17 @@ ReadChars(
}
/*
- * Perform the encoding transformation. Read no more than
- * srcLen bytes, write no more than dstLimit bytes.
+ * Perform the encoding transformation. Read no more than srcLen
+ * bytes, write no more than dstLimit bytes.
*
- * Some trickiness with encoding flags here. We do not want
- * the end of a buffer to be treated as the end of all input
- * when the presence of bytes in a next buffer are already
- * known to exist. This is checked with an assert() because
- * so far no test case causing the assertion to be false has
- * been created. The normal operations of channel reading
- * appear to cause EOF and TCL_ENCODING_END setting to appear
- * only in situations where there are no further bytes in
- * any buffers.
+ * Some trickiness with encoding flags here. We do not want the end
+ * of a buffer to be treated as the end of all input when the presence
+ * of bytes in a next buffer are already known to exist. This is
+ * checked with an assert() because so far no test case causing the
+ * assertion to be false has been created. The normal operations of
+ * channel reading appear to cause EOF and TCL_ENCODING_END setting to
+ * appear only in situations where there are no further bytes in any
+ * buffers.
*/
assert(bufPtr->nextPtr == NULL || BytesLeft(bufPtr->nextPtr) == 0
@@ -6098,10 +6144,10 @@ ReadChars(
dst, dstLimit, &srcRead, &dstDecoded, &numChars);
/*
- * Perform the translation transformation in place. Read no more
- * than the dstDecoded bytes the encoding transformation actually
- * produced. Capture the number of bytes written in dstWrote.
- * Capture the number of bytes actually consumed in dstRead.
+ * Perform the translation transformation in place. Read no more than
+ * the dstDecoded bytes the encoding transformation actually produced.
+ * Capture the number of bytes written in dstWrote. Capture the number
+ * of bytes actually consumed in dstRead.
*/
dstWrote = dstLimit;
@@ -6109,11 +6155,9 @@ ReadChars(
TranslateInputEOL(statePtr, dst, dst, &dstWrote, &dstRead);
if (dstRead < dstDecoded) {
-
/*
- * The encoding transformation produced bytes that the
- * translation transformation did not consume. Why did
- * this happen?
+ * The encoding transformation produced bytes that the translation
+ * transformation did not consume. Why did this happen?
*/
if (statePtr->inEofChar && dst[dstRead] == statePtr->inEofChar) {
@@ -6122,40 +6166,38 @@ ReadChars(
* we saw it and stopped translating at that point.
*
* NOTE the bizarre spec of TranslateInputEOL in this case.
- * Clearly the eof char had to be read in order to account
- * for the stopping, but the value of dstRead does not
- * include it.
+ * Clearly the eof char had to be read in order to account for
+ * the stopping, but the value of dstRead does not include it.
*
- * Also rather bizarre, our caller can only notice an
- * EOF condition if we return the value -1 as the number
- * of chars read. This forces us to perform a 2-call
- * dance where the first call can read all the chars
- * up to the eof char, and the second call is solely
- * for consuming the encoded eof char then pointed at
- * by src so that we can return that magic -1 value.
- * This seems really wasteful, especially since
- * the first decoding pass of each call is likely to
- * decode many bytes beyond that eof char that's all we
- * care about.
+ * Also rather bizarre, our caller can only notice an EOF
+ * condition if we return the value -1 as the number of chars
+ * read. This forces us to perform a 2-call dance where the
+ * first call can read all the chars up to the eof char, and
+ * the second call is solely for consuming the encoded eof
+ * char then pointed at by src so that we can return that
+ * magic -1 value. This seems really wasteful, especially
+ * since the first decoding pass of each call is likely to
+ * decode many bytes beyond that eof char that's all we care
+ * about.
*/
if (dstRead == 0) {
/*
- * Curious choice in the eof char handling. We leave
- * the eof char in the buffer. So, no need to compute
- * a proper srcRead value. At this point, there
- * are no chars before the eof char in the buffer.
+ * Curious choice in the eof char handling. We leave the
+ * eof char in the buffer. So, no need to compute a proper
+ * srcRead value. At this point, there are no chars before
+ * the eof char in the buffer.
*/
+
Tcl_SetObjLength(objPtr, numBytes);
return -1;
}
{
/*
- * There are chars leading the buffer before the eof
- * char. Adjust the dstLimit so we go back and read
- * only those and do not encounter the eof char this
- * time.
+ * There are chars leading the buffer before the eof char.
+ * Adjust the dstLimit so we go back and read only those
+ * and do not encounter the eof char this time.
*/
dstLimit = dstRead - 1 + TCL_UTF_MAX;
@@ -6167,10 +6209,9 @@ ReadChars(
}
/*
- * 2) The other way to read fewer bytes than are decoded
- * is when the final byte is \r and we're in a CRLF
- * translation mode so we cannot decide whether to
- * record \r or \n yet.
+ * 2) The other way to read fewer bytes than are decoded is when
+ * the final byte is \r and we're in a CRLF translation mode so
+ * we cannot decide whether to record \r or \n yet.
*/
assert(dst[dstRead] == '\r');
@@ -6178,10 +6219,10 @@ ReadChars(
if (dstWrote > 0) {
/*
- * There are chars we can read before we hit the bare cr.
- * Go back with a smaller dstLimit so we get them in the
- * next pass, compute a matching srcRead, and don't end
- * up back here in this call.
+ * There are chars we can read before we hit the bare CR. Go
+ * back with a smaller dstLimit so we get them in the next
+ * pass, compute a matching srcRead, and don't end up back
+ * here in this call.
*/
dstLimit = dstRead - 1 + TCL_UTF_MAX;
@@ -6195,9 +6236,9 @@ ReadChars(
assert(dstRead == 0);
/*
- * We decoded only the bare cr, and we cannot read a
- * translated char from that alone. We have to know what's
- * next. So why do we only have the one decoded char?
+ * We decoded only the bare CR, and we cannot read a translated
+ * char from that alone. We have to know what's next. So why do
+ * we only have the one decoded char?
*/
if (code != TCL_OK) {
@@ -6238,10 +6279,9 @@ ReadChars(
}
} else if (statePtr->flags & CHANNEL_EOF) {
-
/*
- * The bare \r is the only char and we will never read
- * a subsequent char to make the determination.
+ * The bare \r is the only char and we will never read a
+ * subsequent char to make the determination.
*/
dst[0] = '\r';
@@ -6251,8 +6291,8 @@ ReadChars(
}
/*
- * Revise the dstRead value so that the numChars calc
- * below correctly computes zero characters read.
+ * Revise the dstRead value so that the numChars calc below
+ * correctly computes zero characters read.
*/
dstRead = numChars;
@@ -6261,9 +6301,9 @@ ReadChars(
}
/*
- * The translation transformation can only reduce the number
- * of chars when it converts \r\n into \n. The reduction in
- * the number of chars is the difference in bytes read and written.
+ * The translation transformation can only reduce the number of chars
+ * when it converts \r\n into \n. The reduction in the number of chars
+ * is the difference in bytes read and written.
*/
numChars -= (dstRead - dstWrote);
@@ -6273,10 +6313,9 @@ ReadChars(
/*
* TODO: This cannot happen anymore.
*
- * We read more chars than allowed. Reset limits to
- * prevent that and try again. Don't forget the extra
- * padding of TCL_UTF_MAX bytes demanded by the
- * Tcl_ExternalToUtf() call!
+ * We read more chars than allowed. Reset limits to prevent that
+ * and try again. Don't forget the extra padding of TCL_UTF_MAX
+ * bytes demanded by the Tcl_ExternalToUtf() call!
*/
dstLimit = Tcl_UtfAtIndex(dst, charsToRead) - 1 + TCL_UTF_MAX - dst;
@@ -6289,18 +6328,19 @@ ReadChars(
if (dstWrote == 0) {
ChannelBuffer *nextPtr;
- /* We were not able to read any chars. */
+ /*
+ * We were not able to read any chars.
+ */
- assert (numChars == 0);
+ assert(numChars == 0);
/*
- * There is one situation where this is the correct final
- * result. If the src buffer contains only a single \n
- * byte, and we are in TCL_TRANSLATE_AUTO mode, and
- * when the translation pass was made the INPUT_SAW_CR
- * flag was set on the channel. In that case, the
- * correct behavior is to consume that \n and produce the
- * empty string.
+ * There is one situation where this is the correct final result.
+ * If the src buffer contains only a single \n byte, and we are in
+ * TCL_TRANSLATE_AUTO mode, and when the translation pass was made
+ * the INPUT_SAW_CR flag was set on the channel. In that case, the
+ * correct behavior is to consume that \n and produce the empty
+ * string.
*/
if (dstRead == 1 && dst[0] == '\n') {
@@ -6309,12 +6349,13 @@ ReadChars(
goto consume;
}
- /* Otherwise, reading zero characters indicates there's
- * something incomplete at the end of the src buffer.
- * Maybe there were not enough src bytes to decode into
- * a char. Maybe a lone \r could not be translated (crlf
- * mode). Need to combine any unused src bytes we have
- * in the first buffer with subsequent bytes to try again.
+ /*
+ * Otherwise, reading zero characters indicates there's something
+ * incomplete at the end of the src buffer. Maybe there were not
+ * enough src bytes to decode into a char. Maybe a lone \r could
+ * not be translated (crlf mode). Need to combine any unused src
+ * bytes we have in the first buffer with subsequent bytes to try
+ * again.
*/
nextPtr = bufPtr->nextPtr;
@@ -6329,15 +6370,15 @@ ReadChars(
/*
* Space is made at the beginning of the buffer to copy the
- * previous unused bytes there. Check first if the buffer we
- * are using actually has enough space at its beginning for
- * the data we are copying. Because if not we will write over
- * the buffer management information, especially the 'nextPtr'.
+ * previous unused bytes there. Check first if the buffer we are
+ * using actually has enough space at its beginning for the data
+ * we are copying. Because if not we will write over the buffer
+ * management information, especially the 'nextPtr'.
*
- * Note that the BUFFER_PADDING (See AllocChannelBuffer) is
- * used to prevent exactly this situation. I.e. it should never
- * happen. Therefore it is ok to panic should it happen despite
- * the precautions.
+ * Note that the BUFFER_PADDING (See AllocChannelBuffer) is used
+ * to prevent exactly this situation. I.e. it should never happen.
+ * Therefore it is ok to panic should it happen despite the
+ * precautions.
*/
if (nextPtr->nextRemoved - srcLen < 0) {
@@ -6356,10 +6397,12 @@ ReadChars(
consume:
bufPtr->nextRemoved += srcRead;
+
/*
- * If this read contained multibyte characters, revise factorPtr
- * so the next read will allocate bigger buffers.
+ * If this read contained multibyte characters, revise factorPtr so
+ * the next read will allocate bigger buffers.
*/
+
if (numChars && numChars < srcRead) {
*factorPtr = srcRead * UTF_EXPANSION_FACTOR / numChars;
}
@@ -6407,22 +6450,27 @@ TranslateInputEOL(
int inEofChar = statePtr->inEofChar;
/*
- * Depending on the translation mode in use, there's no need
- * to scan more srcLen bytes at srcStart than can possibly transform
- * to dstLen bytes. This keeps the scan for eof char below from
- * being pointlessly long.
+ * Depending on the translation mode in use, there's no need to scan more
+ * srcLen bytes at srcStart than can possibly transform to dstLen bytes.
+ * This keeps the scan for eof char below from being pointlessly long.
*/
switch (statePtr->inputTranslation) {
case TCL_TRANSLATE_LF:
case TCL_TRANSLATE_CR:
if (srcLen > dstLen) {
- /* In these modes, each src byte become a dst byte. */
+ /*
+ * In these modes, each src byte become a dst byte.
+ */
+
srcLen = dstLen;
}
break;
default:
- /* In other modes, at most 2 src bytes become a dst byte. */
+ /*
+ * In other modes, at most 2 src bytes become a dst byte.
+ */
+
if (srcLen/2 > dstLen) {
srcLen = 2 * dstLen;
}
@@ -6755,7 +6803,7 @@ GetInput(
* eofchar.
*/
- assert( !GotFlag(statePtr, CHANNEL_STICKY_EOF) );
+ assert(!GotFlag(statePtr, CHANNEL_STICKY_EOF));
/*
* Prevent reading from a dead channel -- a channel that has been closed
@@ -6769,24 +6817,21 @@ GetInput(
}
/*
- * WARNING: There was once a comment here claiming that it was
- * a bad idea to make another call to the inputproc of a channel
- * driver when EOF has already been detected on the channel. Through
- * much of Tcl's history, this warning was then completely negated
- * by having all (most?) read paths clear the EOF setting before
- * reaching here. So we had a guard that was never triggered.
+ * WARNING: There was once a comment here claiming that it was a bad idea
+ * to make another call to the inputproc of a channel driver when EOF has
+ * already been detected on the channel. Through much of Tcl's history,
+ * this warning was then completely negated by having all (most?) read
+ * paths clear the EOF setting before reaching here. So we had a guard
+ * that was never triggered.
+ *
+ * Don't be tempted to restore the guard. Even if EOF is set on the
+ * channel, continue through and call the inputproc again. This is the
+ * way to enable the ability to [read] again beyond the EOF, which seems a
+ * strange thing to do, but for which use cases exist [Tcl Bug 5adc350683]
+ * and which may even be essential for channels representing things like
+ * ttys or other devices where the stream might take the logical form of a
+ * series of 'files' separated by an EOF condition.
*
- * Don't be tempted to restore the guard. Even if EOF is set on
- * the channel, continue through and call the inputproc again. This
- * is the way to enable the ability to [read] again beyond the EOF,
- * which seems a strange thing to do, but for which use cases exist
- * [Tcl Bug 5adc350683] and which may even be essential for channels
- * representing things like ttys or other devices where the stream
- * might take the logical form of a series of 'files' separated by
- * an EOF condition.
- */
-
- /*
* First check for more buffers in the pushback area of the topmost
* channel in the stack and use them. They can be the result of a
* transformation which went away without reading all the information
@@ -6794,7 +6839,6 @@ GetInput(
*/
if (chanPtr->inQueueHead != NULL) {
-
/* TODO: Tests to cover this. */
assert(statePtr->inQueueHead == NULL);
@@ -6824,8 +6868,9 @@ GetInput(
/*
* Check the actual buffersize against the requested buffersize.
- * Saved buffers of the wrong size are squashed. This is done
- * to honor dynamic changes of the buffersize made by the user.
+ * Saved buffers of the wrong size are squashed. This is done to honor
+ * dynamic changes of the buffersize made by the user.
+ *
* TODO: Tests to cover this.
*/
@@ -7127,53 +7172,12 @@ Tcl_Tell(
/*
*---------------------------------------------------------------------------
*
- * Tcl_SeekOld, Tcl_TellOld --
- *
- * Backward-compatability versions of the seek/tell interface that do not
- * support 64-bit offsets. This interface is not documented or expected
- * to be supported indefinitely.
- *
- * Results:
- * As for Tcl_Seek and Tcl_Tell respectively, except truncated to
- * whatever value will fit in an 'int'.
- *
- * Side effects:
- * As for Tcl_Seek and Tcl_Tell respectively.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tcl_SeekOld(
- Tcl_Channel chan, /* The channel on which to seek. */
- int offset, /* Offset to seek to. */
- int mode) /* Relative to which location to seek? */
-{
- Tcl_WideInt wOffset, wResult;
-
- wOffset = Tcl_LongAsWide((long) offset);
- wResult = Tcl_Seek(chan, wOffset, mode);
- return (int) Tcl_WideAsLong(wResult);
-}
-
-int
-Tcl_TellOld(
- Tcl_Channel chan) /* The channel to return pos for. */
-{
- Tcl_WideInt wResult = Tcl_Tell(chan);
-
- return (int) Tcl_WideAsLong(wResult);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
* Tcl_TruncateChannel --
*
* Truncate a channel to the given length.
*
* Results:
- * TCL_OK on success, TCL_ERROR if the operation failed (e.g. is not
+ * TCL_OK on success, TCL_ERROR if the operation failed (e.g., is not
* supported by the type of channel, or the underlying OS operation
* failed in some way).
*
@@ -9317,7 +9321,7 @@ MBWrite(
* then the calculations involving extra must be made wide too.
*
* Noted with Win32/MSVC debug build treating the warning (possible of
- * data in int64 to int conversion) as error.
+ * data in __int64 to int conversion) as error.
*/
bufPtr = AllocChannelBuffer(extra);
@@ -9533,7 +9537,10 @@ CopyData(
}
if (size == 0) {
if (!GotFlag(inStatePtr, CHANNEL_NONBLOCKING)) {
- /* We allowed a short read. Keep trying. */
+ /*
+ * We allowed a short read. Keep trying.
+ */
+
continue;
}
if (bufObj != NULL) {
@@ -9747,7 +9754,7 @@ DoRead(
ChannelState *statePtr = chanPtr->state;
char *p = dst;
- assert (bytesToRead >= 0);
+ assert(bytesToRead >= 0);
/*
* Early out when we know a read will get the eofchar.
@@ -9763,15 +9770,18 @@ DoRead(
if (GotFlag(statePtr, CHANNEL_STICKY_EOF)) {
SetFlag(statePtr, CHANNEL_EOF);
- assert( statePtr->inputEncodingFlags & TCL_ENCODING_END );
- assert( !GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR) );
+ assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
+ assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
/* TODO: Don't need this call */
UpdateInterest(chanPtr);
return 0;
}
- /* Special handling for zero-char read request. */
+ /*
+ * Special handling for zero-char read request.
+ */
+
if (bytesToRead == 0) {
if (GotFlag(statePtr, CHANNEL_EOF)) {
statePtr->inputEncodingFlags |= TCL_ENCODING_START;
@@ -9786,8 +9796,8 @@ DoRead(
TclChannelPreserve((Tcl_Channel)chanPtr);
while (bytesToRead) {
/*
- * Each pass through the loop is intended to process up to
- * one channel buffer.
+ * Each pass through the loop is intended to process up to one channel
+ * buffer.
*/
int bytesRead, bytesWritten;
@@ -9799,33 +9809,39 @@ DoRead(
while (!bufPtr || /* We got no buffer! OR */
(!IsBufferFull(bufPtr) && /* Our buffer has room AND */
- (BytesLeft(bufPtr) < bytesToRead) ) ) {
- /* Not enough bytes in it
- * yet to fill the dst */
+ (BytesLeft(bufPtr) < bytesToRead))) {
+ /* Not enough bytes in it yet
+ * to fill the dst */
int code;
moreData:
code = GetInput(chanPtr);
bufPtr = statePtr->inQueueHead;
- assert (bufPtr != NULL);
+ assert(bufPtr != NULL);
if (GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)) {
- /* Further reads cannot do any more */
+ /*
+ * Further reads cannot do any more.
+ */
+
break;
}
if (code) {
- /* Read error */
+ /*
+ * Read error
+ */
+
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return -1;
}
- assert (IsBufferFull(bufPtr));
+ assert(IsBufferFull(bufPtr));
}
- assert (bufPtr != NULL);
+ assert(bufPtr != NULL);
bytesRead = BytesLeft(bufPtr);
bytesWritten = bytesToRead;
@@ -9840,8 +9856,8 @@ DoRead(
/*
* Buffer is not empty. How can that be?
*
- * 0) We stopped early because we got all the bytes
- * we were seeking. That's fine.
+ * 0) We stopped early because we got all the bytes we were
+ * seeking. That's fine.
*/
if (bytesToRead == 0) {
@@ -9857,8 +9873,8 @@ DoRead(
}
/*
- * 2) The buffer holds a \r while in CRLF translation,
- * followed by the end of the buffer.
+ * 2) The buffer holds a \r while in CRLF translation, followed by
+ * the end of the buffer.
*/
assert(statePtr->inputTranslation == TCL_TRANSLATE_CRLF);
@@ -9866,26 +9882,38 @@ DoRead(
assert(BytesLeft(bufPtr) == 1);
if (bufPtr->nextPtr == NULL) {
- /* There's no more buffered data.... */
+ /*
+ * There's no more buffered data...
+ */
if (statePtr->flags & CHANNEL_EOF) {
- /* ...and there never will be. */
+ /*
+ * ...and there never will be.
+ */
*p++ = '\r';
bytesToRead--;
bufPtr->nextRemoved++;
} else if (statePtr->flags & CHANNEL_BLOCKED) {
- /* ...and we cannot get more now. */
+ /*
+ * ...and we cannot get more now.
+ */
+
SetFlag(statePtr, CHANNEL_NEED_MORE_DATA);
break;
} else {
- /* ... so we need to get some. */
+ /*
+ * ...so we need to get some.
+ */
+
goto moreData;
}
}
if (bufPtr->nextPtr) {
- /* There's a next buffer. Shift orphan \r to it. */
+ /*
+ * There's a next buffer. Shift orphan \r to it.
+ */
ChannelBuffer *nextPtr = bufPtr->nextPtr;
@@ -9910,8 +9938,8 @@ DoRead(
}
/*
- * When there's no buffered data to read, and we're at EOF,
- * escape to the caller.
+ * When there's no buffered data to read, and we're at EOF, escape to
+ * the caller.
*/
if (GotFlag(statePtr, CHANNEL_EOF)
@@ -9923,11 +9951,11 @@ DoRead(
ResetFlag(statePtr, CHANNEL_BLOCKED);
}
- assert(!GotFlag(statePtr, CHANNEL_EOF)
- || GotFlag(statePtr, CHANNEL_STICKY_EOF)
- || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
- assert( !(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
- == (CHANNEL_EOF|CHANNEL_BLOCKED)) );
+ assert(!GotFlag(statePtr, CHANNEL_EOF)
+ || GotFlag(statePtr, CHANNEL_STICKY_EOF)
+ || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0);
+ assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)
+ == (CHANNEL_EOF|CHANNEL_BLOCKED)));
UpdateInterest(chanPtr);
TclChannelRelease((Tcl_Channel)chanPtr);
return (int)(p - dst);
@@ -11194,7 +11222,7 @@ FreeChannelIntRep(
ResolvedChanName *resPtr = objPtr->internalRep.twoPtrValue.ptr1;
objPtr->typePtr = NULL;
- if (--resPtr->refCount) {
+ if (resPtr->refCount-- > 1) {
return;
}
Tcl_Release(resPtr->statePtr);
diff --git a/generic/tclIO.h b/generic/tclIO.h
index ffbfa31..07c54fa 100644
--- a/generic/tclIO.h
+++ b/generic/tclIO.h
@@ -214,7 +214,7 @@ typedef struct ChannelState {
* because it happened in the background. The
* value is the chanMg, if any. #219's
* companion to 'unreportedError'. */
- int epoch; /* Used to test validity of stored channelname
+ size_t epoch; /* Used to test validity of stored channelname
* lookup results. */
} ChannelState;
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index de65da5..6e8bd09 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -25,7 +25,7 @@ typedef struct AcceptCallback {
* It must be per-thread because of std channel limitations.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* Set to 1 when the module is initialized. */
Tcl_Obj *stdoutObjPtr; /* Cached stdout channel Tcl_Obj */
} ThreadSpecificData;
@@ -113,7 +113,6 @@ Tcl_PutsObjCmd(
int newline; /* Add a newline at end? */
int result; /* Result of puts operation. */
int mode; /* Mode in which channel is opened. */
- ThreadSpecificData *tsdPtr;
switch (objc) {
case 2: /* [puts $x] */
@@ -160,7 +159,7 @@ Tcl_PutsObjCmd(
}
if (chanObjPtr == NULL) {
- tsdPtr = TCL_TSD_INIT(&dataKey);
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
@@ -1485,13 +1484,17 @@ Tcl_SocketObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const socketOptions[] = {
- "-async", "-myaddr", "-myport", "-server", NULL
+ "-async", "-myaddr", "-myport", "-reuseaddr", "-reuseport", "-server",
+ NULL
};
enum socketOptions {
- SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER
+ SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_REUSEADDR, SKT_REUSEPORT,
+ SKT_SERVER
};
- int optionIndex, a, server = 0, port, myport = 0, async = 0;
- const char *host, *myaddr = NULL;
+ int optionIndex, a, server = 0, myport = 0, async = 0, reusep = -1,
+ reusea = -1;
+ unsigned int flags = 0;
+ const char *host, *port, *myaddr = NULL;
Tcl_Obj *script = NULL;
Tcl_Channel chan;
@@ -1557,6 +1560,28 @@ Tcl_SocketObjCmd(
}
script = objv[a];
break;
+ case SKT_REUSEADDR:
+ a++;
+ if (a >= objc) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "no argument given for -reuseaddr option", -1));
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBooleanFromObj(interp, objv[a], &reusea) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ break;
+ case SKT_REUSEPORT:
+ a++;
+ if (a >= objc) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "no argument given for -reuseport option", -1));
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBooleanFromObj(interp, objv[a], &reusep) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ break;
default:
Tcl_Panic("Tcl_SocketObjCmd: bad option index to SocketOptions");
}
@@ -1580,28 +1605,61 @@ Tcl_SocketObjCmd(
"?-myaddr addr? ?-myport myport? ?-async? host port");
iPtr->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv,
- "-server command ?-myaddr addr? port");
+ "-server command ?-reuseaddr boolean? ?-reuseport boolean? "
+ "?-myaddr addr? port");
return TCL_ERROR;
}
- if (a == objc-1) {
- if (TclSockGetPort(interp, TclGetString(objv[a]), "tcp",
- &port) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
+ if (!server && (reusea != -1 || reusep != -1)) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "options -reuseaddr and -reuseport are only valid for servers",
+ -1));
+ return TCL_ERROR;
+ }
+
+ /*
+ * Set the options to their default value if the user didn't override
+ * their value.
+ */
+
+ if (reusep == -1) {
+ reusep = 0;
+ }
+ if (reusea == -1) {
+ reusea = 1;
+ }
+
+ /*
+ * Build the bitset with the flags values.
+ */
+
+ if (reusea) {
+ flags |= TCL_TCPSERVER_REUSEADDR;
+ }
+ if (reusep) {
+ flags |= TCL_TCPSERVER_REUSEPORT;
+ }
+
+ /*
+ * All the arguments should have been parsed by now, 'a' points to the
+ * last one, the port number.
+ */
+
+ if (a != objc-1) {
goto wrongNumArgs;
}
+ port = TclGetString(objv[a]);
+
if (server) {
- AcceptCallback *acceptCallbackPtr =
- ckalloc(sizeof(AcceptCallback));
+ AcceptCallback *acceptCallbackPtr = ckalloc(sizeof(AcceptCallback));
Tcl_IncrRefCount(script);
acceptCallbackPtr->script = script;
acceptCallbackPtr->interp = interp;
- chan = Tcl_OpenTcpServer(interp, port, host, AcceptCallbackProc,
- acceptCallbackPtr);
+
+ chan = Tcl_OpenTcpServerEx(interp, port, host, flags,
+ AcceptCallbackProc, acceptCallbackPtr);
if (chan == NULL) {
Tcl_DecrRefCount(script);
ckfree(acceptCallbackPtr);
@@ -1625,7 +1683,13 @@ Tcl_SocketObjCmd(
Tcl_CreateCloseHandler(chan, TcpServerCloseProc, acceptCallbackPtr);
} else {
- chan = Tcl_OpenTcpClient(interp, port, host, myaddr, myport, async);
+ int portNum;
+
+ if (TclSockGetPort(interp, port, "tcp", &portNum) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ chan = Tcl_OpenTcpClient(interp, portNum, host, myaddr, myport, async);
if (chan == NULL) {
return TCL_ERROR;
}
diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c
index 7f61def..c1e8c44 100644
--- a/generic/tclIOGT.c
+++ b/generic/tclIOGT.c
@@ -211,7 +211,7 @@ struct TransformChannelData {
* a transformation of incoming data. Also
* serves as buffer of all data not yet
* consumed by the reader. */
- int refCount;
+ size_t refCount;
};
static void
@@ -225,7 +225,7 @@ static void
ReleaseData(
TransformChannelData *dataPtr)
{
- if (--dataPtr->refCount) {
+ if (dataPtr->refCount-- > 1) {
return;
}
ResultClear(&dataPtr->result);
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 1089d2b..aefa104 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -234,7 +234,7 @@ typedef enum {
* sharing problems.
*/
-typedef struct ForwardParamBase {
+typedef struct {
int code; /* O: Ok/Fail of the cmd handler */
char *msgStr; /* O: Error message for handler failure */
int mustFree; /* O: True if msgStr is allocated, false if
@@ -309,7 +309,7 @@ typedef struct ForwardingResult ForwardingResult;
* General event structure, with reference to operation specific data.
*/
-typedef struct ForwardingEvent {
+typedef struct {
Tcl_Event event; /* Basic event data, has to be first item */
ForwardingResult *resultPtr;
ForwardedOperation op; /* Forwarded driver operation */
@@ -346,7 +346,7 @@ struct ForwardingResult {
* results. */
};
-typedef struct ThreadSpecificData {
+typedef struct {
/*
* Table of all reflected channels owned by this thread. This is the
* per-thread version of the per-interpreter map.
@@ -591,7 +591,7 @@ TclChanCreateObjCmd(
if (Tcl_ListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s initialize\" returned non-list: %s",
- Tcl_GetString(cmdObj), Tcl_GetString(resObj)));
+ TclGetString(cmdObj), TclGetString(resObj)));
Tcl_DecrRefCount(resObj);
goto error;
}
@@ -617,35 +617,35 @@ TclChanCreateObjCmd(
if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" does not support all required methods",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
if ((mode & TCL_READABLE) && !HAS(methods, METH_READ)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" lacks a \"read\" method",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
if ((mode & TCL_WRITABLE) && !HAS(methods, METH_WRITE)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" lacks a \"write\" method",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
if (!IMPLIES(HAS(methods, METH_CGET), HAS(methods, METH_CGETALL))) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" supports \"cget\" but not \"cgetall\"",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
if (!IMPLIES(HAS(methods, METH_CGETALL), HAS(methods, METH_CGET))) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" supports \"cgetall\" but not \"cget\"",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
@@ -723,7 +723,7 @@ TclChanCreateObjCmd(
Tcl_DecrRefCount(rcPtr->name);
Tcl_DecrRefCount(rcPtr->methods);
Tcl_DecrRefCount(rcPtr->cmd);
- ckfree((char*) rcPtr);
+ ckfree(rcPtr);
return TCL_ERROR;
#undef MODE
@@ -748,7 +748,7 @@ TclChanCreateObjCmd(
*----------------------------------------------------------------------
*/
-typedef struct ReflectEvent {
+typedef struct {
Tcl_Event header;
ReflectedChannel *rcPtr;
int events;
@@ -851,11 +851,12 @@ TclChanPostEventObjCmd(
}
/*
- * Note that the search above subsumes several of the older checks, namely:
+ * Note that the search above subsumes several of the older checks,
+ * namely:
*
- * (1) Does the channel handle refer to a reflected channel ?
+ * (1) Does the channel handle refer to a reflected channel?
* (2) Is the post event issued from the interpreter holding the handler
- * of the reflected channel ?
+ * of the reflected channel?
*
* A successful search answers yes to both. Because the map holds only
* handles of reflected channels, and only of such whose handler is
@@ -939,7 +940,8 @@ TclChanPostEventObjCmd(
(void) GetThreadReflectedChannelMap();
- /* XXX Race condition !!
+ /*
+ * XXX Race condition !!
* XXX The destination thread may not exist anymore already.
* XXX (Delayed postevent executed after channel got removed).
* XXX Can we detect this ? (check the validity of the owner threadid ?)
@@ -1152,7 +1154,7 @@ ReflectClose(
tctPtr = ((Channel *)rcPtr->chan)->typePtr;
if (tctPtr && tctPtr != &tclRChannelType) {
- ckfree((char *)tctPtr);
+ ckfree(tctPtr);
((Channel *)rcPtr->chan)->typePtr = NULL;
}
Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
@@ -1221,8 +1223,8 @@ ReflectClose(
#endif
tctPtr = ((Channel *)rcPtr->chan)->typePtr;
if (tctPtr && tctPtr != &tclRChannelType) {
- ckfree((char *)tctPtr);
- ((Channel *)rcPtr->chan)->typePtr = NULL;
+ ckfree(tctPtr);
+ ((Channel *)rcPtr->chan)->typePtr = NULL;
}
Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
return (result == TCL_OK) ? EOK : EINVAL;
@@ -1272,7 +1274,10 @@ ReflectInput(
if (p.base.code != TCL_OK) {
if (p.base.code < 0) {
- /* No error message, this is an errno signal. */
+ /*
+ * No error message, this is an errno signal.
+ */
+
*errorCodePtr = -p.base.code;
} else {
PassReceivedError(rcPtr->chan, &p);
@@ -1375,7 +1380,10 @@ ReflectOutput(
if (p.base.code != TCL_OK) {
if (p.base.code < 0) {
- /* No error message, this is an errno signal. */
+ /*
+ * No error message, this is an errno signal.
+ */
+
*errorCodePtr = -p.base.code;
} else {
PassReceivedError(rcPtr->chan, &p);
@@ -1426,8 +1434,8 @@ ReflectOutput(
if ((written == 0) && (toWrite > 0)) {
/*
- * The handler claims to have written nothing of what it was
- * given. That is bad.
+ * The handler claims to have written nothing of what it was given.
+ * That is bad.
*/
SetChannelErrorStr(rcPtr->chan, msg_write_nothing);
@@ -2373,8 +2381,8 @@ InvokeTclMethod(
* None.
*
* Users:
- * ReflectInput/Output(), to enable the signaling of EAGAIN
- * on 0-sized short reads/writes.
+ * ReflectInput/Output(), to enable the signaling of EAGAIN on 0-sized
+ * short reads/writes.
*
*----------------------------------------------------------------------
*/
@@ -2398,7 +2406,7 @@ ErrnoReturn(
if (((Tcl_GetIntFromObj(rcPtr->interp, resObj, &code) != TCL_OK)
|| (code >= 0))) {
- if (strcmp("EAGAIN", Tcl_GetString(resObj)) == 0) {
+ if (strcmp("EAGAIN", TclGetString(resObj)) == 0) {
code = -EAGAIN;
} else {
code = 0;
@@ -2560,7 +2568,10 @@ DeleteReflectedChannelMap(
evPtr = resultPtr->evPtr;
- /* Basic crash safety until this routine can get revised [3411310] */
+ /*
+ * Basic crash safety until this routine can get revised [3411310]
+ */
+
if (evPtr == NULL) {
continue;
}
@@ -2675,8 +2686,8 @@ DeleteThreadReflectedChannelMap(
/*
* Go through the list of pending results and cancel all whose events were
- * destined for this thread. While this is in progress we block any
- * other access to the list of pending results.
+ * destined for this thread. While this is in progress we block any other
+ * access to the list of pending results.
*/
Tcl_MutexLock(&rcForwardMutex);
@@ -2707,7 +2718,10 @@ DeleteThreadReflectedChannelMap(
evPtr = resultPtr->evPtr;
- /* Basic crash safety until this routine can get revised [3411310] */
+ /*
+ * Basic crash safety until this routine can get revised [3411310]
+ */
+
if (evPtr == NULL ) {
continue;
}
@@ -2761,8 +2775,8 @@ ForwardOpToHandlerThread(
const void *param) /* Arguments */
{
/*
- * Core of the communication from OWNER to HANDLER thread.
- * The receiver is ForwardProc() below.
+ * Core of the communication from OWNER to HANDLER thread. The receiver is
+ * ForwardProc() below.
*/
Tcl_ThreadId dst = rcPtr->thread;
@@ -2812,7 +2826,10 @@ ForwardOpToHandlerThread(
*/
TclSpliceIn(resultPtr, forwardList);
- /* Do not unlock here. That is done by the ConditionWait */
+
+ /*
+ * Do not unlock here. That is done by the ConditionWait.
+ */
/*
* Ensure cleanup of the event if the origin thread exits while this event
@@ -2888,7 +2905,7 @@ ForwardProc(
* Notes regarding access to the referenced data.
*
* In principle the data belongs to the originating thread (see
- * evPtr->src), however this thread is currently blocked at (*), i.e.
+ * evPtr->src), however this thread is currently blocked at (*), i.e.,
* quiescent. Because of this we can treat the data as belonging to us,
* without fear of race conditions. I.e. we can read and write as we like.
*
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 47e0bc8..f198c69 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -329,7 +329,7 @@ struct ForwardingResult {
* results. */
};
-typedef struct ThreadSpecificData {
+typedef struct {
/*
* Table of all reflected transformations owned by this thread.
*/
@@ -554,7 +554,7 @@ TclChanPushObjCmd(
*/
chanObj = objv[CHAN];
- parentChan = Tcl_GetChannel(interp, Tcl_GetString(chanObj), &mode);
+ parentChan = Tcl_GetChannel(interp, TclGetString(chanObj), &mode);
if (parentChan == NULL) {
return TCL_ERROR;
}
@@ -608,7 +608,7 @@ TclChanPushObjCmd(
if (Tcl_ListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s initialize\" returned non-list: %s",
- Tcl_GetString(cmdObj), Tcl_GetString(resObj)));
+ TclGetString(cmdObj), TclGetString(resObj)));
Tcl_DecrRefCount(resObj);
goto error;
}
@@ -619,7 +619,7 @@ TclChanPushObjCmd(
"method", TCL_EXACT, &methIndex) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s initialize\" returned %s",
- Tcl_GetString(cmdObj),
+ TclGetString(cmdObj),
Tcl_GetString(Tcl_GetObjResult(interp))));
Tcl_DecrRefCount(resObj);
goto error;
@@ -633,7 +633,7 @@ TclChanPushObjCmd(
if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" does not support all required methods",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
@@ -655,7 +655,7 @@ TclChanPushObjCmd(
if (!mode) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" makes the channel inaccessible",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
@@ -666,14 +666,14 @@ TclChanPushObjCmd(
if (!IMPLIES(HAS(methods, METH_DRAIN), HAS(methods, METH_READ))) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" supports \"drain\" but not \"read\"",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
if (!IMPLIES(HAS(methods, METH_FLUSH), HAS(methods, METH_WRITE))) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"chan handler \"%s\" supports \"flush\" but not \"write\"",
- Tcl_GetString(cmdObj)));
+ TclGetString(cmdObj)));
goto error;
}
@@ -694,14 +694,14 @@ TclChanPushObjCmd(
*/
rtmPtr = GetReflectedTransformMap(interp);
- hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
+ hPtr = Tcl_CreateHashEntry(&rtmPtr->map, TclGetString(rtId), &isNew);
if (!isNew && rtPtr != Tcl_GetHashValue(hPtr)) {
Tcl_Panic("TclChanPushObjCmd: duplicate transformation handle");
}
Tcl_SetHashValue(hPtr, rtPtr);
#ifdef TCL_THREADS
rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
+ hPtr = Tcl_CreateHashEntry(&rtmPtr->map, TclGetString(rtId), &isNew);
Tcl_SetHashValue(hPtr, rtPtr);
#endif /* TCL_THREADS */
@@ -1027,7 +1027,7 @@ ReflectClose(
#ifdef TCL_THREADS
rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
if (hPtr) {
Tcl_DeleteHashEntry(hPtr);
}
@@ -2568,7 +2568,7 @@ ForwardProc(
*/
rtmPtr = GetReflectedTransformMap(interp);
- hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
Tcl_DeleteHashEntry(hPtr);
/*
@@ -2578,7 +2578,7 @@ ForwardProc(
*/
rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
Tcl_DeleteHashEntry(hPtr);
FreeReflectedTransformArgs(rtPtr);
@@ -2955,7 +2955,7 @@ ResultClear(
return;
}
- ckfree((char *) rPtr->buf);
+ ckfree(rPtr->buf);
rPtr->buf = NULL;
rPtr->allocated = 0;
}
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index f61073b..6abfa60 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -12,16 +12,21 @@
#include "tclInt.h"
#if defined(_WIN32) && defined(UNICODE)
-/* On Windows, we need to do proper Unicode->UTF-8 conversion. */
+/*
+ * On Windows, we need to do proper Unicode->UTF-8 conversion.
+ */
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized;
Tcl_DString errorMsg; /* UTF-8 encoded error-message */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
#undef gai_strerror
-static const char *gai_strerror(int code) {
+static const char *
+gai_strerror(
+ int code)
+{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (tsdPtr->initialized) {
@@ -56,8 +61,8 @@ static const char *gai_strerror(int code) {
int
TclSockGetPort(
Tcl_Interp *interp,
- const char *string, /* Integer or service name */
- const char *proto, /* "tcp" or "udp", typically */
+ const char *string, /* Integer or service name */
+ const char *proto, /* "tcp" or "udp", typically */
int *portPtr) /* Return port number */
{
struct servent *sp; /* Protocol info for named services */
@@ -126,7 +131,7 @@ TclSockMinimumBuffers(
}
len = sizeof(int);
getsockopt((SOCKET)(size_t) sock, SOL_SOCKET, SO_RCVBUF,
- (char *) &current, &len);
+ (char *) &current, &len);
if (current < size) {
len = sizeof(int);
setsockopt((SOCKET)(size_t) sock, SOL_SOCKET, SO_RCVBUF,
@@ -154,15 +159,15 @@ TclSockMinimumBuffers(
int
TclCreateSocketAddress(
- Tcl_Interp *interp, /* Interpreter for querying
- * the desired socket family */
- struct addrinfo **addrlist, /* Socket address list */
- const char *host, /* Host. NULL implies INADDR_ANY */
- int port, /* Port number */
- int willBind, /* Is this an address to bind() to or
- * to connect() to? */
- const char **errorMsgPtr) /* Place to store the error message
- * detail, if available. */
+ Tcl_Interp *interp, /* Interpreter for querying the desired socket
+ * family */
+ struct addrinfo **addrlist, /* Socket address list */
+ const char *host, /* Host. NULL implies INADDR_ANY */
+ int port, /* Port number */
+ int willBind, /* Is this an address to bind() to or to
+ * connect() to? */
+ const char **errorMsgPtr) /* Place to store the error message detail, if
+ * available. */
{
struct addrinfo hints;
struct addrinfo *p;
@@ -181,30 +186,31 @@ TclCreateSocketAddress(
* Workaround for OSX's apparent inability to resolve "localhost", "0"
* when the loopback device is the only available network interface.
*/
+
if (host != NULL && port == 0) {
- portstring = NULL;
+ portstring = NULL;
} else {
- TclFormatInt(portbuf, port);
- portstring = portbuf;
+ TclFormatInt(portbuf, port);
+ portstring = portbuf;
}
(void) memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
/*
- * Magic variable to enforce a certain address family - to be superseded
- * by a TIP that adds explicit switches to [socket]
+ * Magic variable to enforce a certain address family; to be superseded
+ * by a TIP that adds explicit switches to [socket].
*/
if (interp != NULL) {
- family = Tcl_GetVar2(interp, "::tcl::unsupported::socketAF", NULL, 0);
- if (family != NULL) {
- if (strcmp(family, "inet") == 0) {
- hints.ai_family = AF_INET;
- } else if (strcmp(family, "inet6") == 0) {
- hints.ai_family = AF_INET6;
- }
- }
+ family = Tcl_GetVar2(interp, "::tcl::unsupported::socketAF", NULL, 0);
+ if (family != NULL) {
+ if (strcmp(family, "inet") == 0) {
+ hints.ai_family = AF_INET;
+ } else if (strcmp(family, "inet6") == 0) {
+ hints.ai_family = AF_INET6;
+ }
+ }
}
hints.ai_socktype = SOCK_STREAM;
@@ -214,7 +220,7 @@ TclCreateSocketAddress(
* We found some problems when using AI_ADDRCONFIG, e.g. on systems that
* have no networking besides the loopback interface and want to resolve
* localhost. See [Bugs 3385024, 3382419, 3382431]. As the advantage of
- * using AI_ADDRCONFIG in situations where it works, is probably low,
+ * using AI_ADDRCONFIG is probably low even in situations where it works,
* we'll leave it out for now. After all, it is just an optimisation.
*
* Missing on: OpenBSD, NetBSD.
@@ -251,6 +257,7 @@ TclCreateSocketAddress(
*
* There might be more elegant/efficient ways to do this.
*/
+
if (willBind) {
for (p = *addrlist; p != NULL; p = p->ai_next) {
if (p->ai_family == AF_INET) {
@@ -283,6 +290,38 @@ TclCreateSocketAddress(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_OpenTcpServer --
+ *
+ * Opens a TCP server socket and creates a channel around it.
+ *
+ * Results:
+ * The channel or NULL if failed. If an error occurred, an error message
+ * is left in the interp's result if interp is not NULL.
+ *
+ * Side effects:
+ * Opens a server socket and creates a new channel.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Channel
+Tcl_OpenTcpServer(
+ Tcl_Interp *interp,
+ int port,
+ const char *host,
+ Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData)
+{
+ char portbuf[TCL_INTEGER_SPACE];
+
+ TclFormatInt(portbuf, port);
+ return Tcl_OpenTcpServerEx(interp, portbuf, host, TCL_TCPSERVER_REUSEADDR,
+ acceptProc, callbackData);
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index 397c3b1..ea407ab 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -57,7 +57,7 @@ typedef struct FilesystemRecord {
* this information each time the corresponding epoch counter changes.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized;
size_t cwdPathEpoch;
size_t filesystemEpoch;
@@ -611,6 +611,7 @@ FsRecacheFilesystemList(void)
while (toFree) {
FilesystemRecord *next = toFree->nextPtr;
+
toFree->fsPtr = NULL;
ckfree(toFree);
toFree = next;
@@ -638,8 +639,8 @@ FsGetFirstFilesystem(void)
}
/*
- * The epoch can be changed both by filesystems being added or removed and by
- * env(HOME) changing.
+ * The epoch can be changed by filesystems being added or removed, by changing
+ * the "system encoding" and by env(HOME) changing.
*/
int
@@ -672,7 +673,6 @@ TclFSEpoch(void)
return tsdPtr->filesystemEpoch;
}
-
/*
* If non-NULL, clientData is owned by us and must be freed later.
@@ -784,7 +784,9 @@ TclFinalizeFilesystem(void)
while (fsRecPtr != NULL) {
FilesystemRecord *tmpFsRecPtr = fsRecPtr->nextPtr;
- /* The native filesystem is static, so we don't free it. */
+ /*
+ * The native filesystem is static, so we don't free it.
+ */
if (fsRecPtr != &nativeFilesystemRecord) {
ckfree(fsRecPtr);
@@ -947,7 +949,7 @@ Tcl_FSRegister(
int
Tcl_FSUnregister(
- const Tcl_Filesystem *fsPtr) /* The filesystem record to remove. */
+ const Tcl_Filesystem *fsPtr)/* The filesystem record to remove. */
{
int retVal = TCL_ERROR;
FilesystemRecord *fsRecPtr;
@@ -1233,7 +1235,7 @@ FsAddMountsToGlobResult(
len--;
}
- len++; /* account for '/' in the mElt [Bug 1602539] */
+ len++; /* account for '/' in the mElt [Bug 1602539] */
mElt = TclNewFSPathObj(pathPtr, mount + len, mlen - len);
Tcl_ListObjAppendElement(NULL, resultPtr, mElt);
}
@@ -1403,7 +1405,7 @@ TclFSNormalizeToUniquePath(
* Call each of the "normalise path" functions in succession. This is a
* special case, in which if we have a native filesystem handler, we call
* it first. This is because the root of Tcl's filesystem is always a
- * native filesystem (i.e. '/' on unix is native).
+ * native filesystem (i.e., '/' on unix is native).
*/
firstFsRecPtr = FsGetFirstFilesystem();
@@ -1525,7 +1527,7 @@ TclGetOpenModeEx(
#define RW_MODES (O_RDONLY|O_WRONLY|O_RDWR)
/*
- * Check for the simpler fopen-like access modes (e.g. "r"). They are
+ * Check for the simpler fopen-like access modes (e.g., "r"). They are
* distinguished from the POSIX access modes by the presence of a
* lower-case first letter.
*/
@@ -1890,6 +1892,7 @@ TclNREvalFile(
Tcl_GetString(pathPtr), Tcl_PosixError(interp)));
return TCL_ERROR;
}
+ TclPkgFileSeen(interp, Tcl_GetString(pathPtr));
/*
* The eofchar is \32 (^Z). This is the usual on Windows, but we effect
@@ -2670,6 +2673,7 @@ Tcl_FSGetCwd(
fsRecPtr = fsRecPtr->nextPtr) {
ClientData retCd;
TclFSGetCwdProc2 *proc2;
+
if (fsRecPtr->fsPtr->getCwdProc == NULL) {
continue;
}
@@ -3142,8 +3146,8 @@ Tcl_FSLoadFile(
* Workaround for issue with modern HPUX which do allow the unlink (no ETXTBSY
* error) yet somehow trash some internal data structures which prevents the
* second and further shared libraries from getting properly loaded. Only the
- * first is ok. We try to get around the issue by not unlinking,
- * i.e. emulating the behaviour of the older HPUX which denied removal.
+ * first is ok. We try to get around the issue by not unlinking, i.e.,
+ * emulating the behaviour of the older HPUX which denied removal.
*
* Doing the unlink is also an issue within docker containers, whose AUFS
* bungles this as well, see
@@ -3161,28 +3165,30 @@ Tcl_FSLoadFile(
*/
int
-TclSkipUnlink (Tcl_Obj* shlibFile)
+TclSkipUnlink(
+ Tcl_Obj *shlibFile)
{
- /* Order of testing:
+ /*
+ * Order of testing:
* 1. On hpux we generally want to skip unlink in general
*
* Outside of hpux then:
- * 2. For a general user request (TCL_TEMPLOAD_NO_UNLINK present, non-empty, => int)
+ * 2. For a general user request (TCL_TEMPLOAD_NO_UNLINK present,
+ * non-empty, => int)
* 3. For general AUFS environment (statfs, if available).
*
* Ad 2: This variable can disable/override the AUFS detection, i.e. for
- * testing if a newer AUFS does not have the bug any more.
+ * testing if a newer AUFS does not have the bug any more.
*
- * Ad 3: This is conditionally compiled in. Condition currently must be set manually.
- * This part needs proper tests in the configure(.in).
+ * Ad 3: This is conditionally compiled in. Condition currently must be
+ * set manually. This part needs proper tests in the configure(.in).
*/
#ifdef hpux
return 1;
#else
- char* skipstr;
+ char *skipstr = getenv("TCL_TEMPLOAD_NO_UNLINK");
- skipstr = getenv ("TCL_TEMPLOAD_NO_UNLINK");
if (skipstr && (skipstr[0] != '\0')) {
return atoi(skipstr);
}
@@ -3191,7 +3197,8 @@ TclSkipUnlink (Tcl_Obj* shlibFile)
#ifndef NO_FSTATFS
{
struct statfs fs;
- /* Have fstatfs. May not have the AUFS super magic ... Indeed our build
+ /*
+ * Have fstatfs. May not have the AUFS super magic ... Indeed our build
* box is too old to have it directly in the headers. Define taken from
* http://mooon.googlecode.com/svn/trunk/linux_include/linux/aufs_type.h
* http://aufs.sourceforge.net/
@@ -3208,8 +3215,10 @@ TclSkipUnlink (Tcl_Obj* shlibFile)
#endif /* ... NO_FSTATFS */
#endif /* ... TCL_TEMPLOAD_NO_UNLINK */
- /* Fallback: !hpux, no EV override, no AUFS (detection, nor detected):
- * Don't skip */
+ /*
+ * Fallback: !hpux, no EV override, no AUFS (detection, nor detected):
+ * Don't skip
+ */
return 0;
#endif /* hpux */
}
@@ -3414,9 +3423,8 @@ Tcl_LoadFile(
* avoids any worries about leaving the copy laying around on exit.
*/
- if (
- !TclSkipUnlink (copyToPtr) &&
- (Tcl_FSDeleteFile(copyToPtr) == TCL_OK)) {
+ if (!TclSkipUnlink(copyToPtr) &&
+ (Tcl_FSDeleteFile(copyToPtr) == TCL_OK)) {
Tcl_DecrRefCount(copyToPtr);
/*
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index 6a3e4e3..9f38638 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -101,6 +101,7 @@ typedef struct {
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_GetIndexFromObj
int
Tcl_GetIndexFromObj(
@@ -137,6 +138,7 @@ Tcl_GetIndexFromObj(
return Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, sizeof(char *),
msg, flags, indexPtr);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index c00dff1..8314925 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -1246,7 +1246,7 @@ declare 19 macosx {
}
declare 29 {win unix} {
- int TclWinCPUID(unsigned int index, unsigned int *regs)
+ int TclWinCPUID(int index, int *regs)
}
# Added in 8.6; core of TclpOpenTemporaryFile
declare 30 {win unix} {
diff --git a/generic/tclInt.h b/generic/tclInt.h
index bb67ba0..f43de31 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -265,7 +265,7 @@ typedef struct Namespace {
* strings; values have type (Namespace *). If
* NULL, there are no children. */
#endif
- long nsId; /* Unique id for the namespace. */
+ size_t nsId; /* Unique id for the namespace. */
Tcl_Interp *interp; /* The interpreter containing this
* namespace. */
int flags; /* OR-ed combination of the namespace status
@@ -299,12 +299,12 @@ typedef struct Namespace {
* registered using "namespace export". */
int maxExportPatterns; /* Mumber of export patterns for which space
* is currently allocated. */
- int cmdRefEpoch; /* Incremented if a newly added command
+ size_t cmdRefEpoch; /* Incremented if a newly added command
* shadows a command for which this namespace
* has already cached a Command* pointer; this
* causes all its cached Command* pointers to
* be invalidated. */
- int resolverEpoch; /* Incremented whenever (a) the name
+ size_t resolverEpoch; /* Incremented whenever (a) the name
* resolution rules change for this namespace
* or (b) a newly added command shadows a
* command that is compiled to bytecodes. This
@@ -331,7 +331,7 @@ typedef struct Namespace {
* LookupCompiledLocal to resolve variable
* references within the namespace at compile
* time. */
- int exportLookupEpoch; /* Incremented whenever a command is added to
+ size_t exportLookupEpoch; /* Incremented whenever a command is added to
* a namespace, removed from a namespace or
* the exports of a namespace are changed.
* Allows TIP#112-driven command lists to be
@@ -432,7 +432,7 @@ typedef struct EnsembleConfig {
* if the command has been deleted (or never
* existed; the global namespace never has an
* ensemble command.) */
- int epoch; /* The epoch at which this ensemble's table of
+ size_t epoch; /* The epoch at which this ensemble's table of
* exported commands is valid. */
char **subcommandArrayPtr; /* Array of ensemble subcommand names. At all
* consistent points, this will have the same
@@ -1357,7 +1357,7 @@ MODULE_SCOPE void TclThreadDataKeySet(Tcl_ThreadDataKey *keyPtr,
*/
#define TCL_TSD_INIT(keyPtr) \
- (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
+ Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
/*
*----------------------------------------------------------------
@@ -1639,7 +1639,7 @@ typedef struct Command {
* representing a command's name in a ByteCode
* instruction sequence. This structure can be
* freed when refCount becomes zero. */
- int cmdEpoch; /* Incremented to invalidate any references
+ size_t cmdEpoch; /* Incremented to invalidate any references
* that point to this command when it is
* renamed, deleted, hidden, or exposed. */
CompileProc *compileProc; /* Procedure called to compile command. NULL
@@ -1862,6 +1862,7 @@ typedef struct Interp {
* See Tcl_AppendResult code for details.
*/
+#ifndef TCL_NO_DEPRECATED
char *appendResult; /* Storage space for results generated by
* Tcl_AppendResult. Ckalloc-ed. NULL means
* not yet allocated. */
@@ -1869,6 +1870,11 @@ typedef struct Interp {
* partialResult. */
int appendUsed; /* Number of non-null bytes currently stored
* at partialResult. */
+#else
+ char *appendResultDontUse;
+ int appendAvlDontUse;
+ int appendUsedDontUse;
+#endif
/*
* Information about packages. Used only in tclPkg.c.
@@ -1898,7 +1904,7 @@ typedef struct Interp {
* compiled by the interpreter. Indexed by the
* string representations of literals. Used to
* avoid creating duplicate objects. */
- int compileEpoch; /* Holds the current "compilation epoch" for
+ unsigned int compileEpoch; /* Holds the current "compilation epoch" for
* this interpreter. This is incremented to
* invalidate existing ByteCodes when, e.g., a
* command with a compile procedure is
@@ -1930,8 +1936,12 @@ typedef struct Interp {
* string. Returned by Tcl_ObjSetVar2 when
* variable traces change a variable in a
* gross way. */
+#ifndef TCL_NO_DEPRECATED
char resultSpace[TCL_RESULT_SIZE+1];
/* Static space holding small results. */
+#else
+ char resultSpaceDontUse[TCL_RESULT_SIZE+1];
+#endif
Tcl_Obj *objResultPtr; /* If the last command returned an object
* result, this points to it. Should not be
* accessed directly; see comment above. */
@@ -2608,7 +2618,7 @@ typedef Tcl_ObjCmdProc *TclObjCmdProcType;
*----------------------------------------------------------------
*/
-typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, int *lengthPtr,
+typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, size_t *lengthPtr,
Tcl_Encoding *encodingPtr);
/*
@@ -2620,9 +2630,9 @@ typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, int *lengthPtr,
*/
typedef struct ProcessGlobalValue {
- int epoch; /* Epoch counter to detect changes in the
+ size_t epoch; /* Epoch counter to detect changes in the
* master value. */
- int numBytes; /* Length of the master string. */
+ size_t numBytes; /* Length of the master string. */
char *value; /* The master string value. */
Tcl_Encoding encoding; /* system encoding when master string was
* initialized. */
@@ -2745,7 +2755,6 @@ MODULE_SCOPE long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
* shared by all new objects allocated by Tcl_NewObj.
*/
-MODULE_SCOPE char * tclEmptyStringRep;
MODULE_SCOPE char tclEmptyString;
/*
@@ -2945,6 +2954,7 @@ MODULE_SCOPE void TclFinalizeNotifier(void);
MODULE_SCOPE void TclFinalizeObjects(void);
MODULE_SCOPE void TclFinalizePreserve(void);
MODULE_SCOPE void TclFinalizeSynchronization(void);
+MODULE_SCOPE void TclInitThreadAlloc(void);
MODULE_SCOPE void TclFinalizeThreadAlloc(void);
MODULE_SCOPE void TclFinalizeThreadAllocThread(void);
MODULE_SCOPE void TclFinalizeThreadData(int quick);
@@ -2974,6 +2984,9 @@ MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc,
Tcl_Obj *const objv[]);
MODULE_SCOPE char * TclGetStringStorage(Tcl_Obj *objPtr,
unsigned int *sizePtr);
+MODULE_SCOPE int TclGetLoadedPackagesEx(Tcl_Interp *interp,
+ const char *targetName,
+ const char *packageName);
MODULE_SCOPE int TclGlob(Tcl_Interp *interp, char *pattern,
Tcl_Obj *unquotedPrefix, int globFlags,
Tcl_GlobTypeData *types);
@@ -3072,7 +3085,7 @@ MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr,
int stackSize, int flags);
MODULE_SCOPE int TclpFindVariable(const char *name, int *lengthPtr);
MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr,
- int *lengthPtr, Tcl_Encoding *encodingPtr);
+ size_t *lengthPtr, Tcl_Encoding *encodingPtr);
MODULE_SCOPE void TclpInitLock(void);
MODULE_SCOPE void TclpInitPlatform(void);
MODULE_SCOPE void TclpInitUnlock(void);
@@ -3100,6 +3113,8 @@ MODULE_SCOPE int TclpObjChdir(Tcl_Obj *pathPtr);
MODULE_SCOPE Tcl_Channel TclpOpenTemporaryFile(Tcl_Obj *dirObj,
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
Tcl_Obj *resultingNameObj);
+MODULE_SCOPE void TclPkgFileSeen(Tcl_Interp *interp, const char *fileName);
+MODULE_SCOPE void *TclInitPkgFiles(Tcl_Interp *interp);
MODULE_SCOPE Tcl_Obj * TclPathPart(Tcl_Interp *interp, Tcl_Obj *pathPtr,
Tcl_PathPart portion);
MODULE_SCOPE char * TclpReadlink(const char *fileName,
@@ -3109,7 +3124,7 @@ MODULE_SCOPE void TclpSetVariables(Tcl_Interp *interp);
MODULE_SCOPE void * TclThreadStorageKeyGet(Tcl_ThreadDataKey *keyPtr);
MODULE_SCOPE void TclThreadStorageKeySet(Tcl_ThreadDataKey *keyPtr,
void *data);
-MODULE_SCOPE void TclpThreadExit(int status);
+MODULE_SCOPE TCL_NORETURN void TclpThreadExit(int status);
MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex);
MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id);
MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex);
@@ -3135,11 +3150,20 @@ MODULE_SCOPE void TclSpellFix(Tcl_Interp *interp,
Tcl_Obj *bad, Tcl_Obj *fix);
MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr,
int numBytes);
+MODULE_SCOPE int TclStringCatObjv(Tcl_Interp *interp, int inPlace,
+ int objc, Tcl_Obj *const objv[],
+ Tcl_Obj **objPtrPtr);
+MODULE_SCOPE int TclStringFind(Tcl_Obj *needle, Tcl_Obj *haystack,
+ int start);
+MODULE_SCOPE int TclStringLast(Tcl_Obj *needle, Tcl_Obj *haystack,
+ int last);
MODULE_SCOPE int TclStringMatch(const char *str, int strLen,
const char *pattern, int ptnLen, int flags);
MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj,
Tcl_Obj *patternObj, int flags);
MODULE_SCOPE Tcl_Obj * TclStringObjReverse(Tcl_Obj *objPtr);
+MODULE_SCOPE int TclStringRepeat(Tcl_Interp *interp, Tcl_Obj *objPtr,
+ int count, Tcl_Obj **objPtrPtr);
MODULE_SCOPE void TclSubstCompile(Tcl_Interp *interp, const char *bytes,
int numBytes, int flags, int line,
struct CompileEnv *envPtr);
@@ -3205,9 +3229,11 @@ MODULE_SCOPE Tcl_Command TclInitBinaryCmd(Tcl_Interp *interp);
MODULE_SCOPE int Tcl_BreakObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+#ifndef TCL_NO_DEPRECATED
MODULE_SCOPE int Tcl_CaseObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+#endif
MODULE_SCOPE int Tcl_CatchObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -3262,10 +3288,8 @@ MODULE_SCOPE int Tcl_AssembleObjCmd(ClientData clientData,
MODULE_SCOPE int TclNRAssembleObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-
-MODULE_SCOPE int Tcl_EncodingObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_Command TclInitEncodingCmd(Tcl_Interp *interp);
+MODULE_SCOPE int TclMakeEncodingCommandSafe(Tcl_Interp *interp);
MODULE_SCOPE int Tcl_EofObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -3503,6 +3527,12 @@ MODULE_SCOPE int TclCompileBreakCmd(Tcl_Interp *interp,
MODULE_SCOPE int TclCompileCatchCmd(Tcl_Interp *interp,
Tcl_Parse *parsePtr, Command *cmdPtr,
struct CompileEnv *envPtr);
+MODULE_SCOPE int TclCompileClockClicksCmd(Tcl_Interp *interp,
+ Tcl_Parse *parsePtr, Command *cmdPtr,
+ struct CompileEnv *envPtr);
+MODULE_SCOPE int TclCompileClockReadingCmd(Tcl_Interp *interp,
+ Tcl_Parse *parsePtr, Command *cmdPtr,
+ struct CompileEnv *envPtr);
MODULE_SCOPE int TclCompileConcatCmd(Tcl_Interp *interp,
Tcl_Parse *parsePtr, Command *cmdPtr,
struct CompileEnv *envPtr);
@@ -4050,7 +4080,7 @@ typedef const char *TclDTraceStr;
TclIncrObjsAllocated(); \
TclAllocObjStorage(objPtr); \
(objPtr)->refCount = 0; \
- (objPtr)->bytes = tclEmptyStringRep; \
+ (objPtr)->bytes = &tclEmptyString; \
(objPtr)->length = 0; \
(objPtr)->typePtr = NULL; \
TCL_DTRACE_OBJ_CREATE(objPtr)
@@ -4067,8 +4097,8 @@ typedef const char *TclDTraceStr;
if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \
TCL_DTRACE_OBJ_FREE(objPtr); \
if ((objPtr)->bytes \
- && ((objPtr)->bytes != tclEmptyStringRep)) { \
- ckfree((char *) (objPtr)->bytes); \
+ && ((objPtr)->bytes != &tclEmptyString)) { \
+ ckfree((objPtr)->bytes); \
} \
(objPtr)->length = -1; \
TclFreeObjStorage(objPtr); \
@@ -4091,7 +4121,7 @@ typedef const char *TclDTraceStr;
(objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj))
# define TclFreeObjStorageEx(interp, objPtr) \
- ckfree((char *) (objPtr))
+ ckfree(objPtr)
#undef USE_THREAD_ALLOC
#undef USE_TCLALLOC
@@ -4228,7 +4258,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
#define TclInitStringRep(objPtr, bytePtr, len) \
if ((len) == 0) { \
- (objPtr)->bytes = tclEmptyStringRep; \
+ (objPtr)->bytes = &tclEmptyString; \
(objPtr)->length = 0; \
} else { \
(objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
@@ -4250,7 +4280,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*/
#define TclGetString(objPtr) \
- ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
+ ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString(objPtr))
#define TclGetStringFromObj(objPtr, lenPtr) \
((objPtr)->bytes \
@@ -4285,11 +4315,11 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*/
#define TclInvalidateStringRep(objPtr) \
- if (objPtr->bytes != NULL) { \
- if (objPtr->bytes != tclEmptyStringRep) { \
- ckfree((char *) objPtr->bytes); \
+ if ((objPtr)->bytes != NULL) { \
+ if ((objPtr)->bytes != &tclEmptyString) { \
+ ckfree((objPtr)->bytes); \
} \
- objPtr->bytes = NULL; \
+ (objPtr)->bytes = NULL; \
}
/*
@@ -4419,8 +4449,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*----------------------------------------------------------------
*/
-#define TclIsPureByteArray(objPtr) \
- (((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL))
+MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
/*
*----------------------------------------------------------------
@@ -4502,9 +4531,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
* core. They should only be called on unshared objects. The ANSI C
* "prototypes" for these macros are:
*
- * MODULE_SCOPE void TclSetIntObj(Tcl_Obj *objPtr, int intValue);
* MODULE_SCOPE void TclSetLongObj(Tcl_Obj *objPtr, long longValue);
- * MODULE_SCOPE void TclSetBooleanObj(Tcl_Obj *objPtr, long boolValue);
* MODULE_SCOPE void TclSetWideIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclSetDoubleObj(Tcl_Obj *objPtr, double d);
*----------------------------------------------------------------
@@ -4518,19 +4545,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
(objPtr)->typePtr = &tclIntType; \
} while (0)
-#define TclSetIntObj(objPtr, l) \
- TclSetLongObj(objPtr, l)
-
-/*
- * NOTE: There is to be no such thing as a "pure" boolean. Boolean values set
- * programmatically go straight to being "int" Tcl_Obj's, with value 0 or 1.
- * The only "boolean" Tcl_Obj's shall be those holding the cached boolean
- * value of strings like: "yes", "no", "true", "false", "on", "off".
- */
-
-#define TclSetBooleanObj(objPtr, b) \
- TclSetLongObj(objPtr, (b)!=0);
-
#ifndef TCL_WIDE_INT_IS_LONG
#define TclSetWideIntObj(objPtr, w) \
do { \
@@ -4555,13 +4569,11 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
* types, avoiding the corresponding function calls in time critical parts of
* the core. The ANSI C "prototypes" for these macros are:
*
- * MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, int i);
* MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l);
- * MODULE_SCOPE void TclNewBooleanObj(Tcl_Obj *objPtr, int b);
* MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
- * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, char *s, int len);
- * MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, char*sLiteral);
+ * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, int len);
+ * MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, const char *sLiteral);
*
*----------------------------------------------------------------
*/
@@ -4578,16 +4590,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
-#define TclNewIntObj(objPtr, l) \
- TclNewLongObj(objPtr, l)
-
-/*
- * NOTE: There is to be no such thing as a "pure" boolean.
- * See comment above TclSetBooleanObj macro above.
- */
-#define TclNewBooleanObj(objPtr, b) \
- TclNewLongObj((objPtr), (b)!=0)
-
#define TclNewDoubleObj(objPtr, d) \
do { \
TclIncrObjsAllocated(); \
@@ -4610,15 +4612,9 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
} while (0)
#else /* TCL_MEM_DEBUG */
-#define TclNewIntObj(objPtr, i) \
- (objPtr) = Tcl_NewIntObj(i)
-
#define TclNewLongObj(objPtr, l) \
(objPtr) = Tcl_NewLongObj(l)
-#define TclNewBooleanObj(objPtr, b) \
- (objPtr) = Tcl_NewBooleanObj(b)
-
#define TclNewDoubleObj(objPtr, d) \
(objPtr) = Tcl_NewDoubleObj(d)
@@ -4700,7 +4696,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
#define TclCleanupCommandMacro(cmdPtr) \
if ((cmdPtr)->refCount-- <= 1) { \
- ckfree((char *) (cmdPtr));\
+ ckfree(cmdPtr);\
}
/*
@@ -4858,7 +4854,7 @@ typedef struct NRE_callback {
#else
#define TCLNR_ALLOC(interp, ptr) \
(ptr = ((ClientData) ckalloc(sizeof(NRE_callback))))
-#define TCLNR_FREE(interp, ptr) ckfree((char *) (ptr))
+#define TCLNR_FREE(interp, ptr) ckfree(ptr)
#endif
#if NRE_ENABLE_ASSERTS
diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h
index ac06787..494d6f1 100644
--- a/generic/tclIntPlatDecls.h
+++ b/generic/tclIntPlatDecls.h
@@ -98,7 +98,7 @@ EXTERN int TclUnixCopyFile(const char *src, const char *dst,
/* Slot 27 is reserved */
/* Slot 28 is reserved */
/* 29 */
-EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
+EXTERN int TclWinCPUID(int index, int *regs);
/* 30 */
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
@@ -173,7 +173,7 @@ EXTERN void TclWinFlushDirtyChannels(void);
/* 28 */
EXTERN void TclWinResetInterfaces(void);
/* 29 */
-EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
+EXTERN int TclWinCPUID(int index, int *regs);
/* 30 */
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
@@ -247,7 +247,7 @@ EXTERN void TclMacOSXNotifierAddRunLoopMode(
/* Slot 27 is reserved */
/* Slot 28 is reserved */
/* 29 */
-EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
+EXTERN int TclWinCPUID(int index, int *regs);
/* 30 */
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
@@ -288,7 +288,7 @@ typedef struct TclIntPlatStubs {
void (*reserved26)(void);
void (*reserved27)(void);
void (*reserved28)(void);
- int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
+ int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* UNIX */
#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */
@@ -321,7 +321,7 @@ typedef struct TclIntPlatStubs {
void (*tclWinSetInterfaces) (int wide); /* 26 */
void (*tclWinFlushDirtyChannels) (void); /* 27 */
void (*tclWinResetInterfaces) (void); /* 28 */
- int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
+ int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* WIN */
#ifdef MAC_OSX_TCL /* MACOSX */
@@ -354,7 +354,7 @@ typedef struct TclIntPlatStubs {
void (*reserved26)(void);
void (*reserved27)(void);
void (*reserved28)(void);
- int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
+ int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* MACOSX */
} TclIntPlatStubs;
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 6c7ab64..1bf3cf9 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -331,13 +331,24 @@ TclSetPreInitScript(
*----------------------------------------------------------------------
*/
+typedef struct PkgName {
+ struct PkgName *nextPtr; /* Next in list of package names being initialized. */
+ char name[4];
+} PkgName;
+
int
Tcl_Init(
Tcl_Interp *interp) /* Interpreter to initialize. */
{
+ PkgName pkgName = {NULL, "Tcl"};
+ PkgName **names = TclInitPkgFiles(interp);
+ int result = TCL_ERROR;
+
+ pkgName.nextPtr = *names;
+ *names = &pkgName;
if (tclPreInitScript != NULL) {
if (Tcl_EvalEx(interp, tclPreInitScript, -1, 0) == TCL_ERROR) {
- return TCL_ERROR;
+ goto end;
}
}
@@ -382,7 +393,7 @@ Tcl_Init(
* alternate tclInit command before calling Tcl_Init().
*/
- return Tcl_EvalEx(interp,
+ result = Tcl_EvalEx(interp,
"if {[namespace which -command tclInit] eq \"\"} {\n"
" proc tclInit {} {\n"
" global tcl_libPath tcl_library env tclDefaultLibrary\n"
@@ -410,6 +421,7 @@ Tcl_Init(
" {file join $grandParentDir lib tcl[info tclversion]} \\\n"
" {file join $parentDir library} \\\n"
" {file join $grandParentDir library} \\\n"
+" {file join $grandParentDir tcl[info tclversion] library} \\\n"
" {file join $grandParentDir tcl[info patchlevel] library} \\\n"
" {\n"
"file join [file dirname $grandParentDir] tcl[info patchlevel] library}\n"
@@ -445,6 +457,10 @@ Tcl_Init(
" }\n"
"}\n"
"tclInit", -1, 0);
+
+end:
+ *names = (*names)->nextPtr;
+ return result;
}
/*
@@ -660,14 +676,9 @@ NRInterpCmd(
if (masterInterp == NULL) {
return TCL_ERROR;
}
- if (TclGetString(objv[5])[0] == '\0') {
- if (objc == 6) {
- return AliasDelete(interp, slaveInterp, objv[3]);
- }
- } else {
- return AliasCreate(interp, slaveInterp, masterInterp, objv[3],
- objv[5], objc - 6, objv + 6);
- }
+
+ return AliasCreate(interp, slaveInterp, masterInterp, objv[3],
+ objv[5], objc - 6, objv + 6);
}
goto aliasArgs;
}
@@ -3522,9 +3533,6 @@ Tcl_LimitAddHandler(
if (deleteProc == (Tcl_LimitHandlerDeleteProc *) TCL_DYNAMIC) {
deleteProc = (Tcl_LimitHandlerDeleteProc *) Tcl_Free;
}
- if (deleteProc == (Tcl_LimitHandlerDeleteProc *) TCL_STATIC) {
- deleteProc = NULL;
- }
/*
* Allocate a handler record.
diff --git a/generic/tclLink.c b/generic/tclLink.c
index e6dc657..a39dfcd 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -36,8 +36,10 @@ typedef struct Link {
unsigned int ui;
short s;
unsigned short us;
+#if !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__CYGWIN__)
long l;
unsigned long ul;
+#endif
Tcl_WideInt w;
Tcl_WideUInt uw;
float f;
@@ -67,6 +69,9 @@ typedef struct Link {
static char * LinkTraceProc(ClientData clientData,Tcl_Interp *interp,
const char *name1, const char *name2, int flags);
static Tcl_Obj * ObjValue(Link *linkPtr);
+static int GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr);
+static int GetInvalidWideFromObj(Tcl_Obj *objPtr, Tcl_WideInt *widePtr);
+static int GetInvalidDoubleFromObj(Tcl_Obj *objPtr, double *doublePtr);
/*
* Convenience macro for accessing the value of the C variable pointed to by a
@@ -126,6 +131,14 @@ Tcl_LinkVar(
Tcl_IncrRefCount(linkPtr->varName);
linkPtr->addr = addr;
linkPtr->type = type & ~TCL_LINK_READ_ONLY;
+#if !defined(TCL_NO_DEPRECATED) && (defined(TCL_WIDE_INT_IS_LONG) \
+ || defined(_WIN32) || defined(__CYGWIN__))
+ if (linkPtr->type == 11 /* legacy TCL_LINK_LONG */) {
+ linkPtr->type = TCL_LINK_LONG;
+ } else if (linkPtr->type == 12 /* legacy TCL_LINK_ULONG */) {
+ linkPtr->type = TCL_LINK_ULONG;
+ }
+#endif
if (type & TCL_LINK_READ_ONLY) {
linkPtr->flags = LINK_READ_ONLY;
} else {
@@ -259,7 +272,8 @@ LinkTraceProc(
int flags) /* Miscellaneous additional information. */
{
Link *linkPtr = clientData;
- int changed, valueLength;
+ int changed;
+ size_t valueLength;
const char *value;
char **pp;
Tcl_Obj *valueObj;
@@ -331,12 +345,14 @@ LinkTraceProc(
case TCL_LINK_UINT:
changed = (LinkedVar(unsigned int) != linkPtr->lastValue.ui);
break;
+#if !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__CYGWIN__)
case TCL_LINK_LONG:
changed = (LinkedVar(long) != linkPtr->lastValue.l);
break;
case TCL_LINK_ULONG:
changed = (LinkedVar(unsigned long) != linkPtr->lastValue.ul);
break;
+#endif
case TCL_LINK_FLOAT:
changed = (LinkedVar(float) != linkPtr->lastValue.f);
break;
@@ -378,8 +394,8 @@ LinkTraceProc(
switch (linkPtr->type) {
case TCL_LINK_INT:
- if (Tcl_GetIntFromObj(NULL, valueObj, &linkPtr->lastValue.i)
- != TCL_OK) {
+ if (Tcl_GetIntFromObj(NULL, valueObj, &linkPtr->lastValue.i) != TCL_OK
+ && GetInvalidIntFromObj(valueObj, &linkPtr->lastValue.i) != TCL_OK) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have integer value";
@@ -388,8 +404,8 @@ LinkTraceProc(
break;
case TCL_LINK_WIDE_INT:
- if (Tcl_GetWideIntFromObj(NULL, valueObj, &linkPtr->lastValue.w)
- != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(NULL, valueObj, &linkPtr->lastValue.w) != TCL_OK
+ && GetInvalidWideFromObj(valueObj, &linkPtr->lastValue.w) != TCL_OK) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have integer value";
@@ -398,14 +414,15 @@ LinkTraceProc(
break;
case TCL_LINK_DOUBLE:
- if (Tcl_GetDoubleFromObj(NULL, valueObj, &linkPtr->lastValue.d)
- != TCL_OK) {
+ if (Tcl_GetDoubleFromObj(NULL, valueObj, &linkPtr->lastValue.d) != TCL_OK) {
#ifdef ACCEPT_NAN
if (valueObj->typePtr != &tclDoubleType) {
#endif
- Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
- ObjValue(linkPtr), TCL_GLOBAL_ONLY);
- return (char *) "variable must have real value";
+ if (GetInvalidDoubleFromObj(valueObj, &linkPtr->lastValue.d) != TCL_OK) {
+ Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
+ TCL_GLOBAL_ONLY);
+ return (char *) "variable must have real value";
+ }
#ifdef ACCEPT_NAN
}
linkPtr->lastValue.d = valueObj->internalRep.doubleValue;
@@ -415,8 +432,7 @@ LinkTraceProc(
break;
case TCL_LINK_BOOLEAN:
- if (Tcl_GetBooleanFromObj(NULL, valueObj, &linkPtr->lastValue.i)
- != TCL_OK) {
+ if (Tcl_GetBooleanFromObj(NULL, valueObj, &linkPtr->lastValue.i) != TCL_OK) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have boolean value";
@@ -425,113 +441,115 @@ LinkTraceProc(
break;
case TCL_LINK_CHAR:
- if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
+ if ((Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
+ && GetInvalidIntFromObj(valueObj, &valueInt) != TCL_OK)
|| valueInt < SCHAR_MIN || valueInt > SCHAR_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have char value";
}
- linkPtr->lastValue.c = (char)valueInt;
- LinkedVar(char) = linkPtr->lastValue.c;
+ LinkedVar(char) = linkPtr->lastValue.c = (char)valueInt;
break;
case TCL_LINK_UCHAR:
- if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
+ if ((Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
+ && GetInvalidIntFromObj(valueObj, &valueInt) != TCL_OK)
|| valueInt < 0 || valueInt > UCHAR_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned char value";
}
- linkPtr->lastValue.uc = (unsigned char) valueInt;
- LinkedVar(unsigned char) = linkPtr->lastValue.uc;
+ LinkedVar(unsigned char) = linkPtr->lastValue.uc = (unsigned char) valueInt;
break;
case TCL_LINK_SHORT:
- if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
+ if ((Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
+ && GetInvalidIntFromObj(valueObj, &valueInt) != TCL_OK)
|| valueInt < SHRT_MIN || valueInt > SHRT_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have short value";
}
- linkPtr->lastValue.s = (short)valueInt;
- LinkedVar(short) = linkPtr->lastValue.s;
+ LinkedVar(short) = linkPtr->lastValue.s = (short)valueInt;
break;
case TCL_LINK_USHORT:
- if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
+ if ((Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
+ && GetInvalidIntFromObj(valueObj, &valueInt) != TCL_OK)
|| valueInt < 0 || valueInt > USHRT_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned short value";
}
- linkPtr->lastValue.us = (unsigned short)valueInt;
- LinkedVar(unsigned short) = linkPtr->lastValue.us;
+ LinkedVar(unsigned short) = linkPtr->lastValue.us = (unsigned short)valueInt;
break;
case TCL_LINK_UINT:
- if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
+ if ((Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
+ && GetInvalidWideFromObj(valueObj, &valueWide) != TCL_OK)
|| valueWide < 0 || valueWide > UINT_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned int value";
}
- linkPtr->lastValue.ui = (unsigned int)valueWide;
- LinkedVar(unsigned int) = linkPtr->lastValue.ui;
+ LinkedVar(unsigned int) = linkPtr->lastValue.ui = (unsigned int)valueWide;
break;
+#if !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__CYGWIN__)
case TCL_LINK_LONG:
- if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
+ if ((Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
+ && GetInvalidWideFromObj(valueObj, &valueWide) != TCL_OK)
|| valueWide < LONG_MIN || valueWide > LONG_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have long value";
}
- linkPtr->lastValue.l = (long)valueWide;
- LinkedVar(long) = linkPtr->lastValue.l;
+ LinkedVar(long) = linkPtr->lastValue.l = (long)valueWide;
break;
case TCL_LINK_ULONG:
- if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
+ if ((Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
+ && GetInvalidWideFromObj(valueObj, &valueWide) != TCL_OK)
|| valueWide < 0 || (Tcl_WideUInt) valueWide > ULONG_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned long value";
}
- linkPtr->lastValue.ul = (unsigned long)valueWide;
- LinkedVar(unsigned long) = linkPtr->lastValue.ul;
+ LinkedVar(unsigned long) = linkPtr->lastValue.ul = (unsigned long)valueWide;
break;
+#endif
case TCL_LINK_WIDE_UINT:
/*
* FIXME: represent as a bignum.
*/
- if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
+ && GetInvalidWideFromObj(valueObj, &valueWide) != TCL_OK) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned wide int value";
}
- linkPtr->lastValue.uw = (Tcl_WideUInt)valueWide;
- LinkedVar(Tcl_WideUInt) = linkPtr->lastValue.uw;
+ LinkedVar(Tcl_WideUInt) = linkPtr->lastValue.uw = (Tcl_WideUInt)valueWide;
break;
case TCL_LINK_FLOAT:
- if (Tcl_GetDoubleFromObj(interp, valueObj, &valueDouble) != TCL_OK
+ if ((Tcl_GetDoubleFromObj(NULL, valueObj, &valueDouble) != TCL_OK
+ && GetInvalidDoubleFromObj(valueObj, &valueDouble) != TCL_OK)
|| valueDouble < -FLT_MAX || valueDouble > FLT_MAX) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
return (char *) "variable must have float value";
}
- linkPtr->lastValue.f = (float)valueDouble;
- LinkedVar(float) = linkPtr->lastValue.f;
+ LinkedVar(float) = linkPtr->lastValue.f = (float)valueDouble;
break;
case TCL_LINK_STRING:
- value = TclGetStringFromObj(valueObj, &valueLength);
- valueLength++;
+ value = TclGetString(valueObj);
+ valueLength = valueObj->length + 1;
pp = (char **) linkPtr->addr;
*pp = ckrealloc(*pp, valueLength);
- memcpy(*pp, value, (unsigned) valueLength);
+ memcpy(*pp, value, valueLength);
break;
default:
@@ -577,7 +595,7 @@ ObjValue(
return Tcl_NewDoubleObj(linkPtr->lastValue.d);
case TCL_LINK_BOOLEAN:
linkPtr->lastValue.i = LinkedVar(int);
- return Tcl_NewBooleanObj(linkPtr->lastValue.i != 0);
+ return Tcl_NewBooleanObj(linkPtr->lastValue.i);
case TCL_LINK_CHAR:
linkPtr->lastValue.c = LinkedVar(char);
return Tcl_NewIntObj(linkPtr->lastValue.c);
@@ -593,12 +611,14 @@ ObjValue(
case TCL_LINK_UINT:
linkPtr->lastValue.ui = LinkedVar(unsigned int);
return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.ui);
+#if !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__CYGWIN__)
case TCL_LINK_LONG:
linkPtr->lastValue.l = LinkedVar(long);
return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.l);
case TCL_LINK_ULONG:
linkPtr->lastValue.ul = LinkedVar(unsigned long);
return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.ul);
+#endif
case TCL_LINK_FLOAT:
linkPtr->lastValue.f = LinkedVar(float);
return Tcl_NewDoubleObj(linkPtr->lastValue.f);
@@ -626,6 +646,108 @@ ObjValue(
return resultObj;
}
}
+
+static int SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
+
+static Tcl_ObjType invalidRealType = {
+ "invalidReal", /* name */
+ NULL, /* freeIntRepProc */
+ NULL, /* dupIntRepProc */
+ NULL, /* updateStringProc */
+ SetInvalidRealFromAny /* setFromAnyProc */
+};
+
+static int
+SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) {
+ const char *str;
+ const char *endPtr;
+
+ str = TclGetString(objPtr);
+ if ((objPtr->length == 1) && (str[0] == '.')){
+ objPtr->typePtr = &invalidRealType;
+ objPtr->internalRep.doubleValue = 0.0;
+ return TCL_OK;
+ }
+ if (TclParseNumber(NULL, objPtr, NULL, str, objPtr->length, &endPtr,
+ TCL_PARSE_DECIMAL_ONLY) == TCL_OK) {
+ /* If number is followed by [eE][+-]?, then it is an invalid
+ * double, but it could be the start of a valid double. */
+ if (*endPtr == 'e' || *endPtr == 'E') {
+ ++endPtr;
+ if (*endPtr == '+' || *endPtr == '-') ++endPtr;
+ if (*endPtr == 0) {
+ double doubleValue = 0.0;
+ Tcl_GetDoubleFromObj(NULL, objPtr, &doubleValue);
+ TclFreeIntRep(objPtr);
+ objPtr->typePtr = &invalidRealType;
+ objPtr->internalRep.doubleValue = doubleValue;
+ return TCL_OK;
+ }
+ }
+ }
+ return TCL_ERROR;
+}
+
+
+/*
+ * This function checks for integer representations, which are valid
+ * when linking with C variables, but which are invalid in other
+ * contexts in Tcl. Handled are "+", "-", "", "0x", "0b" and "0o"
+ * (upperand lowercase). See bug [39f6304c2e].
+ */
+int
+GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr)
+{
+ const char *str = TclGetString(objPtr);
+
+ if ((objPtr->length == 0) ||
+ ((objPtr->length == 2) && (str[0] == '0') && strchr("xXbBoO", str[1]))) {
+ *intPtr = 0;
+ return TCL_OK;
+ } else if ((objPtr->length == 1) && strchr("+-", str[0])) {
+ *intPtr = (str[0] == '+');
+ return TCL_OK;
+ }
+ return TCL_ERROR;
+}
+
+int
+GetInvalidWideFromObj(Tcl_Obj *objPtr, Tcl_WideInt *widePtr)
+{
+ int intValue;
+
+ if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ *widePtr = intValue;
+ return TCL_OK;
+}
+
+/*
+ * This function checks for double representations, which are valid
+ * when linking with C variables, but which are invalid in other
+ * contexts in Tcl. Handled are "+", "-", "", ".", "0x", "0b" and "0o"
+ * (upper- and lowercase) and sequences like "1e-". See bug [39f6304c2e].
+ */
+int
+GetInvalidDoubleFromObj(Tcl_Obj *objPtr, double *doublePtr)
+{
+ int intValue;
+
+ if (objPtr->typePtr == &invalidRealType) {
+ goto gotdouble;
+ }
+ if (GetInvalidIntFromObj(objPtr, &intValue) == TCL_OK) {
+ *doublePtr = (double) intValue;
+ return TCL_OK;
+ }
+ if (SetInvalidRealFromAny(NULL, objPtr) == TCL_OK) {
+ gotdouble:
+ *doublePtr = objPtr->internalRep.doubleValue;
+ return TCL_OK;
+ }
+ return TCL_ERROR;
+}
/*
* Local Variables:
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 14b8a14..11374cc 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -374,7 +374,7 @@ Tcl_SetListObj(
listRepPtr = NewListIntRep(objc, objv, 1);
ListSetIntRep(objPtr, listRepPtr);
} else {
- objPtr->bytes = tclEmptyStringRep;
+ objPtr->bytes = &tclEmptyString;
objPtr->length = 0;
}
}
@@ -465,7 +465,7 @@ Tcl_ListObjGetElements(
if (listPtr->typePtr != &tclListType) {
int result;
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
*objcPtr = 0;
*objvPtr = NULL;
return TCL_OK;
@@ -575,7 +575,7 @@ Tcl_ListObjAppendElement(
if (listPtr->typePtr != &tclListType) {
int result;
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
Tcl_SetListObj(listPtr, 1, &objPtr);
return TCL_OK;
}
@@ -739,7 +739,7 @@ Tcl_ListObjIndex(
if (listPtr->typePtr != &tclListType) {
int result;
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
*objPtrPtr = NULL;
return TCL_OK;
}
@@ -792,7 +792,7 @@ Tcl_ListObjLength(
if (listPtr->typePtr != &tclListType) {
int result;
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
*intPtr = 0;
return TCL_OK;
}
@@ -863,7 +863,7 @@ Tcl_ListObjReplace(
Tcl_Panic("%s called with shared object", "Tcl_ListObjReplace");
}
if (listPtr->typePtr != &tclListType) {
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
if (!objc) {
return TCL_OK;
}
@@ -897,18 +897,18 @@ Tcl_ListObjReplace(
}
if (count < 0) {
count = 0;
- } else if (numElems < first+count || first+count < 0) {
- /*
- * The 'first+count < 0' condition here guards agains integer
- * overflow in determining 'first+count'.
- */
+ } else if (first > INT_MAX - count /* Handle integer overflow */
+ || numElems < first+count) {
count = numElems - first;
}
if (objc > LIST_MAX - (numElems - count)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "max length of a Tcl list (%d elements) exceeded", LIST_MAX));
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "max length of a Tcl list (%d elements) exceeded",
+ LIST_MAX));
+ }
return TCL_ERROR;
}
isShared = (listRepPtr->refCount > 1);
@@ -1650,7 +1650,7 @@ TclListObjSetElement(
if (listPtr->typePtr != &tclListType) {
int result;
- if (listPtr->bytes == tclEmptyStringRep) {
+ if (listPtr->bytes == &tclEmptyString) {
if (interp != NULL) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("list index out of range", -1));
@@ -1898,7 +1898,7 @@ SetListFromAny(
while (--elemPtrs >= &listRepPtr->elements) {
Tcl_DecrRefCount(*elemPtrs);
}
- ckfree((char *) listRepPtr);
+ ckfree(listRepPtr);
return TCL_ERROR;
}
if (elemStart == limit) {
@@ -1979,7 +1979,7 @@ UpdateStringOfList(
*/
if (numElems == 0) {
- listPtr->bytes = tclEmptyStringRep;
+ listPtr->bytes = &tclEmptyString;
listPtr->length = 0;
return;
}
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index 7c70e03..bcda420 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -998,7 +998,7 @@ Tcl_StaticPackage(
}
/*
- * Package isn't loade in the current interp yet. Mark it as now being
+ * Package isn't loaded in the current interp yet. Mark it as now being
* loaded.
*/
@@ -1012,10 +1012,10 @@ Tcl_StaticPackage(
/*
*----------------------------------------------------------------------
*
- * TclGetLoadedPackages --
+ * TclGetLoadedPackages, TclGetLoadedPackagesEx --
*
* This function returns information about all of the files that are
- * loaded (either in a particular intepreter, or for all interpreters).
+ * loaded (either in a particular interpreter, or for all interpreters).
*
* Results:
* The return value is a standard Tcl completion code. If successful, a
@@ -1039,16 +1039,27 @@ TclGetLoadedPackages(
* otherwise, just return info about this
* interpreter. */
{
+ return TclGetLoadedPackagesEx(interp, targetName, NULL);
+}
+
+int
+TclGetLoadedPackagesEx(
+ Tcl_Interp *interp, /* Interpreter in which to return information
+ * or error message. */
+ const char *targetName, /* Name of target interpreter or NULL. If
+ * NULL, return info about all interps;
+ * otherwise, just return info about this
+ * interpreter. */
+ const char *packageName) /* Package name or NULL. If NULL, return info
+ * for all packages.
+ */
+{
Tcl_Interp *target;
LoadedPackage *pkgPtr;
InterpPackage *ipPtr;
Tcl_Obj *resultObj, *pkgDesc[2];
if (targetName == NULL) {
- /*
- * Return information about all of the available packages.
- */
-
resultObj = Tcl_NewObj();
Tcl_MutexLock(&packageMutex);
for (pkgPtr = firstPackagePtr; pkgPtr != NULL;
@@ -1063,16 +1074,38 @@ TclGetLoadedPackages(
return TCL_OK;
}
- /*
- * Return information about only the packages that are loaded in a given
- * interpreter.
- */
-
target = Tcl_GetSlave(interp, targetName);
if (target == NULL) {
return TCL_ERROR;
}
ipPtr = Tcl_GetAssocData(target, "tclLoad", NULL);
+
+ /*
+ * Return information about all of the available packages.
+ */
+ if (packageName) {
+ resultObj = NULL;
+
+ for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
+ pkgPtr = ipPtr->pkgPtr;
+
+ if (!strcmp(packageName, pkgPtr->packageName)) {
+ resultObj = Tcl_NewStringObj(pkgPtr->fileName, -1);
+ break;
+ }
+ }
+
+ if (resultObj) {
+ Tcl_SetObjResult(interp, resultObj);
+ }
+ return TCL_OK;
+ }
+
+ /*
+ * Return information about only the packages that are loaded in a given
+ * interpreter.
+ */
+
resultObj = Tcl_NewObj();
for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
pkgPtr = ipPtr->pkgPtr;
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 7f6ecf5..e1bad0e 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -31,8 +31,8 @@
* limited to a single interpreter.
*/
-typedef struct ThreadSpecificData {
- long numNsCreated; /* Count of the number of namespaces created
+typedef struct {
+ size_t numNsCreated; /* Count of the number of namespaces created
* within the thread. This value is used as a
* unique id for each namespace. Cannot be
* per-interp because the nsId is used to
@@ -59,7 +59,7 @@ typedef struct ResolvedNsName {
* the name was resolved. NULL if the name is
* fully qualified and thus the resolution
* does not depend on the context. */
- int refCount; /* Reference count: 1 for each nsName object
+ size_t refCount; /* Reference count: 1 for each nsName object
* that has a pointer to this ResolvedNsName
* structure as its internal rep. This
* structure can be freed when refCount
@@ -1326,8 +1326,7 @@ void
TclNsDecrRefCount(
Namespace *nsPtr)
{
- nsPtr->refCount--;
- if ((nsPtr->refCount == 0) && (nsPtr->flags & NS_DEAD)) {
+ if ((nsPtr->refCount-- <= 1) && (nsPtr->flags & NS_DEAD)) {
NamespaceFree(nsPtr);
}
}
@@ -4671,8 +4670,7 @@ FreeNsNameInternalRep(
* references, free it up.
*/
- resNamePtr->refCount--;
- if (resNamePtr->refCount == 0) {
+ if (resNamePtr->refCount-- <= 1) {
/*
* Decrement the reference count for the cached namespace. If the
* namespace is dead, and there are no more references to it, free
diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c
index 1797760..ac0b94d 100644
--- a/generic/tclOOCall.c
+++ b/generic/tclOOCall.c
@@ -179,6 +179,7 @@ StashCallChain(
CallChain *callPtr)
{
callPtr->refCount++;
+ TclGetString(objPtr);
TclFreeIntRep(objPtr);
objPtr->typePtr = &methodNameType;
objPtr->internalRep.twoPtrValue.ptr1 = callPtr;
@@ -618,6 +619,7 @@ AddClassMethodNames(
int isWanted = (!(flags & PUBLIC_METHOD)
|| (mPtr->flags & PUBLIC_METHOD)) ? IN_LIST : 0;
+ isWanted |= (mPtr->typePtr == NULL ? NO_IMPLEMENTATION : 0);
Tcl_SetHashValue(hPtr, INT2PTR(isWanted));
} else if ((PTR2INT(Tcl_GetHashValue(hPtr)) & NO_IMPLEMENTATION)
&& mPtr->typePtr != NULL) {
diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c
index 8c3f28c..5b0dfc3 100644
--- a/generic/tclOODefineCmds.c
+++ b/generic/tclOODefineCmds.c
@@ -2217,7 +2217,7 @@ ClassSuperSet(
"attempt to form circular dependency graph", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "CIRCULARITY", NULL);
failedAfterAlloc:
- ckfree((char *) superclasses);
+ ckfree(superclasses);
return TCL_ERROR;
}
}
@@ -2234,7 +2234,7 @@ ClassSuperSet(
FOREACH(superPtr, oPtr->classPtr->superclasses) {
TclOORemoveFromSubclasses(oPtr->classPtr, superPtr);
}
- ckfree((char *) oPtr->classPtr->superclasses.list);
+ ckfree(oPtr->classPtr->superclasses.list);
}
oPtr->classPtr->superclasses.list = superclasses;
oPtr->classPtr->superclasses.num = superc;
@@ -2323,7 +2323,7 @@ ClassVarsSet(
}
for (i=0 ; i<varc ; i++) {
- const char *varName = Tcl_GetString(varv[i]);
+ const char *varName = TclGetString(varv[i]);
if (strstr(varName, "::") != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2349,7 +2349,7 @@ ClassVarsSet(
}
if (i != varc) {
if (varc == 0) {
- ckfree((char *) oPtr->classPtr->variables.list);
+ ckfree(oPtr->classPtr->variables.list);
} else if (i) {
oPtr->classPtr->variables.list = (Tcl_Obj **)
ckrealloc((char *) oPtr->classPtr->variables.list,
@@ -2604,7 +2604,7 @@ ObjVarsSet(
}
for (i=0 ; i<varc ; i++) {
- const char *varName = Tcl_GetString(varv[i]);
+ const char *varName = TclGetString(varv[i]);
if (strstr(varName, "::") != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2630,7 +2630,7 @@ ObjVarsSet(
}
if (i != varc) {
if (varc == 0) {
- ckfree((char *) oPtr->variables.list);
+ ckfree(oPtr->variables.list);
} else if (i) {
oPtr->variables.list = (Tcl_Obj **)
ckrealloc((char *) oPtr->variables.list,
diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h
index b75ffdb..ae24dee 100644
--- a/generic/tclOOInt.h
+++ b/generic/tclOOInt.h
@@ -592,7 +592,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
#define AddRef(ptr) ((ptr)->refCount++)
#define DelRef(ptr) do { \
if ((ptr)->refCount-- <= 1) { \
- ckfree((char *) (ptr)); \
+ ckfree(ptr); \
} \
} while(0)
diff --git a/generic/tclObj.c b/generic/tclObj.c
index d3f59ec..f4b81f2 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -49,7 +49,6 @@ Tcl_Mutex tclObjMutex;
*/
char tclEmptyString = '\0';
-char *tclEmptyStringRep = &tclEmptyString;
#if defined(TCL_MEM_DEBUG) && defined(TCL_THREADS)
/*
@@ -76,7 +75,7 @@ typedef struct ObjData {
* The structure defined below is used in this file only.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
Tcl_HashTable *lineCLPtr; /* This table remembers for each Tcl_Obj
* generated by a call to the function
* TclSubstTokens() from a literal text
@@ -345,23 +344,23 @@ typedef struct ResolvedCmdName {
* reference (not the namespace that contains
* the referenced command). NULL if the name
* is fully qualified.*/
- long refNsId; /* refNsPtr's unique namespace id. Used to
+ size_t refNsId; /* refNsPtr's unique namespace id. Used to
* verify that refNsPtr is still valid (e.g.,
* it's possible that the cmd's containing
* namespace was deleted and a new one created
* at the same address). */
- int refNsCmdEpoch; /* Value of the referencing namespace's
+ size_t refNsCmdEpoch; /* Value of the referencing namespace's
* cmdRefEpoch when the pointer was cached.
* Before using the cached pointer, we check
* if the namespace's epoch was incremented;
* if so, this cached pointer is invalid. */
- int cmdEpoch; /* Value of the command's cmdEpoch when this
+ size_t cmdEpoch; /* Value of the command's cmdEpoch when this
* pointer was cached. Before using the cached
* pointer, we check if the cmd's epoch was
* incremented; if so, the cmd was renamed,
* deleted, hidden, or exposed, and so the
* pointer is invalid. */
- int refCount; /* Reference count: 1 for each cmdName object
+ size_t refCount; /* Reference count: 1 for each cmdName object
* that has a pointer to this ResolvedCmdName
* structure as its internal rep. This
* structure can be freed when refCount
@@ -1060,7 +1059,7 @@ TclDbInitNewObj(
* debugging. */
{
objPtr->refCount = 0;
- objPtr->bytes = tclEmptyStringRep;
+ objPtr->bytes = &tclEmptyString;
objPtr->length = 0;
objPtr->typePtr = NULL;
@@ -1733,7 +1732,7 @@ Tcl_InvalidateStringRep(
* is coerced to 1.
*
* When TCL_MEM_DEBUG is defined, this function just returns the result
- * of calling the debugging version Tcl_DbNewBooleanObj.
+ * of calling the debugging version Tcl_DbNewLongObj.
*
* Results:
* The newly created object is returned. This object will have an invalid
@@ -1752,7 +1751,7 @@ Tcl_Obj *
Tcl_NewBooleanObj(
register int boolValue) /* Boolean used to initialize new object. */
{
- return Tcl_DbNewBooleanObj(boolValue, "unknown", 0);
+ return Tcl_DbNewLongObj(boolValue!=0, "unknown", 0);
}
#else /* if not TCL_MEM_DEBUG */
@@ -1763,7 +1762,7 @@ Tcl_NewBooleanObj(
{
register Tcl_Obj *objPtr;
- TclNewBooleanObj(objPtr, boolValue);
+ TclNewLongObj(objPtr, boolValue!=0);
return objPtr;
}
#endif /* TCL_MEM_DEBUG */
@@ -1794,6 +1793,7 @@ Tcl_NewBooleanObj(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_DbNewBooleanObj
#ifdef TCL_MEM_DEBUG
@@ -1810,7 +1810,7 @@ Tcl_DbNewBooleanObj(
TclDbNewObj(objPtr, file, line);
objPtr->bytes = NULL;
- objPtr->internalRep.longValue = (boolValue? 1 : 0);
+ objPtr->internalRep.longValue = (boolValue != 0);
objPtr->typePtr = &tclIntType;
return objPtr;
}
@@ -1857,8 +1857,9 @@ Tcl_SetBooleanObj(
Tcl_Panic("%s called with shared object", "Tcl_SetBooleanObj");
}
- TclSetBooleanObj(objPtr, boolValue);
+ TclSetLongObj(objPtr, boolValue!=0);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -2004,9 +2005,10 @@ static int
ParseBoolean(
register Tcl_Obj *objPtr) /* The object to parse/convert. */
{
- int i, length, newBool;
+ int newBool;
char lowerCase[6];
- const char *str = TclGetStringFromObj(objPtr, &length);
+ const char *str = TclGetString(objPtr);
+ size_t i, length = objPtr->length;
if ((length == 0) || (length > 5)) {
/*
@@ -2058,25 +2060,25 @@ ParseBoolean(
/*
* Checking the 'y' is redundant, but makes the code clearer.
*/
- if (strncmp(lowerCase, "yes", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "yes", length) == 0) {
newBool = 1;
goto goodBoolean;
}
return TCL_ERROR;
case 'n':
- if (strncmp(lowerCase, "no", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "no", length) == 0) {
newBool = 0;
goto goodBoolean;
}
return TCL_ERROR;
case 't':
- if (strncmp(lowerCase, "true", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "true", length) == 0) {
newBool = 1;
goto goodBoolean;
}
return TCL_ERROR;
case 'f':
- if (strncmp(lowerCase, "false", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "false", length) == 0) {
newBool = 0;
goto goodBoolean;
}
@@ -2085,10 +2087,10 @@ ParseBoolean(
if (length < 2) {
return TCL_ERROR;
}
- if (strncmp(lowerCase, "on", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "on", length) == 0) {
newBool = 1;
goto goodBoolean;
- } else if (strncmp(lowerCase, "off", (size_t) length) == 0) {
+ } else if (strncmp(lowerCase, "off", length) == 0) {
newBool = 0;
goto goodBoolean;
}
@@ -2425,7 +2427,7 @@ Tcl_NewIntObj(
{
register Tcl_Obj *objPtr;
- TclNewIntObj(objPtr, intValue);
+ TclNewLongObj(objPtr, intValue);
return objPtr;
}
#endif /* if TCL_MEM_DEBUG */
@@ -2458,7 +2460,7 @@ Tcl_SetIntObj(
Tcl_Panic("%s called with shared object", "Tcl_SetIntObj");
}
- TclSetIntObj(objPtr, intValue);
+ TclSetLongObj(objPtr, intValue);
}
/*
@@ -2784,7 +2786,7 @@ Tcl_GetLongFromObj(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
- Tcl_GetString(objPtr)));
+ TclGetString(objPtr)));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", NULL);
}
return TCL_ERROR;
@@ -3085,7 +3087,7 @@ Tcl_GetWideIntFromObj(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
- Tcl_GetString(objPtr)));
+ TclGetString(objPtr)));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", NULL);
}
return TCL_ERROR;
@@ -3252,13 +3254,11 @@ UpdateStringOfBignum(
if (status != MP_OKAY) {
Tcl_Panic("radix size failure in UpdateStringOfBignum");
}
- if (size == 3) {
+ if (size < 2) {
/*
- * mp_radix_size() returns 3 when more than INT_MAX bytes would be
+ * mp_radix_size() returns < 2 when more than INT_MAX bytes would be
* needed to hold the string rep (because mp_radix_size ignores
- * integer overflow issues). When we know the string rep will be more
- * than 3, we can conclude the string rep would overflow our string
- * length limits.
+ * integer overflow issues).
*
* Note that so long as we enforce our bignums to the size that fits
* in a packed bignum, this branch will never be taken.
@@ -3396,7 +3396,7 @@ GetBignumFromObj(
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
objPtr->typePtr = NULL;
if (objPtr->bytes == NULL) {
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
+ TclInitStringRep(objPtr, &tclEmptyString, 0);
}
}
return TCL_OK;
@@ -3416,7 +3416,7 @@ GetBignumFromObj(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
- Tcl_GetString(objPtr)));
+ TclGetString(objPtr)));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", NULL);
}
return TCL_ERROR;
@@ -3966,7 +3966,7 @@ TclCompareObjKeys(
Tcl_Obj *objPtr1 = keyPtr;
Tcl_Obj *objPtr2 = (Tcl_Obj *) hPtr->key.oneWordValue;
register const char *p1, *p2;
- register int l1, l2;
+ register size_t l1, l2;
/*
* If the object pointers are the same then they match.
@@ -4309,7 +4309,7 @@ FreeCmdNameInternalRep(
* there are no more uses, free the ResolvedCmdName structure.
*/
- if (resPtr->refCount-- == 1) {
+ if (resPtr->refCount-- <= 1) {
/*
* Now free the cached command, unless it is still in its hash
* table or if there are other references to it from other cmdName
@@ -4421,7 +4421,7 @@ SetCmdNameFromAny(
Command *oldCmdPtr = resPtr->cmdPtr;
- if (--oldCmdPtr->refCount == 0) {
+ if (oldCmdPtr->refCount-- <= 1) {
TclCleanupCommandMacro(oldCmdPtr);
}
} else {
@@ -4455,7 +4455,6 @@ Tcl_RepresentationCmd(
int objc,
Tcl_Obj *const objv[])
{
- char ptrBuffer[2*TCL_INTEGER_SPACE+6];
Tcl_Obj *descObj;
if (objc != 2) {
@@ -4469,18 +4468,20 @@ Tcl_RepresentationCmd(
* "1872361827361287"
*/
- sprintf(ptrBuffer, "%p", (void *) objv[1]);
descObj = Tcl_ObjPrintf("value is a %s with a refcount of %d,"
- " object pointer at %s",
- objv[1]->typePtr ? objv[1]->typePtr->name : "pure string",
- objv[1]->refCount, ptrBuffer);
+ " object pointer at %p",
+ objv[1]->typePtr ? objv[1]->typePtr->name : "pure string",
+ objv[1]->refCount, objv[1]);
if (objv[1]->typePtr) {
- sprintf(ptrBuffer, "%p:%p",
- (void *) objv[1]->internalRep.twoPtrValue.ptr1,
- (void *) objv[1]->internalRep.twoPtrValue.ptr2);
- Tcl_AppendPrintfToObj(descObj, ", internal representation %s",
- ptrBuffer);
+ if (objv[1]->typePtr == &tclDoubleType) {
+ Tcl_AppendPrintfToObj(descObj, ", internal representation %g",
+ objv[1]->internalRep.doubleValue);
+ } else {
+ Tcl_AppendPrintfToObj(descObj, ", internal representation %p:%p",
+ (void *) objv[1]->internalRep.twoPtrValue.ptr1,
+ (void *) objv[1]->internalRep.twoPtrValue.ptr2);
+ }
}
if (objv[1]->bytes) {
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 3a04df4..8a28bf2 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -1169,6 +1169,8 @@ ParseTokens(
numBytes--;
nestedPtr = TclStackAlloc(parsePtr->interp, sizeof(Tcl_Parse));
while (1) {
+ const char *curEnd;
+
if (Tcl_ParseCommand(parsePtr->interp, src, numBytes, 1,
nestedPtr) != TCL_OK) {
parsePtr->errorType = nestedPtr->errorType;
@@ -1177,8 +1179,9 @@ ParseTokens(
TclStackFree(parsePtr->interp, nestedPtr);
return TCL_ERROR;
}
+ curEnd = src + numBytes;
src = nestedPtr->commandStart + nestedPtr->commandSize;
- numBytes = parsePtr->end - src;
+ numBytes = curEnd - src;
Tcl_FreeParse(nestedPtr);
/*
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 68ec2c4..0053041 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -2608,7 +2608,7 @@ UpdateStringOfFsPath(
pathPtr->bytes = TclGetStringFromObj(copy, &cwdLen);
pathPtr->length = cwdLen;
- copy->bytes = tclEmptyStringRep;
+ copy->bytes = &tclEmptyString;
copy->length = 0;
TclDecrRefCount(copy);
}
diff --git a/generic/tclPipe.c b/generic/tclPipe.c
index 83fb818..d6cd188 100644
--- a/generic/tclPipe.c
+++ b/generic/tclPipe.c
@@ -60,7 +60,7 @@ static TclFile FileForRedirect(Tcl_Interp *interp, const char *spec,
static TclFile
FileForRedirect(
- Tcl_Interp *interp, /* Intepreter to use for error reporting. */
+ Tcl_Interp *interp, /* Interpreter to use for error reporting. */
const char *spec, /* Points to character just after redirection
* character. */
int atOK, /* Non-zero means that '@' notation can be
diff --git a/generic/tclPkg.c b/generic/tclPkg.c
index 244eb94..9ad3cb7 100644
--- a/generic/tclPkg.c
+++ b/generic/tclPkg.c
@@ -17,6 +17,10 @@
#include "tclInt.h"
+MODULE_SCOPE char *tclEmptyStringRep;
+
+char *tclEmptyStringRep = &tclEmptyString;
+
/*
* Each invocation of the "package ifneeded" command creates a structure of
* the following type, which is used to load the package into the interpreter
@@ -28,10 +32,22 @@ typedef struct PkgAvail {
char *script; /* Script to invoke to provide this version of
* the package. Malloc'ed and protected by
* Tcl_Preserve and Tcl_Release. */
+ char *pkgIndex; /* Full file name of pkgIndex file */
struct PkgAvail *nextPtr; /* Next in list of available versions of the
* same package. */
} PkgAvail;
+typedef struct PkgName {
+ struct PkgName *nextPtr; /* Next in list of package names being initialized. */
+ char name[1];
+} PkgName;
+
+typedef struct PkgFiles {
+ PkgName *names; /* Package names being initialized. Must be first field*/
+ Tcl_HashTable table; /* Table which contains files for each package */
+} PkgFiles;
+
+
/*
* For each package that is known in any way to an interpreter, there is one
* record of the following type. These records are stored in the
@@ -81,7 +97,7 @@ static const char * PkgRequireCore(Tcl_Interp *interp, const char *name,
((v) = ckalloc(len), memcpy((v),(s),(len)))
#define DupString(v,s) \
do { \
- unsigned local__len = (unsigned) (strlen(s) + 1); \
+ size_t local__len = strlen(s) + 1; \
DupBlock((v),(s),local__len); \
} while (0)
@@ -189,6 +205,62 @@ Tcl_PkgProvideEx(
*----------------------------------------------------------------------
*/
+static void PkgFilesCleanupProc(ClientData clientData,
+ Tcl_Interp *interp)
+{
+ PkgFiles *pkgFiles = (PkgFiles *) clientData;
+ Tcl_HashSearch search;
+ Tcl_HashEntry *entry;
+
+ while (pkgFiles->names) {
+ PkgName *name = pkgFiles->names;
+ pkgFiles->names = name->nextPtr;
+ ckfree(name);
+ }
+ entry = Tcl_FirstHashEntry(&pkgFiles->table, &search);
+ while (entry) {
+ Tcl_Obj *obj = (Tcl_Obj *)Tcl_GetHashValue(entry);
+ Tcl_DecrRefCount(obj);
+ entry = Tcl_NextHashEntry(&search);
+ }
+ Tcl_DeleteHashTable(&pkgFiles->table);
+ return;
+}
+
+void *TclInitPkgFiles(Tcl_Interp *interp)
+{
+ /* If assocdata "tclPkgFiles" doesn't exist yet, create it */
+ PkgFiles *pkgFiles = Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
+ if (!pkgFiles) {
+ pkgFiles = ckalloc(sizeof(PkgFiles));
+ pkgFiles->names = NULL;
+ Tcl_InitHashTable(&pkgFiles->table, TCL_STRING_KEYS);
+ Tcl_SetAssocData(interp, "tclPkgFiles", PkgFilesCleanupProc, pkgFiles);
+ }
+ return pkgFiles;
+}
+
+void TclPkgFileSeen(Tcl_Interp *interp, const char *fileName)
+{
+ PkgFiles *pkgFiles = (PkgFiles *) Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
+ if (pkgFiles && pkgFiles->names) {
+ const char *name = pkgFiles->names->name;
+ Tcl_HashTable *table = &pkgFiles->table;
+ int new;
+ Tcl_HashEntry *entry = Tcl_CreateHashEntry(table, name, &new);
+ Tcl_Obj *list;
+
+ if (new) {
+ list = Tcl_NewObj();
+ Tcl_SetHashValue(entry, list);
+ Tcl_IncrRefCount(list);
+ } else {
+ list = Tcl_GetHashValue(entry);
+ }
+ Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj(fileName, -1));
+ }
+}
+
#undef Tcl_PkgRequire
const char *
Tcl_PkgRequire(
@@ -489,12 +561,26 @@ PkgRequireCore(
*/
char *versionToProvide = bestPtr->version;
+ PkgFiles *pkgFiles;
+ PkgName *pkgName;
script = bestPtr->script;
pkgPtr->clientData = versionToProvide;
- Tcl_Preserve(script);
Tcl_Preserve(versionToProvide);
+ Tcl_Preserve(script);
+ pkgFiles = TclInitPkgFiles(interp);
+ /* Push "ifneeded" package name in "tclPkgFiles" assocdata. */
+ pkgName = ckalloc(sizeof(PkgName) + strlen(name));
+ pkgName->nextPtr = pkgFiles->names;
+ strcpy(pkgName->name, name);
+ pkgFiles->names = pkgName;
+ if (bestPtr->pkgIndex) {
+ TclPkgFileSeen(interp, bestPtr->pkgIndex);
+ }
code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ /* Pop the "ifneeded" package name from "tclPkgFiles" assocdata*/
+ pkgFiles->names = pkgName->nextPtr;
+ ckfree(pkgName);
Tcl_Release(script);
pkgPtr = FindPackage(interp, name);
@@ -764,14 +850,14 @@ Tcl_PackageObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const pkgOptions[] = {
- "forget", "ifneeded", "names", "prefer", "present",
- "provide", "require", "unknown", "vcompare", "versions",
- "vsatisfies", NULL
+ "files", "forget", "ifneeded", "names", "prefer",
+ "present", "provide", "require", "unknown", "vcompare",
+ "versions", "vsatisfies", NULL
};
enum pkgOptions {
- PKG_FORGET, PKG_IFNEEDED, PKG_NAMES, PKG_PREFER, PKG_PRESENT,
- PKG_PROVIDE, PKG_REQUIRE, PKG_UNKNOWN, PKG_VCOMPARE, PKG_VERSIONS,
- PKG_VSATISFIES
+ PKG_FILES, PKG_FORGET, PKG_IFNEEDED, PKG_NAMES, PKG_PREFER,
+ PKG_PRESENT, PKG_PROVIDE, PKG_REQUIRE, PKG_UNKNOWN, PKG_VCOMPARE,
+ PKG_VERSIONS, PKG_VSATISFIES
};
Interp *iPtr = (Interp *) interp;
int optionIndex, exact, i, satisfies;
@@ -794,11 +880,37 @@ Tcl_PackageObjCmd(
return TCL_ERROR;
}
switch ((enum pkgOptions) optionIndex) {
+ case PKG_FILES: {
+ PkgFiles *pkgFiles;
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "package");
+ return TCL_ERROR;
+ }
+ pkgFiles = (PkgFiles *) Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
+ if (pkgFiles) {
+ Tcl_HashEntry *entry = Tcl_FindHashEntry(&pkgFiles->table, Tcl_GetString(objv[2]));
+ if (entry) {
+ Tcl_SetObjResult(interp, (Tcl_Obj *)Tcl_GetHashValue(entry));
+ }
+ }
+ break;
+ }
case PKG_FORGET: {
const char *keyString;
+ PkgFiles *pkgFiles = (PkgFiles *) Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
for (i = 2; i < objc; i++) {
keyString = TclGetString(objv[i]);
+ if (pkgFiles) {
+ hPtr = Tcl_FindHashEntry(&pkgFiles->table, keyString);
+ if (hPtr) {
+ Tcl_Obj *obj = Tcl_GetHashValue(hPtr);
+ Tcl_DeleteHashEntry(hPtr);
+ Tcl_DecrRefCount(obj);
+ }
+ }
+
hPtr = Tcl_FindHashEntry(&iPtr->packageTable, keyString);
if (hPtr == NULL) {
continue;
@@ -813,6 +925,9 @@ Tcl_PackageObjCmd(
pkgPtr->availPtr = availPtr->nextPtr;
Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC);
Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
+ if (availPtr->pkgIndex) {
+ Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
+ }
ckfree(availPtr);
}
ckfree(pkgPtr);
@@ -863,6 +978,9 @@ Tcl_PackageObjCmd(
return TCL_OK;
}
Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
+ if (availPtr->pkgIndex) {
+ Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
+ }
break;
}
}
@@ -873,6 +991,7 @@ Tcl_PackageObjCmd(
}
if (availPtr == NULL) {
availPtr = ckalloc(sizeof(PkgAvail));
+ availPtr->pkgIndex = 0;
DupBlock(availPtr->version, argv3, (unsigned) length + 1);
if (prevPtr == NULL) {
@@ -883,6 +1002,10 @@ Tcl_PackageObjCmd(
prevPtr->nextPtr = availPtr;
}
}
+ if (iPtr->scriptFile) {
+ argv4 = TclGetStringFromObj(iPtr->scriptFile, &length);
+ DupBlock(availPtr->pkgIndex, argv4, (unsigned) length + 1);
+ }
argv4 = TclGetStringFromObj(objv[4], &length);
DupBlock(availPtr->script, argv4, (unsigned) length + 1);
break;
@@ -1220,7 +1343,7 @@ FindPackage(
void
TclFreePackageInfo(
- Interp *iPtr) /* Interpereter that is being deleted. */
+ Interp *iPtr) /* Interpreter that is being deleted. */
{
Package *pkgPtr;
Tcl_HashSearch search;
@@ -1238,6 +1361,9 @@ TclFreePackageInfo(
pkgPtr->availPtr = availPtr->nextPtr;
Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC);
Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
+ if (availPtr->pkgIndex) {
+ Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
+ }
ckfree(availPtr);
}
ckfree(pkgPtr);
diff --git a/generic/tclPreserve.c b/generic/tclPreserve.c
index cca13e8..5c6097f 100644
--- a/generic/tclPreserve.c
+++ b/generic/tclPreserve.c
@@ -22,7 +22,7 @@
typedef struct {
ClientData clientData; /* Address of preserved block. */
- int refCount; /* Number of Tcl_Preserve calls in effect for
+ size_t refCount; /* Number of Tcl_Preserve calls in effect for
* block. */
int mustFree; /* Non-zero means Tcl_EventuallyFree was
* called while a Tcl_Preserve call was in
@@ -63,7 +63,7 @@ typedef struct HandleStruct {
* ensure that the contents of the handle are
* not changed by anyone else. */
#endif
- int refCount; /* Number of TclHandlePreserve() calls in
+ size_t refCount; /* Number of TclHandlePreserve() calls in
* effect on this handle. */
} HandleStruct;
@@ -155,7 +155,7 @@ Tcl_Preserve(
refPtr->clientData = clientData;
refPtr->refCount = 1;
refPtr->mustFree = 0;
- refPtr->freeProc = TCL_STATIC;
+ refPtr->freeProc = 0;
inUse += 1;
Tcl_MutexUnlock(&preserveMutex);
}
@@ -195,7 +195,7 @@ Tcl_Release(
continue;
}
- if (--refPtr->refCount != 0) {
+ if (refPtr->refCount-- > 1) {
Tcl_MutexUnlock(&preserveMutex);
return;
}
@@ -459,7 +459,7 @@ TclHandleRelease(
handlePtr, handlePtr->ptr2, handlePtr->ptr);
}
#endif
- if ((--handlePtr->refCount == 0) && (handlePtr->ptr == NULL)) {
+ if ((handlePtr->refCount-- <= 1) && (handlePtr->ptr == NULL)) {
ckfree(handlePtr);
}
}
diff --git a/generic/tclProc.c b/generic/tclProc.c
index bed520a..373192c 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -500,7 +500,8 @@ TclCreateProc(
}
for (i = 0; i < numArgs; i++) {
- int fieldCount, nameLength, valueLength;
+ int fieldCount, nameLength;
+ size_t valueLength;
const char **fieldValues;
/*
@@ -602,12 +603,11 @@ TclCreateProc(
*/
if (localPtr->defValuePtr != NULL) {
- int tmpLength;
- const char *tmpPtr = TclGetStringFromObj(localPtr->defValuePtr,
- &tmpLength);
+ const char *tmpPtr = TclGetString(localPtr->defValuePtr);
+ size_t tmpLength = localPtr->defValuePtr->length;
if ((valueLength != tmpLength) ||
- strncmp(fieldValues[1], tmpPtr, (size_t) tmpLength)) {
+ strncmp(fieldValues[1], tmpPtr, tmpLength)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"procedure \"%s\": formal parameter \"%s\" has "
"default value inconsistent with precompiled body",
diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c
index ea25d4b..5f8dc20 100644
--- a/generic/tclRegexp.c
+++ b/generic/tclRegexp.c
@@ -64,7 +64,7 @@
#define NUM_REGEXPS 30
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* Set to 1 when the module is initialized. */
char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled regular
* expression patterns. NULL means that this
@@ -502,9 +502,16 @@ Tcl_RegExpMatchObj(
{
Tcl_RegExp re;
- re = Tcl_GetRegExpFromObj(interp, patternObj,
- TCL_REG_ADVANCED | TCL_REG_NOSUB);
- if (re == NULL) {
+ /*
+ * For performance reasons, first try compiling the RE without support for
+ * subexpressions. On failure, try again without TCL_REG_NOSUB in case the
+ * RE has backreferences in it. Closely related to [Bug 1366683]. If this
+ * still fails, an error message will be left in the interpreter.
+ */
+
+ if (!(re = Tcl_GetRegExpFromObj(interp, patternObj,
+ TCL_REG_ADVANCED | TCL_REG_NOSUB))
+ && !(re = Tcl_GetRegExpFromObj(interp, patternObj, TCL_REG_ADVANCED))) {
return -1;
}
return Tcl_RegExpExecObj(interp, re, textObj, 0 /* offset */,
@@ -672,7 +679,7 @@ TclRegAbout(
resultObj = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewIntObj((int) regexpPtr->re.re_nsub));
+ Tcl_NewWideIntObj((Tcl_WideInt) regexpPtr->re.re_nsub));
/*
* Now append a list of all the bit-flags set for the RE.
diff --git a/generic/tclRegexp.h b/generic/tclRegexp.h
index 3b2433e..eac0aaa 100644
--- a/generic/tclRegexp.h
+++ b/generic/tclRegexp.h
@@ -37,7 +37,7 @@ typedef struct TclRegexp {
* of subexpressions. */
rm_detail_t details; /* Detailed information on match (currently
* used only for REG_EXPECT). */
- int refCount; /* Count of number of references to this
+ unsigned int refCount; /* Count of number of references to this
* compiled regexp. */
} TclRegexp;
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 9d0714c..57a6de5 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -27,7 +27,9 @@ enum returnKeys {
static Tcl_Obj ** GetKeys(void);
static void ReleaseKeys(ClientData clientData);
static void ResetObjResult(Interp *iPtr);
+#ifndef TCL_NO_DEPRECATED
static void SetupAppendBuffer(Interp *iPtr, int newSpace);
+#endif /* !TCL_NO_DEPRECATED */
/*
* This structure is used to take a snapshot of the interpreter state in
@@ -35,7 +37,7 @@ static void SetupAppendBuffer(Interp *iPtr, int newSpace);
* then back up to the result or the error that was previously in progress.
*/
-typedef struct InterpState {
+typedef struct {
int status; /* return code status */
int flags; /* Each remaining field saves the */
int returnLevel; /* corresponding field of the Interp */
@@ -230,6 +232,7 @@ Tcl_DiscardInterpState(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_SaveResult
void
Tcl_SaveResult(
@@ -461,6 +464,7 @@ Tcl_SetResult(
ResetObjResult(iPtr);
}
+#endif /* !TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -483,18 +487,21 @@ const char *
Tcl_GetStringResult(
register Tcl_Interp *interp)/* Interpreter whose result to return. */
{
+ Interp *iPtr = (Interp *) interp;
+#ifdef TCL_NO_DEPRECATED
+ return Tcl_GetString(iPtr->objResultPtr);
+#else
/*
* If the string result is empty, move the object result to the string
* result, then reset the object result.
*/
- Interp *iPtr = (Interp *) interp;
-
if (*(iPtr->result) == 0) {
Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)),
TCL_VOLATILE);
}
return iPtr->result;
+#endif
}
/*
@@ -536,6 +543,7 @@ Tcl_SetObjResult(
TclDecrRefCount(oldObjResult);
+#ifndef TCL_NO_DEPRECATED
/*
* Reset the string result since we just set the result object.
*/
@@ -550,6 +558,7 @@ Tcl_SetObjResult(
}
iPtr->result = iPtr->resultSpace;
iPtr->resultSpace[0] = 0;
+#endif
}
/*
@@ -578,6 +587,7 @@ Tcl_GetObjResult(
Tcl_Interp *interp) /* Interpreter whose result to return. */
{
register Interp *iPtr = (Interp *) interp;
+#ifndef TCL_NO_DEPRECATED
Tcl_Obj *objResultPtr;
int length;
@@ -604,6 +614,7 @@ Tcl_GetObjResult(
iPtr->result = iPtr->resultSpace;
iPtr->result[0] = 0;
}
+#endif /* !TCL_NO_DEPRECATED */
return iPtr->objResultPtr;
}
@@ -722,6 +733,21 @@ Tcl_AppendElement(
* to result. */
{
Interp *iPtr = (Interp *) interp;
+#ifdef TCL_NO_DEPRECATED
+ Tcl_Obj *elementPtr = Tcl_NewStringObj(element, -1);
+ Tcl_Obj *listPtr = Tcl_NewListObj(1, &elementPtr);
+ const char *bytes;
+
+ if (Tcl_IsShared(iPtr->objResultPtr)) {
+ Tcl_SetObjResult(interp, Tcl_DuplicateObj(iPtr->objResultPtr));
+ }
+ bytes = TclGetString(iPtr->objResultPtr);
+ if (TclNeedSpace(bytes, bytes+iPtr->objResultPtr->length)) {
+ Tcl_AppendToObj(iPtr->objResultPtr, " ", 1);
+ }
+ Tcl_AppendObjToObj(iPtr->objResultPtr, listPtr);
+ Tcl_DecrRefCount(listPtr);
+#else
char *dst;
int size;
int flags;
@@ -765,6 +791,7 @@ Tcl_AppendElement(
flags |= TCL_DONT_QUOTE_HASH;
}
iPtr->appendUsed += Tcl_ConvertElement(element, dst, flags);
+#endif /* !TCL_NO_DEPRECATED */
}
/*
@@ -786,6 +813,7 @@ Tcl_AppendElement(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
static void
SetupAppendBuffer(
Interp *iPtr, /* Interpreter whose result is being set up. */
@@ -846,6 +874,7 @@ SetupAppendBuffer(
Tcl_FreeResult((Tcl_Interp *) iPtr);
iPtr->result = iPtr->appendResult;
}
+#endif /* !TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -875,6 +904,7 @@ Tcl_FreeResult(
{
register Interp *iPtr = (Interp *) interp;
+#ifndef TCL_NO_DEPRECATED
if (iPtr->freeProc != NULL) {
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
@@ -884,6 +914,7 @@ Tcl_FreeResult(
iPtr->freeProc = 0;
}
+#endif /* !TCL_NO_DEPRECATED */
ResetObjResult(iPtr);
}
@@ -913,6 +944,7 @@ Tcl_ResetResult(
register Interp *iPtr = (Interp *) interp;
ResetObjResult(iPtr);
+#ifndef TCL_NO_DEPRECATED
if (iPtr->freeProc != NULL) {
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
@@ -923,6 +955,7 @@ Tcl_ResetResult(
}
iPtr->result = iPtr->resultSpace;
iPtr->resultSpace[0] = 0;
+#endif /* !TCL_NO_DEPRECATED */
if (iPtr->errorCode) {
/* Legacy support */
if (iPtr->flags & ERR_LEGACY_COPY) {
@@ -982,11 +1015,11 @@ ResetObjResult(
Tcl_IncrRefCount(objResultPtr);
iPtr->objResultPtr = objResultPtr;
} else {
- if (objResultPtr->bytes != tclEmptyStringRep) {
+ if (objResultPtr->bytes != &tclEmptyString) {
if (objResultPtr->bytes) {
ckfree(objResultPtr->bytes);
}
- objResultPtr->bytes = tclEmptyStringRep;
+ objResultPtr->bytes = &tclEmptyString;
objResultPtr->length = 0;
}
TclFreeIntRep(objResultPtr);
@@ -1276,10 +1309,8 @@ TclProcessReturn(
Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORINFO],
&valuePtr);
if (valuePtr != NULL) {
- int infoLen;
-
- (void) TclGetStringFromObj(valuePtr, &infoLen);
- if (infoLen) {
+ (void) TclGetString(valuePtr);
+ if (valuePtr->length) {
iPtr->errorInfo = valuePtr;
Tcl_IncrRefCount(iPtr->errorInfo);
iPtr->flags |= ERR_ALREADY_LOGGED;
@@ -1382,13 +1413,11 @@ TclMergeReturnOptions(
Tcl_Obj **keys = GetKeys();
for (; objc > 1; objv += 2, objc -= 2) {
- int optLen;
- const char *opt = TclGetStringFromObj(objv[0], &optLen);
- int compareLen;
- const char *compare =
- TclGetStringFromObj(keys[KEY_OPTIONS], &compareLen);
+ const char *opt = TclGetString(objv[0]);
+ const char *compare = TclGetString(keys[KEY_OPTIONS]);
- if ((optLen == compareLen) && (memcmp(opt, compare, optLen) == 0)) {
+ if ((objv[0]->length == keys[KEY_OPTIONS]->length)
+ && (memcmp(opt, compare, objv[0]->length) == 0)) {
Tcl_DictSearch search;
int done = 0;
Tcl_Obj *keyPtr;
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index f69f6b9..c7fdc5a 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -18,13 +18,6 @@
#include <math.h>
/*
- * Define KILL_OCTAL to suppress interpretation of numbers with leading zero
- * as octal. (Ceterum censeo: numeros octonarios delendos esse.)
- */
-
-#undef KILL_OCTAL
-
-/*
* This code supports (at least hypothetically), IBM, Cray, VAX and IEEE-754
* floating point; of these, only IEEE-754 can represent NaN. IEEE-754 can be
* uniquely determined by radix and by the widths of significand and exponent.
@@ -396,6 +389,9 @@ static Tcl_WideUInt Nokia770Twiddle(Tcl_WideUInt w);
* - TCL_PARSE_SCAN_PREFIXES: ignore the prefixes 0b and 0o that are
* not part of the [scan] command's vocabulary. Use only in
* combination with TCL_PARSE_INTEGER_ONLY.
+ * - TCL_PARSE_BINARY_ONLY: parse only in the binary format, whether
+ * or not a prefix is present that would lead to binary parsing.
+ * Use only in combination with TCL_PARSE_INTEGER_ONLY.
* - TCL_PARSE_OCTAL_ONLY: parse only in the octal format, whether
* or not a prefix is present that would lead to octal parsing.
* Use only in combination with TCL_PARSE_INTEGER_ONLY.
@@ -543,6 +539,20 @@ TclParseNumber(
*/
if (bytes == NULL) {
+ if (interp == NULL && endPtrPtr == NULL) {
+ if (objPtr->typePtr == &tclDictType) {
+ /* A dict can never be a (single) number */
+ return TCL_ERROR;
+ }
+ if (objPtr->typePtr == &tclListType) {
+ int length;
+ /* A list can only be a (single) number if its length == 1 */
+ TclListObjLength(NULL, objPtr, &length);
+ if (length != 1) {
+ return TCL_ERROR;
+ }
+ }
+ }
bytes = TclGetString(objPtr);
}
@@ -627,6 +637,9 @@ TclParseNumber(
acceptPoint = p;
acceptLen = len;
if (c == 'x' || c == 'X') {
+ if (flags & (TCL_PARSE_OCTAL_ONLY|TCL_PARSE_BINARY_ONLY)) {
+ goto endgame;
+ }
state = ZERO_X;
break;
}
@@ -637,6 +650,9 @@ TclParseNumber(
goto zeroo;
}
if (c == 'b' || c == 'B') {
+ if (flags & TCL_PARSE_OCTAL_ONLY) {
+ goto endgame;
+ }
state = ZERO_B;
break;
}
@@ -648,7 +664,7 @@ TclParseNumber(
state = ZERO_O;
break;
}
-#ifdef KILL_OCTAL
+#ifdef TCL_NO_DEPRECATED
goto decimal;
#endif
/* FALLTHROUGH */
@@ -731,7 +747,7 @@ TclParseNumber(
goto endgame;
}
-#ifndef KILL_OCTAL
+#ifndef TCL_NO_DEPRECATED
/*
* Scanned a number with a leading zero that contains an 8, 9,
@@ -870,7 +886,7 @@ TclParseNumber(
* digits.
*/
-#ifdef KILL_OCTAL
+#ifdef TCL_NO_DEPRECATED
decimal:
#endif
acceptState = state;
@@ -3789,7 +3805,7 @@ ShorteningBignumConversion(
--s5;
/*
- * IDEA: It might possibly be a win to fall back to int64
+ * IDEA: It might possibly be a win to fall back to int64_t
* arithmetic here if S < 2**64/10. But it's a win only for
* a fairly narrow range of magnitudes so perhaps not worth
* bothering. We already know that we shorten the
@@ -3954,7 +3970,7 @@ StrictBignumConversion(
* As with the shortening bignum conversion, it's possible at this
* point that we will have reduced the denominator to less than
* 2**64/10, at which point it would be possible to fall back to
- * to int64 arithmetic. But the potential payoff is tremendously
+ * to int64_t arithmetic. But the potential payoff is tremendously
* less - unless we're working in F format - because we know that
* three groups of digits will always suffice for %#.17e, the
* longest format that doesn't introduce empty precision.
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index e3cede6..7c898b7 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -136,7 +136,7 @@ GrowStringBuffer(
char *ptr = NULL;
int attempt;
- if (objPtr->bytes == tclEmptyStringRep) {
+ if (objPtr->bytes == &tclEmptyString) {
objPtr->bytes = NULL;
}
if (flag == 0 || stringPtr->allocated > 0) {
@@ -409,6 +409,15 @@ Tcl_GetCharLength(
int numChars;
/*
+ * Quick, no-shimmer return for short string reps.
+ */
+
+ if ((objPtr->bytes) && (objPtr->length < 2)) {
+ /* 0 bytes -> 0 chars; 1 byte -> 1 char */
+ return objPtr->length;
+ }
+
+ /*
* Optimize the case where we're really dealing with a bytearray object
* without string representation; we don't need to convert to a string to
* perform the get-length operation.
@@ -758,7 +767,7 @@ Tcl_SetObjLength(
/*
* Need to enlarge the buffer.
*/
- if (objPtr->bytes == tclEmptyStringRep) {
+ if (objPtr->bytes == &tclEmptyString) {
objPtr->bytes = ckalloc(length + 1);
} else {
objPtr->bytes = ckrealloc(objPtr->bytes, length + 1);
@@ -864,7 +873,7 @@ Tcl_AttemptSetObjLength(
char *newBytes;
- if (objPtr->bytes == tclEmptyStringRep) {
+ if (objPtr->bytes == &tclEmptyString) {
newBytes = attemptckalloc(length + 1);
} else {
newBytes = attemptckrealloc(objPtr->bytes, length + 1);
@@ -1173,6 +1182,8 @@ Tcl_AppendUnicodeToObj(
* Side effects:
* The string rep of appendObjPtr is appended to the string
* representation of objPtr.
+ * IMPORTANT: This routine does not and MUST NOT shimmer appendObjPtr.
+ * Callers are counting on that.
*
*----------------------------------------------------------------------
*/
@@ -1191,7 +1202,7 @@ Tcl_AppendObjToObj(
* that appending nothing to anything leaves that starting anything...
*/
- if (appendObjPtr->bytes == tclEmptyStringRep) {
+ if (appendObjPtr->bytes == &tclEmptyString) {
return;
}
@@ -1202,7 +1213,7 @@ Tcl_AppendObjToObj(
* information; this is a special-case optimization only.
*/
- if ((TclIsPureByteArray(objPtr) || objPtr->bytes == tclEmptyStringRep)
+ if ((TclIsPureByteArray(objPtr) || objPtr->bytes == &tclEmptyString)
&& TclIsPureByteArray(appendObjPtr)) {
/*
@@ -1659,8 +1670,11 @@ Tcl_AppendFormatToObj(
while (*format != '\0') {
char *end;
- int gotMinus, gotHash, gotZero, gotSpace, gotPlus, sawFlag;
- int width, gotPrecision, precision, useShort, useWide, useBig;
+ int gotMinus = 0, gotHash = 0, gotZero = 0, gotSpace = 0, gotPlus = 0;
+ int width, gotPrecision, precision, sawFlag, useShort = 0, useBig = 0;
+#ifndef TCL_WIDE_INT_IS_LONG
+ int useWide = 0;
+#endif
int newXpg, numChars, allocSegment = 0, segmentLimit, segmentNumBytes;
Tcl_Obj *segment;
Tcl_UniChar ch;
@@ -1736,7 +1750,6 @@ Tcl_AppendFormatToObj(
* Step 2. Set of flags.
*/
- gotMinus = gotHash = gotZero = gotSpace = gotPlus = 0;
sawFlag = 1;
do {
switch (ch) {
@@ -1837,7 +1850,6 @@ Tcl_AppendFormatToObj(
* Step 5. Length modifier.
*/
- useShort = useWide = useBig = 0;
if (ch == 'h') {
useShort = 1;
format += step;
@@ -1854,6 +1866,34 @@ Tcl_AppendFormatToObj(
useWide = 1;
#endif
}
+ } else if (ch == 'I') {
+ if ((format[1] == '6') && (format[2] == '4')) {
+ format += (step + 2);
+ step = Tcl_UtfToUniChar(format, &ch);
+#ifndef TCL_WIDE_INT_IS_LONG
+ useWide = 1;
+#endif
+ } else if ((format[1] == '3') && (format[2] == '2')) {
+ format += (step + 2);
+ step = Tcl_UtfToUniChar(format, &ch);
+ } else {
+ format += step;
+ step = Tcl_UtfToUniChar(format, &ch);
+ }
+ } else if ((ch == 't') || (ch == 'z')) {
+ format += step;
+ step = Tcl_UtfToUniChar(format, &ch);
+#ifndef TCL_WIDE_INT_IS_LONG
+ if (sizeof(size_t) > sizeof(int)) {
+ useWide = 1;
+ }
+#endif
+ } else if ((ch == 'q') ||(ch == 'j')) {
+ format += step;
+ step = Tcl_UtfToUniChar(format, &ch);
+#ifndef TCL_WIDE_INT_IS_LONG
+ useWide = 1;
+#endif
}
format += step;
@@ -1906,6 +1946,7 @@ Tcl_AppendFormatToObj(
}
case 'd':
case 'o':
+ case 'p':
case 'x':
case 'X':
case 'b': {
@@ -1916,11 +1957,17 @@ Tcl_AppendFormatToObj(
mp_int big;
int toAppend, isNegative = 0;
+#ifndef TCL_WIDE_INT_IS_LONG
+ if (ch == 'p') {
+ useWide = 1;
+ }
+#endif
if (useBig) {
if (Tcl_GetBignumFromObj(interp, segment, &big) != TCL_OK) {
goto error;
}
isNegative = (mp_cmp_d(&big, 0) == MP_LT);
+#ifndef TCL_WIDE_INT_IS_LONG
} else if (useWide) {
if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
Tcl_Obj *objPtr;
@@ -1935,6 +1982,7 @@ Tcl_AppendFormatToObj(
Tcl_DecrRefCount(objPtr);
}
isNegative = (w < (Tcl_WideInt) 0);
+#endif
} else if (TclGetLongFromObj(NULL, segment, &l) != TCL_OK) {
if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
Tcl_Obj *objPtr;
@@ -1974,13 +2022,14 @@ Tcl_AppendFormatToObj(
segmentLimit -= 1;
}
- if (gotHash) {
+ if (gotHash || (ch == 'p')) {
switch (ch) {
case 'o':
Tcl_AppendToObj(segment, "0", 1);
segmentLimit -= 1;
precision--;
break;
+ case 'p':
case 'x':
case 'X':
Tcl_AppendToObj(segment, "0x", 2);
@@ -2001,8 +2050,10 @@ Tcl_AppendFormatToObj(
if (useShort) {
pure = Tcl_NewIntObj((int) s);
+#ifndef TCL_WIDE_INT_IS_LONG
} else if (useWide) {
pure = Tcl_NewWideIntObj(w);
+#endif
} else if (useBig) {
pure = Tcl_NewBignumObj(&big);
} else {
@@ -2059,6 +2110,7 @@ Tcl_AppendFormatToObj(
case 'u':
case 'o':
+ case 'p':
case 'x':
case 'X':
case 'b': {
@@ -2085,6 +2137,7 @@ Tcl_AppendFormatToObj(
numDigits++;
us /= base;
}
+#ifndef TCL_WIDE_INT_IS_LONG
} else if (useWide) {
Tcl_WideUInt uw = (Tcl_WideUInt) w;
@@ -2093,6 +2146,7 @@ Tcl_AppendFormatToObj(
numDigits++;
uw /= base;
}
+#endif
} else if (useBig && big.used) {
int leftover = (big.used * DIGIT_BIT) % numBits;
mp_digit mask = (~(mp_digit)0) << (DIGIT_BIT-leftover);
@@ -2448,6 +2502,7 @@ AppendPrintfToObjVA(
case 'u':
case 'd':
case 'o':
+ case 'p':
case 'x':
case 'X':
seekingConversion = 0;
@@ -2461,6 +2516,10 @@ AppendPrintfToObjVA(
Tcl_ListObjAppendElement(NULL, list, Tcl_NewLongObj(
va_arg(argList, long)));
break;
+ case 2:
+ Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(
+ va_arg(argList, Tcl_WideInt)));
+ break;
}
break;
case 'e':
@@ -2489,9 +2548,32 @@ AppendPrintfToObjVA(
gotPrecision = 1;
p++;
break;
- /* TODO: support for wide (and bignum?) arguments */
+ /* TODO: support for bignum arguments */
case 'l':
- size = 1;
+ ++size;
+ p++;
+ break;
+ case 't':
+ case 'z':
+ if (sizeof(size_t) == sizeof(Tcl_WideInt)) {
+ size = 2;
+ }
+ p++;
+ break;
+ case 'j':
+ case 'q':
+ size = 2;
+ p++;
+ break;
+ case 'I':
+ if (p[1]=='6' && p[2]=='4') {
+ p += 2;
+ size = 2;
+ } else if (p[1]=='3' && p[2]=='2') {
+ p += 2;
+ } else if (sizeof(size_t) == sizeof(Tcl_WideInt)) {
+ size = 2;
+ }
p++;
break;
case 'h':
@@ -2598,6 +2680,616 @@ TclGetStringStorage(
*sizePtr = stringPtr->allocated;
return objPtr->bytes;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclStringRepeat --
+ *
+ * Performs the [string repeat] function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * Writes to *objPtrPtr the address of Tcl_Obj that is concatenation
+ * of count copies of the value in objPtr.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TclStringRepeat(
+ Tcl_Interp *interp,
+ Tcl_Obj *objPtr,
+ int count,
+ Tcl_Obj **objPtrPtr)
+{
+ Tcl_Obj *objResultPtr;
+ int length = 0, unichar = 0, done = 1;
+ int binary = TclIsPureByteArray(objPtr);
+
+ /* assert (count >= 2) */
+
+ /*
+ * Analyze to determine what representation result should be.
+ * GOALS: Avoid shimmering & string rep generation.
+ * Produce pure bytearray when possible.
+ * Error on overflow.
+ */
+
+ if (!binary) {
+ if (objPtr->typePtr == &tclStringType) {
+ String *stringPtr = GET_STRING(objPtr);
+ if (stringPtr->hasUnicode) {
+ unichar = 1;
+ }
+ }
+ }
+
+ if (binary) {
+ /* Result will be pure byte array. Pre-size it */
+ Tcl_GetByteArrayFromObj(objPtr, &length);
+ } else if (unichar) {
+ /* Result will be pure Tcl_UniChar array. Pre-size it. */
+ Tcl_GetUnicodeFromObj(objPtr, &length);
+ } else {
+ /* Result will be concat of string reps. Pre-size it. */
+ Tcl_GetStringFromObj(objPtr, &length);
+ }
+
+ if (length == 0) {
+ /* Any repeats of empty is empty. */
+ *objPtrPtr = objPtr;
+ return TCL_OK;
+ }
+
+ if (count > INT_MAX/length) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+
+ if (binary) {
+ /* Efficiently produce a pure byte array result */
+ objResultPtr = Tcl_IsShared(objPtr) ? Tcl_DuplicateObj(objPtr)
+ : objPtr;
+
+ Tcl_SetByteArrayLength(objResultPtr, count*length); /* PANIC? */
+ Tcl_SetByteArrayLength(objResultPtr, length);
+ while (count - done > done) {
+ Tcl_AppendObjToObj(objResultPtr, objResultPtr);
+ done *= 2;
+ }
+ TclAppendBytesToByteArray(objResultPtr,
+ Tcl_GetByteArrayFromObj(objResultPtr, NULL),
+ (count - done) * length);
+ } else if (unichar) {
+ /* Efficiently produce a pure Tcl_UniChar array result */
+ if (Tcl_IsShared(objPtr)) {
+ objResultPtr = Tcl_NewUnicodeObj(Tcl_GetUnicode(objPtr), length);
+ } else {
+ TclInvalidateStringRep(objPtr);
+ objResultPtr = objPtr;
+ }
+
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "string size overflow: unable to alloc %"
+ TCL_LL_MODIFIER "d bytes",
+ (Tcl_WideUInt)STRING_SIZE(count*length)));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_SetObjLength(objResultPtr, length);
+ while (count - done > done) {
+ Tcl_AppendObjToObj(objResultPtr, objResultPtr);
+ done *= 2;
+ }
+ Tcl_AppendUnicodeToObj(objResultPtr, Tcl_GetUnicode(objResultPtr),
+ (count - done) * length);
+ } else {
+ /* Efficiently concatenate string reps */
+ if (Tcl_IsShared(objPtr)) {
+ objResultPtr = Tcl_NewStringObj(Tcl_GetString(objPtr), length);
+ } else {
+ TclFreeIntRep(objPtr);
+ objResultPtr = objPtr;
+ }
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "string size overflow: unable to alloc %u bytes",
+ count*length));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_SetObjLength(objResultPtr, length);
+ while (count - done > done) {
+ Tcl_AppendObjToObj(objResultPtr, objResultPtr);
+ done *= 2;
+ }
+ Tcl_AppendToObj(objResultPtr, Tcl_GetString(objResultPtr),
+ (count - done) * length);
+ }
+ *objPtrPtr = objResultPtr;
+ return TCL_OK;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclStringCatObjv --
+ *
+ * Performs the [string cat] function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * Writes to *objPtrPtr the address of Tcl_Obj that is concatenation
+ * of all objc values in objv.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TclStringCatObjv(
+ Tcl_Interp *interp,
+ int inPlace,
+ int objc,
+ Tcl_Obj * const objv[],
+ Tcl_Obj **objPtrPtr)
+{
+ Tcl_Obj *objPtr, *objResultPtr, * const *ov;
+ int oc, length = 0, binary = 1, first = 0;
+ int allowUniChar = 1, requestUniChar = 0;
+
+ /* assert (objc >= 2) */
+
+ /*
+ * Analyze to determine what representation result should be.
+ * GOALS: Avoid shimmering & string rep generation.
+ * Produce pure bytearray when possible.
+ * Error on overflow.
+ */
+
+ ov = objv, oc = objc;
+ while (oc-- && (binary || allowUniChar)) {
+ objPtr = *ov++;
+
+ if (objPtr->bytes) {
+ /* Value has a string rep. */
+ if (objPtr->length) {
+ /*
+ * Non-empty string rep. Not a pure bytearray, so we
+ * won't create a pure bytearray
+ */
+ binary = 0;
+ if ((objPtr->typePtr) && (objPtr->typePtr != &tclStringType)) {
+ /* Prevent shimmer of non-string types. */
+ allowUniChar = 0;
+ }
+ }
+ } else {
+ /* assert (objPtr->typePtr != NULL) -- stork! */
+ if (TclIsPureByteArray(objPtr)) {
+ allowUniChar = 0;
+ } else {
+ binary = 0;
+ if (objPtr->typePtr == &tclStringType) {
+ /* Have a pure Unicode value; ask to preserve it */
+ requestUniChar = 1;
+ } else {
+ /* Have another type; prevent shimmer */
+ allowUniChar = 0;
+ }
+ }
+ }
+ }
+
+ if (binary) {
+ /* Result will be pure byte array. Pre-size it */
+ ov = objv; oc = objc;
+ while (oc-- && (length >= 0)) {
+ objPtr = *ov++;
+
+ if (objPtr->bytes == NULL) {
+ int numBytes;
+
+ Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */
+ if (length == 0) {
+ first = objc - oc - 1;
+ }
+ length += numBytes;
+ }
+ }
+ } else if (allowUniChar && requestUniChar) {
+ /* Result will be pure Tcl_UniChar array. Pre-size it. */
+ ov = objv; oc = objc;
+ while (oc-- && (length >= 0)) {
+ objPtr = *ov++;
+
+ if ((objPtr->bytes == NULL) || (objPtr->length)) {
+ int numChars;
+
+ Tcl_GetUnicodeFromObj(objPtr, &numChars); /* PANIC? */
+ if (length == 0) {
+ first = objc - oc - 1;
+ }
+ length += numChars;
+ }
+ }
+ } else {
+ /* Result will be concat of string reps. Pre-size it. */
+ ov = objv; oc = objc;
+ while (oc-- && (length >= 0)) {
+ int numBytes;
+
+ objPtr = *ov++;
+
+ Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */
+ if ((length == 0) && numBytes) {
+ first = objc - oc - 1;
+ }
+ length += numBytes;
+ }
+ }
+
+ if (length < 0) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+
+ if (length == 0) {
+ /* Total length of zero means every value has length zero */
+ *objPtrPtr = objv[0];
+ return TCL_OK;
+ }
+
+ objv += first; objc -= first;
+
+ if (binary) {
+ /* Efficiently produce a pure byte array result */
+ unsigned char *dst;
+
+ /*
+ * Broken interface! Byte array value routines offer no way
+ * to handle failure to allocate enough space. Following
+ * stanza may panic.
+ */
+ if (inPlace && !Tcl_IsShared(*objv)) {
+ int start;
+
+ objResultPtr = *objv++; objc--;
+ Tcl_GetByteArrayFromObj(objResultPtr, &start);
+ dst = Tcl_SetByteArrayLength(objResultPtr, length) + start;
+ } else {
+ objResultPtr = Tcl_NewByteArrayObj(NULL, length);
+ dst = Tcl_SetByteArrayLength(objResultPtr, length);
+ }
+ while (objc--) {
+ Tcl_Obj *objPtr = *objv++;
+
+ if (objPtr->bytes == NULL) {
+ int more;
+ unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
+ memcpy(dst, src, (size_t) more);
+ dst += more;
+ }
+ }
+ } else if (allowUniChar && requestUniChar) {
+ /* Efficiently produce a pure Tcl_UniChar array result */
+ Tcl_UniChar *dst;
+
+ if (inPlace && !Tcl_IsShared(*objv)) {
+ int start;
+
+ objResultPtr = *objv++; objc--;
+
+ /* Ugly interface! Force resize of the unicode array. */
+ Tcl_GetUnicodeFromObj(objResultPtr, &start);
+ Tcl_InvalidateStringRep(objResultPtr);
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "concatenation failed: unable to alloc %"
+ TCL_LL_MODIFIER "d bytes",
+ (Tcl_WideUInt)STRING_SIZE(length)));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ dst = Tcl_GetUnicode(objResultPtr) + start;
+ } else {
+ Tcl_UniChar ch = 0;
+
+ /* Ugly interface! No scheme to init array size. */
+ objResultPtr = Tcl_NewUnicodeObj(&ch, 0); /* PANIC? */
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "concatenation failed: unable to alloc %"
+ TCL_LL_MODIFIER "d bytes",
+ (Tcl_WideUInt)STRING_SIZE(length)));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ dst = Tcl_GetUnicode(objResultPtr);
+ }
+ while (objc--) {
+ Tcl_Obj *objPtr = *objv++;
+
+ if ((objPtr->bytes == NULL) || (objPtr->length)) {
+ int more;
+ Tcl_UniChar *src = Tcl_GetUnicodeFromObj(objPtr, &more);
+ memcpy(dst, src, more * sizeof(Tcl_UniChar));
+ dst += more;
+ }
+ }
+ } else {
+ /* Efficiently concatenate string reps */
+ char *dst;
+
+ if (inPlace && !Tcl_IsShared(*objv)) {
+ int start;
+
+ objResultPtr = *objv++; objc--;
+
+ Tcl_GetStringFromObj(objResultPtr, &start);
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "concatenation failed: unable to alloc %u bytes",
+ length));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ dst = Tcl_GetString(objResultPtr) + start;
+ if (length > start) {
+ TclFreeIntRep(objResultPtr);
+ }
+ } else {
+ objResultPtr = Tcl_NewObj(); /* PANIC? */
+ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "concatenation failed: unable to alloc %u bytes",
+ length));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
+ }
+ dst = Tcl_GetString(objResultPtr);
+ }
+ while (objc--) {
+ Tcl_Obj *objPtr = *objv++;
+
+ if ((objPtr->bytes == NULL) || (objPtr->length)) {
+ int more;
+ char *src = Tcl_GetStringFromObj(objPtr, &more);
+ memcpy(dst, src, (size_t) more);
+ dst += more;
+ }
+ }
+ }
+ *objPtrPtr = objResultPtr;
+ return TCL_OK;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclStringFind --
+ *
+ * Implements the [string first] operation.
+ *
+ * Results:
+ * If needle is found as a substring of haystack, the index of the
+ * first instance of such a find is returned. If needle is not present
+ * as a substring of haystack, -1 is returned.
+ *
+ * Side effects:
+ * needle and haystack may have their Tcl_ObjType changed.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TclStringFind(
+ Tcl_Obj *needle,
+ Tcl_Obj *haystack,
+ int start)
+{
+ int lh, ln = Tcl_GetCharLength(needle);
+
+ if (ln == 0) {
+ /*
+ * We don't find empty substrings. Bizarre!
+ *
+ * TODO: When we one day make this a true substring
+ * finder, change this to "return 0"
+ */
+ return -1;
+ }
+
+ if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
+ unsigned char *end, *try, *bh;
+ unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
+
+ bh = Tcl_GetByteArrayFromObj(haystack, &lh);
+ end = bh + lh;
+
+ try = bh + start;
+ while (try + ln <= end) {
+ try = memchr(try, bn[0], end - try);
+
+ if (try == NULL) {
+ return -1;
+ }
+ if (0 == memcmp(try+1, bn+1, ln-1)) {
+ return (try - bh);
+ }
+ try++;
+ }
+ return -1;
+ }
+
+ lh = Tcl_GetCharLength(haystack);
+ if (haystack->bytes && (lh == haystack->length)) {
+ /* haystack is all single-byte chars */
+
+ if (needle->bytes && (ln == needle->length)) {
+ /* needle is also all single-byte chars */
+ char *found = strstr(haystack->bytes + start, needle->bytes);
+
+ if (found) {
+ return (found - haystack->bytes);
+ } else {
+ return -1;
+ }
+ } else {
+ /*
+ * Cannot find substring with a multi-byte char inside
+ * a string with no multi-byte chars.
+ */
+ return -1;
+ }
+ } else {
+ Tcl_UniChar *try, *end, *uh;
+ Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
+
+ uh = Tcl_GetUnicodeFromObj(haystack, &lh);
+ end = uh + lh;
+
+ try = uh + start;
+ while (try + ln <= end) {
+ if ((*try == *un)
+ && (0 == memcmp(try+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
+ return (try - uh);
+ }
+ try++;
+ }
+ return -1;
+ }
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclStringLast --
+ *
+ * Implements the [string last] operation.
+ *
+ * Results:
+ * If needle is found as a substring of haystack, the index of the
+ * last instance of such a find is returned. If needle is not present
+ * as a substring of haystack, -1 is returned.
+ *
+ * Side effects:
+ * needle and haystack may have their Tcl_ObjType changed.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TclStringLast(
+ Tcl_Obj *needle,
+ Tcl_Obj *haystack,
+ int last)
+{
+ int lh, ln = Tcl_GetCharLength(needle);
+
+ if (ln == 0) {
+ /*
+ * We don't find empty substrings. Bizarre!
+ *
+ * TODO: When we one day make this a true substring
+ * finder, change this to "return 0"
+ */
+ return -1;
+ }
+
+ if (ln > last + 1) {
+ return -1;
+ }
+
+ if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
+ unsigned char *try, *bh;
+ unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
+
+ bh = Tcl_GetByteArrayFromObj(haystack, &lh);
+
+ if (last + 1 > lh) {
+ last = lh - 1;
+ }
+ try = bh + last + 1 - ln;
+ while (try >= bh) {
+ if ((*try == bn[0])
+ && (0 == memcmp(try+1, bn+1, ln-1))) {
+ return (try - bh);
+ }
+ try--;
+ }
+ return -1;
+ }
+
+ lh = Tcl_GetCharLength(haystack);
+ if (last + 1 > lh) {
+ last = lh - 1;
+ }
+ if (haystack->bytes && (lh == haystack->length)) {
+ /* haystack is all single-byte chars */
+
+ if (needle->bytes && (ln == needle->length)) {
+ /* needle is also all single-byte chars */
+
+ char *try = haystack->bytes + last + 1 - ln;
+ while (try >= haystack->bytes) {
+ if ((*try == needle->bytes[0])
+ && (0 == memcmp(try+1, needle->bytes + 1, ln - 1))) {
+ return (try - haystack->bytes);
+ }
+ try--;
+ }
+ return -1;
+ } else {
+ /*
+ * Cannot find substring with a multi-byte char inside
+ * a string with no multi-byte chars.
+ */
+ return -1;
+ }
+ } else {
+ Tcl_UniChar *try, *uh;
+ Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
+
+ uh = Tcl_GetUnicodeFromObj(haystack, &lh);
+
+ try = uh + last + 1 - ln;
+ while (try >= uh) {
+ if ((*try == un[0])
+ && (0 == memcmp(try+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
+ return (try - uh);
+ }
+ try--;
+ }
+ return -1;
+ }
+}
+
/*
*---------------------------------------------------------------------------
*
@@ -2948,8 +3640,18 @@ UpdateStringOfString(
{
String *stringPtr = GET_STRING(objPtr);
+ /*
+ * This routine is only called when we need to generate the
+ * string rep objPtr->bytes because it does not exist -- it is NULL.
+ * In that circumstance, any lingering claim about the size of
+ * memory pointed to by that NULL pointer is clearly bogus, and
+ * needs a reset.
+ */
+
+ stringPtr->allocated = 0;
+
if (stringPtr->numChars == 0) {
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
+ TclInitStringRep(objPtr, &tclEmptyString, 0);
} else {
(void) ExtendStringRepWithUnicode(objPtr, stringPtr->unicode,
stringPtr->numChars);
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index db6f7e4..1ef1957 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -72,17 +72,17 @@ typedef struct {
do { \
if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
Tcl_Panic("max length for a Tcl unicode value (%d chars) exceeded", \
- STRING_MAXCHARS); \
+ (int)STRING_MAXCHARS); \
} \
} while (0)
#define stringAttemptAlloc(numChars) \
- (String *) attemptckalloc((unsigned) STRING_SIZE(numChars))
+ (String *) attemptckalloc(STRING_SIZE(numChars))
#define stringAlloc(numChars) \
- (String *) ckalloc((unsigned) STRING_SIZE(numChars))
+ (String *) ckalloc(STRING_SIZE(numChars))
#define stringRealloc(ptr, numChars) \
- (String *) ckrealloc((ptr), (unsigned) STRING_SIZE(numChars))
+ (String *) ckrealloc((ptr), STRING_SIZE(numChars))
#define stringAttemptRealloc(ptr, numChars) \
- (String *) attemptckrealloc((ptr), (unsigned) STRING_SIZE(numChars))
+ (String *) attemptckrealloc((ptr), STRING_SIZE(numChars))
#define GET_STRING(objPtr) \
((String *) (objPtr)->internalRep.twoPtrValue.ptr1)
#define SET_STRING(objPtr, stringPtr) \
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 5b7a1cd..59325b7 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -41,15 +41,15 @@
#undef Tcl_FindExecutable
#undef TclpGetPid
#undef TclSockMinimumBuffers
-#define TclBackgroundException Tcl_BackgroundException
#undef Tcl_SetIntObj
#undef TclpInetNtoa
#undef TclWinGetServByName
#undef TclWinGetSockOpt
#undef TclWinSetSockOpt
+#undef TclWinNToHS
/* See bug 510001: TclSockMinimumBuffers needs plat imp */
-#ifdef _WIN64
+#if defined(_WIN64) || defined(TCL_NO_DEPRECATED)
# define TclSockMinimumBuffersOld 0
#else
#define TclSockMinimumBuffersOld sockMinimumBuffersOld
@@ -59,6 +59,17 @@ static int TclSockMinimumBuffersOld(int sock, int size)
}
#endif
+#if defined(TCL_NO_DEPRECATED)
+# define TclSetStartupScriptPath 0
+# define TclGetStartupScriptPath 0
+# define TclSetStartupScriptFileName 0
+# define TclGetStartupScriptFileName 0
+# define TclpInetNtoa 0
+# define TclWinGetServByName 0
+# define TclWinGetSockOpt 0
+# define TclWinSetSockOpt 0
+# define TclWinNToHS 0
+#else
#define TclSetStartupScriptPath setStartupScriptPath
static void TclSetStartupScriptPath(Tcl_Obj *path)
{
@@ -92,6 +103,7 @@ static unsigned short TclWinNToHS(unsigned short ns) {
return ntohs(ns);
}
#endif
+#endif /* TCL_NO_DEPRECATED */
#ifdef _WIN32
# define TclUnixWaitForFile 0
@@ -287,12 +299,102 @@ static int formatInt(char *buffer, int n){
}
#define TclFormatInt (int(*)(char *, long))formatInt
-#endif
+#endif /* TCL_WIDE_INT_IS_LONG */
+
+#endif /* __CYGWIN__ */
-#else /* UNIX and MAC */
+#ifdef TCL_NO_DEPRECATED
+# define Tcl_SeekOld 0
+# define Tcl_TellOld 0
+# undef Tcl_SetBooleanObj
+# define Tcl_SetBooleanObj 0
+# undef Tcl_PkgPresent
+# define Tcl_PkgPresent 0
+# undef Tcl_PkgProvide
+# define Tcl_PkgProvide 0
+# undef Tcl_PkgRequire
+# define Tcl_PkgRequire 0
+# undef Tcl_GetIndexFromObj
+# define Tcl_GetIndexFromObj 0
+# define Tcl_NewBooleanObj 0
+# undef Tcl_DbNewBooleanObj
+# define Tcl_DbNewBooleanObj 0
+# undef Tcl_SetBooleanObj
+# define Tcl_SetBooleanObj 0
+# undef Tcl_SetVar
+# define Tcl_SetVar 0
+# undef Tcl_UnsetVar
+# define Tcl_UnsetVar 0
+# undef Tcl_GetVar
+# define Tcl_GetVar 0
+# undef Tcl_TraceVar
+# define Tcl_TraceVar 0
+# undef Tcl_UntraceVar
+# define Tcl_UntraceVar 0
+# undef Tcl_VarTraceInfo
+# define Tcl_VarTraceInfo 0
+# undef Tcl_UpVar
+# define Tcl_UpVar 0
+# undef Tcl_AddErrorInfo
+# define Tcl_AddErrorInfo 0
+# undef Tcl_AddObjErrorInfo
+# define Tcl_AddObjErrorInfo 0
+# undef Tcl_Eval
+# define Tcl_Eval 0
+# undef Tcl_GlobalEval
+# define Tcl_GlobalEval 0
+# undef Tcl_SaveResult
+# define Tcl_SaveResult 0
+# undef Tcl_RestoreResult
+# define Tcl_RestoreResult 0
+# undef Tcl_DiscardResult
+# define Tcl_DiscardResult 0
+# undef Tcl_SetResult
+# define Tcl_SetResult 0
+# undef Tcl_EvalObj
+# define Tcl_EvalObj 0
+# undef Tcl_GlobalEvalObj
+# define Tcl_GlobalEvalObj 0
+# define TclBackgroundException 0
+# undef TclpReaddir
+# define TclpReaddir 0
+# undef TclpGetDate
+# define TclpGetDate 0
+# undef TclpLocaltime
+# define TclpLocaltime 0
+# undef TclpGmtime
+# define TclpGmtime 0
+# define TclpLocaltime_unix 0
+# define TclpGmtime_unix 0
+#else /* TCL_NO_DEPRECATED */
+# define Tcl_SeekOld seekOld
+# define Tcl_TellOld tellOld
+# define TclBackgroundException Tcl_BackgroundException
# define TclpLocaltime_unix TclpLocaltime
# define TclpGmtime_unix TclpGmtime
-#endif
+
+static int
+seekOld(
+ Tcl_Channel chan, /* The channel on which to seek. */
+ int offset, /* Offset to seek to. */
+ int mode) /* Relative to which location to seek? */
+{
+ Tcl_WideInt wOffset, wResult;
+
+ wOffset = Tcl_LongAsWide((long) offset);
+ wResult = Tcl_Seek(chan, wOffset, mode);
+ return (int) Tcl_WideAsLong(wResult);
+}
+
+static int
+tellOld(
+ Tcl_Channel chan) /* The channel to return pos for. */
+{
+ Tcl_WideInt wResult = Tcl_Tell(chan);
+
+ return (int) Tcl_WideAsLong(wResult);
+}
+#endif /* !TCL_NO_DEPRECATED */
/*
* WARNING: The contents of this file is automatically generated by the
@@ -749,6 +851,7 @@ const TclTomMathStubs tclTomMathStubs = {
TclBNInitBignumFromLong, /* 64 */
TclBNInitBignumFromWideInt, /* 65 */
TclBNInitBignumFromWideUInt, /* 66 */
+ TclBN_mp_expt_d_ex, /* 67 */
};
static const TclStubHooks tclStubHooks = {
@@ -1415,6 +1518,7 @@ const TclStubs tclStubs = {
Tcl_FindSymbol, /* 628 */
Tcl_FSUnloadFile, /* 629 */
Tcl_ZlibStreamSetCompressionDictionary, /* 630 */
+ Tcl_OpenTcpServerEx, /* 631 */
};
/* !END!: Do not edit above this line. */
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index afabdca..5261591 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -67,7 +67,7 @@ Tcl_InitStubs(
if (!stubsPtr || (stubsPtr->magic != (((exact&0xff00) >= 0x900) ? magic : TCL_STUB_MAGIC))) {
iPtr->result = (char *)"interpreter uses an incompatible stubs mechanism";
- iPtr->freeProc = TCL_STATIC;
+ iPtr->freeProc = 0;
return NULL;
}
@@ -101,12 +101,16 @@ Tcl_InitStubs(
}
}
}
- tclStubsPtr = (TclStubs *)pkgData;
+ if (((exact&0xff00) < 0x900)) {
+ /* We are running Tcl 8.x */
+ stubsPtr = (TclStubs *)pkgData;
+ }
+ tclStubsPtr = stubsPtr;
- if (tclStubsPtr->hooks) {
- tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
- tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
- tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
+ if (stubsPtr->hooks) {
+ tclPlatStubsPtr = stubsPtr->hooks->tclPlatStubs;
+ tclIntStubsPtr = stubsPtr->hooks->tclIntStubs;
+ tclIntPlatStubsPtr = stubsPtr->hooks->tclIntPlatStubs;
} else {
tclPlatStubsPtr = NULL;
tclIntStubsPtr = NULL;
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 47d85e1..547dc9a 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -67,6 +67,18 @@ typedef struct TestAsyncHandler {
/* Next is list of handlers. */
} TestAsyncHandler;
+/*
+ * Start of the socket driver state structure to acces field testFlags
+ */
+
+typedef struct TcpState TcpState;
+
+struct TcpState {
+ Tcl_Channel channel; /* Channel associated with this socket. */
+ int testFlags; /* bit field for tests. Is set by testsocket
+ * test procedure */
+};
+
TCL_DECLARE_MUTEX(asyncTestMutex)
static TestAsyncHandler *firstHandler = NULL;
@@ -90,7 +102,7 @@ static Tcl_Trace cmdTrace;
* TestdelCmd:
*/
-typedef struct DelCmd {
+typedef struct {
Tcl_Interp *interp; /* Interpreter in which command exists. */
char *deleteCmd; /* Script to execute when command is deleted.
* Malloc'ed. */
@@ -101,7 +113,7 @@ typedef struct DelCmd {
* command.
*/
-typedef struct TclEncoding {
+typedef struct {
Tcl_Interp *interp;
char *toUtfCmd;
char *fromUtfCmd;
@@ -124,7 +136,7 @@ static int exitMainLoop = 0;
* Event structure used in testing the event queue management procedures.
*/
-typedef struct TestEvent {
+typedef struct {
Tcl_Event header; /* Header common to all events */
Tcl_Interp *interp; /* Interpreter that will handle the event */
Tcl_Obj *command; /* Command to evaluate when the event occurs */
@@ -290,12 +302,14 @@ static int TestlinkCmd(ClientData dummy,
static int TestlocaleCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+#ifndef TCL_NO_DEPRECATED
static int TestMathFunc(ClientData clientData,
Tcl_Interp *interp, Tcl_Value *args,
Tcl_Value *resultPtr);
static int TestMathFunc2(ClientData clientData,
Tcl_Interp *interp, Tcl_Value *args,
Tcl_Value *resultPtr);
+#endif /* TCL_NO_DEPRECATED */
static int TestmainthreadCmd(ClientData dummy,
Tcl_Interp *interp, int argc, const char **argv);
static int TestsetmainloopCmd(ClientData dummy,
@@ -318,6 +332,9 @@ static int TestparsevarnameObjCmd(ClientData dummy,
static int TestpreferstableObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+static int TestprintObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static int TestregexpObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -326,12 +343,10 @@ static int TestreturnObjCmd(ClientData dummy,
Tcl_Obj *const objv[]);
static void TestregexpXflags(const char *string,
int length, int *cflagsPtr, int *eflagsPtr);
-#ifndef TCL_NO_DEPRECATED
static int TestsaveresultCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static void TestsaveresultFree(char *blockPtr);
-#endif /* TCL_NO_DEPRECATED */
static int TestsetassocdataCmd(ClientData dummy,
Tcl_Interp *interp, int argc, const char **argv);
static int TestsetCmd(ClientData dummy,
@@ -361,6 +376,8 @@ static int TestChannelCmd(ClientData clientData,
Tcl_Interp *interp, int argc, const char **argv);
static int TestChannelEventCmd(ClientData clientData,
Tcl_Interp *interp, int argc, const char **argv);
+static int TestSocketCmd(ClientData clientData,
+ Tcl_Interp *interp, int argc, const char **argv);
static int TestFilesystemObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -541,10 +558,10 @@ Tcltest_Init(
"-appinitprocclosestderr", "-appinitprocsetrcfile", NULL
};
- if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
- if (Tcl_TomMath_InitStubs(interp, "8.5") == NULL) {
+ if (Tcl_TomMath_InitStubs(interp, "8.5-") == NULL) {
return TCL_ERROR;
}
if (Tcl_OOInitStubs(interp) == NULL) {
@@ -552,7 +569,7 @@ Tcltest_Init(
}
/* TIP #268: Full patchlevel instead of just major.minor */
- if (Tcl_PkgProvide(interp, "Tcltest", TCL_PATCH_LEVEL) == TCL_ERROR) {
+ if (Tcl_PkgProvideEx(interp, "Tcltest", TCL_PATCH_LEVEL, NULL) == TCL_ERROR) {
return TCL_ERROR;
}
@@ -649,14 +666,14 @@ Tcltest_Init(
NULL, NULL);
Tcl_CreateObjCommand(interp, "testpreferstable", TestpreferstableObjCmd,
NULL, NULL);
+ Tcl_CreateObjCommand(interp, "testprint", TestprintObjCmd,
+ NULL, NULL);
Tcl_CreateObjCommand(interp, "testregexp", TestregexpObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testreturn", TestreturnObjCmd,
NULL, NULL);
-#ifndef TCL_NO_DEPRECATED
Tcl_CreateObjCommand(interp, "testsaveresult", TestsaveresultCmd,
NULL, NULL);
-#endif /* TCL_NO_DEPRECATED */
Tcl_CreateCommand(interp, "testsetassocdata", TestsetassocdataCmd,
NULL, NULL);
Tcl_CreateCommand(interp, "testsetnoerr", TestsetCmd,
@@ -673,6 +690,8 @@ Tcltest_Init(
TestNumUtfCharsCmd, NULL, NULL);
Tcl_CreateCommand(interp, "testsetplatform", TestsetplatformCmd,
NULL, NULL);
+ Tcl_CreateCommand(interp, "testsocket", TestSocketCmd,
+ NULL, NULL);
Tcl_CreateCommand(interp, "teststaticpkg", TeststaticpkgCmd,
NULL, NULL);
Tcl_CreateCommand(interp, "testtranslatefilename",
@@ -781,7 +800,7 @@ int
Tcltest_SafeInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
- if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
return Procbodytest_SafeInit(interp);
@@ -818,7 +837,7 @@ TestasyncCmd(
if (argc < 2) {
wrongNumArgs:
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_AppendResult(interp, "wrong # args", NULL);
return TCL_ERROR;
}
if (strcmp(argv[1], "create") == 0) {
@@ -908,7 +927,7 @@ TestasyncCmd(
if (Tcl_CreateThread(&threadID, AsyncThreadProc,
INT2PTR(id), TCL_THREAD_STACK_DEFAULT,
TCL_THREAD_NOFLAGS) != TCL_OK) {
- Tcl_SetResult(interp, "can't create thread", TCL_STATIC);
+ Tcl_AppendResult(interp, "can't create thread", NULL);
Tcl_MutexUnlock(&asyncTestMutex);
return TCL_ERROR;
}
@@ -1055,7 +1074,7 @@ TestcmdinfoCmd(
Tcl_DStringResult(interp, &delString);
} else if (strcmp(argv[1], "get") == 0) {
if (Tcl_GetCommandInfo(interp, argv[2], &info) ==0) {
- Tcl_SetResult(interp, "??", TCL_STATIC);
+ Tcl_AppendResult(interp, "??", NULL);
return TCL_OK;
}
if (info.proc == CmdProc1) {
@@ -1182,7 +1201,7 @@ TestcmdtokenCmd(
token = Tcl_CreateCommand(interp, argv[2], CmdProc1,
(ClientData) "original", NULL);
sprintf(buf, "%p", (void *)token);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_AppendResult(interp, buf, NULL);
} else if (strcmp(argv[1], "name") == 0) {
Tcl_Obj *objPtr;
@@ -1288,7 +1307,7 @@ TestcmdtraceCmd(
result = Tcl_EvalEx(interp, argv[2], -1, 0);
Tcl_DeleteTrace(interp, cmdTrace);
if (!deleteCalled) {
- Tcl_SetResult(interp, "Delete wasn't called", TCL_STATIC);
+ Tcl_AppendResult(interp, "Delete wasn't called", NULL);
return TCL_ERROR;
} else {
return result;
@@ -1588,7 +1607,7 @@ TestdelCmd(
Tcl_Interp *slave;
if (argc != 4) {
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_AppendResult(interp, "wrong # args", NULL);
return TCL_ERROR;
}
@@ -1793,7 +1812,7 @@ TestdstringCmd(
if (argc < 2) {
wrongNumArgs:
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_AppendResult(interp, "wrong # args", NULL);
return TCL_ERROR;
}
if (strcmp(argv[1], "append") == 0) {
@@ -1829,9 +1848,9 @@ TestdstringCmd(
goto wrongNumArgs;
}
if (strcmp(argv[2], "staticsmall") == 0) {
- Tcl_SetResult(interp, "short", TCL_STATIC);
+ Tcl_AppendResult(interp, "short", NULL);
} else if (strcmp(argv[2], "staticlarge") == 0) {
- Tcl_SetResult(interp, "first0 first1 first2 first3 first4 first5 first6 first7 first8 first9\nsecond0 second1 second2 second3 second4 second5 second6 second7 second8 second9\nthird0 third1 third2 third3 third4 third5 third6 third7 third8 third9\nfourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9\nfifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9\nsixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9\nseventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9\n", TCL_STATIC);
+ Tcl_AppendResult(interp, "first0 first1 first2 first3 first4 first5 first6 first7 first8 first9\nsecond0 second1 second2 second3 second4 second5 second6 second7 second8 second9\nthird0 third1 third2 third3 third4 third5 third6 third7 third8 third9\nfourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9\nfifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9\nsixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9\nseventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9\n", NULL);
} else if (strcmp(argv[2], "free") == 0) {
char *s = ckalloc(100);
strcpy(s, "This is a malloc-ed string");
@@ -1991,7 +2010,7 @@ EncodingToUtfProc(
TclEncoding *encodingPtr;
encodingPtr = (TclEncoding *) clientData;
- Tcl_EvalEx(encodingPtr->interp,encodingPtr->toUtfCmd,-1,TCL_EVAL_GLOBAL);
+ Tcl_EvalEx(encodingPtr->interp, encodingPtr->toUtfCmd, -1, TCL_EVAL_GLOBAL);
len = strlen(Tcl_GetStringResult(encodingPtr->interp));
if (len > dstLen) {
@@ -2023,7 +2042,7 @@ EncodingFromUtfProc(
TclEncoding *encodingPtr;
encodingPtr = (TclEncoding *) clientData;
- Tcl_EvalEx(encodingPtr->interp, encodingPtr->fromUtfCmd,-1,TCL_EVAL_GLOBAL);
+ Tcl_EvalEx(encodingPtr->interp, encodingPtr->fromUtfCmd, -1, TCL_EVAL_GLOBAL);
len = strlen(Tcl_GetStringResult(encodingPtr->interp));
if (len > dstLen) {
@@ -2431,7 +2450,7 @@ TestexprlongCmd(
" expression\"", NULL);
return TCL_ERROR;
}
- Tcl_SetResult(interp, "This is a result", TCL_STATIC);
+ Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLong(interp, argv[1], &exprResult);
if (result != TCL_OK) {
return result;
@@ -2473,7 +2492,7 @@ TestexprlongobjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "expression");
return TCL_ERROR;
}
- Tcl_SetResult(interp, "This is a result", TCL_STATIC);
+ Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprLongObj(interp, objv[1], &exprResult);
if (result != TCL_OK) {
return result;
@@ -2516,7 +2535,7 @@ TestexprdoubleCmd(
" expression\"", NULL);
return TCL_ERROR;
}
- Tcl_SetResult(interp, "This is a result", TCL_STATIC);
+ Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprDouble(interp, argv[1], &exprResult);
if (result != TCL_OK) {
return result;
@@ -2559,7 +2578,7 @@ TestexprdoubleobjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "expression");
return TCL_ERROR;
}
- Tcl_SetResult(interp, "This is a result", TCL_STATIC);
+ Tcl_AppendResult(interp, "This is a result", NULL);
result = Tcl_ExprDoubleObj(interp, objv[1], &exprResult);
if (result != TCL_OK) {
return result;
@@ -3336,6 +3355,7 @@ TestlocaleCmd(
*/
/* ARGSUSED */
+#ifndef TCL_NO_DEPRECATED
static int
TestMathFunc(
ClientData clientData, /* Integer value to return. */
@@ -3401,7 +3421,7 @@ TestMathFunc2(
resultPtr->type = TCL_WIDE_INT;
resultPtr->wideValue = ((w0 > w1)? w0 : w1);
} else {
- Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
+ Tcl_AppendResult(interp, "T3: wrong type for arg 2", NULL);
result = TCL_ERROR;
}
} else if (args[0].type == TCL_DOUBLE) {
@@ -3423,7 +3443,7 @@ TestMathFunc2(
resultPtr->type = TCL_DOUBLE;
resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
} else {
- Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
+ Tcl_AppendResult(interp, "T3: wrong type for arg 2", NULL);
result = TCL_ERROR;
}
} else if (args[0].type == TCL_WIDE_INT) {
@@ -3446,15 +3466,16 @@ TestMathFunc2(
resultPtr->type = TCL_WIDE_INT;
resultPtr->wideValue = ((w0 > w1)? w0 : w1);
} else {
- Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
+ Tcl_AppendResult(interp, "T3: wrong type for arg 2", NULL);
result = TCL_ERROR;
}
} else {
- Tcl_SetResult(interp, "T3: wrong type for arg 1", TCL_STATIC);
+ Tcl_AppendResult(interp, "T3: wrong type for arg 1", NULL);
result = TCL_ERROR;
}
return result;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -3820,6 +3841,45 @@ TestpreferstableObjCmd(
/*
*----------------------------------------------------------------------
*
+ * TestprintObjCmd --
+ *
+ * This procedure implements the "testprint" command. It is
+ * used for being able to test the Tcl_ObjPrintf() function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TestprintObjCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* The argument objects. */
+{
+ Tcl_WideInt argv1 = 0;
+ size_t argv2;
+
+ if (objc < 2 || objc > 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "format wideint");
+ }
+
+ if (objc > 1) {
+ Tcl_GetWideIntFromObj(interp, objv[2], &argv1);
+ }
+ argv2 = (size_t)argv1;
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1, argv2, argv2));
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TestregexpObjCmd --
*
* This procedure implements the "testregexp" command. It is used to give
@@ -4444,7 +4504,7 @@ TestseterrorcodeCmd(
const char **argv) /* Argument strings. */
{
if (argc > 6) {
- Tcl_SetResult(interp, "too many args", TCL_STATIC);
+ Tcl_AppendResult(interp, "too many args", NULL);
return TCL_ERROR;
}
switch (argc) {
@@ -4597,7 +4657,7 @@ TestpanicCmd(
int argc, /* Number of arguments. */
const char **argv) /* Argument strings. */
{
- const char *argString;
+ char *argString;
/*
* Put the arguments into a var args structure
@@ -5048,7 +5108,7 @@ TestsetCmd(
const char *value;
if (argc == 2) {
- Tcl_SetResult(interp, "before get", TCL_STATIC);
+ Tcl_AppendResult(interp, "before get", NULL);
value = Tcl_GetVar2(interp, argv[1], NULL, flags);
if (value == NULL) {
return TCL_ERROR;
@@ -5056,7 +5116,7 @@ TestsetCmd(
Tcl_AppendElement(interp, value);
return TCL_OK;
} else if (argc == 3) {
- Tcl_SetResult(interp, "before set", TCL_STATIC);
+ Tcl_AppendResult(interp, "before set", NULL);
value = Tcl_SetVar2(interp, argv[1], NULL, argv[2], flags);
if (value == NULL) {
return TCL_ERROR;
@@ -5080,7 +5140,7 @@ Testset2Cmd(
const char *value;
if (argc == 3) {
- Tcl_SetResult(interp, "before get", TCL_STATIC);
+ Tcl_AppendResult(interp, "before get", NULL);
value = Tcl_GetVar2(interp, argv[1], argv[2], flags);
if (value == NULL) {
return TCL_ERROR;
@@ -5088,7 +5148,7 @@ Testset2Cmd(
Tcl_AppendElement(interp, value);
return TCL_OK;
} else if (argc == 4) {
- Tcl_SetResult(interp, "before set", TCL_STATIC);
+ Tcl_AppendResult(interp, "before set", NULL);
value = Tcl_SetVar2(interp, argv[1], argv[2], argv[3], flags);
if (value == NULL) {
return TCL_ERROR;
@@ -5102,7 +5162,6 @@ Testset2Cmd(
}
}
-#ifndef TCL_NO_DEPRECATED
/*
*----------------------------------------------------------------------
*
@@ -5155,10 +5214,11 @@ TestsaveresultCmd(
return TCL_ERROR;
}
+ freeCount = 0;
objPtr = NULL; /* Lint. */
switch ((enum options) index) {
case RESULT_SMALL:
- Tcl_SetResult(interp, "small result", TCL_VOLATILE);
+ Tcl_AppendResult(interp, "small result", NULL);
break;
case RESULT_APPEND:
Tcl_AppendResult(interp, "append result", NULL);
@@ -5179,7 +5239,6 @@ TestsaveresultCmd(
break;
}
- freeCount = 0;
Tcl_SaveResult(interp, &state);
if (((enum options) index) == RESULT_OBJECT) {
@@ -5197,11 +5256,9 @@ TestsaveresultCmd(
switch ((enum options) index) {
case RESULT_DYNAMIC: {
- int present = iPtr->freeProc == TestsaveresultFree;
- int called = freeCount;
+ int presentOrFreed = (iPtr->freeProc == TestsaveresultFree) ^ freeCount;
- Tcl_AppendElement(interp, called ? "called" : "notCalled");
- Tcl_AppendElement(interp, present ? "present" : "missing");
+ Tcl_AppendElement(interp, presentOrFreed ? "presentOrFreed" : "missingOrLeak");
break;
}
case RESULT_OBJECT:
@@ -5236,7 +5293,6 @@ TestsaveresultFree(
{
freeCount++;
}
-#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -5268,7 +5324,7 @@ TestmainthreadCmd(
Tcl_SetObjResult(interp, idObj);
return TCL_OK;
} else {
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_AppendResult(interp, "wrong # args", NULL);
return TCL_ERROR;
}
}
@@ -6041,6 +6097,75 @@ TestChannelEventCmd(
/*
*----------------------------------------------------------------------
*
+ * TestSocketCmd --
+ *
+ * Implements the Tcl "testsocket" debugging command and its
+ * subcommands. This is part of the testing environment.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ /* ARGSUSED */
+static int
+TestSocketCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Interpreter for result. */
+ int argc, /* Count of additional args. */
+ const char **argv) /* Additional arg strings. */
+{
+ const char *cmdName; /* Sub command. */
+ size_t len; /* Length of subcommand string. */
+
+ if (argc < 2) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " subcommand ?additional args..?\"", NULL);
+ return TCL_ERROR;
+ }
+ cmdName = argv[1];
+ len = strlen(cmdName);
+
+ if ((cmdName[0] == 't') && (strncmp(cmdName, "testflags", len) == 0)) {
+ Tcl_Channel hChannel;
+ int modePtr;
+ TcpState *statePtr;
+ /* Set test value in the socket driver
+ */
+ /* Check for argument "channel name"
+ */
+ if (argc < 4) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " testflags channel flags\"", NULL);
+ return TCL_ERROR;
+ }
+ hChannel = Tcl_GetChannel(interp, argv[2], &modePtr);
+ if ( NULL == hChannel ) {
+ Tcl_AppendResult(interp, "unknown channel:", argv[2], NULL);
+ return TCL_ERROR;
+ }
+ statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel);
+ if ( NULL == statePtr) {
+ Tcl_AppendResult(interp, "No channel instance data:", argv[2],
+ NULL);
+ return TCL_ERROR;
+ }
+ statePtr->testFlags = atoi(argv[3]);
+ return TCL_OK;
+ }
+
+ Tcl_AppendResult(interp, "bad option \"", cmdName, "\": should be "
+ "testflags", NULL);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TestWrongNumArgsObjCmd --
*
* Test the Tcl_WrongNumArgs function.
@@ -6069,7 +6194,7 @@ TestWrongNumArgsObjCmd(
* Don't use Tcl_WrongNumArgs here, as that is the function
* we want to test!
*/
- Tcl_SetResult(interp, "insufficient arguments", TCL_STATIC);
+ Tcl_AppendResult(interp, "insufficient arguments", NULL);
return TCL_ERROR;
}
@@ -6086,7 +6211,7 @@ TestWrongNumArgsObjCmd(
/*
* Asked for more arguments than were given.
*/
- Tcl_SetResult(interp, "insufficient arguments", TCL_STATIC);
+ Tcl_AppendResult(interp, "insufficient arguments", NULL);
return TCL_ERROR;
}
@@ -6751,7 +6876,7 @@ TestcpuidCmd(
Tcl_Obj *const * objv) /* Parameter vector */
{
int status, index, i;
- unsigned int regs[4];
+ int regs[4];
Tcl_Obj *regsObjs[4];
if (objc != 2) {
@@ -6761,14 +6886,14 @@ TestcpuidCmd(
if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
return TCL_ERROR;
}
- status = TclWinCPUID((unsigned) index, regs);
+ status = TclWinCPUID(index, regs);
if (status != TCL_OK) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operation not available", -1));
return status;
}
for (i=0 ; i<4 ; ++i) {
- regsObjs[i] = Tcl_NewIntObj((int) regs[i]);
+ regsObjs[i] = Tcl_NewIntObj(regs[i]);
}
Tcl_SetObjResult(interp, Tcl_NewListObj(4, regsObjs));
return TCL_OK;
@@ -6863,7 +6988,7 @@ TestgetintCmd(
const char **argv)
{
if (argc < 2) {
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_AppendResult(interp, "wrong # args", NULL);
return TCL_ERROR;
} else {
int val, i, total=0;
@@ -7387,7 +7512,7 @@ InterpCmdResolver(
*/
CallFrame *parentFramePtr = varFramePtr->callerPtr;
- char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
+ const char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 6053ae3..5627608 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -152,10 +152,11 @@ TestbignumobjCmd(
Tcl_Obj *const objv[]) /* Argument vector */
{
const char *const subcmds[] = {
- "set", "get", "mult10", "div10", NULL
+ "set", "get", "mult10", "div10", "iseven", "radixsize", NULL
};
enum options {
- BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10
+ BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10, BIGNUM_ISEVEN,
+ BIGNUM_RADIXSIZE
};
int index, varIndex;
const char *string;
@@ -274,6 +275,50 @@ TestbignumobjCmd(
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&newValue));
}
+ break;
+
+ case BIGNUM_ISEVEN:
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "varIndex");
+ return TCL_ERROR;
+ }
+ if (CheckIfVarUnset(interp, varPtr,varIndex)) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
+ &bignumValue) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (!Tcl_IsShared(varPtr[varIndex])) {
+ Tcl_SetIntObj(varPtr[varIndex], mp_iseven(&bignumValue));
+ } else {
+ SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(mp_iseven(&bignumValue)));
+ }
+ mp_clear(&bignumValue);
+ break;
+
+ case BIGNUM_RADIXSIZE:
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "varIndex");
+ return TCL_ERROR;
+ }
+ if (CheckIfVarUnset(interp, varPtr,varIndex)) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
+ &bignumValue) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (mp_radix_size(&bignumValue, 10, &index) != MP_OKAY) {
+ return TCL_ERROR;
+ }
+ if (!Tcl_IsShared(varPtr[varIndex])) {
+ Tcl_SetIntObj(varPtr[varIndex], index);
+ } else {
+ SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(index));
+ }
+ mp_clear(&bignumValue);
+ break;
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
@@ -1056,7 +1101,7 @@ TestobjCmd(
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(varPtr[varIndex]->refCount));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(varPtr[varIndex]->refCount));
} else if (strcmp(subCmd, "type") == 0) {
if (objc != 3) {
goto wrongNumArgs;
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c
index 018f006..8077de4 100644
--- a/generic/tclThreadAlloc.c
+++ b/generic/tclThreadAlloc.c
@@ -196,20 +196,11 @@ GetCache(void)
if (listLockPtr == NULL) {
Tcl_Mutex *initLockPtr;
- unsigned int i;
initLockPtr = Tcl_GetAllocMutex();
Tcl_MutexLock(initLockPtr);
if (listLockPtr == NULL) {
- listLockPtr = TclpNewAllocMutex();
- objLockPtr = TclpNewAllocMutex();
- for (i = 0; i < NBUCKETS; ++i) {
- bucketInfo[i].blockSize = MINALLOC << i;
- bucketInfo[i].maxBlocks = 1 << (NBUCKETS - 1 - i);
- bucketInfo[i].numMove = i < NBUCKETS - 1 ?
- 1 << (NBUCKETS - 2 - i) : 1;
- bucketInfo[i].lockPtr = TclpNewAllocMutex();
- }
+ TclInitThreadAlloc();
}
Tcl_MutexUnlock(initLockPtr);
}
@@ -1064,6 +1055,40 @@ GetBlocks(
}
return 1;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclInitThreadAlloc --
+ *
+ * Initializes the allocator cache-maintenance structures.
+ * It is done early and protected during the TclInitSubsystems().
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclInitThreadAlloc(void)
+{
+ unsigned int i;
+
+ listLockPtr = TclpNewAllocMutex();
+ objLockPtr = TclpNewAllocMutex();
+ for (i = 0; i < NBUCKETS; ++i) {
+ bucketInfo[i].blockSize = MINALLOC << i;
+ bucketInfo[i].maxBlocks = 1 << (NBUCKETS - 1 - i);
+ bucketInfo[i].numMove = i < NBUCKETS - 1 ?
+ 1 << (NBUCKETS - 2 - i) : 1;
+ bucketInfo[i].lockPtr = TclpNewAllocMutex();
+ }
+ TclpInitAllocCache();
+}
/*
*----------------------------------------------------------------------
@@ -1106,9 +1131,9 @@ TclFinalizeThreadAlloc(void)
*
* TclFinalizeThreadAllocThread --
*
- * This procedure is used to destroy single thread private resources used
- * in this file.
- * Called in TclpFinalizeThreadData when a thread exits (Tcl_FinalizeThread).
+ * This procedure is used to destroy single thread private resources
+ * defined in this file. Called either during Tcl_FinalizeThread() or
+ * Tcl_Finalize().
*
* Results:
* None.
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index 1a05f80..9c5fecb 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -341,7 +341,7 @@ ThreadObjCmd(
} else if (objc == 3
&& strcmp("-main", Tcl_GetString(objv[2])) == 0) {
Tcl_MutexLock(&threadMutex);
- idObj = Tcl_NewLongObj((long)(size_t)mainThreadId);
+ idObj = Tcl_NewWideIntObj((Tcl_WideInt)(size_t)mainThreadId);
Tcl_MutexUnlock(&threadMutex);
} else {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
@@ -655,7 +655,7 @@ ThreadErrorProc(
char *script;
char buf[TCL_DOUBLE_SPACE+1];
- sprintf(buf, "%" TCL_LL_MODIFIER "d", (Tcl_WideInt)(size_t)Tcl_GetCurrentThread());
+ sprintf(buf, "%p", Tcl_GetCurrentThread());
errorInfo = Tcl_GetVar2(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
if (errorProcString == NULL) {
diff --git a/generic/tclTimer.c b/generic/tclTimer.c
index adc36ce..16003b0 100644
--- a/generic/tclTimer.c
+++ b/generic/tclTimer.c
@@ -1053,11 +1053,17 @@ AfterDelay(
if (diff > TCL_TIME_MAXIMUM_SLICE) {
diff = TCL_TIME_MAXIMUM_SLICE;
}
- if (diff == 0 && TCL_TIME_BEFORE(now, endTime)) diff = 1;
+ if (diff == 0 && TCL_TIME_BEFORE(now, endTime)) {
+ diff = 1;
+ }
if (diff > 0) {
Tcl_Sleep((long) diff);
- if (diff < SLEEP_OFFLOAD_GETTIMEOFDAY) break;
- } else break;
+ if (diff < SLEEP_OFFLOAD_GETTIMEOFDAY) {
+ break;
+ }
+ } else {
+ break;
+ }
} else {
diff = TCL_TIME_DIFF_MS(iPtr->limit.time, now);
#ifndef TCL_WIDE_INT_IS_LONG
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index 610a031..74ccefc 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -90,7 +90,7 @@ declare 21 {
int TclBN_mp_init(mp_int *a)
}
declare 22 {
- int TclBN_mp_init_copy(mp_int *a, mp_int *b)
+ int TclBN_mp_init_copy(mp_int *a, const mp_int *b)
}
declare 23 {
int TclBN_mp_init_multi(mp_int *a, ...)
@@ -129,7 +129,7 @@ declare 34 {
int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c)
}
declare 35 {
- int TclBN_mp_radix_size(mp_int *a, int radix, int *size)
+ int TclBN_mp_radix_size(const mp_int *a, int radix, int *size)
}
declare 36 {
int TclBN_mp_read_radix(mp_int *a, const char *str, int radix)
@@ -233,6 +233,11 @@ declare 66 {
void TclBNInitBignumFromWideUInt(mp_int *bignum, Tcl_WideUInt initVal)
}
+# Added in libtommath 1.0
+declare 67 {
+ int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c, int fast)
+}
+
# Local Variables:
# mode: tcl
# End:
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index dd9edaf..001019c 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -10,7 +10,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef BN_H_
#define BN_H_
@@ -22,33 +22,15 @@
-#ifndef MIN
-# define MIN(x,y) ((x)<(y)?(x):(y))
-#endif
-
-#ifndef MAX
-# define MAX(x,y) ((x)>(y)?(x):(y))
-#endif
-
#ifdef __cplusplus
extern "C" {
-
-/* C++ compilers don't like assigning void * to mp_digit * */
-#define OPT_CAST(x) (x *)
-
-#else
-
-/* C on the other hand doesn't care */
-#define OPT_CAST(x)
-
#endif
-
/* detect 64-bit mode if possible */
-#if defined(NEVER) /* 128-bit ints fail in too many places */
-# if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
-# define MP_64BIT
-# endif
+#if defined(NEVER) /* 128-bit ints fail in too many places */
+ #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
+ #define MP_64BIT
+ #endif
#endif
/* some default configurations.
@@ -61,83 +43,89 @@ extern "C" {
*/
#ifdef MP_8BIT
#ifndef MP_DIGIT_DECLARED
- typedef unsigned char mp_digit;
+ typedef uint8_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
- typedef unsigned short mp_word;
+ typedef uint16_t mp_word;
+#define MP_SIZEOF_MP_DIGIT 1
+#ifdef DIGIT_BIT
+#error You must not define DIGIT_BIT when using MP_8BIT
+#endif
#elif defined(MP_16BIT)
#ifndef MP_DIGIT_DECLARED
- typedef unsigned short mp_digit;
+ typedef uint16_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
- typedef unsigned long mp_word;
+ typedef uint32_t mp_word;
+#define MP_SIZEOF_MP_DIGIT 2
+#ifdef DIGIT_BIT
+#error You must not define DIGIT_BIT when using MP_16BIT
+#endif
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
#ifndef CRYPT
- typedef unsigned long long ulong64;
- typedef signed long long long64;
+ typedef unsigned long long ulong64;
+ typedef signed long long long64;
#endif
#ifndef MP_DIGIT_DECLARED
- typedef unsigned long mp_digit;
+ typedef ulong64 mp_digit;
#define MP_DIGIT_DECLARED
#endif
- typedef unsigned long mp_word __attribute__ ((mode(TI)));
+#if defined(_WIN32)
+ typedef unsigned __int128 mp_word;
+#elif defined(__GNUC__)
+ typedef unsigned long mp_word __attribute__ ((mode(TI)));
+#else
+ /* it seems you have a problem
+ * but we assume you can somewhere define your own uint128_t */
+ typedef uint128_t mp_word;
+#endif
-# define DIGIT_BIT 60
+ #define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
-
+
/* this is to make porting into LibTomCrypt easier :-) */
#ifndef CRYPT
-# if defined(_MSC_VER) || defined(__BORLANDC__)
- typedef unsigned __int64 ulong64;
- typedef signed __int64 long64;
-# else
- typedef unsigned long long ulong64;
- typedef signed long long long64;
-# endif
+ typedef unsigned long long ulong64;
+ typedef signed long long long64;
#endif
#ifndef MP_DIGIT_DECLARED
- typedef unsigned int mp_digit;
+ typedef uint32_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
- typedef ulong64 mp_word;
+ typedef ulong64 mp_word;
-#ifdef MP_31BIT
+#ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
-# define DIGIT_BIT 31
+ #define DIGIT_BIT 31
#else
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
-# define DIGIT_BIT 28
-# define MP_28BIT
-#endif
-#endif
-
-/* define heap macros */
-#if 0 /* these are macros in tclTomMathDecls.h */
-#ifndef CRYPT
- /* default to libc stuff */
-# ifndef XMALLOC
-# define XMALLOC malloc
-# define XFREE free
-# define XREALLOC realloc
-# define XCALLOC calloc
-# else
- /* prototypes for our heap functions */
- extern void *XMALLOC(size_t n);
- extern void *XREALLOC(void *p, size_t n);
- extern void *XCALLOC(size_t n, size_t s);
- extern void XFREE(void *p);
-# endif
+ #define DIGIT_BIT 28
+ #define MP_28BIT
#endif
#endif
-
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT
-# define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */
+ #define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
+ typedef uint_least32_t mp_min_u32;
+#else
+ typedef mp_digit mp_min_u32;
+#endif
+
+/* platforms that can use a better rand function */
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+ #define MP_USE_ALT_RAND 1
+#endif
+
+/* use arc4random on platforms that support it */
+#ifdef MP_USE_ALT_RAND
+ #define MP_GEN_RANDOM() arc4random()
+#else
+ #define MP_GEN_RANDOM() rand()
#endif
#define MP_DIGIT_BIT DIGIT_BIT
@@ -180,15 +168,15 @@ MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
/* default precision */
#ifndef MP_PREC
-# ifndef MP_LOW_MEM
-# define MP_PREC 32 /* default digits of precision */
-# else
-# define MP_PREC 8 /* default digits of precision */
-# endif
+ #ifndef MP_LOW_MEM
+ #define MP_PREC 32 /* default digits of precision */
+ #else
+ #define MP_PREC 8 /* default digits of precision */
+ #endif
#endif
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
+#define MP_WARRAY (1 << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1))
/* the infamous mp_int structure */
#ifndef MP_INT_DECLARED
@@ -209,9 +197,7 @@ typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
#define SIGN(m) ((m)->sign)
/* error code to char* string */
-/*
-char *mp_error_to_string(int code);
-*/
+const char *mp_error_to_string(int code);
/* ---> init and deinit bignum functions <--- */
/* init a bignum */
@@ -256,8 +242,9 @@ int mp_init_size(mp_int *a, int size);
/* ---> Basic Manipulations <--- */
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
-#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
+#define mp_iseven(a) ((((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO)
+#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO)
+#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
/* set to zero */
/*
@@ -274,9 +261,25 @@ void mp_set(mp_int *a, mp_digit b);
int mp_set_int(mp_int *a, unsigned long b);
*/
+/* set a platform dependent unsigned long value */
+/*
+int mp_set_long(mp_int *a, unsigned long b);
+*/
+
+/* set a platform dependent unsigned long long value */
+/*
+int mp_set_long_long(mp_int *a, unsigned long long b);
+*/
+
/* get a 32-bit value */
unsigned long mp_get_int(mp_int * a);
+/* get a platform dependent unsigned long value */
+unsigned long mp_get_long(mp_int * a);
+
+/* get a platform dependent unsigned long long value */
+unsigned long long mp_get_long_long(mp_int * a);
+
/* initialize and set a digit */
/*
int mp_init_set (mp_int * a, mp_digit b);
@@ -294,7 +297,7 @@ int mp_copy(const mp_int *a, mp_int *b);
/* inits and copies, a = b */
/*
-int mp_init_copy(mp_int *a, mp_int *b);
+int mp_init_copy(mp_int *a, const mp_int *b);
*/
/* trim unused digits */
@@ -302,6 +305,16 @@ int mp_init_copy(mp_int *a, mp_int *b);
void mp_clamp(mp_int *a);
*/
+/* import binary data */
+/*
+int mp_import(mp_int* rop, size_t count, int order, size_t size, int endian, size_t nails, const void* op);
+*/
+
+/* export binary data */
+/*
+int mp_export(void* rop, size_t* countp, int order, size_t size, int endian, size_t nails, mp_int* op);
+*/
+
/* ---> digit manipulation <--- */
/* right shift by "b" digits */
@@ -314,7 +327,7 @@ void mp_rshd(mp_int *a, int b);
int mp_lshd(mp_int *a, int b);
*/
-/* c = a / 2**b */
+/* c = a / 2**b, implemented as c = a >> b */
/*
int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
*/
@@ -324,7 +337,7 @@ int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
int mp_div_2(mp_int *a, mp_int *b);
*/
-/* c = a * 2**b */
+/* c = a * 2**b, implemented as c = a << b */
/*
int mp_mul_2d(const mp_int *a, int b, mp_int *c);
*/
@@ -334,7 +347,7 @@ int mp_mul_2d(const mp_int *a, int b, mp_int *c);
int mp_mul_2(mp_int *a, mp_int *b);
*/
-/* c = a mod 2**d */
+/* c = a mod 2**b */
/*
int mp_mod_2d(const mp_int *a, int b, mp_int *c);
*/
@@ -346,7 +359,7 @@ int mp_2expt(mp_int *a, int b);
/* Counts the number of lsbs which are zero before the first zero bit */
/*
-int mp_cnt_lsb(mp_int *a);
+int mp_cnt_lsb(const mp_int *a);
*/
/* I Love Earth! */
@@ -460,6 +473,9 @@ int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
/*
int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
*/
+/*
+int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
+*/
/* c = a mod b, 0 <= c < b */
/*
@@ -515,12 +531,20 @@ int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
/*
int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
*/
+/*
+int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
+*/
/* special sqrt algo */
/*
int mp_sqrt(mp_int *arg, mp_int *ret);
*/
+/* special sqrt (mod prime) */
+/*
+int mp_sqrtmod_prime(mp_int *arg, mp_int *prime, mp_int *ret);
+*/
+
/* is number a square? */
/*
int mp_is_square(mp_int *arg, int *ret);
@@ -623,7 +647,7 @@ int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
/* table of first PRIME_SIZE primes */
#if defined(BUILD_tcl) || !defined(_WIN32)
-MODULE_SCOPE const mp_digit ltm_prime_tab[];
+MODULE_SCOPE const mp_digit ltm_prime_tab[PRIME_SIZE];
#endif
/* result=1 if a is divisible by one of the first PRIME_SIZE primes */
@@ -646,7 +670,7 @@ int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result);
*/
/* This gives [for a given bit size] the number of trials required
- * such that Miller-Rabin gives a prob of failure lower than 2^-96
+ * such that Miller-Rabin gives a prob of failure lower than 2^-96
*/
/*
int mp_prime_rabin_miller_trials(int size);
@@ -673,7 +697,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
*/
/* makes a truly random prime of a given size (bytes),
- * call with bbs = 1 if you want it to be congruent to 3 mod 4
+ * call with bbs = 1 if you want it to be congruent to 3 mod 4
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
* have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
@@ -686,10 +710,9 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
/* makes a truly random prime of a given size (bits),
*
* Flags are as follows:
- *
+ *
* LTM_PRIME_BBS - make prime congruent to 3 mod 4
* LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
* LTM_PRIME_2MSB_ON - make the 2nd highest bit one
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
@@ -742,15 +765,17 @@ int mp_toradix(mp_int *a, char *str, int radix);
int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
*/
/*
-int mp_radix_size(mp_int *a, int radix, int *size);
+int mp_radix_size(const mp_int *a, int radix, int *size);
*/
+#ifndef LTM_NO_FILE
/*
int mp_fread(mp_int *a, int radix, FILE *stream);
*/
/*
int mp_fwrite(mp_int *a, int radix, FILE *stream);
*/
+#endif
#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
#define mp_raw_size(mp) mp_signed_bin_size(mp)
@@ -764,69 +789,14 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream);
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
-/* lowlevel functions, do not call! */
-/*
-int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
-*/
-/*
-int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
-*/
-#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
-/*
-int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-*/
-/*
-int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-*/
-/*
-int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-*/
-/*
-int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-*/
-/*
-int fast_s_mp_sqr(mp_int *a, mp_int *b);
-*/
-/*
-int s_mp_sqr(mp_int *a, mp_int *b);
-*/
-/*
-int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
-*/
-/*
-int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
-*/
-/*
-int mp_karatsuba_sqr(mp_int *a, mp_int *b);
-*/
-/*
-int mp_toom_sqr(mp_int *a, mp_int *b);
-*/
-/*
-int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
-*/
-/*
-int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
-*/
-/*
-int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
-*/
-/*
-int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode);
-*/
-/*
-int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode);
-*/
-/*
-void bn_reverse(unsigned char *s, int len);
-*/
-
-#if defined(BUILD_tcl) || !defined(_WIN32)
-MODULE_SCOPE const char *mp_s_rmap;
-#endif
-
#ifdef __cplusplus
-}
+ }
#endif
#endif
+
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
+
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 2ce9d5a..209c486 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -73,6 +73,7 @@
#define mp_div_d TclBN_mp_div_d
#define mp_exch TclBN_mp_exch
#define mp_expt_d TclBN_mp_expt_d
+#define mp_expt_d_ex TclBN_mp_expt_d_ex
#define mp_grow TclBN_mp_grow
#define mp_init TclBN_mp_init
#define mp_init_copy TclBN_mp_init_copy
@@ -190,7 +191,7 @@ EXTERN int TclBN_mp_grow(mp_int *a, int size);
/* 21 */
EXTERN int TclBN_mp_init(mp_int *a);
/* 22 */
-EXTERN int TclBN_mp_init_copy(mp_int *a, mp_int *b);
+EXTERN int TclBN_mp_init_copy(mp_int *a, const mp_int *b);
/* 23 */
EXTERN int TclBN_mp_init_multi(mp_int *a, ...);
/* 24 */
@@ -216,7 +217,8 @@ EXTERN int TclBN_mp_neg(const mp_int *a, mp_int *b);
/* 34 */
EXTERN int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c);
/* 35 */
-EXTERN int TclBN_mp_radix_size(mp_int *a, int radix, int *size);
+EXTERN int TclBN_mp_radix_size(const mp_int *a, int radix,
+ int *size);
/* 36 */
EXTERN int TclBN_mp_read_radix(mp_int *a, const char *str,
int radix);
@@ -287,6 +289,9 @@ EXTERN void TclBNInitBignumFromWideInt(mp_int *bignum,
/* 66 */
EXTERN void TclBNInitBignumFromWideUInt(mp_int *bignum,
Tcl_WideUInt initVal);
+/* 67 */
+EXTERN int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c,
+ int fast);
typedef struct TclTomMathStubs {
int magic;
@@ -314,7 +319,7 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_expt_d) (mp_int *a, mp_digit b, mp_int *c); /* 19 */
int (*tclBN_mp_grow) (mp_int *a, int size); /* 20 */
int (*tclBN_mp_init) (mp_int *a); /* 21 */
- int (*tclBN_mp_init_copy) (mp_int *a, mp_int *b); /* 22 */
+ int (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b); /* 22 */
int (*tclBN_mp_init_multi) (mp_int *a, ...); /* 23 */
int (*tclBN_mp_init_set) (mp_int *a, mp_digit b); /* 24 */
int (*tclBN_mp_init_size) (mp_int *a, int size); /* 25 */
@@ -327,7 +332,7 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
int (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
int (*tclBN_mp_or) (mp_int *a, mp_int *b, mp_int *c); /* 34 */
- int (*tclBN_mp_radix_size) (mp_int *a, int radix, int *size); /* 35 */
+ int (*tclBN_mp_radix_size) (const mp_int *a, int radix, int *size); /* 35 */
int (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix); /* 36 */
void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */
int (*tclBN_mp_shrink) (mp_int *a); /* 38 */
@@ -359,6 +364,7 @@ typedef struct TclTomMathStubs {
void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
+ int (*tclBN_mp_expt_d_ex) (mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */
} TclTomMathStubs;
extern const TclTomMathStubs *tclTomMathStubsPtr;
@@ -507,6 +513,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
(tclTomMathStubsPtr->tclBNInitBignumFromWideInt) /* 65 */
#define TclBNInitBignumFromWideUInt \
(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
+#define TclBN_mp_expt_d_ex \
+ (tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
#endif /* defined(USE_TCL_STUBS) */
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index 0c73cba..f86f472 100644
--- a/generic/tclTrace.c
+++ b/generic/tclTrace.c
@@ -52,7 +52,7 @@ typedef struct {
* invoked step trace */
int curFlags; /* Trace flags for the current command */
int curCode; /* Return code for the current command */
- int refCount; /* Used to ensure this structure is not
+ size_t refCount; /* Used to ensure this structure is not
* deleted too early. Keeps track of how many
* pieces of code have a pointer to this
* structure. */
@@ -2819,6 +2819,7 @@ DisposeTraceResult(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_UntraceVar
void
Tcl_UntraceVar(
@@ -2834,6 +2835,7 @@ Tcl_UntraceVar(
{
Tcl_UntraceVar2(interp, varName, NULL, flags, proc, clientData);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -2988,6 +2990,7 @@ Tcl_UntraceVar2(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_VarTraceInfo
ClientData
Tcl_VarTraceInfo(
@@ -3005,6 +3008,7 @@ Tcl_VarTraceInfo(
return Tcl_VarTraceInfo2(interp, varName, NULL, flags, proc,
prevClientData);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -3097,6 +3101,7 @@ Tcl_VarTraceInfo2(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_TraceVar
int
Tcl_TraceVar(
@@ -3114,6 +3119,7 @@ Tcl_TraceVar(
{
return Tcl_TraceVar2(interp, varName, NULL, flags, proc, clientData);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index f0c7f77..91cc3b4 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -1384,7 +1384,7 @@ TclConvertElement(
*/
if ((src == NULL) || (length == 0) || (*src == '\0' && length == -1)) {
- src = tclEmptyStringRep;
+ src = &tclEmptyString;
length = 0;
conversion = CONVERT_BRACE;
}
@@ -2894,7 +2894,6 @@ Tcl_DStringResult(
Tcl_DString *dsPtr) /* Dynamic string that is to become the
* result of interp. */
{
- Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, TclDStringToObj(dsPtr));
}
@@ -2924,6 +2923,14 @@ Tcl_DStringGetResult(
Tcl_DString *dsPtr) /* Dynamic string that is to become the result
* of interp. */
{
+#ifdef TCL_NO_DEPRECATED
+ Tcl_Obj *obj = Tcl_GetObjResult(interp);
+ const char *bytes = TclGetString(obj);
+
+ Tcl_DStringFree(dsPtr);
+ Tcl_DStringAppend(dsPtr, bytes, obj->length);
+ Tcl_ResetResult(interp);
+#else
Interp *iPtr = (Interp *) interp;
if (dsPtr->string != dsPtr->staticSpace) {
@@ -2932,7 +2939,7 @@ Tcl_DStringGetResult(
/*
* Do more efficient transfer when we know the result is a Tcl_Obj. When
- * there's no st`ring result, we only have to deal with two cases:
+ * there's no string result, we only have to deal with two cases:
*
* 1. When the string rep is the empty string, when we don't copy but
* instead use the staticSpace in the DString to hold an empty string.
@@ -2947,17 +2954,17 @@ Tcl_DStringGetResult(
if (!iPtr->result[0] && iPtr->objResultPtr
&& !Tcl_IsShared(iPtr->objResultPtr)) {
- if (iPtr->objResultPtr->bytes == tclEmptyStringRep) {
+ if (iPtr->objResultPtr->bytes == &tclEmptyString) {
dsPtr->string = dsPtr->staticSpace;
dsPtr->string[0] = 0;
dsPtr->length = 0;
dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE;
} else {
- dsPtr->string = Tcl_GetString(iPtr->objResultPtr);
+ dsPtr->string = TclGetString(iPtr->objResultPtr);
dsPtr->length = iPtr->objResultPtr->length;
dsPtr->spaceAvl = dsPtr->length + 1;
TclFreeIntRep(iPtr->objResultPtr);
- iPtr->objResultPtr->bytes = tclEmptyStringRep;
+ iPtr->objResultPtr->bytes = &tclEmptyString;
iPtr->objResultPtr->length = 0;
}
return;
@@ -2995,6 +3002,7 @@ Tcl_DStringGetResult(
iPtr->result = iPtr->resultSpace;
iPtr->resultSpace[0] = 0;
+#endif /* !TCL_NO_DEPRECATED */
}
/*
@@ -3145,7 +3153,7 @@ Tcl_PrintDouble(
int signum;
char *digits;
char *end;
- int *precisionPtr = Tcl_GetThreadData(&precisionKey, (int) sizeof(int));
+ int *precisionPtr = Tcl_GetThreadData(&precisionKey, sizeof(int));
/*
* Handle NaN.
@@ -3318,7 +3326,7 @@ TclPrecTraceProc(
{
Tcl_Obj *value;
int prec;
- int *precisionPtr = Tcl_GetThreadData(&precisionKey, (int) sizeof(int));
+ int *precisionPtr = Tcl_GetThreadData(&precisionKey, sizeof(int));
/*
* If the variable is unset, then recreate the trace.
@@ -3576,7 +3584,7 @@ TclGetIntForIndex(
int *indexPtr) /* Location filled in with an integer
* representing an index. */
{
- int length;
+ size_t length;
char *opPtr;
const char *bytes;
@@ -3594,7 +3602,8 @@ TclGetIntForIndex(
return TCL_OK;
}
- bytes = TclGetStringFromObj(objPtr, &length);
+ bytes = TclGetString(objPtr);
+ length = objPtr->length;
/*
* Leading whitespace is acceptable in an index.
@@ -3639,7 +3648,7 @@ TclGetIntForIndex(
parseError:
if (interp != NULL) {
- bytes = Tcl_GetString(objPtr);
+ bytes = TclGetString(objPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad index \"%s\": must be integer?[+-]integer? or"
" end?[+-]integer?", bytes));
@@ -4000,9 +4009,10 @@ TclSetProcessGlobalValue(
} else {
Tcl_CreateExitHandler(FreeProcessGlobalValue, pgvPtr);
}
- bytes = TclGetStringFromObj(newValue, &pgvPtr->numBytes);
+ bytes = TclGetString(newValue);
+ pgvPtr->numBytes = newValue->length;
pgvPtr->value = ckalloc(pgvPtr->numBytes + 1);
- memcpy(pgvPtr->value, bytes, (unsigned) pgvPtr->numBytes + 1);
+ memcpy(pgvPtr->value, bytes, pgvPtr->numBytes + 1);
if (pgvPtr->encoding) {
Tcl_FreeEncoding(pgvPtr->encoding);
}
@@ -4017,7 +4027,7 @@ TclSetProcessGlobalValue(
Tcl_IncrRefCount(newValue);
cacheMap = GetThreadHash(&pgvPtr->key);
ClearHash(cacheMap);
- hPtr = Tcl_CreateHashEntry(cacheMap, INT2PTR(pgvPtr->epoch), &dummy);
+ hPtr = Tcl_CreateHashEntry(cacheMap, (void *)(pgvPtr->epoch), &dummy);
Tcl_SetHashValue(hPtr, newValue);
Tcl_MutexUnlock(&pgvPtr->mutex);
}
@@ -4043,7 +4053,7 @@ TclGetProcessGlobalValue(
Tcl_Obj *value = NULL;
Tcl_HashTable *cacheMap;
Tcl_HashEntry *hPtr;
- int epoch = pgvPtr->epoch;
+ size_t epoch = pgvPtr->epoch;
if (pgvPtr->encoding) {
Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);
@@ -4058,8 +4068,7 @@ TclGetProcessGlobalValue(
Tcl_DString native, newValue;
Tcl_MutexLock(&pgvPtr->mutex);
- pgvPtr->epoch++;
- epoch = pgvPtr->epoch;
+ epoch = ++pgvPtr->epoch;
Tcl_UtfToExternalDString(pgvPtr->encoding, pgvPtr->value,
pgvPtr->numBytes, &native);
Tcl_ExternalToUtfDString(current, Tcl_DStringValue(&native),
@@ -4078,7 +4087,7 @@ TclGetProcessGlobalValue(
}
}
cacheMap = GetThreadHash(&pgvPtr->key);
- hPtr = Tcl_FindHashEntry(cacheMap, (char *) INT2PTR(epoch));
+ hPtr = Tcl_FindHashEntry(cacheMap, (void *) (epoch));
if (NULL == hPtr) {
int dummy;
@@ -4111,7 +4120,7 @@ TclGetProcessGlobalValue(
value = Tcl_NewStringObj(pgvPtr->value, pgvPtr->numBytes);
hPtr = Tcl_CreateHashEntry(cacheMap,
- INT2PTR(pgvPtr->epoch), &dummy);
+ (void *)(pgvPtr->epoch), &dummy);
Tcl_MutexUnlock(&pgvPtr->mutex);
Tcl_SetHashValue(hPtr, value);
Tcl_IncrRefCount(value);
@@ -4194,11 +4203,10 @@ TclGetObjNameOfExecutable(void)
const char *
Tcl_GetNameOfExecutable(void)
{
- int numBytes;
- const char *bytes =
- Tcl_GetStringFromObj(TclGetObjNameOfExecutable(), &numBytes);
+ Tcl_Obj *obj = TclGetObjNameOfExecutable();
+ const char *bytes = TclGetString(obj);
- if (numBytes == 0) {
+ if (obj->length == 0) {
return NULL;
}
return bytes;
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 48e09f6..1947c8d 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -1067,6 +1067,7 @@ TclLookupArrayElement(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_GetVar
const char *
Tcl_GetVar(
@@ -1087,6 +1088,7 @@ Tcl_GetVar(
}
return TclGetString(resultPtr);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -1410,6 +1412,7 @@ Tcl_SetObjCmd(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_SetVar
const char *
Tcl_SetVar(
@@ -1422,18 +1425,15 @@ Tcl_SetVar(
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT,
* TCL_LEAVE_ERR_MSG. */
{
- Tcl_Obj *varValuePtr, *varNamePtr = Tcl_NewStringObj(varName, -1);
-
- Tcl_IncrRefCount(varNamePtr);
- varValuePtr = Tcl_ObjSetVar2(interp, varNamePtr, NULL,
+ Tcl_Obj *varValuePtr = Tcl_SetVar2Ex(interp, varName, NULL,
Tcl_NewStringObj(newValue, -1), flags);
- Tcl_DecrRefCount(varNamePtr);
if (varValuePtr == NULL) {
return NULL;
}
return TclGetString(varValuePtr);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -2005,6 +2005,7 @@ TclPtrIncrObjVar(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_UnsetVar
int
Tcl_UnsetVar(
@@ -2033,6 +2034,7 @@ Tcl_UnsetVar(
Tcl_DecrRefCount(varNamePtr);
return result;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -2754,7 +2756,7 @@ TclArraySet(
} else {
/*
* Not a dictionary, so assume (and convert to, for backward-
- * -compatability reasons) a list.
+ * -compatibility reasons) a list.
*/
int elemLen;
@@ -4050,7 +4052,7 @@ TclInitArrayCmd(
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
- * message is left in iPtr->result.
+ * message is left in interp.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
@@ -4144,7 +4146,7 @@ ObjMakeUpvar(
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
- * message is left in iPtr->result.
+ * message is left in interp.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
@@ -4320,6 +4322,7 @@ TclPtrObjMakeUpvar(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef Tcl_UpVar
int
Tcl_UpVar(
@@ -4353,6 +4356,7 @@ Tcl_UpVar(
Tcl_DecrRefCount(localNamePtr);
return result;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index a7e8a8a..96b8318 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -177,6 +177,8 @@ static Tcl_ObjCmdProc ZlibStreamPutCmd;
static void ConvertError(Tcl_Interp *interp, int code,
uLong adler);
static Tcl_Obj * ConvertErrorToList(int code, uLong adler);
+static inline int Deflate(z_streamp strm, void *bufferPtr,
+ int bufferSize, int flush, int *writtenPtr);
static void ExtractHeader(gz_header *headerPtr, Tcl_Obj *dictObj);
static int GenerateHeader(Tcl_Interp *interp, Tcl_Obj *dictObj,
GzipHeader *headerPtr, int *extraSizePtr);
@@ -371,7 +373,7 @@ ConvertErrorToList(
default:
TclNewLiteralStringObj(objv[2], "UNKNOWN");
- TclNewIntObj(objv[3], code);
+ TclNewLongObj(objv[3], code);
return Tcl_NewListObj(4, objv);
}
}
@@ -578,6 +580,10 @@ ExtractHeader(
}
}
+/*
+ * Disentangle the worst of how the zlib API is used.
+ */
+
static int
SetInflateDictionary(
z_streamp strm,
@@ -605,6 +611,38 @@ SetDeflateDictionary(
}
return Z_OK;
}
+
+static inline int
+Deflate(
+ z_streamp strm,
+ void *bufferPtr,
+ int bufferSize,
+ int flush,
+ int *writtenPtr)
+{
+ int e;
+
+ strm->next_out = (Bytef *) bufferPtr;
+ strm->avail_out = (unsigned) bufferSize;
+ e = deflate(strm, flush);
+ if (writtenPtr != NULL) {
+ *writtenPtr = bufferSize - strm->avail_out;
+ }
+ return e;
+}
+
+static inline void
+AppendByteArray(
+ Tcl_Obj *listObj,
+ void *buffer,
+ int size)
+{
+ if (size > 0) {
+ Tcl_Obj *baObj = Tcl_NewByteArrayObj((unsigned char *) buffer, size);
+
+ Tcl_ListObjAppendElement(NULL, listObj, baObj);
+ }
+}
/*
*----------------------------------------------------------------------
@@ -1139,6 +1177,8 @@ Tcl_ZlibStreamSetCompressionDictionary(
*----------------------------------------------------------------------
*/
+#define BUFFER_SIZE_LIMIT 0xFFFF
+
int
Tcl_ZlibStreamPut(
Tcl_ZlibStream zshandle, /* As obtained from Tcl_ZlibStreamInit */
@@ -1148,8 +1188,7 @@ Tcl_ZlibStreamPut(
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
char *dataTmp = NULL;
- int e, size, outSize;
- Tcl_Obj *obj;
+ int e, size, outSize, toStore;
if (zshPtr->streamEnd) {
if (zshPtr->interp) {
@@ -1165,36 +1204,55 @@ Tcl_ZlibStreamPut(
zshPtr->stream.avail_in = size;
/*
- * Must not do a zero-length compress. [Bug 25842c161]
+ * Must not do a zero-length compress unless finalizing. [Bug 25842c161]
*/
- if (size == 0) {
+ if (size == 0 && flush != Z_FINISH) {
return TCL_OK;
}
if (HaveDictToSet(zshPtr)) {
e = SetDeflateDictionary(&zshPtr->stream, zshPtr->compDictObj);
if (e != Z_OK) {
- if (zshPtr->interp) {
- ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
- }
+ ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
return TCL_ERROR;
}
DictWasSet(zshPtr);
}
/*
- * Deflatebound doesn't seem to take various header sizes into
- * account, so we add 100 extra bytes.
+ * deflateBound() doesn't seem to take various header sizes into
+ * account, so we add 100 extra bytes. However, we can also loop
+ * around again so we also set an upper bound on the output buffer
+ * size.
*/
- outSize = deflateBound(&zshPtr->stream, zshPtr->stream.avail_in)+100;
- zshPtr->stream.avail_out = outSize;
- dataTmp = ckalloc(zshPtr->stream.avail_out);
- zshPtr->stream.next_out = (Bytef *) dataTmp;
+ outSize = deflateBound(&zshPtr->stream, size) + 100;
+ if (outSize > BUFFER_SIZE_LIMIT) {
+ outSize = BUFFER_SIZE_LIMIT;
+ }
+ dataTmp = ckalloc(outSize);
+
+ while (1) {
+ e = Deflate(&zshPtr->stream, dataTmp, outSize, flush, &toStore);
+
+ /*
+ * Test if we've filled the buffer up and have to ask deflate() to
+ * give us some more. Note that the condition for needing to
+ * repeat a buffer transfer when the result is Z_OK is whether
+ * there is no more space in the buffer we provided; the zlib
+ * library does not necessarily return a different code in that
+ * case. [Bug b26e38a3e4] [Tk Bug 10f2e7872b]
+ */
+
+ if ((e != Z_BUF_ERROR) && (e != Z_OK || toStore < outSize)) {
+ if ((e == Z_OK) || (flush == Z_FINISH && e == Z_STREAM_END)) {
+ break;
+ }
+ ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
+ return TCL_ERROR;
+ }
- e = deflate(&zshPtr->stream, flush);
- while (e == Z_BUF_ERROR || (flush == Z_FINISH && e == Z_OK)) {
/*
* Output buffer too small to hold the data being generated or we
* are doing the end-of-stream flush (which can spit out masses of
@@ -1202,45 +1260,21 @@ Tcl_ZlibStreamPut(
* saving the old generated data to the outData list.
*/
- obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp, outSize);
- Tcl_ListObjAppendElement(NULL, zshPtr->outData, obj);
+ AppendByteArray(zshPtr->outData, dataTmp, outSize);
- if (outSize < 0xFFFF) {
- outSize = 0xFFFF; /* There may be *lots* of data left to
- * output... */
+ if (outSize < BUFFER_SIZE_LIMIT) {
+ outSize = BUFFER_SIZE_LIMIT;
+ /* There may be *lots* of data left to output... */
dataTmp = ckrealloc(dataTmp, outSize);
}
- zshPtr->stream.avail_out = outSize;
- zshPtr->stream.next_out = (Bytef *) dataTmp;
-
- e = deflate(&zshPtr->stream, flush);
- }
-
- if (e != Z_OK && !(flush==Z_FINISH && e==Z_STREAM_END)) {
- if (zshPtr->interp) {
- ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
- }
- return TCL_ERROR;
}
/*
- * And append the final data block.
+ * And append the final data block to the outData list.
*/
- if (outSize - zshPtr->stream.avail_out > 0) {
- obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
- outSize - zshPtr->stream.avail_out);
-
- /*
- * Now append the compressed data to the outData list.
- */
-
- Tcl_ListObjAppendElement(NULL, zshPtr->outData, obj);
- }
-
- if (dataTmp) {
- ckfree(dataTmp);
- }
+ AppendByteArray(zshPtr->outData, dataTmp, toStore);
+ ckfree(dataTmp);
} else {
/*
* This is easy. Just append to the inData list.
@@ -1356,9 +1390,7 @@ Tcl_ZlibStreamGet(
if (IsRawStream(zshPtr) && HaveDictToSet(zshPtr)) {
e = SetInflateDictionary(&zshPtr->stream, zshPtr->compDictObj);
if (e != Z_OK) {
- if (zshPtr->interp) {
- ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
- }
+ ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
return TCL_ERROR;
}
DictWasSet(zshPtr);
@@ -2879,10 +2911,8 @@ ZlibTransformClose(
if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
cd->outStream.avail_in = 0;
do {
- cd->outStream.next_out = (Bytef *) cd->outBuffer;
- cd->outStream.avail_out = (unsigned) cd->outAllocated;
- e = deflate(&cd->outStream, Z_FINISH);
- written = cd->outAllocated - cd->outStream.avail_out;
+ e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
+ Z_FINISH, &written);
/*
* Can't be sure that deflate() won't declare the buffer to be
@@ -3086,17 +3116,15 @@ ZlibTransformOutput(
cd->outStream.next_in = (Bytef *) buf;
cd->outStream.avail_in = toWrite;
do {
- cd->outStream.next_out = (Bytef *) cd->outBuffer;
- cd->outStream.avail_out = cd->outAllocated;
-
- e = deflate(&cd->outStream, Z_NO_FLUSH);
- produced = cd->outAllocated - cd->outStream.avail_out;
+ e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
+ Z_NO_FLUSH, &produced);
if ((e == Z_OK && produced > 0) || e == Z_BUF_ERROR) {
/*
* deflate() indicates that it is out of space by returning
- * Z_BUF_ERROR; in that case, we must write the whole buffer out
- * and retry to compress what is left.
+ * Z_BUF_ERROR *or* by simply returning Z_OK with no remaining
+ * space; in either case, we must write the whole buffer out and
+ * retry to compress what is left.
*/
if (e == Z_BUF_ERROR) {
@@ -3149,10 +3177,8 @@ ZlibTransformFlush(
* Get the bytes to go out of the compression engine.
*/
- cd->outStream.next_out = (Bytef *) cd->outBuffer;
- cd->outStream.avail_out = cd->outAllocated;
-
- e = deflate(&cd->outStream, flushType);
+ e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
+ flushType, &len);
if (e != Z_OK && e != Z_BUF_ERROR) {
ConvertError(interp, e, cd->outStream.adler);
return TCL_ERROR;
@@ -3162,7 +3188,6 @@ ZlibTransformFlush(
* Write the bytes we've received to the next layer.
*/
- len = cd->outStream.next_out - (Bytef *) cd->outBuffer;
if (len > 0 && Tcl_WriteRaw(cd->parent, cd->outBuffer, len) < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"problem flushing channel: %s",
diff --git a/library/clock.tcl b/library/clock.tcl
index 535a67d..535a67d 100755..100644
--- a/library/clock.tcl
+++ b/library/clock.tcl
diff --git a/library/history.tcl b/library/history.tcl
index 51d2404..ef9099b 100644
--- a/library/history.tcl
+++ b/library/history.tcl
@@ -56,6 +56,30 @@ proc ::history {args} {
tailcall apply {arglist {tailcall history {*}$arglist} ::tcl} $args
}
+# (unnamed) --
+#
+# Callback when [::history] is destroyed. Destroys the implementation.
+#
+# Parameters:
+# oldName what the command was called.
+# newName what the command is now called (an empty string).
+# op the operation (= delete).
+#
+# Results:
+# none
+#
+# Side Effects:
+# The implementation of the [::history] command ceases to exist.
+
+trace add command ::history delete [list apply {{oldName newName op} {
+ variable history
+ unset -nocomplain history
+ foreach c [info procs ::tcl::Hist*] {
+ rename $c {}
+ }
+ rename ::tcl::history {}
+} ::tcl}]
+
# tcl::HistAdd --
#
# Add an item to the history, and optionally eval it at the global scope
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 5a05fa0..ccd4cd1 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -8,10 +8,10 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-package require Tcl 8.6
+package require Tcl 8.6-
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
-package provide http 2.8.9
+package provide http 2.8.10
namespace eval http {
# Allow resourcing to not clobber existing data
@@ -1047,7 +1047,7 @@ proc http::Event {sock token} {
fconfigure $sock -translation binary
if {
- $state(-binary) || ![string match -nocase text* $state(type)]
+ $state(-binary) || [IsBinaryContentType $state(type)]
} {
# Turn off conversions for non-text data
set state(binary) 1
@@ -1183,6 +1183,38 @@ proc http::Event {sock token} {
}
}
+# http::IsBinaryContentType --
+#
+# Determine if the content-type means that we should definitely transfer
+# the data as binary. [Bug 838e99a76d]
+#
+# Arguments
+# type The content-type of the data.
+#
+# Results:
+# Boolean, true if we definitely should be binary.
+
+proc http::IsBinaryContentType {type} {
+ lassign [split [string tolower $type] "/;"] major minor
+ if {$major eq "text"} {
+ return false
+ }
+ # There's a bunch of XML-as-application-format things about. See RFC 3023
+ # and so on.
+ if {$major eq "application"} {
+ set minor [string trimright $minor]
+ if {$minor in {"xml" "xml-external-parsed-entity" "xml-dtd"}} {
+ return false
+ }
+ }
+ # Not just application/foobar+xml but also image/svg+xml, so let us not
+ # restrict things for now...
+ if {[string match "*+xml" $minor]} {
+ return false
+ }
+ return true
+}
+
# http::getTextLine --
#
# Get one line with the stream in blocking crlf mode
@@ -1415,7 +1447,7 @@ proc http::mapReply {string} {
set converted [string map $formMap $string]
if {[string match "*\[\u0100-\uffff\]*" $converted]} {
regexp "\[\u0100-\uffff\]" $converted badChar
- # Return this error message for maximum compatability... :^/
+ # Return this error message for maximum compatibility... :^/
return -code error \
"can't read \"formMap($badChar)\": no such element in array"
}
diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl
index 6e0301a..841b4eb 100644
--- a/library/http/pkgIndex.tcl
+++ b/library/http/pkgIndex.tcl
@@ -1,2 +1,2 @@
-if {![package vsatisfies [package provide Tcl] 8.6]} {return}
-package ifneeded http 2.8.9 [list tclPkgSetup $dir http 2.8.9 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
+if {![package vsatisfies [package provide Tcl] 8.6-]} {return}
+package ifneeded http 2.8.10 [list tclPkgSetup $dir http 2.8.10 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
diff --git a/library/init.tcl b/library/init.tcl
index 544ea77..8a680f1 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -45,6 +45,7 @@ if {![info exists auto_path]} {
set auto_path ""
}
}
+
namespace eval tcl {
variable Dir
foreach Dir [list $::tcl_library [file dirname $::tcl_library]] {
@@ -112,6 +113,8 @@ namespace eval tcl {
}
}
+namespace eval tcl::Pkg {}
+
# Windows specific end of initialization
if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} {
@@ -169,13 +172,7 @@ if {[interp issafe]} {
namespace eval ::tcl::clock [list variable TclLibDir $::tcl_library]
- proc clock args {
- namespace eval ::tcl::clock [list namespace ensemble create -command \
- [uplevel 1 [list namespace origin [lindex [info level 0] 0]]] \
- -subcommands {
- add clicks format microseconds milliseconds scan seconds
- }]
-
+ proc ::tcl::initClock {} {
# Auto-loading stubs for 'clock.tcl'
foreach cmd {add format scan} {
@@ -186,8 +183,9 @@ if {[interp issafe]} {
}
}
- return [uplevel 1 [info level 0]]
+ rename ::tcl::initClock {}
}
+ ::tcl::initClock
}
# Conditionalize for presence of exec.
@@ -457,6 +455,22 @@ proc auto_load {cmd {namespace {}}} {
return 0
}
+# ::tcl::Pkg::source --
+# This procedure provides an alternative "source" command, which doesn't
+# register the file for the "package files" command. Safe interpreters
+# don't have to do anything special.
+#
+# Arguments:
+# filename
+
+proc ::tcl::Pkg::source {filename} {
+ if {[interp issafe]} {
+ uplevel 1 [list ::source $filename]
+ } else {
+ uplevel 1 [list ::source -nopkg $filename]
+ }
+}
+
# auto_load_index --
# Loads the contents of tclIndex files on the auto_path directory
# list. This is usually invoked within auto_load to load the index
@@ -499,7 +513,7 @@ proc auto_load_index {} {
}
set name [lindex $line 0]
set auto_index($name) \
- "source [file join $dir [lindex $line 1]]"
+ "::tcl::Pkg::source [file join $dir [lindex $line 1]]"
}
} else {
error "[file join $dir tclIndex] isn't a proper Tcl index file"
@@ -636,8 +650,9 @@ proc auto_execok name {
}
set auto_execs($name) ""
- set shellBuiltins [list cls copy date del dir echo erase md mkdir \
- mklink rd ren rename rmdir start time type ver vol]
+ set shellBuiltins [list assoc cls copy date del dir echo erase ftype \
+ md mkdir mklink move rd ren rename rmdir start \
+ time type ver vol]
if {[info exists env(PATHEXT)]} {
# Add an initial ; to have the {} extension check first.
set execExtensions [split ";$env(PATHEXT)" ";"]
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl
index a43f13e..928474d 100644
--- a/library/msgcat/msgcat.tcl
+++ b/library/msgcat/msgcat.tcl
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-package require Tcl 8.5
+package require Tcl 8.5-
# When the version number changes, be sure to update the pkgIndex.tcl file,
# and the installation directory in the Makefiles.
package provide msgcat 1.6.0
diff --git a/library/package.tcl b/library/package.tcl
index 44e3b28..c72fbfb 100644
--- a/library/package.tcl
+++ b/library/package.tcl
@@ -488,7 +488,7 @@ proc tclPkgUnknown {name args} {
set dir [file dirname $file]
if {![info exists procdDirs($dir)]} {
try {
- source $file
+ ::tcl::Pkg::source $file
} trap {POSIX EACCES} {} {
# $file was not readable; silently ignore
continue
@@ -506,7 +506,7 @@ proc tclPkgUnknown {name args} {
# safe interps usually don't have "file exists",
if {([interp issafe] || [file exists $file])} {
try {
- source $file
+ ::tcl::Pkg::source $file
} trap {POSIX EACCES} {} {
# $file was not readable; silently ignore
continue
@@ -590,7 +590,7 @@ proc tcl::MacOSXPkgUnknown {original name args} {
set dir [file dirname $file]
if {![info exists procdDirs($dir)]} {
try {
- source $file
+ ::tcl::Pkg::source $file
} trap {POSIX EACCES} {} {
# $file was not readable; silently ignore
continue
diff --git a/library/tclIndex b/library/tclIndex
index 26603c1..87a2814 100644
--- a/library/tclIndex
+++ b/library/tclIndex
@@ -7,69 +7,69 @@
# element name is the name of a command and the value is
# a script that loads the command.
-set auto_index(auto_reset) [list source [file join $dir auto.tcl]]
-set auto_index(tcl_findLibrary) [list source [file join $dir auto.tcl]]
-set auto_index(auto_mkindex) [list source [file join $dir auto.tcl]]
-set auto_index(auto_mkindex_old) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::init) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::cleanup) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::mkindex) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::hook) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::slavehook) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::command) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::commandInit) [list source [file join $dir auto.tcl]]
-set auto_index(::auto_mkindex_parser::fullname) [list source [file join $dir auto.tcl]]
-set auto_index(history) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistAdd) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistKeep) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistClear) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistInfo) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistRedo) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistIndex) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistEvent) [list source [file join $dir history.tcl]]
-set auto_index(::tcl::HistChange) [list source [file join $dir history.tcl]]
-set auto_index(pkg_mkIndex) [list source [file join $dir package.tcl]]
-set auto_index(tclPkgSetup) [list source [file join $dir package.tcl]]
-set auto_index(tclPkgUnknown) [list source [file join $dir package.tcl]]
-set auto_index(::tcl::MacOSXPkgUnknown) [list source [file join $dir package.tcl]]
-set auto_index(::pkg::create) [list source [file join $dir package.tcl]]
-set auto_index(parray) [list source [file join $dir parray.tcl]]
-set auto_index(::safe::InterpStatics) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::InterpNested) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpCreate) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpInit) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::CheckInterp) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpConfigure) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::InterpCreate) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::InterpSetConfig) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpFindInAccessPath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpAddToAccessPath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::InterpInit) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AddSubDirs) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::interpDelete) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::setLogCmd) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::SyncAccessPath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::PathToken) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::TranslatePath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::Log) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::CheckFileName) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AliasGlob) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AliasSource) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AliasLoad) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::FileInAccessPath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::DirInAccessPath) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::Subset) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AliasSubset) [list source [file join $dir safe.tcl]]
-set auto_index(::safe::AliasEncoding) [list source [file join $dir safe.tcl]]
-set auto_index(tcl_wordBreakAfter) [list source [file join $dir word.tcl]]
-set auto_index(tcl_wordBreakBefore) [list source [file join $dir word.tcl]]
-set auto_index(tcl_endOfWord) [list source [file join $dir word.tcl]]
-set auto_index(tcl_startOfNextWord) [list source [file join $dir word.tcl]]
-set auto_index(tcl_startOfPreviousWord) [list source [file join $dir word.tcl]]
-set auto_index(::tcl::tm::add) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::remove) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::list) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::Defaults) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::UnknownHandler) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::roots) [list source [file join $dir tm.tcl]]
-set auto_index(::tcl::tm::path) [list source [file join $dir tm.tcl]]
+set auto_index(auto_reset) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(tcl_findLibrary) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(auto_mkindex) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(auto_mkindex_old) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::init) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::cleanup) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::mkindex) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::hook) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::slavehook) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::command) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::commandInit) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(::auto_mkindex_parser::fullname) [list ::tcl::Pkg::source [file join $dir auto.tcl]]
+set auto_index(history) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistAdd) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistKeep) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistClear) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistInfo) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistRedo) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistIndex) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistEvent) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(::tcl::HistChange) [list ::tcl::Pkg::source [file join $dir history.tcl]]
+set auto_index(pkg_mkIndex) [list ::tcl::Pkg::source [file join $dir package.tcl]]
+set auto_index(tclPkgSetup) [list ::tcl::Pkg::source [file join $dir package.tcl]]
+set auto_index(tclPkgUnknown) [list ::tcl::Pkg::source [file join $dir package.tcl]]
+set auto_index(::tcl::MacOSXPkgUnknown) [list ::tcl::Pkg::source [file join $dir package.tcl]]
+set auto_index(::pkg::create) [list ::tcl::Pkg::source [file join $dir package.tcl]]
+set auto_index(parray) [list ::tcl::Pkg::source [file join $dir parray.tcl]]
+set auto_index(::safe::InterpStatics) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::InterpNested) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpCreate) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpInit) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::CheckInterp) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpConfigure) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::InterpCreate) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::InterpSetConfig) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpFindInAccessPath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpAddToAccessPath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::InterpInit) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AddSubDirs) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::interpDelete) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::setLogCmd) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::SyncAccessPath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::PathToken) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::TranslatePath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::Log) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::CheckFileName) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AliasGlob) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AliasSource) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AliasLoad) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::FileInAccessPath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::DirInAccessPath) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::Subset) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AliasSubset) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::AliasEncoding) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(tcl_wordBreakAfter) [list ::tcl::Pkg::source [file join $dir word.tcl]]
+set auto_index(tcl_wordBreakBefore) [list ::tcl::Pkg::source [file join $dir word.tcl]]
+set auto_index(tcl_endOfWord) [list ::tcl::Pkg::source [file join $dir word.tcl]]
+set auto_index(tcl_startOfNextWord) [list ::tcl::Pkg::source [file join $dir word.tcl]]
+set auto_index(tcl_startOfPreviousWord) [list ::tcl::Pkg::source [file join $dir word.tcl]]
+set auto_index(::tcl::tm::add) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::remove) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::list) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::Defaults) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::UnknownHandler) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::roots) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
+set auto_index(::tcl::tm::path) [list ::tcl::Pkg::source [file join $dir tm.tcl]]
diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl
index cde2660..75975d2 100644
--- a/library/tcltest/tcltest.tcl
+++ b/library/tcltest/tcltest.tcl
@@ -16,7 +16,7 @@
# Contributions from Don Porter, NIST, 2002. (not subject to US copyright)
# All rights reserved.
-package require Tcl 8.5 ;# -verbose line uses [info frame]
+package require Tcl 8.5- ;# -verbose line uses [info frame]
namespace eval tcltest {
# When the version number changes, be sure to update the pkgIndex.tcl file,
diff --git a/library/tzdata/Africa/Accra b/library/tzdata/Africa/Accra
index 39db976..18f4522 100644
--- a/library/tzdata/Africa/Accra
+++ b/library/tzdata/Africa/Accra
@@ -2,51 +2,51 @@
set TZData(:Africa/Accra) {
{-9223372036854775808 -52 0 LMT}
- {-1640995148 0 0 GMT}
- {-1556841600 1200 1 GHST}
- {-1546388400 0 0 GMT}
- {-1525305600 1200 1 GHST}
- {-1514852400 0 0 GMT}
- {-1493769600 1200 1 GHST}
- {-1483316400 0 0 GMT}
- {-1462233600 1200 1 GHST}
- {-1451780400 0 0 GMT}
- {-1430611200 1200 1 GHST}
- {-1420158000 0 0 GMT}
- {-1399075200 1200 1 GHST}
- {-1388622000 0 0 GMT}
- {-1367539200 1200 1 GHST}
- {-1357086000 0 0 GMT}
- {-1336003200 1200 1 GHST}
- {-1325550000 0 0 GMT}
- {-1304380800 1200 1 GHST}
- {-1293927600 0 0 GMT}
- {-1272844800 1200 1 GHST}
- {-1262391600 0 0 GMT}
- {-1241308800 1200 1 GHST}
- {-1230855600 0 0 GMT}
- {-1209772800 1200 1 GHST}
- {-1199319600 0 0 GMT}
- {-1178150400 1200 1 GHST}
- {-1167697200 0 0 GMT}
- {-1146614400 1200 1 GHST}
- {-1136161200 0 0 GMT}
- {-1115078400 1200 1 GHST}
- {-1104625200 0 0 GMT}
- {-1083542400 1200 1 GHST}
- {-1073089200 0 0 GMT}
- {-1051920000 1200 1 GHST}
- {-1041466800 0 0 GMT}
- {-1020384000 1200 1 GHST}
- {-1009930800 0 0 GMT}
- {-988848000 1200 1 GHST}
- {-978394800 0 0 GMT}
- {-957312000 1200 1 GHST}
- {-946858800 0 0 GMT}
- {-925689600 1200 1 GHST}
- {-915236400 0 0 GMT}
- {-894153600 1200 1 GHST}
- {-883700400 0 0 GMT}
- {-862617600 1200 1 GHST}
- {-852164400 0 0 GMT}
+ {-1640995148 0 0 +0020}
+ {-1556841600 1200 1 +0020}
+ {-1546388400 0 0 +0020}
+ {-1525305600 1200 1 +0020}
+ {-1514852400 0 0 +0020}
+ {-1493769600 1200 1 +0020}
+ {-1483316400 0 0 +0020}
+ {-1462233600 1200 1 +0020}
+ {-1451780400 0 0 +0020}
+ {-1430611200 1200 1 +0020}
+ {-1420158000 0 0 +0020}
+ {-1399075200 1200 1 +0020}
+ {-1388622000 0 0 +0020}
+ {-1367539200 1200 1 +0020}
+ {-1357086000 0 0 +0020}
+ {-1336003200 1200 1 +0020}
+ {-1325550000 0 0 +0020}
+ {-1304380800 1200 1 +0020}
+ {-1293927600 0 0 +0020}
+ {-1272844800 1200 1 +0020}
+ {-1262391600 0 0 +0020}
+ {-1241308800 1200 1 +0020}
+ {-1230855600 0 0 +0020}
+ {-1209772800 1200 1 +0020}
+ {-1199319600 0 0 +0020}
+ {-1178150400 1200 1 +0020}
+ {-1167697200 0 0 +0020}
+ {-1146614400 1200 1 +0020}
+ {-1136161200 0 0 +0020}
+ {-1115078400 1200 1 +0020}
+ {-1104625200 0 0 +0020}
+ {-1083542400 1200 1 +0020}
+ {-1073089200 0 0 +0020}
+ {-1051920000 1200 1 +0020}
+ {-1041466800 0 0 +0020}
+ {-1020384000 1200 1 +0020}
+ {-1009930800 0 0 +0020}
+ {-988848000 1200 1 +0020}
+ {-978394800 0 0 +0020}
+ {-957312000 1200 1 +0020}
+ {-946858800 0 0 +0020}
+ {-925689600 1200 1 +0020}
+ {-915236400 0 0 +0020}
+ {-894153600 1200 1 +0020}
+ {-883700400 0 0 +0020}
+ {-862617600 1200 1 +0020}
+ {-852164400 0 0 +0020}
}
diff --git a/library/tzdata/Africa/Bissau b/library/tzdata/Africa/Bissau
index 5693228..88d9d03 100644
--- a/library/tzdata/Africa/Bissau
+++ b/library/tzdata/Africa/Bissau
@@ -2,6 +2,6 @@
set TZData(:Africa/Bissau) {
{-9223372036854775808 -3740 0 LMT}
- {-1830380260 -3600 0 WAT}
+ {-1830380260 -3600 0 -01}
{157770000 0 0 GMT}
}
diff --git a/library/tzdata/Africa/Ceuta b/library/tzdata/Africa/Ceuta
index 882c13d..057ca22 100644
--- a/library/tzdata/Africa/Ceuta
+++ b/library/tzdata/Africa/Ceuta
@@ -2,18 +2,18 @@
set TZData(:Africa/Ceuta) {
{-9223372036854775808 -1276 0 LMT}
- {-2177451524 0 0 WET}
+ {-2177452800 0 0 WET}
{-1630112400 3600 1 WEST}
{-1616810400 0 0 WET}
{-1451692800 0 0 WET}
{-1442451600 3600 1 WEST}
- {-1427677200 0 0 WET}
+ {-1427673600 0 0 WET}
{-1379293200 3600 1 WEST}
- {-1364778000 0 0 WET}
+ {-1364774400 0 0 WET}
{-1348448400 3600 1 WEST}
- {-1333328400 0 0 WET}
- {-1316394000 3600 1 WEST}
- {-1301274000 0 0 WET}
+ {-1333324800 0 0 WET}
+ {-1316390400 3600 1 WEST}
+ {-1301270400 0 0 WET}
{-1293840000 0 0 WET}
{-81432000 3600 1 WEST}
{-71110800 0 0 WET}
diff --git a/library/tzdata/Africa/El_Aaiun b/library/tzdata/Africa/El_Aaiun
index 77e149e..7bdc496 100644
--- a/library/tzdata/Africa/El_Aaiun
+++ b/library/tzdata/Africa/El_Aaiun
@@ -2,7 +2,7 @@
set TZData(:Africa/El_Aaiun) {
{-9223372036854775808 -3168 0 LMT}
- {-1136070432 -3600 0 WAT}
+ {-1136070432 -3600 0 -01}
{198291600 0 0 WET}
{199756800 3600 1 WEST}
{207702000 0 0 WET}
diff --git a/library/tzdata/Africa/Monrovia b/library/tzdata/Africa/Monrovia
index 1cfff58..2b311bb 100644
--- a/library/tzdata/Africa/Monrovia
+++ b/library/tzdata/Africa/Monrovia
@@ -3,6 +3,6 @@
set TZData(:Africa/Monrovia) {
{-9223372036854775808 -2588 0 LMT}
{-2776979812 -2588 0 MMT}
- {-1604359012 -2670 0 LRT}
- {73529070 0 0 GMT}
+ {-1604359012 -2670 0 MMT}
+ {63593070 0 0 GMT}
}
diff --git a/library/tzdata/Africa/Nairobi b/library/tzdata/Africa/Nairobi
index 6846069..715dc45 100644
--- a/library/tzdata/Africa/Nairobi
+++ b/library/tzdata/Africa/Nairobi
@@ -3,7 +3,7 @@
set TZData(:Africa/Nairobi) {
{-9223372036854775808 8836 0 LMT}
{-1309746436 10800 0 EAT}
- {-1262314800 9000 0 BEAT}
- {-946780200 9900 0 BEAUT}
+ {-1262314800 9000 0 +0230}
+ {-946780200 9900 0 +0245}
{-315629100 10800 0 EAT}
}
diff --git a/library/tzdata/Africa/Windhoek b/library/tzdata/Africa/Windhoek
index a655f2e..1b8f86a 100644
--- a/library/tzdata/Africa/Windhoek
+++ b/library/tzdata/Africa/Windhoek
@@ -2,7 +2,7 @@
set TZData(:Africa/Windhoek) {
{-9223372036854775808 4104 0 LMT}
- {-2458170504 5400 0 SWAT}
+ {-2458170504 5400 0 +0130}
{-2109288600 7200 0 SAST}
{-860976000 10800 1 SAST}
{-845254800 7200 0 SAST}
diff --git a/library/tzdata/America/Anchorage b/library/tzdata/America/Anchorage
index e02dd01..127d365 100644
--- a/library/tzdata/America/Anchorage
+++ b/library/tzdata/America/Anchorage
@@ -3,12 +3,11 @@
set TZData(:America/Anchorage) {
{-9223372036854775808 50424 0 LMT}
{-3225362424 -35976 0 LMT}
- {-2188951224 -36000 0 CAT}
- {-883576800 -36000 0 CAWT}
- {-880200000 -32400 1 CAWT}
- {-769395600 -32400 0 CAPT}
- {-765378000 -36000 0 CAPT}
- {-757346400 -36000 0 CAT}
+ {-2188951224 -36000 0 AST}
+ {-883576800 -36000 0 AST}
+ {-880200000 -32400 1 AWT}
+ {-769395600 -32400 1 APT}
+ {-765378000 -36000 0 AST}
{-86882400 -36000 0 AHST}
{-31500000 -36000 0 AHST}
{-21470400 -32400 1 AHDT}
diff --git a/library/tzdata/America/Araguaina b/library/tzdata/America/Araguaina
index e4a0d52..b9e2aec 100644
--- a/library/tzdata/America/Araguaina
+++ b/library/tzdata/America/Araguaina
@@ -2,59 +2,59 @@
set TZData(:America/Araguaina) {
{-9223372036854775808 -11568 0 LMT}
- {-1767214032 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {653536800 -10800 0 BRT}
- {811047600 -10800 0 BRT}
- {813726000 -7200 1 BRST}
- {824004000 -10800 0 BRT}
- {844570800 -7200 1 BRST}
- {856058400 -10800 0 BRT}
- {876106800 -7200 1 BRST}
- {888717600 -10800 0 BRT}
- {908074800 -7200 1 BRST}
- {919562400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {982461600 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1036292400 -7200 1 BRST}
- {1045360800 -10800 0 BRT}
- {1064368800 -10800 0 BRT}
- {1350788400 -7200 0 BRST}
- {1361066400 -10800 0 BRT}
- {1378000800 -10800 0 BRT}
+ {-1767214032 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {653536800 -10800 0 -03}
+ {811047600 -10800 0 -03}
+ {813726000 -7200 1 -02}
+ {824004000 -10800 0 -03}
+ {844570800 -7200 1 -02}
+ {856058400 -10800 0 -03}
+ {876106800 -7200 1 -02}
+ {888717600 -10800 0 -03}
+ {908074800 -7200 1 -02}
+ {919562400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {982461600 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1036292400 -7200 1 -02}
+ {1045360800 -10800 0 -03}
+ {1064368800 -10800 0 -03}
+ {1350788400 -7200 0 -02}
+ {1361066400 -10800 0 -03}
+ {1378000800 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Buenos_Aires b/library/tzdata/America/Argentina/Buenos_Aires
index 73cc8e9..8be2c45 100644
--- a/library/tzdata/America/Argentina/Buenos_Aires
+++ b/library/tzdata/America/Argentina/Buenos_Aires
@@ -3,65 +3,65 @@
set TZData(:America/Argentina/Buenos_Aires) {
{-9223372036854775808 -14028 0 LMT}
{-2372097972 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -10800 0 ART}
- {687927600 -7200 1 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224385200 -7200 1 ARST}
- {1237082400 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224385200 -7200 1 -02}
+ {1237082400 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Catamarca b/library/tzdata/America/Argentina/Catamarca
index 7739203..a546bfc 100644
--- a/library/tzdata/America/Argentina/Catamarca
+++ b/library/tzdata/America/Argentina/Catamarca
@@ -3,66 +3,66 @@
set TZData(:America/Argentina/Catamarca) {
{-9223372036854775808 -15788 0 LMT}
{-2372096212 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -14400 0 WART}
- {687931200 -7200 0 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1086058800 -14400 0 WART}
- {1087704000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -14400 0 -04}
+ {687931200 -7200 0 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1086058800 -14400 0 -04}
+ {1087704000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Cordoba b/library/tzdata/America/Argentina/Cordoba
index b08539e..ec6978e 100644
--- a/library/tzdata/America/Argentina/Cordoba
+++ b/library/tzdata/America/Argentina/Cordoba
@@ -3,65 +3,65 @@
set TZData(:America/Argentina/Cordoba) {
{-9223372036854775808 -15408 0 LMT}
{-2372096592 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -14400 0 WART}
- {687931200 -7200 0 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224385200 -7200 1 ARST}
- {1237082400 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -14400 0 -04}
+ {687931200 -7200 0 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224385200 -7200 1 -02}
+ {1237082400 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Jujuy b/library/tzdata/America/Argentina/Jujuy
index 4f95f8a..0e11ba2 100644
--- a/library/tzdata/America/Argentina/Jujuy
+++ b/library/tzdata/America/Argentina/Jujuy
@@ -3,65 +3,65 @@
set TZData(:America/Argentina/Jujuy) {
{-9223372036854775808 -15672 0 LMT}
{-2372096328 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -14400 0 WART}
- {657086400 -10800 1 WARST}
- {669178800 -14400 0 WART}
- {686721600 -7200 1 ARST}
- {694231200 -7200 0 ART}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -14400 0 -04}
+ {657086400 -10800 1 -03}
+ {669178800 -14400 0 -04}
+ {686721600 -7200 1 -02}
+ {694231200 -7200 0 -03}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/La_Rioja b/library/tzdata/America/Argentina/La_Rioja
index 835e29d..90e0030 100644
--- a/library/tzdata/America/Argentina/La_Rioja
+++ b/library/tzdata/America/Argentina/La_Rioja
@@ -3,67 +3,67 @@
set TZData(:America/Argentina/La_Rioja) {
{-9223372036854775808 -16044 0 LMT}
{-2372095956 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667792800 -14400 0 WART}
- {673588800 -10800 0 ART}
- {687927600 -7200 1 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1086058800 -14400 0 WART}
- {1087704000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667792800 -14400 0 -04}
+ {673588800 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1086058800 -14400 0 -04}
+ {1087704000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Mendoza b/library/tzdata/America/Argentina/Mendoza
index 2c6fb58..8dfcd2b 100644
--- a/library/tzdata/America/Argentina/Mendoza
+++ b/library/tzdata/America/Argentina/Mendoza
@@ -3,66 +3,66 @@
set TZData(:America/Argentina/Mendoza) {
{-9223372036854775808 -16516 0 LMT}
{-2372095484 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -14400 0 WART}
- {655963200 -10800 1 WARST}
- {667796400 -14400 0 WART}
- {687499200 -10800 1 WARST}
- {699418800 -14400 0 WART}
- {719380800 -7200 0 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1085281200 -14400 0 WART}
- {1096171200 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -14400 0 -04}
+ {655963200 -10800 1 -03}
+ {667796400 -14400 0 -04}
+ {687499200 -10800 1 -03}
+ {699418800 -14400 0 -04}
+ {719380800 -7200 0 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1085281200 -14400 0 -04}
+ {1096171200 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Rio_Gallegos b/library/tzdata/America/Argentina/Rio_Gallegos
index 91d37dd..4b2a348 100644
--- a/library/tzdata/America/Argentina/Rio_Gallegos
+++ b/library/tzdata/America/Argentina/Rio_Gallegos
@@ -3,66 +3,66 @@
set TZData(:America/Argentina/Rio_Gallegos) {
{-9223372036854775808 -16612 0 LMT}
{-2372095388 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -10800 0 ART}
- {687927600 -7200 1 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1086058800 -14400 0 WART}
- {1087704000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1086058800 -14400 0 -04}
+ {1087704000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Salta b/library/tzdata/America/Argentina/Salta
index a5a7010..4f9ccf9 100644
--- a/library/tzdata/America/Argentina/Salta
+++ b/library/tzdata/America/Argentina/Salta
@@ -3,64 +3,64 @@
set TZData(:America/Argentina/Salta) {
{-9223372036854775808 -15700 0 LMT}
{-2372096300 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -14400 0 WART}
- {687931200 -7200 0 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -14400 0 -04}
+ {687931200 -7200 0 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/San_Juan b/library/tzdata/America/Argentina/San_Juan
index 417e234..1f0530a 100644
--- a/library/tzdata/America/Argentina/San_Juan
+++ b/library/tzdata/America/Argentina/San_Juan
@@ -3,67 +3,67 @@
set TZData(:America/Argentina/San_Juan) {
{-9223372036854775808 -16444 0 LMT}
{-2372095556 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667792800 -14400 0 WART}
- {673588800 -10800 0 ART}
- {687927600 -7200 1 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1085972400 -14400 0 WART}
- {1090728000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667792800 -14400 0 -04}
+ {673588800 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1085972400 -14400 0 -04}
+ {1090728000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/San_Luis b/library/tzdata/America/Argentina/San_Luis
index 8ca55d7..3583a39 100644
--- a/library/tzdata/America/Argentina/San_Luis
+++ b/library/tzdata/America/Argentina/San_Luis
@@ -3,66 +3,66 @@
set TZData(:America/Argentina/San_Luis) {
{-9223372036854775808 -15924 0 LMT}
{-2372096076 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {631159200 -7200 1 ARST}
- {637380000 -14400 0 WART}
- {655963200 -10800 1 WARST}
- {667796400 -14400 0 WART}
- {675748800 -10800 0 ART}
- {938919600 -10800 1 WARST}
- {952052400 -10800 0 ART}
- {1085972400 -14400 0 WART}
- {1090728000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1200880800 -10800 0 WART}
- {1205031600 -14400 0 WART}
- {1223784000 -10800 1 WARST}
- {1236481200 -14400 0 WART}
- {1255233600 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {631159200 -7200 1 -02}
+ {637380000 -14400 0 -04}
+ {655963200 -10800 1 -03}
+ {667796400 -14400 0 -04}
+ {675748800 -10800 0 -03}
+ {938919600 -10800 1 -03}
+ {952052400 -10800 0 -03}
+ {1085972400 -14400 0 -04}
+ {1090728000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1200880800 -10800 0 -04}
+ {1205031600 -14400 0 -04}
+ {1223784000 -10800 1 -03}
+ {1236481200 -14400 0 -04}
+ {1255233600 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Tucuman b/library/tzdata/America/Argentina/Tucuman
index 3500986..15c5c63 100644
--- a/library/tzdata/America/Argentina/Tucuman
+++ b/library/tzdata/America/Argentina/Tucuman
@@ -3,67 +3,67 @@
set TZData(:America/Argentina/Tucuman) {
{-9223372036854775808 -15652 0 LMT}
{-2372096348 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -14400 0 WART}
- {687931200 -7200 0 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1086058800 -14400 0 WART}
- {1087099200 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224385200 -7200 1 ARST}
- {1237082400 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -14400 0 -04}
+ {687931200 -7200 0 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1086058800 -14400 0 -04}
+ {1087099200 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224385200 -7200 1 -02}
+ {1237082400 -10800 0 -03}
}
diff --git a/library/tzdata/America/Argentina/Ushuaia b/library/tzdata/America/Argentina/Ushuaia
index 4fcf92d..4214c1d 100644
--- a/library/tzdata/America/Argentina/Ushuaia
+++ b/library/tzdata/America/Argentina/Ushuaia
@@ -3,66 +3,66 @@
set TZData(:America/Argentina/Ushuaia) {
{-9223372036854775808 -16392 0 LMT}
{-2372095608 -15408 0 CMT}
- {-1567453392 -14400 0 ART}
- {-1233432000 -10800 0 ARST}
- {-1222981200 -14400 0 ART}
- {-1205956800 -10800 1 ARST}
- {-1194037200 -14400 0 ART}
- {-1172865600 -10800 1 ARST}
- {-1162501200 -14400 0 ART}
- {-1141329600 -10800 1 ARST}
- {-1130965200 -14400 0 ART}
- {-1109793600 -10800 1 ARST}
- {-1099429200 -14400 0 ART}
- {-1078257600 -10800 1 ARST}
- {-1067806800 -14400 0 ART}
- {-1046635200 -10800 1 ARST}
- {-1036270800 -14400 0 ART}
- {-1015099200 -10800 1 ARST}
- {-1004734800 -14400 0 ART}
- {-983563200 -10800 1 ARST}
- {-973198800 -14400 0 ART}
- {-952027200 -10800 1 ARST}
- {-941576400 -14400 0 ART}
- {-931032000 -10800 1 ARST}
- {-900882000 -14400 0 ART}
- {-890337600 -10800 1 ARST}
- {-833749200 -14400 0 ART}
- {-827265600 -10800 1 ARST}
- {-752274000 -14400 0 ART}
- {-733780800 -10800 1 ARST}
- {-197326800 -14400 0 ART}
- {-190843200 -10800 1 ARST}
- {-184194000 -14400 0 ART}
- {-164491200 -10800 1 ARST}
- {-152658000 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {596948400 -7200 1 ARST}
- {605066400 -10800 0 ART}
- {624423600 -7200 1 ARST}
- {636516000 -10800 0 ART}
- {656478000 -7200 1 ARST}
- {667965600 -10800 0 ART}
- {687927600 -7200 1 ARST}
- {699415200 -10800 0 ART}
- {719377200 -7200 1 ARST}
- {731469600 -10800 0 ART}
- {938916000 -10800 0 ART}
- {938919600 -10800 1 ARST}
- {952056000 -10800 0 ART}
- {1085886000 -14400 0 WART}
- {1087704000 -10800 0 ART}
- {1198983600 -7200 1 ARST}
- {1205632800 -10800 0 ART}
- {1224295200 -10800 0 ART}
+ {-1567453392 -14400 0 -04}
+ {-1233432000 -10800 0 -03}
+ {-1222981200 -14400 0 -04}
+ {-1205956800 -10800 1 -03}
+ {-1194037200 -14400 0 -04}
+ {-1172865600 -10800 1 -03}
+ {-1162501200 -14400 0 -04}
+ {-1141329600 -10800 1 -03}
+ {-1130965200 -14400 0 -04}
+ {-1109793600 -10800 1 -03}
+ {-1099429200 -14400 0 -04}
+ {-1078257600 -10800 1 -03}
+ {-1067806800 -14400 0 -04}
+ {-1046635200 -10800 1 -03}
+ {-1036270800 -14400 0 -04}
+ {-1015099200 -10800 1 -03}
+ {-1004734800 -14400 0 -04}
+ {-983563200 -10800 1 -03}
+ {-973198800 -14400 0 -04}
+ {-952027200 -10800 1 -03}
+ {-941576400 -14400 0 -04}
+ {-931032000 -10800 1 -03}
+ {-900882000 -14400 0 -04}
+ {-890337600 -10800 1 -03}
+ {-833749200 -14400 0 -04}
+ {-827265600 -10800 1 -03}
+ {-752274000 -14400 0 -04}
+ {-733780800 -10800 1 -03}
+ {-197326800 -14400 0 -04}
+ {-190843200 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-164491200 -10800 1 -03}
+ {-152658000 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {596948400 -7200 1 -02}
+ {605066400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {731469600 -10800 0 -03}
+ {938916000 -10800 0 -04}
+ {938919600 -10800 1 -03}
+ {952056000 -10800 0 -03}
+ {1085886000 -14400 0 -04}
+ {1087704000 -10800 0 -03}
+ {1198983600 -7200 1 -02}
+ {1205632800 -10800 0 -03}
+ {1224295200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Asuncion b/library/tzdata/America/Asuncion
index 9ea30da..606db57 100644
--- a/library/tzdata/America/Asuncion
+++ b/library/tzdata/America/Asuncion
@@ -3,257 +3,257 @@
set TZData(:America/Asuncion) {
{-9223372036854775808 -13840 0 LMT}
{-2524507760 -13840 0 AMT}
- {-1206389360 -14400 0 PYT}
- {86760000 -10800 0 PYT}
- {134017200 -14400 0 PYT}
- {162878400 -14400 0 PYT}
- {181368000 -10800 1 PYST}
- {194497200 -14400 0 PYT}
- {212990400 -10800 1 PYST}
- {226033200 -14400 0 PYT}
- {244526400 -10800 1 PYST}
- {257569200 -14400 0 PYT}
- {276062400 -10800 1 PYST}
- {291783600 -14400 0 PYT}
- {307598400 -10800 1 PYST}
- {323406000 -14400 0 PYT}
- {339220800 -10800 1 PYST}
- {354942000 -14400 0 PYT}
- {370756800 -10800 1 PYST}
- {386478000 -14400 0 PYT}
- {402292800 -10800 1 PYST}
- {418014000 -14400 0 PYT}
- {433828800 -10800 1 PYST}
- {449636400 -14400 0 PYT}
- {465451200 -10800 1 PYST}
- {481172400 -14400 0 PYT}
- {496987200 -10800 1 PYST}
- {512708400 -14400 0 PYT}
- {528523200 -10800 1 PYST}
- {544244400 -14400 0 PYT}
- {560059200 -10800 1 PYST}
- {575866800 -14400 0 PYT}
- {591681600 -10800 1 PYST}
- {607402800 -14400 0 PYT}
- {625032000 -10800 1 PYST}
- {638938800 -14400 0 PYT}
- {654753600 -10800 1 PYST}
- {670474800 -14400 0 PYT}
- {686721600 -10800 1 PYST}
- {699418800 -14400 0 PYT}
- {718257600 -10800 1 PYST}
- {733546800 -14400 0 PYT}
- {749448000 -10800 1 PYST}
- {762318000 -14400 0 PYT}
- {780984000 -10800 1 PYST}
- {793767600 -14400 0 PYT}
- {812520000 -10800 1 PYST}
- {825649200 -14400 0 PYT}
- {844574400 -10800 1 PYST}
- {856666800 -14400 0 PYT}
- {876024000 -10800 1 PYST}
- {888721200 -14400 0 PYT}
- {907473600 -10800 1 PYST}
- {920775600 -14400 0 PYT}
- {938923200 -10800 1 PYST}
- {952225200 -14400 0 PYT}
- {970372800 -10800 1 PYST}
- {983674800 -14400 0 PYT}
- {1002427200 -10800 1 PYST}
- {1018148400 -14400 0 PYT}
- {1030852800 -10800 1 PYST}
- {1049598000 -14400 0 PYT}
- {1062907200 -10800 1 PYST}
- {1081047600 -14400 0 PYT}
- {1097985600 -10800 1 PYST}
- {1110682800 -14400 0 PYT}
- {1129435200 -10800 1 PYST}
- {1142132400 -14400 0 PYT}
- {1160884800 -10800 1 PYST}
- {1173582000 -14400 0 PYT}
- {1192939200 -10800 1 PYST}
- {1205031600 -14400 0 PYT}
- {1224388800 -10800 1 PYST}
- {1236481200 -14400 0 PYT}
- {1255838400 -10800 1 PYST}
- {1270954800 -14400 0 PYT}
- {1286078400 -10800 1 PYST}
- {1302404400 -14400 0 PYT}
- {1317528000 -10800 1 PYST}
- {1333854000 -14400 0 PYT}
- {1349582400 -10800 1 PYST}
- {1364094000 -14400 0 PYT}
- {1381032000 -10800 1 PYST}
- {1395543600 -14400 0 PYT}
- {1412481600 -10800 1 PYST}
- {1426993200 -14400 0 PYT}
- {1443931200 -10800 1 PYST}
- {1459047600 -14400 0 PYT}
- {1475380800 -10800 1 PYST}
- {1490497200 -14400 0 PYT}
- {1506830400 -10800 1 PYST}
- {1521946800 -14400 0 PYT}
- {1538884800 -10800 1 PYST}
- {1553396400 -14400 0 PYT}
- {1570334400 -10800 1 PYST}
- {1584846000 -14400 0 PYT}
- {1601784000 -10800 1 PYST}
- {1616900400 -14400 0 PYT}
- {1633233600 -10800 1 PYST}
- {1648350000 -14400 0 PYT}
- {1664683200 -10800 1 PYST}
- {1679799600 -14400 0 PYT}
- {1696132800 -10800 1 PYST}
- {1711249200 -14400 0 PYT}
- {1728187200 -10800 1 PYST}
- {1742698800 -14400 0 PYT}
- {1759636800 -10800 1 PYST}
- {1774148400 -14400 0 PYT}
- {1791086400 -10800 1 PYST}
- {1806202800 -14400 0 PYT}
- {1822536000 -10800 1 PYST}
- {1837652400 -14400 0 PYT}
- {1853985600 -10800 1 PYST}
- {1869102000 -14400 0 PYT}
- {1886040000 -10800 1 PYST}
- {1900551600 -14400 0 PYT}
- {1917489600 -10800 1 PYST}
- {1932001200 -14400 0 PYT}
- {1948939200 -10800 1 PYST}
- {1964055600 -14400 0 PYT}
- {1980388800 -10800 1 PYST}
- {1995505200 -14400 0 PYT}
- {2011838400 -10800 1 PYST}
- {2026954800 -14400 0 PYT}
- {2043288000 -10800 1 PYST}
- {2058404400 -14400 0 PYT}
- {2075342400 -10800 1 PYST}
- {2089854000 -14400 0 PYT}
- {2106792000 -10800 1 PYST}
- {2121303600 -14400 0 PYT}
- {2138241600 -10800 1 PYST}
- {2153358000 -14400 0 PYT}
- {2169691200 -10800 1 PYST}
- {2184807600 -14400 0 PYT}
- {2201140800 -10800 1 PYST}
- {2216257200 -14400 0 PYT}
- {2233195200 -10800 1 PYST}
- {2247706800 -14400 0 PYT}
- {2264644800 -10800 1 PYST}
- {2279156400 -14400 0 PYT}
- {2296094400 -10800 1 PYST}
- {2310606000 -14400 0 PYT}
- {2327544000 -10800 1 PYST}
- {2342660400 -14400 0 PYT}
- {2358993600 -10800 1 PYST}
- {2374110000 -14400 0 PYT}
- {2390443200 -10800 1 PYST}
- {2405559600 -14400 0 PYT}
- {2422497600 -10800 1 PYST}
- {2437009200 -14400 0 PYT}
- {2453947200 -10800 1 PYST}
- {2468458800 -14400 0 PYT}
- {2485396800 -10800 1 PYST}
- {2500513200 -14400 0 PYT}
- {2516846400 -10800 1 PYST}
- {2531962800 -14400 0 PYT}
- {2548296000 -10800 1 PYST}
- {2563412400 -14400 0 PYT}
- {2579745600 -10800 1 PYST}
- {2594862000 -14400 0 PYT}
- {2611800000 -10800 1 PYST}
- {2626311600 -14400 0 PYT}
- {2643249600 -10800 1 PYST}
- {2657761200 -14400 0 PYT}
- {2674699200 -10800 1 PYST}
- {2689815600 -14400 0 PYT}
- {2706148800 -10800 1 PYST}
- {2721265200 -14400 0 PYT}
- {2737598400 -10800 1 PYST}
- {2752714800 -14400 0 PYT}
- {2769652800 -10800 1 PYST}
- {2784164400 -14400 0 PYT}
- {2801102400 -10800 1 PYST}
- {2815614000 -14400 0 PYT}
- {2832552000 -10800 1 PYST}
- {2847668400 -14400 0 PYT}
- {2864001600 -10800 1 PYST}
- {2879118000 -14400 0 PYT}
- {2895451200 -10800 1 PYST}
- {2910567600 -14400 0 PYT}
- {2926900800 -10800 1 PYST}
- {2942017200 -14400 0 PYT}
- {2958955200 -10800 1 PYST}
- {2973466800 -14400 0 PYT}
- {2990404800 -10800 1 PYST}
- {3004916400 -14400 0 PYT}
- {3021854400 -10800 1 PYST}
- {3036970800 -14400 0 PYT}
- {3053304000 -10800 1 PYST}
- {3068420400 -14400 0 PYT}
- {3084753600 -10800 1 PYST}
- {3099870000 -14400 0 PYT}
- {3116808000 -10800 1 PYST}
- {3131319600 -14400 0 PYT}
- {3148257600 -10800 1 PYST}
- {3162769200 -14400 0 PYT}
- {3179707200 -10800 1 PYST}
- {3194218800 -14400 0 PYT}
- {3211156800 -10800 1 PYST}
- {3226273200 -14400 0 PYT}
- {3242606400 -10800 1 PYST}
- {3257722800 -14400 0 PYT}
- {3274056000 -10800 1 PYST}
- {3289172400 -14400 0 PYT}
- {3306110400 -10800 1 PYST}
- {3320622000 -14400 0 PYT}
- {3337560000 -10800 1 PYST}
- {3352071600 -14400 0 PYT}
- {3369009600 -10800 1 PYST}
- {3384126000 -14400 0 PYT}
- {3400459200 -10800 1 PYST}
- {3415575600 -14400 0 PYT}
- {3431908800 -10800 1 PYST}
- {3447025200 -14400 0 PYT}
- {3463358400 -10800 1 PYST}
- {3478474800 -14400 0 PYT}
- {3495412800 -10800 1 PYST}
- {3509924400 -14400 0 PYT}
- {3526862400 -10800 1 PYST}
- {3541374000 -14400 0 PYT}
- {3558312000 -10800 1 PYST}
- {3573428400 -14400 0 PYT}
- {3589761600 -10800 1 PYST}
- {3604878000 -14400 0 PYT}
- {3621211200 -10800 1 PYST}
- {3636327600 -14400 0 PYT}
- {3653265600 -10800 1 PYST}
- {3667777200 -14400 0 PYT}
- {3684715200 -10800 1 PYST}
- {3699226800 -14400 0 PYT}
- {3716164800 -10800 1 PYST}
- {3731281200 -14400 0 PYT}
- {3747614400 -10800 1 PYST}
- {3762730800 -14400 0 PYT}
- {3779064000 -10800 1 PYST}
- {3794180400 -14400 0 PYT}
- {3810513600 -10800 1 PYST}
- {3825630000 -14400 0 PYT}
- {3842568000 -10800 1 PYST}
- {3857079600 -14400 0 PYT}
- {3874017600 -10800 1 PYST}
- {3888529200 -14400 0 PYT}
- {3905467200 -10800 1 PYST}
- {3920583600 -14400 0 PYT}
- {3936916800 -10800 1 PYST}
- {3952033200 -14400 0 PYT}
- {3968366400 -10800 1 PYST}
- {3983482800 -14400 0 PYT}
- {4000420800 -10800 1 PYST}
- {4014932400 -14400 0 PYT}
- {4031870400 -10800 1 PYST}
- {4046382000 -14400 0 PYT}
- {4063320000 -10800 1 PYST}
- {4077831600 -14400 0 PYT}
- {4094769600 -10800 1 PYST}
+ {-1206389360 -14400 0 -04}
+ {86760000 -10800 0 -03}
+ {134017200 -14400 0 -04}
+ {162878400 -14400 0 -04}
+ {181368000 -10800 1 -03}
+ {194497200 -14400 0 -04}
+ {212990400 -10800 1 -03}
+ {226033200 -14400 0 -04}
+ {244526400 -10800 1 -03}
+ {257569200 -14400 0 -04}
+ {276062400 -10800 1 -03}
+ {291783600 -14400 0 -04}
+ {307598400 -10800 1 -03}
+ {323406000 -14400 0 -04}
+ {339220800 -10800 1 -03}
+ {354942000 -14400 0 -04}
+ {370756800 -10800 1 -03}
+ {386478000 -14400 0 -04}
+ {402292800 -10800 1 -03}
+ {418014000 -14400 0 -04}
+ {433828800 -10800 1 -03}
+ {449636400 -14400 0 -04}
+ {465451200 -10800 1 -03}
+ {481172400 -14400 0 -04}
+ {496987200 -10800 1 -03}
+ {512708400 -14400 0 -04}
+ {528523200 -10800 1 -03}
+ {544244400 -14400 0 -04}
+ {560059200 -10800 1 -03}
+ {575866800 -14400 0 -04}
+ {591681600 -10800 1 -03}
+ {607402800 -14400 0 -04}
+ {625032000 -10800 1 -03}
+ {638938800 -14400 0 -04}
+ {654753600 -10800 1 -03}
+ {670474800 -14400 0 -04}
+ {686721600 -10800 1 -03}
+ {699418800 -14400 0 -04}
+ {718257600 -10800 1 -03}
+ {733546800 -14400 0 -04}
+ {749448000 -10800 1 -03}
+ {762318000 -14400 0 -04}
+ {780984000 -10800 1 -03}
+ {793767600 -14400 0 -04}
+ {812520000 -10800 1 -03}
+ {825649200 -14400 0 -04}
+ {844574400 -10800 1 -03}
+ {856666800 -14400 0 -04}
+ {876024000 -10800 1 -03}
+ {888721200 -14400 0 -04}
+ {907473600 -10800 1 -03}
+ {920775600 -14400 0 -04}
+ {938923200 -10800 1 -03}
+ {952225200 -14400 0 -04}
+ {970372800 -10800 1 -03}
+ {983674800 -14400 0 -04}
+ {1002427200 -10800 1 -03}
+ {1018148400 -14400 0 -04}
+ {1030852800 -10800 1 -03}
+ {1049598000 -14400 0 -04}
+ {1062907200 -10800 1 -03}
+ {1081047600 -14400 0 -04}
+ {1097985600 -10800 1 -03}
+ {1110682800 -14400 0 -04}
+ {1129435200 -10800 1 -03}
+ {1142132400 -14400 0 -04}
+ {1160884800 -10800 1 -03}
+ {1173582000 -14400 0 -04}
+ {1192939200 -10800 1 -03}
+ {1205031600 -14400 0 -04}
+ {1224388800 -10800 1 -03}
+ {1236481200 -14400 0 -04}
+ {1255838400 -10800 1 -03}
+ {1270954800 -14400 0 -04}
+ {1286078400 -10800 1 -03}
+ {1302404400 -14400 0 -04}
+ {1317528000 -10800 1 -03}
+ {1333854000 -14400 0 -04}
+ {1349582400 -10800 1 -03}
+ {1364094000 -14400 0 -04}
+ {1381032000 -10800 1 -03}
+ {1395543600 -14400 0 -04}
+ {1412481600 -10800 1 -03}
+ {1426993200 -14400 0 -04}
+ {1443931200 -10800 1 -03}
+ {1459047600 -14400 0 -04}
+ {1475380800 -10800 1 -03}
+ {1490497200 -14400 0 -04}
+ {1506830400 -10800 1 -03}
+ {1521946800 -14400 0 -04}
+ {1538884800 -10800 1 -03}
+ {1553396400 -14400 0 -04}
+ {1570334400 -10800 1 -03}
+ {1584846000 -14400 0 -04}
+ {1601784000 -10800 1 -03}
+ {1616900400 -14400 0 -04}
+ {1633233600 -10800 1 -03}
+ {1648350000 -14400 0 -04}
+ {1664683200 -10800 1 -03}
+ {1679799600 -14400 0 -04}
+ {1696132800 -10800 1 -03}
+ {1711249200 -14400 0 -04}
+ {1728187200 -10800 1 -03}
+ {1742698800 -14400 0 -04}
+ {1759636800 -10800 1 -03}
+ {1774148400 -14400 0 -04}
+ {1791086400 -10800 1 -03}
+ {1806202800 -14400 0 -04}
+ {1822536000 -10800 1 -03}
+ {1837652400 -14400 0 -04}
+ {1853985600 -10800 1 -03}
+ {1869102000 -14400 0 -04}
+ {1886040000 -10800 1 -03}
+ {1900551600 -14400 0 -04}
+ {1917489600 -10800 1 -03}
+ {1932001200 -14400 0 -04}
+ {1948939200 -10800 1 -03}
+ {1964055600 -14400 0 -04}
+ {1980388800 -10800 1 -03}
+ {1995505200 -14400 0 -04}
+ {2011838400 -10800 1 -03}
+ {2026954800 -14400 0 -04}
+ {2043288000 -10800 1 -03}
+ {2058404400 -14400 0 -04}
+ {2075342400 -10800 1 -03}
+ {2089854000 -14400 0 -04}
+ {2106792000 -10800 1 -03}
+ {2121303600 -14400 0 -04}
+ {2138241600 -10800 1 -03}
+ {2153358000 -14400 0 -04}
+ {2169691200 -10800 1 -03}
+ {2184807600 -14400 0 -04}
+ {2201140800 -10800 1 -03}
+ {2216257200 -14400 0 -04}
+ {2233195200 -10800 1 -03}
+ {2247706800 -14400 0 -04}
+ {2264644800 -10800 1 -03}
+ {2279156400 -14400 0 -04}
+ {2296094400 -10800 1 -03}
+ {2310606000 -14400 0 -04}
+ {2327544000 -10800 1 -03}
+ {2342660400 -14400 0 -04}
+ {2358993600 -10800 1 -03}
+ {2374110000 -14400 0 -04}
+ {2390443200 -10800 1 -03}
+ {2405559600 -14400 0 -04}
+ {2422497600 -10800 1 -03}
+ {2437009200 -14400 0 -04}
+ {2453947200 -10800 1 -03}
+ {2468458800 -14400 0 -04}
+ {2485396800 -10800 1 -03}
+ {2500513200 -14400 0 -04}
+ {2516846400 -10800 1 -03}
+ {2531962800 -14400 0 -04}
+ {2548296000 -10800 1 -03}
+ {2563412400 -14400 0 -04}
+ {2579745600 -10800 1 -03}
+ {2594862000 -14400 0 -04}
+ {2611800000 -10800 1 -03}
+ {2626311600 -14400 0 -04}
+ {2643249600 -10800 1 -03}
+ {2657761200 -14400 0 -04}
+ {2674699200 -10800 1 -03}
+ {2689815600 -14400 0 -04}
+ {2706148800 -10800 1 -03}
+ {2721265200 -14400 0 -04}
+ {2737598400 -10800 1 -03}
+ {2752714800 -14400 0 -04}
+ {2769652800 -10800 1 -03}
+ {2784164400 -14400 0 -04}
+ {2801102400 -10800 1 -03}
+ {2815614000 -14400 0 -04}
+ {2832552000 -10800 1 -03}
+ {2847668400 -14400 0 -04}
+ {2864001600 -10800 1 -03}
+ {2879118000 -14400 0 -04}
+ {2895451200 -10800 1 -03}
+ {2910567600 -14400 0 -04}
+ {2926900800 -10800 1 -03}
+ {2942017200 -14400 0 -04}
+ {2958955200 -10800 1 -03}
+ {2973466800 -14400 0 -04}
+ {2990404800 -10800 1 -03}
+ {3004916400 -14400 0 -04}
+ {3021854400 -10800 1 -03}
+ {3036970800 -14400 0 -04}
+ {3053304000 -10800 1 -03}
+ {3068420400 -14400 0 -04}
+ {3084753600 -10800 1 -03}
+ {3099870000 -14400 0 -04}
+ {3116808000 -10800 1 -03}
+ {3131319600 -14400 0 -04}
+ {3148257600 -10800 1 -03}
+ {3162769200 -14400 0 -04}
+ {3179707200 -10800 1 -03}
+ {3194218800 -14400 0 -04}
+ {3211156800 -10800 1 -03}
+ {3226273200 -14400 0 -04}
+ {3242606400 -10800 1 -03}
+ {3257722800 -14400 0 -04}
+ {3274056000 -10800 1 -03}
+ {3289172400 -14400 0 -04}
+ {3306110400 -10800 1 -03}
+ {3320622000 -14400 0 -04}
+ {3337560000 -10800 1 -03}
+ {3352071600 -14400 0 -04}
+ {3369009600 -10800 1 -03}
+ {3384126000 -14400 0 -04}
+ {3400459200 -10800 1 -03}
+ {3415575600 -14400 0 -04}
+ {3431908800 -10800 1 -03}
+ {3447025200 -14400 0 -04}
+ {3463358400 -10800 1 -03}
+ {3478474800 -14400 0 -04}
+ {3495412800 -10800 1 -03}
+ {3509924400 -14400 0 -04}
+ {3526862400 -10800 1 -03}
+ {3541374000 -14400 0 -04}
+ {3558312000 -10800 1 -03}
+ {3573428400 -14400 0 -04}
+ {3589761600 -10800 1 -03}
+ {3604878000 -14400 0 -04}
+ {3621211200 -10800 1 -03}
+ {3636327600 -14400 0 -04}
+ {3653265600 -10800 1 -03}
+ {3667777200 -14400 0 -04}
+ {3684715200 -10800 1 -03}
+ {3699226800 -14400 0 -04}
+ {3716164800 -10800 1 -03}
+ {3731281200 -14400 0 -04}
+ {3747614400 -10800 1 -03}
+ {3762730800 -14400 0 -04}
+ {3779064000 -10800 1 -03}
+ {3794180400 -14400 0 -04}
+ {3810513600 -10800 1 -03}
+ {3825630000 -14400 0 -04}
+ {3842568000 -10800 1 -03}
+ {3857079600 -14400 0 -04}
+ {3874017600 -10800 1 -03}
+ {3888529200 -14400 0 -04}
+ {3905467200 -10800 1 -03}
+ {3920583600 -14400 0 -04}
+ {3936916800 -10800 1 -03}
+ {3952033200 -14400 0 -04}
+ {3968366400 -10800 1 -03}
+ {3983482800 -14400 0 -04}
+ {4000420800 -10800 1 -03}
+ {4014932400 -14400 0 -04}
+ {4031870400 -10800 1 -03}
+ {4046382000 -14400 0 -04}
+ {4063320000 -10800 1 -03}
+ {4077831600 -14400 0 -04}
+ {4094769600 -10800 1 -03}
}
diff --git a/library/tzdata/America/Bahia b/library/tzdata/America/Bahia
index ac67b71..7dbcb90 100644
--- a/library/tzdata/America/Bahia
+++ b/library/tzdata/America/Bahia
@@ -2,67 +2,67 @@
set TZData(:America/Bahia) {
{-9223372036854775808 -9244 0 LMT}
- {-1767216356 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {656478000 -7200 1 BRST}
- {666756000 -10800 0 BRT}
- {687927600 -7200 1 BRST}
- {697600800 -10800 0 BRT}
- {719982000 -7200 1 BRST}
- {728445600 -10800 0 BRT}
- {750826800 -7200 1 BRST}
- {761709600 -10800 0 BRT}
- {782276400 -7200 1 BRST}
- {793159200 -10800 0 BRT}
- {813726000 -7200 1 BRST}
- {824004000 -10800 0 BRT}
- {844570800 -7200 1 BRST}
- {856058400 -10800 0 BRT}
- {876106800 -7200 1 BRST}
- {888717600 -10800 0 BRT}
- {908074800 -7200 1 BRST}
- {919562400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {982461600 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1036292400 -7200 1 BRST}
- {1045360800 -10800 0 BRT}
- {1064368800 -10800 0 BRT}
- {1318734000 -7200 0 BRST}
- {1330221600 -10800 0 BRT}
- {1350784800 -10800 0 BRT}
+ {-1767216356 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {666756000 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {697600800 -10800 0 -03}
+ {719982000 -7200 1 -02}
+ {728445600 -10800 0 -03}
+ {750826800 -7200 1 -02}
+ {761709600 -10800 0 -03}
+ {782276400 -7200 1 -02}
+ {793159200 -10800 0 -03}
+ {813726000 -7200 1 -02}
+ {824004000 -10800 0 -03}
+ {844570800 -7200 1 -02}
+ {856058400 -10800 0 -03}
+ {876106800 -7200 1 -02}
+ {888717600 -10800 0 -03}
+ {908074800 -7200 1 -02}
+ {919562400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {982461600 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1036292400 -7200 1 -02}
+ {1045360800 -10800 0 -03}
+ {1064368800 -10800 0 -03}
+ {1318734000 -7200 0 -02}
+ {1330221600 -10800 0 -03}
+ {1350784800 -10800 0 -03}
}
diff --git a/library/tzdata/America/Belem b/library/tzdata/America/Belem
index ed92fd1..b2bf3a6 100644
--- a/library/tzdata/America/Belem
+++ b/library/tzdata/America/Belem
@@ -2,34 +2,34 @@
set TZData(:America/Belem) {
{-9223372036854775808 -11636 0 LMT}
- {-1767213964 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {590032800 -10800 0 BRT}
+ {-1767213964 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {590032800 -10800 0 -03}
}
diff --git a/library/tzdata/America/Belize b/library/tzdata/America/Belize
index 547fd72..5b46388 100644
--- a/library/tzdata/America/Belize
+++ b/library/tzdata/America/Belize
@@ -3,55 +3,55 @@
set TZData(:America/Belize) {
{-9223372036854775808 -21168 0 LMT}
{-1822500432 -21600 0 CST}
- {-1616954400 -19800 1 CHDT}
+ {-1616954400 -19800 1 -0530}
{-1606069800 -21600 0 CST}
- {-1585504800 -19800 1 CHDT}
+ {-1585504800 -19800 1 -0530}
{-1574015400 -21600 0 CST}
- {-1554055200 -19800 1 CHDT}
+ {-1554055200 -19800 1 -0530}
{-1542565800 -21600 0 CST}
- {-1522605600 -19800 1 CHDT}
+ {-1522605600 -19800 1 -0530}
{-1511116200 -21600 0 CST}
- {-1490551200 -19800 1 CHDT}
+ {-1490551200 -19800 1 -0530}
{-1479666600 -21600 0 CST}
- {-1459101600 -19800 1 CHDT}
+ {-1459101600 -19800 1 -0530}
{-1448217000 -21600 0 CST}
- {-1427652000 -19800 1 CHDT}
+ {-1427652000 -19800 1 -0530}
{-1416162600 -21600 0 CST}
- {-1396202400 -19800 1 CHDT}
+ {-1396202400 -19800 1 -0530}
{-1384713000 -21600 0 CST}
- {-1364752800 -19800 1 CHDT}
+ {-1364752800 -19800 1 -0530}
{-1353263400 -21600 0 CST}
- {-1333303200 -19800 1 CHDT}
+ {-1333303200 -19800 1 -0530}
{-1321813800 -21600 0 CST}
- {-1301248800 -19800 1 CHDT}
+ {-1301248800 -19800 1 -0530}
{-1290364200 -21600 0 CST}
- {-1269799200 -19800 1 CHDT}
+ {-1269799200 -19800 1 -0530}
{-1258914600 -21600 0 CST}
- {-1238349600 -19800 1 CHDT}
+ {-1238349600 -19800 1 -0530}
{-1226860200 -21600 0 CST}
- {-1206900000 -19800 1 CHDT}
+ {-1206900000 -19800 1 -0530}
{-1195410600 -21600 0 CST}
- {-1175450400 -19800 1 CHDT}
+ {-1175450400 -19800 1 -0530}
{-1163961000 -21600 0 CST}
- {-1143396000 -19800 1 CHDT}
+ {-1143396000 -19800 1 -0530}
{-1132511400 -21600 0 CST}
- {-1111946400 -19800 1 CHDT}
+ {-1111946400 -19800 1 -0530}
{-1101061800 -21600 0 CST}
- {-1080496800 -19800 1 CHDT}
+ {-1080496800 -19800 1 -0530}
{-1069612200 -21600 0 CST}
- {-1049047200 -19800 1 CHDT}
+ {-1049047200 -19800 1 -0530}
{-1037557800 -21600 0 CST}
- {-1017597600 -19800 1 CHDT}
+ {-1017597600 -19800 1 -0530}
{-1006108200 -21600 0 CST}
- {-986148000 -19800 1 CHDT}
+ {-986148000 -19800 1 -0530}
{-974658600 -21600 0 CST}
- {-954093600 -19800 1 CHDT}
+ {-954093600 -19800 1 -0530}
{-943209000 -21600 0 CST}
- {-922644000 -19800 1 CHDT}
+ {-922644000 -19800 1 -0530}
{-911759400 -21600 0 CST}
- {-891194400 -19800 1 CHDT}
+ {-891194400 -19800 1 -0530}
{-879705000 -21600 0 CST}
- {-859744800 -19800 1 CHDT}
+ {-859744800 -19800 1 -0530}
{-848255400 -21600 0 CST}
{123919200 -18000 1 CDT}
{129618000 -21600 0 CST}
diff --git a/library/tzdata/America/Boa_Vista b/library/tzdata/America/Boa_Vista
index c85bc27..982249b 100644
--- a/library/tzdata/America/Boa_Vista
+++ b/library/tzdata/America/Boa_Vista
@@ -2,39 +2,39 @@
set TZData(:America/Boa_Vista) {
{-9223372036854775808 -14560 0 LMT}
- {-1767211040 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {590036400 -14400 0 AMT}
- {938664000 -14400 0 AMT}
- {938923200 -10800 1 AMST}
- {951620400 -14400 0 AMT}
- {970977600 -10800 1 AMST}
- {971578800 -14400 0 AMT}
+ {-1767211040 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {590036400 -14400 0 -04}
+ {938664000 -14400 0 -04}
+ {938923200 -10800 1 -03}
+ {951620400 -14400 0 -04}
+ {970977600 -10800 1 -03}
+ {971578800 -14400 0 -04}
}
diff --git a/library/tzdata/America/Bogota b/library/tzdata/America/Bogota
index b28abc1..69e4557 100644
--- a/library/tzdata/America/Bogota
+++ b/library/tzdata/America/Bogota
@@ -3,7 +3,7 @@
set TZData(:America/Bogota) {
{-9223372036854775808 -17776 0 LMT}
{-2707671824 -17776 0 BMT}
- {-1739041424 -18000 0 COT}
- {704869200 -14400 1 COST}
- {733896000 -18000 0 COT}
+ {-1739041424 -18000 0 -05}
+ {704869200 -14400 1 -04}
+ {733896000 -18000 0 -05}
}
diff --git a/library/tzdata/America/Campo_Grande b/library/tzdata/America/Campo_Grande
index 2cafe14..77cb4d1 100644
--- a/library/tzdata/America/Campo_Grande
+++ b/library/tzdata/America/Campo_Grande
@@ -2,256 +2,256 @@
set TZData(:America/Campo_Grande) {
{-9223372036854775808 -13108 0 LMT}
- {-1767212492 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {592977600 -10800 1 AMST}
- {602046000 -14400 0 AMT}
- {624427200 -10800 1 AMST}
- {634705200 -14400 0 AMT}
- {656481600 -10800 1 AMST}
- {666759600 -14400 0 AMT}
- {687931200 -10800 1 AMST}
- {697604400 -14400 0 AMT}
- {719985600 -10800 1 AMST}
- {728449200 -14400 0 AMT}
- {750830400 -10800 1 AMST}
- {761713200 -14400 0 AMT}
- {782280000 -10800 1 AMST}
- {793162800 -14400 0 AMT}
- {813729600 -10800 1 AMST}
- {824007600 -14400 0 AMT}
- {844574400 -10800 1 AMST}
- {856062000 -14400 0 AMT}
- {876110400 -10800 1 AMST}
- {888721200 -14400 0 AMT}
- {908078400 -10800 1 AMST}
- {919566000 -14400 0 AMT}
- {938923200 -10800 1 AMST}
- {951620400 -14400 0 AMT}
- {970977600 -10800 1 AMST}
- {982465200 -14400 0 AMT}
- {1003032000 -10800 1 AMST}
- {1013914800 -14400 0 AMT}
- {1036296000 -10800 1 AMST}
- {1045364400 -14400 0 AMT}
- {1066536000 -10800 1 AMST}
- {1076814000 -14400 0 AMT}
- {1099368000 -10800 1 AMST}
- {1108868400 -14400 0 AMT}
- {1129435200 -10800 1 AMST}
- {1140318000 -14400 0 AMT}
- {1162699200 -10800 1 AMST}
- {1172372400 -14400 0 AMT}
- {1192334400 -10800 1 AMST}
- {1203217200 -14400 0 AMT}
- {1224388800 -10800 1 AMST}
- {1234666800 -14400 0 AMT}
- {1255838400 -10800 1 AMST}
- {1266721200 -14400 0 AMT}
- {1287288000 -10800 1 AMST}
- {1298170800 -14400 0 AMT}
- {1318737600 -10800 1 AMST}
- {1330225200 -14400 0 AMT}
- {1350792000 -10800 1 AMST}
- {1361070000 -14400 0 AMT}
- {1382241600 -10800 1 AMST}
- {1392519600 -14400 0 AMT}
- {1413691200 -10800 1 AMST}
- {1424574000 -14400 0 AMT}
- {1445140800 -10800 1 AMST}
- {1456023600 -14400 0 AMT}
- {1476590400 -10800 1 AMST}
- {1487473200 -14400 0 AMT}
- {1508040000 -10800 1 AMST}
- {1518922800 -14400 0 AMT}
- {1540094400 -10800 1 AMST}
- {1550372400 -14400 0 AMT}
- {1571544000 -10800 1 AMST}
- {1581822000 -14400 0 AMT}
- {1602993600 -10800 1 AMST}
- {1613876400 -14400 0 AMT}
- {1634443200 -10800 1 AMST}
- {1645326000 -14400 0 AMT}
- {1665892800 -10800 1 AMST}
- {1677380400 -14400 0 AMT}
- {1697342400 -10800 1 AMST}
- {1708225200 -14400 0 AMT}
- {1729396800 -10800 1 AMST}
- {1739674800 -14400 0 AMT}
- {1760846400 -10800 1 AMST}
- {1771729200 -14400 0 AMT}
- {1792296000 -10800 1 AMST}
- {1803178800 -14400 0 AMT}
- {1823745600 -10800 1 AMST}
- {1834628400 -14400 0 AMT}
- {1855195200 -10800 1 AMST}
- {1866078000 -14400 0 AMT}
- {1887249600 -10800 1 AMST}
- {1897527600 -14400 0 AMT}
- {1918699200 -10800 1 AMST}
- {1928977200 -14400 0 AMT}
- {1950148800 -10800 1 AMST}
- {1960426800 -14400 0 AMT}
- {1981598400 -10800 1 AMST}
- {1992481200 -14400 0 AMT}
- {2013048000 -10800 1 AMST}
- {2024535600 -14400 0 AMT}
- {2044497600 -10800 1 AMST}
- {2055380400 -14400 0 AMT}
- {2076552000 -10800 1 AMST}
- {2086830000 -14400 0 AMT}
- {2108001600 -10800 1 AMST}
- {2118884400 -14400 0 AMT}
- {2139451200 -10800 1 AMST}
- {2150334000 -14400 0 AMT}
- {2170900800 -10800 1 AMST}
- {2181783600 -14400 0 AMT}
- {2202350400 -10800 1 AMST}
- {2213233200 -14400 0 AMT}
- {2234404800 -10800 1 AMST}
- {2244682800 -14400 0 AMT}
- {2265854400 -10800 1 AMST}
- {2276132400 -14400 0 AMT}
- {2297304000 -10800 1 AMST}
- {2307582000 -14400 0 AMT}
- {2328753600 -10800 1 AMST}
- {2339636400 -14400 0 AMT}
- {2360203200 -10800 1 AMST}
- {2371086000 -14400 0 AMT}
- {2391652800 -10800 1 AMST}
- {2402535600 -14400 0 AMT}
- {2423707200 -10800 1 AMST}
- {2433985200 -14400 0 AMT}
- {2455156800 -10800 1 AMST}
- {2465434800 -14400 0 AMT}
- {2486606400 -10800 1 AMST}
- {2497489200 -14400 0 AMT}
- {2518056000 -10800 1 AMST}
- {2528938800 -14400 0 AMT}
- {2549505600 -10800 1 AMST}
- {2560388400 -14400 0 AMT}
- {2580955200 -10800 1 AMST}
- {2591838000 -14400 0 AMT}
- {2613009600 -10800 1 AMST}
- {2623287600 -14400 0 AMT}
- {2644459200 -10800 1 AMST}
- {2654737200 -14400 0 AMT}
- {2675908800 -10800 1 AMST}
- {2686791600 -14400 0 AMT}
- {2707358400 -10800 1 AMST}
- {2718241200 -14400 0 AMT}
- {2738808000 -10800 1 AMST}
- {2749690800 -14400 0 AMT}
- {2770862400 -10800 1 AMST}
- {2781140400 -14400 0 AMT}
- {2802312000 -10800 1 AMST}
- {2812590000 -14400 0 AMT}
- {2833761600 -10800 1 AMST}
- {2844039600 -14400 0 AMT}
- {2865211200 -10800 1 AMST}
- {2876094000 -14400 0 AMT}
- {2896660800 -10800 1 AMST}
- {2907543600 -14400 0 AMT}
- {2928110400 -10800 1 AMST}
- {2938993200 -14400 0 AMT}
- {2960164800 -10800 1 AMST}
- {2970442800 -14400 0 AMT}
- {2991614400 -10800 1 AMST}
- {3001892400 -14400 0 AMT}
- {3023064000 -10800 1 AMST}
- {3033946800 -14400 0 AMT}
- {3054513600 -10800 1 AMST}
- {3065396400 -14400 0 AMT}
- {3085963200 -10800 1 AMST}
- {3096846000 -14400 0 AMT}
- {3118017600 -10800 1 AMST}
- {3128295600 -14400 0 AMT}
- {3149467200 -10800 1 AMST}
- {3159745200 -14400 0 AMT}
- {3180916800 -10800 1 AMST}
- {3191194800 -14400 0 AMT}
- {3212366400 -10800 1 AMST}
- {3223249200 -14400 0 AMT}
- {3243816000 -10800 1 AMST}
- {3254698800 -14400 0 AMT}
- {3275265600 -10800 1 AMST}
- {3286148400 -14400 0 AMT}
- {3307320000 -10800 1 AMST}
- {3317598000 -14400 0 AMT}
- {3338769600 -10800 1 AMST}
- {3349047600 -14400 0 AMT}
- {3370219200 -10800 1 AMST}
- {3381102000 -14400 0 AMT}
- {3401668800 -10800 1 AMST}
- {3412551600 -14400 0 AMT}
- {3433118400 -10800 1 AMST}
- {3444001200 -14400 0 AMT}
- {3464568000 -10800 1 AMST}
- {3475450800 -14400 0 AMT}
- {3496622400 -10800 1 AMST}
- {3506900400 -14400 0 AMT}
- {3528072000 -10800 1 AMST}
- {3538350000 -14400 0 AMT}
- {3559521600 -10800 1 AMST}
- {3570404400 -14400 0 AMT}
- {3590971200 -10800 1 AMST}
- {3601854000 -14400 0 AMT}
- {3622420800 -10800 1 AMST}
- {3633303600 -14400 0 AMT}
- {3654475200 -10800 1 AMST}
- {3664753200 -14400 0 AMT}
- {3685924800 -10800 1 AMST}
- {3696202800 -14400 0 AMT}
- {3717374400 -10800 1 AMST}
- {3727652400 -14400 0 AMT}
- {3748824000 -10800 1 AMST}
- {3759706800 -14400 0 AMT}
- {3780273600 -10800 1 AMST}
- {3791156400 -14400 0 AMT}
- {3811723200 -10800 1 AMST}
- {3822606000 -14400 0 AMT}
- {3843777600 -10800 1 AMST}
- {3854055600 -14400 0 AMT}
- {3875227200 -10800 1 AMST}
- {3885505200 -14400 0 AMT}
- {3906676800 -10800 1 AMST}
- {3917559600 -14400 0 AMT}
- {3938126400 -10800 1 AMST}
- {3949009200 -14400 0 AMT}
- {3969576000 -10800 1 AMST}
- {3980458800 -14400 0 AMT}
- {4001630400 -10800 1 AMST}
- {4011908400 -14400 0 AMT}
- {4033080000 -10800 1 AMST}
- {4043358000 -14400 0 AMT}
- {4064529600 -10800 1 AMST}
- {4074807600 -14400 0 AMT}
- {4095979200 -10800 1 AMST}
+ {-1767212492 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {592977600 -10800 1 -03}
+ {602046000 -14400 0 -04}
+ {624427200 -10800 1 -03}
+ {634705200 -14400 0 -04}
+ {656481600 -10800 1 -03}
+ {666759600 -14400 0 -04}
+ {687931200 -10800 1 -03}
+ {697604400 -14400 0 -04}
+ {719985600 -10800 1 -03}
+ {728449200 -14400 0 -04}
+ {750830400 -10800 1 -03}
+ {761713200 -14400 0 -04}
+ {782280000 -10800 1 -03}
+ {793162800 -14400 0 -04}
+ {813729600 -10800 1 -03}
+ {824007600 -14400 0 -04}
+ {844574400 -10800 1 -03}
+ {856062000 -14400 0 -04}
+ {876110400 -10800 1 -03}
+ {888721200 -14400 0 -04}
+ {908078400 -10800 1 -03}
+ {919566000 -14400 0 -04}
+ {938923200 -10800 1 -03}
+ {951620400 -14400 0 -04}
+ {970977600 -10800 1 -03}
+ {982465200 -14400 0 -04}
+ {1003032000 -10800 1 -03}
+ {1013914800 -14400 0 -04}
+ {1036296000 -10800 1 -03}
+ {1045364400 -14400 0 -04}
+ {1066536000 -10800 1 -03}
+ {1076814000 -14400 0 -04}
+ {1099368000 -10800 1 -03}
+ {1108868400 -14400 0 -04}
+ {1129435200 -10800 1 -03}
+ {1140318000 -14400 0 -04}
+ {1162699200 -10800 1 -03}
+ {1172372400 -14400 0 -04}
+ {1192334400 -10800 1 -03}
+ {1203217200 -14400 0 -04}
+ {1224388800 -10800 1 -03}
+ {1234666800 -14400 0 -04}
+ {1255838400 -10800 1 -03}
+ {1266721200 -14400 0 -04}
+ {1287288000 -10800 1 -03}
+ {1298170800 -14400 0 -04}
+ {1318737600 -10800 1 -03}
+ {1330225200 -14400 0 -04}
+ {1350792000 -10800 1 -03}
+ {1361070000 -14400 0 -04}
+ {1382241600 -10800 1 -03}
+ {1392519600 -14400 0 -04}
+ {1413691200 -10800 1 -03}
+ {1424574000 -14400 0 -04}
+ {1445140800 -10800 1 -03}
+ {1456023600 -14400 0 -04}
+ {1476590400 -10800 1 -03}
+ {1487473200 -14400 0 -04}
+ {1508040000 -10800 1 -03}
+ {1518922800 -14400 0 -04}
+ {1540094400 -10800 1 -03}
+ {1550372400 -14400 0 -04}
+ {1571544000 -10800 1 -03}
+ {1581822000 -14400 0 -04}
+ {1602993600 -10800 1 -03}
+ {1613876400 -14400 0 -04}
+ {1634443200 -10800 1 -03}
+ {1645326000 -14400 0 -04}
+ {1665892800 -10800 1 -03}
+ {1677380400 -14400 0 -04}
+ {1697342400 -10800 1 -03}
+ {1708225200 -14400 0 -04}
+ {1729396800 -10800 1 -03}
+ {1739674800 -14400 0 -04}
+ {1760846400 -10800 1 -03}
+ {1771729200 -14400 0 -04}
+ {1792296000 -10800 1 -03}
+ {1803178800 -14400 0 -04}
+ {1823745600 -10800 1 -03}
+ {1834628400 -14400 0 -04}
+ {1855195200 -10800 1 -03}
+ {1866078000 -14400 0 -04}
+ {1887249600 -10800 1 -03}
+ {1897527600 -14400 0 -04}
+ {1918699200 -10800 1 -03}
+ {1928977200 -14400 0 -04}
+ {1950148800 -10800 1 -03}
+ {1960426800 -14400 0 -04}
+ {1981598400 -10800 1 -03}
+ {1992481200 -14400 0 -04}
+ {2013048000 -10800 1 -03}
+ {2024535600 -14400 0 -04}
+ {2044497600 -10800 1 -03}
+ {2055380400 -14400 0 -04}
+ {2076552000 -10800 1 -03}
+ {2086830000 -14400 0 -04}
+ {2108001600 -10800 1 -03}
+ {2118884400 -14400 0 -04}
+ {2139451200 -10800 1 -03}
+ {2150334000 -14400 0 -04}
+ {2170900800 -10800 1 -03}
+ {2181783600 -14400 0 -04}
+ {2202350400 -10800 1 -03}
+ {2213233200 -14400 0 -04}
+ {2234404800 -10800 1 -03}
+ {2244682800 -14400 0 -04}
+ {2265854400 -10800 1 -03}
+ {2276132400 -14400 0 -04}
+ {2297304000 -10800 1 -03}
+ {2307582000 -14400 0 -04}
+ {2328753600 -10800 1 -03}
+ {2339636400 -14400 0 -04}
+ {2360203200 -10800 1 -03}
+ {2371086000 -14400 0 -04}
+ {2391652800 -10800 1 -03}
+ {2402535600 -14400 0 -04}
+ {2423707200 -10800 1 -03}
+ {2433985200 -14400 0 -04}
+ {2455156800 -10800 1 -03}
+ {2465434800 -14400 0 -04}
+ {2486606400 -10800 1 -03}
+ {2497489200 -14400 0 -04}
+ {2518056000 -10800 1 -03}
+ {2528938800 -14400 0 -04}
+ {2549505600 -10800 1 -03}
+ {2560388400 -14400 0 -04}
+ {2580955200 -10800 1 -03}
+ {2591838000 -14400 0 -04}
+ {2613009600 -10800 1 -03}
+ {2623287600 -14400 0 -04}
+ {2644459200 -10800 1 -03}
+ {2654737200 -14400 0 -04}
+ {2675908800 -10800 1 -03}
+ {2686791600 -14400 0 -04}
+ {2707358400 -10800 1 -03}
+ {2718241200 -14400 0 -04}
+ {2738808000 -10800 1 -03}
+ {2749690800 -14400 0 -04}
+ {2770862400 -10800 1 -03}
+ {2781140400 -14400 0 -04}
+ {2802312000 -10800 1 -03}
+ {2812590000 -14400 0 -04}
+ {2833761600 -10800 1 -03}
+ {2844039600 -14400 0 -04}
+ {2865211200 -10800 1 -03}
+ {2876094000 -14400 0 -04}
+ {2896660800 -10800 1 -03}
+ {2907543600 -14400 0 -04}
+ {2928110400 -10800 1 -03}
+ {2938993200 -14400 0 -04}
+ {2960164800 -10800 1 -03}
+ {2970442800 -14400 0 -04}
+ {2991614400 -10800 1 -03}
+ {3001892400 -14400 0 -04}
+ {3023064000 -10800 1 -03}
+ {3033946800 -14400 0 -04}
+ {3054513600 -10800 1 -03}
+ {3065396400 -14400 0 -04}
+ {3085963200 -10800 1 -03}
+ {3096846000 -14400 0 -04}
+ {3118017600 -10800 1 -03}
+ {3128295600 -14400 0 -04}
+ {3149467200 -10800 1 -03}
+ {3159745200 -14400 0 -04}
+ {3180916800 -10800 1 -03}
+ {3191194800 -14400 0 -04}
+ {3212366400 -10800 1 -03}
+ {3223249200 -14400 0 -04}
+ {3243816000 -10800 1 -03}
+ {3254698800 -14400 0 -04}
+ {3275265600 -10800 1 -03}
+ {3286148400 -14400 0 -04}
+ {3307320000 -10800 1 -03}
+ {3317598000 -14400 0 -04}
+ {3338769600 -10800 1 -03}
+ {3349047600 -14400 0 -04}
+ {3370219200 -10800 1 -03}
+ {3381102000 -14400 0 -04}
+ {3401668800 -10800 1 -03}
+ {3412551600 -14400 0 -04}
+ {3433118400 -10800 1 -03}
+ {3444001200 -14400 0 -04}
+ {3464568000 -10800 1 -03}
+ {3475450800 -14400 0 -04}
+ {3496622400 -10800 1 -03}
+ {3506900400 -14400 0 -04}
+ {3528072000 -10800 1 -03}
+ {3538350000 -14400 0 -04}
+ {3559521600 -10800 1 -03}
+ {3570404400 -14400 0 -04}
+ {3590971200 -10800 1 -03}
+ {3601854000 -14400 0 -04}
+ {3622420800 -10800 1 -03}
+ {3633303600 -14400 0 -04}
+ {3654475200 -10800 1 -03}
+ {3664753200 -14400 0 -04}
+ {3685924800 -10800 1 -03}
+ {3696202800 -14400 0 -04}
+ {3717374400 -10800 1 -03}
+ {3727652400 -14400 0 -04}
+ {3748824000 -10800 1 -03}
+ {3759706800 -14400 0 -04}
+ {3780273600 -10800 1 -03}
+ {3791156400 -14400 0 -04}
+ {3811723200 -10800 1 -03}
+ {3822606000 -14400 0 -04}
+ {3843777600 -10800 1 -03}
+ {3854055600 -14400 0 -04}
+ {3875227200 -10800 1 -03}
+ {3885505200 -14400 0 -04}
+ {3906676800 -10800 1 -03}
+ {3917559600 -14400 0 -04}
+ {3938126400 -10800 1 -03}
+ {3949009200 -14400 0 -04}
+ {3969576000 -10800 1 -03}
+ {3980458800 -14400 0 -04}
+ {4001630400 -10800 1 -03}
+ {4011908400 -14400 0 -04}
+ {4033080000 -10800 1 -03}
+ {4043358000 -14400 0 -04}
+ {4064529600 -10800 1 -03}
+ {4074807600 -14400 0 -04}
+ {4095979200 -10800 1 -03}
}
diff --git a/library/tzdata/America/Caracas b/library/tzdata/America/Caracas
index 253c4ce..f0dbffe 100644
--- a/library/tzdata/America/Caracas
+++ b/library/tzdata/America/Caracas
@@ -3,8 +3,8 @@
set TZData(:America/Caracas) {
{-9223372036854775808 -16064 0 LMT}
{-2524505536 -16060 0 CMT}
- {-1826739140 -16200 0 VET}
- {-157750200 -14400 0 VET}
- {1197183600 -16200 0 VET}
- {1462086000 -14400 0 VET}
+ {-1826739140 -16200 0 -0430}
+ {-157750200 -14400 0 -04}
+ {1197183600 -16200 0 -0430}
+ {1462086000 -14400 0 -04}
}
diff --git a/library/tzdata/America/Cayenne b/library/tzdata/America/Cayenne
index de3d65b..6b1a3e9 100644
--- a/library/tzdata/America/Cayenne
+++ b/library/tzdata/America/Cayenne
@@ -2,6 +2,6 @@
set TZData(:America/Cayenne) {
{-9223372036854775808 -12560 0 LMT}
- {-1846269040 -14400 0 GFT}
- {-71092800 -10800 0 GFT}
+ {-1846269040 -14400 0 -04}
+ {-71092800 -10800 0 -03}
}
diff --git a/library/tzdata/America/Cuiaba b/library/tzdata/America/Cuiaba
index 0301862..57cd38c 100644
--- a/library/tzdata/America/Cuiaba
+++ b/library/tzdata/America/Cuiaba
@@ -2,256 +2,256 @@
set TZData(:America/Cuiaba) {
{-9223372036854775808 -13460 0 LMT}
- {-1767212140 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {592977600 -10800 1 AMST}
- {602046000 -14400 0 AMT}
- {624427200 -10800 1 AMST}
- {634705200 -14400 0 AMT}
- {656481600 -10800 1 AMST}
- {666759600 -14400 0 AMT}
- {687931200 -10800 1 AMST}
- {697604400 -14400 0 AMT}
- {719985600 -10800 1 AMST}
- {728449200 -14400 0 AMT}
- {750830400 -10800 1 AMST}
- {761713200 -14400 0 AMT}
- {782280000 -10800 1 AMST}
- {793162800 -14400 0 AMT}
- {813729600 -10800 1 AMST}
- {824007600 -14400 0 AMT}
- {844574400 -10800 1 AMST}
- {856062000 -14400 0 AMT}
- {876110400 -10800 1 AMST}
- {888721200 -14400 0 AMT}
- {908078400 -10800 1 AMST}
- {919566000 -14400 0 AMT}
- {938923200 -10800 1 AMST}
- {951620400 -14400 0 AMT}
- {970977600 -10800 1 AMST}
- {982465200 -14400 0 AMT}
- {1003032000 -10800 1 AMST}
- {1013914800 -14400 0 AMT}
- {1036296000 -10800 1 AMST}
- {1045364400 -14400 0 AMT}
- {1064372400 -14400 0 AMT}
- {1096603200 -14400 0 AMT}
- {1099368000 -10800 1 AMST}
- {1108868400 -14400 0 AMT}
- {1129435200 -10800 1 AMST}
- {1140318000 -14400 0 AMT}
- {1162699200 -10800 1 AMST}
- {1172372400 -14400 0 AMT}
- {1192334400 -10800 1 AMST}
- {1203217200 -14400 0 AMT}
- {1224388800 -10800 1 AMST}
- {1234666800 -14400 0 AMT}
- {1255838400 -10800 1 AMST}
- {1266721200 -14400 0 AMT}
- {1287288000 -10800 1 AMST}
- {1298170800 -14400 0 AMT}
- {1318737600 -10800 1 AMST}
- {1330225200 -14400 0 AMT}
- {1350792000 -10800 1 AMST}
- {1361070000 -14400 0 AMT}
- {1382241600 -10800 1 AMST}
- {1392519600 -14400 0 AMT}
- {1413691200 -10800 1 AMST}
- {1424574000 -14400 0 AMT}
- {1445140800 -10800 1 AMST}
- {1456023600 -14400 0 AMT}
- {1476590400 -10800 1 AMST}
- {1487473200 -14400 0 AMT}
- {1508040000 -10800 1 AMST}
- {1518922800 -14400 0 AMT}
- {1540094400 -10800 1 AMST}
- {1550372400 -14400 0 AMT}
- {1571544000 -10800 1 AMST}
- {1581822000 -14400 0 AMT}
- {1602993600 -10800 1 AMST}
- {1613876400 -14400 0 AMT}
- {1634443200 -10800 1 AMST}
- {1645326000 -14400 0 AMT}
- {1665892800 -10800 1 AMST}
- {1677380400 -14400 0 AMT}
- {1697342400 -10800 1 AMST}
- {1708225200 -14400 0 AMT}
- {1729396800 -10800 1 AMST}
- {1739674800 -14400 0 AMT}
- {1760846400 -10800 1 AMST}
- {1771729200 -14400 0 AMT}
- {1792296000 -10800 1 AMST}
- {1803178800 -14400 0 AMT}
- {1823745600 -10800 1 AMST}
- {1834628400 -14400 0 AMT}
- {1855195200 -10800 1 AMST}
- {1866078000 -14400 0 AMT}
- {1887249600 -10800 1 AMST}
- {1897527600 -14400 0 AMT}
- {1918699200 -10800 1 AMST}
- {1928977200 -14400 0 AMT}
- {1950148800 -10800 1 AMST}
- {1960426800 -14400 0 AMT}
- {1981598400 -10800 1 AMST}
- {1992481200 -14400 0 AMT}
- {2013048000 -10800 1 AMST}
- {2024535600 -14400 0 AMT}
- {2044497600 -10800 1 AMST}
- {2055380400 -14400 0 AMT}
- {2076552000 -10800 1 AMST}
- {2086830000 -14400 0 AMT}
- {2108001600 -10800 1 AMST}
- {2118884400 -14400 0 AMT}
- {2139451200 -10800 1 AMST}
- {2150334000 -14400 0 AMT}
- {2170900800 -10800 1 AMST}
- {2181783600 -14400 0 AMT}
- {2202350400 -10800 1 AMST}
- {2213233200 -14400 0 AMT}
- {2234404800 -10800 1 AMST}
- {2244682800 -14400 0 AMT}
- {2265854400 -10800 1 AMST}
- {2276132400 -14400 0 AMT}
- {2297304000 -10800 1 AMST}
- {2307582000 -14400 0 AMT}
- {2328753600 -10800 1 AMST}
- {2339636400 -14400 0 AMT}
- {2360203200 -10800 1 AMST}
- {2371086000 -14400 0 AMT}
- {2391652800 -10800 1 AMST}
- {2402535600 -14400 0 AMT}
- {2423707200 -10800 1 AMST}
- {2433985200 -14400 0 AMT}
- {2455156800 -10800 1 AMST}
- {2465434800 -14400 0 AMT}
- {2486606400 -10800 1 AMST}
- {2497489200 -14400 0 AMT}
- {2518056000 -10800 1 AMST}
- {2528938800 -14400 0 AMT}
- {2549505600 -10800 1 AMST}
- {2560388400 -14400 0 AMT}
- {2580955200 -10800 1 AMST}
- {2591838000 -14400 0 AMT}
- {2613009600 -10800 1 AMST}
- {2623287600 -14400 0 AMT}
- {2644459200 -10800 1 AMST}
- {2654737200 -14400 0 AMT}
- {2675908800 -10800 1 AMST}
- {2686791600 -14400 0 AMT}
- {2707358400 -10800 1 AMST}
- {2718241200 -14400 0 AMT}
- {2738808000 -10800 1 AMST}
- {2749690800 -14400 0 AMT}
- {2770862400 -10800 1 AMST}
- {2781140400 -14400 0 AMT}
- {2802312000 -10800 1 AMST}
- {2812590000 -14400 0 AMT}
- {2833761600 -10800 1 AMST}
- {2844039600 -14400 0 AMT}
- {2865211200 -10800 1 AMST}
- {2876094000 -14400 0 AMT}
- {2896660800 -10800 1 AMST}
- {2907543600 -14400 0 AMT}
- {2928110400 -10800 1 AMST}
- {2938993200 -14400 0 AMT}
- {2960164800 -10800 1 AMST}
- {2970442800 -14400 0 AMT}
- {2991614400 -10800 1 AMST}
- {3001892400 -14400 0 AMT}
- {3023064000 -10800 1 AMST}
- {3033946800 -14400 0 AMT}
- {3054513600 -10800 1 AMST}
- {3065396400 -14400 0 AMT}
- {3085963200 -10800 1 AMST}
- {3096846000 -14400 0 AMT}
- {3118017600 -10800 1 AMST}
- {3128295600 -14400 0 AMT}
- {3149467200 -10800 1 AMST}
- {3159745200 -14400 0 AMT}
- {3180916800 -10800 1 AMST}
- {3191194800 -14400 0 AMT}
- {3212366400 -10800 1 AMST}
- {3223249200 -14400 0 AMT}
- {3243816000 -10800 1 AMST}
- {3254698800 -14400 0 AMT}
- {3275265600 -10800 1 AMST}
- {3286148400 -14400 0 AMT}
- {3307320000 -10800 1 AMST}
- {3317598000 -14400 0 AMT}
- {3338769600 -10800 1 AMST}
- {3349047600 -14400 0 AMT}
- {3370219200 -10800 1 AMST}
- {3381102000 -14400 0 AMT}
- {3401668800 -10800 1 AMST}
- {3412551600 -14400 0 AMT}
- {3433118400 -10800 1 AMST}
- {3444001200 -14400 0 AMT}
- {3464568000 -10800 1 AMST}
- {3475450800 -14400 0 AMT}
- {3496622400 -10800 1 AMST}
- {3506900400 -14400 0 AMT}
- {3528072000 -10800 1 AMST}
- {3538350000 -14400 0 AMT}
- {3559521600 -10800 1 AMST}
- {3570404400 -14400 0 AMT}
- {3590971200 -10800 1 AMST}
- {3601854000 -14400 0 AMT}
- {3622420800 -10800 1 AMST}
- {3633303600 -14400 0 AMT}
- {3654475200 -10800 1 AMST}
- {3664753200 -14400 0 AMT}
- {3685924800 -10800 1 AMST}
- {3696202800 -14400 0 AMT}
- {3717374400 -10800 1 AMST}
- {3727652400 -14400 0 AMT}
- {3748824000 -10800 1 AMST}
- {3759706800 -14400 0 AMT}
- {3780273600 -10800 1 AMST}
- {3791156400 -14400 0 AMT}
- {3811723200 -10800 1 AMST}
- {3822606000 -14400 0 AMT}
- {3843777600 -10800 1 AMST}
- {3854055600 -14400 0 AMT}
- {3875227200 -10800 1 AMST}
- {3885505200 -14400 0 AMT}
- {3906676800 -10800 1 AMST}
- {3917559600 -14400 0 AMT}
- {3938126400 -10800 1 AMST}
- {3949009200 -14400 0 AMT}
- {3969576000 -10800 1 AMST}
- {3980458800 -14400 0 AMT}
- {4001630400 -10800 1 AMST}
- {4011908400 -14400 0 AMT}
- {4033080000 -10800 1 AMST}
- {4043358000 -14400 0 AMT}
- {4064529600 -10800 1 AMST}
- {4074807600 -14400 0 AMT}
- {4095979200 -10800 1 AMST}
+ {-1767212140 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {592977600 -10800 1 -03}
+ {602046000 -14400 0 -04}
+ {624427200 -10800 1 -03}
+ {634705200 -14400 0 -04}
+ {656481600 -10800 1 -03}
+ {666759600 -14400 0 -04}
+ {687931200 -10800 1 -03}
+ {697604400 -14400 0 -04}
+ {719985600 -10800 1 -03}
+ {728449200 -14400 0 -04}
+ {750830400 -10800 1 -03}
+ {761713200 -14400 0 -04}
+ {782280000 -10800 1 -03}
+ {793162800 -14400 0 -04}
+ {813729600 -10800 1 -03}
+ {824007600 -14400 0 -04}
+ {844574400 -10800 1 -03}
+ {856062000 -14400 0 -04}
+ {876110400 -10800 1 -03}
+ {888721200 -14400 0 -04}
+ {908078400 -10800 1 -03}
+ {919566000 -14400 0 -04}
+ {938923200 -10800 1 -03}
+ {951620400 -14400 0 -04}
+ {970977600 -10800 1 -03}
+ {982465200 -14400 0 -04}
+ {1003032000 -10800 1 -03}
+ {1013914800 -14400 0 -04}
+ {1036296000 -10800 1 -03}
+ {1045364400 -14400 0 -04}
+ {1064372400 -14400 0 -04}
+ {1096603200 -14400 0 -04}
+ {1099368000 -10800 1 -03}
+ {1108868400 -14400 0 -04}
+ {1129435200 -10800 1 -03}
+ {1140318000 -14400 0 -04}
+ {1162699200 -10800 1 -03}
+ {1172372400 -14400 0 -04}
+ {1192334400 -10800 1 -03}
+ {1203217200 -14400 0 -04}
+ {1224388800 -10800 1 -03}
+ {1234666800 -14400 0 -04}
+ {1255838400 -10800 1 -03}
+ {1266721200 -14400 0 -04}
+ {1287288000 -10800 1 -03}
+ {1298170800 -14400 0 -04}
+ {1318737600 -10800 1 -03}
+ {1330225200 -14400 0 -04}
+ {1350792000 -10800 1 -03}
+ {1361070000 -14400 0 -04}
+ {1382241600 -10800 1 -03}
+ {1392519600 -14400 0 -04}
+ {1413691200 -10800 1 -03}
+ {1424574000 -14400 0 -04}
+ {1445140800 -10800 1 -03}
+ {1456023600 -14400 0 -04}
+ {1476590400 -10800 1 -03}
+ {1487473200 -14400 0 -04}
+ {1508040000 -10800 1 -03}
+ {1518922800 -14400 0 -04}
+ {1540094400 -10800 1 -03}
+ {1550372400 -14400 0 -04}
+ {1571544000 -10800 1 -03}
+ {1581822000 -14400 0 -04}
+ {1602993600 -10800 1 -03}
+ {1613876400 -14400 0 -04}
+ {1634443200 -10800 1 -03}
+ {1645326000 -14400 0 -04}
+ {1665892800 -10800 1 -03}
+ {1677380400 -14400 0 -04}
+ {1697342400 -10800 1 -03}
+ {1708225200 -14400 0 -04}
+ {1729396800 -10800 1 -03}
+ {1739674800 -14400 0 -04}
+ {1760846400 -10800 1 -03}
+ {1771729200 -14400 0 -04}
+ {1792296000 -10800 1 -03}
+ {1803178800 -14400 0 -04}
+ {1823745600 -10800 1 -03}
+ {1834628400 -14400 0 -04}
+ {1855195200 -10800 1 -03}
+ {1866078000 -14400 0 -04}
+ {1887249600 -10800 1 -03}
+ {1897527600 -14400 0 -04}
+ {1918699200 -10800 1 -03}
+ {1928977200 -14400 0 -04}
+ {1950148800 -10800 1 -03}
+ {1960426800 -14400 0 -04}
+ {1981598400 -10800 1 -03}
+ {1992481200 -14400 0 -04}
+ {2013048000 -10800 1 -03}
+ {2024535600 -14400 0 -04}
+ {2044497600 -10800 1 -03}
+ {2055380400 -14400 0 -04}
+ {2076552000 -10800 1 -03}
+ {2086830000 -14400 0 -04}
+ {2108001600 -10800 1 -03}
+ {2118884400 -14400 0 -04}
+ {2139451200 -10800 1 -03}
+ {2150334000 -14400 0 -04}
+ {2170900800 -10800 1 -03}
+ {2181783600 -14400 0 -04}
+ {2202350400 -10800 1 -03}
+ {2213233200 -14400 0 -04}
+ {2234404800 -10800 1 -03}
+ {2244682800 -14400 0 -04}
+ {2265854400 -10800 1 -03}
+ {2276132400 -14400 0 -04}
+ {2297304000 -10800 1 -03}
+ {2307582000 -14400 0 -04}
+ {2328753600 -10800 1 -03}
+ {2339636400 -14400 0 -04}
+ {2360203200 -10800 1 -03}
+ {2371086000 -14400 0 -04}
+ {2391652800 -10800 1 -03}
+ {2402535600 -14400 0 -04}
+ {2423707200 -10800 1 -03}
+ {2433985200 -14400 0 -04}
+ {2455156800 -10800 1 -03}
+ {2465434800 -14400 0 -04}
+ {2486606400 -10800 1 -03}
+ {2497489200 -14400 0 -04}
+ {2518056000 -10800 1 -03}
+ {2528938800 -14400 0 -04}
+ {2549505600 -10800 1 -03}
+ {2560388400 -14400 0 -04}
+ {2580955200 -10800 1 -03}
+ {2591838000 -14400 0 -04}
+ {2613009600 -10800 1 -03}
+ {2623287600 -14400 0 -04}
+ {2644459200 -10800 1 -03}
+ {2654737200 -14400 0 -04}
+ {2675908800 -10800 1 -03}
+ {2686791600 -14400 0 -04}
+ {2707358400 -10800 1 -03}
+ {2718241200 -14400 0 -04}
+ {2738808000 -10800 1 -03}
+ {2749690800 -14400 0 -04}
+ {2770862400 -10800 1 -03}
+ {2781140400 -14400 0 -04}
+ {2802312000 -10800 1 -03}
+ {2812590000 -14400 0 -04}
+ {2833761600 -10800 1 -03}
+ {2844039600 -14400 0 -04}
+ {2865211200 -10800 1 -03}
+ {2876094000 -14400 0 -04}
+ {2896660800 -10800 1 -03}
+ {2907543600 -14400 0 -04}
+ {2928110400 -10800 1 -03}
+ {2938993200 -14400 0 -04}
+ {2960164800 -10800 1 -03}
+ {2970442800 -14400 0 -04}
+ {2991614400 -10800 1 -03}
+ {3001892400 -14400 0 -04}
+ {3023064000 -10800 1 -03}
+ {3033946800 -14400 0 -04}
+ {3054513600 -10800 1 -03}
+ {3065396400 -14400 0 -04}
+ {3085963200 -10800 1 -03}
+ {3096846000 -14400 0 -04}
+ {3118017600 -10800 1 -03}
+ {3128295600 -14400 0 -04}
+ {3149467200 -10800 1 -03}
+ {3159745200 -14400 0 -04}
+ {3180916800 -10800 1 -03}
+ {3191194800 -14400 0 -04}
+ {3212366400 -10800 1 -03}
+ {3223249200 -14400 0 -04}
+ {3243816000 -10800 1 -03}
+ {3254698800 -14400 0 -04}
+ {3275265600 -10800 1 -03}
+ {3286148400 -14400 0 -04}
+ {3307320000 -10800 1 -03}
+ {3317598000 -14400 0 -04}
+ {3338769600 -10800 1 -03}
+ {3349047600 -14400 0 -04}
+ {3370219200 -10800 1 -03}
+ {3381102000 -14400 0 -04}
+ {3401668800 -10800 1 -03}
+ {3412551600 -14400 0 -04}
+ {3433118400 -10800 1 -03}
+ {3444001200 -14400 0 -04}
+ {3464568000 -10800 1 -03}
+ {3475450800 -14400 0 -04}
+ {3496622400 -10800 1 -03}
+ {3506900400 -14400 0 -04}
+ {3528072000 -10800 1 -03}
+ {3538350000 -14400 0 -04}
+ {3559521600 -10800 1 -03}
+ {3570404400 -14400 0 -04}
+ {3590971200 -10800 1 -03}
+ {3601854000 -14400 0 -04}
+ {3622420800 -10800 1 -03}
+ {3633303600 -14400 0 -04}
+ {3654475200 -10800 1 -03}
+ {3664753200 -14400 0 -04}
+ {3685924800 -10800 1 -03}
+ {3696202800 -14400 0 -04}
+ {3717374400 -10800 1 -03}
+ {3727652400 -14400 0 -04}
+ {3748824000 -10800 1 -03}
+ {3759706800 -14400 0 -04}
+ {3780273600 -10800 1 -03}
+ {3791156400 -14400 0 -04}
+ {3811723200 -10800 1 -03}
+ {3822606000 -14400 0 -04}
+ {3843777600 -10800 1 -03}
+ {3854055600 -14400 0 -04}
+ {3875227200 -10800 1 -03}
+ {3885505200 -14400 0 -04}
+ {3906676800 -10800 1 -03}
+ {3917559600 -14400 0 -04}
+ {3938126400 -10800 1 -03}
+ {3949009200 -14400 0 -04}
+ {3969576000 -10800 1 -03}
+ {3980458800 -14400 0 -04}
+ {4001630400 -10800 1 -03}
+ {4011908400 -14400 0 -04}
+ {4033080000 -10800 1 -03}
+ {4043358000 -14400 0 -04}
+ {4064529600 -10800 1 -03}
+ {4074807600 -14400 0 -04}
+ {4095979200 -10800 1 -03}
}
diff --git a/library/tzdata/America/Curacao b/library/tzdata/America/Curacao
index 5189e9c..0a19090 100644
--- a/library/tzdata/America/Curacao
+++ b/library/tzdata/America/Curacao
@@ -2,6 +2,6 @@
set TZData(:America/Curacao) {
{-9223372036854775808 -16547 0 LMT}
- {-1826738653 -16200 0 ANT}
+ {-1826738653 -16200 0 -0430}
{-157750200 -14400 0 AST}
}
diff --git a/library/tzdata/America/Danmarkshavn b/library/tzdata/America/Danmarkshavn
index 8d66d3a..4d9d7bb 100644
--- a/library/tzdata/America/Danmarkshavn
+++ b/library/tzdata/America/Danmarkshavn
@@ -2,38 +2,38 @@
set TZData(:America/Danmarkshavn) {
{-9223372036854775808 -4480 0 LMT}
- {-1686091520 -10800 0 WGT}
- {323845200 -7200 0 WGST}
- {338950800 -10800 0 WGT}
- {354675600 -7200 1 WGST}
- {370400400 -10800 0 WGT}
- {386125200 -7200 1 WGST}
- {401850000 -10800 0 WGT}
- {417574800 -7200 1 WGST}
- {433299600 -10800 0 WGT}
- {449024400 -7200 1 WGST}
- {465354000 -10800 0 WGT}
- {481078800 -7200 1 WGST}
- {496803600 -10800 0 WGT}
- {512528400 -7200 1 WGST}
- {528253200 -10800 0 WGT}
- {543978000 -7200 1 WGST}
- {559702800 -10800 0 WGT}
- {575427600 -7200 1 WGST}
- {591152400 -10800 0 WGT}
- {606877200 -7200 1 WGST}
- {622602000 -10800 0 WGT}
- {638326800 -7200 1 WGST}
- {654656400 -10800 0 WGT}
- {670381200 -7200 1 WGST}
- {686106000 -10800 0 WGT}
- {701830800 -7200 1 WGST}
- {717555600 -10800 0 WGT}
- {733280400 -7200 1 WGST}
- {749005200 -10800 0 WGT}
- {764730000 -7200 1 WGST}
- {780454800 -10800 0 WGT}
- {796179600 -7200 1 WGST}
- {811904400 -10800 0 WGT}
+ {-1686091520 -10800 0 -03}
+ {323845200 -7200 0 -02}
+ {338950800 -10800 0 -03}
+ {354675600 -7200 1 -02}
+ {370400400 -10800 0 -03}
+ {386125200 -7200 1 -02}
+ {401850000 -10800 0 -03}
+ {417574800 -7200 1 -02}
+ {433299600 -10800 0 -03}
+ {449024400 -7200 1 -02}
+ {465354000 -10800 0 -03}
+ {481078800 -7200 1 -02}
+ {496803600 -10800 0 -03}
+ {512528400 -7200 1 -02}
+ {528253200 -10800 0 -03}
+ {543978000 -7200 1 -02}
+ {559702800 -10800 0 -03}
+ {575427600 -7200 1 -02}
+ {591152400 -10800 0 -03}
+ {606877200 -7200 1 -02}
+ {622602000 -10800 0 -03}
+ {638326800 -7200 1 -02}
+ {654656400 -10800 0 -03}
+ {670381200 -7200 1 -02}
+ {686106000 -10800 0 -03}
+ {701830800 -7200 1 -02}
+ {717555600 -10800 0 -03}
+ {733280400 -7200 1 -02}
+ {749005200 -10800 0 -03}
+ {764730000 -7200 1 -02}
+ {780454800 -10800 0 -03}
+ {796179600 -7200 1 -02}
+ {811904400 -10800 0 -03}
{820465200 0 0 GMT}
}
diff --git a/library/tzdata/America/Eirunepe b/library/tzdata/America/Eirunepe
index a05631f..41b4cc9 100644
--- a/library/tzdata/America/Eirunepe
+++ b/library/tzdata/America/Eirunepe
@@ -2,40 +2,40 @@
set TZData(:America/Eirunepe) {
{-9223372036854775808 -16768 0 LMT}
- {-1767208832 -18000 0 ACT}
- {-1206950400 -14400 1 ACST}
- {-1191355200 -18000 0 ACT}
- {-1175367600 -14400 1 ACST}
- {-1159819200 -18000 0 ACT}
- {-633812400 -14400 1 ACST}
- {-622062000 -18000 0 ACT}
- {-602276400 -14400 1 ACST}
- {-591825600 -18000 0 ACT}
- {-570740400 -14400 1 ACST}
- {-560203200 -18000 0 ACT}
- {-539118000 -14400 1 ACST}
- {-531345600 -18000 0 ACT}
- {-191358000 -14400 1 ACST}
- {-184190400 -18000 0 ACT}
- {-155156400 -14400 1 ACST}
- {-150062400 -18000 0 ACT}
- {-128890800 -14400 1 ACST}
- {-121118400 -18000 0 ACT}
- {-99946800 -14400 1 ACST}
- {-89582400 -18000 0 ACT}
- {-68410800 -14400 1 ACST}
- {-57960000 -18000 0 ACT}
- {499755600 -14400 1 ACST}
- {511243200 -18000 0 ACT}
- {530600400 -14400 1 ACST}
- {540273600 -18000 0 ACT}
- {562136400 -14400 1 ACST}
- {571204800 -18000 0 ACT}
- {590040000 -18000 0 ACT}
- {749192400 -18000 0 ACT}
- {750834000 -14400 1 ACST}
- {761716800 -18000 0 ACT}
- {780206400 -18000 0 ACT}
- {1214283600 -14400 0 AMT}
- {1384056000 -18000 0 ACT}
+ {-1767208832 -18000 0 -05}
+ {-1206950400 -14400 1 -04}
+ {-1191355200 -18000 0 -05}
+ {-1175367600 -14400 1 -04}
+ {-1159819200 -18000 0 -05}
+ {-633812400 -14400 1 -04}
+ {-622062000 -18000 0 -05}
+ {-602276400 -14400 1 -04}
+ {-591825600 -18000 0 -05}
+ {-570740400 -14400 1 -04}
+ {-560203200 -18000 0 -05}
+ {-539118000 -14400 1 -04}
+ {-531345600 -18000 0 -05}
+ {-191358000 -14400 1 -04}
+ {-184190400 -18000 0 -05}
+ {-155156400 -14400 1 -04}
+ {-150062400 -18000 0 -05}
+ {-128890800 -14400 1 -04}
+ {-121118400 -18000 0 -05}
+ {-99946800 -14400 1 -04}
+ {-89582400 -18000 0 -05}
+ {-68410800 -14400 1 -04}
+ {-57960000 -18000 0 -05}
+ {499755600 -14400 1 -04}
+ {511243200 -18000 0 -05}
+ {530600400 -14400 1 -04}
+ {540273600 -18000 0 -05}
+ {562136400 -14400 1 -04}
+ {571204800 -18000 0 -05}
+ {590040000 -18000 0 -05}
+ {749192400 -18000 0 -05}
+ {750834000 -14400 1 -04}
+ {761716800 -18000 0 -05}
+ {780206400 -18000 0 -05}
+ {1214283600 -14400 0 -04}
+ {1384056000 -18000 0 -05}
}
diff --git a/library/tzdata/America/Fortaleza b/library/tzdata/America/Fortaleza
index 581faa5..06c7b84 100644
--- a/library/tzdata/America/Fortaleza
+++ b/library/tzdata/America/Fortaleza
@@ -2,47 +2,47 @@
set TZData(:America/Fortaleza) {
{-9223372036854775808 -9240 0 LMT}
- {-1767216360 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {653536800 -10800 0 BRT}
- {938660400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {972180000 -10800 0 BRT}
- {1000350000 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1033437600 -10800 0 BRT}
+ {-1767216360 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {653536800 -10800 0 -03}
+ {938660400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {972180000 -10800 0 -03}
+ {1000350000 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1033437600 -10800 0 -03}
}
diff --git a/library/tzdata/America/Godthab b/library/tzdata/America/Godthab
index 3c003cc..3e45f87 100644
--- a/library/tzdata/America/Godthab
+++ b/library/tzdata/America/Godthab
@@ -2,245 +2,245 @@
set TZData(:America/Godthab) {
{-9223372036854775808 -12416 0 LMT}
- {-1686083584 -10800 0 WGT}
- {323845200 -7200 0 WGST}
- {338950800 -10800 0 WGT}
- {354675600 -7200 1 WGST}
- {370400400 -10800 0 WGT}
- {386125200 -7200 1 WGST}
- {401850000 -10800 0 WGT}
- {417574800 -7200 1 WGST}
- {433299600 -10800 0 WGT}
- {449024400 -7200 1 WGST}
- {465354000 -10800 0 WGT}
- {481078800 -7200 1 WGST}
- {496803600 -10800 0 WGT}
- {512528400 -7200 1 WGST}
- {528253200 -10800 0 WGT}
- {543978000 -7200 1 WGST}
- {559702800 -10800 0 WGT}
- {575427600 -7200 1 WGST}
- {591152400 -10800 0 WGT}
- {606877200 -7200 1 WGST}
- {622602000 -10800 0 WGT}
- {638326800 -7200 1 WGST}
- {654656400 -10800 0 WGT}
- {670381200 -7200 1 WGST}
- {686106000 -10800 0 WGT}
- {701830800 -7200 1 WGST}
- {717555600 -10800 0 WGT}
- {733280400 -7200 1 WGST}
- {749005200 -10800 0 WGT}
- {764730000 -7200 1 WGST}
- {780454800 -10800 0 WGT}
- {796179600 -7200 1 WGST}
- {811904400 -10800 0 WGT}
- {828234000 -7200 1 WGST}
- {846378000 -10800 0 WGT}
- {859683600 -7200 1 WGST}
- {877827600 -10800 0 WGT}
- {891133200 -7200 1 WGST}
- {909277200 -10800 0 WGT}
- {922582800 -7200 1 WGST}
- {941331600 -10800 0 WGT}
- {954032400 -7200 1 WGST}
- {972781200 -10800 0 WGT}
- {985482000 -7200 1 WGST}
- {1004230800 -10800 0 WGT}
- {1017536400 -7200 1 WGST}
- {1035680400 -10800 0 WGT}
- {1048986000 -7200 1 WGST}
- {1067130000 -10800 0 WGT}
- {1080435600 -7200 1 WGST}
- {1099184400 -10800 0 WGT}
- {1111885200 -7200 1 WGST}
- {1130634000 -10800 0 WGT}
- {1143334800 -7200 1 WGST}
- {1162083600 -10800 0 WGT}
- {1174784400 -7200 1 WGST}
- {1193533200 -10800 0 WGT}
- {1206838800 -7200 1 WGST}
- {1224982800 -10800 0 WGT}
- {1238288400 -7200 1 WGST}
- {1256432400 -10800 0 WGT}
- {1269738000 -7200 1 WGST}
- {1288486800 -10800 0 WGT}
- {1301187600 -7200 1 WGST}
- {1319936400 -10800 0 WGT}
- {1332637200 -7200 1 WGST}
- {1351386000 -10800 0 WGT}
- {1364691600 -7200 1 WGST}
- {1382835600 -10800 0 WGT}
- {1396141200 -7200 1 WGST}
- {1414285200 -10800 0 WGT}
- {1427590800 -7200 1 WGST}
- {1445734800 -10800 0 WGT}
- {1459040400 -7200 1 WGST}
- {1477789200 -10800 0 WGT}
- {1490490000 -7200 1 WGST}
- {1509238800 -10800 0 WGT}
- {1521939600 -7200 1 WGST}
- {1540688400 -10800 0 WGT}
- {1553994000 -7200 1 WGST}
- {1572138000 -10800 0 WGT}
- {1585443600 -7200 1 WGST}
- {1603587600 -10800 0 WGT}
- {1616893200 -7200 1 WGST}
- {1635642000 -10800 0 WGT}
- {1648342800 -7200 1 WGST}
- {1667091600 -10800 0 WGT}
- {1679792400 -7200 1 WGST}
- {1698541200 -10800 0 WGT}
- {1711846800 -7200 1 WGST}
- {1729990800 -10800 0 WGT}
- {1743296400 -7200 1 WGST}
- {1761440400 -10800 0 WGT}
- {1774746000 -7200 1 WGST}
- {1792890000 -10800 0 WGT}
- {1806195600 -7200 1 WGST}
- {1824944400 -10800 0 WGT}
- {1837645200 -7200 1 WGST}
- {1856394000 -10800 0 WGT}
- {1869094800 -7200 1 WGST}
- {1887843600 -10800 0 WGT}
- {1901149200 -7200 1 WGST}
- {1919293200 -10800 0 WGT}
- {1932598800 -7200 1 WGST}
- {1950742800 -10800 0 WGT}
- {1964048400 -7200 1 WGST}
- {1982797200 -10800 0 WGT}
- {1995498000 -7200 1 WGST}
- {2014246800 -10800 0 WGT}
- {2026947600 -7200 1 WGST}
- {2045696400 -10800 0 WGT}
- {2058397200 -7200 1 WGST}
- {2077146000 -10800 0 WGT}
- {2090451600 -7200 1 WGST}
- {2108595600 -10800 0 WGT}
- {2121901200 -7200 1 WGST}
- {2140045200 -10800 0 WGT}
- {2153350800 -7200 1 WGST}
- {2172099600 -10800 0 WGT}
- {2184800400 -7200 1 WGST}
- {2203549200 -10800 0 WGT}
- {2216250000 -7200 1 WGST}
- {2234998800 -10800 0 WGT}
- {2248304400 -7200 1 WGST}
- {2266448400 -10800 0 WGT}
- {2279754000 -7200 1 WGST}
- {2297898000 -10800 0 WGT}
- {2311203600 -7200 1 WGST}
- {2329347600 -10800 0 WGT}
- {2342653200 -7200 1 WGST}
- {2361402000 -10800 0 WGT}
- {2374102800 -7200 1 WGST}
- {2392851600 -10800 0 WGT}
- {2405552400 -7200 1 WGST}
- {2424301200 -10800 0 WGT}
- {2437606800 -7200 1 WGST}
- {2455750800 -10800 0 WGT}
- {2469056400 -7200 1 WGST}
- {2487200400 -10800 0 WGT}
- {2500506000 -7200 1 WGST}
- {2519254800 -10800 0 WGT}
- {2531955600 -7200 1 WGST}
- {2550704400 -10800 0 WGT}
- {2563405200 -7200 1 WGST}
- {2582154000 -10800 0 WGT}
- {2595459600 -7200 1 WGST}
- {2613603600 -10800 0 WGT}
- {2626909200 -7200 1 WGST}
- {2645053200 -10800 0 WGT}
- {2658358800 -7200 1 WGST}
- {2676502800 -10800 0 WGT}
- {2689808400 -7200 1 WGST}
- {2708557200 -10800 0 WGT}
- {2721258000 -7200 1 WGST}
- {2740006800 -10800 0 WGT}
- {2752707600 -7200 1 WGST}
- {2771456400 -10800 0 WGT}
- {2784762000 -7200 1 WGST}
- {2802906000 -10800 0 WGT}
- {2816211600 -7200 1 WGST}
- {2834355600 -10800 0 WGT}
- {2847661200 -7200 1 WGST}
- {2866410000 -10800 0 WGT}
- {2879110800 -7200 1 WGST}
- {2897859600 -10800 0 WGT}
- {2910560400 -7200 1 WGST}
- {2929309200 -10800 0 WGT}
- {2942010000 -7200 1 WGST}
- {2960758800 -10800 0 WGT}
- {2974064400 -7200 1 WGST}
- {2992208400 -10800 0 WGT}
- {3005514000 -7200 1 WGST}
- {3023658000 -10800 0 WGT}
- {3036963600 -7200 1 WGST}
- {3055712400 -10800 0 WGT}
- {3068413200 -7200 1 WGST}
- {3087162000 -10800 0 WGT}
- {3099862800 -7200 1 WGST}
- {3118611600 -10800 0 WGT}
- {3131917200 -7200 1 WGST}
- {3150061200 -10800 0 WGT}
- {3163366800 -7200 1 WGST}
- {3181510800 -10800 0 WGT}
- {3194816400 -7200 1 WGST}
- {3212960400 -10800 0 WGT}
- {3226266000 -7200 1 WGST}
- {3245014800 -10800 0 WGT}
- {3257715600 -7200 1 WGST}
- {3276464400 -10800 0 WGT}
- {3289165200 -7200 1 WGST}
- {3307914000 -10800 0 WGT}
- {3321219600 -7200 1 WGST}
- {3339363600 -10800 0 WGT}
- {3352669200 -7200 1 WGST}
- {3370813200 -10800 0 WGT}
- {3384118800 -7200 1 WGST}
- {3402867600 -10800 0 WGT}
- {3415568400 -7200 1 WGST}
- {3434317200 -10800 0 WGT}
- {3447018000 -7200 1 WGST}
- {3465766800 -10800 0 WGT}
- {3479072400 -7200 1 WGST}
- {3497216400 -10800 0 WGT}
- {3510522000 -7200 1 WGST}
- {3528666000 -10800 0 WGT}
- {3541971600 -7200 1 WGST}
- {3560115600 -10800 0 WGT}
- {3573421200 -7200 1 WGST}
- {3592170000 -10800 0 WGT}
- {3604870800 -7200 1 WGST}
- {3623619600 -10800 0 WGT}
- {3636320400 -7200 1 WGST}
- {3655069200 -10800 0 WGT}
- {3668374800 -7200 1 WGST}
- {3686518800 -10800 0 WGT}
- {3699824400 -7200 1 WGST}
- {3717968400 -10800 0 WGT}
- {3731274000 -7200 1 WGST}
- {3750022800 -10800 0 WGT}
- {3762723600 -7200 1 WGST}
- {3781472400 -10800 0 WGT}
- {3794173200 -7200 1 WGST}
- {3812922000 -10800 0 WGT}
- {3825622800 -7200 1 WGST}
- {3844371600 -10800 0 WGT}
- {3857677200 -7200 1 WGST}
- {3875821200 -10800 0 WGT}
- {3889126800 -7200 1 WGST}
- {3907270800 -10800 0 WGT}
- {3920576400 -7200 1 WGST}
- {3939325200 -10800 0 WGT}
- {3952026000 -7200 1 WGST}
- {3970774800 -10800 0 WGT}
- {3983475600 -7200 1 WGST}
- {4002224400 -10800 0 WGT}
- {4015530000 -7200 1 WGST}
- {4033674000 -10800 0 WGT}
- {4046979600 -7200 1 WGST}
- {4065123600 -10800 0 WGT}
- {4078429200 -7200 1 WGST}
- {4096573200 -10800 0 WGT}
+ {-1686083584 -10800 0 -03}
+ {323845200 -7200 0 -02}
+ {338950800 -10800 0 -03}
+ {354675600 -7200 1 -02}
+ {370400400 -10800 0 -03}
+ {386125200 -7200 1 -02}
+ {401850000 -10800 0 -03}
+ {417574800 -7200 1 -02}
+ {433299600 -10800 0 -03}
+ {449024400 -7200 1 -02}
+ {465354000 -10800 0 -03}
+ {481078800 -7200 1 -02}
+ {496803600 -10800 0 -03}
+ {512528400 -7200 1 -02}
+ {528253200 -10800 0 -03}
+ {543978000 -7200 1 -02}
+ {559702800 -10800 0 -03}
+ {575427600 -7200 1 -02}
+ {591152400 -10800 0 -03}
+ {606877200 -7200 1 -02}
+ {622602000 -10800 0 -03}
+ {638326800 -7200 1 -02}
+ {654656400 -10800 0 -03}
+ {670381200 -7200 1 -02}
+ {686106000 -10800 0 -03}
+ {701830800 -7200 1 -02}
+ {717555600 -10800 0 -03}
+ {733280400 -7200 1 -02}
+ {749005200 -10800 0 -03}
+ {764730000 -7200 1 -02}
+ {780454800 -10800 0 -03}
+ {796179600 -7200 1 -02}
+ {811904400 -10800 0 -03}
+ {828234000 -7200 1 -02}
+ {846378000 -10800 0 -03}
+ {859683600 -7200 1 -02}
+ {877827600 -10800 0 -03}
+ {891133200 -7200 1 -02}
+ {909277200 -10800 0 -03}
+ {922582800 -7200 1 -02}
+ {941331600 -10800 0 -03}
+ {954032400 -7200 1 -02}
+ {972781200 -10800 0 -03}
+ {985482000 -7200 1 -02}
+ {1004230800 -10800 0 -03}
+ {1017536400 -7200 1 -02}
+ {1035680400 -10800 0 -03}
+ {1048986000 -7200 1 -02}
+ {1067130000 -10800 0 -03}
+ {1080435600 -7200 1 -02}
+ {1099184400 -10800 0 -03}
+ {1111885200 -7200 1 -02}
+ {1130634000 -10800 0 -03}
+ {1143334800 -7200 1 -02}
+ {1162083600 -10800 0 -03}
+ {1174784400 -7200 1 -02}
+ {1193533200 -10800 0 -03}
+ {1206838800 -7200 1 -02}
+ {1224982800 -10800 0 -03}
+ {1238288400 -7200 1 -02}
+ {1256432400 -10800 0 -03}
+ {1269738000 -7200 1 -02}
+ {1288486800 -10800 0 -03}
+ {1301187600 -7200 1 -02}
+ {1319936400 -10800 0 -03}
+ {1332637200 -7200 1 -02}
+ {1351386000 -10800 0 -03}
+ {1364691600 -7200 1 -02}
+ {1382835600 -10800 0 -03}
+ {1396141200 -7200 1 -02}
+ {1414285200 -10800 0 -03}
+ {1427590800 -7200 1 -02}
+ {1445734800 -10800 0 -03}
+ {1459040400 -7200 1 -02}
+ {1477789200 -10800 0 -03}
+ {1490490000 -7200 1 -02}
+ {1509238800 -10800 0 -03}
+ {1521939600 -7200 1 -02}
+ {1540688400 -10800 0 -03}
+ {1553994000 -7200 1 -02}
+ {1572138000 -10800 0 -03}
+ {1585443600 -7200 1 -02}
+ {1603587600 -10800 0 -03}
+ {1616893200 -7200 1 -02}
+ {1635642000 -10800 0 -03}
+ {1648342800 -7200 1 -02}
+ {1667091600 -10800 0 -03}
+ {1679792400 -7200 1 -02}
+ {1698541200 -10800 0 -03}
+ {1711846800 -7200 1 -02}
+ {1729990800 -10800 0 -03}
+ {1743296400 -7200 1 -02}
+ {1761440400 -10800 0 -03}
+ {1774746000 -7200 1 -02}
+ {1792890000 -10800 0 -03}
+ {1806195600 -7200 1 -02}
+ {1824944400 -10800 0 -03}
+ {1837645200 -7200 1 -02}
+ {1856394000 -10800 0 -03}
+ {1869094800 -7200 1 -02}
+ {1887843600 -10800 0 -03}
+ {1901149200 -7200 1 -02}
+ {1919293200 -10800 0 -03}
+ {1932598800 -7200 1 -02}
+ {1950742800 -10800 0 -03}
+ {1964048400 -7200 1 -02}
+ {1982797200 -10800 0 -03}
+ {1995498000 -7200 1 -02}
+ {2014246800 -10800 0 -03}
+ {2026947600 -7200 1 -02}
+ {2045696400 -10800 0 -03}
+ {2058397200 -7200 1 -02}
+ {2077146000 -10800 0 -03}
+ {2090451600 -7200 1 -02}
+ {2108595600 -10800 0 -03}
+ {2121901200 -7200 1 -02}
+ {2140045200 -10800 0 -03}
+ {2153350800 -7200 1 -02}
+ {2172099600 -10800 0 -03}
+ {2184800400 -7200 1 -02}
+ {2203549200 -10800 0 -03}
+ {2216250000 -7200 1 -02}
+ {2234998800 -10800 0 -03}
+ {2248304400 -7200 1 -02}
+ {2266448400 -10800 0 -03}
+ {2279754000 -7200 1 -02}
+ {2297898000 -10800 0 -03}
+ {2311203600 -7200 1 -02}
+ {2329347600 -10800 0 -03}
+ {2342653200 -7200 1 -02}
+ {2361402000 -10800 0 -03}
+ {2374102800 -7200 1 -02}
+ {2392851600 -10800 0 -03}
+ {2405552400 -7200 1 -02}
+ {2424301200 -10800 0 -03}
+ {2437606800 -7200 1 -02}
+ {2455750800 -10800 0 -03}
+ {2469056400 -7200 1 -02}
+ {2487200400 -10800 0 -03}
+ {2500506000 -7200 1 -02}
+ {2519254800 -10800 0 -03}
+ {2531955600 -7200 1 -02}
+ {2550704400 -10800 0 -03}
+ {2563405200 -7200 1 -02}
+ {2582154000 -10800 0 -03}
+ {2595459600 -7200 1 -02}
+ {2613603600 -10800 0 -03}
+ {2626909200 -7200 1 -02}
+ {2645053200 -10800 0 -03}
+ {2658358800 -7200 1 -02}
+ {2676502800 -10800 0 -03}
+ {2689808400 -7200 1 -02}
+ {2708557200 -10800 0 -03}
+ {2721258000 -7200 1 -02}
+ {2740006800 -10800 0 -03}
+ {2752707600 -7200 1 -02}
+ {2771456400 -10800 0 -03}
+ {2784762000 -7200 1 -02}
+ {2802906000 -10800 0 -03}
+ {2816211600 -7200 1 -02}
+ {2834355600 -10800 0 -03}
+ {2847661200 -7200 1 -02}
+ {2866410000 -10800 0 -03}
+ {2879110800 -7200 1 -02}
+ {2897859600 -10800 0 -03}
+ {2910560400 -7200 1 -02}
+ {2929309200 -10800 0 -03}
+ {2942010000 -7200 1 -02}
+ {2960758800 -10800 0 -03}
+ {2974064400 -7200 1 -02}
+ {2992208400 -10800 0 -03}
+ {3005514000 -7200 1 -02}
+ {3023658000 -10800 0 -03}
+ {3036963600 -7200 1 -02}
+ {3055712400 -10800 0 -03}
+ {3068413200 -7200 1 -02}
+ {3087162000 -10800 0 -03}
+ {3099862800 -7200 1 -02}
+ {3118611600 -10800 0 -03}
+ {3131917200 -7200 1 -02}
+ {3150061200 -10800 0 -03}
+ {3163366800 -7200 1 -02}
+ {3181510800 -10800 0 -03}
+ {3194816400 -7200 1 -02}
+ {3212960400 -10800 0 -03}
+ {3226266000 -7200 1 -02}
+ {3245014800 -10800 0 -03}
+ {3257715600 -7200 1 -02}
+ {3276464400 -10800 0 -03}
+ {3289165200 -7200 1 -02}
+ {3307914000 -10800 0 -03}
+ {3321219600 -7200 1 -02}
+ {3339363600 -10800 0 -03}
+ {3352669200 -7200 1 -02}
+ {3370813200 -10800 0 -03}
+ {3384118800 -7200 1 -02}
+ {3402867600 -10800 0 -03}
+ {3415568400 -7200 1 -02}
+ {3434317200 -10800 0 -03}
+ {3447018000 -7200 1 -02}
+ {3465766800 -10800 0 -03}
+ {3479072400 -7200 1 -02}
+ {3497216400 -10800 0 -03}
+ {3510522000 -7200 1 -02}
+ {3528666000 -10800 0 -03}
+ {3541971600 -7200 1 -02}
+ {3560115600 -10800 0 -03}
+ {3573421200 -7200 1 -02}
+ {3592170000 -10800 0 -03}
+ {3604870800 -7200 1 -02}
+ {3623619600 -10800 0 -03}
+ {3636320400 -7200 1 -02}
+ {3655069200 -10800 0 -03}
+ {3668374800 -7200 1 -02}
+ {3686518800 -10800 0 -03}
+ {3699824400 -7200 1 -02}
+ {3717968400 -10800 0 -03}
+ {3731274000 -7200 1 -02}
+ {3750022800 -10800 0 -03}
+ {3762723600 -7200 1 -02}
+ {3781472400 -10800 0 -03}
+ {3794173200 -7200 1 -02}
+ {3812922000 -10800 0 -03}
+ {3825622800 -7200 1 -02}
+ {3844371600 -10800 0 -03}
+ {3857677200 -7200 1 -02}
+ {3875821200 -10800 0 -03}
+ {3889126800 -7200 1 -02}
+ {3907270800 -10800 0 -03}
+ {3920576400 -7200 1 -02}
+ {3939325200 -10800 0 -03}
+ {3952026000 -7200 1 -02}
+ {3970774800 -10800 0 -03}
+ {3983475600 -7200 1 -02}
+ {4002224400 -10800 0 -03}
+ {4015530000 -7200 1 -02}
+ {4033674000 -10800 0 -03}
+ {4046979600 -7200 1 -02}
+ {4065123600 -10800 0 -03}
+ {4078429200 -7200 1 -02}
+ {4096573200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Guayaquil b/library/tzdata/America/Guayaquil
index e940a5b..353eb69 100644
--- a/library/tzdata/America/Guayaquil
+++ b/library/tzdata/America/Guayaquil
@@ -3,5 +3,7 @@
set TZData(:America/Guayaquil) {
{-9223372036854775808 -19160 0 LMT}
{-2524502440 -18840 0 QMT}
- {-1230749160 -18000 0 ECT}
+ {-1230749160 -18000 0 -05}
+ {722926800 -14400 1 -04}
+ {728884800 -18000 0 -05}
}
diff --git a/library/tzdata/America/Guyana b/library/tzdata/America/Guyana
index c58a989..fab7855 100644
--- a/library/tzdata/America/Guyana
+++ b/library/tzdata/America/Guyana
@@ -2,8 +2,7 @@
set TZData(:America/Guyana) {
{-9223372036854775808 -13960 0 LMT}
- {-1730578040 -13500 0 GBGT}
- {-113688900 -13500 0 GYT}
- {176010300 -10800 0 GYT}
- {662698800 -14400 0 GYT}
+ {-1730578040 -13500 0 -0345}
+ {176010300 -10800 0 -03}
+ {662698800 -14400 0 -04}
}
diff --git a/library/tzdata/America/La_Paz b/library/tzdata/America/La_Paz
index 38ffbb0..a245afd 100644
--- a/library/tzdata/America/La_Paz
+++ b/library/tzdata/America/La_Paz
@@ -4,5 +4,5 @@ set TZData(:America/La_Paz) {
{-9223372036854775808 -16356 0 LMT}
{-2524505244 -16356 0 CMT}
{-1205954844 -12756 1 BOST}
- {-1192307244 -14400 0 BOT}
+ {-1192307244 -14400 0 -04}
}
diff --git a/library/tzdata/America/Lima b/library/tzdata/America/Lima
index c6e6ac1..b224a64 100644
--- a/library/tzdata/America/Lima
+++ b/library/tzdata/America/Lima
@@ -3,14 +3,14 @@
set TZData(:America/Lima) {
{-9223372036854775808 -18492 0 LMT}
{-2524503108 -18516 0 LMT}
- {-1938538284 -14400 0 PEST}
- {-1002052800 -18000 0 PET}
- {-986756400 -14400 1 PEST}
- {-971035200 -18000 0 PET}
- {-955306800 -14400 1 PEST}
- {-939585600 -18000 0 PET}
- {512712000 -18000 0 PET}
- {544248000 -18000 0 PET}
- {638942400 -18000 0 PET}
- {765172800 -18000 0 PET}
+ {-1938538284 -14400 0 -04}
+ {-1002052800 -18000 0 -05}
+ {-986756400 -14400 1 -04}
+ {-971035200 -18000 0 -05}
+ {-955306800 -14400 1 -04}
+ {-939585600 -18000 0 -05}
+ {512712000 -18000 0 -05}
+ {544248000 -18000 0 -05}
+ {638942400 -18000 0 -05}
+ {765172800 -18000 0 -05}
}
diff --git a/library/tzdata/America/Los_Angeles b/library/tzdata/America/Los_Angeles
index da6ca99..8e26526 100644
--- a/library/tzdata/America/Los_Angeles
+++ b/library/tzdata/America/Los_Angeles
@@ -11,41 +11,41 @@ set TZData(:America/Los_Angeles) {
{-769395600 -25200 1 PPT}
{-765385200 -28800 0 PST}
{-757353600 -28800 0 PST}
- {-687967200 -25200 1 PDT}
+ {-687967140 -25200 1 PDT}
{-662655600 -28800 0 PST}
- {-620834400 -25200 1 PDT}
+ {-620838000 -25200 1 PDT}
{-608137200 -28800 0 PST}
- {-589384800 -25200 1 PDT}
+ {-589388400 -25200 1 PDT}
{-576082800 -28800 0 PST}
- {-557935200 -25200 1 PDT}
+ {-557938800 -25200 1 PDT}
{-544633200 -28800 0 PST}
- {-526485600 -25200 1 PDT}
+ {-526489200 -25200 1 PDT}
{-513183600 -28800 0 PST}
- {-495036000 -25200 1 PDT}
+ {-495039600 -25200 1 PDT}
{-481734000 -28800 0 PST}
- {-463586400 -25200 1 PDT}
+ {-463590000 -25200 1 PDT}
{-450284400 -28800 0 PST}
- {-431532000 -25200 1 PDT}
+ {-431535600 -25200 1 PDT}
{-418230000 -28800 0 PST}
- {-400082400 -25200 1 PDT}
+ {-400086000 -25200 1 PDT}
{-386780400 -28800 0 PST}
- {-368632800 -25200 1 PDT}
+ {-368636400 -25200 1 PDT}
{-355330800 -28800 0 PST}
- {-337183200 -25200 1 PDT}
+ {-337186800 -25200 1 PDT}
{-323881200 -28800 0 PST}
- {-305733600 -25200 1 PDT}
+ {-305737200 -25200 1 PDT}
{-292431600 -28800 0 PST}
- {-273679200 -25200 1 PDT}
+ {-273682800 -25200 1 PDT}
{-260982000 -28800 0 PST}
- {-242229600 -25200 1 PDT}
+ {-242233200 -25200 1 PDT}
{-226508400 -28800 0 PST}
- {-210780000 -25200 1 PDT}
+ {-210783600 -25200 1 PDT}
{-195058800 -28800 0 PST}
- {-179330400 -25200 1 PDT}
+ {-179334000 -25200 1 PDT}
{-163609200 -28800 0 PST}
- {-147880800 -25200 1 PDT}
+ {-147884400 -25200 1 PDT}
{-131554800 -28800 0 PST}
- {-116431200 -25200 1 PDT}
+ {-116434800 -25200 1 PDT}
{-100105200 -28800 0 PST}
{-94665600 -28800 0 PST}
{-84376800 -25200 1 PDT}
diff --git a/library/tzdata/America/Maceio b/library/tzdata/America/Maceio
index 333b878..e6ed548 100644
--- a/library/tzdata/America/Maceio
+++ b/library/tzdata/America/Maceio
@@ -2,51 +2,51 @@
set TZData(:America/Maceio) {
{-9223372036854775808 -8572 0 LMT}
- {-1767217028 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {653536800 -10800 0 BRT}
- {813553200 -10800 0 BRT}
- {813726000 -7200 1 BRST}
- {824004000 -10800 0 BRT}
- {841802400 -10800 0 BRT}
- {938660400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {972180000 -10800 0 BRT}
- {1000350000 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1033437600 -10800 0 BRT}
+ {-1767217028 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {653536800 -10800 0 -03}
+ {813553200 -10800 0 -03}
+ {813726000 -7200 1 -02}
+ {824004000 -10800 0 -03}
+ {841802400 -10800 0 -03}
+ {938660400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {972180000 -10800 0 -03}
+ {1000350000 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1033437600 -10800 0 -03}
}
diff --git a/library/tzdata/America/Manaus b/library/tzdata/America/Manaus
index 058e0f7..f17023c 100644
--- a/library/tzdata/America/Manaus
+++ b/library/tzdata/America/Manaus
@@ -2,38 +2,38 @@
set TZData(:America/Manaus) {
{-9223372036854775808 -14404 0 LMT}
- {-1767211196 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {590036400 -14400 0 AMT}
- {749188800 -14400 0 AMT}
- {750830400 -10800 1 AMST}
- {761713200 -14400 0 AMT}
- {780202800 -14400 0 AMT}
+ {-1767211196 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {590036400 -14400 0 -04}
+ {749188800 -14400 0 -04}
+ {750830400 -10800 1 -03}
+ {761713200 -14400 0 -04}
+ {780202800 -14400 0 -04}
}
diff --git a/library/tzdata/America/Miquelon b/library/tzdata/America/Miquelon
index a7410f1..c299be6 100644
--- a/library/tzdata/America/Miquelon
+++ b/library/tzdata/America/Miquelon
@@ -3,232 +3,232 @@
set TZData(:America/Miquelon) {
{-9223372036854775808 -13480 0 LMT}
{-1850328920 -14400 0 AST}
- {326001600 -10800 0 PMST}
- {536468400 -10800 0 PMST}
- {544597200 -7200 1 PMDT}
- {562132800 -10800 0 PMST}
- {576046800 -7200 1 PMDT}
- {594187200 -10800 0 PMST}
- {607496400 -7200 1 PMDT}
- {625636800 -10800 0 PMST}
- {638946000 -7200 1 PMDT}
- {657086400 -10800 0 PMST}
- {671000400 -7200 1 PMDT}
- {688536000 -10800 0 PMST}
- {702450000 -7200 1 PMDT}
- {719985600 -10800 0 PMST}
- {733899600 -7200 1 PMDT}
- {752040000 -10800 0 PMST}
- {765349200 -7200 1 PMDT}
- {783489600 -10800 0 PMST}
- {796798800 -7200 1 PMDT}
- {814939200 -10800 0 PMST}
- {828853200 -7200 1 PMDT}
- {846388800 -10800 0 PMST}
- {860302800 -7200 1 PMDT}
- {877838400 -10800 0 PMST}
- {891752400 -7200 1 PMDT}
- {909288000 -10800 0 PMST}
- {923202000 -7200 1 PMDT}
- {941342400 -10800 0 PMST}
- {954651600 -7200 1 PMDT}
- {972792000 -10800 0 PMST}
- {986101200 -7200 1 PMDT}
- {1004241600 -10800 0 PMST}
- {1018155600 -7200 1 PMDT}
- {1035691200 -10800 0 PMST}
- {1049605200 -7200 1 PMDT}
- {1067140800 -10800 0 PMST}
- {1081054800 -7200 1 PMDT}
- {1099195200 -10800 0 PMST}
- {1112504400 -7200 1 PMDT}
- {1130644800 -10800 0 PMST}
- {1143954000 -7200 1 PMDT}
- {1162094400 -10800 0 PMST}
- {1173589200 -7200 1 PMDT}
- {1194148800 -10800 0 PMST}
- {1205038800 -7200 1 PMDT}
- {1225598400 -10800 0 PMST}
- {1236488400 -7200 1 PMDT}
- {1257048000 -10800 0 PMST}
- {1268542800 -7200 1 PMDT}
- {1289102400 -10800 0 PMST}
- {1299992400 -7200 1 PMDT}
- {1320552000 -10800 0 PMST}
- {1331442000 -7200 1 PMDT}
- {1352001600 -10800 0 PMST}
- {1362891600 -7200 1 PMDT}
- {1383451200 -10800 0 PMST}
- {1394341200 -7200 1 PMDT}
- {1414900800 -10800 0 PMST}
- {1425790800 -7200 1 PMDT}
- {1446350400 -10800 0 PMST}
- {1457845200 -7200 1 PMDT}
- {1478404800 -10800 0 PMST}
- {1489294800 -7200 1 PMDT}
- {1509854400 -10800 0 PMST}
- {1520744400 -7200 1 PMDT}
- {1541304000 -10800 0 PMST}
- {1552194000 -7200 1 PMDT}
- {1572753600 -10800 0 PMST}
- {1583643600 -7200 1 PMDT}
- {1604203200 -10800 0 PMST}
- {1615698000 -7200 1 PMDT}
- {1636257600 -10800 0 PMST}
- {1647147600 -7200 1 PMDT}
- {1667707200 -10800 0 PMST}
- {1678597200 -7200 1 PMDT}
- {1699156800 -10800 0 PMST}
- {1710046800 -7200 1 PMDT}
- {1730606400 -10800 0 PMST}
- {1741496400 -7200 1 PMDT}
- {1762056000 -10800 0 PMST}
- {1772946000 -7200 1 PMDT}
- {1793505600 -10800 0 PMST}
- {1805000400 -7200 1 PMDT}
- {1825560000 -10800 0 PMST}
- {1836450000 -7200 1 PMDT}
- {1857009600 -10800 0 PMST}
- {1867899600 -7200 1 PMDT}
- {1888459200 -10800 0 PMST}
- {1899349200 -7200 1 PMDT}
- {1919908800 -10800 0 PMST}
- {1930798800 -7200 1 PMDT}
- {1951358400 -10800 0 PMST}
- {1962853200 -7200 1 PMDT}
- {1983412800 -10800 0 PMST}
- {1994302800 -7200 1 PMDT}
- {2014862400 -10800 0 PMST}
- {2025752400 -7200 1 PMDT}
- {2046312000 -10800 0 PMST}
- {2057202000 -7200 1 PMDT}
- {2077761600 -10800 0 PMST}
- {2088651600 -7200 1 PMDT}
- {2109211200 -10800 0 PMST}
- {2120101200 -7200 1 PMDT}
- {2140660800 -10800 0 PMST}
- {2152155600 -7200 1 PMDT}
- {2172715200 -10800 0 PMST}
- {2183605200 -7200 1 PMDT}
- {2204164800 -10800 0 PMST}
- {2215054800 -7200 1 PMDT}
- {2235614400 -10800 0 PMST}
- {2246504400 -7200 1 PMDT}
- {2267064000 -10800 0 PMST}
- {2277954000 -7200 1 PMDT}
- {2298513600 -10800 0 PMST}
- {2309403600 -7200 1 PMDT}
- {2329963200 -10800 0 PMST}
- {2341458000 -7200 1 PMDT}
- {2362017600 -10800 0 PMST}
- {2372907600 -7200 1 PMDT}
- {2393467200 -10800 0 PMST}
- {2404357200 -7200 1 PMDT}
- {2424916800 -10800 0 PMST}
- {2435806800 -7200 1 PMDT}
- {2456366400 -10800 0 PMST}
- {2467256400 -7200 1 PMDT}
- {2487816000 -10800 0 PMST}
- {2499310800 -7200 1 PMDT}
- {2519870400 -10800 0 PMST}
- {2530760400 -7200 1 PMDT}
- {2551320000 -10800 0 PMST}
- {2562210000 -7200 1 PMDT}
- {2582769600 -10800 0 PMST}
- {2593659600 -7200 1 PMDT}
- {2614219200 -10800 0 PMST}
- {2625109200 -7200 1 PMDT}
- {2645668800 -10800 0 PMST}
- {2656558800 -7200 1 PMDT}
- {2677118400 -10800 0 PMST}
- {2688613200 -7200 1 PMDT}
- {2709172800 -10800 0 PMST}
- {2720062800 -7200 1 PMDT}
- {2740622400 -10800 0 PMST}
- {2751512400 -7200 1 PMDT}
- {2772072000 -10800 0 PMST}
- {2782962000 -7200 1 PMDT}
- {2803521600 -10800 0 PMST}
- {2814411600 -7200 1 PMDT}
- {2834971200 -10800 0 PMST}
- {2846466000 -7200 1 PMDT}
- {2867025600 -10800 0 PMST}
- {2877915600 -7200 1 PMDT}
- {2898475200 -10800 0 PMST}
- {2909365200 -7200 1 PMDT}
- {2929924800 -10800 0 PMST}
- {2940814800 -7200 1 PMDT}
- {2961374400 -10800 0 PMST}
- {2972264400 -7200 1 PMDT}
- {2992824000 -10800 0 PMST}
- {3003714000 -7200 1 PMDT}
- {3024273600 -10800 0 PMST}
- {3035768400 -7200 1 PMDT}
- {3056328000 -10800 0 PMST}
- {3067218000 -7200 1 PMDT}
- {3087777600 -10800 0 PMST}
- {3098667600 -7200 1 PMDT}
- {3119227200 -10800 0 PMST}
- {3130117200 -7200 1 PMDT}
- {3150676800 -10800 0 PMST}
- {3161566800 -7200 1 PMDT}
- {3182126400 -10800 0 PMST}
- {3193016400 -7200 1 PMDT}
- {3213576000 -10800 0 PMST}
- {3225070800 -7200 1 PMDT}
- {3245630400 -10800 0 PMST}
- {3256520400 -7200 1 PMDT}
- {3277080000 -10800 0 PMST}
- {3287970000 -7200 1 PMDT}
- {3308529600 -10800 0 PMST}
- {3319419600 -7200 1 PMDT}
- {3339979200 -10800 0 PMST}
- {3350869200 -7200 1 PMDT}
- {3371428800 -10800 0 PMST}
- {3382923600 -7200 1 PMDT}
- {3403483200 -10800 0 PMST}
- {3414373200 -7200 1 PMDT}
- {3434932800 -10800 0 PMST}
- {3445822800 -7200 1 PMDT}
- {3466382400 -10800 0 PMST}
- {3477272400 -7200 1 PMDT}
- {3497832000 -10800 0 PMST}
- {3508722000 -7200 1 PMDT}
- {3529281600 -10800 0 PMST}
- {3540171600 -7200 1 PMDT}
- {3560731200 -10800 0 PMST}
- {3572226000 -7200 1 PMDT}
- {3592785600 -10800 0 PMST}
- {3603675600 -7200 1 PMDT}
- {3624235200 -10800 0 PMST}
- {3635125200 -7200 1 PMDT}
- {3655684800 -10800 0 PMST}
- {3666574800 -7200 1 PMDT}
- {3687134400 -10800 0 PMST}
- {3698024400 -7200 1 PMDT}
- {3718584000 -10800 0 PMST}
- {3730078800 -7200 1 PMDT}
- {3750638400 -10800 0 PMST}
- {3761528400 -7200 1 PMDT}
- {3782088000 -10800 0 PMST}
- {3792978000 -7200 1 PMDT}
- {3813537600 -10800 0 PMST}
- {3824427600 -7200 1 PMDT}
- {3844987200 -10800 0 PMST}
- {3855877200 -7200 1 PMDT}
- {3876436800 -10800 0 PMST}
- {3887326800 -7200 1 PMDT}
- {3907886400 -10800 0 PMST}
- {3919381200 -7200 1 PMDT}
- {3939940800 -10800 0 PMST}
- {3950830800 -7200 1 PMDT}
- {3971390400 -10800 0 PMST}
- {3982280400 -7200 1 PMDT}
- {4002840000 -10800 0 PMST}
- {4013730000 -7200 1 PMDT}
- {4034289600 -10800 0 PMST}
- {4045179600 -7200 1 PMDT}
- {4065739200 -10800 0 PMST}
- {4076629200 -7200 1 PMDT}
- {4097188800 -10800 0 PMST}
+ {326001600 -10800 0 -03}
+ {536468400 -10800 0 -02}
+ {544597200 -7200 1 -02}
+ {562132800 -10800 0 -02}
+ {576046800 -7200 1 -02}
+ {594187200 -10800 0 -02}
+ {607496400 -7200 1 -02}
+ {625636800 -10800 0 -02}
+ {638946000 -7200 1 -02}
+ {657086400 -10800 0 -02}
+ {671000400 -7200 1 -02}
+ {688536000 -10800 0 -02}
+ {702450000 -7200 1 -02}
+ {719985600 -10800 0 -02}
+ {733899600 -7200 1 -02}
+ {752040000 -10800 0 -02}
+ {765349200 -7200 1 -02}
+ {783489600 -10800 0 -02}
+ {796798800 -7200 1 -02}
+ {814939200 -10800 0 -02}
+ {828853200 -7200 1 -02}
+ {846388800 -10800 0 -02}
+ {860302800 -7200 1 -02}
+ {877838400 -10800 0 -02}
+ {891752400 -7200 1 -02}
+ {909288000 -10800 0 -02}
+ {923202000 -7200 1 -02}
+ {941342400 -10800 0 -02}
+ {954651600 -7200 1 -02}
+ {972792000 -10800 0 -02}
+ {986101200 -7200 1 -02}
+ {1004241600 -10800 0 -02}
+ {1018155600 -7200 1 -02}
+ {1035691200 -10800 0 -02}
+ {1049605200 -7200 1 -02}
+ {1067140800 -10800 0 -02}
+ {1081054800 -7200 1 -02}
+ {1099195200 -10800 0 -02}
+ {1112504400 -7200 1 -02}
+ {1130644800 -10800 0 -02}
+ {1143954000 -7200 1 -02}
+ {1162094400 -10800 0 -02}
+ {1173589200 -7200 1 -02}
+ {1194148800 -10800 0 -02}
+ {1205038800 -7200 1 -02}
+ {1225598400 -10800 0 -02}
+ {1236488400 -7200 1 -02}
+ {1257048000 -10800 0 -02}
+ {1268542800 -7200 1 -02}
+ {1289102400 -10800 0 -02}
+ {1299992400 -7200 1 -02}
+ {1320552000 -10800 0 -02}
+ {1331442000 -7200 1 -02}
+ {1352001600 -10800 0 -02}
+ {1362891600 -7200 1 -02}
+ {1383451200 -10800 0 -02}
+ {1394341200 -7200 1 -02}
+ {1414900800 -10800 0 -02}
+ {1425790800 -7200 1 -02}
+ {1446350400 -10800 0 -02}
+ {1457845200 -7200 1 -02}
+ {1478404800 -10800 0 -02}
+ {1489294800 -7200 1 -02}
+ {1509854400 -10800 0 -02}
+ {1520744400 -7200 1 -02}
+ {1541304000 -10800 0 -02}
+ {1552194000 -7200 1 -02}
+ {1572753600 -10800 0 -02}
+ {1583643600 -7200 1 -02}
+ {1604203200 -10800 0 -02}
+ {1615698000 -7200 1 -02}
+ {1636257600 -10800 0 -02}
+ {1647147600 -7200 1 -02}
+ {1667707200 -10800 0 -02}
+ {1678597200 -7200 1 -02}
+ {1699156800 -10800 0 -02}
+ {1710046800 -7200 1 -02}
+ {1730606400 -10800 0 -02}
+ {1741496400 -7200 1 -02}
+ {1762056000 -10800 0 -02}
+ {1772946000 -7200 1 -02}
+ {1793505600 -10800 0 -02}
+ {1805000400 -7200 1 -02}
+ {1825560000 -10800 0 -02}
+ {1836450000 -7200 1 -02}
+ {1857009600 -10800 0 -02}
+ {1867899600 -7200 1 -02}
+ {1888459200 -10800 0 -02}
+ {1899349200 -7200 1 -02}
+ {1919908800 -10800 0 -02}
+ {1930798800 -7200 1 -02}
+ {1951358400 -10800 0 -02}
+ {1962853200 -7200 1 -02}
+ {1983412800 -10800 0 -02}
+ {1994302800 -7200 1 -02}
+ {2014862400 -10800 0 -02}
+ {2025752400 -7200 1 -02}
+ {2046312000 -10800 0 -02}
+ {2057202000 -7200 1 -02}
+ {2077761600 -10800 0 -02}
+ {2088651600 -7200 1 -02}
+ {2109211200 -10800 0 -02}
+ {2120101200 -7200 1 -02}
+ {2140660800 -10800 0 -02}
+ {2152155600 -7200 1 -02}
+ {2172715200 -10800 0 -02}
+ {2183605200 -7200 1 -02}
+ {2204164800 -10800 0 -02}
+ {2215054800 -7200 1 -02}
+ {2235614400 -10800 0 -02}
+ {2246504400 -7200 1 -02}
+ {2267064000 -10800 0 -02}
+ {2277954000 -7200 1 -02}
+ {2298513600 -10800 0 -02}
+ {2309403600 -7200 1 -02}
+ {2329963200 -10800 0 -02}
+ {2341458000 -7200 1 -02}
+ {2362017600 -10800 0 -02}
+ {2372907600 -7200 1 -02}
+ {2393467200 -10800 0 -02}
+ {2404357200 -7200 1 -02}
+ {2424916800 -10800 0 -02}
+ {2435806800 -7200 1 -02}
+ {2456366400 -10800 0 -02}
+ {2467256400 -7200 1 -02}
+ {2487816000 -10800 0 -02}
+ {2499310800 -7200 1 -02}
+ {2519870400 -10800 0 -02}
+ {2530760400 -7200 1 -02}
+ {2551320000 -10800 0 -02}
+ {2562210000 -7200 1 -02}
+ {2582769600 -10800 0 -02}
+ {2593659600 -7200 1 -02}
+ {2614219200 -10800 0 -02}
+ {2625109200 -7200 1 -02}
+ {2645668800 -10800 0 -02}
+ {2656558800 -7200 1 -02}
+ {2677118400 -10800 0 -02}
+ {2688613200 -7200 1 -02}
+ {2709172800 -10800 0 -02}
+ {2720062800 -7200 1 -02}
+ {2740622400 -10800 0 -02}
+ {2751512400 -7200 1 -02}
+ {2772072000 -10800 0 -02}
+ {2782962000 -7200 1 -02}
+ {2803521600 -10800 0 -02}
+ {2814411600 -7200 1 -02}
+ {2834971200 -10800 0 -02}
+ {2846466000 -7200 1 -02}
+ {2867025600 -10800 0 -02}
+ {2877915600 -7200 1 -02}
+ {2898475200 -10800 0 -02}
+ {2909365200 -7200 1 -02}
+ {2929924800 -10800 0 -02}
+ {2940814800 -7200 1 -02}
+ {2961374400 -10800 0 -02}
+ {2972264400 -7200 1 -02}
+ {2992824000 -10800 0 -02}
+ {3003714000 -7200 1 -02}
+ {3024273600 -10800 0 -02}
+ {3035768400 -7200 1 -02}
+ {3056328000 -10800 0 -02}
+ {3067218000 -7200 1 -02}
+ {3087777600 -10800 0 -02}
+ {3098667600 -7200 1 -02}
+ {3119227200 -10800 0 -02}
+ {3130117200 -7200 1 -02}
+ {3150676800 -10800 0 -02}
+ {3161566800 -7200 1 -02}
+ {3182126400 -10800 0 -02}
+ {3193016400 -7200 1 -02}
+ {3213576000 -10800 0 -02}
+ {3225070800 -7200 1 -02}
+ {3245630400 -10800 0 -02}
+ {3256520400 -7200 1 -02}
+ {3277080000 -10800 0 -02}
+ {3287970000 -7200 1 -02}
+ {3308529600 -10800 0 -02}
+ {3319419600 -7200 1 -02}
+ {3339979200 -10800 0 -02}
+ {3350869200 -7200 1 -02}
+ {3371428800 -10800 0 -02}
+ {3382923600 -7200 1 -02}
+ {3403483200 -10800 0 -02}
+ {3414373200 -7200 1 -02}
+ {3434932800 -10800 0 -02}
+ {3445822800 -7200 1 -02}
+ {3466382400 -10800 0 -02}
+ {3477272400 -7200 1 -02}
+ {3497832000 -10800 0 -02}
+ {3508722000 -7200 1 -02}
+ {3529281600 -10800 0 -02}
+ {3540171600 -7200 1 -02}
+ {3560731200 -10800 0 -02}
+ {3572226000 -7200 1 -02}
+ {3592785600 -10800 0 -02}
+ {3603675600 -7200 1 -02}
+ {3624235200 -10800 0 -02}
+ {3635125200 -7200 1 -02}
+ {3655684800 -10800 0 -02}
+ {3666574800 -7200 1 -02}
+ {3687134400 -10800 0 -02}
+ {3698024400 -7200 1 -02}
+ {3718584000 -10800 0 -02}
+ {3730078800 -7200 1 -02}
+ {3750638400 -10800 0 -02}
+ {3761528400 -7200 1 -02}
+ {3782088000 -10800 0 -02}
+ {3792978000 -7200 1 -02}
+ {3813537600 -10800 0 -02}
+ {3824427600 -7200 1 -02}
+ {3844987200 -10800 0 -02}
+ {3855877200 -7200 1 -02}
+ {3876436800 -10800 0 -02}
+ {3887326800 -7200 1 -02}
+ {3907886400 -10800 0 -02}
+ {3919381200 -7200 1 -02}
+ {3939940800 -10800 0 -02}
+ {3950830800 -7200 1 -02}
+ {3971390400 -10800 0 -02}
+ {3982280400 -7200 1 -02}
+ {4002840000 -10800 0 -02}
+ {4013730000 -7200 1 -02}
+ {4034289600 -10800 0 -02}
+ {4045179600 -7200 1 -02}
+ {4065739200 -10800 0 -02}
+ {4076629200 -7200 1 -02}
+ {4097188800 -10800 0 -02}
}
diff --git a/library/tzdata/America/Montevideo b/library/tzdata/America/Montevideo
index 91a5117..ff85fb3 100644
--- a/library/tzdata/America/Montevideo
+++ b/library/tzdata/America/Montevideo
@@ -3,90 +3,94 @@
set TZData(:America/Montevideo) {
{-9223372036854775808 -13484 0 LMT}
{-2256668116 -13484 0 MMT}
- {-1567455316 -12600 0 UYT}
- {-1459542600 -10800 1 UYHST}
- {-1443819600 -12600 0 UYT}
- {-1428006600 -10800 1 UYHST}
- {-1412283600 -12600 0 UYT}
- {-1396470600 -10800 1 UYHST}
- {-1380747600 -12600 0 UYT}
- {-1141590600 -10800 1 UYHST}
- {-1128286800 -12600 0 UYT}
- {-1110141000 -10800 1 UYHST}
- {-1096837200 -12600 0 UYT}
- {-1078691400 -10800 1 UYHST}
- {-1065387600 -12600 0 UYT}
- {-1046637000 -10800 1 UYHST}
- {-1033938000 -12600 0 UYT}
- {-1015187400 -10800 1 UYHST}
- {-1002488400 -12600 0 UYT}
- {-983737800 -10800 1 UYHST}
- {-971038800 -12600 0 UYT}
- {-952288200 -10800 1 UYHST}
- {-938984400 -12600 0 UYT}
- {-920838600 -10800 1 UYHST}
- {-907534800 -12600 0 UYT}
- {-896819400 -10800 1 UYHST}
- {-853623000 -10800 0 UYT}
- {-853621200 -7200 1 UYST}
- {-845848800 -10800 0 UYT}
- {-334789200 -7200 1 UYST}
- {-319672800 -10800 0 UYT}
- {-314226000 -7200 1 UYST}
- {-309996000 -10800 0 UYT}
- {-149720400 -7200 1 UYST}
- {-134604000 -10800 0 UYT}
- {-118270800 -7200 1 UYST}
- {-100044000 -10800 0 UYT}
- {-86821200 -7200 1 UYST}
- {-68508000 -10800 0 UYT}
- {-50446800 -9000 1 UYHST}
- {-34119000 -10800 0 UYT}
- {-18910800 -9000 1 UYHST}
- {-2583000 -10800 0 UYT}
- {12625200 -9000 1 UYHST}
- {28953000 -10800 0 UYT}
- {72932400 -7200 1 UYST}
- {82692000 -10800 0 UYT}
- {132116400 -9000 1 UYHST}
- {156911400 -7200 1 UYST}
- {212983200 -10800 0 UYT}
- {250052400 -7200 1 UYST}
- {260244000 -10800 0 UYT}
- {307594800 -7200 1 UYST}
- {325994400 -10800 0 UYT}
- {566449200 -7200 1 UYST}
- {574308000 -10800 0 UYT}
- {597812400 -7200 1 UYST}
- {605671200 -10800 0 UYT}
- {625633200 -7200 1 UYST}
- {636516000 -10800 0 UYT}
- {656478000 -7200 1 UYST}
- {667965600 -10800 0 UYT}
- {688532400 -7200 1 UYST}
- {699415200 -10800 0 UYT}
- {719377200 -7200 1 UYST}
- {730864800 -10800 0 UYT}
- {1095562800 -7200 1 UYST}
- {1111896000 -10800 0 UYT}
- {1128834000 -7200 1 UYST}
- {1142136000 -10800 0 UYT}
- {1159678800 -7200 1 UYST}
- {1173585600 -10800 0 UYT}
- {1191733200 -7200 1 UYST}
- {1205035200 -10800 0 UYT}
- {1223182800 -7200 1 UYST}
- {1236484800 -10800 0 UYT}
- {1254632400 -7200 1 UYST}
- {1268539200 -10800 0 UYT}
- {1286082000 -7200 1 UYST}
- {1299988800 -10800 0 UYT}
- {1317531600 -7200 1 UYST}
- {1331438400 -10800 0 UYT}
- {1349586000 -7200 1 UYST}
- {1362888000 -10800 0 UYT}
- {1381035600 -7200 1 UYST}
- {1394337600 -10800 0 UYT}
- {1412485200 -7200 1 UYST}
- {1425787200 -10800 0 UYT}
+ {-1567455316 -12600 0 -0330}
+ {-1459542600 -10800 1 -03}
+ {-1443819600 -12600 0 -0330}
+ {-1428006600 -10800 1 -03}
+ {-1412283600 -12600 0 -0330}
+ {-1396470600 -10800 1 -03}
+ {-1380747600 -12600 0 -0330}
+ {-1141590600 -10800 1 -03}
+ {-1128286800 -12600 0 -0330}
+ {-1110141000 -10800 1 -03}
+ {-1096837200 -12600 0 -0330}
+ {-1078691400 -10800 1 -03}
+ {-1065387600 -12600 0 -0330}
+ {-1046637000 -10800 1 -03}
+ {-1033938000 -12600 0 -0330}
+ {-1015187400 -10800 1 -03}
+ {-1002488400 -12600 0 -0330}
+ {-983737800 -10800 1 -03}
+ {-971038800 -12600 0 -0330}
+ {-952288200 -10800 1 -03}
+ {-938984400 -12600 0 -0330}
+ {-920838600 -10800 1 -03}
+ {-907534800 -12600 0 -0330}
+ {-896819400 -10800 1 -03}
+ {-853623000 -10800 0 -03}
+ {-853621200 -7200 1 -02}
+ {-845848800 -10800 0 -03}
+ {-334789200 -7200 1 -02}
+ {-319672800 -10800 0 -03}
+ {-314226000 -7200 1 -02}
+ {-309996000 -10800 0 -03}
+ {-149720400 -7200 1 -02}
+ {-134604000 -10800 0 -03}
+ {-118270800 -7200 1 -02}
+ {-100044000 -10800 0 -03}
+ {-86821200 -7200 1 -02}
+ {-68508000 -10800 0 -03}
+ {-63147600 -10800 0 -03}
+ {-50446800 -9000 1 -0230}
+ {-34119000 -10800 0 -03}
+ {-18910800 -9000 1 -0230}
+ {-2583000 -10800 0 -03}
+ {12625200 -9000 1 -0230}
+ {28953000 -10800 0 -03}
+ {31546800 -10800 0 -03}
+ {72932400 -7200 1 -02}
+ {82692000 -10800 0 -03}
+ {126241200 -10800 0 -03}
+ {132116400 -9000 1 -0230}
+ {156909600 -9000 0 -02}
+ {156911400 -7200 1 -02}
+ {212983200 -10800 0 -03}
+ {250052400 -7200 1 -02}
+ {260244000 -10800 0 -03}
+ {307594800 -7200 1 -02}
+ {325994400 -10800 0 -03}
+ {566449200 -7200 1 -02}
+ {574308000 -10800 0 -03}
+ {597812400 -7200 1 -02}
+ {605671200 -10800 0 -03}
+ {625633200 -7200 1 -02}
+ {636516000 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {667965600 -10800 0 -03}
+ {688532400 -7200 1 -02}
+ {699415200 -10800 0 -03}
+ {719377200 -7200 1 -02}
+ {730864800 -10800 0 -03}
+ {1095562800 -7200 1 -02}
+ {1111896000 -10800 0 -03}
+ {1128834000 -7200 1 -02}
+ {1142136000 -10800 0 -03}
+ {1159678800 -7200 1 -02}
+ {1173585600 -10800 0 -03}
+ {1191733200 -7200 1 -02}
+ {1205035200 -10800 0 -03}
+ {1223182800 -7200 1 -02}
+ {1236484800 -10800 0 -03}
+ {1254632400 -7200 1 -02}
+ {1268539200 -10800 0 -03}
+ {1286082000 -7200 1 -02}
+ {1299988800 -10800 0 -03}
+ {1317531600 -7200 1 -02}
+ {1331438400 -10800 0 -03}
+ {1349586000 -7200 1 -02}
+ {1362888000 -10800 0 -03}
+ {1381035600 -7200 1 -02}
+ {1394337600 -10800 0 -03}
+ {1412485200 -7200 1 -02}
+ {1425787200 -10800 0 -03}
}
diff --git a/library/tzdata/America/Noronha b/library/tzdata/America/Noronha
index 94d6f42..f24b412 100644
--- a/library/tzdata/America/Noronha
+++ b/library/tzdata/America/Noronha
@@ -2,47 +2,47 @@
set TZData(:America/Noronha) {
{-9223372036854775808 -7780 0 LMT}
- {-1767217820 -7200 0 FNT}
- {-1206961200 -3600 1 FNST}
- {-1191366000 -7200 0 FNT}
- {-1175378400 -3600 1 FNST}
- {-1159830000 -7200 0 FNT}
- {-633823200 -3600 1 FNST}
- {-622072800 -7200 0 FNT}
- {-602287200 -3600 1 FNST}
- {-591836400 -7200 0 FNT}
- {-570751200 -3600 1 FNST}
- {-560214000 -7200 0 FNT}
- {-539128800 -3600 1 FNST}
- {-531356400 -7200 0 FNT}
- {-191368800 -3600 1 FNST}
- {-184201200 -7200 0 FNT}
- {-155167200 -3600 1 FNST}
- {-150073200 -7200 0 FNT}
- {-128901600 -3600 1 FNST}
- {-121129200 -7200 0 FNT}
- {-99957600 -3600 1 FNST}
- {-89593200 -7200 0 FNT}
- {-68421600 -3600 1 FNST}
- {-57970800 -7200 0 FNT}
- {499744800 -3600 1 FNST}
- {511232400 -7200 0 FNT}
- {530589600 -3600 1 FNST}
- {540262800 -7200 0 FNT}
- {562125600 -3600 1 FNST}
- {571194000 -7200 0 FNT}
- {592970400 -3600 1 FNST}
- {602038800 -7200 0 FNT}
- {624420000 -3600 1 FNST}
- {634698000 -7200 0 FNT}
- {653533200 -7200 0 FNT}
- {938656800 -7200 0 FNT}
- {938916000 -3600 1 FNST}
- {951613200 -7200 0 FNT}
- {970970400 -3600 1 FNST}
- {971571600 -7200 0 FNT}
- {1000346400 -7200 0 FNT}
- {1003024800 -3600 1 FNST}
- {1013907600 -7200 0 FNT}
- {1033434000 -7200 0 FNT}
+ {-1767217820 -7200 0 -02}
+ {-1206961200 -3600 1 -01}
+ {-1191366000 -7200 0 -02}
+ {-1175378400 -3600 1 -01}
+ {-1159830000 -7200 0 -02}
+ {-633823200 -3600 1 -01}
+ {-622072800 -7200 0 -02}
+ {-602287200 -3600 1 -01}
+ {-591836400 -7200 0 -02}
+ {-570751200 -3600 1 -01}
+ {-560214000 -7200 0 -02}
+ {-539128800 -3600 1 -01}
+ {-531356400 -7200 0 -02}
+ {-191368800 -3600 1 -01}
+ {-184201200 -7200 0 -02}
+ {-155167200 -3600 1 -01}
+ {-150073200 -7200 0 -02}
+ {-128901600 -3600 1 -01}
+ {-121129200 -7200 0 -02}
+ {-99957600 -3600 1 -01}
+ {-89593200 -7200 0 -02}
+ {-68421600 -3600 1 -01}
+ {-57970800 -7200 0 -02}
+ {499744800 -3600 1 -01}
+ {511232400 -7200 0 -02}
+ {530589600 -3600 1 -01}
+ {540262800 -7200 0 -02}
+ {562125600 -3600 1 -01}
+ {571194000 -7200 0 -02}
+ {592970400 -3600 1 -01}
+ {602038800 -7200 0 -02}
+ {624420000 -3600 1 -01}
+ {634698000 -7200 0 -02}
+ {653533200 -7200 0 -02}
+ {938656800 -7200 0 -02}
+ {938916000 -3600 1 -01}
+ {951613200 -7200 0 -02}
+ {970970400 -3600 1 -01}
+ {971571600 -7200 0 -02}
+ {1000346400 -7200 0 -02}
+ {1003024800 -3600 1 -01}
+ {1013907600 -7200 0 -02}
+ {1033434000 -7200 0 -02}
}
diff --git a/library/tzdata/America/Paramaribo b/library/tzdata/America/Paramaribo
index d15f5c7..7a80f1d 100644
--- a/library/tzdata/America/Paramaribo
+++ b/library/tzdata/America/Paramaribo
@@ -4,7 +4,6 @@ set TZData(:America/Paramaribo) {
{-9223372036854775808 -13240 0 LMT}
{-1861906760 -13252 0 PMT}
{-1104524348 -13236 0 PMT}
- {-765317964 -12600 0 NEGT}
- {185686200 -12600 0 SRT}
- {465449400 -10800 0 SRT}
+ {-765317964 -12600 0 -0330}
+ {465449400 -10800 0 -03}
}
diff --git a/library/tzdata/America/Port-au-Prince b/library/tzdata/America/Port-au-Prince
index b8b60d6..23e7de4 100644
--- a/library/tzdata/America/Port-au-Prince
+++ b/library/tzdata/America/Port-au-Prince
@@ -46,4 +46,170 @@ set TZData(:America/Port-au-Prince) {
{1414908000 -18000 0 EST}
{1425798000 -14400 1 EDT}
{1446357600 -18000 0 EST}
+ {1489302000 -14400 1 EDT}
+ {1509861600 -18000 0 EST}
+ {1520751600 -14400 1 EDT}
+ {1541311200 -18000 0 EST}
+ {1552201200 -14400 1 EDT}
+ {1572760800 -18000 0 EST}
+ {1583650800 -14400 1 EDT}
+ {1604210400 -18000 0 EST}
+ {1615705200 -14400 1 EDT}
+ {1636264800 -18000 0 EST}
+ {1647154800 -14400 1 EDT}
+ {1667714400 -18000 0 EST}
+ {1678604400 -14400 1 EDT}
+ {1699164000 -18000 0 EST}
+ {1710054000 -14400 1 EDT}
+ {1730613600 -18000 0 EST}
+ {1741503600 -14400 1 EDT}
+ {1762063200 -18000 0 EST}
+ {1772953200 -14400 1 EDT}
+ {1793512800 -18000 0 EST}
+ {1805007600 -14400 1 EDT}
+ {1825567200 -18000 0 EST}
+ {1836457200 -14400 1 EDT}
+ {1857016800 -18000 0 EST}
+ {1867906800 -14400 1 EDT}
+ {1888466400 -18000 0 EST}
+ {1899356400 -14400 1 EDT}
+ {1919916000 -18000 0 EST}
+ {1930806000 -14400 1 EDT}
+ {1951365600 -18000 0 EST}
+ {1962860400 -14400 1 EDT}
+ {1983420000 -18000 0 EST}
+ {1994310000 -14400 1 EDT}
+ {2014869600 -18000 0 EST}
+ {2025759600 -14400 1 EDT}
+ {2046319200 -18000 0 EST}
+ {2057209200 -14400 1 EDT}
+ {2077768800 -18000 0 EST}
+ {2088658800 -14400 1 EDT}
+ {2109218400 -18000 0 EST}
+ {2120108400 -14400 1 EDT}
+ {2140668000 -18000 0 EST}
+ {2152162800 -14400 1 EDT}
+ {2172722400 -18000 0 EST}
+ {2183612400 -14400 1 EDT}
+ {2204172000 -18000 0 EST}
+ {2215062000 -14400 1 EDT}
+ {2235621600 -18000 0 EST}
+ {2246511600 -14400 1 EDT}
+ {2267071200 -18000 0 EST}
+ {2277961200 -14400 1 EDT}
+ {2298520800 -18000 0 EST}
+ {2309410800 -14400 1 EDT}
+ {2329970400 -18000 0 EST}
+ {2341465200 -14400 1 EDT}
+ {2362024800 -18000 0 EST}
+ {2372914800 -14400 1 EDT}
+ {2393474400 -18000 0 EST}
+ {2404364400 -14400 1 EDT}
+ {2424924000 -18000 0 EST}
+ {2435814000 -14400 1 EDT}
+ {2456373600 -18000 0 EST}
+ {2467263600 -14400 1 EDT}
+ {2487823200 -18000 0 EST}
+ {2499318000 -14400 1 EDT}
+ {2519877600 -18000 0 EST}
+ {2530767600 -14400 1 EDT}
+ {2551327200 -18000 0 EST}
+ {2562217200 -14400 1 EDT}
+ {2582776800 -18000 0 EST}
+ {2593666800 -14400 1 EDT}
+ {2614226400 -18000 0 EST}
+ {2625116400 -14400 1 EDT}
+ {2645676000 -18000 0 EST}
+ {2656566000 -14400 1 EDT}
+ {2677125600 -18000 0 EST}
+ {2688620400 -14400 1 EDT}
+ {2709180000 -18000 0 EST}
+ {2720070000 -14400 1 EDT}
+ {2740629600 -18000 0 EST}
+ {2751519600 -14400 1 EDT}
+ {2772079200 -18000 0 EST}
+ {2782969200 -14400 1 EDT}
+ {2803528800 -18000 0 EST}
+ {2814418800 -14400 1 EDT}
+ {2834978400 -18000 0 EST}
+ {2846473200 -14400 1 EDT}
+ {2867032800 -18000 0 EST}
+ {2877922800 -14400 1 EDT}
+ {2898482400 -18000 0 EST}
+ {2909372400 -14400 1 EDT}
+ {2929932000 -18000 0 EST}
+ {2940822000 -14400 1 EDT}
+ {2961381600 -18000 0 EST}
+ {2972271600 -14400 1 EDT}
+ {2992831200 -18000 0 EST}
+ {3003721200 -14400 1 EDT}
+ {3024280800 -18000 0 EST}
+ {3035775600 -14400 1 EDT}
+ {3056335200 -18000 0 EST}
+ {3067225200 -14400 1 EDT}
+ {3087784800 -18000 0 EST}
+ {3098674800 -14400 1 EDT}
+ {3119234400 -18000 0 EST}
+ {3130124400 -14400 1 EDT}
+ {3150684000 -18000 0 EST}
+ {3161574000 -14400 1 EDT}
+ {3182133600 -18000 0 EST}
+ {3193023600 -14400 1 EDT}
+ {3213583200 -18000 0 EST}
+ {3225078000 -14400 1 EDT}
+ {3245637600 -18000 0 EST}
+ {3256527600 -14400 1 EDT}
+ {3277087200 -18000 0 EST}
+ {3287977200 -14400 1 EDT}
+ {3308536800 -18000 0 EST}
+ {3319426800 -14400 1 EDT}
+ {3339986400 -18000 0 EST}
+ {3350876400 -14400 1 EDT}
+ {3371436000 -18000 0 EST}
+ {3382930800 -14400 1 EDT}
+ {3403490400 -18000 0 EST}
+ {3414380400 -14400 1 EDT}
+ {3434940000 -18000 0 EST}
+ {3445830000 -14400 1 EDT}
+ {3466389600 -18000 0 EST}
+ {3477279600 -14400 1 EDT}
+ {3497839200 -18000 0 EST}
+ {3508729200 -14400 1 EDT}
+ {3529288800 -18000 0 EST}
+ {3540178800 -14400 1 EDT}
+ {3560738400 -18000 0 EST}
+ {3572233200 -14400 1 EDT}
+ {3592792800 -18000 0 EST}
+ {3603682800 -14400 1 EDT}
+ {3624242400 -18000 0 EST}
+ {3635132400 -14400 1 EDT}
+ {3655692000 -18000 0 EST}
+ {3666582000 -14400 1 EDT}
+ {3687141600 -18000 0 EST}
+ {3698031600 -14400 1 EDT}
+ {3718591200 -18000 0 EST}
+ {3730086000 -14400 1 EDT}
+ {3750645600 -18000 0 EST}
+ {3761535600 -14400 1 EDT}
+ {3782095200 -18000 0 EST}
+ {3792985200 -14400 1 EDT}
+ {3813544800 -18000 0 EST}
+ {3824434800 -14400 1 EDT}
+ {3844994400 -18000 0 EST}
+ {3855884400 -14400 1 EDT}
+ {3876444000 -18000 0 EST}
+ {3887334000 -14400 1 EDT}
+ {3907893600 -18000 0 EST}
+ {3919388400 -14400 1 EDT}
+ {3939948000 -18000 0 EST}
+ {3950838000 -14400 1 EDT}
+ {3971397600 -18000 0 EST}
+ {3982287600 -14400 1 EDT}
+ {4002847200 -18000 0 EST}
+ {4013737200 -14400 1 EDT}
+ {4034296800 -18000 0 EST}
+ {4045186800 -14400 1 EDT}
+ {4065746400 -18000 0 EST}
+ {4076636400 -14400 1 EDT}
+ {4097196000 -18000 0 EST}
}
diff --git a/library/tzdata/America/Porto_Velho b/library/tzdata/America/Porto_Velho
index ce611d2..42566ad 100644
--- a/library/tzdata/America/Porto_Velho
+++ b/library/tzdata/America/Porto_Velho
@@ -2,34 +2,34 @@
set TZData(:America/Porto_Velho) {
{-9223372036854775808 -15336 0 LMT}
- {-1767210264 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {590036400 -14400 0 AMT}
+ {-1767210264 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {590036400 -14400 0 -04}
}
diff --git a/library/tzdata/America/Punta_Arenas b/library/tzdata/America/Punta_Arenas
new file mode 100644
index 0000000..75487e7
--- /dev/null
+++ b/library/tzdata/America/Punta_Arenas
@@ -0,0 +1,122 @@
+# created by tools/tclZIC.tcl - do not edit
+
+set TZData(:America/Punta_Arenas) {
+ {-9223372036854775808 -17020 0 LMT}
+ {-2524504580 -16966 0 SMT}
+ {-1892661434 -18000 0 -05}
+ {-1688410800 -16966 0 SMT}
+ {-1619205434 -14400 0 -04}
+ {-1593806400 -16966 0 SMT}
+ {-1335986234 -18000 0 -05}
+ {-1335985200 -14400 1 -04}
+ {-1317585600 -18000 0 -05}
+ {-1304362800 -14400 1 -04}
+ {-1286049600 -18000 0 -05}
+ {-1272826800 -14400 1 -04}
+ {-1254513600 -18000 0 -05}
+ {-1241290800 -14400 1 -04}
+ {-1222977600 -18000 0 -05}
+ {-1209754800 -14400 1 -04}
+ {-1191355200 -18000 0 -05}
+ {-1178132400 -14400 0 -04}
+ {-870552000 -18000 0 -05}
+ {-865278000 -14400 0 -04}
+ {-718056000 -18000 0 -05}
+ {-713649600 -14400 0 -04}
+ {-36619200 -10800 1 -03}
+ {-23922000 -14400 0 -04}
+ {-3355200 -10800 1 -03}
+ {7527600 -14400 0 -04}
+ {24465600 -10800 1 -03}
+ {37767600 -14400 0 -04}
+ {55915200 -10800 1 -03}
+ {69217200 -14400 0 -04}
+ {87969600 -10800 1 -03}
+ {100666800 -14400 0 -04}
+ {118209600 -10800 1 -03}
+ {132116400 -14400 0 -04}
+ {150868800 -10800 1 -03}
+ {163566000 -14400 0 -04}
+ {182318400 -10800 1 -03}
+ {195620400 -14400 0 -04}
+ {213768000 -10800 1 -03}
+ {227070000 -14400 0 -04}
+ {245217600 -10800 1 -03}
+ {258519600 -14400 0 -04}
+ {277272000 -10800 1 -03}
+ {289969200 -14400 0 -04}
+ {308721600 -10800 1 -03}
+ {321418800 -14400 0 -04}
+ {340171200 -10800 1 -03}
+ {353473200 -14400 0 -04}
+ {371620800 -10800 1 -03}
+ {384922800 -14400 0 -04}
+ {403070400 -10800 1 -03}
+ {416372400 -14400 0 -04}
+ {434520000 -10800 1 -03}
+ {447822000 -14400 0 -04}
+ {466574400 -10800 1 -03}
+ {479271600 -14400 0 -04}
+ {498024000 -10800 1 -03}
+ {510721200 -14400 0 -04}
+ {529473600 -10800 1 -03}
+ {545194800 -14400 0 -04}
+ {560923200 -10800 1 -03}
+ {574225200 -14400 0 -04}
+ {592372800 -10800 1 -03}
+ {605674800 -14400 0 -04}
+ {624427200 -10800 1 -03}
+ {637124400 -14400 0 -04}
+ {653457600 -10800 1 -03}
+ {668574000 -14400 0 -04}
+ {687326400 -10800 1 -03}
+ {700628400 -14400 0 -04}
+ {718776000 -10800 1 -03}
+ {732078000 -14400 0 -04}
+ {750225600 -10800 1 -03}
+ {763527600 -14400 0 -04}
+ {781675200 -10800 1 -03}
+ {794977200 -14400 0 -04}
+ {813729600 -10800 1 -03}
+ {826426800 -14400 0 -04}
+ {845179200 -10800 1 -03}
+ {859690800 -14400 0 -04}
+ {876628800 -10800 1 -03}
+ {889930800 -14400 0 -04}
+ {906868800 -10800 1 -03}
+ {923194800 -14400 0 -04}
+ {939528000 -10800 1 -03}
+ {952830000 -14400 0 -04}
+ {971582400 -10800 1 -03}
+ {984279600 -14400 0 -04}
+ {1003032000 -10800 1 -03}
+ {1015729200 -14400 0 -04}
+ {1034481600 -10800 1 -03}
+ {1047178800 -14400 0 -04}
+ {1065931200 -10800 1 -03}
+ {1079233200 -14400 0 -04}
+ {1097380800 -10800 1 -03}
+ {1110682800 -14400 0 -04}
+ {1128830400 -10800 1 -03}
+ {1142132400 -14400 0 -04}
+ {1160884800 -10800 1 -03}
+ {1173582000 -14400 0 -04}
+ {1192334400 -10800 1 -03}
+ {1206846000 -14400 0 -04}
+ {1223784000 -10800 1 -03}
+ {1237086000 -14400 0 -04}
+ {1255233600 -10800 1 -03}
+ {1270350000 -14400 0 -04}
+ {1286683200 -10800 1 -03}
+ {1304823600 -14400 0 -04}
+ {1313899200 -10800 1 -03}
+ {1335668400 -14400 0 -04}
+ {1346558400 -10800 1 -03}
+ {1367118000 -14400 0 -04}
+ {1378612800 -10800 1 -03}
+ {1398567600 -14400 0 -04}
+ {1410062400 -10800 1 -03}
+ {1463281200 -14400 0 -04}
+ {1471147200 -10800 1 -03}
+ {1480820400 -10800 0 -03}
+}
diff --git a/library/tzdata/America/Recife b/library/tzdata/America/Recife
index f6ae00e..8eae571 100644
--- a/library/tzdata/America/Recife
+++ b/library/tzdata/America/Recife
@@ -2,47 +2,47 @@
set TZData(:America/Recife) {
{-9223372036854775808 -8376 0 LMT}
- {-1767217224 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-191365200 -7200 1 BRST}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {653536800 -10800 0 BRT}
- {938660400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {971575200 -10800 0 BRT}
- {1000350000 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1033437600 -10800 0 BRT}
+ {-1767217224 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-191365200 -7200 1 -02}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {653536800 -10800 0 -03}
+ {938660400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {971575200 -10800 0 -03}
+ {1000350000 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1033437600 -10800 0 -03}
}
diff --git a/library/tzdata/America/Rio_Branco b/library/tzdata/America/Rio_Branco
index f0ff7fa..e3c2f31 100644
--- a/library/tzdata/America/Rio_Branco
+++ b/library/tzdata/America/Rio_Branco
@@ -2,36 +2,36 @@
set TZData(:America/Rio_Branco) {
{-9223372036854775808 -16272 0 LMT}
- {-1767209328 -18000 0 ACT}
- {-1206950400 -14400 1 ACST}
- {-1191355200 -18000 0 ACT}
- {-1175367600 -14400 1 ACST}
- {-1159819200 -18000 0 ACT}
- {-633812400 -14400 1 ACST}
- {-622062000 -18000 0 ACT}
- {-602276400 -14400 1 ACST}
- {-591825600 -18000 0 ACT}
- {-570740400 -14400 1 ACST}
- {-560203200 -18000 0 ACT}
- {-539118000 -14400 1 ACST}
- {-531345600 -18000 0 ACT}
- {-191358000 -14400 1 ACST}
- {-184190400 -18000 0 ACT}
- {-155156400 -14400 1 ACST}
- {-150062400 -18000 0 ACT}
- {-128890800 -14400 1 ACST}
- {-121118400 -18000 0 ACT}
- {-99946800 -14400 1 ACST}
- {-89582400 -18000 0 ACT}
- {-68410800 -14400 1 ACST}
- {-57960000 -18000 0 ACT}
- {499755600 -14400 1 ACST}
- {511243200 -18000 0 ACT}
- {530600400 -14400 1 ACST}
- {540273600 -18000 0 ACT}
- {562136400 -14400 1 ACST}
- {571204800 -18000 0 ACT}
- {590040000 -18000 0 ACT}
- {1214283600 -14400 0 AMT}
- {1384056000 -18000 0 ACT}
+ {-1767209328 -18000 0 -05}
+ {-1206950400 -14400 1 -04}
+ {-1191355200 -18000 0 -05}
+ {-1175367600 -14400 1 -04}
+ {-1159819200 -18000 0 -05}
+ {-633812400 -14400 1 -04}
+ {-622062000 -18000 0 -05}
+ {-602276400 -14400 1 -04}
+ {-591825600 -18000 0 -05}
+ {-570740400 -14400 1 -04}
+ {-560203200 -18000 0 -05}
+ {-539118000 -14400 1 -04}
+ {-531345600 -18000 0 -05}
+ {-191358000 -14400 1 -04}
+ {-184190400 -18000 0 -05}
+ {-155156400 -14400 1 -04}
+ {-150062400 -18000 0 -05}
+ {-128890800 -14400 1 -04}
+ {-121118400 -18000 0 -05}
+ {-99946800 -14400 1 -04}
+ {-89582400 -18000 0 -05}
+ {-68410800 -14400 1 -04}
+ {-57960000 -18000 0 -05}
+ {499755600 -14400 1 -04}
+ {511243200 -18000 0 -05}
+ {530600400 -14400 1 -04}
+ {540273600 -18000 0 -05}
+ {562136400 -14400 1 -04}
+ {571204800 -18000 0 -05}
+ {590040000 -18000 0 -05}
+ {1214283600 -14400 0 -04}
+ {1384056000 -18000 0 -05}
}
diff --git a/library/tzdata/America/Santarem b/library/tzdata/America/Santarem
index b6e9264..f81e9b6 100644
--- a/library/tzdata/America/Santarem
+++ b/library/tzdata/America/Santarem
@@ -2,35 +2,35 @@
set TZData(:America/Santarem) {
{-9223372036854775808 -13128 0 LMT}
- {-1767212472 -14400 0 AMT}
- {-1206954000 -10800 1 AMST}
- {-1191358800 -14400 0 AMT}
- {-1175371200 -10800 1 AMST}
- {-1159822800 -14400 0 AMT}
- {-633816000 -10800 1 AMST}
- {-622065600 -14400 0 AMT}
- {-602280000 -10800 1 AMST}
- {-591829200 -14400 0 AMT}
- {-570744000 -10800 1 AMST}
- {-560206800 -14400 0 AMT}
- {-539121600 -10800 1 AMST}
- {-531349200 -14400 0 AMT}
- {-191361600 -10800 1 AMST}
- {-184194000 -14400 0 AMT}
- {-155160000 -10800 1 AMST}
- {-150066000 -14400 0 AMT}
- {-128894400 -10800 1 AMST}
- {-121122000 -14400 0 AMT}
- {-99950400 -10800 1 AMST}
- {-89586000 -14400 0 AMT}
- {-68414400 -10800 1 AMST}
- {-57963600 -14400 0 AMT}
- {499752000 -10800 1 AMST}
- {511239600 -14400 0 AMT}
- {530596800 -10800 1 AMST}
- {540270000 -14400 0 AMT}
- {562132800 -10800 1 AMST}
- {571201200 -14400 0 AMT}
- {590036400 -14400 0 AMT}
- {1214280000 -10800 0 BRT}
+ {-1767212472 -14400 0 -04}
+ {-1206954000 -10800 1 -03}
+ {-1191358800 -14400 0 -04}
+ {-1175371200 -10800 1 -03}
+ {-1159822800 -14400 0 -04}
+ {-633816000 -10800 1 -03}
+ {-622065600 -14400 0 -04}
+ {-602280000 -10800 1 -03}
+ {-591829200 -14400 0 -04}
+ {-570744000 -10800 1 -03}
+ {-560206800 -14400 0 -04}
+ {-539121600 -10800 1 -03}
+ {-531349200 -14400 0 -04}
+ {-191361600 -10800 1 -03}
+ {-184194000 -14400 0 -04}
+ {-155160000 -10800 1 -03}
+ {-150066000 -14400 0 -04}
+ {-128894400 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-99950400 -10800 1 -03}
+ {-89586000 -14400 0 -04}
+ {-68414400 -10800 1 -03}
+ {-57963600 -14400 0 -04}
+ {499752000 -10800 1 -03}
+ {511239600 -14400 0 -04}
+ {530596800 -10800 1 -03}
+ {540270000 -14400 0 -04}
+ {562132800 -10800 1 -03}
+ {571201200 -14400 0 -04}
+ {590036400 -14400 0 -04}
+ {1214280000 -10800 0 -03}
}
diff --git a/library/tzdata/America/Santiago b/library/tzdata/America/Santiago
index 3a5c0fd..95e920d 100644
--- a/library/tzdata/America/Santiago
+++ b/library/tzdata/America/Santiago
@@ -3,287 +3,287 @@
set TZData(:America/Santiago) {
{-9223372036854775808 -16966 0 LMT}
{-2524504634 -16966 0 SMT}
- {-1892661434 -18000 0 CLT}
+ {-1892661434 -18000 0 -05}
{-1688410800 -16966 0 SMT}
- {-1619205434 -14400 0 CLT}
+ {-1619205434 -14400 0 -04}
{-1593806400 -16966 0 SMT}
- {-1335986234 -18000 0 CLT}
- {-1335985200 -14400 1 CLST}
- {-1317585600 -18000 0 CLT}
- {-1304362800 -14400 1 CLST}
- {-1286049600 -18000 0 CLT}
- {-1272826800 -14400 1 CLST}
- {-1254513600 -18000 0 CLT}
- {-1241290800 -14400 1 CLST}
- {-1222977600 -18000 0 CLT}
- {-1209754800 -14400 1 CLST}
- {-1191355200 -18000 0 CLT}
- {-1178132400 -14400 0 CLT}
- {-870552000 -18000 0 CLT}
- {-865278000 -14400 0 CLT}
- {-740520000 -10800 1 CLST}
- {-736376400 -14400 0 CLT}
- {-718056000 -18000 0 CLT}
- {-713649600 -14400 0 CLT}
- {-36619200 -10800 1 CLST}
- {-23922000 -14400 0 CLT}
- {-3355200 -10800 1 CLST}
- {7527600 -14400 0 CLT}
- {24465600 -10800 1 CLST}
- {37767600 -14400 0 CLT}
- {55915200 -10800 1 CLST}
- {69217200 -14400 0 CLT}
- {87969600 -10800 1 CLST}
- {100666800 -14400 0 CLT}
- {118209600 -10800 1 CLST}
- {132116400 -14400 0 CLT}
- {150868800 -10800 1 CLST}
- {163566000 -14400 0 CLT}
- {182318400 -10800 1 CLST}
- {195620400 -14400 0 CLT}
- {213768000 -10800 1 CLST}
- {227070000 -14400 0 CLT}
- {245217600 -10800 1 CLST}
- {258519600 -14400 0 CLT}
- {277272000 -10800 1 CLST}
- {289969200 -14400 0 CLT}
- {308721600 -10800 1 CLST}
- {321418800 -14400 0 CLT}
- {340171200 -10800 1 CLST}
- {353473200 -14400 0 CLT}
- {371620800 -10800 1 CLST}
- {384922800 -14400 0 CLT}
- {403070400 -10800 1 CLST}
- {416372400 -14400 0 CLT}
- {434520000 -10800 1 CLST}
- {447822000 -14400 0 CLT}
- {466574400 -10800 1 CLST}
- {479271600 -14400 0 CLT}
- {498024000 -10800 1 CLST}
- {510721200 -14400 0 CLT}
- {529473600 -10800 1 CLST}
- {545194800 -14400 0 CLT}
- {560923200 -10800 1 CLST}
- {574225200 -14400 0 CLT}
- {592372800 -10800 1 CLST}
- {605674800 -14400 0 CLT}
- {624427200 -10800 1 CLST}
- {637124400 -14400 0 CLT}
- {653457600 -10800 1 CLST}
- {668574000 -14400 0 CLT}
- {687326400 -10800 1 CLST}
- {700628400 -14400 0 CLT}
- {718776000 -10800 1 CLST}
- {732078000 -14400 0 CLT}
- {750225600 -10800 1 CLST}
- {763527600 -14400 0 CLT}
- {781675200 -10800 1 CLST}
- {794977200 -14400 0 CLT}
- {813729600 -10800 1 CLST}
- {826426800 -14400 0 CLT}
- {845179200 -10800 1 CLST}
- {859690800 -14400 0 CLT}
- {876628800 -10800 1 CLST}
- {889930800 -14400 0 CLT}
- {906868800 -10800 1 CLST}
- {923194800 -14400 0 CLT}
- {939528000 -10800 1 CLST}
- {952830000 -14400 0 CLT}
- {971582400 -10800 1 CLST}
- {984279600 -14400 0 CLT}
- {1003032000 -10800 1 CLST}
- {1015729200 -14400 0 CLT}
- {1034481600 -10800 1 CLST}
- {1047178800 -14400 0 CLT}
- {1065931200 -10800 1 CLST}
- {1079233200 -14400 0 CLT}
- {1097380800 -10800 1 CLST}
- {1110682800 -14400 0 CLT}
- {1128830400 -10800 1 CLST}
- {1142132400 -14400 0 CLT}
- {1160884800 -10800 1 CLST}
- {1173582000 -14400 0 CLT}
- {1192334400 -10800 1 CLST}
- {1206846000 -14400 0 CLT}
- {1223784000 -10800 1 CLST}
- {1237086000 -14400 0 CLT}
- {1255233600 -10800 1 CLST}
- {1270350000 -14400 0 CLT}
- {1286683200 -10800 1 CLST}
- {1304823600 -14400 0 CLT}
- {1313899200 -10800 1 CLST}
- {1335668400 -14400 0 CLT}
- {1346558400 -10800 1 CLST}
- {1367118000 -14400 0 CLT}
- {1378612800 -10800 1 CLST}
- {1398567600 -14400 0 CLT}
- {1410062400 -10800 1 CLST}
- {1463281200 -14400 0 CLT}
- {1471147200 -10800 1 CLST}
- {1494730800 -14400 0 CLT}
- {1502596800 -10800 1 CLST}
- {1526180400 -14400 0 CLT}
- {1534046400 -10800 1 CLST}
- {1557630000 -14400 0 CLT}
- {1565496000 -10800 1 CLST}
- {1589079600 -14400 0 CLT}
- {1596945600 -10800 1 CLST}
- {1620529200 -14400 0 CLT}
- {1629000000 -10800 1 CLST}
- {1652583600 -14400 0 CLT}
- {1660449600 -10800 1 CLST}
- {1684033200 -14400 0 CLT}
- {1691899200 -10800 1 CLST}
- {1715482800 -14400 0 CLT}
- {1723348800 -10800 1 CLST}
- {1746932400 -14400 0 CLT}
- {1754798400 -10800 1 CLST}
- {1778382000 -14400 0 CLT}
- {1786248000 -10800 1 CLST}
- {1809831600 -14400 0 CLT}
- {1818302400 -10800 1 CLST}
- {1841886000 -14400 0 CLT}
- {1849752000 -10800 1 CLST}
- {1873335600 -14400 0 CLT}
- {1881201600 -10800 1 CLST}
- {1904785200 -14400 0 CLT}
- {1912651200 -10800 1 CLST}
- {1936234800 -14400 0 CLT}
- {1944100800 -10800 1 CLST}
- {1967684400 -14400 0 CLT}
- {1976155200 -10800 1 CLST}
- {1999738800 -14400 0 CLT}
- {2007604800 -10800 1 CLST}
- {2031188400 -14400 0 CLT}
- {2039054400 -10800 1 CLST}
- {2062638000 -14400 0 CLT}
- {2070504000 -10800 1 CLST}
- {2094087600 -14400 0 CLT}
- {2101953600 -10800 1 CLST}
- {2125537200 -14400 0 CLT}
- {2133403200 -10800 1 CLST}
- {2156986800 -14400 0 CLT}
- {2165457600 -10800 1 CLST}
- {2189041200 -14400 0 CLT}
- {2196907200 -10800 1 CLST}
- {2220490800 -14400 0 CLT}
- {2228356800 -10800 1 CLST}
- {2251940400 -14400 0 CLT}
- {2259806400 -10800 1 CLST}
- {2283390000 -14400 0 CLT}
- {2291256000 -10800 1 CLST}
- {2314839600 -14400 0 CLT}
- {2322705600 -10800 1 CLST}
- {2346894000 -14400 0 CLT}
- {2354760000 -10800 1 CLST}
- {2378343600 -14400 0 CLT}
- {2386209600 -10800 1 CLST}
- {2409793200 -14400 0 CLT}
- {2417659200 -10800 1 CLST}
- {2441242800 -14400 0 CLT}
- {2449108800 -10800 1 CLST}
- {2472692400 -14400 0 CLT}
- {2480558400 -10800 1 CLST}
- {2504142000 -14400 0 CLT}
- {2512612800 -10800 1 CLST}
- {2536196400 -14400 0 CLT}
- {2544062400 -10800 1 CLST}
- {2567646000 -14400 0 CLT}
- {2575512000 -10800 1 CLST}
- {2599095600 -14400 0 CLT}
- {2606961600 -10800 1 CLST}
- {2630545200 -14400 0 CLT}
- {2638411200 -10800 1 CLST}
- {2661994800 -14400 0 CLT}
- {2669860800 -10800 1 CLST}
- {2693444400 -14400 0 CLT}
- {2701915200 -10800 1 CLST}
- {2725498800 -14400 0 CLT}
- {2733364800 -10800 1 CLST}
- {2756948400 -14400 0 CLT}
- {2764814400 -10800 1 CLST}
- {2788398000 -14400 0 CLT}
- {2796264000 -10800 1 CLST}
- {2819847600 -14400 0 CLT}
- {2827713600 -10800 1 CLST}
- {2851297200 -14400 0 CLT}
- {2859768000 -10800 1 CLST}
- {2883351600 -14400 0 CLT}
- {2891217600 -10800 1 CLST}
- {2914801200 -14400 0 CLT}
- {2922667200 -10800 1 CLST}
- {2946250800 -14400 0 CLT}
- {2954116800 -10800 1 CLST}
- {2977700400 -14400 0 CLT}
- {2985566400 -10800 1 CLST}
- {3009150000 -14400 0 CLT}
- {3017016000 -10800 1 CLST}
- {3040599600 -14400 0 CLT}
- {3049070400 -10800 1 CLST}
- {3072654000 -14400 0 CLT}
- {3080520000 -10800 1 CLST}
- {3104103600 -14400 0 CLT}
- {3111969600 -10800 1 CLST}
- {3135553200 -14400 0 CLT}
- {3143419200 -10800 1 CLST}
- {3167002800 -14400 0 CLT}
- {3174868800 -10800 1 CLST}
- {3198452400 -14400 0 CLT}
- {3206318400 -10800 1 CLST}
- {3230506800 -14400 0 CLT}
- {3238372800 -10800 1 CLST}
- {3261956400 -14400 0 CLT}
- {3269822400 -10800 1 CLST}
- {3293406000 -14400 0 CLT}
- {3301272000 -10800 1 CLST}
- {3324855600 -14400 0 CLT}
- {3332721600 -10800 1 CLST}
- {3356305200 -14400 0 CLT}
- {3364171200 -10800 1 CLST}
- {3387754800 -14400 0 CLT}
- {3396225600 -10800 1 CLST}
- {3419809200 -14400 0 CLT}
- {3427675200 -10800 1 CLST}
- {3451258800 -14400 0 CLT}
- {3459124800 -10800 1 CLST}
- {3482708400 -14400 0 CLT}
- {3490574400 -10800 1 CLST}
- {3514158000 -14400 0 CLT}
- {3522024000 -10800 1 CLST}
- {3545607600 -14400 0 CLT}
- {3553473600 -10800 1 CLST}
- {3577057200 -14400 0 CLT}
- {3585528000 -10800 1 CLST}
- {3609111600 -14400 0 CLT}
- {3616977600 -10800 1 CLST}
- {3640561200 -14400 0 CLT}
- {3648427200 -10800 1 CLST}
- {3672010800 -14400 0 CLT}
- {3679876800 -10800 1 CLST}
- {3703460400 -14400 0 CLT}
- {3711326400 -10800 1 CLST}
- {3734910000 -14400 0 CLT}
- {3743380800 -10800 1 CLST}
- {3766964400 -14400 0 CLT}
- {3774830400 -10800 1 CLST}
- {3798414000 -14400 0 CLT}
- {3806280000 -10800 1 CLST}
- {3829863600 -14400 0 CLT}
- {3837729600 -10800 1 CLST}
- {3861313200 -14400 0 CLT}
- {3869179200 -10800 1 CLST}
- {3892762800 -14400 0 CLT}
- {3900628800 -10800 1 CLST}
- {3924212400 -14400 0 CLT}
- {3932683200 -10800 1 CLST}
- {3956266800 -14400 0 CLT}
- {3964132800 -10800 1 CLST}
- {3987716400 -14400 0 CLT}
- {3995582400 -10800 1 CLST}
- {4019166000 -14400 0 CLT}
- {4027032000 -10800 1 CLST}
- {4050615600 -14400 0 CLT}
- {4058481600 -10800 1 CLST}
- {4082065200 -14400 0 CLT}
- {4089931200 -10800 1 CLST}
+ {-1335986234 -18000 0 -05}
+ {-1335985200 -14400 1 -04}
+ {-1317585600 -18000 0 -05}
+ {-1304362800 -14400 1 -04}
+ {-1286049600 -18000 0 -05}
+ {-1272826800 -14400 1 -04}
+ {-1254513600 -18000 0 -05}
+ {-1241290800 -14400 1 -04}
+ {-1222977600 -18000 0 -05}
+ {-1209754800 -14400 1 -04}
+ {-1191355200 -18000 0 -05}
+ {-1178132400 -14400 0 -04}
+ {-870552000 -18000 0 -05}
+ {-865278000 -14400 0 -04}
+ {-740520000 -10800 1 -03}
+ {-736376400 -14400 0 -04}
+ {-718056000 -18000 0 -05}
+ {-713649600 -14400 0 -04}
+ {-36619200 -10800 1 -03}
+ {-23922000 -14400 0 -04}
+ {-3355200 -10800 1 -03}
+ {7527600 -14400 0 -04}
+ {24465600 -10800 1 -03}
+ {37767600 -14400 0 -04}
+ {55915200 -10800 1 -03}
+ {69217200 -14400 0 -04}
+ {87969600 -10800 1 -03}
+ {100666800 -14400 0 -04}
+ {118209600 -10800 1 -03}
+ {132116400 -14400 0 -04}
+ {150868800 -10800 1 -03}
+ {163566000 -14400 0 -04}
+ {182318400 -10800 1 -03}
+ {195620400 -14400 0 -04}
+ {213768000 -10800 1 -03}
+ {227070000 -14400 0 -04}
+ {245217600 -10800 1 -03}
+ {258519600 -14400 0 -04}
+ {277272000 -10800 1 -03}
+ {289969200 -14400 0 -04}
+ {308721600 -10800 1 -03}
+ {321418800 -14400 0 -04}
+ {340171200 -10800 1 -03}
+ {353473200 -14400 0 -04}
+ {371620800 -10800 1 -03}
+ {384922800 -14400 0 -04}
+ {403070400 -10800 1 -03}
+ {416372400 -14400 0 -04}
+ {434520000 -10800 1 -03}
+ {447822000 -14400 0 -04}
+ {466574400 -10800 1 -03}
+ {479271600 -14400 0 -04}
+ {498024000 -10800 1 -03}
+ {510721200 -14400 0 -04}
+ {529473600 -10800 1 -03}
+ {545194800 -14400 0 -04}
+ {560923200 -10800 1 -03}
+ {574225200 -14400 0 -04}
+ {592372800 -10800 1 -03}
+ {605674800 -14400 0 -04}
+ {624427200 -10800 1 -03}
+ {637124400 -14400 0 -04}
+ {653457600 -10800 1 -03}
+ {668574000 -14400 0 -04}
+ {687326400 -10800 1 -03}
+ {700628400 -14400 0 -04}
+ {718776000 -10800 1 -03}
+ {732078000 -14400 0 -04}
+ {750225600 -10800 1 -03}
+ {763527600 -14400 0 -04}
+ {781675200 -10800 1 -03}
+ {794977200 -14400 0 -04}
+ {813729600 -10800 1 -03}
+ {826426800 -14400 0 -04}
+ {845179200 -10800 1 -03}
+ {859690800 -14400 0 -04}
+ {876628800 -10800 1 -03}
+ {889930800 -14400 0 -04}
+ {906868800 -10800 1 -03}
+ {923194800 -14400 0 -04}
+ {939528000 -10800 1 -03}
+ {952830000 -14400 0 -04}
+ {971582400 -10800 1 -03}
+ {984279600 -14400 0 -04}
+ {1003032000 -10800 1 -03}
+ {1015729200 -14400 0 -04}
+ {1034481600 -10800 1 -03}
+ {1047178800 -14400 0 -04}
+ {1065931200 -10800 1 -03}
+ {1079233200 -14400 0 -04}
+ {1097380800 -10800 1 -03}
+ {1110682800 -14400 0 -04}
+ {1128830400 -10800 1 -03}
+ {1142132400 -14400 0 -04}
+ {1160884800 -10800 1 -03}
+ {1173582000 -14400 0 -04}
+ {1192334400 -10800 1 -03}
+ {1206846000 -14400 0 -04}
+ {1223784000 -10800 1 -03}
+ {1237086000 -14400 0 -04}
+ {1255233600 -10800 1 -03}
+ {1270350000 -14400 0 -04}
+ {1286683200 -10800 1 -03}
+ {1304823600 -14400 0 -04}
+ {1313899200 -10800 1 -03}
+ {1335668400 -14400 0 -04}
+ {1346558400 -10800 1 -03}
+ {1367118000 -14400 0 -04}
+ {1378612800 -10800 1 -03}
+ {1398567600 -14400 0 -04}
+ {1410062400 -10800 1 -03}
+ {1463281200 -14400 0 -04}
+ {1471147200 -10800 1 -03}
+ {1494730800 -14400 0 -04}
+ {1502596800 -10800 1 -03}
+ {1526180400 -14400 0 -04}
+ {1534046400 -10800 1 -03}
+ {1557630000 -14400 0 -04}
+ {1565496000 -10800 1 -03}
+ {1589079600 -14400 0 -04}
+ {1596945600 -10800 1 -03}
+ {1620529200 -14400 0 -04}
+ {1629000000 -10800 1 -03}
+ {1652583600 -14400 0 -04}
+ {1660449600 -10800 1 -03}
+ {1684033200 -14400 0 -04}
+ {1691899200 -10800 1 -03}
+ {1715482800 -14400 0 -04}
+ {1723348800 -10800 1 -03}
+ {1746932400 -14400 0 -04}
+ {1754798400 -10800 1 -03}
+ {1778382000 -14400 0 -04}
+ {1786248000 -10800 1 -03}
+ {1809831600 -14400 0 -04}
+ {1818302400 -10800 1 -03}
+ {1841886000 -14400 0 -04}
+ {1849752000 -10800 1 -03}
+ {1873335600 -14400 0 -04}
+ {1881201600 -10800 1 -03}
+ {1904785200 -14400 0 -04}
+ {1912651200 -10800 1 -03}
+ {1936234800 -14400 0 -04}
+ {1944100800 -10800 1 -03}
+ {1967684400 -14400 0 -04}
+ {1976155200 -10800 1 -03}
+ {1999738800 -14400 0 -04}
+ {2007604800 -10800 1 -03}
+ {2031188400 -14400 0 -04}
+ {2039054400 -10800 1 -03}
+ {2062638000 -14400 0 -04}
+ {2070504000 -10800 1 -03}
+ {2094087600 -14400 0 -04}
+ {2101953600 -10800 1 -03}
+ {2125537200 -14400 0 -04}
+ {2133403200 -10800 1 -03}
+ {2156986800 -14400 0 -04}
+ {2165457600 -10800 1 -03}
+ {2189041200 -14400 0 -04}
+ {2196907200 -10800 1 -03}
+ {2220490800 -14400 0 -04}
+ {2228356800 -10800 1 -03}
+ {2251940400 -14400 0 -04}
+ {2259806400 -10800 1 -03}
+ {2283390000 -14400 0 -04}
+ {2291256000 -10800 1 -03}
+ {2314839600 -14400 0 -04}
+ {2322705600 -10800 1 -03}
+ {2346894000 -14400 0 -04}
+ {2354760000 -10800 1 -03}
+ {2378343600 -14400 0 -04}
+ {2386209600 -10800 1 -03}
+ {2409793200 -14400 0 -04}
+ {2417659200 -10800 1 -03}
+ {2441242800 -14400 0 -04}
+ {2449108800 -10800 1 -03}
+ {2472692400 -14400 0 -04}
+ {2480558400 -10800 1 -03}
+ {2504142000 -14400 0 -04}
+ {2512612800 -10800 1 -03}
+ {2536196400 -14400 0 -04}
+ {2544062400 -10800 1 -03}
+ {2567646000 -14400 0 -04}
+ {2575512000 -10800 1 -03}
+ {2599095600 -14400 0 -04}
+ {2606961600 -10800 1 -03}
+ {2630545200 -14400 0 -04}
+ {2638411200 -10800 1 -03}
+ {2661994800 -14400 0 -04}
+ {2669860800 -10800 1 -03}
+ {2693444400 -14400 0 -04}
+ {2701915200 -10800 1 -03}
+ {2725498800 -14400 0 -04}
+ {2733364800 -10800 1 -03}
+ {2756948400 -14400 0 -04}
+ {2764814400 -10800 1 -03}
+ {2788398000 -14400 0 -04}
+ {2796264000 -10800 1 -03}
+ {2819847600 -14400 0 -04}
+ {2827713600 -10800 1 -03}
+ {2851297200 -14400 0 -04}
+ {2859768000 -10800 1 -03}
+ {2883351600 -14400 0 -04}
+ {2891217600 -10800 1 -03}
+ {2914801200 -14400 0 -04}
+ {2922667200 -10800 1 -03}
+ {2946250800 -14400 0 -04}
+ {2954116800 -10800 1 -03}
+ {2977700400 -14400 0 -04}
+ {2985566400 -10800 1 -03}
+ {3009150000 -14400 0 -04}
+ {3017016000 -10800 1 -03}
+ {3040599600 -14400 0 -04}
+ {3049070400 -10800 1 -03}
+ {3072654000 -14400 0 -04}
+ {3080520000 -10800 1 -03}
+ {3104103600 -14400 0 -04}
+ {3111969600 -10800 1 -03}
+ {3135553200 -14400 0 -04}
+ {3143419200 -10800 1 -03}
+ {3167002800 -14400 0 -04}
+ {3174868800 -10800 1 -03}
+ {3198452400 -14400 0 -04}
+ {3206318400 -10800 1 -03}
+ {3230506800 -14400 0 -04}
+ {3238372800 -10800 1 -03}
+ {3261956400 -14400 0 -04}
+ {3269822400 -10800 1 -03}
+ {3293406000 -14400 0 -04}
+ {3301272000 -10800 1 -03}
+ {3324855600 -14400 0 -04}
+ {3332721600 -10800 1 -03}
+ {3356305200 -14400 0 -04}
+ {3364171200 -10800 1 -03}
+ {3387754800 -14400 0 -04}
+ {3396225600 -10800 1 -03}
+ {3419809200 -14400 0 -04}
+ {3427675200 -10800 1 -03}
+ {3451258800 -14400 0 -04}
+ {3459124800 -10800 1 -03}
+ {3482708400 -14400 0 -04}
+ {3490574400 -10800 1 -03}
+ {3514158000 -14400 0 -04}
+ {3522024000 -10800 1 -03}
+ {3545607600 -14400 0 -04}
+ {3553473600 -10800 1 -03}
+ {3577057200 -14400 0 -04}
+ {3585528000 -10800 1 -03}
+ {3609111600 -14400 0 -04}
+ {3616977600 -10800 1 -03}
+ {3640561200 -14400 0 -04}
+ {3648427200 -10800 1 -03}
+ {3672010800 -14400 0 -04}
+ {3679876800 -10800 1 -03}
+ {3703460400 -14400 0 -04}
+ {3711326400 -10800 1 -03}
+ {3734910000 -14400 0 -04}
+ {3743380800 -10800 1 -03}
+ {3766964400 -14400 0 -04}
+ {3774830400 -10800 1 -03}
+ {3798414000 -14400 0 -04}
+ {3806280000 -10800 1 -03}
+ {3829863600 -14400 0 -04}
+ {3837729600 -10800 1 -03}
+ {3861313200 -14400 0 -04}
+ {3869179200 -10800 1 -03}
+ {3892762800 -14400 0 -04}
+ {3900628800 -10800 1 -03}
+ {3924212400 -14400 0 -04}
+ {3932683200 -10800 1 -03}
+ {3956266800 -14400 0 -04}
+ {3964132800 -10800 1 -03}
+ {3987716400 -14400 0 -04}
+ {3995582400 -10800 1 -03}
+ {4019166000 -14400 0 -04}
+ {4027032000 -10800 1 -03}
+ {4050615600 -14400 0 -04}
+ {4058481600 -10800 1 -03}
+ {4082065200 -14400 0 -04}
+ {4089931200 -10800 1 -03}
}
diff --git a/library/tzdata/America/Santo_Domingo b/library/tzdata/America/Santo_Domingo
index 7706918..28d3a9c 100644
--- a/library/tzdata/America/Santo_Domingo
+++ b/library/tzdata/America/Santo_Domingo
@@ -6,15 +6,15 @@ set TZData(:America/Santo_Domingo) {
{-1159773600 -18000 0 EST}
{-100119600 -14400 1 EDT}
{-89668800 -18000 0 EST}
- {-5770800 -16200 1 EHDT}
+ {-5770800 -16200 1 -0430}
{4422600 -18000 0 EST}
- {25678800 -16200 1 EHDT}
+ {25678800 -16200 1 -0430}
{33193800 -18000 0 EST}
- {57733200 -16200 1 EHDT}
+ {57733200 -16200 1 -0430}
{64816200 -18000 0 EST}
- {89182800 -16200 1 EHDT}
+ {89182800 -16200 1 -0430}
{96438600 -18000 0 EST}
- {120632400 -16200 1 EHDT}
+ {120632400 -16200 1 -0430}
{127974600 -18000 0 EST}
{152082000 -14400 0 AST}
{975823200 -14400 0 AST}
diff --git a/library/tzdata/America/Sao_Paulo b/library/tzdata/America/Sao_Paulo
index 8d70063..a61c638 100644
--- a/library/tzdata/America/Sao_Paulo
+++ b/library/tzdata/America/Sao_Paulo
@@ -2,257 +2,257 @@
set TZData(:America/Sao_Paulo) {
{-9223372036854775808 -11188 0 LMT}
- {-1767214412 -10800 0 BRT}
- {-1206957600 -7200 1 BRST}
- {-1191362400 -10800 0 BRT}
- {-1175374800 -7200 1 BRST}
- {-1159826400 -10800 0 BRT}
- {-633819600 -7200 1 BRST}
- {-622069200 -10800 0 BRT}
- {-602283600 -7200 1 BRST}
- {-591832800 -10800 0 BRT}
- {-570747600 -7200 1 BRST}
- {-560210400 -10800 0 BRT}
- {-539125200 -7200 1 BRST}
- {-531352800 -10800 0 BRT}
- {-195429600 -7200 1 BRST}
- {-189381600 -7200 0 BRT}
- {-184197600 -10800 0 BRT}
- {-155163600 -7200 1 BRST}
- {-150069600 -10800 0 BRT}
- {-128898000 -7200 1 BRST}
- {-121125600 -10800 0 BRT}
- {-99954000 -7200 1 BRST}
- {-89589600 -10800 0 BRT}
- {-68418000 -7200 1 BRST}
- {-57967200 -10800 0 BRT}
- {499748400 -7200 1 BRST}
- {511236000 -10800 0 BRT}
- {530593200 -7200 1 BRST}
- {540266400 -10800 0 BRT}
- {562129200 -7200 1 BRST}
- {571197600 -10800 0 BRT}
- {592974000 -7200 1 BRST}
- {602042400 -10800 0 BRT}
- {624423600 -7200 1 BRST}
- {634701600 -10800 0 BRT}
- {656478000 -7200 1 BRST}
- {666756000 -10800 0 BRT}
- {687927600 -7200 1 BRST}
- {697600800 -10800 0 BRT}
- {719982000 -7200 1 BRST}
- {728445600 -10800 0 BRT}
- {750826800 -7200 1 BRST}
- {761709600 -10800 0 BRT}
- {782276400 -7200 1 BRST}
- {793159200 -10800 0 BRT}
- {813726000 -7200 1 BRST}
- {824004000 -10800 0 BRT}
- {844570800 -7200 1 BRST}
- {856058400 -10800 0 BRT}
- {876106800 -7200 1 BRST}
- {888717600 -10800 0 BRT}
- {908074800 -7200 1 BRST}
- {919562400 -10800 0 BRT}
- {938919600 -7200 1 BRST}
- {951616800 -10800 0 BRT}
- {970974000 -7200 1 BRST}
- {982461600 -10800 0 BRT}
- {1003028400 -7200 1 BRST}
- {1013911200 -10800 0 BRT}
- {1036292400 -7200 1 BRST}
- {1045360800 -10800 0 BRT}
- {1066532400 -7200 1 BRST}
- {1076810400 -10800 0 BRT}
- {1099364400 -7200 1 BRST}
- {1108864800 -10800 0 BRT}
- {1129431600 -7200 1 BRST}
- {1140314400 -10800 0 BRT}
- {1162695600 -7200 1 BRST}
- {1172368800 -10800 0 BRT}
- {1192330800 -7200 1 BRST}
- {1203213600 -10800 0 BRT}
- {1224385200 -7200 1 BRST}
- {1234663200 -10800 0 BRT}
- {1255834800 -7200 1 BRST}
- {1266717600 -10800 0 BRT}
- {1287284400 -7200 1 BRST}
- {1298167200 -10800 0 BRT}
- {1318734000 -7200 1 BRST}
- {1330221600 -10800 0 BRT}
- {1350788400 -7200 1 BRST}
- {1361066400 -10800 0 BRT}
- {1382238000 -7200 1 BRST}
- {1392516000 -10800 0 BRT}
- {1413687600 -7200 1 BRST}
- {1424570400 -10800 0 BRT}
- {1445137200 -7200 1 BRST}
- {1456020000 -10800 0 BRT}
- {1476586800 -7200 1 BRST}
- {1487469600 -10800 0 BRT}
- {1508036400 -7200 1 BRST}
- {1518919200 -10800 0 BRT}
- {1540090800 -7200 1 BRST}
- {1550368800 -10800 0 BRT}
- {1571540400 -7200 1 BRST}
- {1581818400 -10800 0 BRT}
- {1602990000 -7200 1 BRST}
- {1613872800 -10800 0 BRT}
- {1634439600 -7200 1 BRST}
- {1645322400 -10800 0 BRT}
- {1665889200 -7200 1 BRST}
- {1677376800 -10800 0 BRT}
- {1697338800 -7200 1 BRST}
- {1708221600 -10800 0 BRT}
- {1729393200 -7200 1 BRST}
- {1739671200 -10800 0 BRT}
- {1760842800 -7200 1 BRST}
- {1771725600 -10800 0 BRT}
- {1792292400 -7200 1 BRST}
- {1803175200 -10800 0 BRT}
- {1823742000 -7200 1 BRST}
- {1834624800 -10800 0 BRT}
- {1855191600 -7200 1 BRST}
- {1866074400 -10800 0 BRT}
- {1887246000 -7200 1 BRST}
- {1897524000 -10800 0 BRT}
- {1918695600 -7200 1 BRST}
- {1928973600 -10800 0 BRT}
- {1950145200 -7200 1 BRST}
- {1960423200 -10800 0 BRT}
- {1981594800 -7200 1 BRST}
- {1992477600 -10800 0 BRT}
- {2013044400 -7200 1 BRST}
- {2024532000 -10800 0 BRT}
- {2044494000 -7200 1 BRST}
- {2055376800 -10800 0 BRT}
- {2076548400 -7200 1 BRST}
- {2086826400 -10800 0 BRT}
- {2107998000 -7200 1 BRST}
- {2118880800 -10800 0 BRT}
- {2139447600 -7200 1 BRST}
- {2150330400 -10800 0 BRT}
- {2170897200 -7200 1 BRST}
- {2181780000 -10800 0 BRT}
- {2202346800 -7200 1 BRST}
- {2213229600 -10800 0 BRT}
- {2234401200 -7200 1 BRST}
- {2244679200 -10800 0 BRT}
- {2265850800 -7200 1 BRST}
- {2276128800 -10800 0 BRT}
- {2297300400 -7200 1 BRST}
- {2307578400 -10800 0 BRT}
- {2328750000 -7200 1 BRST}
- {2339632800 -10800 0 BRT}
- {2360199600 -7200 1 BRST}
- {2371082400 -10800 0 BRT}
- {2391649200 -7200 1 BRST}
- {2402532000 -10800 0 BRT}
- {2423703600 -7200 1 BRST}
- {2433981600 -10800 0 BRT}
- {2455153200 -7200 1 BRST}
- {2465431200 -10800 0 BRT}
- {2486602800 -7200 1 BRST}
- {2497485600 -10800 0 BRT}
- {2518052400 -7200 1 BRST}
- {2528935200 -10800 0 BRT}
- {2549502000 -7200 1 BRST}
- {2560384800 -10800 0 BRT}
- {2580951600 -7200 1 BRST}
- {2591834400 -10800 0 BRT}
- {2613006000 -7200 1 BRST}
- {2623284000 -10800 0 BRT}
- {2644455600 -7200 1 BRST}
- {2654733600 -10800 0 BRT}
- {2675905200 -7200 1 BRST}
- {2686788000 -10800 0 BRT}
- {2707354800 -7200 1 BRST}
- {2718237600 -10800 0 BRT}
- {2738804400 -7200 1 BRST}
- {2749687200 -10800 0 BRT}
- {2770858800 -7200 1 BRST}
- {2781136800 -10800 0 BRT}
- {2802308400 -7200 1 BRST}
- {2812586400 -10800 0 BRT}
- {2833758000 -7200 1 BRST}
- {2844036000 -10800 0 BRT}
- {2865207600 -7200 1 BRST}
- {2876090400 -10800 0 BRT}
- {2896657200 -7200 1 BRST}
- {2907540000 -10800 0 BRT}
- {2928106800 -7200 1 BRST}
- {2938989600 -10800 0 BRT}
- {2960161200 -7200 1 BRST}
- {2970439200 -10800 0 BRT}
- {2991610800 -7200 1 BRST}
- {3001888800 -10800 0 BRT}
- {3023060400 -7200 1 BRST}
- {3033943200 -10800 0 BRT}
- {3054510000 -7200 1 BRST}
- {3065392800 -10800 0 BRT}
- {3085959600 -7200 1 BRST}
- {3096842400 -10800 0 BRT}
- {3118014000 -7200 1 BRST}
- {3128292000 -10800 0 BRT}
- {3149463600 -7200 1 BRST}
- {3159741600 -10800 0 BRT}
- {3180913200 -7200 1 BRST}
- {3191191200 -10800 0 BRT}
- {3212362800 -7200 1 BRST}
- {3223245600 -10800 0 BRT}
- {3243812400 -7200 1 BRST}
- {3254695200 -10800 0 BRT}
- {3275262000 -7200 1 BRST}
- {3286144800 -10800 0 BRT}
- {3307316400 -7200 1 BRST}
- {3317594400 -10800 0 BRT}
- {3338766000 -7200 1 BRST}
- {3349044000 -10800 0 BRT}
- {3370215600 -7200 1 BRST}
- {3381098400 -10800 0 BRT}
- {3401665200 -7200 1 BRST}
- {3412548000 -10800 0 BRT}
- {3433114800 -7200 1 BRST}
- {3443997600 -10800 0 BRT}
- {3464564400 -7200 1 BRST}
- {3475447200 -10800 0 BRT}
- {3496618800 -7200 1 BRST}
- {3506896800 -10800 0 BRT}
- {3528068400 -7200 1 BRST}
- {3538346400 -10800 0 BRT}
- {3559518000 -7200 1 BRST}
- {3570400800 -10800 0 BRT}
- {3590967600 -7200 1 BRST}
- {3601850400 -10800 0 BRT}
- {3622417200 -7200 1 BRST}
- {3633300000 -10800 0 BRT}
- {3654471600 -7200 1 BRST}
- {3664749600 -10800 0 BRT}
- {3685921200 -7200 1 BRST}
- {3696199200 -10800 0 BRT}
- {3717370800 -7200 1 BRST}
- {3727648800 -10800 0 BRT}
- {3748820400 -7200 1 BRST}
- {3759703200 -10800 0 BRT}
- {3780270000 -7200 1 BRST}
- {3791152800 -10800 0 BRT}
- {3811719600 -7200 1 BRST}
- {3822602400 -10800 0 BRT}
- {3843774000 -7200 1 BRST}
- {3854052000 -10800 0 BRT}
- {3875223600 -7200 1 BRST}
- {3885501600 -10800 0 BRT}
- {3906673200 -7200 1 BRST}
- {3917556000 -10800 0 BRT}
- {3938122800 -7200 1 BRST}
- {3949005600 -10800 0 BRT}
- {3969572400 -7200 1 BRST}
- {3980455200 -10800 0 BRT}
- {4001626800 -7200 1 BRST}
- {4011904800 -10800 0 BRT}
- {4033076400 -7200 1 BRST}
- {4043354400 -10800 0 BRT}
- {4064526000 -7200 1 BRST}
- {4074804000 -10800 0 BRT}
- {4095975600 -7200 1 BRST}
+ {-1767214412 -10800 0 -03}
+ {-1206957600 -7200 1 -02}
+ {-1191362400 -10800 0 -03}
+ {-1175374800 -7200 1 -02}
+ {-1159826400 -10800 0 -03}
+ {-633819600 -7200 1 -02}
+ {-622069200 -10800 0 -03}
+ {-602283600 -7200 1 -02}
+ {-591832800 -10800 0 -03}
+ {-570747600 -7200 1 -02}
+ {-560210400 -10800 0 -03}
+ {-539125200 -7200 1 -02}
+ {-531352800 -10800 0 -03}
+ {-195429600 -7200 1 -02}
+ {-189381600 -7200 0 -03}
+ {-184197600 -10800 0 -03}
+ {-155163600 -7200 1 -02}
+ {-150069600 -10800 0 -03}
+ {-128898000 -7200 1 -02}
+ {-121125600 -10800 0 -03}
+ {-99954000 -7200 1 -02}
+ {-89589600 -10800 0 -03}
+ {-68418000 -7200 1 -02}
+ {-57967200 -10800 0 -03}
+ {499748400 -7200 1 -02}
+ {511236000 -10800 0 -03}
+ {530593200 -7200 1 -02}
+ {540266400 -10800 0 -03}
+ {562129200 -7200 1 -02}
+ {571197600 -10800 0 -03}
+ {592974000 -7200 1 -02}
+ {602042400 -10800 0 -03}
+ {624423600 -7200 1 -02}
+ {634701600 -10800 0 -03}
+ {656478000 -7200 1 -02}
+ {666756000 -10800 0 -03}
+ {687927600 -7200 1 -02}
+ {697600800 -10800 0 -03}
+ {719982000 -7200 1 -02}
+ {728445600 -10800 0 -03}
+ {750826800 -7200 1 -02}
+ {761709600 -10800 0 -03}
+ {782276400 -7200 1 -02}
+ {793159200 -10800 0 -03}
+ {813726000 -7200 1 -02}
+ {824004000 -10800 0 -03}
+ {844570800 -7200 1 -02}
+ {856058400 -10800 0 -03}
+ {876106800 -7200 1 -02}
+ {888717600 -10800 0 -03}
+ {908074800 -7200 1 -02}
+ {919562400 -10800 0 -03}
+ {938919600 -7200 1 -02}
+ {951616800 -10800 0 -03}
+ {970974000 -7200 1 -02}
+ {982461600 -10800 0 -03}
+ {1003028400 -7200 1 -02}
+ {1013911200 -10800 0 -03}
+ {1036292400 -7200 1 -02}
+ {1045360800 -10800 0 -03}
+ {1066532400 -7200 1 -02}
+ {1076810400 -10800 0 -03}
+ {1099364400 -7200 1 -02}
+ {1108864800 -10800 0 -03}
+ {1129431600 -7200 1 -02}
+ {1140314400 -10800 0 -03}
+ {1162695600 -7200 1 -02}
+ {1172368800 -10800 0 -03}
+ {1192330800 -7200 1 -02}
+ {1203213600 -10800 0 -03}
+ {1224385200 -7200 1 -02}
+ {1234663200 -10800 0 -03}
+ {1255834800 -7200 1 -02}
+ {1266717600 -10800 0 -03}
+ {1287284400 -7200 1 -02}
+ {1298167200 -10800 0 -03}
+ {1318734000 -7200 1 -02}
+ {1330221600 -10800 0 -03}
+ {1350788400 -7200 1 -02}
+ {1361066400 -10800 0 -03}
+ {1382238000 -7200 1 -02}
+ {1392516000 -10800 0 -03}
+ {1413687600 -7200 1 -02}
+ {1424570400 -10800 0 -03}
+ {1445137200 -7200 1 -02}
+ {1456020000 -10800 0 -03}
+ {1476586800 -7200 1 -02}
+ {1487469600 -10800 0 -03}
+ {1508036400 -7200 1 -02}
+ {1518919200 -10800 0 -03}
+ {1540090800 -7200 1 -02}
+ {1550368800 -10800 0 -03}
+ {1571540400 -7200 1 -02}
+ {1581818400 -10800 0 -03}
+ {1602990000 -7200 1 -02}
+ {1613872800 -10800 0 -03}
+ {1634439600 -7200 1 -02}
+ {1645322400 -10800 0 -03}
+ {1665889200 -7200 1 -02}
+ {1677376800 -10800 0 -03}
+ {1697338800 -7200 1 -02}
+ {1708221600 -10800 0 -03}
+ {1729393200 -7200 1 -02}
+ {1739671200 -10800 0 -03}
+ {1760842800 -7200 1 -02}
+ {1771725600 -10800 0 -03}
+ {1792292400 -7200 1 -02}
+ {1803175200 -10800 0 -03}
+ {1823742000 -7200 1 -02}
+ {1834624800 -10800 0 -03}
+ {1855191600 -7200 1 -02}
+ {1866074400 -10800 0 -03}
+ {1887246000 -7200 1 -02}
+ {1897524000 -10800 0 -03}
+ {1918695600 -7200 1 -02}
+ {1928973600 -10800 0 -03}
+ {1950145200 -7200 1 -02}
+ {1960423200 -10800 0 -03}
+ {1981594800 -7200 1 -02}
+ {1992477600 -10800 0 -03}
+ {2013044400 -7200 1 -02}
+ {2024532000 -10800 0 -03}
+ {2044494000 -7200 1 -02}
+ {2055376800 -10800 0 -03}
+ {2076548400 -7200 1 -02}
+ {2086826400 -10800 0 -03}
+ {2107998000 -7200 1 -02}
+ {2118880800 -10800 0 -03}
+ {2139447600 -7200 1 -02}
+ {2150330400 -10800 0 -03}
+ {2170897200 -7200 1 -02}
+ {2181780000 -10800 0 -03}
+ {2202346800 -7200 1 -02}
+ {2213229600 -10800 0 -03}
+ {2234401200 -7200 1 -02}
+ {2244679200 -10800 0 -03}
+ {2265850800 -7200 1 -02}
+ {2276128800 -10800 0 -03}
+ {2297300400 -7200 1 -02}
+ {2307578400 -10800 0 -03}
+ {2328750000 -7200 1 -02}
+ {2339632800 -10800 0 -03}
+ {2360199600 -7200 1 -02}
+ {2371082400 -10800 0 -03}
+ {2391649200 -7200 1 -02}
+ {2402532000 -10800 0 -03}
+ {2423703600 -7200 1 -02}
+ {2433981600 -10800 0 -03}
+ {2455153200 -7200 1 -02}
+ {2465431200 -10800 0 -03}
+ {2486602800 -7200 1 -02}
+ {2497485600 -10800 0 -03}
+ {2518052400 -7200 1 -02}
+ {2528935200 -10800 0 -03}
+ {2549502000 -7200 1 -02}
+ {2560384800 -10800 0 -03}
+ {2580951600 -7200 1 -02}
+ {2591834400 -10800 0 -03}
+ {2613006000 -7200 1 -02}
+ {2623284000 -10800 0 -03}
+ {2644455600 -7200 1 -02}
+ {2654733600 -10800 0 -03}
+ {2675905200 -7200 1 -02}
+ {2686788000 -10800 0 -03}
+ {2707354800 -7200 1 -02}
+ {2718237600 -10800 0 -03}
+ {2738804400 -7200 1 -02}
+ {2749687200 -10800 0 -03}
+ {2770858800 -7200 1 -02}
+ {2781136800 -10800 0 -03}
+ {2802308400 -7200 1 -02}
+ {2812586400 -10800 0 -03}
+ {2833758000 -7200 1 -02}
+ {2844036000 -10800 0 -03}
+ {2865207600 -7200 1 -02}
+ {2876090400 -10800 0 -03}
+ {2896657200 -7200 1 -02}
+ {2907540000 -10800 0 -03}
+ {2928106800 -7200 1 -02}
+ {2938989600 -10800 0 -03}
+ {2960161200 -7200 1 -02}
+ {2970439200 -10800 0 -03}
+ {2991610800 -7200 1 -02}
+ {3001888800 -10800 0 -03}
+ {3023060400 -7200 1 -02}
+ {3033943200 -10800 0 -03}
+ {3054510000 -7200 1 -02}
+ {3065392800 -10800 0 -03}
+ {3085959600 -7200 1 -02}
+ {3096842400 -10800 0 -03}
+ {3118014000 -7200 1 -02}
+ {3128292000 -10800 0 -03}
+ {3149463600 -7200 1 -02}
+ {3159741600 -10800 0 -03}
+ {3180913200 -7200 1 -02}
+ {3191191200 -10800 0 -03}
+ {3212362800 -7200 1 -02}
+ {3223245600 -10800 0 -03}
+ {3243812400 -7200 1 -02}
+ {3254695200 -10800 0 -03}
+ {3275262000 -7200 1 -02}
+ {3286144800 -10800 0 -03}
+ {3307316400 -7200 1 -02}
+ {3317594400 -10800 0 -03}
+ {3338766000 -7200 1 -02}
+ {3349044000 -10800 0 -03}
+ {3370215600 -7200 1 -02}
+ {3381098400 -10800 0 -03}
+ {3401665200 -7200 1 -02}
+ {3412548000 -10800 0 -03}
+ {3433114800 -7200 1 -02}
+ {3443997600 -10800 0 -03}
+ {3464564400 -7200 1 -02}
+ {3475447200 -10800 0 -03}
+ {3496618800 -7200 1 -02}
+ {3506896800 -10800 0 -03}
+ {3528068400 -7200 1 -02}
+ {3538346400 -10800 0 -03}
+ {3559518000 -7200 1 -02}
+ {3570400800 -10800 0 -03}
+ {3590967600 -7200 1 -02}
+ {3601850400 -10800 0 -03}
+ {3622417200 -7200 1 -02}
+ {3633300000 -10800 0 -03}
+ {3654471600 -7200 1 -02}
+ {3664749600 -10800 0 -03}
+ {3685921200 -7200 1 -02}
+ {3696199200 -10800 0 -03}
+ {3717370800 -7200 1 -02}
+ {3727648800 -10800 0 -03}
+ {3748820400 -7200 1 -02}
+ {3759703200 -10800 0 -03}
+ {3780270000 -7200 1 -02}
+ {3791152800 -10800 0 -03}
+ {3811719600 -7200 1 -02}
+ {3822602400 -10800 0 -03}
+ {3843774000 -7200 1 -02}
+ {3854052000 -10800 0 -03}
+ {3875223600 -7200 1 -02}
+ {3885501600 -10800 0 -03}
+ {3906673200 -7200 1 -02}
+ {3917556000 -10800 0 -03}
+ {3938122800 -7200 1 -02}
+ {3949005600 -10800 0 -03}
+ {3969572400 -7200 1 -02}
+ {3980455200 -10800 0 -03}
+ {4001626800 -7200 1 -02}
+ {4011904800 -10800 0 -03}
+ {4033076400 -7200 1 -02}
+ {4043354400 -10800 0 -03}
+ {4064526000 -7200 1 -02}
+ {4074804000 -10800 0 -03}
+ {4095975600 -7200 1 -02}
}
diff --git a/library/tzdata/America/Scoresbysund b/library/tzdata/America/Scoresbysund
index 74a332c..7430635 100644
--- a/library/tzdata/America/Scoresbysund
+++ b/library/tzdata/America/Scoresbysund
@@ -2,245 +2,245 @@
set TZData(:America/Scoresbysund) {
{-9223372036854775808 -5272 0 LMT}
- {-1686090728 -7200 0 CGT}
- {323841600 -3600 0 CGST}
- {338961600 -7200 0 CGT}
- {354679200 0 0 EGST}
- {370400400 -3600 0 EGT}
- {386125200 0 1 EGST}
- {401850000 -3600 0 EGT}
- {417574800 0 1 EGST}
- {433299600 -3600 0 EGT}
- {449024400 0 1 EGST}
- {465354000 -3600 0 EGT}
- {481078800 0 1 EGST}
- {496803600 -3600 0 EGT}
- {512528400 0 1 EGST}
- {528253200 -3600 0 EGT}
- {543978000 0 1 EGST}
- {559702800 -3600 0 EGT}
- {575427600 0 1 EGST}
- {591152400 -3600 0 EGT}
- {606877200 0 1 EGST}
- {622602000 -3600 0 EGT}
- {638326800 0 1 EGST}
- {654656400 -3600 0 EGT}
- {670381200 0 1 EGST}
- {686106000 -3600 0 EGT}
- {701830800 0 1 EGST}
- {717555600 -3600 0 EGT}
- {733280400 0 1 EGST}
- {749005200 -3600 0 EGT}
- {764730000 0 1 EGST}
- {780454800 -3600 0 EGT}
- {796179600 0 1 EGST}
- {811904400 -3600 0 EGT}
- {828234000 0 1 EGST}
- {846378000 -3600 0 EGT}
- {859683600 0 1 EGST}
- {877827600 -3600 0 EGT}
- {891133200 0 1 EGST}
- {909277200 -3600 0 EGT}
- {922582800 0 1 EGST}
- {941331600 -3600 0 EGT}
- {954032400 0 1 EGST}
- {972781200 -3600 0 EGT}
- {985482000 0 1 EGST}
- {1004230800 -3600 0 EGT}
- {1017536400 0 1 EGST}
- {1035680400 -3600 0 EGT}
- {1048986000 0 1 EGST}
- {1067130000 -3600 0 EGT}
- {1080435600 0 1 EGST}
- {1099184400 -3600 0 EGT}
- {1111885200 0 1 EGST}
- {1130634000 -3600 0 EGT}
- {1143334800 0 1 EGST}
- {1162083600 -3600 0 EGT}
- {1174784400 0 1 EGST}
- {1193533200 -3600 0 EGT}
- {1206838800 0 1 EGST}
- {1224982800 -3600 0 EGT}
- {1238288400 0 1 EGST}
- {1256432400 -3600 0 EGT}
- {1269738000 0 1 EGST}
- {1288486800 -3600 0 EGT}
- {1301187600 0 1 EGST}
- {1319936400 -3600 0 EGT}
- {1332637200 0 1 EGST}
- {1351386000 -3600 0 EGT}
- {1364691600 0 1 EGST}
- {1382835600 -3600 0 EGT}
- {1396141200 0 1 EGST}
- {1414285200 -3600 0 EGT}
- {1427590800 0 1 EGST}
- {1445734800 -3600 0 EGT}
- {1459040400 0 1 EGST}
- {1477789200 -3600 0 EGT}
- {1490490000 0 1 EGST}
- {1509238800 -3600 0 EGT}
- {1521939600 0 1 EGST}
- {1540688400 -3600 0 EGT}
- {1553994000 0 1 EGST}
- {1572138000 -3600 0 EGT}
- {1585443600 0 1 EGST}
- {1603587600 -3600 0 EGT}
- {1616893200 0 1 EGST}
- {1635642000 -3600 0 EGT}
- {1648342800 0 1 EGST}
- {1667091600 -3600 0 EGT}
- {1679792400 0 1 EGST}
- {1698541200 -3600 0 EGT}
- {1711846800 0 1 EGST}
- {1729990800 -3600 0 EGT}
- {1743296400 0 1 EGST}
- {1761440400 -3600 0 EGT}
- {1774746000 0 1 EGST}
- {1792890000 -3600 0 EGT}
- {1806195600 0 1 EGST}
- {1824944400 -3600 0 EGT}
- {1837645200 0 1 EGST}
- {1856394000 -3600 0 EGT}
- {1869094800 0 1 EGST}
- {1887843600 -3600 0 EGT}
- {1901149200 0 1 EGST}
- {1919293200 -3600 0 EGT}
- {1932598800 0 1 EGST}
- {1950742800 -3600 0 EGT}
- {1964048400 0 1 EGST}
- {1982797200 -3600 0 EGT}
- {1995498000 0 1 EGST}
- {2014246800 -3600 0 EGT}
- {2026947600 0 1 EGST}
- {2045696400 -3600 0 EGT}
- {2058397200 0 1 EGST}
- {2077146000 -3600 0 EGT}
- {2090451600 0 1 EGST}
- {2108595600 -3600 0 EGT}
- {2121901200 0 1 EGST}
- {2140045200 -3600 0 EGT}
- {2153350800 0 1 EGST}
- {2172099600 -3600 0 EGT}
- {2184800400 0 1 EGST}
- {2203549200 -3600 0 EGT}
- {2216250000 0 1 EGST}
- {2234998800 -3600 0 EGT}
- {2248304400 0 1 EGST}
- {2266448400 -3600 0 EGT}
- {2279754000 0 1 EGST}
- {2297898000 -3600 0 EGT}
- {2311203600 0 1 EGST}
- {2329347600 -3600 0 EGT}
- {2342653200 0 1 EGST}
- {2361402000 -3600 0 EGT}
- {2374102800 0 1 EGST}
- {2392851600 -3600 0 EGT}
- {2405552400 0 1 EGST}
- {2424301200 -3600 0 EGT}
- {2437606800 0 1 EGST}
- {2455750800 -3600 0 EGT}
- {2469056400 0 1 EGST}
- {2487200400 -3600 0 EGT}
- {2500506000 0 1 EGST}
- {2519254800 -3600 0 EGT}
- {2531955600 0 1 EGST}
- {2550704400 -3600 0 EGT}
- {2563405200 0 1 EGST}
- {2582154000 -3600 0 EGT}
- {2595459600 0 1 EGST}
- {2613603600 -3600 0 EGT}
- {2626909200 0 1 EGST}
- {2645053200 -3600 0 EGT}
- {2658358800 0 1 EGST}
- {2676502800 -3600 0 EGT}
- {2689808400 0 1 EGST}
- {2708557200 -3600 0 EGT}
- {2721258000 0 1 EGST}
- {2740006800 -3600 0 EGT}
- {2752707600 0 1 EGST}
- {2771456400 -3600 0 EGT}
- {2784762000 0 1 EGST}
- {2802906000 -3600 0 EGT}
- {2816211600 0 1 EGST}
- {2834355600 -3600 0 EGT}
- {2847661200 0 1 EGST}
- {2866410000 -3600 0 EGT}
- {2879110800 0 1 EGST}
- {2897859600 -3600 0 EGT}
- {2910560400 0 1 EGST}
- {2929309200 -3600 0 EGT}
- {2942010000 0 1 EGST}
- {2960758800 -3600 0 EGT}
- {2974064400 0 1 EGST}
- {2992208400 -3600 0 EGT}
- {3005514000 0 1 EGST}
- {3023658000 -3600 0 EGT}
- {3036963600 0 1 EGST}
- {3055712400 -3600 0 EGT}
- {3068413200 0 1 EGST}
- {3087162000 -3600 0 EGT}
- {3099862800 0 1 EGST}
- {3118611600 -3600 0 EGT}
- {3131917200 0 1 EGST}
- {3150061200 -3600 0 EGT}
- {3163366800 0 1 EGST}
- {3181510800 -3600 0 EGT}
- {3194816400 0 1 EGST}
- {3212960400 -3600 0 EGT}
- {3226266000 0 1 EGST}
- {3245014800 -3600 0 EGT}
- {3257715600 0 1 EGST}
- {3276464400 -3600 0 EGT}
- {3289165200 0 1 EGST}
- {3307914000 -3600 0 EGT}
- {3321219600 0 1 EGST}
- {3339363600 -3600 0 EGT}
- {3352669200 0 1 EGST}
- {3370813200 -3600 0 EGT}
- {3384118800 0 1 EGST}
- {3402867600 -3600 0 EGT}
- {3415568400 0 1 EGST}
- {3434317200 -3600 0 EGT}
- {3447018000 0 1 EGST}
- {3465766800 -3600 0 EGT}
- {3479072400 0 1 EGST}
- {3497216400 -3600 0 EGT}
- {3510522000 0 1 EGST}
- {3528666000 -3600 0 EGT}
- {3541971600 0 1 EGST}
- {3560115600 -3600 0 EGT}
- {3573421200 0 1 EGST}
- {3592170000 -3600 0 EGT}
- {3604870800 0 1 EGST}
- {3623619600 -3600 0 EGT}
- {3636320400 0 1 EGST}
- {3655069200 -3600 0 EGT}
- {3668374800 0 1 EGST}
- {3686518800 -3600 0 EGT}
- {3699824400 0 1 EGST}
- {3717968400 -3600 0 EGT}
- {3731274000 0 1 EGST}
- {3750022800 -3600 0 EGT}
- {3762723600 0 1 EGST}
- {3781472400 -3600 0 EGT}
- {3794173200 0 1 EGST}
- {3812922000 -3600 0 EGT}
- {3825622800 0 1 EGST}
- {3844371600 -3600 0 EGT}
- {3857677200 0 1 EGST}
- {3875821200 -3600 0 EGT}
- {3889126800 0 1 EGST}
- {3907270800 -3600 0 EGT}
- {3920576400 0 1 EGST}
- {3939325200 -3600 0 EGT}
- {3952026000 0 1 EGST}
- {3970774800 -3600 0 EGT}
- {3983475600 0 1 EGST}
- {4002224400 -3600 0 EGT}
- {4015530000 0 1 EGST}
- {4033674000 -3600 0 EGT}
- {4046979600 0 1 EGST}
- {4065123600 -3600 0 EGT}
- {4078429200 0 1 EGST}
- {4096573200 -3600 0 EGT}
+ {-1686090728 -7200 0 -02}
+ {323841600 -3600 0 -01}
+ {338961600 -7200 0 -02}
+ {354679200 0 0 +00}
+ {370400400 -3600 0 -01}
+ {386125200 0 1 +00}
+ {401850000 -3600 0 -01}
+ {417574800 0 1 +00}
+ {433299600 -3600 0 -01}
+ {449024400 0 1 +00}
+ {465354000 -3600 0 -01}
+ {481078800 0 1 +00}
+ {496803600 -3600 0 -01}
+ {512528400 0 1 +00}
+ {528253200 -3600 0 -01}
+ {543978000 0 1 +00}
+ {559702800 -3600 0 -01}
+ {575427600 0 1 +00}
+ {591152400 -3600 0 -01}
+ {606877200 0 1 +00}
+ {622602000 -3600 0 -01}
+ {638326800 0 1 +00}
+ {654656400 -3600 0 -01}
+ {670381200 0 1 +00}
+ {686106000 -3600 0 -01}
+ {701830800 0 1 +00}
+ {717555600 -3600 0 -01}
+ {733280400 0 1 +00}
+ {749005200 -3600 0 -01}
+ {764730000 0 1 +00}
+ {780454800 -3600 0 -01}
+ {796179600 0 1 +00}
+ {811904400 -3600 0 -01}
+ {828234000 0 1 +00}
+ {846378000 -3600 0 -01}
+ {859683600 0 1 +00}
+ {877827600 -3600 0 -01}
+ {891133200 0 1 +00}
+ {909277200 -3600 0 -01}
+ {922582800 0 1 +00}
+ {941331600 -3600 0 -01}
+ {954032400 0 1 +00}
+ {972781200 -3600 0 -01}
+ {985482000 0 1 +00}
+ {1004230800 -3600 0 -01}
+ {1017536400 0 1 +00}
+ {1035680400 -3600 0 -01}
+ {1048986000 0 1 +00}
+ {1067130000 -3600 0 -01}
+ {1080435600 0 1 +00}
+ {1099184400 -3600 0 -01}
+ {1111885200 0 1 +00}
+ {1130634000 -3600 0 -01}
+ {1143334800 0 1 +00}
+ {1162083600 -3600 0 -01}
+ {1174784400 0 1 +00}
+ {1193533200 -3600 0 -01}
+ {1206838800 0 1 +00}
+ {1224982800 -3600 0 -01}
+ {1238288400 0 1 +00}
+ {1256432400 -3600 0 -01}
+ {1269738000 0 1 +00}
+ {1288486800 -3600 0 -01}
+ {1301187600 0 1 +00}
+ {1319936400 -3600 0 -01}
+ {1332637200 0 1 +00}
+ {1351386000 -3600 0 -01}
+ {1364691600 0 1 +00}
+ {1382835600 -3600 0 -01}
+ {1396141200 0 1 +00}
+ {1414285200 -3600 0 -01}
+ {1427590800 0 1 +00}
+ {1445734800 -3600 0 -01}
+ {1459040400 0 1 +00}
+ {1477789200 -3600 0 -01}
+ {1490490000 0 1 +00}
+ {1509238800 -3600 0 -01}
+ {1521939600 0 1 +00}
+ {1540688400 -3600 0 -01}
+ {1553994000 0 1 +00}
+ {1572138000 -3600 0 -01}
+ {1585443600 0 1 +00}
+ {1603587600 -3600 0 -01}
+ {1616893200 0 1 +00}
+ {1635642000 -3600 0 -01}
+ {1648342800 0 1 +00}
+ {1667091600 -3600 0 -01}
+ {1679792400 0 1 +00}
+ {1698541200 -3600 0 -01}
+ {1711846800 0 1 +00}
+ {1729990800 -3600 0 -01}
+ {1743296400 0 1 +00}
+ {1761440400 -3600 0 -01}
+ {1774746000 0 1 +00}
+ {1792890000 -3600 0 -01}
+ {1806195600 0 1 +00}
+ {1824944400 -3600 0 -01}
+ {1837645200 0 1 +00}
+ {1856394000 -3600 0 -01}
+ {1869094800 0 1 +00}
+ {1887843600 -3600 0 -01}
+ {1901149200 0 1 +00}
+ {1919293200 -3600 0 -01}
+ {1932598800 0 1 +00}
+ {1950742800 -3600 0 -01}
+ {1964048400 0 1 +00}
+ {1982797200 -3600 0 -01}
+ {1995498000 0 1 +00}
+ {2014246800 -3600 0 -01}
+ {2026947600 0 1 +00}
+ {2045696400 -3600 0 -01}
+ {2058397200 0 1 +00}
+ {2077146000 -3600 0 -01}
+ {2090451600 0 1 +00}
+ {2108595600 -3600 0 -01}
+ {2121901200 0 1 +00}
+ {2140045200 -3600 0 -01}
+ {2153350800 0 1 +00}
+ {2172099600 -3600 0 -01}
+ {2184800400 0 1 +00}
+ {2203549200 -3600 0 -01}
+ {2216250000 0 1 +00}
+ {2234998800 -3600 0 -01}
+ {2248304400 0 1 +00}
+ {2266448400 -3600 0 -01}
+ {2279754000 0 1 +00}
+ {2297898000 -3600 0 -01}
+ {2311203600 0 1 +00}
+ {2329347600 -3600 0 -01}
+ {2342653200 0 1 +00}
+ {2361402000 -3600 0 -01}
+ {2374102800 0 1 +00}
+ {2392851600 -3600 0 -01}
+ {2405552400 0 1 +00}
+ {2424301200 -3600 0 -01}
+ {2437606800 0 1 +00}
+ {2455750800 -3600 0 -01}
+ {2469056400 0 1 +00}
+ {2487200400 -3600 0 -01}
+ {2500506000 0 1 +00}
+ {2519254800 -3600 0 -01}
+ {2531955600 0 1 +00}
+ {2550704400 -3600 0 -01}
+ {2563405200 0 1 +00}
+ {2582154000 -3600 0 -01}
+ {2595459600 0 1 +00}
+ {2613603600 -3600 0 -01}
+ {2626909200 0 1 +00}
+ {2645053200 -3600 0 -01}
+ {2658358800 0 1 +00}
+ {2676502800 -3600 0 -01}
+ {2689808400 0 1 +00}
+ {2708557200 -3600 0 -01}
+ {2721258000 0 1 +00}
+ {2740006800 -3600 0 -01}
+ {2752707600 0 1 +00}
+ {2771456400 -3600 0 -01}
+ {2784762000 0 1 +00}
+ {2802906000 -3600 0 -01}
+ {2816211600 0 1 +00}
+ {2834355600 -3600 0 -01}
+ {2847661200 0 1 +00}
+ {2866410000 -3600 0 -01}
+ {2879110800 0 1 +00}
+ {2897859600 -3600 0 -01}
+ {2910560400 0 1 +00}
+ {2929309200 -3600 0 -01}
+ {2942010000 0 1 +00}
+ {2960758800 -3600 0 -01}
+ {2974064400 0 1 +00}
+ {2992208400 -3600 0 -01}
+ {3005514000 0 1 +00}
+ {3023658000 -3600 0 -01}
+ {3036963600 0 1 +00}
+ {3055712400 -3600 0 -01}
+ {3068413200 0 1 +00}
+ {3087162000 -3600 0 -01}
+ {3099862800 0 1 +00}
+ {3118611600 -3600 0 -01}
+ {3131917200 0 1 +00}
+ {3150061200 -3600 0 -01}
+ {3163366800 0 1 +00}
+ {3181510800 -3600 0 -01}
+ {3194816400 0 1 +00}
+ {3212960400 -3600 0 -01}
+ {3226266000 0 1 +00}
+ {3245014800 -3600 0 -01}
+ {3257715600 0 1 +00}
+ {3276464400 -3600 0 -01}
+ {3289165200 0 1 +00}
+ {3307914000 -3600 0 -01}
+ {3321219600 0 1 +00}
+ {3339363600 -3600 0 -01}
+ {3352669200 0 1 +00}
+ {3370813200 -3600 0 -01}
+ {3384118800 0 1 +00}
+ {3402867600 -3600 0 -01}
+ {3415568400 0 1 +00}
+ {3434317200 -3600 0 -01}
+ {3447018000 0 1 +00}
+ {3465766800 -3600 0 -01}
+ {3479072400 0 1 +00}
+ {3497216400 -3600 0 -01}
+ {3510522000 0 1 +00}
+ {3528666000 -3600 0 -01}
+ {3541971600 0 1 +00}
+ {3560115600 -3600 0 -01}
+ {3573421200 0 1 +00}
+ {3592170000 -3600 0 -01}
+ {3604870800 0 1 +00}
+ {3623619600 -3600 0 -01}
+ {3636320400 0 1 +00}
+ {3655069200 -3600 0 -01}
+ {3668374800 0 1 +00}
+ {3686518800 -3600 0 -01}
+ {3699824400 0 1 +00}
+ {3717968400 -3600 0 -01}
+ {3731274000 0 1 +00}
+ {3750022800 -3600 0 -01}
+ {3762723600 0 1 +00}
+ {3781472400 -3600 0 -01}
+ {3794173200 0 1 +00}
+ {3812922000 -3600 0 -01}
+ {3825622800 0 1 +00}
+ {3844371600 -3600 0 -01}
+ {3857677200 0 1 +00}
+ {3875821200 -3600 0 -01}
+ {3889126800 0 1 +00}
+ {3907270800 -3600 0 -01}
+ {3920576400 0 1 +00}
+ {3939325200 -3600 0 -01}
+ {3952026000 0 1 +00}
+ {3970774800 -3600 0 -01}
+ {3983475600 0 1 +00}
+ {4002224400 -3600 0 -01}
+ {4015530000 0 1 +00}
+ {4033674000 -3600 0 -01}
+ {4046979600 0 1 +00}
+ {4065123600 -3600 0 -01}
+ {4078429200 0 1 +00}
+ {4096573200 -3600 0 -01}
}
diff --git a/library/tzdata/America/Tijuana b/library/tzdata/America/Tijuana
index 6118cde..4b7ebe7 100644
--- a/library/tzdata/America/Tijuana
+++ b/library/tzdata/America/Tijuana
@@ -14,19 +14,19 @@ set TZData(:America/Tijuana) {
{-686073600 -25200 1 PDT}
{-661539600 -28800 0 PST}
{-504892800 -28800 0 PST}
- {-495036000 -25200 1 PDT}
+ {-495039600 -25200 1 PDT}
{-481734000 -28800 0 PST}
- {-463586400 -25200 1 PDT}
+ {-463590000 -25200 1 PDT}
{-450284400 -28800 0 PST}
- {-431532000 -25200 1 PDT}
+ {-431535600 -25200 1 PDT}
{-418230000 -28800 0 PST}
- {-400082400 -25200 1 PDT}
+ {-400086000 -25200 1 PDT}
{-386780400 -28800 0 PST}
- {-368632800 -25200 1 PDT}
+ {-368636400 -25200 1 PDT}
{-355330800 -28800 0 PST}
- {-337183200 -25200 1 PDT}
+ {-337186800 -25200 1 PDT}
{-323881200 -28800 0 PST}
- {-305733600 -25200 1 PDT}
+ {-305737200 -25200 1 PDT}
{-292431600 -28800 0 PST}
{-283968000 -28800 0 PST}
{189331200 -28800 0 PST}
diff --git a/library/tzdata/Antarctica/Casey b/library/tzdata/Antarctica/Casey
index 2573dac..beb0f9e 100644
--- a/library/tzdata/Antarctica/Casey
+++ b/library/tzdata/Antarctica/Casey
@@ -2,9 +2,10 @@
set TZData(:Antarctica/Casey) {
{-9223372036854775808 0 0 -00}
- {-31536000 28800 0 AWST}
- {1255802400 39600 0 CAST}
- {1267714800 28800 0 AWST}
- {1319738400 39600 0 CAST}
- {1329843600 28800 0 AWST}
+ {-31536000 28800 0 +08}
+ {1255802400 39600 0 +11}
+ {1267714800 28800 0 +08}
+ {1319738400 39600 0 +11}
+ {1329843600 28800 0 +08}
+ {1477065600 39600 0 +11}
}
diff --git a/library/tzdata/Antarctica/Davis b/library/tzdata/Antarctica/Davis
index c98be2f..9bb178b 100644
--- a/library/tzdata/Antarctica/Davis
+++ b/library/tzdata/Antarctica/Davis
@@ -2,11 +2,11 @@
set TZData(:Antarctica/Davis) {
{-9223372036854775808 0 0 -00}
- {-409190400 25200 0 DAVT}
+ {-409190400 25200 0 +07}
{-163062000 0 0 -00}
- {-28857600 25200 0 DAVT}
- {1255806000 18000 0 DAVT}
- {1268251200 25200 0 DAVT}
- {1319742000 18000 0 DAVT}
- {1329854400 25200 0 DAVT}
+ {-28857600 25200 0 +07}
+ {1255806000 18000 0 +05}
+ {1268251200 25200 0 +07}
+ {1319742000 18000 0 +05}
+ {1329854400 25200 0 +07}
}
diff --git a/library/tzdata/Antarctica/DumontDUrville b/library/tzdata/Antarctica/DumontDUrville
index 8d21d45..f734aed 100644
--- a/library/tzdata/Antarctica/DumontDUrville
+++ b/library/tzdata/Antarctica/DumontDUrville
@@ -2,7 +2,7 @@
set TZData(:Antarctica/DumontDUrville) {
{-9223372036854775808 0 0 -00}
- {-725846400 36000 0 PMT}
+ {-725846400 36000 0 +10}
{-566992800 0 0 -00}
- {-415497600 36000 0 DDUT}
+ {-415497600 36000 0 +10}
}
diff --git a/library/tzdata/Antarctica/Macquarie b/library/tzdata/Antarctica/Macquarie
index 9ed0630..60bf7a6 100644
--- a/library/tzdata/Antarctica/Macquarie
+++ b/library/tzdata/Antarctica/Macquarie
@@ -93,5 +93,5 @@ set TZData(:Antarctica/Macquarie) {
{1223136000 39600 1 AEDT}
{1238860800 36000 0 AEST}
{1254585600 39600 1 AEDT}
- {1270310400 39600 0 MIST}
+ {1270310400 39600 0 +11}
}
diff --git a/library/tzdata/Antarctica/Mawson b/library/tzdata/Antarctica/Mawson
index e50aa07..4828b1a 100644
--- a/library/tzdata/Antarctica/Mawson
+++ b/library/tzdata/Antarctica/Mawson
@@ -2,6 +2,6 @@
set TZData(:Antarctica/Mawson) {
{-9223372036854775808 0 0 -00}
- {-501206400 21600 0 MAWT}
- {1255809600 18000 0 MAWT}
+ {-501206400 21600 0 +06}
+ {1255809600 18000 0 +05}
}
diff --git a/library/tzdata/Antarctica/Palmer b/library/tzdata/Antarctica/Palmer
index 62b17e1..bb2be4d 100644
--- a/library/tzdata/Antarctica/Palmer
+++ b/library/tzdata/Antarctica/Palmer
@@ -2,251 +2,86 @@
set TZData(:Antarctica/Palmer) {
{-9223372036854775808 0 0 -00}
- {-157766400 -14400 0 ART}
- {-152654400 -14400 0 ART}
- {-132955200 -10800 1 ARST}
- {-121122000 -14400 0 ART}
- {-101419200 -10800 1 ARST}
- {-86821200 -14400 0 ART}
- {-71092800 -10800 1 ARST}
- {-54766800 -14400 0 ART}
- {-39038400 -10800 1 ARST}
- {-23317200 -14400 0 ART}
- {-7588800 -10800 0 ART}
- {128142000 -7200 1 ARST}
- {136605600 -10800 0 ART}
- {389070000 -14400 0 CLT}
- {403070400 -10800 1 CLST}
- {416372400 -14400 0 CLT}
- {434520000 -10800 1 CLST}
- {447822000 -14400 0 CLT}
- {466574400 -10800 1 CLST}
- {479271600 -14400 0 CLT}
- {498024000 -10800 1 CLST}
- {510721200 -14400 0 CLT}
- {529473600 -10800 1 CLST}
- {545194800 -14400 0 CLT}
- {560923200 -10800 1 CLST}
- {574225200 -14400 0 CLT}
- {592372800 -10800 1 CLST}
- {605674800 -14400 0 CLT}
- {624427200 -10800 1 CLST}
- {637124400 -14400 0 CLT}
- {653457600 -10800 1 CLST}
- {668574000 -14400 0 CLT}
- {687326400 -10800 1 CLST}
- {700628400 -14400 0 CLT}
- {718776000 -10800 1 CLST}
- {732078000 -14400 0 CLT}
- {750225600 -10800 1 CLST}
- {763527600 -14400 0 CLT}
- {781675200 -10800 1 CLST}
- {794977200 -14400 0 CLT}
- {813729600 -10800 1 CLST}
- {826426800 -14400 0 CLT}
- {845179200 -10800 1 CLST}
- {859690800 -14400 0 CLT}
- {876628800 -10800 1 CLST}
- {889930800 -14400 0 CLT}
- {906868800 -10800 1 CLST}
- {923194800 -14400 0 CLT}
- {939528000 -10800 1 CLST}
- {952830000 -14400 0 CLT}
- {971582400 -10800 1 CLST}
- {984279600 -14400 0 CLT}
- {1003032000 -10800 1 CLST}
- {1015729200 -14400 0 CLT}
- {1034481600 -10800 1 CLST}
- {1047178800 -14400 0 CLT}
- {1065931200 -10800 1 CLST}
- {1079233200 -14400 0 CLT}
- {1097380800 -10800 1 CLST}
- {1110682800 -14400 0 CLT}
- {1128830400 -10800 1 CLST}
- {1142132400 -14400 0 CLT}
- {1160884800 -10800 1 CLST}
- {1173582000 -14400 0 CLT}
- {1192334400 -10800 1 CLST}
- {1206846000 -14400 0 CLT}
- {1223784000 -10800 1 CLST}
- {1237086000 -14400 0 CLT}
- {1255233600 -10800 1 CLST}
- {1270350000 -14400 0 CLT}
- {1286683200 -10800 1 CLST}
- {1304823600 -14400 0 CLT}
- {1313899200 -10800 1 CLST}
- {1335668400 -14400 0 CLT}
- {1346558400 -10800 1 CLST}
- {1367118000 -14400 0 CLT}
- {1378612800 -10800 1 CLST}
- {1398567600 -14400 0 CLT}
- {1410062400 -10800 1 CLST}
- {1463281200 -14400 0 CLT}
- {1471147200 -10800 1 CLST}
- {1494730800 -14400 0 CLT}
- {1502596800 -10800 1 CLST}
- {1526180400 -14400 0 CLT}
- {1534046400 -10800 1 CLST}
- {1557630000 -14400 0 CLT}
- {1565496000 -10800 1 CLST}
- {1589079600 -14400 0 CLT}
- {1596945600 -10800 1 CLST}
- {1620529200 -14400 0 CLT}
- {1629000000 -10800 1 CLST}
- {1652583600 -14400 0 CLT}
- {1660449600 -10800 1 CLST}
- {1684033200 -14400 0 CLT}
- {1691899200 -10800 1 CLST}
- {1715482800 -14400 0 CLT}
- {1723348800 -10800 1 CLST}
- {1746932400 -14400 0 CLT}
- {1754798400 -10800 1 CLST}
- {1778382000 -14400 0 CLT}
- {1786248000 -10800 1 CLST}
- {1809831600 -14400 0 CLT}
- {1818302400 -10800 1 CLST}
- {1841886000 -14400 0 CLT}
- {1849752000 -10800 1 CLST}
- {1873335600 -14400 0 CLT}
- {1881201600 -10800 1 CLST}
- {1904785200 -14400 0 CLT}
- {1912651200 -10800 1 CLST}
- {1936234800 -14400 0 CLT}
- {1944100800 -10800 1 CLST}
- {1967684400 -14400 0 CLT}
- {1976155200 -10800 1 CLST}
- {1999738800 -14400 0 CLT}
- {2007604800 -10800 1 CLST}
- {2031188400 -14400 0 CLT}
- {2039054400 -10800 1 CLST}
- {2062638000 -14400 0 CLT}
- {2070504000 -10800 1 CLST}
- {2094087600 -14400 0 CLT}
- {2101953600 -10800 1 CLST}
- {2125537200 -14400 0 CLT}
- {2133403200 -10800 1 CLST}
- {2156986800 -14400 0 CLT}
- {2165457600 -10800 1 CLST}
- {2189041200 -14400 0 CLT}
- {2196907200 -10800 1 CLST}
- {2220490800 -14400 0 CLT}
- {2228356800 -10800 1 CLST}
- {2251940400 -14400 0 CLT}
- {2259806400 -10800 1 CLST}
- {2283390000 -14400 0 CLT}
- {2291256000 -10800 1 CLST}
- {2314839600 -14400 0 CLT}
- {2322705600 -10800 1 CLST}
- {2346894000 -14400 0 CLT}
- {2354760000 -10800 1 CLST}
- {2378343600 -14400 0 CLT}
- {2386209600 -10800 1 CLST}
- {2409793200 -14400 0 CLT}
- {2417659200 -10800 1 CLST}
- {2441242800 -14400 0 CLT}
- {2449108800 -10800 1 CLST}
- {2472692400 -14400 0 CLT}
- {2480558400 -10800 1 CLST}
- {2504142000 -14400 0 CLT}
- {2512612800 -10800 1 CLST}
- {2536196400 -14400 0 CLT}
- {2544062400 -10800 1 CLST}
- {2567646000 -14400 0 CLT}
- {2575512000 -10800 1 CLST}
- {2599095600 -14400 0 CLT}
- {2606961600 -10800 1 CLST}
- {2630545200 -14400 0 CLT}
- {2638411200 -10800 1 CLST}
- {2661994800 -14400 0 CLT}
- {2669860800 -10800 1 CLST}
- {2693444400 -14400 0 CLT}
- {2701915200 -10800 1 CLST}
- {2725498800 -14400 0 CLT}
- {2733364800 -10800 1 CLST}
- {2756948400 -14400 0 CLT}
- {2764814400 -10800 1 CLST}
- {2788398000 -14400 0 CLT}
- {2796264000 -10800 1 CLST}
- {2819847600 -14400 0 CLT}
- {2827713600 -10800 1 CLST}
- {2851297200 -14400 0 CLT}
- {2859768000 -10800 1 CLST}
- {2883351600 -14400 0 CLT}
- {2891217600 -10800 1 CLST}
- {2914801200 -14400 0 CLT}
- {2922667200 -10800 1 CLST}
- {2946250800 -14400 0 CLT}
- {2954116800 -10800 1 CLST}
- {2977700400 -14400 0 CLT}
- {2985566400 -10800 1 CLST}
- {3009150000 -14400 0 CLT}
- {3017016000 -10800 1 CLST}
- {3040599600 -14400 0 CLT}
- {3049070400 -10800 1 CLST}
- {3072654000 -14400 0 CLT}
- {3080520000 -10800 1 CLST}
- {3104103600 -14400 0 CLT}
- {3111969600 -10800 1 CLST}
- {3135553200 -14400 0 CLT}
- {3143419200 -10800 1 CLST}
- {3167002800 -14400 0 CLT}
- {3174868800 -10800 1 CLST}
- {3198452400 -14400 0 CLT}
- {3206318400 -10800 1 CLST}
- {3230506800 -14400 0 CLT}
- {3238372800 -10800 1 CLST}
- {3261956400 -14400 0 CLT}
- {3269822400 -10800 1 CLST}
- {3293406000 -14400 0 CLT}
- {3301272000 -10800 1 CLST}
- {3324855600 -14400 0 CLT}
- {3332721600 -10800 1 CLST}
- {3356305200 -14400 0 CLT}
- {3364171200 -10800 1 CLST}
- {3387754800 -14400 0 CLT}
- {3396225600 -10800 1 CLST}
- {3419809200 -14400 0 CLT}
- {3427675200 -10800 1 CLST}
- {3451258800 -14400 0 CLT}
- {3459124800 -10800 1 CLST}
- {3482708400 -14400 0 CLT}
- {3490574400 -10800 1 CLST}
- {3514158000 -14400 0 CLT}
- {3522024000 -10800 1 CLST}
- {3545607600 -14400 0 CLT}
- {3553473600 -10800 1 CLST}
- {3577057200 -14400 0 CLT}
- {3585528000 -10800 1 CLST}
- {3609111600 -14400 0 CLT}
- {3616977600 -10800 1 CLST}
- {3640561200 -14400 0 CLT}
- {3648427200 -10800 1 CLST}
- {3672010800 -14400 0 CLT}
- {3679876800 -10800 1 CLST}
- {3703460400 -14400 0 CLT}
- {3711326400 -10800 1 CLST}
- {3734910000 -14400 0 CLT}
- {3743380800 -10800 1 CLST}
- {3766964400 -14400 0 CLT}
- {3774830400 -10800 1 CLST}
- {3798414000 -14400 0 CLT}
- {3806280000 -10800 1 CLST}
- {3829863600 -14400 0 CLT}
- {3837729600 -10800 1 CLST}
- {3861313200 -14400 0 CLT}
- {3869179200 -10800 1 CLST}
- {3892762800 -14400 0 CLT}
- {3900628800 -10800 1 CLST}
- {3924212400 -14400 0 CLT}
- {3932683200 -10800 1 CLST}
- {3956266800 -14400 0 CLT}
- {3964132800 -10800 1 CLST}
- {3987716400 -14400 0 CLT}
- {3995582400 -10800 1 CLST}
- {4019166000 -14400 0 CLT}
- {4027032000 -10800 1 CLST}
- {4050615600 -14400 0 CLT}
- {4058481600 -10800 1 CLST}
- {4082065200 -14400 0 CLT}
- {4089931200 -10800 1 CLST}
+ {-157766400 -14400 0 -04}
+ {-152654400 -14400 0 -04}
+ {-132955200 -10800 1 -03}
+ {-121122000 -14400 0 -04}
+ {-101419200 -10800 1 -03}
+ {-86821200 -14400 0 -04}
+ {-71092800 -10800 1 -03}
+ {-54766800 -14400 0 -04}
+ {-39038400 -10800 1 -03}
+ {-23317200 -14400 0 -04}
+ {-7588800 -10800 0 -03}
+ {128142000 -7200 1 -02}
+ {136605600 -10800 0 -03}
+ {389070000 -14400 0 -04}
+ {403070400 -10800 1 -03}
+ {416372400 -14400 0 -04}
+ {434520000 -10800 1 -03}
+ {447822000 -14400 0 -04}
+ {466574400 -10800 1 -03}
+ {479271600 -14400 0 -04}
+ {498024000 -10800 1 -03}
+ {510721200 -14400 0 -04}
+ {529473600 -10800 1 -03}
+ {545194800 -14400 0 -04}
+ {560923200 -10800 1 -03}
+ {574225200 -14400 0 -04}
+ {592372800 -10800 1 -03}
+ {605674800 -14400 0 -04}
+ {624427200 -10800 1 -03}
+ {637124400 -14400 0 -04}
+ {653457600 -10800 1 -03}
+ {668574000 -14400 0 -04}
+ {687326400 -10800 1 -03}
+ {700628400 -14400 0 -04}
+ {718776000 -10800 1 -03}
+ {732078000 -14400 0 -04}
+ {750225600 -10800 1 -03}
+ {763527600 -14400 0 -04}
+ {781675200 -10800 1 -03}
+ {794977200 -14400 0 -04}
+ {813729600 -10800 1 -03}
+ {826426800 -14400 0 -04}
+ {845179200 -10800 1 -03}
+ {859690800 -14400 0 -04}
+ {876628800 -10800 1 -03}
+ {889930800 -14400 0 -04}
+ {906868800 -10800 1 -03}
+ {923194800 -14400 0 -04}
+ {939528000 -10800 1 -03}
+ {952830000 -14400 0 -04}
+ {971582400 -10800 1 -03}
+ {984279600 -14400 0 -04}
+ {1003032000 -10800 1 -03}
+ {1015729200 -14400 0 -04}
+ {1034481600 -10800 1 -03}
+ {1047178800 -14400 0 -04}
+ {1065931200 -10800 1 -03}
+ {1079233200 -14400 0 -04}
+ {1097380800 -10800 1 -03}
+ {1110682800 -14400 0 -04}
+ {1128830400 -10800 1 -03}
+ {1142132400 -14400 0 -04}
+ {1160884800 -10800 1 -03}
+ {1173582000 -14400 0 -04}
+ {1192334400 -10800 1 -03}
+ {1206846000 -14400 0 -04}
+ {1223784000 -10800 1 -03}
+ {1237086000 -14400 0 -04}
+ {1255233600 -10800 1 -03}
+ {1270350000 -14400 0 -04}
+ {1286683200 -10800 1 -03}
+ {1304823600 -14400 0 -04}
+ {1313899200 -10800 1 -03}
+ {1335668400 -14400 0 -04}
+ {1346558400 -10800 1 -03}
+ {1367118000 -14400 0 -04}
+ {1378612800 -10800 1 -03}
+ {1398567600 -14400 0 -04}
+ {1410062400 -10800 1 -03}
+ {1463281200 -14400 0 -04}
+ {1471147200 -10800 1 -03}
+ {1480820400 -10800 0 -03}
}
diff --git a/library/tzdata/Antarctica/Rothera b/library/tzdata/Antarctica/Rothera
index 3a219c7..7f0134f 100644
--- a/library/tzdata/Antarctica/Rothera
+++ b/library/tzdata/Antarctica/Rothera
@@ -2,5 +2,5 @@
set TZData(:Antarctica/Rothera) {
{-9223372036854775808 0 0 -00}
- {218246400 -10800 0 ROTT}
+ {218246400 -10800 0 -03}
}
diff --git a/library/tzdata/Antarctica/Syowa b/library/tzdata/Antarctica/Syowa
index 1fe030a..a44dd5c 100644
--- a/library/tzdata/Antarctica/Syowa
+++ b/library/tzdata/Antarctica/Syowa
@@ -2,5 +2,5 @@
set TZData(:Antarctica/Syowa) {
{-9223372036854775808 0 0 -00}
- {-407808000 10800 0 SYOT}
+ {-407808000 10800 0 +03}
}
diff --git a/library/tzdata/Antarctica/Troll b/library/tzdata/Antarctica/Troll
index 09727a8..fe44578 100644
--- a/library/tzdata/Antarctica/Troll
+++ b/library/tzdata/Antarctica/Troll
@@ -2,195 +2,195 @@
set TZData(:Antarctica/Troll) {
{-9223372036854775808 0 0 -00}
- {1108166400 0 0 UTC}
- {1111885200 7200 1 CEST}
- {1130634000 0 0 UTC}
- {1143334800 7200 1 CEST}
- {1162083600 0 0 UTC}
- {1174784400 7200 1 CEST}
- {1193533200 0 0 UTC}
- {1206838800 7200 1 CEST}
- {1224982800 0 0 UTC}
- {1238288400 7200 1 CEST}
- {1256432400 0 0 UTC}
- {1269738000 7200 1 CEST}
- {1288486800 0 0 UTC}
- {1301187600 7200 1 CEST}
- {1319936400 0 0 UTC}
- {1332637200 7200 1 CEST}
- {1351386000 0 0 UTC}
- {1364691600 7200 1 CEST}
- {1382835600 0 0 UTC}
- {1396141200 7200 1 CEST}
- {1414285200 0 0 UTC}
- {1427590800 7200 1 CEST}
- {1445734800 0 0 UTC}
- {1459040400 7200 1 CEST}
- {1477789200 0 0 UTC}
- {1490490000 7200 1 CEST}
- {1509238800 0 0 UTC}
- {1521939600 7200 1 CEST}
- {1540688400 0 0 UTC}
- {1553994000 7200 1 CEST}
- {1572138000 0 0 UTC}
- {1585443600 7200 1 CEST}
- {1603587600 0 0 UTC}
- {1616893200 7200 1 CEST}
- {1635642000 0 0 UTC}
- {1648342800 7200 1 CEST}
- {1667091600 0 0 UTC}
- {1679792400 7200 1 CEST}
- {1698541200 0 0 UTC}
- {1711846800 7200 1 CEST}
- {1729990800 0 0 UTC}
- {1743296400 7200 1 CEST}
- {1761440400 0 0 UTC}
- {1774746000 7200 1 CEST}
- {1792890000 0 0 UTC}
- {1806195600 7200 1 CEST}
- {1824944400 0 0 UTC}
- {1837645200 7200 1 CEST}
- {1856394000 0 0 UTC}
- {1869094800 7200 1 CEST}
- {1887843600 0 0 UTC}
- {1901149200 7200 1 CEST}
- {1919293200 0 0 UTC}
- {1932598800 7200 1 CEST}
- {1950742800 0 0 UTC}
- {1964048400 7200 1 CEST}
- {1982797200 0 0 UTC}
- {1995498000 7200 1 CEST}
- {2014246800 0 0 UTC}
- {2026947600 7200 1 CEST}
- {2045696400 0 0 UTC}
- {2058397200 7200 1 CEST}
- {2077146000 0 0 UTC}
- {2090451600 7200 1 CEST}
- {2108595600 0 0 UTC}
- {2121901200 7200 1 CEST}
- {2140045200 0 0 UTC}
- {2153350800 7200 1 CEST}
- {2172099600 0 0 UTC}
- {2184800400 7200 1 CEST}
- {2203549200 0 0 UTC}
- {2216250000 7200 1 CEST}
- {2234998800 0 0 UTC}
- {2248304400 7200 1 CEST}
- {2266448400 0 0 UTC}
- {2279754000 7200 1 CEST}
- {2297898000 0 0 UTC}
- {2311203600 7200 1 CEST}
- {2329347600 0 0 UTC}
- {2342653200 7200 1 CEST}
- {2361402000 0 0 UTC}
- {2374102800 7200 1 CEST}
- {2392851600 0 0 UTC}
- {2405552400 7200 1 CEST}
- {2424301200 0 0 UTC}
- {2437606800 7200 1 CEST}
- {2455750800 0 0 UTC}
- {2469056400 7200 1 CEST}
- {2487200400 0 0 UTC}
- {2500506000 7200 1 CEST}
- {2519254800 0 0 UTC}
- {2531955600 7200 1 CEST}
- {2550704400 0 0 UTC}
- {2563405200 7200 1 CEST}
- {2582154000 0 0 UTC}
- {2595459600 7200 1 CEST}
- {2613603600 0 0 UTC}
- {2626909200 7200 1 CEST}
- {2645053200 0 0 UTC}
- {2658358800 7200 1 CEST}
- {2676502800 0 0 UTC}
- {2689808400 7200 1 CEST}
- {2708557200 0 0 UTC}
- {2721258000 7200 1 CEST}
- {2740006800 0 0 UTC}
- {2752707600 7200 1 CEST}
- {2771456400 0 0 UTC}
- {2784762000 7200 1 CEST}
- {2802906000 0 0 UTC}
- {2816211600 7200 1 CEST}
- {2834355600 0 0 UTC}
- {2847661200 7200 1 CEST}
- {2866410000 0 0 UTC}
- {2879110800 7200 1 CEST}
- {2897859600 0 0 UTC}
- {2910560400 7200 1 CEST}
- {2929309200 0 0 UTC}
- {2942010000 7200 1 CEST}
- {2960758800 0 0 UTC}
- {2974064400 7200 1 CEST}
- {2992208400 0 0 UTC}
- {3005514000 7200 1 CEST}
- {3023658000 0 0 UTC}
- {3036963600 7200 1 CEST}
- {3055712400 0 0 UTC}
- {3068413200 7200 1 CEST}
- {3087162000 0 0 UTC}
- {3099862800 7200 1 CEST}
- {3118611600 0 0 UTC}
- {3131917200 7200 1 CEST}
- {3150061200 0 0 UTC}
- {3163366800 7200 1 CEST}
- {3181510800 0 0 UTC}
- {3194816400 7200 1 CEST}
- {3212960400 0 0 UTC}
- {3226266000 7200 1 CEST}
- {3245014800 0 0 UTC}
- {3257715600 7200 1 CEST}
- {3276464400 0 0 UTC}
- {3289165200 7200 1 CEST}
- {3307914000 0 0 UTC}
- {3321219600 7200 1 CEST}
- {3339363600 0 0 UTC}
- {3352669200 7200 1 CEST}
- {3370813200 0 0 UTC}
- {3384118800 7200 1 CEST}
- {3402867600 0 0 UTC}
- {3415568400 7200 1 CEST}
- {3434317200 0 0 UTC}
- {3447018000 7200 1 CEST}
- {3465766800 0 0 UTC}
- {3479072400 7200 1 CEST}
- {3497216400 0 0 UTC}
- {3510522000 7200 1 CEST}
- {3528666000 0 0 UTC}
- {3541971600 7200 1 CEST}
- {3560115600 0 0 UTC}
- {3573421200 7200 1 CEST}
- {3592170000 0 0 UTC}
- {3604870800 7200 1 CEST}
- {3623619600 0 0 UTC}
- {3636320400 7200 1 CEST}
- {3655069200 0 0 UTC}
- {3668374800 7200 1 CEST}
- {3686518800 0 0 UTC}
- {3699824400 7200 1 CEST}
- {3717968400 0 0 UTC}
- {3731274000 7200 1 CEST}
- {3750022800 0 0 UTC}
- {3762723600 7200 1 CEST}
- {3781472400 0 0 UTC}
- {3794173200 7200 1 CEST}
- {3812922000 0 0 UTC}
- {3825622800 7200 1 CEST}
- {3844371600 0 0 UTC}
- {3857677200 7200 1 CEST}
- {3875821200 0 0 UTC}
- {3889126800 7200 1 CEST}
- {3907270800 0 0 UTC}
- {3920576400 7200 1 CEST}
- {3939325200 0 0 UTC}
- {3952026000 7200 1 CEST}
- {3970774800 0 0 UTC}
- {3983475600 7200 1 CEST}
- {4002224400 0 0 UTC}
- {4015530000 7200 1 CEST}
- {4033674000 0 0 UTC}
- {4046979600 7200 1 CEST}
- {4065123600 0 0 UTC}
- {4078429200 7200 1 CEST}
- {4096573200 0 0 UTC}
+ {1108166400 0 0 +00}
+ {1111885200 7200 1 +02}
+ {1130634000 0 0 +00}
+ {1143334800 7200 1 +02}
+ {1162083600 0 0 +00}
+ {1174784400 7200 1 +02}
+ {1193533200 0 0 +00}
+ {1206838800 7200 1 +02}
+ {1224982800 0 0 +00}
+ {1238288400 7200 1 +02}
+ {1256432400 0 0 +00}
+ {1269738000 7200 1 +02}
+ {1288486800 0 0 +00}
+ {1301187600 7200 1 +02}
+ {1319936400 0 0 +00}
+ {1332637200 7200 1 +02}
+ {1351386000 0 0 +00}
+ {1364691600 7200 1 +02}
+ {1382835600 0 0 +00}
+ {1396141200 7200 1 +02}
+ {1414285200 0 0 +00}
+ {1427590800 7200 1 +02}
+ {1445734800 0 0 +00}
+ {1459040400 7200 1 +02}
+ {1477789200 0 0 +00}
+ {1490490000 7200 1 +02}
+ {1509238800 0 0 +00}
+ {1521939600 7200 1 +02}
+ {1540688400 0 0 +00}
+ {1553994000 7200 1 +02}
+ {1572138000 0 0 +00}
+ {1585443600 7200 1 +02}
+ {1603587600 0 0 +00}
+ {1616893200 7200 1 +02}
+ {1635642000 0 0 +00}
+ {1648342800 7200 1 +02}
+ {1667091600 0 0 +00}
+ {1679792400 7200 1 +02}
+ {1698541200 0 0 +00}
+ {1711846800 7200 1 +02}
+ {1729990800 0 0 +00}
+ {1743296400 7200 1 +02}
+ {1761440400 0 0 +00}
+ {1774746000 7200 1 +02}
+ {1792890000 0 0 +00}
+ {1806195600 7200 1 +02}
+ {1824944400 0 0 +00}
+ {1837645200 7200 1 +02}
+ {1856394000 0 0 +00}
+ {1869094800 7200 1 +02}
+ {1887843600 0 0 +00}
+ {1901149200 7200 1 +02}
+ {1919293200 0 0 +00}
+ {1932598800 7200 1 +02}
+ {1950742800 0 0 +00}
+ {1964048400 7200 1 +02}
+ {1982797200 0 0 +00}
+ {1995498000 7200 1 +02}
+ {2014246800 0 0 +00}
+ {2026947600 7200 1 +02}
+ {2045696400 0 0 +00}
+ {2058397200 7200 1 +02}
+ {2077146000 0 0 +00}
+ {2090451600 7200 1 +02}
+ {2108595600 0 0 +00}
+ {2121901200 7200 1 +02}
+ {2140045200 0 0 +00}
+ {2153350800 7200 1 +02}
+ {2172099600 0 0 +00}
+ {2184800400 7200 1 +02}
+ {2203549200 0 0 +00}
+ {2216250000 7200 1 +02}
+ {2234998800 0 0 +00}
+ {2248304400 7200 1 +02}
+ {2266448400 0 0 +00}
+ {2279754000 7200 1 +02}
+ {2297898000 0 0 +00}
+ {2311203600 7200 1 +02}
+ {2329347600 0 0 +00}
+ {2342653200 7200 1 +02}
+ {2361402000 0 0 +00}
+ {2374102800 7200 1 +02}
+ {2392851600 0 0 +00}
+ {2405552400 7200 1 +02}
+ {2424301200 0 0 +00}
+ {2437606800 7200 1 +02}
+ {2455750800 0 0 +00}
+ {2469056400 7200 1 +02}
+ {2487200400 0 0 +00}
+ {2500506000 7200 1 +02}
+ {2519254800 0 0 +00}
+ {2531955600 7200 1 +02}
+ {2550704400 0 0 +00}
+ {2563405200 7200 1 +02}
+ {2582154000 0 0 +00}
+ {2595459600 7200 1 +02}
+ {2613603600 0 0 +00}
+ {2626909200 7200 1 +02}
+ {2645053200 0 0 +00}
+ {2658358800 7200 1 +02}
+ {2676502800 0 0 +00}
+ {2689808400 7200 1 +02}
+ {2708557200 0 0 +00}
+ {2721258000 7200 1 +02}
+ {2740006800 0 0 +00}
+ {2752707600 7200 1 +02}
+ {2771456400 0 0 +00}
+ {2784762000 7200 1 +02}
+ {2802906000 0 0 +00}
+ {2816211600 7200 1 +02}
+ {2834355600 0 0 +00}
+ {2847661200 7200 1 +02}
+ {2866410000 0 0 +00}
+ {2879110800 7200 1 +02}
+ {2897859600 0 0 +00}
+ {2910560400 7200 1 +02}
+ {2929309200 0 0 +00}
+ {2942010000 7200 1 +02}
+ {2960758800 0 0 +00}
+ {2974064400 7200 1 +02}
+ {2992208400 0 0 +00}
+ {3005514000 7200 1 +02}
+ {3023658000 0 0 +00}
+ {3036963600 7200 1 +02}
+ {3055712400 0 0 +00}
+ {3068413200 7200 1 +02}
+ {3087162000 0 0 +00}
+ {3099862800 7200 1 +02}
+ {3118611600 0 0 +00}
+ {3131917200 7200 1 +02}
+ {3150061200 0 0 +00}
+ {3163366800 7200 1 +02}
+ {3181510800 0 0 +00}
+ {3194816400 7200 1 +02}
+ {3212960400 0 0 +00}
+ {3226266000 7200 1 +02}
+ {3245014800 0 0 +00}
+ {3257715600 7200 1 +02}
+ {3276464400 0 0 +00}
+ {3289165200 7200 1 +02}
+ {3307914000 0 0 +00}
+ {3321219600 7200 1 +02}
+ {3339363600 0 0 +00}
+ {3352669200 7200 1 +02}
+ {3370813200 0 0 +00}
+ {3384118800 7200 1 +02}
+ {3402867600 0 0 +00}
+ {3415568400 7200 1 +02}
+ {3434317200 0 0 +00}
+ {3447018000 7200 1 +02}
+ {3465766800 0 0 +00}
+ {3479072400 7200 1 +02}
+ {3497216400 0 0 +00}
+ {3510522000 7200 1 +02}
+ {3528666000 0 0 +00}
+ {3541971600 7200 1 +02}
+ {3560115600 0 0 +00}
+ {3573421200 7200 1 +02}
+ {3592170000 0 0 +00}
+ {3604870800 7200 1 +02}
+ {3623619600 0 0 +00}
+ {3636320400 7200 1 +02}
+ {3655069200 0 0 +00}
+ {3668374800 7200 1 +02}
+ {3686518800 0 0 +00}
+ {3699824400 7200 1 +02}
+ {3717968400 0 0 +00}
+ {3731274000 7200 1 +02}
+ {3750022800 0 0 +00}
+ {3762723600 7200 1 +02}
+ {3781472400 0 0 +00}
+ {3794173200 7200 1 +02}
+ {3812922000 0 0 +00}
+ {3825622800 7200 1 +02}
+ {3844371600 0 0 +00}
+ {3857677200 7200 1 +02}
+ {3875821200 0 0 +00}
+ {3889126800 7200 1 +02}
+ {3907270800 0 0 +00}
+ {3920576400 7200 1 +02}
+ {3939325200 0 0 +00}
+ {3952026000 7200 1 +02}
+ {3970774800 0 0 +00}
+ {3983475600 7200 1 +02}
+ {4002224400 0 0 +00}
+ {4015530000 7200 1 +02}
+ {4033674000 0 0 +00}
+ {4046979600 7200 1 +02}
+ {4065123600 0 0 +00}
+ {4078429200 7200 1 +02}
+ {4096573200 0 0 +00}
}
diff --git a/library/tzdata/Antarctica/Vostok b/library/tzdata/Antarctica/Vostok
index a59868b..7f345a2 100644
--- a/library/tzdata/Antarctica/Vostok
+++ b/library/tzdata/Antarctica/Vostok
@@ -2,5 +2,5 @@
set TZData(:Antarctica/Vostok) {
{-9223372036854775808 0 0 -00}
- {-380073600 21600 0 VOST}
+ {-380073600 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Anadyr b/library/tzdata/Asia/Anadyr
index 2e8ffc7..d1314c6 100644
--- a/library/tzdata/Asia/Anadyr
+++ b/library/tzdata/Asia/Anadyr
@@ -2,71 +2,71 @@
set TZData(:Asia/Anadyr) {
{-9223372036854775808 42596 0 LMT}
- {-1441194596 43200 0 ANAT}
- {-1247572800 46800 0 ANAMMTT}
- {354884400 50400 1 ANAST}
- {370692000 46800 0 ANAT}
- {386420400 43200 0 ANAMMTT}
- {386424000 46800 1 ANAST}
- {402231600 43200 0 ANAT}
- {417960000 46800 1 ANAST}
- {433767600 43200 0 ANAT}
- {449582400 46800 1 ANAST}
- {465314400 43200 0 ANAT}
- {481039200 46800 1 ANAST}
- {496764000 43200 0 ANAT}
- {512488800 46800 1 ANAST}
- {528213600 43200 0 ANAT}
- {543938400 46800 1 ANAST}
- {559663200 43200 0 ANAT}
- {575388000 46800 1 ANAST}
- {591112800 43200 0 ANAT}
- {606837600 46800 1 ANAST}
- {622562400 43200 0 ANAT}
- {638287200 46800 1 ANAST}
- {654616800 43200 0 ANAT}
- {670341600 39600 0 ANAMMTT}
- {670345200 43200 1 ANAST}
- {686070000 39600 0 ANAT}
- {695746800 43200 0 ANAMMTT}
- {701791200 46800 1 ANAST}
- {717516000 43200 0 ANAT}
- {733240800 46800 1 ANAST}
- {748965600 43200 0 ANAT}
- {764690400 46800 1 ANAST}
- {780415200 43200 0 ANAT}
- {796140000 46800 1 ANAST}
- {811864800 43200 0 ANAT}
- {828194400 46800 1 ANAST}
- {846338400 43200 0 ANAT}
- {859644000 46800 1 ANAST}
- {877788000 43200 0 ANAT}
- {891093600 46800 1 ANAST}
- {909237600 43200 0 ANAT}
- {922543200 46800 1 ANAST}
- {941292000 43200 0 ANAT}
- {953992800 46800 1 ANAST}
- {972741600 43200 0 ANAT}
- {985442400 46800 1 ANAST}
- {1004191200 43200 0 ANAT}
- {1017496800 46800 1 ANAST}
- {1035640800 43200 0 ANAT}
- {1048946400 46800 1 ANAST}
- {1067090400 43200 0 ANAT}
- {1080396000 46800 1 ANAST}
- {1099144800 43200 0 ANAT}
- {1111845600 46800 1 ANAST}
- {1130594400 43200 0 ANAT}
- {1143295200 46800 1 ANAST}
- {1162044000 43200 0 ANAT}
- {1174744800 46800 1 ANAST}
- {1193493600 43200 0 ANAT}
- {1206799200 46800 1 ANAST}
- {1224943200 43200 0 ANAT}
- {1238248800 46800 1 ANAST}
- {1256392800 43200 0 ANAT}
- {1269698400 39600 0 ANAMMTT}
- {1269702000 43200 1 ANAST}
- {1288450800 39600 0 ANAT}
- {1301151600 43200 0 ANAT}
+ {-1441194596 43200 0 +12}
+ {-1247572800 46800 0 +14}
+ {354884400 50400 1 +14}
+ {370692000 46800 0 +13}
+ {386420400 43200 0 +13}
+ {386424000 46800 1 +13}
+ {402231600 43200 0 +12}
+ {417960000 46800 1 +13}
+ {433767600 43200 0 +12}
+ {449582400 46800 1 +13}
+ {465314400 43200 0 +12}
+ {481039200 46800 1 +13}
+ {496764000 43200 0 +12}
+ {512488800 46800 1 +13}
+ {528213600 43200 0 +12}
+ {543938400 46800 1 +13}
+ {559663200 43200 0 +12}
+ {575388000 46800 1 +13}
+ {591112800 43200 0 +12}
+ {606837600 46800 1 +13}
+ {622562400 43200 0 +12}
+ {638287200 46800 1 +13}
+ {654616800 43200 0 +12}
+ {670341600 39600 0 +12}
+ {670345200 43200 1 +12}
+ {686070000 39600 0 +11}
+ {695746800 43200 0 +13}
+ {701791200 46800 1 +13}
+ {717516000 43200 0 +12}
+ {733240800 46800 1 +13}
+ {748965600 43200 0 +12}
+ {764690400 46800 1 +13}
+ {780415200 43200 0 +12}
+ {796140000 46800 1 +13}
+ {811864800 43200 0 +12}
+ {828194400 46800 1 +13}
+ {846338400 43200 0 +12}
+ {859644000 46800 1 +13}
+ {877788000 43200 0 +12}
+ {891093600 46800 1 +13}
+ {909237600 43200 0 +12}
+ {922543200 46800 1 +13}
+ {941292000 43200 0 +12}
+ {953992800 46800 1 +13}
+ {972741600 43200 0 +12}
+ {985442400 46800 1 +13}
+ {1004191200 43200 0 +12}
+ {1017496800 46800 1 +13}
+ {1035640800 43200 0 +12}
+ {1048946400 46800 1 +13}
+ {1067090400 43200 0 +12}
+ {1080396000 46800 1 +13}
+ {1099144800 43200 0 +12}
+ {1111845600 46800 1 +13}
+ {1130594400 43200 0 +12}
+ {1143295200 46800 1 +13}
+ {1162044000 43200 0 +12}
+ {1174744800 46800 1 +13}
+ {1193493600 43200 0 +12}
+ {1206799200 46800 1 +13}
+ {1224943200 43200 0 +12}
+ {1238248800 46800 1 +13}
+ {1256392800 43200 0 +12}
+ {1269698400 39600 0 +12}
+ {1269702000 43200 1 +12}
+ {1288450800 39600 0 +11}
+ {1301151600 43200 0 +12}
}
diff --git a/library/tzdata/Asia/Aqtau b/library/tzdata/Asia/Aqtau
index 90cc94d..c128b27 100644
--- a/library/tzdata/Asia/Aqtau
+++ b/library/tzdata/Asia/Aqtau
@@ -4,7 +4,6 @@ set TZData(:Asia/Aqtau) {
{-9223372036854775808 12064 0 LMT}
{-1441164064 14400 0 +04}
{-1247544000 18000 0 +05}
- {-220942800 18000 0 +05}
{370724400 21600 0 +06}
{386445600 18000 0 +05}
{386449200 21600 1 +06}
diff --git a/library/tzdata/Asia/Ashgabat b/library/tzdata/Asia/Ashgabat
index 64bdb3a..fa6a619 100644
--- a/library/tzdata/Asia/Ashgabat
+++ b/library/tzdata/Asia/Ashgabat
@@ -2,30 +2,30 @@
set TZData(:Asia/Ashgabat) {
{-9223372036854775808 14012 0 LMT}
- {-1441166012 14400 0 ASHT}
- {-1247544000 18000 0 ASHT}
- {354913200 21600 1 ASHST}
- {370720800 18000 0 ASHT}
- {386449200 21600 1 ASHST}
- {402256800 18000 0 ASHT}
- {417985200 21600 1 ASHST}
- {433792800 18000 0 ASHT}
- {449607600 21600 1 ASHST}
- {465339600 18000 0 ASHT}
- {481064400 21600 1 ASHST}
- {496789200 18000 0 ASHT}
- {512514000 21600 1 ASHST}
- {528238800 18000 0 ASHT}
- {543963600 21600 1 ASHST}
- {559688400 18000 0 ASHT}
- {575413200 21600 1 ASHST}
- {591138000 18000 0 ASHT}
- {606862800 21600 1 ASHST}
- {622587600 18000 0 ASHT}
- {638312400 21600 1 ASHST}
- {654642000 18000 0 ASHT}
- {670366800 14400 0 ASHT}
- {670370400 18000 1 ASHST}
- {686095200 14400 0 ASHT}
- {695772000 18000 0 TMT}
+ {-1441166012 14400 0 +04}
+ {-1247544000 18000 0 +05}
+ {354913200 21600 1 +06}
+ {370720800 18000 0 +05}
+ {386449200 21600 1 +06}
+ {402256800 18000 0 +05}
+ {417985200 21600 1 +06}
+ {433792800 18000 0 +05}
+ {449607600 21600 1 +06}
+ {465339600 18000 0 +05}
+ {481064400 21600 1 +06}
+ {496789200 18000 0 +05}
+ {512514000 21600 1 +06}
+ {528238800 18000 0 +05}
+ {543963600 21600 1 +06}
+ {559688400 18000 0 +05}
+ {575413200 21600 1 +06}
+ {591138000 18000 0 +05}
+ {606862800 21600 1 +06}
+ {622587600 18000 0 +05}
+ {638312400 21600 1 +06}
+ {654642000 18000 0 +05}
+ {670366800 14400 0 +04}
+ {670370400 18000 1 +05}
+ {686095200 14400 0 +04}
+ {695772000 18000 0 +05}
}
diff --git a/library/tzdata/Asia/Atyrau b/library/tzdata/Asia/Atyrau
new file mode 100644
index 0000000..c31ff11
--- /dev/null
+++ b/library/tzdata/Asia/Atyrau
@@ -0,0 +1,58 @@
+# created by tools/tclZIC.tcl - do not edit
+
+set TZData(:Asia/Atyrau) {
+ {-9223372036854775808 12464 0 LMT}
+ {-1441164464 10800 0 +03}
+ {-1247540400 18000 0 +05}
+ {370724400 21600 0 +06}
+ {386445600 18000 0 +05}
+ {386449200 21600 1 +06}
+ {402256800 18000 0 +05}
+ {417985200 21600 1 +06}
+ {433792800 18000 0 +05}
+ {449607600 21600 1 +06}
+ {465339600 18000 0 +05}
+ {481064400 21600 1 +06}
+ {496789200 18000 0 +05}
+ {512514000 21600 1 +06}
+ {528238800 18000 0 +05}
+ {543963600 21600 1 +06}
+ {559688400 18000 0 +05}
+ {575413200 21600 1 +06}
+ {591138000 18000 0 +05}
+ {606862800 21600 1 +06}
+ {622587600 18000 0 +05}
+ {638312400 21600 1 +06}
+ {654642000 18000 0 +05}
+ {670366800 14400 0 +04}
+ {670370400 18000 1 +05}
+ {686095200 14400 0 +04}
+ {695772000 18000 0 +05}
+ {701816400 21600 1 +06}
+ {717541200 18000 0 +05}
+ {733266000 21600 1 +06}
+ {748990800 18000 0 +05}
+ {764715600 21600 1 +06}
+ {780440400 18000 0 +05}
+ {796165200 21600 1 +06}
+ {811890000 18000 0 +05}
+ {828219600 21600 1 +06}
+ {846363600 18000 0 +05}
+ {859669200 21600 1 +06}
+ {877813200 18000 0 +05}
+ {891118800 21600 1 +06}
+ {909262800 18000 0 +05}
+ {922568400 14400 0 +04}
+ {922572000 18000 1 +05}
+ {941320800 14400 0 +04}
+ {954021600 18000 1 +05}
+ {972770400 14400 0 +04}
+ {985471200 18000 1 +05}
+ {1004220000 14400 0 +04}
+ {1017525600 18000 1 +05}
+ {1035669600 14400 0 +04}
+ {1048975200 18000 1 +05}
+ {1067119200 14400 0 +04}
+ {1080424800 18000 1 +05}
+ {1099173600 18000 0 +05}
+}
diff --git a/library/tzdata/Asia/Baghdad b/library/tzdata/Asia/Baghdad
index c1058cb..623e310 100644
--- a/library/tzdata/Asia/Baghdad
+++ b/library/tzdata/Asia/Baghdad
@@ -3,57 +3,57 @@
set TZData(:Asia/Baghdad) {
{-9223372036854775808 10660 0 LMT}
{-2524532260 10656 0 BMT}
- {-1641005856 10800 0 AST}
- {389048400 14400 0 ADT}
- {402264000 10800 0 AST}
- {417906000 14400 1 ADT}
- {433800000 10800 0 AST}
- {449614800 14400 1 ADT}
- {465422400 10800 0 AST}
- {481150800 14400 1 ADT}
- {496792800 10800 0 AST}
- {512517600 14400 1 ADT}
- {528242400 10800 0 AST}
- {543967200 14400 1 ADT}
- {559692000 10800 0 AST}
- {575416800 14400 1 ADT}
- {591141600 10800 0 AST}
- {606866400 14400 1 ADT}
- {622591200 10800 0 AST}
- {638316000 14400 1 ADT}
- {654645600 10800 0 AST}
- {670464000 14400 1 ADT}
- {686275200 10800 0 AST}
- {702086400 14400 1 ADT}
- {717897600 10800 0 AST}
- {733622400 14400 1 ADT}
- {749433600 10800 0 AST}
- {765158400 14400 1 ADT}
- {780969600 10800 0 AST}
- {796694400 14400 1 ADT}
- {812505600 10800 0 AST}
- {828316800 14400 1 ADT}
- {844128000 10800 0 AST}
- {859852800 14400 1 ADT}
- {875664000 10800 0 AST}
- {891388800 14400 1 ADT}
- {907200000 10800 0 AST}
- {922924800 14400 1 ADT}
- {938736000 10800 0 AST}
- {954547200 14400 1 ADT}
- {970358400 10800 0 AST}
- {986083200 14400 1 ADT}
- {1001894400 10800 0 AST}
- {1017619200 14400 1 ADT}
- {1033430400 10800 0 AST}
- {1049155200 14400 1 ADT}
- {1064966400 10800 0 AST}
- {1080777600 14400 1 ADT}
- {1096588800 10800 0 AST}
- {1112313600 14400 1 ADT}
- {1128124800 10800 0 AST}
- {1143849600 14400 1 ADT}
- {1159660800 10800 0 AST}
- {1175385600 14400 1 ADT}
- {1191196800 10800 0 AST}
+ {-1641005856 10800 0 +03}
+ {389048400 14400 0 +04}
+ {402264000 10800 0 +04}
+ {417906000 14400 1 +04}
+ {433800000 10800 0 +04}
+ {449614800 14400 1 +04}
+ {465422400 10800 0 +04}
+ {481150800 14400 1 +04}
+ {496792800 10800 0 +04}
+ {512517600 14400 1 +04}
+ {528242400 10800 0 +04}
+ {543967200 14400 1 +04}
+ {559692000 10800 0 +04}
+ {575416800 14400 1 +04}
+ {591141600 10800 0 +04}
+ {606866400 14400 1 +04}
+ {622591200 10800 0 +04}
+ {638316000 14400 1 +04}
+ {654645600 10800 0 +04}
+ {670464000 14400 1 +04}
+ {686275200 10800 0 +04}
+ {702086400 14400 1 +04}
+ {717897600 10800 0 +04}
+ {733622400 14400 1 +04}
+ {749433600 10800 0 +04}
+ {765158400 14400 1 +04}
+ {780969600 10800 0 +04}
+ {796694400 14400 1 +04}
+ {812505600 10800 0 +04}
+ {828316800 14400 1 +04}
+ {844128000 10800 0 +04}
+ {859852800 14400 1 +04}
+ {875664000 10800 0 +04}
+ {891388800 14400 1 +04}
+ {907200000 10800 0 +04}
+ {922924800 14400 1 +04}
+ {938736000 10800 0 +04}
+ {954547200 14400 1 +04}
+ {970358400 10800 0 +04}
+ {986083200 14400 1 +04}
+ {1001894400 10800 0 +04}
+ {1017619200 14400 1 +04}
+ {1033430400 10800 0 +04}
+ {1049155200 14400 1 +04}
+ {1064966400 10800 0 +04}
+ {1080777600 14400 1 +04}
+ {1096588800 10800 0 +04}
+ {1112313600 14400 1 +04}
+ {1128124800 10800 0 +04}
+ {1143849600 14400 1 +04}
+ {1159660800 10800 0 +04}
+ {1175385600 14400 1 +04}
+ {1191196800 10800 0 +04}
}
diff --git a/library/tzdata/Asia/Baku b/library/tzdata/Asia/Baku
index e9ee835..f945b89 100644
--- a/library/tzdata/Asia/Baku
+++ b/library/tzdata/Asia/Baku
@@ -2,73 +2,73 @@
set TZData(:Asia/Baku) {
{-9223372036854775808 11964 0 LMT}
- {-1441163964 10800 0 BAKT}
- {-405140400 14400 0 BAKT}
- {354916800 18000 1 BAKST}
- {370724400 14400 0 BAKT}
- {386452800 18000 1 BAKST}
- {402260400 14400 0 BAKT}
- {417988800 18000 1 BAKST}
- {433796400 14400 0 BAKT}
- {449611200 18000 1 BAKST}
- {465343200 14400 0 BAKT}
- {481068000 18000 1 BAKST}
- {496792800 14400 0 BAKT}
- {512517600 18000 1 BAKST}
- {528242400 14400 0 BAKT}
- {543967200 18000 1 BAKST}
- {559692000 14400 0 BAKT}
- {575416800 18000 1 BAKST}
- {591141600 14400 0 BAKT}
- {606866400 18000 1 BAKST}
- {622591200 14400 0 BAKT}
- {638316000 18000 1 BAKST}
- {654645600 14400 0 BAKT}
- {670370400 14400 1 BAKST}
- {683496000 14400 0 AZST}
- {686098800 10800 0 AZT}
- {701823600 14400 1 AZST}
- {717548400 14400 0 AZT}
- {820440000 14400 0 AZT}
- {828234000 18000 1 AZST}
- {846378000 14400 0 AZT}
- {852062400 14400 0 AZT}
- {859680000 18000 1 AZST}
- {877824000 14400 0 AZT}
- {891129600 18000 1 AZST}
- {909273600 14400 0 AZT}
- {922579200 18000 1 AZST}
- {941328000 14400 0 AZT}
- {954028800 18000 1 AZST}
- {972777600 14400 0 AZT}
- {985478400 18000 1 AZST}
- {1004227200 14400 0 AZT}
- {1017532800 18000 1 AZST}
- {1035676800 14400 0 AZT}
- {1048982400 18000 1 AZST}
- {1067126400 14400 0 AZT}
- {1080432000 18000 1 AZST}
- {1099180800 14400 0 AZT}
- {1111881600 18000 1 AZST}
- {1130630400 14400 0 AZT}
- {1143331200 18000 1 AZST}
- {1162080000 14400 0 AZT}
- {1174780800 18000 1 AZST}
- {1193529600 14400 0 AZT}
- {1206835200 18000 1 AZST}
- {1224979200 14400 0 AZT}
- {1238284800 18000 1 AZST}
- {1256428800 14400 0 AZT}
- {1269734400 18000 1 AZST}
- {1288483200 14400 0 AZT}
- {1301184000 18000 1 AZST}
- {1319932800 14400 0 AZT}
- {1332633600 18000 1 AZST}
- {1351382400 14400 0 AZT}
- {1364688000 18000 1 AZST}
- {1382832000 14400 0 AZT}
- {1396137600 18000 1 AZST}
- {1414281600 14400 0 AZT}
- {1427587200 18000 1 AZST}
- {1445731200 14400 0 AZT}
+ {-1441163964 10800 0 +03}
+ {-405140400 14400 0 +04}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 18000 1 +05}
+ {591141600 14400 0 +04}
+ {606866400 18000 1 +05}
+ {622591200 14400 0 +04}
+ {638316000 18000 1 +05}
+ {654645600 14400 0 +04}
+ {670370400 10800 0 +03}
+ {670374000 14400 1 +04}
+ {686098800 10800 0 +03}
+ {701823600 14400 1 +04}
+ {717548400 14400 0 +04}
+ {820440000 14400 0 +04}
+ {828234000 18000 1 +05}
+ {846378000 14400 0 +04}
+ {852062400 14400 0 +04}
+ {859680000 18000 1 +05}
+ {877824000 14400 0 +04}
+ {891129600 18000 1 +05}
+ {909273600 14400 0 +04}
+ {922579200 18000 1 +05}
+ {941328000 14400 0 +04}
+ {954028800 18000 1 +05}
+ {972777600 14400 0 +04}
+ {985478400 18000 1 +05}
+ {1004227200 14400 0 +04}
+ {1017532800 18000 1 +05}
+ {1035676800 14400 0 +04}
+ {1048982400 18000 1 +05}
+ {1067126400 14400 0 +04}
+ {1080432000 18000 1 +05}
+ {1099180800 14400 0 +04}
+ {1111881600 18000 1 +05}
+ {1130630400 14400 0 +04}
+ {1143331200 18000 1 +05}
+ {1162080000 14400 0 +04}
+ {1174780800 18000 1 +05}
+ {1193529600 14400 0 +04}
+ {1206835200 18000 1 +05}
+ {1224979200 14400 0 +04}
+ {1238284800 18000 1 +05}
+ {1256428800 14400 0 +04}
+ {1269734400 18000 1 +05}
+ {1288483200 14400 0 +04}
+ {1301184000 18000 1 +05}
+ {1319932800 14400 0 +04}
+ {1332633600 18000 1 +05}
+ {1351382400 14400 0 +04}
+ {1364688000 18000 1 +05}
+ {1382832000 14400 0 +04}
+ {1396137600 18000 1 +05}
+ {1414281600 14400 0 +04}
+ {1427587200 18000 1 +05}
+ {1445731200 14400 0 +04}
}
diff --git a/library/tzdata/Asia/Bangkok b/library/tzdata/Asia/Bangkok
index 6df7680..aeb5473 100644
--- a/library/tzdata/Asia/Bangkok
+++ b/library/tzdata/Asia/Bangkok
@@ -3,5 +3,5 @@
set TZData(:Asia/Bangkok) {
{-9223372036854775808 24124 0 LMT}
{-2840164924 24124 0 BMT}
- {-1570084924 25200 0 ICT}
+ {-1570084924 25200 0 +07}
}
diff --git a/library/tzdata/Asia/Bishkek b/library/tzdata/Asia/Bishkek
index 6ba3896..a02d789 100644
--- a/library/tzdata/Asia/Bishkek
+++ b/library/tzdata/Asia/Bishkek
@@ -2,56 +2,57 @@
set TZData(:Asia/Bishkek) {
{-9223372036854775808 17904 0 LMT}
- {-1441169904 18000 0 FRUT}
- {-1247547600 21600 0 FRUT}
- {354909600 25200 1 FRUST}
- {370717200 21600 0 FRUT}
- {386445600 25200 1 FRUST}
- {402253200 21600 0 FRUT}
- {417981600 25200 1 FRUST}
- {433789200 21600 0 FRUT}
- {449604000 25200 1 FRUST}
- {465336000 21600 0 FRUT}
- {481060800 25200 1 FRUST}
- {496785600 21600 0 FRUT}
- {512510400 25200 1 FRUST}
- {528235200 21600 0 FRUT}
- {543960000 25200 1 FRUST}
- {559684800 21600 0 FRUT}
- {575409600 25200 1 FRUST}
- {591134400 21600 0 FRUT}
- {606859200 25200 1 FRUST}
- {622584000 21600 0 FRUT}
- {638308800 25200 1 FRUST}
- {654638400 21600 0 FRUT}
- {670363200 21600 1 FRUST}
- {683582400 21600 0 KGT}
- {703018800 21600 1 KGST}
- {717530400 18000 0 KGT}
- {734468400 21600 1 KGST}
- {748980000 18000 0 KGT}
- {765918000 21600 1 KGST}
- {780429600 18000 0 KGT}
- {797367600 21600 1 KGST}
- {811879200 18000 0 KGT}
- {828817200 21600 1 KGST}
- {843933600 18000 0 KGT}
- {859671000 21600 1 KGST}
- {877811400 18000 0 KGT}
- {891120600 21600 1 KGST}
- {909261000 18000 0 KGT}
- {922570200 21600 1 KGST}
- {941315400 18000 0 KGT}
- {954019800 21600 1 KGST}
- {972765000 18000 0 KGT}
- {985469400 21600 1 KGST}
- {1004214600 18000 0 KGT}
- {1017523800 21600 1 KGST}
- {1035664200 18000 0 KGT}
- {1048973400 21600 1 KGST}
- {1067113800 18000 0 KGT}
- {1080423000 21600 1 KGST}
- {1099168200 18000 0 KGT}
- {1111872600 21600 1 KGST}
- {1123783200 21600 0 KGT}
+ {-1441169904 18000 0 +05}
+ {-1247547600 21600 0 +06}
+ {354909600 25200 1 +07}
+ {370717200 21600 0 +06}
+ {386445600 25200 1 +07}
+ {402253200 21600 0 +06}
+ {417981600 25200 1 +07}
+ {433789200 21600 0 +06}
+ {449604000 25200 1 +07}
+ {465336000 21600 0 +06}
+ {481060800 25200 1 +07}
+ {496785600 21600 0 +06}
+ {512510400 25200 1 +07}
+ {528235200 21600 0 +06}
+ {543960000 25200 1 +07}
+ {559684800 21600 0 +06}
+ {575409600 25200 1 +07}
+ {591134400 21600 0 +06}
+ {606859200 25200 1 +07}
+ {622584000 21600 0 +06}
+ {638308800 25200 1 +07}
+ {654638400 21600 0 +06}
+ {670363200 18000 0 +05}
+ {670366800 21600 1 +06}
+ {683586000 18000 0 +05}
+ {703018800 21600 1 +06}
+ {717530400 18000 0 +05}
+ {734468400 21600 1 +06}
+ {748980000 18000 0 +05}
+ {765918000 21600 1 +06}
+ {780429600 18000 0 +05}
+ {797367600 21600 1 +06}
+ {811879200 18000 0 +05}
+ {828817200 21600 1 +06}
+ {843933600 18000 0 +05}
+ {859671000 21600 1 +06}
+ {877811400 18000 0 +05}
+ {891120600 21600 1 +06}
+ {909261000 18000 0 +05}
+ {922570200 21600 1 +06}
+ {941315400 18000 0 +05}
+ {954019800 21600 1 +06}
+ {972765000 18000 0 +05}
+ {985469400 21600 1 +06}
+ {1004214600 18000 0 +05}
+ {1017523800 21600 1 +06}
+ {1035664200 18000 0 +05}
+ {1048973400 21600 1 +06}
+ {1067113800 18000 0 +05}
+ {1080423000 21600 1 +06}
+ {1099168200 18000 0 +05}
+ {1111872600 21600 1 +06}
+ {1123783200 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Brunei b/library/tzdata/Asia/Brunei
index 63d380b..e8cc8c3 100644
--- a/library/tzdata/Asia/Brunei
+++ b/library/tzdata/Asia/Brunei
@@ -2,6 +2,6 @@
set TZData(:Asia/Brunei) {
{-9223372036854775808 27580 0 LMT}
- {-1383464380 27000 0 BNT}
- {-1167636600 28800 0 BNT}
+ {-1383464380 27000 0 +0730}
+ {-1167636600 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Chita b/library/tzdata/Asia/Chita
index 2517beb..279c016 100644
--- a/library/tzdata/Asia/Chita
+++ b/library/tzdata/Asia/Chita
@@ -2,71 +2,71 @@
set TZData(:Asia/Chita) {
{-9223372036854775808 27232 0 LMT}
- {-1579419232 28800 0 YAKT}
- {-1247558400 32400 0 YAKMMTT}
- {354898800 36000 1 YAKST}
- {370706400 32400 0 YAKT}
- {386434800 36000 1 YAKST}
- {402242400 32400 0 YAKT}
- {417970800 36000 1 YAKST}
- {433778400 32400 0 YAKT}
- {449593200 36000 1 YAKST}
- {465325200 32400 0 YAKT}
- {481050000 36000 1 YAKST}
- {496774800 32400 0 YAKT}
- {512499600 36000 1 YAKST}
- {528224400 32400 0 YAKT}
- {543949200 36000 1 YAKST}
- {559674000 32400 0 YAKT}
- {575398800 36000 1 YAKST}
- {591123600 32400 0 YAKT}
- {606848400 36000 1 YAKST}
- {622573200 32400 0 YAKT}
- {638298000 36000 1 YAKST}
- {654627600 32400 0 YAKT}
- {670352400 28800 0 YAKMMTT}
- {670356000 32400 1 YAKST}
- {686080800 28800 0 YAKT}
- {695757600 32400 0 YAKMMTT}
- {701802000 36000 1 YAKST}
- {717526800 32400 0 YAKT}
- {733251600 36000 1 YAKST}
- {748976400 32400 0 YAKT}
- {764701200 36000 1 YAKST}
- {780426000 32400 0 YAKT}
- {796150800 36000 1 YAKST}
- {811875600 32400 0 YAKT}
- {828205200 36000 1 YAKST}
- {846349200 32400 0 YAKT}
- {859654800 36000 1 YAKST}
- {877798800 32400 0 YAKT}
- {891104400 36000 1 YAKST}
- {909248400 32400 0 YAKT}
- {922554000 36000 1 YAKST}
- {941302800 32400 0 YAKT}
- {954003600 36000 1 YAKST}
- {972752400 32400 0 YAKT}
- {985453200 36000 1 YAKST}
- {1004202000 32400 0 YAKT}
- {1017507600 36000 1 YAKST}
- {1035651600 32400 0 YAKT}
- {1048957200 36000 1 YAKST}
- {1067101200 32400 0 YAKT}
- {1080406800 36000 1 YAKST}
- {1099155600 32400 0 YAKT}
- {1111856400 36000 1 YAKST}
- {1130605200 32400 0 YAKT}
- {1143306000 36000 1 YAKST}
- {1162054800 32400 0 YAKT}
- {1174755600 36000 1 YAKST}
- {1193504400 32400 0 YAKT}
- {1206810000 36000 1 YAKST}
- {1224954000 32400 0 YAKT}
- {1238259600 36000 1 YAKST}
- {1256403600 32400 0 YAKT}
- {1269709200 36000 1 YAKST}
- {1288458000 32400 0 YAKT}
- {1301158800 36000 0 YAKT}
- {1414252800 28800 0 IRKT}
- {1459015200 32400 0 YAKT}
+ {-1579419232 28800 0 +08}
+ {-1247558400 32400 0 +10}
+ {354898800 36000 1 +10}
+ {370706400 32400 0 +09}
+ {386434800 36000 1 +10}
+ {402242400 32400 0 +09}
+ {417970800 36000 1 +10}
+ {433778400 32400 0 +09}
+ {449593200 36000 1 +10}
+ {465325200 32400 0 +09}
+ {481050000 36000 1 +10}
+ {496774800 32400 0 +09}
+ {512499600 36000 1 +10}
+ {528224400 32400 0 +09}
+ {543949200 36000 1 +10}
+ {559674000 32400 0 +09}
+ {575398800 36000 1 +10}
+ {591123600 32400 0 +09}
+ {606848400 36000 1 +10}
+ {622573200 32400 0 +09}
+ {638298000 36000 1 +10}
+ {654627600 32400 0 +09}
+ {670352400 28800 0 +09}
+ {670356000 32400 1 +09}
+ {686080800 28800 0 +08}
+ {695757600 32400 0 +10}
+ {701802000 36000 1 +10}
+ {717526800 32400 0 +09}
+ {733251600 36000 1 +10}
+ {748976400 32400 0 +09}
+ {764701200 36000 1 +10}
+ {780426000 32400 0 +09}
+ {796150800 36000 1 +10}
+ {811875600 32400 0 +09}
+ {828205200 36000 1 +10}
+ {846349200 32400 0 +09}
+ {859654800 36000 1 +10}
+ {877798800 32400 0 +09}
+ {891104400 36000 1 +10}
+ {909248400 32400 0 +09}
+ {922554000 36000 1 +10}
+ {941302800 32400 0 +09}
+ {954003600 36000 1 +10}
+ {972752400 32400 0 +09}
+ {985453200 36000 1 +10}
+ {1004202000 32400 0 +09}
+ {1017507600 36000 1 +10}
+ {1035651600 32400 0 +09}
+ {1048957200 36000 1 +10}
+ {1067101200 32400 0 +09}
+ {1080406800 36000 1 +10}
+ {1099155600 32400 0 +09}
+ {1111856400 36000 1 +10}
+ {1130605200 32400 0 +09}
+ {1143306000 36000 1 +10}
+ {1162054800 32400 0 +09}
+ {1174755600 36000 1 +10}
+ {1193504400 32400 0 +09}
+ {1206810000 36000 1 +10}
+ {1224954000 32400 0 +09}
+ {1238259600 36000 1 +10}
+ {1256403600 32400 0 +09}
+ {1269709200 36000 1 +10}
+ {1288458000 32400 0 +09}
+ {1301158800 36000 0 +10}
+ {1414252800 28800 0 +08}
+ {1459015200 32400 0 +09}
}
diff --git a/library/tzdata/Asia/Choibalsan b/library/tzdata/Asia/Choibalsan
index 2bcf7f7..3db65de 100644
--- a/library/tzdata/Asia/Choibalsan
+++ b/library/tzdata/Asia/Choibalsan
@@ -2,221 +2,55 @@
set TZData(:Asia/Choibalsan) {
{-9223372036854775808 27480 0 LMT}
- {-2032933080 25200 0 ULAT}
- {252435600 28800 0 ULAT}
- {417974400 36000 0 CHOST}
- {433778400 32400 0 CHOT}
- {449593200 36000 1 CHOST}
- {465314400 32400 0 CHOT}
- {481042800 36000 1 CHOST}
- {496764000 32400 0 CHOT}
- {512492400 36000 1 CHOST}
- {528213600 32400 0 CHOT}
- {543942000 36000 1 CHOST}
- {559663200 32400 0 CHOT}
- {575391600 36000 1 CHOST}
- {591112800 32400 0 CHOT}
- {606841200 36000 1 CHOST}
- {622562400 32400 0 CHOT}
- {638290800 36000 1 CHOST}
- {654616800 32400 0 CHOT}
- {670345200 36000 1 CHOST}
- {686066400 32400 0 CHOT}
- {701794800 36000 1 CHOST}
- {717516000 32400 0 CHOT}
- {733244400 36000 1 CHOST}
- {748965600 32400 0 CHOT}
- {764694000 36000 1 CHOST}
- {780415200 32400 0 CHOT}
- {796143600 36000 1 CHOST}
- {811864800 32400 0 CHOT}
- {828198000 36000 1 CHOST}
- {843919200 32400 0 CHOT}
- {859647600 36000 1 CHOST}
- {875368800 32400 0 CHOT}
- {891097200 36000 1 CHOST}
- {906818400 32400 0 CHOT}
- {988390800 36000 1 CHOST}
- {1001692800 32400 0 CHOT}
- {1017421200 36000 1 CHOST}
- {1033142400 32400 0 CHOT}
- {1048870800 36000 1 CHOST}
- {1064592000 32400 0 CHOT}
- {1080320400 36000 1 CHOST}
- {1096041600 32400 0 CHOT}
- {1111770000 36000 1 CHOST}
- {1127491200 32400 0 CHOT}
- {1143219600 36000 1 CHOST}
- {1159545600 32400 0 CHOT}
- {1206889200 28800 0 CHOT}
- {1427479200 32400 1 CHOST}
- {1443193200 28800 0 CHOT}
- {1458928800 32400 1 CHOST}
- {1474642800 28800 0 CHOT}
- {1490378400 32400 1 CHOST}
- {1506697200 28800 0 CHOT}
- {1522432800 32400 1 CHOST}
- {1538146800 28800 0 CHOT}
- {1553882400 32400 1 CHOST}
- {1569596400 28800 0 CHOT}
- {1585332000 32400 1 CHOST}
- {1601046000 28800 0 CHOT}
- {1616781600 32400 1 CHOST}
- {1632495600 28800 0 CHOT}
- {1648231200 32400 1 CHOST}
- {1663945200 28800 0 CHOT}
- {1679680800 32400 1 CHOST}
- {1695999600 28800 0 CHOT}
- {1711735200 32400 1 CHOST}
- {1727449200 28800 0 CHOT}
- {1743184800 32400 1 CHOST}
- {1758898800 28800 0 CHOT}
- {1774634400 32400 1 CHOST}
- {1790348400 28800 0 CHOT}
- {1806084000 32400 1 CHOST}
- {1821798000 28800 0 CHOT}
- {1837533600 32400 1 CHOST}
- {1853852400 28800 0 CHOT}
- {1869588000 32400 1 CHOST}
- {1885302000 28800 0 CHOT}
- {1901037600 32400 1 CHOST}
- {1916751600 28800 0 CHOT}
- {1932487200 32400 1 CHOST}
- {1948201200 28800 0 CHOT}
- {1963936800 32400 1 CHOST}
- {1979650800 28800 0 CHOT}
- {1995386400 32400 1 CHOST}
- {2011100400 28800 0 CHOT}
- {2026836000 32400 1 CHOST}
- {2043154800 28800 0 CHOT}
- {2058890400 32400 1 CHOST}
- {2074604400 28800 0 CHOT}
- {2090340000 32400 1 CHOST}
- {2106054000 28800 0 CHOT}
- {2121789600 32400 1 CHOST}
- {2137503600 28800 0 CHOT}
- {2153239200 32400 1 CHOST}
- {2168953200 28800 0 CHOT}
- {2184688800 32400 1 CHOST}
- {2200402800 28800 0 CHOT}
- {2216743200 32400 1 CHOST}
- {2232457200 28800 0 CHOT}
- {2248192800 32400 1 CHOST}
- {2263906800 28800 0 CHOT}
- {2279642400 32400 1 CHOST}
- {2295356400 28800 0 CHOT}
- {2311092000 32400 1 CHOST}
- {2326806000 28800 0 CHOT}
- {2342541600 32400 1 CHOST}
- {2358255600 28800 0 CHOT}
- {2373991200 32400 1 CHOST}
- {2390310000 28800 0 CHOT}
- {2406045600 32400 1 CHOST}
- {2421759600 28800 0 CHOT}
- {2437495200 32400 1 CHOST}
- {2453209200 28800 0 CHOT}
- {2468944800 32400 1 CHOST}
- {2484658800 28800 0 CHOT}
- {2500394400 32400 1 CHOST}
- {2516108400 28800 0 CHOT}
- {2531844000 32400 1 CHOST}
- {2547558000 28800 0 CHOT}
- {2563293600 32400 1 CHOST}
- {2579612400 28800 0 CHOT}
- {2595348000 32400 1 CHOST}
- {2611062000 28800 0 CHOT}
- {2626797600 32400 1 CHOST}
- {2642511600 28800 0 CHOT}
- {2658247200 32400 1 CHOST}
- {2673961200 28800 0 CHOT}
- {2689696800 32400 1 CHOST}
- {2705410800 28800 0 CHOT}
- {2721146400 32400 1 CHOST}
- {2737465200 28800 0 CHOT}
- {2753200800 32400 1 CHOST}
- {2768914800 28800 0 CHOT}
- {2784650400 32400 1 CHOST}
- {2800364400 28800 0 CHOT}
- {2816100000 32400 1 CHOST}
- {2831814000 28800 0 CHOT}
- {2847549600 32400 1 CHOST}
- {2863263600 28800 0 CHOT}
- {2878999200 32400 1 CHOST}
- {2894713200 28800 0 CHOT}
- {2910448800 32400 1 CHOST}
- {2926767600 28800 0 CHOT}
- {2942503200 32400 1 CHOST}
- {2958217200 28800 0 CHOT}
- {2973952800 32400 1 CHOST}
- {2989666800 28800 0 CHOT}
- {3005402400 32400 1 CHOST}
- {3021116400 28800 0 CHOT}
- {3036852000 32400 1 CHOST}
- {3052566000 28800 0 CHOT}
- {3068301600 32400 1 CHOST}
- {3084015600 28800 0 CHOT}
- {3100356000 32400 1 CHOST}
- {3116070000 28800 0 CHOT}
- {3131805600 32400 1 CHOST}
- {3147519600 28800 0 CHOT}
- {3163255200 32400 1 CHOST}
- {3178969200 28800 0 CHOT}
- {3194704800 32400 1 CHOST}
- {3210418800 28800 0 CHOT}
- {3226154400 32400 1 CHOST}
- {3241868400 28800 0 CHOT}
- {3257604000 32400 1 CHOST}
- {3273922800 28800 0 CHOT}
- {3289658400 32400 1 CHOST}
- {3305372400 28800 0 CHOT}
- {3321108000 32400 1 CHOST}
- {3336822000 28800 0 CHOT}
- {3352557600 32400 1 CHOST}
- {3368271600 28800 0 CHOT}
- {3384007200 32400 1 CHOST}
- {3399721200 28800 0 CHOT}
- {3415456800 32400 1 CHOST}
- {3431170800 28800 0 CHOT}
- {3446906400 32400 1 CHOST}
- {3463225200 28800 0 CHOT}
- {3478960800 32400 1 CHOST}
- {3494674800 28800 0 CHOT}
- {3510410400 32400 1 CHOST}
- {3526124400 28800 0 CHOT}
- {3541860000 32400 1 CHOST}
- {3557574000 28800 0 CHOT}
- {3573309600 32400 1 CHOST}
- {3589023600 28800 0 CHOT}
- {3604759200 32400 1 CHOST}
- {3621078000 28800 0 CHOT}
- {3636813600 32400 1 CHOST}
- {3652527600 28800 0 CHOT}
- {3668263200 32400 1 CHOST}
- {3683977200 28800 0 CHOT}
- {3699712800 32400 1 CHOST}
- {3715426800 28800 0 CHOT}
- {3731162400 32400 1 CHOST}
- {3746876400 28800 0 CHOT}
- {3762612000 32400 1 CHOST}
- {3778326000 28800 0 CHOT}
- {3794061600 32400 1 CHOST}
- {3810380400 28800 0 CHOT}
- {3826116000 32400 1 CHOST}
- {3841830000 28800 0 CHOT}
- {3857565600 32400 1 CHOST}
- {3873279600 28800 0 CHOT}
- {3889015200 32400 1 CHOST}
- {3904729200 28800 0 CHOT}
- {3920464800 32400 1 CHOST}
- {3936178800 28800 0 CHOT}
- {3951914400 32400 1 CHOST}
- {3967628400 28800 0 CHOT}
- {3983968800 32400 1 CHOST}
- {3999682800 28800 0 CHOT}
- {4015418400 32400 1 CHOST}
- {4031132400 28800 0 CHOT}
- {4046868000 32400 1 CHOST}
- {4062582000 28800 0 CHOT}
- {4078317600 32400 1 CHOST}
- {4094031600 28800 0 CHOT}
+ {-2032933080 25200 0 +07}
+ {252435600 28800 0 +08}
+ {417974400 36000 0 +10}
+ {433778400 32400 0 +09}
+ {449593200 36000 1 +10}
+ {465314400 32400 0 +09}
+ {481042800 36000 1 +10}
+ {496764000 32400 0 +09}
+ {512492400 36000 1 +10}
+ {528213600 32400 0 +09}
+ {543942000 36000 1 +10}
+ {559663200 32400 0 +09}
+ {575391600 36000 1 +10}
+ {591112800 32400 0 +09}
+ {606841200 36000 1 +10}
+ {622562400 32400 0 +09}
+ {638290800 36000 1 +10}
+ {654616800 32400 0 +09}
+ {670345200 36000 1 +10}
+ {686066400 32400 0 +09}
+ {701794800 36000 1 +10}
+ {717516000 32400 0 +09}
+ {733244400 36000 1 +10}
+ {748965600 32400 0 +09}
+ {764694000 36000 1 +10}
+ {780415200 32400 0 +09}
+ {796143600 36000 1 +10}
+ {811864800 32400 0 +09}
+ {828198000 36000 1 +10}
+ {843919200 32400 0 +09}
+ {859647600 36000 1 +10}
+ {875368800 32400 0 +09}
+ {891097200 36000 1 +10}
+ {906818400 32400 0 +09}
+ {988390800 36000 1 +10}
+ {1001692800 32400 0 +09}
+ {1017421200 36000 1 +10}
+ {1033142400 32400 0 +09}
+ {1048870800 36000 1 +10}
+ {1064592000 32400 0 +09}
+ {1080320400 36000 1 +10}
+ {1096041600 32400 0 +09}
+ {1111770000 36000 1 +10}
+ {1127491200 32400 0 +09}
+ {1143219600 36000 1 +10}
+ {1159545600 32400 0 +09}
+ {1206889200 28800 0 +08}
+ {1427479200 32400 1 +09}
+ {1443193200 28800 0 +08}
+ {1458928800 32400 1 +09}
+ {1474642800 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Colombo b/library/tzdata/Asia/Colombo
index ca7bffc..7a14a9b 100644
--- a/library/tzdata/Asia/Colombo
+++ b/library/tzdata/Asia/Colombo
@@ -3,11 +3,11 @@
set TZData(:Asia/Colombo) {
{-9223372036854775808 19164 0 LMT}
{-2840159964 19172 0 MMT}
- {-2019705572 19800 0 IST}
- {-883287000 21600 1 IHST}
- {-862639200 23400 1 IST}
- {-764051400 19800 0 IST}
- {832962600 23400 0 LKT}
- {846266400 21600 0 LKT}
- {1145039400 19800 0 IST}
+ {-2019705572 19800 0 +0530}
+ {-883287000 21600 1 +06}
+ {-862639200 23400 1 +0630}
+ {-764051400 19800 0 +0530}
+ {832962600 23400 0 +0630}
+ {846266400 21600 0 +06}
+ {1145039400 19800 0 +0530}
}
diff --git a/library/tzdata/Asia/Dhaka b/library/tzdata/Asia/Dhaka
index 6e8a334..0dc3987 100644
--- a/library/tzdata/Asia/Dhaka
+++ b/library/tzdata/Asia/Dhaka
@@ -3,12 +3,11 @@
set TZData(:Asia/Dhaka) {
{-9223372036854775808 21700 0 LMT}
{-2524543300 21200 0 HMT}
- {-891582800 23400 0 BURT}
- {-872058600 19800 0 IST}
- {-862637400 23400 0 BURT}
- {-576138600 21600 0 DACT}
- {38772000 21600 0 BDT}
- {1230746400 21600 0 BDT}
- {1245430800 25200 1 BDST}
- {1262278800 21600 0 BDT}
+ {-891582800 23400 0 +0630}
+ {-872058600 19800 0 +0530}
+ {-862637400 23400 0 +0630}
+ {-576138600 21600 0 +06}
+ {1230746400 21600 0 +06}
+ {1245430800 25200 1 +07}
+ {1262278800 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Dili b/library/tzdata/Asia/Dili
index f783557..89cf22f 100644
--- a/library/tzdata/Asia/Dili
+++ b/library/tzdata/Asia/Dili
@@ -2,9 +2,8 @@
set TZData(:Asia/Dili) {
{-9223372036854775808 30140 0 LMT}
- {-1830414140 28800 0 TLT}
- {-879152400 32400 0 JST}
- {-766054800 32400 0 TLT}
- {199897200 28800 0 WITA}
- {969120000 32400 0 TLT}
+ {-1830414140 28800 0 +08}
+ {-879152400 32400 0 +09}
+ {199897200 28800 0 +08}
+ {969120000 32400 0 +09}
}
diff --git a/library/tzdata/Asia/Dubai b/library/tzdata/Asia/Dubai
index b8730e5..6c18e79 100644
--- a/library/tzdata/Asia/Dubai
+++ b/library/tzdata/Asia/Dubai
@@ -2,5 +2,5 @@
set TZData(:Asia/Dubai) {
{-9223372036854775808 13272 0 LMT}
- {-1577936472 14400 0 GST}
+ {-1577936472 14400 0 +04}
}
diff --git a/library/tzdata/Asia/Dushanbe b/library/tzdata/Asia/Dushanbe
index 59f8cb6..e9ed132 100644
--- a/library/tzdata/Asia/Dushanbe
+++ b/library/tzdata/Asia/Dushanbe
@@ -2,28 +2,28 @@
set TZData(:Asia/Dushanbe) {
{-9223372036854775808 16512 0 LMT}
- {-1441168512 18000 0 DUST}
- {-1247547600 21600 0 DUST}
- {354909600 25200 1 DUSST}
- {370717200 21600 0 DUST}
- {386445600 25200 1 DUSST}
- {402253200 21600 0 DUST}
- {417981600 25200 1 DUSST}
- {433789200 21600 0 DUST}
- {449604000 25200 1 DUSST}
- {465336000 21600 0 DUST}
- {481060800 25200 1 DUSST}
- {496785600 21600 0 DUST}
- {512510400 25200 1 DUSST}
- {528235200 21600 0 DUST}
- {543960000 25200 1 DUSST}
- {559684800 21600 0 DUST}
- {575409600 25200 1 DUSST}
- {591134400 21600 0 DUST}
- {606859200 25200 1 DUSST}
- {622584000 21600 0 DUST}
- {638308800 25200 1 DUSST}
- {654638400 21600 0 DUST}
- {670363200 21600 1 DUSST}
- {684363600 18000 0 TJT}
+ {-1441168512 18000 0 +05}
+ {-1247547600 21600 0 +06}
+ {354909600 25200 1 +07}
+ {370717200 21600 0 +06}
+ {386445600 25200 1 +07}
+ {402253200 21600 0 +06}
+ {417981600 25200 1 +07}
+ {433789200 21600 0 +06}
+ {449604000 25200 1 +07}
+ {465336000 21600 0 +06}
+ {481060800 25200 1 +07}
+ {496785600 21600 0 +06}
+ {512510400 25200 1 +07}
+ {528235200 21600 0 +06}
+ {543960000 25200 1 +07}
+ {559684800 21600 0 +06}
+ {575409600 25200 1 +07}
+ {591134400 21600 0 +06}
+ {606859200 25200 1 +07}
+ {622584000 21600 0 +06}
+ {638308800 25200 1 +07}
+ {654638400 21600 0 +06}
+ {670363200 21600 1 +06}
+ {684363600 18000 0 +05}
}
diff --git a/library/tzdata/Asia/Famagusta b/library/tzdata/Asia/Famagusta
new file mode 100644
index 0000000..384c183
--- /dev/null
+++ b/library/tzdata/Asia/Famagusta
@@ -0,0 +1,91 @@
+# created by tools/tclZIC.tcl - do not edit
+
+set TZData(:Asia/Famagusta) {
+ {-9223372036854775808 8148 0 LMT}
+ {-1518920148 7200 0 EET}
+ {166572000 10800 1 EEST}
+ {182293200 7200 0 EET}
+ {200959200 10800 1 EEST}
+ {213829200 7200 0 EET}
+ {228866400 10800 1 EEST}
+ {243982800 7200 0 EET}
+ {260316000 10800 1 EEST}
+ {276123600 7200 0 EET}
+ {291765600 10800 1 EEST}
+ {307486800 7200 0 EET}
+ {323820000 10800 1 EEST}
+ {338936400 7200 0 EET}
+ {354664800 10800 1 EEST}
+ {370386000 7200 0 EET}
+ {386114400 10800 1 EEST}
+ {401835600 7200 0 EET}
+ {417564000 10800 1 EEST}
+ {433285200 7200 0 EET}
+ {449013600 10800 1 EEST}
+ {465339600 7200 0 EET}
+ {481068000 10800 1 EEST}
+ {496789200 7200 0 EET}
+ {512517600 10800 1 EEST}
+ {528238800 7200 0 EET}
+ {543967200 10800 1 EEST}
+ {559688400 7200 0 EET}
+ {575416800 10800 1 EEST}
+ {591138000 7200 0 EET}
+ {606866400 10800 1 EEST}
+ {622587600 7200 0 EET}
+ {638316000 10800 1 EEST}
+ {654642000 7200 0 EET}
+ {670370400 10800 1 EEST}
+ {686091600 7200 0 EET}
+ {701820000 10800 1 EEST}
+ {717541200 7200 0 EET}
+ {733269600 10800 1 EEST}
+ {748990800 7200 0 EET}
+ {764719200 10800 1 EEST}
+ {780440400 7200 0 EET}
+ {796168800 10800 1 EEST}
+ {811890000 7200 0 EET}
+ {828223200 10800 1 EEST}
+ {843944400 7200 0 EET}
+ {859672800 10800 1 EEST}
+ {875394000 7200 0 EET}
+ {891122400 10800 1 EEST}
+ {904597200 10800 0 EEST}
+ {909277200 7200 0 EET}
+ {922582800 10800 1 EEST}
+ {941331600 7200 0 EET}
+ {954032400 10800 1 EEST}
+ {972781200 7200 0 EET}
+ {985482000 10800 1 EEST}
+ {1004230800 7200 0 EET}
+ {1017536400 10800 1 EEST}
+ {1035680400 7200 0 EET}
+ {1048986000 10800 1 EEST}
+ {1067130000 7200 0 EET}
+ {1080435600 10800 1 EEST}
+ {1099184400 7200 0 EET}
+ {1111885200 10800 1 EEST}
+ {1130634000 7200 0 EET}
+ {1143334800 10800 1 EEST}
+ {1162083600 7200 0 EET}
+ {1174784400 10800 1 EEST}
+ {1193533200 7200 0 EET}
+ {1206838800 10800 1 EEST}
+ {1224982800 7200 0 EET}
+ {1238288400 10800 1 EEST}
+ {1256432400 7200 0 EET}
+ {1269738000 10800 1 EEST}
+ {1288486800 7200 0 EET}
+ {1301187600 10800 1 EEST}
+ {1319936400 7200 0 EET}
+ {1332637200 10800 1 EEST}
+ {1351386000 7200 0 EET}
+ {1364691600 10800 1 EEST}
+ {1382835600 7200 0 EET}
+ {1396141200 10800 1 EEST}
+ {1414285200 7200 0 EET}
+ {1427590800 10800 1 EEST}
+ {1445734800 7200 0 EET}
+ {1459040400 10800 1 EEST}
+ {1473285600 10800 0 +03}
+}
diff --git a/library/tzdata/Asia/Gaza b/library/tzdata/Asia/Gaza
index 6adfe6d..1149d51 100644
--- a/library/tzdata/Asia/Gaza
+++ b/library/tzdata/Asia/Gaza
@@ -2,17 +2,17 @@
set TZData(:Asia/Gaza) {
{-9223372036854775808 8272 0 LMT}
- {-2185409872 7200 0 EET}
- {-933645600 10800 1 EET}
- {-857358000 7200 0 EET}
- {-844300800 10800 1 EET}
- {-825822000 7200 0 EET}
- {-812685600 10800 1 EET}
- {-794199600 7200 0 EET}
- {-779853600 10800 1 EET}
- {-762656400 7200 0 EET}
- {-748310400 10800 1 EET}
- {-731127600 7200 0 EET}
+ {-2185409872 7200 0 EEST}
+ {-933645600 10800 1 EEST}
+ {-857358000 7200 0 EEST}
+ {-844300800 10800 1 EEST}
+ {-825822000 7200 0 EEST}
+ {-812685600 10800 1 EEST}
+ {-794199600 7200 0 EEST}
+ {-779853600 10800 1 EEST}
+ {-762656400 7200 0 EEST}
+ {-748310400 10800 1 EEST}
+ {-731127600 7200 0 EEST}
{-682653600 7200 0 EET}
{-399088800 10800 1 EEST}
{-386650800 7200 0 EET}
@@ -108,171 +108,171 @@ set TZData(:Asia/Gaza) {
{1427493600 10800 1 EEST}
{1445547600 7200 0 EET}
{1458946800 10800 1 EEST}
- {1476997200 7200 0 EET}
+ {1477692000 7200 0 EET}
{1490396400 10800 1 EEST}
- {1509051600 7200 0 EET}
+ {1509141600 7200 0 EET}
{1522450800 10800 1 EEST}
- {1540501200 7200 0 EET}
+ {1540591200 7200 0 EET}
{1553900400 10800 1 EEST}
- {1571950800 7200 0 EET}
+ {1572040800 7200 0 EET}
{1585350000 10800 1 EEST}
- {1603400400 7200 0 EET}
+ {1604095200 7200 0 EET}
{1616799600 10800 1 EEST}
- {1634850000 7200 0 EET}
+ {1635544800 7200 0 EET}
{1648249200 10800 1 EEST}
- {1666299600 7200 0 EET}
+ {1666994400 7200 0 EET}
{1679698800 10800 1 EEST}
- {1698354000 7200 0 EET}
+ {1698444000 7200 0 EET}
{1711753200 10800 1 EEST}
- {1729803600 7200 0 EET}
+ {1729893600 7200 0 EET}
{1743202800 10800 1 EEST}
- {1761253200 7200 0 EET}
+ {1761343200 7200 0 EET}
{1774652400 10800 1 EEST}
- {1792702800 7200 0 EET}
+ {1793397600 7200 0 EET}
{1806102000 10800 1 EEST}
- {1824152400 7200 0 EET}
+ {1824847200 7200 0 EET}
{1837551600 10800 1 EEST}
- {1856206800 7200 0 EET}
+ {1856296800 7200 0 EET}
{1869606000 10800 1 EEST}
- {1887656400 7200 0 EET}
+ {1887746400 7200 0 EET}
{1901055600 10800 1 EEST}
- {1919106000 7200 0 EET}
+ {1919196000 7200 0 EET}
{1932505200 10800 1 EEST}
- {1950555600 7200 0 EET}
+ {1950645600 7200 0 EET}
{1963954800 10800 1 EEST}
- {1982005200 7200 0 EET}
+ {1982700000 7200 0 EET}
{1995404400 10800 1 EEST}
- {2013454800 7200 0 EET}
+ {2014149600 7200 0 EET}
{2026854000 10800 1 EEST}
- {2045509200 7200 0 EET}
+ {2045599200 7200 0 EET}
{2058908400 10800 1 EEST}
- {2076958800 7200 0 EET}
+ {2077048800 7200 0 EET}
{2090358000 10800 1 EEST}
- {2108408400 7200 0 EET}
+ {2108498400 7200 0 EET}
{2121807600 10800 1 EEST}
- {2139858000 7200 0 EET}
+ {2140552800 7200 0 EET}
{2153257200 10800 1 EEST}
- {2171307600 7200 0 EET}
+ {2172002400 7200 0 EET}
{2184706800 10800 1 EEST}
- {2202757200 7200 0 EET}
+ {2203452000 7200 0 EET}
{2216761200 10800 1 EEST}
- {2234811600 7200 0 EET}
+ {2234901600 7200 0 EET}
{2248210800 10800 1 EEST}
- {2266261200 7200 0 EET}
+ {2266351200 7200 0 EET}
{2279660400 10800 1 EEST}
- {2297710800 7200 0 EET}
+ {2297800800 7200 0 EET}
{2311110000 10800 1 EEST}
- {2329160400 7200 0 EET}
+ {2329855200 7200 0 EET}
{2342559600 10800 1 EEST}
- {2360610000 7200 0 EET}
+ {2361304800 7200 0 EET}
{2374009200 10800 1 EEST}
- {2392664400 7200 0 EET}
+ {2392754400 7200 0 EET}
{2406063600 10800 1 EEST}
- {2424114000 7200 0 EET}
+ {2424204000 7200 0 EET}
{2437513200 10800 1 EEST}
- {2455563600 7200 0 EET}
+ {2455653600 7200 0 EET}
{2468962800 10800 1 EEST}
- {2487013200 7200 0 EET}
+ {2487708000 7200 0 EET}
{2500412400 10800 1 EEST}
- {2518462800 7200 0 EET}
+ {2519157600 7200 0 EET}
{2531862000 10800 1 EEST}
- {2549912400 7200 0 EET}
+ {2550607200 7200 0 EET}
{2563311600 10800 1 EEST}
- {2581966800 7200 0 EET}
+ {2582056800 7200 0 EET}
{2595366000 10800 1 EEST}
- {2613416400 7200 0 EET}
+ {2613506400 7200 0 EET}
{2626815600 10800 1 EEST}
- {2644866000 7200 0 EET}
+ {2644956000 7200 0 EET}
{2658265200 10800 1 EEST}
- {2676315600 7200 0 EET}
+ {2677010400 7200 0 EET}
{2689714800 10800 1 EEST}
- {2707765200 7200 0 EET}
+ {2708460000 7200 0 EET}
{2721164400 10800 1 EEST}
- {2739819600 7200 0 EET}
+ {2739909600 7200 0 EET}
{2753218800 10800 1 EEST}
- {2771269200 7200 0 EET}
+ {2771359200 7200 0 EET}
{2784668400 10800 1 EEST}
- {2802718800 7200 0 EET}
+ {2802808800 7200 0 EET}
{2816118000 10800 1 EEST}
- {2834168400 7200 0 EET}
+ {2834258400 7200 0 EET}
{2847567600 10800 1 EEST}
- {2865618000 7200 0 EET}
+ {2866312800 7200 0 EET}
{2879017200 10800 1 EEST}
- {2897067600 7200 0 EET}
+ {2897762400 7200 0 EET}
{2910466800 10800 1 EEST}
- {2929122000 7200 0 EET}
+ {2929212000 7200 0 EET}
{2942521200 10800 1 EEST}
- {2960571600 7200 0 EET}
+ {2960661600 7200 0 EET}
{2973970800 10800 1 EEST}
- {2992021200 7200 0 EET}
+ {2992111200 7200 0 EET}
{3005420400 10800 1 EEST}
- {3023470800 7200 0 EET}
+ {3024165600 7200 0 EET}
{3036870000 10800 1 EEST}
- {3054920400 7200 0 EET}
+ {3055615200 7200 0 EET}
{3068319600 10800 1 EEST}
- {3086370000 7200 0 EET}
+ {3087064800 7200 0 EET}
{3100374000 10800 1 EEST}
- {3118424400 7200 0 EET}
+ {3118514400 7200 0 EET}
{3131823600 10800 1 EEST}
- {3149874000 7200 0 EET}
+ {3149964000 7200 0 EET}
{3163273200 10800 1 EEST}
- {3181323600 7200 0 EET}
+ {3181413600 7200 0 EET}
{3194722800 10800 1 EEST}
- {3212773200 7200 0 EET}
+ {3213468000 7200 0 EET}
{3226172400 10800 1 EEST}
- {3244222800 7200 0 EET}
+ {3244917600 7200 0 EET}
{3257622000 10800 1 EEST}
- {3276277200 7200 0 EET}
+ {3276367200 7200 0 EET}
{3289676400 10800 1 EEST}
- {3307726800 7200 0 EET}
+ {3307816800 7200 0 EET}
{3321126000 10800 1 EEST}
- {3339176400 7200 0 EET}
+ {3339266400 7200 0 EET}
{3352575600 10800 1 EEST}
- {3370626000 7200 0 EET}
+ {3371320800 7200 0 EET}
{3384025200 10800 1 EEST}
- {3402075600 7200 0 EET}
+ {3402770400 7200 0 EET}
{3415474800 10800 1 EEST}
- {3433525200 7200 0 EET}
+ {3434220000 7200 0 EET}
{3446924400 10800 1 EEST}
- {3465579600 7200 0 EET}
+ {3465669600 7200 0 EET}
{3478978800 10800 1 EEST}
- {3497029200 7200 0 EET}
+ {3497119200 7200 0 EET}
{3510428400 10800 1 EEST}
- {3528478800 7200 0 EET}
+ {3528568800 7200 0 EET}
{3541878000 10800 1 EEST}
- {3559928400 7200 0 EET}
+ {3560623200 7200 0 EET}
{3573327600 10800 1 EEST}
- {3591378000 7200 0 EET}
+ {3592072800 7200 0 EET}
{3604777200 10800 1 EEST}
- {3623432400 7200 0 EET}
+ {3623522400 7200 0 EET}
{3636831600 10800 1 EEST}
- {3654882000 7200 0 EET}
+ {3654972000 7200 0 EET}
{3668281200 10800 1 EEST}
- {3686331600 7200 0 EET}
+ {3686421600 7200 0 EET}
{3699730800 10800 1 EEST}
- {3717781200 7200 0 EET}
+ {3717871200 7200 0 EET}
{3731180400 10800 1 EEST}
- {3749230800 7200 0 EET}
+ {3749925600 7200 0 EET}
{3762630000 10800 1 EEST}
- {3780680400 7200 0 EET}
+ {3781375200 7200 0 EET}
{3794079600 10800 1 EEST}
- {3812734800 7200 0 EET}
+ {3812824800 7200 0 EET}
{3826134000 10800 1 EEST}
- {3844184400 7200 0 EET}
+ {3844274400 7200 0 EET}
{3857583600 10800 1 EEST}
- {3875634000 7200 0 EET}
+ {3875724000 7200 0 EET}
{3889033200 10800 1 EEST}
- {3907083600 7200 0 EET}
+ {3907778400 7200 0 EET}
{3920482800 10800 1 EEST}
- {3938533200 7200 0 EET}
+ {3939228000 7200 0 EET}
{3951932400 10800 1 EEST}
- {3969982800 7200 0 EET}
+ {3970677600 7200 0 EET}
{3983986800 10800 1 EEST}
- {4002037200 7200 0 EET}
+ {4002127200 7200 0 EET}
{4015436400 10800 1 EEST}
- {4033486800 7200 0 EET}
+ {4033576800 7200 0 EET}
{4046886000 10800 1 EEST}
- {4064936400 7200 0 EET}
+ {4065026400 7200 0 EET}
{4078335600 10800 1 EEST}
- {4096386000 7200 0 EET}
+ {4097080800 7200 0 EET}
}
diff --git a/library/tzdata/Asia/Hebron b/library/tzdata/Asia/Hebron
index 2db45f2..5d312b8 100644
--- a/library/tzdata/Asia/Hebron
+++ b/library/tzdata/Asia/Hebron
@@ -2,17 +2,17 @@
set TZData(:Asia/Hebron) {
{-9223372036854775808 8423 0 LMT}
- {-2185410023 7200 0 EET}
- {-933645600 10800 1 EET}
- {-857358000 7200 0 EET}
- {-844300800 10800 1 EET}
- {-825822000 7200 0 EET}
- {-812685600 10800 1 EET}
- {-794199600 7200 0 EET}
- {-779853600 10800 1 EET}
- {-762656400 7200 0 EET}
- {-748310400 10800 1 EET}
- {-731127600 7200 0 EET}
+ {-2185410023 7200 0 EEST}
+ {-933645600 10800 1 EEST}
+ {-857358000 7200 0 EEST}
+ {-844300800 10800 1 EEST}
+ {-825822000 7200 0 EEST}
+ {-812685600 10800 1 EEST}
+ {-794199600 7200 0 EEST}
+ {-779853600 10800 1 EEST}
+ {-762656400 7200 0 EEST}
+ {-748310400 10800 1 EEST}
+ {-731127600 7200 0 EEST}
{-682653600 7200 0 EET}
{-399088800 10800 1 EEST}
{-386650800 7200 0 EET}
@@ -107,171 +107,171 @@ set TZData(:Asia/Hebron) {
{1427493600 10800 1 EEST}
{1445547600 7200 0 EET}
{1458946800 10800 1 EEST}
- {1476997200 7200 0 EET}
+ {1477692000 7200 0 EET}
{1490396400 10800 1 EEST}
- {1509051600 7200 0 EET}
+ {1509141600 7200 0 EET}
{1522450800 10800 1 EEST}
- {1540501200 7200 0 EET}
+ {1540591200 7200 0 EET}
{1553900400 10800 1 EEST}
- {1571950800 7200 0 EET}
+ {1572040800 7200 0 EET}
{1585350000 10800 1 EEST}
- {1603400400 7200 0 EET}
+ {1604095200 7200 0 EET}
{1616799600 10800 1 EEST}
- {1634850000 7200 0 EET}
+ {1635544800 7200 0 EET}
{1648249200 10800 1 EEST}
- {1666299600 7200 0 EET}
+ {1666994400 7200 0 EET}
{1679698800 10800 1 EEST}
- {1698354000 7200 0 EET}
+ {1698444000 7200 0 EET}
{1711753200 10800 1 EEST}
- {1729803600 7200 0 EET}
+ {1729893600 7200 0 EET}
{1743202800 10800 1 EEST}
- {1761253200 7200 0 EET}
+ {1761343200 7200 0 EET}
{1774652400 10800 1 EEST}
- {1792702800 7200 0 EET}
+ {1793397600 7200 0 EET}
{1806102000 10800 1 EEST}
- {1824152400 7200 0 EET}
+ {1824847200 7200 0 EET}
{1837551600 10800 1 EEST}
- {1856206800 7200 0 EET}
+ {1856296800 7200 0 EET}
{1869606000 10800 1 EEST}
- {1887656400 7200 0 EET}
+ {1887746400 7200 0 EET}
{1901055600 10800 1 EEST}
- {1919106000 7200 0 EET}
+ {1919196000 7200 0 EET}
{1932505200 10800 1 EEST}
- {1950555600 7200 0 EET}
+ {1950645600 7200 0 EET}
{1963954800 10800 1 EEST}
- {1982005200 7200 0 EET}
+ {1982700000 7200 0 EET}
{1995404400 10800 1 EEST}
- {2013454800 7200 0 EET}
+ {2014149600 7200 0 EET}
{2026854000 10800 1 EEST}
- {2045509200 7200 0 EET}
+ {2045599200 7200 0 EET}
{2058908400 10800 1 EEST}
- {2076958800 7200 0 EET}
+ {2077048800 7200 0 EET}
{2090358000 10800 1 EEST}
- {2108408400 7200 0 EET}
+ {2108498400 7200 0 EET}
{2121807600 10800 1 EEST}
- {2139858000 7200 0 EET}
+ {2140552800 7200 0 EET}
{2153257200 10800 1 EEST}
- {2171307600 7200 0 EET}
+ {2172002400 7200 0 EET}
{2184706800 10800 1 EEST}
- {2202757200 7200 0 EET}
+ {2203452000 7200 0 EET}
{2216761200 10800 1 EEST}
- {2234811600 7200 0 EET}
+ {2234901600 7200 0 EET}
{2248210800 10800 1 EEST}
- {2266261200 7200 0 EET}
+ {2266351200 7200 0 EET}
{2279660400 10800 1 EEST}
- {2297710800 7200 0 EET}
+ {2297800800 7200 0 EET}
{2311110000 10800 1 EEST}
- {2329160400 7200 0 EET}
+ {2329855200 7200 0 EET}
{2342559600 10800 1 EEST}
- {2360610000 7200 0 EET}
+ {2361304800 7200 0 EET}
{2374009200 10800 1 EEST}
- {2392664400 7200 0 EET}
+ {2392754400 7200 0 EET}
{2406063600 10800 1 EEST}
- {2424114000 7200 0 EET}
+ {2424204000 7200 0 EET}
{2437513200 10800 1 EEST}
- {2455563600 7200 0 EET}
+ {2455653600 7200 0 EET}
{2468962800 10800 1 EEST}
- {2487013200 7200 0 EET}
+ {2487708000 7200 0 EET}
{2500412400 10800 1 EEST}
- {2518462800 7200 0 EET}
+ {2519157600 7200 0 EET}
{2531862000 10800 1 EEST}
- {2549912400 7200 0 EET}
+ {2550607200 7200 0 EET}
{2563311600 10800 1 EEST}
- {2581966800 7200 0 EET}
+ {2582056800 7200 0 EET}
{2595366000 10800 1 EEST}
- {2613416400 7200 0 EET}
+ {2613506400 7200 0 EET}
{2626815600 10800 1 EEST}
- {2644866000 7200 0 EET}
+ {2644956000 7200 0 EET}
{2658265200 10800 1 EEST}
- {2676315600 7200 0 EET}
+ {2677010400 7200 0 EET}
{2689714800 10800 1 EEST}
- {2707765200 7200 0 EET}
+ {2708460000 7200 0 EET}
{2721164400 10800 1 EEST}
- {2739819600 7200 0 EET}
+ {2739909600 7200 0 EET}
{2753218800 10800 1 EEST}
- {2771269200 7200 0 EET}
+ {2771359200 7200 0 EET}
{2784668400 10800 1 EEST}
- {2802718800 7200 0 EET}
+ {2802808800 7200 0 EET}
{2816118000 10800 1 EEST}
- {2834168400 7200 0 EET}
+ {2834258400 7200 0 EET}
{2847567600 10800 1 EEST}
- {2865618000 7200 0 EET}
+ {2866312800 7200 0 EET}
{2879017200 10800 1 EEST}
- {2897067600 7200 0 EET}
+ {2897762400 7200 0 EET}
{2910466800 10800 1 EEST}
- {2929122000 7200 0 EET}
+ {2929212000 7200 0 EET}
{2942521200 10800 1 EEST}
- {2960571600 7200 0 EET}
+ {2960661600 7200 0 EET}
{2973970800 10800 1 EEST}
- {2992021200 7200 0 EET}
+ {2992111200 7200 0 EET}
{3005420400 10800 1 EEST}
- {3023470800 7200 0 EET}
+ {3024165600 7200 0 EET}
{3036870000 10800 1 EEST}
- {3054920400 7200 0 EET}
+ {3055615200 7200 0 EET}
{3068319600 10800 1 EEST}
- {3086370000 7200 0 EET}
+ {3087064800 7200 0 EET}
{3100374000 10800 1 EEST}
- {3118424400 7200 0 EET}
+ {3118514400 7200 0 EET}
{3131823600 10800 1 EEST}
- {3149874000 7200 0 EET}
+ {3149964000 7200 0 EET}
{3163273200 10800 1 EEST}
- {3181323600 7200 0 EET}
+ {3181413600 7200 0 EET}
{3194722800 10800 1 EEST}
- {3212773200 7200 0 EET}
+ {3213468000 7200 0 EET}
{3226172400 10800 1 EEST}
- {3244222800 7200 0 EET}
+ {3244917600 7200 0 EET}
{3257622000 10800 1 EEST}
- {3276277200 7200 0 EET}
+ {3276367200 7200 0 EET}
{3289676400 10800 1 EEST}
- {3307726800 7200 0 EET}
+ {3307816800 7200 0 EET}
{3321126000 10800 1 EEST}
- {3339176400 7200 0 EET}
+ {3339266400 7200 0 EET}
{3352575600 10800 1 EEST}
- {3370626000 7200 0 EET}
+ {3371320800 7200 0 EET}
{3384025200 10800 1 EEST}
- {3402075600 7200 0 EET}
+ {3402770400 7200 0 EET}
{3415474800 10800 1 EEST}
- {3433525200 7200 0 EET}
+ {3434220000 7200 0 EET}
{3446924400 10800 1 EEST}
- {3465579600 7200 0 EET}
+ {3465669600 7200 0 EET}
{3478978800 10800 1 EEST}
- {3497029200 7200 0 EET}
+ {3497119200 7200 0 EET}
{3510428400 10800 1 EEST}
- {3528478800 7200 0 EET}
+ {3528568800 7200 0 EET}
{3541878000 10800 1 EEST}
- {3559928400 7200 0 EET}
+ {3560623200 7200 0 EET}
{3573327600 10800 1 EEST}
- {3591378000 7200 0 EET}
+ {3592072800 7200 0 EET}
{3604777200 10800 1 EEST}
- {3623432400 7200 0 EET}
+ {3623522400 7200 0 EET}
{3636831600 10800 1 EEST}
- {3654882000 7200 0 EET}
+ {3654972000 7200 0 EET}
{3668281200 10800 1 EEST}
- {3686331600 7200 0 EET}
+ {3686421600 7200 0 EET}
{3699730800 10800 1 EEST}
- {3717781200 7200 0 EET}
+ {3717871200 7200 0 EET}
{3731180400 10800 1 EEST}
- {3749230800 7200 0 EET}
+ {3749925600 7200 0 EET}
{3762630000 10800 1 EEST}
- {3780680400 7200 0 EET}
+ {3781375200 7200 0 EET}
{3794079600 10800 1 EEST}
- {3812734800 7200 0 EET}
+ {3812824800 7200 0 EET}
{3826134000 10800 1 EEST}
- {3844184400 7200 0 EET}
+ {3844274400 7200 0 EET}
{3857583600 10800 1 EEST}
- {3875634000 7200 0 EET}
+ {3875724000 7200 0 EET}
{3889033200 10800 1 EEST}
- {3907083600 7200 0 EET}
+ {3907778400 7200 0 EET}
{3920482800 10800 1 EEST}
- {3938533200 7200 0 EET}
+ {3939228000 7200 0 EET}
{3951932400 10800 1 EEST}
- {3969982800 7200 0 EET}
+ {3970677600 7200 0 EET}
{3983986800 10800 1 EEST}
- {4002037200 7200 0 EET}
+ {4002127200 7200 0 EET}
{4015436400 10800 1 EEST}
- {4033486800 7200 0 EET}
+ {4033576800 7200 0 EET}
{4046886000 10800 1 EEST}
- {4064936400 7200 0 EET}
+ {4065026400 7200 0 EET}
{4078335600 10800 1 EEST}
- {4096386000 7200 0 EET}
+ {4097080800 7200 0 EET}
}
diff --git a/library/tzdata/Asia/Ho_Chi_Minh b/library/tzdata/Asia/Ho_Chi_Minh
index 9da89f4..b4e749b 100644
--- a/library/tzdata/Asia/Ho_Chi_Minh
+++ b/library/tzdata/Asia/Ho_Chi_Minh
@@ -3,12 +3,12 @@
set TZData(:Asia/Ho_Chi_Minh) {
{-9223372036854775808 25600 0 LMT}
{-2004073600 25590 0 PLMT}
- {-1851577590 25200 0 ICT}
- {-852105600 28800 0 IDT}
- {-782643600 32400 0 JST}
- {-767869200 25200 0 ICT}
- {-718095600 28800 0 IDT}
- {-457776000 25200 0 ICT}
- {-315648000 28800 0 IDT}
- {171820800 25200 0 ICT}
+ {-1851577590 25200 0 +07}
+ {-852105600 28800 0 +08}
+ {-782643600 32400 0 +09}
+ {-767869200 25200 0 +07}
+ {-718095600 28800 0 +08}
+ {-457776000 25200 0 +07}
+ {-315648000 28800 0 +08}
+ {171820800 25200 0 +07}
}
diff --git a/library/tzdata/Asia/Hovd b/library/tzdata/Asia/Hovd
index 3d200a6..a9c995b 100644
--- a/library/tzdata/Asia/Hovd
+++ b/library/tzdata/Asia/Hovd
@@ -2,220 +2,54 @@
set TZData(:Asia/Hovd) {
{-9223372036854775808 21996 0 LMT}
- {-2032927596 21600 0 HOVT}
- {252439200 25200 0 HOVT}
- {417978000 28800 1 HOVST}
- {433785600 25200 0 HOVT}
- {449600400 28800 1 HOVST}
- {465321600 25200 0 HOVT}
- {481050000 28800 1 HOVST}
- {496771200 25200 0 HOVT}
- {512499600 28800 1 HOVST}
- {528220800 25200 0 HOVT}
- {543949200 28800 1 HOVST}
- {559670400 25200 0 HOVT}
- {575398800 28800 1 HOVST}
- {591120000 25200 0 HOVT}
- {606848400 28800 1 HOVST}
- {622569600 25200 0 HOVT}
- {638298000 28800 1 HOVST}
- {654624000 25200 0 HOVT}
- {670352400 28800 1 HOVST}
- {686073600 25200 0 HOVT}
- {701802000 28800 1 HOVST}
- {717523200 25200 0 HOVT}
- {733251600 28800 1 HOVST}
- {748972800 25200 0 HOVT}
- {764701200 28800 1 HOVST}
- {780422400 25200 0 HOVT}
- {796150800 28800 1 HOVST}
- {811872000 25200 0 HOVT}
- {828205200 28800 1 HOVST}
- {843926400 25200 0 HOVT}
- {859654800 28800 1 HOVST}
- {875376000 25200 0 HOVT}
- {891104400 28800 1 HOVST}
- {906825600 25200 0 HOVT}
- {988398000 28800 1 HOVST}
- {1001700000 25200 0 HOVT}
- {1017428400 28800 1 HOVST}
- {1033149600 25200 0 HOVT}
- {1048878000 28800 1 HOVST}
- {1064599200 25200 0 HOVT}
- {1080327600 28800 1 HOVST}
- {1096048800 25200 0 HOVT}
- {1111777200 28800 1 HOVST}
- {1127498400 25200 0 HOVT}
- {1143226800 28800 1 HOVST}
- {1159552800 25200 0 HOVT}
- {1427482800 28800 1 HOVST}
- {1443196800 25200 0 HOVT}
- {1458932400 28800 1 HOVST}
- {1474646400 25200 0 HOVT}
- {1490382000 28800 1 HOVST}
- {1506700800 25200 0 HOVT}
- {1522436400 28800 1 HOVST}
- {1538150400 25200 0 HOVT}
- {1553886000 28800 1 HOVST}
- {1569600000 25200 0 HOVT}
- {1585335600 28800 1 HOVST}
- {1601049600 25200 0 HOVT}
- {1616785200 28800 1 HOVST}
- {1632499200 25200 0 HOVT}
- {1648234800 28800 1 HOVST}
- {1663948800 25200 0 HOVT}
- {1679684400 28800 1 HOVST}
- {1696003200 25200 0 HOVT}
- {1711738800 28800 1 HOVST}
- {1727452800 25200 0 HOVT}
- {1743188400 28800 1 HOVST}
- {1758902400 25200 0 HOVT}
- {1774638000 28800 1 HOVST}
- {1790352000 25200 0 HOVT}
- {1806087600 28800 1 HOVST}
- {1821801600 25200 0 HOVT}
- {1837537200 28800 1 HOVST}
- {1853856000 25200 0 HOVT}
- {1869591600 28800 1 HOVST}
- {1885305600 25200 0 HOVT}
- {1901041200 28800 1 HOVST}
- {1916755200 25200 0 HOVT}
- {1932490800 28800 1 HOVST}
- {1948204800 25200 0 HOVT}
- {1963940400 28800 1 HOVST}
- {1979654400 25200 0 HOVT}
- {1995390000 28800 1 HOVST}
- {2011104000 25200 0 HOVT}
- {2026839600 28800 1 HOVST}
- {2043158400 25200 0 HOVT}
- {2058894000 28800 1 HOVST}
- {2074608000 25200 0 HOVT}
- {2090343600 28800 1 HOVST}
- {2106057600 25200 0 HOVT}
- {2121793200 28800 1 HOVST}
- {2137507200 25200 0 HOVT}
- {2153242800 28800 1 HOVST}
- {2168956800 25200 0 HOVT}
- {2184692400 28800 1 HOVST}
- {2200406400 25200 0 HOVT}
- {2216746800 28800 1 HOVST}
- {2232460800 25200 0 HOVT}
- {2248196400 28800 1 HOVST}
- {2263910400 25200 0 HOVT}
- {2279646000 28800 1 HOVST}
- {2295360000 25200 0 HOVT}
- {2311095600 28800 1 HOVST}
- {2326809600 25200 0 HOVT}
- {2342545200 28800 1 HOVST}
- {2358259200 25200 0 HOVT}
- {2373994800 28800 1 HOVST}
- {2390313600 25200 0 HOVT}
- {2406049200 28800 1 HOVST}
- {2421763200 25200 0 HOVT}
- {2437498800 28800 1 HOVST}
- {2453212800 25200 0 HOVT}
- {2468948400 28800 1 HOVST}
- {2484662400 25200 0 HOVT}
- {2500398000 28800 1 HOVST}
- {2516112000 25200 0 HOVT}
- {2531847600 28800 1 HOVST}
- {2547561600 25200 0 HOVT}
- {2563297200 28800 1 HOVST}
- {2579616000 25200 0 HOVT}
- {2595351600 28800 1 HOVST}
- {2611065600 25200 0 HOVT}
- {2626801200 28800 1 HOVST}
- {2642515200 25200 0 HOVT}
- {2658250800 28800 1 HOVST}
- {2673964800 25200 0 HOVT}
- {2689700400 28800 1 HOVST}
- {2705414400 25200 0 HOVT}
- {2721150000 28800 1 HOVST}
- {2737468800 25200 0 HOVT}
- {2753204400 28800 1 HOVST}
- {2768918400 25200 0 HOVT}
- {2784654000 28800 1 HOVST}
- {2800368000 25200 0 HOVT}
- {2816103600 28800 1 HOVST}
- {2831817600 25200 0 HOVT}
- {2847553200 28800 1 HOVST}
- {2863267200 25200 0 HOVT}
- {2879002800 28800 1 HOVST}
- {2894716800 25200 0 HOVT}
- {2910452400 28800 1 HOVST}
- {2926771200 25200 0 HOVT}
- {2942506800 28800 1 HOVST}
- {2958220800 25200 0 HOVT}
- {2973956400 28800 1 HOVST}
- {2989670400 25200 0 HOVT}
- {3005406000 28800 1 HOVST}
- {3021120000 25200 0 HOVT}
- {3036855600 28800 1 HOVST}
- {3052569600 25200 0 HOVT}
- {3068305200 28800 1 HOVST}
- {3084019200 25200 0 HOVT}
- {3100359600 28800 1 HOVST}
- {3116073600 25200 0 HOVT}
- {3131809200 28800 1 HOVST}
- {3147523200 25200 0 HOVT}
- {3163258800 28800 1 HOVST}
- {3178972800 25200 0 HOVT}
- {3194708400 28800 1 HOVST}
- {3210422400 25200 0 HOVT}
- {3226158000 28800 1 HOVST}
- {3241872000 25200 0 HOVT}
- {3257607600 28800 1 HOVST}
- {3273926400 25200 0 HOVT}
- {3289662000 28800 1 HOVST}
- {3305376000 25200 0 HOVT}
- {3321111600 28800 1 HOVST}
- {3336825600 25200 0 HOVT}
- {3352561200 28800 1 HOVST}
- {3368275200 25200 0 HOVT}
- {3384010800 28800 1 HOVST}
- {3399724800 25200 0 HOVT}
- {3415460400 28800 1 HOVST}
- {3431174400 25200 0 HOVT}
- {3446910000 28800 1 HOVST}
- {3463228800 25200 0 HOVT}
- {3478964400 28800 1 HOVST}
- {3494678400 25200 0 HOVT}
- {3510414000 28800 1 HOVST}
- {3526128000 25200 0 HOVT}
- {3541863600 28800 1 HOVST}
- {3557577600 25200 0 HOVT}
- {3573313200 28800 1 HOVST}
- {3589027200 25200 0 HOVT}
- {3604762800 28800 1 HOVST}
- {3621081600 25200 0 HOVT}
- {3636817200 28800 1 HOVST}
- {3652531200 25200 0 HOVT}
- {3668266800 28800 1 HOVST}
- {3683980800 25200 0 HOVT}
- {3699716400 28800 1 HOVST}
- {3715430400 25200 0 HOVT}
- {3731166000 28800 1 HOVST}
- {3746880000 25200 0 HOVT}
- {3762615600 28800 1 HOVST}
- {3778329600 25200 0 HOVT}
- {3794065200 28800 1 HOVST}
- {3810384000 25200 0 HOVT}
- {3826119600 28800 1 HOVST}
- {3841833600 25200 0 HOVT}
- {3857569200 28800 1 HOVST}
- {3873283200 25200 0 HOVT}
- {3889018800 28800 1 HOVST}
- {3904732800 25200 0 HOVT}
- {3920468400 28800 1 HOVST}
- {3936182400 25200 0 HOVT}
- {3951918000 28800 1 HOVST}
- {3967632000 25200 0 HOVT}
- {3983972400 28800 1 HOVST}
- {3999686400 25200 0 HOVT}
- {4015422000 28800 1 HOVST}
- {4031136000 25200 0 HOVT}
- {4046871600 28800 1 HOVST}
- {4062585600 25200 0 HOVT}
- {4078321200 28800 1 HOVST}
- {4094035200 25200 0 HOVT}
+ {-2032927596 21600 0 +06}
+ {252439200 25200 0 +07}
+ {417978000 28800 1 +08}
+ {433785600 25200 0 +07}
+ {449600400 28800 1 +08}
+ {465321600 25200 0 +07}
+ {481050000 28800 1 +08}
+ {496771200 25200 0 +07}
+ {512499600 28800 1 +08}
+ {528220800 25200 0 +07}
+ {543949200 28800 1 +08}
+ {559670400 25200 0 +07}
+ {575398800 28800 1 +08}
+ {591120000 25200 0 +07}
+ {606848400 28800 1 +08}
+ {622569600 25200 0 +07}
+ {638298000 28800 1 +08}
+ {654624000 25200 0 +07}
+ {670352400 28800 1 +08}
+ {686073600 25200 0 +07}
+ {701802000 28800 1 +08}
+ {717523200 25200 0 +07}
+ {733251600 28800 1 +08}
+ {748972800 25200 0 +07}
+ {764701200 28800 1 +08}
+ {780422400 25200 0 +07}
+ {796150800 28800 1 +08}
+ {811872000 25200 0 +07}
+ {828205200 28800 1 +08}
+ {843926400 25200 0 +07}
+ {859654800 28800 1 +08}
+ {875376000 25200 0 +07}
+ {891104400 28800 1 +08}
+ {906825600 25200 0 +07}
+ {988398000 28800 1 +08}
+ {1001700000 25200 0 +07}
+ {1017428400 28800 1 +08}
+ {1033149600 25200 0 +07}
+ {1048878000 28800 1 +08}
+ {1064599200 25200 0 +07}
+ {1080327600 28800 1 +08}
+ {1096048800 25200 0 +07}
+ {1111777200 28800 1 +08}
+ {1127498400 25200 0 +07}
+ {1143226800 28800 1 +08}
+ {1159552800 25200 0 +07}
+ {1427482800 28800 1 +08}
+ {1443196800 25200 0 +07}
+ {1458932400 28800 1 +08}
+ {1474646400 25200 0 +07}
}
diff --git a/library/tzdata/Asia/Irkutsk b/library/tzdata/Asia/Irkutsk
index ebe00c3..9666969 100644
--- a/library/tzdata/Asia/Irkutsk
+++ b/library/tzdata/Asia/Irkutsk
@@ -3,70 +3,70 @@
set TZData(:Asia/Irkutsk) {
{-9223372036854775808 25025 0 LMT}
{-2840165825 25025 0 IMT}
- {-1575874625 25200 0 IRKT}
- {-1247554800 28800 0 IRKMMTT}
- {354902400 32400 1 IRKST}
- {370710000 28800 0 IRKT}
- {386438400 32400 1 IRKST}
- {402246000 28800 0 IRKT}
- {417974400 32400 1 IRKST}
- {433782000 28800 0 IRKT}
- {449596800 32400 1 IRKST}
- {465328800 28800 0 IRKT}
- {481053600 32400 1 IRKST}
- {496778400 28800 0 IRKT}
- {512503200 32400 1 IRKST}
- {528228000 28800 0 IRKT}
- {543952800 32400 1 IRKST}
- {559677600 28800 0 IRKT}
- {575402400 32400 1 IRKST}
- {591127200 28800 0 IRKT}
- {606852000 32400 1 IRKST}
- {622576800 28800 0 IRKT}
- {638301600 32400 1 IRKST}
- {654631200 28800 0 IRKT}
- {670356000 25200 0 IRKMMTT}
- {670359600 28800 1 IRKST}
- {686084400 25200 0 IRKT}
- {695761200 28800 0 IRKMMTT}
- {701805600 32400 1 IRKST}
- {717530400 28800 0 IRKT}
- {733255200 32400 1 IRKST}
- {748980000 28800 0 IRKT}
- {764704800 32400 1 IRKST}
- {780429600 28800 0 IRKT}
- {796154400 32400 1 IRKST}
- {811879200 28800 0 IRKT}
- {828208800 32400 1 IRKST}
- {846352800 28800 0 IRKT}
- {859658400 32400 1 IRKST}
- {877802400 28800 0 IRKT}
- {891108000 32400 1 IRKST}
- {909252000 28800 0 IRKT}
- {922557600 32400 1 IRKST}
- {941306400 28800 0 IRKT}
- {954007200 32400 1 IRKST}
- {972756000 28800 0 IRKT}
- {985456800 32400 1 IRKST}
- {1004205600 28800 0 IRKT}
- {1017511200 32400 1 IRKST}
- {1035655200 28800 0 IRKT}
- {1048960800 32400 1 IRKST}
- {1067104800 28800 0 IRKT}
- {1080410400 32400 1 IRKST}
- {1099159200 28800 0 IRKT}
- {1111860000 32400 1 IRKST}
- {1130608800 28800 0 IRKT}
- {1143309600 32400 1 IRKST}
- {1162058400 28800 0 IRKT}
- {1174759200 32400 1 IRKST}
- {1193508000 28800 0 IRKT}
- {1206813600 32400 1 IRKST}
- {1224957600 28800 0 IRKT}
- {1238263200 32400 1 IRKST}
- {1256407200 28800 0 IRKT}
- {1269712800 32400 1 IRKST}
- {1288461600 28800 0 IRKT}
- {1301162400 32400 0 IRKT}
- {1414256400 28800 0 IRKT}
+ {-1575874625 25200 0 +07}
+ {-1247554800 28800 0 +09}
+ {354902400 32400 1 +09}
+ {370710000 28800 0 +08}
+ {386438400 32400 1 +09}
+ {402246000 28800 0 +08}
+ {417974400 32400 1 +09}
+ {433782000 28800 0 +08}
+ {449596800 32400 1 +09}
+ {465328800 28800 0 +08}
+ {481053600 32400 1 +09}
+ {496778400 28800 0 +08}
+ {512503200 32400 1 +09}
+ {528228000 28800 0 +08}
+ {543952800 32400 1 +09}
+ {559677600 28800 0 +08}
+ {575402400 32400 1 +09}
+ {591127200 28800 0 +08}
+ {606852000 32400 1 +09}
+ {622576800 28800 0 +08}
+ {638301600 32400 1 +09}
+ {654631200 28800 0 +08}
+ {670356000 25200 0 +08}
+ {670359600 28800 1 +08}
+ {686084400 25200 0 +07}
+ {695761200 28800 0 +09}
+ {701805600 32400 1 +09}
+ {717530400 28800 0 +08}
+ {733255200 32400 1 +09}
+ {748980000 28800 0 +08}
+ {764704800 32400 1 +09}
+ {780429600 28800 0 +08}
+ {796154400 32400 1 +09}
+ {811879200 28800 0 +08}
+ {828208800 32400 1 +09}
+ {846352800 28800 0 +08}
+ {859658400 32400 1 +09}
+ {877802400 28800 0 +08}
+ {891108000 32400 1 +09}
+ {909252000 28800 0 +08}
+ {922557600 32400 1 +09}
+ {941306400 28800 0 +08}
+ {954007200 32400 1 +09}
+ {972756000 28800 0 +08}
+ {985456800 32400 1 +09}
+ {1004205600 28800 0 +08}
+ {1017511200 32400 1 +09}
+ {1035655200 28800 0 +08}
+ {1048960800 32400 1 +09}
+ {1067104800 28800 0 +08}
+ {1080410400 32400 1 +09}
+ {1099159200 28800 0 +08}
+ {1111860000 32400 1 +09}
+ {1130608800 28800 0 +08}
+ {1143309600 32400 1 +09}
+ {1162058400 28800 0 +08}
+ {1174759200 32400 1 +09}
+ {1193508000 28800 0 +08}
+ {1206813600 32400 1 +09}
+ {1224957600 28800 0 +08}
+ {1238263200 32400 1 +09}
+ {1256407200 28800 0 +08}
+ {1269712800 32400 1 +09}
+ {1288461600 28800 0 +08}
+ {1301162400 32400 0 +09}
+ {1414256400 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Jakarta b/library/tzdata/Asia/Jakarta
index 75cd659..21da168 100644
--- a/library/tzdata/Asia/Jakarta
+++ b/library/tzdata/Asia/Jakarta
@@ -3,11 +3,11 @@
set TZData(:Asia/Jakarta) {
{-9223372036854775808 25632 0 LMT}
{-3231299232 25632 0 BMT}
- {-1451719200 26400 0 JAVT}
- {-1172906400 27000 0 WIB}
- {-876641400 32400 0 JST}
- {-766054800 27000 0 WIB}
- {-683883000 28800 0 WIB}
- {-620812800 27000 0 WIB}
+ {-1451719200 26400 0 +0720}
+ {-1172906400 27000 0 +0730}
+ {-876641400 32400 0 +09}
+ {-766054800 27000 0 +0730}
+ {-683883000 28800 0 +08}
+ {-620812800 27000 0 +0730}
{-189415800 25200 0 WIB}
}
diff --git a/library/tzdata/Asia/Jayapura b/library/tzdata/Asia/Jayapura
index f3a4c44..1432488 100644
--- a/library/tzdata/Asia/Jayapura
+++ b/library/tzdata/Asia/Jayapura
@@ -2,7 +2,7 @@
set TZData(:Asia/Jayapura) {
{-9223372036854775808 33768 0 LMT}
- {-1172913768 32400 0 WIT}
- {-799491600 34200 0 ACST}
+ {-1172913768 32400 0 +09}
+ {-799491600 34200 0 +0930}
{-189423000 32400 0 WIT}
}
diff --git a/library/tzdata/Asia/Kabul b/library/tzdata/Asia/Kabul
index 33d7282..3613de4 100644
--- a/library/tzdata/Asia/Kabul
+++ b/library/tzdata/Asia/Kabul
@@ -2,6 +2,6 @@
set TZData(:Asia/Kabul) {
{-9223372036854775808 16608 0 LMT}
- {-2524538208 14400 0 AFT}
- {-788932800 16200 0 AFT}
+ {-2524538208 14400 0 +04}
+ {-788932800 16200 0 +0430}
}
diff --git a/library/tzdata/Asia/Kamchatka b/library/tzdata/Asia/Kamchatka
index 2b77154..818fc2d 100644
--- a/library/tzdata/Asia/Kamchatka
+++ b/library/tzdata/Asia/Kamchatka
@@ -2,70 +2,70 @@
set TZData(:Asia/Kamchatka) {
{-9223372036854775808 38076 0 LMT}
- {-1487759676 39600 0 PETT}
- {-1247569200 43200 0 PETMMTT}
- {354888000 46800 1 PETST}
- {370695600 43200 0 PETT}
- {386424000 46800 1 PETST}
- {402231600 43200 0 PETT}
- {417960000 46800 1 PETST}
- {433767600 43200 0 PETT}
- {449582400 46800 1 PETST}
- {465314400 43200 0 PETT}
- {481039200 46800 1 PETST}
- {496764000 43200 0 PETT}
- {512488800 46800 1 PETST}
- {528213600 43200 0 PETT}
- {543938400 46800 1 PETST}
- {559663200 43200 0 PETT}
- {575388000 46800 1 PETST}
- {591112800 43200 0 PETT}
- {606837600 46800 1 PETST}
- {622562400 43200 0 PETT}
- {638287200 46800 1 PETST}
- {654616800 43200 0 PETT}
- {670341600 39600 0 PETMMTT}
- {670345200 43200 1 PETST}
- {686070000 39600 0 PETT}
- {695746800 43200 0 PETMMTT}
- {701791200 46800 1 PETST}
- {717516000 43200 0 PETT}
- {733240800 46800 1 PETST}
- {748965600 43200 0 PETT}
- {764690400 46800 1 PETST}
- {780415200 43200 0 PETT}
- {796140000 46800 1 PETST}
- {811864800 43200 0 PETT}
- {828194400 46800 1 PETST}
- {846338400 43200 0 PETT}
- {859644000 46800 1 PETST}
- {877788000 43200 0 PETT}
- {891093600 46800 1 PETST}
- {909237600 43200 0 PETT}
- {922543200 46800 1 PETST}
- {941292000 43200 0 PETT}
- {953992800 46800 1 PETST}
- {972741600 43200 0 PETT}
- {985442400 46800 1 PETST}
- {1004191200 43200 0 PETT}
- {1017496800 46800 1 PETST}
- {1035640800 43200 0 PETT}
- {1048946400 46800 1 PETST}
- {1067090400 43200 0 PETT}
- {1080396000 46800 1 PETST}
- {1099144800 43200 0 PETT}
- {1111845600 46800 1 PETST}
- {1130594400 43200 0 PETT}
- {1143295200 46800 1 PETST}
- {1162044000 43200 0 PETT}
- {1174744800 46800 1 PETST}
- {1193493600 43200 0 PETT}
- {1206799200 46800 1 PETST}
- {1224943200 43200 0 PETT}
- {1238248800 46800 1 PETST}
- {1256392800 43200 0 PETT}
- {1269698400 39600 0 PETMMTT}
- {1269702000 43200 1 PETST}
- {1288450800 39600 0 PETT}
- {1301151600 43200 0 PETT}
+ {-1487759676 39600 0 +11}
+ {-1247569200 43200 0 +13}
+ {354888000 46800 1 +13}
+ {370695600 43200 0 +12}
+ {386424000 46800 1 +13}
+ {402231600 43200 0 +12}
+ {417960000 46800 1 +13}
+ {433767600 43200 0 +12}
+ {449582400 46800 1 +13}
+ {465314400 43200 0 +12}
+ {481039200 46800 1 +13}
+ {496764000 43200 0 +12}
+ {512488800 46800 1 +13}
+ {528213600 43200 0 +12}
+ {543938400 46800 1 +13}
+ {559663200 43200 0 +12}
+ {575388000 46800 1 +13}
+ {591112800 43200 0 +12}
+ {606837600 46800 1 +13}
+ {622562400 43200 0 +12}
+ {638287200 46800 1 +13}
+ {654616800 43200 0 +12}
+ {670341600 39600 0 +12}
+ {670345200 43200 1 +12}
+ {686070000 39600 0 +11}
+ {695746800 43200 0 +13}
+ {701791200 46800 1 +13}
+ {717516000 43200 0 +12}
+ {733240800 46800 1 +13}
+ {748965600 43200 0 +12}
+ {764690400 46800 1 +13}
+ {780415200 43200 0 +12}
+ {796140000 46800 1 +13}
+ {811864800 43200 0 +12}
+ {828194400 46800 1 +13}
+ {846338400 43200 0 +12}
+ {859644000 46800 1 +13}
+ {877788000 43200 0 +12}
+ {891093600 46800 1 +13}
+ {909237600 43200 0 +12}
+ {922543200 46800 1 +13}
+ {941292000 43200 0 +12}
+ {953992800 46800 1 +13}
+ {972741600 43200 0 +12}
+ {985442400 46800 1 +13}
+ {1004191200 43200 0 +12}
+ {1017496800 46800 1 +13}
+ {1035640800 43200 0 +12}
+ {1048946400 46800 1 +13}
+ {1067090400 43200 0 +12}
+ {1080396000 46800 1 +13}
+ {1099144800 43200 0 +12}
+ {1111845600 46800 1 +13}
+ {1130594400 43200 0 +12}
+ {1143295200 46800 1 +13}
+ {1162044000 43200 0 +12}
+ {1174744800 46800 1 +13}
+ {1193493600 43200 0 +12}
+ {1206799200 46800 1 +13}
+ {1224943200 43200 0 +12}
+ {1238248800 46800 1 +13}
+ {1256392800 43200 0 +12}
+ {1269698400 39600 0 +12}
+ {1269702000 43200 1 +12}
+ {1288450800 39600 0 +11}
+ {1301151600 43200 0 +12}
}
diff --git a/library/tzdata/Asia/Karachi b/library/tzdata/Asia/Karachi
index 669c11a..1d81926 100644
--- a/library/tzdata/Asia/Karachi
+++ b/library/tzdata/Asia/Karachi
@@ -2,10 +2,10 @@
set TZData(:Asia/Karachi) {
{-9223372036854775808 16092 0 LMT}
- {-1988166492 19800 0 IST}
- {-862637400 23400 1 IST}
- {-764145000 19800 0 IST}
- {-576135000 18000 0 KART}
+ {-1988166492 19800 0 +0530}
+ {-862637400 23400 1 +0630}
+ {-764145000 19800 0 +0530}
+ {-576135000 18000 0 +05}
{38775600 18000 0 PKT}
{1018119600 21600 1 PKST}
{1033840800 18000 0 PKT}
diff --git a/library/tzdata/Asia/Kathmandu b/library/tzdata/Asia/Kathmandu
index dbec1f0..f88a5a2 100644
--- a/library/tzdata/Asia/Kathmandu
+++ b/library/tzdata/Asia/Kathmandu
@@ -2,6 +2,6 @@
set TZData(:Asia/Kathmandu) {
{-9223372036854775808 20476 0 LMT}
- {-1577943676 19800 0 IST}
- {504901800 20700 0 NPT}
+ {-1577943676 19800 0 +0530}
+ {504901800 20700 0 +0545}
}
diff --git a/library/tzdata/Asia/Khandyga b/library/tzdata/Asia/Khandyga
index b898e0d..07bffac 100644
--- a/library/tzdata/Asia/Khandyga
+++ b/library/tzdata/Asia/Khandyga
@@ -2,72 +2,72 @@
set TZData(:Asia/Khandyga) {
{-9223372036854775808 32533 0 LMT}
- {-1579424533 28800 0 YAKT}
- {-1247558400 32400 0 YAKMMTT}
- {354898800 36000 1 YAKST}
- {370706400 32400 0 YAKT}
- {386434800 36000 1 YAKST}
- {402242400 32400 0 YAKT}
- {417970800 36000 1 YAKST}
- {433778400 32400 0 YAKT}
- {449593200 36000 1 YAKST}
- {465325200 32400 0 YAKT}
- {481050000 36000 1 YAKST}
- {496774800 32400 0 YAKT}
- {512499600 36000 1 YAKST}
- {528224400 32400 0 YAKT}
- {543949200 36000 1 YAKST}
- {559674000 32400 0 YAKT}
- {575398800 36000 1 YAKST}
- {591123600 32400 0 YAKT}
- {606848400 36000 1 YAKST}
- {622573200 32400 0 YAKT}
- {638298000 36000 1 YAKST}
- {654627600 32400 0 YAKT}
- {670352400 28800 0 YAKMMTT}
- {670356000 32400 1 YAKST}
- {686080800 28800 0 YAKT}
- {695757600 32400 0 YAKMMTT}
- {701802000 36000 1 YAKST}
- {717526800 32400 0 YAKT}
- {733251600 36000 1 YAKST}
- {748976400 32400 0 YAKT}
- {764701200 36000 1 YAKST}
- {780426000 32400 0 YAKT}
- {796150800 36000 1 YAKST}
- {811875600 32400 0 YAKT}
- {828205200 36000 1 YAKST}
- {846349200 32400 0 YAKT}
- {859654800 36000 1 YAKST}
- {877798800 32400 0 YAKT}
- {891104400 36000 1 YAKST}
- {909248400 32400 0 YAKT}
- {922554000 36000 1 YAKST}
- {941302800 32400 0 YAKT}
- {954003600 36000 1 YAKST}
- {972752400 32400 0 YAKT}
- {985453200 36000 1 YAKST}
- {1004202000 32400 0 YAKT}
- {1017507600 36000 1 YAKST}
- {1035651600 32400 0 YAKT}
- {1048957200 36000 1 YAKST}
- {1067101200 32400 0 YAKT}
- {1072882800 36000 0 VLAMMTT}
- {1080403200 39600 1 VLAST}
- {1099152000 36000 0 VLAT}
- {1111852800 39600 1 VLAST}
- {1130601600 36000 0 VLAT}
- {1143302400 39600 1 VLAST}
- {1162051200 36000 0 VLAT}
- {1174752000 39600 1 VLAST}
- {1193500800 36000 0 VLAT}
- {1206806400 39600 1 VLAST}
- {1224950400 36000 0 VLAT}
- {1238256000 39600 1 VLAST}
- {1256400000 36000 0 VLAT}
- {1269705600 39600 1 VLAST}
- {1288454400 36000 0 VLAT}
- {1301155200 39600 0 VLAT}
- {1315832400 36000 0 YAKT}
- {1414252800 32400 0 YAKT}
+ {-1579424533 28800 0 +08}
+ {-1247558400 32400 0 +10}
+ {354898800 36000 1 +10}
+ {370706400 32400 0 +09}
+ {386434800 36000 1 +10}
+ {402242400 32400 0 +09}
+ {417970800 36000 1 +10}
+ {433778400 32400 0 +09}
+ {449593200 36000 1 +10}
+ {465325200 32400 0 +09}
+ {481050000 36000 1 +10}
+ {496774800 32400 0 +09}
+ {512499600 36000 1 +10}
+ {528224400 32400 0 +09}
+ {543949200 36000 1 +10}
+ {559674000 32400 0 +09}
+ {575398800 36000 1 +10}
+ {591123600 32400 0 +09}
+ {606848400 36000 1 +10}
+ {622573200 32400 0 +09}
+ {638298000 36000 1 +10}
+ {654627600 32400 0 +09}
+ {670352400 28800 0 +09}
+ {670356000 32400 1 +09}
+ {686080800 28800 0 +08}
+ {695757600 32400 0 +10}
+ {701802000 36000 1 +10}
+ {717526800 32400 0 +09}
+ {733251600 36000 1 +10}
+ {748976400 32400 0 +09}
+ {764701200 36000 1 +10}
+ {780426000 32400 0 +09}
+ {796150800 36000 1 +10}
+ {811875600 32400 0 +09}
+ {828205200 36000 1 +10}
+ {846349200 32400 0 +09}
+ {859654800 36000 1 +10}
+ {877798800 32400 0 +09}
+ {891104400 36000 1 +10}
+ {909248400 32400 0 +09}
+ {922554000 36000 1 +10}
+ {941302800 32400 0 +09}
+ {954003600 36000 1 +10}
+ {972752400 32400 0 +09}
+ {985453200 36000 1 +10}
+ {1004202000 32400 0 +09}
+ {1017507600 36000 1 +10}
+ {1035651600 32400 0 +09}
+ {1048957200 36000 1 +10}
+ {1067101200 32400 0 +09}
+ {1072882800 36000 0 +11}
+ {1080403200 39600 1 +11}
+ {1099152000 36000 0 +10}
+ {1111852800 39600 1 +11}
+ {1130601600 36000 0 +10}
+ {1143302400 39600 1 +11}
+ {1162051200 36000 0 +10}
+ {1174752000 39600 1 +11}
+ {1193500800 36000 0 +10}
+ {1206806400 39600 1 +11}
+ {1224950400 36000 0 +10}
+ {1238256000 39600 1 +11}
+ {1256400000 36000 0 +10}
+ {1269705600 39600 1 +11}
+ {1288454400 36000 0 +10}
+ {1301155200 39600 0 +11}
+ {1315832400 36000 0 +10}
+ {1414252800 32400 0 +09}
}
diff --git a/library/tzdata/Asia/Kolkata b/library/tzdata/Asia/Kolkata
index a87bf31..6b3b9fb 100644
--- a/library/tzdata/Asia/Kolkata
+++ b/library/tzdata/Asia/Kolkata
@@ -3,8 +3,8 @@
set TZData(:Asia/Kolkata) {
{-9223372036854775808 21208 0 LMT}
{-2840162008 21200 0 HMT}
- {-891582800 23400 0 BURT}
+ {-891582800 23400 0 +0630}
{-872058600 19800 0 IST}
- {-862637400 23400 1 IST}
+ {-862637400 23400 1 +0630}
{-764145000 19800 0 IST}
}
diff --git a/library/tzdata/Asia/Krasnoyarsk b/library/tzdata/Asia/Krasnoyarsk
index 3c6285e..0721425 100644
--- a/library/tzdata/Asia/Krasnoyarsk
+++ b/library/tzdata/Asia/Krasnoyarsk
@@ -2,70 +2,70 @@
set TZData(:Asia/Krasnoyarsk) {
{-9223372036854775808 22286 0 LMT}
- {-1577513486 21600 0 KRAT}
- {-1247551200 25200 0 KRAMMTT}
- {354906000 28800 1 KRAST}
- {370713600 25200 0 KRAT}
- {386442000 28800 1 KRAST}
- {402249600 25200 0 KRAT}
- {417978000 28800 1 KRAST}
- {433785600 25200 0 KRAT}
- {449600400 28800 1 KRAST}
- {465332400 25200 0 KRAT}
- {481057200 28800 1 KRAST}
- {496782000 25200 0 KRAT}
- {512506800 28800 1 KRAST}
- {528231600 25200 0 KRAT}
- {543956400 28800 1 KRAST}
- {559681200 25200 0 KRAT}
- {575406000 28800 1 KRAST}
- {591130800 25200 0 KRAT}
- {606855600 28800 1 KRAST}
- {622580400 25200 0 KRAT}
- {638305200 28800 1 KRAST}
- {654634800 25200 0 KRAT}
- {670359600 21600 0 KRAMMTT}
- {670363200 25200 1 KRAST}
- {686088000 21600 0 KRAT}
- {695764800 25200 0 KRAMMTT}
- {701809200 28800 1 KRAST}
- {717534000 25200 0 KRAT}
- {733258800 28800 1 KRAST}
- {748983600 25200 0 KRAT}
- {764708400 28800 1 KRAST}
- {780433200 25200 0 KRAT}
- {796158000 28800 1 KRAST}
- {811882800 25200 0 KRAT}
- {828212400 28800 1 KRAST}
- {846356400 25200 0 KRAT}
- {859662000 28800 1 KRAST}
- {877806000 25200 0 KRAT}
- {891111600 28800 1 KRAST}
- {909255600 25200 0 KRAT}
- {922561200 28800 1 KRAST}
- {941310000 25200 0 KRAT}
- {954010800 28800 1 KRAST}
- {972759600 25200 0 KRAT}
- {985460400 28800 1 KRAST}
- {1004209200 25200 0 KRAT}
- {1017514800 28800 1 KRAST}
- {1035658800 25200 0 KRAT}
- {1048964400 28800 1 KRAST}
- {1067108400 25200 0 KRAT}
- {1080414000 28800 1 KRAST}
- {1099162800 25200 0 KRAT}
- {1111863600 28800 1 KRAST}
- {1130612400 25200 0 KRAT}
- {1143313200 28800 1 KRAST}
- {1162062000 25200 0 KRAT}
- {1174762800 28800 1 KRAST}
- {1193511600 25200 0 KRAT}
- {1206817200 28800 1 KRAST}
- {1224961200 25200 0 KRAT}
- {1238266800 28800 1 KRAST}
- {1256410800 25200 0 KRAT}
- {1269716400 28800 1 KRAST}
- {1288465200 25200 0 KRAT}
- {1301166000 28800 0 KRAT}
- {1414260000 25200 0 KRAT}
+ {-1577513486 21600 0 +06}
+ {-1247551200 25200 0 +08}
+ {354906000 28800 1 +08}
+ {370713600 25200 0 +07}
+ {386442000 28800 1 +08}
+ {402249600 25200 0 +07}
+ {417978000 28800 1 +08}
+ {433785600 25200 0 +07}
+ {449600400 28800 1 +08}
+ {465332400 25200 0 +07}
+ {481057200 28800 1 +08}
+ {496782000 25200 0 +07}
+ {512506800 28800 1 +08}
+ {528231600 25200 0 +07}
+ {543956400 28800 1 +08}
+ {559681200 25200 0 +07}
+ {575406000 28800 1 +08}
+ {591130800 25200 0 +07}
+ {606855600 28800 1 +08}
+ {622580400 25200 0 +07}
+ {638305200 28800 1 +08}
+ {654634800 25200 0 +07}
+ {670359600 21600 0 +07}
+ {670363200 25200 1 +07}
+ {686088000 21600 0 +06}
+ {695764800 25200 0 +08}
+ {701809200 28800 1 +08}
+ {717534000 25200 0 +07}
+ {733258800 28800 1 +08}
+ {748983600 25200 0 +07}
+ {764708400 28800 1 +08}
+ {780433200 25200 0 +07}
+ {796158000 28800 1 +08}
+ {811882800 25200 0 +07}
+ {828212400 28800 1 +08}
+ {846356400 25200 0 +07}
+ {859662000 28800 1 +08}
+ {877806000 25200 0 +07}
+ {891111600 28800 1 +08}
+ {909255600 25200 0 +07}
+ {922561200 28800 1 +08}
+ {941310000 25200 0 +07}
+ {954010800 28800 1 +08}
+ {972759600 25200 0 +07}
+ {985460400 28800 1 +08}
+ {1004209200 25200 0 +07}
+ {1017514800 28800 1 +08}
+ {1035658800 25200 0 +07}
+ {1048964400 28800 1 +08}
+ {1067108400 25200 0 +07}
+ {1080414000 28800 1 +08}
+ {1099162800 25200 0 +07}
+ {1111863600 28800 1 +08}
+ {1130612400 25200 0 +07}
+ {1143313200 28800 1 +08}
+ {1162062000 25200 0 +07}
+ {1174762800 28800 1 +08}
+ {1193511600 25200 0 +07}
+ {1206817200 28800 1 +08}
+ {1224961200 25200 0 +07}
+ {1238266800 28800 1 +08}
+ {1256410800 25200 0 +07}
+ {1269716400 28800 1 +08}
+ {1288465200 25200 0 +07}
+ {1301166000 28800 0 +08}
+ {1414260000 25200 0 +07}
}
diff --git a/library/tzdata/Asia/Kuala_Lumpur b/library/tzdata/Asia/Kuala_Lumpur
index 7a54bd6..84eae1d 100644
--- a/library/tzdata/Asia/Kuala_Lumpur
+++ b/library/tzdata/Asia/Kuala_Lumpur
@@ -3,11 +3,11 @@
set TZData(:Asia/Kuala_Lumpur) {
{-9223372036854775808 24406 0 LMT}
{-2177477206 24925 0 SMT}
- {-2038200925 25200 0 MALT}
- {-1167634800 26400 1 MALST}
- {-1073028000 26400 0 MALT}
- {-894180000 27000 0 MALT}
- {-879665400 32400 0 JST}
- {-767005200 27000 0 MALT}
- {378664200 28800 0 MYT}
+ {-2038200925 25200 0 +07}
+ {-1167634800 26400 1 +0720}
+ {-1073028000 26400 0 +0720}
+ {-894180000 27000 0 +0730}
+ {-879665400 32400 0 +09}
+ {-767005200 27000 0 +0730}
+ {378664200 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Kuching b/library/tzdata/Asia/Kuching
index 0f9110c..d6f5ad4 100644
--- a/library/tzdata/Asia/Kuching
+++ b/library/tzdata/Asia/Kuching
@@ -2,23 +2,22 @@
set TZData(:Asia/Kuching) {
{-9223372036854775808 26480 0 LMT}
- {-1383463280 27000 0 BORT}
- {-1167636600 28800 0 BORT}
- {-1082448000 30000 1 BORTST}
- {-1074586800 28800 0 BORT}
- {-1050825600 30000 1 BORTST}
- {-1042964400 28800 0 BORT}
- {-1019289600 30000 1 BORTST}
- {-1011428400 28800 0 BORT}
- {-987753600 30000 1 BORTST}
- {-979892400 28800 0 BORT}
- {-956217600 30000 1 BORTST}
- {-948356400 28800 0 BORT}
- {-924595200 30000 1 BORTST}
- {-916734000 28800 0 BORT}
- {-893059200 30000 1 BORTST}
- {-885198000 28800 0 BORT}
- {-879667200 32400 0 JST}
- {-767005200 28800 0 BORT}
- {378662400 28800 0 MYT}
+ {-1383463280 27000 0 +0730}
+ {-1167636600 28800 0 +08}
+ {-1082448000 30000 1 +0820}
+ {-1074586800 28800 0 +08}
+ {-1050825600 30000 1 +0820}
+ {-1042964400 28800 0 +08}
+ {-1019289600 30000 1 +0820}
+ {-1011428400 28800 0 +08}
+ {-987753600 30000 1 +0820}
+ {-979892400 28800 0 +08}
+ {-956217600 30000 1 +0820}
+ {-948356400 28800 0 +08}
+ {-924595200 30000 1 +0820}
+ {-916734000 28800 0 +08}
+ {-893059200 30000 1 +0820}
+ {-885198000 28800 0 +08}
+ {-879667200 32400 0 +09}
+ {-767005200 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Macau b/library/tzdata/Asia/Macau
index 9d4abfe..8458a8a 100644
--- a/library/tzdata/Asia/Macau
+++ b/library/tzdata/Asia/Macau
@@ -2,45 +2,45 @@
set TZData(:Asia/Macau) {
{-9223372036854775808 27260 0 LMT}
- {-1830411260 28800 0 MOT}
- {-277360200 32400 1 MOST}
- {-257405400 28800 0 MOT}
- {-245910600 32400 1 MOST}
- {-225955800 28800 0 MOT}
- {-214473600 32400 1 MOST}
- {-194506200 28800 0 MOT}
- {-182406600 32400 1 MOST}
- {-163056600 28800 0 MOT}
- {-150969600 32400 1 MOST}
- {-131619600 28800 0 MOT}
- {-117088200 32400 1 MOST}
- {-101367000 28800 0 MOT}
- {-85638600 32400 1 MOST}
- {-69312600 28800 0 MOT}
- {-53584200 32400 1 MOST}
- {-37863000 28800 0 MOT}
- {-22134600 32400 1 MOST}
- {-6413400 28800 0 MOT}
- {9315000 32400 1 MOST}
- {25036200 28800 0 MOT}
- {40764600 32400 1 MOST}
- {56485800 28800 0 MOT}
- {72201600 32400 1 MOST}
- {87922800 28800 0 MOT}
- {103651200 32400 1 MOST}
- {119977200 28800 0 MOT}
- {135705600 32400 1 MOST}
- {151439400 28800 0 MOT}
- {167167800 32400 1 MOST}
- {182889000 28800 0 MOT}
- {198617400 32400 1 MOST}
- {214338600 28800 0 MOT}
- {230067000 32400 1 MOST}
- {245788200 28800 0 MOT}
- {261504000 32400 1 MOST}
- {277225200 28800 0 MOT}
- {292953600 32400 1 MOST}
- {309279600 28800 0 MOT}
- {325008000 32400 1 MOST}
- {340729200 28800 0 MOT}
+ {-1830411260 28800 0 CST}
+ {-277360200 32400 1 CDT}
+ {-257405400 28800 0 CST}
+ {-245910600 32400 1 CDT}
+ {-225955800 28800 0 CST}
+ {-214473600 32400 1 CDT}
+ {-194506200 28800 0 CST}
+ {-182406600 32400 1 CDT}
+ {-163056600 28800 0 CST}
+ {-150969600 32400 1 CDT}
+ {-131619600 28800 0 CST}
+ {-117088200 32400 1 CDT}
+ {-101367000 28800 0 CST}
+ {-85638600 32400 1 CDT}
+ {-69312600 28800 0 CST}
+ {-53584200 32400 1 CDT}
+ {-37863000 28800 0 CST}
+ {-22134600 32400 1 CDT}
+ {-6413400 28800 0 CST}
+ {9315000 32400 1 CDT}
+ {25036200 28800 0 CST}
+ {40764600 32400 1 CDT}
+ {56485800 28800 0 CST}
+ {72201600 32400 1 CDT}
+ {87922800 28800 0 CST}
+ {103651200 32400 1 CDT}
+ {119977200 28800 0 CST}
+ {135705600 32400 1 CDT}
+ {151439400 28800 0 CST}
+ {167167800 32400 1 CDT}
+ {182889000 28800 0 CST}
+ {198617400 32400 1 CDT}
+ {214338600 28800 0 CST}
+ {230067000 32400 1 CDT}
+ {245788200 28800 0 CST}
+ {261504000 32400 1 CDT}
+ {277225200 28800 0 CST}
+ {292953600 32400 1 CDT}
+ {309279600 28800 0 CST}
+ {325008000 32400 1 CDT}
+ {340729200 28800 0 CST}
}
diff --git a/library/tzdata/Asia/Magadan b/library/tzdata/Asia/Magadan
index afe78da..0626899 100644
--- a/library/tzdata/Asia/Magadan
+++ b/library/tzdata/Asia/Magadan
@@ -2,71 +2,71 @@
set TZData(:Asia/Magadan) {
{-9223372036854775808 36192 0 LMT}
- {-1441188192 36000 0 MAGT}
- {-1247565600 39600 0 MAGMMTT}
- {354891600 43200 1 MAGST}
- {370699200 39600 0 MAGT}
- {386427600 43200 1 MAGST}
- {402235200 39600 0 MAGT}
- {417963600 43200 1 MAGST}
- {433771200 39600 0 MAGT}
- {449586000 43200 1 MAGST}
- {465318000 39600 0 MAGT}
- {481042800 43200 1 MAGST}
- {496767600 39600 0 MAGT}
- {512492400 43200 1 MAGST}
- {528217200 39600 0 MAGT}
- {543942000 43200 1 MAGST}
- {559666800 39600 0 MAGT}
- {575391600 43200 1 MAGST}
- {591116400 39600 0 MAGT}
- {606841200 43200 1 MAGST}
- {622566000 39600 0 MAGT}
- {638290800 43200 1 MAGST}
- {654620400 39600 0 MAGT}
- {670345200 36000 0 MAGMMTT}
- {670348800 39600 1 MAGST}
- {686073600 36000 0 MAGT}
- {695750400 39600 0 MAGMMTT}
- {701794800 43200 1 MAGST}
- {717519600 39600 0 MAGT}
- {733244400 43200 1 MAGST}
- {748969200 39600 0 MAGT}
- {764694000 43200 1 MAGST}
- {780418800 39600 0 MAGT}
- {796143600 43200 1 MAGST}
- {811868400 39600 0 MAGT}
- {828198000 43200 1 MAGST}
- {846342000 39600 0 MAGT}
- {859647600 43200 1 MAGST}
- {877791600 39600 0 MAGT}
- {891097200 43200 1 MAGST}
- {909241200 39600 0 MAGT}
- {922546800 43200 1 MAGST}
- {941295600 39600 0 MAGT}
- {953996400 43200 1 MAGST}
- {972745200 39600 0 MAGT}
- {985446000 43200 1 MAGST}
- {1004194800 39600 0 MAGT}
- {1017500400 43200 1 MAGST}
- {1035644400 39600 0 MAGT}
- {1048950000 43200 1 MAGST}
- {1067094000 39600 0 MAGT}
- {1080399600 43200 1 MAGST}
- {1099148400 39600 0 MAGT}
- {1111849200 43200 1 MAGST}
- {1130598000 39600 0 MAGT}
- {1143298800 43200 1 MAGST}
- {1162047600 39600 0 MAGT}
- {1174748400 43200 1 MAGST}
- {1193497200 39600 0 MAGT}
- {1206802800 43200 1 MAGST}
- {1224946800 39600 0 MAGT}
- {1238252400 43200 1 MAGST}
- {1256396400 39600 0 MAGT}
- {1269702000 43200 1 MAGST}
- {1288450800 39600 0 MAGT}
- {1301151600 43200 0 MAGT}
- {1414245600 36000 0 MAGT}
- {1461427200 39600 0 MAGT}
+ {-1441188192 36000 0 +10}
+ {-1247565600 39600 0 +12}
+ {354891600 43200 1 +12}
+ {370699200 39600 0 +11}
+ {386427600 43200 1 +12}
+ {402235200 39600 0 +11}
+ {417963600 43200 1 +12}
+ {433771200 39600 0 +11}
+ {449586000 43200 1 +12}
+ {465318000 39600 0 +11}
+ {481042800 43200 1 +12}
+ {496767600 39600 0 +11}
+ {512492400 43200 1 +12}
+ {528217200 39600 0 +11}
+ {543942000 43200 1 +12}
+ {559666800 39600 0 +11}
+ {575391600 43200 1 +12}
+ {591116400 39600 0 +11}
+ {606841200 43200 1 +12}
+ {622566000 39600 0 +11}
+ {638290800 43200 1 +12}
+ {654620400 39600 0 +11}
+ {670345200 36000 0 +11}
+ {670348800 39600 1 +11}
+ {686073600 36000 0 +10}
+ {695750400 39600 0 +12}
+ {701794800 43200 1 +12}
+ {717519600 39600 0 +11}
+ {733244400 43200 1 +12}
+ {748969200 39600 0 +11}
+ {764694000 43200 1 +12}
+ {780418800 39600 0 +11}
+ {796143600 43200 1 +12}
+ {811868400 39600 0 +11}
+ {828198000 43200 1 +12}
+ {846342000 39600 0 +11}
+ {859647600 43200 1 +12}
+ {877791600 39600 0 +11}
+ {891097200 43200 1 +12}
+ {909241200 39600 0 +11}
+ {922546800 43200 1 +12}
+ {941295600 39600 0 +11}
+ {953996400 43200 1 +12}
+ {972745200 39600 0 +11}
+ {985446000 43200 1 +12}
+ {1004194800 39600 0 +11}
+ {1017500400 43200 1 +12}
+ {1035644400 39600 0 +11}
+ {1048950000 43200 1 +12}
+ {1067094000 39600 0 +11}
+ {1080399600 43200 1 +12}
+ {1099148400 39600 0 +11}
+ {1111849200 43200 1 +12}
+ {1130598000 39600 0 +11}
+ {1143298800 43200 1 +12}
+ {1162047600 39600 0 +11}
+ {1174748400 43200 1 +12}
+ {1193497200 39600 0 +11}
+ {1206802800 43200 1 +12}
+ {1224946800 39600 0 +11}
+ {1238252400 43200 1 +12}
+ {1256396400 39600 0 +11}
+ {1269702000 43200 1 +12}
+ {1288450800 39600 0 +11}
+ {1301151600 43200 0 +12}
+ {1414245600 36000 0 +10}
+ {1461427200 39600 0 +11}
}
diff --git a/library/tzdata/Asia/Makassar b/library/tzdata/Asia/Makassar
index be947f3..1be5c59 100644
--- a/library/tzdata/Asia/Makassar
+++ b/library/tzdata/Asia/Makassar
@@ -3,7 +3,7 @@
set TZData(:Asia/Makassar) {
{-9223372036854775808 28656 0 LMT}
{-1577951856 28656 0 MMT}
- {-1172908656 28800 0 WITA}
- {-880272000 32400 0 JST}
+ {-1172908656 28800 0 +08}
+ {-880272000 32400 0 +09}
{-766054800 28800 0 WITA}
}
diff --git a/library/tzdata/Asia/Manila b/library/tzdata/Asia/Manila
index 9cc25e8..987919a 100644
--- a/library/tzdata/Asia/Manila
+++ b/library/tzdata/Asia/Manila
@@ -3,13 +3,13 @@
set TZData(:Asia/Manila) {
{-9223372036854775808 -57360 0 LMT}
{-3944621040 29040 0 LMT}
- {-2229321840 28800 0 PHT}
- {-1046678400 32400 1 PHST}
- {-1038733200 28800 0 PHT}
- {-873273600 32400 0 JST}
- {-794221200 28800 0 PHT}
- {-496224000 32400 1 PHST}
- {-489315600 28800 0 PHT}
- {259344000 32400 1 PHST}
- {275151600 28800 0 PHT}
+ {-2229321840 28800 0 +08}
+ {-1046678400 32400 1 +09}
+ {-1038733200 28800 0 +08}
+ {-873273600 32400 0 +09}
+ {-794221200 28800 0 +08}
+ {-496224000 32400 1 +09}
+ {-489315600 28800 0 +08}
+ {259344000 32400 1 +09}
+ {275151600 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Omsk b/library/tzdata/Asia/Omsk
index a6fa180..74163d5 100644
--- a/library/tzdata/Asia/Omsk
+++ b/library/tzdata/Asia/Omsk
@@ -2,70 +2,70 @@
set TZData(:Asia/Omsk) {
{-9223372036854775808 17610 0 LMT}
- {-1582088010 18000 0 OMST}
- {-1247547600 21600 0 OMSMMTT}
- {354909600 25200 1 OMSST}
- {370717200 21600 0 OMST}
- {386445600 25200 1 OMSST}
- {402253200 21600 0 OMST}
- {417981600 25200 1 OMSST}
- {433789200 21600 0 OMST}
- {449604000 25200 1 OMSST}
- {465336000 21600 0 OMST}
- {481060800 25200 1 OMSST}
- {496785600 21600 0 OMST}
- {512510400 25200 1 OMSST}
- {528235200 21600 0 OMST}
- {543960000 25200 1 OMSST}
- {559684800 21600 0 OMST}
- {575409600 25200 1 OMSST}
- {591134400 21600 0 OMST}
- {606859200 25200 1 OMSST}
- {622584000 21600 0 OMST}
- {638308800 25200 1 OMSST}
- {654638400 21600 0 OMST}
- {670363200 18000 0 OMSMMTT}
- {670366800 21600 1 OMSST}
- {686091600 18000 0 OMST}
- {695768400 21600 0 OMSMMTT}
- {701812800 25200 1 OMSST}
- {717537600 21600 0 OMST}
- {733262400 25200 1 OMSST}
- {748987200 21600 0 OMST}
- {764712000 25200 1 OMSST}
- {780436800 21600 0 OMST}
- {796161600 25200 1 OMSST}
- {811886400 21600 0 OMST}
- {828216000 25200 1 OMSST}
- {846360000 21600 0 OMST}
- {859665600 25200 1 OMSST}
- {877809600 21600 0 OMST}
- {891115200 25200 1 OMSST}
- {909259200 21600 0 OMST}
- {922564800 25200 1 OMSST}
- {941313600 21600 0 OMST}
- {954014400 25200 1 OMSST}
- {972763200 21600 0 OMST}
- {985464000 25200 1 OMSST}
- {1004212800 21600 0 OMST}
- {1017518400 25200 1 OMSST}
- {1035662400 21600 0 OMST}
- {1048968000 25200 1 OMSST}
- {1067112000 21600 0 OMST}
- {1080417600 25200 1 OMSST}
- {1099166400 21600 0 OMST}
- {1111867200 25200 1 OMSST}
- {1130616000 21600 0 OMST}
- {1143316800 25200 1 OMSST}
- {1162065600 21600 0 OMST}
- {1174766400 25200 1 OMSST}
- {1193515200 21600 0 OMST}
- {1206820800 25200 1 OMSST}
- {1224964800 21600 0 OMST}
- {1238270400 25200 1 OMSST}
- {1256414400 21600 0 OMST}
- {1269720000 25200 1 OMSST}
- {1288468800 21600 0 OMST}
- {1301169600 25200 0 OMST}
- {1414263600 21600 0 OMST}
+ {-1582088010 18000 0 +05}
+ {-1247547600 21600 0 +07}
+ {354909600 25200 1 +07}
+ {370717200 21600 0 +06}
+ {386445600 25200 1 +07}
+ {402253200 21600 0 +06}
+ {417981600 25200 1 +07}
+ {433789200 21600 0 +06}
+ {449604000 25200 1 +07}
+ {465336000 21600 0 +06}
+ {481060800 25200 1 +07}
+ {496785600 21600 0 +06}
+ {512510400 25200 1 +07}
+ {528235200 21600 0 +06}
+ {543960000 25200 1 +07}
+ {559684800 21600 0 +06}
+ {575409600 25200 1 +07}
+ {591134400 21600 0 +06}
+ {606859200 25200 1 +07}
+ {622584000 21600 0 +06}
+ {638308800 25200 1 +07}
+ {654638400 21600 0 +06}
+ {670363200 18000 0 +06}
+ {670366800 21600 1 +06}
+ {686091600 18000 0 +05}
+ {695768400 21600 0 +07}
+ {701812800 25200 1 +07}
+ {717537600 21600 0 +06}
+ {733262400 25200 1 +07}
+ {748987200 21600 0 +06}
+ {764712000 25200 1 +07}
+ {780436800 21600 0 +06}
+ {796161600 25200 1 +07}
+ {811886400 21600 0 +06}
+ {828216000 25200 1 +07}
+ {846360000 21600 0 +06}
+ {859665600 25200 1 +07}
+ {877809600 21600 0 +06}
+ {891115200 25200 1 +07}
+ {909259200 21600 0 +06}
+ {922564800 25200 1 +07}
+ {941313600 21600 0 +06}
+ {954014400 25200 1 +07}
+ {972763200 21600 0 +06}
+ {985464000 25200 1 +07}
+ {1004212800 21600 0 +06}
+ {1017518400 25200 1 +07}
+ {1035662400 21600 0 +06}
+ {1048968000 25200 1 +07}
+ {1067112000 21600 0 +06}
+ {1080417600 25200 1 +07}
+ {1099166400 21600 0 +06}
+ {1111867200 25200 1 +07}
+ {1130616000 21600 0 +06}
+ {1143316800 25200 1 +07}
+ {1162065600 21600 0 +06}
+ {1174766400 25200 1 +07}
+ {1193515200 21600 0 +06}
+ {1206820800 25200 1 +07}
+ {1224964800 21600 0 +06}
+ {1238270400 25200 1 +07}
+ {1256414400 21600 0 +06}
+ {1269720000 25200 1 +07}
+ {1288468800 21600 0 +06}
+ {1301169600 25200 0 +07}
+ {1414263600 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Oral b/library/tzdata/Asia/Oral
index 962111b..624a59d 100644
--- a/library/tzdata/Asia/Oral
+++ b/library/tzdata/Asia/Oral
@@ -2,8 +2,8 @@
set TZData(:Asia/Oral) {
{-9223372036854775808 12324 0 LMT}
- {-1441164324 14400 0 +04}
- {-1247544000 18000 0 +05}
+ {-1441164324 10800 0 +03}
+ {-1247540400 18000 0 +05}
{354913200 21600 1 +06}
{370720800 21600 0 +06}
{386445600 18000 0 +05}
diff --git a/library/tzdata/Asia/Pontianak b/library/tzdata/Asia/Pontianak
index 728b552..ed59e9d 100644
--- a/library/tzdata/Asia/Pontianak
+++ b/library/tzdata/Asia/Pontianak
@@ -3,11 +3,11 @@
set TZData(:Asia/Pontianak) {
{-9223372036854775808 26240 0 LMT}
{-1946186240 26240 0 PMT}
- {-1172906240 27000 0 WIB}
- {-881220600 32400 0 JST}
- {-766054800 27000 0 WIB}
- {-683883000 28800 0 WIB}
- {-620812800 27000 0 WIB}
+ {-1172906240 27000 0 +0730}
+ {-881220600 32400 0 +09}
+ {-766054800 27000 0 +0730}
+ {-683883000 28800 0 +08}
+ {-620812800 27000 0 +0730}
{-189415800 28800 0 WITA}
{567964800 25200 0 WIB}
}
diff --git a/library/tzdata/Asia/Pyongyang b/library/tzdata/Asia/Pyongyang
index 4ade8e6..72e7f23 100644
--- a/library/tzdata/Asia/Pyongyang
+++ b/library/tzdata/Asia/Pyongyang
@@ -3,8 +3,7 @@
set TZData(:Asia/Pyongyang) {
{-9223372036854775808 30180 0 LMT}
{-1948782180 30600 0 KST}
- {-1830414600 32400 0 JCST}
- {-1017824400 32400 0 JST}
+ {-1830414600 32400 0 JST}
{-768646800 32400 0 KST}
{1439564400 30600 0 KST}
}
diff --git a/library/tzdata/Asia/Qatar b/library/tzdata/Asia/Qatar
index bfb4eb4..10b4f6d 100644
--- a/library/tzdata/Asia/Qatar
+++ b/library/tzdata/Asia/Qatar
@@ -2,6 +2,6 @@
set TZData(:Asia/Qatar) {
{-9223372036854775808 12368 0 LMT}
- {-1577935568 14400 0 GST}
- {76190400 10800 0 AST}
+ {-1577935568 14400 0 +04}
+ {76190400 10800 0 +03}
}
diff --git a/library/tzdata/Asia/Rangoon b/library/tzdata/Asia/Rangoon
index 4f3ac02..8ea2748 100644
--- a/library/tzdata/Asia/Rangoon
+++ b/library/tzdata/Asia/Rangoon
@@ -1,9 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
-
-set TZData(:Asia/Rangoon) {
- {-9223372036854775808 23080 0 LMT}
- {-2840163880 23080 0 RMT}
- {-1577946280 23400 0 BURT}
- {-873268200 32400 0 JST}
- {-778410000 23400 0 MMT}
+if {![info exists TZData(Asia/Yangon)]} {
+ LoadTimeZoneFile Asia/Yangon
}
+set TZData(:Asia/Rangoon) $TZData(:Asia/Yangon)
diff --git a/library/tzdata/Asia/Riyadh b/library/tzdata/Asia/Riyadh
index 12c9e24..af5efa8 100644
--- a/library/tzdata/Asia/Riyadh
+++ b/library/tzdata/Asia/Riyadh
@@ -2,5 +2,5 @@
set TZData(:Asia/Riyadh) {
{-9223372036854775808 11212 0 LMT}
- {-719636812 10800 0 AST}
+ {-719636812 10800 0 +03}
}
diff --git a/library/tzdata/Asia/Sakhalin b/library/tzdata/Asia/Sakhalin
index 1de22f4..4ba7c8c 100644
--- a/library/tzdata/Asia/Sakhalin
+++ b/library/tzdata/Asia/Sakhalin
@@ -2,73 +2,72 @@
set TZData(:Asia/Sakhalin) {
{-9223372036854775808 34248 0 LMT}
- {-2031039048 32400 0 JCST}
- {-1017824400 32400 0 JST}
- {-768560400 39600 0 SAKMMTT}
- {354891600 43200 1 SAKST}
- {370699200 39600 0 SAKT}
- {386427600 43200 1 SAKST}
- {402235200 39600 0 SAKT}
- {417963600 43200 1 SAKST}
- {433771200 39600 0 SAKT}
- {449586000 43200 1 SAKST}
- {465318000 39600 0 SAKT}
- {481042800 43200 1 SAKST}
- {496767600 39600 0 SAKT}
- {512492400 43200 1 SAKST}
- {528217200 39600 0 SAKT}
- {543942000 43200 1 SAKST}
- {559666800 39600 0 SAKT}
- {575391600 43200 1 SAKST}
- {591116400 39600 0 SAKT}
- {606841200 43200 1 SAKST}
- {622566000 39600 0 SAKT}
- {638290800 43200 1 SAKST}
- {654620400 39600 0 SAKT}
- {670345200 36000 0 SAKMMTT}
- {670348800 39600 1 SAKST}
- {686073600 36000 0 SAKT}
- {695750400 39600 0 SAKMMTT}
- {701794800 43200 1 SAKST}
- {717519600 39600 0 SAKT}
- {733244400 43200 1 SAKST}
- {748969200 39600 0 SAKT}
- {764694000 43200 1 SAKST}
- {780418800 39600 0 SAKT}
- {796143600 43200 1 SAKST}
- {811868400 39600 0 SAKT}
- {828198000 43200 1 SAKST}
- {846342000 39600 0 SAKT}
- {859647600 36000 0 SAKMMTT}
- {859651200 39600 1 SAKST}
- {877795200 36000 0 SAKT}
- {891100800 39600 1 SAKST}
- {909244800 36000 0 SAKT}
- {922550400 39600 1 SAKST}
- {941299200 36000 0 SAKT}
- {954000000 39600 1 SAKST}
- {972748800 36000 0 SAKT}
- {985449600 39600 1 SAKST}
- {1004198400 36000 0 SAKT}
- {1017504000 39600 1 SAKST}
- {1035648000 36000 0 SAKT}
- {1048953600 39600 1 SAKST}
- {1067097600 36000 0 SAKT}
- {1080403200 39600 1 SAKST}
- {1099152000 36000 0 SAKT}
- {1111852800 39600 1 SAKST}
- {1130601600 36000 0 SAKT}
- {1143302400 39600 1 SAKST}
- {1162051200 36000 0 SAKT}
- {1174752000 39600 1 SAKST}
- {1193500800 36000 0 SAKT}
- {1206806400 39600 1 SAKST}
- {1224950400 36000 0 SAKT}
- {1238256000 39600 1 SAKST}
- {1256400000 36000 0 SAKT}
- {1269705600 39600 1 SAKST}
- {1288454400 36000 0 SAKT}
- {1301155200 39600 0 SAKT}
- {1414249200 36000 0 SAKT}
- {1459008000 39600 0 SAKT}
+ {-2031039048 32400 0 +09}
+ {-768560400 39600 0 +12}
+ {354891600 43200 1 +12}
+ {370699200 39600 0 +11}
+ {386427600 43200 1 +12}
+ {402235200 39600 0 +11}
+ {417963600 43200 1 +12}
+ {433771200 39600 0 +11}
+ {449586000 43200 1 +12}
+ {465318000 39600 0 +11}
+ {481042800 43200 1 +12}
+ {496767600 39600 0 +11}
+ {512492400 43200 1 +12}
+ {528217200 39600 0 +11}
+ {543942000 43200 1 +12}
+ {559666800 39600 0 +11}
+ {575391600 43200 1 +12}
+ {591116400 39600 0 +11}
+ {606841200 43200 1 +12}
+ {622566000 39600 0 +11}
+ {638290800 43200 1 +12}
+ {654620400 39600 0 +11}
+ {670345200 36000 0 +11}
+ {670348800 39600 1 +11}
+ {686073600 36000 0 +10}
+ {695750400 39600 0 +12}
+ {701794800 43200 1 +12}
+ {717519600 39600 0 +11}
+ {733244400 43200 1 +12}
+ {748969200 39600 0 +11}
+ {764694000 43200 1 +12}
+ {780418800 39600 0 +11}
+ {796143600 43200 1 +12}
+ {811868400 39600 0 +11}
+ {828198000 43200 1 +12}
+ {846342000 39600 0 +11}
+ {859647600 36000 0 +11}
+ {859651200 39600 1 +11}
+ {877795200 36000 0 +10}
+ {891100800 39600 1 +11}
+ {909244800 36000 0 +10}
+ {922550400 39600 1 +11}
+ {941299200 36000 0 +10}
+ {954000000 39600 1 +11}
+ {972748800 36000 0 +10}
+ {985449600 39600 1 +11}
+ {1004198400 36000 0 +10}
+ {1017504000 39600 1 +11}
+ {1035648000 36000 0 +10}
+ {1048953600 39600 1 +11}
+ {1067097600 36000 0 +10}
+ {1080403200 39600 1 +11}
+ {1099152000 36000 0 +10}
+ {1111852800 39600 1 +11}
+ {1130601600 36000 0 +10}
+ {1143302400 39600 1 +11}
+ {1162051200 36000 0 +10}
+ {1174752000 39600 1 +11}
+ {1193500800 36000 0 +10}
+ {1206806400 39600 1 +11}
+ {1224950400 36000 0 +10}
+ {1238256000 39600 1 +11}
+ {1256400000 36000 0 +10}
+ {1269705600 39600 1 +11}
+ {1288454400 36000 0 +10}
+ {1301155200 39600 0 +11}
+ {1414249200 36000 0 +10}
+ {1459008000 39600 0 +11}
}
diff --git a/library/tzdata/Asia/Samarkand b/library/tzdata/Asia/Samarkand
index 4b3b49f..43ad774 100644
--- a/library/tzdata/Asia/Samarkand
+++ b/library/tzdata/Asia/Samarkand
@@ -2,31 +2,30 @@
set TZData(:Asia/Samarkand) {
{-9223372036854775808 16073 0 LMT}
- {-1441168073 14400 0 SAMT}
- {-1247544000 18000 0 SAMT}
- {354913200 21600 1 SAMST}
- {370720800 21600 0 TAST}
- {386445600 18000 0 SAMT}
- {386449200 21600 1 SAMST}
- {402256800 18000 0 SAMT}
- {417985200 21600 1 SAMST}
- {433792800 18000 0 SAMT}
- {449607600 21600 1 SAMST}
- {465339600 18000 0 SAMT}
- {481064400 21600 1 SAMST}
- {496789200 18000 0 SAMT}
- {512514000 21600 1 SAMST}
- {528238800 18000 0 SAMT}
- {543963600 21600 1 SAMST}
- {559688400 18000 0 SAMT}
- {575413200 21600 1 SAMST}
- {591138000 18000 0 SAMT}
- {606862800 21600 1 SAMST}
- {622587600 18000 0 SAMT}
- {638312400 21600 1 SAMST}
- {654642000 18000 0 SAMT}
- {670366800 21600 1 SAMST}
- {683665200 21600 0 UZST}
- {686091600 18000 0 UZT}
- {694206000 18000 0 UZT}
+ {-1441168073 14400 0 +04}
+ {-1247544000 18000 0 +05}
+ {354913200 21600 1 +06}
+ {370720800 21600 0 +06}
+ {386445600 18000 0 +05}
+ {386449200 21600 1 +06}
+ {402256800 18000 0 +05}
+ {417985200 21600 1 +06}
+ {433792800 18000 0 +05}
+ {449607600 21600 1 +06}
+ {465339600 18000 0 +05}
+ {481064400 21600 1 +06}
+ {496789200 18000 0 +05}
+ {512514000 21600 1 +06}
+ {528238800 18000 0 +05}
+ {543963600 21600 1 +06}
+ {559688400 18000 0 +05}
+ {575413200 21600 1 +06}
+ {591138000 18000 0 +05}
+ {606862800 21600 1 +06}
+ {622587600 18000 0 +05}
+ {638312400 21600 1 +06}
+ {654642000 18000 0 +05}
+ {670366800 21600 1 +06}
+ {686091600 18000 0 +05}
+ {694206000 18000 0 +05}
}
diff --git a/library/tzdata/Asia/Seoul b/library/tzdata/Asia/Seoul
index c24a1d8..b226eb5 100644
--- a/library/tzdata/Asia/Seoul
+++ b/library/tzdata/Asia/Seoul
@@ -3,8 +3,7 @@
set TZData(:Asia/Seoul) {
{-9223372036854775808 30472 0 LMT}
{-1948782472 30600 0 KST}
- {-1830414600 32400 0 JCST}
- {-1017824400 32400 0 JST}
+ {-1830414600 32400 0 JST}
{-767350800 32400 0 KST}
{-498128400 30600 0 KST}
{-462702600 34200 1 KDT}
diff --git a/library/tzdata/Asia/Singapore b/library/tzdata/Asia/Singapore
index e2f226e..f10eb1f 100644
--- a/library/tzdata/Asia/Singapore
+++ b/library/tzdata/Asia/Singapore
@@ -3,12 +3,11 @@
set TZData(:Asia/Singapore) {
{-9223372036854775808 24925 0 LMT}
{-2177477725 24925 0 SMT}
- {-2038200925 25200 0 MALT}
- {-1167634800 26400 1 MALST}
- {-1073028000 26400 0 MALT}
- {-894180000 27000 0 MALT}
- {-879665400 32400 0 JST}
- {-767005200 27000 0 MALT}
- {-138785400 27000 0 SGT}
- {378664200 28800 0 SGT}
+ {-2038200925 25200 0 +07}
+ {-1167634800 26400 1 +0720}
+ {-1073028000 26400 0 +0720}
+ {-894180000 27000 0 +0730}
+ {-879665400 32400 0 +09}
+ {-767005200 27000 0 +0730}
+ {378664200 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Srednekolymsk b/library/tzdata/Asia/Srednekolymsk
index a0586aa..1099a4b 100644
--- a/library/tzdata/Asia/Srednekolymsk
+++ b/library/tzdata/Asia/Srednekolymsk
@@ -2,70 +2,70 @@
set TZData(:Asia/Srednekolymsk) {
{-9223372036854775808 36892 0 LMT}
- {-1441188892 36000 0 MAGT}
- {-1247565600 39600 0 MAGMMTT}
- {354891600 43200 1 MAGST}
- {370699200 39600 0 MAGT}
- {386427600 43200 1 MAGST}
- {402235200 39600 0 MAGT}
- {417963600 43200 1 MAGST}
- {433771200 39600 0 MAGT}
- {449586000 43200 1 MAGST}
- {465318000 39600 0 MAGT}
- {481042800 43200 1 MAGST}
- {496767600 39600 0 MAGT}
- {512492400 43200 1 MAGST}
- {528217200 39600 0 MAGT}
- {543942000 43200 1 MAGST}
- {559666800 39600 0 MAGT}
- {575391600 43200 1 MAGST}
- {591116400 39600 0 MAGT}
- {606841200 43200 1 MAGST}
- {622566000 39600 0 MAGT}
- {638290800 43200 1 MAGST}
- {654620400 39600 0 MAGT}
- {670345200 36000 0 MAGMMTT}
- {670348800 39600 1 MAGST}
- {686073600 36000 0 MAGT}
- {695750400 39600 0 MAGMMTT}
- {701794800 43200 1 MAGST}
- {717519600 39600 0 MAGT}
- {733244400 43200 1 MAGST}
- {748969200 39600 0 MAGT}
- {764694000 43200 1 MAGST}
- {780418800 39600 0 MAGT}
- {796143600 43200 1 MAGST}
- {811868400 39600 0 MAGT}
- {828198000 43200 1 MAGST}
- {846342000 39600 0 MAGT}
- {859647600 43200 1 MAGST}
- {877791600 39600 0 MAGT}
- {891097200 43200 1 MAGST}
- {909241200 39600 0 MAGT}
- {922546800 43200 1 MAGST}
- {941295600 39600 0 MAGT}
- {953996400 43200 1 MAGST}
- {972745200 39600 0 MAGT}
- {985446000 43200 1 MAGST}
- {1004194800 39600 0 MAGT}
- {1017500400 43200 1 MAGST}
- {1035644400 39600 0 MAGT}
- {1048950000 43200 1 MAGST}
- {1067094000 39600 0 MAGT}
- {1080399600 43200 1 MAGST}
- {1099148400 39600 0 MAGT}
- {1111849200 43200 1 MAGST}
- {1130598000 39600 0 MAGT}
- {1143298800 43200 1 MAGST}
- {1162047600 39600 0 MAGT}
- {1174748400 43200 1 MAGST}
- {1193497200 39600 0 MAGT}
- {1206802800 43200 1 MAGST}
- {1224946800 39600 0 MAGT}
- {1238252400 43200 1 MAGST}
- {1256396400 39600 0 MAGT}
- {1269702000 43200 1 MAGST}
- {1288450800 39600 0 MAGT}
- {1301151600 43200 0 MAGT}
- {1414245600 39600 0 SRET}
+ {-1441188892 36000 0 +10}
+ {-1247565600 39600 0 +12}
+ {354891600 43200 1 +12}
+ {370699200 39600 0 +11}
+ {386427600 43200 1 +12}
+ {402235200 39600 0 +11}
+ {417963600 43200 1 +12}
+ {433771200 39600 0 +11}
+ {449586000 43200 1 +12}
+ {465318000 39600 0 +11}
+ {481042800 43200 1 +12}
+ {496767600 39600 0 +11}
+ {512492400 43200 1 +12}
+ {528217200 39600 0 +11}
+ {543942000 43200 1 +12}
+ {559666800 39600 0 +11}
+ {575391600 43200 1 +12}
+ {591116400 39600 0 +11}
+ {606841200 43200 1 +12}
+ {622566000 39600 0 +11}
+ {638290800 43200 1 +12}
+ {654620400 39600 0 +11}
+ {670345200 36000 0 +11}
+ {670348800 39600 1 +11}
+ {686073600 36000 0 +10}
+ {695750400 39600 0 +12}
+ {701794800 43200 1 +12}
+ {717519600 39600 0 +11}
+ {733244400 43200 1 +12}
+ {748969200 39600 0 +11}
+ {764694000 43200 1 +12}
+ {780418800 39600 0 +11}
+ {796143600 43200 1 +12}
+ {811868400 39600 0 +11}
+ {828198000 43200 1 +12}
+ {846342000 39600 0 +11}
+ {859647600 43200 1 +12}
+ {877791600 39600 0 +11}
+ {891097200 43200 1 +12}
+ {909241200 39600 0 +11}
+ {922546800 43200 1 +12}
+ {941295600 39600 0 +11}
+ {953996400 43200 1 +12}
+ {972745200 39600 0 +11}
+ {985446000 43200 1 +12}
+ {1004194800 39600 0 +11}
+ {1017500400 43200 1 +12}
+ {1035644400 39600 0 +11}
+ {1048950000 43200 1 +12}
+ {1067094000 39600 0 +11}
+ {1080399600 43200 1 +12}
+ {1099148400 39600 0 +11}
+ {1111849200 43200 1 +12}
+ {1130598000 39600 0 +11}
+ {1143298800 43200 1 +12}
+ {1162047600 39600 0 +11}
+ {1174748400 43200 1 +12}
+ {1193497200 39600 0 +11}
+ {1206802800 43200 1 +12}
+ {1224946800 39600 0 +11}
+ {1238252400 43200 1 +12}
+ {1256396400 39600 0 +11}
+ {1269702000 43200 1 +12}
+ {1288450800 39600 0 +11}
+ {1301151600 43200 0 +12}
+ {1414245600 39600 0 +11}
}
diff --git a/library/tzdata/Asia/Taipei b/library/tzdata/Asia/Taipei
index 61c77ef..cb8fb89 100644
--- a/library/tzdata/Asia/Taipei
+++ b/library/tzdata/Asia/Taipei
@@ -2,7 +2,7 @@
set TZData(:Asia/Taipei) {
{-9223372036854775808 29160 0 LMT}
- {-2335248360 28800 0 JWST}
+ {-2335248360 28800 0 CST}
{-1017820800 32400 0 JST}
{-766224000 28800 0 CST}
{-745833600 32400 1 CDT}
diff --git a/library/tzdata/Asia/Tashkent b/library/tzdata/Asia/Tashkent
index 1477376..7b6abe4 100644
--- a/library/tzdata/Asia/Tashkent
+++ b/library/tzdata/Asia/Tashkent
@@ -2,31 +2,30 @@
set TZData(:Asia/Tashkent) {
{-9223372036854775808 16631 0 LMT}
- {-1441168631 18000 0 TAST}
- {-1247547600 21600 0 TAST}
- {354909600 25200 1 TASST}
- {370717200 21600 0 TAST}
- {386445600 25200 1 TASST}
- {402253200 21600 0 TAST}
- {417981600 25200 1 TASST}
- {433789200 21600 0 TAST}
- {449604000 25200 1 TASST}
- {465336000 21600 0 TAST}
- {481060800 25200 1 TASST}
- {496785600 21600 0 TAST}
- {512510400 25200 1 TASST}
- {528235200 21600 0 TAST}
- {543960000 25200 1 TASST}
- {559684800 21600 0 TAST}
- {575409600 25200 1 TASST}
- {591134400 21600 0 TAST}
- {606859200 25200 1 TASST}
- {622584000 21600 0 TAST}
- {638308800 25200 1 TASST}
- {654638400 21600 0 TAST}
- {670363200 18000 0 TAST}
- {670366800 21600 1 TASST}
- {683665200 21600 0 UZST}
- {686091600 18000 0 UZT}
- {694206000 18000 0 UZT}
+ {-1441168631 18000 0 +05}
+ {-1247547600 21600 0 +06}
+ {354909600 25200 1 +07}
+ {370717200 21600 0 +06}
+ {386445600 25200 1 +07}
+ {402253200 21600 0 +06}
+ {417981600 25200 1 +07}
+ {433789200 21600 0 +06}
+ {449604000 25200 1 +07}
+ {465336000 21600 0 +06}
+ {481060800 25200 1 +07}
+ {496785600 21600 0 +06}
+ {512510400 25200 1 +07}
+ {528235200 21600 0 +06}
+ {543960000 25200 1 +07}
+ {559684800 21600 0 +06}
+ {575409600 25200 1 +07}
+ {591134400 21600 0 +06}
+ {606859200 25200 1 +07}
+ {622584000 21600 0 +06}
+ {638308800 25200 1 +07}
+ {654638400 21600 0 +06}
+ {670363200 18000 0 +05}
+ {670366800 21600 1 +06}
+ {686091600 18000 0 +05}
+ {694206000 18000 0 +05}
}
diff --git a/library/tzdata/Asia/Tbilisi b/library/tzdata/Asia/Tbilisi
index 54b278a..60d253c 100644
--- a/library/tzdata/Asia/Tbilisi
+++ b/library/tzdata/Asia/Tbilisi
@@ -3,58 +3,58 @@
set TZData(:Asia/Tbilisi) {
{-9223372036854775808 10751 0 LMT}
{-2840151551 10751 0 TBMT}
- {-1441162751 10800 0 TBIT}
- {-405140400 14400 0 TBIT}
- {354916800 18000 1 TBIST}
- {370724400 14400 0 TBIT}
- {386452800 18000 1 TBIST}
- {402260400 14400 0 TBIT}
- {417988800 18000 1 TBIST}
- {433796400 14400 0 TBIT}
- {449611200 18000 1 TBIST}
- {465343200 14400 0 TBIT}
- {481068000 18000 1 TBIST}
- {496792800 14400 0 TBIT}
- {512517600 18000 1 TBIST}
- {528242400 14400 0 TBIT}
- {543967200 18000 1 TBIST}
- {559692000 14400 0 TBIT}
- {575416800 18000 1 TBIST}
- {591141600 14400 0 TBIT}
- {606866400 18000 1 TBIST}
- {622591200 14400 0 TBIT}
- {638316000 18000 1 TBIST}
- {654645600 14400 0 TBIT}
- {670370400 14400 1 TBIST}
- {671140800 14400 0 GEST}
- {686098800 10800 0 GET}
- {694213200 10800 0 GET}
- {701816400 14400 1 GEST}
- {717537600 10800 0 GET}
- {733266000 14400 1 GEST}
- {748987200 10800 0 GET}
- {764715600 14400 1 GEST}
- {780440400 14400 0 GET}
- {796161600 18000 1 GEST}
- {811882800 14400 0 GET}
- {828216000 18000 1 GEST}
- {846360000 18000 1 GEST}
- {859662000 18000 0 GEST}
- {877806000 14400 0 GET}
- {891115200 18000 1 GEST}
- {909255600 14400 0 GET}
- {922564800 18000 1 GEST}
- {941310000 14400 0 GET}
- {954014400 18000 1 GEST}
- {972759600 14400 0 GET}
- {985464000 18000 1 GEST}
- {1004209200 14400 0 GET}
- {1017518400 18000 1 GEST}
- {1035658800 14400 0 GET}
- {1048968000 18000 1 GEST}
- {1067108400 14400 0 GET}
- {1080417600 18000 1 GEST}
- {1088280000 14400 0 GEST}
- {1099177200 10800 0 GET}
- {1111878000 14400 0 GET}
+ {-1441162751 10800 0 +03}
+ {-405140400 14400 0 +04}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 18000 1 +05}
+ {591141600 14400 0 +04}
+ {606866400 18000 1 +05}
+ {622591200 14400 0 +04}
+ {638316000 18000 1 +05}
+ {654645600 14400 0 +04}
+ {670370400 10800 0 +03}
+ {670374000 14400 1 +04}
+ {686098800 10800 0 +03}
+ {694213200 10800 0 +03}
+ {701816400 14400 1 +04}
+ {717537600 10800 0 +03}
+ {733266000 14400 1 +04}
+ {748987200 10800 0 +03}
+ {764715600 14400 1 +04}
+ {780440400 14400 0 +04}
+ {796161600 18000 1 +05}
+ {811882800 14400 0 +04}
+ {828216000 18000 1 +05}
+ {846360000 18000 1 +05}
+ {859662000 18000 0 +05}
+ {877806000 14400 0 +04}
+ {891115200 18000 1 +05}
+ {909255600 14400 0 +04}
+ {922564800 18000 1 +05}
+ {941310000 14400 0 +04}
+ {954014400 18000 1 +05}
+ {972759600 14400 0 +04}
+ {985464000 18000 1 +05}
+ {1004209200 14400 0 +04}
+ {1017518400 18000 1 +05}
+ {1035658800 14400 0 +04}
+ {1048968000 18000 1 +05}
+ {1067108400 14400 0 +04}
+ {1080417600 18000 1 +05}
+ {1088280000 14400 0 +04}
+ {1099177200 10800 0 +03}
+ {1111878000 14400 0 +04}
}
diff --git a/library/tzdata/Asia/Tehran b/library/tzdata/Asia/Tehran
index 5fd840d..a8912ce 100644
--- a/library/tzdata/Asia/Tehran
+++ b/library/tzdata/Asia/Tehran
@@ -3,227 +3,227 @@
set TZData(:Asia/Tehran) {
{-9223372036854775808 12344 0 LMT}
{-1704165944 12344 0 TMT}
- {-757394744 12600 0 IRST}
- {247177800 14400 0 IRST}
- {259272000 18000 1 IRDT}
- {277758000 14400 0 IRST}
- {283982400 12600 0 IRST}
- {290809800 16200 1 IRDT}
- {306531000 12600 0 IRST}
- {322432200 16200 1 IRDT}
- {338499000 12600 0 IRST}
- {673216200 16200 1 IRDT}
- {685481400 12600 0 IRST}
- {701209800 16200 1 IRDT}
- {717103800 12600 0 IRST}
- {732745800 16200 1 IRDT}
- {748639800 12600 0 IRST}
- {764281800 16200 1 IRDT}
- {780175800 12600 0 IRST}
- {795817800 16200 1 IRDT}
- {811711800 12600 0 IRST}
- {827353800 16200 1 IRDT}
- {843247800 12600 0 IRST}
- {858976200 16200 1 IRDT}
- {874870200 12600 0 IRST}
- {890512200 16200 1 IRDT}
- {906406200 12600 0 IRST}
- {922048200 16200 1 IRDT}
- {937942200 12600 0 IRST}
- {953584200 16200 1 IRDT}
- {969478200 12600 0 IRST}
- {985206600 16200 1 IRDT}
- {1001100600 12600 0 IRST}
- {1016742600 16200 1 IRDT}
- {1032636600 12600 0 IRST}
- {1048278600 16200 1 IRDT}
- {1064172600 12600 0 IRST}
- {1079814600 16200 1 IRDT}
- {1095708600 12600 0 IRST}
- {1111437000 16200 1 IRDT}
- {1127331000 12600 0 IRST}
- {1206045000 16200 1 IRDT}
- {1221939000 12600 0 IRST}
- {1237667400 16200 1 IRDT}
- {1253561400 12600 0 IRST}
- {1269203400 16200 1 IRDT}
- {1285097400 12600 0 IRST}
- {1300739400 16200 1 IRDT}
- {1316633400 12600 0 IRST}
- {1332275400 16200 1 IRDT}
- {1348169400 12600 0 IRST}
- {1363897800 16200 1 IRDT}
- {1379791800 12600 0 IRST}
- {1395433800 16200 1 IRDT}
- {1411327800 12600 0 IRST}
- {1426969800 16200 1 IRDT}
- {1442863800 12600 0 IRST}
- {1458505800 16200 1 IRDT}
- {1474399800 12600 0 IRST}
- {1490128200 16200 1 IRDT}
- {1506022200 12600 0 IRST}
- {1521664200 16200 1 IRDT}
- {1537558200 12600 0 IRST}
- {1553200200 16200 1 IRDT}
- {1569094200 12600 0 IRST}
- {1584736200 16200 1 IRDT}
- {1600630200 12600 0 IRST}
- {1616358600 16200 1 IRDT}
- {1632252600 12600 0 IRST}
- {1647894600 16200 1 IRDT}
- {1663788600 12600 0 IRST}
- {1679430600 16200 1 IRDT}
- {1695324600 12600 0 IRST}
- {1710966600 16200 1 IRDT}
- {1726860600 12600 0 IRST}
- {1742589000 16200 1 IRDT}
- {1758483000 12600 0 IRST}
- {1774125000 16200 1 IRDT}
- {1790019000 12600 0 IRST}
- {1805661000 16200 1 IRDT}
- {1821555000 12600 0 IRST}
- {1837197000 16200 1 IRDT}
- {1853091000 12600 0 IRST}
- {1868733000 16200 1 IRDT}
- {1884627000 12600 0 IRST}
- {1900355400 16200 1 IRDT}
- {1916249400 12600 0 IRST}
- {1931891400 16200 1 IRDT}
- {1947785400 12600 0 IRST}
- {1963427400 16200 1 IRDT}
- {1979321400 12600 0 IRST}
- {1994963400 16200 1 IRDT}
- {2010857400 12600 0 IRST}
- {2026585800 16200 1 IRDT}
- {2042479800 12600 0 IRST}
- {2058121800 16200 1 IRDT}
- {2074015800 12600 0 IRST}
- {2089657800 16200 1 IRDT}
- {2105551800 12600 0 IRST}
- {2121193800 16200 1 IRDT}
- {2137087800 12600 0 IRST}
- {2152729800 16200 1 IRDT}
- {2168623800 12600 0 IRST}
- {2184265800 16200 1 IRDT}
- {2200159800 12600 0 IRST}
- {2215888200 16200 1 IRDT}
- {2231782200 12600 0 IRST}
- {2247424200 16200 1 IRDT}
- {2263318200 12600 0 IRST}
- {2278960200 16200 1 IRDT}
- {2294854200 12600 0 IRST}
- {2310496200 16200 1 IRDT}
- {2326390200 12600 0 IRST}
- {2342118600 16200 1 IRDT}
- {2358012600 12600 0 IRST}
- {2373654600 16200 1 IRDT}
- {2389548600 12600 0 IRST}
- {2405190600 16200 1 IRDT}
- {2421084600 12600 0 IRST}
- {2436726600 16200 1 IRDT}
- {2452620600 12600 0 IRST}
- {2468349000 16200 1 IRDT}
- {2484243000 12600 0 IRST}
- {2499885000 16200 1 IRDT}
- {2515779000 12600 0 IRST}
- {2531421000 16200 1 IRDT}
- {2547315000 12600 0 IRST}
- {2562957000 16200 1 IRDT}
- {2578851000 12600 0 IRST}
- {2594579400 16200 1 IRDT}
- {2610473400 12600 0 IRST}
- {2626115400 16200 1 IRDT}
- {2642009400 12600 0 IRST}
- {2657651400 16200 1 IRDT}
- {2673545400 12600 0 IRST}
- {2689187400 16200 1 IRDT}
- {2705081400 12600 0 IRST}
- {2720809800 16200 1 IRDT}
- {2736703800 12600 0 IRST}
- {2752345800 16200 1 IRDT}
- {2768239800 12600 0 IRST}
- {2783881800 16200 1 IRDT}
- {2799775800 12600 0 IRST}
- {2815417800 16200 1 IRDT}
- {2831311800 12600 0 IRST}
- {2847040200 16200 1 IRDT}
- {2862934200 12600 0 IRST}
- {2878576200 16200 1 IRDT}
- {2894470200 12600 0 IRST}
- {2910112200 16200 1 IRDT}
- {2926006200 12600 0 IRST}
- {2941648200 16200 1 IRDT}
- {2957542200 12600 0 IRST}
- {2973270600 16200 1 IRDT}
- {2989164600 12600 0 IRST}
- {3004806600 16200 1 IRDT}
- {3020700600 12600 0 IRST}
- {3036342600 16200 1 IRDT}
- {3052236600 12600 0 IRST}
- {3067878600 16200 1 IRDT}
- {3083772600 12600 0 IRST}
- {3099501000 16200 1 IRDT}
- {3115395000 12600 0 IRST}
- {3131037000 16200 1 IRDT}
- {3146931000 12600 0 IRST}
- {3162573000 16200 1 IRDT}
- {3178467000 12600 0 IRST}
- {3194109000 16200 1 IRDT}
- {3210003000 12600 0 IRST}
- {3225731400 16200 1 IRDT}
- {3241625400 12600 0 IRST}
- {3257267400 16200 1 IRDT}
- {3273161400 12600 0 IRST}
- {3288803400 16200 1 IRDT}
- {3304697400 12600 0 IRST}
- {3320339400 16200 1 IRDT}
- {3336233400 12600 0 IRST}
- {3351961800 16200 1 IRDT}
- {3367855800 12600 0 IRST}
- {3383497800 16200 1 IRDT}
- {3399391800 12600 0 IRST}
- {3415033800 16200 1 IRDT}
- {3430927800 12600 0 IRST}
- {3446569800 16200 1 IRDT}
- {3462463800 12600 0 IRST}
- {3478192200 16200 1 IRDT}
- {3494086200 12600 0 IRST}
- {3509728200 16200 1 IRDT}
- {3525622200 12600 0 IRST}
- {3541264200 16200 1 IRDT}
- {3557158200 12600 0 IRST}
- {3572800200 16200 1 IRDT}
- {3588694200 12600 0 IRST}
- {3604422600 16200 1 IRDT}
- {3620316600 12600 0 IRST}
- {3635958600 16200 1 IRDT}
- {3651852600 12600 0 IRST}
- {3667494600 16200 1 IRDT}
- {3683388600 12600 0 IRST}
- {3699030600 16200 1 IRDT}
- {3714924600 12600 0 IRST}
- {3730653000 16200 1 IRDT}
- {3746547000 12600 0 IRST}
- {3762189000 16200 1 IRDT}
- {3778083000 12600 0 IRST}
- {3793725000 16200 1 IRDT}
- {3809619000 12600 0 IRST}
- {3825261000 16200 1 IRDT}
- {3841155000 12600 0 IRST}
- {3856883400 16200 1 IRDT}
- {3872777400 12600 0 IRST}
- {3888419400 16200 1 IRDT}
- {3904313400 12600 0 IRST}
- {3919955400 16200 1 IRDT}
- {3935849400 12600 0 IRST}
- {3951491400 16200 1 IRDT}
- {3967385400 12600 0 IRST}
- {3983113800 16200 1 IRDT}
- {3999007800 12600 0 IRST}
- {4014649800 16200 1 IRDT}
- {4030543800 12600 0 IRST}
- {4046185800 16200 1 IRDT}
- {4062079800 12600 0 IRST}
- {4077721800 16200 1 IRDT}
- {4093615800 12600 0 IRST}
+ {-757394744 12600 0 +0330}
+ {247177800 14400 0 +05}
+ {259272000 18000 1 +05}
+ {277758000 14400 0 +05}
+ {283982400 12600 0 +0430}
+ {290809800 16200 1 +0430}
+ {306531000 12600 0 +0430}
+ {322432200 16200 1 +0430}
+ {338499000 12600 0 +0430}
+ {673216200 16200 1 +0430}
+ {685481400 12600 0 +0430}
+ {701209800 16200 1 +0430}
+ {717103800 12600 0 +0430}
+ {732745800 16200 1 +0430}
+ {748639800 12600 0 +0430}
+ {764281800 16200 1 +0430}
+ {780175800 12600 0 +0430}
+ {795817800 16200 1 +0430}
+ {811711800 12600 0 +0430}
+ {827353800 16200 1 +0430}
+ {843247800 12600 0 +0430}
+ {858976200 16200 1 +0430}
+ {874870200 12600 0 +0430}
+ {890512200 16200 1 +0430}
+ {906406200 12600 0 +0430}
+ {922048200 16200 1 +0430}
+ {937942200 12600 0 +0430}
+ {953584200 16200 1 +0430}
+ {969478200 12600 0 +0430}
+ {985206600 16200 1 +0430}
+ {1001100600 12600 0 +0430}
+ {1016742600 16200 1 +0430}
+ {1032636600 12600 0 +0430}
+ {1048278600 16200 1 +0430}
+ {1064172600 12600 0 +0430}
+ {1079814600 16200 1 +0430}
+ {1095708600 12600 0 +0430}
+ {1111437000 16200 1 +0430}
+ {1127331000 12600 0 +0430}
+ {1206045000 16200 1 +0430}
+ {1221939000 12600 0 +0430}
+ {1237667400 16200 1 +0430}
+ {1253561400 12600 0 +0430}
+ {1269203400 16200 1 +0430}
+ {1285097400 12600 0 +0430}
+ {1300739400 16200 1 +0430}
+ {1316633400 12600 0 +0430}
+ {1332275400 16200 1 +0430}
+ {1348169400 12600 0 +0430}
+ {1363897800 16200 1 +0430}
+ {1379791800 12600 0 +0430}
+ {1395433800 16200 1 +0430}
+ {1411327800 12600 0 +0430}
+ {1426969800 16200 1 +0430}
+ {1442863800 12600 0 +0430}
+ {1458505800 16200 1 +0430}
+ {1474399800 12600 0 +0430}
+ {1490128200 16200 1 +0430}
+ {1506022200 12600 0 +0430}
+ {1521664200 16200 1 +0430}
+ {1537558200 12600 0 +0430}
+ {1553200200 16200 1 +0430}
+ {1569094200 12600 0 +0430}
+ {1584736200 16200 1 +0430}
+ {1600630200 12600 0 +0430}
+ {1616358600 16200 1 +0430}
+ {1632252600 12600 0 +0430}
+ {1647894600 16200 1 +0430}
+ {1663788600 12600 0 +0430}
+ {1679430600 16200 1 +0430}
+ {1695324600 12600 0 +0430}
+ {1710966600 16200 1 +0430}
+ {1726860600 12600 0 +0430}
+ {1742589000 16200 1 +0430}
+ {1758483000 12600 0 +0430}
+ {1774125000 16200 1 +0430}
+ {1790019000 12600 0 +0430}
+ {1805661000 16200 1 +0430}
+ {1821555000 12600 0 +0430}
+ {1837197000 16200 1 +0430}
+ {1853091000 12600 0 +0430}
+ {1868733000 16200 1 +0430}
+ {1884627000 12600 0 +0430}
+ {1900355400 16200 1 +0430}
+ {1916249400 12600 0 +0430}
+ {1931891400 16200 1 +0430}
+ {1947785400 12600 0 +0430}
+ {1963427400 16200 1 +0430}
+ {1979321400 12600 0 +0430}
+ {1994963400 16200 1 +0430}
+ {2010857400 12600 0 +0430}
+ {2026585800 16200 1 +0430}
+ {2042479800 12600 0 +0430}
+ {2058121800 16200 1 +0430}
+ {2074015800 12600 0 +0430}
+ {2089657800 16200 1 +0430}
+ {2105551800 12600 0 +0430}
+ {2121193800 16200 1 +0430}
+ {2137087800 12600 0 +0430}
+ {2152729800 16200 1 +0430}
+ {2168623800 12600 0 +0430}
+ {2184265800 16200 1 +0430}
+ {2200159800 12600 0 +0430}
+ {2215888200 16200 1 +0430}
+ {2231782200 12600 0 +0430}
+ {2247424200 16200 1 +0430}
+ {2263318200 12600 0 +0430}
+ {2278960200 16200 1 +0430}
+ {2294854200 12600 0 +0430}
+ {2310496200 16200 1 +0430}
+ {2326390200 12600 0 +0430}
+ {2342118600 16200 1 +0430}
+ {2358012600 12600 0 +0430}
+ {2373654600 16200 1 +0430}
+ {2389548600 12600 0 +0430}
+ {2405190600 16200 1 +0430}
+ {2421084600 12600 0 +0430}
+ {2436726600 16200 1 +0430}
+ {2452620600 12600 0 +0430}
+ {2468349000 16200 1 +0430}
+ {2484243000 12600 0 +0430}
+ {2499885000 16200 1 +0430}
+ {2515779000 12600 0 +0430}
+ {2531421000 16200 1 +0430}
+ {2547315000 12600 0 +0430}
+ {2562957000 16200 1 +0430}
+ {2578851000 12600 0 +0430}
+ {2594579400 16200 1 +0430}
+ {2610473400 12600 0 +0430}
+ {2626115400 16200 1 +0430}
+ {2642009400 12600 0 +0430}
+ {2657651400 16200 1 +0430}
+ {2673545400 12600 0 +0430}
+ {2689187400 16200 1 +0430}
+ {2705081400 12600 0 +0430}
+ {2720809800 16200 1 +0430}
+ {2736703800 12600 0 +0430}
+ {2752345800 16200 1 +0430}
+ {2768239800 12600 0 +0430}
+ {2783881800 16200 1 +0430}
+ {2799775800 12600 0 +0430}
+ {2815417800 16200 1 +0430}
+ {2831311800 12600 0 +0430}
+ {2847040200 16200 1 +0430}
+ {2862934200 12600 0 +0430}
+ {2878576200 16200 1 +0430}
+ {2894470200 12600 0 +0430}
+ {2910112200 16200 1 +0430}
+ {2926006200 12600 0 +0430}
+ {2941648200 16200 1 +0430}
+ {2957542200 12600 0 +0430}
+ {2973270600 16200 1 +0430}
+ {2989164600 12600 0 +0430}
+ {3004806600 16200 1 +0430}
+ {3020700600 12600 0 +0430}
+ {3036342600 16200 1 +0430}
+ {3052236600 12600 0 +0430}
+ {3067878600 16200 1 +0430}
+ {3083772600 12600 0 +0430}
+ {3099501000 16200 1 +0430}
+ {3115395000 12600 0 +0430}
+ {3131037000 16200 1 +0430}
+ {3146931000 12600 0 +0430}
+ {3162573000 16200 1 +0430}
+ {3178467000 12600 0 +0430}
+ {3194109000 16200 1 +0430}
+ {3210003000 12600 0 +0430}
+ {3225731400 16200 1 +0430}
+ {3241625400 12600 0 +0430}
+ {3257267400 16200 1 +0430}
+ {3273161400 12600 0 +0430}
+ {3288803400 16200 1 +0430}
+ {3304697400 12600 0 +0430}
+ {3320339400 16200 1 +0430}
+ {3336233400 12600 0 +0430}
+ {3351961800 16200 1 +0430}
+ {3367855800 12600 0 +0430}
+ {3383497800 16200 1 +0430}
+ {3399391800 12600 0 +0430}
+ {3415033800 16200 1 +0430}
+ {3430927800 12600 0 +0430}
+ {3446569800 16200 1 +0430}
+ {3462463800 12600 0 +0430}
+ {3478192200 16200 1 +0430}
+ {3494086200 12600 0 +0430}
+ {3509728200 16200 1 +0430}
+ {3525622200 12600 0 +0430}
+ {3541264200 16200 1 +0430}
+ {3557158200 12600 0 +0430}
+ {3572800200 16200 1 +0430}
+ {3588694200 12600 0 +0430}
+ {3604422600 16200 1 +0430}
+ {3620316600 12600 0 +0430}
+ {3635958600 16200 1 +0430}
+ {3651852600 12600 0 +0430}
+ {3667494600 16200 1 +0430}
+ {3683388600 12600 0 +0430}
+ {3699030600 16200 1 +0430}
+ {3714924600 12600 0 +0430}
+ {3730653000 16200 1 +0430}
+ {3746547000 12600 0 +0430}
+ {3762189000 16200 1 +0430}
+ {3778083000 12600 0 +0430}
+ {3793725000 16200 1 +0430}
+ {3809619000 12600 0 +0430}
+ {3825261000 16200 1 +0430}
+ {3841155000 12600 0 +0430}
+ {3856883400 16200 1 +0430}
+ {3872777400 12600 0 +0430}
+ {3888419400 16200 1 +0430}
+ {3904313400 12600 0 +0430}
+ {3919955400 16200 1 +0430}
+ {3935849400 12600 0 +0430}
+ {3951491400 16200 1 +0430}
+ {3967385400 12600 0 +0430}
+ {3983113800 16200 1 +0430}
+ {3999007800 12600 0 +0430}
+ {4014649800 16200 1 +0430}
+ {4030543800 12600 0 +0430}
+ {4046185800 16200 1 +0430}
+ {4062079800 12600 0 +0430}
+ {4077721800 16200 1 +0430}
+ {4093615800 12600 0 +0430}
}
diff --git a/library/tzdata/Asia/Thimphu b/library/tzdata/Asia/Thimphu
index 8c981de..55c3d7f 100644
--- a/library/tzdata/Asia/Thimphu
+++ b/library/tzdata/Asia/Thimphu
@@ -2,6 +2,6 @@
set TZData(:Asia/Thimphu) {
{-9223372036854775808 21516 0 LMT}
- {-706341516 19800 0 IST}
- {560025000 21600 0 BTT}
+ {-706341516 19800 0 +0530}
+ {560025000 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Tokyo b/library/tzdata/Asia/Tokyo
index 5bfc75c..10add1c 100644
--- a/library/tzdata/Asia/Tokyo
+++ b/library/tzdata/Asia/Tokyo
@@ -3,8 +3,6 @@
set TZData(:Asia/Tokyo) {
{-9223372036854775808 33539 0 LMT}
{-2587712400 32400 0 JST}
- {-2335251600 32400 0 JCST}
- {-1017824400 32400 0 JST}
{-683794800 36000 1 JDT}
{-672393600 32400 0 JST}
{-654764400 36000 1 JDT}
diff --git a/library/tzdata/Asia/Ulaanbaatar b/library/tzdata/Asia/Ulaanbaatar
index 93e066c..e0ba7ab 100644
--- a/library/tzdata/Asia/Ulaanbaatar
+++ b/library/tzdata/Asia/Ulaanbaatar
@@ -2,220 +2,54 @@
set TZData(:Asia/Ulaanbaatar) {
{-9223372036854775808 25652 0 LMT}
- {-2032931252 25200 0 ULAT}
- {252435600 28800 0 ULAT}
- {417974400 32400 1 ULAST}
- {433782000 28800 0 ULAT}
- {449596800 32400 1 ULAST}
- {465318000 28800 0 ULAT}
- {481046400 32400 1 ULAST}
- {496767600 28800 0 ULAT}
- {512496000 32400 1 ULAST}
- {528217200 28800 0 ULAT}
- {543945600 32400 1 ULAST}
- {559666800 28800 0 ULAT}
- {575395200 32400 1 ULAST}
- {591116400 28800 0 ULAT}
- {606844800 32400 1 ULAST}
- {622566000 28800 0 ULAT}
- {638294400 32400 1 ULAST}
- {654620400 28800 0 ULAT}
- {670348800 32400 1 ULAST}
- {686070000 28800 0 ULAT}
- {701798400 32400 1 ULAST}
- {717519600 28800 0 ULAT}
- {733248000 32400 1 ULAST}
- {748969200 28800 0 ULAT}
- {764697600 32400 1 ULAST}
- {780418800 28800 0 ULAT}
- {796147200 32400 1 ULAST}
- {811868400 28800 0 ULAT}
- {828201600 32400 1 ULAST}
- {843922800 28800 0 ULAT}
- {859651200 32400 1 ULAST}
- {875372400 28800 0 ULAT}
- {891100800 32400 1 ULAST}
- {906822000 28800 0 ULAT}
- {988394400 32400 1 ULAST}
- {1001696400 28800 0 ULAT}
- {1017424800 32400 1 ULAST}
- {1033146000 28800 0 ULAT}
- {1048874400 32400 1 ULAST}
- {1064595600 28800 0 ULAT}
- {1080324000 32400 1 ULAST}
- {1096045200 28800 0 ULAT}
- {1111773600 32400 1 ULAST}
- {1127494800 28800 0 ULAT}
- {1143223200 32400 1 ULAST}
- {1159549200 28800 0 ULAT}
- {1427479200 32400 1 ULAST}
- {1443193200 28800 0 ULAT}
- {1458928800 32400 1 ULAST}
- {1474642800 28800 0 ULAT}
- {1490378400 32400 1 ULAST}
- {1506697200 28800 0 ULAT}
- {1522432800 32400 1 ULAST}
- {1538146800 28800 0 ULAT}
- {1553882400 32400 1 ULAST}
- {1569596400 28800 0 ULAT}
- {1585332000 32400 1 ULAST}
- {1601046000 28800 0 ULAT}
- {1616781600 32400 1 ULAST}
- {1632495600 28800 0 ULAT}
- {1648231200 32400 1 ULAST}
- {1663945200 28800 0 ULAT}
- {1679680800 32400 1 ULAST}
- {1695999600 28800 0 ULAT}
- {1711735200 32400 1 ULAST}
- {1727449200 28800 0 ULAT}
- {1743184800 32400 1 ULAST}
- {1758898800 28800 0 ULAT}
- {1774634400 32400 1 ULAST}
- {1790348400 28800 0 ULAT}
- {1806084000 32400 1 ULAST}
- {1821798000 28800 0 ULAT}
- {1837533600 32400 1 ULAST}
- {1853852400 28800 0 ULAT}
- {1869588000 32400 1 ULAST}
- {1885302000 28800 0 ULAT}
- {1901037600 32400 1 ULAST}
- {1916751600 28800 0 ULAT}
- {1932487200 32400 1 ULAST}
- {1948201200 28800 0 ULAT}
- {1963936800 32400 1 ULAST}
- {1979650800 28800 0 ULAT}
- {1995386400 32400 1 ULAST}
- {2011100400 28800 0 ULAT}
- {2026836000 32400 1 ULAST}
- {2043154800 28800 0 ULAT}
- {2058890400 32400 1 ULAST}
- {2074604400 28800 0 ULAT}
- {2090340000 32400 1 ULAST}
- {2106054000 28800 0 ULAT}
- {2121789600 32400 1 ULAST}
- {2137503600 28800 0 ULAT}
- {2153239200 32400 1 ULAST}
- {2168953200 28800 0 ULAT}
- {2184688800 32400 1 ULAST}
- {2200402800 28800 0 ULAT}
- {2216743200 32400 1 ULAST}
- {2232457200 28800 0 ULAT}
- {2248192800 32400 1 ULAST}
- {2263906800 28800 0 ULAT}
- {2279642400 32400 1 ULAST}
- {2295356400 28800 0 ULAT}
- {2311092000 32400 1 ULAST}
- {2326806000 28800 0 ULAT}
- {2342541600 32400 1 ULAST}
- {2358255600 28800 0 ULAT}
- {2373991200 32400 1 ULAST}
- {2390310000 28800 0 ULAT}
- {2406045600 32400 1 ULAST}
- {2421759600 28800 0 ULAT}
- {2437495200 32400 1 ULAST}
- {2453209200 28800 0 ULAT}
- {2468944800 32400 1 ULAST}
- {2484658800 28800 0 ULAT}
- {2500394400 32400 1 ULAST}
- {2516108400 28800 0 ULAT}
- {2531844000 32400 1 ULAST}
- {2547558000 28800 0 ULAT}
- {2563293600 32400 1 ULAST}
- {2579612400 28800 0 ULAT}
- {2595348000 32400 1 ULAST}
- {2611062000 28800 0 ULAT}
- {2626797600 32400 1 ULAST}
- {2642511600 28800 0 ULAT}
- {2658247200 32400 1 ULAST}
- {2673961200 28800 0 ULAT}
- {2689696800 32400 1 ULAST}
- {2705410800 28800 0 ULAT}
- {2721146400 32400 1 ULAST}
- {2737465200 28800 0 ULAT}
- {2753200800 32400 1 ULAST}
- {2768914800 28800 0 ULAT}
- {2784650400 32400 1 ULAST}
- {2800364400 28800 0 ULAT}
- {2816100000 32400 1 ULAST}
- {2831814000 28800 0 ULAT}
- {2847549600 32400 1 ULAST}
- {2863263600 28800 0 ULAT}
- {2878999200 32400 1 ULAST}
- {2894713200 28800 0 ULAT}
- {2910448800 32400 1 ULAST}
- {2926767600 28800 0 ULAT}
- {2942503200 32400 1 ULAST}
- {2958217200 28800 0 ULAT}
- {2973952800 32400 1 ULAST}
- {2989666800 28800 0 ULAT}
- {3005402400 32400 1 ULAST}
- {3021116400 28800 0 ULAT}
- {3036852000 32400 1 ULAST}
- {3052566000 28800 0 ULAT}
- {3068301600 32400 1 ULAST}
- {3084015600 28800 0 ULAT}
- {3100356000 32400 1 ULAST}
- {3116070000 28800 0 ULAT}
- {3131805600 32400 1 ULAST}
- {3147519600 28800 0 ULAT}
- {3163255200 32400 1 ULAST}
- {3178969200 28800 0 ULAT}
- {3194704800 32400 1 ULAST}
- {3210418800 28800 0 ULAT}
- {3226154400 32400 1 ULAST}
- {3241868400 28800 0 ULAT}
- {3257604000 32400 1 ULAST}
- {3273922800 28800 0 ULAT}
- {3289658400 32400 1 ULAST}
- {3305372400 28800 0 ULAT}
- {3321108000 32400 1 ULAST}
- {3336822000 28800 0 ULAT}
- {3352557600 32400 1 ULAST}
- {3368271600 28800 0 ULAT}
- {3384007200 32400 1 ULAST}
- {3399721200 28800 0 ULAT}
- {3415456800 32400 1 ULAST}
- {3431170800 28800 0 ULAT}
- {3446906400 32400 1 ULAST}
- {3463225200 28800 0 ULAT}
- {3478960800 32400 1 ULAST}
- {3494674800 28800 0 ULAT}
- {3510410400 32400 1 ULAST}
- {3526124400 28800 0 ULAT}
- {3541860000 32400 1 ULAST}
- {3557574000 28800 0 ULAT}
- {3573309600 32400 1 ULAST}
- {3589023600 28800 0 ULAT}
- {3604759200 32400 1 ULAST}
- {3621078000 28800 0 ULAT}
- {3636813600 32400 1 ULAST}
- {3652527600 28800 0 ULAT}
- {3668263200 32400 1 ULAST}
- {3683977200 28800 0 ULAT}
- {3699712800 32400 1 ULAST}
- {3715426800 28800 0 ULAT}
- {3731162400 32400 1 ULAST}
- {3746876400 28800 0 ULAT}
- {3762612000 32400 1 ULAST}
- {3778326000 28800 0 ULAT}
- {3794061600 32400 1 ULAST}
- {3810380400 28800 0 ULAT}
- {3826116000 32400 1 ULAST}
- {3841830000 28800 0 ULAT}
- {3857565600 32400 1 ULAST}
- {3873279600 28800 0 ULAT}
- {3889015200 32400 1 ULAST}
- {3904729200 28800 0 ULAT}
- {3920464800 32400 1 ULAST}
- {3936178800 28800 0 ULAT}
- {3951914400 32400 1 ULAST}
- {3967628400 28800 0 ULAT}
- {3983968800 32400 1 ULAST}
- {3999682800 28800 0 ULAT}
- {4015418400 32400 1 ULAST}
- {4031132400 28800 0 ULAT}
- {4046868000 32400 1 ULAST}
- {4062582000 28800 0 ULAT}
- {4078317600 32400 1 ULAST}
- {4094031600 28800 0 ULAT}
+ {-2032931252 25200 0 +07}
+ {252435600 28800 0 +08}
+ {417974400 32400 1 +09}
+ {433782000 28800 0 +08}
+ {449596800 32400 1 +09}
+ {465318000 28800 0 +08}
+ {481046400 32400 1 +09}
+ {496767600 28800 0 +08}
+ {512496000 32400 1 +09}
+ {528217200 28800 0 +08}
+ {543945600 32400 1 +09}
+ {559666800 28800 0 +08}
+ {575395200 32400 1 +09}
+ {591116400 28800 0 +08}
+ {606844800 32400 1 +09}
+ {622566000 28800 0 +08}
+ {638294400 32400 1 +09}
+ {654620400 28800 0 +08}
+ {670348800 32400 1 +09}
+ {686070000 28800 0 +08}
+ {701798400 32400 1 +09}
+ {717519600 28800 0 +08}
+ {733248000 32400 1 +09}
+ {748969200 28800 0 +08}
+ {764697600 32400 1 +09}
+ {780418800 28800 0 +08}
+ {796147200 32400 1 +09}
+ {811868400 28800 0 +08}
+ {828201600 32400 1 +09}
+ {843922800 28800 0 +08}
+ {859651200 32400 1 +09}
+ {875372400 28800 0 +08}
+ {891100800 32400 1 +09}
+ {906822000 28800 0 +08}
+ {988394400 32400 1 +09}
+ {1001696400 28800 0 +08}
+ {1017424800 32400 1 +09}
+ {1033146000 28800 0 +08}
+ {1048874400 32400 1 +09}
+ {1064595600 28800 0 +08}
+ {1080324000 32400 1 +09}
+ {1096045200 28800 0 +08}
+ {1111773600 32400 1 +09}
+ {1127494800 28800 0 +08}
+ {1143223200 32400 1 +09}
+ {1159549200 28800 0 +08}
+ {1427479200 32400 1 +09}
+ {1443193200 28800 0 +08}
+ {1458928800 32400 1 +09}
+ {1474642800 28800 0 +08}
}
diff --git a/library/tzdata/Asia/Urumqi b/library/tzdata/Asia/Urumqi
index 4f3cd67..194e090 100644
--- a/library/tzdata/Asia/Urumqi
+++ b/library/tzdata/Asia/Urumqi
@@ -2,5 +2,5 @@
set TZData(:Asia/Urumqi) {
{-9223372036854775808 21020 0 LMT}
- {-1325483420 21600 0 XJT}
+ {-1325483420 21600 0 +06}
}
diff --git a/library/tzdata/Asia/Ust-Nera b/library/tzdata/Asia/Ust-Nera
index 3380b7b..021fa62 100644
--- a/library/tzdata/Asia/Ust-Nera
+++ b/library/tzdata/Asia/Ust-Nera
@@ -2,70 +2,70 @@
set TZData(:Asia/Ust-Nera) {
{-9223372036854775808 34374 0 LMT}
- {-1579426374 28800 0 YAKT}
- {354898800 43200 0 MAGST}
- {370699200 39600 0 MAGT}
- {386427600 43200 1 MAGST}
- {402235200 39600 0 MAGT}
- {417963600 43200 1 MAGST}
- {433771200 39600 0 MAGT}
- {449586000 43200 1 MAGST}
- {465318000 39600 0 MAGT}
- {481042800 43200 1 MAGST}
- {496767600 39600 0 MAGT}
- {512492400 43200 1 MAGST}
- {528217200 39600 0 MAGT}
- {543942000 43200 1 MAGST}
- {559666800 39600 0 MAGT}
- {575391600 43200 1 MAGST}
- {591116400 39600 0 MAGT}
- {606841200 43200 1 MAGST}
- {622566000 39600 0 MAGT}
- {638290800 43200 1 MAGST}
- {654620400 39600 0 MAGT}
- {670345200 36000 0 MAGMMTT}
- {670348800 39600 1 MAGST}
- {686073600 36000 0 MAGT}
- {695750400 39600 0 MAGMMTT}
- {701794800 43200 1 MAGST}
- {717519600 39600 0 MAGT}
- {733244400 43200 1 MAGST}
- {748969200 39600 0 MAGT}
- {764694000 43200 1 MAGST}
- {780418800 39600 0 MAGT}
- {796143600 43200 1 MAGST}
- {811868400 39600 0 MAGT}
- {828198000 43200 1 MAGST}
- {846342000 39600 0 MAGT}
- {859647600 43200 1 MAGST}
- {877791600 39600 0 MAGT}
- {891097200 43200 1 MAGST}
- {909241200 39600 0 MAGT}
- {922546800 43200 1 MAGST}
- {941295600 39600 0 MAGT}
- {953996400 43200 1 MAGST}
- {972745200 39600 0 MAGT}
- {985446000 43200 1 MAGST}
- {1004194800 39600 0 MAGT}
- {1017500400 43200 1 MAGST}
- {1035644400 39600 0 MAGT}
- {1048950000 43200 1 MAGST}
- {1067094000 39600 0 MAGT}
- {1080399600 43200 1 MAGST}
- {1099148400 39600 0 MAGT}
- {1111849200 43200 1 MAGST}
- {1130598000 39600 0 MAGT}
- {1143298800 43200 1 MAGST}
- {1162047600 39600 0 MAGT}
- {1174748400 43200 1 MAGST}
- {1193497200 39600 0 MAGT}
- {1206802800 43200 1 MAGST}
- {1224946800 39600 0 MAGT}
- {1238252400 43200 1 MAGST}
- {1256396400 39600 0 MAGT}
- {1269702000 43200 1 MAGST}
- {1288450800 39600 0 MAGT}
- {1301151600 43200 0 MAGT}
- {1315828800 39600 0 VLAT}
- {1414249200 36000 0 VLAT}
+ {-1579426374 28800 0 +08}
+ {354898800 43200 0 +12}
+ {370699200 39600 0 +11}
+ {386427600 43200 1 +12}
+ {402235200 39600 0 +11}
+ {417963600 43200 1 +12}
+ {433771200 39600 0 +11}
+ {449586000 43200 1 +12}
+ {465318000 39600 0 +11}
+ {481042800 43200 1 +12}
+ {496767600 39600 0 +11}
+ {512492400 43200 1 +12}
+ {528217200 39600 0 +11}
+ {543942000 43200 1 +12}
+ {559666800 39600 0 +11}
+ {575391600 43200 1 +12}
+ {591116400 39600 0 +11}
+ {606841200 43200 1 +12}
+ {622566000 39600 0 +11}
+ {638290800 43200 1 +12}
+ {654620400 39600 0 +11}
+ {670345200 36000 0 +11}
+ {670348800 39600 1 +11}
+ {686073600 36000 0 +10}
+ {695750400 39600 0 +12}
+ {701794800 43200 1 +12}
+ {717519600 39600 0 +11}
+ {733244400 43200 1 +12}
+ {748969200 39600 0 +11}
+ {764694000 43200 1 +12}
+ {780418800 39600 0 +11}
+ {796143600 43200 1 +12}
+ {811868400 39600 0 +11}
+ {828198000 43200 1 +12}
+ {846342000 39600 0 +11}
+ {859647600 43200 1 +12}
+ {877791600 39600 0 +11}
+ {891097200 43200 1 +12}
+ {909241200 39600 0 +11}
+ {922546800 43200 1 +12}
+ {941295600 39600 0 +11}
+ {953996400 43200 1 +12}
+ {972745200 39600 0 +11}
+ {985446000 43200 1 +12}
+ {1004194800 39600 0 +11}
+ {1017500400 43200 1 +12}
+ {1035644400 39600 0 +11}
+ {1048950000 43200 1 +12}
+ {1067094000 39600 0 +11}
+ {1080399600 43200 1 +12}
+ {1099148400 39600 0 +11}
+ {1111849200 43200 1 +12}
+ {1130598000 39600 0 +11}
+ {1143298800 43200 1 +12}
+ {1162047600 39600 0 +11}
+ {1174748400 43200 1 +12}
+ {1193497200 39600 0 +11}
+ {1206802800 43200 1 +12}
+ {1224946800 39600 0 +11}
+ {1238252400 43200 1 +12}
+ {1256396400 39600 0 +11}
+ {1269702000 43200 1 +12}
+ {1288450800 39600 0 +11}
+ {1301151600 43200 0 +12}
+ {1315828800 39600 0 +11}
+ {1414249200 36000 0 +10}
}
diff --git a/library/tzdata/Asia/Vladivostok b/library/tzdata/Asia/Vladivostok
index b279d1c..e8f651c 100644
--- a/library/tzdata/Asia/Vladivostok
+++ b/library/tzdata/Asia/Vladivostok
@@ -2,70 +2,70 @@
set TZData(:Asia/Vladivostok) {
{-9223372036854775808 31651 0 LMT}
- {-1487321251 32400 0 VLAT}
- {-1247562000 36000 0 VLAMMTT}
- {354895200 39600 1 VLAST}
- {370702800 36000 0 VLAT}
- {386431200 39600 1 VLAST}
- {402238800 36000 0 VLAT}
- {417967200 39600 1 VLAST}
- {433774800 36000 0 VLAT}
- {449589600 39600 1 VLAST}
- {465321600 36000 0 VLAT}
- {481046400 39600 1 VLAST}
- {496771200 36000 0 VLAT}
- {512496000 39600 1 VLAST}
- {528220800 36000 0 VLAT}
- {543945600 39600 1 VLAST}
- {559670400 36000 0 VLAT}
- {575395200 39600 1 VLAST}
- {591120000 36000 0 VLAT}
- {606844800 39600 1 VLAST}
- {622569600 36000 0 VLAT}
- {638294400 39600 1 VLAST}
- {654624000 36000 0 VLAT}
- {670348800 32400 0 VLAMMTT}
- {670352400 36000 1 VLAST}
- {686077200 32400 0 VLAT}
- {695754000 36000 0 VLAMMTT}
- {701798400 39600 1 VLAST}
- {717523200 36000 0 VLAT}
- {733248000 39600 1 VLAST}
- {748972800 36000 0 VLAT}
- {764697600 39600 1 VLAST}
- {780422400 36000 0 VLAT}
- {796147200 39600 1 VLAST}
- {811872000 36000 0 VLAT}
- {828201600 39600 1 VLAST}
- {846345600 36000 0 VLAT}
- {859651200 39600 1 VLAST}
- {877795200 36000 0 VLAT}
- {891100800 39600 1 VLAST}
- {909244800 36000 0 VLAT}
- {922550400 39600 1 VLAST}
- {941299200 36000 0 VLAT}
- {954000000 39600 1 VLAST}
- {972748800 36000 0 VLAT}
- {985449600 39600 1 VLAST}
- {1004198400 36000 0 VLAT}
- {1017504000 39600 1 VLAST}
- {1035648000 36000 0 VLAT}
- {1048953600 39600 1 VLAST}
- {1067097600 36000 0 VLAT}
- {1080403200 39600 1 VLAST}
- {1099152000 36000 0 VLAT}
- {1111852800 39600 1 VLAST}
- {1130601600 36000 0 VLAT}
- {1143302400 39600 1 VLAST}
- {1162051200 36000 0 VLAT}
- {1174752000 39600 1 VLAST}
- {1193500800 36000 0 VLAT}
- {1206806400 39600 1 VLAST}
- {1224950400 36000 0 VLAT}
- {1238256000 39600 1 VLAST}
- {1256400000 36000 0 VLAT}
- {1269705600 39600 1 VLAST}
- {1288454400 36000 0 VLAT}
- {1301155200 39600 0 VLAT}
- {1414249200 36000 0 VLAT}
+ {-1487321251 32400 0 +09}
+ {-1247562000 36000 0 +11}
+ {354895200 39600 1 +11}
+ {370702800 36000 0 +10}
+ {386431200 39600 1 +11}
+ {402238800 36000 0 +10}
+ {417967200 39600 1 +11}
+ {433774800 36000 0 +10}
+ {449589600 39600 1 +11}
+ {465321600 36000 0 +10}
+ {481046400 39600 1 +11}
+ {496771200 36000 0 +10}
+ {512496000 39600 1 +11}
+ {528220800 36000 0 +10}
+ {543945600 39600 1 +11}
+ {559670400 36000 0 +10}
+ {575395200 39600 1 +11}
+ {591120000 36000 0 +10}
+ {606844800 39600 1 +11}
+ {622569600 36000 0 +10}
+ {638294400 39600 1 +11}
+ {654624000 36000 0 +10}
+ {670348800 32400 0 +10}
+ {670352400 36000 1 +10}
+ {686077200 32400 0 +09}
+ {695754000 36000 0 +11}
+ {701798400 39600 1 +11}
+ {717523200 36000 0 +10}
+ {733248000 39600 1 +11}
+ {748972800 36000 0 +10}
+ {764697600 39600 1 +11}
+ {780422400 36000 0 +10}
+ {796147200 39600 1 +11}
+ {811872000 36000 0 +10}
+ {828201600 39600 1 +11}
+ {846345600 36000 0 +10}
+ {859651200 39600 1 +11}
+ {877795200 36000 0 +10}
+ {891100800 39600 1 +11}
+ {909244800 36000 0 +10}
+ {922550400 39600 1 +11}
+ {941299200 36000 0 +10}
+ {954000000 39600 1 +11}
+ {972748800 36000 0 +10}
+ {985449600 39600 1 +11}
+ {1004198400 36000 0 +10}
+ {1017504000 39600 1 +11}
+ {1035648000 36000 0 +10}
+ {1048953600 39600 1 +11}
+ {1067097600 36000 0 +10}
+ {1080403200 39600 1 +11}
+ {1099152000 36000 0 +10}
+ {1111852800 39600 1 +11}
+ {1130601600 36000 0 +10}
+ {1143302400 39600 1 +11}
+ {1162051200 36000 0 +10}
+ {1174752000 39600 1 +11}
+ {1193500800 36000 0 +10}
+ {1206806400 39600 1 +11}
+ {1224950400 36000 0 +10}
+ {1238256000 39600 1 +11}
+ {1256400000 36000 0 +10}
+ {1269705600 39600 1 +11}
+ {1288454400 36000 0 +10}
+ {1301155200 39600 0 +11}
+ {1414249200 36000 0 +10}
}
diff --git a/library/tzdata/Asia/Yakutsk b/library/tzdata/Asia/Yakutsk
index 0074379..8ee153a 100644
--- a/library/tzdata/Asia/Yakutsk
+++ b/library/tzdata/Asia/Yakutsk
@@ -2,70 +2,70 @@
set TZData(:Asia/Yakutsk) {
{-9223372036854775808 31138 0 LMT}
- {-1579423138 28800 0 YAKT}
- {-1247558400 32400 0 YAKMMTT}
- {354898800 36000 1 YAKST}
- {370706400 32400 0 YAKT}
- {386434800 36000 1 YAKST}
- {402242400 32400 0 YAKT}
- {417970800 36000 1 YAKST}
- {433778400 32400 0 YAKT}
- {449593200 36000 1 YAKST}
- {465325200 32400 0 YAKT}
- {481050000 36000 1 YAKST}
- {496774800 32400 0 YAKT}
- {512499600 36000 1 YAKST}
- {528224400 32400 0 YAKT}
- {543949200 36000 1 YAKST}
- {559674000 32400 0 YAKT}
- {575398800 36000 1 YAKST}
- {591123600 32400 0 YAKT}
- {606848400 36000 1 YAKST}
- {622573200 32400 0 YAKT}
- {638298000 36000 1 YAKST}
- {654627600 32400 0 YAKT}
- {670352400 28800 0 YAKMMTT}
- {670356000 32400 1 YAKST}
- {686080800 28800 0 YAKT}
- {695757600 32400 0 YAKMMTT}
- {701802000 36000 1 YAKST}
- {717526800 32400 0 YAKT}
- {733251600 36000 1 YAKST}
- {748976400 32400 0 YAKT}
- {764701200 36000 1 YAKST}
- {780426000 32400 0 YAKT}
- {796150800 36000 1 YAKST}
- {811875600 32400 0 YAKT}
- {828205200 36000 1 YAKST}
- {846349200 32400 0 YAKT}
- {859654800 36000 1 YAKST}
- {877798800 32400 0 YAKT}
- {891104400 36000 1 YAKST}
- {909248400 32400 0 YAKT}
- {922554000 36000 1 YAKST}
- {941302800 32400 0 YAKT}
- {954003600 36000 1 YAKST}
- {972752400 32400 0 YAKT}
- {985453200 36000 1 YAKST}
- {1004202000 32400 0 YAKT}
- {1017507600 36000 1 YAKST}
- {1035651600 32400 0 YAKT}
- {1048957200 36000 1 YAKST}
- {1067101200 32400 0 YAKT}
- {1080406800 36000 1 YAKST}
- {1099155600 32400 0 YAKT}
- {1111856400 36000 1 YAKST}
- {1130605200 32400 0 YAKT}
- {1143306000 36000 1 YAKST}
- {1162054800 32400 0 YAKT}
- {1174755600 36000 1 YAKST}
- {1193504400 32400 0 YAKT}
- {1206810000 36000 1 YAKST}
- {1224954000 32400 0 YAKT}
- {1238259600 36000 1 YAKST}
- {1256403600 32400 0 YAKT}
- {1269709200 36000 1 YAKST}
- {1288458000 32400 0 YAKT}
- {1301158800 36000 0 YAKT}
- {1414252800 32400 0 YAKT}
+ {-1579423138 28800 0 +08}
+ {-1247558400 32400 0 +10}
+ {354898800 36000 1 +10}
+ {370706400 32400 0 +09}
+ {386434800 36000 1 +10}
+ {402242400 32400 0 +09}
+ {417970800 36000 1 +10}
+ {433778400 32400 0 +09}
+ {449593200 36000 1 +10}
+ {465325200 32400 0 +09}
+ {481050000 36000 1 +10}
+ {496774800 32400 0 +09}
+ {512499600 36000 1 +10}
+ {528224400 32400 0 +09}
+ {543949200 36000 1 +10}
+ {559674000 32400 0 +09}
+ {575398800 36000 1 +10}
+ {591123600 32400 0 +09}
+ {606848400 36000 1 +10}
+ {622573200 32400 0 +09}
+ {638298000 36000 1 +10}
+ {654627600 32400 0 +09}
+ {670352400 28800 0 +09}
+ {670356000 32400 1 +09}
+ {686080800 28800 0 +08}
+ {695757600 32400 0 +10}
+ {701802000 36000 1 +10}
+ {717526800 32400 0 +09}
+ {733251600 36000 1 +10}
+ {748976400 32400 0 +09}
+ {764701200 36000 1 +10}
+ {780426000 32400 0 +09}
+ {796150800 36000 1 +10}
+ {811875600 32400 0 +09}
+ {828205200 36000 1 +10}
+ {846349200 32400 0 +09}
+ {859654800 36000 1 +10}
+ {877798800 32400 0 +09}
+ {891104400 36000 1 +10}
+ {909248400 32400 0 +09}
+ {922554000 36000 1 +10}
+ {941302800 32400 0 +09}
+ {954003600 36000 1 +10}
+ {972752400 32400 0 +09}
+ {985453200 36000 1 +10}
+ {1004202000 32400 0 +09}
+ {1017507600 36000 1 +10}
+ {1035651600 32400 0 +09}
+ {1048957200 36000 1 +10}
+ {1067101200 32400 0 +09}
+ {1080406800 36000 1 +10}
+ {1099155600 32400 0 +09}
+ {1111856400 36000 1 +10}
+ {1130605200 32400 0 +09}
+ {1143306000 36000 1 +10}
+ {1162054800 32400 0 +09}
+ {1174755600 36000 1 +10}
+ {1193504400 32400 0 +09}
+ {1206810000 36000 1 +10}
+ {1224954000 32400 0 +09}
+ {1238259600 36000 1 +10}
+ {1256403600 32400 0 +09}
+ {1269709200 36000 1 +10}
+ {1288458000 32400 0 +09}
+ {1301158800 36000 0 +10}
+ {1414252800 32400 0 +09}
}
diff --git a/library/tzdata/Asia/Yangon b/library/tzdata/Asia/Yangon
new file mode 100644
index 0000000..8e17d82
--- /dev/null
+++ b/library/tzdata/Asia/Yangon
@@ -0,0 +1,9 @@
+# created by tools/tclZIC.tcl - do not edit
+
+set TZData(:Asia/Yangon) {
+ {-9223372036854775808 23080 0 LMT}
+ {-2840163880 23080 0 RMT}
+ {-1577946280 23400 0 +0630}
+ {-873268200 32400 0 +09}
+ {-778410000 23400 0 +0630}
+}
diff --git a/library/tzdata/Asia/Yekaterinburg b/library/tzdata/Asia/Yekaterinburg
index fdd89b0..d2133b1 100644
--- a/library/tzdata/Asia/Yekaterinburg
+++ b/library/tzdata/Asia/Yekaterinburg
@@ -3,70 +3,70 @@
set TZData(:Asia/Yekaterinburg) {
{-9223372036854775808 14553 0 LMT}
{-1688270553 13505 0 PMT}
- {-1592610305 14400 0 SVET}
- {-1247544000 18000 0 SVEMMTT}
- {354913200 21600 1 SVEST}
- {370720800 18000 0 SVET}
- {386449200 21600 1 SVEST}
- {402256800 18000 0 SVET}
- {417985200 21600 1 SVEST}
- {433792800 18000 0 SVET}
- {449607600 21600 1 SVEST}
- {465339600 18000 0 SVET}
- {481064400 21600 1 SVEST}
- {496789200 18000 0 SVET}
- {512514000 21600 1 SVEST}
- {528238800 18000 0 SVET}
- {543963600 21600 1 SVEST}
- {559688400 18000 0 SVET}
- {575413200 21600 1 SVEST}
- {591138000 18000 0 SVET}
- {606862800 21600 1 SVEST}
- {622587600 18000 0 SVET}
- {638312400 21600 1 SVEST}
- {654642000 18000 0 SVET}
- {670366800 14400 0 SVEMMTT}
- {670370400 18000 1 SVEST}
- {686095200 14400 0 SVET}
- {695772000 18000 0 YEKMMTT}
- {701816400 21600 1 YEKST}
- {717541200 18000 0 YEKT}
- {733266000 21600 1 YEKST}
- {748990800 18000 0 YEKT}
- {764715600 21600 1 YEKST}
- {780440400 18000 0 YEKT}
- {796165200 21600 1 YEKST}
- {811890000 18000 0 YEKT}
- {828219600 21600 1 YEKST}
- {846363600 18000 0 YEKT}
- {859669200 21600 1 YEKST}
- {877813200 18000 0 YEKT}
- {891118800 21600 1 YEKST}
- {909262800 18000 0 YEKT}
- {922568400 21600 1 YEKST}
- {941317200 18000 0 YEKT}
- {954018000 21600 1 YEKST}
- {972766800 18000 0 YEKT}
- {985467600 21600 1 YEKST}
- {1004216400 18000 0 YEKT}
- {1017522000 21600 1 YEKST}
- {1035666000 18000 0 YEKT}
- {1048971600 21600 1 YEKST}
- {1067115600 18000 0 YEKT}
- {1080421200 21600 1 YEKST}
- {1099170000 18000 0 YEKT}
- {1111870800 21600 1 YEKST}
- {1130619600 18000 0 YEKT}
- {1143320400 21600 1 YEKST}
- {1162069200 18000 0 YEKT}
- {1174770000 21600 1 YEKST}
- {1193518800 18000 0 YEKT}
- {1206824400 21600 1 YEKST}
- {1224968400 18000 0 YEKT}
- {1238274000 21600 1 YEKST}
- {1256418000 18000 0 YEKT}
- {1269723600 21600 1 YEKST}
- {1288472400 18000 0 YEKT}
- {1301173200 21600 0 YEKT}
- {1414267200 18000 0 YEKT}
+ {-1592610305 14400 0 +04}
+ {-1247544000 18000 0 +06}
+ {354913200 21600 1 +06}
+ {370720800 18000 0 +05}
+ {386449200 21600 1 +06}
+ {402256800 18000 0 +05}
+ {417985200 21600 1 +06}
+ {433792800 18000 0 +05}
+ {449607600 21600 1 +06}
+ {465339600 18000 0 +05}
+ {481064400 21600 1 +06}
+ {496789200 18000 0 +05}
+ {512514000 21600 1 +06}
+ {528238800 18000 0 +05}
+ {543963600 21600 1 +06}
+ {559688400 18000 0 +05}
+ {575413200 21600 1 +06}
+ {591138000 18000 0 +05}
+ {606862800 21600 1 +06}
+ {622587600 18000 0 +05}
+ {638312400 21600 1 +06}
+ {654642000 18000 0 +05}
+ {670366800 14400 0 +05}
+ {670370400 18000 1 +05}
+ {686095200 14400 0 +04}
+ {695772000 18000 0 +06}
+ {701816400 21600 1 +06}
+ {717541200 18000 0 +05}
+ {733266000 21600 1 +06}
+ {748990800 18000 0 +05}
+ {764715600 21600 1 +06}
+ {780440400 18000 0 +05}
+ {796165200 21600 1 +06}
+ {811890000 18000 0 +05}
+ {828219600 21600 1 +06}
+ {846363600 18000 0 +05}
+ {859669200 21600 1 +06}
+ {877813200 18000 0 +05}
+ {891118800 21600 1 +06}
+ {909262800 18000 0 +05}
+ {922568400 21600 1 +06}
+ {941317200 18000 0 +05}
+ {954018000 21600 1 +06}
+ {972766800 18000 0 +05}
+ {985467600 21600 1 +06}
+ {1004216400 18000 0 +05}
+ {1017522000 21600 1 +06}
+ {1035666000 18000 0 +05}
+ {1048971600 21600 1 +06}
+ {1067115600 18000 0 +05}
+ {1080421200 21600 1 +06}
+ {1099170000 18000 0 +05}
+ {1111870800 21600 1 +06}
+ {1130619600 18000 0 +05}
+ {1143320400 21600 1 +06}
+ {1162069200 18000 0 +05}
+ {1174770000 21600 1 +06}
+ {1193518800 18000 0 +05}
+ {1206824400 21600 1 +06}
+ {1224968400 18000 0 +05}
+ {1238274000 21600 1 +06}
+ {1256418000 18000 0 +05}
+ {1269723600 21600 1 +06}
+ {1288472400 18000 0 +05}
+ {1301173200 21600 0 +06}
+ {1414267200 18000 0 +05}
}
diff --git a/library/tzdata/Asia/Yerevan b/library/tzdata/Asia/Yerevan
index c552403..0ffb69e 100644
--- a/library/tzdata/Asia/Yerevan
+++ b/library/tzdata/Asia/Yerevan
@@ -2,69 +2,68 @@
set TZData(:Asia/Yerevan) {
{-9223372036854775808 10680 0 LMT}
- {-1441162680 10800 0 YERT}
- {-405140400 14400 0 YERT}
- {354916800 18000 1 YERST}
- {370724400 14400 0 YERT}
- {386452800 18000 1 YERST}
- {402260400 14400 0 YERT}
- {417988800 18000 1 YERST}
- {433796400 14400 0 YERT}
- {449611200 18000 1 YERST}
- {465343200 14400 0 YERT}
- {481068000 18000 1 YERST}
- {496792800 14400 0 YERT}
- {512517600 18000 1 YERST}
- {528242400 14400 0 YERT}
- {543967200 18000 1 YERST}
- {559692000 14400 0 YERT}
- {575416800 18000 1 YERST}
- {591141600 14400 0 YERT}
- {606866400 18000 1 YERST}
- {622591200 14400 0 YERT}
- {638316000 18000 1 YERST}
- {654645600 14400 0 YERT}
- {670370400 14400 1 YERST}
- {685569600 14400 0 AMST}
- {686098800 10800 0 AMT}
- {701823600 14400 1 AMST}
- {717548400 10800 0 AMT}
- {733273200 14400 1 AMST}
- {748998000 10800 0 AMT}
- {764722800 14400 1 AMST}
- {780447600 10800 0 AMT}
- {796172400 14400 1 AMST}
- {811897200 14400 0 AMT}
- {852062400 14400 0 AMT}
- {859672800 18000 1 AMST}
- {877816800 14400 0 AMT}
- {891122400 18000 1 AMST}
- {909266400 14400 0 AMT}
- {922572000 18000 1 AMST}
- {941320800 14400 0 AMT}
- {954021600 18000 1 AMST}
- {972770400 14400 0 AMT}
- {985471200 18000 1 AMST}
- {1004220000 14400 0 AMT}
- {1017525600 18000 1 AMST}
- {1035669600 14400 0 AMT}
- {1048975200 18000 1 AMST}
- {1067119200 14400 0 AMT}
- {1080424800 18000 1 AMST}
- {1099173600 14400 0 AMT}
- {1111874400 18000 1 AMST}
- {1130623200 14400 0 AMT}
- {1143324000 18000 1 AMST}
- {1162072800 14400 0 AMT}
- {1174773600 18000 1 AMST}
- {1193522400 14400 0 AMT}
- {1206828000 18000 1 AMST}
- {1224972000 14400 0 AMT}
- {1238277600 18000 1 AMST}
- {1256421600 14400 0 AMT}
- {1269727200 18000 1 AMST}
- {1288476000 14400 0 AMT}
- {1301176800 18000 1 AMST}
- {1319925600 14400 0 AMT}
- {1328731200 14400 0 AMT}
+ {-1441162680 10800 0 +03}
+ {-405140400 14400 0 +04}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 18000 1 +05}
+ {591141600 14400 0 +04}
+ {606866400 18000 1 +05}
+ {622591200 14400 0 +04}
+ {638316000 18000 1 +05}
+ {654645600 14400 0 +04}
+ {670370400 10800 0 +03}
+ {670374000 14400 1 +04}
+ {686098800 10800 0 +03}
+ {701823600 14400 1 +04}
+ {717548400 10800 0 +03}
+ {733273200 14400 1 +04}
+ {748998000 10800 0 +03}
+ {764722800 14400 1 +04}
+ {780447600 10800 0 +03}
+ {796172400 14400 1 +04}
+ {811897200 14400 0 +04}
+ {852062400 14400 0 +04}
+ {859672800 18000 1 +05}
+ {877816800 14400 0 +04}
+ {891122400 18000 1 +05}
+ {909266400 14400 0 +04}
+ {922572000 18000 1 +05}
+ {941320800 14400 0 +04}
+ {954021600 18000 1 +05}
+ {972770400 14400 0 +04}
+ {985471200 18000 1 +05}
+ {1004220000 14400 0 +04}
+ {1017525600 18000 1 +05}
+ {1035669600 14400 0 +04}
+ {1048975200 18000 1 +05}
+ {1067119200 14400 0 +04}
+ {1080424800 18000 1 +05}
+ {1099173600 14400 0 +04}
+ {1111874400 18000 1 +05}
+ {1130623200 14400 0 +04}
+ {1143324000 18000 1 +05}
+ {1162072800 14400 0 +04}
+ {1174773600 18000 1 +05}
+ {1193522400 14400 0 +04}
+ {1206828000 18000 1 +05}
+ {1224972000 14400 0 +04}
+ {1238277600 18000 1 +05}
+ {1256421600 14400 0 +04}
+ {1269727200 18000 1 +05}
+ {1288476000 14400 0 +04}
+ {1301176800 18000 1 +05}
+ {1319925600 14400 0 +04}
}
diff --git a/library/tzdata/Atlantic/Azores b/library/tzdata/Atlantic/Azores
index fd47ba5..a9bec94 100644
--- a/library/tzdata/Atlantic/Azores
+++ b/library/tzdata/Atlantic/Azores
@@ -3,347 +3,343 @@
set TZData(:Atlantic/Azores) {
{-9223372036854775808 -6160 0 LMT}
{-2713904240 -6872 0 HMT}
- {-1830377128 -7200 0 AZOT}
- {-1689548400 -3600 1 AZOST}
- {-1677794400 -7200 0 AZOT}
- {-1667430000 -3600 1 AZOST}
- {-1647730800 -7200 0 AZOT}
- {-1635807600 -3600 1 AZOST}
- {-1616194800 -7200 0 AZOT}
- {-1604358000 -3600 1 AZOST}
- {-1584658800 -7200 0 AZOT}
- {-1572735600 -3600 1 AZOST}
- {-1553036400 -7200 0 AZOT}
- {-1541199600 -3600 1 AZOST}
- {-1521500400 -7200 0 AZOT}
- {-1442444400 -3600 1 AZOST}
- {-1426806000 -7200 0 AZOT}
- {-1379286000 -3600 1 AZOST}
- {-1364770800 -7200 0 AZOT}
- {-1348441200 -3600 1 AZOST}
- {-1333321200 -7200 0 AZOT}
- {-1316386800 -3600 1 AZOST}
- {-1301266800 -7200 0 AZOT}
- {-1284332400 -3600 1 AZOST}
- {-1269817200 -7200 0 AZOT}
- {-1221433200 -3600 1 AZOST}
- {-1206918000 -7200 0 AZOT}
- {-1191193200 -3600 1 AZOST}
- {-1175468400 -7200 0 AZOT}
- {-1127689200 -3600 1 AZOST}
- {-1111964400 -7200 0 AZOT}
- {-1096844400 -3600 1 AZOST}
- {-1080514800 -7200 0 AZOT}
- {-1063580400 -3600 1 AZOST}
- {-1049065200 -7200 0 AZOT}
- {-1033340400 -3600 1 AZOST}
- {-1017615600 -7200 0 AZOT}
- {-1002495600 -3600 1 AZOST}
- {-986166000 -7200 0 AZOT}
- {-969231600 -3600 1 AZOST}
- {-950482800 -7200 0 AZOT}
- {-942015600 -3600 1 AZOST}
- {-922662000 -7200 0 AZOT}
- {-906937200 -3600 1 AZOST}
- {-891126000 -7200 0 AZOT}
- {-877302000 -3600 1 AZOST}
- {-873676800 0 1 AZOMT}
- {-864000000 -3600 1 AZOST}
- {-857948400 -7200 0 AZOT}
- {-845852400 -3600 1 AZOST}
- {-842832000 0 1 AZOMT}
- {-831340800 -3600 1 AZOST}
- {-825894000 -7200 0 AZOT}
- {-814402800 -3600 1 AZOST}
- {-810777600 0 1 AZOMT}
- {-799891200 -3600 1 AZOST}
- {-794444400 -7200 0 AZOT}
- {-782953200 -3600 1 AZOST}
- {-779328000 0 1 AZOMT}
- {-768441600 -3600 1 AZOST}
- {-762994800 -7200 0 AZOT}
- {-749084400 -3600 1 AZOST}
- {-733359600 -7200 0 AZOT}
- {-717624000 -3600 1 AZOST}
- {-701899200 -7200 0 AZOT}
- {-686174400 -3600 1 AZOST}
- {-670449600 -7200 0 AZOT}
- {-654724800 -3600 1 AZOST}
- {-639000000 -7200 0 AZOT}
- {-591825600 -3600 1 AZOST}
- {-575496000 -7200 0 AZOT}
- {-559771200 -3600 1 AZOST}
- {-544046400 -7200 0 AZOT}
- {-528321600 -3600 1 AZOST}
- {-512596800 -7200 0 AZOT}
- {-496872000 -3600 1 AZOST}
- {-481147200 -7200 0 AZOT}
- {-465422400 -3600 1 AZOST}
- {-449697600 -7200 0 AZOT}
- {-433972800 -3600 1 AZOST}
- {-417643200 -7200 0 AZOT}
- {-401918400 -3600 1 AZOST}
- {-386193600 -7200 0 AZOT}
- {-370468800 -3600 1 AZOST}
- {-354744000 -7200 0 AZOT}
- {-339019200 -3600 1 AZOST}
- {-323294400 -7200 0 AZOT}
- {-307569600 -3600 1 AZOST}
- {-291844800 -7200 0 AZOT}
- {-276120000 -3600 1 AZOST}
- {-260395200 -7200 0 AZOT}
- {-244670400 -3600 1 AZOST}
- {-228340800 -7200 0 AZOT}
- {-212616000 -3600 1 AZOST}
- {-196891200 -7200 0 AZOT}
- {-181166400 -3600 1 AZOST}
- {-165441600 -7200 0 AZOT}
- {-149716800 -3600 1 AZOST}
- {-133992000 -7200 0 AZOT}
- {-118267200 -3600 0 AZOT}
- {228272400 0 1 AZOST}
- {243997200 -3600 0 AZOT}
- {260326800 0 1 AZOST}
- {276051600 -3600 0 AZOT}
- {291776400 0 1 AZOST}
- {307504800 -3600 0 AZOT}
- {323226000 0 1 AZOST}
- {338954400 -3600 0 AZOT}
- {354679200 0 1 AZOST}
- {370404000 -3600 0 AZOT}
- {386128800 0 1 AZOST}
- {401853600 -3600 0 AZOT}
- {417582000 0 1 AZOST}
- {433303200 -3600 0 AZOT}
- {449028000 0 1 AZOST}
- {465357600 -3600 0 AZOT}
- {481082400 0 1 AZOST}
- {496807200 -3600 0 AZOT}
- {512532000 0 1 AZOST}
- {528256800 -3600 0 AZOT}
- {543981600 0 1 AZOST}
- {559706400 -3600 0 AZOT}
- {575431200 0 1 AZOST}
- {591156000 -3600 0 AZOT}
- {606880800 0 1 AZOST}
- {622605600 -3600 0 AZOT}
- {638330400 0 1 AZOST}
- {654660000 -3600 0 AZOT}
- {670384800 0 1 AZOST}
- {686109600 -3600 0 AZOT}
- {701834400 0 1 AZOST}
- {733280400 0 0 AZOST}
- {749005200 -3600 0 AZOT}
- {764730000 0 1 AZOST}
- {780454800 -3600 0 AZOT}
- {796179600 0 1 AZOST}
- {811904400 -3600 0 AZOT}
- {828234000 0 1 AZOST}
- {846378000 -3600 0 AZOT}
- {859683600 0 1 AZOST}
- {877827600 -3600 0 AZOT}
- {891133200 0 1 AZOST}
- {909277200 -3600 0 AZOT}
- {922582800 0 1 AZOST}
- {941331600 -3600 0 AZOT}
- {954032400 0 1 AZOST}
- {972781200 -3600 0 AZOT}
- {985482000 0 1 AZOST}
- {1004230800 -3600 0 AZOT}
- {1017536400 0 1 AZOST}
- {1035680400 -3600 0 AZOT}
- {1048986000 0 1 AZOST}
- {1067130000 -3600 0 AZOT}
- {1080435600 0 1 AZOST}
- {1099184400 -3600 0 AZOT}
- {1111885200 0 1 AZOST}
- {1130634000 -3600 0 AZOT}
- {1143334800 0 1 AZOST}
- {1162083600 -3600 0 AZOT}
- {1174784400 0 1 AZOST}
- {1193533200 -3600 0 AZOT}
- {1206838800 0 1 AZOST}
- {1224982800 -3600 0 AZOT}
- {1238288400 0 1 AZOST}
- {1256432400 -3600 0 AZOT}
- {1269738000 0 1 AZOST}
- {1288486800 -3600 0 AZOT}
- {1301187600 0 1 AZOST}
- {1319936400 -3600 0 AZOT}
- {1332637200 0 1 AZOST}
- {1351386000 -3600 0 AZOT}
- {1364691600 0 1 AZOST}
- {1382835600 -3600 0 AZOT}
- {1396141200 0 1 AZOST}
- {1414285200 -3600 0 AZOT}
- {1427590800 0 1 AZOST}
- {1445734800 -3600 0 AZOT}
- {1459040400 0 1 AZOST}
- {1477789200 -3600 0 AZOT}
- {1490490000 0 1 AZOST}
- {1509238800 -3600 0 AZOT}
- {1521939600 0 1 AZOST}
- {1540688400 -3600 0 AZOT}
- {1553994000 0 1 AZOST}
- {1572138000 -3600 0 AZOT}
- {1585443600 0 1 AZOST}
- {1603587600 -3600 0 AZOT}
- {1616893200 0 1 AZOST}
- {1635642000 -3600 0 AZOT}
- {1648342800 0 1 AZOST}
- {1667091600 -3600 0 AZOT}
- {1679792400 0 1 AZOST}
- {1698541200 -3600 0 AZOT}
- {1711846800 0 1 AZOST}
- {1729990800 -3600 0 AZOT}
- {1743296400 0 1 AZOST}
- {1761440400 -3600 0 AZOT}
- {1774746000 0 1 AZOST}
- {1792890000 -3600 0 AZOT}
- {1806195600 0 1 AZOST}
- {1824944400 -3600 0 AZOT}
- {1837645200 0 1 AZOST}
- {1856394000 -3600 0 AZOT}
- {1869094800 0 1 AZOST}
- {1887843600 -3600 0 AZOT}
- {1901149200 0 1 AZOST}
- {1919293200 -3600 0 AZOT}
- {1932598800 0 1 AZOST}
- {1950742800 -3600 0 AZOT}
- {1964048400 0 1 AZOST}
- {1982797200 -3600 0 AZOT}
- {1995498000 0 1 AZOST}
- {2014246800 -3600 0 AZOT}
- {2026947600 0 1 AZOST}
- {2045696400 -3600 0 AZOT}
- {2058397200 0 1 AZOST}
- {2077146000 -3600 0 AZOT}
- {2090451600 0 1 AZOST}
- {2108595600 -3600 0 AZOT}
- {2121901200 0 1 AZOST}
- {2140045200 -3600 0 AZOT}
- {2153350800 0 1 AZOST}
- {2172099600 -3600 0 AZOT}
- {2184800400 0 1 AZOST}
- {2203549200 -3600 0 AZOT}
- {2216250000 0 1 AZOST}
- {2234998800 -3600 0 AZOT}
- {2248304400 0 1 AZOST}
- {2266448400 -3600 0 AZOT}
- {2279754000 0 1 AZOST}
- {2297898000 -3600 0 AZOT}
- {2311203600 0 1 AZOST}
- {2329347600 -3600 0 AZOT}
- {2342653200 0 1 AZOST}
- {2361402000 -3600 0 AZOT}
- {2374102800 0 1 AZOST}
- {2392851600 -3600 0 AZOT}
- {2405552400 0 1 AZOST}
- {2424301200 -3600 0 AZOT}
- {2437606800 0 1 AZOST}
- {2455750800 -3600 0 AZOT}
- {2469056400 0 1 AZOST}
- {2487200400 -3600 0 AZOT}
- {2500506000 0 1 AZOST}
- {2519254800 -3600 0 AZOT}
- {2531955600 0 1 AZOST}
- {2550704400 -3600 0 AZOT}
- {2563405200 0 1 AZOST}
- {2582154000 -3600 0 AZOT}
- {2595459600 0 1 AZOST}
- {2613603600 -3600 0 AZOT}
- {2626909200 0 1 AZOST}
- {2645053200 -3600 0 AZOT}
- {2658358800 0 1 AZOST}
- {2676502800 -3600 0 AZOT}
- {2689808400 0 1 AZOST}
- {2708557200 -3600 0 AZOT}
- {2721258000 0 1 AZOST}
- {2740006800 -3600 0 AZOT}
- {2752707600 0 1 AZOST}
- {2771456400 -3600 0 AZOT}
- {2784762000 0 1 AZOST}
- {2802906000 -3600 0 AZOT}
- {2816211600 0 1 AZOST}
- {2834355600 -3600 0 AZOT}
- {2847661200 0 1 AZOST}
- {2866410000 -3600 0 AZOT}
- {2879110800 0 1 AZOST}
- {2897859600 -3600 0 AZOT}
- {2910560400 0 1 AZOST}
- {2929309200 -3600 0 AZOT}
- {2942010000 0 1 AZOST}
- {2960758800 -3600 0 AZOT}
- {2974064400 0 1 AZOST}
- {2992208400 -3600 0 AZOT}
- {3005514000 0 1 AZOST}
- {3023658000 -3600 0 AZOT}
- {3036963600 0 1 AZOST}
- {3055712400 -3600 0 AZOT}
- {3068413200 0 1 AZOST}
- {3087162000 -3600 0 AZOT}
- {3099862800 0 1 AZOST}
- {3118611600 -3600 0 AZOT}
- {3131917200 0 1 AZOST}
- {3150061200 -3600 0 AZOT}
- {3163366800 0 1 AZOST}
- {3181510800 -3600 0 AZOT}
- {3194816400 0 1 AZOST}
- {3212960400 -3600 0 AZOT}
- {3226266000 0 1 AZOST}
- {3245014800 -3600 0 AZOT}
- {3257715600 0 1 AZOST}
- {3276464400 -3600 0 AZOT}
- {3289165200 0 1 AZOST}
- {3307914000 -3600 0 AZOT}
- {3321219600 0 1 AZOST}
- {3339363600 -3600 0 AZOT}
- {3352669200 0 1 AZOST}
- {3370813200 -3600 0 AZOT}
- {3384118800 0 1 AZOST}
- {3402867600 -3600 0 AZOT}
- {3415568400 0 1 AZOST}
- {3434317200 -3600 0 AZOT}
- {3447018000 0 1 AZOST}
- {3465766800 -3600 0 AZOT}
- {3479072400 0 1 AZOST}
- {3497216400 -3600 0 AZOT}
- {3510522000 0 1 AZOST}
- {3528666000 -3600 0 AZOT}
- {3541971600 0 1 AZOST}
- {3560115600 -3600 0 AZOT}
- {3573421200 0 1 AZOST}
- {3592170000 -3600 0 AZOT}
- {3604870800 0 1 AZOST}
- {3623619600 -3600 0 AZOT}
- {3636320400 0 1 AZOST}
- {3655069200 -3600 0 AZOT}
- {3668374800 0 1 AZOST}
- {3686518800 -3600 0 AZOT}
- {3699824400 0 1 AZOST}
- {3717968400 -3600 0 AZOT}
- {3731274000 0 1 AZOST}
- {3750022800 -3600 0 AZOT}
- {3762723600 0 1 AZOST}
- {3781472400 -3600 0 AZOT}
- {3794173200 0 1 AZOST}
- {3812922000 -3600 0 AZOT}
- {3825622800 0 1 AZOST}
- {3844371600 -3600 0 AZOT}
- {3857677200 0 1 AZOST}
- {3875821200 -3600 0 AZOT}
- {3889126800 0 1 AZOST}
- {3907270800 -3600 0 AZOT}
- {3920576400 0 1 AZOST}
- {3939325200 -3600 0 AZOT}
- {3952026000 0 1 AZOST}
- {3970774800 -3600 0 AZOT}
- {3983475600 0 1 AZOST}
- {4002224400 -3600 0 AZOT}
- {4015530000 0 1 AZOST}
- {4033674000 -3600 0 AZOT}
- {4046979600 0 1 AZOST}
- {4065123600 -3600 0 AZOT}
- {4078429200 0 1 AZOST}
- {4096573200 -3600 0 AZOT}
+ {-1830377128 -7200 0 -02}
+ {-1689548400 -3600 1 -01}
+ {-1677794400 -7200 0 -02}
+ {-1667430000 -3600 1 -01}
+ {-1647730800 -7200 0 -02}
+ {-1635807600 -3600 1 -01}
+ {-1616194800 -7200 0 -02}
+ {-1604358000 -3600 1 -01}
+ {-1584658800 -7200 0 -02}
+ {-1572735600 -3600 1 -01}
+ {-1553036400 -7200 0 -02}
+ {-1541199600 -3600 1 -01}
+ {-1521500400 -7200 0 -02}
+ {-1442444400 -3600 1 -01}
+ {-1426806000 -7200 0 -02}
+ {-1379286000 -3600 1 -01}
+ {-1364770800 -7200 0 -02}
+ {-1348441200 -3600 1 -01}
+ {-1333321200 -7200 0 -02}
+ {-1316386800 -3600 1 -01}
+ {-1301266800 -7200 0 -02}
+ {-1284332400 -3600 1 -01}
+ {-1269817200 -7200 0 -02}
+ {-1221433200 -3600 1 -01}
+ {-1206918000 -7200 0 -02}
+ {-1191193200 -3600 1 -01}
+ {-1175468400 -7200 0 -02}
+ {-1127689200 -3600 1 -01}
+ {-1111964400 -7200 0 -02}
+ {-1096844400 -3600 1 -01}
+ {-1080514800 -7200 0 -02}
+ {-1063580400 -3600 1 -01}
+ {-1049065200 -7200 0 -02}
+ {-1033340400 -3600 1 -01}
+ {-1017615600 -7200 0 -02}
+ {-1002495600 -3600 1 -01}
+ {-986166000 -7200 0 -02}
+ {-969231600 -3600 1 -01}
+ {-950482800 -7200 0 -02}
+ {-942015600 -3600 1 -01}
+ {-922662000 -7200 0 -02}
+ {-906937200 -3600 1 -01}
+ {-891126000 -7200 0 -02}
+ {-877302000 -3600 1 -01}
+ {-864000000 -3600 0 -01}
+ {-857948400 -7200 0 -02}
+ {-845852400 -3600 1 -01}
+ {-831340800 -3600 0 -01}
+ {-825894000 -7200 0 -02}
+ {-814402800 -3600 1 -01}
+ {-799891200 -3600 0 -01}
+ {-794444400 -7200 0 -02}
+ {-782953200 -3600 1 -01}
+ {-768441600 -3600 0 -01}
+ {-762994800 -7200 0 -02}
+ {-749084400 -3600 1 -01}
+ {-733359600 -7200 0 -02}
+ {-717624000 -3600 1 -01}
+ {-701899200 -7200 0 -02}
+ {-686174400 -3600 1 -01}
+ {-670449600 -7200 0 -02}
+ {-654724800 -3600 1 -01}
+ {-639000000 -7200 0 -02}
+ {-591825600 -3600 1 -01}
+ {-575496000 -7200 0 -02}
+ {-559771200 -3600 1 -01}
+ {-544046400 -7200 0 -02}
+ {-528321600 -3600 1 -01}
+ {-512596800 -7200 0 -02}
+ {-496872000 -3600 1 -01}
+ {-481147200 -7200 0 -02}
+ {-465422400 -3600 1 -01}
+ {-449697600 -7200 0 -02}
+ {-433972800 -3600 1 -01}
+ {-417643200 -7200 0 -02}
+ {-401918400 -3600 1 -01}
+ {-386193600 -7200 0 -02}
+ {-370468800 -3600 1 -01}
+ {-354744000 -7200 0 -02}
+ {-339019200 -3600 1 -01}
+ {-323294400 -7200 0 -02}
+ {-307569600 -3600 1 -01}
+ {-291844800 -7200 0 -02}
+ {-276120000 -3600 1 -01}
+ {-260395200 -7200 0 -02}
+ {-244670400 -3600 1 -01}
+ {-228340800 -7200 0 -02}
+ {-212616000 -3600 1 -01}
+ {-196891200 -7200 0 -02}
+ {-181166400 -3600 1 -01}
+ {-165441600 -7200 0 -02}
+ {-149716800 -3600 1 -01}
+ {-133992000 -7200 0 -02}
+ {-118267200 -3600 0 -01}
+ {228272400 0 1 +00}
+ {243997200 -3600 0 -01}
+ {260326800 0 1 +00}
+ {276051600 -3600 0 -01}
+ {291776400 0 1 +00}
+ {307504800 -3600 0 -01}
+ {323226000 0 1 +00}
+ {338954400 -3600 0 -01}
+ {354679200 0 1 +00}
+ {370404000 -3600 0 -01}
+ {386128800 0 1 +00}
+ {401853600 -3600 0 -01}
+ {417582000 0 1 +00}
+ {433303200 -3600 0 -01}
+ {449028000 0 1 +00}
+ {465357600 -3600 0 -01}
+ {481082400 0 1 +00}
+ {496807200 -3600 0 -01}
+ {512532000 0 1 +00}
+ {528256800 -3600 0 -01}
+ {543981600 0 1 +00}
+ {559706400 -3600 0 -01}
+ {575431200 0 1 +00}
+ {591156000 -3600 0 -01}
+ {606880800 0 1 +00}
+ {622605600 -3600 0 -01}
+ {638330400 0 1 +00}
+ {654660000 -3600 0 -01}
+ {670384800 0 1 +00}
+ {686109600 -3600 0 -01}
+ {701834400 0 1 +00}
+ {733280400 0 0 +00}
+ {749005200 -3600 0 -01}
+ {764730000 0 1 +00}
+ {780454800 -3600 0 -01}
+ {796179600 0 1 +00}
+ {811904400 -3600 0 -01}
+ {828234000 0 1 +00}
+ {846378000 -3600 0 -01}
+ {859683600 0 1 +00}
+ {877827600 -3600 0 -01}
+ {891133200 0 1 +00}
+ {909277200 -3600 0 -01}
+ {922582800 0 1 +00}
+ {941331600 -3600 0 -01}
+ {954032400 0 1 +00}
+ {972781200 -3600 0 -01}
+ {985482000 0 1 +00}
+ {1004230800 -3600 0 -01}
+ {1017536400 0 1 +00}
+ {1035680400 -3600 0 -01}
+ {1048986000 0 1 +00}
+ {1067130000 -3600 0 -01}
+ {1080435600 0 1 +00}
+ {1099184400 -3600 0 -01}
+ {1111885200 0 1 +00}
+ {1130634000 -3600 0 -01}
+ {1143334800 0 1 +00}
+ {1162083600 -3600 0 -01}
+ {1174784400 0 1 +00}
+ {1193533200 -3600 0 -01}
+ {1206838800 0 1 +00}
+ {1224982800 -3600 0 -01}
+ {1238288400 0 1 +00}
+ {1256432400 -3600 0 -01}
+ {1269738000 0 1 +00}
+ {1288486800 -3600 0 -01}
+ {1301187600 0 1 +00}
+ {1319936400 -3600 0 -01}
+ {1332637200 0 1 +00}
+ {1351386000 -3600 0 -01}
+ {1364691600 0 1 +00}
+ {1382835600 -3600 0 -01}
+ {1396141200 0 1 +00}
+ {1414285200 -3600 0 -01}
+ {1427590800 0 1 +00}
+ {1445734800 -3600 0 -01}
+ {1459040400 0 1 +00}
+ {1477789200 -3600 0 -01}
+ {1490490000 0 1 +00}
+ {1509238800 -3600 0 -01}
+ {1521939600 0 1 +00}
+ {1540688400 -3600 0 -01}
+ {1553994000 0 1 +00}
+ {1572138000 -3600 0 -01}
+ {1585443600 0 1 +00}
+ {1603587600 -3600 0 -01}
+ {1616893200 0 1 +00}
+ {1635642000 -3600 0 -01}
+ {1648342800 0 1 +00}
+ {1667091600 -3600 0 -01}
+ {1679792400 0 1 +00}
+ {1698541200 -3600 0 -01}
+ {1711846800 0 1 +00}
+ {1729990800 -3600 0 -01}
+ {1743296400 0 1 +00}
+ {1761440400 -3600 0 -01}
+ {1774746000 0 1 +00}
+ {1792890000 -3600 0 -01}
+ {1806195600 0 1 +00}
+ {1824944400 -3600 0 -01}
+ {1837645200 0 1 +00}
+ {1856394000 -3600 0 -01}
+ {1869094800 0 1 +00}
+ {1887843600 -3600 0 -01}
+ {1901149200 0 1 +00}
+ {1919293200 -3600 0 -01}
+ {1932598800 0 1 +00}
+ {1950742800 -3600 0 -01}
+ {1964048400 0 1 +00}
+ {1982797200 -3600 0 -01}
+ {1995498000 0 1 +00}
+ {2014246800 -3600 0 -01}
+ {2026947600 0 1 +00}
+ {2045696400 -3600 0 -01}
+ {2058397200 0 1 +00}
+ {2077146000 -3600 0 -01}
+ {2090451600 0 1 +00}
+ {2108595600 -3600 0 -01}
+ {2121901200 0 1 +00}
+ {2140045200 -3600 0 -01}
+ {2153350800 0 1 +00}
+ {2172099600 -3600 0 -01}
+ {2184800400 0 1 +00}
+ {2203549200 -3600 0 -01}
+ {2216250000 0 1 +00}
+ {2234998800 -3600 0 -01}
+ {2248304400 0 1 +00}
+ {2266448400 -3600 0 -01}
+ {2279754000 0 1 +00}
+ {2297898000 -3600 0 -01}
+ {2311203600 0 1 +00}
+ {2329347600 -3600 0 -01}
+ {2342653200 0 1 +00}
+ {2361402000 -3600 0 -01}
+ {2374102800 0 1 +00}
+ {2392851600 -3600 0 -01}
+ {2405552400 0 1 +00}
+ {2424301200 -3600 0 -01}
+ {2437606800 0 1 +00}
+ {2455750800 -3600 0 -01}
+ {2469056400 0 1 +00}
+ {2487200400 -3600 0 -01}
+ {2500506000 0 1 +00}
+ {2519254800 -3600 0 -01}
+ {2531955600 0 1 +00}
+ {2550704400 -3600 0 -01}
+ {2563405200 0 1 +00}
+ {2582154000 -3600 0 -01}
+ {2595459600 0 1 +00}
+ {2613603600 -3600 0 -01}
+ {2626909200 0 1 +00}
+ {2645053200 -3600 0 -01}
+ {2658358800 0 1 +00}
+ {2676502800 -3600 0 -01}
+ {2689808400 0 1 +00}
+ {2708557200 -3600 0 -01}
+ {2721258000 0 1 +00}
+ {2740006800 -3600 0 -01}
+ {2752707600 0 1 +00}
+ {2771456400 -3600 0 -01}
+ {2784762000 0 1 +00}
+ {2802906000 -3600 0 -01}
+ {2816211600 0 1 +00}
+ {2834355600 -3600 0 -01}
+ {2847661200 0 1 +00}
+ {2866410000 -3600 0 -01}
+ {2879110800 0 1 +00}
+ {2897859600 -3600 0 -01}
+ {2910560400 0 1 +00}
+ {2929309200 -3600 0 -01}
+ {2942010000 0 1 +00}
+ {2960758800 -3600 0 -01}
+ {2974064400 0 1 +00}
+ {2992208400 -3600 0 -01}
+ {3005514000 0 1 +00}
+ {3023658000 -3600 0 -01}
+ {3036963600 0 1 +00}
+ {3055712400 -3600 0 -01}
+ {3068413200 0 1 +00}
+ {3087162000 -3600 0 -01}
+ {3099862800 0 1 +00}
+ {3118611600 -3600 0 -01}
+ {3131917200 0 1 +00}
+ {3150061200 -3600 0 -01}
+ {3163366800 0 1 +00}
+ {3181510800 -3600 0 -01}
+ {3194816400 0 1 +00}
+ {3212960400 -3600 0 -01}
+ {3226266000 0 1 +00}
+ {3245014800 -3600 0 -01}
+ {3257715600 0 1 +00}
+ {3276464400 -3600 0 -01}
+ {3289165200 0 1 +00}
+ {3307914000 -3600 0 -01}
+ {3321219600 0 1 +00}
+ {3339363600 -3600 0 -01}
+ {3352669200 0 1 +00}
+ {3370813200 -3600 0 -01}
+ {3384118800 0 1 +00}
+ {3402867600 -3600 0 -01}
+ {3415568400 0 1 +00}
+ {3434317200 -3600 0 -01}
+ {3447018000 0 1 +00}
+ {3465766800 -3600 0 -01}
+ {3479072400 0 1 +00}
+ {3497216400 -3600 0 -01}
+ {3510522000 0 1 +00}
+ {3528666000 -3600 0 -01}
+ {3541971600 0 1 +00}
+ {3560115600 -3600 0 -01}
+ {3573421200 0 1 +00}
+ {3592170000 -3600 0 -01}
+ {3604870800 0 1 +00}
+ {3623619600 -3600 0 -01}
+ {3636320400 0 1 +00}
+ {3655069200 -3600 0 -01}
+ {3668374800 0 1 +00}
+ {3686518800 -3600 0 -01}
+ {3699824400 0 1 +00}
+ {3717968400 -3600 0 -01}
+ {3731274000 0 1 +00}
+ {3750022800 -3600 0 -01}
+ {3762723600 0 1 +00}
+ {3781472400 -3600 0 -01}
+ {3794173200 0 1 +00}
+ {3812922000 -3600 0 -01}
+ {3825622800 0 1 +00}
+ {3844371600 -3600 0 -01}
+ {3857677200 0 1 +00}
+ {3875821200 -3600 0 -01}
+ {3889126800 0 1 +00}
+ {3907270800 -3600 0 -01}
+ {3920576400 0 1 +00}
+ {3939325200 -3600 0 -01}
+ {3952026000 0 1 +00}
+ {3970774800 -3600 0 -01}
+ {3983475600 0 1 +00}
+ {4002224400 -3600 0 -01}
+ {4015530000 0 1 +00}
+ {4033674000 -3600 0 -01}
+ {4046979600 0 1 +00}
+ {4065123600 -3600 0 -01}
+ {4078429200 0 1 +00}
+ {4096573200 -3600 0 -01}
}
diff --git a/library/tzdata/Atlantic/Canary b/library/tzdata/Atlantic/Canary
index dcfba83..b5c2997 100644
--- a/library/tzdata/Atlantic/Canary
+++ b/library/tzdata/Atlantic/Canary
@@ -2,7 +2,7 @@
set TZData(:Atlantic/Canary) {
{-9223372036854775808 -3696 0 LMT}
- {-1509663504 -3600 0 CANT}
+ {-1509663504 -3600 0 -01}
{-733874400 0 0 WET}
{323827200 3600 1 WEST}
{338950800 0 0 WET}
diff --git a/library/tzdata/Atlantic/Cape_Verde b/library/tzdata/Atlantic/Cape_Verde
index f0bb79f..6fc94eb 100644
--- a/library/tzdata/Atlantic/Cape_Verde
+++ b/library/tzdata/Atlantic/Cape_Verde
@@ -2,8 +2,8 @@
set TZData(:Atlantic/Cape_Verde) {
{-9223372036854775808 -5644 0 LMT}
- {-1988144756 -7200 0 CVT}
- {-862610400 -3600 1 CVST}
- {-764118000 -7200 0 CVT}
- {186120000 -3600 0 CVT}
+ {-1988144756 -7200 0 -02}
+ {-862610400 -3600 1 -01}
+ {-764118000 -7200 0 -02}
+ {186120000 -3600 0 -01}
}
diff --git a/library/tzdata/Atlantic/Madeira b/library/tzdata/Atlantic/Madeira
index fac7f92..cc5e5f8 100644
--- a/library/tzdata/Atlantic/Madeira
+++ b/library/tzdata/Atlantic/Madeira
@@ -3,103 +3,99 @@
set TZData(:Atlantic/Madeira) {
{-9223372036854775808 -4056 0 LMT}
{-2713906344 -4056 0 FMT}
- {-1830379944 -3600 0 MADT}
- {-1689552000 0 1 MADST}
- {-1677798000 -3600 0 MADT}
- {-1667433600 0 1 MADST}
- {-1647734400 -3600 0 MADT}
- {-1635811200 0 1 MADST}
- {-1616198400 -3600 0 MADT}
- {-1604361600 0 1 MADST}
- {-1584662400 -3600 0 MADT}
- {-1572739200 0 1 MADST}
- {-1553040000 -3600 0 MADT}
- {-1541203200 0 1 MADST}
- {-1521504000 -3600 0 MADT}
- {-1442448000 0 1 MADST}
- {-1426809600 -3600 0 MADT}
- {-1379289600 0 1 MADST}
- {-1364774400 -3600 0 MADT}
- {-1348444800 0 1 MADST}
- {-1333324800 -3600 0 MADT}
- {-1316390400 0 1 MADST}
- {-1301270400 -3600 0 MADT}
- {-1284336000 0 1 MADST}
- {-1269820800 -3600 0 MADT}
- {-1221436800 0 1 MADST}
- {-1206921600 -3600 0 MADT}
- {-1191196800 0 1 MADST}
- {-1175472000 -3600 0 MADT}
- {-1127692800 0 1 MADST}
- {-1111968000 -3600 0 MADT}
- {-1096848000 0 1 MADST}
- {-1080518400 -3600 0 MADT}
- {-1063584000 0 1 MADST}
- {-1049068800 -3600 0 MADT}
- {-1033344000 0 1 MADST}
- {-1017619200 -3600 0 MADT}
- {-1002499200 0 1 MADST}
- {-986169600 -3600 0 MADT}
- {-969235200 0 1 MADST}
- {-950486400 -3600 0 MADT}
- {-942019200 0 1 MADST}
- {-922665600 -3600 0 MADT}
- {-906940800 0 1 MADST}
- {-891129600 -3600 0 MADT}
- {-877305600 0 1 MADST}
- {-873680400 3600 1 MADMT}
- {-864003600 0 1 MADST}
- {-857952000 -3600 0 MADT}
- {-845856000 0 1 MADST}
- {-842835600 3600 1 MADMT}
- {-831344400 0 1 MADST}
- {-825897600 -3600 0 MADT}
- {-814406400 0 1 MADST}
- {-810781200 3600 1 MADMT}
- {-799894800 0 1 MADST}
- {-794448000 -3600 0 MADT}
- {-782956800 0 1 MADST}
- {-779331600 3600 1 MADMT}
- {-768445200 0 1 MADST}
- {-762998400 -3600 0 MADT}
- {-749088000 0 1 MADST}
- {-733363200 -3600 0 MADT}
- {-717627600 0 1 MADST}
- {-701902800 -3600 0 MADT}
- {-686178000 0 1 MADST}
- {-670453200 -3600 0 MADT}
- {-654728400 0 1 MADST}
- {-639003600 -3600 0 MADT}
- {-591829200 0 1 MADST}
- {-575499600 -3600 0 MADT}
- {-559774800 0 1 MADST}
- {-544050000 -3600 0 MADT}
- {-528325200 0 1 MADST}
- {-512600400 -3600 0 MADT}
- {-496875600 0 1 MADST}
- {-481150800 -3600 0 MADT}
- {-465426000 0 1 MADST}
- {-449701200 -3600 0 MADT}
- {-433976400 0 1 MADST}
- {-417646800 -3600 0 MADT}
- {-401922000 0 1 MADST}
- {-386197200 -3600 0 MADT}
- {-370472400 0 1 MADST}
- {-354747600 -3600 0 MADT}
- {-339022800 0 1 MADST}
- {-323298000 -3600 0 MADT}
- {-307573200 0 1 MADST}
- {-291848400 -3600 0 MADT}
- {-276123600 0 1 MADST}
- {-260398800 -3600 0 MADT}
- {-244674000 0 1 MADST}
- {-228344400 -3600 0 MADT}
- {-212619600 0 1 MADST}
- {-196894800 -3600 0 MADT}
- {-181170000 0 1 MADST}
- {-165445200 -3600 0 MADT}
- {-149720400 0 1 MADST}
- {-133995600 -3600 0 MADT}
+ {-1830379944 -3600 0 -01}
+ {-1689552000 0 1 +00}
+ {-1677798000 -3600 0 -01}
+ {-1667433600 0 1 +00}
+ {-1647734400 -3600 0 -01}
+ {-1635811200 0 1 +00}
+ {-1616198400 -3600 0 -01}
+ {-1604361600 0 1 +00}
+ {-1584662400 -3600 0 -01}
+ {-1572739200 0 1 +00}
+ {-1553040000 -3600 0 -01}
+ {-1541203200 0 1 +00}
+ {-1521504000 -3600 0 -01}
+ {-1442448000 0 1 +00}
+ {-1426809600 -3600 0 -01}
+ {-1379289600 0 1 +00}
+ {-1364774400 -3600 0 -01}
+ {-1348444800 0 1 +00}
+ {-1333324800 -3600 0 -01}
+ {-1316390400 0 1 +00}
+ {-1301270400 -3600 0 -01}
+ {-1284336000 0 1 +00}
+ {-1269820800 -3600 0 -01}
+ {-1221436800 0 1 +00}
+ {-1206921600 -3600 0 -01}
+ {-1191196800 0 1 +00}
+ {-1175472000 -3600 0 -01}
+ {-1127692800 0 1 +00}
+ {-1111968000 -3600 0 -01}
+ {-1096848000 0 1 +00}
+ {-1080518400 -3600 0 -01}
+ {-1063584000 0 1 +00}
+ {-1049068800 -3600 0 -01}
+ {-1033344000 0 1 +00}
+ {-1017619200 -3600 0 -01}
+ {-1002499200 0 1 +00}
+ {-986169600 -3600 0 -01}
+ {-969235200 0 1 +00}
+ {-950486400 -3600 0 -01}
+ {-942019200 0 1 +00}
+ {-922665600 -3600 0 -01}
+ {-906940800 0 1 +00}
+ {-891129600 -3600 0 -01}
+ {-877305600 0 1 +00}
+ {-864003600 0 0 +00}
+ {-857952000 -3600 0 -01}
+ {-845856000 0 1 +00}
+ {-831344400 0 0 +00}
+ {-825897600 -3600 0 -01}
+ {-814406400 0 1 +00}
+ {-799894800 0 0 +00}
+ {-794448000 -3600 0 -01}
+ {-782956800 0 1 +00}
+ {-768445200 0 0 +00}
+ {-762998400 -3600 0 -01}
+ {-749088000 0 1 +00}
+ {-733363200 -3600 0 -01}
+ {-717627600 0 1 +00}
+ {-701902800 -3600 0 -01}
+ {-686178000 0 1 +00}
+ {-670453200 -3600 0 -01}
+ {-654728400 0 1 +00}
+ {-639003600 -3600 0 -01}
+ {-591829200 0 1 +00}
+ {-575499600 -3600 0 -01}
+ {-559774800 0 1 +00}
+ {-544050000 -3600 0 -01}
+ {-528325200 0 1 +00}
+ {-512600400 -3600 0 -01}
+ {-496875600 0 1 +00}
+ {-481150800 -3600 0 -01}
+ {-465426000 0 1 +00}
+ {-449701200 -3600 0 -01}
+ {-433976400 0 1 +00}
+ {-417646800 -3600 0 -01}
+ {-401922000 0 1 +00}
+ {-386197200 -3600 0 -01}
+ {-370472400 0 1 +00}
+ {-354747600 -3600 0 -01}
+ {-339022800 0 1 +00}
+ {-323298000 -3600 0 -01}
+ {-307573200 0 1 +00}
+ {-291848400 -3600 0 -01}
+ {-276123600 0 1 +00}
+ {-260398800 -3600 0 -01}
+ {-244674000 0 1 +00}
+ {-228344400 -3600 0 -01}
+ {-212619600 0 1 +00}
+ {-196894800 -3600 0 -01}
+ {-181170000 0 1 +00}
+ {-165445200 -3600 0 -01}
+ {-149720400 0 1 +00}
+ {-133995600 -3600 0 -01}
{-118270800 0 0 WET}
{228268800 3600 1 WEST}
{243993600 0 0 WET}
diff --git a/library/tzdata/Atlantic/Reykjavik b/library/tzdata/Atlantic/Reykjavik
index ad7f0db..5555460 100644
--- a/library/tzdata/Atlantic/Reykjavik
+++ b/library/tzdata/Atlantic/Reykjavik
@@ -2,72 +2,72 @@
set TZData(:Atlantic/Reykjavik) {
{-9223372036854775808 -5280 0 LMT}
- {-1956609120 -3600 0 IST}
- {-1668211200 0 1 ISST}
- {-1647212400 -3600 0 IST}
- {-1636675200 0 1 ISST}
- {-1613430000 -3600 0 IST}
- {-1605139200 0 1 ISST}
- {-1581894000 -3600 0 IST}
- {-1539561600 0 1 ISST}
- {-1531350000 -3600 0 IST}
- {-968025600 0 1 ISST}
- {-952293600 -3600 0 IST}
- {-942008400 0 1 ISST}
- {-920239200 -3600 0 IST}
- {-909957600 0 1 ISST}
- {-888789600 -3600 0 IST}
- {-877903200 0 1 ISST}
- {-857944800 -3600 0 IST}
- {-846453600 0 1 ISST}
- {-826495200 -3600 0 IST}
- {-815004000 0 1 ISST}
- {-795045600 -3600 0 IST}
- {-783554400 0 1 ISST}
- {-762991200 -3600 0 IST}
- {-752104800 0 1 ISST}
- {-731541600 -3600 0 IST}
- {-717631200 0 1 ISST}
- {-700092000 -3600 0 IST}
- {-686181600 0 1 ISST}
- {-668642400 -3600 0 IST}
- {-654732000 0 1 ISST}
- {-636588000 -3600 0 IST}
- {-623282400 0 1 ISST}
- {-605743200 -3600 0 IST}
- {-591832800 0 1 ISST}
- {-573688800 -3600 0 IST}
- {-559778400 0 1 ISST}
- {-542239200 -3600 0 IST}
- {-528328800 0 1 ISST}
- {-510789600 -3600 0 IST}
- {-496879200 0 1 ISST}
- {-479340000 -3600 0 IST}
- {-465429600 0 1 ISST}
- {-447890400 -3600 0 IST}
- {-433980000 0 1 ISST}
- {-415836000 -3600 0 IST}
- {-401925600 0 1 ISST}
- {-384386400 -3600 0 IST}
- {-370476000 0 1 ISST}
- {-352936800 -3600 0 IST}
- {-339026400 0 1 ISST}
- {-321487200 -3600 0 IST}
- {-307576800 0 1 ISST}
- {-290037600 -3600 0 IST}
- {-276127200 0 1 ISST}
- {-258588000 -3600 0 IST}
- {-244677600 0 1 ISST}
- {-226533600 -3600 0 IST}
- {-212623200 0 1 ISST}
- {-195084000 -3600 0 IST}
- {-181173600 0 1 ISST}
- {-163634400 -3600 0 IST}
- {-149724000 0 1 ISST}
- {-132184800 -3600 0 IST}
- {-118274400 0 1 ISST}
- {-100735200 -3600 0 IST}
- {-86824800 0 1 ISST}
- {-68680800 -3600 0 IST}
+ {-1956609120 -3600 0 -01}
+ {-1668211200 0 1 +00}
+ {-1647212400 -3600 0 -01}
+ {-1636675200 0 1 +00}
+ {-1613430000 -3600 0 -01}
+ {-1605139200 0 1 +00}
+ {-1581894000 -3600 0 -01}
+ {-1539561600 0 1 +00}
+ {-1531350000 -3600 0 -01}
+ {-968025600 0 1 +00}
+ {-952293600 -3600 0 -01}
+ {-942008400 0 1 +00}
+ {-920239200 -3600 0 -01}
+ {-909957600 0 1 +00}
+ {-888789600 -3600 0 -01}
+ {-877903200 0 1 +00}
+ {-857944800 -3600 0 -01}
+ {-846453600 0 1 +00}
+ {-826495200 -3600 0 -01}
+ {-815004000 0 1 +00}
+ {-795045600 -3600 0 -01}
+ {-783554400 0 1 +00}
+ {-762991200 -3600 0 -01}
+ {-752104800 0 1 +00}
+ {-731541600 -3600 0 -01}
+ {-717631200 0 1 +00}
+ {-700092000 -3600 0 -01}
+ {-686181600 0 1 +00}
+ {-668642400 -3600 0 -01}
+ {-654732000 0 1 +00}
+ {-636588000 -3600 0 -01}
+ {-623282400 0 1 +00}
+ {-605743200 -3600 0 -01}
+ {-591832800 0 1 +00}
+ {-573688800 -3600 0 -01}
+ {-559778400 0 1 +00}
+ {-542239200 -3600 0 -01}
+ {-528328800 0 1 +00}
+ {-510789600 -3600 0 -01}
+ {-496879200 0 1 +00}
+ {-479340000 -3600 0 -01}
+ {-465429600 0 1 +00}
+ {-447890400 -3600 0 -01}
+ {-433980000 0 1 +00}
+ {-415836000 -3600 0 -01}
+ {-401925600 0 1 +00}
+ {-384386400 -3600 0 -01}
+ {-370476000 0 1 +00}
+ {-352936800 -3600 0 -01}
+ {-339026400 0 1 +00}
+ {-321487200 -3600 0 -01}
+ {-307576800 0 1 +00}
+ {-290037600 -3600 0 -01}
+ {-276127200 0 1 +00}
+ {-258588000 -3600 0 -01}
+ {-244677600 0 1 +00}
+ {-226533600 -3600 0 -01}
+ {-212623200 0 1 +00}
+ {-195084000 -3600 0 -01}
+ {-181173600 0 1 +00}
+ {-163634400 -3600 0 -01}
+ {-149724000 0 1 +00}
+ {-132184800 -3600 0 -01}
+ {-118274400 0 1 +00}
+ {-100735200 -3600 0 -01}
+ {-86824800 0 1 +00}
+ {-68680800 -3600 0 -01}
{-54770400 0 0 GMT}
}
diff --git a/library/tzdata/Atlantic/South_Georgia b/library/tzdata/Atlantic/South_Georgia
index cbfc826..eb7307c 100644
--- a/library/tzdata/Atlantic/South_Georgia
+++ b/library/tzdata/Atlantic/South_Georgia
@@ -2,5 +2,5 @@
set TZData(:Atlantic/South_Georgia) {
{-9223372036854775808 -8768 0 LMT}
- {-2524512832 -7200 0 GST}
+ {-2524512832 -7200 0 -02}
}
diff --git a/library/tzdata/Atlantic/Stanley b/library/tzdata/Atlantic/Stanley
index c287238..5210832 100644
--- a/library/tzdata/Atlantic/Stanley
+++ b/library/tzdata/Atlantic/Stanley
@@ -3,73 +3,73 @@
set TZData(:Atlantic/Stanley) {
{-9223372036854775808 -13884 0 LMT}
{-2524507716 -13884 0 SMT}
- {-1824235716 -14400 0 FKT}
- {-1018209600 -10800 1 FKST}
- {-1003093200 -14400 0 FKT}
- {-986760000 -10800 1 FKST}
- {-971643600 -14400 0 FKT}
- {-954705600 -10800 1 FKST}
- {-939589200 -14400 0 FKT}
- {-923256000 -10800 1 FKST}
- {-908139600 -14400 0 FKT}
- {-891806400 -10800 1 FKST}
- {-876690000 -14400 0 FKT}
- {-860356800 -10800 1 FKST}
- {420606000 -7200 0 FKT}
- {433303200 -7200 1 FKST}
- {452052000 -10800 0 FKT}
- {464151600 -7200 1 FKST}
- {483501600 -10800 0 FKT}
- {495597600 -14400 0 FKT}
- {495604800 -10800 1 FKST}
- {514350000 -14400 0 FKT}
- {527054400 -10800 1 FKST}
- {545799600 -14400 0 FKT}
- {558504000 -10800 1 FKST}
- {577249200 -14400 0 FKT}
- {589953600 -10800 1 FKST}
- {608698800 -14400 0 FKT}
- {621403200 -10800 1 FKST}
- {640753200 -14400 0 FKT}
- {652852800 -10800 1 FKST}
- {672202800 -14400 0 FKT}
- {684907200 -10800 1 FKST}
- {703652400 -14400 0 FKT}
- {716356800 -10800 1 FKST}
- {735102000 -14400 0 FKT}
- {747806400 -10800 1 FKST}
- {766551600 -14400 0 FKT}
- {779256000 -10800 1 FKST}
- {798001200 -14400 0 FKT}
- {810705600 -10800 1 FKST}
- {830055600 -14400 0 FKT}
- {842760000 -10800 1 FKST}
- {861505200 -14400 0 FKT}
- {874209600 -10800 1 FKST}
- {892954800 -14400 0 FKT}
- {905659200 -10800 1 FKST}
- {924404400 -14400 0 FKT}
- {937108800 -10800 1 FKST}
- {955854000 -14400 0 FKT}
- {968558400 -10800 1 FKST}
- {987310800 -14400 0 FKT}
- {999410400 -10800 1 FKST}
- {1019365200 -14400 0 FKT}
- {1030860000 -10800 1 FKST}
- {1050814800 -14400 0 FKT}
- {1062914400 -10800 1 FKST}
- {1082264400 -14400 0 FKT}
- {1094364000 -10800 1 FKST}
- {1113714000 -14400 0 FKT}
- {1125813600 -10800 1 FKST}
- {1145163600 -14400 0 FKT}
- {1157263200 -10800 1 FKST}
- {1176613200 -14400 0 FKT}
- {1188712800 -10800 1 FKST}
- {1208667600 -14400 0 FKT}
- {1220767200 -10800 1 FKST}
- {1240117200 -14400 0 FKT}
- {1252216800 -10800 1 FKST}
- {1271566800 -14400 0 FKT}
- {1283662800 -10800 0 FKST}
+ {-1824235716 -14400 0 -04}
+ {-1018209600 -10800 1 -03}
+ {-1003093200 -14400 0 -04}
+ {-986760000 -10800 1 -03}
+ {-971643600 -14400 0 -04}
+ {-954705600 -10800 1 -03}
+ {-939589200 -14400 0 -04}
+ {-923256000 -10800 1 -03}
+ {-908139600 -14400 0 -04}
+ {-891806400 -10800 1 -03}
+ {-876690000 -14400 0 -04}
+ {-860356800 -10800 1 -03}
+ {420606000 -7200 0 -03}
+ {433303200 -7200 1 -02}
+ {452052000 -10800 0 -03}
+ {464151600 -7200 1 -02}
+ {483501600 -10800 0 -03}
+ {495597600 -14400 0 -04}
+ {495604800 -10800 1 -03}
+ {514350000 -14400 0 -04}
+ {527054400 -10800 1 -03}
+ {545799600 -14400 0 -04}
+ {558504000 -10800 1 -03}
+ {577249200 -14400 0 -04}
+ {589953600 -10800 1 -03}
+ {608698800 -14400 0 -04}
+ {621403200 -10800 1 -03}
+ {640753200 -14400 0 -04}
+ {652852800 -10800 1 -03}
+ {672202800 -14400 0 -04}
+ {684907200 -10800 1 -03}
+ {703652400 -14400 0 -04}
+ {716356800 -10800 1 -03}
+ {735102000 -14400 0 -04}
+ {747806400 -10800 1 -03}
+ {766551600 -14400 0 -04}
+ {779256000 -10800 1 -03}
+ {798001200 -14400 0 -04}
+ {810705600 -10800 1 -03}
+ {830055600 -14400 0 -04}
+ {842760000 -10800 1 -03}
+ {861505200 -14400 0 -04}
+ {874209600 -10800 1 -03}
+ {892954800 -14400 0 -04}
+ {905659200 -10800 1 -03}
+ {924404400 -14400 0 -04}
+ {937108800 -10800 1 -03}
+ {955854000 -14400 0 -04}
+ {968558400 -10800 1 -03}
+ {987310800 -14400 0 -04}
+ {999410400 -10800 1 -03}
+ {1019365200 -14400 0 -04}
+ {1030860000 -10800 1 -03}
+ {1050814800 -14400 0 -04}
+ {1062914400 -10800 1 -03}
+ {1082264400 -14400 0 -04}
+ {1094364000 -10800 1 -03}
+ {1113714000 -14400 0 -04}
+ {1125813600 -10800 1 -03}
+ {1145163600 -14400 0 -04}
+ {1157263200 -10800 1 -03}
+ {1176613200 -14400 0 -04}
+ {1188712800 -10800 1 -03}
+ {1208667600 -14400 0 -04}
+ {1220767200 -10800 1 -03}
+ {1240117200 -14400 0 -04}
+ {1252216800 -10800 1 -03}
+ {1271566800 -14400 0 -04}
+ {1283662800 -10800 0 -03}
}
diff --git a/library/tzdata/Australia/Eucla b/library/tzdata/Australia/Eucla
index 08a1948..8008980 100644
--- a/library/tzdata/Australia/Eucla
+++ b/library/tzdata/Australia/Eucla
@@ -2,24 +2,24 @@
set TZData(:Australia/Eucla) {
{-9223372036854775808 30928 0 LMT}
- {-2337928528 31500 0 ACWST}
- {-1672562640 35100 1 ACWDT}
- {-1665387900 31500 0 ACWST}
- {-883637100 35100 1 ACWDT}
- {-876123900 31500 0 ACWST}
- {-860395500 35100 1 ACWDT}
- {-844674300 31500 0 ACWST}
- {-836473500 35100 0 ACWST}
- {152039700 35100 1 ACWDT}
- {162926100 31500 0 ACWST}
- {436295700 35100 1 ACWDT}
- {447182100 31500 0 ACWST}
- {690311700 35100 1 ACWDT}
- {699383700 31500 0 ACWST}
- {1165079700 35100 1 ACWDT}
- {1174756500 31500 0 ACWST}
- {1193505300 35100 1 ACWDT}
- {1206810900 31500 0 ACWST}
- {1224954900 35100 1 ACWDT}
- {1238260500 31500 0 ACWST}
+ {-2337928528 31500 0 +0945}
+ {-1672562640 35100 1 +0945}
+ {-1665387900 31500 0 +0945}
+ {-883637100 35100 1 +0945}
+ {-876123900 31500 0 +0945}
+ {-860395500 35100 1 +0945}
+ {-844674300 31500 0 +0945}
+ {-836473500 35100 0 +0945}
+ {152039700 35100 1 +0945}
+ {162926100 31500 0 +0945}
+ {436295700 35100 1 +0945}
+ {447182100 31500 0 +0945}
+ {690311700 35100 1 +0945}
+ {699383700 31500 0 +0945}
+ {1165079700 35100 1 +0945}
+ {1174756500 31500 0 +0945}
+ {1193505300 35100 1 +0945}
+ {1206810900 31500 0 +0945}
+ {1224954900 35100 1 +0945}
+ {1238260500 31500 0 +0945}
}
diff --git a/library/tzdata/Australia/Lord_Howe b/library/tzdata/Australia/Lord_Howe
index a8ff80e..0e2405e 100644
--- a/library/tzdata/Australia/Lord_Howe
+++ b/library/tzdata/Australia/Lord_Howe
@@ -3,242 +3,243 @@
set TZData(:Australia/Lord_Howe) {
{-9223372036854775808 38180 0 LMT}
{-2364114980 36000 0 AEST}
- {352216800 37800 0 LHST}
- {372785400 41400 1 LHDT}
- {384273000 37800 0 LHST}
- {404839800 41400 1 LHDT}
- {415722600 37800 0 LHST}
- {436289400 41400 1 LHDT}
- {447172200 37800 0 LHST}
- {467739000 41400 1 LHDT}
- {478621800 37800 0 LHST}
- {499188600 39600 1 LHDT}
- {511282800 37800 0 LHST}
- {530033400 39600 1 LHDT}
- {542732400 37800 0 LHST}
- {562087800 39600 1 LHDT}
- {574786800 37800 0 LHST}
- {594142200 39600 1 LHDT}
- {606236400 37800 0 LHST}
- {625591800 39600 1 LHDT}
- {636476400 37800 0 LHST}
- {657041400 39600 1 LHDT}
- {667926000 37800 0 LHST}
- {688491000 39600 1 LHDT}
- {699375600 37800 0 LHST}
- {719940600 39600 1 LHDT}
- {731430000 37800 0 LHST}
- {751995000 39600 1 LHDT}
- {762879600 37800 0 LHST}
- {783444600 39600 1 LHDT}
- {794329200 37800 0 LHST}
- {814894200 39600 1 LHDT}
- {828198000 37800 0 LHST}
- {846343800 39600 1 LHDT}
- {859647600 37800 0 LHST}
- {877793400 39600 1 LHDT}
- {891097200 37800 0 LHST}
- {909243000 39600 1 LHDT}
- {922546800 37800 0 LHST}
- {941297400 39600 1 LHDT}
- {953996400 37800 0 LHST}
- {967303800 39600 1 LHDT}
- {985446000 37800 0 LHST}
- {1004196600 39600 1 LHDT}
- {1017500400 37800 0 LHST}
- {1035646200 39600 1 LHDT}
- {1048950000 37800 0 LHST}
- {1067095800 39600 1 LHDT}
- {1080399600 37800 0 LHST}
- {1099150200 39600 1 LHDT}
- {1111849200 37800 0 LHST}
- {1130599800 39600 1 LHDT}
- {1143903600 37800 0 LHST}
- {1162049400 39600 1 LHDT}
- {1174748400 37800 0 LHST}
- {1193499000 39600 1 LHDT}
- {1207407600 37800 0 LHST}
- {1223134200 39600 1 LHDT}
- {1238857200 37800 0 LHST}
- {1254583800 39600 1 LHDT}
- {1270306800 37800 0 LHST}
- {1286033400 39600 1 LHDT}
- {1301756400 37800 0 LHST}
- {1317483000 39600 1 LHDT}
- {1333206000 37800 0 LHST}
- {1349537400 39600 1 LHDT}
- {1365260400 37800 0 LHST}
- {1380987000 39600 1 LHDT}
- {1396710000 37800 0 LHST}
- {1412436600 39600 1 LHDT}
- {1428159600 37800 0 LHST}
- {1443886200 39600 1 LHDT}
- {1459609200 37800 0 LHST}
- {1475335800 39600 1 LHDT}
- {1491058800 37800 0 LHST}
- {1506785400 39600 1 LHDT}
- {1522508400 37800 0 LHST}
- {1538839800 39600 1 LHDT}
- {1554562800 37800 0 LHST}
- {1570289400 39600 1 LHDT}
- {1586012400 37800 0 LHST}
- {1601739000 39600 1 LHDT}
- {1617462000 37800 0 LHST}
- {1633188600 39600 1 LHDT}
- {1648911600 37800 0 LHST}
- {1664638200 39600 1 LHDT}
- {1680361200 37800 0 LHST}
- {1696087800 39600 1 LHDT}
- {1712415600 37800 0 LHST}
- {1728142200 39600 1 LHDT}
- {1743865200 37800 0 LHST}
- {1759591800 39600 1 LHDT}
- {1775314800 37800 0 LHST}
- {1791041400 39600 1 LHDT}
- {1806764400 37800 0 LHST}
- {1822491000 39600 1 LHDT}
- {1838214000 37800 0 LHST}
- {1853940600 39600 1 LHDT}
- {1869663600 37800 0 LHST}
- {1885995000 39600 1 LHDT}
- {1901718000 37800 0 LHST}
- {1917444600 39600 1 LHDT}
- {1933167600 37800 0 LHST}
- {1948894200 39600 1 LHDT}
- {1964617200 37800 0 LHST}
- {1980343800 39600 1 LHDT}
- {1996066800 37800 0 LHST}
- {2011793400 39600 1 LHDT}
- {2027516400 37800 0 LHST}
- {2043243000 39600 1 LHDT}
- {2058966000 37800 0 LHST}
- {2075297400 39600 1 LHDT}
- {2091020400 37800 0 LHST}
- {2106747000 39600 1 LHDT}
- {2122470000 37800 0 LHST}
- {2138196600 39600 1 LHDT}
- {2153919600 37800 0 LHST}
- {2169646200 39600 1 LHDT}
- {2185369200 37800 0 LHST}
- {2201095800 39600 1 LHDT}
- {2216818800 37800 0 LHST}
- {2233150200 39600 1 LHDT}
- {2248873200 37800 0 LHST}
- {2264599800 39600 1 LHDT}
- {2280322800 37800 0 LHST}
- {2296049400 39600 1 LHDT}
- {2311772400 37800 0 LHST}
- {2327499000 39600 1 LHDT}
- {2343222000 37800 0 LHST}
- {2358948600 39600 1 LHDT}
- {2374671600 37800 0 LHST}
- {2390398200 39600 1 LHDT}
- {2406121200 37800 0 LHST}
- {2422452600 39600 1 LHDT}
- {2438175600 37800 0 LHST}
- {2453902200 39600 1 LHDT}
- {2469625200 37800 0 LHST}
- {2485351800 39600 1 LHDT}
- {2501074800 37800 0 LHST}
- {2516801400 39600 1 LHDT}
- {2532524400 37800 0 LHST}
- {2548251000 39600 1 LHDT}
- {2563974000 37800 0 LHST}
- {2579700600 39600 1 LHDT}
- {2596028400 37800 0 LHST}
- {2611755000 39600 1 LHDT}
- {2627478000 37800 0 LHST}
- {2643204600 39600 1 LHDT}
- {2658927600 37800 0 LHST}
- {2674654200 39600 1 LHDT}
- {2690377200 37800 0 LHST}
- {2706103800 39600 1 LHDT}
- {2721826800 37800 0 LHST}
- {2737553400 39600 1 LHDT}
- {2753276400 37800 0 LHST}
- {2769607800 39600 1 LHDT}
- {2785330800 37800 0 LHST}
- {2801057400 39600 1 LHDT}
- {2816780400 37800 0 LHST}
- {2832507000 39600 1 LHDT}
- {2848230000 37800 0 LHST}
- {2863956600 39600 1 LHDT}
- {2879679600 37800 0 LHST}
- {2895406200 39600 1 LHDT}
- {2911129200 37800 0 LHST}
- {2926855800 39600 1 LHDT}
- {2942578800 37800 0 LHST}
- {2958910200 39600 1 LHDT}
- {2974633200 37800 0 LHST}
- {2990359800 39600 1 LHDT}
- {3006082800 37800 0 LHST}
- {3021809400 39600 1 LHDT}
- {3037532400 37800 0 LHST}
- {3053259000 39600 1 LHDT}
- {3068982000 37800 0 LHST}
- {3084708600 39600 1 LHDT}
- {3100431600 37800 0 LHST}
- {3116763000 39600 1 LHDT}
- {3132486000 37800 0 LHST}
- {3148212600 39600 1 LHDT}
- {3163935600 37800 0 LHST}
- {3179662200 39600 1 LHDT}
- {3195385200 37800 0 LHST}
- {3211111800 39600 1 LHDT}
- {3226834800 37800 0 LHST}
- {3242561400 39600 1 LHDT}
- {3258284400 37800 0 LHST}
- {3274011000 39600 1 LHDT}
- {3289734000 37800 0 LHST}
- {3306065400 39600 1 LHDT}
- {3321788400 37800 0 LHST}
- {3337515000 39600 1 LHDT}
- {3353238000 37800 0 LHST}
- {3368964600 39600 1 LHDT}
- {3384687600 37800 0 LHST}
- {3400414200 39600 1 LHDT}
- {3416137200 37800 0 LHST}
- {3431863800 39600 1 LHDT}
- {3447586800 37800 0 LHST}
- {3463313400 39600 1 LHDT}
- {3479641200 37800 0 LHST}
- {3495367800 39600 1 LHDT}
- {3511090800 37800 0 LHST}
- {3526817400 39600 1 LHDT}
- {3542540400 37800 0 LHST}
- {3558267000 39600 1 LHDT}
- {3573990000 37800 0 LHST}
- {3589716600 39600 1 LHDT}
- {3605439600 37800 0 LHST}
- {3621166200 39600 1 LHDT}
- {3636889200 37800 0 LHST}
- {3653220600 39600 1 LHDT}
- {3668943600 37800 0 LHST}
- {3684670200 39600 1 LHDT}
- {3700393200 37800 0 LHST}
- {3716119800 39600 1 LHDT}
- {3731842800 37800 0 LHST}
- {3747569400 39600 1 LHDT}
- {3763292400 37800 0 LHST}
- {3779019000 39600 1 LHDT}
- {3794742000 37800 0 LHST}
- {3810468600 39600 1 LHDT}
- {3826191600 37800 0 LHST}
- {3842523000 39600 1 LHDT}
- {3858246000 37800 0 LHST}
- {3873972600 39600 1 LHDT}
- {3889695600 37800 0 LHST}
- {3905422200 39600 1 LHDT}
- {3921145200 37800 0 LHST}
- {3936871800 39600 1 LHDT}
- {3952594800 37800 0 LHST}
- {3968321400 39600 1 LHDT}
- {3984044400 37800 0 LHST}
- {4000375800 39600 1 LHDT}
- {4016098800 37800 0 LHST}
- {4031825400 39600 1 LHDT}
- {4047548400 37800 0 LHST}
- {4063275000 39600 1 LHDT}
- {4078998000 37800 0 LHST}
- {4094724600 39600 1 LHDT}
+ {352216800 37800 0 +1130}
+ {372785400 41400 1 +1130}
+ {384273000 37800 0 +1130}
+ {404839800 41400 1 +1130}
+ {415722600 37800 0 +1130}
+ {436289400 41400 1 +1130}
+ {447172200 37800 0 +1130}
+ {467739000 41400 1 +1130}
+ {478621800 37800 0 +1130}
+ {488984400 37800 0 +11}
+ {499188600 39600 1 +11}
+ {511282800 37800 0 +11}
+ {530033400 39600 1 +11}
+ {542732400 37800 0 +11}
+ {562087800 39600 1 +11}
+ {574786800 37800 0 +11}
+ {594142200 39600 1 +11}
+ {606236400 37800 0 +11}
+ {625591800 39600 1 +11}
+ {636476400 37800 0 +11}
+ {657041400 39600 1 +11}
+ {667926000 37800 0 +11}
+ {688491000 39600 1 +11}
+ {699375600 37800 0 +11}
+ {719940600 39600 1 +11}
+ {731430000 37800 0 +11}
+ {751995000 39600 1 +11}
+ {762879600 37800 0 +11}
+ {783444600 39600 1 +11}
+ {794329200 37800 0 +11}
+ {814894200 39600 1 +11}
+ {828198000 37800 0 +11}
+ {846343800 39600 1 +11}
+ {859647600 37800 0 +11}
+ {877793400 39600 1 +11}
+ {891097200 37800 0 +11}
+ {909243000 39600 1 +11}
+ {922546800 37800 0 +11}
+ {941297400 39600 1 +11}
+ {953996400 37800 0 +11}
+ {967303800 39600 1 +11}
+ {985446000 37800 0 +11}
+ {1004196600 39600 1 +11}
+ {1017500400 37800 0 +11}
+ {1035646200 39600 1 +11}
+ {1048950000 37800 0 +11}
+ {1067095800 39600 1 +11}
+ {1080399600 37800 0 +11}
+ {1099150200 39600 1 +11}
+ {1111849200 37800 0 +11}
+ {1130599800 39600 1 +11}
+ {1143903600 37800 0 +11}
+ {1162049400 39600 1 +11}
+ {1174748400 37800 0 +11}
+ {1193499000 39600 1 +11}
+ {1207407600 37800 0 +11}
+ {1223134200 39600 1 +11}
+ {1238857200 37800 0 +11}
+ {1254583800 39600 1 +11}
+ {1270306800 37800 0 +11}
+ {1286033400 39600 1 +11}
+ {1301756400 37800 0 +11}
+ {1317483000 39600 1 +11}
+ {1333206000 37800 0 +11}
+ {1349537400 39600 1 +11}
+ {1365260400 37800 0 +11}
+ {1380987000 39600 1 +11}
+ {1396710000 37800 0 +11}
+ {1412436600 39600 1 +11}
+ {1428159600 37800 0 +11}
+ {1443886200 39600 1 +11}
+ {1459609200 37800 0 +11}
+ {1475335800 39600 1 +11}
+ {1491058800 37800 0 +11}
+ {1506785400 39600 1 +11}
+ {1522508400 37800 0 +11}
+ {1538839800 39600 1 +11}
+ {1554562800 37800 0 +11}
+ {1570289400 39600 1 +11}
+ {1586012400 37800 0 +11}
+ {1601739000 39600 1 +11}
+ {1617462000 37800 0 +11}
+ {1633188600 39600 1 +11}
+ {1648911600 37800 0 +11}
+ {1664638200 39600 1 +11}
+ {1680361200 37800 0 +11}
+ {1696087800 39600 1 +11}
+ {1712415600 37800 0 +11}
+ {1728142200 39600 1 +11}
+ {1743865200 37800 0 +11}
+ {1759591800 39600 1 +11}
+ {1775314800 37800 0 +11}
+ {1791041400 39600 1 +11}
+ {1806764400 37800 0 +11}
+ {1822491000 39600 1 +11}
+ {1838214000 37800 0 +11}
+ {1853940600 39600 1 +11}
+ {1869663600 37800 0 +11}
+ {1885995000 39600 1 +11}
+ {1901718000 37800 0 +11}
+ {1917444600 39600 1 +11}
+ {1933167600 37800 0 +11}
+ {1948894200 39600 1 +11}
+ {1964617200 37800 0 +11}
+ {1980343800 39600 1 +11}
+ {1996066800 37800 0 +11}
+ {2011793400 39600 1 +11}
+ {2027516400 37800 0 +11}
+ {2043243000 39600 1 +11}
+ {2058966000 37800 0 +11}
+ {2075297400 39600 1 +11}
+ {2091020400 37800 0 +11}
+ {2106747000 39600 1 +11}
+ {2122470000 37800 0 +11}
+ {2138196600 39600 1 +11}
+ {2153919600 37800 0 +11}
+ {2169646200 39600 1 +11}
+ {2185369200 37800 0 +11}
+ {2201095800 39600 1 +11}
+ {2216818800 37800 0 +11}
+ {2233150200 39600 1 +11}
+ {2248873200 37800 0 +11}
+ {2264599800 39600 1 +11}
+ {2280322800 37800 0 +11}
+ {2296049400 39600 1 +11}
+ {2311772400 37800 0 +11}
+ {2327499000 39600 1 +11}
+ {2343222000 37800 0 +11}
+ {2358948600 39600 1 +11}
+ {2374671600 37800 0 +11}
+ {2390398200 39600 1 +11}
+ {2406121200 37800 0 +11}
+ {2422452600 39600 1 +11}
+ {2438175600 37800 0 +11}
+ {2453902200 39600 1 +11}
+ {2469625200 37800 0 +11}
+ {2485351800 39600 1 +11}
+ {2501074800 37800 0 +11}
+ {2516801400 39600 1 +11}
+ {2532524400 37800 0 +11}
+ {2548251000 39600 1 +11}
+ {2563974000 37800 0 +11}
+ {2579700600 39600 1 +11}
+ {2596028400 37800 0 +11}
+ {2611755000 39600 1 +11}
+ {2627478000 37800 0 +11}
+ {2643204600 39600 1 +11}
+ {2658927600 37800 0 +11}
+ {2674654200 39600 1 +11}
+ {2690377200 37800 0 +11}
+ {2706103800 39600 1 +11}
+ {2721826800 37800 0 +11}
+ {2737553400 39600 1 +11}
+ {2753276400 37800 0 +11}
+ {2769607800 39600 1 +11}
+ {2785330800 37800 0 +11}
+ {2801057400 39600 1 +11}
+ {2816780400 37800 0 +11}
+ {2832507000 39600 1 +11}
+ {2848230000 37800 0 +11}
+ {2863956600 39600 1 +11}
+ {2879679600 37800 0 +11}
+ {2895406200 39600 1 +11}
+ {2911129200 37800 0 +11}
+ {2926855800 39600 1 +11}
+ {2942578800 37800 0 +11}
+ {2958910200 39600 1 +11}
+ {2974633200 37800 0 +11}
+ {2990359800 39600 1 +11}
+ {3006082800 37800 0 +11}
+ {3021809400 39600 1 +11}
+ {3037532400 37800 0 +11}
+ {3053259000 39600 1 +11}
+ {3068982000 37800 0 +11}
+ {3084708600 39600 1 +11}
+ {3100431600 37800 0 +11}
+ {3116763000 39600 1 +11}
+ {3132486000 37800 0 +11}
+ {3148212600 39600 1 +11}
+ {3163935600 37800 0 +11}
+ {3179662200 39600 1 +11}
+ {3195385200 37800 0 +11}
+ {3211111800 39600 1 +11}
+ {3226834800 37800 0 +11}
+ {3242561400 39600 1 +11}
+ {3258284400 37800 0 +11}
+ {3274011000 39600 1 +11}
+ {3289734000 37800 0 +11}
+ {3306065400 39600 1 +11}
+ {3321788400 37800 0 +11}
+ {3337515000 39600 1 +11}
+ {3353238000 37800 0 +11}
+ {3368964600 39600 1 +11}
+ {3384687600 37800 0 +11}
+ {3400414200 39600 1 +11}
+ {3416137200 37800 0 +11}
+ {3431863800 39600 1 +11}
+ {3447586800 37800 0 +11}
+ {3463313400 39600 1 +11}
+ {3479641200 37800 0 +11}
+ {3495367800 39600 1 +11}
+ {3511090800 37800 0 +11}
+ {3526817400 39600 1 +11}
+ {3542540400 37800 0 +11}
+ {3558267000 39600 1 +11}
+ {3573990000 37800 0 +11}
+ {3589716600 39600 1 +11}
+ {3605439600 37800 0 +11}
+ {3621166200 39600 1 +11}
+ {3636889200 37800 0 +11}
+ {3653220600 39600 1 +11}
+ {3668943600 37800 0 +11}
+ {3684670200 39600 1 +11}
+ {3700393200 37800 0 +11}
+ {3716119800 39600 1 +11}
+ {3731842800 37800 0 +11}
+ {3747569400 39600 1 +11}
+ {3763292400 37800 0 +11}
+ {3779019000 39600 1 +11}
+ {3794742000 37800 0 +11}
+ {3810468600 39600 1 +11}
+ {3826191600 37800 0 +11}
+ {3842523000 39600 1 +11}
+ {3858246000 37800 0 +11}
+ {3873972600 39600 1 +11}
+ {3889695600 37800 0 +11}
+ {3905422200 39600 1 +11}
+ {3921145200 37800 0 +11}
+ {3936871800 39600 1 +11}
+ {3952594800 37800 0 +11}
+ {3968321400 39600 1 +11}
+ {3984044400 37800 0 +11}
+ {4000375800 39600 1 +11}
+ {4016098800 37800 0 +11}
+ {4031825400 39600 1 +11}
+ {4047548400 37800 0 +11}
+ {4063275000 39600 1 +11}
+ {4078998000 37800 0 +11}
+ {4094724600 39600 1 +11}
}
diff --git a/library/tzdata/Etc/GMT+1 b/library/tzdata/Etc/GMT+1
index 12f97ba..70d39cf 100644
--- a/library/tzdata/Etc/GMT+1
+++ b/library/tzdata/Etc/GMT+1
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+1) {
- {-9223372036854775808 -3600 0 GMT+1}
+ {-9223372036854775808 -3600 0 -01}
}
diff --git a/library/tzdata/Etc/GMT+10 b/library/tzdata/Etc/GMT+10
index 6ea50bb..9165a08 100644
--- a/library/tzdata/Etc/GMT+10
+++ b/library/tzdata/Etc/GMT+10
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+10) {
- {-9223372036854775808 -36000 0 GMT+10}
+ {-9223372036854775808 -36000 0 -10}
}
diff --git a/library/tzdata/Etc/GMT+11 b/library/tzdata/Etc/GMT+11
index c91b169..a1aaf74 100644
--- a/library/tzdata/Etc/GMT+11
+++ b/library/tzdata/Etc/GMT+11
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+11) {
- {-9223372036854775808 -39600 0 GMT+11}
+ {-9223372036854775808 -39600 0 -11}
}
diff --git a/library/tzdata/Etc/GMT+12 b/library/tzdata/Etc/GMT+12
index 29a4cee..d2c082a 100644
--- a/library/tzdata/Etc/GMT+12
+++ b/library/tzdata/Etc/GMT+12
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+12) {
- {-9223372036854775808 -43200 0 GMT+12}
+ {-9223372036854775808 -43200 0 -12}
}
diff --git a/library/tzdata/Etc/GMT+2 b/library/tzdata/Etc/GMT+2
index 8c6b526..46cca7d 100644
--- a/library/tzdata/Etc/GMT+2
+++ b/library/tzdata/Etc/GMT+2
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+2) {
- {-9223372036854775808 -7200 0 GMT+2}
+ {-9223372036854775808 -7200 0 -02}
}
diff --git a/library/tzdata/Etc/GMT+3 b/library/tzdata/Etc/GMT+3
index 862571d..e1e3001 100644
--- a/library/tzdata/Etc/GMT+3
+++ b/library/tzdata/Etc/GMT+3
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+3) {
- {-9223372036854775808 -10800 0 GMT+3}
+ {-9223372036854775808 -10800 0 -03}
}
diff --git a/library/tzdata/Etc/GMT+4 b/library/tzdata/Etc/GMT+4
index a933bbc..32afa24 100644
--- a/library/tzdata/Etc/GMT+4
+++ b/library/tzdata/Etc/GMT+4
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+4) {
- {-9223372036854775808 -14400 0 GMT+4}
+ {-9223372036854775808 -14400 0 -04}
}
diff --git a/library/tzdata/Etc/GMT+5 b/library/tzdata/Etc/GMT+5
index 80cc25c..747abf5 100644
--- a/library/tzdata/Etc/GMT+5
+++ b/library/tzdata/Etc/GMT+5
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+5) {
- {-9223372036854775808 -18000 0 GMT+5}
+ {-9223372036854775808 -18000 0 -05}
}
diff --git a/library/tzdata/Etc/GMT+6 b/library/tzdata/Etc/GMT+6
index bc57bd6..1096839 100644
--- a/library/tzdata/Etc/GMT+6
+++ b/library/tzdata/Etc/GMT+6
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+6) {
- {-9223372036854775808 -21600 0 GMT+6}
+ {-9223372036854775808 -21600 0 -06}
}
diff --git a/library/tzdata/Etc/GMT+7 b/library/tzdata/Etc/GMT+7
index d419eb9..6d47863 100644
--- a/library/tzdata/Etc/GMT+7
+++ b/library/tzdata/Etc/GMT+7
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+7) {
- {-9223372036854775808 -25200 0 GMT+7}
+ {-9223372036854775808 -25200 0 -07}
}
diff --git a/library/tzdata/Etc/GMT+8 b/library/tzdata/Etc/GMT+8
index 705ad40..33c0f69 100644
--- a/library/tzdata/Etc/GMT+8
+++ b/library/tzdata/Etc/GMT+8
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+8) {
- {-9223372036854775808 -28800 0 GMT+8}
+ {-9223372036854775808 -28800 0 -08}
}
diff --git a/library/tzdata/Etc/GMT+9 b/library/tzdata/Etc/GMT+9
index 4086639..4119bf4 100644
--- a/library/tzdata/Etc/GMT+9
+++ b/library/tzdata/Etc/GMT+9
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT+9) {
- {-9223372036854775808 -32400 0 GMT+9}
+ {-9223372036854775808 -32400 0 -09}
}
diff --git a/library/tzdata/Etc/GMT-1 b/library/tzdata/Etc/GMT-1
index a44dd1f..e7ac44b 100644
--- a/library/tzdata/Etc/GMT-1
+++ b/library/tzdata/Etc/GMT-1
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-1) {
- {-9223372036854775808 3600 0 GMT-1}
+ {-9223372036854775808 3600 0 +01}
}
diff --git a/library/tzdata/Etc/GMT-10 b/library/tzdata/Etc/GMT-10
index 1c50d01..fdbd1e3 100644
--- a/library/tzdata/Etc/GMT-10
+++ b/library/tzdata/Etc/GMT-10
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-10) {
- {-9223372036854775808 36000 0 GMT-10}
+ {-9223372036854775808 36000 0 +10}
}
diff --git a/library/tzdata/Etc/GMT-11 b/library/tzdata/Etc/GMT-11
index d07710f..4b28ad0 100644
--- a/library/tzdata/Etc/GMT-11
+++ b/library/tzdata/Etc/GMT-11
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-11) {
- {-9223372036854775808 39600 0 GMT-11}
+ {-9223372036854775808 39600 0 +11}
}
diff --git a/library/tzdata/Etc/GMT-12 b/library/tzdata/Etc/GMT-12
index a23b98d..594bac3 100644
--- a/library/tzdata/Etc/GMT-12
+++ b/library/tzdata/Etc/GMT-12
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-12) {
- {-9223372036854775808 43200 0 GMT-12}
+ {-9223372036854775808 43200 0 +12}
}
diff --git a/library/tzdata/Etc/GMT-13 b/library/tzdata/Etc/GMT-13
index 1a6700a..f61159e 100644
--- a/library/tzdata/Etc/GMT-13
+++ b/library/tzdata/Etc/GMT-13
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-13) {
- {-9223372036854775808 46800 0 GMT-13}
+ {-9223372036854775808 46800 0 +13}
}
diff --git a/library/tzdata/Etc/GMT-14 b/library/tzdata/Etc/GMT-14
index 3707e21..493800f 100644
--- a/library/tzdata/Etc/GMT-14
+++ b/library/tzdata/Etc/GMT-14
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-14) {
- {-9223372036854775808 50400 0 GMT-14}
+ {-9223372036854775808 50400 0 +14}
}
diff --git a/library/tzdata/Etc/GMT-2 b/library/tzdata/Etc/GMT-2
index f9dea16..51fdbed 100644
--- a/library/tzdata/Etc/GMT-2
+++ b/library/tzdata/Etc/GMT-2
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-2) {
- {-9223372036854775808 7200 0 GMT-2}
+ {-9223372036854775808 7200 0 +02}
}
diff --git a/library/tzdata/Etc/GMT-3 b/library/tzdata/Etc/GMT-3
index 99145b8..7aed39d 100644
--- a/library/tzdata/Etc/GMT-3
+++ b/library/tzdata/Etc/GMT-3
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-3) {
- {-9223372036854775808 10800 0 GMT-3}
+ {-9223372036854775808 10800 0 +03}
}
diff --git a/library/tzdata/Etc/GMT-4 b/library/tzdata/Etc/GMT-4
index 27b4fec..6ca6372 100644
--- a/library/tzdata/Etc/GMT-4
+++ b/library/tzdata/Etc/GMT-4
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-4) {
- {-9223372036854775808 14400 0 GMT-4}
+ {-9223372036854775808 14400 0 +04}
}
diff --git a/library/tzdata/Etc/GMT-5 b/library/tzdata/Etc/GMT-5
index dbe3df7..6c47a31 100644
--- a/library/tzdata/Etc/GMT-5
+++ b/library/tzdata/Etc/GMT-5
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-5) {
- {-9223372036854775808 18000 0 GMT-5}
+ {-9223372036854775808 18000 0 +05}
}
diff --git a/library/tzdata/Etc/GMT-6 b/library/tzdata/Etc/GMT-6
index 414dbfa..202e7f8 100644
--- a/library/tzdata/Etc/GMT-6
+++ b/library/tzdata/Etc/GMT-6
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-6) {
- {-9223372036854775808 21600 0 GMT-6}
+ {-9223372036854775808 21600 0 +06}
}
diff --git a/library/tzdata/Etc/GMT-7 b/library/tzdata/Etc/GMT-7
index 2bd59db..c6deaf3 100644
--- a/library/tzdata/Etc/GMT-7
+++ b/library/tzdata/Etc/GMT-7
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-7) {
- {-9223372036854775808 25200 0 GMT-7}
+ {-9223372036854775808 25200 0 +07}
}
diff --git a/library/tzdata/Etc/GMT-8 b/library/tzdata/Etc/GMT-8
index 7303721..4bed42e 100644
--- a/library/tzdata/Etc/GMT-8
+++ b/library/tzdata/Etc/GMT-8
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-8) {
- {-9223372036854775808 28800 0 GMT-8}
+ {-9223372036854775808 28800 0 +08}
}
diff --git a/library/tzdata/Etc/GMT-9 b/library/tzdata/Etc/GMT-9
index 46e6878..2a7625b 100644
--- a/library/tzdata/Etc/GMT-9
+++ b/library/tzdata/Etc/GMT-9
@@ -1,5 +1,5 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Etc/GMT-9) {
- {-9223372036854775808 32400 0 GMT-9}
+ {-9223372036854775808 32400 0 +09}
}
diff --git a/library/tzdata/Europe/Amsterdam b/library/tzdata/Europe/Amsterdam
index bd89127..b683c99 100644
--- a/library/tzdata/Europe/Amsterdam
+++ b/library/tzdata/Europe/Amsterdam
@@ -46,12 +46,12 @@ set TZData(:Europe/Amsterdam) {
{-1061331572 4772 1 NST}
{-1049062772 1172 0 AMT}
{-1029190772 4772 1 NST}
- {-1025741972 4800 0 NEST}
- {-1017613200 1200 0 NET}
- {-998259600 4800 1 NEST}
- {-986163600 1200 0 NET}
- {-966723600 4800 1 NEST}
- {-954109200 1200 0 NET}
+ {-1025741972 4800 0 +0120}
+ {-1017613200 1200 0 +0020}
+ {-998259600 4800 1 +0120}
+ {-986163600 1200 0 +0020}
+ {-966723600 4800 1 +0120}
+ {-954109200 1200 0 +0020}
{-935022000 7200 0 CEST}
{-857257200 3600 0 CET}
{-844556400 7200 1 CEST}
diff --git a/library/tzdata/Europe/Istanbul b/library/tzdata/Europe/Istanbul
index 8eadbc3..d00533f 100644
--- a/library/tzdata/Europe/Istanbul
+++ b/library/tzdata/Europe/Istanbul
@@ -57,37 +57,37 @@ set TZData(:Europe/Istanbul) {
{228866400 10800 1 EEST}
{245797200 7200 0 EET}
{260316000 10800 1 EEST}
- {277246800 14400 0 TRST}
- {291769200 14400 1 TRST}
- {308779200 10800 0 TRT}
- {323827200 14400 1 TRST}
- {340228800 10800 0 TRT}
- {354672000 14400 1 TRST}
- {371678400 10800 0 TRT}
- {386121600 14400 1 TRST}
- {403128000 10800 0 TRT}
- {428446800 14400 1 TRST}
- {433886400 10800 0 TRT}
+ {277246800 14400 0 +04}
+ {291769200 14400 1 +04}
+ {308779200 10800 0 +03}
+ {323827200 14400 1 +04}
+ {340228800 10800 0 +03}
+ {354672000 14400 1 +04}
+ {371678400 10800 0 +03}
+ {386121600 14400 1 +04}
+ {403128000 10800 0 +03}
+ {428446800 14400 1 +04}
+ {433886400 10800 0 +03}
{482792400 7200 0 EET}
{482796000 10800 1 EEST}
{496702800 7200 0 EET}
- {512524800 10800 1 EEST}
- {528249600 7200 0 EET}
- {543974400 10800 1 EEST}
- {559699200 7200 0 EET}
- {575424000 10800 1 EEST}
- {591148800 7200 0 EET}
- {606873600 10800 1 EEST}
- {622598400 7200 0 EET}
- {638323200 10800 1 EEST}
- {654652800 7200 0 EET}
+ {512521200 10800 1 EEST}
+ {528246000 7200 0 EET}
+ {543970800 10800 1 EEST}
+ {559695600 7200 0 EET}
+ {575420400 10800 1 EEST}
+ {591145200 7200 0 EET}
+ {606870000 10800 1 EEST}
+ {622594800 7200 0 EET}
+ {638319600 10800 1 EEST}
+ {654649200 7200 0 EET}
{670374000 10800 1 EEST}
{686098800 7200 0 EET}
{701823600 10800 1 EEST}
{717548400 7200 0 EET}
{733273200 10800 1 EEST}
{748998000 7200 0 EET}
- {764722800 10800 1 EEST}
+ {764118000 10800 1 EEST}
{780447600 7200 0 EET}
{796172400 10800 1 EEST}
{811897200 7200 0 EET}
@@ -136,171 +136,5 @@ set TZData(:Europe/Istanbul) {
{1445734800 10800 1 EEST}
{1446944400 7200 0 EET}
{1459040400 10800 1 EEST}
- {1477789200 7200 0 EET}
- {1490490000 10800 1 EEST}
- {1509238800 7200 0 EET}
- {1521939600 10800 1 EEST}
- {1540688400 7200 0 EET}
- {1553994000 10800 1 EEST}
- {1572138000 7200 0 EET}
- {1585443600 10800 1 EEST}
- {1603587600 7200 0 EET}
- {1616893200 10800 1 EEST}
- {1635642000 7200 0 EET}
- {1648342800 10800 1 EEST}
- {1667091600 7200 0 EET}
- {1679792400 10800 1 EEST}
- {1698541200 7200 0 EET}
- {1711846800 10800 1 EEST}
- {1729990800 7200 0 EET}
- {1743296400 10800 1 EEST}
- {1761440400 7200 0 EET}
- {1774746000 10800 1 EEST}
- {1792890000 7200 0 EET}
- {1806195600 10800 1 EEST}
- {1824944400 7200 0 EET}
- {1837645200 10800 1 EEST}
- {1856394000 7200 0 EET}
- {1869094800 10800 1 EEST}
- {1887843600 7200 0 EET}
- {1901149200 10800 1 EEST}
- {1919293200 7200 0 EET}
- {1932598800 10800 1 EEST}
- {1950742800 7200 0 EET}
- {1964048400 10800 1 EEST}
- {1982797200 7200 0 EET}
- {1995498000 10800 1 EEST}
- {2014246800 7200 0 EET}
- {2026947600 10800 1 EEST}
- {2045696400 7200 0 EET}
- {2058397200 10800 1 EEST}
- {2077146000 7200 0 EET}
- {2090451600 10800 1 EEST}
- {2108595600 7200 0 EET}
- {2121901200 10800 1 EEST}
- {2140045200 7200 0 EET}
- {2153350800 10800 1 EEST}
- {2172099600 7200 0 EET}
- {2184800400 10800 1 EEST}
- {2203549200 7200 0 EET}
- {2216250000 10800 1 EEST}
- {2234998800 7200 0 EET}
- {2248304400 10800 1 EEST}
- {2266448400 7200 0 EET}
- {2279754000 10800 1 EEST}
- {2297898000 7200 0 EET}
- {2311203600 10800 1 EEST}
- {2329347600 7200 0 EET}
- {2342653200 10800 1 EEST}
- {2361402000 7200 0 EET}
- {2374102800 10800 1 EEST}
- {2392851600 7200 0 EET}
- {2405552400 10800 1 EEST}
- {2424301200 7200 0 EET}
- {2437606800 10800 1 EEST}
- {2455750800 7200 0 EET}
- {2469056400 10800 1 EEST}
- {2487200400 7200 0 EET}
- {2500506000 10800 1 EEST}
- {2519254800 7200 0 EET}
- {2531955600 10800 1 EEST}
- {2550704400 7200 0 EET}
- {2563405200 10800 1 EEST}
- {2582154000 7200 0 EET}
- {2595459600 10800 1 EEST}
- {2613603600 7200 0 EET}
- {2626909200 10800 1 EEST}
- {2645053200 7200 0 EET}
- {2658358800 10800 1 EEST}
- {2676502800 7200 0 EET}
- {2689808400 10800 1 EEST}
- {2708557200 7200 0 EET}
- {2721258000 10800 1 EEST}
- {2740006800 7200 0 EET}
- {2752707600 10800 1 EEST}
- {2771456400 7200 0 EET}
- {2784762000 10800 1 EEST}
- {2802906000 7200 0 EET}
- {2816211600 10800 1 EEST}
- {2834355600 7200 0 EET}
- {2847661200 10800 1 EEST}
- {2866410000 7200 0 EET}
- {2879110800 10800 1 EEST}
- {2897859600 7200 0 EET}
- {2910560400 10800 1 EEST}
- {2929309200 7200 0 EET}
- {2942010000 10800 1 EEST}
- {2960758800 7200 0 EET}
- {2974064400 10800 1 EEST}
- {2992208400 7200 0 EET}
- {3005514000 10800 1 EEST}
- {3023658000 7200 0 EET}
- {3036963600 10800 1 EEST}
- {3055712400 7200 0 EET}
- {3068413200 10800 1 EEST}
- {3087162000 7200 0 EET}
- {3099862800 10800 1 EEST}
- {3118611600 7200 0 EET}
- {3131917200 10800 1 EEST}
- {3150061200 7200 0 EET}
- {3163366800 10800 1 EEST}
- {3181510800 7200 0 EET}
- {3194816400 10800 1 EEST}
- {3212960400 7200 0 EET}
- {3226266000 10800 1 EEST}
- {3245014800 7200 0 EET}
- {3257715600 10800 1 EEST}
- {3276464400 7200 0 EET}
- {3289165200 10800 1 EEST}
- {3307914000 7200 0 EET}
- {3321219600 10800 1 EEST}
- {3339363600 7200 0 EET}
- {3352669200 10800 1 EEST}
- {3370813200 7200 0 EET}
- {3384118800 10800 1 EEST}
- {3402867600 7200 0 EET}
- {3415568400 10800 1 EEST}
- {3434317200 7200 0 EET}
- {3447018000 10800 1 EEST}
- {3465766800 7200 0 EET}
- {3479072400 10800 1 EEST}
- {3497216400 7200 0 EET}
- {3510522000 10800 1 EEST}
- {3528666000 7200 0 EET}
- {3541971600 10800 1 EEST}
- {3560115600 7200 0 EET}
- {3573421200 10800 1 EEST}
- {3592170000 7200 0 EET}
- {3604870800 10800 1 EEST}
- {3623619600 7200 0 EET}
- {3636320400 10800 1 EEST}
- {3655069200 7200 0 EET}
- {3668374800 10800 1 EEST}
- {3686518800 7200 0 EET}
- {3699824400 10800 1 EEST}
- {3717968400 7200 0 EET}
- {3731274000 10800 1 EEST}
- {3750022800 7200 0 EET}
- {3762723600 10800 1 EEST}
- {3781472400 7200 0 EET}
- {3794173200 10800 1 EEST}
- {3812922000 7200 0 EET}
- {3825622800 10800 1 EEST}
- {3844371600 7200 0 EET}
- {3857677200 10800 1 EEST}
- {3875821200 7200 0 EET}
- {3889126800 10800 1 EEST}
- {3907270800 7200 0 EET}
- {3920576400 10800 1 EEST}
- {3939325200 7200 0 EET}
- {3952026000 10800 1 EEST}
- {3970774800 7200 0 EET}
- {3983475600 10800 1 EEST}
- {4002224400 7200 0 EET}
- {4015530000 10800 1 EEST}
- {4033674000 7200 0 EET}
- {4046979600 10800 1 EEST}
- {4065123600 7200 0 EET}
- {4078429200 10800 1 EEST}
- {4096573200 7200 0 EET}
+ {1473199200 10800 0 +03}
}
diff --git a/library/tzdata/Europe/Kaliningrad b/library/tzdata/Europe/Kaliningrad
index 85add82..e1713ae 100644
--- a/library/tzdata/Europe/Kaliningrad
+++ b/library/tzdata/Europe/Kaliningrad
@@ -80,6 +80,6 @@ set TZData(:Europe/Kaliningrad) {
{1256428800 7200 0 EET}
{1269734400 10800 1 EEST}
{1288483200 7200 0 EET}
- {1301184000 10800 0 FET}
+ {1301184000 10800 0 +03}
{1414278000 7200 0 EET}
}
diff --git a/library/tzdata/Europe/Kirov b/library/tzdata/Europe/Kirov
index 82ffc9e..8762d22 100644
--- a/library/tzdata/Europe/Kirov
+++ b/library/tzdata/Europe/Kirov
@@ -2,7 +2,7 @@
set TZData(:Europe/Kirov) {
{-9223372036854775808 11928 0 LMT}
- {-1593825528 10800 0 +03}
+ {-1593820800 10800 0 +03}
{-1247540400 14400 0 +05}
{354916800 18000 1 +05}
{370724400 14400 0 +04}
diff --git a/library/tzdata/Europe/Madrid b/library/tzdata/Europe/Madrid
index 50de14f..f4dd484 100644
--- a/library/tzdata/Europe/Madrid
+++ b/library/tzdata/Europe/Madrid
@@ -2,52 +2,50 @@
set TZData(:Europe/Madrid) {
{-9223372036854775808 -884 0 LMT}
- {-2177451916 0 0 WET}
- {-1661734800 3600 1 WEST}
- {-1648429200 0 0 WET}
+ {-2177452800 0 0 WET}
{-1631926800 3600 1 WEST}
- {-1616893200 0 0 WET}
- {-1601254800 3600 1 WEST}
- {-1585357200 0 0 WET}
+ {-1616889600 0 0 WET}
+ {-1601168400 3600 1 WEST}
+ {-1585353600 0 0 WET}
{-1442451600 3600 1 WEST}
- {-1427677200 0 0 WET}
+ {-1427673600 0 0 WET}
{-1379293200 3600 1 WEST}
- {-1364778000 0 0 WET}
+ {-1364774400 0 0 WET}
{-1348448400 3600 1 WEST}
- {-1333328400 0 0 WET}
- {-1316394000 3600 1 WEST}
- {-1301274000 0 0 WET}
+ {-1333324800 0 0 WET}
+ {-1316390400 3600 1 WEST}
+ {-1301270400 0 0 WET}
{-1284339600 3600 1 WEST}
- {-1269824400 0 0 WET}
- {-1029114000 3600 1 WEST}
- {-1017622800 0 0 WET}
- {-1002848400 3600 1 WEST}
- {-986173200 0 0 WET}
- {-969238800 3600 1 WEST}
- {-954118800 0 0 WET}
- {-940208400 3600 1 WEST}
- {-873079200 7200 1 WEMT}
- {-862538400 3600 1 WEST}
- {-842839200 7200 1 WEMT}
- {-828237600 3600 1 WEST}
- {-811389600 7200 1 WEMT}
- {-796010400 3600 1 WEST}
- {-779940000 7200 1 WEMT}
- {-765421200 3600 1 WEST}
- {-748490400 7200 1 WEMT}
- {-733881600 3600 0 CET}
+ {-1269820800 0 0 WET}
+ {-1026954000 3600 1 WEST}
+ {-1017619200 0 0 WET}
+ {-1001898000 3600 1 WEST}
+ {-999482400 7200 1 WEMT}
+ {-986090400 3600 1 WEST}
+ {-954115200 0 0 WET}
+ {-940208400 3600 0 CET}
+ {-873079200 7200 1 CEST}
+ {-862621200 3600 0 CET}
+ {-842839200 7200 1 CEST}
+ {-828320400 3600 0 CET}
+ {-811389600 7200 1 CEST}
+ {-796870800 3600 0 CET}
+ {-779940000 7200 1 CEST}
+ {-765421200 3600 0 CET}
+ {-748490400 7200 1 CEST}
+ {-733971600 3600 0 CET}
{-652327200 7200 1 CEST}
- {-639190800 3600 0 CET}
+ {-639018000 3600 0 CET}
{135122400 7200 1 CEST}
{150246000 3600 0 CET}
- {167176800 7200 1 CEST}
+ {166572000 7200 1 CEST}
{181695600 3600 0 CET}
{196812000 7200 1 CEST}
{212540400 3600 0 CET}
{228866400 7200 1 CEST}
{243990000 3600 0 CET}
- {260402400 7200 1 CEST}
- {276044400 3600 0 CET}
+ {260326800 7200 1 CEST}
+ {276051600 3600 0 CET}
{283993200 3600 0 CET}
{291776400 7200 1 CEST}
{307501200 3600 0 CET}
diff --git a/library/tzdata/Europe/Malta b/library/tzdata/Europe/Malta
index b84f68e..0ebe2f6 100644
--- a/library/tzdata/Europe/Malta
+++ b/library/tzdata/Europe/Malta
@@ -3,23 +3,23 @@
set TZData(:Europe/Malta) {
{-9223372036854775808 3484 0 LMT}
{-2403478684 3600 0 CET}
- {-1690851600 7200 1 CEST}
- {-1680483600 3600 0 CET}
+ {-1690765200 7200 1 CEST}
+ {-1680487200 3600 0 CET}
{-1664758800 7200 1 CEST}
- {-1649034000 3600 0 CET}
+ {-1648951200 3600 0 CET}
{-1635123600 7200 1 CEST}
- {-1616979600 3600 0 CET}
+ {-1616896800 3600 0 CET}
{-1604278800 7200 1 CEST}
- {-1585530000 3600 0 CET}
+ {-1585533600 3600 0 CET}
{-1571014800 7200 1 CEST}
- {-1555290000 3600 0 CET}
+ {-1555293600 3600 0 CET}
{-932432400 7200 1 CEST}
{-857257200 3600 0 CET}
{-844556400 7200 1 CEST}
{-828226800 3600 0 CET}
- {-812502000 7200 1 CEST}
- {-796777200 3600 0 CET}
- {-781052400 7200 0 CEST}
+ {-812588400 7200 1 CEST}
+ {-798073200 3600 0 CET}
+ {-781052400 7200 1 CEST}
{-766717200 3600 0 CET}
{-750898800 7200 1 CEST}
{-733359600 3600 0 CET}
@@ -30,17 +30,17 @@ set TZData(:Europe/Malta) {
{-114051600 7200 1 CEST}
{-103168800 3600 0 CET}
{-81997200 7200 1 CEST}
- {-71719200 3600 0 CET}
+ {-71715600 3600 0 CET}
{-50547600 7200 1 CEST}
- {-40269600 3600 0 CET}
+ {-40266000 3600 0 CET}
{-18493200 7200 1 CEST}
- {-8215200 3600 0 CET}
+ {-8211600 3600 0 CET}
{12956400 7200 1 CEST}
- {23234400 3600 0 CET}
+ {23238000 3600 0 CET}
{43801200 7200 1 CEST}
{54687600 3600 0 CET}
{75855600 7200 1 CEST}
- {86738400 3600 0 CET}
+ {86742000 3600 0 CET}
{102380400 7200 0 CEST}
{118105200 3600 0 CET}
{135730800 7200 1 CEST}
diff --git a/library/tzdata/Europe/Minsk b/library/tzdata/Europe/Minsk
index 2857e5b..7a6232e 100644
--- a/library/tzdata/Europe/Minsk
+++ b/library/tzdata/Europe/Minsk
@@ -71,6 +71,5 @@ set TZData(:Europe/Minsk) {
{1256428800 7200 0 EET}
{1269734400 10800 1 EEST}
{1288483200 7200 0 EET}
- {1301184000 10800 0 FET}
- {1414274400 10800 0 MSK}
+ {1301184000 10800 0 +03}
}
diff --git a/library/tzdata/Europe/Moscow b/library/tzdata/Europe/Moscow
index 1e2f45b..9b513b1 100644
--- a/library/tzdata/Europe/Moscow
+++ b/library/tzdata/Europe/Moscow
@@ -9,10 +9,10 @@ set TZData(:Europe/Moscow) {
{-1627965079 16279 1 MDST}
{-1618716679 12679 1 MST}
{-1596429079 16279 1 MDST}
- {-1593822679 14400 0 MSD}
+ {-1593820800 14400 0 MSD}
{-1589860800 10800 0 MSK}
{-1542427200 14400 1 MSD}
- {-1539493200 18000 1 MSM}
+ {-1539493200 18000 1 +05}
{-1525323600 14400 1 MSD}
{-1491188400 7200 0 EET}
{-1247536800 10800 0 MSD}
diff --git a/library/tzdata/Europe/Rome b/library/tzdata/Europe/Rome
index 64948b8..f53340c 100644
--- a/library/tzdata/Europe/Rome
+++ b/library/tzdata/Europe/Rome
@@ -3,24 +3,25 @@
set TZData(:Europe/Rome) {
{-9223372036854775808 2996 0 LMT}
{-3259097396 2996 0 RMT}
- {-2403564596 3600 0 CET}
- {-1690851600 7200 1 CEST}
- {-1680483600 3600 0 CET}
+ {-2403565200 3600 0 CET}
+ {-1690765200 7200 1 CEST}
+ {-1680487200 3600 0 CET}
{-1664758800 7200 1 CEST}
- {-1649034000 3600 0 CET}
+ {-1648951200 3600 0 CET}
{-1635123600 7200 1 CEST}
- {-1616979600 3600 0 CET}
+ {-1616896800 3600 0 CET}
{-1604278800 7200 1 CEST}
- {-1585530000 3600 0 CET}
+ {-1585533600 3600 0 CET}
{-1571014800 7200 1 CEST}
- {-1555290000 3600 0 CET}
+ {-1555293600 3600 0 CET}
{-932432400 7200 1 CEST}
{-857257200 3600 0 CET}
{-844556400 7200 1 CEST}
+ {-830307600 7200 0 CEST}
{-828226800 3600 0 CET}
{-812502000 7200 1 CEST}
- {-804819600 3600 0 CET}
- {-798080400 3600 0 CET}
+ {-807152400 7200 0 CEST}
+ {-798073200 3600 0 CET}
{-781052400 7200 1 CEST}
{-766717200 3600 0 CET}
{-750898800 7200 1 CEST}
@@ -32,21 +33,21 @@ set TZData(:Europe/Rome) {
{-114051600 7200 1 CEST}
{-103168800 3600 0 CET}
{-81997200 7200 1 CEST}
- {-71719200 3600 0 CET}
+ {-71715600 3600 0 CET}
{-50547600 7200 1 CEST}
- {-40269600 3600 0 CET}
+ {-40266000 3600 0 CET}
{-18493200 7200 1 CEST}
- {-8215200 3600 0 CET}
+ {-8211600 3600 0 CET}
{12956400 7200 1 CEST}
- {23234400 3600 0 CET}
+ {23238000 3600 0 CET}
{43801200 7200 1 CEST}
{54687600 3600 0 CET}
{75855600 7200 1 CEST}
- {86738400 3600 0 CET}
+ {86742000 3600 0 CET}
{107910000 7200 1 CEST}
- {118188000 3600 0 CET}
+ {118191600 3600 0 CET}
{138754800 7200 1 CEST}
- {149637600 3600 0 CET}
+ {149641200 3600 0 CET}
{170809200 7200 1 CEST}
{181090800 3600 0 CET}
{202258800 7200 1 CEST}
diff --git a/library/tzdata/Europe/Samara b/library/tzdata/Europe/Samara
index 08203c0..8f21c57 100644
--- a/library/tzdata/Europe/Samara
+++ b/library/tzdata/Europe/Samara
@@ -2,72 +2,72 @@
set TZData(:Europe/Samara) {
{-9223372036854775808 12020 0 LMT}
- {-1593825620 10800 0 SAMT}
- {-1247540400 14400 0 SAMT}
- {-1102305600 14400 0 KUYMMTT}
- {354916800 18000 1 KUYST}
- {370724400 14400 0 KUYT}
- {386452800 18000 1 KUYST}
- {402260400 14400 0 KUYT}
- {417988800 18000 1 KUYST}
- {433796400 14400 0 KUYT}
- {449611200 18000 1 KUYST}
- {465343200 14400 0 KUYT}
- {481068000 18000 1 KUYST}
- {496792800 14400 0 KUYT}
- {512517600 18000 1 KUYST}
- {528242400 14400 0 KUYT}
- {543967200 18000 1 KUYST}
- {559692000 14400 0 KUYT}
- {575416800 18000 1 KUYST}
- {591141600 14400 0 KUYT}
- {606866400 10800 0 MSD}
- {606870000 14400 1 MSD}
- {622594800 10800 0 MSK}
- {638319600 14400 1 MSD}
- {654649200 10800 0 MSK}
- {670374000 7200 0 EEMMTT}
- {670377600 10800 1 EEST}
- {686102400 10800 0 SAMT}
- {687916800 14400 0 SAMT}
- {701820000 18000 1 SAMST}
- {717544800 14400 0 SAMT}
- {733269600 18000 1 SAMST}
- {748994400 14400 0 SAMT}
- {764719200 18000 1 SAMST}
- {780444000 14400 0 SAMT}
- {796168800 18000 1 SAMST}
- {811893600 14400 0 SAMT}
- {828223200 18000 1 SAMST}
- {846367200 14400 0 SAMT}
- {859672800 18000 1 SAMST}
- {877816800 14400 0 SAMT}
- {891122400 18000 1 SAMST}
- {909266400 14400 0 SAMT}
- {922572000 18000 1 SAMST}
- {941320800 14400 0 SAMT}
- {954021600 18000 1 SAMST}
- {972770400 14400 0 SAMT}
- {985471200 18000 1 SAMST}
- {1004220000 14400 0 SAMT}
- {1017525600 18000 1 SAMST}
- {1035669600 14400 0 SAMT}
- {1048975200 18000 1 SAMST}
- {1067119200 14400 0 SAMT}
- {1080424800 18000 1 SAMST}
- {1099173600 14400 0 SAMT}
- {1111874400 18000 1 SAMST}
- {1130623200 14400 0 SAMT}
- {1143324000 18000 1 SAMST}
- {1162072800 14400 0 SAMT}
- {1174773600 18000 1 SAMST}
- {1193522400 14400 0 SAMT}
- {1206828000 18000 1 SAMST}
- {1224972000 14400 0 SAMT}
- {1238277600 18000 1 SAMST}
- {1256421600 14400 0 SAMT}
- {1269727200 10800 0 SAMMMTT}
- {1269730800 14400 1 SAMST}
- {1288479600 10800 0 SAMT}
- {1301180400 14400 0 SAMT}
+ {-1593820800 10800 0 +03}
+ {-1247540400 14400 0 +04}
+ {-1102305600 14400 0 +05}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 18000 1 +05}
+ {591141600 14400 0 +04}
+ {606866400 10800 0 +04}
+ {606870000 14400 1 +04}
+ {622594800 10800 0 +03}
+ {638319600 14400 1 +04}
+ {654649200 10800 0 +03}
+ {670374000 7200 0 +03}
+ {670377600 10800 1 +03}
+ {686102400 10800 0 +03}
+ {687916800 14400 0 +04}
+ {701820000 18000 1 +05}
+ {717544800 14400 0 +04}
+ {733269600 18000 1 +05}
+ {748994400 14400 0 +04}
+ {764719200 18000 1 +05}
+ {780444000 14400 0 +04}
+ {796168800 18000 1 +05}
+ {811893600 14400 0 +04}
+ {828223200 18000 1 +05}
+ {846367200 14400 0 +04}
+ {859672800 18000 1 +05}
+ {877816800 14400 0 +04}
+ {891122400 18000 1 +05}
+ {909266400 14400 0 +04}
+ {922572000 18000 1 +05}
+ {941320800 14400 0 +04}
+ {954021600 18000 1 +05}
+ {972770400 14400 0 +04}
+ {985471200 18000 1 +05}
+ {1004220000 14400 0 +04}
+ {1017525600 18000 1 +05}
+ {1035669600 14400 0 +04}
+ {1048975200 18000 1 +05}
+ {1067119200 14400 0 +04}
+ {1080424800 18000 1 +05}
+ {1099173600 14400 0 +04}
+ {1111874400 18000 1 +05}
+ {1130623200 14400 0 +04}
+ {1143324000 18000 1 +05}
+ {1162072800 14400 0 +04}
+ {1174773600 18000 1 +05}
+ {1193522400 14400 0 +04}
+ {1206828000 18000 1 +05}
+ {1224972000 14400 0 +04}
+ {1238277600 18000 1 +05}
+ {1256421600 14400 0 +04}
+ {1269727200 10800 0 +04}
+ {1269730800 14400 1 +04}
+ {1288479600 10800 0 +03}
+ {1301180400 14400 0 +04}
}
diff --git a/library/tzdata/Europe/Saratov b/library/tzdata/Europe/Saratov
new file mode 100644
index 0000000..d89a217
--- /dev/null
+++ b/library/tzdata/Europe/Saratov
@@ -0,0 +1,71 @@
+# created by tools/tclZIC.tcl - do not edit
+
+set TZData(:Europe/Saratov) {
+ {-9223372036854775808 11058 0 LMT}
+ {-1593820800 10800 0 +03}
+ {-1247540400 14400 0 +05}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 10800 0 +04}
+ {575420400 14400 1 +04}
+ {591145200 10800 0 +03}
+ {606870000 14400 1 +04}
+ {622594800 10800 0 +03}
+ {638319600 14400 1 +04}
+ {654649200 10800 0 +03}
+ {670374000 14400 0 +04}
+ {701820000 10800 0 +04}
+ {701823600 14400 1 +04}
+ {717548400 10800 0 +03}
+ {733273200 14400 1 +04}
+ {748998000 10800 0 +03}
+ {764722800 14400 1 +04}
+ {780447600 10800 0 +03}
+ {796172400 14400 1 +04}
+ {811897200 10800 0 +03}
+ {828226800 14400 1 +04}
+ {846370800 10800 0 +03}
+ {859676400 14400 1 +04}
+ {877820400 10800 0 +03}
+ {891126000 14400 1 +04}
+ {909270000 10800 0 +03}
+ {922575600 14400 1 +04}
+ {941324400 10800 0 +03}
+ {954025200 14400 1 +04}
+ {972774000 10800 0 +03}
+ {985474800 14400 1 +04}
+ {1004223600 10800 0 +03}
+ {1017529200 14400 1 +04}
+ {1035673200 10800 0 +03}
+ {1048978800 14400 1 +04}
+ {1067122800 10800 0 +03}
+ {1080428400 14400 1 +04}
+ {1099177200 10800 0 +03}
+ {1111878000 14400 1 +04}
+ {1130626800 10800 0 +03}
+ {1143327600 14400 1 +04}
+ {1162076400 10800 0 +03}
+ {1174777200 14400 1 +04}
+ {1193526000 10800 0 +03}
+ {1206831600 14400 1 +04}
+ {1224975600 10800 0 +03}
+ {1238281200 14400 1 +04}
+ {1256425200 10800 0 +03}
+ {1269730800 14400 1 +04}
+ {1288479600 10800 0 +03}
+ {1301180400 14400 0 +04}
+ {1414274400 10800 0 +03}
+ {1480806000 14400 0 +04}
+}
diff --git a/library/tzdata/Europe/Ulyanovsk b/library/tzdata/Europe/Ulyanovsk
index d5c33b5..8fb3f9e 100644
--- a/library/tzdata/Europe/Ulyanovsk
+++ b/library/tzdata/Europe/Ulyanovsk
@@ -2,7 +2,7 @@
set TZData(:Europe/Ulyanovsk) {
{-9223372036854775808 11616 0 LMT}
- {-1593825216 10800 0 +03}
+ {-1593820800 10800 0 +03}
{-1247540400 14400 0 +05}
{354916800 18000 1 +05}
{370724400 14400 0 +04}
diff --git a/library/tzdata/Europe/Volgograd b/library/tzdata/Europe/Volgograd
index 83996b0..05e1044 100644
--- a/library/tzdata/Europe/Volgograd
+++ b/library/tzdata/Europe/Volgograd
@@ -2,71 +2,70 @@
set TZData(:Europe/Volgograd) {
{-9223372036854775808 10660 0 LMT}
- {-1577761060 10800 0 TSAT}
- {-1411873200 10800 0 STAT}
- {-1247540400 14400 0 STAT}
- {-256881600 14400 0 VOLMMTT}
- {354916800 18000 1 VOLST}
- {370724400 14400 0 VOLT}
- {386452800 18000 1 VOLST}
- {402260400 14400 0 VOLT}
- {417988800 18000 1 VOLST}
- {433796400 14400 0 VOLT}
- {449611200 18000 1 VOLST}
- {465343200 14400 0 VOLT}
- {481068000 18000 1 VOLST}
- {496792800 14400 0 VOLT}
- {512517600 18000 1 VOLST}
- {528242400 14400 0 VOLT}
- {543967200 18000 1 VOLST}
- {559692000 14400 0 VOLT}
- {575416800 10800 0 VOLMMTT}
- {575420400 14400 1 VOLST}
- {591145200 10800 0 VOLT}
- {606870000 14400 1 VOLST}
- {622594800 10800 0 VOLT}
- {638319600 14400 1 VOLST}
- {654649200 10800 0 VOLT}
- {670374000 14400 0 VOLT}
- {701820000 10800 0 MSD}
- {701823600 14400 1 MSD}
- {717548400 10800 0 MSK}
- {733273200 14400 1 MSD}
- {748998000 10800 0 MSK}
- {764722800 14400 1 MSD}
- {780447600 10800 0 MSK}
- {796172400 14400 1 MSD}
- {811897200 10800 0 MSK}
- {828226800 14400 1 MSD}
- {846370800 10800 0 MSK}
- {859676400 14400 1 MSD}
- {877820400 10800 0 MSK}
- {891126000 14400 1 MSD}
- {909270000 10800 0 MSK}
- {922575600 14400 1 MSD}
- {941324400 10800 0 MSK}
- {954025200 14400 1 MSD}
- {972774000 10800 0 MSK}
- {985474800 14400 1 MSD}
- {1004223600 10800 0 MSK}
- {1017529200 14400 1 MSD}
- {1035673200 10800 0 MSK}
- {1048978800 14400 1 MSD}
- {1067122800 10800 0 MSK}
- {1080428400 14400 1 MSD}
- {1099177200 10800 0 MSK}
- {1111878000 14400 1 MSD}
- {1130626800 10800 0 MSK}
- {1143327600 14400 1 MSD}
- {1162076400 10800 0 MSK}
- {1174777200 14400 1 MSD}
- {1193526000 10800 0 MSK}
- {1206831600 14400 1 MSD}
- {1224975600 10800 0 MSK}
- {1238281200 14400 1 MSD}
- {1256425200 10800 0 MSK}
- {1269730800 14400 1 MSD}
- {1288479600 10800 0 MSK}
- {1301180400 14400 0 MSK}
- {1414274400 10800 0 MSK}
+ {-1577761060 10800 0 +03}
+ {-1247540400 14400 0 +04}
+ {-256881600 14400 0 +05}
+ {354916800 18000 1 +05}
+ {370724400 14400 0 +04}
+ {386452800 18000 1 +05}
+ {402260400 14400 0 +04}
+ {417988800 18000 1 +05}
+ {433796400 14400 0 +04}
+ {449611200 18000 1 +05}
+ {465343200 14400 0 +04}
+ {481068000 18000 1 +05}
+ {496792800 14400 0 +04}
+ {512517600 18000 1 +05}
+ {528242400 14400 0 +04}
+ {543967200 18000 1 +05}
+ {559692000 14400 0 +04}
+ {575416800 10800 0 +04}
+ {575420400 14400 1 +04}
+ {591145200 10800 0 +03}
+ {606870000 14400 1 +04}
+ {622594800 10800 0 +03}
+ {638319600 14400 1 +04}
+ {654649200 10800 0 +03}
+ {670374000 14400 0 +04}
+ {701820000 10800 0 +04}
+ {701823600 14400 1 +04}
+ {717548400 10800 0 +03}
+ {733273200 14400 1 +04}
+ {748998000 10800 0 +03}
+ {764722800 14400 1 +04}
+ {780447600 10800 0 +03}
+ {796172400 14400 1 +04}
+ {811897200 10800 0 +03}
+ {828226800 14400 1 +04}
+ {846370800 10800 0 +03}
+ {859676400 14400 1 +04}
+ {877820400 10800 0 +03}
+ {891126000 14400 1 +04}
+ {909270000 10800 0 +03}
+ {922575600 14400 1 +04}
+ {941324400 10800 0 +03}
+ {954025200 14400 1 +04}
+ {972774000 10800 0 +03}
+ {985474800 14400 1 +04}
+ {1004223600 10800 0 +03}
+ {1017529200 14400 1 +04}
+ {1035673200 10800 0 +03}
+ {1048978800 14400 1 +04}
+ {1067122800 10800 0 +03}
+ {1080428400 14400 1 +04}
+ {1099177200 10800 0 +03}
+ {1111878000 14400 1 +04}
+ {1130626800 10800 0 +03}
+ {1143327600 14400 1 +04}
+ {1162076400 10800 0 +03}
+ {1174777200 14400 1 +04}
+ {1193526000 10800 0 +03}
+ {1206831600 14400 1 +04}
+ {1224975600 10800 0 +03}
+ {1238281200 14400 1 +04}
+ {1256425200 10800 0 +03}
+ {1269730800 14400 1 +04}
+ {1288479600 10800 0 +03}
+ {1301180400 14400 0 +04}
+ {1414274400 10800 0 +03}
}
diff --git a/library/tzdata/Europe/Zaporozhye b/library/tzdata/Europe/Zaporozhye
index 01418cd..478a61c 100644
--- a/library/tzdata/Europe/Zaporozhye
+++ b/library/tzdata/Europe/Zaporozhye
@@ -2,7 +2,7 @@
set TZData(:Europe/Zaporozhye) {
{-9223372036854775808 8440 0 LMT}
- {-2840149240 8400 0 CUT}
+ {-2840149240 8400 0 +0220}
{-1441160400 7200 0 EET}
{-1247536800 10800 0 MSK}
{-894769200 3600 0 CET}
diff --git a/library/tzdata/Indian/Chagos b/library/tzdata/Indian/Chagos
index a5cec61..23ea790 100644
--- a/library/tzdata/Indian/Chagos
+++ b/library/tzdata/Indian/Chagos
@@ -2,6 +2,6 @@
set TZData(:Indian/Chagos) {
{-9223372036854775808 17380 0 LMT}
- {-1988167780 18000 0 IOT}
- {820436400 21600 0 IOT}
+ {-1988167780 18000 0 +05}
+ {820436400 21600 0 +06}
}
diff --git a/library/tzdata/Indian/Christmas b/library/tzdata/Indian/Christmas
index c36e973..76f8cbe 100644
--- a/library/tzdata/Indian/Christmas
+++ b/library/tzdata/Indian/Christmas
@@ -2,5 +2,5 @@
set TZData(:Indian/Christmas) {
{-9223372036854775808 25372 0 LMT}
- {-2364102172 25200 0 CXT}
+ {-2364102172 25200 0 +07}
}
diff --git a/library/tzdata/Indian/Cocos b/library/tzdata/Indian/Cocos
index a63ae68..833eb20 100644
--- a/library/tzdata/Indian/Cocos
+++ b/library/tzdata/Indian/Cocos
@@ -2,5 +2,5 @@
set TZData(:Indian/Cocos) {
{-9223372036854775808 23260 0 LMT}
- {-2209012060 23400 0 CCT}
+ {-2209012060 23400 0 +0630}
}
diff --git a/library/tzdata/Indian/Kerguelen b/library/tzdata/Indian/Kerguelen
index 8820010..93f2d94 100644
--- a/library/tzdata/Indian/Kerguelen
+++ b/library/tzdata/Indian/Kerguelen
@@ -2,5 +2,5 @@
set TZData(:Indian/Kerguelen) {
{-9223372036854775808 0 0 -00}
- {-631152000 18000 0 TFT}
+ {-631152000 18000 0 +05}
}
diff --git a/library/tzdata/Indian/Mahe b/library/tzdata/Indian/Mahe
index c88a24b..3dd5b40 100644
--- a/library/tzdata/Indian/Mahe
+++ b/library/tzdata/Indian/Mahe
@@ -2,5 +2,5 @@
set TZData(:Indian/Mahe) {
{-9223372036854775808 13308 0 LMT}
- {-2006653308 14400 0 SCT}
+ {-2006653308 14400 0 +04}
}
diff --git a/library/tzdata/Indian/Maldives b/library/tzdata/Indian/Maldives
index 2c2c739..b23bf2b 100644
--- a/library/tzdata/Indian/Maldives
+++ b/library/tzdata/Indian/Maldives
@@ -3,5 +3,5 @@
set TZData(:Indian/Maldives) {
{-9223372036854775808 17640 0 LMT}
{-2840158440 17640 0 MMT}
- {-315636840 18000 0 MVT}
+ {-315636840 18000 0 +05}
}
diff --git a/library/tzdata/Indian/Mauritius b/library/tzdata/Indian/Mauritius
index a9c07eb..2a7a0b1 100644
--- a/library/tzdata/Indian/Mauritius
+++ b/library/tzdata/Indian/Mauritius
@@ -2,9 +2,9 @@
set TZData(:Indian/Mauritius) {
{-9223372036854775808 13800 0 LMT}
- {-1988164200 14400 0 MUT}
- {403041600 18000 1 MUST}
- {417034800 14400 0 MUT}
- {1224972000 18000 1 MUST}
- {1238274000 14400 0 MUT}
+ {-1988164200 14400 0 +04}
+ {403041600 18000 1 +05}
+ {417034800 14400 0 +04}
+ {1224972000 18000 1 +05}
+ {1238274000 14400 0 +04}
}
diff --git a/library/tzdata/Indian/Reunion b/library/tzdata/Indian/Reunion
index de2dd60..aa78dec 100644
--- a/library/tzdata/Indian/Reunion
+++ b/library/tzdata/Indian/Reunion
@@ -2,5 +2,5 @@
set TZData(:Indian/Reunion) {
{-9223372036854775808 13312 0 LMT}
- {-1848886912 14400 0 RET}
+ {-1848886912 14400 0 +04}
}
diff --git a/library/tzdata/Pacific/Apia b/library/tzdata/Pacific/Apia
index 21d6669..feef374 100644
--- a/library/tzdata/Pacific/Apia
+++ b/library/tzdata/Pacific/Apia
@@ -3,186 +3,186 @@
set TZData(:Pacific/Apia) {
{-9223372036854775808 45184 0 LMT}
{-2855737984 -41216 0 LMT}
- {-1861878784 -41400 0 WSST}
- {-631110600 -39600 0 SST}
- {1285498800 -36000 1 SDT}
- {1301752800 -39600 0 SST}
- {1316872800 -36000 1 SDT}
- {1325239200 50400 0 WSDT}
- {1333202400 46800 0 WSST}
- {1348927200 50400 1 WSDT}
- {1365256800 46800 0 WSST}
- {1380376800 50400 1 WSDT}
- {1396706400 46800 0 WSST}
- {1411826400 50400 1 WSDT}
- {1428156000 46800 0 WSST}
- {1443276000 50400 1 WSDT}
- {1459605600 46800 0 WSST}
- {1474725600 50400 1 WSDT}
- {1491055200 46800 0 WSST}
- {1506175200 50400 1 WSDT}
- {1522504800 46800 0 WSST}
- {1538229600 50400 1 WSDT}
- {1554559200 46800 0 WSST}
- {1569679200 50400 1 WSDT}
- {1586008800 46800 0 WSST}
- {1601128800 50400 1 WSDT}
- {1617458400 46800 0 WSST}
- {1632578400 50400 1 WSDT}
- {1648908000 46800 0 WSST}
- {1664028000 50400 1 WSDT}
- {1680357600 46800 0 WSST}
- {1695477600 50400 1 WSDT}
- {1712412000 46800 0 WSST}
- {1727532000 50400 1 WSDT}
- {1743861600 46800 0 WSST}
- {1758981600 50400 1 WSDT}
- {1775311200 46800 0 WSST}
- {1790431200 50400 1 WSDT}
- {1806760800 46800 0 WSST}
- {1821880800 50400 1 WSDT}
- {1838210400 46800 0 WSST}
- {1853330400 50400 1 WSDT}
- {1869660000 46800 0 WSST}
- {1885384800 50400 1 WSDT}
- {1901714400 46800 0 WSST}
- {1916834400 50400 1 WSDT}
- {1933164000 46800 0 WSST}
- {1948284000 50400 1 WSDT}
- {1964613600 46800 0 WSST}
- {1979733600 50400 1 WSDT}
- {1996063200 46800 0 WSST}
- {2011183200 50400 1 WSDT}
- {2027512800 46800 0 WSST}
- {2042632800 50400 1 WSDT}
- {2058962400 46800 0 WSST}
- {2074687200 50400 1 WSDT}
- {2091016800 46800 0 WSST}
- {2106136800 50400 1 WSDT}
- {2122466400 46800 0 WSST}
- {2137586400 50400 1 WSDT}
- {2153916000 46800 0 WSST}
- {2169036000 50400 1 WSDT}
- {2185365600 46800 0 WSST}
- {2200485600 50400 1 WSDT}
- {2216815200 46800 0 WSST}
- {2232540000 50400 1 WSDT}
- {2248869600 46800 0 WSST}
- {2263989600 50400 1 WSDT}
- {2280319200 46800 0 WSST}
- {2295439200 50400 1 WSDT}
- {2311768800 46800 0 WSST}
- {2326888800 50400 1 WSDT}
- {2343218400 46800 0 WSST}
- {2358338400 50400 1 WSDT}
- {2374668000 46800 0 WSST}
- {2389788000 50400 1 WSDT}
- {2406117600 46800 0 WSST}
- {2421842400 50400 1 WSDT}
- {2438172000 46800 0 WSST}
- {2453292000 50400 1 WSDT}
- {2469621600 46800 0 WSST}
- {2484741600 50400 1 WSDT}
- {2501071200 46800 0 WSST}
- {2516191200 50400 1 WSDT}
- {2532520800 46800 0 WSST}
- {2547640800 50400 1 WSDT}
- {2563970400 46800 0 WSST}
- {2579090400 50400 1 WSDT}
- {2596024800 46800 0 WSST}
- {2611144800 50400 1 WSDT}
- {2627474400 46800 0 WSST}
- {2642594400 50400 1 WSDT}
- {2658924000 46800 0 WSST}
- {2674044000 50400 1 WSDT}
- {2690373600 46800 0 WSST}
- {2705493600 50400 1 WSDT}
- {2721823200 46800 0 WSST}
- {2736943200 50400 1 WSDT}
- {2753272800 46800 0 WSST}
- {2768997600 50400 1 WSDT}
- {2785327200 46800 0 WSST}
- {2800447200 50400 1 WSDT}
- {2816776800 46800 0 WSST}
- {2831896800 50400 1 WSDT}
- {2848226400 46800 0 WSST}
- {2863346400 50400 1 WSDT}
- {2879676000 46800 0 WSST}
- {2894796000 50400 1 WSDT}
- {2911125600 46800 0 WSST}
- {2926245600 50400 1 WSDT}
- {2942575200 46800 0 WSST}
- {2958300000 50400 1 WSDT}
- {2974629600 46800 0 WSST}
- {2989749600 50400 1 WSDT}
- {3006079200 46800 0 WSST}
- {3021199200 50400 1 WSDT}
- {3037528800 46800 0 WSST}
- {3052648800 50400 1 WSDT}
- {3068978400 46800 0 WSST}
- {3084098400 50400 1 WSDT}
- {3100428000 46800 0 WSST}
- {3116152800 50400 1 WSDT}
- {3132482400 46800 0 WSST}
- {3147602400 50400 1 WSDT}
- {3163932000 46800 0 WSST}
- {3179052000 50400 1 WSDT}
- {3195381600 46800 0 WSST}
- {3210501600 50400 1 WSDT}
- {3226831200 46800 0 WSST}
- {3241951200 50400 1 WSDT}
- {3258280800 46800 0 WSST}
- {3273400800 50400 1 WSDT}
- {3289730400 46800 0 WSST}
- {3305455200 50400 1 WSDT}
- {3321784800 46800 0 WSST}
- {3336904800 50400 1 WSDT}
- {3353234400 46800 0 WSST}
- {3368354400 50400 1 WSDT}
- {3384684000 46800 0 WSST}
- {3399804000 50400 1 WSDT}
- {3416133600 46800 0 WSST}
- {3431253600 50400 1 WSDT}
- {3447583200 46800 0 WSST}
- {3462703200 50400 1 WSDT}
- {3479637600 46800 0 WSST}
- {3494757600 50400 1 WSDT}
- {3511087200 46800 0 WSST}
- {3526207200 50400 1 WSDT}
- {3542536800 46800 0 WSST}
- {3557656800 50400 1 WSDT}
- {3573986400 46800 0 WSST}
- {3589106400 50400 1 WSDT}
- {3605436000 46800 0 WSST}
- {3620556000 50400 1 WSDT}
- {3636885600 46800 0 WSST}
- {3652610400 50400 1 WSDT}
- {3668940000 46800 0 WSST}
- {3684060000 50400 1 WSDT}
- {3700389600 46800 0 WSST}
- {3715509600 50400 1 WSDT}
- {3731839200 46800 0 WSST}
- {3746959200 50400 1 WSDT}
- {3763288800 46800 0 WSST}
- {3778408800 50400 1 WSDT}
- {3794738400 46800 0 WSST}
- {3809858400 50400 1 WSDT}
- {3826188000 46800 0 WSST}
- {3841912800 50400 1 WSDT}
- {3858242400 46800 0 WSST}
- {3873362400 50400 1 WSDT}
- {3889692000 46800 0 WSST}
- {3904812000 50400 1 WSDT}
- {3921141600 46800 0 WSST}
- {3936261600 50400 1 WSDT}
- {3952591200 46800 0 WSST}
- {3967711200 50400 1 WSDT}
- {3984040800 46800 0 WSST}
- {3999765600 50400 1 WSDT}
- {4016095200 46800 0 WSST}
- {4031215200 50400 1 WSDT}
- {4047544800 46800 0 WSST}
- {4062664800 50400 1 WSDT}
- {4078994400 46800 0 WSST}
- {4094114400 50400 1 WSDT}
+ {-1861878784 -41400 0 -1130}
+ {-631110600 -39600 0 -10}
+ {1285498800 -36000 1 -10}
+ {1301752800 -39600 0 -10}
+ {1316872800 -36000 1 -10}
+ {1325239200 50400 0 +14}
+ {1333202400 46800 0 +14}
+ {1348927200 50400 1 +14}
+ {1365256800 46800 0 +14}
+ {1380376800 50400 1 +14}
+ {1396706400 46800 0 +14}
+ {1411826400 50400 1 +14}
+ {1428156000 46800 0 +14}
+ {1443276000 50400 1 +14}
+ {1459605600 46800 0 +14}
+ {1474725600 50400 1 +14}
+ {1491055200 46800 0 +14}
+ {1506175200 50400 1 +14}
+ {1522504800 46800 0 +14}
+ {1538229600 50400 1 +14}
+ {1554559200 46800 0 +14}
+ {1569679200 50400 1 +14}
+ {1586008800 46800 0 +14}
+ {1601128800 50400 1 +14}
+ {1617458400 46800 0 +14}
+ {1632578400 50400 1 +14}
+ {1648908000 46800 0 +14}
+ {1664028000 50400 1 +14}
+ {1680357600 46800 0 +14}
+ {1695477600 50400 1 +14}
+ {1712412000 46800 0 +14}
+ {1727532000 50400 1 +14}
+ {1743861600 46800 0 +14}
+ {1758981600 50400 1 +14}
+ {1775311200 46800 0 +14}
+ {1790431200 50400 1 +14}
+ {1806760800 46800 0 +14}
+ {1821880800 50400 1 +14}
+ {1838210400 46800 0 +14}
+ {1853330400 50400 1 +14}
+ {1869660000 46800 0 +14}
+ {1885384800 50400 1 +14}
+ {1901714400 46800 0 +14}
+ {1916834400 50400 1 +14}
+ {1933164000 46800 0 +14}
+ {1948284000 50400 1 +14}
+ {1964613600 46800 0 +14}
+ {1979733600 50400 1 +14}
+ {1996063200 46800 0 +14}
+ {2011183200 50400 1 +14}
+ {2027512800 46800 0 +14}
+ {2042632800 50400 1 +14}
+ {2058962400 46800 0 +14}
+ {2074687200 50400 1 +14}
+ {2091016800 46800 0 +14}
+ {2106136800 50400 1 +14}
+ {2122466400 46800 0 +14}
+ {2137586400 50400 1 +14}
+ {2153916000 46800 0 +14}
+ {2169036000 50400 1 +14}
+ {2185365600 46800 0 +14}
+ {2200485600 50400 1 +14}
+ {2216815200 46800 0 +14}
+ {2232540000 50400 1 +14}
+ {2248869600 46800 0 +14}
+ {2263989600 50400 1 +14}
+ {2280319200 46800 0 +14}
+ {2295439200 50400 1 +14}
+ {2311768800 46800 0 +14}
+ {2326888800 50400 1 +14}
+ {2343218400 46800 0 +14}
+ {2358338400 50400 1 +14}
+ {2374668000 46800 0 +14}
+ {2389788000 50400 1 +14}
+ {2406117600 46800 0 +14}
+ {2421842400 50400 1 +14}
+ {2438172000 46800 0 +14}
+ {2453292000 50400 1 +14}
+ {2469621600 46800 0 +14}
+ {2484741600 50400 1 +14}
+ {2501071200 46800 0 +14}
+ {2516191200 50400 1 +14}
+ {2532520800 46800 0 +14}
+ {2547640800 50400 1 +14}
+ {2563970400 46800 0 +14}
+ {2579090400 50400 1 +14}
+ {2596024800 46800 0 +14}
+ {2611144800 50400 1 +14}
+ {2627474400 46800 0 +14}
+ {2642594400 50400 1 +14}
+ {2658924000 46800 0 +14}
+ {2674044000 50400 1 +14}
+ {2690373600 46800 0 +14}
+ {2705493600 50400 1 +14}
+ {2721823200 46800 0 +14}
+ {2736943200 50400 1 +14}
+ {2753272800 46800 0 +14}
+ {2768997600 50400 1 +14}
+ {2785327200 46800 0 +14}
+ {2800447200 50400 1 +14}
+ {2816776800 46800 0 +14}
+ {2831896800 50400 1 +14}
+ {2848226400 46800 0 +14}
+ {2863346400 50400 1 +14}
+ {2879676000 46800 0 +14}
+ {2894796000 50400 1 +14}
+ {2911125600 46800 0 +14}
+ {2926245600 50400 1 +14}
+ {2942575200 46800 0 +14}
+ {2958300000 50400 1 +14}
+ {2974629600 46800 0 +14}
+ {2989749600 50400 1 +14}
+ {3006079200 46800 0 +14}
+ {3021199200 50400 1 +14}
+ {3037528800 46800 0 +14}
+ {3052648800 50400 1 +14}
+ {3068978400 46800 0 +14}
+ {3084098400 50400 1 +14}
+ {3100428000 46800 0 +14}
+ {3116152800 50400 1 +14}
+ {3132482400 46800 0 +14}
+ {3147602400 50400 1 +14}
+ {3163932000 46800 0 +14}
+ {3179052000 50400 1 +14}
+ {3195381600 46800 0 +14}
+ {3210501600 50400 1 +14}
+ {3226831200 46800 0 +14}
+ {3241951200 50400 1 +14}
+ {3258280800 46800 0 +14}
+ {3273400800 50400 1 +14}
+ {3289730400 46800 0 +14}
+ {3305455200 50400 1 +14}
+ {3321784800 46800 0 +14}
+ {3336904800 50400 1 +14}
+ {3353234400 46800 0 +14}
+ {3368354400 50400 1 +14}
+ {3384684000 46800 0 +14}
+ {3399804000 50400 1 +14}
+ {3416133600 46800 0 +14}
+ {3431253600 50400 1 +14}
+ {3447583200 46800 0 +14}
+ {3462703200 50400 1 +14}
+ {3479637600 46800 0 +14}
+ {3494757600 50400 1 +14}
+ {3511087200 46800 0 +14}
+ {3526207200 50400 1 +14}
+ {3542536800 46800 0 +14}
+ {3557656800 50400 1 +14}
+ {3573986400 46800 0 +14}
+ {3589106400 50400 1 +14}
+ {3605436000 46800 0 +14}
+ {3620556000 50400 1 +14}
+ {3636885600 46800 0 +14}
+ {3652610400 50400 1 +14}
+ {3668940000 46800 0 +14}
+ {3684060000 50400 1 +14}
+ {3700389600 46800 0 +14}
+ {3715509600 50400 1 +14}
+ {3731839200 46800 0 +14}
+ {3746959200 50400 1 +14}
+ {3763288800 46800 0 +14}
+ {3778408800 50400 1 +14}
+ {3794738400 46800 0 +14}
+ {3809858400 50400 1 +14}
+ {3826188000 46800 0 +14}
+ {3841912800 50400 1 +14}
+ {3858242400 46800 0 +14}
+ {3873362400 50400 1 +14}
+ {3889692000 46800 0 +14}
+ {3904812000 50400 1 +14}
+ {3921141600 46800 0 +14}
+ {3936261600 50400 1 +14}
+ {3952591200 46800 0 +14}
+ {3967711200 50400 1 +14}
+ {3984040800 46800 0 +14}
+ {3999765600 50400 1 +14}
+ {4016095200 46800 0 +14}
+ {4031215200 50400 1 +14}
+ {4047544800 46800 0 +14}
+ {4062664800 50400 1 +14}
+ {4078994400 46800 0 +14}
+ {4094114400 50400 1 +14}
}
diff --git a/library/tzdata/Pacific/Bougainville b/library/tzdata/Pacific/Bougainville
index 06996f9..3c00b29 100644
--- a/library/tzdata/Pacific/Bougainville
+++ b/library/tzdata/Pacific/Bougainville
@@ -3,8 +3,8 @@
set TZData(:Pacific/Bougainville) {
{-9223372036854775808 37336 0 LMT}
{-2840178136 35312 0 PMMT}
- {-2366790512 36000 0 PGT}
- {-868010400 32400 0 JST}
- {-768906000 36000 0 PGT}
- {1419696000 39600 0 BST}
+ {-2366790512 36000 0 +10}
+ {-868010400 32400 0 +09}
+ {-768906000 36000 0 +10}
+ {1419696000 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Chatham b/library/tzdata/Pacific/Chatham
index 94a5512..5d39879 100644
--- a/library/tzdata/Pacific/Chatham
+++ b/library/tzdata/Pacific/Chatham
@@ -2,257 +2,257 @@
set TZData(:Pacific/Chatham) {
{-9223372036854775808 44028 0 LMT}
- {-3192437628 44100 0 CHAST}
- {-757426500 45900 0 CHAST}
- {152632800 49500 1 CHADT}
- {162309600 45900 0 CHAST}
- {183477600 49500 1 CHADT}
- {194968800 45900 0 CHAST}
- {215532000 49500 1 CHADT}
- {226418400 45900 0 CHAST}
- {246981600 49500 1 CHADT}
- {257868000 45900 0 CHAST}
- {278431200 49500 1 CHADT}
- {289317600 45900 0 CHAST}
- {309880800 49500 1 CHADT}
- {320767200 45900 0 CHAST}
- {341330400 49500 1 CHADT}
- {352216800 45900 0 CHAST}
- {372780000 49500 1 CHADT}
- {384271200 45900 0 CHAST}
- {404834400 49500 1 CHADT}
- {415720800 45900 0 CHAST}
- {436284000 49500 1 CHADT}
- {447170400 45900 0 CHAST}
- {467733600 49500 1 CHADT}
- {478620000 45900 0 CHAST}
- {499183200 49500 1 CHADT}
- {510069600 45900 0 CHAST}
- {530632800 49500 1 CHADT}
- {541519200 45900 0 CHAST}
- {562082400 49500 1 CHADT}
- {573573600 45900 0 CHAST}
- {594136800 49500 1 CHADT}
- {605023200 45900 0 CHAST}
- {623772000 49500 1 CHADT}
- {637682400 45900 0 CHAST}
- {655221600 49500 1 CHADT}
- {669132000 45900 0 CHAST}
- {686671200 49500 1 CHADT}
- {700581600 45900 0 CHAST}
- {718120800 49500 1 CHADT}
- {732636000 45900 0 CHAST}
- {749570400 49500 1 CHADT}
- {764085600 45900 0 CHAST}
- {781020000 49500 1 CHADT}
- {795535200 45900 0 CHAST}
- {812469600 49500 1 CHADT}
- {826984800 45900 0 CHAST}
- {844524000 49500 1 CHADT}
- {858434400 45900 0 CHAST}
- {875973600 49500 1 CHADT}
- {889884000 45900 0 CHAST}
- {907423200 49500 1 CHADT}
- {921938400 45900 0 CHAST}
- {938872800 49500 1 CHADT}
- {953388000 45900 0 CHAST}
- {970322400 49500 1 CHADT}
- {984837600 45900 0 CHAST}
- {1002376800 49500 1 CHADT}
- {1016287200 45900 0 CHAST}
- {1033826400 49500 1 CHADT}
- {1047736800 45900 0 CHAST}
- {1065276000 49500 1 CHADT}
- {1079791200 45900 0 CHAST}
- {1096725600 49500 1 CHADT}
- {1111240800 45900 0 CHAST}
- {1128175200 49500 1 CHADT}
- {1142690400 45900 0 CHAST}
- {1159624800 49500 1 CHADT}
- {1174140000 45900 0 CHAST}
- {1191074400 49500 1 CHADT}
- {1207404000 45900 0 CHAST}
- {1222524000 49500 1 CHADT}
- {1238853600 45900 0 CHAST}
- {1253973600 49500 1 CHADT}
- {1270303200 45900 0 CHAST}
- {1285423200 49500 1 CHADT}
- {1301752800 45900 0 CHAST}
- {1316872800 49500 1 CHADT}
- {1333202400 45900 0 CHAST}
- {1348927200 49500 1 CHADT}
- {1365256800 45900 0 CHAST}
- {1380376800 49500 1 CHADT}
- {1396706400 45900 0 CHAST}
- {1411826400 49500 1 CHADT}
- {1428156000 45900 0 CHAST}
- {1443276000 49500 1 CHADT}
- {1459605600 45900 0 CHAST}
- {1474725600 49500 1 CHADT}
- {1491055200 45900 0 CHAST}
- {1506175200 49500 1 CHADT}
- {1522504800 45900 0 CHAST}
- {1538229600 49500 1 CHADT}
- {1554559200 45900 0 CHAST}
- {1569679200 49500 1 CHADT}
- {1586008800 45900 0 CHAST}
- {1601128800 49500 1 CHADT}
- {1617458400 45900 0 CHAST}
- {1632578400 49500 1 CHADT}
- {1648908000 45900 0 CHAST}
- {1664028000 49500 1 CHADT}
- {1680357600 45900 0 CHAST}
- {1695477600 49500 1 CHADT}
- {1712412000 45900 0 CHAST}
- {1727532000 49500 1 CHADT}
- {1743861600 45900 0 CHAST}
- {1758981600 49500 1 CHADT}
- {1775311200 45900 0 CHAST}
- {1790431200 49500 1 CHADT}
- {1806760800 45900 0 CHAST}
- {1821880800 49500 1 CHADT}
- {1838210400 45900 0 CHAST}
- {1853330400 49500 1 CHADT}
- {1869660000 45900 0 CHAST}
- {1885384800 49500 1 CHADT}
- {1901714400 45900 0 CHAST}
- {1916834400 49500 1 CHADT}
- {1933164000 45900 0 CHAST}
- {1948284000 49500 1 CHADT}
- {1964613600 45900 0 CHAST}
- {1979733600 49500 1 CHADT}
- {1996063200 45900 0 CHAST}
- {2011183200 49500 1 CHADT}
- {2027512800 45900 0 CHAST}
- {2042632800 49500 1 CHADT}
- {2058962400 45900 0 CHAST}
- {2074687200 49500 1 CHADT}
- {2091016800 45900 0 CHAST}
- {2106136800 49500 1 CHADT}
- {2122466400 45900 0 CHAST}
- {2137586400 49500 1 CHADT}
- {2153916000 45900 0 CHAST}
- {2169036000 49500 1 CHADT}
- {2185365600 45900 0 CHAST}
- {2200485600 49500 1 CHADT}
- {2216815200 45900 0 CHAST}
- {2232540000 49500 1 CHADT}
- {2248869600 45900 0 CHAST}
- {2263989600 49500 1 CHADT}
- {2280319200 45900 0 CHAST}
- {2295439200 49500 1 CHADT}
- {2311768800 45900 0 CHAST}
- {2326888800 49500 1 CHADT}
- {2343218400 45900 0 CHAST}
- {2358338400 49500 1 CHADT}
- {2374668000 45900 0 CHAST}
- {2389788000 49500 1 CHADT}
- {2406117600 45900 0 CHAST}
- {2421842400 49500 1 CHADT}
- {2438172000 45900 0 CHAST}
- {2453292000 49500 1 CHADT}
- {2469621600 45900 0 CHAST}
- {2484741600 49500 1 CHADT}
- {2501071200 45900 0 CHAST}
- {2516191200 49500 1 CHADT}
- {2532520800 45900 0 CHAST}
- {2547640800 49500 1 CHADT}
- {2563970400 45900 0 CHAST}
- {2579090400 49500 1 CHADT}
- {2596024800 45900 0 CHAST}
- {2611144800 49500 1 CHADT}
- {2627474400 45900 0 CHAST}
- {2642594400 49500 1 CHADT}
- {2658924000 45900 0 CHAST}
- {2674044000 49500 1 CHADT}
- {2690373600 45900 0 CHAST}
- {2705493600 49500 1 CHADT}
- {2721823200 45900 0 CHAST}
- {2736943200 49500 1 CHADT}
- {2753272800 45900 0 CHAST}
- {2768997600 49500 1 CHADT}
- {2785327200 45900 0 CHAST}
- {2800447200 49500 1 CHADT}
- {2816776800 45900 0 CHAST}
- {2831896800 49500 1 CHADT}
- {2848226400 45900 0 CHAST}
- {2863346400 49500 1 CHADT}
- {2879676000 45900 0 CHAST}
- {2894796000 49500 1 CHADT}
- {2911125600 45900 0 CHAST}
- {2926245600 49500 1 CHADT}
- {2942575200 45900 0 CHAST}
- {2958300000 49500 1 CHADT}
- {2974629600 45900 0 CHAST}
- {2989749600 49500 1 CHADT}
- {3006079200 45900 0 CHAST}
- {3021199200 49500 1 CHADT}
- {3037528800 45900 0 CHAST}
- {3052648800 49500 1 CHADT}
- {3068978400 45900 0 CHAST}
- {3084098400 49500 1 CHADT}
- {3100428000 45900 0 CHAST}
- {3116152800 49500 1 CHADT}
- {3132482400 45900 0 CHAST}
- {3147602400 49500 1 CHADT}
- {3163932000 45900 0 CHAST}
- {3179052000 49500 1 CHADT}
- {3195381600 45900 0 CHAST}
- {3210501600 49500 1 CHADT}
- {3226831200 45900 0 CHAST}
- {3241951200 49500 1 CHADT}
- {3258280800 45900 0 CHAST}
- {3273400800 49500 1 CHADT}
- {3289730400 45900 0 CHAST}
- {3305455200 49500 1 CHADT}
- {3321784800 45900 0 CHAST}
- {3336904800 49500 1 CHADT}
- {3353234400 45900 0 CHAST}
- {3368354400 49500 1 CHADT}
- {3384684000 45900 0 CHAST}
- {3399804000 49500 1 CHADT}
- {3416133600 45900 0 CHAST}
- {3431253600 49500 1 CHADT}
- {3447583200 45900 0 CHAST}
- {3462703200 49500 1 CHADT}
- {3479637600 45900 0 CHAST}
- {3494757600 49500 1 CHADT}
- {3511087200 45900 0 CHAST}
- {3526207200 49500 1 CHADT}
- {3542536800 45900 0 CHAST}
- {3557656800 49500 1 CHADT}
- {3573986400 45900 0 CHAST}
- {3589106400 49500 1 CHADT}
- {3605436000 45900 0 CHAST}
- {3620556000 49500 1 CHADT}
- {3636885600 45900 0 CHAST}
- {3652610400 49500 1 CHADT}
- {3668940000 45900 0 CHAST}
- {3684060000 49500 1 CHADT}
- {3700389600 45900 0 CHAST}
- {3715509600 49500 1 CHADT}
- {3731839200 45900 0 CHAST}
- {3746959200 49500 1 CHADT}
- {3763288800 45900 0 CHAST}
- {3778408800 49500 1 CHADT}
- {3794738400 45900 0 CHAST}
- {3809858400 49500 1 CHADT}
- {3826188000 45900 0 CHAST}
- {3841912800 49500 1 CHADT}
- {3858242400 45900 0 CHAST}
- {3873362400 49500 1 CHADT}
- {3889692000 45900 0 CHAST}
- {3904812000 49500 1 CHADT}
- {3921141600 45900 0 CHAST}
- {3936261600 49500 1 CHADT}
- {3952591200 45900 0 CHAST}
- {3967711200 49500 1 CHADT}
- {3984040800 45900 0 CHAST}
- {3999765600 49500 1 CHADT}
- {4016095200 45900 0 CHAST}
- {4031215200 49500 1 CHADT}
- {4047544800 45900 0 CHAST}
- {4062664800 49500 1 CHADT}
- {4078994400 45900 0 CHAST}
- {4094114400 49500 1 CHADT}
+ {-3192437628 44100 0 +1215}
+ {-757426500 45900 0 +1345}
+ {152632800 49500 1 +1345}
+ {162309600 45900 0 +1345}
+ {183477600 49500 1 +1345}
+ {194968800 45900 0 +1345}
+ {215532000 49500 1 +1345}
+ {226418400 45900 0 +1345}
+ {246981600 49500 1 +1345}
+ {257868000 45900 0 +1345}
+ {278431200 49500 1 +1345}
+ {289317600 45900 0 +1345}
+ {309880800 49500 1 +1345}
+ {320767200 45900 0 +1345}
+ {341330400 49500 1 +1345}
+ {352216800 45900 0 +1345}
+ {372780000 49500 1 +1345}
+ {384271200 45900 0 +1345}
+ {404834400 49500 1 +1345}
+ {415720800 45900 0 +1345}
+ {436284000 49500 1 +1345}
+ {447170400 45900 0 +1345}
+ {467733600 49500 1 +1345}
+ {478620000 45900 0 +1345}
+ {499183200 49500 1 +1345}
+ {510069600 45900 0 +1345}
+ {530632800 49500 1 +1345}
+ {541519200 45900 0 +1345}
+ {562082400 49500 1 +1345}
+ {573573600 45900 0 +1345}
+ {594136800 49500 1 +1345}
+ {605023200 45900 0 +1345}
+ {623772000 49500 1 +1345}
+ {637682400 45900 0 +1345}
+ {655221600 49500 1 +1345}
+ {669132000 45900 0 +1345}
+ {686671200 49500 1 +1345}
+ {700581600 45900 0 +1345}
+ {718120800 49500 1 +1345}
+ {732636000 45900 0 +1345}
+ {749570400 49500 1 +1345}
+ {764085600 45900 0 +1345}
+ {781020000 49500 1 +1345}
+ {795535200 45900 0 +1345}
+ {812469600 49500 1 +1345}
+ {826984800 45900 0 +1345}
+ {844524000 49500 1 +1345}
+ {858434400 45900 0 +1345}
+ {875973600 49500 1 +1345}
+ {889884000 45900 0 +1345}
+ {907423200 49500 1 +1345}
+ {921938400 45900 0 +1345}
+ {938872800 49500 1 +1345}
+ {953388000 45900 0 +1345}
+ {970322400 49500 1 +1345}
+ {984837600 45900 0 +1345}
+ {1002376800 49500 1 +1345}
+ {1016287200 45900 0 +1345}
+ {1033826400 49500 1 +1345}
+ {1047736800 45900 0 +1345}
+ {1065276000 49500 1 +1345}
+ {1079791200 45900 0 +1345}
+ {1096725600 49500 1 +1345}
+ {1111240800 45900 0 +1345}
+ {1128175200 49500 1 +1345}
+ {1142690400 45900 0 +1345}
+ {1159624800 49500 1 +1345}
+ {1174140000 45900 0 +1345}
+ {1191074400 49500 1 +1345}
+ {1207404000 45900 0 +1345}
+ {1222524000 49500 1 +1345}
+ {1238853600 45900 0 +1345}
+ {1253973600 49500 1 +1345}
+ {1270303200 45900 0 +1345}
+ {1285423200 49500 1 +1345}
+ {1301752800 45900 0 +1345}
+ {1316872800 49500 1 +1345}
+ {1333202400 45900 0 +1345}
+ {1348927200 49500 1 +1345}
+ {1365256800 45900 0 +1345}
+ {1380376800 49500 1 +1345}
+ {1396706400 45900 0 +1345}
+ {1411826400 49500 1 +1345}
+ {1428156000 45900 0 +1345}
+ {1443276000 49500 1 +1345}
+ {1459605600 45900 0 +1345}
+ {1474725600 49500 1 +1345}
+ {1491055200 45900 0 +1345}
+ {1506175200 49500 1 +1345}
+ {1522504800 45900 0 +1345}
+ {1538229600 49500 1 +1345}
+ {1554559200 45900 0 +1345}
+ {1569679200 49500 1 +1345}
+ {1586008800 45900 0 +1345}
+ {1601128800 49500 1 +1345}
+ {1617458400 45900 0 +1345}
+ {1632578400 49500 1 +1345}
+ {1648908000 45900 0 +1345}
+ {1664028000 49500 1 +1345}
+ {1680357600 45900 0 +1345}
+ {1695477600 49500 1 +1345}
+ {1712412000 45900 0 +1345}
+ {1727532000 49500 1 +1345}
+ {1743861600 45900 0 +1345}
+ {1758981600 49500 1 +1345}
+ {1775311200 45900 0 +1345}
+ {1790431200 49500 1 +1345}
+ {1806760800 45900 0 +1345}
+ {1821880800 49500 1 +1345}
+ {1838210400 45900 0 +1345}
+ {1853330400 49500 1 +1345}
+ {1869660000 45900 0 +1345}
+ {1885384800 49500 1 +1345}
+ {1901714400 45900 0 +1345}
+ {1916834400 49500 1 +1345}
+ {1933164000 45900 0 +1345}
+ {1948284000 49500 1 +1345}
+ {1964613600 45900 0 +1345}
+ {1979733600 49500 1 +1345}
+ {1996063200 45900 0 +1345}
+ {2011183200 49500 1 +1345}
+ {2027512800 45900 0 +1345}
+ {2042632800 49500 1 +1345}
+ {2058962400 45900 0 +1345}
+ {2074687200 49500 1 +1345}
+ {2091016800 45900 0 +1345}
+ {2106136800 49500 1 +1345}
+ {2122466400 45900 0 +1345}
+ {2137586400 49500 1 +1345}
+ {2153916000 45900 0 +1345}
+ {2169036000 49500 1 +1345}
+ {2185365600 45900 0 +1345}
+ {2200485600 49500 1 +1345}
+ {2216815200 45900 0 +1345}
+ {2232540000 49500 1 +1345}
+ {2248869600 45900 0 +1345}
+ {2263989600 49500 1 +1345}
+ {2280319200 45900 0 +1345}
+ {2295439200 49500 1 +1345}
+ {2311768800 45900 0 +1345}
+ {2326888800 49500 1 +1345}
+ {2343218400 45900 0 +1345}
+ {2358338400 49500 1 +1345}
+ {2374668000 45900 0 +1345}
+ {2389788000 49500 1 +1345}
+ {2406117600 45900 0 +1345}
+ {2421842400 49500 1 +1345}
+ {2438172000 45900 0 +1345}
+ {2453292000 49500 1 +1345}
+ {2469621600 45900 0 +1345}
+ {2484741600 49500 1 +1345}
+ {2501071200 45900 0 +1345}
+ {2516191200 49500 1 +1345}
+ {2532520800 45900 0 +1345}
+ {2547640800 49500 1 +1345}
+ {2563970400 45900 0 +1345}
+ {2579090400 49500 1 +1345}
+ {2596024800 45900 0 +1345}
+ {2611144800 49500 1 +1345}
+ {2627474400 45900 0 +1345}
+ {2642594400 49500 1 +1345}
+ {2658924000 45900 0 +1345}
+ {2674044000 49500 1 +1345}
+ {2690373600 45900 0 +1345}
+ {2705493600 49500 1 +1345}
+ {2721823200 45900 0 +1345}
+ {2736943200 49500 1 +1345}
+ {2753272800 45900 0 +1345}
+ {2768997600 49500 1 +1345}
+ {2785327200 45900 0 +1345}
+ {2800447200 49500 1 +1345}
+ {2816776800 45900 0 +1345}
+ {2831896800 49500 1 +1345}
+ {2848226400 45900 0 +1345}
+ {2863346400 49500 1 +1345}
+ {2879676000 45900 0 +1345}
+ {2894796000 49500 1 +1345}
+ {2911125600 45900 0 +1345}
+ {2926245600 49500 1 +1345}
+ {2942575200 45900 0 +1345}
+ {2958300000 49500 1 +1345}
+ {2974629600 45900 0 +1345}
+ {2989749600 49500 1 +1345}
+ {3006079200 45900 0 +1345}
+ {3021199200 49500 1 +1345}
+ {3037528800 45900 0 +1345}
+ {3052648800 49500 1 +1345}
+ {3068978400 45900 0 +1345}
+ {3084098400 49500 1 +1345}
+ {3100428000 45900 0 +1345}
+ {3116152800 49500 1 +1345}
+ {3132482400 45900 0 +1345}
+ {3147602400 49500 1 +1345}
+ {3163932000 45900 0 +1345}
+ {3179052000 49500 1 +1345}
+ {3195381600 45900 0 +1345}
+ {3210501600 49500 1 +1345}
+ {3226831200 45900 0 +1345}
+ {3241951200 49500 1 +1345}
+ {3258280800 45900 0 +1345}
+ {3273400800 49500 1 +1345}
+ {3289730400 45900 0 +1345}
+ {3305455200 49500 1 +1345}
+ {3321784800 45900 0 +1345}
+ {3336904800 49500 1 +1345}
+ {3353234400 45900 0 +1345}
+ {3368354400 49500 1 +1345}
+ {3384684000 45900 0 +1345}
+ {3399804000 49500 1 +1345}
+ {3416133600 45900 0 +1345}
+ {3431253600 49500 1 +1345}
+ {3447583200 45900 0 +1345}
+ {3462703200 49500 1 +1345}
+ {3479637600 45900 0 +1345}
+ {3494757600 49500 1 +1345}
+ {3511087200 45900 0 +1345}
+ {3526207200 49500 1 +1345}
+ {3542536800 45900 0 +1345}
+ {3557656800 49500 1 +1345}
+ {3573986400 45900 0 +1345}
+ {3589106400 49500 1 +1345}
+ {3605436000 45900 0 +1345}
+ {3620556000 49500 1 +1345}
+ {3636885600 45900 0 +1345}
+ {3652610400 49500 1 +1345}
+ {3668940000 45900 0 +1345}
+ {3684060000 49500 1 +1345}
+ {3700389600 45900 0 +1345}
+ {3715509600 49500 1 +1345}
+ {3731839200 45900 0 +1345}
+ {3746959200 49500 1 +1345}
+ {3763288800 45900 0 +1345}
+ {3778408800 49500 1 +1345}
+ {3794738400 45900 0 +1345}
+ {3809858400 49500 1 +1345}
+ {3826188000 45900 0 +1345}
+ {3841912800 49500 1 +1345}
+ {3858242400 45900 0 +1345}
+ {3873362400 49500 1 +1345}
+ {3889692000 45900 0 +1345}
+ {3904812000 49500 1 +1345}
+ {3921141600 45900 0 +1345}
+ {3936261600 49500 1 +1345}
+ {3952591200 45900 0 +1345}
+ {3967711200 49500 1 +1345}
+ {3984040800 45900 0 +1345}
+ {3999765600 49500 1 +1345}
+ {4016095200 45900 0 +1345}
+ {4031215200 49500 1 +1345}
+ {4047544800 45900 0 +1345}
+ {4062664800 49500 1 +1345}
+ {4078994400 45900 0 +1345}
+ {4094114400 49500 1 +1345}
}
diff --git a/library/tzdata/Pacific/Chuuk b/library/tzdata/Pacific/Chuuk
index 70b14b2..4e9d099 100644
--- a/library/tzdata/Pacific/Chuuk
+++ b/library/tzdata/Pacific/Chuuk
@@ -2,5 +2,5 @@
set TZData(:Pacific/Chuuk) {
{-9223372036854775808 36428 0 LMT}
- {-2177489228 36000 0 CHUT}
+ {-2177489228 36000 0 +10}
}
diff --git a/library/tzdata/Pacific/Easter b/library/tzdata/Pacific/Easter
index ef0f2d5..474a32b 100644
--- a/library/tzdata/Pacific/Easter
+++ b/library/tzdata/Pacific/Easter
@@ -3,266 +3,266 @@
set TZData(:Pacific/Easter) {
{-9223372036854775808 -26248 0 LMT}
{-2524495352 -26248 0 EMT}
- {-1178124152 -25200 0 EAST}
- {-36619200 -21600 1 EASST}
- {-23922000 -25200 0 EAST}
- {-3355200 -21600 1 EASST}
- {7527600 -25200 0 EAST}
- {24465600 -21600 1 EASST}
- {37767600 -25200 0 EAST}
- {55915200 -21600 1 EASST}
- {69217200 -25200 0 EAST}
- {87969600 -21600 1 EASST}
- {100666800 -25200 0 EAST}
- {118209600 -21600 1 EASST}
- {132116400 -25200 0 EAST}
- {150868800 -21600 1 EASST}
- {163566000 -25200 0 EAST}
- {182318400 -21600 1 EASST}
- {195620400 -25200 0 EAST}
- {213768000 -21600 1 EASST}
- {227070000 -25200 0 EAST}
- {245217600 -21600 1 EASST}
- {258519600 -25200 0 EAST}
- {277272000 -21600 1 EASST}
- {289969200 -25200 0 EAST}
- {308721600 -21600 1 EASST}
- {321418800 -25200 0 EAST}
- {340171200 -21600 1 EASST}
- {353473200 -25200 0 EAST}
- {371620800 -21600 1 EASST}
- {384922800 -21600 0 EAST}
- {403070400 -18000 1 EASST}
- {416372400 -21600 0 EAST}
- {434520000 -18000 1 EASST}
- {447822000 -21600 0 EAST}
- {466574400 -18000 1 EASST}
- {479271600 -21600 0 EAST}
- {498024000 -18000 1 EASST}
- {510721200 -21600 0 EAST}
- {529473600 -18000 1 EASST}
- {545194800 -21600 0 EAST}
- {560923200 -18000 1 EASST}
- {574225200 -21600 0 EAST}
- {592372800 -18000 1 EASST}
- {605674800 -21600 0 EAST}
- {624427200 -18000 1 EASST}
- {637124400 -21600 0 EAST}
- {653457600 -18000 1 EASST}
- {668574000 -21600 0 EAST}
- {687326400 -18000 1 EASST}
- {700628400 -21600 0 EAST}
- {718776000 -18000 1 EASST}
- {732078000 -21600 0 EAST}
- {750225600 -18000 1 EASST}
- {763527600 -21600 0 EAST}
- {781675200 -18000 1 EASST}
- {794977200 -21600 0 EAST}
- {813729600 -18000 1 EASST}
- {826426800 -21600 0 EAST}
- {845179200 -18000 1 EASST}
- {859690800 -21600 0 EAST}
- {876628800 -18000 1 EASST}
- {889930800 -21600 0 EAST}
- {906868800 -18000 1 EASST}
- {923194800 -21600 0 EAST}
- {939528000 -18000 1 EASST}
- {952830000 -21600 0 EAST}
- {971582400 -18000 1 EASST}
- {984279600 -21600 0 EAST}
- {1003032000 -18000 1 EASST}
- {1015729200 -21600 0 EAST}
- {1034481600 -18000 1 EASST}
- {1047178800 -21600 0 EAST}
- {1065931200 -18000 1 EASST}
- {1079233200 -21600 0 EAST}
- {1097380800 -18000 1 EASST}
- {1110682800 -21600 0 EAST}
- {1128830400 -18000 1 EASST}
- {1142132400 -21600 0 EAST}
- {1160884800 -18000 1 EASST}
- {1173582000 -21600 0 EAST}
- {1192334400 -18000 1 EASST}
- {1206846000 -21600 0 EAST}
- {1223784000 -18000 1 EASST}
- {1237086000 -21600 0 EAST}
- {1255233600 -18000 1 EASST}
- {1270350000 -21600 0 EAST}
- {1286683200 -18000 1 EASST}
- {1304823600 -21600 0 EAST}
- {1313899200 -18000 1 EASST}
- {1335668400 -21600 0 EAST}
- {1346558400 -18000 1 EASST}
- {1367118000 -21600 0 EAST}
- {1378612800 -18000 1 EASST}
- {1398567600 -21600 0 EAST}
- {1410062400 -18000 1 EASST}
- {1463281200 -21600 0 EAST}
- {1471147200 -18000 1 EASST}
- {1494730800 -21600 0 EAST}
- {1502596800 -18000 1 EASST}
- {1526180400 -21600 0 EAST}
- {1534046400 -18000 1 EASST}
- {1557630000 -21600 0 EAST}
- {1565496000 -18000 1 EASST}
- {1589079600 -21600 0 EAST}
- {1596945600 -18000 1 EASST}
- {1620529200 -21600 0 EAST}
- {1629000000 -18000 1 EASST}
- {1652583600 -21600 0 EAST}
- {1660449600 -18000 1 EASST}
- {1684033200 -21600 0 EAST}
- {1691899200 -18000 1 EASST}
- {1715482800 -21600 0 EAST}
- {1723348800 -18000 1 EASST}
- {1746932400 -21600 0 EAST}
- {1754798400 -18000 1 EASST}
- {1778382000 -21600 0 EAST}
- {1786248000 -18000 1 EASST}
- {1809831600 -21600 0 EAST}
- {1818302400 -18000 1 EASST}
- {1841886000 -21600 0 EAST}
- {1849752000 -18000 1 EASST}
- {1873335600 -21600 0 EAST}
- {1881201600 -18000 1 EASST}
- {1904785200 -21600 0 EAST}
- {1912651200 -18000 1 EASST}
- {1936234800 -21600 0 EAST}
- {1944100800 -18000 1 EASST}
- {1967684400 -21600 0 EAST}
- {1976155200 -18000 1 EASST}
- {1999738800 -21600 0 EAST}
- {2007604800 -18000 1 EASST}
- {2031188400 -21600 0 EAST}
- {2039054400 -18000 1 EASST}
- {2062638000 -21600 0 EAST}
- {2070504000 -18000 1 EASST}
- {2094087600 -21600 0 EAST}
- {2101953600 -18000 1 EASST}
- {2125537200 -21600 0 EAST}
- {2133403200 -18000 1 EASST}
- {2156986800 -21600 0 EAST}
- {2165457600 -18000 1 EASST}
- {2189041200 -21600 0 EAST}
- {2196907200 -18000 1 EASST}
- {2220490800 -21600 0 EAST}
- {2228356800 -18000 1 EASST}
- {2251940400 -21600 0 EAST}
- {2259806400 -18000 1 EASST}
- {2283390000 -21600 0 EAST}
- {2291256000 -18000 1 EASST}
- {2314839600 -21600 0 EAST}
- {2322705600 -18000 1 EASST}
- {2346894000 -21600 0 EAST}
- {2354760000 -18000 1 EASST}
- {2378343600 -21600 0 EAST}
- {2386209600 -18000 1 EASST}
- {2409793200 -21600 0 EAST}
- {2417659200 -18000 1 EASST}
- {2441242800 -21600 0 EAST}
- {2449108800 -18000 1 EASST}
- {2472692400 -21600 0 EAST}
- {2480558400 -18000 1 EASST}
- {2504142000 -21600 0 EAST}
- {2512612800 -18000 1 EASST}
- {2536196400 -21600 0 EAST}
- {2544062400 -18000 1 EASST}
- {2567646000 -21600 0 EAST}
- {2575512000 -18000 1 EASST}
- {2599095600 -21600 0 EAST}
- {2606961600 -18000 1 EASST}
- {2630545200 -21600 0 EAST}
- {2638411200 -18000 1 EASST}
- {2661994800 -21600 0 EAST}
- {2669860800 -18000 1 EASST}
- {2693444400 -21600 0 EAST}
- {2701915200 -18000 1 EASST}
- {2725498800 -21600 0 EAST}
- {2733364800 -18000 1 EASST}
- {2756948400 -21600 0 EAST}
- {2764814400 -18000 1 EASST}
- {2788398000 -21600 0 EAST}
- {2796264000 -18000 1 EASST}
- {2819847600 -21600 0 EAST}
- {2827713600 -18000 1 EASST}
- {2851297200 -21600 0 EAST}
- {2859768000 -18000 1 EASST}
- {2883351600 -21600 0 EAST}
- {2891217600 -18000 1 EASST}
- {2914801200 -21600 0 EAST}
- {2922667200 -18000 1 EASST}
- {2946250800 -21600 0 EAST}
- {2954116800 -18000 1 EASST}
- {2977700400 -21600 0 EAST}
- {2985566400 -18000 1 EASST}
- {3009150000 -21600 0 EAST}
- {3017016000 -18000 1 EASST}
- {3040599600 -21600 0 EAST}
- {3049070400 -18000 1 EASST}
- {3072654000 -21600 0 EAST}
- {3080520000 -18000 1 EASST}
- {3104103600 -21600 0 EAST}
- {3111969600 -18000 1 EASST}
- {3135553200 -21600 0 EAST}
- {3143419200 -18000 1 EASST}
- {3167002800 -21600 0 EAST}
- {3174868800 -18000 1 EASST}
- {3198452400 -21600 0 EAST}
- {3206318400 -18000 1 EASST}
- {3230506800 -21600 0 EAST}
- {3238372800 -18000 1 EASST}
- {3261956400 -21600 0 EAST}
- {3269822400 -18000 1 EASST}
- {3293406000 -21600 0 EAST}
- {3301272000 -18000 1 EASST}
- {3324855600 -21600 0 EAST}
- {3332721600 -18000 1 EASST}
- {3356305200 -21600 0 EAST}
- {3364171200 -18000 1 EASST}
- {3387754800 -21600 0 EAST}
- {3396225600 -18000 1 EASST}
- {3419809200 -21600 0 EAST}
- {3427675200 -18000 1 EASST}
- {3451258800 -21600 0 EAST}
- {3459124800 -18000 1 EASST}
- {3482708400 -21600 0 EAST}
- {3490574400 -18000 1 EASST}
- {3514158000 -21600 0 EAST}
- {3522024000 -18000 1 EASST}
- {3545607600 -21600 0 EAST}
- {3553473600 -18000 1 EASST}
- {3577057200 -21600 0 EAST}
- {3585528000 -18000 1 EASST}
- {3609111600 -21600 0 EAST}
- {3616977600 -18000 1 EASST}
- {3640561200 -21600 0 EAST}
- {3648427200 -18000 1 EASST}
- {3672010800 -21600 0 EAST}
- {3679876800 -18000 1 EASST}
- {3703460400 -21600 0 EAST}
- {3711326400 -18000 1 EASST}
- {3734910000 -21600 0 EAST}
- {3743380800 -18000 1 EASST}
- {3766964400 -21600 0 EAST}
- {3774830400 -18000 1 EASST}
- {3798414000 -21600 0 EAST}
- {3806280000 -18000 1 EASST}
- {3829863600 -21600 0 EAST}
- {3837729600 -18000 1 EASST}
- {3861313200 -21600 0 EAST}
- {3869179200 -18000 1 EASST}
- {3892762800 -21600 0 EAST}
- {3900628800 -18000 1 EASST}
- {3924212400 -21600 0 EAST}
- {3932683200 -18000 1 EASST}
- {3956266800 -21600 0 EAST}
- {3964132800 -18000 1 EASST}
- {3987716400 -21600 0 EAST}
- {3995582400 -18000 1 EASST}
- {4019166000 -21600 0 EAST}
- {4027032000 -18000 1 EASST}
- {4050615600 -21600 0 EAST}
- {4058481600 -18000 1 EASST}
- {4082065200 -21600 0 EAST}
- {4089931200 -18000 1 EASST}
+ {-1178124152 -25200 0 -07}
+ {-36619200 -21600 1 -06}
+ {-23922000 -25200 0 -07}
+ {-3355200 -21600 1 -06}
+ {7527600 -25200 0 -07}
+ {24465600 -21600 1 -06}
+ {37767600 -25200 0 -07}
+ {55915200 -21600 1 -06}
+ {69217200 -25200 0 -07}
+ {87969600 -21600 1 -06}
+ {100666800 -25200 0 -07}
+ {118209600 -21600 1 -06}
+ {132116400 -25200 0 -07}
+ {150868800 -21600 1 -06}
+ {163566000 -25200 0 -07}
+ {182318400 -21600 1 -06}
+ {195620400 -25200 0 -07}
+ {213768000 -21600 1 -06}
+ {227070000 -25200 0 -07}
+ {245217600 -21600 1 -06}
+ {258519600 -25200 0 -07}
+ {277272000 -21600 1 -06}
+ {289969200 -25200 0 -07}
+ {308721600 -21600 1 -06}
+ {321418800 -25200 0 -07}
+ {340171200 -21600 1 -06}
+ {353473200 -25200 0 -07}
+ {371620800 -21600 1 -06}
+ {384922800 -21600 0 -06}
+ {403070400 -18000 1 -05}
+ {416372400 -21600 0 -06}
+ {434520000 -18000 1 -05}
+ {447822000 -21600 0 -06}
+ {466574400 -18000 1 -05}
+ {479271600 -21600 0 -06}
+ {498024000 -18000 1 -05}
+ {510721200 -21600 0 -06}
+ {529473600 -18000 1 -05}
+ {545194800 -21600 0 -06}
+ {560923200 -18000 1 -05}
+ {574225200 -21600 0 -06}
+ {592372800 -18000 1 -05}
+ {605674800 -21600 0 -06}
+ {624427200 -18000 1 -05}
+ {637124400 -21600 0 -06}
+ {653457600 -18000 1 -05}
+ {668574000 -21600 0 -06}
+ {687326400 -18000 1 -05}
+ {700628400 -21600 0 -06}
+ {718776000 -18000 1 -05}
+ {732078000 -21600 0 -06}
+ {750225600 -18000 1 -05}
+ {763527600 -21600 0 -06}
+ {781675200 -18000 1 -05}
+ {794977200 -21600 0 -06}
+ {813729600 -18000 1 -05}
+ {826426800 -21600 0 -06}
+ {845179200 -18000 1 -05}
+ {859690800 -21600 0 -06}
+ {876628800 -18000 1 -05}
+ {889930800 -21600 0 -06}
+ {906868800 -18000 1 -05}
+ {923194800 -21600 0 -06}
+ {939528000 -18000 1 -05}
+ {952830000 -21600 0 -06}
+ {971582400 -18000 1 -05}
+ {984279600 -21600 0 -06}
+ {1003032000 -18000 1 -05}
+ {1015729200 -21600 0 -06}
+ {1034481600 -18000 1 -05}
+ {1047178800 -21600 0 -06}
+ {1065931200 -18000 1 -05}
+ {1079233200 -21600 0 -06}
+ {1097380800 -18000 1 -05}
+ {1110682800 -21600 0 -06}
+ {1128830400 -18000 1 -05}
+ {1142132400 -21600 0 -06}
+ {1160884800 -18000 1 -05}
+ {1173582000 -21600 0 -06}
+ {1192334400 -18000 1 -05}
+ {1206846000 -21600 0 -06}
+ {1223784000 -18000 1 -05}
+ {1237086000 -21600 0 -06}
+ {1255233600 -18000 1 -05}
+ {1270350000 -21600 0 -06}
+ {1286683200 -18000 1 -05}
+ {1304823600 -21600 0 -06}
+ {1313899200 -18000 1 -05}
+ {1335668400 -21600 0 -06}
+ {1346558400 -18000 1 -05}
+ {1367118000 -21600 0 -06}
+ {1378612800 -18000 1 -05}
+ {1398567600 -21600 0 -06}
+ {1410062400 -18000 1 -05}
+ {1463281200 -21600 0 -06}
+ {1471147200 -18000 1 -05}
+ {1494730800 -21600 0 -06}
+ {1502596800 -18000 1 -05}
+ {1526180400 -21600 0 -06}
+ {1534046400 -18000 1 -05}
+ {1557630000 -21600 0 -06}
+ {1565496000 -18000 1 -05}
+ {1589079600 -21600 0 -06}
+ {1596945600 -18000 1 -05}
+ {1620529200 -21600 0 -06}
+ {1629000000 -18000 1 -05}
+ {1652583600 -21600 0 -06}
+ {1660449600 -18000 1 -05}
+ {1684033200 -21600 0 -06}
+ {1691899200 -18000 1 -05}
+ {1715482800 -21600 0 -06}
+ {1723348800 -18000 1 -05}
+ {1746932400 -21600 0 -06}
+ {1754798400 -18000 1 -05}
+ {1778382000 -21600 0 -06}
+ {1786248000 -18000 1 -05}
+ {1809831600 -21600 0 -06}
+ {1818302400 -18000 1 -05}
+ {1841886000 -21600 0 -06}
+ {1849752000 -18000 1 -05}
+ {1873335600 -21600 0 -06}
+ {1881201600 -18000 1 -05}
+ {1904785200 -21600 0 -06}
+ {1912651200 -18000 1 -05}
+ {1936234800 -21600 0 -06}
+ {1944100800 -18000 1 -05}
+ {1967684400 -21600 0 -06}
+ {1976155200 -18000 1 -05}
+ {1999738800 -21600 0 -06}
+ {2007604800 -18000 1 -05}
+ {2031188400 -21600 0 -06}
+ {2039054400 -18000 1 -05}
+ {2062638000 -21600 0 -06}
+ {2070504000 -18000 1 -05}
+ {2094087600 -21600 0 -06}
+ {2101953600 -18000 1 -05}
+ {2125537200 -21600 0 -06}
+ {2133403200 -18000 1 -05}
+ {2156986800 -21600 0 -06}
+ {2165457600 -18000 1 -05}
+ {2189041200 -21600 0 -06}
+ {2196907200 -18000 1 -05}
+ {2220490800 -21600 0 -06}
+ {2228356800 -18000 1 -05}
+ {2251940400 -21600 0 -06}
+ {2259806400 -18000 1 -05}
+ {2283390000 -21600 0 -06}
+ {2291256000 -18000 1 -05}
+ {2314839600 -21600 0 -06}
+ {2322705600 -18000 1 -05}
+ {2346894000 -21600 0 -06}
+ {2354760000 -18000 1 -05}
+ {2378343600 -21600 0 -06}
+ {2386209600 -18000 1 -05}
+ {2409793200 -21600 0 -06}
+ {2417659200 -18000 1 -05}
+ {2441242800 -21600 0 -06}
+ {2449108800 -18000 1 -05}
+ {2472692400 -21600 0 -06}
+ {2480558400 -18000 1 -05}
+ {2504142000 -21600 0 -06}
+ {2512612800 -18000 1 -05}
+ {2536196400 -21600 0 -06}
+ {2544062400 -18000 1 -05}
+ {2567646000 -21600 0 -06}
+ {2575512000 -18000 1 -05}
+ {2599095600 -21600 0 -06}
+ {2606961600 -18000 1 -05}
+ {2630545200 -21600 0 -06}
+ {2638411200 -18000 1 -05}
+ {2661994800 -21600 0 -06}
+ {2669860800 -18000 1 -05}
+ {2693444400 -21600 0 -06}
+ {2701915200 -18000 1 -05}
+ {2725498800 -21600 0 -06}
+ {2733364800 -18000 1 -05}
+ {2756948400 -21600 0 -06}
+ {2764814400 -18000 1 -05}
+ {2788398000 -21600 0 -06}
+ {2796264000 -18000 1 -05}
+ {2819847600 -21600 0 -06}
+ {2827713600 -18000 1 -05}
+ {2851297200 -21600 0 -06}
+ {2859768000 -18000 1 -05}
+ {2883351600 -21600 0 -06}
+ {2891217600 -18000 1 -05}
+ {2914801200 -21600 0 -06}
+ {2922667200 -18000 1 -05}
+ {2946250800 -21600 0 -06}
+ {2954116800 -18000 1 -05}
+ {2977700400 -21600 0 -06}
+ {2985566400 -18000 1 -05}
+ {3009150000 -21600 0 -06}
+ {3017016000 -18000 1 -05}
+ {3040599600 -21600 0 -06}
+ {3049070400 -18000 1 -05}
+ {3072654000 -21600 0 -06}
+ {3080520000 -18000 1 -05}
+ {3104103600 -21600 0 -06}
+ {3111969600 -18000 1 -05}
+ {3135553200 -21600 0 -06}
+ {3143419200 -18000 1 -05}
+ {3167002800 -21600 0 -06}
+ {3174868800 -18000 1 -05}
+ {3198452400 -21600 0 -06}
+ {3206318400 -18000 1 -05}
+ {3230506800 -21600 0 -06}
+ {3238372800 -18000 1 -05}
+ {3261956400 -21600 0 -06}
+ {3269822400 -18000 1 -05}
+ {3293406000 -21600 0 -06}
+ {3301272000 -18000 1 -05}
+ {3324855600 -21600 0 -06}
+ {3332721600 -18000 1 -05}
+ {3356305200 -21600 0 -06}
+ {3364171200 -18000 1 -05}
+ {3387754800 -21600 0 -06}
+ {3396225600 -18000 1 -05}
+ {3419809200 -21600 0 -06}
+ {3427675200 -18000 1 -05}
+ {3451258800 -21600 0 -06}
+ {3459124800 -18000 1 -05}
+ {3482708400 -21600 0 -06}
+ {3490574400 -18000 1 -05}
+ {3514158000 -21600 0 -06}
+ {3522024000 -18000 1 -05}
+ {3545607600 -21600 0 -06}
+ {3553473600 -18000 1 -05}
+ {3577057200 -21600 0 -06}
+ {3585528000 -18000 1 -05}
+ {3609111600 -21600 0 -06}
+ {3616977600 -18000 1 -05}
+ {3640561200 -21600 0 -06}
+ {3648427200 -18000 1 -05}
+ {3672010800 -21600 0 -06}
+ {3679876800 -18000 1 -05}
+ {3703460400 -21600 0 -06}
+ {3711326400 -18000 1 -05}
+ {3734910000 -21600 0 -06}
+ {3743380800 -18000 1 -05}
+ {3766964400 -21600 0 -06}
+ {3774830400 -18000 1 -05}
+ {3798414000 -21600 0 -06}
+ {3806280000 -18000 1 -05}
+ {3829863600 -21600 0 -06}
+ {3837729600 -18000 1 -05}
+ {3861313200 -21600 0 -06}
+ {3869179200 -18000 1 -05}
+ {3892762800 -21600 0 -06}
+ {3900628800 -18000 1 -05}
+ {3924212400 -21600 0 -06}
+ {3932683200 -18000 1 -05}
+ {3956266800 -21600 0 -06}
+ {3964132800 -18000 1 -05}
+ {3987716400 -21600 0 -06}
+ {3995582400 -18000 1 -05}
+ {4019166000 -21600 0 -06}
+ {4027032000 -18000 1 -05}
+ {4050615600 -21600 0 -06}
+ {4058481600 -18000 1 -05}
+ {4082065200 -21600 0 -06}
+ {4089931200 -18000 1 -05}
}
diff --git a/library/tzdata/Pacific/Efate b/library/tzdata/Pacific/Efate
index 18db6de..a43852e 100644
--- a/library/tzdata/Pacific/Efate
+++ b/library/tzdata/Pacific/Efate
@@ -2,25 +2,25 @@
set TZData(:Pacific/Efate) {
{-9223372036854775808 40396 0 LMT}
- {-1829387596 39600 0 VUT}
- {433256400 43200 1 VUST}
- {448977600 39600 0 VUT}
- {467298000 43200 1 VUST}
- {480427200 39600 0 VUT}
- {496760400 43200 1 VUST}
- {511876800 39600 0 VUT}
- {528210000 43200 1 VUST}
- {543931200 39600 0 VUT}
- {559659600 43200 1 VUST}
- {575380800 39600 0 VUT}
- {591109200 43200 1 VUST}
- {606830400 39600 0 VUT}
- {622558800 43200 1 VUST}
- {638280000 39600 0 VUT}
- {654008400 43200 1 VUST}
- {669729600 39600 0 VUT}
- {686062800 43200 1 VUST}
- {696340800 39600 0 VUT}
- {719931600 43200 1 VUST}
- {727790400 39600 0 VUT}
+ {-1829387596 39600 0 +11}
+ {433256400 43200 1 +12}
+ {448977600 39600 0 +11}
+ {467298000 43200 1 +12}
+ {480427200 39600 0 +11}
+ {496760400 43200 1 +12}
+ {511876800 39600 0 +11}
+ {528210000 43200 1 +12}
+ {543931200 39600 0 +11}
+ {559659600 43200 1 +12}
+ {575380800 39600 0 +11}
+ {591109200 43200 1 +12}
+ {606830400 39600 0 +11}
+ {622558800 43200 1 +12}
+ {638280000 39600 0 +11}
+ {654008400 43200 1 +12}
+ {669729600 39600 0 +11}
+ {686062800 43200 1 +12}
+ {696340800 39600 0 +11}
+ {719931600 43200 1 +12}
+ {727790400 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Enderbury b/library/tzdata/Pacific/Enderbury
index 55784c4..6abd57e 100644
--- a/library/tzdata/Pacific/Enderbury
+++ b/library/tzdata/Pacific/Enderbury
@@ -2,7 +2,7 @@
set TZData(:Pacific/Enderbury) {
{-9223372036854775808 -41060 0 LMT}
- {-2177411740 -43200 0 PHOT}
- {307627200 -39600 0 PHOT}
- {788958000 46800 0 PHOT}
+ {-2177411740 -43200 0 -12}
+ {307627200 -39600 0 -11}
+ {788958000 46800 0 +13}
}
diff --git a/library/tzdata/Pacific/Fakaofo b/library/tzdata/Pacific/Fakaofo
index 6ec98eb..d75030d 100644
--- a/library/tzdata/Pacific/Fakaofo
+++ b/library/tzdata/Pacific/Fakaofo
@@ -2,6 +2,6 @@
set TZData(:Pacific/Fakaofo) {
{-9223372036854775808 -41096 0 LMT}
- {-2177411704 -39600 0 TKT}
- {1325242800 46800 0 TKT}
+ {-2177411704 -39600 0 -11}
+ {1325242800 46800 0 +13}
}
diff --git a/library/tzdata/Pacific/Fiji b/library/tzdata/Pacific/Fiji
index 8f8b12f..fa8c99e 100644
--- a/library/tzdata/Pacific/Fiji
+++ b/library/tzdata/Pacific/Fiji
@@ -2,190 +2,190 @@
set TZData(:Pacific/Fiji) {
{-9223372036854775808 42944 0 LMT}
- {-1709985344 43200 0 FJT}
- {909842400 46800 1 FJST}
- {920124000 43200 0 FJT}
- {941896800 46800 1 FJST}
- {951573600 43200 0 FJT}
- {1259416800 46800 1 FJST}
- {1269698400 43200 0 FJT}
- {1287842400 46800 1 FJST}
- {1299333600 43200 0 FJT}
- {1319292000 46800 1 FJST}
- {1327154400 43200 0 FJT}
- {1350741600 46800 1 FJST}
- {1358604000 43200 0 FJT}
- {1382796000 46800 1 FJST}
- {1390050000 43200 0 FJT}
- {1414850400 46800 1 FJST}
- {1421503200 43200 0 FJT}
- {1446300000 46800 1 FJST}
- {1452952800 43200 0 FJT}
- {1478354400 46800 1 FJST}
- {1484402400 43200 0 FJT}
- {1509804000 46800 1 FJST}
- {1516456800 43200 0 FJT}
- {1541253600 46800 1 FJST}
- {1547906400 43200 0 FJT}
- {1572703200 46800 1 FJST}
- {1579356000 43200 0 FJT}
- {1604152800 46800 1 FJST}
- {1610805600 43200 0 FJT}
- {1636207200 46800 1 FJST}
- {1642255200 43200 0 FJT}
- {1667656800 46800 1 FJST}
- {1673704800 43200 0 FJT}
- {1699106400 46800 1 FJST}
- {1705759200 43200 0 FJT}
- {1730556000 46800 1 FJST}
- {1737208800 43200 0 FJT}
- {1762005600 46800 1 FJST}
- {1768658400 43200 0 FJT}
- {1793455200 46800 1 FJST}
- {1800108000 43200 0 FJT}
- {1825509600 46800 1 FJST}
- {1831557600 43200 0 FJT}
- {1856959200 46800 1 FJST}
- {1863612000 43200 0 FJT}
- {1888408800 46800 1 FJST}
- {1895061600 43200 0 FJT}
- {1919858400 46800 1 FJST}
- {1926511200 43200 0 FJT}
- {1951308000 46800 1 FJST}
- {1957960800 43200 0 FJT}
- {1983362400 46800 1 FJST}
- {1989410400 43200 0 FJT}
- {2014812000 46800 1 FJST}
- {2020860000 43200 0 FJT}
- {2046261600 46800 1 FJST}
- {2052914400 43200 0 FJT}
- {2077711200 46800 1 FJST}
- {2084364000 43200 0 FJT}
- {2109160800 46800 1 FJST}
- {2115813600 43200 0 FJT}
- {2140610400 46800 1 FJST}
- {2147263200 43200 0 FJT}
- {2172664800 46800 1 FJST}
- {2178712800 43200 0 FJT}
- {2204114400 46800 1 FJST}
- {2210162400 43200 0 FJT}
- {2235564000 46800 1 FJST}
- {2242216800 43200 0 FJT}
- {2267013600 46800 1 FJST}
- {2273666400 43200 0 FJT}
- {2298463200 46800 1 FJST}
- {2305116000 43200 0 FJT}
- {2329912800 46800 1 FJST}
- {2336565600 43200 0 FJT}
- {2361967200 46800 1 FJST}
- {2368015200 43200 0 FJT}
- {2393416800 46800 1 FJST}
- {2400069600 43200 0 FJT}
- {2424866400 46800 1 FJST}
- {2431519200 43200 0 FJT}
- {2456316000 46800 1 FJST}
- {2462968800 43200 0 FJT}
- {2487765600 46800 1 FJST}
- {2494418400 43200 0 FJT}
- {2519820000 46800 1 FJST}
- {2525868000 43200 0 FJT}
- {2551269600 46800 1 FJST}
- {2557317600 43200 0 FJT}
- {2582719200 46800 1 FJST}
- {2589372000 43200 0 FJT}
- {2614168800 46800 1 FJST}
- {2620821600 43200 0 FJT}
- {2645618400 46800 1 FJST}
- {2652271200 43200 0 FJT}
- {2677068000 46800 1 FJST}
- {2683720800 43200 0 FJT}
- {2709122400 46800 1 FJST}
- {2715170400 43200 0 FJT}
- {2740572000 46800 1 FJST}
- {2747224800 43200 0 FJT}
- {2772021600 46800 1 FJST}
- {2778674400 43200 0 FJT}
- {2803471200 46800 1 FJST}
- {2810124000 43200 0 FJT}
- {2834920800 46800 1 FJST}
- {2841573600 43200 0 FJT}
- {2866975200 46800 1 FJST}
- {2873023200 43200 0 FJT}
- {2898424800 46800 1 FJST}
- {2904472800 43200 0 FJT}
- {2929874400 46800 1 FJST}
- {2936527200 43200 0 FJT}
- {2961324000 46800 1 FJST}
- {2967976800 43200 0 FJT}
- {2992773600 46800 1 FJST}
- {2999426400 43200 0 FJT}
- {3024223200 46800 1 FJST}
- {3030876000 43200 0 FJT}
- {3056277600 46800 1 FJST}
- {3062325600 43200 0 FJT}
- {3087727200 46800 1 FJST}
- {3093775200 43200 0 FJT}
- {3119176800 46800 1 FJST}
- {3125829600 43200 0 FJT}
- {3150626400 46800 1 FJST}
- {3157279200 43200 0 FJT}
- {3182076000 46800 1 FJST}
- {3188728800 43200 0 FJT}
- {3213525600 46800 1 FJST}
- {3220178400 43200 0 FJT}
- {3245580000 46800 1 FJST}
- {3251628000 43200 0 FJT}
- {3277029600 46800 1 FJST}
- {3283682400 43200 0 FJT}
- {3308479200 46800 1 FJST}
- {3315132000 43200 0 FJT}
- {3339928800 46800 1 FJST}
- {3346581600 43200 0 FJT}
- {3371378400 46800 1 FJST}
- {3378031200 43200 0 FJT}
- {3403432800 46800 1 FJST}
- {3409480800 43200 0 FJT}
- {3434882400 46800 1 FJST}
- {3440930400 43200 0 FJT}
- {3466332000 46800 1 FJST}
- {3472984800 43200 0 FJT}
- {3497781600 46800 1 FJST}
- {3504434400 43200 0 FJT}
- {3529231200 46800 1 FJST}
- {3535884000 43200 0 FJT}
- {3560680800 46800 1 FJST}
- {3567333600 43200 0 FJT}
- {3592735200 46800 1 FJST}
- {3598783200 43200 0 FJT}
- {3624184800 46800 1 FJST}
- {3630837600 43200 0 FJT}
- {3655634400 46800 1 FJST}
- {3662287200 43200 0 FJT}
- {3687084000 46800 1 FJST}
- {3693736800 43200 0 FJT}
- {3718533600 46800 1 FJST}
- {3725186400 43200 0 FJT}
- {3750588000 46800 1 FJST}
- {3756636000 43200 0 FJT}
- {3782037600 46800 1 FJST}
- {3788085600 43200 0 FJT}
- {3813487200 46800 1 FJST}
- {3820140000 43200 0 FJT}
- {3844936800 46800 1 FJST}
- {3851589600 43200 0 FJT}
- {3876386400 46800 1 FJST}
- {3883039200 43200 0 FJT}
- {3907836000 46800 1 FJST}
- {3914488800 43200 0 FJT}
- {3939890400 46800 1 FJST}
- {3945938400 43200 0 FJT}
- {3971340000 46800 1 FJST}
- {3977388000 43200 0 FJT}
- {4002789600 46800 1 FJST}
- {4009442400 43200 0 FJT}
- {4034239200 46800 1 FJST}
- {4040892000 43200 0 FJT}
- {4065688800 46800 1 FJST}
- {4072341600 43200 0 FJT}
- {4097138400 46800 1 FJST}
+ {-1709985344 43200 0 +12}
+ {909842400 46800 1 +13}
+ {920124000 43200 0 +12}
+ {941896800 46800 1 +13}
+ {951573600 43200 0 +12}
+ {1259416800 46800 1 +13}
+ {1269698400 43200 0 +12}
+ {1287842400 46800 1 +13}
+ {1299333600 43200 0 +12}
+ {1319292000 46800 1 +13}
+ {1327154400 43200 0 +12}
+ {1350741600 46800 1 +13}
+ {1358604000 43200 0 +12}
+ {1382796000 46800 1 +13}
+ {1390050000 43200 0 +12}
+ {1414850400 46800 1 +13}
+ {1421503200 43200 0 +12}
+ {1446300000 46800 1 +13}
+ {1452952800 43200 0 +12}
+ {1478354400 46800 1 +13}
+ {1484402400 43200 0 +12}
+ {1509804000 46800 1 +13}
+ {1516456800 43200 0 +12}
+ {1541253600 46800 1 +13}
+ {1547906400 43200 0 +12}
+ {1572703200 46800 1 +13}
+ {1579356000 43200 0 +12}
+ {1604152800 46800 1 +13}
+ {1610805600 43200 0 +12}
+ {1636207200 46800 1 +13}
+ {1642255200 43200 0 +12}
+ {1667656800 46800 1 +13}
+ {1673704800 43200 0 +12}
+ {1699106400 46800 1 +13}
+ {1705759200 43200 0 +12}
+ {1730556000 46800 1 +13}
+ {1737208800 43200 0 +12}
+ {1762005600 46800 1 +13}
+ {1768658400 43200 0 +12}
+ {1793455200 46800 1 +13}
+ {1800108000 43200 0 +12}
+ {1825509600 46800 1 +13}
+ {1831557600 43200 0 +12}
+ {1856959200 46800 1 +13}
+ {1863612000 43200 0 +12}
+ {1888408800 46800 1 +13}
+ {1895061600 43200 0 +12}
+ {1919858400 46800 1 +13}
+ {1926511200 43200 0 +12}
+ {1951308000 46800 1 +13}
+ {1957960800 43200 0 +12}
+ {1983362400 46800 1 +13}
+ {1989410400 43200 0 +12}
+ {2014812000 46800 1 +13}
+ {2020860000 43200 0 +12}
+ {2046261600 46800 1 +13}
+ {2052914400 43200 0 +12}
+ {2077711200 46800 1 +13}
+ {2084364000 43200 0 +12}
+ {2109160800 46800 1 +13}
+ {2115813600 43200 0 +12}
+ {2140610400 46800 1 +13}
+ {2147263200 43200 0 +12}
+ {2172664800 46800 1 +13}
+ {2178712800 43200 0 +12}
+ {2204114400 46800 1 +13}
+ {2210162400 43200 0 +12}
+ {2235564000 46800 1 +13}
+ {2242216800 43200 0 +12}
+ {2267013600 46800 1 +13}
+ {2273666400 43200 0 +12}
+ {2298463200 46800 1 +13}
+ {2305116000 43200 0 +12}
+ {2329912800 46800 1 +13}
+ {2336565600 43200 0 +12}
+ {2361967200 46800 1 +13}
+ {2368015200 43200 0 +12}
+ {2393416800 46800 1 +13}
+ {2400069600 43200 0 +12}
+ {2424866400 46800 1 +13}
+ {2431519200 43200 0 +12}
+ {2456316000 46800 1 +13}
+ {2462968800 43200 0 +12}
+ {2487765600 46800 1 +13}
+ {2494418400 43200 0 +12}
+ {2519820000 46800 1 +13}
+ {2525868000 43200 0 +12}
+ {2551269600 46800 1 +13}
+ {2557317600 43200 0 +12}
+ {2582719200 46800 1 +13}
+ {2589372000 43200 0 +12}
+ {2614168800 46800 1 +13}
+ {2620821600 43200 0 +12}
+ {2645618400 46800 1 +13}
+ {2652271200 43200 0 +12}
+ {2677068000 46800 1 +13}
+ {2683720800 43200 0 +12}
+ {2709122400 46800 1 +13}
+ {2715170400 43200 0 +12}
+ {2740572000 46800 1 +13}
+ {2747224800 43200 0 +12}
+ {2772021600 46800 1 +13}
+ {2778674400 43200 0 +12}
+ {2803471200 46800 1 +13}
+ {2810124000 43200 0 +12}
+ {2834920800 46800 1 +13}
+ {2841573600 43200 0 +12}
+ {2866975200 46800 1 +13}
+ {2873023200 43200 0 +12}
+ {2898424800 46800 1 +13}
+ {2904472800 43200 0 +12}
+ {2929874400 46800 1 +13}
+ {2936527200 43200 0 +12}
+ {2961324000 46800 1 +13}
+ {2967976800 43200 0 +12}
+ {2992773600 46800 1 +13}
+ {2999426400 43200 0 +12}
+ {3024223200 46800 1 +13}
+ {3030876000 43200 0 +12}
+ {3056277600 46800 1 +13}
+ {3062325600 43200 0 +12}
+ {3087727200 46800 1 +13}
+ {3093775200 43200 0 +12}
+ {3119176800 46800 1 +13}
+ {3125829600 43200 0 +12}
+ {3150626400 46800 1 +13}
+ {3157279200 43200 0 +12}
+ {3182076000 46800 1 +13}
+ {3188728800 43200 0 +12}
+ {3213525600 46800 1 +13}
+ {3220178400 43200 0 +12}
+ {3245580000 46800 1 +13}
+ {3251628000 43200 0 +12}
+ {3277029600 46800 1 +13}
+ {3283682400 43200 0 +12}
+ {3308479200 46800 1 +13}
+ {3315132000 43200 0 +12}
+ {3339928800 46800 1 +13}
+ {3346581600 43200 0 +12}
+ {3371378400 46800 1 +13}
+ {3378031200 43200 0 +12}
+ {3403432800 46800 1 +13}
+ {3409480800 43200 0 +12}
+ {3434882400 46800 1 +13}
+ {3440930400 43200 0 +12}
+ {3466332000 46800 1 +13}
+ {3472984800 43200 0 +12}
+ {3497781600 46800 1 +13}
+ {3504434400 43200 0 +12}
+ {3529231200 46800 1 +13}
+ {3535884000 43200 0 +12}
+ {3560680800 46800 1 +13}
+ {3567333600 43200 0 +12}
+ {3592735200 46800 1 +13}
+ {3598783200 43200 0 +12}
+ {3624184800 46800 1 +13}
+ {3630837600 43200 0 +12}
+ {3655634400 46800 1 +13}
+ {3662287200 43200 0 +12}
+ {3687084000 46800 1 +13}
+ {3693736800 43200 0 +12}
+ {3718533600 46800 1 +13}
+ {3725186400 43200 0 +12}
+ {3750588000 46800 1 +13}
+ {3756636000 43200 0 +12}
+ {3782037600 46800 1 +13}
+ {3788085600 43200 0 +12}
+ {3813487200 46800 1 +13}
+ {3820140000 43200 0 +12}
+ {3844936800 46800 1 +13}
+ {3851589600 43200 0 +12}
+ {3876386400 46800 1 +13}
+ {3883039200 43200 0 +12}
+ {3907836000 46800 1 +13}
+ {3914488800 43200 0 +12}
+ {3939890400 46800 1 +13}
+ {3945938400 43200 0 +12}
+ {3971340000 46800 1 +13}
+ {3977388000 43200 0 +12}
+ {4002789600 46800 1 +13}
+ {4009442400 43200 0 +12}
+ {4034239200 46800 1 +13}
+ {4040892000 43200 0 +12}
+ {4065688800 46800 1 +13}
+ {4072341600 43200 0 +12}
+ {4097138400 46800 1 +13}
}
diff --git a/library/tzdata/Pacific/Funafuti b/library/tzdata/Pacific/Funafuti
index b94e4fb..d806525 100644
--- a/library/tzdata/Pacific/Funafuti
+++ b/library/tzdata/Pacific/Funafuti
@@ -2,5 +2,5 @@
set TZData(:Pacific/Funafuti) {
{-9223372036854775808 43012 0 LMT}
- {-2177495812 43200 0 TVT}
+ {-2177495812 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Galapagos b/library/tzdata/Pacific/Galapagos
index d8c80e8..f276f73 100644
--- a/library/tzdata/Pacific/Galapagos
+++ b/library/tzdata/Pacific/Galapagos
@@ -2,6 +2,8 @@
set TZData(:Pacific/Galapagos) {
{-9223372036854775808 -21504 0 LMT}
- {-1230746496 -18000 0 ECT}
- {504939600 -21600 0 GALT}
+ {-1230746496 -18000 0 -05}
+ {504939600 -21600 0 -06}
+ {722930400 -18000 1 -05}
+ {728888400 -21600 0 -06}
}
diff --git a/library/tzdata/Pacific/Gambier b/library/tzdata/Pacific/Gambier
index d69f99a..9ebd97c 100644
--- a/library/tzdata/Pacific/Gambier
+++ b/library/tzdata/Pacific/Gambier
@@ -2,5 +2,5 @@
set TZData(:Pacific/Gambier) {
{-9223372036854775808 -32388 0 LMT}
- {-1806678012 -32400 0 GAMT}
+ {-1806678012 -32400 0 -09}
}
diff --git a/library/tzdata/Pacific/Guadalcanal b/library/tzdata/Pacific/Guadalcanal
index 09a67dd..7e13e6e 100644
--- a/library/tzdata/Pacific/Guadalcanal
+++ b/library/tzdata/Pacific/Guadalcanal
@@ -2,5 +2,5 @@
set TZData(:Pacific/Guadalcanal) {
{-9223372036854775808 38388 0 LMT}
- {-1806748788 39600 0 SBT}
+ {-1806748788 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Kiritimati b/library/tzdata/Pacific/Kiritimati
index 06b695b..b703f19 100644
--- a/library/tzdata/Pacific/Kiritimati
+++ b/library/tzdata/Pacific/Kiritimati
@@ -2,7 +2,7 @@
set TZData(:Pacific/Kiritimati) {
{-9223372036854775808 -37760 0 LMT}
- {-2177415040 -38400 0 LINT}
- {307622400 -36000 0 LINT}
- {788954400 50400 0 LINT}
+ {-2177415040 -38400 0 -1040}
+ {307622400 -36000 0 -10}
+ {788954400 50400 0 +14}
}
diff --git a/library/tzdata/Pacific/Kosrae b/library/tzdata/Pacific/Kosrae
index a16b19d..04bed35 100644
--- a/library/tzdata/Pacific/Kosrae
+++ b/library/tzdata/Pacific/Kosrae
@@ -2,7 +2,7 @@
set TZData(:Pacific/Kosrae) {
{-9223372036854775808 39116 0 LMT}
- {-2177491916 39600 0 KOST}
- {-7988400 43200 0 KOST}
- {915105600 39600 0 KOST}
+ {-2177491916 39600 0 +11}
+ {-7988400 43200 0 +12}
+ {915105600 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Kwajalein b/library/tzdata/Pacific/Kwajalein
index 8600b3b..19e1067 100644
--- a/library/tzdata/Pacific/Kwajalein
+++ b/library/tzdata/Pacific/Kwajalein
@@ -2,7 +2,7 @@
set TZData(:Pacific/Kwajalein) {
{-9223372036854775808 40160 0 LMT}
- {-2177492960 39600 0 MHT}
- {-7988400 -43200 0 KWAT}
- {745848000 43200 0 MHT}
+ {-2177492960 39600 0 +11}
+ {-7988400 -43200 0 -12}
+ {745848000 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Majuro b/library/tzdata/Pacific/Majuro
index 468baab..5e9ac99 100644
--- a/library/tzdata/Pacific/Majuro
+++ b/library/tzdata/Pacific/Majuro
@@ -2,6 +2,6 @@
set TZData(:Pacific/Majuro) {
{-9223372036854775808 41088 0 LMT}
- {-2177493888 39600 0 MHT}
- {-7988400 43200 0 MHT}
+ {-2177493888 39600 0 +11}
+ {-7988400 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Marquesas b/library/tzdata/Pacific/Marquesas
index 9bb508f..ac77a2f 100644
--- a/library/tzdata/Pacific/Marquesas
+++ b/library/tzdata/Pacific/Marquesas
@@ -2,5 +2,5 @@
set TZData(:Pacific/Marquesas) {
{-9223372036854775808 -33480 0 LMT}
- {-1806676920 -34200 0 MART}
+ {-1806676920 -34200 0 -0930}
}
diff --git a/library/tzdata/Pacific/Nauru b/library/tzdata/Pacific/Nauru
index 2da1e25..de10811 100644
--- a/library/tzdata/Pacific/Nauru
+++ b/library/tzdata/Pacific/Nauru
@@ -2,8 +2,8 @@
set TZData(:Pacific/Nauru) {
{-9223372036854775808 40060 0 LMT}
- {-1545131260 41400 0 NRT}
- {-877347000 32400 0 JST}
- {-800960400 41400 0 NRT}
- {294323400 43200 0 NRT}
+ {-1545131260 41400 0 +1130}
+ {-877347000 32400 0 +09}
+ {-800960400 41400 0 +1130}
+ {294323400 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Niue b/library/tzdata/Pacific/Niue
index cf149fc..fe19c59 100644
--- a/library/tzdata/Pacific/Niue
+++ b/library/tzdata/Pacific/Niue
@@ -2,7 +2,7 @@
set TZData(:Pacific/Niue) {
{-9223372036854775808 -40780 0 LMT}
- {-2177412020 -40800 0 NUT}
- {-599575200 -41400 0 NUT}
- {276089400 -39600 0 NUT}
+ {-2177412020 -40800 0 -1120}
+ {-599575200 -41400 0 -1130}
+ {276089400 -39600 0 -11}
}
diff --git a/library/tzdata/Pacific/Norfolk b/library/tzdata/Pacific/Norfolk
index b12ab8c..f0556ab 100644
--- a/library/tzdata/Pacific/Norfolk
+++ b/library/tzdata/Pacific/Norfolk
@@ -2,9 +2,9 @@
set TZData(:Pacific/Norfolk) {
{-9223372036854775808 40312 0 LMT}
- {-2177493112 40320 0 NMT}
- {-599656320 41400 0 NFT}
- {152029800 45000 1 NFST}
- {162912600 41400 0 NFT}
- {1443882600 39600 0 NFT}
+ {-2177493112 40320 0 +1112}
+ {-599656320 41400 0 +1130}
+ {152029800 45000 1 +1230}
+ {162912600 41400 0 +1130}
+ {1443882600 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Noumea b/library/tzdata/Pacific/Noumea
index db1eeae..36b570d 100644
--- a/library/tzdata/Pacific/Noumea
+++ b/library/tzdata/Pacific/Noumea
@@ -2,11 +2,11 @@
set TZData(:Pacific/Noumea) {
{-9223372036854775808 39948 0 LMT}
- {-1829387148 39600 0 NCT}
- {250002000 43200 1 NCST}
- {257342400 39600 0 NCT}
- {281451600 43200 1 NCST}
- {288878400 39600 0 NCT}
- {849366000 43200 1 NCST}
- {857228400 39600 0 NCT}
+ {-1829387148 39600 0 +11}
+ {250002000 43200 1 +12}
+ {257342400 39600 0 +11}
+ {281451600 43200 1 +12}
+ {288878400 39600 0 +11}
+ {849366000 43200 1 +12}
+ {857228400 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Pago_Pago b/library/tzdata/Pacific/Pago_Pago
index ca261d0..d30c981 100644
--- a/library/tzdata/Pacific/Pago_Pago
+++ b/library/tzdata/Pacific/Pago_Pago
@@ -3,7 +3,5 @@
set TZData(:Pacific/Pago_Pago) {
{-9223372036854775808 45432 0 LMT}
{-2855738232 -40968 0 LMT}
- {-1861879032 -39600 0 NST}
- {-86878800 -39600 0 BST}
- {439038000 -39600 0 SST}
+ {-1861879032 -39600 0 SST}
}
diff --git a/library/tzdata/Pacific/Palau b/library/tzdata/Pacific/Palau
index ee0606d..a50fd2a 100644
--- a/library/tzdata/Pacific/Palau
+++ b/library/tzdata/Pacific/Palau
@@ -2,5 +2,5 @@
set TZData(:Pacific/Palau) {
{-9223372036854775808 32276 0 LMT}
- {-2177485076 32400 0 PWT}
+ {-2177485076 32400 0 +09}
}
diff --git a/library/tzdata/Pacific/Pitcairn b/library/tzdata/Pacific/Pitcairn
index d62644e..6813978 100644
--- a/library/tzdata/Pacific/Pitcairn
+++ b/library/tzdata/Pacific/Pitcairn
@@ -2,6 +2,6 @@
set TZData(:Pacific/Pitcairn) {
{-9223372036854775808 -31220 0 LMT}
- {-2177421580 -30600 0 PNT}
- {893665800 -28800 0 PST}
+ {-2177421580 -30600 0 -0830}
+ {893665800 -28800 0 -08}
}
diff --git a/library/tzdata/Pacific/Pohnpei b/library/tzdata/Pacific/Pohnpei
index 58978da..3fcb5d0 100644
--- a/library/tzdata/Pacific/Pohnpei
+++ b/library/tzdata/Pacific/Pohnpei
@@ -2,5 +2,5 @@
set TZData(:Pacific/Pohnpei) {
{-9223372036854775808 37972 0 LMT}
- {-2177490772 39600 0 PONT}
+ {-2177490772 39600 0 +11}
}
diff --git a/library/tzdata/Pacific/Port_Moresby b/library/tzdata/Pacific/Port_Moresby
index 65eb533..c3a5e4f 100644
--- a/library/tzdata/Pacific/Port_Moresby
+++ b/library/tzdata/Pacific/Port_Moresby
@@ -3,5 +3,5 @@
set TZData(:Pacific/Port_Moresby) {
{-9223372036854775808 35320 0 LMT}
{-2840176120 35312 0 PMMT}
- {-2366790512 36000 0 PGT}
+ {-2366790512 36000 0 +10}
}
diff --git a/library/tzdata/Pacific/Rarotonga b/library/tzdata/Pacific/Rarotonga
index a4ecf8d..9a70318 100644
--- a/library/tzdata/Pacific/Rarotonga
+++ b/library/tzdata/Pacific/Rarotonga
@@ -2,31 +2,31 @@
set TZData(:Pacific/Rarotonga) {
{-9223372036854775808 -38344 0 LMT}
- {-2177414456 -37800 0 CKT}
- {279714600 -34200 0 CKHST}
- {289387800 -36000 0 CKT}
- {309952800 -34200 1 CKHST}
- {320837400 -36000 0 CKT}
- {341402400 -34200 1 CKHST}
- {352287000 -36000 0 CKT}
- {372852000 -34200 1 CKHST}
- {384341400 -36000 0 CKT}
- {404906400 -34200 1 CKHST}
- {415791000 -36000 0 CKT}
- {436356000 -34200 1 CKHST}
- {447240600 -36000 0 CKT}
- {467805600 -34200 1 CKHST}
- {478690200 -36000 0 CKT}
- {499255200 -34200 1 CKHST}
- {510139800 -36000 0 CKT}
- {530704800 -34200 1 CKHST}
- {541589400 -36000 0 CKT}
- {562154400 -34200 1 CKHST}
- {573643800 -36000 0 CKT}
- {594208800 -34200 1 CKHST}
- {605093400 -36000 0 CKT}
- {625658400 -34200 1 CKHST}
- {636543000 -36000 0 CKT}
- {657108000 -34200 1 CKHST}
- {667992600 -36000 0 CKT}
+ {-2177414456 -37800 0 -1030}
+ {279714600 -34200 0 -0930}
+ {289387800 -36000 0 -10}
+ {309952800 -34200 1 -0930}
+ {320837400 -36000 0 -10}
+ {341402400 -34200 1 -0930}
+ {352287000 -36000 0 -10}
+ {372852000 -34200 1 -0930}
+ {384341400 -36000 0 -10}
+ {404906400 -34200 1 -0930}
+ {415791000 -36000 0 -10}
+ {436356000 -34200 1 -0930}
+ {447240600 -36000 0 -10}
+ {467805600 -34200 1 -0930}
+ {478690200 -36000 0 -10}
+ {499255200 -34200 1 -0930}
+ {510139800 -36000 0 -10}
+ {530704800 -34200 1 -0930}
+ {541589400 -36000 0 -10}
+ {562154400 -34200 1 -0930}
+ {573643800 -36000 0 -10}
+ {594208800 -34200 1 -0930}
+ {605093400 -36000 0 -10}
+ {625658400 -34200 1 -0930}
+ {636543000 -36000 0 -10}
+ {657108000 -34200 1 -0930}
+ {667992600 -36000 0 -10}
}
diff --git a/library/tzdata/Pacific/Tahiti b/library/tzdata/Pacific/Tahiti
index f739223..768553c 100644
--- a/library/tzdata/Pacific/Tahiti
+++ b/library/tzdata/Pacific/Tahiti
@@ -2,5 +2,5 @@
set TZData(:Pacific/Tahiti) {
{-9223372036854775808 -35896 0 LMT}
- {-1806674504 -36000 0 TAHT}
+ {-1806674504 -36000 0 -10}
}
diff --git a/library/tzdata/Pacific/Tarawa b/library/tzdata/Pacific/Tarawa
index 2dab5a2..2b9b556 100644
--- a/library/tzdata/Pacific/Tarawa
+++ b/library/tzdata/Pacific/Tarawa
@@ -2,5 +2,5 @@
set TZData(:Pacific/Tarawa) {
{-9223372036854775808 41524 0 LMT}
- {-2177494324 43200 0 GILT}
+ {-2177494324 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Tongatapu b/library/tzdata/Pacific/Tongatapu
index da9f857..731b4f6 100644
--- a/library/tzdata/Pacific/Tongatapu
+++ b/library/tzdata/Pacific/Tongatapu
@@ -2,13 +2,180 @@
set TZData(:Pacific/Tongatapu) {
{-9223372036854775808 44360 0 LMT}
- {-2177497160 44400 0 TOT}
- {-915193200 46800 0 TOT}
- {915102000 46800 0 TOT}
- {939214800 50400 1 TOST}
- {953384400 46800 0 TOT}
- {973342800 50400 1 TOST}
- {980596800 46800 0 TOT}
- {1004792400 50400 1 TOST}
- {1012046400 46800 0 TOT}
+ {-2177497160 44400 0 +1220}
+ {-915193200 46800 0 +13}
+ {915102000 46800 0 +13}
+ {939214800 50400 1 +14}
+ {953384400 46800 0 +13}
+ {973342800 50400 1 +14}
+ {980596800 46800 0 +13}
+ {1004792400 50400 1 +14}
+ {1012046400 46800 0 +13}
+ {1478350800 50400 1 +14}
+ {1484398800 46800 0 +13}
+ {1509800400 50400 1 +14}
+ {1516453200 46800 0 +13}
+ {1541250000 50400 1 +14}
+ {1547902800 46800 0 +13}
+ {1572699600 50400 1 +14}
+ {1579352400 46800 0 +13}
+ {1604149200 50400 1 +14}
+ {1610802000 46800 0 +13}
+ {1636203600 50400 1 +14}
+ {1642251600 46800 0 +13}
+ {1667653200 50400 1 +14}
+ {1673701200 46800 0 +13}
+ {1699102800 50400 1 +14}
+ {1705755600 46800 0 +13}
+ {1730552400 50400 1 +14}
+ {1737205200 46800 0 +13}
+ {1762002000 50400 1 +14}
+ {1768654800 46800 0 +13}
+ {1793451600 50400 1 +14}
+ {1800104400 46800 0 +13}
+ {1825506000 50400 1 +14}
+ {1831554000 46800 0 +13}
+ {1856955600 50400 1 +14}
+ {1863608400 46800 0 +13}
+ {1888405200 50400 1 +14}
+ {1895058000 46800 0 +13}
+ {1919854800 50400 1 +14}
+ {1926507600 46800 0 +13}
+ {1951304400 50400 1 +14}
+ {1957957200 46800 0 +13}
+ {1983358800 50400 1 +14}
+ {1989406800 46800 0 +13}
+ {2014808400 50400 1 +14}
+ {2020856400 46800 0 +13}
+ {2046258000 50400 1 +14}
+ {2052910800 46800 0 +13}
+ {2077707600 50400 1 +14}
+ {2084360400 46800 0 +13}
+ {2109157200 50400 1 +14}
+ {2115810000 46800 0 +13}
+ {2140606800 50400 1 +14}
+ {2147259600 46800 0 +13}
+ {2172661200 50400 1 +14}
+ {2178709200 46800 0 +13}
+ {2204110800 50400 1 +14}
+ {2210158800 46800 0 +13}
+ {2235560400 50400 1 +14}
+ {2242213200 46800 0 +13}
+ {2267010000 50400 1 +14}
+ {2273662800 46800 0 +13}
+ {2298459600 50400 1 +14}
+ {2305112400 46800 0 +13}
+ {2329909200 50400 1 +14}
+ {2336562000 46800 0 +13}
+ {2361963600 50400 1 +14}
+ {2368011600 46800 0 +13}
+ {2393413200 50400 1 +14}
+ {2400066000 46800 0 +13}
+ {2424862800 50400 1 +14}
+ {2431515600 46800 0 +13}
+ {2456312400 50400 1 +14}
+ {2462965200 46800 0 +13}
+ {2487762000 50400 1 +14}
+ {2494414800 46800 0 +13}
+ {2519816400 50400 1 +14}
+ {2525864400 46800 0 +13}
+ {2551266000 50400 1 +14}
+ {2557314000 46800 0 +13}
+ {2582715600 50400 1 +14}
+ {2589368400 46800 0 +13}
+ {2614165200 50400 1 +14}
+ {2620818000 46800 0 +13}
+ {2645614800 50400 1 +14}
+ {2652267600 46800 0 +13}
+ {2677064400 50400 1 +14}
+ {2683717200 46800 0 +13}
+ {2709118800 50400 1 +14}
+ {2715166800 46800 0 +13}
+ {2740568400 50400 1 +14}
+ {2747221200 46800 0 +13}
+ {2772018000 50400 1 +14}
+ {2778670800 46800 0 +13}
+ {2803467600 50400 1 +14}
+ {2810120400 46800 0 +13}
+ {2834917200 50400 1 +14}
+ {2841570000 46800 0 +13}
+ {2866971600 50400 1 +14}
+ {2873019600 46800 0 +13}
+ {2898421200 50400 1 +14}
+ {2904469200 46800 0 +13}
+ {2929870800 50400 1 +14}
+ {2936523600 46800 0 +13}
+ {2961320400 50400 1 +14}
+ {2967973200 46800 0 +13}
+ {2992770000 50400 1 +14}
+ {2999422800 46800 0 +13}
+ {3024219600 50400 1 +14}
+ {3030872400 46800 0 +13}
+ {3056274000 50400 1 +14}
+ {3062322000 46800 0 +13}
+ {3087723600 50400 1 +14}
+ {3093771600 46800 0 +13}
+ {3119173200 50400 1 +14}
+ {3125826000 46800 0 +13}
+ {3150622800 50400 1 +14}
+ {3157275600 46800 0 +13}
+ {3182072400 50400 1 +14}
+ {3188725200 46800 0 +13}
+ {3213522000 50400 1 +14}
+ {3220174800 46800 0 +13}
+ {3245576400 50400 1 +14}
+ {3251624400 46800 0 +13}
+ {3277026000 50400 1 +14}
+ {3283678800 46800 0 +13}
+ {3308475600 50400 1 +14}
+ {3315128400 46800 0 +13}
+ {3339925200 50400 1 +14}
+ {3346578000 46800 0 +13}
+ {3371374800 50400 1 +14}
+ {3378027600 46800 0 +13}
+ {3403429200 50400 1 +14}
+ {3409477200 46800 0 +13}
+ {3434878800 50400 1 +14}
+ {3440926800 46800 0 +13}
+ {3466328400 50400 1 +14}
+ {3472981200 46800 0 +13}
+ {3497778000 50400 1 +14}
+ {3504430800 46800 0 +13}
+ {3529227600 50400 1 +14}
+ {3535880400 46800 0 +13}
+ {3560677200 50400 1 +14}
+ {3567330000 46800 0 +13}
+ {3592731600 50400 1 +14}
+ {3598779600 46800 0 +13}
+ {3624181200 50400 1 +14}
+ {3630834000 46800 0 +13}
+ {3655630800 50400 1 +14}
+ {3662283600 46800 0 +13}
+ {3687080400 50400 1 +14}
+ {3693733200 46800 0 +13}
+ {3718530000 50400 1 +14}
+ {3725182800 46800 0 +13}
+ {3750584400 50400 1 +14}
+ {3756632400 46800 0 +13}
+ {3782034000 50400 1 +14}
+ {3788082000 46800 0 +13}
+ {3813483600 50400 1 +14}
+ {3820136400 46800 0 +13}
+ {3844933200 50400 1 +14}
+ {3851586000 46800 0 +13}
+ {3876382800 50400 1 +14}
+ {3883035600 46800 0 +13}
+ {3907832400 50400 1 +14}
+ {3914485200 46800 0 +13}
+ {3939886800 50400 1 +14}
+ {3945934800 46800 0 +13}
+ {3971336400 50400 1 +14}
+ {3977384400 46800 0 +13}
+ {4002786000 50400 1 +14}
+ {4009438800 46800 0 +13}
+ {4034235600 50400 1 +14}
+ {4040888400 46800 0 +13}
+ {4065685200 50400 1 +14}
+ {4072338000 46800 0 +13}
+ {4097134800 50400 1 +14}
}
diff --git a/library/tzdata/Pacific/Wake b/library/tzdata/Pacific/Wake
index 5afedf5..67eab37 100644
--- a/library/tzdata/Pacific/Wake
+++ b/library/tzdata/Pacific/Wake
@@ -2,5 +2,5 @@
set TZData(:Pacific/Wake) {
{-9223372036854775808 39988 0 LMT}
- {-2177492788 43200 0 WAKT}
+ {-2177492788 43200 0 +12}
}
diff --git a/library/tzdata/Pacific/Wallis b/library/tzdata/Pacific/Wallis
index 7bdd964..152e6af 100644
--- a/library/tzdata/Pacific/Wallis
+++ b/library/tzdata/Pacific/Wallis
@@ -2,5 +2,5 @@
set TZData(:Pacific/Wallis) {
{-9223372036854775808 44120 0 LMT}
- {-2177496920 43200 0 WFT}
+ {-2177496920 43200 0 +12}
}
diff --git a/libtommath/LICENSE b/libtommath/LICENSE
index 5baa792..a75014d 100644
--- a/libtommath/LICENSE
+++ b/libtommath/LICENSE
@@ -1,4 +1,29 @@
-LibTomMath is hereby released into the Public Domain.
+LibTomMath is licensed under DUAL licensing terms.
--- Tom St Denis
+Choose and use the license of your needs.
+[LICENSE #1]
+
+LibTomMath is public domain. As should all quality software be.
+
+Tom St Denis
+
+[/LICENSE #1]
+
+[LICENSE #2]
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+[/LICENSE #2]
diff --git a/libtommath/bn.ilg b/libtommath/bn.ilg
deleted file mode 100644
index 3c859f0..0000000
--- a/libtommath/bn.ilg
+++ /dev/null
@@ -1,6 +0,0 @@
-This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
-Scanning input file bn.idx....done (79 entries accepted, 0 rejected).
-Sorting entries....done (511 comparisons).
-Generating output file bn.ind....done (82 lines written, 0 warnings).
-Output written in bn.ind.
-Transcript written in bn.ilg.
diff --git a/libtommath/bn.ind b/libtommath/bn.ind
deleted file mode 100644
index e5f7d4a..0000000
--- a/libtommath/bn.ind
+++ /dev/null
@@ -1,82 +0,0 @@
-\begin{theindex}
-
- \item mp\_add, \hyperpage{29}
- \item mp\_add\_d, \hyperpage{52}
- \item mp\_and, \hyperpage{29}
- \item mp\_clear, \hyperpage{11}
- \item mp\_clear\_multi, \hyperpage{12}
- \item mp\_cmp, \hyperpage{24}
- \item mp\_cmp\_d, \hyperpage{25}
- \item mp\_cmp\_mag, \hyperpage{23}
- \item mp\_div, \hyperpage{30}
- \item mp\_div\_2, \hyperpage{26}
- \item mp\_div\_2d, \hyperpage{28}
- \item mp\_div\_d, \hyperpage{52}
- \item mp\_dr\_reduce, \hyperpage{40}
- \item mp\_dr\_setup, \hyperpage{40}
- \item MP\_EQ, \hyperpage{22}
- \item mp\_error\_to\_string, \hyperpage{10}
- \item mp\_expt\_d, \hyperpage{43}
- \item mp\_exptmod, \hyperpage{43}
- \item mp\_exteuclid, \hyperpage{51}
- \item mp\_gcd, \hyperpage{51}
- \item mp\_get\_int, \hyperpage{20}
- \item mp\_grow, \hyperpage{16}
- \item MP\_GT, \hyperpage{22}
- \item mp\_init, \hyperpage{11}
- \item mp\_init\_copy, \hyperpage{13}
- \item mp\_init\_multi, \hyperpage{12}
- \item mp\_init\_set, \hyperpage{21}
- \item mp\_init\_set\_int, \hyperpage{21}
- \item mp\_init\_size, \hyperpage{14}
- \item mp\_int, \hyperpage{10}
- \item mp\_invmod, \hyperpage{52}
- \item mp\_jacobi, \hyperpage{52}
- \item mp\_lcm, \hyperpage{51}
- \item mp\_lshd, \hyperpage{28}
- \item MP\_LT, \hyperpage{22}
- \item MP\_MEM, \hyperpage{9}
- \item mp\_mod, \hyperpage{35}
- \item mp\_mod\_d, \hyperpage{52}
- \item mp\_montgomery\_calc\_normalization, \hyperpage{38}
- \item mp\_montgomery\_reduce, \hyperpage{37}
- \item mp\_montgomery\_setup, \hyperpage{37}
- \item mp\_mul, \hyperpage{31}
- \item mp\_mul\_2, \hyperpage{26}
- \item mp\_mul\_2d, \hyperpage{28}
- \item mp\_mul\_d, \hyperpage{52}
- \item mp\_n\_root, \hyperpage{44}
- \item mp\_neg, \hyperpage{29}
- \item MP\_NO, \hyperpage{9}
- \item MP\_OKAY, \hyperpage{9}
- \item mp\_or, \hyperpage{29}
- \item mp\_prime\_fermat, \hyperpage{45}
- \item mp\_prime\_is\_divisible, \hyperpage{45}
- \item mp\_prime\_is\_prime, \hyperpage{46}
- \item mp\_prime\_miller\_rabin, \hyperpage{45}
- \item mp\_prime\_next\_prime, \hyperpage{46}
- \item mp\_prime\_rabin\_miller\_trials, \hyperpage{46}
- \item mp\_prime\_random, \hyperpage{47}
- \item mp\_prime\_random\_ex, \hyperpage{47}
- \item mp\_radix\_size, \hyperpage{49}
- \item mp\_read\_radix, \hyperpage{49}
- \item mp\_read\_unsigned\_bin, \hyperpage{50}
- \item mp\_reduce, \hyperpage{36}
- \item mp\_reduce\_2k, \hyperpage{41}
- \item mp\_reduce\_2k\_setup, \hyperpage{41}
- \item mp\_reduce\_setup, \hyperpage{36}
- \item mp\_rshd, \hyperpage{28}
- \item mp\_set, \hyperpage{19}
- \item mp\_set\_int, \hyperpage{20}
- \item mp\_shrink, \hyperpage{15}
- \item mp\_sqr, \hyperpage{33}
- \item mp\_sub, \hyperpage{29}
- \item mp\_sub\_d, \hyperpage{52}
- \item mp\_to\_unsigned\_bin, \hyperpage{50}
- \item mp\_toradix, \hyperpage{49}
- \item mp\_unsigned\_bin\_size, \hyperpage{50}
- \item MP\_VAL, \hyperpage{9}
- \item mp\_xor, \hyperpage{29}
- \item MP\_YES, \hyperpage{9}
-
-\end{theindex}
diff --git a/libtommath/bn.pdf b/libtommath/bn.pdf
deleted file mode 100644
index 392b649..0000000
--- a/libtommath/bn.pdf
+++ /dev/null
Binary files differ
diff --git a/libtommath/bn.tex b/libtommath/bn.tex
deleted file mode 100644
index e8eb994..0000000
--- a/libtommath/bn.tex
+++ /dev/null
@@ -1,1835 +0,0 @@
-\documentclass[b5paper]{book}
-\usepackage{hyperref}
-\usepackage{makeidx}
-\usepackage{amssymb}
-\usepackage{color}
-\usepackage{alltt}
-\usepackage{graphicx}
-\usepackage{layout}
-\def\union{\cup}
-\def\intersect{\cap}
-\def\getsrandom{\stackrel{\rm R}{\gets}}
-\def\cross{\times}
-\def\cat{\hspace{0.5em} \| \hspace{0.5em}}
-\def\catn{$\|$}
-\def\divides{\hspace{0.3em} | \hspace{0.3em}}
-\def\nequiv{\not\equiv}
-\def\approx{\raisebox{0.2ex}{\mbox{\small $\sim$}}}
-\def\lcm{{\rm lcm}}
-\def\gcd{{\rm gcd}}
-\def\log{{\rm log}}
-\def\ord{{\rm ord}}
-\def\abs{{\mathit abs}}
-\def\rep{{\mathit rep}}
-\def\mod{{\mathit\ mod\ }}
-\renewcommand{\pmod}[1]{\ ({\rm mod\ }{#1})}
-\newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor}
-\newcommand{\ceil}[1]{\left\lceil{#1}\right\rceil}
-\def\Or{{\rm\ or\ }}
-\def\And{{\rm\ and\ }}
-\def\iff{\hspace{1em}\Longleftrightarrow\hspace{1em}}
-\def\implies{\Rightarrow}
-\def\undefined{{\rm ``undefined"}}
-\def\Proof{\vspace{1ex}\noindent {\bf Proof:}\hspace{1em}}
-\let\oldphi\phi
-\def\phi{\varphi}
-\def\Pr{{\rm Pr}}
-\newcommand{\str}[1]{{\mathbf{#1}}}
-\def\F{{\mathbb F}}
-\def\N{{\mathbb N}}
-\def\Z{{\mathbb Z}}
-\def\R{{\mathbb R}}
-\def\C{{\mathbb C}}
-\def\Q{{\mathbb Q}}
-\definecolor{DGray}{gray}{0.5}
-\newcommand{\emailaddr}[1]{\mbox{$<${#1}$>$}}
-\def\twiddle{\raisebox{0.3ex}{\mbox{\tiny $\sim$}}}
-\def\gap{\vspace{0.5ex}}
-\makeindex
-\begin{document}
-\frontmatter
-\pagestyle{empty}
-\title{LibTomMath User Manual \\ v0.39}
-\author{Tom St Denis \\ tomstdenis@iahu.ca}
-\maketitle
-This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
-formatted for B5 [176x250] paper using the \LaTeX{} {\em book} macro package.
-
-\vspace{10cm}
-
-\begin{flushright}Open Source. Open Academia. Open Minds.
-
-\mbox{ }
-
-Tom St Denis,
-
-Ontario, Canada
-\end{flushright}
-
-\tableofcontents
-\listoffigures
-\mainmatter
-\pagestyle{headings}
-\chapter{Introduction}
-\section{What is LibTomMath?}
-LibTomMath is a library of source code which provides a series of efficient and carefully written functions for manipulating
-large integer numbers. It was written in portable ISO C source code so that it will build on any platform with a conforming
-C compiler.
-
-In a nutshell the library was written from scratch with verbose comments to help instruct computer science students how
-to implement ``bignum'' math. However, the resulting code has proven to be very useful. It has been used by numerous
-universities, commercial and open source software developers. It has been used on a variety of platforms ranging from
-Linux and Windows based x86 to ARM based Gameboys and PPC based MacOS machines.
-
-\section{License}
-As of the v0.25 the library source code has been placed in the public domain with every new release. As of the v0.28
-release the textbook ``Implementing Multiple Precision Arithmetic'' has been placed in the public domain with every new
-release as well. This textbook is meant to compliment the project by providing a more solid walkthrough of the development
-algorithms used in the library.
-
-Since both\footnote{Note that the MPI files under mtest/ are copyrighted by Michael Fromberger. They are not required to use LibTomMath.} are in the
-public domain everyone is entitled to do with them as they see fit.
-
-\section{Building LibTomMath}
-
-LibTomMath is meant to be very ``GCC friendly'' as it comes with a makefile well suited for GCC. However, the library will
-also build in MSVC, Borland C out of the box. For any other ISO C compiler a makefile will have to be made by the end
-developer.
-
-\subsection{Static Libraries}
-To build as a static library for GCC issue the following
-\begin{alltt}
-make
-\end{alltt}
-
-command. This will build the library and archive the object files in ``libtommath.a''. Now you link against
-that and include ``tommath.h'' within your programs. Alternatively to build with MSVC issue the following
-\begin{alltt}
-nmake -f makefile.msvc
-\end{alltt}
-
-This will build the library and archive the object files in ``tommath.lib''. This has been tested with MSVC
-version 6.00 with service pack 5.
-
-\subsection{Shared Libraries}
-To build as a shared library for GCC issue the following
-\begin{alltt}
-make -f makefile.shared
-\end{alltt}
-This requires the ``libtool'' package (common on most Linux/BSD systems). It will build LibTomMath as both shared
-and static then install (by default) into /usr/lib as well as install the header files in /usr/include. The shared
-library (resource) will be called ``libtommath.la'' while the static library called ``libtommath.a''. Generally
-you use libtool to link your application against the shared object.
-
-There is limited support for making a ``DLL'' in windows via the ``makefile.cygwin\_dll'' makefile. It requires
-Cygwin to work with since it requires the auto-export/import functionality. The resulting DLL and import library
-``libtommath.dll.a'' can be used to link LibTomMath dynamically to any Windows program using Cygwin.
-
-\subsection{Testing}
-To build the library and the test harness type
-
-\begin{alltt}
-make test
-\end{alltt}
-
-This will build the library, ``test'' and ``mtest/mtest''. The ``test'' program will accept test vectors and verify the
-results. ``mtest/mtest'' will generate test vectors using the MPI library by Michael Fromberger\footnote{A copy of MPI
-is included in the package}. Simply pipe mtest into test using
-
-\begin{alltt}
-mtest/mtest | test
-\end{alltt}
-
-If you do not have a ``/dev/urandom'' style RNG source you will have to write your own PRNG and simply pipe that into
-mtest. For example, if your PRNG program is called ``myprng'' simply invoke
-
-\begin{alltt}
-myprng | mtest/mtest | test
-\end{alltt}
-
-This will output a row of numbers that are increasing. Each column is a different test (such as addition, multiplication, etc)
-that is being performed. The numbers represent how many times the test was invoked. If an error is detected the program
-will exit with a dump of the relevent numbers it was working with.
-
-\section{Build Configuration}
-LibTomMath can configured at build time in three phases we shall call ``depends'', ``tweaks'' and ``trims''.
-Each phase changes how the library is built and they are applied one after another respectively.
-
-To make the system more powerful you can tweak the build process. Classes are defined in the file
-``tommath\_superclass.h''. By default, the symbol ``LTM\_ALL'' shall be defined which simply
-instructs the system to build all of the functions. This is how LibTomMath used to be packaged. This will give you
-access to every function LibTomMath offers.
-
-However, there are cases where such a build is not optional. For instance, you want to perform RSA operations. You
-don't need the vast majority of the library to perform these operations. Aside from LTM\_ALL there is
-another pre--defined class ``SC\_RSA\_1'' which works in conjunction with the RSA from LibTomCrypt. Additional
-classes can be defined base on the need of the user.
-
-\subsection{Build Depends}
-In the file tommath\_class.h you will see a large list of C ``defines'' followed by a series of ``ifdefs''
-which further define symbols. All of the symbols (technically they're macros $\ldots$) represent a given C source
-file. For instance, BN\_MP\_ADD\_C represents the file ``bn\_mp\_add.c''. When a define has been enabled the
-function in the respective file will be compiled and linked into the library. Accordingly when the define
-is absent the file will not be compiled and not contribute any size to the library.
-
-You will also note that the header tommath\_class.h is actually recursively included (it includes itself twice).
-This is to help resolve as many dependencies as possible. In the last pass the symbol LTM\_LAST will be defined.
-This is useful for ``trims''.
-
-\subsection{Build Tweaks}
-A tweak is an algorithm ``alternative''. For example, to provide tradeoffs (usually between size and space).
-They can be enabled at any pass of the configuration phase.
-
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|l|}
-\hline \textbf{Define} & \textbf{Purpose} \\
-\hline BN\_MP\_DIV\_SMALL & Enables a slower, smaller and equally \\
- & functional mp\_div() function \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-
-\subsection{Build Trims}
-A trim is a manner of removing functionality from a function that is not required. For instance, to perform
-RSA cryptography you only require exponentiation with odd moduli so even moduli support can be safely removed.
-Build trims are meant to be defined on the last pass of the configuration which means they are to be defined
-only if LTM\_LAST has been defined.
-
-\subsubsection{Moduli Related}
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|l|}
-\hline \textbf{Restriction} & \textbf{Undefine} \\
-\hline Exponentiation with odd moduli only & BN\_S\_MP\_EXPTMOD\_C \\
- & BN\_MP\_REDUCE\_C \\
- & BN\_MP\_REDUCE\_SETUP\_C \\
- & BN\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
- & BN\_FAST\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
-\hline Exponentiation with random odd moduli & (The above plus the following) \\
- & BN\_MP\_REDUCE\_2K\_C \\
- & BN\_MP\_REDUCE\_2K\_SETUP\_C \\
- & BN\_MP\_REDUCE\_IS\_2K\_C \\
- & BN\_MP\_DR\_IS\_MODULUS\_C \\
- & BN\_MP\_DR\_REDUCE\_C \\
- & BN\_MP\_DR\_SETUP\_C \\
-\hline Modular inverse odd moduli only & BN\_MP\_INVMOD\_SLOW\_C \\
-\hline Modular inverse (both, smaller/slower) & BN\_FAST\_MP\_INVMOD\_C \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-
-\subsubsection{Operand Size Related}
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|l|}
-\hline \textbf{Restriction} & \textbf{Undefine} \\
-\hline Moduli $\le 2560$ bits & BN\_MP\_MONTGOMERY\_REDUCE\_C \\
- & BN\_S\_MP\_MUL\_DIGS\_C \\
- & BN\_S\_MP\_MUL\_HIGH\_DIGS\_C \\
- & BN\_S\_MP\_SQR\_C \\
-\hline Polynomial Schmolynomial & BN\_MP\_KARATSUBA\_MUL\_C \\
- & BN\_MP\_KARATSUBA\_SQR\_C \\
- & BN\_MP\_TOOM\_MUL\_C \\
- & BN\_MP\_TOOM\_SQR\_C \\
-
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-
-
-\section{Purpose of LibTomMath}
-Unlike GNU MP (GMP) Library, LIP, OpenSSL or various other commercial kits (Miracl), LibTomMath was not written with
-bleeding edge performance in mind. First and foremost LibTomMath was written to be entirely open. Not only is the
-source code public domain (unlike various other GPL/etc licensed code), not only is the code freely downloadable but the
-source code is also accessible for computer science students attempting to learn ``BigNum'' or multiple precision
-arithmetic techniques.
-
-LibTomMath was written to be an instructive collection of source code. This is why there are many comments, only one
-function per source file and often I use a ``middle-road'' approach where I don't cut corners for an extra 2\% speed
-increase.
-
-Source code alone cannot really teach how the algorithms work which is why I also wrote a textbook that accompanies
-the library (beat that!).
-
-So you may be thinking ``should I use LibTomMath?'' and the answer is a definite maybe. Let me tabulate what I think
-are the pros and cons of LibTomMath by comparing it to the math routines from GnuPG\footnote{GnuPG v1.2.3 versus LibTomMath v0.28}.
-
-\newpage\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|c|c|l|}
-\hline \textbf{Criteria} & \textbf{Pro} & \textbf{Con} & \textbf{Notes} \\
-\hline Few lines of code per file & X & & GnuPG $ = 300.9$, LibTomMath $ = 71.97$ \\
-\hline Commented function prototypes & X && GnuPG function names are cryptic. \\
-\hline Speed && X & LibTomMath is slower. \\
-\hline Totally free & X & & GPL has unfavourable restrictions.\\
-\hline Large function base & X & & GnuPG is barebones. \\
-\hline Five modular reduction algorithms & X & & Faster modular exponentiation for a variety of moduli. \\
-\hline Portable & X & & GnuPG requires configuration to build. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{LibTomMath Valuation}
-\end{figure}
-
-It may seem odd to compare LibTomMath to GnuPG since the math in GnuPG is only a small portion of the entire application.
-However, LibTomMath was written with cryptography in mind. It provides essentially all of the functions a cryptosystem
-would require when working with large integers.
-
-So it may feel tempting to just rip the math code out of GnuPG (or GnuMP where it was taken from originally) in your
-own application but I think there are reasons not to. While LibTomMath is slower than libraries such as GnuMP it is
-not normally significantly slower. On x86 machines the difference is normally a factor of two when performing modular
-exponentiations. It depends largely on the processor, compiler and the moduli being used.
-
-Essentially the only time you wouldn't use LibTomMath is when blazing speed is the primary concern. However,
-on the other side of the coin LibTomMath offers you a totally free (public domain) well structured math library
-that is very flexible, complete and performs well in resource contrained environments. Fast RSA for example can
-be performed with as little as 8KB of ram for data (again depending on build options).
-
-\chapter{Getting Started with LibTomMath}
-\section{Building Programs}
-In order to use LibTomMath you must include ``tommath.h'' and link against the appropriate library file (typically
-libtommath.a). There is no library initialization required and the entire library is thread safe.
-
-\section{Return Codes}
-There are three possible return codes a function may return.
-
-\index{MP\_OKAY}\index{MP\_YES}\index{MP\_NO}\index{MP\_VAL}\index{MP\_MEM}
-\begin{figure}[here!]
-\begin{center}
-\begin{small}
-\begin{tabular}{|l|l|}
-\hline \textbf{Code} & \textbf{Meaning} \\
-\hline MP\_OKAY & The function succeeded. \\
-\hline MP\_VAL & The function input was invalid. \\
-\hline MP\_MEM & Heap memory exhausted. \\
-\hline &\\
-\hline MP\_YES & Response is yes. \\
-\hline MP\_NO & Response is no. \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Return Codes}
-\end{figure}
-
-The last two codes listed are not actually ``return'ed'' by a function. They are placed in an integer (the caller must
-provide the address of an integer it can store to) which the caller can access. To convert one of the three return codes
-to a string use the following function.
-
-\index{mp\_error\_to\_string}
-\begin{alltt}
-char *mp_error_to_string(int code);
-\end{alltt}
-
-This will return a pointer to a string which describes the given error code. It will not work for the return codes
-MP\_YES and MP\_NO.
-
-\section{Data Types}
-The basic ``multiple precision integer'' type is known as the ``mp\_int'' within LibTomMath. This data type is used to
-organize all of the data required to manipulate the integer it represents. Within LibTomMath it has been prototyped
-as the following.
-
-\index{mp\_int}
-\begin{alltt}
-typedef struct \{
- int used, alloc, sign;
- mp_digit *dp;
-\} mp_int;
-\end{alltt}
-
-Where ``mp\_digit'' is a data type that represents individual digits of the integer. By default, an mp\_digit is the
-ISO C ``unsigned long'' data type and each digit is $28-$bits long. The mp\_digit type can be configured to suit other
-platforms by defining the appropriate macros.
-
-All LTM functions that use the mp\_int type will expect a pointer to mp\_int structure. You must allocate memory to
-hold the structure itself by yourself (whether off stack or heap it doesn't matter). The very first thing that must be
-done to use an mp\_int is that it must be initialized.
-
-\section{Function Organization}
-
-The arithmetic functions of the library are all organized to have the same style prototype. That is source operands
-are passed on the left and the destination is on the right. For instance,
-
-\begin{alltt}
-mp_add(&a, &b, &c); /* c = a + b */
-mp_mul(&a, &a, &c); /* c = a * a */
-mp_div(&a, &b, &c, &d); /* c = [a/b], d = a mod b */
-\end{alltt}
-
-Another feature of the way the functions have been implemented is that source operands can be destination operands as well.
-For instance,
-
-\begin{alltt}
-mp_add(&a, &b, &b); /* b = a + b */
-mp_div(&a, &b, &a, &c); /* a = [a/b], c = a mod b */
-\end{alltt}
-
-This allows operands to be re-used which can make programming simpler.
-
-\section{Initialization}
-\subsection{Single Initialization}
-A single mp\_int can be initialized with the ``mp\_init'' function.
-
-\index{mp\_init}
-\begin{alltt}
-int mp_init (mp_int * a);
-\end{alltt}
-
-This function expects a pointer to an mp\_int structure and will initialize the members of the structure so the mp\_int
-represents the default integer which is zero. If the functions returns MP\_OKAY then the mp\_int is ready to be used
-by the other LibTomMath functions.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the number */
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\subsection{Single Free}
-When you are finished with an mp\_int it is ideal to return the heap it used back to the system. The following function
-provides this functionality.
-
-\index{mp\_clear}
-\begin{alltt}
-void mp_clear (mp_int * a);
-\end{alltt}
-
-The function expects a pointer to a previously initialized mp\_int structure and frees the heap it uses. It sets the
-pointer\footnote{The ``dp'' member.} within the mp\_int to \textbf{NULL} which is used to prevent double free situations.
-Is is legal to call mp\_clear() twice on the same mp\_int in a row.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the number */
-
- /* We're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\subsection{Multiple Initializations}
-Certain algorithms require more than one large integer. In these instances it is ideal to initialize all of the mp\_int
-variables in an ``all or nothing'' fashion. That is, they are either all initialized successfully or they are all
-not initialized.
-
-The mp\_init\_multi() function provides this functionality.
-
-\index{mp\_init\_multi} \index{mp\_clear\_multi}
-\begin{alltt}
-int mp_init_multi(mp_int *mp, ...);
-\end{alltt}
-
-It accepts a \textbf{NULL} terminated list of pointers to mp\_int structures. It will attempt to initialize them all
-at once. If the function returns MP\_OKAY then all of the mp\_int variables are ready to use, otherwise none of them
-are available for use. A complementary mp\_clear\_multi() function allows multiple mp\_int variables to be free'd
-from the heap at the same time.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int num1, num2, num3;
- int result;
-
- if ((result = mp_init_multi(&num1,
- &num2,
- &num3, NULL)) != MP\_OKAY) \{
- printf("Error initializing the numbers. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the numbers */
-
- /* We're done with them. */
- mp_clear_multi(&num1, &num2, &num3, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\subsection{Other Initializers}
-To initialized and make a copy of an mp\_int the mp\_init\_copy() function has been provided.
-
-\index{mp\_init\_copy}
-\begin{alltt}
-int mp_init_copy (mp_int * a, mp_int * b);
-\end{alltt}
-
-This function will initialize $a$ and make it a copy of $b$ if all goes well.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int num1, num2;
- int result;
-
- /* initialize and do work on num1 ... */
-
- /* We want a copy of num1 in num2 now */
- if ((result = mp_init_copy(&num2, &num1)) != MP_OKAY) \{
- printf("Error initializing the copy. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now num2 is ready and contains a copy of num1 */
-
- /* We're done with them. */
- mp_clear_multi(&num1, &num2, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-Another less common initializer is mp\_init\_size() which allows the user to initialize an mp\_int with a given
-default number of digits. By default, all initializers allocate \textbf{MP\_PREC} digits. This function lets
-you override this behaviour.
-
-\index{mp\_init\_size}
-\begin{alltt}
-int mp_init_size (mp_int * a, int size);
-\end{alltt}
-
-The $size$ parameter must be greater than zero. If the function succeeds the mp\_int $a$ will be initialized
-to have $size$ digits (which are all initially zero).
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- /* we need a 60-digit number */
- if ((result = mp_init_size(&number, 60)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the number */
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\section{Maintenance Functions}
-
-\subsection{Reducing Memory Usage}
-When an mp\_int is in a state where it won't be changed again\footnote{A Diffie-Hellman modulus for instance.} excess
-digits can be removed to return memory to the heap with the mp\_shrink() function.
-
-\index{mp\_shrink}
-\begin{alltt}
-int mp_shrink (mp_int * a);
-\end{alltt}
-
-This will remove excess digits of the mp\_int $a$. If the operation fails the mp\_int should be intact without the
-excess digits being removed. Note that you can use a shrunk mp\_int in further computations, however, such operations
-will require heap operations which can be slow. It is not ideal to shrink mp\_int variables that you will further
-modify in the system (unless you are seriously low on memory).
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the number [e.g. pre-computation] */
-
- /* We're done with it for now. */
- if ((result = mp_shrink(&number)) != MP_OKAY) \{
- printf("Error shrinking the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use it .... */
-
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\subsection{Adding additional digits}
-
-Within the mp\_int structure are two parameters which control the limitations of the array of digits that represent
-the integer the mp\_int is meant to equal. The \textit{used} parameter dictates how many digits are significant, that is,
-contribute to the value of the mp\_int. The \textit{alloc} parameter dictates how many digits are currently available in
-the array. If you need to perform an operation that requires more digits you will have to mp\_grow() the mp\_int to
-your desired size.
-
-\index{mp\_grow}
-\begin{alltt}
-int mp_grow (mp_int * a, int size);
-\end{alltt}
-
-This will grow the array of digits of $a$ to $size$. If the \textit{alloc} parameter is already bigger than
-$size$ the function will not do anything.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* use the number */
-
- /* We need to add 20 digits to the number */
- if ((result = mp_grow(&number, number.alloc + 20)) != MP_OKAY) \{
- printf("Error growing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
-
- /* use the number */
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\chapter{Basic Operations}
-\section{Small Constants}
-Setting mp\_ints to small constants is a relatively common operation. To accomodate these instances there are two
-small constant assignment functions. The first function is used to set a single digit constant while the second sets
-an ISO C style ``unsigned long'' constant. The reason for both functions is efficiency. Setting a single digit is quick but the
-domain of a digit can change (it's always at least $0 \ldots 127$).
-
-\subsection{Single Digit}
-
-Setting a single digit can be accomplished with the following function.
-
-\index{mp\_set}
-\begin{alltt}
-void mp_set (mp_int * a, mp_digit b);
-\end{alltt}
-
-This will zero the contents of $a$ and make it represent an integer equal to the value of $b$. Note that this
-function has a return type of \textbf{void}. It cannot cause an error so it is safe to assume the function
-succeeded.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number to 5 */
- mp_set(&number, 5);
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-\subsection{Long Constants}
-
-To set a constant that is the size of an ISO C ``unsigned long'' and larger than a single digit the following function
-can be used.
-
-\index{mp\_set\_int}
-\begin{alltt}
-int mp_set_int (mp_int * a, unsigned long b);
-\end{alltt}
-
-This will assign the value of the 32-bit variable $b$ to the mp\_int $a$. Unlike mp\_set() this function will always
-accept a 32-bit input regardless of the size of a single digit. However, since the value may span several digits
-this function can fail if it runs out of heap memory.
-
-To get the ``unsigned long'' copy of an mp\_int the following function can be used.
-
-\index{mp\_get\_int}
-\begin{alltt}
-unsigned long mp_get_int (mp_int * a);
-\end{alltt}
-
-This will return the 32 least significant bits of the mp\_int $a$.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number to 654321 (note this is bigger than 127) */
- if ((result = mp_set_int(&number, 654321)) != MP_OKAY) \{
- printf("Error setting the value of the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- printf("number == \%lu", mp_get_int(&number));
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-This should output the following if the program succeeds.
-
-\begin{alltt}
-number == 654321
-\end{alltt}
-
-\subsection{Initialize and Setting Constants}
-To both initialize and set small constants the following two functions are available.
-\index{mp\_init\_set} \index{mp\_init\_set\_int}
-\begin{alltt}
-int mp_init_set (mp_int * a, mp_digit b);
-int mp_init_set_int (mp_int * a, unsigned long b);
-\end{alltt}
-
-Both functions work like the previous counterparts except they first mp\_init $a$ before setting the values.
-
-\begin{alltt}
-int main(void)
-\{
- mp_int number1, number2;
- int result;
-
- /* initialize and set a single digit */
- if ((result = mp_init_set(&number1, 100)) != MP_OKAY) \{
- printf("Error setting number1: \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* initialize and set a long */
- if ((result = mp_init_set_int(&number2, 1023)) != MP_OKAY) \{
- printf("Error setting number2: \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* display */
- printf("Number1, Number2 == \%lu, \%lu",
- mp_get_int(&number1), mp_get_int(&number2));
-
- /* clear */
- mp_clear_multi(&number1, &number2, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt}
-
-If this program succeeds it shall output.
-\begin{alltt}
-Number1, Number2 == 100, 1023
-\end{alltt}
-
-\section{Comparisons}
-
-Comparisons in LibTomMath are always performed in a ``left to right'' fashion. There are three possible return codes
-for any comparison.
-
-\index{MP\_GT} \index{MP\_EQ} \index{MP\_LT}
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|c|c|}
-\hline \textbf{Result Code} & \textbf{Meaning} \\
-\hline MP\_GT & $a > b$ \\
-\hline MP\_EQ & $a = b$ \\
-\hline MP\_LT & $a < b$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Comparison Codes for $a, b$}
-\label{fig:CMP}
-\end{figure}
-
-In figure \ref{fig:CMP} two integers $a$ and $b$ are being compared. In this case $a$ is said to be ``to the left'' of
-$b$.
-
-\subsection{Unsigned comparison}
-
-An unsigned comparison considers only the digits themselves and not the associated \textit{sign} flag of the
-mp\_int structures. This is analogous to an absolute comparison. The function mp\_cmp\_mag() will compare two
-mp\_int variables based on their digits only.
-
-\index{mp\_cmp\_mag}
-\begin{alltt}
-int mp_cmp_mag(mp_int * a, mp_int * b);
-\end{alltt}
-This will compare $a$ to $b$ placing $a$ to the left of $b$. This function cannot fail and will return one of the
-three compare codes listed in figure \ref{fig:CMP}.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number1, number2;
- int result;
-
- if ((result = mp_init_multi(&number1, &number2, NULL)) != MP_OKAY) \{
- printf("Error initializing the numbers. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number1 to 5 */
- mp_set(&number1, 5);
-
- /* set the number2 to -6 */
- mp_set(&number2, 6);
- if ((result = mp_neg(&number2, &number2)) != MP_OKAY) \{
- printf("Error negating number2. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- switch(mp_cmp_mag(&number1, &number2)) \{
- case MP_GT: printf("|number1| > |number2|"); break;
- case MP_EQ: printf("|number1| = |number2|"); break;
- case MP_LT: printf("|number1| < |number2|"); break;
- \}
-
- /* we're done with it. */
- mp_clear_multi(&number1, &number2, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-If this program\footnote{This function uses the mp\_neg() function which is discussed in section \ref{sec:NEG}.} completes
-successfully it should print the following.
-
-\begin{alltt}
-|number1| < |number2|
-\end{alltt}
-
-This is because $\vert -6 \vert = 6$ and obviously $5 < 6$.
-
-\subsection{Signed comparison}
-
-To compare two mp\_int variables based on their signed value the mp\_cmp() function is provided.
-
-\index{mp\_cmp}
-\begin{alltt}
-int mp_cmp(mp_int * a, mp_int * b);
-\end{alltt}
-
-This will compare $a$ to the left of $b$. It will first compare the signs of the two mp\_int variables. If they
-differ it will return immediately based on their signs. If the signs are equal then it will compare the digits
-individually. This function will return one of the compare conditions codes listed in figure \ref{fig:CMP}.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number1, number2;
- int result;
-
- if ((result = mp_init_multi(&number1, &number2, NULL)) != MP_OKAY) \{
- printf("Error initializing the numbers. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number1 to 5 */
- mp_set(&number1, 5);
-
- /* set the number2 to -6 */
- mp_set(&number2, 6);
- if ((result = mp_neg(&number2, &number2)) != MP_OKAY) \{
- printf("Error negating number2. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- switch(mp_cmp(&number1, &number2)) \{
- case MP_GT: printf("number1 > number2"); break;
- case MP_EQ: printf("number1 = number2"); break;
- case MP_LT: printf("number1 < number2"); break;
- \}
-
- /* we're done with it. */
- mp_clear_multi(&number1, &number2, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-If this program\footnote{This function uses the mp\_neg() function which is discussed in section \ref{sec:NEG}.} completes
-successfully it should print the following.
-
-\begin{alltt}
-number1 > number2
-\end{alltt}
-
-\subsection{Single Digit}
-
-To compare a single digit against an mp\_int the following function has been provided.
-
-\index{mp\_cmp\_d}
-\begin{alltt}
-int mp_cmp_d(mp_int * a, mp_digit b);
-\end{alltt}
-
-This will compare $a$ to the left of $b$ using a signed comparison. Note that it will always treat $b$ as
-positive. This function is rather handy when you have to compare against small values such as $1$ (which often
-comes up in cryptography). The function cannot fail and will return one of the tree compare condition codes
-listed in figure \ref{fig:CMP}.
-
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number to 5 */
- mp_set(&number, 5);
-
- switch(mp_cmp_d(&number, 7)) \{
- case MP_GT: printf("number > 7"); break;
- case MP_EQ: printf("number = 7"); break;
- case MP_LT: printf("number < 7"); break;
- \}
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-If this program functions properly it will print out the following.
-
-\begin{alltt}
-number < 7
-\end{alltt}
-
-\section{Logical Operations}
-
-Logical operations are operations that can be performed either with simple shifts or boolean operators such as
-AND, XOR and OR directly. These operations are very quick.
-
-\subsection{Multiplication by two}
-
-Multiplications and divisions by any power of two can be performed with quick logical shifts either left or
-right depending on the operation.
-
-When multiplying or dividing by two a special case routine can be used which are as follows.
-\index{mp\_mul\_2} \index{mp\_div\_2}
-\begin{alltt}
-int mp_mul_2(mp_int * a, mp_int * b);
-int mp_div_2(mp_int * a, mp_int * b);
-\end{alltt}
-
-The former will assign twice $a$ to $b$ while the latter will assign half $a$ to $b$. These functions are fast
-since the shift counts and maskes are hardcoded into the routines.
-
-\begin{small} \begin{alltt}
-int main(void)
-\{
- mp_int number;
- int result;
-
- if ((result = mp_init(&number)) != MP_OKAY) \{
- printf("Error initializing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the number to 5 */
- mp_set(&number, 5);
-
- /* multiply by two */
- if ((result = mp\_mul\_2(&number, &number)) != MP_OKAY) \{
- printf("Error multiplying the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
- switch(mp_cmp_d(&number, 7)) \{
- case MP_GT: printf("2*number > 7"); break;
- case MP_EQ: printf("2*number = 7"); break;
- case MP_LT: printf("2*number < 7"); break;
- \}
-
- /* now divide by two */
- if ((result = mp\_div\_2(&number, &number)) != MP_OKAY) \{
- printf("Error dividing the number. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
- switch(mp_cmp_d(&number, 7)) \{
- case MP_GT: printf("2*number/2 > 7"); break;
- case MP_EQ: printf("2*number/2 = 7"); break;
- case MP_LT: printf("2*number/2 < 7"); break;
- \}
-
- /* we're done with it. */
- mp_clear(&number);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt} \end{small}
-
-If this program is successful it will print out the following text.
-
-\begin{alltt}
-2*number > 7
-2*number/2 < 7
-\end{alltt}
-
-Since $10 > 7$ and $5 < 7$. To multiply by a power of two the following function can be used.
-
-\index{mp\_mul\_2d}
-\begin{alltt}
-int mp_mul_2d(mp_int * a, int b, mp_int * c);
-\end{alltt}
-
-This will multiply $a$ by $2^b$ and store the result in ``c''. If the value of $b$ is less than or equal to
-zero the function will copy $a$ to ``c'' without performing any further actions.
-
-To divide by a power of two use the following.
-
-\index{mp\_div\_2d}
-\begin{alltt}
-int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
-\end{alltt}
-Which will divide $a$ by $2^b$, store the quotient in ``c'' and the remainder in ``d'. If $b \le 0$ then the
-function simply copies $a$ over to ``c'' and zeroes $d$. The variable $d$ may be passed as a \textbf{NULL}
-value to signal that the remainder is not desired.
-
-\subsection{Polynomial Basis Operations}
-
-Strictly speaking the organization of the integers within the mp\_int structures is what is known as a
-``polynomial basis''. This simply means a field element is stored by divisions of a radix. For example, if
-$f(x) = \sum_{i=0}^{k} y_ix^k$ for any vector $\vec y$ then the array of digits in $\vec y$ are said to be
-the polynomial basis representation of $z$ if $f(\beta) = z$ for a given radix $\beta$.
-
-To multiply by the polynomial $g(x) = x$ all you have todo is shift the digits of the basis left one place. The
-following function provides this operation.
-
-\index{mp\_lshd}
-\begin{alltt}
-int mp_lshd (mp_int * a, int b);
-\end{alltt}
-
-This will multiply $a$ in place by $x^b$ which is equivalent to shifting the digits left $b$ places and inserting zeroes
-in the least significant digits. Similarly to divide by a power of $x$ the following function is provided.
-
-\index{mp\_rshd}
-\begin{alltt}
-void mp_rshd (mp_int * a, int b)
-\end{alltt}
-This will divide $a$ in place by $x^b$ and discard the remainder. This function cannot fail as it performs the operations
-in place and no new digits are required to complete it.
-
-\subsection{AND, OR and XOR Operations}
-
-While AND, OR and XOR operations are not typical ``bignum functions'' they can be useful in several instances. The
-three functions are prototyped as follows.
-
-\index{mp\_or} \index{mp\_and} \index{mp\_xor}
-\begin{alltt}
-int mp_or (mp_int * a, mp_int * b, mp_int * c);
-int mp_and (mp_int * a, mp_int * b, mp_int * c);
-int mp_xor (mp_int * a, mp_int * b, mp_int * c);
-\end{alltt}
-
-Which compute $c = a \odot b$ where $\odot$ is one of OR, AND or XOR.
-
-\section{Addition and Subtraction}
-
-To compute an addition or subtraction the following two functions can be used.
-
-\index{mp\_add} \index{mp\_sub}
-\begin{alltt}
-int mp_add (mp_int * a, mp_int * b, mp_int * c);
-int mp_sub (mp_int * a, mp_int * b, mp_int * c)
-\end{alltt}
-
-Which perform $c = a \odot b$ where $\odot$ is one of signed addition or subtraction. The operations are fully sign
-aware.
-
-\section{Sign Manipulation}
-\subsection{Negation}
-\label{sec:NEG}
-Simple integer negation can be performed with the following.
-
-\index{mp\_neg}
-\begin{alltt}
-int mp_neg (mp_int * a, mp_int * b);
-\end{alltt}
-
-Which assigns $-a$ to $b$.
-
-\subsection{Absolute}
-Simple integer absolutes can be performed with the following.
-
-\index{mp\_neg}
-\begin{alltt}
-int mp_abs (mp_int * a, mp_int * b);
-\end{alltt}
-
-Which assigns $\vert a \vert$ to $b$.
-
-\section{Integer Division and Remainder}
-To perform a complete and general integer division with remainder use the following function.
-
-\index{mp\_div}
-\begin{alltt}
-int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
-\end{alltt}
-
-This divides $a$ by $b$ and stores the quotient in $c$ and $d$. The signed quotient is computed such that
-$bc + d = a$. Note that either of $c$ or $d$ can be set to \textbf{NULL} if their value is not required. If
-$b$ is zero the function returns \textbf{MP\_VAL}.
-
-
-\chapter{Multiplication and Squaring}
-\section{Multiplication}
-A full signed integer multiplication can be performed with the following.
-\index{mp\_mul}
-\begin{alltt}
-int mp_mul (mp_int * a, mp_int * b, mp_int * c);
-\end{alltt}
-Which assigns the full signed product $ab$ to $c$. This function actually breaks into one of four cases which are
-specific multiplication routines optimized for given parameters. First there are the Toom-Cook multiplications which
-should only be used with very large inputs. This is followed by the Karatsuba multiplications which are for moderate
-sized inputs. Then followed by the Comba and baseline multipliers.
-
-Fortunately for the developer you don't really need to know this unless you really want to fine tune the system. mp\_mul()
-will determine on its own\footnote{Some tweaking may be required.} what routine to use automatically when it is called.
-
-\begin{alltt}
-int main(void)
-\{
- mp_int number1, number2;
- int result;
-
- /* Initialize the numbers */
- if ((result = mp_init_multi(&number1,
- &number2, NULL)) != MP_OKAY) \{
- printf("Error initializing the numbers. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* set the terms */
- if ((result = mp_set_int(&number, 257)) != MP_OKAY) \{
- printf("Error setting number1. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- if ((result = mp_set_int(&number2, 1023)) != MP_OKAY) \{
- printf("Error setting number2. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* multiply them */
- if ((result = mp_mul(&number1, &number2,
- &number1)) != MP_OKAY) \{
- printf("Error multiplying terms. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* display */
- printf("number1 * number2 == \%lu", mp_get_int(&number1));
-
- /* free terms and return */
- mp_clear_multi(&number1, &number2, NULL);
-
- return EXIT_SUCCESS;
-\}
-\end{alltt}
-
-If this program succeeds it shall output the following.
-
-\begin{alltt}
-number1 * number2 == 262911
-\end{alltt}
-
-\section{Squaring}
-Since squaring can be performed faster than multiplication it is performed it's own function instead of just using
-mp\_mul().
-
-\index{mp\_sqr}
-\begin{alltt}
-int mp_sqr (mp_int * a, mp_int * b);
-\end{alltt}
-
-Will square $a$ and store it in $b$. Like the case of multiplication there are four different squaring
-algorithms all which can be called from mp\_sqr(). It is ideal to use mp\_sqr over mp\_mul when squaring terms because
-of the speed difference.
-
-\section{Tuning Polynomial Basis Routines}
-
-Both of the Toom-Cook and Karatsuba multiplication algorithms are faster than the traditional $O(n^2)$ approach that
-the Comba and baseline algorithms use. At $O(n^{1.464973})$ and $O(n^{1.584962})$ running times respectively they require
-considerably less work. For example, a 10000-digit multiplication would take roughly 724,000 single precision
-multiplications with Toom-Cook or 100,000,000 single precision multiplications with the standard Comba (a factor
-of 138).
-
-So why not always use Karatsuba or Toom-Cook? The simple answer is that they have so much overhead that they're not
-actually faster than Comba until you hit distinct ``cutoff'' points. For Karatsuba with the default configuration,
-GCC 3.3.1 and an Athlon XP processor the cutoff point is roughly 110 digits (about 70 for the Intel P4). That is, at
-110 digits Karatsuba and Comba multiplications just about break even and for 110+ digits Karatsuba is faster.
-
-Toom-Cook has incredible overhead and is probably only useful for very large inputs. So far no known cutoff points
-exist and for the most part I just set the cutoff points very high to make sure they're not called.
-
-A demo program in the ``etc/'' directory of the project called ``tune.c'' can be used to find the cutoff points. This
-can be built with GCC as follows
-
-\begin{alltt}
-make XXX
-\end{alltt}
-Where ``XXX'' is one of the following entries from the table \ref{fig:tuning}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|l|l|}
-\hline \textbf{Value of XXX} & \textbf{Meaning} \\
-\hline tune & Builds portable tuning application \\
-\hline tune86 & Builds x86 (pentium and up) program for COFF \\
-\hline tune86c & Builds x86 program for Cygwin \\
-\hline tune86l & Builds x86 program for Linux (ELF format) \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Build Names for Tuning Programs}
-\label{fig:tuning}
-\end{figure}
-
-When the program is running it will output a series of measurements for different cutoff points. It will first find
-good Karatsuba squaring and multiplication points. Then it proceeds to find Toom-Cook points. Note that the Toom-Cook
-tuning takes a very long time as the cutoff points are likely to be very high.
-
-\chapter{Modular Reduction}
-
-Modular reduction is process of taking the remainder of one quantity divided by another. Expressed
-as (\ref{eqn:mod}) the modular reduction is equivalent to the remainder of $b$ divided by $c$.
-
-\begin{equation}
-a \equiv b \mbox{ (mod }c\mbox{)}
-\label{eqn:mod}
-\end{equation}
-
-Of particular interest to cryptography are reductions where $b$ is limited to the range $0 \le b < c^2$ since particularly
-fast reduction algorithms can be written for the limited range.
-
-Note that one of the four optimized reduction algorithms are automatically chosen in the modular exponentiation
-algorithm mp\_exptmod when an appropriate modulus is detected.
-
-\section{Straight Division}
-In order to effect an arbitrary modular reduction the following algorithm is provided.
-
-\index{mp\_mod}
-\begin{alltt}
-int mp_mod(mp_int *a, mp_int *b, mp_int *c);
-\end{alltt}
-
-This reduces $a$ modulo $b$ and stores the result in $c$. The sign of $c$ shall agree with the sign
-of $b$. This algorithm accepts an input $a$ of any range and is not limited by $0 \le a < b^2$.
-
-\section{Barrett Reduction}
-
-Barrett reduction is a generic optimized reduction algorithm that requires pre--computation to achieve
-a decent speedup over straight division. First a $\mu$ value must be precomputed with the following function.
-
-\index{mp\_reduce\_setup}
-\begin{alltt}
-int mp_reduce_setup(mp_int *a, mp_int *b);
-\end{alltt}
-
-Given a modulus in $b$ this produces the required $\mu$ value in $a$. For any given modulus this only has to
-be computed once. Modular reduction can now be performed with the following.
-
-\index{mp\_reduce}
-\begin{alltt}
-int mp_reduce(mp_int *a, mp_int *b, mp_int *c);
-\end{alltt}
-
-This will reduce $a$ in place modulo $b$ with the precomputed $\mu$ value in $c$. $a$ must be in the range
-$0 \le a < b^2$.
-
-\begin{alltt}
-int main(void)
-\{
- mp_int a, b, c, mu;
- int result;
-
- /* initialize a,b to desired values, mp_init mu,
- * c and set c to 1...we want to compute a^3 mod b
- */
-
- /* get mu value */
- if ((result = mp_reduce_setup(&mu, b)) != MP_OKAY) \{
- printf("Error getting mu. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* square a to get c = a^2 */
- if ((result = mp_sqr(&a, &c)) != MP_OKAY) \{
- printf("Error squaring. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now reduce `c' modulo b */
- if ((result = mp_reduce(&c, &b, &mu)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* multiply a to get c = a^3 */
- if ((result = mp_mul(&a, &c, &c)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now reduce `c' modulo b */
- if ((result = mp_reduce(&c, &b, &mu)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* c now equals a^3 mod b */
-
- return EXIT_SUCCESS;
-\}
-\end{alltt}
-
-This program will calculate $a^3 \mbox{ mod }b$ if all the functions succeed.
-
-\section{Montgomery Reduction}
-
-Montgomery is a specialized reduction algorithm for any odd moduli. Like Barrett reduction a pre--computation
-step is required. This is accomplished with the following.
-
-\index{mp\_montgomery\_setup}
-\begin{alltt}
-int mp_montgomery_setup(mp_int *a, mp_digit *mp);
-\end{alltt}
-
-For the given odd moduli $a$ the precomputation value is placed in $mp$. The reduction is computed with the
-following.
-
-\index{mp\_montgomery\_reduce}
-\begin{alltt}
-int mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
-\end{alltt}
-This reduces $a$ in place modulo $m$ with the pre--computed value $mp$. $a$ must be in the range
-$0 \le a < b^2$.
-
-Montgomery reduction is faster than Barrett reduction for moduli smaller than the ``comba'' limit. With the default
-setup for instance, the limit is $127$ digits ($3556$--bits). Note that this function is not limited to
-$127$ digits just that it falls back to a baseline algorithm after that point.
-
-An important observation is that this reduction does not return $a \mbox{ mod }m$ but $aR^{-1} \mbox{ mod }m$
-where $R = \beta^n$, $n$ is the n number of digits in $m$ and $\beta$ is radix used (default is $2^{28}$).
-
-To quickly calculate $R$ the following function was provided.
-
-\index{mp\_montgomery\_calc\_normalization}
-\begin{alltt}
-int mp_montgomery_calc_normalization(mp_int *a, mp_int *b);
-\end{alltt}
-Which calculates $a = R$ for the odd moduli $b$ without using multiplication or division.
-
-The normal modus operandi for Montgomery reductions is to normalize the integers before entering the system. For
-example, to calculate $a^3 \mbox { mod }b$ using Montgomery reduction the value of $a$ can be normalized by
-multiplying it by $R$. Consider the following code snippet.
-
-\begin{alltt}
-int main(void)
-\{
- mp_int a, b, c, R;
- mp_digit mp;
- int result;
-
- /* initialize a,b to desired values,
- * mp_init R, c and set c to 1....
- */
-
- /* get normalization */
- if ((result = mp_montgomery_calc_normalization(&R, b)) != MP_OKAY) \{
- printf("Error getting norm. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* get mp value */
- if ((result = mp_montgomery_setup(&c, &mp)) != MP_OKAY) \{
- printf("Error setting up montgomery. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* normalize `a' so now a is equal to aR */
- if ((result = mp_mulmod(&a, &R, &b, &a)) != MP_OKAY) \{
- printf("Error computing aR. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* square a to get c = a^2R^2 */
- if ((result = mp_sqr(&a, &c)) != MP_OKAY) \{
- printf("Error squaring. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now reduce `c' back down to c = a^2R^2 * R^-1 == a^2R */
- if ((result = mp_montgomery_reduce(&c, &b, mp)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* multiply a to get c = a^3R^2 */
- if ((result = mp_mul(&a, &c, &c)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now reduce `c' back down to c = a^3R^2 * R^-1 == a^3R */
- if ((result = mp_montgomery_reduce(&c, &b, mp)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* now reduce (again) `c' back down to c = a^3R * R^-1 == a^3 */
- if ((result = mp_montgomery_reduce(&c, &b, mp)) != MP_OKAY) \{
- printf("Error reducing. \%s",
- mp_error_to_string(result));
- return EXIT_FAILURE;
- \}
-
- /* c now equals a^3 mod b */
-
- return EXIT_SUCCESS;
-\}
-\end{alltt}
-
-This particular example does not look too efficient but it demonstrates the point of the algorithm. By
-normalizing the inputs the reduced results are always of the form $aR$ for some variable $a$. This allows
-a single final reduction to correct for the normalization and the fast reduction used within the algorithm.
-
-For more details consider examining the file \textit{bn\_mp\_exptmod\_fast.c}.
-
-\section{Restricted Dimminished Radix}
-
-``Dimminished Radix'' reduction refers to reduction with respect to moduli that are ameniable to simple
-digit shifting and small multiplications. In this case the ``restricted'' variant refers to moduli of the
-form $\beta^k - p$ for some $k \ge 0$ and $0 < p < \beta$ where $\beta$ is the radix (default to $2^{28}$).
-
-As in the case of Montgomery reduction there is a pre--computation phase required for a given modulus.
-
-\index{mp\_dr\_setup}
-\begin{alltt}
-void mp_dr_setup(mp_int *a, mp_digit *d);
-\end{alltt}
-
-This computes the value required for the modulus $a$ and stores it in $d$. This function cannot fail
-and does not return any error codes. After the pre--computation a reduction can be performed with the
-following.
-
-\index{mp\_dr\_reduce}
-\begin{alltt}
-int mp_dr_reduce(mp_int *a, mp_int *b, mp_digit mp);
-\end{alltt}
-
-This reduces $a$ in place modulo $b$ with the pre--computed value $mp$. $b$ must be of a restricted
-dimminished radix form and $a$ must be in the range $0 \le a < b^2$. Dimminished radix reductions are
-much faster than both Barrett and Montgomery reductions as they have a much lower asymtotic running time.
-
-Since the moduli are restricted this algorithm is not particularly useful for something like Rabin, RSA or
-BBS cryptographic purposes. This reduction algorithm is useful for Diffie-Hellman and ECC where fixed
-primes are acceptable.
-
-Note that unlike Montgomery reduction there is no normalization process. The result of this function is
-equal to the correct residue.
-
-\section{Unrestricted Dimminshed Radix}
-
-Unrestricted reductions work much like the restricted counterparts except in this case the moduli is of the
-form $2^k - p$ for $0 < p < \beta$. In this sense the unrestricted reductions are more flexible as they
-can be applied to a wider range of numbers.
-
-\index{mp\_reduce\_2k\_setup}
-\begin{alltt}
-int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
-\end{alltt}
-
-This will compute the required $d$ value for the given moduli $a$.
-
-\index{mp\_reduce\_2k}
-\begin{alltt}
-int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
-\end{alltt}
-
-This will reduce $a$ in place modulo $n$ with the pre--computed value $d$. From my experience this routine is
-slower than mp\_dr\_reduce but faster for most moduli sizes than the Montgomery reduction.
-
-\chapter{Exponentiation}
-\section{Single Digit Exponentiation}
-\index{mp\_expt\_d}
-\begin{alltt}
-int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
-\end{alltt}
-This computes $c = a^b$ using a simple binary left-to-right algorithm. It is faster than repeated multiplications by
-$a$ for all values of $b$ greater than three.
-
-\section{Modular Exponentiation}
-\index{mp\_exptmod}
-\begin{alltt}
-int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
-\end{alltt}
-This computes $Y \equiv G^X \mbox{ (mod }P\mbox{)}$ using a variable width sliding window algorithm. This function
-will automatically detect the fastest modular reduction technique to use during the operation. For negative values of
-$X$ the operation is performed as $Y \equiv (G^{-1} \mbox{ mod }P)^{\vert X \vert} \mbox{ (mod }P\mbox{)}$ provided that
-$gcd(G, P) = 1$.
-
-This function is actually a shell around the two internal exponentiation functions. This routine will automatically
-detect when Barrett, Montgomery, Restricted and Unrestricted Dimminished Radix based exponentiation can be used. Generally
-moduli of the a ``restricted dimminished radix'' form lead to the fastest modular exponentiations. Followed by Montgomery
-and the other two algorithms.
-
-\section{Root Finding}
-\index{mp\_n\_root}
-\begin{alltt}
-int mp_n_root (mp_int * a, mp_digit b, mp_int * c)
-\end{alltt}
-This computes $c = a^{1/b}$ such that $c^b \le a$ and $(c+1)^b > a$. The implementation of this function is not
-ideal for values of $b$ greater than three. It will work but become very slow. So unless you are working with very small
-numbers (less than 1000 bits) I'd avoid $b > 3$ situations. Will return a positive root only for even roots and return
-a root with the sign of the input for odd roots. For example, performing $4^{1/2}$ will return $2$ whereas $(-8)^{1/3}$
-will return $-2$.
-
-This algorithm uses the ``Newton Approximation'' method and will converge on the correct root fairly quickly. Since
-the algorithm requires raising $a$ to the power of $b$ it is not ideal to attempt to find roots for large
-values of $b$. If particularly large roots are required then a factor method could be used instead. For example,
-$a^{1/16}$ is equivalent to $\left (a^{1/4} \right)^{1/4}$ or simply
-$\left ( \left ( \left ( a^{1/2} \right )^{1/2} \right )^{1/2} \right )^{1/2}$
-
-\chapter{Prime Numbers}
-\section{Trial Division}
-\index{mp\_prime\_is\_divisible}
-\begin{alltt}
-int mp_prime_is_divisible (mp_int * a, int *result)
-\end{alltt}
-This will attempt to evenly divide $a$ by a list of primes\footnote{Default is the first 256 primes.} and store the
-outcome in ``result''. That is if $result = 0$ then $a$ is not divisible by the primes, otherwise it is. Note that
-if the function does not return \textbf{MP\_OKAY} the value in ``result'' should be considered undefined\footnote{Currently
-the default is to set it to zero first.}.
-
-\section{Fermat Test}
-\index{mp\_prime\_fermat}
-\begin{alltt}
-int mp_prime_fermat (mp_int * a, mp_int * b, int *result)
-\end{alltt}
-Performs a Fermat primality test to the base $b$. That is it computes $b^a \mbox{ mod }a$ and tests whether the value is
-equal to $b$ or not. If the values are equal then $a$ is probably prime and $result$ is set to one. Otherwise $result$
-is set to zero.
-
-\section{Miller-Rabin Test}
-\index{mp\_prime\_miller\_rabin}
-\begin{alltt}
-int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
-\end{alltt}
-Performs a Miller-Rabin test to the base $b$ of $a$. This test is much stronger than the Fermat test and is very hard to
-fool (besides with Carmichael numbers). If $a$ passes the test (therefore is probably prime) $result$ is set to one.
-Otherwise $result$ is set to zero.
-
-Note that is suggested that you use the Miller-Rabin test instead of the Fermat test since all of the failures of
-Miller-Rabin are a subset of the failures of the Fermat test.
-
-\subsection{Required Number of Tests}
-Generally to ensure a number is very likely to be prime you have to perform the Miller-Rabin with at least a half-dozen
-or so unique bases. However, it has been proven that the probability of failure goes down as the size of the input goes up.
-This is why a simple function has been provided to help out.
-
-\index{mp\_prime\_rabin\_miller\_trials}
-\begin{alltt}
-int mp_prime_rabin_miller_trials(int size)
-\end{alltt}
-This returns the number of trials required for a $2^{-96}$ (or lower) probability of failure for a given ``size'' expressed
-in bits. This comes in handy specially since larger numbers are slower to test. For example, a 512-bit number would
-require ten tests whereas a 1024-bit number would only require four tests.
-
-You should always still perform a trial division before a Miller-Rabin test though.
-
-\section{Primality Testing}
-\index{mp\_prime\_is\_prime}
-\begin{alltt}
-int mp_prime_is_prime (mp_int * a, int t, int *result)
-\end{alltt}
-This will perform a trial division followed by $t$ rounds of Miller-Rabin tests on $a$ and store the result in $result$.
-If $a$ passes all of the tests $result$ is set to one, otherwise it is set to zero. Note that $t$ is bounded by
-$1 \le t < PRIME\_SIZE$ where $PRIME\_SIZE$ is the number of primes in the prime number table (by default this is $256$).
-
-\section{Next Prime}
-\index{mp\_prime\_next\_prime}
-\begin{alltt}
-int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
-\end{alltt}
-This finds the next prime after $a$ that passes mp\_prime\_is\_prime() with $t$ tests. Set $bbs\_style$ to one if you
-want only the next prime congruent to $3 \mbox{ mod } 4$, otherwise set it to zero to find any next prime.
-
-\section{Random Primes}
-\index{mp\_prime\_random}
-\begin{alltt}
-int mp_prime_random(mp_int *a, int t, int size, int bbs,
- ltm_prime_callback cb, void *dat)
-\end{alltt}
-This will find a prime greater than $256^{size}$ which can be ``bbs\_style'' or not depending on $bbs$ and must pass
-$t$ rounds of tests. The ``ltm\_prime\_callback'' is a typedef for
-
-\begin{alltt}
-typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
-\end{alltt}
-
-Which is a function that must read $len$ bytes (and return the amount stored) into $dst$. The $dat$ variable is simply
-copied from the original input. It can be used to pass RNG context data to the callback. The function
-mp\_prime\_random() is more suitable for generating primes which must be secret (as in the case of RSA) since there
-is no skew on the least significant bits.
-
-\textit{Note:} As of v0.30 of the LibTomMath library this function has been deprecated. It is still available
-but users are encouraged to use the new mp\_prime\_random\_ex() function instead.
-
-\subsection{Extended Generation}
-\index{mp\_prime\_random\_ex}
-\begin{alltt}
-int mp_prime_random_ex(mp_int *a, int t,
- int size, int flags,
- ltm_prime_callback cb, void *dat);
-\end{alltt}
-This will generate a prime in $a$ using $t$ tests of the primality testing algorithms. The variable $size$
-specifies the bit length of the prime desired. The variable $flags$ specifies one of several options available
-(see fig. \ref{fig:primeopts}) which can be OR'ed together. The callback parameters are used as in
-mp\_prime\_random().
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|r|l|}
-\hline \textbf{Flag} & \textbf{Meaning} \\
-\hline LTM\_PRIME\_BBS & Make the prime congruent to $3$ modulo $4$ \\
-\hline LTM\_PRIME\_SAFE & Make a prime $p$ such that $(p - 1)/2$ is also prime. \\
- & This option implies LTM\_PRIME\_BBS as well. \\
-\hline LTM\_PRIME\_2MSB\_OFF & Makes sure that the bit adjacent to the most significant bit \\
- & Is forced to zero. \\
-\hline LTM\_PRIME\_2MSB\_ON & Makes sure that the bit adjacent to the most significant bit \\
- & Is forced to one. \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Primality Generation Options}
-\label{fig:primeopts}
-\end{figure}
-
-\chapter{Input and Output}
-\section{ASCII Conversions}
-\subsection{To ASCII}
-\index{mp\_toradix}
-\begin{alltt}
-int mp_toradix (mp_int * a, char *str, int radix);
-\end{alltt}
-This still store $a$ in ``str'' as a base-``radix'' string of ASCII chars. This function appends a NUL character
-to terminate the string. Valid values of ``radix'' line in the range $[2, 64]$. To determine the size (exact) required
-by the conversion before storing any data use the following function.
-
-\index{mp\_radix\_size}
-\begin{alltt}
-int mp_radix_size (mp_int * a, int radix, int *size)
-\end{alltt}
-This stores in ``size'' the number of characters (including space for the NUL terminator) required. Upon error this
-function returns an error code and ``size'' will be zero.
-
-\subsection{From ASCII}
-\index{mp\_read\_radix}
-\begin{alltt}
-int mp_read_radix (mp_int * a, char *str, int radix);
-\end{alltt}
-This will read the base-``radix'' NUL terminated string from ``str'' into $a$. It will stop reading when it reads a
-character it does not recognize (which happens to include th NUL char... imagine that...). A single leading $-$ sign
-can be used to denote a negative number.
-
-\section{Binary Conversions}
-
-Converting an mp\_int to and from binary is another keen idea.
-
-\index{mp\_unsigned\_bin\_size}
-\begin{alltt}
-int mp_unsigned_bin_size(mp_int *a);
-\end{alltt}
-
-This will return the number of bytes (octets) required to store the unsigned copy of the integer $a$.
-
-\index{mp\_to\_unsigned\_bin}
-\begin{alltt}
-int mp_to_unsigned_bin(mp_int *a, unsigned char *b);
-\end{alltt}
-This will store $a$ into the buffer $b$ in big--endian format. Fortunately this is exactly what DER (or is it ASN?)
-requires. It does not store the sign of the integer.
-
-\index{mp\_read\_unsigned\_bin}
-\begin{alltt}
-int mp_read_unsigned_bin(mp_int *a, unsigned char *b, int c);
-\end{alltt}
-This will read in an unsigned big--endian array of bytes (octets) from $b$ of length $c$ into $a$. The resulting
-integer $a$ will always be positive.
-
-For those who acknowledge the existence of negative numbers (heretic!) there are ``signed'' versions of the
-previous functions.
-
-\begin{alltt}
-int mp_signed_bin_size(mp_int *a);
-int mp_read_signed_bin(mp_int *a, unsigned char *b, int c);
-int mp_to_signed_bin(mp_int *a, unsigned char *b);
-\end{alltt}
-They operate essentially the same as the unsigned copies except they prefix the data with zero or non--zero
-byte depending on the sign. If the sign is zpos (e.g. not negative) the prefix is zero, otherwise the prefix
-is non--zero.
-
-\chapter{Algebraic Functions}
-\section{Extended Euclidean Algorithm}
-\index{mp\_exteuclid}
-\begin{alltt}
-int mp_exteuclid(mp_int *a, mp_int *b,
- mp_int *U1, mp_int *U2, mp_int *U3);
-\end{alltt}
-
-This finds the triple U1/U2/U3 using the Extended Euclidean algorithm such that the following equation holds.
-
-\begin{equation}
-a \cdot U1 + b \cdot U2 = U3
-\end{equation}
-
-Any of the U1/U2/U3 paramters can be set to \textbf{NULL} if they are not desired.
-
-\section{Greatest Common Divisor}
-\index{mp\_gcd}
-\begin{alltt}
-int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
-\end{alltt}
-This will compute the greatest common divisor of $a$ and $b$ and store it in $c$.
-
-\section{Least Common Multiple}
-\index{mp\_lcm}
-\begin{alltt}
-int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
-\end{alltt}
-This will compute the least common multiple of $a$ and $b$ and store it in $c$.
-
-\section{Jacobi Symbol}
-\index{mp\_jacobi}
-\begin{alltt}
-int mp_jacobi (mp_int * a, mp_int * p, int *c)
-\end{alltt}
-This will compute the Jacobi symbol for $a$ with respect to $p$. If $p$ is prime this essentially computes the Legendre
-symbol. The result is stored in $c$ and can take on one of three values $\lbrace -1, 0, 1 \rbrace$. If $p$ is prime
-then the result will be $-1$ when $a$ is not a quadratic residue modulo $p$. The result will be $0$ if $a$ divides $p$
-and the result will be $1$ if $a$ is a quadratic residue modulo $p$.
-
-\section{Modular Inverse}
-\index{mp\_invmod}
-\begin{alltt}
-int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-\end{alltt}
-Computes the multiplicative inverse of $a$ modulo $b$ and stores the result in $c$ such that $ac \equiv 1 \mbox{ (mod }b\mbox{)}$.
-
-\section{Single Digit Functions}
-
-For those using small numbers (\textit{snicker snicker}) there are several ``helper'' functions
-
-\index{mp\_add\_d} \index{mp\_sub\_d} \index{mp\_mul\_d} \index{mp\_div\_d} \index{mp\_mod\_d}
-\begin{alltt}
-int mp_add_d(mp_int *a, mp_digit b, mp_int *c);
-int mp_sub_d(mp_int *a, mp_digit b, mp_int *c);
-int mp_mul_d(mp_int *a, mp_digit b, mp_int *c);
-int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
-int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c);
-\end{alltt}
-
-These work like the full mp\_int capable variants except the second parameter $b$ is a mp\_digit. These
-functions fairly handy if you have to work with relatively small numbers since you will not have to allocate
-an entire mp\_int to store a number like $1$ or $2$.
-
-\input{bn.ind}
-
-\end{document}
diff --git a/libtommath/bn_error.c b/libtommath/bn_error.c
index 6393bb0..3abf1a7 100644
--- a/libtommath/bn_error.c
+++ b/libtommath/bn_error.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_ERROR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,12 +12,12 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const struct {
int code;
- char *msg;
+ const char *msg;
} msgs[] = {
{ MP_OKAY, "Successful" },
{ MP_MEM, "Out of heap" },
@@ -25,7 +25,7 @@ static const struct {
};
/* return a char * string for a given code */
-char *mp_error_to_string(int code)
+const char *mp_error_to_string(int code)
{
int x;
@@ -41,3 +41,7 @@ char *mp_error_to_string(int code)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_fast_mp_invmod.c b/libtommath/bn_fast_mp_invmod.c
index fafd9dc..aa41098 100644
--- a/libtommath/bn_fast_mp_invmod.c
+++ b/libtommath/bn_fast_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_FAST_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the modular inverse via binary extended euclidean algorithm,
@@ -27,7 +27,7 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
int res, neg;
/* 2. [modified] b must be odd */
- if (mp_iseven (b) == 1) {
+ if (mp_iseven (b) == MP_YES) {
return MP_VAL;
}
@@ -57,13 +57,13 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
top:
/* 4. while u is even do */
- while (mp_iseven (&u) == 1) {
+ while (mp_iseven (&u) == MP_YES) {
/* 4.1 u = u/2 */
if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
goto LBL_ERR;
}
/* 4.2 if B is odd then */
- if (mp_isodd (&B) == 1) {
+ if (mp_isodd (&B) == MP_YES) {
if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
goto LBL_ERR;
}
@@ -75,13 +75,13 @@ top:
}
/* 5. while v is even do */
- while (mp_iseven (&v) == 1) {
+ while (mp_iseven (&v) == MP_YES) {
/* 5.1 v = v/2 */
if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
goto LBL_ERR;
}
/* 5.2 if D is odd then */
- if (mp_isodd (&D) == 1) {
+ if (mp_isodd (&D) == MP_YES) {
/* D = (D-x)/2 */
if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
goto LBL_ERR;
@@ -115,7 +115,7 @@ top:
}
/* if not zero goto step 4 */
- if (mp_iszero (&u) == 0) {
+ if (mp_iszero (&u) == MP_NO) {
goto top;
}
@@ -142,3 +142,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_fast_mp_montgomery_reduce.c b/libtommath/bn_fast_mp_montgomery_reduce.c
index e941dc2..a63839d 100644
--- a/libtommath/bn_fast_mp_montgomery_reduce.c
+++ b/libtommath/bn_fast_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction
@@ -32,7 +32,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
olduse = x->used;
/* grow a as required */
- if (x->alloc < n->used + 1) {
+ if (x->alloc < (n->used + 1)) {
if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
return res;
}
@@ -42,8 +42,8 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* an array of double precision words W[...]
*/
{
- register mp_word *_W;
- register mp_digit *tmpx;
+ mp_word *_W;
+ mp_digit *tmpx;
/* alias for the W[] array */
_W = W;
@@ -57,7 +57,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
}
/* zero the high words of W[a->used..m->used*2] */
- for (; ix < n->used * 2 + 1; ix++) {
+ for (; ix < ((n->used * 2) + 1); ix++) {
*_W++ = 0;
}
}
@@ -72,7 +72,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* by casting the value down to a mp_digit. Note this requires
* that W[ix-1] have the carry cleared (see after the inner loop)
*/
- register mp_digit mu;
+ mp_digit mu;
mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK);
/* a = a + mu * m * b**i
@@ -90,9 +90,9 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* first m->used words of W[] have the carries fixed
*/
{
- register int iy;
- register mp_digit *tmpn;
- register mp_word *_W;
+ int iy;
+ mp_digit *tmpn;
+ mp_word *_W;
/* alias for the digits of the modulus */
tmpn = n->dp;
@@ -115,8 +115,8 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* significant digits we zeroed].
*/
{
- register mp_digit *tmpx;
- register mp_word *_W, *_W1;
+ mp_digit *tmpx;
+ mp_word *_W, *_W1;
/* nox fix rest of carries */
@@ -126,7 +126,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
/* alias for next word, where the carry goes */
_W = W + ++ix;
- for (; ix <= n->used * 2 + 1; ix++) {
+ for (; ix <= ((n->used * 2) + 1); ix++) {
*_W++ += *_W1++ >> ((mp_word) DIGIT_BIT);
}
@@ -143,7 +143,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
/* alias for shifted double precision result */
_W = W + n->used;
- for (ix = 0; ix < n->used + 1; ix++) {
+ for (ix = 0; ix < (n->used + 1); ix++) {
*tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK));
}
@@ -166,3 +166,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c
index ab157b9..acd13b4 100644
--- a/libtommath/bn_fast_s_mp_mul_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_digs.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_FAST_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Fast (comba) multiplier
@@ -35,7 +35,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
{
int olduse, res, pa, ix, iz;
mp_digit W[MP_WARRAY];
- register mp_word _W;
+ mp_word _W;
/* grow the destination as required */
if (c->alloc < digs) {
@@ -78,16 +78,16 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
/* make next carry */
_W = _W >> ((mp_word)DIGIT_BIT);
- }
+ }
/* setup dest */
olduse = c->used;
c->used = pa;
{
- register mp_digit *tmpc;
+ mp_digit *tmpc;
tmpc = c->dp;
- for (ix = 0; ix < pa+1; ix++) {
+ for (ix = 0; ix < (pa + 1); ix++) {
/* now extract the previous digit [below the carry] */
*tmpc++ = W[ix];
}
@@ -101,3 +101,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_fast_s_mp_mul_high_digs.c b/libtommath/bn_fast_s_mp_mul_high_digs.c
index ec9f58a..b96cf60 100644
--- a/libtommath/bn_fast_s_mp_mul_high_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_high_digs.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* this is a modified version of fast_s_mul_digs that only produces
@@ -75,7 +75,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
c->used = pa;
{
- register mp_digit *tmpc;
+ mp_digit *tmpc;
tmpc = c->dp + digs;
for (ix = digs; ix < pa; ix++) {
@@ -92,3 +92,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_fast_s_mp_sqr.c b/libtommath/bn_fast_s_mp_sqr.c
index 1abf24b..775c76f 100644
--- a/libtommath/bn_fast_s_mp_sqr.c
+++ b/libtommath/bn_fast_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_FAST_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* the jist of squaring...
@@ -66,7 +66,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
* we halve the distance since they approach at a rate of 2x
* and we have to round because odd cases need to be executed
*/
- iy = MIN(iy, (ty-tx+1)>>1);
+ iy = MIN(iy, ((ty-tx)+1)>>1);
/* execute loop */
for (iz = 0; iz < iy; iz++) {
@@ -108,3 +108,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_2expt.c b/libtommath/bn_mp_2expt.c
index a32572d..2845814 100644
--- a/libtommath/bn_mp_2expt.c
+++ b/libtommath/bn_mp_2expt.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_2EXPT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes a = 2**b
@@ -29,12 +29,12 @@ mp_2expt (mp_int * a, int b)
mp_zero (a);
/* grow a to accomodate the single bit */
- if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) {
+ if ((res = mp_grow (a, (b / DIGIT_BIT) + 1)) != MP_OKAY) {
return res;
}
/* set the used count of where the bit will go */
- a->used = b / DIGIT_BIT + 1;
+ a->used = (b / DIGIT_BIT) + 1;
/* put the single bit in its place */
a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
@@ -42,3 +42,7 @@ mp_2expt (mp_int * a, int b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_abs.c b/libtommath/bn_mp_abs.c
index dc51884..cc9c3db 100644
--- a/libtommath/bn_mp_abs.c
+++ b/libtommath/bn_mp_abs.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_ABS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = |a|
@@ -37,3 +37,7 @@ mp_abs (mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_add.c b/libtommath/bn_mp_add.c
index d9b8fa5..236fc75 100644
--- a/libtommath/bn_mp_add.c
+++ b/libtommath/bn_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level addition (handles signs) */
@@ -47,3 +47,7 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c
index 5281ad4..4d4e1df 100644
--- a/libtommath/bn_mp_add_d.c
+++ b/libtommath/bn_mp_add_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_ADD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit addition */
@@ -23,23 +23,22 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
mp_digit *tmpa, *tmpc, mu;
/* grow c as required */
- if (c->alloc < a->used + 1) {
+ if (c->alloc < (a->used + 1)) {
if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
return res;
}
}
/* if a is negative and |a| >= b, call c = |a| - b */
- if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) {
+ if ((a->sign == MP_NEG) && ((a->used > 1) || (a->dp[0] >= b))) {
/* temporarily fix sign of a */
a->sign = MP_ZPOS;
/* c = |a| - b */
res = mp_sub_d(a, b, c);
- /* fix signs */
- a->sign = MP_NEG;
- c->sign = (c->used) ? MP_NEG : MP_ZPOS;
+ /* fix sign */
+ a->sign = c->sign = MP_NEG;
/* clamp */
mp_clamp(c);
@@ -107,3 +106,7 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_addmod.c b/libtommath/bn_mp_addmod.c
index bff193f..825c928 100644
--- a/libtommath/bn_mp_addmod.c
+++ b/libtommath/bn_mp_addmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_ADDMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a + b (mod c) */
@@ -35,3 +35,7 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c
index 02bef18..3b6b03e 100644
--- a/libtommath/bn_mp_and.c
+++ b/libtommath/bn_mp_and.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_AND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* AND two ints together */
@@ -51,3 +51,7 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_clamp.c b/libtommath/bn_mp_clamp.c
index 74887bb..d4fb70d 100644
--- a/libtommath/bn_mp_clamp.c
+++ b/libtommath/bn_mp_clamp.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CLAMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* trim unused digits
@@ -28,7 +28,7 @@ mp_clamp (mp_int * a)
/* decrease used while the most significant digit is
* zero.
*/
- while (a->used > 0 && a->dp[a->used - 1] == 0) {
+ while ((a->used > 0) && (a->dp[a->used - 1] == 0)) {
--(a->used);
}
@@ -38,3 +38,7 @@ mp_clamp (mp_int * a)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c
index bd07e76..17ef9d5 100644
--- a/libtommath/bn_mp_clear.c
+++ b/libtommath/bn_mp_clear.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CLEAR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* clear one (frees) */
@@ -38,3 +38,7 @@ mp_clear (mp_int * a)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_clear_multi.c b/libtommath/bn_mp_clear_multi.c
index c3ad7a8..441a200 100644
--- a/libtommath/bn_mp_clear_multi.c
+++ b/libtommath/bn_mp_clear_multi.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CLEAR_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
@@ -28,3 +28,7 @@ void mp_clear_multi(mp_int *mp, ...)
va_end(args);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_cmp.c b/libtommath/bn_mp_cmp.c
index 943249d..15179ca 100644
--- a/libtommath/bn_mp_cmp.c
+++ b/libtommath/bn_mp_cmp.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare two ints (signed)*/
@@ -37,3 +37,7 @@ mp_cmp (const mp_int * a, const mp_int * b)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_cmp_d.c b/libtommath/bn_mp_cmp_d.c
index ecec091..0c9fc86 100644
--- a/libtommath/bn_mp_cmp_d.c
+++ b/libtommath/bn_mp_cmp_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CMP_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare a digit */
@@ -38,3 +38,7 @@ int mp_cmp_d(const mp_int * a, mp_digit b)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_cmp_mag.c b/libtommath/bn_mp_cmp_mag.c
index b23a191..a537608 100644
--- a/libtommath/bn_mp_cmp_mag.c
+++ b/libtommath/bn_mp_cmp_mag.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CMP_MAG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare maginitude of two ints (unsigned) */
@@ -49,3 +49,7 @@ int mp_cmp_mag (const mp_int * a, const mp_int * b)
return MP_EQ;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_cnt_lsb.c b/libtommath/bn_mp_cnt_lsb.c
index f205e8c..b638dc4 100644
--- a/libtommath/bn_mp_cnt_lsb.c
+++ b/libtommath/bn_mp_cnt_lsb.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_CNT_LSB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const int lnz[16] = {
@@ -26,12 +26,12 @@ int mp_cnt_lsb(const mp_int *a)
mp_digit q, qq;
/* easy out */
- if (mp_iszero(a) == 1) {
+ if (mp_iszero(a) == MP_YES) {
return 0;
}
/* scan lower digits until non-zero */
- for (x = 0; x < a->used && a->dp[x] == 0; x++);
+ for (x = 0; (x < a->used) && (a->dp[x] == 0); x++) {}
q = a->dp[x];
x *= DIGIT_BIT;
@@ -47,3 +47,7 @@ int mp_cnt_lsb(const mp_int *a)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_copy.c b/libtommath/bn_mp_copy.c
index ffbc0d4..c15f961 100644
--- a/libtommath/bn_mp_copy.c
+++ b/libtommath/bn_mp_copy.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* copy, b = a */
@@ -35,7 +35,7 @@ mp_copy (const mp_int * a, mp_int * b)
/* zero b and copy the parameters over */
{
- register mp_digit *tmpa, *tmpb;
+ mp_digit *tmpa, *tmpb;
/* pointer aliases */
@@ -62,3 +62,7 @@ mp_copy (const mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_count_bits.c b/libtommath/bn_mp_count_bits.c
index 00d364e..47aa569 100644
--- a/libtommath/bn_mp_count_bits.c
+++ b/libtommath/bn_mp_count_bits.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_COUNT_BITS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns the number of bits in an int */
@@ -39,3 +39,7 @@ mp_count_bits (const mp_int * a)
return r;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c
index de4ca04..3ca5d7f 100644
--- a/libtommath/bn_mp_div.c
+++ b/libtommath/bn_mp_div.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DIV_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef BN_MP_DIV_SMALL
@@ -24,7 +24,7 @@ int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
int res, n, n2;
/* is divisor zero ? */
- if (mp_iszero (b) == 1) {
+ if (mp_iszero (b) == MP_YES) {
return MP_VAL;
}
@@ -40,9 +40,9 @@ int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
}
return res;
}
-
+
/* init our temps */
- if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) {
+ if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL)) != MP_OKAY) {
return res;
}
@@ -50,7 +50,7 @@ int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
mp_set(&tq, 1);
n = mp_count_bits(a) - mp_count_bits(b);
if (((res = mp_abs(a, &ta)) != MP_OKAY) ||
- ((res = mp_abs(b, &tb)) != MP_OKAY) ||
+ ((res = mp_abs(b, &tb)) != MP_OKAY) ||
((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) ||
((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) {
goto LBL_ERR;
@@ -71,7 +71,7 @@ int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
/* now q == quotient and ta == remainder */
n = a->sign;
- n2 = (a->sign == b->sign ? MP_ZPOS : MP_NEG);
+ n2 = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
if (c != NULL) {
mp_exch(c, &q);
c->sign = (mp_iszero(c) == MP_YES) ? MP_ZPOS : n2;
@@ -87,17 +87,17 @@ LBL_ERR:
#else
-/* integer signed division.
+/* integer signed division.
* c*b + d == a [e.g. a/b, c=quotient, d=remainder]
* HAC pp.598 Algorithm 14.20
*
- * Note that the description in HAC is horribly
- * incomplete. For example, it doesn't consider
- * the case where digits are removed from 'x' in
- * the inner loop. It also doesn't consider the
+ * Note that the description in HAC is horribly
+ * incomplete. For example, it doesn't consider
+ * the case where digits are removed from 'x' in
+ * the inner loop. It also doesn't consider the
* case that y has fewer than three digits, etc..
*
- * The overall algorithm is as described as
+ * The overall algorithm is as described as
* 14.20 from HAC but fixed to treat these cases.
*/
int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
@@ -106,7 +106,7 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
int res, n, t, i, norm, neg;
/* is divisor zero ? */
- if (mp_iszero (b) == 1) {
+ if (mp_iszero (b) == MP_YES) {
return MP_VAL;
}
@@ -187,51 +187,52 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
continue;
}
- /* step 3.1 if xi == yt then set q{i-t-1} to b-1,
+ /* step 3.1 if xi == yt then set q{i-t-1} to b-1,
* otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */
if (x.dp[i] == y.dp[t]) {
- q.dp[i - t - 1] = ((((mp_digit)1) << DIGIT_BIT) - 1);
+ q.dp[(i - t) - 1] = ((((mp_digit)1) << DIGIT_BIT) - 1);
} else {
mp_word tmp;
tmp = ((mp_word) x.dp[i]) << ((mp_word) DIGIT_BIT);
tmp |= ((mp_word) x.dp[i - 1]);
tmp /= ((mp_word) y.dp[t]);
- if (tmp > (mp_word) MP_MASK)
+ if (tmp > (mp_word) MP_MASK) {
tmp = MP_MASK;
- q.dp[i - t - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK));
+ }
+ q.dp[(i - t) - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK));
}
- /* while (q{i-t-1} * (yt * b + y{t-1})) >
- xi * b**2 + xi-1 * b + xi-2
-
- do q{i-t-1} -= 1;
+ /* while (q{i-t-1} * (yt * b + y{t-1})) >
+ xi * b**2 + xi-1 * b + xi-2
+
+ do q{i-t-1} -= 1;
*/
- q.dp[i - t - 1] = (q.dp[i - t - 1] + 1) & MP_MASK;
+ q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] + 1) & MP_MASK;
do {
- q.dp[i - t - 1] = (q.dp[i - t - 1] - 1) & MP_MASK;
+ q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] - 1) & MP_MASK;
/* find left hand */
mp_zero (&t1);
- t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1];
+ t1.dp[0] = ((t - 1) < 0) ? 0 : y.dp[t - 1];
t1.dp[1] = y.dp[t];
t1.used = 2;
- if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) {
+ if ((res = mp_mul_d (&t1, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
goto LBL_Y;
}
/* find right hand */
- t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2];
- t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1];
+ t2.dp[0] = ((i - 2) < 0) ? 0 : x.dp[i - 2];
+ t2.dp[1] = ((i - 1) < 0) ? 0 : x.dp[i - 1];
t2.dp[2] = x.dp[i];
t2.used = 3;
} while (mp_cmp_mag(&t1, &t2) == MP_GT);
/* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */
- if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) {
+ if ((res = mp_mul_d (&y, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
goto LBL_Y;
}
- if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
+ if ((res = mp_lshd (&t1, (i - t) - 1)) != MP_OKAY) {
goto LBL_Y;
}
@@ -244,23 +245,23 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
if ((res = mp_copy (&y, &t1)) != MP_OKAY) {
goto LBL_Y;
}
- if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
+ if ((res = mp_lshd (&t1, (i - t) - 1)) != MP_OKAY) {
goto LBL_Y;
}
if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) {
goto LBL_Y;
}
- q.dp[i - t - 1] = (q.dp[i - t - 1] - 1UL) & MP_MASK;
+ q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] - 1UL) & MP_MASK;
}
}
- /* now q is the quotient and x is the remainder
- * [which we have to normalize]
+ /* now q is the quotient and x is the remainder
+ * [which we have to normalize]
*/
-
+
/* get sign before writing to c */
- x.sign = x.used == 0 ? MP_ZPOS : a->sign;
+ x.sign = (x.used == 0) ? MP_ZPOS : a->sign;
if (c != NULL) {
mp_clamp (&q);
@@ -269,7 +270,9 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
}
if (d != NULL) {
- mp_div_2d (&x, norm, &x, NULL);
+ if ((res = mp_div_2d (&x, norm, &x, NULL)) != MP_OKAY) {
+ goto LBL_Y;
+ }
mp_exch (&x, d);
}
@@ -286,3 +289,7 @@ LBL_Q:mp_clear (&q);
#endif
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_div_2.c b/libtommath/bn_mp_div_2.c
index 186a959..d2a213f 100644
--- a/libtommath/bn_mp_div_2.c
+++ b/libtommath/bn_mp_div_2.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DIV_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a/2 */
@@ -30,7 +30,7 @@ int mp_div_2(mp_int * a, mp_int * b)
oldused = b->used;
b->used = a->used;
{
- register mp_digit r, rr, *tmpa, *tmpb;
+ mp_digit r, rr, *tmpa, *tmpb;
/* source alias */
tmpa = a->dp + b->used - 1;
@@ -62,3 +62,7 @@ int mp_div_2(mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_div_2d.c b/libtommath/bn_mp_div_2d.c
index d7b7e05..49d7479 100644
--- a/libtommath/bn_mp_div_2d.c
+++ b/libtommath/bn_mp_div_2d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DIV_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
@@ -58,7 +58,7 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d)
/* shift any bit count < DIGIT_BIT */
D = (mp_digit) (b % DIGIT_BIT);
if (D != 0) {
- register mp_digit *tmpc, mask, shift;
+ mp_digit *tmpc, mask, shift;
/* mask */
mask = (((mp_digit)1) << D) - 1;
@@ -91,3 +91,7 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c
index 79a9816..c2b76fb 100644
--- a/libtommath/bn_mp_div_3.c
+++ b/libtommath/bn_mp_div_3.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DIV_3_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* divide by three (based on routine from MPI and the GMP manual) */
@@ -73,3 +73,7 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c
index af18d0a..7dc0904 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DIV_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static int s_is_power_of_two(mp_digit b, int *p)
@@ -20,7 +20,7 @@ static int s_is_power_of_two(mp_digit b, int *p)
int x;
/* quick out - if (b & (b-1)) isn't zero, b isn't a power of two */
- if ((b==0) || (b & (b-1))) {
+ if ((b == 0) || ((b & (b-1)) != 0)) {
return 0;
}
for (x = 1; x < DIGIT_BIT; x++) {
@@ -46,7 +46,7 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
}
/* quick outs */
- if (b == 1 || mp_iszero(a) == 1) {
+ if ((b == 1) || (mp_iszero(a) == MP_YES)) {
if (d != NULL) {
*d = 0;
}
@@ -108,3 +108,7 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_dr_is_modulus.c b/libtommath/bn_mp_dr_is_modulus.c
index 8ad31dc..599d929 100644
--- a/libtommath/bn_mp_dr_is_modulus.c
+++ b/libtommath/bn_mp_dr_is_modulus.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DR_IS_MODULUS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if a number is a valid DR modulus */
@@ -37,3 +37,7 @@ int mp_dr_is_modulus(mp_int *a)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_dr_reduce.c b/libtommath/bn_mp_dr_reduce.c
index 8337591..2273c79 100644
--- a/libtommath/bn_mp_dr_reduce.c
+++ b/libtommath/bn_mp_dr_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DR_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
@@ -40,7 +40,7 @@ mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k)
m = n->used;
/* ensure that "x" has at least 2m digits */
- if (x->alloc < m + m) {
+ if (x->alloc < (m + m)) {
if ((err = mp_grow (x, m + m)) != MP_OKAY) {
return err;
}
@@ -62,7 +62,7 @@ top:
/* compute (x mod B**m) + k * [x/B**m] inline and inplace */
for (i = 0; i < m; i++) {
- r = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu;
+ r = (((mp_word)*tmpx2++) * (mp_word)k) + *tmpx1 + mu;
*tmpx1++ = (mp_digit)(r & MP_MASK);
mu = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
}
@@ -82,9 +82,15 @@ top:
* Each successive "recursion" makes the input smaller and smaller.
*/
if (mp_cmp_mag (x, n) != MP_LT) {
- s_mp_sub(x, n, x);
+ if ((err = s_mp_sub(x, n, x)) != MP_OKAY) {
+ return err;
+ }
goto top;
}
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_dr_setup.c b/libtommath/bn_mp_dr_setup.c
index de00e2d..1bccb2b 100644
--- a/libtommath/bn_mp_dr_setup.c
+++ b/libtommath/bn_mp_dr_setup.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_DR_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
@@ -26,3 +26,7 @@ void mp_dr_setup(mp_int *a, mp_digit *d)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_exch.c b/libtommath/bn_mp_exch.c
index b7bd186..634193b 100644
--- a/libtommath/bn_mp_exch.c
+++ b/libtommath/bn_mp_exch.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_EXCH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* swap the elements of two integers, for cases where you can't simply swap the
@@ -28,3 +28,7 @@ mp_exch (mp_int * a, mp_int * b)
*b = t;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c
new file mode 100644
index 0000000..ac4c2f9
--- /dev/null
+++ b/libtommath/bn_mp_export.c
@@ -0,0 +1,88 @@
+#include <tommath_private.h>
+#ifdef BN_MP_EXPORT_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* based on gmp's mpz_export.
+ * see http://gmplib.org/manual/Integer-Import-and-Export.html
+ */
+int mp_export(void* rop, size_t* countp, int order, size_t size,
+ int endian, size_t nails, mp_int* op) {
+ int result;
+ size_t odd_nails, nail_bytes, i, j, bits, count;
+ unsigned char odd_nail_mask;
+
+ mp_int t;
+
+ if ((result = mp_init_copy(&t, op)) != MP_OKAY) {
+ return result;
+ }
+
+ if (endian == 0) {
+ union {
+ unsigned int i;
+ char c[4];
+ } lint;
+ lint.i = 0x01020304;
+
+ endian = (lint.c[0] == 4) ? -1 : 1;
+ }
+
+ odd_nails = (nails % 8);
+ odd_nail_mask = 0xff;
+ for (i = 0; i < odd_nails; ++i) {
+ odd_nail_mask ^= (1 << (7 - i));
+ }
+ nail_bytes = nails / 8;
+
+ bits = mp_count_bits(&t);
+ count = (bits / ((size * 8) - nails)) + (((bits % ((size * 8) - nails)) != 0) ? 1 : 0);
+
+ for (i = 0; i < count; ++i) {
+ for (j = 0; j < size; ++j) {
+ unsigned char* byte = (
+ (unsigned char*)rop +
+ (((order == -1) ? i : ((count - 1) - i)) * size) +
+ ((endian == -1) ? j : ((size - 1) - j))
+ );
+
+ if (j >= (size - nail_bytes)) {
+ *byte = 0;
+ continue;
+ }
+
+ *byte = (unsigned char)((j == ((size - nail_bytes) - 1)) ? (t.dp[0] & odd_nail_mask) : (t.dp[0] & 0xFF));
+
+ if ((result = mp_div_2d(&t, ((j == ((size - nail_bytes) - 1)) ? (8 - odd_nails) : 8), &t, NULL)) != MP_OKAY) {
+ mp_clear(&t);
+ return result;
+ }
+ }
+ }
+
+ mp_clear(&t);
+
+ if (countp != NULL) {
+ *countp = count;
+ }
+
+ return MP_OKAY;
+}
+
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_expt_d.c b/libtommath/bn_mp_expt_d.c
index 132f480..61c5a1d 100644
--- a/libtommath/bn_mp_expt_d.c
+++ b/libtommath/bn_mp_expt_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_EXPT_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,42 +12,17 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* calculate c = a**b using a square-multiply algorithm */
+/* wrapper function for mp_expt_d_ex() */
int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
{
- int res, x;
- mp_int g;
-
- if ((res = mp_init_copy (&g, a)) != MP_OKAY) {
- return res;
- }
-
- /* set initial result */
- mp_set (c, 1);
-
- for (x = 0; x < (int) DIGIT_BIT; x++) {
- /* square */
- if ((res = mp_sqr (c, c)) != MP_OKAY) {
- mp_clear (&g);
- return res;
- }
-
- /* if the bit is set multiply */
- if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) {
- if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
- mp_clear (&g);
- return res;
- }
- }
-
- /* shift to next bit */
- b <<= 1;
- }
-
- mp_clear (&g);
- return MP_OKAY;
+ return mp_expt_d_ex(a, b, c, 0);
}
+
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_expt_d_ex.c b/libtommath/bn_mp_expt_d_ex.c
new file mode 100644
index 0000000..649d224
--- /dev/null
+++ b/libtommath/bn_mp_expt_d_ex.c
@@ -0,0 +1,83 @@
+#include <tommath_private.h>
+#ifdef BN_MP_EXPT_D_EX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* calculate c = a**b using a square-multiply algorithm */
+int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
+{
+ int res;
+ unsigned int x;
+
+ mp_int g;
+
+ if ((res = mp_init_copy (&g, a)) != MP_OKAY) {
+ return res;
+ }
+
+ /* set initial result */
+ mp_set (c, 1);
+
+ if (fast != 0) {
+ while (b > 0) {
+ /* if the bit is set multiply */
+ if ((b & 1) != 0) {
+ if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
+ mp_clear (&g);
+ return res;
+ }
+ }
+
+ /* square */
+ if (b > 1) {
+ if ((res = mp_sqr (&g, &g)) != MP_OKAY) {
+ mp_clear (&g);
+ return res;
+ }
+ }
+
+ /* shift to next bit */
+ b >>= 1;
+ }
+ }
+ else {
+ for (x = 0; x < DIGIT_BIT; x++) {
+ /* square */
+ if ((res = mp_sqr (c, c)) != MP_OKAY) {
+ mp_clear (&g);
+ return res;
+ }
+
+ /* if the bit is set multiply */
+ if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) {
+ if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
+ mp_clear (&g);
+ return res;
+ }
+ }
+
+ /* shift to next bit */
+ b <<= 1;
+ }
+ } /* if ... else */
+
+ mp_clear (&g);
+ return MP_OKAY;
+}
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_exptmod.c b/libtommath/bn_mp_exptmod.c
index b7d9fb7..0973e44 100644
--- a/libtommath/bn_mp_exptmod.c
+++ b/libtommath/bn_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
@@ -89,7 +89,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
/* if the modulus is odd or dr != 0 use the montgomery method */
#ifdef BN_MP_EXPTMOD_FAST_C
- if (mp_isodd (P) == 1 || dr != 0) {
+ if ((mp_isodd (P) == MP_YES) || (dr != 0)) {
return mp_exptmod_fast (G, X, P, Y, dr);
} else {
#endif
@@ -106,3 +106,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_exptmod_fast.c b/libtommath/bn_mp_exptmod_fast.c
index 1902e79..8d280bd 100644
--- a/libtommath/bn_mp_exptmod_fast.c
+++ b/libtommath/bn_mp_exptmod_fast.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_EXPTMOD_FAST_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
@@ -96,8 +96,8 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
- if (((P->used * 2 + 1) < MP_WARRAY) &&
- P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
+ if ((((P->used * 2) + 1) < MP_WARRAY) &&
+ (P->used < (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
redux = fast_mp_montgomery_reduce;
} else
#endif
@@ -219,12 +219,12 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
* in the exponent. Technically this opt is not required but it
* does lower the # of trivial squaring/reductions used
*/
- if (mode == 0 && y == 0) {
+ if ((mode == 0) && (y == 0)) {
continue;
}
/* if the bit is zero and mode == 1 then we square */
- if (mode == 1 && y == 0) {
+ if ((mode == 1) && (y == 0)) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
goto LBL_RES;
}
@@ -266,7 +266,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
}
/* if bits remain then square/multiply */
- if (mode == 2 && bitcpy > 0) {
+ if ((mode == 2) && (bitcpy > 0)) {
/* square then multiply if the bit is set */
for (x = 0; x < bitcpy; x++) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
@@ -314,3 +314,8 @@ LBL_M:
return err;
}
#endif
+
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c
index 2e69ce1..fbbd92c 100644
--- a/libtommath/bn_mp_exteuclid.c
+++ b/libtommath/bn_mp_exteuclid.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_EXTEUCLID_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,10 +12,10 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* Extended euclidean algorithm of (a, b) produces
+/* Extended euclidean algorithm of (a, b) produces
a*u1 + b*u2 = u3
*/
int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
@@ -61,9 +61,9 @@ int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
/* make sure U3 >= 0 */
if (u3.sign == MP_NEG) {
- mp_neg(&u1, &u1);
- mp_neg(&u2, &u2);
- mp_neg(&u3, &u3);
+ if ((err = mp_neg(&u1, &u1)) != MP_OKAY) { goto _ERR; }
+ if ((err = mp_neg(&u2, &u2)) != MP_OKAY) { goto _ERR; }
+ if ((err = mp_neg(&u3, &u3)) != MP_OKAY) { goto _ERR; }
}
/* copy result out */
@@ -76,3 +76,7 @@ _ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_fread.c b/libtommath/bn_mp_fread.c
index 44e1ea8..a4fa8c9 100644
--- a/libtommath/bn_mp_fread.c
+++ b/libtommath/bn_mp_fread.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_FREAD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read a bigint from a file stream in ASCII */
@@ -61,3 +61,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_fwrite.c b/libtommath/bn_mp_fwrite.c
index b0ec29e..90f1fc5 100644
--- a/libtommath/bn_mp_fwrite.c
+++ b/libtommath/bn_mp_fwrite.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_FWRITE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
int mp_fwrite(mp_int *a, int radix, FILE *stream)
@@ -46,3 +46,7 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_gcd.c b/libtommath/bn_mp_gcd.c
index 68cfa03..16acfd9 100644
--- a/libtommath/bn_mp_gcd.c
+++ b/libtommath/bn_mp_gcd.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_GCD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Greatest Common Divisor using the binary method */
@@ -70,7 +70,7 @@ int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
}
}
- while (mp_iszero(&v) == 0) {
+ while (mp_iszero(&v) == MP_NO) {
/* make sure v is the largest */
if (mp_cmp_mag(&u, &v) == MP_GT) {
/* swap u and v to make sure v is >= u */
@@ -99,3 +99,7 @@ LBL_U:mp_clear (&v);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c
index 762cb23..99fb850 100644
--- a/libtommath/bn_mp_get_int.c
+++ b/libtommath/bn_mp_get_int.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_GET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,25 +12,25 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the lower 32-bits of an mp_int */
-unsigned long mp_get_int(mp_int * a)
+unsigned long mp_get_int(mp_int * a)
{
int i;
- unsigned long res;
+ mp_min_u32 res;
if (a->used == 0) {
return 0;
}
/* get number of digits of the lsb we have to read */
- i = MIN(a->used,(int)((sizeof(unsigned long)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1;
+ i = MIN(a->used,(int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
res = DIGIT(a,i);
-
+
while (--i >= 0) {
res = (res << DIGIT_BIT) | DIGIT(a,i);
}
@@ -39,3 +39,7 @@ unsigned long mp_get_int(mp_int * a)
return res & 0xFFFFFFFFUL;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_get_long.c b/libtommath/bn_mp_get_long.c
new file mode 100644
index 0000000..7c3d0fe
--- /dev/null
+++ b/libtommath/bn_mp_get_long.c
@@ -0,0 +1,41 @@
+#include <tommath_private.h>
+#ifdef BN_MP_GET_LONG_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* get the lower unsigned long of an mp_int, platform dependent */
+unsigned long mp_get_long(mp_int * a)
+{
+ int i;
+ unsigned long res;
+
+ if (a->used == 0) {
+ return 0;
+ }
+
+ /* get number of digits of the lsb we have to read */
+ i = MIN(a->used,(int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+
+ /* get most significant digit of result */
+ res = DIGIT(a,i);
+
+#if (ULONG_MAX != 0xffffffffuL) || (DIGIT_BIT < 32)
+ while (--i >= 0) {
+ res = (res << DIGIT_BIT) | DIGIT(a,i);
+ }
+#endif
+ return res;
+}
+#endif
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
new file mode 100644
index 0000000..4b959e6
--- /dev/null
+++ b/libtommath/bn_mp_get_long_long.c
@@ -0,0 +1,41 @@
+#include <tommath_private.h>
+#ifdef BN_MP_GET_LONG_LONG_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* get the lower unsigned long long of an mp_int, platform dependent */
+unsigned long long mp_get_long_long (mp_int * a)
+{
+ int i;
+ unsigned long long res;
+
+ if (a->used == 0) {
+ return 0;
+ }
+
+ /* get number of digits of the lsb we have to read */
+ i = MIN(a->used,(int)(((sizeof(unsigned long long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+
+ /* get most significant digit of result */
+ res = DIGIT(a,i);
+
+#if DIGIT_BIT < 64
+ while (--i >= 0) {
+ res = (res << DIGIT_BIT) | DIGIT(a,i);
+ }
+#endif
+ return res;
+}
+#endif
diff --git a/libtommath/bn_mp_grow.c b/libtommath/bn_mp_grow.c
index b5b2407..cbdcfed 100644
--- a/libtommath/bn_mp_grow.c
+++ b/libtommath/bn_mp_grow.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_GROW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* grow as required */
@@ -51,3 +51,7 @@ int mp_grow (mp_int * a, int size)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c
new file mode 100644
index 0000000..dd4b8e6
--- /dev/null
+++ b/libtommath/bn_mp_import.c
@@ -0,0 +1,73 @@
+#include <tommath_private.h>
+#ifdef BN_MP_IMPORT_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* based on gmp's mpz_import.
+ * see http://gmplib.org/manual/Integer-Import-and-Export.html
+ */
+int mp_import(mp_int* rop, size_t count, int order, size_t size,
+ int endian, size_t nails, const void* op) {
+ int result;
+ size_t odd_nails, nail_bytes, i, j;
+ unsigned char odd_nail_mask;
+
+ mp_zero(rop);
+
+ if (endian == 0) {
+ union {
+ unsigned int i;
+ char c[4];
+ } lint;
+ lint.i = 0x01020304;
+
+ endian = (lint.c[0] == 4) ? -1 : 1;
+ }
+
+ odd_nails = (nails % 8);
+ odd_nail_mask = 0xff;
+ for (i = 0; i < odd_nails; ++i) {
+ odd_nail_mask ^= (1 << (7 - i));
+ }
+ nail_bytes = nails / 8;
+
+ for (i = 0; i < count; ++i) {
+ for (j = 0; j < (size - nail_bytes); ++j) {
+ unsigned char byte = *(
+ (unsigned char*)op +
+ (((order == 1) ? i : ((count - 1) - i)) * size) +
+ ((endian == 1) ? (j + nail_bytes) : (((size - 1) - j) - nail_bytes))
+ );
+
+ if (
+ (result = mp_mul_2d(rop, ((j == 0) ? (8 - odd_nails) : 8), rop)) != MP_OKAY) {
+ return result;
+ }
+
+ rop->dp[0] |= (j == 0) ? (byte & odd_nail_mask) : byte;
+ rop->used += 1;
+ }
+ }
+
+ mp_clamp(rop);
+
+ return MP_OKAY;
+}
+
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init.c b/libtommath/bn_mp_init.c
index ddb2d07..7a57730 100644
--- a/libtommath/bn_mp_init.c
+++ b/libtommath/bn_mp_init.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init a new mp_int */
@@ -40,3 +40,7 @@ int mp_init (mp_int * a)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init_copy.c b/libtommath/bn_mp_init_copy.c
index 2410a9f..33b0e82 100644
--- a/libtommath/bn_mp_init_copy.c
+++ b/libtommath/bn_mp_init_copy.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,17 +12,21 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* creates "a" then copies b into it */
-int mp_init_copy (mp_int * a, mp_int * b)
+int mp_init_copy (mp_int * a, const mp_int * b)
{
int res;
- if ((res = mp_init (a)) != MP_OKAY) {
+ if ((res = mp_init_size (a, b->used)) != MP_OKAY) {
return res;
}
return mp_copy (b, a);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init_multi.c b/libtommath/bn_mp_init_multi.c
index 44e3fe6..52220a3 100644
--- a/libtommath/bn_mp_init_multi.c
+++ b/libtommath/bn_mp_init_multi.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
@@ -37,7 +37,7 @@ int mp_init_multi(mp_int *mp, ...)
/* now start cleaning up */
cur_arg = mp;
va_start(clean_args, mp);
- while (n--) {
+ while (n-- != 0) {
mp_clear(cur_arg);
cur_arg = va_arg(clean_args, mp_int*);
}
@@ -53,3 +53,7 @@ int mp_init_multi(mp_int *mp, ...)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init_set.c b/libtommath/bn_mp_init_set.c
index dc08867..c337e50 100644
--- a/libtommath/bn_mp_init_set.c
+++ b/libtommath/bn_mp_init_set.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
@@ -26,3 +26,7 @@ int mp_init_set (mp_int * a, mp_digit b)
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init_set_int.c b/libtommath/bn_mp_init_set_int.c
index 56b27e0..c88f14e 100644
--- a/libtommath/bn_mp_init_set_int.c
+++ b/libtommath/bn_mp_init_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
@@ -25,3 +25,7 @@ int mp_init_set_int (mp_int * a, unsigned long b)
return mp_set_int(a, b);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_init_size.c b/libtommath/bn_mp_init_size.c
index 8ed2c2a..e1d1b51 100644
--- a/libtommath/bn_mp_init_size.c
+++ b/libtommath/bn_mp_init_size.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INIT_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init an mp_init for a given size */
@@ -42,3 +42,7 @@ int mp_init_size (mp_int * a, int size)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_invmod.c b/libtommath/bn_mp_invmod.c
index fdb6c88..44951e5 100644
--- a/libtommath/bn_mp_invmod.c
+++ b/libtommath/bn_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,28 +12,32 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
{
/* b cannot be negative */
- if (b->sign == MP_NEG || mp_iszero(b) == 1) {
+ if ((b->sign == MP_NEG) || (mp_iszero(b) == MP_YES)) {
return MP_VAL;
}
#ifdef BN_FAST_MP_INVMOD_C
/* if the modulus is odd we can use a faster routine instead */
- if (mp_isodd (b) == 1) {
+ if (mp_isodd (b) == MP_YES) {
return fast_mp_invmod (a, b, c);
}
#endif
#ifdef BN_MP_INVMOD_SLOW_C
return mp_invmod_slow(a, b, c);
-#endif
-
+#else
return MP_VAL;
+#endif
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_invmod_slow.c b/libtommath/bn_mp_invmod_slow.c
index e079819..a21f947 100644
--- a/libtommath/bn_mp_invmod_slow.c
+++ b/libtommath/bn_mp_invmod_slow.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_INVMOD_SLOW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
@@ -22,7 +22,7 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
int res;
/* b cannot be negative */
- if (b->sign == MP_NEG || mp_iszero(b) == 1) {
+ if ((b->sign == MP_NEG) || (mp_iszero(b) == MP_YES)) {
return MP_VAL;
}
@@ -41,7 +41,7 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
}
/* 2. [modified] if x,y are both even then return an error! */
- if (mp_iseven (&x) == 1 && mp_iseven (&y) == 1) {
+ if ((mp_iseven (&x) == MP_YES) && (mp_iseven (&y) == MP_YES)) {
res = MP_VAL;
goto LBL_ERR;
}
@@ -58,13 +58,13 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
top:
/* 4. while u is even do */
- while (mp_iseven (&u) == 1) {
+ while (mp_iseven (&u) == MP_YES) {
/* 4.1 u = u/2 */
if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
goto LBL_ERR;
}
/* 4.2 if A or B is odd then */
- if (mp_isodd (&A) == 1 || mp_isodd (&B) == 1) {
+ if ((mp_isodd (&A) == MP_YES) || (mp_isodd (&B) == MP_YES)) {
/* A = (A+y)/2, B = (B-x)/2 */
if ((res = mp_add (&A, &y, &A)) != MP_OKAY) {
goto LBL_ERR;
@@ -83,13 +83,13 @@ top:
}
/* 5. while v is even do */
- while (mp_iseven (&v) == 1) {
+ while (mp_iseven (&v) == MP_YES) {
/* 5.1 v = v/2 */
if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
goto LBL_ERR;
}
/* 5.2 if C or D is odd then */
- if (mp_isodd (&C) == 1 || mp_isodd (&D) == 1) {
+ if ((mp_isodd (&C) == MP_YES) || (mp_isodd (&D) == MP_YES)) {
/* C = (C+y)/2, D = (D-x)/2 */
if ((res = mp_add (&C, &y, &C)) != MP_OKAY) {
goto LBL_ERR;
@@ -137,7 +137,7 @@ top:
}
/* if not zero goto step 4 */
- if (mp_iszero (&u) == 0)
+ if (mp_iszero (&u) == MP_NO)
goto top;
/* now a = C, b = D, gcd == g*v */
@@ -169,3 +169,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 926b449..9f065ef 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_IS_SQUARE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Check if remainders are possible squares - fast exclude non-squares */
@@ -82,13 +82,13 @@ int mp_is_square(mp_int *arg,int *ret)
* free "t" so the easiest way is to goto ERR. We know that res
* is already equal to MP_OKAY from the mp_mod call
*/
- if ( (1L<<(r%11)) & 0x5C4L ) goto ERR;
- if ( (1L<<(r%13)) & 0x9E4L ) goto ERR;
- if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR;
- if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR;
- if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR;
- if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR;
- if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR;
+ if (((1L<<(r%11)) & 0x5C4L) != 0L) goto ERR;
+ if (((1L<<(r%13)) & 0x9E4L) != 0L) goto ERR;
+ if (((1L<<(r%17)) & 0x5CE8L) != 0L) goto ERR;
+ if (((1L<<(r%19)) & 0x4F50CL) != 0L) goto ERR;
+ if (((1L<<(r%23)) & 0x7ACCA0L) != 0L) goto ERR;
+ if (((1L<<(r%29)) & 0xC2EDD0CL) != 0L) goto ERR;
+ if (((1L<<(r%31)) & 0x6DE2B848L) != 0L) goto ERR;
/* Final check - is sqr(sqrt(arg)) == arg ? */
if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
@@ -103,3 +103,7 @@ ERR:mp_clear(&t);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_jacobi.c b/libtommath/bn_mp_jacobi.c
index 1644698..3c114e3 100644
--- a/libtommath/bn_mp_jacobi.c
+++ b/libtommath/bn_mp_jacobi.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_JACOBI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,27 +12,39 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the jacobi c = (a | n) (or Legendre if n is prime)
* HAC pp. 73 Algorithm 2.149
+ * HAC is wrong here, as the special case of (0 | 1) is not
+ * handled correctly.
*/
-int mp_jacobi (mp_int * a, mp_int * p, int *c)
+int mp_jacobi (mp_int * a, mp_int * n, int *c)
{
mp_int a1, p1;
int k, s, r, res;
mp_digit residue;
- /* if p <= 0 return MP_VAL */
- if (mp_cmp_d(p, 0) != MP_GT) {
+ /* if a < 0 return MP_VAL */
+ if (mp_isneg(a) == MP_YES) {
return MP_VAL;
}
- /* step 1. if a == 0, return 0 */
- if (mp_iszero (a) == 1) {
- *c = 0;
- return MP_OKAY;
+ /* if n <= 0 return MP_VAL */
+ if (mp_cmp_d(n, 0) != MP_GT) {
+ return MP_VAL;
+ }
+
+ /* step 1. handle case of a == 0 */
+ if (mp_iszero (a) == MP_YES) {
+ /* special case of a == 0 and n == 1 */
+ if (mp_cmp_d (n, 1) == MP_EQ) {
+ *c = 1;
+ } else {
+ *c = 0;
+ }
+ return MP_OKAY;
}
/* step 2. if a == 1, return 1 */
@@ -64,17 +76,17 @@ int mp_jacobi (mp_int * a, mp_int * p, int *c)
s = 1;
} else {
/* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */
- residue = p->dp[0] & 7;
+ residue = n->dp[0] & 7;
- if (residue == 1 || residue == 7) {
+ if ((residue == 1) || (residue == 7)) {
s = 1;
- } else if (residue == 3 || residue == 5) {
+ } else if ((residue == 3) || (residue == 5)) {
s = -1;
}
}
/* step 5. if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */
- if ( ((p->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) {
+ if ( ((n->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) {
s = -s;
}
@@ -83,7 +95,7 @@ int mp_jacobi (mp_int * a, mp_int * p, int *c)
*c = s;
} else {
/* n1 = n mod a1 */
- if ((res = mp_mod (p, &a1, &p1)) != MP_OKAY) {
+ if ((res = mp_mod (n, &a1, &p1)) != MP_OKAY) {
goto LBL_P1;
}
if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) {
@@ -99,3 +111,7 @@ LBL_A1:mp_clear (&a1);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_karatsuba_mul.c b/libtommath/bn_mp_karatsuba_mul.c
index 0d62b9b..d65e37e 100644
--- a/libtommath/bn_mp_karatsuba_mul.c
+++ b/libtommath/bn_mp_karatsuba_mul.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_KARATSUBA_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = |a| * |b| using Karatsuba Multiplication using
@@ -82,8 +82,8 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
y1.used = b->used - B;
{
- register int x;
- register mp_digit *tmpa, *tmpb, *tmpx, *tmpy;
+ int x;
+ mp_digit *tmpa, *tmpb, *tmpx, *tmpy;
/* we copy the digits directly instead of using higher level functions
* since we also need to shift the digits
@@ -161,3 +161,7 @@ ERR:
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c
index 829405a..739840d 100644
--- a/libtommath/bn_mp_karatsuba_sqr.c
+++ b/libtommath/bn_mp_karatsuba_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_KARATSUBA_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Karatsuba squaring, computes b = a*a using three
@@ -52,8 +52,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
goto X0X0;
{
- register int x;
- register mp_digit *dst, *src;
+ int x;
+ mp_digit *dst, *src;
src = a->dp;
@@ -115,3 +115,7 @@ ERR:
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_lcm.c b/libtommath/bn_mp_lcm.c
index 1d53921..3bff571 100644
--- a/libtommath/bn_mp_lcm.c
+++ b/libtommath/bn_mp_lcm.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_LCM_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes least common multiple as |a*b|/(a, b) */
@@ -54,3 +54,7 @@ LBL_T:
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_lshd.c b/libtommath/bn_mp_lshd.c
index ce1e63b..f6f800f 100644
--- a/libtommath/bn_mp_lshd.c
+++ b/libtommath/bn_mp_lshd.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_LSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left a certain amount of digits */
@@ -26,14 +26,14 @@ int mp_lshd (mp_int * a, int b)
}
/* grow to fit the new digits */
- if (a->alloc < a->used + b) {
+ if (a->alloc < (a->used + b)) {
if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
return res;
}
}
{
- register mp_digit *top, *bottom;
+ mp_digit *top, *bottom;
/* increment the used by the shift amount then copy upwards */
a->used += b;
@@ -42,7 +42,7 @@ int mp_lshd (mp_int * a, int b)
top = a->dp + a->used - 1;
/* base */
- bottom = a->dp + a->used - 1 - b;
+ bottom = (a->dp + a->used - 1) - b;
/* much like mp_rshd this is implemented using a sliding window
* except the window goes the otherway around. Copying from
@@ -61,3 +61,7 @@ int mp_lshd (mp_int * a, int b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c
index 98e155e..b67467d 100644
--- a/libtommath/bn_mp_mod.c
+++ b/libtommath/bn_mp_mod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,10 +12,10 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* c = a mod b, 0 <= c < b */
+/* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */
int
mp_mod (mp_int * a, mp_int * b, mp_int * c)
{
@@ -31,14 +31,18 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
return res;
}
- if (t.sign != b->sign) {
- res = mp_add (b, &t, c);
- } else {
+ if ((mp_iszero(&t) != MP_NO) || (t.sign == b->sign)) {
res = MP_OKAY;
mp_exch (&t, c);
+ } else {
+ res = mp_add (b, &t, c);
}
mp_clear (&t);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mod_2d.c b/libtommath/bn_mp_mod_2d.c
index 0170f65..954d64f 100644
--- a/libtommath/bn_mp_mod_2d.c
+++ b/libtommath/bn_mp_mod_2d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MOD_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* calc a value mod 2**b */
@@ -39,7 +39,7 @@ mp_mod_2d (const mp_int * a, int b, mp_int * c)
}
/* zero digits above the last digit of the modulus */
- for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) {
+ for (x = (b / DIGIT_BIT) + (((b % DIGIT_BIT) == 0) ? 0 : 1); x < c->used; x++) {
c->dp[x] = 0;
}
/* clear the digit that is not completely outside/inside the modulus */
@@ -49,3 +49,7 @@ mp_mod_2d (const mp_int * a, int b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mod_d.c b/libtommath/bn_mp_mod_d.c
index f642ee8..d8722f0 100644
--- a/libtommath/bn_mp_mod_d.c
+++ b/libtommath/bn_mp_mod_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MOD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
int
@@ -21,3 +21,7 @@ mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
return mp_div_d(a, b, NULL, c);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_montgomery_calc_normalization.c b/libtommath/bn_mp_montgomery_calc_normalization.c
index 0748762..ea87cbd 100644
--- a/libtommath/bn_mp_montgomery_calc_normalization.c
+++ b/libtommath/bn_mp_montgomery_calc_normalization.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/*
@@ -29,7 +29,7 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
bits = mp_count_bits (b) % DIGIT_BIT;
if (b->used > 1) {
- if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
+ if ((res = mp_2expt (a, ((b->used - 1) * DIGIT_BIT) + bits - 1)) != MP_OKAY) {
return res;
}
} else {
@@ -53,3 +53,7 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c
index bc6abb8..af2cc58 100644
--- a/libtommath/bn_mp_montgomery_reduce.c
+++ b/libtommath/bn_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
@@ -28,10 +28,10 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* than the available columns [255 per default] since carries
* are fixed up in the inner loop.
*/
- digs = n->used * 2 + 1;
+ digs = (n->used * 2) + 1;
if ((digs < MP_WARRAY) &&
- n->used <
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
+ (n->used <
+ (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
return fast_mp_montgomery_reduce (x, n, rho);
}
@@ -52,13 +52,13 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
* following inner loop to reduce the
* input one digit at a time
*/
- mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK);
+ mu = (mp_digit) (((mp_word)x->dp[ix] * (mp_word)rho) & MP_MASK);
/* a = a + mu * m * b**i */
{
- register int iy;
- register mp_digit *tmpn, *tmpx, u;
- register mp_word r;
+ int iy;
+ mp_digit *tmpn, *tmpx, u;
+ mp_word r;
/* alias for digits of the modulus */
tmpn = n->dp;
@@ -72,8 +72,8 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
/* Multiply and add in place */
for (iy = 0; iy < n->used; iy++) {
/* compute product and sum */
- r = ((mp_word)mu) * ((mp_word)*tmpn++) +
- ((mp_word) u) + ((mp_word) * tmpx);
+ r = ((mp_word)mu * (mp_word)*tmpn++) +
+ (mp_word) u + (mp_word) *tmpx;
/* get carry */
u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
@@ -85,7 +85,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
/* propagate carries upwards as required*/
- while (u) {
+ while (u != 0) {
*tmpx += u;
u = *tmpx >> DIGIT_BIT;
*tmpx++ &= MP_MASK;
@@ -112,3 +112,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_montgomery_setup.c b/libtommath/bn_mp_montgomery_setup.c
index b8e1887..264a2bd 100644
--- a/libtommath/bn_mp_montgomery_setup.c
+++ b/libtommath/bn_mp_montgomery_setup.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MONTGOMERY_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* setups the montgomery reduction stuff */
@@ -36,20 +36,24 @@ mp_montgomery_setup (mp_int * n, mp_digit * rho)
}
x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
- x *= 2 - b * x; /* here x*a==1 mod 2**8 */
+ x *= 2 - (b * x); /* here x*a==1 mod 2**8 */
#if !defined(MP_8BIT)
- x *= 2 - b * x; /* here x*a==1 mod 2**16 */
+ x *= 2 - (b * x); /* here x*a==1 mod 2**16 */
#endif
#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT))
- x *= 2 - b * x; /* here x*a==1 mod 2**32 */
+ x *= 2 - (b * x); /* here x*a==1 mod 2**32 */
#endif
#ifdef MP_64BIT
- x *= 2 - b * x; /* here x*a==1 mod 2**64 */
+ x *= 2 - (b * x); /* here x*a==1 mod 2**64 */
#endif
/* rho = -1/m mod b */
- *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
+ *rho = (mp_digit)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index fc024be..ea53d5e 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level multiplication (handles sign) */
@@ -44,19 +44,24 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
#ifdef BN_FAST_S_MP_MUL_DIGS_C
if ((digs < MP_WARRAY) &&
- MIN(a->used, b->used) <=
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
+ (MIN(a->used, b->used) <=
+ (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
res = fast_s_mp_mul_digs (a, b, c, digs);
} else
#endif
+ {
#ifdef BN_S_MP_MUL_DIGS_C
res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */
#else
res = MP_VAL;
#endif
-
+ }
}
c->sign = (c->used > 0) ? neg : MP_ZPOS;
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mul_2.c b/libtommath/bn_mp_mul_2.c
index 2ca6022..9c72c7f 100644
--- a/libtommath/bn_mp_mul_2.c
+++ b/libtommath/bn_mp_mul_2.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MUL_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a*2 */
@@ -21,7 +21,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
int x, res, oldused;
/* grow to accomodate result */
- if (b->alloc < a->used + 1) {
+ if (b->alloc < (a->used + 1)) {
if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
return res;
}
@@ -31,7 +31,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
b->used = a->used;
{
- register mp_digit r, rr, *tmpa, *tmpb;
+ mp_digit r, rr, *tmpa, *tmpb;
/* alias for source */
tmpa = a->dp;
@@ -76,3 +76,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mul_2d.c b/libtommath/bn_mp_mul_2d.c
index 4ac2e4e..e9b284e 100644
--- a/libtommath/bn_mp_mul_2d.c
+++ b/libtommath/bn_mp_mul_2d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MUL_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left by a certain bit count */
@@ -28,8 +28,8 @@ int mp_mul_2d (const mp_int * a, int b, mp_int * c)
}
}
- if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) {
- if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {
+ if (c->alloc < (int)(c->used + (b / DIGIT_BIT) + 1)) {
+ if ((res = mp_grow (c, c->used + (b / DIGIT_BIT) + 1)) != MP_OKAY) {
return res;
}
}
@@ -44,8 +44,8 @@ int mp_mul_2d (const mp_int * a, int b, mp_int * c)
/* shift any bit count < DIGIT_BIT */
d = (mp_digit) (b % DIGIT_BIT);
if (d != 0) {
- register mp_digit *tmpc, shift, mask, r, rr;
- register int x;
+ mp_digit *tmpc, shift, mask, r, rr;
+ int x;
/* bitmask for carries */
mask = (((mp_digit)1) << d) - 1;
@@ -79,3 +79,7 @@ int mp_mul_2d (const mp_int * a, int b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c
index ba45a0c..e77da5d 100644
--- a/libtommath/bn_mp_mul_d.c
+++ b/libtommath/bn_mp_mul_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MUL_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiply by a digit */
@@ -24,7 +24,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
int ix, res, olduse;
/* make sure c is big enough to hold a*b */
- if (c->alloc < a->used + 1) {
+ if (c->alloc < (a->used + 1)) {
if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) {
return res;
}
@@ -48,7 +48,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
/* compute columns */
for (ix = 0; ix < a->used; ix++) {
/* compute product and carry sum for this term */
- r = ((mp_word) u) + ((mp_word)*tmpa++) * ((mp_word)b);
+ r = (mp_word)u + ((mp_word)*tmpa++ * (mp_word)b);
/* mask off higher bits to get a single digit */
*tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK));
@@ -73,3 +73,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_mulmod.c b/libtommath/bn_mp_mulmod.c
index 649b717..5ea88ef 100644
--- a/libtommath/bn_mp_mulmod.c
+++ b/libtommath/bn_mp_mulmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_MULMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a * b (mod c) */
@@ -34,3 +34,7 @@ int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_n_root.c b/libtommath/bn_mp_n_root.c
index b2700a8..a14ee67 100644
--- a/libtommath/bn_mp_n_root.c
+++ b/libtommath/bn_mp_n_root.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_N_ROOT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,117 +12,19 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* find the n'th root of an integer
- *
- * Result found such that (c)**b <= a and (c+1)**b > a
- *
- * This algorithm uses Newton's approximation
- * x[i+1] = x[i] - f(x[i])/f'(x[i])
- * which will find the root in log(N) time where
- * each step involves a fair bit. This is not meant to
- * find huge roots [square and cube, etc].
+/* wrapper function for mp_n_root_ex()
+ * computes c = (a)**(1/b) such that (c)**b <= a and (c+1)**b > a
*/
int mp_n_root (mp_int * a, mp_digit b, mp_int * c)
{
- mp_int t1, t2, t3;
- int res, neg;
-
- /* input must be positive if b is even */
- if ((b & 1) == 0 && a->sign == MP_NEG) {
- return MP_VAL;
- }
-
- if ((res = mp_init (&t1)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init (&t2)) != MP_OKAY) {
- goto LBL_T1;
- }
-
- if ((res = mp_init (&t3)) != MP_OKAY) {
- goto LBL_T2;
- }
-
- /* if a is negative fudge the sign but keep track */
- neg = a->sign;
- a->sign = MP_ZPOS;
-
- /* t2 = 2 */
- mp_set (&t2, 2);
-
- do {
- /* t1 = t2 */
- if ((res = mp_copy (&t2, &t1)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */
-
- /* t3 = t1**(b-1) */
- if ((res = mp_expt_d (&t1, b - 1, &t3)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* numerator */
- /* t2 = t1**b */
- if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t2 = t1**b - a */
- if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* denominator */
- /* t3 = t1**(b-1) * b */
- if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t3 = (t1**b - a)/(b * t1**(b-1)) */
- if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
- } while (mp_cmp (&t1, &t2) != MP_EQ);
-
- /* result can be off by a few so check */
- for (;;) {
- if ((res = mp_expt_d (&t1, b, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- if (mp_cmp (&t2, a) == MP_GT) {
- if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) {
- goto LBL_T3;
- }
- } else {
- break;
- }
- }
-
- /* reset the sign of a first */
- a->sign = neg;
-
- /* set the result */
- mp_exch (&t1, c);
-
- /* set the sign of the result */
- c->sign = neg;
-
- res = MP_OKAY;
-
-LBL_T3:mp_clear (&t3);
-LBL_T2:mp_clear (&t2);
-LBL_T1:mp_clear (&t1);
- return res;
+ return mp_n_root_ex(a, b, c, 0);
}
+
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_n_root_ex.c b/libtommath/bn_mp_n_root_ex.c
new file mode 100644
index 0000000..79d1dfb
--- /dev/null
+++ b/libtommath/bn_mp_n_root_ex.c
@@ -0,0 +1,132 @@
+#include <tommath_private.h>
+#ifdef BN_MP_N_ROOT_EX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* find the n'th root of an integer
+ *
+ * Result found such that (c)**b <= a and (c+1)**b > a
+ *
+ * This algorithm uses Newton's approximation
+ * x[i+1] = x[i] - f(x[i])/f'(x[i])
+ * which will find the root in log(N) time where
+ * each step involves a fair bit. This is not meant to
+ * find huge roots [square and cube, etc].
+ */
+int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
+{
+ mp_int t1, t2, t3;
+ int res, neg;
+
+ /* input must be positive if b is even */
+ if (((b & 1) == 0) && (a->sign == MP_NEG)) {
+ return MP_VAL;
+ }
+
+ if ((res = mp_init (&t1)) != MP_OKAY) {
+ return res;
+ }
+
+ if ((res = mp_init (&t2)) != MP_OKAY) {
+ goto LBL_T1;
+ }
+
+ if ((res = mp_init (&t3)) != MP_OKAY) {
+ goto LBL_T2;
+ }
+
+ /* if a is negative fudge the sign but keep track */
+ neg = a->sign;
+ a->sign = MP_ZPOS;
+
+ /* t2 = 2 */
+ mp_set (&t2, 2);
+
+ do {
+ /* t1 = t2 */
+ if ((res = mp_copy (&t2, &t1)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */
+
+ /* t3 = t1**(b-1) */
+ if ((res = mp_expt_d_ex (&t1, b - 1, &t3, fast)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ /* numerator */
+ /* t2 = t1**b */
+ if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ /* t2 = t1**b - a */
+ if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ /* denominator */
+ /* t3 = t1**(b-1) * b */
+ if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ /* t3 = (t1**b - a)/(b * t1**(b-1)) */
+ if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+ } while (mp_cmp (&t1, &t2) != MP_EQ);
+
+ /* result can be off by a few so check */
+ for (;;) {
+ if ((res = mp_expt_d_ex (&t1, b, &t2, fast)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+
+ if (mp_cmp (&t2, a) == MP_GT) {
+ if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) {
+ goto LBL_T3;
+ }
+ } else {
+ break;
+ }
+ }
+
+ /* reset the sign of a first */
+ a->sign = neg;
+
+ /* set the result */
+ mp_exch (&t1, c);
+
+ /* set the sign of the result */
+ c->sign = neg;
+
+ res = MP_OKAY;
+
+LBL_T3:mp_clear (&t3);
+LBL_T2:mp_clear (&t2);
+LBL_T1:mp_clear (&t1);
+ return res;
+}
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_neg.c b/libtommath/bn_mp_neg.c
index 07fb148..952a991 100644
--- a/libtommath/bn_mp_neg.c
+++ b/libtommath/bn_mp_neg.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_NEG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = -a */
@@ -34,3 +34,7 @@ int mp_neg (const mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_or.c b/libtommath/bn_mp_or.c
index aa5b1bd..b7f2e4f 100644
--- a/libtommath/bn_mp_or.c
+++ b/libtommath/bn_mp_or.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_OR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* OR two ints together */
@@ -44,3 +44,7 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_fermat.c b/libtommath/bn_mp_prime_fermat.c
index 7b9b12e..9dc9e85 100644
--- a/libtommath/bn_mp_prime_fermat.c
+++ b/libtommath/bn_mp_prime_fermat.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_FERMAT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs one Fermat test.
@@ -56,3 +56,7 @@ LBL_T:mp_clear (&t);
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_is_divisible.c b/libtommath/bn_mp_prime_is_divisible.c
index 710c967..5854f08 100644
--- a/libtommath/bn_mp_prime_is_divisible.c
+++ b/libtommath/bn_mp_prime_is_divisible.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if an integers is divisible by one
@@ -44,3 +44,7 @@ int mp_prime_is_divisible (mp_int * a, int *result)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c
index ce225a3..be5ebe4 100644
--- a/libtommath/bn_mp_prime_is_prime.c
+++ b/libtommath/bn_mp_prime_is_prime.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_IS_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs a variable number of rounds of Miller-Rabin
@@ -31,7 +31,7 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
*result = MP_NO;
/* valid value of t? */
- if (t <= 0 || t > PRIME_SIZE) {
+ if ((t <= 0) || (t > PRIME_SIZE)) {
return MP_VAL;
}
@@ -77,3 +77,7 @@ LBL_B:mp_clear (&b);
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_miller_rabin.c b/libtommath/bn_mp_prime_miller_rabin.c
index c5185b8..7b5c8d2 100644
--- a/libtommath/bn_mp_prime_miller_rabin.c
+++ b/libtommath/bn_mp_prime_miller_rabin.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_MILLER_RABIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Miller-Rabin test of "a" to the base of "b" as described in
@@ -67,10 +67,10 @@ int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
}
/* if y != 1 and y != n1 do */
- if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) {
+ if ((mp_cmp_d (&y, 1) != MP_EQ) && (mp_cmp (&y, &n1) != MP_EQ)) {
j = 1;
/* while j <= s-1 and y != n1 */
- while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) {
+ while ((j <= (s - 1)) && (mp_cmp (&y, &n1) != MP_EQ)) {
if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
goto LBL_Y;
}
@@ -97,3 +97,7 @@ LBL_N1:mp_clear (&n1);
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_next_prime.c b/libtommath/bn_mp_prime_next_prime.c
index 2433e8c..9951dc3 100644
--- a/libtommath/bn_mp_prime_next_prime.c
+++ b/libtommath/bn_mp_prime_next_prime.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_NEXT_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* finds the next prime after the number "a" using "t" trials
@@ -22,12 +22,12 @@
*/
int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
{
- int err, res, x, y;
+ int err, res = MP_NO, x, y;
mp_digit res_tab[PRIME_SIZE], step, kstep;
mp_int b;
/* ensure t is valid */
- if (t <= 0 || t > PRIME_SIZE) {
+ if ((t <= 0) || (t > PRIME_SIZE)) {
return MP_VAL;
}
@@ -84,7 +84,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
if ((err = mp_sub_d(a, (a->dp[0] & 3) + 1, a)) != MP_OKAY) { return err; };
}
} else {
- if (mp_iseven(a) == 1) {
+ if (mp_iseven(a) == MP_YES) {
/* force odd */
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) {
return err;
@@ -129,7 +129,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
y = 1;
}
}
- } while (y == 1 && step < ((((mp_digit)1)<<DIGIT_BIT) - kstep));
+ } while ((y == 1) && (step < ((((mp_digit)1) << DIGIT_BIT) - kstep)));
/* add the step */
if ((err = mp_add_d(a, step, a)) != MP_OKAY) {
@@ -137,7 +137,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
}
/* if didn't pass sieve and step == MAX then skip test */
- if (y == 1 && step >= ((((mp_digit)1)<<DIGIT_BIT) - kstep)) {
+ if ((y == 1) && (step >= ((((mp_digit)1) << DIGIT_BIT) - kstep))) {
continue;
}
@@ -164,3 +164,7 @@ LBL_ERR:
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_rabin_miller_trials.c b/libtommath/bn_mp_prime_rabin_miller_trials.c
index e57a43c..bca4229 100644
--- a/libtommath/bn_mp_prime_rabin_miller_trials.c
+++ b/libtommath/bn_mp_prime_rabin_miller_trials.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
@@ -46,3 +46,7 @@ int mp_prime_rabin_miller_trials(int size)
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_prime_random_ex.c b/libtommath/bn_mp_prime_random_ex.c
index a37477e..1efc4fc 100644
--- a/libtommath/bn_mp_prime_random_ex.c
+++ b/libtommath/bn_mp_prime_random_ex.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_PRIME_RANDOM_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* makes a truly random prime of a given size (bits),
@@ -21,7 +21,6 @@
*
* LTM_PRIME_BBS - make prime congruent to 3 mod 4
* LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
* LTM_PRIME_2MSB_ON - make the 2nd highest bit one
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
@@ -37,12 +36,12 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
int res, err, bsize, maskOR_msb_offset;
/* sanity check the input */
- if (size <= 1 || t <= 0) {
+ if ((size <= 1) || (t <= 0)) {
return MP_VAL;
}
/* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
- if (flags & LTM_PRIME_SAFE) {
+ if ((flags & LTM_PRIME_SAFE) != 0) {
flags |= LTM_PRIME_BBS;
}
@@ -61,13 +60,13 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
/* calc the maskOR_msb */
maskOR_msb = 0;
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
- if (flags & LTM_PRIME_2MSB_ON) {
+ if ((flags & LTM_PRIME_2MSB_ON) != 0) {
maskOR_msb |= 0x80 >> ((9 - size) & 7);
}
/* get the maskOR_lsb */
maskOR_lsb = 1;
- if (flags & LTM_PRIME_BBS) {
+ if ((flags & LTM_PRIME_BBS) != 0) {
maskOR_lsb |= 3;
}
@@ -95,7 +94,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
continue;
}
- if (flags & LTM_PRIME_SAFE) {
+ if ((flags & LTM_PRIME_SAFE) != 0) {
/* see if (a-1)/2 is prime */
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
@@ -105,7 +104,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
}
} while (res == MP_NO);
- if (flags & LTM_PRIME_SAFE) {
+ if ((flags & LTM_PRIME_SAFE) != 0) {
/* restore a to the original value */
if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }
@@ -119,3 +118,7 @@ error:
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c
index 40c4d04..d4a02e8 100644
--- a/libtommath/bn_mp_radix_size.c
+++ b/libtommath/bn_mp_radix_size.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_RADIX_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,11 +12,11 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns size of ASCII reprensentation */
-int mp_radix_size (mp_int * a, int radix, int *size)
+int mp_radix_size (const mp_int * a, int radix, int *size)
{
int res, digs;
mp_int t;
@@ -24,14 +24,8 @@ int mp_radix_size (mp_int * a, int radix, int *size)
*size = 0;
- /* special case for binary */
- if (radix == 2) {
- *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1;
- return MP_OKAY;
- }
-
/* make sure the radix is in range */
- if (radix < 2 || radix > 64) {
+ if ((radix < 2) || (radix > 64)) {
return MP_VAL;
}
@@ -40,6 +34,12 @@ int mp_radix_size (mp_int * a, int radix, int *size)
return MP_OKAY;
}
+ /* special case for binary */
+ if (radix == 2) {
+ *size = mp_count_bits (a) + ((a->sign == MP_NEG) ? 1 : 0) + 1;
+ return MP_OKAY;
+ }
+
/* digs is the digit count */
digs = 0;
@@ -66,18 +66,13 @@ int mp_radix_size (mp_int * a, int radix, int *size)
}
mp_clear (&t);
- /*
- * return digs + 1, the 1 is for the NULL byte that would be required.
- * mp_toradix_n requires a minimum of 3 bytes, so never report less than
- * that.
- */
-
- if ( digs >= 2 ) {
- *size = digs + 1;
- } else {
- *size = 3;
- }
+ /* return digs + 1, the 1 is for the NULL byte that would be required. */
+ *size = digs + 1;
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_radix_smap.c b/libtommath/bn_mp_radix_smap.c
index 7aeb375..d1c75ad 100644
--- a/libtommath/bn_mp_radix_smap.c
+++ b/libtommath/bn_mp_radix_smap.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_RADIX_SMAP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,9 +12,13 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* chars used in radix conversions */
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_rand.c b/libtommath/bn_mp_rand.c
index 17c1fbe..4c9610d 100644
--- a/libtommath/bn_mp_rand.c
+++ b/libtommath/bn_mp_rand.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_RAND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* makes a pseudo-random int of a given size */
@@ -29,7 +29,7 @@ mp_rand (mp_int * a, int digits)
/* first place a random non-zero digit */
do {
- d = ((mp_digit) abs (rand ())) & MP_MASK;
+ d = ((mp_digit) abs (MP_GEN_RANDOM())) & MP_MASK;
} while (d == 0);
if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
@@ -41,7 +41,7 @@ mp_rand (mp_int * a, int digits)
return res;
}
- if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) {
+ if ((res = mp_add_d (a, ((mp_digit) abs (MP_GEN_RANDOM())), a)) != MP_OKAY) {
return res;
}
}
@@ -49,3 +49,7 @@ mp_rand (mp_int * a, int digits)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c
index 4b92589..93ccd3b 100644
--- a/libtommath/bn_mp_read_radix.c
+++ b/libtommath/bn_mp_read_radix.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_READ_RADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read a string [ASCII] in a given radix */
@@ -25,7 +25,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
mp_zero(a);
/* make sure the radix is ok */
- if (radix < 2 || radix > 64) {
+ if ((radix < 2) || (radix > 64)) {
return MP_VAL;
}
@@ -43,12 +43,12 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
mp_zero (a);
/* process each digit of the string */
- while (*str) {
- /* if the radix < 36 the conversion is case insensitive
+ while (*str != '\0') {
+ /* if the radix <= 36 the conversion is case insensitive
* this allows numbers like 1AB and 1ab to represent the same value
* [e.g. in hex]
*/
- ch = (char) ((radix < 36) ? toupper ((unsigned char) *str) : *str);
+ ch = (radix <= 36) ? (char)toupper((unsigned char)*str) : *str;
for (y = 0; y < 64; y++) {
if (ch == mp_s_rmap[y]) {
break;
@@ -80,9 +80,13 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
}
/* set the sign only if a != 0 */
- if (mp_iszero(a) != 1) {
+ if (mp_iszero(a) != MP_YES) {
a->sign = neg;
}
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_read_signed_bin.c b/libtommath/bn_mp_read_signed_bin.c
index 3ee8556..a4d4760 100644
--- a/libtommath/bn_mp_read_signed_bin.c
+++ b/libtommath/bn_mp_read_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_READ_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
@@ -35,3 +35,7 @@ int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_read_unsigned_bin.c b/libtommath/bn_mp_read_unsigned_bin.c
index caf5be0..e8e5df8 100644
--- a/libtommath/bn_mp_read_unsigned_bin.c
+++ b/libtommath/bn_mp_read_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_READ_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
@@ -37,15 +37,19 @@ int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
}
#ifndef MP_8BIT
- a->dp[0] |= *b++;
- a->used += 1;
+ a->dp[0] |= *b++;
+ a->used += 1;
#else
- a->dp[0] = (*b & MP_MASK);
- a->dp[1] |= ((*b++ >> 7U) & 1);
- a->used += 2;
+ a->dp[0] = (*b & MP_MASK);
+ a->dp[1] |= ((*b++ >> 7U) & 1);
+ a->used += 2;
#endif
}
mp_clamp (a);
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce.c b/libtommath/bn_mp_reduce.c
index 4375e4e..e2c3a58 100644
--- a/libtommath/bn_mp_reduce.c
+++ b/libtommath/bn_mp_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,10 +12,10 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* reduces x mod m, assumes 0 < x < m**2, mu is
+/* reduces x mod m, assumes 0 < x < m**2, mu is
* precomputed via mp_reduce_setup.
* From HAC pp.604 Algorithm 14.42
*/
@@ -30,10 +30,10 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
}
/* q1 = x / b**(k-1) */
- mp_rshd (&q, um - 1);
+ mp_rshd (&q, um - 1);
/* according to HAC this optimization is ok */
- if (((unsigned long) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
+ if (((mp_digit) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
goto CLEANUP;
}
@@ -46,8 +46,8 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
goto CLEANUP;
}
-#else
- {
+#else
+ {
res = MP_VAL;
goto CLEANUP;
}
@@ -55,7 +55,7 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
}
/* q3 = q2 / b**(k+1) */
- mp_rshd (&q, um + 1);
+ mp_rshd (&q, um + 1);
/* x = x mod b**(k+1), quick (no division) */
if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
@@ -87,10 +87,14 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
goto CLEANUP;
}
}
-
+
CLEANUP:
mp_clear (&q);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_2k.c b/libtommath/bn_mp_reduce_2k.c
index 428f2ff..2876a75 100644
--- a/libtommath/bn_mp_reduce_2k.c
+++ b/libtommath/bn_mp_reduce_2k.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces a modulo n where n is of the form 2**p - d */
@@ -20,38 +20,44 @@ int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d)
{
mp_int q;
int p, res;
-
+
if ((res = mp_init(&q)) != MP_OKAY) {
return res;
}
-
- p = mp_count_bits(n);
+
+ p = mp_count_bits(n);
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
goto ERR;
}
-
+
if (d != 1) {
/* q = q * d */
- if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
+ if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
goto ERR;
}
}
-
+
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
goto ERR;
}
-
+
if (mp_cmp_mag(a, n) != MP_LT) {
- s_mp_sub(a, n, a);
+ if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
+ goto ERR;
+ }
goto top;
}
-
+
ERR:
mp_clear(&q);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_2k_l.c b/libtommath/bn_mp_reduce_2k_l.c
index 8e52efa..3225214 100644
--- a/libtommath/bn_mp_reduce_2k_l.c
+++ b/libtommath/bn_mp_reduce_2k_l.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,10 +12,10 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* reduces a modulo n where n is of the form 2**p - d
+/* reduces a modulo n where n is of the form 2**p - d
This differs from reduce_2k since "d" can be larger
than a single digit.
*/
@@ -23,36 +23,42 @@ int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d)
{
mp_int q;
int p, res;
-
+
if ((res = mp_init(&q)) != MP_OKAY) {
return res;
}
-
- p = mp_count_bits(n);
+
+ p = mp_count_bits(n);
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
goto ERR;
}
-
+
/* q = q * d */
- if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
+ if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
goto ERR;
}
-
+
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
goto ERR;
}
-
+
if (mp_cmp_mag(a, n) != MP_LT) {
- s_mp_sub(a, n, a);
+ if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
+ goto ERR;
+ }
goto top;
}
-
+
ERR:
mp_clear(&q);
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_2k_setup.c b/libtommath/bn_mp_reduce_2k_setup.c
index ac043f6..545051e 100644
--- a/libtommath/bn_mp_reduce_2k_setup.c
+++ b/libtommath/bn_mp_reduce_2k_setup.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_2K_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
@@ -41,3 +41,7 @@ int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_2k_setup_l.c b/libtommath/bn_mp_reduce_2k_setup_l.c
index b59a1ed..59132dd 100644
--- a/libtommath/bn_mp_reduce_2k_setup_l.c
+++ b/libtommath/bn_mp_reduce_2k_setup_l.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_2K_SETUP_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
@@ -38,3 +38,7 @@ ERR:
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_is_2k.c b/libtommath/bn_mp_reduce_is_2k.c
index 4655fcf..784947b 100644
--- a/libtommath/bn_mp_reduce_is_2k.c
+++ b/libtommath/bn_mp_reduce_is_2k.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_IS_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if mp_reduce_2k can be used */
@@ -46,3 +46,7 @@ int mp_reduce_is_2k(mp_int *a)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_is_2k_l.c b/libtommath/bn_mp_reduce_is_2k_l.c
index 7b57865..c193f39 100644
--- a/libtommath/bn_mp_reduce_is_2k_l.c
+++ b/libtommath/bn_mp_reduce_is_2k_l.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_IS_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if reduce_2k_l can be used */
@@ -38,3 +38,7 @@ int mp_reduce_is_2k_l(mp_int *a)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_reduce_setup.c b/libtommath/bn_mp_reduce_setup.c
index d8cefd9..f97eed5 100644
--- a/libtommath/bn_mp_reduce_setup.c
+++ b/libtommath/bn_mp_reduce_setup.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_REDUCE_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* pre-calculate the value required for Barrett reduction
@@ -28,3 +28,7 @@ int mp_reduce_setup (mp_int * a, mp_int * b)
return mp_div (a, b, a, NULL);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_rshd.c b/libtommath/bn_mp_rshd.c
index e6095b3..77b0f6c 100644
--- a/libtommath/bn_mp_rshd.c
+++ b/libtommath/bn_mp_rshd.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_RSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right a certain amount of digits */
@@ -32,7 +32,7 @@ void mp_rshd (mp_int * a, int b)
}
{
- register mp_digit *bottom, *top;
+ mp_digit *bottom, *top;
/* shift the digits down */
@@ -66,3 +66,7 @@ void mp_rshd (mp_int * a, int b)
a->used -= b;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_set.c b/libtommath/bn_mp_set.c
index c32fc42..cac48ea 100644
--- a/libtommath/bn_mp_set.c
+++ b/libtommath/bn_mp_set.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to a digit */
@@ -23,3 +23,7 @@ void mp_set (mp_int * a, mp_digit b)
a->used = (a->dp[0] != 0) ? 1 : 0;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_set_int.c b/libtommath/bn_mp_set_int.c
index b0fc344..5aa59d5 100644
--- a/libtommath/bn_mp_set_int.c
+++ b/libtommath/bn_mp_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set a 32-bit const */
@@ -42,3 +42,7 @@ int mp_set_int (mp_int * a, unsigned long b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_set_long.c b/libtommath/bn_mp_set_long.c
new file mode 100644
index 0000000..281fce7
--- /dev/null
+++ b/libtommath/bn_mp_set_long.c
@@ -0,0 +1,24 @@
+#include <tommath_private.h>
+#ifdef BN_MP_SET_LONG_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* set a platform dependent unsigned long int */
+MP_SET_XLONG(mp_set_long, unsigned long)
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_set_long_long.c b/libtommath/bn_mp_set_long_long.c
new file mode 100644
index 0000000..3c4b01a
--- /dev/null
+++ b/libtommath/bn_mp_set_long_long.c
@@ -0,0 +1,24 @@
+#include <tommath_private.h>
+#ifdef BN_MP_SET_LONG_LONG_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
+ */
+
+/* set a platform dependent unsigned long long int */
+MP_SET_XLONG(mp_set_long_long, unsigned long long)
+#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_shrink.c b/libtommath/bn_mp_shrink.c
index bfdf93a..1ad2ede 100644
--- a/libtommath/bn_mp_shrink.c
+++ b/libtommath/bn_mp_shrink.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SHRINK_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shrink a bignum */
@@ -21,8 +21,9 @@ int mp_shrink (mp_int * a)
mp_digit *tmp;
int used = 1;
- if(a->used > 0)
+ if(a->used > 0) {
used = a->used;
+ }
if (a->alloc != used) {
if ((tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * used)) == NULL) {
@@ -34,3 +35,7 @@ int mp_shrink (mp_int * a)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_signed_bin_size.c b/libtommath/bn_mp_signed_bin_size.c
index 8f88e76..0e760a6 100644
--- a/libtommath/bn_mp_signed_bin_size.c
+++ b/libtommath/bn_mp_signed_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an signed equivalent */
@@ -21,3 +21,7 @@ int mp_signed_bin_size (mp_int * a)
return 1 + mp_unsigned_bin_size (a);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index 3938537..ad2099b 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes b = a*a */
@@ -29,26 +29,32 @@ mp_sqr (mp_int * a, mp_int * b)
} else
#endif
#ifdef BN_MP_KARATSUBA_SQR_C
-if (a->used >= KARATSUBA_SQR_CUTOFF) {
+ if (a->used >= KARATSUBA_SQR_CUTOFF) {
res = mp_karatsuba_sqr (a, b);
} else
#endif
{
#ifdef BN_FAST_S_MP_SQR_C
/* can we use the fast comba multiplier? */
- if ((a->used * 2 + 1) < MP_WARRAY &&
- a->used <
- (1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) {
+ if ((((a->used * 2) + 1) < MP_WARRAY) &&
+ (a->used <
+ (1 << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) - 1)))) {
res = fast_s_mp_sqr (a, b);
} else
#endif
+ {
#ifdef BN_S_MP_SQR_C
res = s_mp_sqr (a, b);
#else
res = MP_VAL;
#endif
+ }
}
b->sign = MP_ZPOS;
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_sqrmod.c b/libtommath/bn_mp_sqrmod.c
index 6f90772..2f9463d 100644
--- a/libtommath/bn_mp_sqrmod.c
+++ b/libtommath/bn_mp_sqrmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SQRMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = a * a (mod b) */
@@ -35,3 +35,7 @@ mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c
index 016b8ba..7c9d25d 100644
--- a/libtommath/bn_mp_sqrt.c
+++ b/libtommath/bn_mp_sqrt.c
@@ -1,5 +1,4 @@
-#include <tommath.h>
-
+#include <tommath_private.h>
#ifdef BN_MP_SQRT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -13,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef NO_FLOATING_POINT
@@ -140,3 +139,7 @@ E2: mp_clear(&t1);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_sqrtmod_prime.c b/libtommath/bn_mp_sqrtmod_prime.c
new file mode 100644
index 0000000..968729e
--- /dev/null
+++ b/libtommath/bn_mp_sqrtmod_prime.c
@@ -0,0 +1,124 @@
+#include <tommath_private.h>
+#ifdef BN_MP_SQRTMOD_PRIME_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* Tonelli-Shanks algorithm
+ * https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm
+ * https://gmplib.org/list-archives/gmp-discuss/2013-April/005300.html
+ *
+ */
+
+int mp_sqrtmod_prime(mp_int *n, mp_int *prime, mp_int *ret)
+{
+ int res, legendre;
+ mp_int t1, C, Q, S, Z, M, T, R, two;
+ mp_digit i;
+
+ /* first handle the simple cases */
+ if (mp_cmp_d(n, 0) == MP_EQ) {
+ mp_zero(ret);
+ return MP_OKAY;
+ }
+ if (mp_cmp_d(prime, 2) == MP_EQ) return MP_VAL; /* prime must be odd */
+ if ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY) return res;
+ if (legendre == -1) return MP_VAL; /* quadratic non-residue mod prime */
+
+ if ((res = mp_init_multi(&t1, &C, &Q, &S, &Z, &M, &T, &R, &two, NULL)) != MP_OKAY) {
+ return res;
+ }
+
+ /* SPECIAL CASE: if prime mod 4 == 3
+ * compute directly: res = n^(prime+1)/4 mod prime
+ * Handbook of Applied Cryptography algorithm 3.36
+ */
+ if ((res = mp_mod_d(prime, 4, &i)) != MP_OKAY) goto cleanup;
+ if (i == 3) {
+ if ((res = mp_add_d(prime, 1, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_exptmod(n, &t1, prime, ret)) != MP_OKAY) goto cleanup;
+ res = MP_OKAY;
+ goto cleanup;
+ }
+
+ /* NOW: Tonelli-Shanks algorithm */
+
+ /* factor out powers of 2 from prime-1, defining Q and S as: prime-1 = Q*2^S */
+ if ((res = mp_copy(prime, &Q)) != MP_OKAY) goto cleanup;
+ if ((res = mp_sub_d(&Q, 1, &Q)) != MP_OKAY) goto cleanup;
+ /* Q = prime - 1 */
+ mp_zero(&S);
+ /* S = 0 */
+ while (mp_iseven(&Q) != MP_NO) {
+ if ((res = mp_div_2(&Q, &Q)) != MP_OKAY) goto cleanup;
+ /* Q = Q / 2 */
+ if ((res = mp_add_d(&S, 1, &S)) != MP_OKAY) goto cleanup;
+ /* S = S + 1 */
+ }
+
+ /* find a Z such that the Legendre symbol (Z|prime) == -1 */
+ if ((res = mp_set_int(&Z, 2)) != MP_OKAY) goto cleanup;
+ /* Z = 2 */
+ while(1) {
+ if ((res = mp_jacobi(&Z, prime, &legendre)) != MP_OKAY) goto cleanup;
+ if (legendre == -1) break;
+ if ((res = mp_add_d(&Z, 1, &Z)) != MP_OKAY) goto cleanup;
+ /* Z = Z + 1 */
+ }
+
+ if ((res = mp_exptmod(&Z, &Q, prime, &C)) != MP_OKAY) goto cleanup;
+ /* C = Z ^ Q mod prime */
+ if ((res = mp_add_d(&Q, 1, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
+ /* t1 = (Q + 1) / 2 */
+ if ((res = mp_exptmod(n, &t1, prime, &R)) != MP_OKAY) goto cleanup;
+ /* R = n ^ ((Q + 1) / 2) mod prime */
+ if ((res = mp_exptmod(n, &Q, prime, &T)) != MP_OKAY) goto cleanup;
+ /* T = n ^ Q mod prime */
+ if ((res = mp_copy(&S, &M)) != MP_OKAY) goto cleanup;
+ /* M = S */
+ if ((res = mp_set_int(&two, 2)) != MP_OKAY) goto cleanup;
+
+ res = MP_VAL;
+ while (1) {
+ if ((res = mp_copy(&T, &t1)) != MP_OKAY) goto cleanup;
+ i = 0;
+ while (1) {
+ if (mp_cmp_d(&t1, 1) == MP_EQ) break;
+ if ((res = mp_exptmod(&t1, &two, prime, &t1)) != MP_OKAY) goto cleanup;
+ i++;
+ }
+ if (i == 0) {
+ if ((res = mp_copy(&R, ret)) != MP_OKAY) goto cleanup;
+ res = MP_OKAY;
+ goto cleanup;
+ }
+ if ((res = mp_sub_d(&M, i, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) goto cleanup;
+ if ((res = mp_exptmod(&two, &t1, prime, &t1)) != MP_OKAY) goto cleanup;
+ /* t1 = 2 ^ (M - i - 1) */
+ if ((res = mp_exptmod(&C, &t1, prime, &t1)) != MP_OKAY) goto cleanup;
+ /* t1 = C ^ (2 ^ (M - i - 1)) mod prime */
+ if ((res = mp_sqrmod(&t1, prime, &C)) != MP_OKAY) goto cleanup;
+ /* C = (t1 * t1) mod prime */
+ if ((res = mp_mulmod(&R, &t1, prime, &R)) != MP_OKAY) goto cleanup;
+ /* R = (R * t1) mod prime */
+ if ((res = mp_mulmod(&T, &C, prime, &T)) != MP_OKAY) goto cleanup;
+ /* T = (T * C) mod prime */
+ mp_set(&M, i);
+ /* M = i */
+ }
+
+cleanup:
+ mp_clear_multi(&t1, &C, &Q, &S, &Z, &M, &T, &R, &two, NULL);
+ return res;
+}
+
+#endif
diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c
index 13cb43e..0d616c2 100644
--- a/libtommath/bn_mp_sub.c
+++ b/libtommath/bn_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level subtraction (handles signs) */
@@ -53,3 +53,7 @@ mp_sub (mp_int * a, mp_int * b, mp_int * c)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_sub_d.c b/libtommath/bn_mp_sub_d.c
index b1e4e3f..f5a932f 100644
--- a/libtommath/bn_mp_sub_d.c
+++ b/libtommath/bn_mp_sub_d.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SUB_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit subtraction */
@@ -23,7 +23,7 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
int res, ix, oldused;
/* grow c as required */
- if (c->alloc < a->used + 1) {
+ if (c->alloc < (a->used + 1)) {
if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
return res;
}
@@ -49,7 +49,7 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
tmpc = c->dp;
/* if a <= b simply fix the single digit */
- if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) {
+ if (((a->used == 1) && (a->dp[0] <= b)) || (a->used == 0)) {
if (a->used == 1) {
*tmpc++ = b - *tmpa;
} else {
@@ -67,13 +67,13 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
/* subtract first digit */
*tmpc = *tmpa++ - b;
- mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
+ mu = *tmpc >> ((sizeof(mp_digit) * CHAR_BIT) - 1);
*tmpc++ &= MP_MASK;
/* handle rest of the digits */
for (ix = 1; ix < a->used; ix++) {
*tmpc = *tmpa++ - mu;
- mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
+ mu = *tmpc >> ((sizeof(mp_digit) * CHAR_BIT) - 1);
*tmpc++ &= MP_MASK;
}
}
@@ -87,3 +87,7 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c
index 7461678..87e0889 100644
--- a/libtommath/bn_mp_submod.c
+++ b/libtommath/bn_mp_submod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_SUBMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a - b (mod c) */
@@ -36,3 +36,7 @@ mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_to_signed_bin.c b/libtommath/bn_mp_to_signed_bin.c
index 7871921..e9289ea 100644
--- a/libtommath/bn_mp_to_signed_bin.c
+++ b/libtommath/bn_mp_to_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TO_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
@@ -23,7 +23,11 @@ int mp_to_signed_bin (mp_int * a, unsigned char *b)
if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) {
return res;
}
- b[0] = (unsigned char) ((a->sign == MP_ZPOS) ? 0 : 1);
+ b[0] = (a->sign == MP_ZPOS) ? (unsigned char)0 : (unsigned char)1;
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_to_signed_bin_n.c b/libtommath/bn_mp_to_signed_bin_n.c
index 8da9961..d4fe6e6 100644
--- a/libtommath/bn_mp_to_signed_bin_n.c
+++ b/libtommath/bn_mp_to_signed_bin_n.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TO_SIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
@@ -25,3 +25,7 @@ int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen)
return mp_to_signed_bin(a, b);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_to_unsigned_bin.c b/libtommath/bn_mp_to_unsigned_bin.c
index 9496398..d3ef46f 100644
--- a/libtommath/bn_mp_to_unsigned_bin.c
+++ b/libtommath/bn_mp_to_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TO_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
@@ -26,7 +26,7 @@ int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
}
x = 0;
- while (mp_iszero (&t) == 0) {
+ while (mp_iszero (&t) == MP_NO) {
#ifndef MP_8BIT
b[x++] = (unsigned char) (t.dp[0] & 255);
#else
@@ -42,3 +42,7 @@ int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_to_unsigned_bin_n.c b/libtommath/bn_mp_to_unsigned_bin_n.c
index 4f2a31d..2da13cc 100644
--- a/libtommath/bn_mp_to_unsigned_bin_n.c
+++ b/libtommath/bn_mp_to_unsigned_bin_n.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
@@ -25,3 +25,7 @@ int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen)
return mp_to_unsigned_bin(a, b);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_toom_mul.c b/libtommath/bn_mp_toom_mul.c
index 9daefbd..4731f8f 100644
--- a/libtommath/bn_mp_toom_mul.c
+++ b/libtommath/bn_mp_toom_mul.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TOOM_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,31 +12,31 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-/* multiplication using the Toom-Cook 3-way algorithm
+/* multiplication using the Toom-Cook 3-way algorithm
*
- * Much more complicated than Karatsuba but has a lower
- * asymptotic running time of O(N**1.464). This algorithm is
- * only particularly useful on VERY large inputs
+ * Much more complicated than Karatsuba but has a lower
+ * asymptotic running time of O(N**1.464). This algorithm is
+ * only particularly useful on VERY large inputs
* (we're talking 1000s of digits here...).
*/
int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
{
mp_int w0, w1, w2, w3, w4, tmp1, tmp2, a0, a1, a2, b0, b1, b2;
int res, B;
-
+
/* init temps */
- if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4,
- &a0, &a1, &a2, &b0, &b1,
+ if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4,
+ &a0, &a1, &a2, &b0, &b1,
&b2, &tmp1, &tmp2, NULL)) != MP_OKAY) {
return res;
}
-
+
/* B */
B = MIN(a->used, b->used) / 3;
-
+
/* a = a2 * B**2 + a1 * B + a0 */
if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
goto ERR;
@@ -46,13 +46,15 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
goto ERR;
}
mp_rshd(&a1, B);
- mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
+ if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
+ goto ERR;
+ }
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
goto ERR;
}
mp_rshd(&a2, B*2);
-
+
/* b = b2 * B**2 + b1 * B + b0 */
if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) {
goto ERR;
@@ -62,23 +64,23 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
goto ERR;
}
mp_rshd(&b1, B);
- mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
+ (void)mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
if ((res = mp_copy(b, &b2)) != MP_OKAY) {
goto ERR;
}
mp_rshd(&b2, B*2);
-
+
/* w0 = a0*b0 */
if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
goto ERR;
}
-
+
/* w4 = a2 * b2 */
if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
goto ERR;
}
-
+
/* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */
if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
goto ERR;
@@ -92,7 +94,7 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
goto ERR;
}
-
+
if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
goto ERR;
}
@@ -105,11 +107,11 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
goto ERR;
}
-
+
if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
goto ERR;
}
-
+
/* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */
if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
goto ERR;
@@ -123,7 +125,7 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
goto ERR;
}
-
+
if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
goto ERR;
}
@@ -136,11 +138,11 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
goto ERR;
}
-
+
if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
goto ERR;
}
-
+
/* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */
if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
@@ -158,123 +160,127 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
goto ERR;
}
-
- /* now solve the matrix
-
+
+ /* now solve the matrix
+
0 0 0 0 1
1 2 4 8 16
1 1 1 1 1
16 8 4 2 1
1 0 0 0 0
-
- using 12 subtractions, 4 shifts,
- 2 small divisions and 1 small multiplication
+
+ using 12 subtractions, 4 shifts,
+ 2 small divisions and 1 small multiplication
*/
-
- /* r1 - r4 */
- if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r0 */
- if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/2 */
- if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/2 */
- if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r2 - r0 - r4 */
- if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - 8r0 */
- if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - 8r4 */
- if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* 3r2 - r1 - r3 */
- if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/3 */
- if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/3 */
- if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
- }
-
- /* at this point shift W[n] by B*n */
- if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
- goto ERR;
- }
-
+
+ /* r1 - r4 */
+ if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r0 */
+ if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1/2 */
+ if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3/2 */
+ if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r2 - r0 - r4 */
+ if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - r2 */
+ if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r2 */
+ if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - 8r0 */
+ if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - 8r4 */
+ if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* 3r2 - r1 - r3 */
+ if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - r2 */
+ if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r2 */
+ if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1/3 */
+ if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3/3 */
+ if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
+ goto ERR;
+ }
+
+ /* at this point shift W[n] by B*n */
+ if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
+ goto ERR;
+ }
+
+ if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
+ goto ERR;
+ }
+
ERR:
- mp_clear_multi(&w0, &w1, &w2, &w3, &w4,
- &a0, &a1, &a2, &b0, &b1,
- &b2, &tmp1, &tmp2, NULL);
- return res;
-}
-
+ mp_clear_multi(&w0, &w1, &w2, &w3, &w4,
+ &a0, &a1, &a2, &b0, &b1,
+ &b2, &tmp1, &tmp2, NULL);
+ return res;
+}
+
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c
index 9e3f79c..69b69d4 100644
--- a/libtommath/bn_mp_toom_sqr.c
+++ b/libtommath/bn_mp_toom_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TOOM_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* squaring using Toom-Cook 3-way algorithm */
@@ -39,7 +39,9 @@ mp_toom_sqr(mp_int *a, mp_int *b)
goto ERR;
}
mp_rshd(&a1, B);
- mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
+ if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
+ goto ERR;
+ }
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
goto ERR;
@@ -115,108 +117,112 @@ mp_toom_sqr(mp_int *a, mp_int *b)
using 12 subtractions, 4 shifts, 2 small divisions and 1 small multiplication.
*/
- /* r1 - r4 */
- if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r0 */
- if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/2 */
- if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/2 */
- if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r2 - r0 - r4 */
- if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - 8r0 */
- if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - 8r4 */
- if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* 3r2 - r1 - r3 */
- if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/3 */
- if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/3 */
- if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
- }
-
- /* at this point shift W[n] by B*n */
- if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
- goto ERR;
- }
+ /* r1 - r4 */
+ if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r0 */
+ if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1/2 */
+ if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3/2 */
+ if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r2 - r0 - r4 */
+ if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - r2 */
+ if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r2 */
+ if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - 8r0 */
+ if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - 8r4 */
+ if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* 3r2 - r1 - r3 */
+ if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1 - r2 */
+ if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3 - r2 */
+ if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r1/3 */
+ if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
+ goto ERR;
+ }
+ /* r3/3 */
+ if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
+ goto ERR;
+ }
+
+ /* at this point shift W[n] by B*n */
+ if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
+ goto ERR;
+ }
+
+ if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
+ goto ERR;
+ }
+ if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
+ goto ERR;
+ }
ERR:
- mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
- return res;
+ mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
+ return res;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_toradix.c b/libtommath/bn_mp_toradix.c
index 132743e..f04352d 100644
--- a/libtommath/bn_mp_toradix.c
+++ b/libtommath/bn_mp_toradix.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TORADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64) */
@@ -24,12 +24,12 @@ int mp_toradix (mp_int * a, char *str, int radix)
char *_s = str;
/* check range of the radix */
- if (radix < 2 || radix > 64) {
+ if ((radix < 2) || (radix > 64)) {
return MP_VAL;
}
/* quick out if its zero */
- if (mp_iszero(a) == 1) {
+ if (mp_iszero(a) == MP_YES) {
*str++ = '0';
*str = '\0';
return MP_OKAY;
@@ -47,7 +47,7 @@ int mp_toradix (mp_int * a, char *str, int radix)
}
digs = 0;
- while (mp_iszero (&t) == 0) {
+ while (mp_iszero (&t) == MP_NO) {
if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
mp_clear (&t);
return res;
@@ -69,3 +69,7 @@ int mp_toradix (mp_int * a, char *str, int radix)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_toradix_n.c b/libtommath/bn_mp_toradix_n.c
index dedce71..19b61d7 100644
--- a/libtommath/bn_mp_toradix_n.c
+++ b/libtommath/bn_mp_toradix_n.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_TORADIX_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64)
@@ -27,7 +27,7 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
char *_s = str;
/* check range of the maxlen, radix */
- if (maxlen < 2 || radix < 2 || radix > 64) {
+ if ((maxlen < 2) || (radix < 2) || (radix > 64)) {
return MP_VAL;
}
@@ -56,7 +56,7 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
}
digs = 0;
- while (mp_iszero (&t) == 0) {
+ while (mp_iszero (&t) == MP_NO) {
if (--maxlen < 1) {
/* no more room */
break;
@@ -82,3 +82,7 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_unsigned_bin_size.c b/libtommath/bn_mp_unsigned_bin_size.c
index 58c18fb..0312625 100644
--- a/libtommath/bn_mp_unsigned_bin_size.c
+++ b/libtommath/bn_mp_unsigned_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,13 +12,17 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an unsigned equivalent */
int mp_unsigned_bin_size (mp_int * a)
{
int size = mp_count_bits (a);
- return (size / 8 + ((size & 7) != 0 ? 1 : 0));
+ return (size / 8) + (((size & 7) != 0) ? 1 : 0);
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c
index 432f42e..3c2ba9e 100644
--- a/libtommath/bn_mp_xor.c
+++ b/libtommath/bn_mp_xor.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_XOR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* XOR two ints together */
@@ -45,3 +45,7 @@ mp_xor (mp_int * a, mp_int * b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_mp_zero.c b/libtommath/bn_mp_zero.c
index d697a60..21365ed 100644
--- a/libtommath/bn_mp_zero.c
+++ b/libtommath/bn_mp_zero.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_MP_ZERO_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to zero */
@@ -30,3 +30,7 @@ void mp_zero (mp_int * a)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_prime_tab.c b/libtommath/bn_prime_tab.c
index c47c8bd..ae727a4 100644
--- a/libtommath/bn_prime_tab.c
+++ b/libtommath/bn_prime_tab.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_PRIME_TAB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
const mp_digit ltm_prime_tab[] = {
0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
@@ -55,3 +55,7 @@ const mp_digit ltm_prime_tab[] = {
#endif
};
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_reverse.c b/libtommath/bn_reverse.c
index 9d7fd29..fc6eb2d 100644
--- a/libtommath/bn_reverse.c
+++ b/libtommath/bn_reverse.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_REVERSE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reverse an array, used for radix code */
@@ -33,3 +33,7 @@ bn_reverse (unsigned char *s, int len)
}
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c
index 7527bf8..c2ad649 100644
--- a/libtommath/bn_s_mp_add.c
+++ b/libtommath/bn_s_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level addition, based on HAC pp.594, Algorithm 14.7 */
@@ -36,7 +36,7 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
}
/* init result */
- if (c->alloc < max + 1) {
+ if (c->alloc < (max + 1)) {
if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
return res;
}
@@ -47,8 +47,8 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
c->used = max + 1;
{
- register mp_digit u, *tmpa, *tmpb, *tmpc;
- register int i;
+ mp_digit u, *tmpa, *tmpb, *tmpc;
+ int i;
/* alias for digit pointers */
@@ -103,3 +103,7 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_exptmod.c b/libtommath/bn_s_mp_exptmod.c
index ff6bd54..63e1b1e 100644
--- a/libtommath/bn_s_mp_exptmod.c
+++ b/libtommath/bn_s_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef MP_LOW_MEM
#define TAB_SIZE 32
@@ -164,12 +164,12 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
* in the exponent. Technically this opt is not required but it
* does lower the # of trivial squaring/reductions used
*/
- if (mode == 0 && y == 0) {
+ if ((mode == 0) && (y == 0)) {
continue;
}
/* if the bit is zero and mode == 1 then we square */
- if (mode == 1 && y == 0) {
+ if ((mode == 1) && (y == 0)) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
goto LBL_RES;
}
@@ -211,7 +211,7 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
}
/* if bits remain then square/multiply */
- if (mode == 2 && bitcpy > 0) {
+ if ((mode == 2) && (bitcpy > 0)) {
/* square then multiply if the bit is set */
for (x = 0; x < bitcpy; x++) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
@@ -246,3 +246,7 @@ LBL_M:
return err;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c
index 401f32e..bd8553d 100644
--- a/libtommath/bn_s_mp_mul_digs.c
+++ b/libtommath/bn_s_mp_mul_digs.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and only computes upto digs digits of result
@@ -29,8 +29,8 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
/* can we use the fast multiplier? */
if (((digs) < MP_WARRAY) &&
- MIN (a->used, b->used) <
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
+ (MIN (a->used, b->used) <
+ (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
return fast_s_mp_mul_digs (a, b, c, digs);
}
@@ -61,9 +61,9 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
/* compute the columns of the output and propagate the carry */
for (iy = 0; iy < pb; iy++) {
/* compute the column as a mp_word */
- r = ((mp_word)*tmpt) +
- ((mp_word)tmpx) * ((mp_word)*tmpy++) +
- ((mp_word) u);
+ r = (mp_word)*tmpt +
+ ((mp_word)tmpx * (mp_word)*tmpy++) +
+ (mp_word)u;
/* the new column is the lower part of the result */
*tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
@@ -72,7 +72,7 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
u = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
}
/* set carry if it is placed below digs */
- if (ix + iy < digs) {
+ if ((ix + iy) < digs) {
*tmpt = u;
}
}
@@ -84,3 +84,7 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c
index f4dca76..153cea44 100644
--- a/libtommath/bn_s_mp_mul_high_digs.c
+++ b/libtommath/bn_s_mp_mul_high_digs.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and does not compute the lower digs digits
@@ -30,7 +30,7 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
/* can we use the fast multiplier? */
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
if (((a->used + b->used + 1) < MP_WARRAY)
- && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
+ && (MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
return fast_s_mp_mul_high_digs (a, b, c, digs);
}
#endif
@@ -57,9 +57,9 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
for (iy = digs - ix; iy < pb; iy++) {
/* calculate the double precision result */
- r = ((mp_word)*tmpt) +
- ((mp_word)tmpx) * ((mp_word)*tmpy++) +
- ((mp_word) u);
+ r = (mp_word)*tmpt +
+ ((mp_word)tmpx * (mp_word)*tmpy++) +
+ (mp_word)u;
/* get the lower part */
*tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
@@ -75,3 +75,7 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_sqr.c b/libtommath/bn_s_mp_sqr.c
index 464663f..68c95bc 100644
--- a/libtommath/bn_s_mp_sqr.c
+++ b/libtommath/bn_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
@@ -24,18 +24,18 @@ int s_mp_sqr (mp_int * a, mp_int * b)
mp_digit u, tmpx, *tmpt;
pa = a->used;
- if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) {
+ if ((res = mp_init_size (&t, (2 * pa) + 1)) != MP_OKAY) {
return res;
}
/* default used is maximum possible size */
- t.used = 2*pa + 1;
+ t.used = (2 * pa) + 1;
for (ix = 0; ix < pa; ix++) {
/* first calculate the digit at 2*ix */
/* calculate double precision result */
- r = ((mp_word) t.dp[2*ix]) +
- ((mp_word)a->dp[ix])*((mp_word)a->dp[ix]);
+ r = (mp_word)t.dp[2*ix] +
+ ((mp_word)a->dp[ix] * (mp_word)a->dp[ix]);
/* store lower part in result */
t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK));
@@ -47,7 +47,7 @@ int s_mp_sqr (mp_int * a, mp_int * b)
tmpx = a->dp[ix];
/* alias for where to store the results */
- tmpt = t.dp + (2*ix + 1);
+ tmpt = t.dp + ((2 * ix) + 1);
for (iy = ix + 1; iy < pa; iy++) {
/* first calculate the product */
@@ -78,3 +78,7 @@ int s_mp_sqr (mp_int * a, mp_int * b)
return MP_OKAY;
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c
index 328c9e5..c0ea556 100644
--- a/libtommath/bn_s_mp_sub.c
+++ b/libtommath/bn_s_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BN_S_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
@@ -35,8 +35,8 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
c->used = max;
{
- register mp_digit u, *tmpa, *tmpb, *tmpc;
- register int i;
+ mp_digit u, *tmpa, *tmpb, *tmpc;
+ int i;
/* alias for digit pointers */
tmpa = a->dp;
@@ -47,14 +47,14 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
u = 0;
for (i = 0; i < min; i++) {
/* T[i] = A[i] - B[i] - U */
- *tmpc = *tmpa++ - *tmpb++ - u;
+ *tmpc = (*tmpa++ - *tmpb++) - u;
/* U = carry bit of T[i]
* Note this saves performing an AND operation since
* if a carry does occur it will propagate all the way to the
* MSB. As a result a single shift is enough to get the carry
*/
- u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
+ u = *tmpc >> ((mp_digit)((CHAR_BIT * sizeof(mp_digit)) - 1));
/* Clear carry from T[i] */
*tmpc++ &= MP_MASK;
@@ -66,7 +66,7 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
*tmpc = *tmpa++ - u;
/* U = carry bit of T[i] */
- u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
+ u = *tmpc >> ((mp_digit)((CHAR_BIT * sizeof(mp_digit)) - 1));
/* Clear carry from T[i] */
*tmpc++ &= MP_MASK;
@@ -83,3 +83,7 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
}
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/bncore.c b/libtommath/bncore.c
index eb95a2e..9552714 100644
--- a/libtommath/bncore.c
+++ b/libtommath/bncore.c
@@ -1,4 +1,4 @@
-#include <tommath.h>
+#include <tommath_private.h>
#ifdef BNCORE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -12,7 +12,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Known optimal configurations
@@ -30,3 +30,7 @@ int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsub
TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */
TOOM_SQR_CUTOFF = 400;
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/booker.pl b/libtommath/booker.pl
deleted file mode 100644
index df8b30d..0000000
--- a/libtommath/booker.pl
+++ /dev/null
@@ -1,265 +0,0 @@
-#!/bin/perl
-#
-#Used to prepare the book "tommath.src" for LaTeX by pre-processing it into a .tex file
-#
-#Essentially you write the "tommath.src" as normal LaTex except where you want code snippets you put
-#
-#EXAM,file
-#
-#This preprocessor will then open "file" and insert it as a verbatim copy.
-#
-#Tom St Denis
-
-#get graphics type
-if (shift =~ /PDF/) {
- $graph = "";
-} else {
- $graph = ".ps";
-}
-
-open(IN,"<tommath.src") or die "Can't open source file";
-open(OUT,">tommath.tex") or die "Can't open destination file";
-
-print "Scanning for sections\n";
-$chapter = $section = $subsection = 0;
-$x = 0;
-while (<IN>) {
- print ".";
- if (!(++$x % 80)) { print "\n"; }
- #update the headings
- if (~($_ =~ /\*/)) {
- if ($_ =~ /\\chapter{.+}/) {
- ++$chapter;
- $section = $subsection = 0;
- } elsif ($_ =~ /\\section{.+}/) {
- ++$section;
- $subsection = 0;
- } elsif ($_ =~ /\\subsection{.+}/) {
- ++$subsection;
- }
- }
-
- if ($_ =~ m/MARK/) {
- @m = split(",",$_);
- chomp(@m[1]);
- $index1{@m[1]} = $chapter;
- $index2{@m[1]} = $section;
- $index3{@m[1]} = $subsection;
- }
-}
-close(IN);
-
-open(IN,"<tommath.src") or die "Can't open source file";
-$readline = $wroteline = 0;
-$srcline = 0;
-
-while (<IN>) {
- ++$readline;
- ++$srcline;
-
- if ($_ =~ m/MARK/) {
- } elsif ($_ =~ m/EXAM/ || $_ =~ m/LIST/) {
- if ($_ =~ m/EXAM/) {
- $skipheader = 1;
- } else {
- $skipheader = 0;
- }
-
- # EXAM,file
- chomp($_);
- @m = split(",",$_);
- open(SRC,"<$m[1]") or die "Error:$srcline:Can't open source file $m[1]";
-
- print "$srcline:Inserting $m[1]:";
-
- $line = 0;
- $tmp = $m[1];
- $tmp =~ s/_/"\\_"/ge;
- print OUT "\\vspace{+3mm}\\begin{small}\n\\hspace{-5.1mm}{\\bf File}: $tmp\n\\vspace{-3mm}\n\\begin{alltt}\n";
- $wroteline += 5;
-
- if ($skipheader == 1) {
- # scan till next end of comment, e.g. skip license
- while (<SRC>) {
- $text[$line++] = $_;
- last if ($_ =~ /math\.libtomcrypt\.org/);
- }
- <SRC>;
- }
-
- $inline = 0;
- while (<SRC>) {
- next if ($_ =~ /\$Source/);
- next if ($_ =~ /\$Revision/);
- next if ($_ =~ /\$Date/);
- $text[$line++] = $_;
- ++$inline;
- chomp($_);
- $_ =~ s/\t/" "/ge;
- $_ =~ s/{/"^{"/ge;
- $_ =~ s/}/"^}"/ge;
- $_ =~ s/\\/'\symbol{92}'/ge;
- $_ =~ s/\^/"\\"/ge;
-
- printf OUT ("%03d ", $line);
- for ($x = 0; $x < length($_); $x++) {
- print OUT chr(vec($_, $x, 8));
- if ($x == 75) {
- print OUT "\n ";
- ++$wroteline;
- }
- }
- print OUT "\n";
- ++$wroteline;
- }
- $totlines = $line;
- print OUT "\\end{alltt}\n\\end{small}\n";
- close(SRC);
- print "$inline lines\n";
- $wroteline += 2;
- } elsif ($_ =~ m/@\d+,.+@/) {
- # line contains [number,text]
- # e.g. @14,for (ix = 0)@
- $txt = $_;
- while ($txt =~ m/@\d+,.+@/) {
- @m = split("@",$txt); # splits into text, one, two
- @parms = split(",",$m[1]); # splits one,two into two elements
-
- # now search from $parms[0] down for $parms[1]
- $found1 = 0;
- $found2 = 0;
- for ($i = $parms[0]; $i < $totlines && $found1 == 0; $i++) {
- if ($text[$i] =~ m/\Q$parms[1]\E/) {
- $foundline1 = $i + 1;
- $found1 = 1;
- }
- }
-
- # now search backwards
- for ($i = $parms[0] - 1; $i >= 0 && $found2 == 0; $i--) {
- if ($text[$i] =~ m/\Q$parms[1]\E/) {
- $foundline2 = $i + 1;
- $found2 = 1;
- }
- }
-
- # now use the closest match or the first if tied
- if ($found1 == 1 && $found2 == 0) {
- $found = 1;
- $foundline = $foundline1;
- } elsif ($found1 == 0 && $found2 == 1) {
- $found = 1;
- $foundline = $foundline2;
- } elsif ($found1 == 1 && $found2 == 1) {
- $found = 1;
- if (($foundline1 - $parms[0]) <= ($parms[0] - $foundline2)) {
- $foundline = $foundline1;
- } else {
- $foundline = $foundline2;
- }
- } else {
- $found = 0;
- }
-
- # if found replace
- if ($found == 1) {
- $delta = $parms[0] - $foundline;
- print "Found replacement tag for \"$parms[1]\" on line $srcline which refers to line $foundline (delta $delta)\n";
- $_ =~ s/@\Q$m[1]\E@/$foundline/;
- } else {
- print "ERROR: The tag \"$parms[1]\" on line $srcline was not found in the most recently parsed source!\n";
- }
-
- # remake the rest of the line
- $cnt = @m;
- $txt = "";
- for ($i = 2; $i < $cnt; $i++) {
- $txt = $txt . $m[$i] . "@";
- }
- }
- print OUT $_;
- ++$wroteline;
- } elsif ($_ =~ /~.+~/) {
- # line contains a ~text~ pair used to refer to indexing :-)
- $txt = $_;
- while ($txt =~ /~.+~/) {
- @m = split("~", $txt);
-
- # word is the second position
- $word = @m[1];
- $a = $index1{$word};
- $b = $index2{$word};
- $c = $index3{$word};
-
- # if chapter (a) is zero it wasn't found
- if ($a == 0) {
- print "ERROR: the tag \"$word\" on line $srcline was not found previously marked.\n";
- } else {
- # format the tag as x, x.y or x.y.z depending on the values
- $str = $a;
- $str = $str . ".$b" if ($b != 0);
- $str = $str . ".$c" if ($c != 0);
-
- if ($b == 0 && $c == 0) {
- # its a chapter
- if ($a <= 10) {
- if ($a == 1) {
- $str = "chapter one";
- } elsif ($a == 2) {
- $str = "chapter two";
- } elsif ($a == 3) {
- $str = "chapter three";
- } elsif ($a == 4) {
- $str = "chapter four";
- } elsif ($a == 5) {
- $str = "chapter five";
- } elsif ($a == 6) {
- $str = "chapter six";
- } elsif ($a == 7) {
- $str = "chapter seven";
- } elsif ($a == 8) {
- $str = "chapter eight";
- } elsif ($a == 9) {
- $str = "chapter nine";
- } elsif ($a == 10) {
- $str = "chapter ten";
- }
- } else {
- $str = "chapter " . $str;
- }
- } else {
- $str = "section " . $str if ($b != 0 && $c == 0);
- $str = "sub-section " . $str if ($b != 0 && $c != 0);
- }
-
- #substitute
- $_ =~ s/~\Q$word\E~/$str/;
-
- print "Found replacement tag for marker \"$word\" on line $srcline which refers to $str\n";
- }
-
- # remake rest of the line
- $cnt = @m;
- $txt = "";
- for ($i = 2; $i < $cnt; $i++) {
- $txt = $txt . $m[$i] . "~";
- }
- }
- print OUT $_;
- ++$wroteline;
- } elsif ($_ =~ m/FIGU/) {
- # FIGU,file,caption
- chomp($_);
- @m = split(",", $_);
- print OUT "\\begin{center}\n\\begin{figure}[here]\n\\includegraphics{pics/$m[1]$graph}\n";
- print OUT "\\caption{$m[2]}\n\\label{pic:$m[1]}\n\\end{figure}\n\\end{center}\n";
- $wroteline += 4;
- } else {
- print OUT $_;
- ++$wroteline;
- }
-}
-print "Read $readline lines, wrote $wroteline lines\n";
-
-close (OUT);
-close (IN);
diff --git a/libtommath/callgraph.txt b/libtommath/callgraph.txt
index 2efcf24..e98a910 100644
--- a/libtommath/callgraph.txt
+++ b/libtommath/callgraph.txt
@@ -1,249 +1,140 @@
-BN_PRIME_TAB_C
-
-
-BN_MP_SQRT_C
-+--->BN_MP_N_ROOT_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_SET_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_EXPT_D_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_SQR_C
-| | | +--->BN_MP_TOOM_SQR_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MUL_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_3_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_KARATSUBA_SQR_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_FAST_S_MP_SQR_C
+BN_MP_KARATSUBA_MUL_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SQR_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MUL_C
-| | | +--->BN_MP_TOOM_MUL_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MUL_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_3_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLEAR_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_KARATSUBA_MUL_C
-| | | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_DIV_3_C
| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
+| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_S_MP_ADD_C
+| +--->BN_MP_GROW_C
++--->BN_MP_ADD_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_ZERO_C
+
+
+BN_MP_SET_C
++--->BN_MP_ZERO_C
+
+
+BN_MP_TO_SIGNED_BIN_C
++--->BN_MP_TO_UNSIGNED_BIN_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_S_MP_SUB_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_JACOBI_C
++--->BN_MP_CMP_D_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_CNT_LSB_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_MOD_C
| +--->BN_MP_DIV_C
| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_SET_C
| | +--->BN_MP_COUNT_BITS_C
| | +--->BN_MP_ABS_C
| | +--->BN_MP_MUL_2D_C
@@ -252,6 +143,13 @@ BN_MP_SQRT_C
| | | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
@@ -259,42 +157,481 @@ BN_MP_SQRT_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_INIT_COPY_C
++--->BN_MP_INIT_SIZE_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
+
+
+BN_MP_ABS_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
+
+
+BN_MP_RADIX_SMAP_C
+
+
+BN_MP_EXCH_C
+
+
+BN_MP_EXPORT_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_TO_UNSIGNED_BIN_N_C
++--->BN_MP_UNSIGNED_BIN_SIZE_C
+| +--->BN_MP_COUNT_BITS_C
++--->BN_MP_TO_UNSIGNED_BIN_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_MP_TO_SIGNED_BIN_N_C
++--->BN_MP_SIGNED_BIN_SIZE_C
+| +--->BN_MP_UNSIGNED_BIN_SIZE_C
+| | +--->BN_MP_COUNT_BITS_C
++--->BN_MP_TO_SIGNED_BIN_C
+| +--->BN_MP_TO_UNSIGNED_BIN_C
+| | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+
+
+BN_MP_LCM_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_GCD_C
+| +--->BN_MP_ABS_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_CNT_LSB_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_EXCH_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_CMP_MAG_C
++--->BN_MP_DIV_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_SET_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_ABS_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_INIT_COPY_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CMP_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_MP_CMP_MAG_C
+
+
+BN_MP_PRIME_RABIN_MILLER_TRIALS_C
+
+
+BN_MP_MUL_2D_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_GROW_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_MUL_C
++--->BN_MP_TOOM_MUL_C
+| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_2_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_SUB_D_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_2_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_KARATSUBA_MUL_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLEAR_C
++--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_S_MP_MUL_DIGS_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_MP_SQR_C
++--->BN_MP_TOOM_SQR_C
+| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_2_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_2_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_KARATSUBA_SQR_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_ADD_C
+| | +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_CLEAR_C
++--->BN_FAST_S_MP_SQR_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_S_MP_SQR_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
+
+
+BN_MP_INIT_C
+
+
+BN_MP_2EXPT_C
+--->BN_MP_ZERO_C
++--->BN_MP_GROW_C
+
+
+BN_MP_SIGNED_BIN_SIZE_C
++--->BN_MP_UNSIGNED_BIN_SIZE_C
+| +--->BN_MP_COUNT_BITS_C
+
+
+BN_MP_OR_C
+--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-+--->BN_MP_RSHD_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_MOD_C
++--->BN_MP_INIT_C
+--->BN_MP_DIV_C
| +--->BN_MP_CMP_MAG_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
| +--->BN_MP_INIT_MULTI_C
| | +--->BN_MP_CLEAR_C
| +--->BN_MP_SET_C
@@ -303,6 +640,7 @@ BN_MP_SQRT_C
| +--->BN_MP_MUL_2D_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CMP_C
| +--->BN_MP_SUB_C
@@ -323,19 +661,25 @@ BN_MP_SQRT_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_MULTI_C
| | +--->BN_MP_CLEAR_C
| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_COPY_C
| +--->BN_MP_LSHD_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| +--->BN_MP_RSHD_C
| +--->BN_MP_MUL_D_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_CLEAR_C
++--->BN_MP_CLEAR_C
++--->BN_MP_EXCH_C
+--->BN_MP_ADD_C
| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
@@ -344,134 +688,933 @@ BN_MP_SQRT_C
| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_2_C
+
+
+BN_MP_DIV_C
++--->BN_MP_CMP_MAG_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_ZERO_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_SET_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_ABS_C
++--->BN_MP_MUL_2D_C
| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
++--->BN_MP_CMP_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_INIT_C
++--->BN_MP_INIT_COPY_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
++--->BN_MP_RSHD_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLAMP_C
+--->BN_MP_CLEAR_C
-BN_MP_CMP_D_C
-
-
-BN_MP_EXCH_C
+BN_MP_INIT_SET_C
++--->BN_MP_INIT_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
-BN_MP_IS_SQUARE_C
-+--->BN_MP_MOD_D_C
-| +--->BN_MP_DIV_D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_C
-| | | +--->BN_MP_MOD_2D_C
+BN_MP_PRIME_IS_PRIME_C
++--->BN_MP_CMP_D_C
++--->BN_MP_PRIME_IS_DIVISIBLE_C
+| +--->BN_MP_MOD_D_C
+| | +--->BN_MP_DIV_D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_INIT_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_PRIME_MILLER_RABIN_C
+| +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_INIT_SET_INT_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_SET_INT_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_D_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_CNT_LSB_C
+| +--->BN_MP_DIV_2D_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_EXPTMOD_C
+| | +--->BN_MP_INVMOD_C
+| | | +--->BN_FAST_MP_INVMOD_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MOD_C
+| | | | | +--->BN_MP_DIV_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_COUNT_BITS_C
+| | | | | | +--->BN_MP_ABS_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_INVMOD_SLOW_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_MOD_C
+| | | | | +--->BN_MP_DIV_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_COUNT_BITS_C
+| | | | | | +--->BN_MP_ABS_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_C
| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_REDUCE_IS_2K_L_C
+| | +--->BN_S_MP_EXPTMOD_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_REDUCE_SETUP_C
+| | | | +--->BN_MP_2EXPT_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_DIV_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_REDUCE_C
| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_C
+| | | | | +--->BN_MP_TOOM_MUL_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | | +--->BN_MP_COPY_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_MUL_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_3_C
+| | | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_S_MP_MUL_HIGH_DIGS_C
+| | | | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_REDUCE_2K_SETUP_L_C
+| | | | +--->BN_MP_2EXPT_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_REDUCE_2K_L_C
+| | | | +--->BN_MP_MUL_C
+| | | | | +--->BN_MP_TOOM_MUL_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | | +--->BN_MP_COPY_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_MUL_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_3_C
+| | | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MOD_C
+| | | | +--->BN_MP_DIV_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_SQR_C
+| | | | +--->BN_MP_TOOM_SQR_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_MUL_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_3_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_FAST_S_MP_SQR_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SQR_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_MUL_C
+| | | | +--->BN_MP_TOOM_MUL_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_MUL_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_3_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DR_IS_MODULUS_C
+| | +--->BN_MP_REDUCE_IS_2K_C
+| | | +--->BN_MP_REDUCE_2K_C
+| | | | +--->BN_MP_COUNT_BITS_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_EXPTMOD_FAST_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_MONTGOMERY_SETUP_C
+| | | +--->BN_FAST_MP_MONTGOMERY_REDUCE_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_MONTGOMERY_REDUCE_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_DR_SETUP_C
+| | | +--->BN_MP_DR_REDUCE_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_GET_INT_C
-+--->BN_MP_SQRT_C
-| +--->BN_MP_N_ROOT_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_SET_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_EXPT_D_C
-| | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_REDUCE_2K_SETUP_C
+| | | | +--->BN_MP_2EXPT_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_REDUCE_2K_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
+| | | | +--->BN_MP_2EXPT_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MULMOD_C
+| | | | +--->BN_MP_MUL_C
+| | | | | +--->BN_MP_TOOM_MUL_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | | +--->BN_MP_COPY_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_MUL_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_3_C
+| | | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_MOD_C
+| | | | | +--->BN_MP_DIV_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MOD_C
+| | | | +--->BN_MP_DIV_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_SQR_C
| | | | +--->BN_MP_TOOM_SQR_C
| | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_MOD_2D_C
| | | | | | +--->BN_MP_ZERO_C
| | | | | | +--->BN_MP_CLAMP_C
@@ -509,43 +1652,327 @@ BN_MP_IS_SQUARE_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_FAST_S_MP_SQR_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SQR_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_MUL_C
+| | | | +--->BN_MP_TOOM_MUL_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_MUL_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_SUB_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_3_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| +--->BN_MP_CMP_C
+| | +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_SQRMOD_C
+| | +--->BN_MP_SQR_C
+| | | +--->BN_MP_TOOM_SQR_C
+| | | | +--->BN_MP_INIT_MULTI_C
| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_FAST_S_MP_SQR_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_FAST_S_MP_SQR_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_COUNT_BITS_C
+| | | | +--->BN_MP_ABS_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_CLEAR_C
+
+
+BN_FAST_S_MP_SQR_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_UNSIGNED_BIN_SIZE_C
++--->BN_MP_COUNT_BITS_C
+
+
+BN_MP_INIT_SIZE_C
++--->BN_MP_INIT_C
+
+
+BN_FAST_S_MP_MUL_DIGS_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_REDUCE_IS_2K_L_C
+
+
+BN_MP_REDUCE_IS_2K_C
++--->BN_MP_REDUCE_2K_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_COUNT_BITS_C
+
+
+BN_MP_SUB_C
++--->BN_S_MP_ADD_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_REDUCE_2K_SETUP_C
++--->BN_MP_INIT_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_2EXPT_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_GROW_C
++--->BN_MP_CLEAR_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_DIV_2D_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_ZERO_C
++--->BN_MP_INIT_C
++--->BN_MP_MOD_2D_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_RSHD_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
+
+
+BN_MP_DR_REDUCE_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+
+
+BN_MP_SQRT_C
++--->BN_MP_N_ROOT_C
+| +--->BN_MP_N_ROOT_EX_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_SET_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_EXPT_D_EX_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_MUL_C
| | | | +--->BN_MP_TOOM_MUL_C
| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_MOD_2D_C
| | | | | | +--->BN_MP_ZERO_C
| | | | | | +--->BN_MP_CLAMP_C
@@ -583,32 +2010,96 @@ BN_MP_IS_SQUARE_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_SQR_C
+| | | | +--->BN_MP_TOOM_SQR_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_MUL_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_SUB_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_3_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
| | | | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_FAST_S_MP_SQR_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_S_MP_SQR_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
@@ -661,18 +2152,14 @@ BN_MP_IS_SQUARE_C
| | | +--->BN_MP_KARATSUBA_MUL_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -744,74 +2231,78 @@ BN_MP_IS_SQUARE_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_INIT_SIZE_C
++--->BN_MP_ZERO_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
++--->BN_MP_DIV_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_SET_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_ABS_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_2_C
-| | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_EXCH_C
| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_MULMOD_C
++--->BN_MP_INIT_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_ZERO_C
@@ -852,7 +2343,6 @@ BN_MP_IS_SQUARE_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_3_C
| | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
@@ -860,498 +2350,81 @@ BN_MP_IS_SQUARE_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_SQR_C
+| +--->BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_SQR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
+| +--->BN_S_MP_MUL_DIGS_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_CMP_MAG_C
+--->BN_MP_CLEAR_C
-
-
-BN_MP_NEG_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-
-
-BN_MP_EXPTMOD_C
-+--->BN_MP_INIT_C
-+--->BN_MP_INVMOD_C
-| +--->BN_FAST_MP_INVMOD_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_MOD_C
-| | | +--->BN_MP_DIV_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_SET_C
-| | | | +--->BN_MP_COUNT_BITS_C
-| | | | +--->BN_MP_ABS_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_SET_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_CMP_D_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INVMOD_SLOW_C
+| | +--->BN_MP_ZERO_C
| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_C
-| | | +--->BN_MP_DIV_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_SET_C
-| | | | +--->BN_MP_COUNT_BITS_C
-| | | | +--->BN_MP_ABS_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SET_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_CMP_D_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_ABS_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_CLEAR_MULTI_C
-+--->BN_MP_REDUCE_IS_2K_L_C
-+--->BN_S_MP_EXPTMOD_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_REDUCE_SETUP_C
-| | +--->BN_MP_2EXPT_C
-| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_DIV_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_SET_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_COPY_C
| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_REDUCE_C
-| | +--->BN_MP_INIT_COPY_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_C
-| | | +--->BN_MP_TOOM_MUL_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_MUL_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_3_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | +--->BN_S_MP_MUL_HIGH_DIGS_C
-| | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
-| | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_D_C
-| | +--->BN_MP_SET_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_REDUCE_2K_SETUP_L_C
-| | +--->BN_MP_2EXPT_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_REDUCE_2K_L_C
| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_MUL_C
-| | | +--->BN_MP_TOOM_MUL_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MUL_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_3_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -1359,14 +2432,23 @@ BN_MP_EXPTMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
+
+
+BN_MP_INVMOD_C
++--->BN_FAST_MP_INVMOD_C
+| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
| +--->BN_MP_MOD_C
+| | +--->BN_MP_INIT_C
| | +--->BN_MP_DIV_C
| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_ABS_C
| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
@@ -1390,10 +2472,13 @@ BN_MP_EXPTMOD_C
| | | +--->BN_MP_DIV_2D_C
| | | | +--->BN_MP_MOD_2D_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_COPY_C
| | | +--->BN_MP_LSHD_C
@@ -1404,6 +2489,9 @@ BN_MP_EXPTMOD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
@@ -1412,164 +2500,12 @@ BN_MP_EXPTMOD_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_SQR_C
-| | +--->BN_MP_TOOM_SQR_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_KARATSUBA_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | +--->BN_FAST_S_MP_SQR_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_KARATSUBA_MUL_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| +--->BN_MP_SET_C
| | +--->BN_MP_ZERO_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_DR_IS_MODULUS_C
-+--->BN_MP_REDUCE_IS_2K_C
-| +--->BN_MP_REDUCE_2K_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_2_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_SUB_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -1577,50 +2513,10 @@ BN_MP_EXPTMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_COUNT_BITS_C
-+--->BN_MP_EXPTMOD_FAST_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_MONTGOMERY_SETUP_C
-| +--->BN_FAST_MP_MONTGOMERY_REDUCE_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| +--->BN_MP_MONTGOMERY_REDUCE_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| +--->BN_MP_DR_SETUP_C
-| +--->BN_MP_DR_REDUCE_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_C
| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| +--->BN_MP_REDUCE_2K_SETUP_C
-| | +--->BN_MP_2EXPT_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_REDUCE_2K_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_D_C
+| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -1628,154 +2524,23 @@ BN_MP_EXPTMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-| | +--->BN_MP_2EXPT_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_SET_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MULMOD_C
-| | +--->BN_MP_MUL_C
-| | | +--->BN_MP_TOOM_MUL_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MUL_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_3_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_MUL_DIGS_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_MOD_C
-| | | +--->BN_MP_DIV_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_SET_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| +--->BN_MP_SET_C
-| | +--->BN_MP_ZERO_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_INVMOD_SLOW_C
+| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLEAR_C
| +--->BN_MP_MOD_C
+| | +--->BN_MP_INIT_C
| | +--->BN_MP_DIV_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_ABS_C
| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
@@ -1799,10 +2564,13 @@ BN_MP_EXPTMOD_C
| | | +--->BN_MP_DIV_2D_C
| | | | +--->BN_MP_MOD_2D_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_COPY_C
| | | +--->BN_MP_LSHD_C
@@ -1813,6 +2581,9 @@ BN_MP_EXPTMOD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
@@ -1821,169 +2592,60 @@ BN_MP_EXPTMOD_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_SQR_C
-| | +--->BN_MP_TOOM_SQR_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_KARATSUBA_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | +--->BN_FAST_S_MP_SQR_C
+| +--->BN_MP_SET_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_DIV_2_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_KARATSUBA_MUL_C
-| | | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
-| | | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
+| +--->BN_MP_CMP_C
+| | +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_CMP_D_C
+| +--->BN_MP_CMP_MAG_C
| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
-BN_MP_OR_C
+BN_MP_PRIME_MILLER_RABIN_C
++--->BN_MP_CMP_D_C
+--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_ZERO_C
-
-
-BN_MP_GROW_C
-
-
-BN_MP_COUNT_BITS_C
-
-
-BN_MP_PRIME_FERMAT_C
-+--->BN_MP_CMP_D_C
-+--->BN_MP_INIT_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CNT_LSB_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+--->BN_MP_EXPTMOD_C
| +--->BN_MP_INVMOD_C
| | +--->BN_FAST_MP_INVMOD_C
@@ -2018,18 +2680,10 @@ BN_MP_PRIME_FERMAT_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2D_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLEAR_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_CLEAR_MULTI_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -2040,6 +2694,7 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -2048,7 +2703,6 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_SET_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_DIV_2_C
@@ -2107,18 +2761,10 @@ BN_MP_PRIME_FERMAT_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2D_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLEAR_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_CLEAR_MULTI_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -2129,6 +2775,7 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -2137,7 +2784,6 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_SET_C
@@ -2206,15 +2852,8 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -2224,9 +2863,6 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_C
-| | | +--->BN_MP_INIT_COPY_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_C
@@ -2276,18 +2912,14 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
@@ -2352,15 +2984,6 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_2K_L_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_C
| | | | +--->BN_MP_TOOM_MUL_C
| | | | | +--->BN_MP_INIT_MULTI_C
@@ -2410,18 +3033,14 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -2468,15 +3087,8 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -2485,6 +3097,7 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -2493,7 +3106,6 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SQR_C
@@ -2541,22 +3153,16 @@ BN_MP_PRIME_FERMAT_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -2609,18 +3215,14 @@ BN_MP_PRIME_FERMAT_C
| | | +--->BN_MP_KARATSUBA_MUL_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -2639,15 +3241,6 @@ BN_MP_PRIME_FERMAT_C
| +--->BN_MP_REDUCE_IS_2K_C
| | +--->BN_MP_REDUCE_2K_C
| | | +--->BN_MP_COUNT_BITS_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -2690,15 +3283,6 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_2K_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -2771,18 +3355,14 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -2822,15 +3402,8 @@ BN_MP_PRIME_FERMAT_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2D_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -2839,6 +3412,7 @@ BN_MP_PRIME_FERMAT_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -2847,7 +3421,6 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | +--->BN_MP_SET_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
@@ -2877,15 +3450,8 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2D_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -2894,6 +3460,7 @@ BN_MP_PRIME_FERMAT_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -2902,7 +3469,6 @@ BN_MP_PRIME_FERMAT_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SQR_C
@@ -2950,22 +3516,16 @@ BN_MP_PRIME_FERMAT_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -3018,18 +3578,14 @@ BN_MP_PRIME_FERMAT_C
| | | +--->BN_MP_KARATSUBA_MUL_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -3044,312 +3600,87 @@ BN_MP_PRIME_FERMAT_C
| | +--->BN_MP_EXCH_C
+--->BN_MP_CMP_C
| +--->BN_MP_CMP_MAG_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_SUBMOD_C
-+--->BN_MP_INIT_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
++--->BN_MP_SQRMOD_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-
-
-BN_MP_MOD_2D_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_TORADIX_N_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_DIV_D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_CMP_C
-+--->BN_MP_CMP_MAG_C
-
-
-BNCORE_C
-
-
-BN_MP_TORADIX_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_DIV_D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_ADD_D_C
-+--->BN_MP_GROW_C
-+--->BN_MP_SUB_D_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_DIV_3_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_FAST_S_MP_MUL_DIGS_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_SQRMOD_C
-+--->BN_MP_INIT_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_KARATSUBA_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_SQR_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_FAST_S_MP_SQR_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-
-
-BN_MP_INVMOD_C
-+--->BN_FAST_MP_INVMOD_C
-| +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
| +--->BN_MP_MOD_C
-| | +--->BN_MP_INIT_C
| | +--->BN_MP_DIV_C
| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_SET_C
| | | +--->BN_MP_COUNT_BITS_C
| | | +--->BN_MP_ABS_C
@@ -3358,7 +3689,6 @@ BN_MP_INVMOD_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_C
| | | +--->BN_MP_SUB_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -3373,18 +3703,9 @@ BN_MP_INVMOD_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_COPY_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
@@ -3393,8 +3714,7 @@ BN_MP_INVMOD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
@@ -3403,114 +3723,234 @@ BN_MP_INVMOD_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_READ_UNSIGNED_BIN_C
++--->BN_MP_GROW_C
++--->BN_MP_ZERO_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_N_ROOT_C
++--->BN_MP_N_ROOT_EX_C
+| +--->BN_MP_INIT_C
| +--->BN_MP_SET_C
| | +--->BN_MP_ZERO_C
-| +--->BN_MP_DIV_2_C
+| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
-| | +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_CMP_D_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_INVMOD_SLOW_C
-| +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_MOD_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_DIV_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_SET_C
-| | | +--->BN_MP_COUNT_BITS_C
-| | | +--->BN_MP_ABS_C
-| | | +--->BN_MP_MUL_2D_C
+| +--->BN_MP_EXPT_D_EX_C
+| | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_SQR_C
+| | | +--->BN_MP_TOOM_SQR_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_FAST_S_MP_SQR_C
+| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_C
-| | | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_ADD_C
+| | | +--->BN_MP_SUB_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_COPY_C
-| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_SET_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_DIV_2_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
| +--->BN_MP_SUB_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
@@ -3519,41 +3959,14 @@ BN_MP_INVMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
-| | +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_CMP_D_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-
-
-BN_MP_AND_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
+| +--->BN_MP_MUL_D_C
| | +--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_MUL_D_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_FAST_MP_INVMOD_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
| +--->BN_MP_DIV_C
| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_SET_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_COUNT_BITS_C
| | +--->BN_MP_ABS_C
| | +--->BN_MP_MUL_2D_C
@@ -3562,13 +3975,6 @@ BN_FAST_MP_INVMOD_C
| | | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
@@ -3592,127 +3998,189 @@ BN_FAST_MP_INVMOD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_C
| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_DIV_2_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_C
-| +--->BN_MP_CMP_MAG_C
-+--->BN_MP_CMP_D_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
+| +--->BN_MP_SUB_D_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_D_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
-BN_MP_FWRITE_C
-+--->BN_MP_RADIX_SIZE_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_D_C
+BN_MP_EXPT_D_EX_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_RSHD_C
| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_DIV_3_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_TORADIX_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_D_C
++--->BN_MP_CLEAR_C
++--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_RSHD_C
| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_DIV_3_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_KARATSUBA_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_S_MP_SQR_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-BN_MP_N_ROOT_C
-+--->BN_MP_INIT_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_EXPT_D_C
+BN_MP_EXPT_D_C
++--->BN_MP_EXPT_D_EX_C
| +--->BN_MP_INIT_COPY_C
-| +--->BN_MP_SQR_C
-| | +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_SET_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
| | | +--->BN_MP_INIT_MULTI_C
| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_2_C
@@ -3752,41 +4220,41 @@ BN_MP_N_ROOT_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLEAR_MULTI_C
| | | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_KARATSUBA_SQR_C
+| | +--->BN_MP_KARATSUBA_MUL_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
| | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLEAR_C
-| | +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SQR_C
+| | +--->BN_S_MP_MUL_DIGS_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
| +--->BN_MP_CLEAR_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_2_C
@@ -3824,122 +4292,51 @@ BN_MP_N_ROOT_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_KARATSUBA_MUL_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_KARATSUBA_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_FAST_S_MP_SQR_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
+| | +--->BN_S_MP_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_MUL_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
+
+
+BN_MP_XOR_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_D_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_REDUCE_SETUP_C
++--->BN_MP_2EXPT_C
+| +--->BN_MP_ZERO_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
+--->BN_MP_DIV_C
| +--->BN_MP_CMP_MAG_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
| +--->BN_MP_ZERO_C
| +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_INIT_C
| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_SET_C
| +--->BN_MP_COUNT_BITS_C
| +--->BN_MP_ABS_C
| +--->BN_MP_MUL_2D_C
@@ -3948,6 +4345,13 @@ BN_MP_N_ROOT_C
| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
@@ -3956,6 +4360,7 @@ BN_MP_N_ROOT_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_INIT_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
@@ -3966,65 +4371,30 @@ BN_MP_N_ROOT_C
| +--->BN_MP_CLEAR_MULTI_C
| | +--->BN_MP_CLEAR_C
| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_INIT_C
| +--->BN_MP_INIT_COPY_C
| +--->BN_MP_LSHD_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_RSHD_C
| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_CMP_C
-| +--->BN_MP_CMP_MAG_C
-+--->BN_MP_SUB_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_D_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
-BN_MP_PRIME_RABIN_MILLER_TRIALS_C
+BN_MP_RSHD_C
++--->BN_MP_ZERO_C
-BN_MP_RADIX_SIZE_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_DIV_D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
+BN_MP_NEG_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
-BN_MP_READ_SIGNED_BIN_C
-+--->BN_MP_READ_UNSIGNED_BIN_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
+BN_MP_SHRINK_C
BN_MP_PRIME_RANDOM_EX_C
@@ -4069,6 +4439,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | +--->BN_MP_ZERO_C
| +--->BN_MP_PRIME_MILLER_RABIN_C
| | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | +--->BN_MP_SUB_D_C
@@ -4134,6 +4505,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | | +--->BN_MP_CLEAR_C
| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | | +--->BN_MP_ADD_C
| | | | | | | +--->BN_S_MP_ADD_C
| | | | | | | | +--->BN_MP_GROW_C
@@ -4142,7 +4514,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_DIV_2_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
@@ -4212,6 +4583,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | | +--->BN_MP_CLEAR_C
| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | | +--->BN_MP_ADD_C
| | | | | | | +--->BN_S_MP_ADD_C
| | | | | | | | +--->BN_MP_GROW_C
@@ -4220,7 +4592,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_COPY_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_DIV_2_C
@@ -4346,18 +4717,14 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_SUB_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_ADD_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_LSHD_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
@@ -4469,18 +4836,14 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_SUB_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_ADD_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_LSHD_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_RSHD_C
@@ -4536,6 +4899,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
@@ -4544,7 +4908,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_COPY_C
| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_SQR_C
@@ -4592,22 +4955,16 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
| | | | | | | | +--->BN_MP_ZERO_C
| | | | | | +--->BN_MP_ADD_C
| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_FAST_S_MP_SQR_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
@@ -4660,18 +5017,14 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
@@ -4800,18 +5153,14 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_SUB_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_ADD_C
-| | | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_LSHD_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_RSHD_C
@@ -4860,6 +5209,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CLAMP_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | | +--->BN_MP_ADD_C
| | | | | | | +--->BN_S_MP_ADD_C
| | | | | | | | +--->BN_MP_GROW_C
@@ -4868,7 +5218,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_MOD_C
| | | | | +--->BN_MP_DIV_C
| | | | | | +--->BN_MP_CMP_MAG_C
@@ -4906,6 +5255,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
@@ -4914,7 +5264,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_COPY_C
| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_SQR_C
@@ -4962,22 +5311,16 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
| | | | | | | | +--->BN_MP_ZERO_C
| | | | | | +--->BN_MP_ADD_C
| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_FAST_S_MP_SQR_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
@@ -5030,18 +5373,14 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
@@ -5110,22 +5449,16 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
| | | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_FAST_S_MP_SQR_C
| | | | | +--->BN_MP_GROW_C
@@ -5175,6 +5508,7 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -5183,7 +5517,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
| +--->BN_MP_CLEAR_C
+--->BN_MP_SUB_D_C
@@ -5201,19 +5534,62 @@ BN_MP_PRIME_RANDOM_EX_C
| +--->BN_MP_CLAMP_C
-BN_MP_KARATSUBA_SQR_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
+BN_MP_CMP_D_C
+
+
+BN_MP_DR_IS_MODULUS_C
+
+
+BN_MP_IMPORT_C
++--->BN_MP_ZERO_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_CLAMP_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
+
+
+BN_MP_COUNT_BITS_C
+
+
+BN_MP_FREAD_C
++--->BN_MP_ZERO_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_ADD_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_D_C
+
+
+BN_MP_REDUCE_2K_L_C
++--->BN_MP_INIT_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_RSHD_C
@@ -5223,106 +5599,793 @@ BN_MP_KARATSUBA_SQR_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_2_C
| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_MUL_2D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_SQR_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
| | +--->BN_MP_GROW_C
-| +--->BN_S_MP_SQR_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
+--->BN_S_MP_ADD_C
| +--->BN_MP_GROW_C
-+--->BN_MP_LSHD_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-+--->BN_MP_ADD_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_AND_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
+--->BN_MP_CLEAR_C
-BN_MP_INIT_COPY_C
+BN_MP_SQRMOD_C
++--->BN_MP_INIT_C
++--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_KARATSUBA_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_CLEAR_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+
+
+BN_MP_DIV_D_C
+--->BN_MP_COPY_C
| +--->BN_MP_GROW_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_DIV_3_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
-BN_MP_CLAMP_C
+BN_MP_INIT_MULTI_C
++--->BN_MP_INIT_C
++--->BN_MP_CLEAR_C
-BN_MP_TOOM_SQR_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_2D_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_COPY_C
+BN_S_MP_EXPTMOD_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_C
++--->BN_MP_CLEAR_C
++--->BN_MP_REDUCE_SETUP_C
+| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_ZERO_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_REDUCE_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| +--->BN_S_MP_MUL_HIGH_DIGS_C
+| | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_D_C
+| +--->BN_MP_SET_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_C
+| | +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_REDUCE_2K_SETUP_L_C
+| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_GROW_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_REDUCE_2K_L_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+--->BN_MP_COPY_C
| +--->BN_MP_GROW_C
-+--->BN_MP_RSHD_C
-| +--->BN_MP_ZERO_C
+--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
| +--->BN_MP_KARATSUBA_SQR_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
+| +--->BN_S_MP_MUL_DIGS_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_EXCH_C
+
+
+BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_2EXPT_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_GROW_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
+--->BN_MP_MUL_2_C
| +--->BN_MP_GROW_C
-+--->BN_MP_ADD_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_MONTGOMERY_SETUP_C
+
+
+BN_FAST_MP_INVMOD_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_MOD_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_SUB_C
| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
@@ -5330,7 +6393,10 @@ BN_MP_TOOM_SQR_C
| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_SUB_C
++--->BN_MP_CMP_C
+| +--->BN_MP_CMP_MAG_C
++--->BN_MP_CMP_D_C
++--->BN_MP_ADD_C
| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
@@ -5338,38 +6404,713 @@ BN_MP_TOOM_SQR_C
| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_2_C
-| +--->BN_MP_GROW_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_MP_TO_UNSIGNED_BIN_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_2D_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_CLEAR_MULTI_C
++--->BN_MP_CLEAR_C
+
+
+BNCORE_C
+
+
+BN_MP_TORADIX_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_DIV_D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_EXPTMOD_FAST_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_C
++--->BN_MP_CLEAR_C
++--->BN_MP_MONTGOMERY_SETUP_C
++--->BN_FAST_MP_MONTGOMERY_REDUCE_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_D_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
++--->BN_MP_MONTGOMERY_REDUCE_C
| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_3_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
++--->BN_MP_DR_SETUP_C
++--->BN_MP_DR_REDUCE_C
+| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
++--->BN_MP_REDUCE_2K_SETUP_C
+| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_GROW_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_REDUCE_2K_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
+| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_SET_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_2_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MULMOD_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| +--->BN_MP_MOD_C
+| | +--->BN_MP_DIV_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_ABS_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_KARATSUBA_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
++--->BN_MP_EXCH_C
+
+
+BN_MP_MUL_D_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_SET_LONG_LONG_C
+
+
+BN_MP_DIV_2_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_ERROR_C
+
+
+BN_MP_RAND_C
++--->BN_MP_ZERO_C
++--->BN_MP_ADD_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_LSHD_C
| +--->BN_MP_GROW_C
-+--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_CLEAR_C
+| +--->BN_MP_RSHD_C
-BN_MP_MOD_C
+BN_S_MP_SQR_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_CMP_C
++--->BN_MP_CMP_MAG_C
+
+
+BN_MP_N_ROOT_EX_C
+--->BN_MP_INIT_C
-+--->BN_MP_DIV_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_EXPT_D_EX_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_KARATSUBA_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_FAST_S_MP_SQR_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
++--->BN_MP_MUL_C
+| +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_COPY_C
+| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_C
+| +--->BN_MP_CMP_MAG_C
| +--->BN_MP_ZERO_C
| +--->BN_MP_INIT_MULTI_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_SET_C
| +--->BN_MP_COUNT_BITS_C
| +--->BN_MP_ABS_C
| +--->BN_MP_MUL_2D_C
@@ -5378,13 +7119,6 @@ BN_MP_MOD_C
| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
@@ -5408,70 +7142,156 @@ BN_MP_MOD_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_RSHD_C
| +--->BN_MP_RSHD_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_C
| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_D_C
| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
-BN_MP_INIT_C
+BN_MP_PRIME_IS_DIVISIBLE_C
++--->BN_MP_MOD_D_C
+| +--->BN_MP_DIV_D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
-BN_MP_TOOM_MUL_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_2D_C
+BN_MP_INIT_SET_INT_C
++--->BN_MP_INIT_C
++--->BN_MP_SET_INT_C
| +--->BN_MP_ZERO_C
-| +--->BN_MP_COPY_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_COPY_C
+
+
+BN_MP_DIV_3_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_MONTGOMERY_REDUCE_C
++--->BN_FAST_MP_MONTGOMERY_REDUCE_C
| +--->BN_MP_GROW_C
+| +--->BN_MP_RSHD_C
+| | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+--->BN_MP_RSHD_C
| +--->BN_MP_ZERO_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_KARATSUBA_MUL_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+
+
+BN_MP_INVMOD_SLOW_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_MOD_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_MUL_2_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
++--->BN_MP_COPY_C
| +--->BN_MP_GROW_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_ADD_C
| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
@@ -5488,257 +7308,176 @@ BN_MP_TOOM_MUL_C
| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_2_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_2D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_D_C
++--->BN_MP_CMP_C
+| +--->BN_MP_CMP_MAG_C
++--->BN_MP_CMP_D_C
++--->BN_MP_CMP_MAG_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
+
+
+BN_S_MP_ADD_C
++--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_READ_SIGNED_BIN_C
++--->BN_MP_READ_UNSIGNED_BIN_C
| +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_3_C
+
+
+BN_MP_MOD_D_C
++--->BN_MP_DIV_D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
| +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_INIT_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_LSHD_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_CLEAR_C
-BN_MP_PRIME_IS_PRIME_C
+BN_MP_SQRTMOD_PRIME_C
+--->BN_MP_CMP_D_C
-+--->BN_MP_PRIME_IS_DIVISIBLE_C
-| +--->BN_MP_MOD_D_C
-| | +--->BN_MP_DIV_D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_DIV_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_INIT_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_INIT_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-+--->BN_MP_INIT_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_PRIME_MILLER_RABIN_C
++--->BN_MP_ZERO_C
++--->BN_MP_JACOBI_C
| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| +--->BN_MP_SUB_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CNT_LSB_C
| +--->BN_MP_DIV_2D_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
| | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| +--->BN_MP_EXPTMOD_C
-| | +--->BN_MP_INVMOD_C
-| | | +--->BN_FAST_MP_INVMOD_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_COPY_C
+| +--->BN_MP_MOD_C
+| | +--->BN_MP_DIV_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_ABS_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_MOD_C
-| | | | | +--->BN_MP_DIV_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_COUNT_BITS_C
-| | | | | | +--->BN_MP_ABS_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | | | +--->BN_MP_CLEAR_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_INVMOD_SLOW_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | +--->BN_MP_MOD_C
-| | | | | +--->BN_MP_DIV_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_MP_COPY_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_COUNT_BITS_C
-| | | | | | +--->BN_MP_ABS_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | | | +--->BN_MP_CLEAR_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_CLEAR_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_COPY_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_ABS_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_MOD_D_C
+| +--->BN_MP_DIV_D_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_ADD_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_EXPTMOD_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_INVMOD_C
+| | +--->BN_FAST_MP_INVMOD_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_REDUCE_IS_2K_L_C
-| | +--->BN_S_MP_EXPTMOD_C
-| | | +--->BN_MP_COUNT_BITS_C
-| | | +--->BN_MP_REDUCE_SETUP_C
-| | | | +--->BN_MP_2EXPT_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_MOD_C
| | | | +--->BN_MP_DIV_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_SET_C
+| | | | | +--->BN_MP_COUNT_BITS_C
+| | | | | +--->BN_MP_ABS_C
| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
@@ -5759,8 +7498,18 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -5769,109 +7518,9 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_REDUCE_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_MUL_C
-| | | | | +--->BN_MP_TOOM_MUL_C
-| | | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | | | +--->BN_MP_COPY_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_COPY_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_MUL_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_3_C
-| | | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_S_MP_MUL_HIGH_DIGS_C
-| | | | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_MUL_DIGS_C
-| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -5880,91 +7529,18 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_REDUCE_2K_SETUP_L_C
-| | | | +--->BN_MP_2EXPT_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_REDUCE_2K_L_C
-| | | | +--->BN_MP_MUL_C
-| | | | | +--->BN_MP_TOOM_MUL_C
-| | | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | | | +--->BN_MP_COPY_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_COPY_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_MUL_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_3_C
-| | | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_RSHD_C
-| | | | | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -5972,13 +7548,18 @@ BN_MP_PRIME_IS_PRIME_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INVMOD_SLOW_C
| | | +--->BN_MP_MOD_C
| | | | +--->BN_MP_DIV_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_MP_COPY_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_SET_C
+| | | | | +--->BN_MP_COUNT_BITS_C
+| | | | | +--->BN_MP_ABS_C
| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
@@ -5999,8 +7580,18 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -6009,6 +7600,9 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -6017,17 +7611,98 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_SQR_C
-| | | | +--->BN_MP_TOOM_SQR_C
-| | | | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_ABS_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_REDUCE_IS_2K_L_C
+| +--->BN_S_MP_EXPTMOD_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_REDUCE_SETUP_C
+| | | +--->BN_MP_2EXPT_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_ZERO_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_REDUCE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_C
+| | | | +--->BN_MP_TOOM_MUL_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_MUL_2_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
@@ -6046,9 +7721,6 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
@@ -6062,40 +7734,95 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_FAST_S_MP_SQR_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_S_MP_MUL_HIGH_DIGS_C
+| | | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_REDUCE_2K_SETUP_L_C
+| | | +--->BN_MP_2EXPT_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_REDUCE_2K_L_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_C
| | | | +--->BN_MP_TOOM_MUL_C
-| | | | | +--->BN_MP_INIT_MULTI_C
| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_MUL_2_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
@@ -6114,9 +7841,6 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
@@ -6133,22 +7857,17 @@ BN_MP_PRIME_IS_PRIME_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -6156,56 +7875,58 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_DR_IS_MODULUS_C
-| | +--->BN_MP_REDUCE_IS_2K_C
-| | | +--->BN_MP_REDUCE_2K_C
-| | | | +--->BN_MP_COUNT_BITS_C
-| | | | +--->BN_MP_MUL_D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_EXPTMOD_FAST_C
-| | | +--->BN_MP_COUNT_BITS_C
-| | | +--->BN_MP_MONTGOMERY_SETUP_C
-| | | +--->BN_FAST_MP_MONTGOMERY_REDUCE_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_MONTGOMERY_REDUCE_C
+| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_DR_SETUP_C
-| | | +--->BN_MP_DR_REDUCE_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_REDUCE_2K_SETUP_C
-| | | | +--->BN_MP_2EXPT_C
-| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_COPY_C
| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_MUL_2D_C
| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_REDUCE_2K_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_MUL_D_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -6213,172 +7934,70 @@ BN_MP_PRIME_IS_PRIME_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-| | | | +--->BN_MP_2EXPT_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_SQR_C
+| | | +--->BN_MP_TOOM_SQR_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_MUL_2_C
| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MULMOD_C
-| | | | +--->BN_MP_MUL_C
-| | | | | +--->BN_MP_TOOM_MUL_C
-| | | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | | +--->BN_MP_MOD_2D_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | | | +--->BN_MP_COPY_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_COPY_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_MUL_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_2_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_DIV_3_C
-| | | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_RSHD_C
-| | | | | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_S_MP_MUL_DIGS_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_MOD_C
-| | | | | +--->BN_MP_DIV_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_MP_COPY_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | | +--->BN_MP_MUL_2D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_LSHD_C
-| | | | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_MUL_D_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_MOD_C
-| | | | +--->BN_MP_DIV_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_CMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
-| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_MUL_D_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_FAST_S_MP_SQR_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_MOD_2D_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -6387,17 +8006,139 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_COPY_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_DR_IS_MODULUS_C
+| +--->BN_MP_REDUCE_IS_2K_C
+| | +--->BN_MP_REDUCE_2K_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_SQR_C
-| | | | +--->BN_MP_TOOM_SQR_C
-| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_EXPTMOD_FAST_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_MONTGOMERY_SETUP_C
+| | +--->BN_FAST_MP_MONTGOMERY_REDUCE_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | +--->BN_MP_MONTGOMERY_REDUCE_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | +--->BN_MP_DR_SETUP_C
+| | +--->BN_MP_DR_REDUCE_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | +--->BN_MP_REDUCE_2K_SETUP_C
+| | | +--->BN_MP_2EXPT_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_REDUCE_2K_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
+| | | +--->BN_MP_2EXPT_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_MULMOD_C
+| | | +--->BN_MP_MUL_C
+| | | | +--->BN_MP_TOOM_MUL_C
| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_COPY_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_MUL_2_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
@@ -6416,9 +8157,6 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_MUL_2D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
@@ -6432,117 +8170,138 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_FAST_S_MP_SQR_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SQR_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_MUL_C
-| | | | +--->BN_MP_TOOM_MUL_C
-| | | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_MOD_2D_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_MOD_C
+| | | | +--->BN_MP_DIV_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_MP_COPY_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_SET_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_C
+| | | | | +--->BN_MP_SUB_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_2_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
+| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_RSHD_C
| | | | | +--->BN_MP_MUL_D_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_DIV_3_C
-| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_EXCH_C
-| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_KARATSUBA_MUL_C
-| | | | | +--->BN_MP_INIT_SIZE_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
-| | | | | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
-| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_MUL_DIGS_C
-| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| +--->BN_MP_CMP_C
-| | +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_SQRMOD_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SQR_C
| | | +--->BN_MP_TOOM_SQR_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_MOD_2D_C
-| | | | | +--->BN_MP_ZERO_C
-| | | | | +--->BN_MP_COPY_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_MUL_2_C
| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
@@ -6561,9 +8320,6 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_DIV_2_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_MUL_2D_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
@@ -6575,31 +8331,20 @@ BN_MP_PRIME_IS_PRIME_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_EXCH_C
-| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
-| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -6607,157 +8352,83 @@ BN_MP_PRIME_IS_PRIME_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_C
-| | | +--->BN_MP_DIV_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_COUNT_BITS_C
-| | | | +--->BN_MP_ABS_C
-| | | | +--->BN_MP_MUL_2D_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_LSHD_C
-| | | | | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_MOD_2D_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_SUB_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_MULTI_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_MUL_2D_C
| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_MUL_D_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_COPY_C
-+--->BN_MP_GROW_C
-
-
-BN_S_MP_SUB_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_READ_UNSIGNED_BIN_C
-+--->BN_MP_GROW_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_MUL_2D_C
-| +--->BN_MP_COPY_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_EXPTMOD_FAST_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_INIT_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_MONTGOMERY_SETUP_C
-+--->BN_FAST_MP_MONTGOMERY_REDUCE_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-+--->BN_MP_MONTGOMERY_REDUCE_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
++--->BN_MP_COPY_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-+--->BN_MP_DR_SETUP_C
-+--->BN_MP_DR_REDUCE_C
++--->BN_MP_SUB_D_C
| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-+--->BN_MP_REDUCE_2K_SETUP_C
-| +--->BN_MP_2EXPT_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_GROW_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_REDUCE_2K_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-| +--->BN_MP_2EXPT_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_SET_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_MUL_2_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
++--->BN_MP_SET_INT_C
+| +--->BN_MP_MUL_2D_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_MULMOD_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
-| | | +--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_SQRMOD_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_2_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ADD_C
@@ -6776,9 +8447,6 @@ BN_MP_EXPTMOD_FAST_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
@@ -6790,43 +8458,38 @@ BN_MP_EXPTMOD_FAST_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_KARATSUBA_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_FAST_S_MP_SQR_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_S_MP_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
| +--->BN_MP_MOD_C
| | +--->BN_MP_DIV_C
| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_COUNT_BITS_C
| | | +--->BN_MP_ABS_C
| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
@@ -6866,582 +8529,144 @@ BN_MP_EXPTMOD_FAST_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
++--->BN_MP_MULMOD_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_MUL_2_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_KARATSUBA_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| +--->BN_FAST_S_MP_SQR_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
+| | +--->BN_S_MP_MUL_DIGS_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_KARATSUBA_MUL_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-+--->BN_MP_EXCH_C
-
-
-BN_MP_TO_UNSIGNED_BIN_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_SET_INT_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_MUL_2D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_MOD_D_C
-+--->BN_MP_DIV_D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_SQR_C
-+--->BN_MP_TOOM_SQR_C
-| +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_MUL_2_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_2_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_KARATSUBA_SQR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| +--->BN_MP_ADD_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_CLEAR_C
-+--->BN_FAST_S_MP_SQR_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_S_MP_SQR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_MULMOD_C
-+--->BN_MP_INIT_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_MOD_C
+| | +--->BN_MP_DIV_C
| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_ABS_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_MUL_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_COPY_C
| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-
-
-BN_MP_DIV_2D_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_INIT_C
-+--->BN_MP_MOD_2D_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_RSHD_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-
-
-BN_S_MP_ADD_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
++--->BN_MP_SET_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
-BN_FAST_S_MP_SQR_C
+BN_FAST_S_MP_MUL_HIGH_DIGS_C
+--->BN_MP_GROW_C
+--->BN_MP_CLAMP_C
-BN_S_MP_MUL_DIGS_C
-+--->BN_FAST_S_MP_MUL_DIGS_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_XOR_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_RADIX_SMAP_C
-
-
-BN_MP_DR_IS_MODULUS_C
-
-
-BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_2EXPT_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_MUL_2_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_MP_SUB_C
-+--->BN_S_MP_ADD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_MP_INIT_MULTI_C
-+--->BN_MP_INIT_C
-+--->BN_MP_CLEAR_C
-
-
-BN_S_MP_MUL_HIGH_DIGS_C
-+--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
+BN_REVERSE_C
BN_MP_PRIME_NEXT_PRIME_C
@@ -7483,6 +8708,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| +--->BN_MP_CLAMP_C
+--->BN_MP_PRIME_MILLER_RABIN_C
| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| +--->BN_MP_CNT_LSB_C
@@ -7543,6 +8769,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
@@ -7551,7 +8778,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_DIV_2_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -7621,6 +8847,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
@@ -7629,7 +8856,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_COPY_C
| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_DIV_2_C
@@ -7755,18 +8981,14 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
@@ -7878,18 +9100,14 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
@@ -7945,6 +9163,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -7953,7 +9172,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_SQR_C
@@ -8001,22 +9219,16 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
| | | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_FAST_S_MP_SQR_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -8069,18 +9281,14 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -8209,18 +9417,14 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | | +--->BN_MP_INIT_SIZE_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | | | +--->BN_MP_SUB_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
-| | | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_ADD_C
-| | | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | | +--->BN_S_MP_SUB_C
| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_LSHD_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_RSHD_C
@@ -8269,6 +9473,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_S_MP_ADD_C
| | | | | | | +--->BN_MP_GROW_C
@@ -8277,7 +9482,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MOD_C
| | | | +--->BN_MP_DIV_C
| | | | | +--->BN_MP_CMP_MAG_C
@@ -8315,6 +9519,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -8323,7 +9528,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_SQR_C
@@ -8371,22 +9575,16 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | +--->BN_MP_KARATSUBA_SQR_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
| | | | | | | +--->BN_MP_ZERO_C
| | | | | +--->BN_MP_ADD_C
| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_FAST_S_MP_SQR_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
@@ -8439,18 +9637,14 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -8519,22 +9713,16 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLEAR_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
@@ -8584,6 +9772,7 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -8592,88 +9781,50 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
+--->BN_MP_CLEAR_C
-BN_MP_SIGNED_BIN_SIZE_C
-+--->BN_MP_UNSIGNED_BIN_SIZE_C
-| +--->BN_MP_COUNT_BITS_C
-
-
-BN_MP_INVMOD_SLOW_C
+BN_MP_TOOM_MUL_C
+--->BN_MP_INIT_MULTI_C
| +--->BN_MP_INIT_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
++--->BN_MP_MOD_2D_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_MUL_C
+| +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
+| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_MUL_DIGS_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_DIV_2_C
++--->BN_MP_MUL_2_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
+--->BN_MP_ADD_C
| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
@@ -8690,194 +9841,143 @@ BN_MP_INVMOD_SLOW_C
| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_C
-| +--->BN_MP_CMP_MAG_C
-+--->BN_MP_CMP_D_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_MP_EXCH_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_3_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_GROW_C
+--->BN_MP_CLEAR_MULTI_C
| +--->BN_MP_CLEAR_C
-BN_MP_LCM_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_GCD_C
-| +--->BN_MP_ABS_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_CNT_LSB_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_EXCH_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
+BN_MP_CNT_LSB_C
+
+
+BN_MP_CLAMP_C
+
+
+BN_MP_SUB_D_C
++--->BN_MP_GROW_C
++--->BN_MP_ADD_D_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_ADD_C
++--->BN_S_MP_ADD_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_CMP_MAG_C
-+--->BN_MP_DIV_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_REDUCE_2K_C
++--->BN_MP_INIT_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_DIV_2D_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
| +--->BN_MP_ZERO_C
-| +--->BN_MP_SET_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_ABS_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
+| +--->BN_MP_MOD_2D_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_COPY_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
+| +--->BN_MP_CLEAR_C
| +--->BN_MP_RSHD_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_S_MP_ADD_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_REDUCE_C
++--->BN_MP_REDUCE_SETUP_C
+| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
+| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_INIT_C
+| | +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_REDUCE_2K_L_C
-+--->BN_MP_INIT_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_DIV_2D_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
| +--->BN_MP_ZERO_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
+--->BN_MP_MUL_C
| +--->BN_MP_TOOM_MUL_C
| | +--->BN_MP_INIT_MULTI_C
@@ -8889,8 +9989,6 @@ BN_MP_REDUCE_2K_L_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MUL_2_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
@@ -8931,22 +10029,16 @@ BN_MP_REDUCE_2K_L_C
| +--->BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
| | +--->BN_MP_CLEAR_C
| +--->BN_FAST_S_MP_MUL_DIGS_C
| | +--->BN_MP_GROW_C
@@ -8956,215 +10048,131 @@ BN_MP_REDUCE_2K_L_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_S_MP_ADD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-
-
-BN_REVERSE_C
-
-
-BN_MP_PRIME_IS_DIVISIBLE_C
-+--->BN_MP_MOD_D_C
-| +--->BN_MP_DIV_D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-
-
-BN_MP_SET_C
-+--->BN_MP_ZERO_C
-
-
-BN_MP_GCD_C
-+--->BN_MP_ABS_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_CNT_LSB_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_COPY_C
++--->BN_S_MP_MUL_HIGH_DIGS_C
+| +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_MOD_2D_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
+| +--->BN_MP_INIT_SIZE_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_MP_EXCH_C
-+--->BN_S_MP_SUB_C
+| +--->BN_MP_CLEAR_C
++--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_MUL_2D_C
++--->BN_MP_MOD_2D_C
+| +--->BN_MP_ZERO_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_REDUCE_2K_SETUP_L_C
-+--->BN_MP_INIT_C
-+--->BN_MP_2EXPT_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_READ_RADIX_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_MUL_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_ADD_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_SUB_D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_FAST_S_MP_MUL_HIGH_DIGS_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_FAST_MP_MONTGOMERY_REDUCE_C
-+--->BN_MP_GROW_C
-+--->BN_MP_RSHD_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-
-
-BN_MP_DIV_D_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_MOD_2D_C
++--->BN_S_MP_MUL_DIGS_C
+| +--->BN_FAST_S_MP_MUL_DIGS_C
+| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_DIV_3_C
| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_REDUCE_2K_SETUP_C
-+--->BN_MP_INIT_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_2EXPT_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_CLEAR_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_MP_INIT_SET_C
-+--->BN_MP_INIT_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_D_C
+--->BN_MP_SET_C
| +--->BN_MP_ZERO_C
-
-
-BN_MP_REDUCE_2K_C
-+--->BN_MP_INIT_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_COPY_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_GROW_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_MOD_2D_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_MUL_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_S_MP_ADD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CMP_C
+| +--->BN_MP_CMP_MAG_C
+--->BN_S_MP_SUB_C
| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
+--->BN_MP_CLEAR_C
-BN_ERROR_C
-
-
-BN_MP_EXPT_D_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
+BN_MP_EXPTMOD_C
++--->BN_MP_INIT_C
++--->BN_MP_INVMOD_C
+| +--->BN_FAST_MP_INVMOD_C
| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_COUNT_BITS_C
+| | | | +--->BN_MP_ABS_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SET_C
| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
+| | +--->BN_MP_DIV_2_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -9172,7 +10180,10 @@ BN_MP_EXPT_D_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
+| | +--->BN_MP_CMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_CMP_D_C
+| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -9180,199 +10191,495 @@ BN_MP_EXPT_D_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INVMOD_SLOW_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_COUNT_BITS_C
+| | | | +--->BN_MP_ABS_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
+| | +--->BN_MP_SET_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_DIV_2_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
+| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_SQR_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_CMP_D_C
+| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
+--->BN_MP_CLEAR_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_MOD_2D_C
++--->BN_MP_ABS_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_CLEAR_MULTI_C
++--->BN_MP_REDUCE_IS_2K_L_C
++--->BN_S_MP_EXPTMOD_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_REDUCE_SETUP_C
+| | +--->BN_MP_2EXPT_C
| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_DIV_C
+| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_REDUCE_C
+| | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | +--->BN_S_MP_MUL_HIGH_DIGS_C
+| | | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_MOD_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
+| | +--->BN_S_MP_MUL_DIGS_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_KARATSUBA_MUL_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_D_C
+| | +--->BN_MP_SET_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-
-
-BN_S_MP_EXPTMOD_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_INIT_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_REDUCE_SETUP_C
-| +--->BN_MP_2EXPT_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_REDUCE_2K_SETUP_L_C
+| | +--->BN_MP_2EXPT_C
+| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_REDUCE_2K_L_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MOD_C
+| | +--->BN_MP_DIV_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_SET_C
+| | | +--->BN_MP_MUL_2D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
+| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_KARATSUBA_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_FAST_S_MP_SQR_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_REDUCE_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
+| | +--->BN_S_MP_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| +--->BN_MP_MUL_C
| | +--->BN_MP_TOOM_MUL_C
| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_2_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ADD_C
@@ -9407,24 +10714,21 @@ BN_S_MP_EXPTMOD_C
| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLEAR_MULTI_C
| | +--->BN_MP_KARATSUBA_MUL_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
| | +--->BN_FAST_S_MP_MUL_DIGS_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -9432,29 +10736,25 @@ BN_S_MP_EXPTMOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| +--->BN_S_MP_MUL_HIGH_DIGS_C
-| | +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MOD_2D_C
+| +--->BN_MP_SET_C
| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_DR_IS_MODULUS_C
++--->BN_MP_REDUCE_IS_2K_C
+| +--->BN_MP_REDUCE_2K_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| +--->BN_MP_SUB_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -9462,12 +10762,50 @@ BN_S_MP_EXPTMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_D_C
-| +--->BN_MP_SET_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_LSHD_C
+| +--->BN_MP_COUNT_BITS_C
++--->BN_MP_EXPTMOD_FAST_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_MONTGOMERY_SETUP_C
+| +--->BN_FAST_MP_MONTGOMERY_REDUCE_C
| | +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| +--->BN_MP_MONTGOMERY_REDUCE_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| +--->BN_MP_DR_SETUP_C
+| +--->BN_MP_DR_REDUCE_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| +--->BN_MP_REDUCE_2K_SETUP_C
+| | +--->BN_MP_2EXPT_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_REDUCE_2K_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
@@ -9475,38 +10813,204 @@ BN_S_MP_EXPTMOD_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
+| +--->BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
+| | +--->BN_MP_2EXPT_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_SET_C
+| | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_REDUCE_2K_SETUP_L_C
-| +--->BN_MP_2EXPT_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_GROW_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_REDUCE_2K_L_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_COPY_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_MULMOD_C
+| | +--->BN_MP_MUL_C
+| | | +--->BN_MP_TOOM_MUL_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_COPY_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MUL_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_3_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_MUL_DIGS_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_MOD_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_SUB_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_MUL_D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_SET_C
| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
+| +--->BN_MP_MOD_C
+| | +--->BN_MP_DIV_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_C
-| | +--->BN_MP_TOOM_MUL_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_SQR_C
+| | +--->BN_MP_TOOM_SQR_C
| | | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_2_C
@@ -9543,22 +11047,79 @@ BN_S_MP_EXPTMOD_C
| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_KARATSUBA_MUL_C
+| | +--->BN_MP_KARATSUBA_SQR_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | +--->BN_FAST_S_MP_SQR_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_S_MP_SQR_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| +--->BN_MP_MUL_C
+| | +--->BN_MP_TOOM_MUL_C
+| | | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_MUL_2_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_SUB_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CMP_MAG_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_2_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_2D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_DIV_3_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_GROW_C
+| | +--->BN_MP_KARATSUBA_MUL_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_ADD_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_RSHD_C
@@ -9570,143 +11131,90 @@ BN_S_MP_EXPTMOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+
+
+BN_MP_LSHD_C
++--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
+| +--->BN_MP_ZERO_C
+
+
+BN_MP_ADD_D_C
++--->BN_MP_GROW_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLAMP_C
+
+
+BN_MP_GET_LONG_C
+
+
+BN_MP_GET_LONG_LONG_C
+
+
+BN_MP_CLEAR_C
+
+
+BN_MP_EXTEUCLID_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_SET_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_DIV_C
| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_ABS_C
+| +--->BN_MP_MUL_2D_C
| | +--->BN_MP_GROW_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
+| +--->BN_MP_CMP_C
+| +--->BN_MP_SUB_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_SQR_C
-| +--->BN_MP_TOOM_SQR_C
-| | +--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_DIV_2D_C
+| | +--->BN_MP_INIT_C
| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLEAR_C
| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MUL_2_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_KARATSUBA_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_EXCH_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_INIT_COPY_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_RSHD_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_MUL_D_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SQR_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLEAR_C
+--->BN_MP_MUL_C
| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_CLAMP_C
@@ -9742,76 +11250,63 @@ BN_S_MP_EXPTMOD_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_3_C
| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
+| | | +--->BN_MP_CLEAR_C
| +--->BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_CLEAR_C
| +--->BN_FAST_S_MP_MUL_DIGS_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
| +--->BN_S_MP_MUL_DIGS_C
| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_EXCH_C
-
-
-BN_MP_ABS_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-
-
-BN_MP_INIT_SET_INT_C
-+--->BN_MP_INIT_C
-+--->BN_MP_SET_INT_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_MP_SUB_D_C
-+--->BN_MP_GROW_C
-+--->BN_MP_ADD_D_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_NEG_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_MULTI_C
+| +--->BN_MP_CLEAR_C
-BN_MP_TO_SIGNED_BIN_C
-+--->BN_MP_TO_UNSIGNED_BIN_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
+BN_MP_TORADIX_N_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_DIV_D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
@@ -9819,21 +11314,28 @@ BN_MP_TO_SIGNED_BIN_C
| | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
++--->BN_MP_CLEAR_C
-BN_MP_DIV_2_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_REDUCE_IS_2K_C
-+--->BN_MP_REDUCE_2K_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_COUNT_BITS_C
+BN_MP_RADIX_SIZE_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_DIV_D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_CLAMP_C
@@ -9841,185 +11343,85 @@ BN_MP_REDUCE_IS_2K_C
| | +--->BN_MP_RSHD_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
+| +--->BN_MP_DIV_3_C
+| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_COUNT_BITS_C
-
-
-BN_MP_INIT_SIZE_C
-+--->BN_MP_INIT_C
++--->BN_MP_CLEAR_C
-BN_MP_DIV_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_SET_C
-+--->BN_MP_COUNT_BITS_C
-+--->BN_MP_ABS_C
-+--->BN_MP_MUL_2D_C
+BN_S_MP_MUL_HIGH_DIGS_C
++--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_CLEAR_C
+--->BN_MP_INIT_SIZE_C
| +--->BN_MP_INIT_C
-+--->BN_MP_INIT_C
-+--->BN_MP_INIT_COPY_C
-+--->BN_MP_LSHD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-+--->BN_MP_RSHD_C
-+--->BN_MP_MUL_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
+--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
+--->BN_MP_CLEAR_C
-BN_MP_CLEAR_C
-
-
-BN_MP_MONTGOMERY_REDUCE_C
-+--->BN_FAST_MP_MONTGOMERY_REDUCE_C
+BN_MP_SET_INT_C
++--->BN_MP_ZERO_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
| +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
| +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-+--->BN_MP_GROW_C
+--->BN_MP_CLAMP_C
-+--->BN_MP_RSHD_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-BN_MP_MUL_2_C
-+--->BN_MP_GROW_C
+BN_MP_DR_SETUP_C
-BN_MP_UNSIGNED_BIN_SIZE_C
-+--->BN_MP_COUNT_BITS_C
+BN_MP_MUL_2_C
++--->BN_MP_GROW_C
-BN_MP_ADDMOD_C
-+--->BN_MP_INIT_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-+--->BN_MP_MOD_C
-| +--->BN_MP_DIV_C
-| | +--->BN_MP_CMP_MAG_C
+BN_MP_FWRITE_C
++--->BN_MP_RADIX_SIZE_C
+| +--->BN_MP_COUNT_BITS_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_SET_C
-| | +--->BN_MP_COUNT_BITS_C
-| | +--->BN_MP_ABS_C
-| | +--->BN_MP_MUL_2D_C
+| +--->BN_MP_DIV_D_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_TORADIX_C
+| +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_LSHD_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_MUL_D_C
+| +--->BN_MP_DIV_D_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-
-
-BN_MP_ADD_C
-+--->BN_S_MP_ADD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-
-
-BN_MP_TO_SIGNED_BIN_N_C
-+--->BN_MP_SIGNED_BIN_SIZE_C
-| +--->BN_MP_UNSIGNED_BIN_SIZE_C
-| | +--->BN_MP_COUNT_BITS_C
-+--->BN_MP_TO_SIGNED_BIN_C
-| +--->BN_MP_TO_UNSIGNED_BIN_C
-| | +--->BN_MP_INIT_COPY_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
@@ -10027,71 +11429,92 @@ BN_MP_TO_SIGNED_BIN_N_C
| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
+| +--->BN_MP_CLEAR_C
-BN_MP_REDUCE_IS_2K_L_C
+BN_MP_GROW_C
-BN_MP_RAND_C
+BN_MP_READ_RADIX_C
+--->BN_MP_ZERO_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+--->BN_MP_ADD_D_C
| +--->BN_MP_GROW_C
| +--->BN_MP_SUB_D_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_CLAMP_C
-+--->BN_MP_LSHD_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-
-BN_MP_CNT_LSB_C
-
-
-BN_MP_2EXPT_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_GROW_C
-
-BN_MP_RSHD_C
-+--->BN_MP_ZERO_C
+BN_S_MP_MUL_DIGS_C
++--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_MP_EXCH_C
++--->BN_MP_CLEAR_C
-BN_MP_SHRINK_C
+BN_PRIME_TAB_C
-BN_MP_TO_UNSIGNED_BIN_N_C
-+--->BN_MP_UNSIGNED_BIN_SIZE_C
-| +--->BN_MP_COUNT_BITS_C
-+--->BN_MP_TO_UNSIGNED_BIN_C
-| +--->BN_MP_INIT_COPY_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_DIV_2D_C
+BN_MP_IS_SQUARE_C
++--->BN_MP_MOD_D_C
+| +--->BN_MP_DIV_D_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_DIV_3_C
+| | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_CLEAR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_REDUCE_C
-+--->BN_MP_REDUCE_SETUP_C
-| +--->BN_MP_2EXPT_C
+| | +--->BN_MP_CLEAR_C
++--->BN_MP_INIT_SET_INT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_SET_INT_C
| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_GROW_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MOD_C
+| +--->BN_MP_INIT_C
| +--->BN_MP_DIV_C
| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_SET_C
| | +--->BN_MP_COUNT_BITS_C
@@ -10117,7 +11540,6 @@ BN_MP_REDUCE_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_2D_C
-| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_MOD_2D_C
| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CLEAR_C
@@ -10128,8 +11550,6 @@ BN_MP_REDUCE_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_INIT_C
| | +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
@@ -10140,173 +11560,300 @@ BN_MP_REDUCE_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_RSHD_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
-| | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_COPY_C
+| +--->BN_MP_CLEAR_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_MUL_2_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_CLAMP_C
++--->BN_MP_GET_INT_C
++--->BN_MP_SQRT_C
+| +--->BN_MP_N_ROOT_C
+| | +--->BN_MP_N_ROOT_EX_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_SET_C
+| | | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_EXPT_D_EX_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_MUL_C
+| | | | | +--->BN_MP_TOOM_MUL_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_MUL_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_3_C
+| | | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_EXCH_C
+| | | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_SQR_C
+| | | | | +--->BN_MP_TOOM_SQR_C
+| | | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_MUL_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_SUB_C
+| | | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | | +--->BN_MP_GROW_C
+| | | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_2_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_2D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_MUL_D_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_DIV_3_C
+| | | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_KARATSUBA_SQR_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_RSHD_C
+| | | | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_ADD_C
+| | | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | +--->BN_FAST_S_MP_SQR_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SQR_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | +--->BN_MP_MUL_C
+| | | | +--->BN_MP_TOOM_MUL_C
+| | | | | +--->BN_MP_INIT_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_MUL_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_SUB_C
+| | | | | | +--->BN_S_MP_ADD_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_2D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_MUL_D_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_3_C
+| | | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_KARATSUBA_MUL_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_ADD_C
+| | | | | | +--->BN_MP_CMP_MAG_C
+| | | | | | +--->BN_S_MP_SUB_C
+| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | | +--->BN_MP_ZERO_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_S_MP_MUL_DIGS_C
+| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_SUB_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_DIV_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_INIT_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_COUNT_BITS_C
+| | | | +--->BN_MP_ABS_C
+| | | | +--->BN_MP_MUL_2D_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_LSHD_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_ADD_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_EXCH_C
+| | | | +--->BN_MP_CLEAR_MULTI_C
+| | | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_LSHD_C
+| | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_CMP_C
+| | | | +--->BN_MP_CMP_MAG_C
+| | | +--->BN_MP_SUB_D_C
| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ADD_D_C
+| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_2_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_2D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_MUL_D_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_MUL_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_INIT_COPY_C
| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
+| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_S_MP_MUL_HIGH_DIGS_C
-| +--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_FAST_S_MP_MUL_HIGH_DIGS_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_MOD_2D_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_S_MP_MUL_DIGS_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_D_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_LSHD_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_C
-| +--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_MUL_2D_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_GROW_C
-+--->BN_MP_LSHD_C
| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-+--->BN_MP_CLAMP_C
-
-
-BN_MP_GET_INT_C
-
-
-BN_MP_JACOBI_C
-+--->BN_MP_CMP_D_C
-+--->BN_MP_INIT_COPY_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_CNT_LSB_C
-+--->BN_MP_DIV_2D_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_MOD_C
| +--->BN_MP_DIV_C
| | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ZERO_C
| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_SET_C
@@ -10315,7 +11862,6 @@ BN_MP_JACOBI_C
| | +--->BN_MP_MUL_2D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_RSHD_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CMP_C
| | +--->BN_MP_SUB_C
@@ -10332,20 +11878,23 @@ BN_MP_JACOBI_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_CLEAR_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_RSHD_C
| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
| +--->BN_MP_ADD_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
@@ -10354,160 +11903,24 @@ BN_MP_JACOBI_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_CLEAR_MULTI_C
-+--->BN_MP_CLEAR_C
-
-
-BN_MP_MUL_C
-+--->BN_MP_TOOM_MUL_C
-| +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_MOD_2D_C
-| | +--->BN_MP_ZERO_C
-| | +--->BN_MP_COPY_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_COPY_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_RSHD_C
-| | +--->BN_MP_ZERO_C
-| +--->BN_MP_MUL_2_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| +--->BN_MP_DIV_2_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_3_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-+--->BN_MP_KARATSUBA_MUL_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | +--->BN_MP_CMP_MAG_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_ZERO_C
-| +--->BN_MP_CLEAR_C
-+--->BN_FAST_S_MP_MUL_DIGS_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_S_MP_MUL_DIGS_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_CLAMP_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_EXTEUCLID_C
-+--->BN_MP_INIT_MULTI_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_CLEAR_C
-+--->BN_MP_SET_C
-| +--->BN_MP_ZERO_C
-+--->BN_MP_COPY_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_DIV_C
| +--->BN_MP_CMP_MAG_C
-| +--->BN_MP_ZERO_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_ABS_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
-| +--->BN_MP_SUB_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
-| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_MULTI_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_COPY_C
-| +--->BN_MP_LSHD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_MUL_D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
| +--->BN_MP_CLEAR_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
++--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
+| | +--->BN_MP_INIT_MULTI_C
+| | | +--->BN_MP_INIT_C
+| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_MOD_2D_C
| | | +--->BN_MP_ZERO_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_RSHD_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MUL_2_C
@@ -10548,137 +11961,120 @@ BN_MP_EXTEUCLID_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_KARATSUBA_MUL_C
+| +--->BN_MP_KARATSUBA_SQR_C
| | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_SUB_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_FAST_S_MP_SQR_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
+| +--->BN_S_MP_SQR_C
| | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-+--->BN_MP_NEG_C
-+--->BN_MP_EXCH_C
-+--->BN_MP_CLEAR_MULTI_C
-| +--->BN_MP_CLEAR_C
-
-
-BN_MP_DR_REDUCE_C
-+--->BN_MP_GROW_C
-+--->BN_MP_CLAMP_C
+--->BN_MP_CMP_MAG_C
-+--->BN_S_MP_SUB_C
++--->BN_MP_CLEAR_C
-BN_MP_FREAD_C
-+--->BN_MP_ZERO_C
-+--->BN_MP_MUL_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_ADD_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_SUB_D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
-+--->BN_MP_CMP_D_C
+BN_MP_COPY_C
++--->BN_MP_GROW_C
-BN_MP_REDUCE_SETUP_C
-+--->BN_MP_2EXPT_C
+BN_MP_TOOM_SQR_C
++--->BN_MP_INIT_MULTI_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_MOD_2D_C
| +--->BN_MP_ZERO_C
-| +--->BN_MP_GROW_C
-+--->BN_MP_DIV_C
-| +--->BN_MP_CMP_MAG_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
| +--->BN_MP_ZERO_C
-| +--->BN_MP_INIT_MULTI_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_SET_C
-| +--->BN_MP_COUNT_BITS_C
-| +--->BN_MP_ABS_C
-| +--->BN_MP_MUL_2D_C
-| | +--->BN_MP_GROW_C
-| | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_RSHD_C
++--->BN_MP_SQR_C
+| +--->BN_MP_KARATSUBA_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CMP_C
-| +--->BN_MP_SUB_C
| | +--->BN_S_MP_ADD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_S_MP_SUB_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_ADD_C
-| | +--->BN_S_MP_ADD_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SUB_C
+| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| +--->BN_MP_DIV_2D_C
-| | +--->BN_MP_INIT_C
-| | +--->BN_MP_MOD_2D_C
-| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_MP_CMP_MAG_C
| | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_RSHD_C
+| +--->BN_FAST_S_MP_SQR_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
+| | +--->BN_MP_INIT_SIZE_C
+| | | +--->BN_MP_INIT_C
| | +--->BN_MP_CLAMP_C
| | +--->BN_MP_EXCH_C
-| +--->BN_MP_EXCH_C
-| +--->BN_MP_CLEAR_MULTI_C
| | +--->BN_MP_CLEAR_C
-| +--->BN_MP_INIT_SIZE_C
-| | +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_C
-| +--->BN_MP_INIT_COPY_C
-| +--->BN_MP_LSHD_C
++--->BN_MP_MUL_2_C
+| +--->BN_MP_GROW_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_RSHD_C
-| +--->BN_MP_RSHD_C
-| +--->BN_MP_MUL_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_2_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_D_C
+| +--->BN_MP_GROW_C
| +--->BN_MP_CLAMP_C
++--->BN_MP_DIV_3_C
+| +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_CLEAR_C
++--->BN_MP_LSHD_C
+| +--->BN_MP_GROW_C
++--->BN_MP_CLEAR_MULTI_C
| +--->BN_MP_CLEAR_C
-BN_MP_MONTGOMERY_SETUP_C
-
-
-BN_MP_KARATSUBA_MUL_C
-+--->BN_MP_MUL_C
-| +--->BN_MP_TOOM_MUL_C
+BN_MP_KARATSUBA_SQR_C
++--->BN_MP_INIT_SIZE_C
+| +--->BN_MP_INIT_C
++--->BN_MP_CLAMP_C
++--->BN_MP_SQR_C
+| +--->BN_MP_TOOM_SQR_C
| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
@@ -10686,7 +12082,6 @@ BN_MP_KARATSUBA_MUL_C
| | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_RSHD_C
@@ -10696,86 +12091,55 @@ BN_MP_KARATSUBA_MUL_C
| | +--->BN_MP_ADD_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_SUB_C
| | | +--->BN_S_MP_ADD_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_CMP_MAG_C
| | | +--->BN_S_MP_SUB_C
| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_2_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_MUL_2D_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_LSHD_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_MUL_D_C
| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_DIV_3_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_INIT_C
-| | | +--->BN_MP_CLAMP_C
| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_LSHD_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_CLEAR_MULTI_C
| | | +--->BN_MP_CLEAR_C
-| +--->BN_FAST_S_MP_MUL_DIGS_C
+| +--->BN_FAST_S_MP_SQR_C
| | +--->BN_MP_GROW_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_S_MP_MUL_DIGS_C
-| | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_INIT_C
-| | +--->BN_MP_CLAMP_C
+| +--->BN_S_MP_SQR_C
| | +--->BN_MP_EXCH_C
| | +--->BN_MP_CLEAR_C
-+--->BN_MP_INIT_SIZE_C
-| +--->BN_MP_INIT_C
-+--->BN_MP_CLAMP_C
-+--->BN_MP_SUB_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
-+--->BN_MP_ADD_C
-| +--->BN_S_MP_ADD_C
-| | +--->BN_MP_GROW_C
-| +--->BN_MP_CMP_MAG_C
-| +--->BN_S_MP_SUB_C
-| | +--->BN_MP_GROW_C
++--->BN_S_MP_ADD_C
+| +--->BN_MP_GROW_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+--->BN_MP_LSHD_C
| +--->BN_MP_GROW_C
| +--->BN_MP_RSHD_C
| | +--->BN_MP_ZERO_C
++--->BN_MP_ADD_C
+| +--->BN_MP_CMP_MAG_C
+--->BN_MP_CLEAR_C
-BN_MP_LSHD_C
-+--->BN_MP_GROW_C
-+--->BN_MP_RSHD_C
-| +--->BN_MP_ZERO_C
-
-
-BN_MP_PRIME_MILLER_RABIN_C
-+--->BN_MP_CMP_D_C
+BN_MP_GCD_C
++--->BN_MP_ABS_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+--->BN_MP_INIT_COPY_C
+| +--->BN_MP_INIT_SIZE_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
-+--->BN_MP_SUB_D_C
-| +--->BN_MP_GROW_C
-| +--->BN_MP_ADD_D_C
-| | +--->BN_MP_CLAMP_C
-| +--->BN_MP_CLAMP_C
+--->BN_MP_CNT_LSB_C
+--->BN_MP_DIV_2D_C
| +--->BN_MP_COPY_C
@@ -10787,6 +12151,165 @@ BN_MP_PRIME_MILLER_RABIN_C
| +--->BN_MP_RSHD_C
| +--->BN_MP_CLAMP_C
| +--->BN_MP_EXCH_C
++--->BN_MP_CMP_MAG_C
++--->BN_MP_EXCH_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
+
+
+BN_MP_MOD_2D_C
++--->BN_MP_ZERO_C
++--->BN_MP_COPY_C
+| +--->BN_MP_GROW_C
++--->BN_MP_CLAMP_C
+
+
+BN_FAST_MP_MONTGOMERY_REDUCE_C
++--->BN_MP_GROW_C
++--->BN_MP_RSHD_C
+| +--->BN_MP_ZERO_C
++--->BN_MP_CLAMP_C
++--->BN_MP_CMP_MAG_C
++--->BN_S_MP_SUB_C
+
+
+BN_MP_SUBMOD_C
++--->BN_MP_INIT_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_ADD_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+| +--->BN_MP_ADD_C
+| | +--->BN_S_MP_ADD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_S_MP_SUB_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+
+
+BN_MP_GET_INT_C
+
+
+BN_MP_SET_LONG_C
+
+
+BN_MP_ADDMOD_C
++--->BN_MP_INIT_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_MOD_C
+| +--->BN_MP_DIV_C
+| | +--->BN_MP_CMP_MAG_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_INIT_MULTI_C
+| | +--->BN_MP_SET_C
+| | +--->BN_MP_COUNT_BITS_C
+| | +--->BN_MP_ABS_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CMP_C
+| | +--->BN_MP_SUB_C
+| | | +--->BN_S_MP_ADD_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_S_MP_SUB_C
+| | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_DIV_2D_C
+| | | +--->BN_MP_MOD_2D_C
+| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
+| | +--->BN_MP_EXCH_C
+| | +--->BN_MP_CLEAR_MULTI_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_LSHD_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_RSHD_C
+| | +--->BN_MP_RSHD_C
+| | +--->BN_MP_MUL_D_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
+
+
+BN_MP_PRIME_FERMAT_C
++--->BN_MP_CMP_D_C
++--->BN_MP_INIT_C
+--->BN_MP_EXPTMOD_C
| +--->BN_MP_INVMOD_C
| | +--->BN_FAST_MP_INVMOD_C
@@ -10821,10 +12344,18 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_CLEAR_MULTI_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -10835,6 +12366,7 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -10843,7 +12375,6 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_SET_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_DIV_2_C
@@ -10902,10 +12433,18 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_CLEAR_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_CLEAR_MULTI_C
| | | | | | +--->BN_MP_CLEAR_C
| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -10916,6 +12455,7 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLEAR_C
| | | | +--->BN_MP_CLEAR_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -10924,7 +12464,6 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_COPY_C
| | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_SET_C
@@ -10993,8 +12532,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -11004,6 +12550,10 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_C
+| | | +--->BN_MP_INIT_COPY_C
+| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
| | | +--->BN_MP_RSHD_C
| | | | +--->BN_MP_ZERO_C
| | | +--->BN_MP_MUL_C
@@ -11053,18 +12603,14 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_FAST_S_MP_MUL_DIGS_C
@@ -11129,6 +12675,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_2K_L_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_C
| | | | +--->BN_MP_TOOM_MUL_C
| | | | | +--->BN_MP_INIT_MULTI_C
@@ -11178,18 +12733,14 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -11236,8 +12787,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -11246,6 +12804,7 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -11254,7 +12813,6 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SQR_C
@@ -11302,22 +12860,16 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -11370,18 +12922,14 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | +--->BN_MP_KARATSUBA_MUL_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -11400,6 +12948,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| +--->BN_MP_REDUCE_IS_2K_C
| | +--->BN_MP_REDUCE_2K_C
| | | +--->BN_MP_COUNT_BITS_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -11442,6 +12999,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_REDUCE_2K_C
+| | | +--->BN_MP_DIV_2D_C
+| | | | +--->BN_MP_COPY_C
+| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_MP_ZERO_C
+| | | | +--->BN_MP_MOD_2D_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_RSHD_C
+| | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_MUL_D_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -11514,18 +13080,14 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_MP_KARATSUBA_MUL_C
| | | | | +--->BN_MP_INIT_SIZE_C
| | | | | +--->BN_MP_CLAMP_C
-| | | | | +--->BN_MP_SUB_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
-| | | | | | +--->BN_MP_CMP_MAG_C
-| | | | | | +--->BN_S_MP_SUB_C
-| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_ADD_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ADD_C
-| | | | | | +--->BN_S_MP_ADD_C
-| | | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CMP_MAG_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
+| | | | | +--->BN_S_MP_SUB_C
+| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -11565,8 +13127,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | | +--->BN_S_MP_SUB_C
| | | | | | | +--->BN_MP_GROW_C
| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_DIV_2D_C
+| | | | | | +--->BN_MP_MOD_2D_C
+| | | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_RSHD_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_EXCH_C
| | | | | +--->BN_MP_INIT_SIZE_C
+| | | | | +--->BN_MP_INIT_COPY_C
| | | | | +--->BN_MP_LSHD_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_RSHD_C
@@ -11575,6 +13144,7 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
| | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_S_MP_ADD_C
| | | | | | +--->BN_MP_GROW_C
@@ -11583,7 +13153,6 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
| | +--->BN_MP_SET_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
@@ -11613,8 +13182,15 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
| | | | | | +--->BN_MP_CLAMP_C
+| | | | +--->BN_MP_DIV_2D_C
+| | | | | +--->BN_MP_MOD_2D_C
+| | | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_RSHD_C
+| | | | | +--->BN_MP_CLAMP_C
+| | | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_EXCH_C
| | | | +--->BN_MP_INIT_SIZE_C
+| | | | +--->BN_MP_INIT_COPY_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -11623,6 +13199,7 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
| | | | +--->BN_MP_CLAMP_C
+| | | +--->BN_MP_EXCH_C
| | | +--->BN_MP_ADD_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
@@ -11631,7 +13208,6 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | | +--->BN_S_MP_SUB_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
| | +--->BN_MP_COPY_C
| | | +--->BN_MP_GROW_C
| | +--->BN_MP_SQR_C
@@ -11679,22 +13255,16 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | +--->BN_MP_KARATSUBA_SQR_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | | +--->BN_S_MP_ADD_C
| | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
| | | | | | +--->BN_MP_ZERO_C
| | | | +--->BN_MP_ADD_C
| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
| | | +--->BN_FAST_S_MP_SQR_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_CLAMP_C
@@ -11747,18 +13317,14 @@ BN_MP_PRIME_MILLER_RABIN_C
| | | +--->BN_MP_KARATSUBA_MUL_C
| | | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_SUB_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CMP_MAG_C
-| | | | | +--->BN_S_MP_SUB_C
-| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_ADD_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ADD_C
-| | | | | +--->BN_S_MP_ADD_C
-| | | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_CMP_MAG_C
| | | | | +--->BN_S_MP_SUB_C
| | | | | | +--->BN_MP_GROW_C
+| | | | +--->BN_S_MP_SUB_C
+| | | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_LSHD_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_RSHD_C
@@ -11773,141 +13339,18 @@ BN_MP_PRIME_MILLER_RABIN_C
| | +--->BN_MP_EXCH_C
+--->BN_MP_CMP_C
| +--->BN_MP_CMP_MAG_C
-+--->BN_MP_SQRMOD_C
-| +--->BN_MP_SQR_C
-| | +--->BN_MP_TOOM_SQR_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_MOD_2D_C
-| | | | +--->BN_MP_ZERO_C
-| | | | +--->BN_MP_COPY_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_MUL_2_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_2_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_DIV_3_C
-| | | | +--->BN_MP_INIT_SIZE_C
-| | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_MP_EXCH_C
-| | | | +--->BN_MP_CLEAR_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLEAR_MULTI_C
-| | | | +--->BN_MP_CLEAR_C
-| | +--->BN_MP_KARATSUBA_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_MP_CMP_MAG_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLEAR_C
-| | +--->BN_FAST_S_MP_SQR_C
-| | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_S_MP_SQR_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_C
-| +--->BN_MP_CLEAR_C
-| +--->BN_MP_MOD_C
-| | +--->BN_MP_DIV_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_MP_COPY_C
-| | | | +--->BN_MP_GROW_C
-| | | +--->BN_MP_ZERO_C
-| | | +--->BN_MP_INIT_MULTI_C
-| | | +--->BN_MP_SET_C
-| | | +--->BN_MP_COUNT_BITS_C
-| | | +--->BN_MP_ABS_C
-| | | +--->BN_MP_MUL_2D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_LSHD_C
-| | | | | +--->BN_MP_RSHD_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_SUB_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_ADD_C
-| | | | +--->BN_S_MP_ADD_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | | +--->BN_S_MP_SUB_C
-| | | | | +--->BN_MP_GROW_C
-| | | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_EXCH_C
-| | | +--->BN_MP_CLEAR_MULTI_C
-| | | +--->BN_MP_INIT_SIZE_C
-| | | +--->BN_MP_LSHD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_RSHD_C
-| | | +--->BN_MP_MUL_D_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_ADD_C
-| | | +--->BN_S_MP_ADD_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | | +--->BN_MP_CMP_MAG_C
-| | | +--->BN_S_MP_SUB_C
-| | | | +--->BN_MP_GROW_C
-| | | | +--->BN_MP_CLAMP_C
-| | +--->BN_MP_EXCH_C
+--->BN_MP_CLEAR_C
-BN_MP_DR_SETUP_C
-
-
-BN_MP_CMP_MAG_C
+BN_MP_REDUCE_2K_SETUP_L_C
++--->BN_MP_INIT_C
++--->BN_MP_2EXPT_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_GROW_C
++--->BN_MP_COUNT_BITS_C
++--->BN_S_MP_SUB_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
diff --git a/libtommath/changes.txt b/libtommath/changes.txt
index 4fc0913..d70d589 100644
--- a/libtommath/changes.txt
+++ b/libtommath/changes.txt
@@ -1,11 +1,32 @@
+Feb 5th, 2016
+v1.0.0
+ -- Bump to 1.0.0
+ -- Dirkjan Bussink provided a faster version of mp_expt_d()
+ -- Moritz Lenz contributed a fix to mp_mod()
+ and provided mp_get_long() and mp_set_long()
+ -- Fixed bugs in mp_read_radix(), mp_radix_size
+ Thanks to shameister, Gerhard R,
+ -- Christopher Brown provided mp_export() and mp_import()
+ -- Improvements in the code of mp_init_copy()
+ Thanks to ramkumarkoppu,
+ -- lomereiter provided mp_balance_mul()
+ -- Alexander Boström from the heimdal project contributed patches to
+ mp_prime_next_prime() and mp_invmod() and added a mp_isneg() macro
+ -- Fix build issues for Linux x32 ABI
+ -- Added mp_get_long_long() and mp_set_long_long()
+ -- Carlin provided a patch to use arc4random() instead of rand()
+ on platforms where it is supported
+ -- Karel Miko provided mp_sqrtmod_prime()
+
+
July 23rd, 2010
v0.42.0
-- Fix for mp_prime_next_prime() bug when checking generated prime
-- allow mp_shrink to shrink initialized, but empty MPI's
- -- Added project and solution files for Visual Studio 2005 and Visual Studio 2008.
+ -- Added project and solution files for Visual Studio 2005 and Visual Studio 2008.
March 10th, 2007
-v0.41 -- Wolfgang Ehrhardt suggested a quick fix to mp_div_d() which makes the detection of powers of two quicker.
+v0.41 -- Wolfgang Ehrhardt suggested a quick fix to mp_div_d() which makes the detection of powers of two quicker.
-- [CRI] Added libtommath.dsp for Visual C++ users.
December 24th, 2006
@@ -22,11 +43,11 @@ v0.39 -- Jim Wigginton pointed out my Montgomery examples in figures 6.4 and 6.
Jan 26th, 2006
v0.38 -- broken makefile.shared fixed
-- removed some carry stores that were not required [updated text]
-
+
November 18th, 2005
v0.37 -- [Don Porter] reported on a TCL list [HEY SEND ME BUGREPORTS ALREADY!!!] that mp_add_d() would compute -0 with some inputs. Fixed.
-- [rinick@gmail.com] reported the makefile.bcc was messed up. Fixed.
- -- [Kevin Kenny] reported some issues with mp_toradix_n(). Now it doesn't require a min of 3 chars of output.
+ -- [Kevin Kenny] reported some issues with mp_toradix_n(). Now it doesn't require a min of 3 chars of output.
-- Made the make command renamable. Wee
August 1st, 2005
@@ -36,8 +57,8 @@ v0.36 -- LTM_PRIME_2MSB_ON was fixed and the "OFF" flag was removed.
-- Ported LTC patch to fix the prime_random_ex() function to get the bitsize correct [and the maskOR flags]
-- Kevin Kenny pointed out a stray //
-- David Hulton pointed out a typo in the textbook [mp_montgomery_setup() pseudo-code]
- -- Neal Hamilton (Elliptic Semiconductor) pointed out that my Karatsuba notation was backwards and that I could use
- unsigned operations in the routine.
+ -- Neal Hamilton (Elliptic Semiconductor) pointed out that my Karatsuba notation was backwards and that I could use
+ unsigned operations in the routine.
-- Paul Schmidt pointed out a linking error in mp_exptmod() when BN_S_MP_EXPTMOD_C is undefined (and another for read_radix)
-- Updated makefiles to be way more flexible
@@ -48,7 +69,7 @@ v0.35 -- Stupid XOR function missing line again... oops.
-- [Wolfgang Ehrhardt] Suggested a fix for mp_reduce() which avoided underruns. ;-)
-- mp_rand() would emit one too many digits and it was possible to get a 0 out of it ... oops
-- Added montgomery to the testing to make sure it handles 1..10 digit moduli correctly
- -- Fixed bug in comba that would lead to possible erroneous outputs when "pa < digs"
+ -- Fixed bug in comba that would lead to possible erroneous outputs when "pa < digs"
-- Fixed bug in mp_toradix_size for "0" [Kevin Kenny]
-- Updated chapters 1-5 of the textbook ;-) It now talks about the new comba code!
@@ -59,7 +80,7 @@ v0.34 -- Fixed two more small errors in mp_prime_random_ex()
-- Added "large" diminished radix support. Speeds up things like DSA where the moduli is of the form 2^k - P for some P < 2^(k/2) or so
Actually is faster than Montgomery on my AMD64 (and probably much faster on a P4)
-- Updated the manual a bit
- -- Ok so I haven't done the textbook work yet... My current freelance gig has landed me in France till the
+ -- Ok so I haven't done the textbook work yet... My current freelance gig has landed me in France till the
end of Feb/05. Once I get back I'll have tons of free time and I plan to go to town on the book.
As of this release the API will freeze. At least until the book catches up with all the changes. I welcome
bug reports but new algorithms will have to wait.
@@ -76,7 +97,7 @@ v0.33 -- Fixed "small" variant for mp_div() which would munge with negative div
October 29th, 2004
v0.32 -- Added "makefile.shared" for shared object support
-- Added more to the build options/configs in the manual
- -- Started the Depends framework, wrote dep.pl to scan deps and
+ -- Started the Depends framework, wrote dep.pl to scan deps and
produce "callgraph.txt" ;-)
-- Wrote SC_RSA_1 which will enable close to the minimum required to perform
RSA on 32-bit [or 64-bit] platforms with LibTomCrypt
@@ -84,7 +105,7 @@ v0.32 -- Added "makefile.shared" for shared object support
you want to use as your mp_div() at build time. Saves roughly 8KB or so.
-- Renamed a few files and changed some comments to make depends system work better.
(No changes to function names)
- -- Merged in new Combas that perform 2 reads per inner loop instead of the older
+ -- Merged in new Combas that perform 2 reads per inner loop instead of the older
3reads/2writes per inner loop of the old code. Really though if you want speed
learn to use TomsFastMath ;-)
@@ -113,8 +134,8 @@ v0.30 -- Added "mp_toradix_n" which stores upto "n-1" least significant digits
call.
-- Removed /etclib directory [um LibTomPoly deprecates this].
-- Fixed mp_mod() so the sign of the result agrees with the sign of the modulus.
- ++ N.B. My semester is almost up so expect updates to the textbook to be posted to the libtomcrypt.org
- website.
+ ++ N.B. My semester is almost up so expect updates to the textbook to be posted to the libtomcrypt.org
+ website.
Jan 25th, 2004
v0.29 ++ Note: "Henrik" from the v0.28 changelog refers to Henrik Goldman ;-)
diff --git a/libtommath/demo/demo.c b/libtommath/demo/demo.c
deleted file mode 100644
index e1f8a5e..0000000
--- a/libtommath/demo/demo.c
+++ /dev/null
@@ -1,736 +0,0 @@
-#include <time.h>
-
-#ifdef IOWNANATHLON
-#include <unistd.h>
-#define SLEEP sleep(4)
-#else
-#define SLEEP
-#endif
-
-#include "tommath.h"
-
-void ndraw(mp_int * a, char *name)
-{
- char buf[16000];
-
- printf("%s: ", name);
- mp_toradix(a, buf, 10);
- printf("%s\n", buf);
-}
-
-static void draw(mp_int * a)
-{
- ndraw(a, "");
-}
-
-
-unsigned long lfsr = 0xAAAAAAAAUL;
-
-int lbit(void)
-{
- if (lfsr & 0x80000000UL) {
- lfsr = ((lfsr << 1) ^ 0x8000001BUL) & 0xFFFFFFFFUL;
- return 1;
- } else {
- lfsr <<= 1;
- return 0;
- }
-}
-
-int myrng(unsigned char *dst, int len, void *dat)
-{
- int x;
-
- for (x = 0; x < len; x++)
- dst[x] = rand() & 0xFF;
- return len;
-}
-
-
-
-char cmd[4096], buf[4096];
-int main(void)
-{
- mp_int a, b, c, d, e, f;
- unsigned long expt_n, add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n,
- gcd_n, lcm_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n, t;
- unsigned rr;
- int i, n, err, cnt, ix, old_kara_m, old_kara_s;
- mp_digit mp;
-
-
- mp_init(&a);
- mp_init(&b);
- mp_init(&c);
- mp_init(&d);
- mp_init(&e);
- mp_init(&f);
-
- srand(time(NULL));
-
-#if 0
- // test montgomery
- printf("Testing montgomery...\n");
- for (i = 1; i < 10; i++) {
- printf("Testing digit size: %d\n", i);
- for (n = 0; n < 1000; n++) {
- mp_rand(&a, i);
- a.dp[0] |= 1;
-
- // let's see if R is right
- mp_montgomery_calc_normalization(&b, &a);
- mp_montgomery_setup(&a, &mp);
-
- // now test a random reduction
- for (ix = 0; ix < 100; ix++) {
- mp_rand(&c, 1 + abs(rand()) % (2*i));
- mp_copy(&c, &d);
- mp_copy(&c, &e);
-
- mp_mod(&d, &a, &d);
- mp_montgomery_reduce(&c, &a, mp);
- mp_mulmod(&c, &b, &a, &c);
-
- if (mp_cmp(&c, &d) != MP_EQ) {
-printf("d = e mod a, c = e MOD a\n");
-mp_todecimal(&a, buf); printf("a = %s\n", buf);
-mp_todecimal(&e, buf); printf("e = %s\n", buf);
-mp_todecimal(&d, buf); printf("d = %s\n", buf);
-mp_todecimal(&c, buf); printf("c = %s\n", buf);
-printf("compare no compare!\n"); exit(EXIT_FAILURE); }
- }
- }
- }
- printf("done\n");
-
- // test mp_get_int
- printf("Testing: mp_get_int\n");
- for (i = 0; i < 1000; ++i) {
- t = ((unsigned long) rand() * rand() + 1) & 0xFFFFFFFF;
- mp_set_int(&a, t);
- if (t != mp_get_int(&a)) {
- printf("mp_get_int() bad result!\n");
- return 1;
- }
- }
- mp_set_int(&a, 0);
- if (mp_get_int(&a) != 0) {
- printf("mp_get_int() bad result!\n");
- return 1;
- }
- mp_set_int(&a, 0xffffffff);
- if (mp_get_int(&a) != 0xffffffff) {
- printf("mp_get_int() bad result!\n");
- return 1;
- }
- // test mp_sqrt
- printf("Testing: mp_sqrt\n");
- for (i = 0; i < 1000; ++i) {
- printf("%6d\r", i);
- fflush(stdout);
- n = (rand() & 15) + 1;
- mp_rand(&a, n);
- if (mp_sqrt(&a, &b) != MP_OKAY) {
- printf("mp_sqrt() error!\n");
- return 1;
- }
- mp_n_root(&a, 2, &a);
- if (mp_cmp_mag(&b, &a) != MP_EQ) {
- printf("mp_sqrt() bad result!\n");
- return 1;
- }
- }
-
- printf("\nTesting: mp_is_square\n");
- for (i = 0; i < 1000; ++i) {
- printf("%6d\r", i);
- fflush(stdout);
-
- /* test mp_is_square false negatives */
- n = (rand() & 7) + 1;
- mp_rand(&a, n);
- mp_sqr(&a, &a);
- if (mp_is_square(&a, &n) != MP_OKAY) {
- printf("fn:mp_is_square() error!\n");
- return 1;
- }
- if (n == 0) {
- printf("fn:mp_is_square() bad result!\n");
- return 1;
- }
-
- /* test for false positives */
- mp_add_d(&a, 1, &a);
- if (mp_is_square(&a, &n) != MP_OKAY) {
- printf("fp:mp_is_square() error!\n");
- return 1;
- }
- if (n == 1) {
- printf("fp:mp_is_square() bad result!\n");
- return 1;
- }
-
- }
- printf("\n\n");
-
- /* test for size */
- for (ix = 10; ix < 128; ix++) {
- printf("Testing (not safe-prime): %9d bits \r", ix);
- fflush(stdout);
- err =
- mp_prime_random_ex(&a, 8, ix,
- (rand() & 1) ? LTM_PRIME_2MSB_OFF :
- LTM_PRIME_2MSB_ON, myrng, NULL);
- if (err != MP_OKAY) {
- printf("failed with err code %d\n", err);
- return EXIT_FAILURE;
- }
- if (mp_count_bits(&a) != ix) {
- printf("Prime is %d not %d bits!!!\n", mp_count_bits(&a), ix);
- return EXIT_FAILURE;
- }
- }
-
- for (ix = 16; ix < 128; ix++) {
- printf("Testing ( safe-prime): %9d bits \r", ix);
- fflush(stdout);
- err =
- mp_prime_random_ex(&a, 8, ix,
- ((rand() & 1) ? LTM_PRIME_2MSB_OFF :
- LTM_PRIME_2MSB_ON) | LTM_PRIME_SAFE, myrng,
- NULL);
- if (err != MP_OKAY) {
- printf("failed with err code %d\n", err);
- return EXIT_FAILURE;
- }
- if (mp_count_bits(&a) != ix) {
- printf("Prime is %d not %d bits!!!\n", mp_count_bits(&a), ix);
- return EXIT_FAILURE;
- }
- /* let's see if it's really a safe prime */
- mp_sub_d(&a, 1, &a);
- mp_div_2(&a, &a);
- mp_prime_is_prime(&a, 8, &cnt);
- if (cnt != MP_YES) {
- printf("sub is not prime!\n");
- return EXIT_FAILURE;
- }
- }
-
- printf("\n\n");
-
- mp_read_radix(&a, "123456", 10);
- mp_toradix_n(&a, buf, 10, 3);
- printf("a == %s\n", buf);
- mp_toradix_n(&a, buf, 10, 4);
- printf("a == %s\n", buf);
- mp_toradix_n(&a, buf, 10, 30);
- printf("a == %s\n", buf);
-
-
-#if 0
- for (;;) {
- fgets(buf, sizeof(buf), stdin);
- mp_read_radix(&a, buf, 10);
- mp_prime_next_prime(&a, 5, 1);
- mp_toradix(&a, buf, 10);
- printf("%s, %lu\n", buf, a.dp[0] & 3);
- }
-#endif
-
- /* test mp_cnt_lsb */
- printf("testing mp_cnt_lsb...\n");
- mp_set(&a, 1);
- for (ix = 0; ix < 1024; ix++) {
- if (mp_cnt_lsb(&a) != ix) {
- printf("Failed at %d, %d\n", ix, mp_cnt_lsb(&a));
- return 0;
- }
- mp_mul_2(&a, &a);
- }
-
-/* test mp_reduce_2k */
- printf("Testing mp_reduce_2k...\n");
- for (cnt = 3; cnt <= 128; ++cnt) {
- mp_digit tmp;
-
- mp_2expt(&a, cnt);
- mp_sub_d(&a, 2, &a); /* a = 2**cnt - 2 */
-
-
- printf("\nTesting %4d bits", cnt);
- printf("(%d)", mp_reduce_is_2k(&a));
- mp_reduce_2k_setup(&a, &tmp);
- printf("(%d)", tmp);
- for (ix = 0; ix < 1000; ix++) {
- if (!(ix & 127)) {
- printf(".");
- fflush(stdout);
- }
- mp_rand(&b, (cnt / DIGIT_BIT + 1) * 2);
- mp_copy(&c, &b);
- mp_mod(&c, &a, &c);
- mp_reduce_2k(&b, &a, 2);
- if (mp_cmp(&c, &b)) {
- printf("FAILED\n");
- exit(0);
- }
- }
- }
-
-/* test mp_div_3 */
- printf("Testing mp_div_3...\n");
- mp_set(&d, 3);
- for (cnt = 0; cnt < 10000;) {
- mp_digit r1, r2;
-
- if (!(++cnt & 127))
- printf("%9d\r", cnt);
- mp_rand(&a, abs(rand()) % 128 + 1);
- mp_div(&a, &d, &b, &e);
- mp_div_3(&a, &c, &r2);
-
- if (mp_cmp(&b, &c) || mp_cmp_d(&e, r2)) {
- printf("\n\nmp_div_3 => Failure\n");
- }
- }
- printf("\n\nPassed div_3 testing\n");
-
-/* test the DR reduction */
- printf("testing mp_dr_reduce...\n");
- for (cnt = 2; cnt < 32; cnt++) {
- printf("%d digit modulus\n", cnt);
- mp_grow(&a, cnt);
- mp_zero(&a);
- for (ix = 1; ix < cnt; ix++) {
- a.dp[ix] = MP_MASK;
- }
- a.used = cnt;
- a.dp[0] = 3;
-
- mp_rand(&b, cnt - 1);
- mp_copy(&b, &c);
-
- rr = 0;
- do {
- if (!(rr & 127)) {
- printf("%9lu\r", rr);
- fflush(stdout);
- }
- mp_sqr(&b, &b);
- mp_add_d(&b, 1, &b);
- mp_copy(&b, &c);
-
- mp_mod(&b, &a, &b);
- mp_dr_reduce(&c, &a, (((mp_digit) 1) << DIGIT_BIT) - a.dp[0]);
-
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("Failed on trial %lu\n", rr);
- exit(-1);
-
- }
- } while (++rr < 500);
- printf("Passed DR test for %d digits\n", cnt);
- }
-
-#endif
-
-/* test the mp_reduce_2k_l code */
-#if 0
-#if 0
-/* first load P with 2^1024 - 0x2A434 B9FDEC95 D8F9D550 FFFFFFFF FFFFFFFF */
- mp_2expt(&a, 1024);
- mp_read_radix(&b, "2A434B9FDEC95D8F9D550FFFFFFFFFFFFFFFF", 16);
- mp_sub(&a, &b, &a);
-#elif 1
-/* p = 2^2048 - 0x1 00000000 00000000 00000000 00000000 4945DDBF 8EA2A91D 5776399B B83E188F */
- mp_2expt(&a, 2048);
- mp_read_radix(&b,
- "1000000000000000000000000000000004945DDBF8EA2A91D5776399BB83E188F",
- 16);
- mp_sub(&a, &b, &a);
-#endif
-
- mp_todecimal(&a, buf);
- printf("p==%s\n", buf);
-/* now mp_reduce_is_2k_l() should return */
- if (mp_reduce_is_2k_l(&a) != 1) {
- printf("mp_reduce_is_2k_l() return 0, should be 1\n");
- return EXIT_FAILURE;
- }
- mp_reduce_2k_setup_l(&a, &d);
- /* now do a million square+1 to see if it varies */
- mp_rand(&b, 64);
- mp_mod(&b, &a, &b);
- mp_copy(&b, &c);
- printf("testing mp_reduce_2k_l...");
- fflush(stdout);
- for (cnt = 0; cnt < (1UL << 20); cnt++) {
- mp_sqr(&b, &b);
- mp_add_d(&b, 1, &b);
- mp_reduce_2k_l(&b, &a, &d);
- mp_sqr(&c, &c);
- mp_add_d(&c, 1, &c);
- mp_mod(&c, &a, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("mp_reduce_2k_l() failed at step %lu\n", cnt);
- mp_tohex(&b, buf);
- printf("b == %s\n", buf);
- mp_tohex(&c, buf);
- printf("c == %s\n", buf);
- return EXIT_FAILURE;
- }
- }
- printf("...Passed\n");
-#endif
-
- div2_n = mul2_n = inv_n = expt_n = lcm_n = gcd_n = add_n =
- sub_n = mul_n = div_n = sqr_n = mul2d_n = div2d_n = cnt = add_d_n =
- sub_d_n = 0;
-
- /* force KARA and TOOM to enable despite cutoffs */
- KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 8;
- TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 16;
-
- for (;;) {
- /* randomly clear and re-init one variable, this has the affect of triming the alloc space */
- switch (abs(rand()) % 7) {
- case 0:
- mp_clear(&a);
- mp_init(&a);
- break;
- case 1:
- mp_clear(&b);
- mp_init(&b);
- break;
- case 2:
- mp_clear(&c);
- mp_init(&c);
- break;
- case 3:
- mp_clear(&d);
- mp_init(&d);
- break;
- case 4:
- mp_clear(&e);
- mp_init(&e);
- break;
- case 5:
- mp_clear(&f);
- mp_init(&f);
- break;
- case 6:
- break; /* don't clear any */
- }
-
-
- printf
- ("%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu ",
- add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n, gcd_n, lcm_n,
- expt_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n);
- fgets(cmd, 4095, stdin);
- cmd[strlen(cmd) - 1] = 0;
- printf("%s ]\r", cmd);
- fflush(stdout);
- if (!strcmp(cmd, "mul2d")) {
- ++mul2d_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- sscanf(buf, "%d", &rr);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
-
- mp_mul_2d(&a, rr, &a);
- a.sign = b.sign;
- if (mp_cmp(&a, &b) != MP_EQ) {
- printf("mul2d failed, rr == %d\n", rr);
- draw(&a);
- draw(&b);
- return 0;
- }
- } else if (!strcmp(cmd, "div2d")) {
- ++div2d_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- sscanf(buf, "%d", &rr);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
-
- mp_div_2d(&a, rr, &a, &e);
- a.sign = b.sign;
- if (a.used == b.used && a.used == 0) {
- a.sign = b.sign = MP_ZPOS;
- }
- if (mp_cmp(&a, &b) != MP_EQ) {
- printf("div2d failed, rr == %d\n", rr);
- draw(&a);
- draw(&b);
- return 0;
- }
- } else if (!strcmp(cmd, "add")) {
- ++add_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_add(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("add %lu failure!\n", add_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- return 0;
- }
-
- /* test the sign/unsigned storage functions */
-
- rr = mp_signed_bin_size(&c);
- mp_to_signed_bin(&c, (unsigned char *) cmd);
- memset(cmd + rr, rand() & 255, sizeof(cmd) - rr);
- mp_read_signed_bin(&d, (unsigned char *) cmd, rr);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("mp_signed_bin failure!\n");
- draw(&c);
- draw(&d);
- return 0;
- }
-
-
- rr = mp_unsigned_bin_size(&c);
- mp_to_unsigned_bin(&c, (unsigned char *) cmd);
- memset(cmd + rr, rand() & 255, sizeof(cmd) - rr);
- mp_read_unsigned_bin(&d, (unsigned char *) cmd, rr);
- if (mp_cmp_mag(&c, &d) != MP_EQ) {
- printf("mp_unsigned_bin failure!\n");
- draw(&c);
- draw(&d);
- return 0;
- }
-
- } else if (!strcmp(cmd, "sub")) {
- ++sub_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_sub(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("sub %lu failure!\n", sub_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- return 0;
- }
- } else if (!strcmp(cmd, "mul")) {
- ++mul_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_mul(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("mul %lu failure!\n", mul_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- return 0;
- }
- } else if (!strcmp(cmd, "div")) {
- ++div_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&d, buf, 64);
-
- mp_div(&a, &b, &e, &f);
- if (mp_cmp(&c, &e) != MP_EQ || mp_cmp(&d, &f) != MP_EQ) {
- printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e),
- mp_cmp(&d, &f));
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- draw(&e);
- draw(&f);
- return 0;
- }
-
- } else if (!strcmp(cmd, "sqr")) {
- ++sqr_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_copy(&a, &c);
- mp_sqr(&c, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("sqr %lu failure!\n", sqr_n);
- draw(&a);
- draw(&b);
- draw(&c);
- return 0;
- }
- } else if (!strcmp(cmd, "gcd")) {
- ++gcd_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_gcd(&d, &b, &d);
- d.sign = c.sign;
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("gcd %lu failure!\n", gcd_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- return 0;
- }
- } else if (!strcmp(cmd, "lcm")) {
- ++lcm_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_lcm(&d, &b, &d);
- d.sign = c.sign;
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("lcm %lu failure!\n", lcm_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- return 0;
- }
- } else if (!strcmp(cmd, "expt")) {
- ++expt_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&d, buf, 64);
- mp_copy(&a, &e);
- mp_exptmod(&e, &b, &c, &e);
- if (mp_cmp(&d, &e) != MP_EQ) {
- printf("expt %lu failure!\n", expt_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- draw(&e);
- return 0;
- }
- } else if (!strcmp(cmd, "invmod")) {
- ++inv_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_invmod(&a, &b, &d);
- mp_mulmod(&d, &a, &b, &e);
- if (mp_cmp_d(&e, 1) != MP_EQ) {
- printf("inv [wrong value from MPI?!] failure\n");
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- mp_gcd(&a, &b, &e);
- draw(&e);
- return 0;
- }
-
- } else if (!strcmp(cmd, "div2")) {
- ++div2_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_div_2(&a, &c);
- if (mp_cmp(&c, &b) != MP_EQ) {
- printf("div_2 %lu failure\n", div2_n);
- draw(&a);
- draw(&b);
- draw(&c);
- return 0;
- }
- } else if (!strcmp(cmd, "mul2")) {
- ++mul2_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_mul_2(&a, &c);
- if (mp_cmp(&c, &b) != MP_EQ) {
- printf("mul_2 %lu failure\n", mul2_n);
- draw(&a);
- draw(&b);
- draw(&c);
- return 0;
- }
- } else if (!strcmp(cmd, "add_d")) {
- ++add_d_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- sscanf(buf, "%d", &ix);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_add_d(&a, ix, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("add_d %lu failure\n", add_d_n);
- draw(&a);
- draw(&b);
- draw(&c);
- printf("d == %d\n", ix);
- return 0;
- }
- } else if (!strcmp(cmd, "sub_d")) {
- ++sub_d_n;
- fgets(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- fgets(buf, 4095, stdin);
- sscanf(buf, "%d", &ix);
- fgets(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_sub_d(&a, ix, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("sub_d %lu failure\n", sub_d_n);
- draw(&a);
- draw(&b);
- draw(&c);
- printf("d == %d\n", ix);
- return 0;
- }
- }
- }
- return 0;
-}
diff --git a/libtommath/demo/timing.c b/libtommath/demo/timing.c
deleted file mode 100644
index bb3be52..0000000
--- a/libtommath/demo/timing.c
+++ /dev/null
@@ -1,315 +0,0 @@
-#include <tommath.h>
-#include <time.h>
-
-ulong64 _tt;
-
-#ifdef IOWNANATHLON
-#include <unistd.h>
-#define SLEEP sleep(4)
-#else
-#define SLEEP
-#endif
-
-
-void ndraw(mp_int * a, char *name)
-{
- char buf[4096];
-
- printf("%s: ", name);
- mp_toradix(a, buf, 64);
- printf("%s\n", buf);
-}
-
-static void draw(mp_int * a)
-{
- ndraw(a, "");
-}
-
-
-unsigned long lfsr = 0xAAAAAAAAUL;
-
-int lbit(void)
-{
- if (lfsr & 0x80000000UL) {
- lfsr = ((lfsr << 1) ^ 0x8000001BUL) & 0xFFFFFFFFUL;
- return 1;
- } else {
- lfsr <<= 1;
- return 0;
- }
-}
-
-/* RDTSC from Scott Duplichan */
-static ulong64 TIMFUNC(void)
-{
-#if defined __GNUC__
-#if defined(__i386__) || defined(__x86_64__)
- unsigned long long a;
- __asm__ __volatile__("rdtsc\nmovl %%eax,%0\nmovl %%edx,4+%0\n"::
- "m"(a):"%eax", "%edx");
- return a;
-#else /* gcc-IA64 version */
- unsigned long result;
- __asm__ __volatile__("mov %0=ar.itc":"=r"(result)::"memory");
-
- while (__builtin_expect((int) result == -1, 0))
- __asm__ __volatile__("mov %0=ar.itc":"=r"(result)::"memory");
-
- return result;
-#endif
-
- // Microsoft and Intel Windows compilers
-#elif defined _M_IX86
- __asm rdtsc
-#elif defined _M_AMD64
- return __rdtsc();
-#elif defined _M_IA64
-#if defined __INTEL_COMPILER
-#include <ia64intrin.h>
-#endif
- return __getReg(3116);
-#else
-#error need rdtsc function for this build
-#endif
-}
-
-#define DO(x) x; x;
-//#define DO4(x) DO2(x); DO2(x);
-//#define DO8(x) DO4(x); DO4(x);
-//#define DO(x) DO8(x); DO8(x);
-
-int main(void)
-{
- ulong64 tt, gg, CLK_PER_SEC;
- FILE *log, *logb, *logc, *logd;
- mp_int a, b, c, d, e, f;
- int n, cnt, ix, old_kara_m, old_kara_s;
- unsigned rr;
-
- mp_init(&a);
- mp_init(&b);
- mp_init(&c);
- mp_init(&d);
- mp_init(&e);
- mp_init(&f);
-
- srand(time(NULL));
-
-
- /* temp. turn off TOOM */
- TOOM_MUL_CUTOFF = TOOM_SQR_CUTOFF = 100000;
-
- CLK_PER_SEC = TIMFUNC();
- sleep(1);
- CLK_PER_SEC = TIMFUNC() - CLK_PER_SEC;
-
- printf("CLK_PER_SEC == %llu\n", CLK_PER_SEC);
- goto exptmod;
- log = fopen("logs/add.log", "w");
- for (cnt = 8; cnt <= 128; cnt += 8) {
- SLEEP;
- mp_rand(&a, cnt);
- mp_rand(&b, cnt);
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_add(&a, &b, &c));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 100000);
- printf("Adding\t\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(log, "%d %9llu\n", cnt * DIGIT_BIT, tt);
- fflush(log);
- }
- fclose(log);
-
- log = fopen("logs/sub.log", "w");
- for (cnt = 8; cnt <= 128; cnt += 8) {
- SLEEP;
- mp_rand(&a, cnt);
- mp_rand(&b, cnt);
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_sub(&a, &b, &c));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 100000);
-
- printf("Subtracting\t\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(log, "%d %9llu\n", cnt * DIGIT_BIT, tt);
- fflush(log);
- }
- fclose(log);
-
- /* do mult/square twice, first without karatsuba and second with */
- multtest:
- old_kara_m = KARATSUBA_MUL_CUTOFF;
- old_kara_s = KARATSUBA_SQR_CUTOFF;
- for (ix = 0; ix < 2; ix++) {
- printf("With%s Karatsuba\n", (ix == 0) ? "out" : "");
-
- KARATSUBA_MUL_CUTOFF = (ix == 0) ? 9999 : old_kara_m;
- KARATSUBA_SQR_CUTOFF = (ix == 0) ? 9999 : old_kara_s;
-
- log = fopen((ix == 0) ? "logs/mult.log" : "logs/mult_kara.log", "w");
- for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) {
- SLEEP;
- mp_rand(&a, cnt);
- mp_rand(&b, cnt);
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_mul(&a, &b, &c));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 100);
- printf("Multiplying\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(log, "%d %9llu\n", mp_count_bits(&a), tt);
- fflush(log);
- }
- fclose(log);
-
- log = fopen((ix == 0) ? "logs/sqr.log" : "logs/sqr_kara.log", "w");
- for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) {
- SLEEP;
- mp_rand(&a, cnt);
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_sqr(&a, &b));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 100);
- printf("Squaring\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(log, "%d %9llu\n", mp_count_bits(&a), tt);
- fflush(log);
- }
- fclose(log);
-
- }
- exptmod:
-
- {
- char *primes[] = {
- /* 2K large moduli */
- "179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586239334100047359817950870678242457666208137217",
- "32317006071311007300714876688669951960444102669715484032130345427524655138867890893197201411522913463688717960921898019494119559150490921095088152386448283120630877367300996091750197750389652106796057638384067568276792218642619756161838094338476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638099733077152121140120031150424541696791951097529546801429027668869927491725169",
- "1044388881413152506691752710716624382579964249047383780384233483283953907971557456848826811934997558340890106714439262837987573438185793607263236087851365277945956976543709998340361590134383718314428070011855946226376318839397712745672334684344586617496807908705803704071284048740118609114467977783598029006686938976881787785946905630190260940599579453432823469303026696443059025015972399867714215541693835559885291486318237914434496734087811872639496475100189041349008417061675093668333850551032972088269550769983616369411933015213796825837188091833656751221318492846368125550225998300412344784862595674492194617023806505913245610825731835380087608622102834270197698202313169017678006675195485079921636419370285375124784014907159135459982790513399611551794271106831134090584272884279791554849782954323534517065223269061394905987693002122963395687782878948440616007412945674919823050571642377154816321380631045902916136926708342856440730447899971901781465763473223850267253059899795996090799469201774624817718449867455659250178329070473119433165550807568221846571746373296884912819520317457002440926616910874148385078411929804522981857338977648103126085902995208257421855249796721729039744118165938433694823325696642096892124547425283",
- /* 2K moduli mersenne primes */
- "6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151",
- "531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127",
- "10407932194664399081925240327364085538615262247266704805319112350403608059673360298012239441732324184842421613954281007791383566248323464908139906605677320762924129509389220345773183349661583550472959420547689811211693677147548478866962501384438260291732348885311160828538416585028255604666224831890918801847068222203140521026698435488732958028878050869736186900714720710555703168729087",
- "1475979915214180235084898622737381736312066145333169775147771216478570297878078949377407337049389289382748507531496480477281264838760259191814463365330269540496961201113430156902396093989090226259326935025281409614983499388222831448598601834318536230923772641390209490231836446899608210795482963763094236630945410832793769905399982457186322944729636418890623372171723742105636440368218459649632948538696905872650486914434637457507280441823676813517852099348660847172579408422316678097670224011990280170474894487426924742108823536808485072502240519452587542875349976558572670229633962575212637477897785501552646522609988869914013540483809865681250419497686697771007",
- "259117086013202627776246767922441530941818887553125427303974923161874019266586362086201209516800483406550695241733194177441689509238807017410377709597512042313066624082916353517952311186154862265604547691127595848775610568757931191017711408826252153849035830401185072116424747461823031471398340229288074545677907941037288235820705892351068433882986888616658650280927692080339605869308790500409503709875902119018371991620994002568935113136548829739112656797303241986517250116412703509705427773477972349821676443446668383119322540099648994051790241624056519054483690809616061625743042361721863339415852426431208737266591962061753535748892894599629195183082621860853400937932839420261866586142503251450773096274235376822938649407127700846077124211823080804139298087057504713825264571448379371125032081826126566649084251699453951887789613650248405739378594599444335231188280123660406262468609212150349937584782292237144339628858485938215738821232393687046160677362909315071",
- "190797007524439073807468042969529173669356994749940177394741882673528979787005053706368049835514900244303495954950709725762186311224148828811920216904542206960744666169364221195289538436845390250168663932838805192055137154390912666527533007309292687539092257043362517857366624699975402375462954490293259233303137330643531556539739921926201438606439020075174723029056838272505051571967594608350063404495977660656269020823960825567012344189908927956646011998057988548630107637380993519826582389781888135705408653045219655801758081251164080554609057468028203308718724654081055323215860189611391296030471108443146745671967766308925858547271507311563765171008318248647110097614890313562856541784154881743146033909602737947385055355960331855614540900081456378659068370317267696980001187750995491090350108417050917991562167972281070161305972518044872048331306383715094854938415738549894606070722584737978176686422134354526989443028353644037187375385397838259511833166416134323695660367676897722287918773420968982326089026150031515424165462111337527431154890666327374921446276833564519776797633875503548665093914556482031482248883127023777039667707976559857333357013727342079099064400455741830654320379350833236245819348824064783585692924881021978332974949906122664421376034687815350484991",
-
- /* DR moduli */
- "14059105607947488696282932836518693308967803494693489478439861164411992439598399594747002144074658928593502845729752797260025831423419686528151609940203368612079",
- "101745825697019260773923519755878567461315282017759829107608914364075275235254395622580447400994175578963163918967182013639660669771108475957692810857098847138903161308502419410142185759152435680068435915159402496058513611411688900243039",
- "736335108039604595805923406147184530889923370574768772191969612422073040099331944991573923112581267542507986451953227192970402893063850485730703075899286013451337291468249027691733891486704001513279827771740183629161065194874727962517148100775228363421083691764065477590823919364012917984605619526140821797602431",
- "38564998830736521417281865696453025806593491967131023221754800625044118265468851210705360385717536794615180260494208076605798671660719333199513807806252394423283413430106003596332513246682903994829528690198205120921557533726473585751382193953592127439965050261476810842071573684505878854588706623484573925925903505747545471088867712185004135201289273405614415899438276535626346098904241020877974002916168099951885406379295536200413493190419727789712076165162175783",
- "542189391331696172661670440619180536749994166415993334151601745392193484590296600979602378676624808129613777993466242203025054573692562689251250471628358318743978285860720148446448885701001277560572526947619392551574490839286458454994488665744991822837769918095117129546414124448777033941223565831420390846864429504774477949153794689948747680362212954278693335653935890352619041936727463717926744868338358149568368643403037768649616778526013610493696186055899318268339432671541328195724261329606699831016666359440874843103020666106568222401047720269951530296879490444224546654729111504346660859907296364097126834834235287147",
- "1487259134814709264092032648525971038895865645148901180585340454985524155135260217788758027400478312256339496385275012465661575576202252063145698732079880294664220579764848767704076761853197216563262660046602703973050798218246170835962005598561669706844469447435461092542265792444947706769615695252256130901271870341005768912974433684521436211263358097522726462083917939091760026658925757076733484173202927141441492573799914240222628795405623953109131594523623353044898339481494120112723445689647986475279242446083151413667587008191682564376412347964146113898565886683139407005941383669325997475076910488086663256335689181157957571445067490187939553165903773554290260531009121879044170766615232300936675369451260747671432073394867530820527479172464106442450727640226503746586340279816318821395210726268291535648506190714616083163403189943334431056876038286530365757187367147446004855912033137386225053275419626102417236133948503",
- "1095121115716677802856811290392395128588168592409109494900178008967955253005183831872715423151551999734857184538199864469605657805519106717529655044054833197687459782636297255219742994736751541815269727940751860670268774903340296040006114013971309257028332849679096824800250742691718610670812374272414086863715763724622797509437062518082383056050144624962776302147890521249477060215148275163688301275847155316042279405557632639366066847442861422164832655874655824221577849928863023018366835675399949740429332468186340518172487073360822220449055340582568461568645259954873303616953776393853174845132081121976327462740354930744487429617202585015510744298530101547706821590188733515880733527449780963163909830077616357506845523215289297624086914545378511082534229620116563260168494523906566709418166011112754529766183554579321224940951177394088465596712620076240067370589036924024728375076210477267488679008016579588696191194060127319035195370137160936882402244399699172017835144537488486396906144217720028992863941288217185353914991583400421682751000603596655790990815525126154394344641336397793791497068253936771017031980867706707490224041075826337383538651825493679503771934836094655802776331664261631740148281763487765852746577808019633679",
-
- /* generic unrestricted moduli */
- "17933601194860113372237070562165128350027320072176844226673287945873370751245439587792371960615073855669274087805055507977323024886880985062002853331424203",
- "2893527720709661239493896562339544088620375736490408468011883030469939904368086092336458298221245707898933583190713188177399401852627749210994595974791782790253946539043962213027074922559572312141181787434278708783207966459019479487",
- "347743159439876626079252796797422223177535447388206607607181663903045907591201940478223621722118173270898487582987137708656414344685816179420855160986340457973820182883508387588163122354089264395604796675278966117567294812714812796820596564876450716066283126720010859041484786529056457896367683122960411136319",
- "47266428956356393164697365098120418976400602706072312735924071745438532218237979333351774907308168340693326687317443721193266215155735814510792148768576498491199122744351399489453533553203833318691678263241941706256996197460424029012419012634671862283532342656309677173602509498417976091509154360039893165037637034737020327399910409885798185771003505320583967737293415979917317338985837385734747478364242020380416892056650841470869294527543597349250299539682430605173321029026555546832473048600327036845781970289288898317888427517364945316709081173840186150794397479045034008257793436817683392375274635794835245695887",
- "436463808505957768574894870394349739623346440601945961161254440072143298152040105676491048248110146278752857839930515766167441407021501229924721335644557342265864606569000117714935185566842453630868849121480179691838399545644365571106757731317371758557990781880691336695584799313313687287468894148823761785582982549586183756806449017542622267874275103877481475534991201849912222670102069951687572917937634467778042874315463238062009202992087620963771759666448266532858079402669920025224220613419441069718482837399612644978839925207109870840278194042158748845445131729137117098529028886770063736487420613144045836803985635654192482395882603511950547826439092832800532152534003936926017612446606135655146445620623395788978726744728503058670046885876251527122350275750995227",
- "11424167473351836398078306042624362277956429440521137061889702611766348760692206243140413411077394583180726863277012016602279290144126785129569474909173584789822341986742719230331946072730319555984484911716797058875905400999504305877245849119687509023232790273637466821052576859232452982061831009770786031785669030271542286603956118755585683996118896215213488875253101894663403069677745948305893849505434201763745232895780711972432011344857521691017896316861403206449421332243658855453435784006517202894181640562433575390821384210960117518650374602256601091379644034244332285065935413233557998331562749140202965844219336298970011513882564935538704289446968322281451907487362046511461221329799897350993370560697505809686438782036235372137015731304779072430260986460269894522159103008260495503005267165927542949439526272736586626709581721032189532726389643625590680105784844246152702670169304203783072275089194754889511973916207",
- "1214855636816562637502584060163403830270705000634713483015101384881871978446801224798536155406895823305035467591632531067547890948695117172076954220727075688048751022421198712032848890056357845974246560748347918630050853933697792254955890439720297560693579400297062396904306270145886830719309296352765295712183040773146419022875165382778007040109957609739589875590885701126197906063620133954893216612678838507540777138437797705602453719559017633986486649523611975865005712371194067612263330335590526176087004421363598470302731349138773205901447704682181517904064735636518462452242791676541725292378925568296858010151852326316777511935037531017413910506921922450666933202278489024521263798482237150056835746454842662048692127173834433089016107854491097456725016327709663199738238442164843147132789153725513257167915555162094970853584447993125488607696008169807374736711297007473812256272245489405898470297178738029484459690836250560495461579533254473316340608217876781986188705928270735695752830825527963838355419762516246028680280988020401914551825487349990306976304093109384451438813251211051597392127491464898797406789175453067960072008590614886532333015881171367104445044718144312416815712216611576221546455968770801413440778423979",
- NULL
- };
- log = fopen("logs/expt.log", "w");
- logb = fopen("logs/expt_dr.log", "w");
- logc = fopen("logs/expt_2k.log", "w");
- logd = fopen("logs/expt_2kl.log", "w");
- for (n = 0; primes[n]; n++) {
- SLEEP;
- mp_read_radix(&a, primes[n], 10);
- mp_zero(&b);
- for (rr = 0; rr < (unsigned) mp_count_bits(&a); rr++) {
- mp_mul_2(&b, &b);
- b.dp[0] |= lbit();
- b.used += 1;
- }
- mp_sub_d(&a, 1, &c);
- mp_mod(&b, &c, &b);
- mp_set(&c, 3);
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_exptmod(&c, &b, &a, &d));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 10);
- mp_sub_d(&a, 1, &e);
- mp_sub(&e, &b, &b);
- mp_exptmod(&c, &b, &a, &e); /* c^(p-1-b) mod a */
- mp_mulmod(&e, &d, &a, &d); /* c^b * c^(p-1-b) == c^p-1 == 1 */
- if (mp_cmp_d(&d, 1)) {
- printf("Different (%d)!!!\n", mp_count_bits(&a));
- draw(&d);
- exit(0);
- }
- printf("Exponentiating\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(n < 4 ? logd : (n < 9) ? logc : (n < 16) ? logb : log,
- "%d %9llu\n", mp_count_bits(&a), tt);
- }
- }
- fclose(log);
- fclose(logb);
- fclose(logc);
- fclose(logd);
-
- log = fopen("logs/invmod.log", "w");
- for (cnt = 4; cnt <= 128; cnt += 4) {
- SLEEP;
- mp_rand(&a, cnt);
- mp_rand(&b, cnt);
-
- do {
- mp_add_d(&b, 1, &b);
- mp_gcd(&a, &b, &c);
- } while (mp_cmp_d(&c, 1) != MP_EQ);
-
- rr = 0;
- tt = -1;
- do {
- gg = TIMFUNC();
- DO(mp_invmod(&b, &a, &c));
- gg = (TIMFUNC() - gg) >> 1;
- if (tt > gg)
- tt = gg;
- } while (++rr < 1000);
- mp_mulmod(&b, &c, &a, &d);
- if (mp_cmp_d(&d, 1) != MP_EQ) {
- printf("Failed to invert\n");
- return 0;
- }
- printf("Inverting mod\t%4d-bit => %9llu/sec, %9llu cycles\n",
- mp_count_bits(&a), CLK_PER_SEC / tt, tt);
- fprintf(log, "%d %9llu\n", cnt * DIGIT_BIT, tt);
- }
- fclose(log);
-
- return 0;
-}
diff --git a/libtommath/dep.pl b/libtommath/dep.pl
deleted file mode 100644
index c39e27e..0000000
--- a/libtommath/dep.pl
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/perl
-#
-# Walk through source, add labels and make classes
-#
-#use strict;
-
-my %deplist;
-
-#open class file and write preamble
-open(CLASS, ">tommath_class.h") or die "Couldn't open tommath_class.h for writing\n";
-print CLASS "#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))\n#if defined(LTM2)\n#define LTM3\n#endif\n#if defined(LTM1)\n#define LTM2\n#endif\n#define LTM1\n\n#if defined(LTM_ALL)\n";
-
-foreach my $filename (glob "bn*.c") {
- my $define = $filename;
-
-print "Processing $filename\n";
-
- # convert filename to upper case so we can use it as a define
- $define =~ tr/[a-z]/[A-Z]/;
- $define =~ tr/\./_/;
- print CLASS "#define $define\n";
-
- # now copy text and apply #ifdef as required
- my $apply = 0;
- open(SRC, "<$filename");
- open(OUT, ">tmp");
-
- # first line will be the #ifdef
- my $line = <SRC>;
- if ($line =~ /include/) {
- print OUT $line;
- } else {
- print OUT "#include <tommath.h>\n#ifdef $define\n$line";
- $apply = 1;
- }
- while (<SRC>) {
- if (!($_ =~ /tommath\.h/)) {
- print OUT $_;
- }
- }
- if ($apply == 1) {
- print OUT "#endif\n";
- }
- close SRC;
- close OUT;
-
- unlink($filename);
- rename("tmp", $filename);
-}
-print CLASS "#endif\n\n";
-
-# now do classes
-
-foreach my $filename (glob "bn*.c") {
- open(SRC, "<$filename") or die "Can't open source file!\n";
-
- # convert filename to upper case so we can use it as a define
- $filename =~ tr/[a-z]/[A-Z]/;
- $filename =~ tr/\./_/;
-
- print CLASS "#if defined($filename)\n";
- my $list = $filename;
-
- # scan for mp_* and make classes
- while (<SRC>) {
- my $line = $_;
- while ($line =~ m/(fast_)*(s_)*mp\_[a-z_0-9]*/) {
- $line = $';
- # now $& is the match, we want to skip over LTM keywords like
- # mp_int, mp_word, mp_digit
- if (!($& eq "mp_digit") && !($& eq "mp_word") && !($& eq "mp_int")) {
- my $a = $&;
- $a =~ tr/[a-z]/[A-Z]/;
- $a = "BN_" . $a . "_C";
- if (!($list =~ /$a/)) {
- print CLASS " #define $a\n";
- }
- $list = $list . "," . $a;
- }
- }
- }
- @deplist{$filename} = $list;
-
- print CLASS "#endif\n\n";
- close SRC;
-}
-
-print CLASS "#ifdef LTM3\n#define LTM_LAST\n#endif\n#include <tommath_superclass.h>\n#include <tommath_class.h>\n#else\n#define LTM_LAST\n#endif\n";
-close CLASS;
-
-#now let's make a cool call graph...
-
-open(OUT,">callgraph.txt");
-$indent = 0;
-foreach (keys %deplist) {
- $list = "";
- draw_func(@deplist{$_});
- print OUT "\n\n";
-}
-close(OUT);
-
-sub draw_func()
-{
- my @funcs = split(",", $_[0]);
- if ($list =~ /@funcs[0]/) {
- return;
- } else {
- $list = $list . @funcs[0];
- }
- if ($indent == 0) { }
- elsif ($indent >= 1) { print OUT "| " x ($indent - 1) . "+--->"; }
- print OUT @funcs[0] . "\n";
- shift @funcs;
- my $temp = $list;
- foreach my $i (@funcs) {
- ++$indent;
- draw_func(@deplist{$i});
- --$indent;
- }
- $list = $temp;
-}
-
-
diff --git a/libtommath/etc/2kprime.1 b/libtommath/etc/2kprime.1
deleted file mode 100644
index c41ded1..0000000
--- a/libtommath/etc/2kprime.1
+++ /dev/null
@@ -1,2 +0,0 @@
-256-bits (k = 36113) = 115792089237316195423570985008687907853269984665640564039457584007913129603823
-512-bits (k = 38117) = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006045979
diff --git a/libtommath/etc/2kprime.c b/libtommath/etc/2kprime.c
deleted file mode 100644
index 67a2777..0000000
--- a/libtommath/etc/2kprime.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Makes safe primes of a 2k nature */
-#include <tommath.h>
-#include <time.h>
-
-int sizes[] = {256, 512, 768, 1024, 1536, 2048, 3072, 4096};
-
-int main(void)
-{
- char buf[2000];
- int x, y;
- mp_int q, p;
- FILE *out;
- clock_t t1;
- mp_digit z;
-
- mp_init_multi(&q, &p, NULL);
-
- out = fopen("2kprime.1", "w");
- for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) {
- top:
- mp_2expt(&q, sizes[x]);
- mp_add_d(&q, 3, &q);
- z = -3;
-
- t1 = clock();
- for(;;) {
- mp_sub_d(&q, 4, &q);
- z += 4;
-
- if (z > MP_MASK) {
- printf("No primes of size %d found\n", sizes[x]);
- break;
- }
-
- if (clock() - t1 > CLOCKS_PER_SEC) {
- printf("."); fflush(stdout);
-// sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC);
- t1 = clock();
- }
-
- /* quick test on q */
- mp_prime_is_prime(&q, 1, &y);
- if (y == 0) {
- continue;
- }
-
- /* find (q-1)/2 */
- mp_sub_d(&q, 1, &p);
- mp_div_2(&p, &p);
- mp_prime_is_prime(&p, 3, &y);
- if (y == 0) {
- continue;
- }
-
- /* test on q */
- mp_prime_is_prime(&q, 3, &y);
- if (y == 0) {
- continue;
- }
-
- break;
- }
-
- if (y == 0) {
- ++sizes[x];
- goto top;
- }
-
- mp_toradix(&q, buf, 10);
- printf("\n\n%d-bits (k = %lu) = %s\n", sizes[x], z, buf);
- fprintf(out, "%d-bits (k = %lu) = %s\n", sizes[x], z, buf); fflush(out);
- }
-
- return 0;
-}
diff --git a/libtommath/etc/drprime.c b/libtommath/etc/drprime.c
deleted file mode 100644
index 0d0fdb9..0000000
--- a/libtommath/etc/drprime.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Makes safe primes of a DR nature */
-#include <tommath.h>
-
-int sizes[] = { 1+256/DIGIT_BIT, 1+512/DIGIT_BIT, 1+768/DIGIT_BIT, 1+1024/DIGIT_BIT, 1+2048/DIGIT_BIT, 1+4096/DIGIT_BIT };
-int main(void)
-{
- int res, x, y;
- char buf[4096];
- FILE *out;
- mp_int a, b;
-
- mp_init(&a);
- mp_init(&b);
-
- out = fopen("drprimes.txt", "w");
- for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
- top:
- printf("Seeking a %d-bit safe prime\n", sizes[x] * DIGIT_BIT);
- mp_grow(&a, sizes[x]);
- mp_zero(&a);
- for (y = 1; y < sizes[x]; y++) {
- a.dp[y] = MP_MASK;
- }
-
- /* make a DR modulus */
- a.dp[0] = -1;
- a.used = sizes[x];
-
- /* now loop */
- res = 0;
- for (;;) {
- a.dp[0] += 4;
- if (a.dp[0] >= MP_MASK) break;
- mp_prime_is_prime(&a, 1, &res);
- if (res == 0) continue;
- printf("."); fflush(stdout);
- mp_sub_d(&a, 1, &b);
- mp_div_2(&b, &b);
- mp_prime_is_prime(&b, 3, &res);
- if (res == 0) continue;
- mp_prime_is_prime(&a, 3, &res);
- if (res == 1) break;
- }
-
- if (res != 1) {
- printf("Error not DR modulus\n"); sizes[x] += 1; goto top;
- } else {
- mp_toradix(&a, buf, 10);
- printf("\n\np == %s\n\n", buf);
- fprintf(out, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a), buf); fflush(out);
- }
- }
- fclose(out);
-
- mp_clear(&a);
- mp_clear(&b);
-
- return 0;
-}
diff --git a/libtommath/etc/drprimes.28 b/libtommath/etc/drprimes.28
deleted file mode 100644
index 9d438ad..0000000
--- a/libtommath/etc/drprimes.28
+++ /dev/null
@@ -1,25 +0,0 @@
-DR safe primes for 28-bit digits.
-
-224-bit prime:
-p == 26959946667150639794667015087019630673637144422540572481103341844143
-
-532-bit prime:
-p == 14059105607947488696282932836518693308967803494693489478439861164411992439598399594747002144074658928593502845729752797260025831423419686528151609940203368691747
-
-784-bit prime:
-p == 101745825697019260773923519755878567461315282017759829107608914364075275235254395622580447400994175578963163918967182013639660669771108475957692810857098847138903161308502419410142185759152435680068435915159402496058513611411688900243039
-
-1036-bit prime:
-p == 736335108039604595805923406147184530889923370574768772191969612422073040099331944991573923112581267542507986451953227192970402893063850485730703075899286013451337291468249027691733891486704001513279827771740183629161065194874727962517148100775228363421083691764065477590823919364012917984605619526140821798437127
-
-1540-bit prime:
-p == 38564998830736521417281865696453025806593491967131023221754800625044118265468851210705360385717536794615180260494208076605798671660719333199513807806252394423283413430106003596332513246682903994829528690198205120921557533726473585751382193953592127439965050261476810842071573684505878854588706623484573925925903505747545471088867712185004135201289273405614415899438276535626346098904241020877974002916168099951885406379295536200413493190419727789712076165162175783
-
-2072-bit prime:
-p == 542189391331696172661670440619180536749994166415993334151601745392193484590296600979602378676624808129613777993466242203025054573692562689251250471628358318743978285860720148446448885701001277560572526947619392551574490839286458454994488665744991822837769918095117129546414124448777033941223565831420390846864429504774477949153794689948747680362212954278693335653935890352619041936727463717926744868338358149568368643403037768649616778526013610493696186055899318268339432671541328195724261329606699831016666359440874843103020666106568222401047720269951530296879490444224546654729111504346660859907296364097126834834235287147
-
-3080-bit prime:
-p == 1487259134814709264092032648525971038895865645148901180585340454985524155135260217788758027400478312256339496385275012465661575576202252063145698732079880294664220579764848767704076761853197216563262660046602703973050798218246170835962005598561669706844469447435461092542265792444947706769615695252256130901271870341005768912974433684521436211263358097522726462083917939091760026658925757076733484173202927141441492573799914240222628795405623953109131594523623353044898339481494120112723445689647986475279242446083151413667587008191682564376412347964146113898565886683139407005941383669325997475076910488086663256335689181157957571445067490187939553165903773554290260531009121879044170766615232300936675369451260747671432073394867530820527479172464106442450727640226503746586340279816318821395210726268291535648506190714616083163403189943334431056876038286530365757187367147446004855912033137386225053275419626102417236133948503
-
-4116-bit prime:
-p == 1095121115716677802856811290392395128588168592409109494900178008967955253005183831872715423151551999734857184538199864469605657805519106717529655044054833197687459782636297255219742994736751541815269727940751860670268774903340296040006114013971309257028332849679096824800250742691718610670812374272414086863715763724622797509437062518082383056050144624962776302147890521249477060215148275163688301275847155316042279405557632639366066847442861422164832655874655824221577849928863023018366835675399949740429332468186340518172487073360822220449055340582568461568645259954873303616953776393853174845132081121976327462740354930744487429617202585015510744298530101547706821590188733515880733527449780963163909830077616357506845523215289297624086914545378511082534229620116563260168494523906566709418166011112754529766183554579321224940951177394088465596712620076240067370589036924024728375076210477267488679008016579588696191194060127319035195370137160936882402244399699172017835144537488486396906144217720028992863941288217185353914991583400421682751000603596655790990815525126154394344641336397793791497068253936771017031980867706707490224041075826337383538651825493679503771934836094655802776331664261631740148281763487765852746577808019633679
diff --git a/libtommath/etc/drprimes.txt b/libtommath/etc/drprimes.txt
deleted file mode 100644
index 7c97f67..0000000
--- a/libtommath/etc/drprimes.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-300-bit prime:
-p == 2037035976334486086268445688409378161051468393665936250636140449354381298610415201576637819
-
-540-bit prime:
-p == 3599131035634557106248430806148785487095757694641533306480604458089470064537190296255232548883112685719936728506816716098566612844395439751206810991770626477344739
-
-780-bit prime:
-p == 6359114106063703798370219984742410466332205126109989319225557147754704702203399726411277962562135973685197744935448875852478791860694279747355800678568677946181447581781401213133886609947027230004277244697462656003655947791725966271167
-
diff --git a/libtommath/etc/makefile b/libtommath/etc/makefile
deleted file mode 100644
index 99154d8..0000000
--- a/libtommath/etc/makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-CFLAGS += -Wall -W -Wshadow -O3 -fomit-frame-pointer -funroll-loops -I../
-
-# default lib name (requires install with root)
-# LIBNAME=-ltommath
-
-# libname when you can't install the lib with install
-LIBNAME=../libtommath.a
-
-#provable primes
-pprime: pprime.o
- $(CC) pprime.o $(LIBNAME) -o pprime
-
-# portable [well requires clock()] tuning app
-tune: tune.o
- $(CC) tune.o $(LIBNAME) -o tune
-
-# same app but using RDTSC for higher precision [requires 80586+], coff based gcc installs [e.g. ming, cygwin, djgpp]
-tune86: tune.c
- nasm -f coff timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86
-
-# for cygwin
-tune86c: tune.c
- nasm -f gnuwin32 timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86
-
-#make tune86 for linux or any ELF format
-tune86l: tune.c
- nasm -f elf -DUSE_ELF timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86l
-
-# spits out mersenne primes
-mersenne: mersenne.o
- $(CC) mersenne.o $(LIBNAME) -o mersenne
-
-# fines DR safe primes for the given config
-drprime: drprime.o
- $(CC) drprime.o $(LIBNAME) -o drprime
-
-# fines 2k safe primes for the given config
-2kprime: 2kprime.o
- $(CC) 2kprime.o $(LIBNAME) -o 2kprime
-
-mont: mont.o
- $(CC) mont.o $(LIBNAME) -o mont
-
-
-clean:
- rm -f *.log *.o *.obj *.exe pprime tune mersenne drprime tune86 tune86l mont 2kprime pprime.dat \
- *.da *.dyn *.dpi *~
diff --git a/libtommath/etc/makefile.icc b/libtommath/etc/makefile.icc
deleted file mode 100644
index 8a1ffff..0000000
--- a/libtommath/etc/makefile.icc
+++ /dev/null
@@ -1,67 +0,0 @@
-CC = icc
-
-CFLAGS += -I../
-
-# optimize for SPEED
-#
-# -mcpu= can be pentium, pentiumpro (covers PII through PIII) or pentium4
-# -ax? specifies make code specifically for ? but compatible with IA-32
-# -x? specifies compile solely for ? [not specifically IA-32 compatible]
-#
-# where ? is
-# K - PIII
-# W - first P4 [Williamette]
-# N - P4 Northwood
-# P - P4 Prescott
-# B - Blend of P4 and PM [mobile]
-#
-# Default to just generic max opts
-CFLAGS += -O3 -xP -ip
-
-# default lib name (requires install with root)
-# LIBNAME=-ltommath
-
-# libname when you can't install the lib with install
-LIBNAME=../libtommath.a
-
-#provable primes
-pprime: pprime.o
- $(CC) pprime.o $(LIBNAME) -o pprime
-
-# portable [well requires clock()] tuning app
-tune: tune.o
- $(CC) tune.o $(LIBNAME) -o tune
-
-# same app but using RDTSC for higher precision [requires 80586+], coff based gcc installs [e.g. ming, cygwin, djgpp]
-tune86: tune.c
- nasm -f coff timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86
-
-# for cygwin
-tune86c: tune.c
- nasm -f gnuwin32 timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86
-
-#make tune86 for linux or any ELF format
-tune86l: tune.c
- nasm -f elf -DUSE_ELF timer.asm
- $(CC) -DX86_TIMER $(CFLAGS) tune.c timer.o $(LIBNAME) -o tune86l
-
-# spits out mersenne primes
-mersenne: mersenne.o
- $(CC) mersenne.o $(LIBNAME) -o mersenne
-
-# fines DR safe primes for the given config
-drprime: drprime.o
- $(CC) drprime.o $(LIBNAME) -o drprime
-
-# fines 2k safe primes for the given config
-2kprime: 2kprime.o
- $(CC) 2kprime.o $(LIBNAME) -o 2kprime
-
-mont: mont.o
- $(CC) mont.o $(LIBNAME) -o mont
-
-
-clean:
- rm -f *.log *.o *.obj *.exe pprime tune mersenne drprime tune86 tune86l mont 2kprime pprime.dat *.il
diff --git a/libtommath/etc/makefile.msvc b/libtommath/etc/makefile.msvc
deleted file mode 100644
index 2833372..0000000
--- a/libtommath/etc/makefile.msvc
+++ /dev/null
@@ -1,23 +0,0 @@
-#MSVC Makefile
-#
-#Tom St Denis
-
-CFLAGS = /I../ /Ox /DWIN32 /W3
-
-pprime: pprime.obj
- cl pprime.obj ../tommath.lib
-
-mersenne: mersenne.obj
- cl mersenne.obj ../tommath.lib
-
-tune: tune.obj
- cl tune.obj ../tommath.lib
-
-mont: mont.obj
- cl mont.obj ../tommath.lib
-
-drprime: drprime.obj
- cl drprime.obj ../tommath.lib
-
-2kprime: 2kprime.obj
- cl 2kprime.obj ../tommath.lib
diff --git a/libtommath/etc/mersenne.c b/libtommath/etc/mersenne.c
deleted file mode 100644
index 28ac834..0000000
--- a/libtommath/etc/mersenne.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Finds Mersenne primes using the Lucas-Lehmer test
- *
- * Tom St Denis, tomstdenis@gmail.com
- */
-#include <time.h>
-#include <tommath.h>
-
-int
-is_mersenne (long s, int *pp)
-{
- mp_int n, u;
- int res, k;
-
- *pp = 0;
-
- if ((res = mp_init (&n)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init (&u)) != MP_OKAY) {
- goto LBL_N;
- }
-
- /* n = 2^s - 1 */
- if ((res = mp_2expt(&n, s)) != MP_OKAY) {
- goto LBL_MU;
- }
- if ((res = mp_sub_d (&n, 1, &n)) != MP_OKAY) {
- goto LBL_MU;
- }
-
- /* set u=4 */
- mp_set (&u, 4);
-
- /* for k=1 to s-2 do */
- for (k = 1; k <= s - 2; k++) {
- /* u = u^2 - 2 mod n */
- if ((res = mp_sqr (&u, &u)) != MP_OKAY) {
- goto LBL_MU;
- }
- if ((res = mp_sub_d (&u, 2, &u)) != MP_OKAY) {
- goto LBL_MU;
- }
-
- /* make sure u is positive */
- while (u.sign == MP_NEG) {
- if ((res = mp_add (&u, &n, &u)) != MP_OKAY) {
- goto LBL_MU;
- }
- }
-
- /* reduce */
- if ((res = mp_reduce_2k (&u, &n, 1)) != MP_OKAY) {
- goto LBL_MU;
- }
- }
-
- /* if u == 0 then its prime */
- if (mp_iszero (&u) == 1) {
- mp_prime_is_prime(&n, 8, pp);
- if (*pp != 1) printf("FAILURE\n");
- }
-
- res = MP_OKAY;
-LBL_MU:mp_clear (&u);
-LBL_N:mp_clear (&n);
- return res;
-}
-
-/* square root of a long < 65536 */
-long
-i_sqrt (long x)
-{
- long x1, x2;
-
- x2 = 16;
- do {
- x1 = x2;
- x2 = x1 - ((x1 * x1) - x) / (2 * x1);
- } while (x1 != x2);
-
- if (x1 * x1 > x) {
- --x1;
- }
-
- return x1;
-}
-
-/* is the long prime by brute force */
-int
-isprime (long k)
-{
- long y, z;
-
- y = i_sqrt (k);
- for (z = 2; z <= y; z++) {
- if ((k % z) == 0)
- return 0;
- }
- return 1;
-}
-
-
-int
-main (void)
-{
- int pp;
- long k;
- clock_t tt;
-
- k = 3;
-
- for (;;) {
- /* start time */
- tt = clock ();
-
- /* test if 2^k - 1 is prime */
- if (is_mersenne (k, &pp) != MP_OKAY) {
- printf ("Whoa error\n");
- return -1;
- }
-
- if (pp == 1) {
- /* count time */
- tt = clock () - tt;
-
- /* display if prime */
- printf ("2^%-5ld - 1 is prime, test took %ld ticks\n", k, tt);
- }
-
- /* goto next odd exponent */
- k += 2;
-
- /* but make sure its prime */
- while (isprime (k) == 0) {
- k += 2;
- }
- }
- return 0;
-}
diff --git a/libtommath/etc/mont.c b/libtommath/etc/mont.c
deleted file mode 100644
index 7839675..0000000
--- a/libtommath/etc/mont.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* tests the montgomery routines */
-#include <tommath.h>
-
-int main(void)
-{
- mp_int modulus, R, p, pp;
- mp_digit mp;
- long x, y;
-
- srand(time(NULL));
- mp_init_multi(&modulus, &R, &p, &pp, NULL);
-
- /* loop through various sizes */
- for (x = 4; x < 256; x++) {
- printf("DIGITS == %3ld...", x); fflush(stdout);
-
- /* make up the odd modulus */
- mp_rand(&modulus, x);
- modulus.dp[0] |= 1;
-
- /* now find the R value */
- mp_montgomery_calc_normalization(&R, &modulus);
- mp_montgomery_setup(&modulus, &mp);
-
- /* now run through a bunch tests */
- for (y = 0; y < 1000; y++) {
- mp_rand(&p, x/2); /* p = random */
- mp_mul(&p, &R, &pp); /* pp = R * p */
- mp_montgomery_reduce(&pp, &modulus, mp);
-
- /* should be equal to p */
- if (mp_cmp(&pp, &p) != MP_EQ) {
- printf("FAILURE!\n");
- exit(-1);
- }
- }
- printf("PASSED\n");
- }
-
- return 0;
-}
diff --git a/libtommath/etc/pprime.c b/libtommath/etc/pprime.c
deleted file mode 100644
index 955f19e..0000000
--- a/libtommath/etc/pprime.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* Generates provable primes
- *
- * See http://gmail.com:8080/papers/pp.pdf for more info.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://tom.gmail.com
- */
-#include <time.h>
-#include "tommath.h"
-
-int n_prime;
-FILE *primes;
-
-/* fast square root */
-static mp_digit
-i_sqrt (mp_word x)
-{
- mp_word x1, x2;
-
- x2 = x;
- do {
- x1 = x2;
- x2 = x1 - ((x1 * x1) - x) / (2 * x1);
- } while (x1 != x2);
-
- if (x1 * x1 > x) {
- --x1;
- }
-
- return x1;
-}
-
-
-/* generates a prime digit */
-static void gen_prime (void)
-{
- mp_digit r, x, y, next;
- FILE *out;
-
- out = fopen("pprime.dat", "wb");
-
- /* write first set of primes */
- r = 3; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 5; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 7; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 11; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 13; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 17; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 19; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 23; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 29; fwrite(&r, 1, sizeof(mp_digit), out);
- r = 31; fwrite(&r, 1, sizeof(mp_digit), out);
-
- /* get square root, since if 'r' is composite its factors must be < than this */
- y = i_sqrt (r);
- next = (y + 1) * (y + 1);
-
- for (;;) {
- do {
- r += 2; /* next candidate */
- r &= MP_MASK;
- if (r < 31) break;
-
- /* update sqrt ? */
- if (next <= r) {
- ++y;
- next = (y + 1) * (y + 1);
- }
-
- /* loop if divisible by 3,5,7,11,13,17,19,23,29 */
- if ((r % 3) == 0) {
- x = 0;
- continue;
- }
- if ((r % 5) == 0) {
- x = 0;
- continue;
- }
- if ((r % 7) == 0) {
- x = 0;
- continue;
- }
- if ((r % 11) == 0) {
- x = 0;
- continue;
- }
- if ((r % 13) == 0) {
- x = 0;
- continue;
- }
- if ((r % 17) == 0) {
- x = 0;
- continue;
- }
- if ((r % 19) == 0) {
- x = 0;
- continue;
- }
- if ((r % 23) == 0) {
- x = 0;
- continue;
- }
- if ((r % 29) == 0) {
- x = 0;
- continue;
- }
-
- /* now check if r is divisible by x + k={1,7,11,13,17,19,23,29} */
- for (x = 30; x <= y; x += 30) {
- if ((r % (x + 1)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 7)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 11)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 13)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 17)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 19)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 23)) == 0) {
- x = 0;
- break;
- }
- if ((r % (x + 29)) == 0) {
- x = 0;
- break;
- }
- }
- } while (x == 0);
- if (r > 31) { fwrite(&r, 1, sizeof(mp_digit), out); printf("%9d\r", r); fflush(stdout); }
- if (r < 31) break;
- }
-
- fclose(out);
-}
-
-void load_tab(void)
-{
- primes = fopen("pprime.dat", "rb");
- if (primes == NULL) {
- gen_prime();
- primes = fopen("pprime.dat", "rb");
- }
- fseek(primes, 0, SEEK_END);
- n_prime = ftell(primes) / sizeof(mp_digit);
-}
-
-mp_digit prime_digit(void)
-{
- int n;
- mp_digit d;
-
- n = abs(rand()) % n_prime;
- fseek(primes, n * sizeof(mp_digit), SEEK_SET);
- fread(&d, 1, sizeof(mp_digit), primes);
- return d;
-}
-
-
-/* makes a prime of at least k bits */
-int
-pprime (int k, int li, mp_int * p, mp_int * q)
-{
- mp_int a, b, c, n, x, y, z, v;
- int res, ii;
- static const mp_digit bases[] = { 2, 3, 5, 7, 11, 13, 17, 19 };
-
- /* single digit ? */
- if (k <= (int) DIGIT_BIT) {
- mp_set (p, prime_digit ());
- return MP_OKAY;
- }
-
- if ((res = mp_init (&c)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init (&v)) != MP_OKAY) {
- goto LBL_C;
- }
-
- /* product of first 50 primes */
- if ((res =
- mp_read_radix (&v,
- "19078266889580195013601891820992757757219839668357012055907516904309700014933909014729740190",
- 10)) != MP_OKAY) {
- goto LBL_V;
- }
-
- if ((res = mp_init (&a)) != MP_OKAY) {
- goto LBL_V;
- }
-
- /* set the prime */
- mp_set (&a, prime_digit ());
-
- if ((res = mp_init (&b)) != MP_OKAY) {
- goto LBL_A;
- }
-
- if ((res = mp_init (&n)) != MP_OKAY) {
- goto LBL_B;
- }
-
- if ((res = mp_init (&x)) != MP_OKAY) {
- goto LBL_N;
- }
-
- if ((res = mp_init (&y)) != MP_OKAY) {
- goto LBL_X;
- }
-
- if ((res = mp_init (&z)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- /* now loop making the single digit */
- while (mp_count_bits (&a) < k) {
- fprintf (stderr, "prime has %4d bits left\r", k - mp_count_bits (&a));
- fflush (stderr);
- top:
- mp_set (&b, prime_digit ());
-
- /* now compute z = a * b * 2 */
- if ((res = mp_mul (&a, &b, &z)) != MP_OKAY) { /* z = a * b */
- goto LBL_Z;
- }
-
- if ((res = mp_copy (&z, &c)) != MP_OKAY) { /* c = a * b */
- goto LBL_Z;
- }
-
- if ((res = mp_mul_2 (&z, &z)) != MP_OKAY) { /* z = 2 * a * b */
- goto LBL_Z;
- }
-
- /* n = z + 1 */
- if ((res = mp_add_d (&z, 1, &n)) != MP_OKAY) { /* n = z + 1 */
- goto LBL_Z;
- }
-
- /* check (n, v) == 1 */
- if ((res = mp_gcd (&n, &v, &y)) != MP_OKAY) { /* y = (n, v) */
- goto LBL_Z;
- }
-
- if (mp_cmp_d (&y, 1) != MP_EQ)
- goto top;
-
- /* now try base x=bases[ii] */
- for (ii = 0; ii < li; ii++) {
- mp_set (&x, bases[ii]);
-
- /* compute x^a mod n */
- if ((res = mp_exptmod (&x, &a, &n, &y)) != MP_OKAY) { /* y = x^a mod n */
- goto LBL_Z;
- }
-
- /* if y == 1 loop */
- if (mp_cmp_d (&y, 1) == MP_EQ)
- continue;
-
- /* now x^2a mod n */
- if ((res = mp_sqrmod (&y, &n, &y)) != MP_OKAY) { /* y = x^2a mod n */
- goto LBL_Z;
- }
-
- if (mp_cmp_d (&y, 1) == MP_EQ)
- continue;
-
- /* compute x^b mod n */
- if ((res = mp_exptmod (&x, &b, &n, &y)) != MP_OKAY) { /* y = x^b mod n */
- goto LBL_Z;
- }
-
- /* if y == 1 loop */
- if (mp_cmp_d (&y, 1) == MP_EQ)
- continue;
-
- /* now x^2b mod n */
- if ((res = mp_sqrmod (&y, &n, &y)) != MP_OKAY) { /* y = x^2b mod n */
- goto LBL_Z;
- }
-
- if (mp_cmp_d (&y, 1) == MP_EQ)
- continue;
-
- /* compute x^c mod n == x^ab mod n */
- if ((res = mp_exptmod (&x, &c, &n, &y)) != MP_OKAY) { /* y = x^ab mod n */
- goto LBL_Z;
- }
-
- /* if y == 1 loop */
- if (mp_cmp_d (&y, 1) == MP_EQ)
- continue;
-
- /* now compute (x^c mod n)^2 */
- if ((res = mp_sqrmod (&y, &n, &y)) != MP_OKAY) { /* y = x^2ab mod n */
- goto LBL_Z;
- }
-
- /* y should be 1 */
- if (mp_cmp_d (&y, 1) != MP_EQ)
- continue;
- break;
- }
-
- /* no bases worked? */
- if (ii == li)
- goto top;
-
-{
- char buf[4096];
-
- mp_toradix(&n, buf, 10);
- printf("Certificate of primality for:\n%s\n\n", buf);
- mp_toradix(&a, buf, 10);
- printf("A == \n%s\n\n", buf);
- mp_toradix(&b, buf, 10);
- printf("B == \n%s\n\nG == %d\n", buf, bases[ii]);
- printf("----------------------------------------------------------------\n");
-}
-
- /* a = n */
- mp_copy (&n, &a);
- }
-
- /* get q to be the order of the large prime subgroup */
- mp_sub_d (&n, 1, q);
- mp_div_2 (q, q);
- mp_div (q, &b, q, NULL);
-
- mp_exch (&n, p);
-
- res = MP_OKAY;
-LBL_Z:mp_clear (&z);
-LBL_Y:mp_clear (&y);
-LBL_X:mp_clear (&x);
-LBL_N:mp_clear (&n);
-LBL_B:mp_clear (&b);
-LBL_A:mp_clear (&a);
-LBL_V:mp_clear (&v);
-LBL_C:mp_clear (&c);
- return res;
-}
-
-
-int
-main (void)
-{
- mp_int p, q;
- char buf[4096];
- int k, li;
- clock_t t1;
-
- srand (time (NULL));
- load_tab();
-
- printf ("Enter # of bits: \n");
- fgets (buf, sizeof (buf), stdin);
- sscanf (buf, "%d", &k);
-
- printf ("Enter number of bases to try (1 to 8):\n");
- fgets (buf, sizeof (buf), stdin);
- sscanf (buf, "%d", &li);
-
-
- mp_init (&p);
- mp_init (&q);
-
- t1 = clock ();
- pprime (k, li, &p, &q);
- t1 = clock () - t1;
-
- printf ("\n\nTook %ld ticks, %d bits\n", t1, mp_count_bits (&p));
-
- mp_toradix (&p, buf, 10);
- printf ("P == %s\n", buf);
- mp_toradix (&q, buf, 10);
- printf ("Q == %s\n", buf);
-
- return 0;
-}
diff --git a/libtommath/etc/prime.1024 b/libtommath/etc/prime.1024
deleted file mode 100644
index 5636e2d..0000000
--- a/libtommath/etc/prime.1024
+++ /dev/null
@@ -1,414 +0,0 @@
-Enter # of bits:
-Enter number of bases to try (1 to 8):
-Certificate of primality for:
-36360080703173363
-
-A ==
-89963569
-
-B ==
-202082249
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-4851595597739856136987139
-
-A ==
-36360080703173363
-
-B ==
-66715963
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-19550639734462621430325731591027
-
-A ==
-4851595597739856136987139
-
-B ==
-2014867
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-10409036141344317165691858509923818734539
-
-A ==
-19550639734462621430325731591027
-
-B ==
-266207047
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1049829549988285012736475602118094726647504414203
-
-A ==
-10409036141344317165691858509923818734539
-
-B ==
-50428759
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-77194737385528288387712399596835459931920358844586615003
-
-A ==
-1049829549988285012736475602118094726647504414203
-
-B ==
-36765367
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-35663756695365208574443215955488689578374232732893628896541201763
-
-A ==
-77194737385528288387712399596835459931920358844586615003
-
-B ==
-230998627
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-16711831463502165169495622246023119698415848120292671294127567620396469803
-
-A ==
-35663756695365208574443215955488689578374232732893628896541201763
-
-B ==
-234297127
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-6163534781560285962890718925972249753147470953579266394395432475622345597103528739
-
-A ==
-16711831463502165169495622246023119698415848120292671294127567620396469803
-
-B ==
-184406323
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-814258256205243497704094951432575867360065658372158511036259934640748088306764553488803787
-
-A ==
-6163534781560285962890718925972249753147470953579266394395432475622345597103528739
-
-B ==
-66054487
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-176469695533271657902814176811660357049007467856432383037590673407330246967781451723764079581998187
-
-A ==
-814258256205243497704094951432575867360065658372158511036259934640748088306764553488803787
-
-B ==
-108362239
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-44924492859445516541759485198544012102424796403707253610035148063863073596051272171194806669756971406400419
-
-A ==
-176469695533271657902814176811660357049007467856432383037590673407330246967781451723764079581998187
-
-B ==
-127286707
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-20600996927219343383225424320134474929609459588323857796871086845924186191561749519858600696159932468024710985371059
-
-A ==
-44924492859445516541759485198544012102424796403707253610035148063863073596051272171194806669756971406400419
-
-B ==
-229284691
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-6295696427695493110141186605837397185848992307978456138112526915330347715236378041486547994708748840844217371233735072572979
-
-A ==
-20600996927219343383225424320134474929609459588323857796871086845924186191561749519858600696159932468024710985371059
-
-B ==
-152800771
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-3104984078042317488749073016454213579257792635142218294052134804187631661145261015102617582090263808696699966840735333252107678792123
-
-A ==
-6295696427695493110141186605837397185848992307978456138112526915330347715236378041486547994708748840844217371233735072572979
-
-B ==
-246595759
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-26405175827665701256325699315126705508919255051121452292124404943796947287968603975320562847910946802396632302209435206627913466015741799499
-
-A ==
-3104984078042317488749073016454213579257792635142218294052134804187631661145261015102617582090263808696699966840735333252107678792123
-
-B ==
-4252063
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-11122146237908413610034600609460545703591095894418599759742741406628055069007082998134905595800236452010905900391505454890446585211975124558601770163
-
-A ==
-26405175827665701256325699315126705508919255051121452292124404943796947287968603975320562847910946802396632302209435206627913466015741799499
-
-B ==
-210605419
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1649861642047798890580354082088712649911849362201343649289384923147797960364736011515757482030049342943790127685185806092659832129486307035500638595572396187
-
-A ==
-11122146237908413610034600609460545703591095894418599759742741406628055069007082998134905595800236452010905900391505454890446585211975124558601770163
-
-B ==
-74170111
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-857983367126266717607389719637086684134462613006415859877666235955788392464081914127715967940968197765042399904117392707518175220864852816390004264107201177394565363
-
-A ==
-1649861642047798890580354082088712649911849362201343649289384923147797960364736011515757482030049342943790127685185806092659832129486307035500638595572396187
-
-B ==
-260016763
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-175995909353623703257072120479340610010337144085688850745292031336724691277374210929188442230237711063783727092685448718515661641054886101716698390145283196296702450566161283
-
-A ==
-857983367126266717607389719637086684134462613006415859877666235955788392464081914127715967940968197765042399904117392707518175220864852816390004264107201177394565363
-
-B ==
-102563707
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-48486002551155667224487059713350447239190772068092630563272168418880661006593537218144160068395218642353495339720640699721703003648144463556291315694787862009052641640656933232794283
-
-A ==
-175995909353623703257072120479340610010337144085688850745292031336724691277374210929188442230237711063783727092685448718515661641054886101716698390145283196296702450566161283
-
-B ==
-137747527
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-13156468011529105025061495011938518171328604045212410096476697450506055664012861932372156505805788068791146986282263016790631108386790291275939575123375304599622623328517354163964228279867403
-
-A ==
-48486002551155667224487059713350447239190772068092630563272168418880661006593537218144160068395218642353495339720640699721703003648144463556291315694787862009052641640656933232794283
-
-B ==
-135672847
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-6355194692790533601105154341731997464407930009404822926832136060319955058388106456084549316415200519472481147942263916585428906582726749131479465958107142228236909665306781538860053107680830113869123
-
-A ==
-13156468011529105025061495011938518171328604045212410096476697450506055664012861932372156505805788068791146986282263016790631108386790291275939575123375304599622623328517354163964228279867403
-
-B ==
-241523587
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-3157116676535430302794438027544146642863331358530722860333745617571010460905857862561870488000265751138954271040017454405707755458702044884023184574412221802502351503929935224995314581932097706874819348858083
-
-A ==
-6355194692790533601105154341731997464407930009404822926832136060319955058388106456084549316415200519472481147942263916585428906582726749131479465958107142228236909665306781538860053107680830113869123
-
-B ==
-248388667
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-390533129219992506725320633489467713907837370444962163378727819939092929448752905310115311180032249230394348337568973177802874166228132778126338883671958897238722734394783244237133367055422297736215754829839364158067
-
-A ==
-3157116676535430302794438027544146642863331358530722860333745617571010460905857862561870488000265751138954271040017454405707755458702044884023184574412221802502351503929935224995314581932097706874819348858083
-
-B ==
-61849651
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-48583654555070224891047847050732516652910250240135992225139515777200432486685999462997073444468380434359929499498804723793106565291183220444221080449740542884172281158126259373095216435009661050109711341419005972852770440739
-
-A ==
-390533129219992506725320633489467713907837370444962163378727819939092929448752905310115311180032249230394348337568973177802874166228132778126338883671958897238722734394783244237133367055422297736215754829839364158067
-
-B ==
-62201707
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-25733035251905120039135866524384525138869748427727001128764704499071378939227862068500633813538831598776578372709963673670934388213622433800015759585470542686333039614931682098922935087822950084908715298627996115185849260703525317419
-
-A ==
-48583654555070224891047847050732516652910250240135992225139515777200432486685999462997073444468380434359929499498804723793106565291183220444221080449740542884172281158126259373095216435009661050109711341419005972852770440739
-
-B ==
-264832231
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-2804594464939948901906623499531073917980499195397462605359913717827014360538186518540781517129548650937632008683280555602633122170458773895504894807182664540529077836857897972175530148107545939211339044386106111633510166695386323426241809387
-
-A ==
-25733035251905120039135866524384525138869748427727001128764704499071378939227862068500633813538831598776578372709963673670934388213622433800015759585470542686333039614931682098922935087822950084908715298627996115185849260703525317419
-
-B ==
-54494047
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-738136612083433720096707308165797114449914259256979340471077690416567237592465306112484843530074782721390528773594351482384711900456440808251196845265132086486672447136822046628407467459921823150600138073268385534588238548865012638209515923513516547
-
-A ==
-2804594464939948901906623499531073917980499195397462605359913717827014360538186518540781517129548650937632008683280555602633122170458773895504894807182664540529077836857897972175530148107545939211339044386106111633510166695386323426241809387
-
-B ==
-131594179
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-392847529056126766528615419937165193421166694172790666626558750047057558168124866940509180171236517681470100877687445134633784815352076138790217228749332398026714192707447855731679485746120589851992221508292976900578299504461333767437280988393026452846013683
-
-A ==
-738136612083433720096707308165797114449914259256979340471077690416567237592465306112484843530074782721390528773594351482384711900456440808251196845265132086486672447136822046628407467459921823150600138073268385534588238548865012638209515923513516547
-
-B ==
-266107603
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-168459393231883505975876919268398655632763956627405508859662408056221544310200546265681845397346956580604208064328814319465940958080244889692368602591598503944015835190587740756859842792554282496742843600573336023639256008687581291233481455395123454655488735304365627
-
-A ==
-392847529056126766528615419937165193421166694172790666626558750047057558168124866940509180171236517681470100877687445134633784815352076138790217228749332398026714192707447855731679485746120589851992221508292976900578299504461333767437280988393026452846013683
-
-B ==
-214408111
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-14865774288636941404884923981945833072113667565310054952177860608355263252462409554658728941191929400198053290113492910272458441655458514080123870132092365833472436407455910185221474386718838138135065780840839893113912689594815485706154461164071775481134379794909690501684643
-
-A ==
-168459393231883505975876919268398655632763956627405508859662408056221544310200546265681845397346956580604208064328814319465940958080244889692368602591598503944015835190587740756859842792554282496742843600573336023639256008687581291233481455395123454655488735304365627
-
-B ==
-44122723
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1213301773203241614897109856134894783021668292000023984098824423682568173639394290886185366993108292039068940333907505157813934962357206131450244004178619265868614859794316361031904412926604138893775068853175215502104744339658944443630407632290152772487455298652998368296998719996019
-
-A ==
-14865774288636941404884923981945833072113667565310054952177860608355263252462409554658728941191929400198053290113492910272458441655458514080123870132092365833472436407455910185221474386718838138135065780840839893113912689594815485706154461164071775481134379794909690501684643
-
-B ==
-40808563
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-186935245989515158127969129347464851990429060640910951266513740972248428651109062997368144722015290092846666943896556191257222521203647606911446635194198213436423080005867489516421559330500722264446765608763224572386410155413161172707802334865729654109050873820610813855041667633843601286843
-
-A ==
-1213301773203241614897109856134894783021668292000023984098824423682568173639394290886185366993108292039068940333907505157813934962357206131450244004178619265868614859794316361031904412926604138893775068853175215502104744339658944443630407632290152772487455298652998368296998719996019
-
-B ==
-77035759
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-83142661079751490510739960019112406284111408348732592580459037404394946037094409915127399165633756159385609671956087845517678367844901424617866988187132480585966721962585586730693443536100138246516868613250009028187662080828012497191775172228832247706080044971423654632146928165751885302331924491683
-
-A ==
-186935245989515158127969129347464851990429060640910951266513740972248428651109062997368144722015290092846666943896556191257222521203647606911446635194198213436423080005867489516421559330500722264446765608763224572386410155413161172707802334865729654109050873820610813855041667633843601286843
-
-B ==
-222383587
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-3892354773803809855317742245039794448230625839512638747643814927766738642436392673485997449586432241626440927010641564064764336402368634186618250134234189066179771240232458249806850838490410473462391401438160528157981942499581634732706904411807195259620779379274017704050790865030808501633772117217899534443
-
-A ==
-83142661079751490510739960019112406284111408348732592580459037404394946037094409915127399165633756159385609671956087845517678367844901424617866988187132480585966721962585586730693443536100138246516868613250009028187662080828012497191775172228832247706080044971423654632146928165751885302331924491683
-
-B ==
-23407687
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1663606652988091811284014366560171522582683318514519379924950390627250155440313691226744227787921928894551755219495501365555370027257568506349958010457682898612082048959464465369892842603765280317696116552850664773291371490339084156052244256635115997453399761029567033971998617303988376172539172702246575225837054723
-
-A ==
-3892354773803809855317742245039794448230625839512638747643814927766738642436392673485997449586432241626440927010641564064764336402368634186618250134234189066179771240232458249806850838490410473462391401438160528157981942499581634732706904411807195259620779379274017704050790865030808501633772117217899534443
-
-B ==
-213701827
-
-G == 2
-----------------------------------------------------------------
-
-
-Took 33057 ticks, 1048 bits
-P == 1663606652988091811284014366560171522582683318514519379924950390627250155440313691226744227787921928894551755219495501365555370027257568506349958010457682898612082048959464465369892842603765280317696116552850664773291371490339084156052244256635115997453399761029567033971998617303988376172539172702246575225837054723
-Q == 3892354773803809855317742245039794448230625839512638747643814927766738642436392673485997449586432241626440927010641564064764336402368634186618250134234189066179771240232458249806850838490410473462391401438160528157981942499581634732706904411807195259620779379274017704050790865030808501633772117217899534443
diff --git a/libtommath/etc/prime.512 b/libtommath/etc/prime.512
deleted file mode 100644
index cb6ec30..0000000
--- a/libtommath/etc/prime.512
+++ /dev/null
@@ -1,205 +0,0 @@
-Enter # of bits:
-Enter number of bases to try (1 to 8):
-Certificate of primality for:
-85933926807634727
-
-A ==
-253758023
-
-B ==
-169322581
-
-G == 5
-----------------------------------------------------------------
-Certificate of primality for:
-23930198825086241462113799
-
-A ==
-85933926807634727
-
-B ==
-139236037
-
-G == 11
-----------------------------------------------------------------
-Certificate of primality for:
-6401844647261612602378676572510019
-
-A ==
-23930198825086241462113799
-
-B ==
-133760791
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-269731366027728777712034888684015329354259
-
-A ==
-6401844647261612602378676572510019
-
-B ==
-21066691
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-37942338209025571690075025099189467992329684223707
-
-A ==
-269731366027728777712034888684015329354259
-
-B ==
-70333567
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-15306904714258982484473490774101705363308327436988160248323
-
-A ==
-37942338209025571690075025099189467992329684223707
-
-B ==
-201712723
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1616744757018513392810355191503853040357155275733333124624513530099
-
-A ==
-15306904714258982484473490774101705363308327436988160248323
-
-B ==
-52810963
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-464222094814208047161771036072622485188658077940154689939306386289983787983
-
-A ==
-1616744757018513392810355191503853040357155275733333124624513530099
-
-B ==
-143566909
-
-G == 5
-----------------------------------------------------------------
-Certificate of primality for:
-187429931674053784626487560729643601208757374994177258429930699354770049369025096447
-
-A ==
-464222094814208047161771036072622485188658077940154689939306386289983787983
-
-B ==
-201875281
-
-G == 5
-----------------------------------------------------------------
-Certificate of primality for:
-100579220846502621074093727119851331775052664444339632682598589456666938521976625305832917563
-
-A ==
-187429931674053784626487560729643601208757374994177258429930699354770049369025096447
-
-B ==
-268311523
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1173616081309758475197022137833792133815753368965945885089720153370737965497134878651384030219765163
-
-A ==
-100579220846502621074093727119851331775052664444339632682598589456666938521976625305832917563
-
-B ==
-5834287
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-191456913489905913185935197655672585713573070349044195411728114905691721186574907738081340754373032735283623
-
-A ==
-1173616081309758475197022137833792133815753368965945885089720153370737965497134878651384030219765163
-
-B ==
-81567097
-
-G == 5
-----------------------------------------------------------------
-Certificate of primality for:
-57856530489201750164178576399448868489243874083056587683743345599898489554401618943240901541005080049321706789987519
-
-A ==
-191456913489905913185935197655672585713573070349044195411728114905691721186574907738081340754373032735283623
-
-B ==
-151095433
-
-G == 7
-----------------------------------------------------------------
-Certificate of primality for:
-13790529750452576698109671710773784949185621244122040804792403407272729038377767162233653248852099545134831722512085881814803
-
-A ==
-57856530489201750164178576399448868489243874083056587683743345599898489554401618943240901541005080049321706789987519
-
-B ==
-119178679
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-7075985989000817742677547821106534174334812111605018857703825637170140040509067704269696198231266351631132464035671858077052876058979
-
-A ==
-13790529750452576698109671710773784949185621244122040804792403407272729038377767162233653248852099545134831722512085881814803
-
-B ==
-256552363
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-1227273006232588072907488910282307435921226646895131225407452056677899411162892829564455154080310937471747140942360789623819327234258162420463
-
-A ==
-7075985989000817742677547821106534174334812111605018857703825637170140040509067704269696198231266351631132464035671858077052876058979
-
-B ==
-86720989
-
-G == 5
-----------------------------------------------------------------
-Certificate of primality for:
-446764896913554613686067036908702877942872355053329937790398156069936255759889884246832779737114032666318220500106499161852193765380831330106375235763
-
-A ==
-1227273006232588072907488910282307435921226646895131225407452056677899411162892829564455154080310937471747140942360789623819327234258162420463
-
-B ==
-182015287
-
-G == 2
-----------------------------------------------------------------
-Certificate of primality for:
-5290203010849586596974953717018896543907195901082056939587768479377028575911127944611236020459652034082251335583308070846379514569838984811187823420951275243
-
-A ==
-446764896913554613686067036908702877942872355053329937790398156069936255759889884246832779737114032666318220500106499161852193765380831330106375235763
-
-B ==
-5920567
-
-G == 2
-----------------------------------------------------------------
-
-
-Took 3454 ticks, 521 bits
-P == 5290203010849586596974953717018896543907195901082056939587768479377028575911127944611236020459652034082251335583308070846379514569838984811187823420951275243
-Q == 446764896913554613686067036908702877942872355053329937790398156069936255759889884246832779737114032666318220500106499161852193765380831330106375235763
diff --git a/libtommath/etc/timer.asm b/libtommath/etc/timer.asm
deleted file mode 100644
index 326a947..0000000
--- a/libtommath/etc/timer.asm
+++ /dev/null
@@ -1,37 +0,0 @@
-; x86 timer in NASM
-;
-; Tom St Denis, tomstdenis@iahu.ca
-[bits 32]
-[section .data]
-time dd 0, 0
-
-[section .text]
-
-%ifdef USE_ELF
-[global t_start]
-t_start:
-%else
-[global _t_start]
-_t_start:
-%endif
- push edx
- push eax
- rdtsc
- mov [time+0],edx
- mov [time+4],eax
- pop eax
- pop edx
- ret
-
-%ifdef USE_ELF
-[global t_read]
-t_read:
-%else
-[global _t_read]
-_t_read:
-%endif
- rdtsc
- sub eax,[time+4]
- sbb edx,[time+0]
- ret
- \ No newline at end of file
diff --git a/libtommath/etc/tune.c b/libtommath/etc/tune.c
deleted file mode 100644
index acb146f..0000000
--- a/libtommath/etc/tune.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Tune the Karatsuba parameters
- *
- * Tom St Denis, tomstdenis@gmail.com
- */
-#include <tommath.h>
-#include <time.h>
-
-/* how many times todo each size mult. Depends on your computer. For slow computers
- * this can be low like 5 or 10. For fast [re: Athlon] should be 25 - 50 or so
- */
-#define TIMES (1UL<<14UL)
-
-/* RDTSC from Scott Duplichan */
-static ulong64 TIMFUNC (void)
- {
- #if defined __GNUC__
- #if defined(__i386__) || defined(__x86_64__)
- unsigned long long a;
- __asm__ __volatile__ ("rdtsc\nmovl %%eax,%0\nmovl %%edx,4+%0\n"::"m"(a):"%eax","%edx");
- return a;
- #else /* gcc-IA64 version */
- unsigned long result;
- __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
- while (__builtin_expect ((int) result == -1, 0))
- __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
- return result;
- #endif
-
- // Microsoft and Intel Windows compilers
- #elif defined _M_IX86
- __asm rdtsc
- #elif defined _M_AMD64
- return __rdtsc ();
- #elif defined _M_IA64
- #if defined __INTEL_COMPILER
- #include <ia64intrin.h>
- #endif
- return __getReg (3116);
- #else
- #error need rdtsc function for this build
- #endif
- }
-
-
-#ifndef X86_TIMER
-
-/* generic ISO C timer */
-ulong64 LBL_T;
-void t_start(void) { LBL_T = TIMFUNC(); }
-ulong64 t_read(void) { return TIMFUNC() - LBL_T; }
-
-#else
-extern void t_start(void);
-extern ulong64 t_read(void);
-#endif
-
-ulong64 time_mult(int size, int s)
-{
- unsigned long x;
- mp_int a, b, c;
- ulong64 t1;
-
- mp_init (&a);
- mp_init (&b);
- mp_init (&c);
-
- mp_rand (&a, size);
- mp_rand (&b, size);
-
- if (s == 1) {
- KARATSUBA_MUL_CUTOFF = size;
- } else {
- KARATSUBA_MUL_CUTOFF = 100000;
- }
-
- t_start();
- for (x = 0; x < TIMES; x++) {
- mp_mul(&a,&b,&c);
- }
- t1 = t_read();
- mp_clear (&a);
- mp_clear (&b);
- mp_clear (&c);
- return t1;
-}
-
-ulong64 time_sqr(int size, int s)
-{
- unsigned long x;
- mp_int a, b;
- ulong64 t1;
-
- mp_init (&a);
- mp_init (&b);
-
- mp_rand (&a, size);
-
- if (s == 1) {
- KARATSUBA_SQR_CUTOFF = size;
- } else {
- KARATSUBA_SQR_CUTOFF = 100000;
- }
-
- t_start();
- for (x = 0; x < TIMES; x++) {
- mp_sqr(&a,&b);
- }
- t1 = t_read();
- mp_clear (&a);
- mp_clear (&b);
- return t1;
-}
-
-int
-main (void)
-{
- ulong64 t1, t2;
- int x, y;
-
- for (x = 8; ; x += 2) {
- t1 = time_mult(x, 0);
- t2 = time_mult(x, 1);
- printf("%d: %9llu %9llu, %9llu\n", x, t1, t2, t2 - t1);
- if (t2 < t1) break;
- }
- y = x;
-
- for (x = 8; ; x += 2) {
- t1 = time_sqr(x, 0);
- t2 = time_sqr(x, 1);
- printf("%d: %9llu %9llu, %9llu\n", x, t1, t2, t2 - t1);
- if (t2 < t1) break;
- }
- printf("KARATSUBA_MUL_CUTOFF = %d\n", y);
- printf("KARATSUBA_SQR_CUTOFF = %d\n", x);
-
- return 0;
-}
diff --git a/libtommath/gen.pl b/libtommath/gen.pl
deleted file mode 100644
index 7236591..0000000
--- a/libtommath/gen.pl
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Generates a "single file" you can use to quickly
-# add the whole source without any makefile troubles
-#
-use strict;
-
-open( OUT, ">mpi.c" ) or die "Couldn't open mpi.c for writing: $!";
-foreach my $filename (glob "bn*.c") {
- open( SRC, "<$filename" ) or die "Couldn't open $filename for reading: $!";
- print OUT "/* Start: $filename */\n";
- print OUT while <SRC>;
- print OUT "\n/* End: $filename */\n\n";
- close SRC or die "Error closing $filename after reading: $!";
-}
-print OUT "\n/* EOF */\n";
-close OUT or die "Error closing mpi.c after writing: $!"; \ No newline at end of file
diff --git a/libtommath/logs/README b/libtommath/logs/README
deleted file mode 100644
index 965e7c8..0000000
--- a/libtommath/logs/README
+++ /dev/null
@@ -1,13 +0,0 @@
-To use the pretty graphs you have to first build/run the ltmtest from the root directory of the package.
-Todo this type
-
-make timing ; ltmtest
-
-in the root. It will run for a while [about ten minutes on most PCs] and produce a series of .log files in logs/.
-
-After doing that run "gnuplot graphs.dem" to make the PNGs. If you managed todo that all so far just open index.html to view
-them all :-)
-
-Have fun
-
-Tom \ No newline at end of file
diff --git a/libtommath/logs/add.log b/libtommath/logs/add.log
deleted file mode 100644
index 43503ac..0000000
--- a/libtommath/logs/add.log
+++ /dev/null
@@ -1,16 +0,0 @@
-480 87
-960 111
-1440 135
-1920 159
-2400 200
-2880 224
-3360 248
-3840 272
-4320 296
-4800 320
-5280 344
-5760 368
-6240 392
-6720 416
-7200 440
-7680 464
diff --git a/libtommath/logs/addsub.png b/libtommath/logs/addsub.png
deleted file mode 100644
index 441c7b2..0000000
--- a/libtommath/logs/addsub.png
+++ /dev/null
Binary files differ
diff --git a/libtommath/logs/expt.log b/libtommath/logs/expt.log
deleted file mode 100644
index 70932ab..0000000
--- a/libtommath/logs/expt.log
+++ /dev/null
@@ -1,7 +0,0 @@
-513 1435869
-769 3544970
-1025 7791638
-2049 46902238
-2561 85334899
-3073 141451412
-4097 308770310
diff --git a/libtommath/logs/expt.png b/libtommath/logs/expt.png
deleted file mode 100644
index d779cc5..0000000
--- a/libtommath/logs/expt.png
+++ /dev/null
Binary files differ
diff --git a/libtommath/logs/expt_2k.log b/libtommath/logs/expt_2k.log
deleted file mode 100644
index 97d325f..0000000
--- a/libtommath/logs/expt_2k.log
+++ /dev/null
@@ -1,5 +0,0 @@
-607 2109225
-1279 10148314
-2203 34126877
-3217 82716424
-4253 161569606
diff --git a/libtommath/logs/expt_2kl.log b/libtommath/logs/expt_2kl.log
deleted file mode 100644
index d9ad4be..0000000
--- a/libtommath/logs/expt_2kl.log
+++ /dev/null
@@ -1,4 +0,0 @@
-1024 7705271
-2048 34286851
-4096 165207491
-521 1618631
diff --git a/libtommath/logs/expt_dr.log b/libtommath/logs/expt_dr.log
deleted file mode 100644
index c6bbe07..0000000
--- a/libtommath/logs/expt_dr.log
+++ /dev/null
@@ -1,7 +0,0 @@
-532 1928550
-784 3763908
-1036 7564221
-1540 16566059
-2072 32283784
-3080 79851565
-4116 157843530
diff --git a/libtommath/logs/graphs.dem b/libtommath/logs/graphs.dem
deleted file mode 100644
index dfaf613..0000000
--- a/libtommath/logs/graphs.dem
+++ /dev/null
@@ -1,17 +0,0 @@
-set terminal png
-set size 1.75
-set ylabel "Cycles per Operation"
-set xlabel "Operand size (bits)"
-
-set output "addsub.png"
-plot 'add.log' smooth bezier title "Addition", 'sub.log' smooth bezier title "Subtraction"
-
-set output "mult.png"
-plot 'sqr.log' smooth bezier title "Squaring (without Karatsuba)", 'sqr_kara.log' smooth bezier title "Squaring (Karatsuba)", 'mult.log' smooth bezier title "Multiplication (without Karatsuba)", 'mult_kara.log' smooth bezier title "Multiplication (Karatsuba)"
-
-set output "expt.png"
-plot 'expt.log' smooth bezier title "Exptmod (Montgomery)", 'expt_dr.log' smooth bezier title "Exptmod (Dimminished Radix)", 'expt_2k.log' smooth bezier title "Exptmod (2k Reduction)"
-
-set output "invmod.png"
-plot 'invmod.log' smooth bezier title "Modular Inverse"
-
diff --git a/libtommath/logs/index.html b/libtommath/logs/index.html
deleted file mode 100644
index 8c1ed9d..0000000
--- a/libtommath/logs/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<html>
-<head>
-<title>LibTomMath Log Plots</title>
-</head>
-<body>
-
-<h1>Addition and Subtraction</h1>
-<center><img src=addsub.png></center>
-<hr>
-
-<h1>Multipliers</h1>
-<center><img src=mult.png></center>
-<hr>
-
-<h1>Exptmod</h1>
-<center><img src=expt.png></center>
-<hr>
-
-<h1>Modular Inverse</h1>
-<center><img src=invmod.png></center>
-<hr>
-
-</body>
-</html>
diff --git a/libtommath/logs/invmod.log b/libtommath/logs/invmod.log
deleted file mode 100644
index e69de29..0000000
--- a/libtommath/logs/invmod.log
+++ /dev/null
diff --git a/libtommath/logs/invmod.png b/libtommath/logs/invmod.png
deleted file mode 100644
index 9dcd7d8..0000000
--- a/libtommath/logs/invmod.png
+++ /dev/null
Binary files differ
diff --git a/libtommath/logs/mult.log b/libtommath/logs/mult.log
deleted file mode 100644
index 33563fc..0000000
--- a/libtommath/logs/mult.log
+++ /dev/null
@@ -1,84 +0,0 @@
-271 555
-390 855
-508 1161
-631 1605
-749 2117
-871 2687
-991 3329
-1108 4084
-1231 4786
-1351 5624
-1470 6392
-1586 7364
-1710 8218
-1830 9255
-1951 10217
-2067 11461
-2191 12463
-2308 13677
-2430 14800
-2551 16232
-2671 17460
-2791 18899
-2902 20247
-3028 21902
-3151 23240
-3267 24927
-3391 26441
-3511 28277
-3631 29838
-3749 31751
-3869 33673
-3989 35431
-4111 37518
-4231 39426
-4349 41504
-4471 43567
-4591 45786
-4711 47876
-4831 50299
-4951 52427
-5071 54785
-5189 57241
-5307 59730
-5431 62194
-5551 64761
-5670 67322
-5789 70073
-5907 72663
-6030 75437
-6151 78242
-6268 81202
-6389 83948
-6509 86985
-6631 89903
-6747 93184
-6869 96044
-6991 99286
-7109 102395
-7229 105917
-7351 108940
-7470 112490
-7589 115702
-7711 119508
-7831 122632
-7951 126410
-8071 129808
-8190 133895
-8311 137146
-8431 141218
-8549 144732
-8667 149131
-8790 152462
-8911 156754
-9030 160479
-9149 165138
-9271 168601
-9391 173185
-9511 176988
-9627 181976
-9751 185539
-9870 190388
-9991 194335
-10110 199605
-10228 203298
diff --git a/libtommath/logs/mult.png b/libtommath/logs/mult.png
deleted file mode 100644
index d22e8c8..0000000
--- a/libtommath/logs/mult.png
+++ /dev/null
Binary files differ
diff --git a/libtommath/logs/mult_kara.log b/libtommath/logs/mult_kara.log
deleted file mode 100644
index 7136c79..0000000
--- a/libtommath/logs/mult_kara.log
+++ /dev/null
@@ -1,84 +0,0 @@
-271 560
-391 870
-511 1159
-631 1605
-750 2111
-871 2737
-991 3361
-1111 4054
-1231 4778
-1351 5600
-1471 6404
-1591 7323
-1710 8255
-1831 9239
-1948 10257
-2070 11397
-2190 12531
-2308 13665
-2429 14870
-2550 16175
-2671 17539
-2787 18879
-2911 20350
-3031 21807
-3150 23415
-3270 24897
-3388 26567
-3511 28205
-3627 30076
-3751 31744
-3869 33657
-3991 35425
-4111 37522
-4229 39363
-4351 41503
-4470 43491
-4590 45827
-4711 47795
-4828 50166
-4951 52318
-5070 54911
-5191 57036
-5308 58237
-5431 60248
-5551 62678
-5671 64786
-5791 67294
-5908 69343
-6031 71607
-6151 74166
-6271 76590
-6391 78734
-6511 81175
-6631 83742
-6750 86403
-6868 88873
-6990 91150
-7110 94211
-7228 96922
-7351 99445
-7469 102216
-7589 104968
-7711 108113
-7827 110758
-7950 113714
-8071 116511
-8186 119643
-8310 122679
-8425 125581
-8551 128715
-8669 131778
-8788 135116
-8910 138138
-9031 141628
-9148 144754
-9268 148367
-9391 151551
-9511 155033
-9631 158652
-9751 162125
-9871 165248
-9988 168627
-10111 172427
-10231 176412
diff --git a/libtommath/logs/sqr.log b/libtommath/logs/sqr.log
deleted file mode 100644
index cd29fc5..0000000
--- a/libtommath/logs/sqr.log
+++ /dev/null
@@ -1,84 +0,0 @@
-265 562
-389 882
-509 1207
-631 1572
-750 1990
-859 2433
-991 2894
-1109 3555
-1230 4228
-1350 5018
-1471 5805
-1591 6579
-1709 7415
-1829 8329
-1949 9225
-2071 10139
-2188 11239
-2309 12178
-2431 13212
-2551 14294
-2671 15551
-2791 16512
-2911 17718
-3030 18876
-3150 20259
-3270 21374
-3391 22650
-3511 23948
-3631 25493
-3750 26756
-3870 28225
-3989 29705
-4110 31409
-4230 32834
-4351 34327
-4471 35818
-4591 37636
-4711 39228
-4830 40868
-4949 42393
-5070 44541
-5191 46269
-5310 48162
-5429 49728
-5548 51985
-5671 53948
-5791 55885
-5910 57584
-6031 60082
-6150 62239
-6270 64309
-6390 66014
-6511 68766
-6631 71012
-6750 73172
-6871 74952
-6991 77909
-7111 80371
-7231 82666
-7351 84531
-7469 87698
-7589 90318
-7711 225384
-7830 232428
-7950 240009
-8070 246522
-8190 253662
-8310 260961
-8431 269253
-8549 275743
-8671 283769
-8789 290811
-8911 300034
-9030 306873
-9149 315085
-9270 323944
-9390 332390
-9508 337519
-9631 348986
-9749 356904
-9871 367013
-9989 373831
-10108 381033
-10230 393475
diff --git a/libtommath/logs/sqr_kara.log b/libtommath/logs/sqr_kara.log
deleted file mode 100644
index 06355a7..0000000
--- a/libtommath/logs/sqr_kara.log
+++ /dev/null
@@ -1,84 +0,0 @@
-271 560
-388 878
-511 1179
-629 1625
-751 1988
-871 2423
-989 2896
-1111 3561
-1231 4209
-1350 5015
-1470 5804
-1591 6556
-1709 7420
-1831 8263
-1951 9173
-2070 10153
-2191 11229
-2310 12167
-2431 13211
-2550 14309
-2671 15524
-2788 16525
-2910 17712
-3028 18822
-3148 20220
-3271 21343
-3391 22652
-3511 23944
-3630 25485
-3750 26778
-3868 28201
-3990 29653
-4111 31393
-4225 32841
-4350 34328
-4471 35786
-4590 37652
-4711 39245
-4830 40876
-4951 42433
-5068 44547
-5191 46321
-5311 48140
-5430 49727
-5550 52034
-5671 53954
-5791 55921
-5908 57597
-6031 60084
-6148 62226
-6270 64295
-6390 66045
-6511 68779
-6629 71003
-6751 73169
-6871 74992
-6991 77895
-7110 80376
-7231 82628
-7351 84468
-7470 87664
-7591 90284
-7711 91352
-7828 93995
-7950 96276
-8071 98691
-8190 101256
-8308 103631
-8431 105222
-8550 108343
-8671 110281
-8787 112764
-8911 115397
-9031 117690
-9151 120266
-9271 122715
-9391 124624
-9510 127937
-9630 130313
-9750 132914
-9871 136129
-9991 138517
-10108 141525
-10231 144225
diff --git a/libtommath/logs/sub.log b/libtommath/logs/sub.log
deleted file mode 100644
index 9f84fa2..0000000
--- a/libtommath/logs/sub.log
+++ /dev/null
@@ -1,16 +0,0 @@
-480 94
-960 116
-1440 140
-1920 164
-2400 205
-2880 229
-3360 253
-3840 277
-4320 299
-4800 321
-5280 345
-5760 371
-6240 395
-6720 419
-7200 441
-7680 465
diff --git a/libtommath/makefile b/libtommath/makefile
index 70de306..f90971c 100644
--- a/libtommath/makefile
+++ b/libtommath/makefile
@@ -2,98 +2,66 @@
#
#Tom St Denis
-#version of library
-VERSION=0.42.0
-
-CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare
-
-ifndef MAKE
- MAKE=make
-endif
-
-ifndef IGNORE_SPEED
-
-#for speed
-CFLAGS += -O3 -funroll-loops
-
-#for size
-#CFLAGS += -Os
-
-#x86 optimizations [should be valid for any GCC install though]
-CFLAGS += -fomit-frame-pointer
-
-#debug
-#CFLAGS += -g3
-
-endif
-
-#install as this user
-ifndef INSTALL_GROUP
- GROUP=wheel
+ifeq ($V,1)
+silent=
else
- GROUP=$(INSTALL_GROUP)
+silent=@
endif
-ifndef INSTALL_USER
- USER=root
-else
- USER=$(INSTALL_USER)
+%.o: %.c
+ifneq ($V,1)
+ @echo " * ${CC} $@"
endif
+ ${silent} ${CC} -c ${CFLAGS} $^ -o $@
#default files to install
ifndef LIBNAME
LIBNAME=libtommath.a
endif
-default: ${LIBNAME}
-
-HEADERS=tommath.h tommath_class.h tommath_superclass.h
-
-#LIBPATH-The directory for libtommath to be installed to.
-#INCPATH-The directory to install the header files for libtommath.
-#DATAPATH-The directory to install the pdf docs.
-DESTDIR=
-LIBPATH=/usr/lib
-INCPATH=/usr/include
-DATAPATH=/usr/share/doc/libtommath/pdf
-
-OBJECTS=bncore.o bn_mp_init.o bn_mp_clear.o bn_mp_exch.o bn_mp_grow.o bn_mp_shrink.o \
-bn_mp_clamp.o bn_mp_zero.o bn_mp_set.o bn_mp_set_int.o bn_mp_init_size.o bn_mp_copy.o \
-bn_mp_init_copy.o bn_mp_abs.o bn_mp_neg.o bn_mp_cmp_mag.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_rshd.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_div_2d.o bn_mp_mul_2d.o bn_mp_div_2.o \
-bn_mp_mul_2.o bn_s_mp_add.o bn_s_mp_sub.o bn_fast_s_mp_mul_digs.o bn_s_mp_mul_digs.o \
-bn_fast_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_s_mp_sqr.o \
-bn_mp_add.o bn_mp_sub.o bn_mp_karatsuba_mul.o bn_mp_mul.o bn_mp_karatsuba_sqr.o \
-bn_mp_sqr.o bn_mp_div.o bn_mp_mod.o bn_mp_add_d.o bn_mp_sub_d.o bn_mp_mul_d.o \
-bn_mp_div_d.o bn_mp_mod_d.o bn_mp_expt_d.o bn_mp_addmod.o bn_mp_submod.o \
-bn_mp_mulmod.o bn_mp_sqrmod.o bn_mp_gcd.o bn_mp_lcm.o bn_fast_mp_invmod.o bn_mp_invmod.o \
-bn_mp_reduce.o bn_mp_montgomery_setup.o bn_fast_mp_montgomery_reduce.o bn_mp_montgomery_reduce.o \
-bn_mp_exptmod_fast.o bn_mp_exptmod.o bn_mp_2expt.o bn_mp_n_root.o bn_mp_jacobi.o bn_reverse.o \
-bn_mp_count_bits.o bn_mp_read_unsigned_bin.o bn_mp_read_signed_bin.o bn_mp_to_unsigned_bin.o \
-bn_mp_to_signed_bin.o bn_mp_unsigned_bin_size.o bn_mp_signed_bin_size.o \
-bn_mp_xor.o bn_mp_and.o bn_mp_or.o bn_mp_rand.o bn_mp_montgomery_calc_normalization.o \
-bn_mp_prime_is_divisible.o bn_prime_tab.o bn_mp_prime_fermat.o bn_mp_prime_miller_rabin.o \
-bn_mp_prime_is_prime.o bn_mp_prime_next_prime.o bn_mp_dr_reduce.o \
-bn_mp_dr_is_modulus.o bn_mp_dr_setup.o bn_mp_reduce_setup.o \
-bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_div_3.o bn_s_mp_exptmod.o \
-bn_mp_reduce_2k.o bn_mp_reduce_is_2k.o bn_mp_reduce_2k_setup.o \
-bn_mp_reduce_2k_l.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_2k_setup_l.o \
-bn_mp_radix_smap.o bn_mp_read_radix.o bn_mp_toradix.o bn_mp_radix_size.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_cnt_lsb.o bn_error.o \
-bn_mp_init_multi.o bn_mp_clear_multi.o bn_mp_exteuclid.o bn_mp_toradix_n.o \
-bn_mp_prime_random_ex.o bn_mp_get_int.o bn_mp_sqrt.o bn_mp_is_square.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \
-bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o
+coverage: LIBNAME:=-Wl,--whole-archive $(LIBNAME) -Wl,--no-whole-archive
+
+include makefile.include
+
+LCOV_ARGS=--directory .
+
+#START_INS
+OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
+bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
+bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
+bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
+bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
+bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
+bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
+bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
+bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
+bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
+bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
+bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
+bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
+bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
+bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
+bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
+bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
+bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
+bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_sqr.o bn_s_mp_sub.o
+
+#END_INS
$(LIBNAME): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS)
- ranlib $@
+ $(RANLIB) $@
#make a profiled library (takes a while!!!)
#
# This will build the library with profile generation
# then run the test demo and rebuild the library.
-#
+#
# So far I've seen improvements in the MP math
profiled:
make CFLAGS="$(CFLAGS) -fprofile-arcs -DTESTING" timing
@@ -101,35 +69,42 @@ profiled:
rm -f *.a *.o ltmtest
make CFLAGS="$(CFLAGS) -fbranch-probabilities"
-#make a single object profiled library
+#make a single object profiled library
profiled_single:
perl gen.pl
$(CC) $(CFLAGS) -fprofile-arcs -DTESTING -c mpi.c -o mpi.o
- $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -o ltmtest
+ $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o ltmtest
./ltmtest
rm -f *.o ltmtest
$(CC) $(CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) $(LIBNAME) mpi.o
- ranlib $(LIBNAME)
+ ranlib $(LIBNAME)
install: $(LIBNAME)
- install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
- install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
- install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
- install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
+ install -d $(DESTDIR)$(LIBPATH)
+ install -d $(DESTDIR)$(INCPATH)
+ install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)
+ install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
test: $(LIBNAME) demo/demo.o
- $(CC) $(CFLAGS) demo/demo.o $(LIBNAME) -o test
-
-mtest: test
- cd mtest ; $(CC) $(CFLAGS) mtest.c -o mtest
-
+ $(CC) $(CFLAGS) demo/demo.o $(LIBNAME) $(LFLAGS) -o test
+
+test_standalone: $(LIBNAME) demo/demo.o
+ $(CC) $(CFLAGS) demo/demo.o $(LIBNAME) $(LFLAGS) -o test
+
+.PHONY: mtest
+mtest:
+ cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LFLAGS) -o mtest
+
timing: $(LIBNAME)
- $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o ltmtest
+ $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o ltmtest
+
+coveralls: coverage
+ cpp-coveralls
# makes the LTM book DVI file, requires tetex, perl and makeindex [part of tetex I think]
docdvi: tommath.src
- cd pics ; MAKE=${MAKE} ${MAKE}
+ cd pics ; MAKE=${MAKE} ${MAKE}
echo "hello" > tommath.ind
perl booker.pl
latex tommath > /dev/null
@@ -139,17 +114,37 @@ docdvi: tommath.src
# poster, makes the single page PDF poster
poster: poster.tex
+ cp poster.tex poster.bak
+ touch --reference=poster.tex poster.bak
+ (printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y poster.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > poster-deterministic.tex
+ printf "%s\n" "\pdfinfo{" >> poster-deterministic.tex
+ printf "%s\n" " /CreationDate (\fixedpdfdate)" >> poster-deterministic.tex
+ printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> poster-deterministic.tex
+ cat poster.tex >> poster-deterministic.tex
+ mv poster-deterministic.tex poster.tex
+ touch --reference=poster.bak poster.tex
pdflatex poster
- rm -f poster.aux poster.log
+ sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' poster.pdf
+ mv poster.bak poster.tex
+ rm -f poster.aux poster.log poster.out
# makes the LTM book PDF file, requires tetex, cleans up the LaTeX temp files
docs: docdvi
dvipdf tommath
rm -f tommath.log tommath.aux tommath.dvi tommath.idx tommath.toc tommath.lof tommath.ind tommath.ilg
cd pics ; MAKE=${MAKE} ${MAKE} clean
-
+
#LTM user manual
mandvi: bn.tex
+ cp bn.tex bn.bak
+ touch --reference=bn.tex bn.bak
+ (printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y bn.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > bn-deterministic.tex
+ printf "%s\n" "\pdfinfo{" >> bn-deterministic.tex
+ printf "%s\n" " /CreationDate (\fixedpdfdate)" >> bn-deterministic.tex
+ printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> bn-deterministic.tex
+ cat bn.tex >> bn-deterministic.tex
+ mv bn-deterministic.tex bn.tex
+ touch --reference=bn.bak bn.tex
echo "hello" > bn.ind
latex bn > /dev/null
latex bn > /dev/null
@@ -159,28 +154,36 @@ mandvi: bn.tex
#LTM user manual [pdf]
manual: mandvi
pdflatex bn >/dev/null
+ sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' bn.pdf
+ mv bn.bak bn.tex
rm -f bn.aux bn.dvi bn.log bn.idx bn.lof bn.out bn.toc
-pretty:
+pretty:
perl pretty.build
-clean:
- rm -f *.bat *.pdf *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
- *.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la
- rm -rf .libs
- cd etc ; MAKE=${MAKE} ${MAKE} clean
- cd pics ; MAKE=${MAKE} ${MAKE} clean
-
-#zipup the project (take that!)
+#\zipup the project (take that!)
no_oops: clean
- cd .. ; cvs commit
+ cd .. ; cvs commit
echo Scanning for scratch/dirty files
find . -type f | grep -v CVS | xargs -n 1 bash mess.sh
-zipup: clean manual poster docs
- perl gen.pl ; mv mpi.c pre_gen/ ; \
- cd .. ; rm -rf ltm* libtommath-$(VERSION) ; mkdir libtommath-$(VERSION) ; \
- cp -R ./libtommath/* ./libtommath-$(VERSION)/ ; \
- tar -c libtommath-$(VERSION)/* | bzip2 -9vvc > ltm-$(VERSION).tar.bz2 ; \
- zip -9 -r ltm-$(VERSION).zip libtommath-$(VERSION)/* ; \
- mv -f ltm* ~ ; rm -rf libtommath-$(VERSION)
+.PHONY: pre_gen
+pre_gen:
+ perl gen.pl
+ sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
+ rm mpi.c
+
+zipup:
+ rm -rf ../libtommath-$(VERSION) \
+ && rm -f ../ltm-$(VERSION).zip ../ltm-$(VERSION).zip.asc ../ltm-$(VERSION).tar.xz ../ltm-$(VERSION).tar.xz.asc
+ git archive HEAD --prefix=libtommath-$(VERSION)/ > ../libtommath-$(VERSION).tar
+ cd .. ; tar xf libtommath-$(VERSION).tar
+ MAKE=${MAKE} ${MAKE} -C ../libtommath-$(VERSION) clean manual poster docs
+ tar -c ../libtommath-$(VERSION)/* | xz -9 > ../ltm-$(VERSION).tar.xz
+ find ../libtommath-$(VERSION)/ -type f -exec unix2dos -q {} \;
+ cd .. ; zip -9r ltm-$(VERSION).zip libtommath-$(VERSION)
+ gpg -b -a ../ltm-$(VERSION).tar.xz && gpg -b -a ../ltm-$(VERSION).zip
+
+new_file:
+ bash updatemakes.sh
+ perl dep.pl
diff --git a/libtommath/makefile.bcc b/libtommath/makefile.bcc
index 67743d9..a0cfd74 100644
--- a/libtommath/makefile.bcc
+++ b/libtommath/makefile.bcc
@@ -7,33 +7,35 @@ LIB = tlib
CC = bcc32
CFLAGS = -c -O2 -I.
-OBJECTS=bncore.obj bn_mp_init.obj bn_mp_clear.obj bn_mp_exch.obj bn_mp_grow.obj bn_mp_shrink.obj \
-bn_mp_clamp.obj bn_mp_zero.obj bn_mp_set.obj bn_mp_set_int.obj bn_mp_init_size.obj bn_mp_copy.obj \
-bn_mp_init_copy.obj bn_mp_abs.obj bn_mp_neg.obj bn_mp_cmp_mag.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
-bn_mp_rshd.obj bn_mp_lshd.obj bn_mp_mod_2d.obj bn_mp_div_2d.obj bn_mp_mul_2d.obj bn_mp_div_2.obj \
-bn_mp_mul_2.obj bn_s_mp_add.obj bn_s_mp_sub.obj bn_fast_s_mp_mul_digs.obj bn_s_mp_mul_digs.obj \
-bn_fast_s_mp_mul_high_digs.obj bn_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_s_mp_sqr.obj \
-bn_mp_add.obj bn_mp_sub.obj bn_mp_karatsuba_mul.obj bn_mp_mul.obj bn_mp_karatsuba_sqr.obj \
-bn_mp_sqr.obj bn_mp_div.obj bn_mp_mod.obj bn_mp_add_d.obj bn_mp_sub_d.obj bn_mp_mul_d.obj \
-bn_mp_div_d.obj bn_mp_mod_d.obj bn_mp_expt_d.obj bn_mp_addmod.obj bn_mp_submod.obj \
-bn_mp_mulmod.obj bn_mp_sqrmod.obj bn_mp_gcd.obj bn_mp_lcm.obj bn_fast_mp_invmod.obj bn_mp_invmod.obj \
-bn_mp_reduce.obj bn_mp_montgomery_setup.obj bn_fast_mp_montgomery_reduce.obj bn_mp_montgomery_reduce.obj \
-bn_mp_exptmod_fast.obj bn_mp_exptmod.obj bn_mp_2expt.obj bn_mp_n_root.obj bn_mp_jacobi.obj bn_reverse.obj \
-bn_mp_count_bits.obj bn_mp_read_unsigned_bin.obj bn_mp_read_signed_bin.obj bn_mp_to_unsigned_bin.obj \
-bn_mp_to_signed_bin.obj bn_mp_unsigned_bin_size.obj bn_mp_signed_bin_size.obj \
-bn_mp_xor.obj bn_mp_and.obj bn_mp_or.obj bn_mp_rand.obj bn_mp_montgomery_calc_normalization.obj \
-bn_mp_prime_is_divisible.obj bn_prime_tab.obj bn_mp_prime_fermat.obj bn_mp_prime_miller_rabin.obj \
-bn_mp_prime_is_prime.obj bn_mp_prime_next_prime.obj bn_mp_dr_reduce.obj \
-bn_mp_dr_is_modulus.obj bn_mp_dr_setup.obj bn_mp_reduce_setup.obj \
-bn_mp_toom_mul.obj bn_mp_toom_sqr.obj bn_mp_div_3.obj bn_s_mp_exptmod.obj \
-bn_mp_reduce_2k.obj bn_mp_reduce_is_2k.obj bn_mp_reduce_2k_setup.obj \
-bn_mp_reduce_2k_l.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_2k_setup_l.obj \
-bn_mp_radix_smap.obj bn_mp_read_radix.obj bn_mp_toradix.obj bn_mp_radix_size.obj \
-bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_cnt_lsb.obj bn_error.obj \
-bn_mp_init_multi.obj bn_mp_clear_multi.obj bn_mp_exteuclid.obj bn_mp_toradix_n.obj \
-bn_mp_prime_random_ex.obj bn_mp_get_int.obj bn_mp_sqrt.obj bn_mp_is_square.obj \
-bn_mp_init_set.obj bn_mp_init_set_int.obj bn_mp_invmod_slow.obj bn_mp_prime_rabin_miller_trials.obj \
-bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin_n.obj
+#START_INS
+OBJECTS=bncore.obj bn_error.obj bn_fast_mp_invmod.obj bn_fast_mp_montgomery_reduce.obj bn_fast_s_mp_mul_digs.obj \
+bn_fast_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
+bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
+bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj bn_mp_div_2d.obj bn_mp_div_3.obj \
+bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj bn_mp_exch.obj \
+bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj \
+bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj bn_mp_get_long.obj bn_mp_get_long_long.obj \
+bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj bn_mp_init_multi.obj bn_mp_init_set.obj \
+bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_invmod_slow.obj bn_mp_is_square.obj \
+bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj \
+bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj \
+bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_neg.obj \
+bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj bn_mp_prime_is_divisible.obj \
+bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
+bn_mp_prime_rabin_miller_trials.obj bn_mp_prime_random_ex.obj bn_mp_radix_size.obj bn_mp_radix_smap.obj \
+bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj bn_mp_read_unsigned_bin.obj bn_mp_reduce_2k.obj \
+bn_mp_reduce_2k_l.obj bn_mp_reduce_2k_setup.obj bn_mp_reduce_2k_setup_l.obj bn_mp_reduce.obj \
+bn_mp_reduce_is_2k.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_setup.obj bn_mp_rshd.obj bn_mp_set.obj bn_mp_set_int.obj \
+bn_mp_set_long.obj bn_mp_set_long_long.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj bn_mp_sqr.obj bn_mp_sqrmod.obj \
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_toom_mul.obj \
+bn_mp_toom_sqr.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj \
+bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj \
+bn_prime_tab.obj bn_reverse.obj bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj \
+bn_s_mp_sqr.obj bn_s_mp_sub.obj
+
+#END_INS
+
+HEADERS=tommath.h tommath_class.h tommath_superclass.h
TARGET = libtommath.lib
diff --git a/libtommath/makefile.cygwin_dll b/libtommath/makefile.cygwin_dll
index 85b10c7..59acad3 100644
--- a/libtommath/makefile.cygwin_dll
+++ b/libtommath/makefile.cygwin_dll
@@ -8,37 +8,39 @@
CFLAGS += -I./ -Wall -W -Wshadow -O3 -funroll-loops -mno-cygwin
#x86 optimizations [should be valid for any GCC install though]
-CFLAGS += -fomit-frame-pointer
+CFLAGS += -fomit-frame-pointer
default: windll
-OBJECTS=bncore.o bn_mp_init.o bn_mp_clear.o bn_mp_exch.o bn_mp_grow.o bn_mp_shrink.o \
-bn_mp_clamp.o bn_mp_zero.o bn_mp_set.o bn_mp_set_int.o bn_mp_init_size.o bn_mp_copy.o \
-bn_mp_init_copy.o bn_mp_abs.o bn_mp_neg.o bn_mp_cmp_mag.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_rshd.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_div_2d.o bn_mp_mul_2d.o bn_mp_div_2.o \
-bn_mp_mul_2.o bn_s_mp_add.o bn_s_mp_sub.o bn_fast_s_mp_mul_digs.o bn_s_mp_mul_digs.o \
-bn_fast_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_s_mp_sqr.o \
-bn_mp_add.o bn_mp_sub.o bn_mp_karatsuba_mul.o bn_mp_mul.o bn_mp_karatsuba_sqr.o \
-bn_mp_sqr.o bn_mp_div.o bn_mp_mod.o bn_mp_add_d.o bn_mp_sub_d.o bn_mp_mul_d.o \
-bn_mp_div_d.o bn_mp_mod_d.o bn_mp_expt_d.o bn_mp_addmod.o bn_mp_submod.o \
-bn_mp_mulmod.o bn_mp_sqrmod.o bn_mp_gcd.o bn_mp_lcm.o bn_fast_mp_invmod.o bn_mp_invmod.o \
-bn_mp_reduce.o bn_mp_montgomery_setup.o bn_fast_mp_montgomery_reduce.o bn_mp_montgomery_reduce.o \
-bn_mp_exptmod_fast.o bn_mp_exptmod.o bn_mp_2expt.o bn_mp_n_root.o bn_mp_jacobi.o bn_reverse.o \
-bn_mp_count_bits.o bn_mp_read_unsigned_bin.o bn_mp_read_signed_bin.o bn_mp_to_unsigned_bin.o \
-bn_mp_to_signed_bin.o bn_mp_unsigned_bin_size.o bn_mp_signed_bin_size.o \
-bn_mp_xor.o bn_mp_and.o bn_mp_or.o bn_mp_rand.o bn_mp_montgomery_calc_normalization.o \
-bn_mp_prime_is_divisible.o bn_prime_tab.o bn_mp_prime_fermat.o bn_mp_prime_miller_rabin.o \
-bn_mp_prime_is_prime.o bn_mp_prime_next_prime.o bn_mp_dr_reduce.o \
-bn_mp_dr_is_modulus.o bn_mp_dr_setup.o bn_mp_reduce_setup.o \
-bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_div_3.o bn_s_mp_exptmod.o \
-bn_mp_reduce_2k.o bn_mp_reduce_is_2k.o bn_mp_reduce_2k_setup.o \
-bn_mp_reduce_2k_l.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_2k_setup_l.o \
-bn_mp_radix_smap.o bn_mp_read_radix.o bn_mp_toradix.o bn_mp_radix_size.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_cnt_lsb.o bn_error.o \
-bn_mp_init_multi.o bn_mp_clear_multi.o bn_mp_exteuclid.o bn_mp_toradix_n.o \
-bn_mp_prime_random_ex.o bn_mp_get_int.o bn_mp_sqrt.o bn_mp_is_square.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \
-bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o
+#START_INS
+OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
+bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
+bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
+bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
+bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
+bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
+bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
+bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
+bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
+bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
+bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
+bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
+bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
+bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
+bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
+bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
+bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
+bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
+bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_sqr.o bn_s_mp_sub.o
+
+#END_INS
+
+HEADERS=tommath.h tommath_class.h tommath_superclass.h
# make a Windows DLL via Cygwin
windll: $(OBJECTS)
diff --git a/libtommath/makefile.icc b/libtommath/makefile.icc
index cf70ab0..1563802 100644
--- a/libtommath/makefile.icc
+++ b/libtommath/makefile.icc
@@ -11,7 +11,7 @@ CFLAGS += -I./
# -ax? specifies make code specifically for ? but compatible with IA-32
# -x? specifies compile solely for ? [not specifically IA-32 compatible]
#
-# where ? is
+# where ? is
# K - PIII
# W - first P4 [Williamette]
# N - P4 Northwood
@@ -29,7 +29,6 @@ default: libtommath.a
#default files to install
LIBNAME=libtommath.a
-HEADERS=tommath.h
#LIBPATH-The directory for libtomcrypt to be installed to.
#INCPATH-The directory to install the header files for libtommath.
@@ -39,33 +38,35 @@ LIBPATH=/usr/lib
INCPATH=/usr/include
DATAPATH=/usr/share/doc/libtommath/pdf
-OBJECTS=bncore.o bn_mp_init.o bn_mp_clear.o bn_mp_exch.o bn_mp_grow.o bn_mp_shrink.o \
-bn_mp_clamp.o bn_mp_zero.o bn_mp_set.o bn_mp_set_int.o bn_mp_init_size.o bn_mp_copy.o \
-bn_mp_init_copy.o bn_mp_abs.o bn_mp_neg.o bn_mp_cmp_mag.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_rshd.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_div_2d.o bn_mp_mul_2d.o bn_mp_div_2.o \
-bn_mp_mul_2.o bn_s_mp_add.o bn_s_mp_sub.o bn_fast_s_mp_mul_digs.o bn_s_mp_mul_digs.o \
-bn_fast_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_s_mp_sqr.o \
-bn_mp_add.o bn_mp_sub.o bn_mp_karatsuba_mul.o bn_mp_mul.o bn_mp_karatsuba_sqr.o \
-bn_mp_sqr.o bn_mp_div.o bn_mp_mod.o bn_mp_add_d.o bn_mp_sub_d.o bn_mp_mul_d.o \
-bn_mp_div_d.o bn_mp_mod_d.o bn_mp_expt_d.o bn_mp_addmod.o bn_mp_submod.o \
-bn_mp_mulmod.o bn_mp_sqrmod.o bn_mp_gcd.o bn_mp_lcm.o bn_fast_mp_invmod.o bn_mp_invmod.o \
-bn_mp_reduce.o bn_mp_montgomery_setup.o bn_fast_mp_montgomery_reduce.o bn_mp_montgomery_reduce.o \
-bn_mp_exptmod_fast.o bn_mp_exptmod.o bn_mp_2expt.o bn_mp_n_root.o bn_mp_jacobi.o bn_reverse.o \
-bn_mp_count_bits.o bn_mp_read_unsigned_bin.o bn_mp_read_signed_bin.o bn_mp_to_unsigned_bin.o \
-bn_mp_to_signed_bin.o bn_mp_unsigned_bin_size.o bn_mp_signed_bin_size.o \
-bn_mp_xor.o bn_mp_and.o bn_mp_or.o bn_mp_rand.o bn_mp_montgomery_calc_normalization.o \
-bn_mp_prime_is_divisible.o bn_prime_tab.o bn_mp_prime_fermat.o bn_mp_prime_miller_rabin.o \
-bn_mp_prime_is_prime.o bn_mp_prime_next_prime.o bn_mp_dr_reduce.o \
-bn_mp_dr_is_modulus.o bn_mp_dr_setup.o bn_mp_reduce_setup.o \
-bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_div_3.o bn_s_mp_exptmod.o \
-bn_mp_reduce_2k.o bn_mp_reduce_is_2k.o bn_mp_reduce_2k_setup.o \
-bn_mp_reduce_2k_l.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_2k_setup_l.o \
-bn_mp_radix_smap.o bn_mp_read_radix.o bn_mp_toradix.o bn_mp_radix_size.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_cnt_lsb.o bn_error.o \
-bn_mp_init_multi.o bn_mp_clear_multi.o bn_mp_exteuclid.o bn_mp_toradix_n.o \
-bn_mp_prime_random_ex.o bn_mp_get_int.o bn_mp_sqrt.o bn_mp_is_square.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \
-bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o
+#START_INS
+OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
+bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
+bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
+bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
+bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
+bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
+bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
+bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
+bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
+bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
+bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
+bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
+bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
+bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
+bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
+bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
+bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
+bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
+bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_sqr.o bn_s_mp_sub.o
+
+#END_INS
+
+HEADERS=tommath.h tommath_class.h tommath_superclass.h
libtommath.a: $(OBJECTS)
$(AR) $(ARFLAGS) libtommath.a $(OBJECTS)
@@ -75,7 +76,7 @@ libtommath.a: $(OBJECTS)
#
# This will build the library with profile generation
# then run the test demo and rebuild the library.
-#
+#
# So far I've seen improvements in the MP math
profiled:
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_gen -DTESTING" timing
@@ -83,7 +84,7 @@ profiled:
rm -f *.a *.o ltmtest
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_use"
-#make a single object profiled library
+#make a single object profiled library
profiled_single:
perl gen.pl
$(CC) $(CFLAGS) -prof_gen -DTESTING -c mpi.c -o mpi.o
@@ -92,7 +93,7 @@ profiled_single:
rm -f *.o ltmtest
$(CC) $(CFLAGS) -prof_use -ip -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) libtommath.a mpi.o
- ranlib libtommath.a
+ ranlib libtommath.a
install: libtommath.a
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
@@ -102,10 +103,10 @@ install: libtommath.a
test: libtommath.a demo/demo.o
$(CC) demo/demo.o libtommath.a -o test
-
-mtest: test
+
+mtest: test
cd mtest ; $(CC) $(CFLAGS) mtest.c -o mtest
-
+
timing: libtommath.a
$(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o ltmtest
diff --git a/libtommath/makefile.include b/libtommath/makefile.include
new file mode 100644
index 0000000..c862f0f
--- /dev/null
+++ b/libtommath/makefile.include
@@ -0,0 +1,105 @@
+#
+# Include makefile for libtommath
+#
+
+#version of library
+VERSION=1.0
+VERSION_SO=1:0
+
+# default make target
+default: ${LIBNAME}
+
+# Compiler and Linker Names
+ifndef PREFIX
+ PREFIX=
+endif
+
+ifeq ($(CC),cc)
+ CC = $(PREFIX)gcc
+endif
+LD=$(PREFIX)ld
+AR=$(PREFIX)ar
+RANLIB=$(PREFIX)ranlib
+
+ifndef MAKE
+ MAKE=make
+endif
+
+CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
+
+ifndef NO_ADDTL_WARNINGS
+# additional warnings
+CFLAGS += -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
+CFLAGS += -Wstrict-prototypes -Wpointer-arith
+endif
+
+ifdef COMPILE_DEBUG
+#debug
+CFLAGS += -g3
+else
+
+ifdef COMPILE_SIZE
+#for size
+CFLAGS += -Os
+else
+
+ifndef IGNORE_SPEED
+#for speed
+CFLAGS += -O3 -funroll-loops
+
+#x86 optimizations [should be valid for any GCC install though]
+CFLAGS += -fomit-frame-pointer
+endif
+
+endif # COMPILE_SIZE
+endif # COMPILE_DEBUG
+
+# adjust coverage set
+ifneq ($(filter $(shell arch), i386 i686 x86_64 amd64 ia64),)
+ COVERAGE = test_standalone timing
+ COVERAGE_APP = ./test && ./ltmtest
+else
+ COVERAGE = test_standalone
+ COVERAGE_APP = ./test
+endif
+
+HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h
+HEADERS=tommath_private.h $(HEADERS_PUB)
+
+test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
+
+#LIBPATH-The directory for libtommath to be installed to.
+#INCPATH-The directory to install the header files for libtommath.
+#DATAPATH-The directory to install the pdf docs.
+LIBPATH?=/usr/lib
+INCPATH?=/usr/include
+DATAPATH?=/usr/share/doc/libtommath/pdf
+
+#make the code coverage of the library
+#
+coverage: CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
+coverage: LFLAGS += -lgcov
+coverage: LDFLAGS += -lgcov
+
+coverage: $(COVERAGE)
+ $(COVERAGE_APP)
+
+lcov: coverage
+ rm -f coverage.info
+ lcov --capture --no-external --no-recursion $(LCOV_ARGS) --output-file coverage.info -q
+ genhtml coverage.info --output-directory coverage -q
+
+# target that removes all coverage output
+cleancov-clean:
+ rm -f `find . -type f -name "*.info" | xargs`
+ rm -rf coverage/
+
+# cleans everything - coverage output and standard 'clean'
+cleancov: cleancov-clean clean
+
+clean:
+ rm -f *.gcda *.gcno *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
+ *.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la
+ rm -rf .libs/
+ cd etc ; MAKE=${MAKE} ${MAKE} clean
+ cd pics ; MAKE=${MAKE} ${MAKE} clean
diff --git a/libtommath/makefile.msvc b/libtommath/makefile.msvc
index 5edebec..a47aadd 100644
--- a/libtommath/makefile.msvc
+++ b/libtommath/makefile.msvc
@@ -6,33 +6,33 @@ CFLAGS = /I. /Ox /DWIN32 /W3 /Fo$@
default: library
-OBJECTS=bncore.obj bn_mp_init.obj bn_mp_clear.obj bn_mp_exch.obj bn_mp_grow.obj bn_mp_shrink.obj \
-bn_mp_clamp.obj bn_mp_zero.obj bn_mp_set.obj bn_mp_set_int.obj bn_mp_init_size.obj bn_mp_copy.obj \
-bn_mp_init_copy.obj bn_mp_abs.obj bn_mp_neg.obj bn_mp_cmp_mag.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
-bn_mp_rshd.obj bn_mp_lshd.obj bn_mp_mod_2d.obj bn_mp_div_2d.obj bn_mp_mul_2d.obj bn_mp_div_2.obj \
-bn_mp_mul_2.obj bn_s_mp_add.obj bn_s_mp_sub.obj bn_fast_s_mp_mul_digs.obj bn_s_mp_mul_digs.obj \
-bn_fast_s_mp_mul_high_digs.obj bn_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_s_mp_sqr.obj \
-bn_mp_add.obj bn_mp_sub.obj bn_mp_karatsuba_mul.obj bn_mp_mul.obj bn_mp_karatsuba_sqr.obj \
-bn_mp_sqr.obj bn_mp_div.obj bn_mp_mod.obj bn_mp_add_d.obj bn_mp_sub_d.obj bn_mp_mul_d.obj \
-bn_mp_div_d.obj bn_mp_mod_d.obj bn_mp_expt_d.obj bn_mp_addmod.obj bn_mp_submod.obj \
-bn_mp_mulmod.obj bn_mp_sqrmod.obj bn_mp_gcd.obj bn_mp_lcm.obj bn_fast_mp_invmod.obj bn_mp_invmod.obj \
-bn_mp_reduce.obj bn_mp_montgomery_setup.obj bn_fast_mp_montgomery_reduce.obj bn_mp_montgomery_reduce.obj \
-bn_mp_exptmod_fast.obj bn_mp_exptmod.obj bn_mp_2expt.obj bn_mp_n_root.obj bn_mp_jacobi.obj bn_reverse.obj \
-bn_mp_count_bits.obj bn_mp_read_unsigned_bin.obj bn_mp_read_signed_bin.obj bn_mp_to_unsigned_bin.obj \
-bn_mp_to_signed_bin.obj bn_mp_unsigned_bin_size.obj bn_mp_signed_bin_size.obj \
-bn_mp_xor.obj bn_mp_and.obj bn_mp_or.obj bn_mp_rand.obj bn_mp_montgomery_calc_normalization.obj \
-bn_mp_prime_is_divisible.obj bn_prime_tab.obj bn_mp_prime_fermat.obj bn_mp_prime_miller_rabin.obj \
-bn_mp_prime_is_prime.obj bn_mp_prime_next_prime.obj bn_mp_dr_reduce.obj \
-bn_mp_dr_is_modulus.obj bn_mp_dr_setup.obj bn_mp_reduce_setup.obj \
-bn_mp_toom_mul.obj bn_mp_toom_sqr.obj bn_mp_div_3.obj bn_s_mp_exptmod.obj \
-bn_mp_reduce_2k.obj bn_mp_reduce_is_2k.obj bn_mp_reduce_2k_setup.obj \
-bn_mp_reduce_2k_l.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_2k_setup_l.obj \
-bn_mp_radix_smap.obj bn_mp_read_radix.obj bn_mp_toradix.obj bn_mp_radix_size.obj \
-bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_cnt_lsb.obj bn_error.obj \
-bn_mp_init_multi.obj bn_mp_clear_multi.obj bn_mp_exteuclid.obj bn_mp_toradix_n.obj \
-bn_mp_prime_random_ex.obj bn_mp_get_int.obj bn_mp_sqrt.obj bn_mp_is_square.obj \
-bn_mp_init_set.obj bn_mp_init_set_int.obj bn_mp_invmod_slow.obj bn_mp_prime_rabin_miller_trials.obj \
-bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin_n.obj
+#START_INS
+OBJECTS=bncore.obj bn_error.obj bn_fast_mp_invmod.obj bn_fast_mp_montgomery_reduce.obj bn_fast_s_mp_mul_digs.obj \
+bn_fast_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
+bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
+bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj bn_mp_div_2d.obj bn_mp_div_3.obj \
+bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj bn_mp_exch.obj \
+bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj \
+bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj bn_mp_get_long.obj bn_mp_get_long_long.obj \
+bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj bn_mp_init_multi.obj bn_mp_init_set.obj \
+bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_invmod_slow.obj bn_mp_is_square.obj \
+bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj \
+bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj \
+bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_neg.obj \
+bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj bn_mp_prime_is_divisible.obj \
+bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
+bn_mp_prime_rabin_miller_trials.obj bn_mp_prime_random_ex.obj bn_mp_radix_size.obj bn_mp_radix_smap.obj \
+bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj bn_mp_read_unsigned_bin.obj bn_mp_reduce_2k.obj \
+bn_mp_reduce_2k_l.obj bn_mp_reduce_2k_setup.obj bn_mp_reduce_2k_setup_l.obj bn_mp_reduce.obj \
+bn_mp_reduce_is_2k.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_setup.obj bn_mp_rshd.obj bn_mp_set.obj bn_mp_set_int.obj \
+bn_mp_set_long.obj bn_mp_set_long_long.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj bn_mp_sqr.obj bn_mp_sqrmod.obj \
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_toom_mul.obj \
+bn_mp_toom_sqr.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj \
+bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj \
+bn_prime_tab.obj bn_reverse.obj bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj \
+bn_s_mp_sqr.obj bn_s_mp_sub.obj
+
+#END_INS
HEADERS=tommath.h tommath_class.h tommath_superclass.h
diff --git a/libtommath/makefile.shared b/libtommath/makefile.shared
index f17bbbd..559720e 100644
--- a/libtommath/makefile.shared
+++ b/libtommath/makefile.shared
@@ -1,102 +1,71 @@
#Makefile for GCC
#
#Tom St Denis
-VERSION=0:41
-
-CC = libtool --mode=compile --tag=CC gcc
-
-CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare
-
-ifndef IGNORE_SPEED
-
-#for speed
-CFLAGS += -O3 -funroll-loops
-
-#for size
-#CFLAGS += -Os
-
-#x86 optimizations [should be valid for any GCC install though]
-CFLAGS += -fomit-frame-pointer
-
-endif
-
-#install as this user
-ifndef INSTALL_GROUP
- GROUP=wheel
-else
- GROUP=$(INSTALL_GROUP)
-endif
-
-ifndef INSTALL_USER
- USER=root
-else
- USER=$(INSTALL_USER)
-endif
-
-default: libtommath.la
#default files to install
ifndef LIBNAME
LIBNAME=libtommath.la
endif
-ifndef LIBNAME_S
- LIBNAME_S=libtommath.a
-endif
-HEADERS=tommath.h tommath_class.h tommath_superclass.h
-
-#LIBPATH-The directory for libtommath to be installed to.
-#INCPATH-The directory to install the header files for libtommath.
-#DATAPATH-The directory to install the pdf docs.
-DESTDIR=
-LIBPATH=/usr/lib
-INCPATH=/usr/include
-DATAPATH=/usr/share/doc/libtommath/pdf
-OBJECTS=bncore.o bn_mp_init.o bn_mp_clear.o bn_mp_exch.o bn_mp_grow.o bn_mp_shrink.o \
-bn_mp_clamp.o bn_mp_zero.o bn_mp_set.o bn_mp_set_int.o bn_mp_init_size.o bn_mp_copy.o \
-bn_mp_init_copy.o bn_mp_abs.o bn_mp_neg.o bn_mp_cmp_mag.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_rshd.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_div_2d.o bn_mp_mul_2d.o bn_mp_div_2.o \
-bn_mp_mul_2.o bn_s_mp_add.o bn_s_mp_sub.o bn_fast_s_mp_mul_digs.o bn_s_mp_mul_digs.o \
-bn_fast_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_s_mp_sqr.o \
-bn_mp_add.o bn_mp_sub.o bn_mp_karatsuba_mul.o bn_mp_mul.o bn_mp_karatsuba_sqr.o \
-bn_mp_sqr.o bn_mp_div.o bn_mp_mod.o bn_mp_add_d.o bn_mp_sub_d.o bn_mp_mul_d.o \
-bn_mp_div_d.o bn_mp_mod_d.o bn_mp_expt_d.o bn_mp_addmod.o bn_mp_submod.o \
-bn_mp_mulmod.o bn_mp_sqrmod.o bn_mp_gcd.o bn_mp_lcm.o bn_fast_mp_invmod.o bn_mp_invmod.o \
-bn_mp_reduce.o bn_mp_montgomery_setup.o bn_fast_mp_montgomery_reduce.o bn_mp_montgomery_reduce.o \
-bn_mp_exptmod_fast.o bn_mp_exptmod.o bn_mp_2expt.o bn_mp_n_root.o bn_mp_jacobi.o bn_reverse.o \
-bn_mp_count_bits.o bn_mp_read_unsigned_bin.o bn_mp_read_signed_bin.o bn_mp_to_unsigned_bin.o \
-bn_mp_to_signed_bin.o bn_mp_unsigned_bin_size.o bn_mp_signed_bin_size.o \
-bn_mp_xor.o bn_mp_and.o bn_mp_or.o bn_mp_rand.o bn_mp_montgomery_calc_normalization.o \
-bn_mp_prime_is_divisible.o bn_prime_tab.o bn_mp_prime_fermat.o bn_mp_prime_miller_rabin.o \
-bn_mp_prime_is_prime.o bn_mp_prime_next_prime.o bn_mp_dr_reduce.o \
-bn_mp_dr_is_modulus.o bn_mp_dr_setup.o bn_mp_reduce_setup.o \
-bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_div_3.o bn_s_mp_exptmod.o \
-bn_mp_reduce_2k.o bn_mp_reduce_is_2k.o bn_mp_reduce_2k_setup.o \
-bn_mp_reduce_2k_l.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_2k_setup_l.o \
-bn_mp_radix_smap.o bn_mp_read_radix.o bn_mp_toradix.o bn_mp_radix_size.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_cnt_lsb.o bn_error.o \
-bn_mp_init_multi.o bn_mp_clear_multi.o bn_mp_exteuclid.o bn_mp_toradix_n.o \
-bn_mp_prime_random_ex.o bn_mp_get_int.o bn_mp_sqrt.o bn_mp_is_square.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \
-bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o
+include makefile.include
+
+LT ?= libtool
+LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
+
+LCOV_ARGS=--directory .libs --directory .
+
+#START_INS
+OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
+bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
+bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
+bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
+bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
+bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
+bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
+bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
+bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
+bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
+bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
+bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
+bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
+bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
+bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
+bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
+bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
+bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
+bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_sqr.o bn_s_mp_sub.o
+
+#END_INS
objs: $(OBJECTS)
+.c.o:
+ $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
+
$(LIBNAME): $(OBJECTS)
- libtool --mode=link gcc *.lo -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION)
+ $(LT) --mode=link --tag=CC $(CC) $(LDFLAGS) *.lo -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
install: $(LIBNAME)
- install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
- libtool --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
- install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
- install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
+ install -d $(DESTDIR)$(LIBPATH)
+ install -d $(DESTDIR)$(INCPATH)
+ $(LT) --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+ install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
test: $(LIBNAME) demo/demo.o
- gcc $(CFLAGS) -c demo/demo.c -o demo/demo.o
- libtool --mode=link gcc -o test demo/demo.o $(LIBNAME_S)
-
-mtest: test
- cd mtest ; gcc $(CFLAGS) mtest.c -o mtest
-
+ $(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
+ $(LT) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+
+test_standalone: $(LIBNAME) demo/demo.o
+ $(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
+ $(LT) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+
+mtest:
+ cd mtest ; $(CC) $(CFLAGS) $(LDFLAGS) mtest.c -o mtest
+
timing: $(LIBNAME)
- gcc $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME_S) -o ltmtest
+ $(LT) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o ltmtest
diff --git a/libtommath/mess.sh b/libtommath/mess.sh
deleted file mode 100644
index bf639ce..0000000
--- a/libtommath/mess.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here" ; exit 1; fi
-
-
diff --git a/libtommath/mtest/logtab.h b/libtommath/mtest/logtab.h
deleted file mode 100644
index addd3ab..0000000
--- a/libtommath/mtest/logtab.h
+++ /dev/null
@@ -1,19 +0,0 @@
-const float s_logv_2[] = {
- 0.000000000, 0.000000000, 1.000000000, 0.630929754, /* 0 1 2 3 */
- 0.500000000, 0.430676558, 0.386852807, 0.356207187, /* 4 5 6 7 */
- 0.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8 9 10 11 */
- 0.278942946, 0.270238154, 0.262649535, 0.255958025, /* 12 13 14 15 */
- 0.250000000, 0.244650542, 0.239812467, 0.235408913, /* 16 17 18 19 */
- 0.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */
- 0.218104292, 0.215338279, 0.212746054, 0.210309918, /* 24 25 26 27 */
- 0.208014598, 0.205846832, 0.203795047, 0.201849087, /* 28 29 30 31 */
- 0.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */
- 0.193426404, 0.191958720, 0.190551412, 0.189200360, /* 36 37 38 39 */
- 0.187901825, 0.186652411, 0.185449023, 0.184288833, /* 40 41 42 43 */
- 0.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */
- 0.179052232, 0.178103594, 0.177183820, 0.176291434, /* 48 49 50 51 */
- 0.175425064, 0.174583430, 0.173765343, 0.172969690, /* 52 53 54 55 */
- 0.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */
- 0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */
- 0.166666667
-};
diff --git a/libtommath/mtest/mpi-config.h b/libtommath/mtest/mpi-config.h
deleted file mode 100644
index a347263..0000000
--- a/libtommath/mtest/mpi-config.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Default configuration for MPI library */
-
-#ifndef MPI_CONFIG_H_
-#define MPI_CONFIG_H_
-
-/*
- For boolean options,
- 0 = no
- 1 = yes
-
- Other options are documented individually.
-
- */
-
-#ifndef MP_IOFUNC
-#define MP_IOFUNC 0 /* include mp_print() ? */
-#endif
-
-#ifndef MP_MODARITH
-#define MP_MODARITH 1 /* include modular arithmetic ? */
-#endif
-
-#ifndef MP_NUMTH
-#define MP_NUMTH 1 /* include number theoretic functions? */
-#endif
-
-#ifndef MP_LOGTAB
-#define MP_LOGTAB 1 /* use table of logs instead of log()? */
-#endif
-
-#ifndef MP_MEMSET
-#define MP_MEMSET 1 /* use memset() to zero buffers? */
-#endif
-
-#ifndef MP_MEMCPY
-#define MP_MEMCPY 1 /* use memcpy() to copy buffers? */
-#endif
-
-#ifndef MP_CRYPTO
-#define MP_CRYPTO 1 /* erase memory on free? */
-#endif
-
-#ifndef MP_ARGCHK
-/*
- 0 = no parameter checks
- 1 = runtime checks, continue execution and return an error to caller
- 2 = assertions; dump core on parameter errors
- */
-#define MP_ARGCHK 2 /* how to check input arguments */
-#endif
-
-#ifndef MP_DEBUG
-#define MP_DEBUG 0 /* print diagnostic output? */
-#endif
-
-#ifndef MP_DEFPREC
-#define MP_DEFPREC 64 /* default precision, in digits */
-#endif
-
-#ifndef MP_MACRO
-#define MP_MACRO 1 /* use macros for frequent calls? */
-#endif
-
-#ifndef MP_SQUARE
-#define MP_SQUARE 1 /* use separate squaring code? */
-#endif
-
-#ifndef MP_PTAB_SIZE
-/*
- When building mpprime.c, we build in a table of small prime
- values to use for primality testing. The more you include,
- the more space they take up. See primes.c for the possible
- values (currently 16, 32, 64, 128, 256, and 6542)
- */
-#define MP_PTAB_SIZE 128 /* how many built-in primes? */
-#endif
-
-#ifndef MP_COMPAT_MACROS
-#define MP_COMPAT_MACROS 1 /* define compatibility macros? */
-#endif
-
-#endif /* ifndef MPI_CONFIG_H_ */
-
-
-/* crc==3287762869, version==2, Sat Feb 02 06:43:53 2002 */
diff --git a/libtommath/mtest/mpi-types.h b/libtommath/mtest/mpi-types.h
deleted file mode 100644
index 42ccfc3..0000000
--- a/libtommath/mtest/mpi-types.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Type definitions generated by 'types.pl' */
-typedef char mp_sign;
-typedef unsigned short mp_digit; /* 2 byte type */
-typedef unsigned int mp_word; /* 4 byte type */
-typedef unsigned int mp_size;
-typedef int mp_err;
-
-#define MP_DIGIT_BIT (CHAR_BIT*sizeof(mp_digit))
-#define MP_DIGIT_MAX USHRT_MAX
-#define MP_WORD_BIT (CHAR_BIT*sizeof(mp_word))
-#define MP_WORD_MAX UINT_MAX
-
-#define MP_DIGIT_SIZE 2
-#define DIGIT_FMT "%04X"
-#define RADIX (MP_DIGIT_MAX+1)
diff --git a/libtommath/mtest/mpi.c b/libtommath/mtest/mpi.c
deleted file mode 100644
index 4566e89..0000000
--- a/libtommath/mtest/mpi.c
+++ /dev/null
@@ -1,3979 +0,0 @@
-/*
- mpi.c
-
- by Michael J. Fromberger <sting@linguist.dartmouth.edu>
- Copyright (C) 1998 Michael J. Fromberger, All Rights Reserved
-
- Arbitrary precision integer arithmetic library
- */
-
-#include "mpi.h"
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#if MP_DEBUG
-#include <stdio.h>
-
-#define DIAG(T,V) {fprintf(stderr,T);mp_print(V,stderr);fputc('\n',stderr);}
-#else
-#define DIAG(T,V)
-#endif
-
-/*
- If MP_LOGTAB is not defined, use the math library to compute the
- logarithms on the fly. Otherwise, use the static table below.
- Pick which works best for your system.
- */
-#if MP_LOGTAB
-
-/* {{{ s_logv_2[] - log table for 2 in various bases */
-
-/*
- A table of the logs of 2 for various bases (the 0 and 1 entries of
- this table are meaningless and should not be referenced).
-
- This table is used to compute output lengths for the mp_toradix()
- function. Since a number n in radix r takes up about log_r(n)
- digits, we estimate the output size by taking the least integer
- greater than log_r(n), where:
-
- log_r(n) = log_2(n) * log_r(2)
-
- This table, therefore, is a table of log_r(2) for 2 <= r <= 36,
- which are the output bases supported.
- */
-
-#include "logtab.h"
-
-/* }}} */
-#define LOG_V_2(R) s_logv_2[(R)]
-
-#else
-
-#include <math.h>
-#define LOG_V_2(R) (log(2.0)/log(R))
-
-#endif
-
-/* Default precision for newly created mp_int's */
-static unsigned int s_mp_defprec = MP_DEFPREC;
-
-/* {{{ Digit arithmetic macros */
-
-/*
- When adding and multiplying digits, the results can be larger than
- can be contained in an mp_digit. Thus, an mp_word is used. These
- macros mask off the upper and lower digits of the mp_word (the
- mp_word may be more than 2 mp_digits wide, but we only concern
- ourselves with the low-order 2 mp_digits)
-
- If your mp_word DOES have more than 2 mp_digits, you need to
- uncomment the first line, and comment out the second.
- */
-
-/* #define CARRYOUT(W) (((W)>>DIGIT_BIT)&MP_DIGIT_MAX) */
-#define CARRYOUT(W) ((W)>>DIGIT_BIT)
-#define ACCUM(W) ((W)&MP_DIGIT_MAX)
-
-/* }}} */
-
-/* {{{ Comparison constants */
-
-#define MP_LT -1
-#define MP_EQ 0
-#define MP_GT 1
-
-/* }}} */
-
-/* {{{ Constant strings */
-
-/* Constant strings returned by mp_strerror() */
-static const char *const mp_err_string[] = {
- "unknown result code", /* say what? */
- "boolean true", /* MP_OKAY, MP_YES */
- "boolean false", /* MP_NO */
- "out of memory", /* MP_MEM */
- "argument out of range", /* MP_RANGE */
- "invalid input parameter", /* MP_BADARG */
- "result is undefined" /* MP_UNDEF */
-};
-
-/* Value to digit maps for radix conversion */
-
-/* s_dmap_1 - standard digits and letters */
-static const char *s_dmap_1 =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-
-#if 0
-/* s_dmap_2 - base64 ordering for digits */
-static const char *s_dmap_2 =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-#endif
-
-/* }}} */
-
-/* {{{ Static function declarations */
-
-/*
- If MP_MACRO is false, these will be defined as actual functions;
- otherwise, suitable macro definitions will be used. This works
- around the fact that ANSI C89 doesn't support an 'inline' keyword
- (although I hear C9x will ... about bloody time). At present, the
- macro definitions are identical to the function bodies, but they'll
- expand in place, instead of generating a function call.
-
- I chose these particular functions to be made into macros because
- some profiling showed they are called a lot on a typical workload,
- and yet they are primarily housekeeping.
- */
-#if MP_MACRO == 0
- void s_mp_setz(mp_digit *dp, mp_size count); /* zero digits */
- void s_mp_copy(mp_digit *sp, mp_digit *dp, mp_size count); /* copy */
- void *s_mp_alloc(size_t nb, size_t ni); /* general allocator */
- void s_mp_free(void *ptr); /* general free function */
-#else
-
- /* Even if these are defined as macros, we need to respect the settings
- of the MP_MEMSET and MP_MEMCPY configuration options...
- */
- #if MP_MEMSET == 0
- #define s_mp_setz(dp, count) \
- {int ix;for(ix=0;ix<(count);ix++)(dp)[ix]=0;}
- #else
- #define s_mp_setz(dp, count) memset(dp, 0, (count) * sizeof(mp_digit))
- #endif /* MP_MEMSET */
-
- #if MP_MEMCPY == 0
- #define s_mp_copy(sp, dp, count) \
- {int ix;for(ix=0;ix<(count);ix++)(dp)[ix]=(sp)[ix];}
- #else
- #define s_mp_copy(sp, dp, count) memcpy(dp, sp, (count) * sizeof(mp_digit))
- #endif /* MP_MEMCPY */
-
- #define s_mp_alloc(nb, ni) calloc(nb, ni)
- #define s_mp_free(ptr) {if(ptr) free(ptr);}
-#endif /* MP_MACRO */
-
-mp_err s_mp_grow(mp_int *mp, mp_size min); /* increase allocated size */
-mp_err s_mp_pad(mp_int *mp, mp_size min); /* left pad with zeroes */
-
-void s_mp_clamp(mp_int *mp); /* clip leading zeroes */
-
-void s_mp_exch(mp_int *a, mp_int *b); /* swap a and b in place */
-
-mp_err s_mp_lshd(mp_int *mp, mp_size p); /* left-shift by p digits */
-void s_mp_rshd(mp_int *mp, mp_size p); /* right-shift by p digits */
-void s_mp_div_2d(mp_int *mp, mp_digit d); /* divide by 2^d in place */
-void s_mp_mod_2d(mp_int *mp, mp_digit d); /* modulo 2^d in place */
-mp_err s_mp_mul_2d(mp_int *mp, mp_digit d); /* multiply by 2^d in place*/
-void s_mp_div_2(mp_int *mp); /* divide by 2 in place */
-mp_err s_mp_mul_2(mp_int *mp); /* multiply by 2 in place */
-mp_digit s_mp_norm(mp_int *a, mp_int *b); /* normalize for division */
-mp_err s_mp_add_d(mp_int *mp, mp_digit d); /* unsigned digit addition */
-mp_err s_mp_sub_d(mp_int *mp, mp_digit d); /* unsigned digit subtract */
-mp_err s_mp_mul_d(mp_int *mp, mp_digit d); /* unsigned digit multiply */
-mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r);
- /* unsigned digit divide */
-mp_err s_mp_reduce(mp_int *x, mp_int *m, mp_int *mu);
- /* Barrett reduction */
-mp_err s_mp_add(mp_int *a, mp_int *b); /* magnitude addition */
-mp_err s_mp_sub(mp_int *a, mp_int *b); /* magnitude subtract */
-mp_err s_mp_mul(mp_int *a, mp_int *b); /* magnitude multiply */
-#if 0
-void s_mp_kmul(mp_digit *a, mp_digit *b, mp_digit *out, mp_size len);
- /* multiply buffers in place */
-#endif
-#if MP_SQUARE
-mp_err s_mp_sqr(mp_int *a); /* magnitude square */
-#else
-#define s_mp_sqr(a) s_mp_mul(a, a)
-#endif
-mp_err s_mp_div(mp_int *a, mp_int *b); /* magnitude divide */
-mp_err s_mp_2expt(mp_int *a, mp_digit k); /* a = 2^k */
-int s_mp_cmp(mp_int *a, mp_int *b); /* magnitude comparison */
-int s_mp_cmp_d(mp_int *a, mp_digit d); /* magnitude digit compare */
-int s_mp_ispow2(mp_int *v); /* is v a power of 2? */
-int s_mp_ispow2d(mp_digit d); /* is d a power of 2? */
-
-int s_mp_tovalue(char ch, int r); /* convert ch to value */
-char s_mp_todigit(int val, int r, int low); /* convert val to digit */
-int s_mp_outlen(int bits, int r); /* output length in bytes */
-
-/* }}} */
-
-/* {{{ Default precision manipulation */
-
-unsigned int mp_get_prec(void)
-{
- return s_mp_defprec;
-
-} /* end mp_get_prec() */
-
-void mp_set_prec(unsigned int prec)
-{
- if(prec == 0)
- s_mp_defprec = MP_DEFPREC;
- else
- s_mp_defprec = prec;
-
-} /* end mp_set_prec() */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ mp_init(mp) */
-
-/*
- mp_init(mp)
-
- Initialize a new zero-valued mp_int. Returns MP_OKAY if successful,
- MP_MEM if memory could not be allocated for the structure.
- */
-
-mp_err mp_init(mp_int *mp)
-{
- return mp_init_size(mp, s_mp_defprec);
-
-} /* end mp_init() */
-
-/* }}} */
-
-/* {{{ mp_init_array(mp[], count) */
-
-mp_err mp_init_array(mp_int mp[], int count)
-{
- mp_err res;
- int pos;
-
- ARGCHK(mp !=NULL && count > 0, MP_BADARG);
-
- for(pos = 0; pos < count; ++pos) {
- if((res = mp_init(&mp[pos])) != MP_OKAY)
- goto CLEANUP;
- }
-
- return MP_OKAY;
-
- CLEANUP:
- while(--pos >= 0)
- mp_clear(&mp[pos]);
-
- return res;
-
-} /* end mp_init_array() */
-
-/* }}} */
-
-/* {{{ mp_init_size(mp, prec) */
-
-/*
- mp_init_size(mp, prec)
-
- Initialize a new zero-valued mp_int with at least the given
- precision; returns MP_OKAY if successful, or MP_MEM if memory could
- not be allocated for the structure.
- */
-
-mp_err mp_init_size(mp_int *mp, mp_size prec)
-{
- ARGCHK(mp != NULL && prec > 0, MP_BADARG);
-
- if((DIGITS(mp) = s_mp_alloc(prec, sizeof(mp_digit))) == NULL)
- return MP_MEM;
-
- SIGN(mp) = MP_ZPOS;
- USED(mp) = 1;
- ALLOC(mp) = prec;
-
- return MP_OKAY;
-
-} /* end mp_init_size() */
-
-/* }}} */
-
-/* {{{ mp_init_copy(mp, from) */
-
-/*
- mp_init_copy(mp, from)
-
- Initialize mp as an exact copy of from. Returns MP_OKAY if
- successful, MP_MEM if memory could not be allocated for the new
- structure.
- */
-
-mp_err mp_init_copy(mp_int *mp, mp_int *from)
-{
- ARGCHK(mp != NULL && from != NULL, MP_BADARG);
-
- if(mp == from)
- return MP_OKAY;
-
- if((DIGITS(mp) = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL)
- return MP_MEM;
-
- s_mp_copy(DIGITS(from), DIGITS(mp), USED(from));
- USED(mp) = USED(from);
- ALLOC(mp) = USED(from);
- SIGN(mp) = SIGN(from);
-
- return MP_OKAY;
-
-} /* end mp_init_copy() */
-
-/* }}} */
-
-/* {{{ mp_copy(from, to) */
-
-/*
- mp_copy(from, to)
-
- Copies the mp_int 'from' to the mp_int 'to'. It is presumed that
- 'to' has already been initialized (if not, use mp_init_copy()
- instead). If 'from' and 'to' are identical, nothing happens.
- */
-
-mp_err mp_copy(mp_int *from, mp_int *to)
-{
- ARGCHK(from != NULL && to != NULL, MP_BADARG);
-
- if(from == to)
- return MP_OKAY;
-
- { /* copy */
- mp_digit *tmp;
-
- /*
- If the allocated buffer in 'to' already has enough space to hold
- all the used digits of 'from', we'll re-use it to avoid hitting
- the memory allocater more than necessary; otherwise, we'd have
- to grow anyway, so we just allocate a hunk and make the copy as
- usual
- */
- if(ALLOC(to) >= USED(from)) {
- s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
- s_mp_copy(DIGITS(from), DIGITS(to), USED(from));
-
- } else {
- if((tmp = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL)
- return MP_MEM;
-
- s_mp_copy(DIGITS(from), tmp, USED(from));
-
- if(DIGITS(to) != NULL) {
-#if MP_CRYPTO
- s_mp_setz(DIGITS(to), ALLOC(to));
-#endif
- s_mp_free(DIGITS(to));
- }
-
- DIGITS(to) = tmp;
- ALLOC(to) = USED(from);
- }
-
- /* Copy the precision and sign from the original */
- USED(to) = USED(from);
- SIGN(to) = SIGN(from);
- } /* end copy */
-
- return MP_OKAY;
-
-} /* end mp_copy() */
-
-/* }}} */
-
-/* {{{ mp_exch(mp1, mp2) */
-
-/*
- mp_exch(mp1, mp2)
-
- Exchange mp1 and mp2 without allocating any intermediate memory
- (well, unless you count the stack space needed for this call and the
- locals it creates...). This cannot fail.
- */
-
-void mp_exch(mp_int *mp1, mp_int *mp2)
-{
-#if MP_ARGCHK == 2
- assert(mp1 != NULL && mp2 != NULL);
-#else
- if(mp1 == NULL || mp2 == NULL)
- return;
-#endif
-
- s_mp_exch(mp1, mp2);
-
-} /* end mp_exch() */
-
-/* }}} */
-
-/* {{{ mp_clear(mp) */
-
-/*
- mp_clear(mp)
-
- Release the storage used by an mp_int, and void its fields so that
- if someone calls mp_clear() again for the same int later, we won't
- get tollchocked.
- */
-
-void mp_clear(mp_int *mp)
-{
- if(mp == NULL)
- return;
-
- if(DIGITS(mp) != NULL) {
-#if MP_CRYPTO
- s_mp_setz(DIGITS(mp), ALLOC(mp));
-#endif
- s_mp_free(DIGITS(mp));
- DIGITS(mp) = NULL;
- }
-
- USED(mp) = 0;
- ALLOC(mp) = 0;
-
-} /* end mp_clear() */
-
-/* }}} */
-
-/* {{{ mp_clear_array(mp[], count) */
-
-void mp_clear_array(mp_int mp[], int count)
-{
- ARGCHK(mp != NULL && count > 0, MP_BADARG);
-
- while(--count >= 0)
- mp_clear(&mp[count]);
-
-} /* end mp_clear_array() */
-
-/* }}} */
-
-/* {{{ mp_zero(mp) */
-
-/*
- mp_zero(mp)
-
- Set mp to zero. Does not change the allocated size of the structure,
- and therefore cannot fail (except on a bad argument, which we ignore)
- */
-void mp_zero(mp_int *mp)
-{
- if(mp == NULL)
- return;
-
- s_mp_setz(DIGITS(mp), ALLOC(mp));
- USED(mp) = 1;
- SIGN(mp) = MP_ZPOS;
-
-} /* end mp_zero() */
-
-/* }}} */
-
-/* {{{ mp_set(mp, d) */
-
-void mp_set(mp_int *mp, mp_digit d)
-{
- if(mp == NULL)
- return;
-
- mp_zero(mp);
- DIGIT(mp, 0) = d;
-
-} /* end mp_set() */
-
-/* }}} */
-
-/* {{{ mp_set_int(mp, z) */
-
-mp_err mp_set_int(mp_int *mp, long z)
-{
- int ix;
- unsigned long v = abs(z);
- mp_err res;
-
- ARGCHK(mp != NULL, MP_BADARG);
-
- mp_zero(mp);
- if(z == 0)
- return MP_OKAY; /* shortcut for zero */
-
- for(ix = sizeof(long) - 1; ix >= 0; ix--) {
-
- if((res = s_mp_mul_2d(mp, CHAR_BIT)) != MP_OKAY)
- return res;
-
- res = s_mp_add_d(mp,
- (mp_digit)((v >> (ix * CHAR_BIT)) & UCHAR_MAX));
- if(res != MP_OKAY)
- return res;
-
- }
-
- if(z < 0)
- SIGN(mp) = MP_NEG;
-
- return MP_OKAY;
-
-} /* end mp_set_int() */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ Digit arithmetic */
-
-/* {{{ mp_add_d(a, d, b) */
-
-/*
- mp_add_d(a, d, b)
-
- Compute the sum b = a + d, for a single digit d. Respects the sign of
- its primary addend (single digits are unsigned anyway).
- */
-
-mp_err mp_add_d(mp_int *a, mp_digit d, mp_int *b)
-{
- mp_err res = MP_OKAY;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- if(SIGN(b) == MP_ZPOS) {
- res = s_mp_add_d(b, d);
- } else if(s_mp_cmp_d(b, d) >= 0) {
- res = s_mp_sub_d(b, d);
- } else {
- SIGN(b) = MP_ZPOS;
-
- DIGIT(b, 0) = d - DIGIT(b, 0);
- }
-
- return res;
-
-} /* end mp_add_d() */
-
-/* }}} */
-
-/* {{{ mp_sub_d(a, d, b) */
-
-/*
- mp_sub_d(a, d, b)
-
- Compute the difference b = a - d, for a single digit d. Respects the
- sign of its subtrahend (single digits are unsigned anyway).
- */
-
-mp_err mp_sub_d(mp_int *a, mp_digit d, mp_int *b)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- if(SIGN(b) == MP_NEG) {
- if((res = s_mp_add_d(b, d)) != MP_OKAY)
- return res;
-
- } else if(s_mp_cmp_d(b, d) >= 0) {
- if((res = s_mp_sub_d(b, d)) != MP_OKAY)
- return res;
-
- } else {
- mp_neg(b, b);
-
- DIGIT(b, 0) = d - DIGIT(b, 0);
- SIGN(b) = MP_NEG;
- }
-
- if(s_mp_cmp_d(b, 0) == 0)
- SIGN(b) = MP_ZPOS;
-
- return MP_OKAY;
-
-} /* end mp_sub_d() */
-
-/* }}} */
-
-/* {{{ mp_mul_d(a, d, b) */
-
-/*
- mp_mul_d(a, d, b)
-
- Compute the product b = a * d, for a single digit d. Respects the sign
- of its multiplicand (single digits are unsigned anyway)
- */
-
-mp_err mp_mul_d(mp_int *a, mp_digit d, mp_int *b)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if(d == 0) {
- mp_zero(b);
- return MP_OKAY;
- }
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- res = s_mp_mul_d(b, d);
-
- return res;
-
-} /* end mp_mul_d() */
-
-/* }}} */
-
-/* {{{ mp_mul_2(a, c) */
-
-mp_err mp_mul_2(mp_int *a, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- return s_mp_mul_2(c);
-
-} /* end mp_mul_2() */
-
-/* }}} */
-
-/* {{{ mp_div_d(a, d, q, r) */
-
-/*
- mp_div_d(a, d, q, r)
-
- Compute the quotient q = a / d and remainder r = a mod d, for a
- single digit d. Respects the sign of its divisor (single digits are
- unsigned anyway).
- */
-
-mp_err mp_div_d(mp_int *a, mp_digit d, mp_int *q, mp_digit *r)
-{
- mp_err res;
- mp_digit rem;
- int pow;
-
- ARGCHK(a != NULL, MP_BADARG);
-
- if(d == 0)
- return MP_RANGE;
-
- /* Shortcut for powers of two ... */
- if((pow = s_mp_ispow2d(d)) >= 0) {
- mp_digit mask;
-
- mask = (1 << pow) - 1;
- rem = DIGIT(a, 0) & mask;
-
- if(q) {
- mp_copy(a, q);
- s_mp_div_2d(q, pow);
- }
-
- if(r)
- *r = rem;
-
- return MP_OKAY;
- }
-
- /*
- If the quotient is actually going to be returned, we'll try to
- avoid hitting the memory allocator by copying the dividend into it
- and doing the division there. This can't be any _worse_ than
- always copying, and will sometimes be better (since it won't make
- another copy)
-
- If it's not going to be returned, we need to allocate a temporary
- to hold the quotient, which will just be discarded.
- */
- if(q) {
- if((res = mp_copy(a, q)) != MP_OKAY)
- return res;
-
- res = s_mp_div_d(q, d, &rem);
- if(s_mp_cmp_d(q, 0) == MP_EQ)
- SIGN(q) = MP_ZPOS;
-
- } else {
- mp_int qp;
-
- if((res = mp_init_copy(&qp, a)) != MP_OKAY)
- return res;
-
- res = s_mp_div_d(&qp, d, &rem);
- if(s_mp_cmp_d(&qp, 0) == 0)
- SIGN(&qp) = MP_ZPOS;
-
- mp_clear(&qp);
- }
-
- if(r)
- *r = rem;
-
- return res;
-
-} /* end mp_div_d() */
-
-/* }}} */
-
-/* {{{ mp_div_2(a, c) */
-
-/*
- mp_div_2(a, c)
-
- Compute c = a / 2, disregarding the remainder.
- */
-
-mp_err mp_div_2(mp_int *a, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- s_mp_div_2(c);
-
- return MP_OKAY;
-
-} /* end mp_div_2() */
-
-/* }}} */
-
-/* {{{ mp_expt_d(a, d, b) */
-
-mp_err mp_expt_d(mp_int *a, mp_digit d, mp_int *c)
-{
- mp_int s, x;
- mp_err res;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_init(&s)) != MP_OKAY)
- return res;
- if((res = mp_init_copy(&x, a)) != MP_OKAY)
- goto X;
-
- DIGIT(&s, 0) = 1;
-
- while(d != 0) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d >>= 1;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- s_mp_exch(&s, c);
-
-CLEANUP:
- mp_clear(&x);
-X:
- mp_clear(&s);
-
- return res;
-
-} /* end mp_expt_d() */
-
-/* }}} */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ Full arithmetic */
-
-/* {{{ mp_abs(a, b) */
-
-/*
- mp_abs(a, b)
-
- Compute b = |a|. 'a' and 'b' may be identical.
- */
-
-mp_err mp_abs(mp_int *a, mp_int *b)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- SIGN(b) = MP_ZPOS;
-
- return MP_OKAY;
-
-} /* end mp_abs() */
-
-/* }}} */
-
-/* {{{ mp_neg(a, b) */
-
-/*
- mp_neg(a, b)
-
- Compute b = -a. 'a' and 'b' may be identical.
- */
-
-mp_err mp_neg(mp_int *a, mp_int *b)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- if(s_mp_cmp_d(b, 0) == MP_EQ)
- SIGN(b) = MP_ZPOS;
- else
- SIGN(b) = (SIGN(b) == MP_NEG) ? MP_ZPOS : MP_NEG;
-
- return MP_OKAY;
-
-} /* end mp_neg() */
-
-/* }}} */
-
-/* {{{ mp_add(a, b, c) */
-
-/*
- mp_add(a, b, c)
-
- Compute c = a + b. All parameters may be identical.
- */
-
-mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_err res;
- int cmp;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- if(SIGN(a) == SIGN(b)) { /* same sign: add values, keep sign */
-
- /* Commutativity of addition lets us do this in either order,
- so we avoid having to use a temporary even if the result
- is supposed to replace the output
- */
- if(c == b) {
- if((res = s_mp_add(c, a)) != MP_OKAY)
- return res;
- } else {
- if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- if((res = s_mp_add(c, b)) != MP_OKAY)
- return res;
- }
-
- } else if((cmp = s_mp_cmp(a, b)) > 0) { /* different sign: a > b */
-
- /* If the output is going to be clobbered, we will use a temporary
- variable; otherwise, we'll do it without touching the memory
- allocator at all, if possible
- */
- if(c == b) {
- mp_int tmp;
-
- if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
- return res;
- if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
-
- s_mp_exch(&tmp, c);
- mp_clear(&tmp);
-
- } else {
-
- if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
- return res;
- if((res = s_mp_sub(c, b)) != MP_OKAY)
- return res;
-
- }
-
- } else if(cmp == 0) { /* different sign, a == b */
-
- mp_zero(c);
- return MP_OKAY;
-
- } else { /* different sign: a < b */
-
- /* See above... */
- if(c == a) {
- mp_int tmp;
-
- if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
- return res;
- if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
-
- s_mp_exch(&tmp, c);
- mp_clear(&tmp);
-
- } else {
-
- if(c != b && (res = mp_copy(b, c)) != MP_OKAY)
- return res;
- if((res = s_mp_sub(c, a)) != MP_OKAY)
- return res;
-
- }
- }
-
- if(USED(c) == 1 && DIGIT(c, 0) == 0)
- SIGN(c) = MP_ZPOS;
-
- return MP_OKAY;
-
-} /* end mp_add() */
-
-/* }}} */
-
-/* {{{ mp_sub(a, b, c) */
-
-/*
- mp_sub(a, b, c)
-
- Compute c = a - b. All parameters may be identical.
- */
-
-mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_err res;
- int cmp;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- if(SIGN(a) != SIGN(b)) {
- if(c == a) {
- if((res = s_mp_add(c, b)) != MP_OKAY)
- return res;
- } else {
- if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
- return res;
- if((res = s_mp_add(c, a)) != MP_OKAY)
- return res;
- SIGN(c) = SIGN(a);
- }
-
- } else if((cmp = s_mp_cmp(a, b)) > 0) { /* Same sign, a > b */
- if(c == b) {
- mp_int tmp;
-
- if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
- return res;
- if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
- s_mp_exch(&tmp, c);
- mp_clear(&tmp);
-
- } else {
- if(c != a && ((res = mp_copy(a, c)) != MP_OKAY))
- return res;
-
- if((res = s_mp_sub(c, b)) != MP_OKAY)
- return res;
- }
-
- } else if(cmp == 0) { /* Same sign, equal magnitude */
- mp_zero(c);
- return MP_OKAY;
-
- } else { /* Same sign, b > a */
- if(c == a) {
- mp_int tmp;
-
- if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
- return res;
-
- if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
- s_mp_exch(&tmp, c);
- mp_clear(&tmp);
-
- } else {
- if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
- return res;
-
- if((res = s_mp_sub(c, a)) != MP_OKAY)
- return res;
- }
-
- SIGN(c) = !SIGN(b);
- }
-
- if(USED(c) == 1 && DIGIT(c, 0) == 0)
- SIGN(c) = MP_ZPOS;
-
- return MP_OKAY;
-
-} /* end mp_sub() */
-
-/* }}} */
-
-/* {{{ mp_mul(a, b, c) */
-
-/*
- mp_mul(a, b, c)
-
- Compute c = a * b. All parameters may be identical.
- */
-
-mp_err mp_mul(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_err res;
- mp_sign sgn;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- sgn = (SIGN(a) == SIGN(b)) ? MP_ZPOS : MP_NEG;
-
- if(c == b) {
- if((res = s_mp_mul(c, a)) != MP_OKAY)
- return res;
-
- } else {
- if((res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- if((res = s_mp_mul(c, b)) != MP_OKAY)
- return res;
- }
-
- if(sgn == MP_ZPOS || s_mp_cmp_d(c, 0) == MP_EQ)
- SIGN(c) = MP_ZPOS;
- else
- SIGN(c) = sgn;
-
- return MP_OKAY;
-
-} /* end mp_mul() */
-
-/* }}} */
-
-/* {{{ mp_mul_2d(a, d, c) */
-
-/*
- mp_mul_2d(a, d, c)
-
- Compute c = a * 2^d. a may be the same as c.
- */
-
-mp_err mp_mul_2d(mp_int *a, mp_digit d, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- if(d == 0)
- return MP_OKAY;
-
- return s_mp_mul_2d(c, d);
-
-} /* end mp_mul() */
-
-/* }}} */
-
-/* {{{ mp_sqr(a, b) */
-
-#if MP_SQUARE
-mp_err mp_sqr(mp_int *a, mp_int *b)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if((res = mp_copy(a, b)) != MP_OKAY)
- return res;
-
- if((res = s_mp_sqr(b)) != MP_OKAY)
- return res;
-
- SIGN(b) = MP_ZPOS;
-
- return MP_OKAY;
-
-} /* end mp_sqr() */
-#endif
-
-/* }}} */
-
-/* {{{ mp_div(a, b, q, r) */
-
-/*
- mp_div(a, b, q, r)
-
- Compute q = a / b and r = a mod b. Input parameters may be re-used
- as output parameters. If q or r is NULL, that portion of the
- computation will be discarded (although it will still be computed)
-
- Pay no attention to the hacker behind the curtain.
- */
-
-mp_err mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r)
-{
- mp_err res;
- mp_int qtmp, rtmp;
- int cmp;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- if(mp_cmp_z(b) == MP_EQ)
- return MP_RANGE;
-
- /* If a <= b, we can compute the solution without division, and
- avoid any memory allocation
- */
- if((cmp = s_mp_cmp(a, b)) < 0) {
- if(r) {
- if((res = mp_copy(a, r)) != MP_OKAY)
- return res;
- }
-
- if(q)
- mp_zero(q);
-
- return MP_OKAY;
-
- } else if(cmp == 0) {
-
- /* Set quotient to 1, with appropriate sign */
- if(q) {
- int qneg = (SIGN(a) != SIGN(b));
-
- mp_set(q, 1);
- if(qneg)
- SIGN(q) = MP_NEG;
- }
-
- if(r)
- mp_zero(r);
-
- return MP_OKAY;
- }
-
- /* If we get here, it means we actually have to do some division */
-
- /* Set up some temporaries... */
- if((res = mp_init_copy(&qtmp, a)) != MP_OKAY)
- return res;
- if((res = mp_init_copy(&rtmp, b)) != MP_OKAY)
- goto CLEANUP;
-
- if((res = s_mp_div(&qtmp, &rtmp)) != MP_OKAY)
- goto CLEANUP;
-
- /* Compute the signs for the output */
- SIGN(&rtmp) = SIGN(a); /* Sr = Sa */
- if(SIGN(a) == SIGN(b))
- SIGN(&qtmp) = MP_ZPOS; /* Sq = MP_ZPOS if Sa = Sb */
- else
- SIGN(&qtmp) = MP_NEG; /* Sq = MP_NEG if Sa != Sb */
-
- if(s_mp_cmp_d(&qtmp, 0) == MP_EQ)
- SIGN(&qtmp) = MP_ZPOS;
- if(s_mp_cmp_d(&rtmp, 0) == MP_EQ)
- SIGN(&rtmp) = MP_ZPOS;
-
- /* Copy output, if it is needed */
- if(q)
- s_mp_exch(&qtmp, q);
-
- if(r)
- s_mp_exch(&rtmp, r);
-
-CLEANUP:
- mp_clear(&rtmp);
- mp_clear(&qtmp);
-
- return res;
-
-} /* end mp_div() */
-
-/* }}} */
-
-/* {{{ mp_div_2d(a, d, q, r) */
-
-mp_err mp_div_2d(mp_int *a, mp_digit d, mp_int *q, mp_int *r)
-{
- mp_err res;
-
- ARGCHK(a != NULL, MP_BADARG);
-
- if(q) {
- if((res = mp_copy(a, q)) != MP_OKAY)
- return res;
-
- s_mp_div_2d(q, d);
- }
-
- if(r) {
- if((res = mp_copy(a, r)) != MP_OKAY)
- return res;
-
- s_mp_mod_2d(r, d);
- }
-
- return MP_OKAY;
-
-} /* end mp_div_2d() */
-
-/* }}} */
-
-/* {{{ mp_expt(a, b, c) */
-
-/*
- mp_expt(a, b, c)
-
- Compute c = a ** b, that is, raise a to the b power. Uses a
- standard iterative square-and-multiply technique.
- */
-
-mp_err mp_expt(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_int s, x;
- mp_err res;
- mp_digit d;
- int dig, bit;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- if(mp_cmp_z(b) < 0)
- return MP_RANGE;
-
- if((res = mp_init(&s)) != MP_OKAY)
- return res;
-
- mp_set(&s, 1);
-
- if((res = mp_init_copy(&x, a)) != MP_OKAY)
- goto X;
-
- /* Loop over low-order digits in ascending order */
- for(dig = 0; dig < (USED(b) - 1); dig++) {
- d = DIGIT(b, dig);
-
- /* Loop over bits of each non-maximal digit */
- for(bit = 0; bit < DIGIT_BIT; bit++) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d >>= 1;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
- }
- }
-
- /* Consider now the last digit... */
- d = DIGIT(b, dig);
-
- while(d) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d >>= 1;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- if(mp_iseven(b))
- SIGN(&s) = SIGN(a);
-
- res = mp_copy(&s, c);
-
-CLEANUP:
- mp_clear(&x);
-X:
- mp_clear(&s);
-
- return res;
-
-} /* end mp_expt() */
-
-/* }}} */
-
-/* {{{ mp_2expt(a, k) */
-
-/* Compute a = 2^k */
-
-mp_err mp_2expt(mp_int *a, mp_digit k)
-{
- ARGCHK(a != NULL, MP_BADARG);
-
- return s_mp_2expt(a, k);
-
-} /* end mp_2expt() */
-
-/* }}} */
-
-/* {{{ mp_mod(a, m, c) */
-
-/*
- mp_mod(a, m, c)
-
- Compute c = a (mod m). Result will always be 0 <= c < m.
- */
-
-mp_err mp_mod(mp_int *a, mp_int *m, mp_int *c)
-{
- mp_err res;
- int mag;
-
- ARGCHK(a != NULL && m != NULL && c != NULL, MP_BADARG);
-
- if(SIGN(m) == MP_NEG)
- return MP_RANGE;
-
- /*
- If |a| > m, we need to divide to get the remainder and take the
- absolute value.
-
- If |a| < m, we don't need to do any division, just copy and adjust
- the sign (if a is negative).
-
- If |a| == m, we can simply set the result to zero.
-
- This order is intended to minimize the average path length of the
- comparison chain on common workloads -- the most frequent cases are
- that |a| != m, so we do those first.
- */
- if((mag = s_mp_cmp(a, m)) > 0) {
- if((res = mp_div(a, m, NULL, c)) != MP_OKAY)
- return res;
-
- if(SIGN(c) == MP_NEG) {
- if((res = mp_add(c, m, c)) != MP_OKAY)
- return res;
- }
-
- } else if(mag < 0) {
- if((res = mp_copy(a, c)) != MP_OKAY)
- return res;
-
- if(mp_cmp_z(a) < 0) {
- if((res = mp_add(c, m, c)) != MP_OKAY)
- return res;
-
- }
-
- } else {
- mp_zero(c);
-
- }
-
- return MP_OKAY;
-
-} /* end mp_mod() */
-
-/* }}} */
-
-/* {{{ mp_mod_d(a, d, c) */
-
-/*
- mp_mod_d(a, d, c)
-
- Compute c = a (mod d). Result will always be 0 <= c < d
- */
-mp_err mp_mod_d(mp_int *a, mp_digit d, mp_digit *c)
-{
- mp_err res;
- mp_digit rem;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if(s_mp_cmp_d(a, d) > 0) {
- if((res = mp_div_d(a, d, NULL, &rem)) != MP_OKAY)
- return res;
-
- } else {
- if(SIGN(a) == MP_NEG)
- rem = d - DIGIT(a, 0);
- else
- rem = DIGIT(a, 0);
- }
-
- if(c)
- *c = rem;
-
- return MP_OKAY;
-
-} /* end mp_mod_d() */
-
-/* }}} */
-
-/* {{{ mp_sqrt(a, b) */
-
-/*
- mp_sqrt(a, b)
-
- Compute the integer square root of a, and store the result in b.
- Uses an integer-arithmetic version of Newton's iterative linear
- approximation technique to determine this value; the result has the
- following two properties:
-
- b^2 <= a
- (b+1)^2 >= a
-
- It is a range error to pass a negative value.
- */
-mp_err mp_sqrt(mp_int *a, mp_int *b)
-{
- mp_int x, t;
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL, MP_BADARG);
-
- /* Cannot take square root of a negative value */
- if(SIGN(a) == MP_NEG)
- return MP_RANGE;
-
- /* Special cases for zero and one, trivial */
- if(mp_cmp_d(a, 0) == MP_EQ || mp_cmp_d(a, 1) == MP_EQ)
- return mp_copy(a, b);
-
- /* Initialize the temporaries we'll use below */
- if((res = mp_init_size(&t, USED(a))) != MP_OKAY)
- return res;
-
- /* Compute an initial guess for the iteration as a itself */
- if((res = mp_init_copy(&x, a)) != MP_OKAY)
- goto X;
-
-s_mp_rshd(&x, (USED(&x)/2)+1);
-mp_add_d(&x, 1, &x);
-
- for(;;) {
- /* t = (x * x) - a */
- mp_copy(&x, &t); /* can't fail, t is big enough for original x */
- if((res = mp_sqr(&t, &t)) != MP_OKAY ||
- (res = mp_sub(&t, a, &t)) != MP_OKAY)
- goto CLEANUP;
-
- /* t = t / 2x */
- s_mp_mul_2(&x);
- if((res = mp_div(&t, &x, &t, NULL)) != MP_OKAY)
- goto CLEANUP;
- s_mp_div_2(&x);
-
- /* Terminate the loop, if the quotient is zero */
- if(mp_cmp_z(&t) == MP_EQ)
- break;
-
- /* x = x - t */
- if((res = mp_sub(&x, &t, &x)) != MP_OKAY)
- goto CLEANUP;
-
- }
-
- /* Copy result to output parameter */
- mp_sub_d(&x, 1, &x);
- s_mp_exch(&x, b);
-
- CLEANUP:
- mp_clear(&x);
- X:
- mp_clear(&t);
-
- return res;
-
-} /* end mp_sqrt() */
-
-/* }}} */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ Modular arithmetic */
-
-#if MP_MODARITH
-/* {{{ mp_addmod(a, b, m, c) */
-
-/*
- mp_addmod(a, b, m, c)
-
- Compute c = (a + b) mod m
- */
-
-mp_err mp_addmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL && m != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_add(a, b, c)) != MP_OKAY)
- return res;
- if((res = mp_mod(c, m, c)) != MP_OKAY)
- return res;
-
- return MP_OKAY;
-
-}
-
-/* }}} */
-
-/* {{{ mp_submod(a, b, m, c) */
-
-/*
- mp_submod(a, b, m, c)
-
- Compute c = (a - b) mod m
- */
-
-mp_err mp_submod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL && m != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_sub(a, b, c)) != MP_OKAY)
- return res;
- if((res = mp_mod(c, m, c)) != MP_OKAY)
- return res;
-
- return MP_OKAY;
-
-}
-
-/* }}} */
-
-/* {{{ mp_mulmod(a, b, m, c) */
-
-/*
- mp_mulmod(a, b, m, c)
-
- Compute c = (a * b) mod m
- */
-
-mp_err mp_mulmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL && m != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_mul(a, b, c)) != MP_OKAY)
- return res;
- if((res = mp_mod(c, m, c)) != MP_OKAY)
- return res;
-
- return MP_OKAY;
-
-}
-
-/* }}} */
-
-/* {{{ mp_sqrmod(a, m, c) */
-
-#if MP_SQUARE
-mp_err mp_sqrmod(mp_int *a, mp_int *m, mp_int *c)
-{
- mp_err res;
-
- ARGCHK(a != NULL && m != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_sqr(a, c)) != MP_OKAY)
- return res;
- if((res = mp_mod(c, m, c)) != MP_OKAY)
- return res;
-
- return MP_OKAY;
-
-} /* end mp_sqrmod() */
-#endif
-
-/* }}} */
-
-/* {{{ mp_exptmod(a, b, m, c) */
-
-/*
- mp_exptmod(a, b, m, c)
-
- Compute c = (a ** b) mod m. Uses a standard square-and-multiply
- method with modular reductions at each step. (This is basically the
- same code as mp_expt(), except for the addition of the reductions)
-
- The modular reductions are done using Barrett's algorithm (see
- s_mp_reduce() below for details)
- */
-
-mp_err mp_exptmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
-{
- mp_int s, x, mu;
- mp_err res;
- mp_digit d, *db = DIGITS(b);
- mp_size ub = USED(b);
- int dig, bit;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- if(mp_cmp_z(b) < 0 || mp_cmp_z(m) <= 0)
- return MP_RANGE;
-
- if((res = mp_init(&s)) != MP_OKAY)
- return res;
- if((res = mp_init_copy(&x, a)) != MP_OKAY)
- goto X;
- if((res = mp_mod(&x, m, &x)) != MP_OKAY ||
- (res = mp_init(&mu)) != MP_OKAY)
- goto MU;
-
- mp_set(&s, 1);
-
- /* mu = b^2k / m */
- s_mp_add_d(&mu, 1);
- s_mp_lshd(&mu, 2 * USED(m));
- if((res = mp_div(&mu, m, &mu, NULL)) != MP_OKAY)
- goto CLEANUP;
-
- /* Loop over digits of b in ascending order, except highest order */
- for(dig = 0; dig < (ub - 1); dig++) {
- d = *db++;
-
- /* Loop over the bits of the lower-order digits */
- for(bit = 0; bit < DIGIT_BIT; bit++) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d >>= 1;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
- if((res = s_mp_reduce(&x, m, &mu)) != MP_OKAY)
- goto CLEANUP;
- }
- }
-
- /* Now do the last digit... */
- d = *db;
-
- while(d) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d >>= 1;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
- if((res = s_mp_reduce(&x, m, &mu)) != MP_OKAY)
- goto CLEANUP;
- }
-
- s_mp_exch(&s, c);
-
- CLEANUP:
- mp_clear(&mu);
- MU:
- mp_clear(&x);
- X:
- mp_clear(&s);
-
- return res;
-
-} /* end mp_exptmod() */
-
-/* }}} */
-
-/* {{{ mp_exptmod_d(a, d, m, c) */
-
-mp_err mp_exptmod_d(mp_int *a, mp_digit d, mp_int *m, mp_int *c)
-{
- mp_int s, x;
- mp_err res;
-
- ARGCHK(a != NULL && c != NULL, MP_BADARG);
-
- if((res = mp_init(&s)) != MP_OKAY)
- return res;
- if((res = mp_init_copy(&x, a)) != MP_OKAY)
- goto X;
-
- mp_set(&s, 1);
-
- while(d != 0) {
- if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY ||
- (res = mp_mod(&s, m, &s)) != MP_OKAY)
- goto CLEANUP;
- }
-
- d /= 2;
-
- if((res = s_mp_sqr(&x)) != MP_OKAY ||
- (res = mp_mod(&x, m, &x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- s_mp_exch(&s, c);
-
-CLEANUP:
- mp_clear(&x);
-X:
- mp_clear(&s);
-
- return res;
-
-} /* end mp_exptmod_d() */
-
-/* }}} */
-#endif /* if MP_MODARITH */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ Comparison functions */
-
-/* {{{ mp_cmp_z(a) */
-
-/*
- mp_cmp_z(a)
-
- Compare a <=> 0. Returns <0 if a<0, 0 if a=0, >0 if a>0.
- */
-
-int mp_cmp_z(mp_int *a)
-{
- if(SIGN(a) == MP_NEG)
- return MP_LT;
- else if(USED(a) == 1 && DIGIT(a, 0) == 0)
- return MP_EQ;
- else
- return MP_GT;
-
-} /* end mp_cmp_z() */
-
-/* }}} */
-
-/* {{{ mp_cmp_d(a, d) */
-
-/*
- mp_cmp_d(a, d)
-
- Compare a <=> d. Returns <0 if a<d, 0 if a=d, >0 if a>d
- */
-
-int mp_cmp_d(mp_int *a, mp_digit d)
-{
- ARGCHK(a != NULL, MP_EQ);
-
- if(SIGN(a) == MP_NEG)
- return MP_LT;
-
- return s_mp_cmp_d(a, d);
-
-} /* end mp_cmp_d() */
-
-/* }}} */
-
-/* {{{ mp_cmp(a, b) */
-
-int mp_cmp(mp_int *a, mp_int *b)
-{
- ARGCHK(a != NULL && b != NULL, MP_EQ);
-
- if(SIGN(a) == SIGN(b)) {
- int mag;
-
- if((mag = s_mp_cmp(a, b)) == MP_EQ)
- return MP_EQ;
-
- if(SIGN(a) == MP_ZPOS)
- return mag;
- else
- return -mag;
-
- } else if(SIGN(a) == MP_ZPOS) {
- return MP_GT;
- } else {
- return MP_LT;
- }
-
-} /* end mp_cmp() */
-
-/* }}} */
-
-/* {{{ mp_cmp_mag(a, b) */
-
-/*
- mp_cmp_mag(a, b)
-
- Compares |a| <=> |b|, and returns an appropriate comparison result
- */
-
-int mp_cmp_mag(mp_int *a, mp_int *b)
-{
- ARGCHK(a != NULL && b != NULL, MP_EQ);
-
- return s_mp_cmp(a, b);
-
-} /* end mp_cmp_mag() */
-
-/* }}} */
-
-/* {{{ mp_cmp_int(a, z) */
-
-/*
- This just converts z to an mp_int, and uses the existing comparison
- routines. This is sort of inefficient, but it's not clear to me how
- frequently this wil get used anyway. For small positive constants,
- you can always use mp_cmp_d(), and for zero, there is mp_cmp_z().
- */
-int mp_cmp_int(mp_int *a, long z)
-{
- mp_int tmp;
- int out;
-
- ARGCHK(a != NULL, MP_EQ);
-
- mp_init(&tmp); mp_set_int(&tmp, z);
- out = mp_cmp(a, &tmp);
- mp_clear(&tmp);
-
- return out;
-
-} /* end mp_cmp_int() */
-
-/* }}} */
-
-/* {{{ mp_isodd(a) */
-
-/*
- mp_isodd(a)
-
- Returns a true (non-zero) value if a is odd, false (zero) otherwise.
- */
-int mp_isodd(mp_int *a)
-{
- ARGCHK(a != NULL, 0);
-
- return (DIGIT(a, 0) & 1);
-
-} /* end mp_isodd() */
-
-/* }}} */
-
-/* {{{ mp_iseven(a) */
-
-int mp_iseven(mp_int *a)
-{
- return !mp_isodd(a);
-
-} /* end mp_iseven() */
-
-/* }}} */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ Number theoretic functions */
-
-#if MP_NUMTH
-/* {{{ mp_gcd(a, b, c) */
-
-/*
- Like the old mp_gcd() function, except computes the GCD using the
- binary algorithm due to Josef Stein in 1961 (via Knuth).
- */
-mp_err mp_gcd(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_err res;
- mp_int u, v, t;
- mp_size k = 0;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- if(mp_cmp_z(a) == MP_EQ && mp_cmp_z(b) == MP_EQ)
- return MP_RANGE;
- if(mp_cmp_z(a) == MP_EQ) {
- return mp_copy(b, c);
- } else if(mp_cmp_z(b) == MP_EQ) {
- return mp_copy(a, c);
- }
-
- if((res = mp_init(&t)) != MP_OKAY)
- return res;
- if((res = mp_init_copy(&u, a)) != MP_OKAY)
- goto U;
- if((res = mp_init_copy(&v, b)) != MP_OKAY)
- goto V;
-
- SIGN(&u) = MP_ZPOS;
- SIGN(&v) = MP_ZPOS;
-
- /* Divide out common factors of 2 until at least 1 of a, b is even */
- while(mp_iseven(&u) && mp_iseven(&v)) {
- s_mp_div_2(&u);
- s_mp_div_2(&v);
- ++k;
- }
-
- /* Initialize t */
- if(mp_isodd(&u)) {
- if((res = mp_copy(&v, &t)) != MP_OKAY)
- goto CLEANUP;
-
- /* t = -v */
- if(SIGN(&v) == MP_ZPOS)
- SIGN(&t) = MP_NEG;
- else
- SIGN(&t) = MP_ZPOS;
-
- } else {
- if((res = mp_copy(&u, &t)) != MP_OKAY)
- goto CLEANUP;
-
- }
-
- for(;;) {
- while(mp_iseven(&t)) {
- s_mp_div_2(&t);
- }
-
- if(mp_cmp_z(&t) == MP_GT) {
- if((res = mp_copy(&t, &u)) != MP_OKAY)
- goto CLEANUP;
-
- } else {
- if((res = mp_copy(&t, &v)) != MP_OKAY)
- goto CLEANUP;
-
- /* v = -t */
- if(SIGN(&t) == MP_ZPOS)
- SIGN(&v) = MP_NEG;
- else
- SIGN(&v) = MP_ZPOS;
- }
-
- if((res = mp_sub(&u, &v, &t)) != MP_OKAY)
- goto CLEANUP;
-
- if(s_mp_cmp_d(&t, 0) == MP_EQ)
- break;
- }
-
- s_mp_2expt(&v, k); /* v = 2^k */
- res = mp_mul(&u, &v, c); /* c = u * v */
-
- CLEANUP:
- mp_clear(&v);
- V:
- mp_clear(&u);
- U:
- mp_clear(&t);
-
- return res;
-
-} /* end mp_bgcd() */
-
-/* }}} */
-
-/* {{{ mp_lcm(a, b, c) */
-
-/* We compute the least common multiple using the rule:
-
- ab = [a, b](a, b)
-
- ... by computing the product, and dividing out the gcd.
- */
-
-mp_err mp_lcm(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_int gcd, prod;
- mp_err res;
-
- ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
-
- /* Set up temporaries */
- if((res = mp_init(&gcd)) != MP_OKAY)
- return res;
- if((res = mp_init(&prod)) != MP_OKAY)
- goto GCD;
-
- if((res = mp_mul(a, b, &prod)) != MP_OKAY)
- goto CLEANUP;
- if((res = mp_gcd(a, b, &gcd)) != MP_OKAY)
- goto CLEANUP;
-
- res = mp_div(&prod, &gcd, c, NULL);
-
- CLEANUP:
- mp_clear(&prod);
- GCD:
- mp_clear(&gcd);
-
- return res;
-
-} /* end mp_lcm() */
-
-/* }}} */
-
-/* {{{ mp_xgcd(a, b, g, x, y) */
-
-/*
- mp_xgcd(a, b, g, x, y)
-
- Compute g = (a, b) and values x and y satisfying Bezout's identity
- (that is, ax + by = g). This uses the extended binary GCD algorithm
- based on the Stein algorithm used for mp_gcd()
- */
-
-mp_err mp_xgcd(mp_int *a, mp_int *b, mp_int *g, mp_int *x, mp_int *y)
-{
- mp_int gx, xc, yc, u, v, A, B, C, D;
- mp_int *clean[9];
- mp_err res;
- int last = -1;
-
- if(mp_cmp_z(b) == 0)
- return MP_RANGE;
-
- /* Initialize all these variables we need */
- if((res = mp_init(&u)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &u;
- if((res = mp_init(&v)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &v;
- if((res = mp_init(&gx)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &gx;
- if((res = mp_init(&A)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &A;
- if((res = mp_init(&B)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &B;
- if((res = mp_init(&C)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &C;
- if((res = mp_init(&D)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &D;
- if((res = mp_init_copy(&xc, a)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &xc;
- mp_abs(&xc, &xc);
- if((res = mp_init_copy(&yc, b)) != MP_OKAY) goto CLEANUP;
- clean[++last] = &yc;
- mp_abs(&yc, &yc);
-
- mp_set(&gx, 1);
-
- /* Divide by two until at least one of them is even */
- while(mp_iseven(&xc) && mp_iseven(&yc)) {
- s_mp_div_2(&xc);
- s_mp_div_2(&yc);
- if((res = s_mp_mul_2(&gx)) != MP_OKAY)
- goto CLEANUP;
- }
-
- mp_copy(&xc, &u);
- mp_copy(&yc, &v);
- mp_set(&A, 1); mp_set(&D, 1);
-
- /* Loop through binary GCD algorithm */
- for(;;) {
- while(mp_iseven(&u)) {
- s_mp_div_2(&u);
-
- if(mp_iseven(&A) && mp_iseven(&B)) {
- s_mp_div_2(&A); s_mp_div_2(&B);
- } else {
- if((res = mp_add(&A, &yc, &A)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&A);
- if((res = mp_sub(&B, &xc, &B)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&B);
- }
- }
-
- while(mp_iseven(&v)) {
- s_mp_div_2(&v);
-
- if(mp_iseven(&C) && mp_iseven(&D)) {
- s_mp_div_2(&C); s_mp_div_2(&D);
- } else {
- if((res = mp_add(&C, &yc, &C)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&C);
- if((res = mp_sub(&D, &xc, &D)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&D);
- }
- }
-
- if(mp_cmp(&u, &v) >= 0) {
- if((res = mp_sub(&u, &v, &u)) != MP_OKAY) goto CLEANUP;
- if((res = mp_sub(&A, &C, &A)) != MP_OKAY) goto CLEANUP;
- if((res = mp_sub(&B, &D, &B)) != MP_OKAY) goto CLEANUP;
-
- } else {
- if((res = mp_sub(&v, &u, &v)) != MP_OKAY) goto CLEANUP;
- if((res = mp_sub(&C, &A, &C)) != MP_OKAY) goto CLEANUP;
- if((res = mp_sub(&D, &B, &D)) != MP_OKAY) goto CLEANUP;
-
- }
-
- /* If we're done, copy results to output */
- if(mp_cmp_z(&u) == 0) {
- if(x)
- if((res = mp_copy(&C, x)) != MP_OKAY) goto CLEANUP;
-
- if(y)
- if((res = mp_copy(&D, y)) != MP_OKAY) goto CLEANUP;
-
- if(g)
- if((res = mp_mul(&gx, &v, g)) != MP_OKAY) goto CLEANUP;
-
- break;
- }
- }
-
- CLEANUP:
- while(last >= 0)
- mp_clear(clean[last--]);
-
- return res;
-
-} /* end mp_xgcd() */
-
-/* }}} */
-
-/* {{{ mp_invmod(a, m, c) */
-
-/*
- mp_invmod(a, m, c)
-
- Compute c = a^-1 (mod m), if there is an inverse for a (mod m).
- This is equivalent to the question of whether (a, m) = 1. If not,
- MP_UNDEF is returned, and there is no inverse.
- */
-
-mp_err mp_invmod(mp_int *a, mp_int *m, mp_int *c)
-{
- mp_int g, x;
- mp_err res;
-
- ARGCHK(a && m && c, MP_BADARG);
-
- if(mp_cmp_z(a) == 0 || mp_cmp_z(m) == 0)
- return MP_RANGE;
-
- if((res = mp_init(&g)) != MP_OKAY)
- return res;
- if((res = mp_init(&x)) != MP_OKAY)
- goto X;
-
- if((res = mp_xgcd(a, m, &g, &x, NULL)) != MP_OKAY)
- goto CLEANUP;
-
- if(mp_cmp_d(&g, 1) != MP_EQ) {
- res = MP_UNDEF;
- goto CLEANUP;
- }
-
- res = mp_mod(&x, m, c);
- SIGN(c) = SIGN(a);
-
-CLEANUP:
- mp_clear(&x);
-X:
- mp_clear(&g);
-
- return res;
-
-} /* end mp_invmod() */
-
-/* }}} */
-#endif /* if MP_NUMTH */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ mp_print(mp, ofp) */
-
-#if MP_IOFUNC
-/*
- mp_print(mp, ofp)
-
- Print a textual representation of the given mp_int on the output
- stream 'ofp'. Output is generated using the internal radix.
- */
-
-void mp_print(mp_int *mp, FILE *ofp)
-{
- int ix;
-
- if(mp == NULL || ofp == NULL)
- return;
-
- fputc((SIGN(mp) == MP_NEG) ? '-' : '+', ofp);
-
- for(ix = USED(mp) - 1; ix >= 0; ix--) {
- fprintf(ofp, DIGIT_FMT, DIGIT(mp, ix));
- }
-
-} /* end mp_print() */
-
-#endif /* if MP_IOFUNC */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* {{{ More I/O Functions */
-
-/* {{{ mp_read_signed_bin(mp, str, len) */
-
-/*
- mp_read_signed_bin(mp, str, len)
-
- Read in a raw value (base 256) into the given mp_int
- */
-
-mp_err mp_read_signed_bin(mp_int *mp, unsigned char *str, int len)
-{
- mp_err res;
-
- ARGCHK(mp != NULL && str != NULL && len > 0, MP_BADARG);
-
- if((res = mp_read_unsigned_bin(mp, str + 1, len - 1)) == MP_OKAY) {
- /* Get sign from first byte */
- if(str[0])
- SIGN(mp) = MP_NEG;
- else
- SIGN(mp) = MP_ZPOS;
- }
-
- return res;
-
-} /* end mp_read_signed_bin() */
-
-/* }}} */
-
-/* {{{ mp_signed_bin_size(mp) */
-
-int mp_signed_bin_size(mp_int *mp)
-{
- ARGCHK(mp != NULL, 0);
-
- return mp_unsigned_bin_size(mp) + 1;
-
-} /* end mp_signed_bin_size() */
-
-/* }}} */
-
-/* {{{ mp_to_signed_bin(mp, str) */
-
-mp_err mp_to_signed_bin(mp_int *mp, unsigned char *str)
-{
- ARGCHK(mp != NULL && str != NULL, MP_BADARG);
-
- /* Caller responsible for allocating enough memory (use mp_raw_size(mp)) */
- str[0] = (char)SIGN(mp);
-
- return mp_to_unsigned_bin(mp, str + 1);
-
-} /* end mp_to_signed_bin() */
-
-/* }}} */
-
-/* {{{ mp_read_unsigned_bin(mp, str, len) */
-
-/*
- mp_read_unsigned_bin(mp, str, len)
-
- Read in an unsigned value (base 256) into the given mp_int
- */
-
-mp_err mp_read_unsigned_bin(mp_int *mp, unsigned char *str, int len)
-{
- int ix;
- mp_err res;
-
- ARGCHK(mp != NULL && str != NULL && len > 0, MP_BADARG);
-
- mp_zero(mp);
-
- for(ix = 0; ix < len; ix++) {
- if((res = s_mp_mul_2d(mp, CHAR_BIT)) != MP_OKAY)
- return res;
-
- if((res = mp_add_d(mp, str[ix], mp)) != MP_OKAY)
- return res;
- }
-
- return MP_OKAY;
-
-} /* end mp_read_unsigned_bin() */
-
-/* }}} */
-
-/* {{{ mp_unsigned_bin_size(mp) */
-
-int mp_unsigned_bin_size(mp_int *mp)
-{
- mp_digit topdig;
- int count;
-
- ARGCHK(mp != NULL, 0);
-
- /* Special case for the value zero */
- if(USED(mp) == 1 && DIGIT(mp, 0) == 0)
- return 1;
-
- count = (USED(mp) - 1) * sizeof(mp_digit);
- topdig = DIGIT(mp, USED(mp) - 1);
-
- while(topdig != 0) {
- ++count;
- topdig >>= CHAR_BIT;
- }
-
- return count;
-
-} /* end mp_unsigned_bin_size() */
-
-/* }}} */
-
-/* {{{ mp_to_unsigned_bin(mp, str) */
-
-mp_err mp_to_unsigned_bin(mp_int *mp, unsigned char *str)
-{
- mp_digit *dp, *end, d;
- unsigned char *spos;
-
- ARGCHK(mp != NULL && str != NULL, MP_BADARG);
-
- dp = DIGITS(mp);
- end = dp + USED(mp) - 1;
- spos = str;
-
- /* Special case for zero, quick test */
- if(dp == end && *dp == 0) {
- *str = '\0';
- return MP_OKAY;
- }
-
- /* Generate digits in reverse order */
- while(dp < end) {
- int ix;
-
- d = *dp;
- for(ix = 0; ix < sizeof(mp_digit); ++ix) {
- *spos = d & UCHAR_MAX;
- d >>= CHAR_BIT;
- ++spos;
- }
-
- ++dp;
- }
-
- /* Now handle last digit specially, high order zeroes are not written */
- d = *end;
- while(d != 0) {
- *spos = d & UCHAR_MAX;
- d >>= CHAR_BIT;
- ++spos;
- }
-
- /* Reverse everything to get digits in the correct order */
- while(--spos > str) {
- unsigned char t = *str;
- *str = *spos;
- *spos = t;
-
- ++str;
- }
-
- return MP_OKAY;
-
-} /* end mp_to_unsigned_bin() */
-
-/* }}} */
-
-/* {{{ mp_count_bits(mp) */
-
-int mp_count_bits(mp_int *mp)
-{
- int len;
- mp_digit d;
-
- ARGCHK(mp != NULL, MP_BADARG);
-
- len = DIGIT_BIT * (USED(mp) - 1);
- d = DIGIT(mp, USED(mp) - 1);
-
- while(d != 0) {
- ++len;
- d >>= 1;
- }
-
- return len;
-
-} /* end mp_count_bits() */
-
-/* }}} */
-
-/* {{{ mp_read_radix(mp, str, radix) */
-
-/*
- mp_read_radix(mp, str, radix)
-
- Read an integer from the given string, and set mp to the resulting
- value. The input is presumed to be in base 10. Leading non-digit
- characters are ignored, and the function reads until a non-digit
- character or the end of the string.
- */
-
-mp_err mp_read_radix(mp_int *mp, unsigned char *str, int radix)
-{
- int ix = 0, val = 0;
- mp_err res;
- mp_sign sig = MP_ZPOS;
-
- ARGCHK(mp != NULL && str != NULL && radix >= 2 && radix <= MAX_RADIX,
- MP_BADARG);
-
- mp_zero(mp);
-
- /* Skip leading non-digit characters until a digit or '-' or '+' */
- while(str[ix] &&
- (s_mp_tovalue(str[ix], radix) < 0) &&
- str[ix] != '-' &&
- str[ix] != '+') {
- ++ix;
- }
-
- if(str[ix] == '-') {
- sig = MP_NEG;
- ++ix;
- } else if(str[ix] == '+') {
- sig = MP_ZPOS; /* this is the default anyway... */
- ++ix;
- }
-
- while((val = s_mp_tovalue(str[ix], radix)) >= 0) {
- if((res = s_mp_mul_d(mp, radix)) != MP_OKAY)
- return res;
- if((res = s_mp_add_d(mp, val)) != MP_OKAY)
- return res;
- ++ix;
- }
-
- if(s_mp_cmp_d(mp, 0) == MP_EQ)
- SIGN(mp) = MP_ZPOS;
- else
- SIGN(mp) = sig;
-
- return MP_OKAY;
-
-} /* end mp_read_radix() */
-
-/* }}} */
-
-/* {{{ mp_radix_size(mp, radix) */
-
-int mp_radix_size(mp_int *mp, int radix)
-{
- int len;
- ARGCHK(mp != NULL, 0);
-
- len = s_mp_outlen(mp_count_bits(mp), radix) + 1; /* for NUL terminator */
-
- if(mp_cmp_z(mp) < 0)
- ++len; /* for sign */
-
- return len;
-
-} /* end mp_radix_size() */
-
-/* }}} */
-
-/* {{{ mp_value_radix_size(num, qty, radix) */
-
-/* num = number of digits
- qty = number of bits per digit
- radix = target base
-
- Return the number of digits in the specified radix that would be
- needed to express 'num' digits of 'qty' bits each.
- */
-int mp_value_radix_size(int num, int qty, int radix)
-{
- ARGCHK(num >= 0 && qty > 0 && radix >= 2 && radix <= MAX_RADIX, 0);
-
- return s_mp_outlen(num * qty, radix);
-
-} /* end mp_value_radix_size() */
-
-/* }}} */
-
-/* {{{ mp_toradix(mp, str, radix) */
-
-mp_err mp_toradix(mp_int *mp, unsigned char *str, int radix)
-{
- int ix, pos = 0;
-
- ARGCHK(mp != NULL && str != NULL, MP_BADARG);
- ARGCHK(radix > 1 && radix <= MAX_RADIX, MP_RANGE);
-
- if(mp_cmp_z(mp) == MP_EQ) {
- str[0] = '0';
- str[1] = '\0';
- } else {
- mp_err res;
- mp_int tmp;
- mp_sign sgn;
- mp_digit rem, rdx = (mp_digit)radix;
- char ch;
-
- if((res = mp_init_copy(&tmp, mp)) != MP_OKAY)
- return res;
-
- /* Save sign for later, and take absolute value */
- sgn = SIGN(&tmp); SIGN(&tmp) = MP_ZPOS;
-
- /* Generate output digits in reverse order */
- while(mp_cmp_z(&tmp) != 0) {
- if((res = s_mp_div_d(&tmp, rdx, &rem)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
-
- /* Generate digits, use capital letters */
- ch = s_mp_todigit(rem, radix, 0);
-
- str[pos++] = ch;
- }
-
- /* Add - sign if original value was negative */
- if(sgn == MP_NEG)
- str[pos++] = '-';
-
- /* Add trailing NUL to end the string */
- str[pos--] = '\0';
-
- /* Reverse the digits and sign indicator */
- ix = 0;
- while(ix < pos) {
- char tmp = str[ix];
-
- str[ix] = str[pos];
- str[pos] = tmp;
- ++ix;
- --pos;
- }
-
- mp_clear(&tmp);
- }
-
- return MP_OKAY;
-
-} /* end mp_toradix() */
-
-/* }}} */
-
-/* {{{ mp_char2value(ch, r) */
-
-int mp_char2value(char ch, int r)
-{
- return s_mp_tovalue(ch, r);
-
-} /* end mp_tovalue() */
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ mp_strerror(ec) */
-
-/*
- mp_strerror(ec)
-
- Return a string describing the meaning of error code 'ec'. The
- string returned is allocated in static memory, so the caller should
- not attempt to modify or free the memory associated with this
- string.
- */
-const char *mp_strerror(mp_err ec)
-{
- int aec = (ec < 0) ? -ec : ec;
-
- /* Code values are negative, so the senses of these comparisons
- are accurate */
- if(ec < MP_LAST_CODE || ec > MP_OKAY) {
- return mp_err_string[0]; /* unknown error code */
- } else {
- return mp_err_string[aec + 1];
- }
-
-} /* end mp_strerror() */
-
-/* }}} */
-
-/*========================================================================*/
-/*------------------------------------------------------------------------*/
-/* Static function definitions (internal use only) */
-
-/* {{{ Memory management */
-
-/* {{{ s_mp_grow(mp, min) */
-
-/* Make sure there are at least 'min' digits allocated to mp */
-mp_err s_mp_grow(mp_int *mp, mp_size min)
-{
- if(min > ALLOC(mp)) {
- mp_digit *tmp;
-
- /* Set min to next nearest default precision block size */
- min = ((min + (s_mp_defprec - 1)) / s_mp_defprec) * s_mp_defprec;
-
- if((tmp = s_mp_alloc(min, sizeof(mp_digit))) == NULL)
- return MP_MEM;
-
- s_mp_copy(DIGITS(mp), tmp, USED(mp));
-
-#if MP_CRYPTO
- s_mp_setz(DIGITS(mp), ALLOC(mp));
-#endif
- s_mp_free(DIGITS(mp));
- DIGITS(mp) = tmp;
- ALLOC(mp) = min;
- }
-
- return MP_OKAY;
-
-} /* end s_mp_grow() */
-
-/* }}} */
-
-/* {{{ s_mp_pad(mp, min) */
-
-/* Make sure the used size of mp is at least 'min', growing if needed */
-mp_err s_mp_pad(mp_int *mp, mp_size min)
-{
- if(min > USED(mp)) {
- mp_err res;
-
- /* Make sure there is room to increase precision */
- if(min > ALLOC(mp) && (res = s_mp_grow(mp, min)) != MP_OKAY)
- return res;
-
- /* Increase precision; should already be 0-filled */
- USED(mp) = min;
- }
-
- return MP_OKAY;
-
-} /* end s_mp_pad() */
-
-/* }}} */
-
-/* {{{ s_mp_setz(dp, count) */
-
-#if MP_MACRO == 0
-/* Set 'count' digits pointed to by dp to be zeroes */
-void s_mp_setz(mp_digit *dp, mp_size count)
-{
-#if MP_MEMSET == 0
- int ix;
-
- for(ix = 0; ix < count; ix++)
- dp[ix] = 0;
-#else
- memset(dp, 0, count * sizeof(mp_digit));
-#endif
-
-} /* end s_mp_setz() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_copy(sp, dp, count) */
-
-#if MP_MACRO == 0
-/* Copy 'count' digits from sp to dp */
-void s_mp_copy(mp_digit *sp, mp_digit *dp, mp_size count)
-{
-#if MP_MEMCPY == 0
- int ix;
-
- for(ix = 0; ix < count; ix++)
- dp[ix] = sp[ix];
-#else
- memcpy(dp, sp, count * sizeof(mp_digit));
-#endif
-
-} /* end s_mp_copy() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_alloc(nb, ni) */
-
-#if MP_MACRO == 0
-/* Allocate ni records of nb bytes each, and return a pointer to that */
-void *s_mp_alloc(size_t nb, size_t ni)
-{
- return calloc(nb, ni);
-
-} /* end s_mp_alloc() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_free(ptr) */
-
-#if MP_MACRO == 0
-/* Free the memory pointed to by ptr */
-void s_mp_free(void *ptr)
-{
- if(ptr)
- free(ptr);
-
-} /* end s_mp_free() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_clamp(mp) */
-
-/* Remove leading zeroes from the given value */
-void s_mp_clamp(mp_int *mp)
-{
- mp_size du = USED(mp);
- mp_digit *zp = DIGITS(mp) + du - 1;
-
- while(du > 1 && !*zp--)
- --du;
-
- USED(mp) = du;
-
-} /* end s_mp_clamp() */
-
-
-/* }}} */
-
-/* {{{ s_mp_exch(a, b) */
-
-/* Exchange the data for a and b; (b, a) = (a, b) */
-void s_mp_exch(mp_int *a, mp_int *b)
-{
- mp_int tmp;
-
- tmp = *a;
- *a = *b;
- *b = tmp;
-
-} /* end s_mp_exch() */
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ Arithmetic helpers */
-
-/* {{{ s_mp_lshd(mp, p) */
-
-/*
- Shift mp leftward by p digits, growing if needed, and zero-filling
- the in-shifted digits at the right end. This is a convenient
- alternative to multiplication by powers of the radix
- */
-
-mp_err s_mp_lshd(mp_int *mp, mp_size p)
-{
- mp_err res;
- mp_size pos;
- mp_digit *dp;
- int ix;
-
- if(p == 0)
- return MP_OKAY;
-
- if((res = s_mp_pad(mp, USED(mp) + p)) != MP_OKAY)
- return res;
-
- pos = USED(mp) - 1;
- dp = DIGITS(mp);
-
- /* Shift all the significant figures over as needed */
- for(ix = pos - p; ix >= 0; ix--)
- dp[ix + p] = dp[ix];
-
- /* Fill the bottom digits with zeroes */
- for(ix = 0; ix < p; ix++)
- dp[ix] = 0;
-
- return MP_OKAY;
-
-} /* end s_mp_lshd() */
-
-/* }}} */
-
-/* {{{ s_mp_rshd(mp, p) */
-
-/*
- Shift mp rightward by p digits. Maintains the invariant that
- digits above the precision are all zero. Digits shifted off the
- end are lost. Cannot fail.
- */
-
-void s_mp_rshd(mp_int *mp, mp_size p)
-{
- mp_size ix;
- mp_digit *dp;
-
- if(p == 0)
- return;
-
- /* Shortcut when all digits are to be shifted off */
- if(p >= USED(mp)) {
- s_mp_setz(DIGITS(mp), ALLOC(mp));
- USED(mp) = 1;
- SIGN(mp) = MP_ZPOS;
- return;
- }
-
- /* Shift all the significant figures over as needed */
- dp = DIGITS(mp);
- for(ix = p; ix < USED(mp); ix++)
- dp[ix - p] = dp[ix];
-
- /* Fill the top digits with zeroes */
- ix -= p;
- while(ix < USED(mp))
- dp[ix++] = 0;
-
- /* Strip off any leading zeroes */
- s_mp_clamp(mp);
-
-} /* end s_mp_rshd() */
-
-/* }}} */
-
-/* {{{ s_mp_div_2(mp) */
-
-/* Divide by two -- take advantage of radix properties to do it fast */
-void s_mp_div_2(mp_int *mp)
-{
- s_mp_div_2d(mp, 1);
-
-} /* end s_mp_div_2() */
-
-/* }}} */
-
-/* {{{ s_mp_mul_2(mp) */
-
-mp_err s_mp_mul_2(mp_int *mp)
-{
- int ix;
- mp_digit kin = 0, kout, *dp = DIGITS(mp);
- mp_err res;
-
- /* Shift digits leftward by 1 bit */
- for(ix = 0; ix < USED(mp); ix++) {
- kout = (dp[ix] >> (DIGIT_BIT - 1)) & 1;
- dp[ix] = (dp[ix] << 1) | kin;
-
- kin = kout;
- }
-
- /* Deal with rollover from last digit */
- if(kin) {
- if(ix >= ALLOC(mp)) {
- if((res = s_mp_grow(mp, ALLOC(mp) + 1)) != MP_OKAY)
- return res;
- dp = DIGITS(mp);
- }
-
- dp[ix] = kin;
- USED(mp) += 1;
- }
-
- return MP_OKAY;
-
-} /* end s_mp_mul_2() */
-
-/* }}} */
-
-/* {{{ s_mp_mod_2d(mp, d) */
-
-/*
- Remainder the integer by 2^d, where d is a number of bits. This
- amounts to a bitwise AND of the value, and does not require the full
- division code
- */
-void s_mp_mod_2d(mp_int *mp, mp_digit d)
-{
- unsigned int ndig = (d / DIGIT_BIT), nbit = (d % DIGIT_BIT);
- unsigned int ix;
- mp_digit dmask, *dp = DIGITS(mp);
-
- if(ndig >= USED(mp))
- return;
-
- /* Flush all the bits above 2^d in its digit */
- dmask = (1 << nbit) - 1;
- dp[ndig] &= dmask;
-
- /* Flush all digits above the one with 2^d in it */
- for(ix = ndig + 1; ix < USED(mp); ix++)
- dp[ix] = 0;
-
- s_mp_clamp(mp);
-
-} /* end s_mp_mod_2d() */
-
-/* }}} */
-
-/* {{{ s_mp_mul_2d(mp, d) */
-
-/*
- Multiply by the integer 2^d, where d is a number of bits. This
- amounts to a bitwise shift of the value, and does not require the
- full multiplication code.
- */
-mp_err s_mp_mul_2d(mp_int *mp, mp_digit d)
-{
- mp_err res;
- mp_digit save, next, mask, *dp;
- mp_size used;
- int ix;
-
- if((res = s_mp_lshd(mp, d / DIGIT_BIT)) != MP_OKAY)
- return res;
-
- dp = DIGITS(mp); used = USED(mp);
- d %= DIGIT_BIT;
-
- mask = (1 << d) - 1;
-
- /* If the shift requires another digit, make sure we've got one to
- work with */
- if((dp[used - 1] >> (DIGIT_BIT - d)) & mask) {
- if((res = s_mp_grow(mp, used + 1)) != MP_OKAY)
- return res;
- dp = DIGITS(mp);
- }
-
- /* Do the shifting... */
- save = 0;
- for(ix = 0; ix < used; ix++) {
- next = (dp[ix] >> (DIGIT_BIT - d)) & mask;
- dp[ix] = (dp[ix] << d) | save;
- save = next;
- }
-
- /* If, at this point, we have a nonzero carryout into the next
- digit, we'll increase the size by one digit, and store it...
- */
- if(save) {
- dp[used] = save;
- USED(mp) += 1;
- }
-
- s_mp_clamp(mp);
- return MP_OKAY;
-
-} /* end s_mp_mul_2d() */
-
-/* }}} */
-
-/* {{{ s_mp_div_2d(mp, d) */
-
-/*
- Divide the integer by 2^d, where d is a number of bits. This
- amounts to a bitwise shift of the value, and does not require the
- full division code (used in Barrett reduction, see below)
- */
-void s_mp_div_2d(mp_int *mp, mp_digit d)
-{
- int ix;
- mp_digit save, next, mask, *dp = DIGITS(mp);
-
- s_mp_rshd(mp, d / DIGIT_BIT);
- d %= DIGIT_BIT;
-
- mask = (1 << d) - 1;
-
- save = 0;
- for(ix = USED(mp) - 1; ix >= 0; ix--) {
- next = dp[ix] & mask;
- dp[ix] = (dp[ix] >> d) | (save << (DIGIT_BIT - d));
- save = next;
- }
-
- s_mp_clamp(mp);
-
-} /* end s_mp_div_2d() */
-
-/* }}} */
-
-/* {{{ s_mp_norm(a, b) */
-
-/*
- s_mp_norm(a, b)
-
- Normalize a and b for division, where b is the divisor. In order
- that we might make good guesses for quotient digits, we want the
- leading digit of b to be at least half the radix, which we
- accomplish by multiplying a and b by a constant. This constant is
- returned (so that it can be divided back out of the remainder at the
- end of the division process).
-
- We multiply by the smallest power of 2 that gives us a leading digit
- at least half the radix. By choosing a power of 2, we simplify the
- multiplication and division steps to simple shifts.
- */
-mp_digit s_mp_norm(mp_int *a, mp_int *b)
-{
- mp_digit t, d = 0;
-
- t = DIGIT(b, USED(b) - 1);
- while(t < (RADIX / 2)) {
- t <<= 1;
- ++d;
- }
-
- if(d != 0) {
- s_mp_mul_2d(a, d);
- s_mp_mul_2d(b, d);
- }
-
- return d;
-
-} /* end s_mp_norm() */
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ Primitive digit arithmetic */
-
-/* {{{ s_mp_add_d(mp, d) */
-
-/* Add d to |mp| in place */
-mp_err s_mp_add_d(mp_int *mp, mp_digit d) /* unsigned digit addition */
-{
- mp_word w, k = 0;
- mp_size ix = 1, used = USED(mp);
- mp_digit *dp = DIGITS(mp);
-
- w = dp[0] + d;
- dp[0] = ACCUM(w);
- k = CARRYOUT(w);
-
- while(ix < used && k) {
- w = dp[ix] + k;
- dp[ix] = ACCUM(w);
- k = CARRYOUT(w);
- ++ix;
- }
-
- if(k != 0) {
- mp_err res;
-
- if((res = s_mp_pad(mp, USED(mp) + 1)) != MP_OKAY)
- return res;
-
- DIGIT(mp, ix) = k;
- }
-
- return MP_OKAY;
-
-} /* end s_mp_add_d() */
-
-/* }}} */
-
-/* {{{ s_mp_sub_d(mp, d) */
-
-/* Subtract d from |mp| in place, assumes |mp| > d */
-mp_err s_mp_sub_d(mp_int *mp, mp_digit d) /* unsigned digit subtract */
-{
- mp_word w, b = 0;
- mp_size ix = 1, used = USED(mp);
- mp_digit *dp = DIGITS(mp);
-
- /* Compute initial subtraction */
- w = (RADIX + dp[0]) - d;
- b = CARRYOUT(w) ? 0 : 1;
- dp[0] = ACCUM(w);
-
- /* Propagate borrows leftward */
- while(b && ix < used) {
- w = (RADIX + dp[ix]) - b;
- b = CARRYOUT(w) ? 0 : 1;
- dp[ix] = ACCUM(w);
- ++ix;
- }
-
- /* Remove leading zeroes */
- s_mp_clamp(mp);
-
- /* If we have a borrow out, it's a violation of the input invariant */
- if(b)
- return MP_RANGE;
- else
- return MP_OKAY;
-
-} /* end s_mp_sub_d() */
-
-/* }}} */
-
-/* {{{ s_mp_mul_d(a, d) */
-
-/* Compute a = a * d, single digit multiplication */
-mp_err s_mp_mul_d(mp_int *a, mp_digit d)
-{
- mp_word w, k = 0;
- mp_size ix, max;
- mp_err res;
- mp_digit *dp = DIGITS(a);
-
- /*
- Single-digit multiplication will increase the precision of the
- output by at most one digit. However, we can detect when this
- will happen -- if the high-order digit of a, times d, gives a
- two-digit result, then the precision of the result will increase;
- otherwise it won't. We use this fact to avoid calling s_mp_pad()
- unless absolutely necessary.
- */
- max = USED(a);
- w = dp[max - 1] * d;
- if(CARRYOUT(w) != 0) {
- if((res = s_mp_pad(a, max + 1)) != MP_OKAY)
- return res;
- dp = DIGITS(a);
- }
-
- for(ix = 0; ix < max; ix++) {
- w = (dp[ix] * d) + k;
- dp[ix] = ACCUM(w);
- k = CARRYOUT(w);
- }
-
- /* If there is a precision increase, take care of it here; the above
- test guarantees we have enough storage to do this safely.
- */
- if(k) {
- dp[max] = k;
- USED(a) = max + 1;
- }
-
- s_mp_clamp(a);
-
- return MP_OKAY;
-
-} /* end s_mp_mul_d() */
-
-/* }}} */
-
-/* {{{ s_mp_div_d(mp, d, r) */
-
-/*
- s_mp_div_d(mp, d, r)
-
- Compute the quotient mp = mp / d and remainder r = mp mod d, for a
- single digit d. If r is null, the remainder will be discarded.
- */
-
-mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r)
-{
- mp_word w = 0, t;
- mp_int quot;
- mp_err res;
- mp_digit *dp = DIGITS(mp), *qp;
- int ix;
-
- if(d == 0)
- return MP_RANGE;
-
- /* Make room for the quotient */
- if((res = mp_init_size(&quot, USED(mp))) != MP_OKAY)
- return res;
-
- USED(&quot) = USED(mp); /* so clamping will work below */
- qp = DIGITS(&quot);
-
- /* Divide without subtraction */
- for(ix = USED(mp) - 1; ix >= 0; ix--) {
- w = (w << DIGIT_BIT) | dp[ix];
-
- if(w >= d) {
- t = w / d;
- w = w % d;
- } else {
- t = 0;
- }
-
- qp[ix] = t;
- }
-
- /* Deliver the remainder, if desired */
- if(r)
- *r = w;
-
- s_mp_clamp(&quot);
- mp_exch(&quot, mp);
- mp_clear(&quot);
-
- return MP_OKAY;
-
-} /* end s_mp_div_d() */
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ Primitive full arithmetic */
-
-/* {{{ s_mp_add(a, b) */
-
-/* Compute a = |a| + |b| */
-mp_err s_mp_add(mp_int *a, mp_int *b) /* magnitude addition */
-{
- mp_word w = 0;
- mp_digit *pa, *pb;
- mp_size ix, used = USED(b);
- mp_err res;
-
- /* Make sure a has enough precision for the output value */
- if((used > USED(a)) && (res = s_mp_pad(a, used)) != MP_OKAY)
- return res;
-
- /*
- Add up all digits up to the precision of b. If b had initially
- the same precision as a, or greater, we took care of it by the
- padding step above, so there is no problem. If b had initially
- less precision, we'll have to make sure the carry out is duly
- propagated upward among the higher-order digits of the sum.
- */
- pa = DIGITS(a);
- pb = DIGITS(b);
- for(ix = 0; ix < used; ++ix) {
- w += *pa + *pb++;
- *pa++ = ACCUM(w);
- w = CARRYOUT(w);
- }
-
- /* If we run out of 'b' digits before we're actually done, make
- sure the carries get propagated upward...
- */
- used = USED(a);
- while(w && ix < used) {
- w += *pa;
- *pa++ = ACCUM(w);
- w = CARRYOUT(w);
- ++ix;
- }
-
- /* If there's an overall carry out, increase precision and include
- it. We could have done this initially, but why touch the memory
- allocator unless we're sure we have to?
- */
- if(w) {
- if((res = s_mp_pad(a, used + 1)) != MP_OKAY)
- return res;
-
- DIGIT(a, ix) = w; /* pa may not be valid after s_mp_pad() call */
- }
-
- return MP_OKAY;
-
-} /* end s_mp_add() */
-
-/* }}} */
-
-/* {{{ s_mp_sub(a, b) */
-
-/* Compute a = |a| - |b|, assumes |a| >= |b| */
-mp_err s_mp_sub(mp_int *a, mp_int *b) /* magnitude subtract */
-{
- mp_word w = 0;
- mp_digit *pa, *pb;
- mp_size ix, used = USED(b);
-
- /*
- Subtract and propagate borrow. Up to the precision of b, this
- accounts for the digits of b; after that, we just make sure the
- carries get to the right place. This saves having to pad b out to
- the precision of a just to make the loops work right...
- */
- pa = DIGITS(a);
- pb = DIGITS(b);
-
- for(ix = 0; ix < used; ++ix) {
- w = (RADIX + *pa) - w - *pb++;
- *pa++ = ACCUM(w);
- w = CARRYOUT(w) ? 0 : 1;
- }
-
- used = USED(a);
- while(ix < used) {
- w = RADIX + *pa - w;
- *pa++ = ACCUM(w);
- w = CARRYOUT(w) ? 0 : 1;
- ++ix;
- }
-
- /* Clobber any leading zeroes we created */
- s_mp_clamp(a);
-
- /*
- If there was a borrow out, then |b| > |a| in violation
- of our input invariant. We've already done the work,
- but we'll at least complain about it...
- */
- if(w)
- return MP_RANGE;
- else
- return MP_OKAY;
-
-} /* end s_mp_sub() */
-
-/* }}} */
-
-mp_err s_mp_reduce(mp_int *x, mp_int *m, mp_int *mu)
-{
- mp_int q;
- mp_err res;
- mp_size um = USED(m);
-
- if((res = mp_init_copy(&q, x)) != MP_OKAY)
- return res;
-
- s_mp_rshd(&q, um - 1); /* q1 = x / b^(k-1) */
- s_mp_mul(&q, mu); /* q2 = q1 * mu */
- s_mp_rshd(&q, um + 1); /* q3 = q2 / b^(k+1) */
-
- /* x = x mod b^(k+1), quick (no division) */
- s_mp_mod_2d(x, (mp_digit)(DIGIT_BIT * (um + 1)));
-
- /* q = q * m mod b^(k+1), quick (no division), uses the short multiplier */
-#ifndef SHRT_MUL
- s_mp_mul(&q, m);
- s_mp_mod_2d(&q, (mp_digit)(DIGIT_BIT * (um + 1)));
-#else
- s_mp_mul_dig(&q, m, um + 1);
-#endif
-
- /* x = x - q */
- if((res = mp_sub(x, &q, x)) != MP_OKAY)
- goto CLEANUP;
-
- /* If x < 0, add b^(k+1) to it */
- if(mp_cmp_z(x) < 0) {
- mp_set(&q, 1);
- if((res = s_mp_lshd(&q, um + 1)) != MP_OKAY)
- goto CLEANUP;
- if((res = mp_add(x, &q, x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- /* Back off if it's too big */
- while(mp_cmp(x, m) >= 0) {
- if((res = s_mp_sub(x, m)) != MP_OKAY)
- break;
- }
-
- CLEANUP:
- mp_clear(&q);
-
- return res;
-
-} /* end s_mp_reduce() */
-
-
-
-/* {{{ s_mp_mul(a, b) */
-
-/* Compute a = |a| * |b| */
-mp_err s_mp_mul(mp_int *a, mp_int *b)
-{
- mp_word w, k = 0;
- mp_int tmp;
- mp_err res;
- mp_size ix, jx, ua = USED(a), ub = USED(b);
- mp_digit *pa, *pb, *pt, *pbt;
-
- if((res = mp_init_size(&tmp, ua + ub)) != MP_OKAY)
- return res;
-
- /* This has the effect of left-padding with zeroes... */
- USED(&tmp) = ua + ub;
-
- /* We're going to need the base value each iteration */
- pbt = DIGITS(&tmp);
-
- /* Outer loop: Digits of b */
-
- pb = DIGITS(b);
- for(ix = 0; ix < ub; ++ix, ++pb) {
- if(*pb == 0)
- continue;
-
- /* Inner product: Digits of a */
- pa = DIGITS(a);
- for(jx = 0; jx < ua; ++jx, ++pa) {
- pt = pbt + ix + jx;
- w = *pb * *pa + k + *pt;
- *pt = ACCUM(w);
- k = CARRYOUT(w);
- }
-
- pbt[ix + jx] = k;
- k = 0;
- }
-
- s_mp_clamp(&tmp);
- s_mp_exch(&tmp, a);
-
- mp_clear(&tmp);
-
- return MP_OKAY;
-
-} /* end s_mp_mul() */
-
-/* }}} */
-
-/* {{{ s_mp_kmul(a, b, out, len) */
-
-#if 0
-void s_mp_kmul(mp_digit *a, mp_digit *b, mp_digit *out, mp_size len)
-{
- mp_word w, k = 0;
- mp_size ix, jx;
- mp_digit *pa, *pt;
-
- for(ix = 0; ix < len; ++ix, ++b) {
- if(*b == 0)
- continue;
-
- pa = a;
- for(jx = 0; jx < len; ++jx, ++pa) {
- pt = out + ix + jx;
- w = *b * *pa + k + *pt;
- *pt = ACCUM(w);
- k = CARRYOUT(w);
- }
-
- out[ix + jx] = k;
- k = 0;
- }
-
-} /* end s_mp_kmul() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_sqr(a) */
-
-/*
- Computes the square of a, in place. This can be done more
- efficiently than a general multiplication, because many of the
- computation steps are redundant when squaring. The inner product
- step is a bit more complicated, but we save a fair number of
- iterations of the multiplication loop.
- */
-#if MP_SQUARE
-mp_err s_mp_sqr(mp_int *a)
-{
- mp_word w, k = 0;
- mp_int tmp;
- mp_err res;
- mp_size ix, jx, kx, used = USED(a);
- mp_digit *pa1, *pa2, *pt, *pbt;
-
- if((res = mp_init_size(&tmp, 2 * used)) != MP_OKAY)
- return res;
-
- /* Left-pad with zeroes */
- USED(&tmp) = 2 * used;
-
- /* We need the base value each time through the loop */
- pbt = DIGITS(&tmp);
-
- pa1 = DIGITS(a);
- for(ix = 0; ix < used; ++ix, ++pa1) {
- if(*pa1 == 0)
- continue;
-
- w = DIGIT(&tmp, ix + ix) + (*pa1 * *pa1);
-
- pbt[ix + ix] = ACCUM(w);
- k = CARRYOUT(w);
-
- /*
- The inner product is computed as:
-
- (C, S) = t[i,j] + 2 a[i] a[j] + C
-
- This can overflow what can be represented in an mp_word, and
- since C arithmetic does not provide any way to check for
- overflow, we have to check explicitly for overflow conditions
- before they happen.
- */
- for(jx = ix + 1, pa2 = DIGITS(a) + jx; jx < used; ++jx, ++pa2) {
- mp_word u = 0, v;
-
- /* Store this in a temporary to avoid indirections later */
- pt = pbt + ix + jx;
-
- /* Compute the multiplicative step */
- w = *pa1 * *pa2;
-
- /* If w is more than half MP_WORD_MAX, the doubling will
- overflow, and we need to record a carry out into the next
- word */
- u = (w >> (MP_WORD_BIT - 1)) & 1;
-
- /* Double what we've got, overflow will be ignored as defined
- for C arithmetic (we've already noted if it is to occur)
- */
- w *= 2;
-
- /* Compute the additive step */
- v = *pt + k;
-
- /* If we do not already have an overflow carry, check to see
- if the addition will cause one, and set the carry out if so
- */
- u |= ((MP_WORD_MAX - v) < w);
-
- /* Add in the rest, again ignoring overflow */
- w += v;
-
- /* Set the i,j digit of the output */
- *pt = ACCUM(w);
-
- /* Save carry information for the next iteration of the loop.
- This is why k must be an mp_word, instead of an mp_digit */
- k = CARRYOUT(w) | (u << DIGIT_BIT);
-
- } /* for(jx ...) */
-
- /* Set the last digit in the cycle and reset the carry */
- k = DIGIT(&tmp, ix + jx) + k;
- pbt[ix + jx] = ACCUM(k);
- k = CARRYOUT(k);
-
- /* If we are carrying out, propagate the carry to the next digit
- in the output. This may cascade, so we have to be somewhat
- circumspect -- but we will have enough precision in the output
- that we won't overflow
- */
- kx = 1;
- while(k) {
- k = pbt[ix + jx + kx] + 1;
- pbt[ix + jx + kx] = ACCUM(k);
- k = CARRYOUT(k);
- ++kx;
- }
- } /* for(ix ...) */
-
- s_mp_clamp(&tmp);
- s_mp_exch(&tmp, a);
-
- mp_clear(&tmp);
-
- return MP_OKAY;
-
-} /* end s_mp_sqr() */
-#endif
-
-/* }}} */
-
-/* {{{ s_mp_div(a, b) */
-
-/*
- s_mp_div(a, b)
-
- Compute a = a / b and b = a mod b. Assumes b > a.
- */
-
-mp_err s_mp_div(mp_int *a, mp_int *b)
-{
- mp_int quot, rem, t;
- mp_word q;
- mp_err res;
- mp_digit d;
- int ix;
-
- if(mp_cmp_z(b) == 0)
- return MP_RANGE;
-
- /* Shortcut if b is power of two */
- if((ix = s_mp_ispow2(b)) >= 0) {
- mp_copy(a, b); /* need this for remainder */
- s_mp_div_2d(a, (mp_digit)ix);
- s_mp_mod_2d(b, (mp_digit)ix);
-
- return MP_OKAY;
- }
-
- /* Allocate space to store the quotient */
- if((res = mp_init_size(&quot, USED(a))) != MP_OKAY)
- return res;
-
- /* A working temporary for division */
- if((res = mp_init_size(&t, USED(a))) != MP_OKAY)
- goto T;
-
- /* Allocate space for the remainder */
- if((res = mp_init_size(&rem, USED(a))) != MP_OKAY)
- goto REM;
-
- /* Normalize to optimize guessing */
- d = s_mp_norm(a, b);
-
- /* Perform the division itself...woo! */
- ix = USED(a) - 1;
-
- while(ix >= 0) {
- /* Find a partial substring of a which is at least b */
- while(s_mp_cmp(&rem, b) < 0 && ix >= 0) {
- if((res = s_mp_lshd(&rem, 1)) != MP_OKAY)
- goto CLEANUP;
-
- if((res = s_mp_lshd(&quot, 1)) != MP_OKAY)
- goto CLEANUP;
-
- DIGIT(&rem, 0) = DIGIT(a, ix);
- s_mp_clamp(&rem);
- --ix;
- }
-
- /* If we didn't find one, we're finished dividing */
- if(s_mp_cmp(&rem, b) < 0)
- break;
-
- /* Compute a guess for the next quotient digit */
- q = DIGIT(&rem, USED(&rem) - 1);
- if(q <= DIGIT(b, USED(b) - 1) && USED(&rem) > 1)
- q = (q << DIGIT_BIT) | DIGIT(&rem, USED(&rem) - 2);
-
- q /= DIGIT(b, USED(b) - 1);
-
- /* The guess can be as much as RADIX + 1 */
- if(q >= RADIX)
- q = RADIX - 1;
-
- /* See what that multiplies out to */
- mp_copy(b, &t);
- if((res = s_mp_mul_d(&t, q)) != MP_OKAY)
- goto CLEANUP;
-
- /*
- If it's too big, back it off. We should not have to do this
- more than once, or, in rare cases, twice. Knuth describes a
- method by which this could be reduced to a maximum of once, but
- I didn't implement that here.
- */
- while(s_mp_cmp(&t, &rem) > 0) {
- --q;
- s_mp_sub(&t, b);
- }
-
- /* At this point, q should be the right next digit */
- if((res = s_mp_sub(&rem, &t)) != MP_OKAY)
- goto CLEANUP;
-
- /*
- Include the digit in the quotient. We allocated enough memory
- for any quotient we could ever possibly get, so we should not
- have to check for failures here
- */
- DIGIT(&quot, 0) = q;
- }
-
- /* Denormalize remainder */
- if(d != 0)
- s_mp_div_2d(&rem, d);
-
- s_mp_clamp(&quot);
- s_mp_clamp(&rem);
-
- /* Copy quotient back to output */
- s_mp_exch(&quot, a);
-
- /* Copy remainder back to output */
- s_mp_exch(&rem, b);
-
-CLEANUP:
- mp_clear(&rem);
-REM:
- mp_clear(&t);
-T:
- mp_clear(&quot);
-
- return res;
-
-} /* end s_mp_div() */
-
-/* }}} */
-
-/* {{{ s_mp_2expt(a, k) */
-
-mp_err s_mp_2expt(mp_int *a, mp_digit k)
-{
- mp_err res;
- mp_size dig, bit;
-
- dig = k / DIGIT_BIT;
- bit = k % DIGIT_BIT;
-
- mp_zero(a);
- if((res = s_mp_pad(a, dig + 1)) != MP_OKAY)
- return res;
-
- DIGIT(a, dig) |= (1 << bit);
-
- return MP_OKAY;
-
-} /* end s_mp_2expt() */
-
-/* }}} */
-
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ Primitive comparisons */
-
-/* {{{ s_mp_cmp(a, b) */
-
-/* Compare |a| <=> |b|, return 0 if equal, <0 if a<b, >0 if a>b */
-int s_mp_cmp(mp_int *a, mp_int *b)
-{
- mp_size ua = USED(a), ub = USED(b);
-
- if(ua > ub)
- return MP_GT;
- else if(ua < ub)
- return MP_LT;
- else {
- int ix = ua - 1;
- mp_digit *ap = DIGITS(a) + ix, *bp = DIGITS(b) + ix;
-
- while(ix >= 0) {
- if(*ap > *bp)
- return MP_GT;
- else if(*ap < *bp)
- return MP_LT;
-
- --ap; --bp; --ix;
- }
-
- return MP_EQ;
- }
-
-} /* end s_mp_cmp() */
-
-/* }}} */
-
-/* {{{ s_mp_cmp_d(a, d) */
-
-/* Compare |a| <=> d, return 0 if equal, <0 if a<d, >0 if a>d */
-int s_mp_cmp_d(mp_int *a, mp_digit d)
-{
- mp_size ua = USED(a);
- mp_digit *ap = DIGITS(a);
-
- if(ua > 1)
- return MP_GT;
-
- if(*ap < d)
- return MP_LT;
- else if(*ap > d)
- return MP_GT;
- else
- return MP_EQ;
-
-} /* end s_mp_cmp_d() */
-
-/* }}} */
-
-/* {{{ s_mp_ispow2(v) */
-
-/*
- Returns -1 if the value is not a power of two; otherwise, it returns
- k such that v = 2^k, i.e. lg(v).
- */
-int s_mp_ispow2(mp_int *v)
-{
- mp_digit d, *dp;
- mp_size uv = USED(v);
- int extra = 0, ix;
-
- d = DIGIT(v, uv - 1); /* most significant digit of v */
-
- while(d && ((d & 1) == 0)) {
- d >>= 1;
- ++extra;
- }
-
- if(d == 1) {
- ix = uv - 2;
- dp = DIGITS(v) + ix;
-
- while(ix >= 0) {
- if(*dp)
- return -1; /* not a power of two */
-
- --dp; --ix;
- }
-
- return ((uv - 1) * DIGIT_BIT) + extra;
- }
-
- return -1;
-
-} /* end s_mp_ispow2() */
-
-/* }}} */
-
-/* {{{ s_mp_ispow2d(d) */
-
-int s_mp_ispow2d(mp_digit d)
-{
- int pow = 0;
-
- while((d & 1) == 0) {
- ++pow; d >>= 1;
- }
-
- if(d == 1)
- return pow;
-
- return -1;
-
-} /* end s_mp_ispow2d() */
-
-/* }}} */
-
-/* }}} */
-
-/* {{{ Primitive I/O helpers */
-
-/* {{{ s_mp_tovalue(ch, r) */
-
-/*
- Convert the given character to its digit value, in the given radix.
- If the given character is not understood in the given radix, -1 is
- returned. Otherwise the digit's numeric value is returned.
-
- The results will be odd if you use a radix < 2 or > 62, you are
- expected to know what you're up to.
- */
-int s_mp_tovalue(char ch, int r)
-{
- int val, xch;
-
- if(r > 36)
- xch = ch;
- else
- xch = toupper(ch);
-
- if(isdigit(xch))
- val = xch - '0';
- else if(isupper(xch))
- val = xch - 'A' + 10;
- else if(islower(xch))
- val = xch - 'a' + 36;
- else if(xch == '+')
- val = 62;
- else if(xch == '/')
- val = 63;
- else
- return -1;
-
- if(val < 0 || val >= r)
- return -1;
-
- return val;
-
-} /* end s_mp_tovalue() */
-
-/* }}} */
-
-/* {{{ s_mp_todigit(val, r, low) */
-
-/*
- Convert val to a radix-r digit, if possible. If val is out of range
- for r, returns zero. Otherwise, returns an ASCII character denoting
- the value in the given radix.
-
- The results may be odd if you use a radix < 2 or > 64, you are
- expected to know what you're doing.
- */
-
-char s_mp_todigit(int val, int r, int low)
-{
- char ch;
-
- if(val < 0 || val >= r)
- return 0;
-
- ch = s_dmap_1[val];
-
- if(r <= 36 && low)
- ch = tolower(ch);
-
- return ch;
-
-} /* end s_mp_todigit() */
-
-/* }}} */
-
-/* {{{ s_mp_outlen(bits, radix) */
-
-/*
- Return an estimate for how long a string is needed to hold a radix
- r representation of a number with 'bits' significant bits.
-
- Does not include space for a sign or a NUL terminator.
- */
-int s_mp_outlen(int bits, int r)
-{
- return (int)((double)bits * LOG_V_2(r));
-
-} /* end s_mp_outlen() */
-
-/* }}} */
-
-/* }}} */
-
-/*------------------------------------------------------------------------*/
-/* HERE THERE BE DRAGONS */
-/* crc==4242132123, version==2, Sat Feb 02 06:43:52 2002 */
diff --git a/libtommath/mtest/mpi.h b/libtommath/mtest/mpi.h
deleted file mode 100644
index 211421f..0000000
--- a/libtommath/mtest/mpi.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- mpi.h
-
- by Michael J. Fromberger <sting@linguist.dartmouth.edu>
- Copyright (C) 1998 Michael J. Fromberger, All Rights Reserved
-
- Arbitrary precision integer arithmetic library
- */
-
-#ifndef _H_MPI_
-#define _H_MPI_
-
-#include "mpi-config.h"
-
-#define MP_LT -1
-#define MP_EQ 0
-#define MP_GT 1
-
-#if MP_DEBUG
-#undef MP_IOFUNC
-#define MP_IOFUNC 1
-#endif
-
-#if MP_IOFUNC
-#include <stdio.h>
-#include <ctype.h>
-#endif
-
-#include <limits.h>
-
-#define MP_NEG 1
-#define MP_ZPOS 0
-
-/* Included for compatibility... */
-#define NEG MP_NEG
-#define ZPOS MP_ZPOS
-
-#define MP_OKAY 0 /* no error, all is well */
-#define MP_YES 0 /* yes (boolean result) */
-#define MP_NO -1 /* no (boolean result) */
-#define MP_MEM -2 /* out of memory */
-#define MP_RANGE -3 /* argument out of range */
-#define MP_BADARG -4 /* invalid parameter */
-#define MP_UNDEF -5 /* answer is undefined */
-#define MP_LAST_CODE MP_UNDEF
-
-#include "mpi-types.h"
-
-/* Included for compatibility... */
-#define DIGIT_BIT MP_DIGIT_BIT
-#define DIGIT_MAX MP_DIGIT_MAX
-
-/* Macros for accessing the mp_int internals */
-#define SIGN(MP) ((MP)->sign)
-#define USED(MP) ((MP)->used)
-#define ALLOC(MP) ((MP)->alloc)
-#define DIGITS(MP) ((MP)->dp)
-#define DIGIT(MP,N) (MP)->dp[(N)]
-
-#if MP_ARGCHK == 1
-#define ARGCHK(X,Y) {if(!(X)){return (Y);}}
-#elif MP_ARGCHK == 2
-#include <assert.h>
-#define ARGCHK(X,Y) assert(X)
-#else
-#define ARGCHK(X,Y) /* */
-#endif
-
-/* This defines the maximum I/O base (minimum is 2) */
-#define MAX_RADIX 64
-
-typedef struct {
- mp_sign sign; /* sign of this quantity */
- mp_size alloc; /* how many digits allocated */
- mp_size used; /* how many digits used */
- mp_digit *dp; /* the digits themselves */
-} mp_int;
-
-/*------------------------------------------------------------------------*/
-/* Default precision */
-
-unsigned int mp_get_prec(void);
-void mp_set_prec(unsigned int prec);
-
-/*------------------------------------------------------------------------*/
-/* Memory management */
-
-mp_err mp_init(mp_int *mp);
-mp_err mp_init_array(mp_int mp[], int count);
-mp_err mp_init_size(mp_int *mp, mp_size prec);
-mp_err mp_init_copy(mp_int *mp, mp_int *from);
-mp_err mp_copy(mp_int *from, mp_int *to);
-void mp_exch(mp_int *mp1, mp_int *mp2);
-void mp_clear(mp_int *mp);
-void mp_clear_array(mp_int mp[], int count);
-void mp_zero(mp_int *mp);
-void mp_set(mp_int *mp, mp_digit d);
-mp_err mp_set_int(mp_int *mp, long z);
-mp_err mp_shrink(mp_int *a);
-
-
-/*------------------------------------------------------------------------*/
-/* Single digit arithmetic */
-
-mp_err mp_add_d(mp_int *a, mp_digit d, mp_int *b);
-mp_err mp_sub_d(mp_int *a, mp_digit d, mp_int *b);
-mp_err mp_mul_d(mp_int *a, mp_digit d, mp_int *b);
-mp_err mp_mul_2(mp_int *a, mp_int *c);
-mp_err mp_div_d(mp_int *a, mp_digit d, mp_int *q, mp_digit *r);
-mp_err mp_div_2(mp_int *a, mp_int *c);
-mp_err mp_expt_d(mp_int *a, mp_digit d, mp_int *c);
-
-/*------------------------------------------------------------------------*/
-/* Sign manipulations */
-
-mp_err mp_abs(mp_int *a, mp_int *b);
-mp_err mp_neg(mp_int *a, mp_int *b);
-
-/*------------------------------------------------------------------------*/
-/* Full arithmetic */
-
-mp_err mp_add(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_mul(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_mul_2d(mp_int *a, mp_digit d, mp_int *c);
-#if MP_SQUARE
-mp_err mp_sqr(mp_int *a, mp_int *b);
-#else
-#define mp_sqr(a, b) mp_mul(a, a, b)
-#endif
-mp_err mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r);
-mp_err mp_div_2d(mp_int *a, mp_digit d, mp_int *q, mp_int *r);
-mp_err mp_expt(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_2expt(mp_int *a, mp_digit k);
-mp_err mp_sqrt(mp_int *a, mp_int *b);
-
-/*------------------------------------------------------------------------*/
-/* Modular arithmetic */
-
-#if MP_MODARITH
-mp_err mp_mod(mp_int *a, mp_int *m, mp_int *c);
-mp_err mp_mod_d(mp_int *a, mp_digit d, mp_digit *c);
-mp_err mp_addmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c);
-mp_err mp_submod(mp_int *a, mp_int *b, mp_int *m, mp_int *c);
-mp_err mp_mulmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c);
-#if MP_SQUARE
-mp_err mp_sqrmod(mp_int *a, mp_int *m, mp_int *c);
-#else
-#define mp_sqrmod(a, m, c) mp_mulmod(a, a, m, c)
-#endif
-mp_err mp_exptmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c);
-mp_err mp_exptmod_d(mp_int *a, mp_digit d, mp_int *m, mp_int *c);
-#endif /* MP_MODARITH */
-
-/*------------------------------------------------------------------------*/
-/* Comparisons */
-
-int mp_cmp_z(mp_int *a);
-int mp_cmp_d(mp_int *a, mp_digit d);
-int mp_cmp(mp_int *a, mp_int *b);
-int mp_cmp_mag(mp_int *a, mp_int *b);
-int mp_cmp_int(mp_int *a, long z);
-int mp_isodd(mp_int *a);
-int mp_iseven(mp_int *a);
-
-/*------------------------------------------------------------------------*/
-/* Number theoretic */
-
-#if MP_NUMTH
-mp_err mp_gcd(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_lcm(mp_int *a, mp_int *b, mp_int *c);
-mp_err mp_xgcd(mp_int *a, mp_int *b, mp_int *g, mp_int *x, mp_int *y);
-mp_err mp_invmod(mp_int *a, mp_int *m, mp_int *c);
-#endif /* end MP_NUMTH */
-
-/*------------------------------------------------------------------------*/
-/* Input and output */
-
-#if MP_IOFUNC
-void mp_print(mp_int *mp, FILE *ofp);
-#endif /* end MP_IOFUNC */
-
-/*------------------------------------------------------------------------*/
-/* Base conversion */
-
-#define BITS 1
-#define BYTES CHAR_BIT
-
-mp_err mp_read_signed_bin(mp_int *mp, unsigned char *str, int len);
-int mp_signed_bin_size(mp_int *mp);
-mp_err mp_to_signed_bin(mp_int *mp, unsigned char *str);
-
-mp_err mp_read_unsigned_bin(mp_int *mp, unsigned char *str, int len);
-int mp_unsigned_bin_size(mp_int *mp);
-mp_err mp_to_unsigned_bin(mp_int *mp, unsigned char *str);
-
-int mp_count_bits(mp_int *mp);
-
-#if MP_COMPAT_MACROS
-#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
-#define mp_raw_size(mp) mp_signed_bin_size(mp)
-#define mp_toraw(mp, str) mp_to_signed_bin((mp), (str))
-#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
-#define mp_mag_size(mp) mp_unsigned_bin_size(mp)
-#define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str))
-#endif
-
-mp_err mp_read_radix(mp_int *mp, unsigned char *str, int radix);
-int mp_radix_size(mp_int *mp, int radix);
-int mp_value_radix_size(int num, int qty, int radix);
-mp_err mp_toradix(mp_int *mp, unsigned char *str, int radix);
-
-int mp_char2value(char ch, int r);
-
-#define mp_tobinary(M, S) mp_toradix((M), (S), 2)
-#define mp_tooctal(M, S) mp_toradix((M), (S), 8)
-#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
-#define mp_tohex(M, S) mp_toradix((M), (S), 16)
-
-/*------------------------------------------------------------------------*/
-/* Error strings */
-
-const char *mp_strerror(mp_err ec);
-
-#endif /* end _H_MPI_ */
diff --git a/libtommath/mtest/mtest.c b/libtommath/mtest/mtest.c
deleted file mode 100644
index d46f456..0000000
--- a/libtommath/mtest/mtest.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* makes a bignum test harness with NUM tests per operation
- *
- * the output is made in the following format [one parameter per line]
-
-operation
-operand1
-operand2
-[... operandN]
-result1
-result2
-[... resultN]
-
-So for example "a * b mod n" would be
-
-mulmod
-a
-b
-n
-a*b mod n
-
-e.g. if a=3, b=4 n=11 then
-
-mulmod
-3
-4
-11
-1
-
- */
-
-#ifdef MP_8BIT
-#define THE_MASK 127
-#else
-#define THE_MASK 32767
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include "mpi.c"
-
-FILE *rng;
-
-void rand_num(mp_int *a)
-{
- int n, size;
- unsigned char buf[2048];
-
- size = 1 + ((fgetc(rng)<<8) + fgetc(rng)) % 101;
- buf[0] = (fgetc(rng)&1)?1:0;
- fread(buf+1, 1, size, rng);
- while (buf[1] == 0) buf[1] = fgetc(rng);
- mp_read_raw(a, buf, 1+size);
-}
-
-void rand_num2(mp_int *a)
-{
- int n, size;
- unsigned char buf[2048];
-
- size = 10 + ((fgetc(rng)<<8) + fgetc(rng)) % 101;
- buf[0] = (fgetc(rng)&1)?1:0;
- fread(buf+1, 1, size, rng);
- while (buf[1] == 0) buf[1] = fgetc(rng);
- mp_read_raw(a, buf, 1+size);
-}
-
-#define mp_to64(a, b) mp_toradix(a, b, 64)
-
-int main(void)
-{
- int n, tmp;
- mp_int a, b, c, d, e;
- clock_t t1;
- char buf[4096];
-
- mp_init(&a);
- mp_init(&b);
- mp_init(&c);
- mp_init(&d);
- mp_init(&e);
-
-
- /* initial (2^n - 1)^2 testing, makes sure the comba multiplier works [it has the new carry code] */
-/*
- mp_set(&a, 1);
- for (n = 1; n < 8192; n++) {
- mp_mul(&a, &a, &c);
- printf("mul\n");
- mp_to64(&a, buf);
- printf("%s\n%s\n", buf, buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
-
- mp_add_d(&a, 1, &a);
- mp_mul_2(&a, &a);
- mp_sub_d(&a, 1, &a);
- }
-*/
-
- rng = fopen("/dev/urandom", "rb");
- if (rng == NULL) {
- rng = fopen("/dev/random", "rb");
- if (rng == NULL) {
- fprintf(stderr, "\nWarning: stdin used as random source\n\n");
- rng = stdin;
- }
- }
-
- t1 = clock();
- for (;;) {
-#if 0
- if (clock() - t1 > CLOCKS_PER_SEC) {
- sleep(2);
- t1 = clock();
- }
-#endif
- n = fgetc(rng) % 15;
-
- if (n == 0) {
- /* add tests */
- rand_num(&a);
- rand_num(&b);
- mp_add(&a, &b, &c);
- printf("add\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 1) {
- /* sub tests */
- rand_num(&a);
- rand_num(&b);
- mp_sub(&a, &b, &c);
- printf("sub\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 2) {
- /* mul tests */
- rand_num(&a);
- rand_num(&b);
- mp_mul(&a, &b, &c);
- printf("mul\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 3) {
- /* div tests */
- rand_num(&a);
- rand_num(&b);
- mp_div(&a, &b, &c, &d);
- printf("div\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- mp_to64(&d, buf);
- printf("%s\n", buf);
- } else if (n == 4) {
- /* sqr tests */
- rand_num(&a);
- mp_sqr(&a, &b);
- printf("sqr\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 5) {
- /* mul_2d test */
- rand_num(&a);
- mp_copy(&a, &b);
- n = fgetc(rng) & 63;
- mp_mul_2d(&b, n, &b);
- mp_to64(&a, buf);
- printf("mul2d\n");
- printf("%s\n", buf);
- printf("%d\n", n);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 6) {
- /* div_2d test */
- rand_num(&a);
- mp_copy(&a, &b);
- n = fgetc(rng) & 63;
- mp_div_2d(&b, n, &b, NULL);
- mp_to64(&a, buf);
- printf("div2d\n");
- printf("%s\n", buf);
- printf("%d\n", n);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 7) {
- /* gcd test */
- rand_num(&a);
- rand_num(&b);
- a.sign = MP_ZPOS;
- b.sign = MP_ZPOS;
- mp_gcd(&a, &b, &c);
- printf("gcd\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 8) {
- /* lcm test */
- rand_num(&a);
- rand_num(&b);
- a.sign = MP_ZPOS;
- b.sign = MP_ZPOS;
- mp_lcm(&a, &b, &c);
- printf("lcm\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 9) {
- /* exptmod test */
- rand_num2(&a);
- rand_num2(&b);
- rand_num2(&c);
-// if (c.dp[0]&1) mp_add_d(&c, 1, &c);
- a.sign = b.sign = c.sign = 0;
- mp_exptmod(&a, &b, &c, &d);
- printf("expt\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- mp_to64(&d, buf);
- printf("%s\n", buf);
- } else if (n == 10) {
- /* invmod test */
- rand_num2(&a);
- rand_num2(&b);
- b.sign = MP_ZPOS;
- a.sign = MP_ZPOS;
- mp_gcd(&a, &b, &c);
- if (mp_cmp_d(&c, 1) != 0) continue;
- if (mp_cmp_d(&b, 1) == 0) continue;
- mp_invmod(&a, &b, &c);
- printf("invmod\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- mp_to64(&c, buf);
- printf("%s\n", buf);
- } else if (n == 11) {
- rand_num(&a);
- mp_mul_2(&a, &a);
- mp_div_2(&a, &b);
- printf("div2\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 12) {
- rand_num2(&a);
- mp_mul_2(&a, &b);
- printf("mul2\n");
- mp_to64(&a, buf);
- printf("%s\n", buf);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 13) {
- rand_num2(&a);
- tmp = abs(rand()) & THE_MASK;
- mp_add_d(&a, tmp, &b);
- printf("add_d\n");
- mp_to64(&a, buf);
- printf("%s\n%d\n", buf, tmp);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- } else if (n == 14) {
- rand_num2(&a);
- tmp = abs(rand()) & THE_MASK;
- mp_sub_d(&a, tmp, &b);
- printf("sub_d\n");
- mp_to64(&a, buf);
- printf("%s\n%d\n", buf, tmp);
- mp_to64(&b, buf);
- printf("%s\n", buf);
- }
- }
- fclose(rng);
- return 0;
-}
diff --git a/libtommath/pics/design_process.sxd b/libtommath/pics/design_process.sxd
deleted file mode 100644
index 7414dbb..0000000
--- a/libtommath/pics/design_process.sxd
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/design_process.tif b/libtommath/pics/design_process.tif
deleted file mode 100644
index 4a0c012..0000000
--- a/libtommath/pics/design_process.tif
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/expt_state.sxd b/libtommath/pics/expt_state.sxd
deleted file mode 100644
index 6518404..0000000
--- a/libtommath/pics/expt_state.sxd
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/expt_state.tif b/libtommath/pics/expt_state.tif
deleted file mode 100644
index 0aaee39..0000000
--- a/libtommath/pics/expt_state.tif
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/makefile b/libtommath/pics/makefile
deleted file mode 100644
index 3ecb02f..0000000
--- a/libtommath/pics/makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-# makes the images... yeah
-
-default: pses
-
-design_process.ps: design_process.tif
- tiff2ps -s -e design_process.tif > design_process.ps
-
-sliding_window.ps: sliding_window.tif
- tiff2ps -s -e sliding_window.tif > sliding_window.ps
-
-expt_state.ps: expt_state.tif
- tiff2ps -s -e expt_state.tif > expt_state.ps
-
-primality.ps: primality.tif
- tiff2ps -s -e primality.tif > primality.ps
-
-design_process.pdf: design_process.ps
- epstopdf design_process.ps
-
-sliding_window.pdf: sliding_window.ps
- epstopdf sliding_window.ps
-
-expt_state.pdf: expt_state.ps
- epstopdf expt_state.ps
-
-primality.pdf: primality.ps
- epstopdf primality.ps
-
-
-pses: sliding_window.ps expt_state.ps primality.ps design_process.ps
-pdfes: sliding_window.pdf expt_state.pdf primality.pdf design_process.pdf
-
-clean:
- rm -rf *.ps *.pdf .xvpics
- \ No newline at end of file
diff --git a/libtommath/pics/primality.tif b/libtommath/pics/primality.tif
deleted file mode 100644
index 83aafe0..0000000
--- a/libtommath/pics/primality.tif
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/radix.sxd b/libtommath/pics/radix.sxd
deleted file mode 100644
index b9eb9a0..0000000
--- a/libtommath/pics/radix.sxd
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/sliding_window.sxd b/libtommath/pics/sliding_window.sxd
deleted file mode 100644
index 91e7c0d..0000000
--- a/libtommath/pics/sliding_window.sxd
+++ /dev/null
Binary files differ
diff --git a/libtommath/pics/sliding_window.tif b/libtommath/pics/sliding_window.tif
deleted file mode 100644
index bb4cb96..0000000
--- a/libtommath/pics/sliding_window.tif
+++ /dev/null
Binary files differ
diff --git a/libtommath/poster.out b/libtommath/poster.out
deleted file mode 100644
index e69de29..0000000
--- a/libtommath/poster.out
+++ /dev/null
diff --git a/libtommath/poster.pdf b/libtommath/poster.pdf
deleted file mode 100644
index 1f705cf..0000000
--- a/libtommath/poster.pdf
+++ /dev/null
Binary files differ
diff --git a/libtommath/poster.tex b/libtommath/poster.tex
deleted file mode 100644
index e7388f4..0000000
--- a/libtommath/poster.tex
+++ /dev/null
@@ -1,35 +0,0 @@
-\documentclass[landscape,11pt]{article}
-\usepackage{amsmath, amssymb}
-\usepackage{hyperref}
-\begin{document}
-\hspace*{-3in}
-\begin{tabular}{llllll}
-$c = a + b$ & {\tt mp\_add(\&a, \&b, \&c)} & $b = 2a$ & {\tt mp\_mul\_2(\&a, \&b)} & \\
-$c = a - b$ & {\tt mp\_sub(\&a, \&b, \&c)} & $b = a/2$ & {\tt mp\_div\_2(\&a, \&b)} & \\
-$c = ab $ & {\tt mp\_mul(\&a, \&b, \&c)} & $c = 2^ba$ & {\tt mp\_mul\_2d(\&a, b, \&c)} \\
-$b = a^2 $ & {\tt mp\_sqr(\&a, \&b)} & $c = a/2^b, d = a \mod 2^b$ & {\tt mp\_div\_2d(\&a, b, \&c, \&d)} \\
-$c = \lfloor a/b \rfloor, d = a \mod b$ & {\tt mp\_div(\&a, \&b, \&c, \&d)} & $c = a \mod 2^b $ & {\tt mp\_mod\_2d(\&a, b, \&c)} \\
- && \\
-$a = b $ & {\tt mp\_set\_int(\&a, b)} & $c = a \vee b$ & {\tt mp\_or(\&a, \&b, \&c)} \\
-$b = a $ & {\tt mp\_copy(\&a, \&b)} & $c = a \wedge b$ & {\tt mp\_and(\&a, \&b, \&c)} \\
- && $c = a \oplus b$ & {\tt mp\_xor(\&a, \&b, \&c)} \\
- & \\
-$b = -a $ & {\tt mp\_neg(\&a, \&b)} & $d = a + b \mod c$ & {\tt mp\_addmod(\&a, \&b, \&c, \&d)} \\
-$b = |a| $ & {\tt mp\_abs(\&a, \&b)} & $d = a - b \mod c$ & {\tt mp\_submod(\&a, \&b, \&c, \&d)} \\
- && $d = ab \mod c$ & {\tt mp\_mulmod(\&a, \&b, \&c, \&d)} \\
-Compare $a$ and $b$ & {\tt mp\_cmp(\&a, \&b)} & $c = a^2 \mod b$ & {\tt mp\_sqrmod(\&a, \&b, \&c)} \\
-Is Zero? & {\tt mp\_iszero(\&a)} & $c = a^{-1} \mod b$ & {\tt mp\_invmod(\&a, \&b, \&c)} \\
-Is Even? & {\tt mp\_iseven(\&a)} & $d = a^b \mod c$ & {\tt mp\_exptmod(\&a, \&b, \&c, \&d)} \\
-Is Odd ? & {\tt mp\_isodd(\&a)} \\
-&\\
-$\vert \vert a \vert \vert$ & {\tt mp\_unsigned\_bin\_size(\&a)} & $res$ = 1 if $a$ prime to $t$ rounds? & {\tt mp\_prime\_is\_prime(\&a, t, \&res)} \\
-$buf \leftarrow a$ & {\tt mp\_to\_unsigned\_bin(\&a, buf)} & Next prime after $a$ to $t$ rounds. & {\tt mp\_prime\_next\_prime(\&a, t, bbs\_style)} \\
-$a \leftarrow buf[0..len-1]$ & {\tt mp\_read\_unsigned\_bin(\&a, buf, len)} \\
-&\\
-$b = \sqrt{a}$ & {\tt mp\_sqrt(\&a, \&b)} & $c = \mbox{gcd}(a, b)$ & {\tt mp\_gcd(\&a, \&b, \&c)} \\
-$c = a^{1/b}$ & {\tt mp\_n\_root(\&a, b, \&c)} & $c = \mbox{lcm}(a, b)$ & {\tt mp\_lcm(\&a, \&b, \&c)} \\
-&\\
-Greater Than & MP\_GT & Equal To & MP\_EQ \\
-Less Than & MP\_LT & Bits per digit & DIGIT\_BIT \\
-\end{tabular}
-\end{document}
diff --git a/libtommath/pre_gen/mpi.c b/libtommath/pre_gen/mpi.c
deleted file mode 100644
index d2224c0..0000000
--- a/libtommath/pre_gen/mpi.c
+++ /dev/null
@@ -1,9048 +0,0 @@
-/* Start: bn_error.c */
-#include <tommath.h>
-#ifdef BN_ERROR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-static const struct {
- int code;
- char *msg;
-} msgs[] = {
- { MP_OKAY, "Successful" },
- { MP_MEM, "Out of heap" },
- { MP_VAL, "Value out of range" }
-};
-
-/* return a char * string for a given code */
-char *mp_error_to_string(int code)
-{
- int x;
-
- /* scan the lookup table for the given message */
- for (x = 0; x < (int)(sizeof(msgs) / sizeof(msgs[0])); x++) {
- if (msgs[x].code == code) {
- return msgs[x].msg;
- }
- }
-
- /* generic reply for invalid code */
- return "Invalid error code";
-}
-
-#endif
-
-/* End: bn_error.c */
-
-/* Start: bn_fast_mp_invmod.c */
-#include <tommath.h>
-#ifdef BN_FAST_MP_INVMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes the modular inverse via binary extended euclidean algorithm,
- * that is c = 1/a mod b
- *
- * Based on slow invmod except this is optimized for the case where b is
- * odd as per HAC Note 14.64 on pp. 610
- */
-int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int x, y, u, v, B, D;
- int res, neg;
-
- /* 2. [modified] b must be odd */
- if (mp_iseven (b) == 1) {
- return MP_VAL;
- }
-
- /* init all our temps */
- if ((res = mp_init_multi(&x, &y, &u, &v, &B, &D, NULL)) != MP_OKAY) {
- return res;
- }
-
- /* x == modulus, y == value to invert */
- if ((res = mp_copy (b, &x)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- /* we need y = |a| */
- if ((res = mp_mod (a, b, &y)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
- if ((res = mp_copy (&x, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_copy (&y, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
- mp_set (&D, 1);
-
-top:
- /* 4. while u is even do */
- while (mp_iseven (&u) == 1) {
- /* 4.1 u = u/2 */
- if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
- /* 4.2 if B is odd then */
- if (mp_isodd (&B) == 1) {
- if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
- /* B = B/2 */
- if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* 5. while v is even do */
- while (mp_iseven (&v) == 1) {
- /* 5.1 v = v/2 */
- if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
- /* 5.2 if D is odd then */
- if (mp_isodd (&D) == 1) {
- /* D = (D-x)/2 */
- if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
- /* D = D/2 */
- if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* 6. if u >= v then */
- if (mp_cmp (&u, &v) != MP_LT) {
- /* u = u - v, B = B - D */
- if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- } else {
- /* v - v - u, D = D - B */
- if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* if not zero goto step 4 */
- if (mp_iszero (&u) == 0) {
- goto top;
- }
-
- /* now a = C, b = D, gcd == g*v */
-
- /* if v != 1 then there is no inverse */
- if (mp_cmp_d (&v, 1) != MP_EQ) {
- res = MP_VAL;
- goto LBL_ERR;
- }
-
- /* b is now the inverse */
- neg = a->sign;
- while (D.sign == MP_NEG) {
- if ((res = mp_add (&D, b, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
- mp_exch (&D, c);
- c->sign = neg;
- res = MP_OKAY;
-
-LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
- return res;
-}
-#endif
-
-/* End: bn_fast_mp_invmod.c */
-
-/* Start: bn_fast_mp_montgomery_reduce.c */
-#include <tommath.h>
-#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes xR**-1 == x (mod N) via Montgomery Reduction
- *
- * This is an optimized implementation of montgomery_reduce
- * which uses the comba method to quickly calculate the columns of the
- * reduction.
- *
- * Based on Algorithm 14.32 on pp.601 of HAC.
-*/
-int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
-{
- int ix, res, olduse;
- mp_word W[MP_WARRAY];
-
- /* get old used count */
- olduse = x->used;
-
- /* grow a as required */
- if (x->alloc < n->used + 1) {
- if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* first we have to get the digits of the input into
- * an array of double precision words W[...]
- */
- {
- register mp_word *_W;
- register mp_digit *tmpx;
-
- /* alias for the W[] array */
- _W = W;
-
- /* alias for the digits of x*/
- tmpx = x->dp;
-
- /* copy the digits of a into W[0..a->used-1] */
- for (ix = 0; ix < x->used; ix++) {
- *_W++ = *tmpx++;
- }
-
- /* zero the high words of W[a->used..m->used*2] */
- for (; ix < n->used * 2 + 1; ix++) {
- *_W++ = 0;
- }
- }
-
- /* now we proceed to zero successive digits
- * from the least significant upwards
- */
- for (ix = 0; ix < n->used; ix++) {
- /* mu = ai * m' mod b
- *
- * We avoid a double precision multiplication (which isn't required)
- * by casting the value down to a mp_digit. Note this requires
- * that W[ix-1] have the carry cleared (see after the inner loop)
- */
- register mp_digit mu;
- mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK);
-
- /* a = a + mu * m * b**i
- *
- * This is computed in place and on the fly. The multiplication
- * by b**i is handled by offseting which columns the results
- * are added to.
- *
- * Note the comba method normally doesn't handle carries in the
- * inner loop In this case we fix the carry from the previous
- * column since the Montgomery reduction requires digits of the
- * result (so far) [see above] to work. This is
- * handled by fixing up one carry after the inner loop. The
- * carry fixups are done in order so after these loops the
- * first m->used words of W[] have the carries fixed
- */
- {
- register int iy;
- register mp_digit *tmpn;
- register mp_word *_W;
-
- /* alias for the digits of the modulus */
- tmpn = n->dp;
-
- /* Alias for the columns set by an offset of ix */
- _W = W + ix;
-
- /* inner loop */
- for (iy = 0; iy < n->used; iy++) {
- *_W++ += ((mp_word)mu) * ((mp_word)*tmpn++);
- }
- }
-
- /* now fix carry for next digit, W[ix+1] */
- W[ix + 1] += W[ix] >> ((mp_word) DIGIT_BIT);
- }
-
- /* now we have to propagate the carries and
- * shift the words downward [all those least
- * significant digits we zeroed].
- */
- {
- register mp_digit *tmpx;
- register mp_word *_W, *_W1;
-
- /* nox fix rest of carries */
-
- /* alias for current word */
- _W1 = W + ix;
-
- /* alias for next word, where the carry goes */
- _W = W + ++ix;
-
- for (; ix <= n->used * 2 + 1; ix++) {
- *_W++ += *_W1++ >> ((mp_word) DIGIT_BIT);
- }
-
- /* copy out, A = A/b**n
- *
- * The result is A/b**n but instead of converting from an
- * array of mp_word to mp_digit than calling mp_rshd
- * we just copy them in the right order
- */
-
- /* alias for destination word */
- tmpx = x->dp;
-
- /* alias for shifted double precision result */
- _W = W + n->used;
-
- for (ix = 0; ix < n->used + 1; ix++) {
- *tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK));
- }
-
- /* zero oldused digits, if the input a was larger than
- * m->used+1 we'll have to clear the digits
- */
- for (; ix < olduse; ix++) {
- *tmpx++ = 0;
- }
- }
-
- /* set the max used and clamp */
- x->used = n->used + 1;
- mp_clamp (x);
-
- /* if A >= m then A = A - m */
- if (mp_cmp_mag (x, n) != MP_LT) {
- return s_mp_sub (x, n, x);
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_fast_mp_montgomery_reduce.c */
-
-/* Start: bn_fast_s_mp_mul_digs.c */
-#include <tommath.h>
-#ifdef BN_FAST_S_MP_MUL_DIGS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Fast (comba) multiplier
- *
- * This is the fast column-array [comba] multiplier. It is
- * designed to compute the columns of the product first
- * then handle the carries afterwards. This has the effect
- * of making the nested loops that compute the columns very
- * simple and schedulable on super-scalar processors.
- *
- * This has been modified to produce a variable number of
- * digits of output so if say only a half-product is required
- * you don't have to compute the upper half (a feature
- * required for fast Barrett reduction).
- *
- * Based on Algorithm 14.12 on pp.595 of HAC.
- *
- */
-int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
- int olduse, res, pa, ix, iz;
- mp_digit W[MP_WARRAY];
- register mp_word _W;
-
- /* grow the destination as required */
- if (c->alloc < digs) {
- if ((res = mp_grow (c, digs)) != MP_OKAY) {
- return res;
- }
- }
-
- /* number of output digits to produce */
- pa = MIN(digs, a->used + b->used);
-
- /* clear the carry */
- _W = 0;
- for (ix = 0; ix < pa; ix++) {
- int tx, ty;
- int iy;
- mp_digit *tmpx, *tmpy;
-
- /* get offsets into the two bignums */
- ty = MIN(b->used-1, ix);
- tx = ix - ty;
-
- /* setup temp aliases */
- tmpx = a->dp + tx;
- tmpy = b->dp + ty;
-
- /* this is the number of times the loop will iterrate, essentially
- while (tx++ < a->used && ty-- >= 0) { ... }
- */
- iy = MIN(a->used-tx, ty+1);
-
- /* execute loop */
- for (iz = 0; iz < iy; ++iz) {
- _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
-
- }
-
- /* store term */
- W[ix] = ((mp_digit)_W) & MP_MASK;
-
- /* make next carry */
- _W = _W >> ((mp_word)DIGIT_BIT);
- }
-
- /* setup dest */
- olduse = c->used;
- c->used = pa;
-
- {
- register mp_digit *tmpc;
- tmpc = c->dp;
- for (ix = 0; ix < pa+1; ix++) {
- /* now extract the previous digit [below the carry] */
- *tmpc++ = W[ix];
- }
-
- /* clear unused digits [that existed in the old copy of c] */
- for (; ix < olduse; ix++) {
- *tmpc++ = 0;
- }
- }
- mp_clamp (c);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_fast_s_mp_mul_digs.c */
-
-/* Start: bn_fast_s_mp_mul_high_digs.c */
-#include <tommath.h>
-#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* this is a modified version of fast_s_mul_digs that only produces
- * output digits *above* digs. See the comments for fast_s_mul_digs
- * to see how it works.
- *
- * This is used in the Barrett reduction since for one of the multiplications
- * only the higher digits were needed. This essentially halves the work.
- *
- * Based on Algorithm 14.12 on pp.595 of HAC.
- */
-int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
- int olduse, res, pa, ix, iz;
- mp_digit W[MP_WARRAY];
- mp_word _W;
-
- /* grow the destination as required */
- pa = a->used + b->used;
- if (c->alloc < pa) {
- if ((res = mp_grow (c, pa)) != MP_OKAY) {
- return res;
- }
- }
-
- /* number of output digits to produce */
- pa = a->used + b->used;
- _W = 0;
- for (ix = digs; ix < pa; ix++) {
- int tx, ty, iy;
- mp_digit *tmpx, *tmpy;
-
- /* get offsets into the two bignums */
- ty = MIN(b->used-1, ix);
- tx = ix - ty;
-
- /* setup temp aliases */
- tmpx = a->dp + tx;
- tmpy = b->dp + ty;
-
- /* this is the number of times the loop will iterrate, essentially its
- while (tx++ < a->used && ty-- >= 0) { ... }
- */
- iy = MIN(a->used-tx, ty+1);
-
- /* execute loop */
- for (iz = 0; iz < iy; iz++) {
- _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
- }
-
- /* store term */
- W[ix] = ((mp_digit)_W) & MP_MASK;
-
- /* make next carry */
- _W = _W >> ((mp_word)DIGIT_BIT);
- }
-
- /* setup dest */
- olduse = c->used;
- c->used = pa;
-
- {
- register mp_digit *tmpc;
-
- tmpc = c->dp + digs;
- for (ix = digs; ix < pa; ix++) {
- /* now extract the previous digit [below the carry] */
- *tmpc++ = W[ix];
- }
-
- /* clear unused digits [that existed in the old copy of c] */
- for (; ix < olduse; ix++) {
- *tmpc++ = 0;
- }
- }
- mp_clamp (c);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_fast_s_mp_mul_high_digs.c */
-
-/* Start: bn_fast_s_mp_sqr.c */
-#include <tommath.h>
-#ifdef BN_FAST_S_MP_SQR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* the jist of squaring...
- * you do like mult except the offset of the tmpx [one that
- * starts closer to zero] can't equal the offset of tmpy.
- * So basically you set up iy like before then you min it with
- * (ty-tx) so that it never happens. You double all those
- * you add in the inner loop
-
-After that loop you do the squares and add them in.
-*/
-
-int fast_s_mp_sqr (mp_int * a, mp_int * b)
-{
- int olduse, res, pa, ix, iz;
- mp_digit W[MP_WARRAY], *tmpx;
- mp_word W1;
-
- /* grow the destination as required */
- pa = a->used + a->used;
- if (b->alloc < pa) {
- if ((res = mp_grow (b, pa)) != MP_OKAY) {
- return res;
- }
- }
-
- /* number of output digits to produce */
- W1 = 0;
- for (ix = 0; ix < pa; ix++) {
- int tx, ty, iy;
- mp_word _W;
- mp_digit *tmpy;
-
- /* clear counter */
- _W = 0;
-
- /* get offsets into the two bignums */
- ty = MIN(a->used-1, ix);
- tx = ix - ty;
-
- /* setup temp aliases */
- tmpx = a->dp + tx;
- tmpy = a->dp + ty;
-
- /* this is the number of times the loop will iterrate, essentially
- while (tx++ < a->used && ty-- >= 0) { ... }
- */
- iy = MIN(a->used-tx, ty+1);
-
- /* now for squaring tx can never equal ty
- * we halve the distance since they approach at a rate of 2x
- * and we have to round because odd cases need to be executed
- */
- iy = MIN(iy, (ty-tx+1)>>1);
-
- /* execute loop */
- for (iz = 0; iz < iy; iz++) {
- _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
- }
-
- /* double the inner product and add carry */
- _W = _W + _W + W1;
-
- /* even columns have the square term in them */
- if ((ix&1) == 0) {
- _W += ((mp_word)a->dp[ix>>1])*((mp_word)a->dp[ix>>1]);
- }
-
- /* store it */
- W[ix] = (mp_digit)(_W & MP_MASK);
-
- /* make next carry */
- W1 = _W >> ((mp_word)DIGIT_BIT);
- }
-
- /* setup dest */
- olduse = b->used;
- b->used = a->used+a->used;
-
- {
- mp_digit *tmpb;
- tmpb = b->dp;
- for (ix = 0; ix < pa; ix++) {
- *tmpb++ = W[ix] & MP_MASK;
- }
-
- /* clear unused digits [that existed in the old copy of c] */
- for (; ix < olduse; ix++) {
- *tmpb++ = 0;
- }
- }
- mp_clamp (b);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_fast_s_mp_sqr.c */
-
-/* Start: bn_mp_2expt.c */
-#include <tommath.h>
-#ifdef BN_MP_2EXPT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes a = 2**b
- *
- * Simple algorithm which zeroes the int, grows it then just sets one bit
- * as required.
- */
-int
-mp_2expt (mp_int * a, int b)
-{
- int res;
-
- /* zero a as per default */
- mp_zero (a);
-
- /* grow a to accomodate the single bit */
- if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) {
- return res;
- }
-
- /* set the used count of where the bit will go */
- a->used = b / DIGIT_BIT + 1;
-
- /* put the single bit in its place */
- a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_2expt.c */
-
-/* Start: bn_mp_abs.c */
-#include <tommath.h>
-#ifdef BN_MP_ABS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* b = |a|
- *
- * Simple function copies the input and fixes the sign to positive
- */
-int
-mp_abs (mp_int * a, mp_int * b)
-{
- int res;
-
- /* copy a to b */
- if (a != b) {
- if ((res = mp_copy (a, b)) != MP_OKAY) {
- return res;
- }
- }
-
- /* force the sign of b to positive */
- b->sign = MP_ZPOS;
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_abs.c */
-
-/* Start: bn_mp_add.c */
-#include <tommath.h>
-#ifdef BN_MP_ADD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* high level addition (handles signs) */
-int mp_add (mp_int * a, mp_int * b, mp_int * c)
-{
- int sa, sb, res;
-
- /* get sign of both inputs */
- sa = a->sign;
- sb = b->sign;
-
- /* handle two cases, not four */
- if (sa == sb) {
- /* both positive or both negative */
- /* add their magnitudes, copy the sign */
- c->sign = sa;
- res = s_mp_add (a, b, c);
- } else {
- /* one positive, the other negative */
- /* subtract the one with the greater magnitude from */
- /* the one of the lesser magnitude. The result gets */
- /* the sign of the one with the greater magnitude. */
- if (mp_cmp_mag (a, b) == MP_LT) {
- c->sign = sb;
- res = s_mp_sub (b, a, c);
- } else {
- c->sign = sa;
- res = s_mp_sub (a, b, c);
- }
- }
- return res;
-}
-
-#endif
-
-/* End: bn_mp_add.c */
-
-/* Start: bn_mp_add_d.c */
-#include <tommath.h>
-#ifdef BN_MP_ADD_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* single digit addition */
-int
-mp_add_d (mp_int * a, mp_digit b, mp_int * c)
-{
- int res, ix, oldused;
- mp_digit *tmpa, *tmpc, mu;
-
- /* grow c as required */
- if (c->alloc < a->used + 1) {
- if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* if a is negative and |a| >= b, call c = |a| - b */
- if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) {
- /* temporarily fix sign of a */
- a->sign = MP_ZPOS;
-
- /* c = |a| - b */
- res = mp_sub_d(a, b, c);
-
- /* fix sign */
- a->sign = c->sign = MP_NEG;
-
- /* clamp */
- mp_clamp(c);
-
- return res;
- }
-
- /* old number of used digits in c */
- oldused = c->used;
-
- /* sign always positive */
- c->sign = MP_ZPOS;
-
- /* source alias */
- tmpa = a->dp;
-
- /* destination alias */
- tmpc = c->dp;
-
- /* if a is positive */
- if (a->sign == MP_ZPOS) {
- /* add digit, after this we're propagating
- * the carry.
- */
- *tmpc = *tmpa++ + b;
- mu = *tmpc >> DIGIT_BIT;
- *tmpc++ &= MP_MASK;
-
- /* now handle rest of the digits */
- for (ix = 1; ix < a->used; ix++) {
- *tmpc = *tmpa++ + mu;
- mu = *tmpc >> DIGIT_BIT;
- *tmpc++ &= MP_MASK;
- }
- /* set final carry */
- ix++;
- *tmpc++ = mu;
-
- /* setup size */
- c->used = a->used + 1;
- } else {
- /* a was negative and |a| < b */
- c->used = 1;
-
- /* the result is a single digit */
- if (a->used == 1) {
- *tmpc++ = b - a->dp[0];
- } else {
- *tmpc++ = b;
- }
-
- /* setup count so the clearing of oldused
- * can fall through correctly
- */
- ix = 1;
- }
-
- /* now zero to oldused */
- while (ix++ < oldused) {
- *tmpc++ = 0;
- }
- mp_clamp(c);
-
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_add_d.c */
-
-/* Start: bn_mp_addmod.c */
-#include <tommath.h>
-#ifdef BN_MP_ADDMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* d = a + b (mod c) */
-int
-mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
- int res;
- mp_int t;
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_add (a, b, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- res = mp_mod (&t, c, d);
- mp_clear (&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_addmod.c */
-
-/* Start: bn_mp_and.c */
-#include <tommath.h>
-#ifdef BN_MP_AND_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* AND two ints together */
-int
-mp_and (mp_int * a, mp_int * b, mp_int * c)
-{
- int res, ix, px;
- mp_int t, *x;
-
- if (a->used > b->used) {
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
- px = b->used;
- x = b;
- } else {
- if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
- return res;
- }
- px = a->used;
- x = a;
- }
-
- for (ix = 0; ix < px; ix++) {
- t.dp[ix] &= x->dp[ix];
- }
-
- /* zero digits above the last from the smallest mp_int */
- for (; ix < t.used; ix++) {
- t.dp[ix] = 0;
- }
-
- mp_clamp (&t);
- mp_exch (c, &t);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_and.c */
-
-/* Start: bn_mp_clamp.c */
-#include <tommath.h>
-#ifdef BN_MP_CLAMP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* trim unused digits
- *
- * This is used to ensure that leading zero digits are
- * trimed and the leading "used" digit will be non-zero
- * Typically very fast. Also fixes the sign if there
- * are no more leading digits
- */
-void
-mp_clamp (mp_int * a)
-{
- /* decrease used while the most significant digit is
- * zero.
- */
- while (a->used > 0 && a->dp[a->used - 1] == 0) {
- --(a->used);
- }
-
- /* reset the sign flag if used == 0 */
- if (a->used == 0) {
- a->sign = MP_ZPOS;
- }
-}
-#endif
-
-/* End: bn_mp_clamp.c */
-
-/* Start: bn_mp_clear.c */
-#include <tommath.h>
-#ifdef BN_MP_CLEAR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* clear one (frees) */
-void
-mp_clear (mp_int * a)
-{
- int i;
-
- /* only do anything if a hasn't been freed previously */
- if (a->dp != NULL) {
- /* first zero the digits */
- for (i = 0; i < a->used; i++) {
- a->dp[i] = 0;
- }
-
- /* free ram */
- XFREE(a->dp);
-
- /* reset members to make debugging easier */
- a->dp = NULL;
- a->alloc = a->used = 0;
- a->sign = MP_ZPOS;
- }
-}
-#endif
-
-/* End: bn_mp_clear.c */
-
-/* Start: bn_mp_clear_multi.c */
-#include <tommath.h>
-#ifdef BN_MP_CLEAR_MULTI_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-#include <stdarg.h>
-
-void mp_clear_multi(mp_int *mp, ...)
-{
- mp_int* next_mp = mp;
- va_list args;
- va_start(args, mp);
- while (next_mp != NULL) {
- mp_clear(next_mp);
- next_mp = va_arg(args, mp_int*);
- }
- va_end(args);
-}
-#endif
-
-/* End: bn_mp_clear_multi.c */
-
-/* Start: bn_mp_cmp.c */
-#include <tommath.h>
-#ifdef BN_MP_CMP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* compare two ints (signed)*/
-int
-mp_cmp (mp_int * a, mp_int * b)
-{
- /* compare based on sign */
- if (a->sign != b->sign) {
- if (a->sign == MP_NEG) {
- return MP_LT;
- } else {
- return MP_GT;
- }
- }
-
- /* compare digits */
- if (a->sign == MP_NEG) {
- /* if negative compare opposite direction */
- return mp_cmp_mag(b, a);
- } else {
- return mp_cmp_mag(a, b);
- }
-}
-#endif
-
-/* End: bn_mp_cmp.c */
-
-/* Start: bn_mp_cmp_d.c */
-#include <tommath.h>
-#ifdef BN_MP_CMP_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* compare a digit */
-int mp_cmp_d(mp_int * a, mp_digit b)
-{
- /* compare based on sign */
- if (a->sign == MP_NEG) {
- return MP_LT;
- }
-
- /* compare based on magnitude */
- if (a->used > 1) {
- return MP_GT;
- }
-
- /* compare the only digit of a to b */
- if (a->dp[0] > b) {
- return MP_GT;
- } else if (a->dp[0] < b) {
- return MP_LT;
- } else {
- return MP_EQ;
- }
-}
-#endif
-
-/* End: bn_mp_cmp_d.c */
-
-/* Start: bn_mp_cmp_mag.c */
-#include <tommath.h>
-#ifdef BN_MP_CMP_MAG_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* compare maginitude of two ints (unsigned) */
-int mp_cmp_mag (mp_int * a, mp_int * b)
-{
- int n;
- mp_digit *tmpa, *tmpb;
-
- /* compare based on # of non-zero digits */
- if (a->used > b->used) {
- return MP_GT;
- }
-
- if (a->used < b->used) {
- return MP_LT;
- }
-
- /* alias for a */
- tmpa = a->dp + (a->used - 1);
-
- /* alias for b */
- tmpb = b->dp + (a->used - 1);
-
- /* compare based on digits */
- for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
- if (*tmpa > *tmpb) {
- return MP_GT;
- }
-
- if (*tmpa < *tmpb) {
- return MP_LT;
- }
- }
- return MP_EQ;
-}
-#endif
-
-/* End: bn_mp_cmp_mag.c */
-
-/* Start: bn_mp_cnt_lsb.c */
-#include <tommath.h>
-#ifdef BN_MP_CNT_LSB_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-static const int lnz[16] = {
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
-};
-
-/* Counts the number of lsbs which are zero before the first zero bit */
-int mp_cnt_lsb(mp_int *a)
-{
- int x;
- mp_digit q, qq;
-
- /* easy out */
- if (mp_iszero(a) == 1) {
- return 0;
- }
-
- /* scan lower digits until non-zero */
- for (x = 0; x < a->used && a->dp[x] == 0; x++);
- q = a->dp[x];
- x *= DIGIT_BIT;
-
- /* now scan this digit until a 1 is found */
- if ((q & 1) == 0) {
- do {
- qq = q & 15;
- x += lnz[qq];
- q >>= 4;
- } while (qq == 0);
- }
- return x;
-}
-
-#endif
-
-/* End: bn_mp_cnt_lsb.c */
-
-/* Start: bn_mp_copy.c */
-#include <tommath.h>
-#ifdef BN_MP_COPY_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* copy, b = a */
-int
-mp_copy (mp_int * a, mp_int * b)
-{
- int res, n;
-
- /* if dst == src do nothing */
- if (a == b) {
- return MP_OKAY;
- }
-
- /* grow dest */
- if (b->alloc < a->used) {
- if ((res = mp_grow (b, a->used)) != MP_OKAY) {
- return res;
- }
- }
-
- /* zero b and copy the parameters over */
- {
- register mp_digit *tmpa, *tmpb;
-
- /* pointer aliases */
-
- /* source */
- tmpa = a->dp;
-
- /* destination */
- tmpb = b->dp;
-
- /* copy all the digits */
- for (n = 0; n < a->used; n++) {
- *tmpb++ = *tmpa++;
- }
-
- /* clear high digits */
- for (; n < b->used; n++) {
- *tmpb++ = 0;
- }
- }
-
- /* copy used count and sign */
- b->used = a->used;
- b->sign = a->sign;
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_copy.c */
-
-/* Start: bn_mp_count_bits.c */
-#include <tommath.h>
-#ifdef BN_MP_COUNT_BITS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* returns the number of bits in an int */
-int
-mp_count_bits (mp_int * a)
-{
- int r;
- mp_digit q;
-
- /* shortcut */
- if (a->used == 0) {
- return 0;
- }
-
- /* get number of digits and add that */
- r = (a->used - 1) * DIGIT_BIT;
-
- /* take the last digit and count the bits in it */
- q = a->dp[a->used - 1];
- while (q > ((mp_digit) 0)) {
- ++r;
- q >>= ((mp_digit) 1);
- }
- return r;
-}
-#endif
-
-/* End: bn_mp_count_bits.c */
-
-/* Start: bn_mp_div.c */
-#include <tommath.h>
-#ifdef BN_MP_DIV_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-#ifdef BN_MP_DIV_SMALL
-
-/* slower bit-bang division... also smaller */
-int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
- mp_int ta, tb, tq, q;
- int res, n, n2;
-
- /* is divisor zero ? */
- if (mp_iszero (b) == 1) {
- return MP_VAL;
- }
-
- /* if a < b then q=0, r = a */
- if (mp_cmp_mag (a, b) == MP_LT) {
- if (d != NULL) {
- res = mp_copy (a, d);
- } else {
- res = MP_OKAY;
- }
- if (c != NULL) {
- mp_zero (c);
- }
- return res;
- }
-
- /* init our temps */
- if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) {
- return res;
- }
-
-
- mp_set(&tq, 1);
- n = mp_count_bits(a) - mp_count_bits(b);
- if (((res = mp_abs(a, &ta)) != MP_OKAY) ||
- ((res = mp_abs(b, &tb)) != MP_OKAY) ||
- ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) ||
- ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) {
- goto LBL_ERR;
- }
-
- while (n-- >= 0) {
- if (mp_cmp(&tb, &ta) != MP_GT) {
- if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) ||
- ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) {
- goto LBL_ERR;
- }
- }
- if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) ||
- ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) {
- goto LBL_ERR;
- }
- }
-
- /* now q == quotient and ta == remainder */
- n = a->sign;
- n2 = (a->sign == b->sign ? MP_ZPOS : MP_NEG);
- if (c != NULL) {
- mp_exch(c, &q);
- c->sign = (mp_iszero(c) == MP_YES) ? MP_ZPOS : n2;
- }
- if (d != NULL) {
- mp_exch(d, &ta);
- d->sign = (mp_iszero(d) == MP_YES) ? MP_ZPOS : n;
- }
-LBL_ERR:
- mp_clear_multi(&ta, &tb, &tq, &q, NULL);
- return res;
-}
-
-#else
-
-/* integer signed division.
- * c*b + d == a [e.g. a/b, c=quotient, d=remainder]
- * HAC pp.598 Algorithm 14.20
- *
- * Note that the description in HAC is horribly
- * incomplete. For example, it doesn't consider
- * the case where digits are removed from 'x' in
- * the inner loop. It also doesn't consider the
- * case that y has fewer than three digits, etc..
- *
- * The overall algorithm is as described as
- * 14.20 from HAC but fixed to treat these cases.
-*/
-int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
- mp_int q, x, y, t1, t2;
- int res, n, t, i, norm, neg;
-
- /* is divisor zero ? */
- if (mp_iszero (b) == 1) {
- return MP_VAL;
- }
-
- /* if a < b then q=0, r = a */
- if (mp_cmp_mag (a, b) == MP_LT) {
- if (d != NULL) {
- res = mp_copy (a, d);
- } else {
- res = MP_OKAY;
- }
- if (c != NULL) {
- mp_zero (c);
- }
- return res;
- }
-
- if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) {
- return res;
- }
- q.used = a->used + 2;
-
- if ((res = mp_init (&t1)) != MP_OKAY) {
- goto LBL_Q;
- }
-
- if ((res = mp_init (&t2)) != MP_OKAY) {
- goto LBL_T1;
- }
-
- if ((res = mp_init_copy (&x, a)) != MP_OKAY) {
- goto LBL_T2;
- }
-
- if ((res = mp_init_copy (&y, b)) != MP_OKAY) {
- goto LBL_X;
- }
-
- /* fix the sign */
- neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
- x.sign = y.sign = MP_ZPOS;
-
- /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */
- norm = mp_count_bits(&y) % DIGIT_BIT;
- if (norm < (int)(DIGIT_BIT-1)) {
- norm = (DIGIT_BIT-1) - norm;
- if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) {
- goto LBL_Y;
- }
- if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) {
- goto LBL_Y;
- }
- } else {
- norm = 0;
- }
-
- /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */
- n = x.used - 1;
- t = y.used - 1;
-
- /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */
- if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
- goto LBL_Y;
- }
-
- while (mp_cmp (&x, &y) != MP_LT) {
- ++(q.dp[n - t]);
- if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) {
- goto LBL_Y;
- }
- }
-
- /* reset y by shifting it back down */
- mp_rshd (&y, n - t);
-
- /* step 3. for i from n down to (t + 1) */
- for (i = n; i >= (t + 1); i--) {
- if (i > x.used) {
- continue;
- }
-
- /* step 3.1 if xi == yt then set q{i-t-1} to b-1,
- * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */
- if (x.dp[i] == y.dp[t]) {
- q.dp[i - t - 1] = ((((mp_digit)1) << DIGIT_BIT) - 1);
- } else {
- mp_word tmp;
- tmp = ((mp_word) x.dp[i]) << ((mp_word) DIGIT_BIT);
- tmp |= ((mp_word) x.dp[i - 1]);
- tmp /= ((mp_word) y.dp[t]);
- if (tmp > (mp_word) MP_MASK)
- tmp = MP_MASK;
- q.dp[i - t - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK));
- }
-
- /* while (q{i-t-1} * (yt * b + y{t-1})) >
- xi * b**2 + xi-1 * b + xi-2
-
- do q{i-t-1} -= 1;
- */
- q.dp[i - t - 1] = (q.dp[i - t - 1] + 1) & MP_MASK;
- do {
- q.dp[i - t - 1] = (q.dp[i - t - 1] - 1) & MP_MASK;
-
- /* find left hand */
- mp_zero (&t1);
- t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1];
- t1.dp[1] = y.dp[t];
- t1.used = 2;
- if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- /* find right hand */
- t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2];
- t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1];
- t2.dp[2] = x.dp[i];
- t2.used = 3;
- } while (mp_cmp_mag(&t1, &t2) == MP_GT);
-
- /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */
- if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */
- if (x.sign == MP_NEG) {
- if ((res = mp_copy (&y, &t1)) != MP_OKAY) {
- goto LBL_Y;
- }
- if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
- goto LBL_Y;
- }
- if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- q.dp[i - t - 1] = (q.dp[i - t - 1] - 1UL) & MP_MASK;
- }
- }
-
- /* now q is the quotient and x is the remainder
- * [which we have to normalize]
- */
-
- /* get sign before writing to c */
- x.sign = x.used == 0 ? MP_ZPOS : a->sign;
-
- if (c != NULL) {
- mp_clamp (&q);
- mp_exch (&q, c);
- c->sign = neg;
- }
-
- if (d != NULL) {
- mp_div_2d (&x, norm, &x, NULL);
- mp_exch (&x, d);
- }
-
- res = MP_OKAY;
-
-LBL_Y:mp_clear (&y);
-LBL_X:mp_clear (&x);
-LBL_T2:mp_clear (&t2);
-LBL_T1:mp_clear (&t1);
-LBL_Q:mp_clear (&q);
- return res;
-}
-
-#endif
-
-#endif
-
-/* End: bn_mp_div.c */
-
-/* Start: bn_mp_div_2.c */
-#include <tommath.h>
-#ifdef BN_MP_DIV_2_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* b = a/2 */
-int mp_div_2(mp_int * a, mp_int * b)
-{
- int x, res, oldused;
-
- /* copy */
- if (b->alloc < a->used) {
- if ((res = mp_grow (b, a->used)) != MP_OKAY) {
- return res;
- }
- }
-
- oldused = b->used;
- b->used = a->used;
- {
- register mp_digit r, rr, *tmpa, *tmpb;
-
- /* source alias */
- tmpa = a->dp + b->used - 1;
-
- /* dest alias */
- tmpb = b->dp + b->used - 1;
-
- /* carry */
- r = 0;
- for (x = b->used - 1; x >= 0; x--) {
- /* get the carry for the next iteration */
- rr = *tmpa & 1;
-
- /* shift the current digit, add in carry and store */
- *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1));
-
- /* forward carry to next iteration */
- r = rr;
- }
-
- /* zero excess digits */
- tmpb = b->dp + b->used;
- for (x = b->used; x < oldused; x++) {
- *tmpb++ = 0;
- }
- }
- b->sign = a->sign;
- mp_clamp (b);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_div_2.c */
-
-/* Start: bn_mp_div_2d.c */
-#include <tommath.h>
-#ifdef BN_MP_DIV_2D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
-int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
-{
- mp_digit D, r, rr;
- int x, res;
- mp_int t;
-
-
- /* if the shift count is <= 0 then we do no work */
- if (b <= 0) {
- res = mp_copy (a, c);
- if (d != NULL) {
- mp_zero (d);
- }
- return res;
- }
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- /* get the remainder */
- if (d != NULL) {
- if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- }
-
- /* copy */
- if ((res = mp_copy (a, c)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
-
- /* shift by as many digits in the bit count */
- if (b >= (int)DIGIT_BIT) {
- mp_rshd (c, b / DIGIT_BIT);
- }
-
- /* shift any bit count < DIGIT_BIT */
- D = (mp_digit) (b % DIGIT_BIT);
- if (D != 0) {
- register mp_digit *tmpc, mask, shift;
-
- /* mask */
- mask = (((mp_digit)1) << D) - 1;
-
- /* shift for lsb */
- shift = DIGIT_BIT - D;
-
- /* alias */
- tmpc = c->dp + (c->used - 1);
-
- /* carry */
- r = 0;
- for (x = c->used - 1; x >= 0; x--) {
- /* get the lower bits of this word in a temp */
- rr = *tmpc & mask;
-
- /* shift the current word and mix in the carry bits from the previous word */
- *tmpc = (*tmpc >> D) | (r << shift);
- --tmpc;
-
- /* set the carry to the carry bits of the current word found above */
- r = rr;
- }
- }
- mp_clamp (c);
- if (d != NULL) {
- mp_exch (&t, d);
- }
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_div_2d.c */
-
-/* Start: bn_mp_div_3.c */
-#include <tommath.h>
-#ifdef BN_MP_DIV_3_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* divide by three (based on routine from MPI and the GMP manual) */
-int
-mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
-{
- mp_int q;
- mp_word w, t;
- mp_digit b;
- int res, ix;
-
- /* b = 2**DIGIT_BIT / 3 */
- b = (((mp_word)1) << ((mp_word)DIGIT_BIT)) / ((mp_word)3);
-
- if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
- return res;
- }
-
- q.used = a->used;
- q.sign = a->sign;
- w = 0;
- for (ix = a->used - 1; ix >= 0; ix--) {
- w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]);
-
- if (w >= 3) {
- /* multiply w by [1/3] */
- t = (w * ((mp_word)b)) >> ((mp_word)DIGIT_BIT);
-
- /* now subtract 3 * [w/3] from w, to get the remainder */
- w -= t+t+t;
-
- /* fixup the remainder as required since
- * the optimization is not exact.
- */
- while (w >= 3) {
- t += 1;
- w -= 3;
- }
- } else {
- t = 0;
- }
- q.dp[ix] = (mp_digit)t;
- }
-
- /* [optional] store the remainder */
- if (d != NULL) {
- *d = (mp_digit)w;
- }
-
- /* [optional] store the quotient */
- if (c != NULL) {
- mp_clamp(&q);
- mp_exch(&q, c);
- }
- mp_clear(&q);
-
- return res;
-}
-
-#endif
-
-/* End: bn_mp_div_3.c */
-
-/* Start: bn_mp_div_d.c */
-#include <tommath.h>
-#ifdef BN_MP_DIV_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-static int s_is_power_of_two(mp_digit b, int *p)
-{
- int x;
-
- /* fast return if no power of two */
- if ((b==0) || (b & (b-1))) {
- return 0;
- }
-
- for (x = 0; x < DIGIT_BIT; x++) {
- if (b == (((mp_digit)1)<<x)) {
- *p = x;
- return 1;
- }
- }
- return 0;
-}
-
-/* single digit division (based on routine from MPI) */
-int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
-{
- mp_int q;
- mp_word w;
- mp_digit t;
- int res, ix;
-
- /* cannot divide by zero */
- if (b == 0) {
- return MP_VAL;
- }
-
- /* quick outs */
- if (b == 1 || mp_iszero(a) == 1) {
- if (d != NULL) {
- *d = 0;
- }
- if (c != NULL) {
- return mp_copy(a, c);
- }
- return MP_OKAY;
- }
-
- /* power of two ? */
- if (s_is_power_of_two(b, &ix) == 1) {
- if (d != NULL) {
- *d = a->dp[0] & ((((mp_digit)1)<<ix) - 1);
- }
- if (c != NULL) {
- return mp_div_2d(a, ix, c, NULL);
- }
- return MP_OKAY;
- }
-
-#ifdef BN_MP_DIV_3_C
- /* three? */
- if (b == 3) {
- return mp_div_3(a, c, d);
- }
-#endif
-
- /* no easy answer [c'est la vie]. Just division */
- if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
- return res;
- }
-
- q.used = a->used;
- q.sign = a->sign;
- w = 0;
- for (ix = a->used - 1; ix >= 0; ix--) {
- w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]);
-
- if (w >= b) {
- t = (mp_digit)(w / b);
- w -= ((mp_word)t) * ((mp_word)b);
- } else {
- t = 0;
- }
- q.dp[ix] = (mp_digit)t;
- }
-
- if (d != NULL) {
- *d = (mp_digit)w;
- }
-
- if (c != NULL) {
- mp_clamp(&q);
- mp_exch(&q, c);
- }
- mp_clear(&q);
-
- return res;
-}
-
-#endif
-
-/* End: bn_mp_div_d.c */
-
-/* Start: bn_mp_dr_is_modulus.c */
-#include <tommath.h>
-#ifdef BN_MP_DR_IS_MODULUS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines if a number is a valid DR modulus */
-int mp_dr_is_modulus(mp_int *a)
-{
- int ix;
-
- /* must be at least two digits */
- if (a->used < 2) {
- return 0;
- }
-
- /* must be of the form b**k - a [a <= b] so all
- * but the first digit must be equal to -1 (mod b).
- */
- for (ix = 1; ix < a->used; ix++) {
- if (a->dp[ix] != MP_MASK) {
- return 0;
- }
- }
- return 1;
-}
-
-#endif
-
-/* End: bn_mp_dr_is_modulus.c */
-
-/* Start: bn_mp_dr_reduce.c */
-#include <tommath.h>
-#ifdef BN_MP_DR_REDUCE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
- *
- * Based on algorithm from the paper
- *
- * "Generating Efficient Primes for Discrete Log Cryptosystems"
- * Chae Hoon Lim, Pil Joong Lee,
- * POSTECH Information Research Laboratories
- *
- * The modulus must be of a special format [see manual]
- *
- * Has been modified to use algorithm 7.10 from the LTM book instead
- *
- * Input x must be in the range 0 <= x <= (n-1)**2
- */
-int
-mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k)
-{
- int err, i, m;
- mp_word r;
- mp_digit mu, *tmpx1, *tmpx2;
-
- /* m = digits in modulus */
- m = n->used;
-
- /* ensure that "x" has at least 2m digits */
- if (x->alloc < m + m) {
- if ((err = mp_grow (x, m + m)) != MP_OKAY) {
- return err;
- }
- }
-
-/* top of loop, this is where the code resumes if
- * another reduction pass is required.
- */
-top:
- /* aliases for digits */
- /* alias for lower half of x */
- tmpx1 = x->dp;
-
- /* alias for upper half of x, or x/B**m */
- tmpx2 = x->dp + m;
-
- /* set carry to zero */
- mu = 0;
-
- /* compute (x mod B**m) + k * [x/B**m] inline and inplace */
- for (i = 0; i < m; i++) {
- r = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu;
- *tmpx1++ = (mp_digit)(r & MP_MASK);
- mu = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
- }
-
- /* set final carry */
- *tmpx1++ = mu;
-
- /* zero words above m */
- for (i = m + 1; i < x->used; i++) {
- *tmpx1++ = 0;
- }
-
- /* clamp, sub and return */
- mp_clamp (x);
-
- /* if x >= n then subtract and reduce again
- * Each successive "recursion" makes the input smaller and smaller.
- */
- if (mp_cmp_mag (x, n) != MP_LT) {
- s_mp_sub(x, n, x);
- goto top;
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_dr_reduce.c */
-
-/* Start: bn_mp_dr_setup.c */
-#include <tommath.h>
-#ifdef BN_MP_DR_SETUP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines the setup value */
-void mp_dr_setup(mp_int *a, mp_digit *d)
-{
- /* the casts are required if DIGIT_BIT is one less than
- * the number of bits in a mp_digit [e.g. DIGIT_BIT==31]
- */
- *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) -
- ((mp_word)a->dp[0]));
-}
-
-#endif
-
-/* End: bn_mp_dr_setup.c */
-
-/* Start: bn_mp_exch.c */
-#include <tommath.h>
-#ifdef BN_MP_EXCH_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* swap the elements of two integers, for cases where you can't simply swap the
- * mp_int pointers around
- */
-void
-mp_exch (mp_int * a, mp_int * b)
-{
- mp_int t;
-
- t = *a;
- *a = *b;
- *b = t;
-}
-#endif
-
-/* End: bn_mp_exch.c */
-
-/* Start: bn_mp_expt_d.c */
-#include <tommath.h>
-#ifdef BN_MP_EXPT_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* calculate c = a**b using a square-multiply algorithm */
-int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
-{
- int res, x;
- mp_int g;
-
- if ((res = mp_init_copy (&g, a)) != MP_OKAY) {
- return res;
- }
-
- /* set initial result */
- mp_set (c, 1);
-
- for (x = 0; x < (int) DIGIT_BIT; x++) {
- /* square */
- if ((res = mp_sqr (c, c)) != MP_OKAY) {
- mp_clear (&g);
- return res;
- }
-
- /* if the bit is set multiply */
- if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) {
- if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
- mp_clear (&g);
- return res;
- }
- }
-
- /* shift to next bit */
- b <<= 1;
- }
-
- mp_clear (&g);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_expt_d.c */
-
-/* Start: bn_mp_exptmod.c */
-#include <tommath.h>
-#ifdef BN_MP_EXPTMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-
-/* this is a shell function that calls either the normal or Montgomery
- * exptmod functions. Originally the call to the montgomery code was
- * embedded in the normal function but that wasted alot of stack space
- * for nothing (since 99% of the time the Montgomery code would be called)
- */
-int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
-{
- int dr;
-
- /* modulus P must be positive */
- if (P->sign == MP_NEG) {
- return MP_VAL;
- }
-
- /* if exponent X is negative we have to recurse */
- if (X->sign == MP_NEG) {
-#ifdef BN_MP_INVMOD_C
- mp_int tmpG, tmpX;
- int err;
-
- /* first compute 1/G mod P */
- if ((err = mp_init(&tmpG)) != MP_OKAY) {
- return err;
- }
- if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) {
- mp_clear(&tmpG);
- return err;
- }
-
- /* now get |X| */
- if ((err = mp_init(&tmpX)) != MP_OKAY) {
- mp_clear(&tmpG);
- return err;
- }
- if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {
- mp_clear_multi(&tmpG, &tmpX, NULL);
- return err;
- }
-
- /* and now compute (1/G)**|X| instead of G**X [X < 0] */
- err = mp_exptmod(&tmpG, &tmpX, P, Y);
- mp_clear_multi(&tmpG, &tmpX, NULL);
- return err;
-#else
- /* no invmod */
- return MP_VAL;
-#endif
- }
-
-/* modified diminished radix reduction */
-#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C)
- if (mp_reduce_is_2k_l(P) == MP_YES) {
- return s_mp_exptmod(G, X, P, Y, 1);
- }
-#endif
-
-#ifdef BN_MP_DR_IS_MODULUS_C
- /* is it a DR modulus? */
- dr = mp_dr_is_modulus(P);
-#else
- /* default to no */
- dr = 0;
-#endif
-
-#ifdef BN_MP_REDUCE_IS_2K_C
- /* if not, is it a unrestricted DR modulus? */
- if (dr == 0) {
- dr = mp_reduce_is_2k(P) << 1;
- }
-#endif
-
- /* if the modulus is odd or dr != 0 use the montgomery method */
-#ifdef BN_MP_EXPTMOD_FAST_C
- if (mp_isodd (P) == 1 || dr != 0) {
- return mp_exptmod_fast (G, X, P, Y, dr);
- } else {
-#endif
-#ifdef BN_S_MP_EXPTMOD_C
- /* otherwise use the generic Barrett reduction technique */
- return s_mp_exptmod (G, X, P, Y, 0);
-#else
- /* no exptmod for evens */
- return MP_VAL;
-#endif
-#ifdef BN_MP_EXPTMOD_FAST_C
- }
-#endif
-}
-
-#endif
-
-/* End: bn_mp_exptmod.c */
-
-/* Start: bn_mp_exptmod_fast.c */
-#include <tommath.h>
-#ifdef BN_MP_EXPTMOD_FAST_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
- *
- * Uses a left-to-right k-ary sliding window to compute the modular exponentiation.
- * The value of k changes based on the size of the exponent.
- *
- * Uses Montgomery or Diminished Radix reduction [whichever appropriate]
- */
-
-#ifdef MP_LOW_MEM
- #define TAB_SIZE 32
-#else
- #define TAB_SIZE 256
-#endif
-
-int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
-{
- mp_int M[TAB_SIZE], res;
- mp_digit buf, mp;
- int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
-
- /* use a pointer to the reduction algorithm. This allows us to use
- * one of many reduction algorithms without modding the guts of
- * the code with if statements everywhere.
- */
- int (*redux)(mp_int*,mp_int*,mp_digit);
-
- /* find window size */
- x = mp_count_bits (X);
- if (x <= 7) {
- winsize = 2;
- } else if (x <= 36) {
- winsize = 3;
- } else if (x <= 140) {
- winsize = 4;
- } else if (x <= 450) {
- winsize = 5;
- } else if (x <= 1303) {
- winsize = 6;
- } else if (x <= 3529) {
- winsize = 7;
- } else {
- winsize = 8;
- }
-
-#ifdef MP_LOW_MEM
- if (winsize > 5) {
- winsize = 5;
- }
-#endif
-
- /* init M array */
- /* init first cell */
- if ((err = mp_init(&M[1])) != MP_OKAY) {
- return err;
- }
-
- /* now init the second half of the array */
- for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
- if ((err = mp_init(&M[x])) != MP_OKAY) {
- for (y = 1<<(winsize-1); y < x; y++) {
- mp_clear (&M[y]);
- }
- mp_clear(&M[1]);
- return err;
- }
- }
-
- /* determine and setup reduction code */
- if (redmode == 0) {
-#ifdef BN_MP_MONTGOMERY_SETUP_C
- /* now setup montgomery */
- if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) {
- goto LBL_M;
- }
-#else
- err = MP_VAL;
- goto LBL_M;
-#endif
-
- /* automatically pick the comba one if available (saves quite a few calls/ifs) */
-#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
- if (((P->used * 2 + 1) < MP_WARRAY) &&
- P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
- redux = fast_mp_montgomery_reduce;
- } else
-#endif
- {
-#ifdef BN_MP_MONTGOMERY_REDUCE_C
- /* use slower baseline Montgomery method */
- redux = mp_montgomery_reduce;
-#else
- err = MP_VAL;
- goto LBL_M;
-#endif
- }
- } else if (redmode == 1) {
-#if defined(BN_MP_DR_SETUP_C) && defined(BN_MP_DR_REDUCE_C)
- /* setup DR reduction for moduli of the form B**k - b */
- mp_dr_setup(P, &mp);
- redux = mp_dr_reduce;
-#else
- err = MP_VAL;
- goto LBL_M;
-#endif
- } else {
-#if defined(BN_MP_REDUCE_2K_SETUP_C) && defined(BN_MP_REDUCE_2K_C)
- /* setup DR reduction for moduli of the form 2**k - b */
- if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) {
- goto LBL_M;
- }
- redux = mp_reduce_2k;
-#else
- err = MP_VAL;
- goto LBL_M;
-#endif
- }
-
- /* setup result */
- if ((err = mp_init (&res)) != MP_OKAY) {
- goto LBL_M;
- }
-
- /* create M table
- *
-
- *
- * The first half of the table is not computed though accept for M[0] and M[1]
- */
-
- if (redmode == 0) {
-#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
- /* now we need R mod m */
- if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) {
- goto LBL_RES;
- }
-#else
- err = MP_VAL;
- goto LBL_RES;
-#endif
-
- /* now set M[1] to G * R mod m */
- if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) {
- goto LBL_RES;
- }
- } else {
- mp_set(&res, 1);
- if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
- if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto LBL_RES;
- }
-
- for (x = 0; x < (winsize - 1); x++) {
- if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* create upper table */
- for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
- if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&M[x], P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* set initial mode and bit cnt */
- mode = 0;
- bitcnt = 1;
- buf = 0;
- digidx = X->used - 1;
- bitcpy = 0;
- bitbuf = 0;
-
- for (;;) {
- /* grab next digit as required */
- if (--bitcnt == 0) {
- /* if digidx == -1 we are out of digits so break */
- if (digidx == -1) {
- break;
- }
- /* read next digit and reset bitcnt */
- buf = X->dp[digidx--];
- bitcnt = (int)DIGIT_BIT;
- }
-
- /* grab the next msb from the exponent */
- y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1;
- buf <<= (mp_digit)1;
-
- /* if the bit is zero and mode == 0 then we ignore it
- * These represent the leading zero bits before the first 1 bit
- * in the exponent. Technically this opt is not required but it
- * does lower the # of trivial squaring/reductions used
- */
- if (mode == 0 && y == 0) {
- continue;
- }
-
- /* if the bit is zero and mode == 1 then we square */
- if (mode == 1 && y == 0) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- continue;
- }
-
- /* else we add it to the window */
- bitbuf |= (y << (winsize - ++bitcpy));
- mode = 2;
-
- if (bitcpy == winsize) {
- /* ok window is filled so square as required and multiply */
- /* square first */
- for (x = 0; x < winsize; x++) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* then multiply */
- if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
-
- /* empty window and reset */
- bitcpy = 0;
- bitbuf = 0;
- mode = 1;
- }
- }
-
- /* if bits remain then square/multiply */
- if (mode == 2 && bitcpy > 0) {
- /* square then multiply if the bit is set */
- for (x = 0; x < bitcpy; x++) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
-
- /* get next bit of the window */
- bitbuf <<= 1;
- if ((bitbuf & (1 << winsize)) != 0) {
- /* then multiply */
- if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
- }
- }
-
- if (redmode == 0) {
- /* fixup result if Montgomery reduction is used
- * recall that any value in a Montgomery system is
- * actually multiplied by R mod n. So we have
- * to reduce one more time to cancel out the factor
- * of R.
- */
- if ((err = redux(&res, P, mp)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* swap res with Y */
- mp_exch (&res, Y);
- err = MP_OKAY;
-LBL_RES:mp_clear (&res);
-LBL_M:
- mp_clear(&M[1]);
- for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
- mp_clear (&M[x]);
- }
- return err;
-}
-#endif
-
-/* End: bn_mp_exptmod_fast.c */
-
-/* Start: bn_mp_exteuclid.c */
-#include <tommath.h>
-#ifdef BN_MP_EXTEUCLID_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Extended euclidean algorithm of (a, b) produces
- a*u1 + b*u2 = u3
- */
-int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
-{
- mp_int u1,u2,u3,v1,v2,v3,t1,t2,t3,q,tmp;
- int err;
-
- if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) {
- return err;
- }
-
- /* initialize, (u1,u2,u3) = (1,0,a) */
- mp_set(&u1, 1);
- if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto _ERR; }
-
- /* initialize, (v1,v2,v3) = (0,1,b) */
- mp_set(&v2, 1);
- if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto _ERR; }
-
- /* loop while v3 != 0 */
- while (mp_iszero(&v3) == MP_NO) {
- /* q = u3/v3 */
- if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto _ERR; }
-
- /* (t1,t2,t3) = (u1,u2,u3) - (v1,v2,v3)q */
- if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto _ERR; }
-
- /* (u1,u2,u3) = (v1,v2,v3) */
- if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto _ERR; }
-
- /* (v1,v2,v3) = (t1,t2,t3) */
- if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto _ERR; }
- if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto _ERR; }
- }
-
- /* make sure U3 >= 0 */
- if (u3.sign == MP_NEG) {
- mp_neg(&u1, &u1);
- mp_neg(&u2, &u2);
- mp_neg(&u3, &u3);
- }
-
- /* copy result out */
- if (U1 != NULL) { mp_exch(U1, &u1); }
- if (U2 != NULL) { mp_exch(U2, &u2); }
- if (U3 != NULL) { mp_exch(U3, &u3); }
-
- err = MP_OKAY;
-_ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL);
- return err;
-}
-#endif
-
-/* End: bn_mp_exteuclid.c */
-
-/* Start: bn_mp_fread.c */
-#include <tommath.h>
-#ifdef BN_MP_FREAD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* read a bigint from a file stream in ASCII */
-int mp_fread(mp_int *a, int radix, FILE *stream)
-{
- int err, ch, neg, y;
-
- /* clear a */
- mp_zero(a);
-
- /* if first digit is - then set negative */
- ch = fgetc(stream);
- if (ch == '-') {
- neg = MP_NEG;
- ch = fgetc(stream);
- } else {
- neg = MP_ZPOS;
- }
-
- for (;;) {
- /* find y in the radix map */
- for (y = 0; y < radix; y++) {
- if (mp_s_rmap[y] == ch) {
- break;
- }
- }
- if (y == radix) {
- break;
- }
-
- /* shift up and add */
- if ((err = mp_mul_d(a, radix, a)) != MP_OKAY) {
- return err;
- }
- if ((err = mp_add_d(a, y, a)) != MP_OKAY) {
- return err;
- }
-
- ch = fgetc(stream);
- }
- if (mp_cmp_d(a, 0) != MP_EQ) {
- a->sign = neg;
- }
-
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_fread.c */
-
-/* Start: bn_mp_fwrite.c */
-#include <tommath.h>
-#ifdef BN_MP_FWRITE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-int mp_fwrite(mp_int *a, int radix, FILE *stream)
-{
- char *buf;
- int err, len, x;
-
- if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) {
- return err;
- }
-
- buf = OPT_CAST(char) XMALLOC (len);
- if (buf == NULL) {
- return MP_MEM;
- }
-
- if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) {
- XFREE (buf);
- return err;
- }
-
- for (x = 0; x < len; x++) {
- if (fputc(buf[x], stream) == EOF) {
- XFREE (buf);
- return MP_VAL;
- }
- }
-
- XFREE (buf);
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_fwrite.c */
-
-/* Start: bn_mp_gcd.c */
-#include <tommath.h>
-#ifdef BN_MP_GCD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Greatest Common Divisor using the binary method */
-int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int u, v;
- int k, u_lsb, v_lsb, res;
-
- /* either zero than gcd is the largest */
- if (mp_iszero (a) == MP_YES) {
- return mp_abs (b, c);
- }
- if (mp_iszero (b) == MP_YES) {
- return mp_abs (a, c);
- }
-
- /* get copies of a and b we can modify */
- if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init_copy (&v, b)) != MP_OKAY) {
- goto LBL_U;
- }
-
- /* must be positive for the remainder of the algorithm */
- u.sign = v.sign = MP_ZPOS;
-
- /* B1. Find the common power of two for u and v */
- u_lsb = mp_cnt_lsb(&u);
- v_lsb = mp_cnt_lsb(&v);
- k = MIN(u_lsb, v_lsb);
-
- if (k > 0) {
- /* divide the power of two out */
- if ((res = mp_div_2d(&u, k, &u, NULL)) != MP_OKAY) {
- goto LBL_V;
- }
-
- if ((res = mp_div_2d(&v, k, &v, NULL)) != MP_OKAY) {
- goto LBL_V;
- }
- }
-
- /* divide any remaining factors of two out */
- if (u_lsb != k) {
- if ((res = mp_div_2d(&u, u_lsb - k, &u, NULL)) != MP_OKAY) {
- goto LBL_V;
- }
- }
-
- if (v_lsb != k) {
- if ((res = mp_div_2d(&v, v_lsb - k, &v, NULL)) != MP_OKAY) {
- goto LBL_V;
- }
- }
-
- while (mp_iszero(&v) == 0) {
- /* make sure v is the largest */
- if (mp_cmp_mag(&u, &v) == MP_GT) {
- /* swap u and v to make sure v is >= u */
- mp_exch(&u, &v);
- }
-
- /* subtract smallest from largest */
- if ((res = s_mp_sub(&v, &u, &v)) != MP_OKAY) {
- goto LBL_V;
- }
-
- /* Divide out all factors of two */
- if ((res = mp_div_2d(&v, mp_cnt_lsb(&v), &v, NULL)) != MP_OKAY) {
- goto LBL_V;
- }
- }
-
- /* multiply by 2**k which we divided out at the beginning */
- if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) {
- goto LBL_V;
- }
- c->sign = MP_ZPOS;
- res = MP_OKAY;
-LBL_V:mp_clear (&u);
-LBL_U:mp_clear (&v);
- return res;
-}
-#endif
-
-/* End: bn_mp_gcd.c */
-
-/* Start: bn_mp_get_int.c */
-#include <tommath.h>
-#ifdef BN_MP_GET_INT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* get the lower 32-bits of an mp_int */
-unsigned long mp_get_int(mp_int * a)
-{
- int i;
- unsigned long res;
-
- if (a->used == 0) {
- return 0;
- }
-
- /* get number of digits of the lsb we have to read */
- i = MIN(a->used,(int)((sizeof(unsigned long)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1;
-
- /* get most significant digit of result */
- res = DIGIT(a,i);
-
- while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a,i);
- }
-
- /* force result to 32-bits always so it is consistent on non 32-bit platforms */
- return res & 0xFFFFFFFFUL;
-}
-#endif
-
-/* End: bn_mp_get_int.c */
-
-/* Start: bn_mp_grow.c */
-#include <tommath.h>
-#ifdef BN_MP_GROW_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* grow as required */
-int mp_grow (mp_int * a, int size)
-{
- int i;
- mp_digit *tmp;
-
- /* if the alloc size is smaller alloc more ram */
- if (a->alloc < size) {
- /* ensure there are always at least MP_PREC digits extra on top */
- size += (MP_PREC * 2) - (size % MP_PREC);
-
- /* reallocate the array a->dp
- *
- * We store the return in a temporary variable
- * in case the operation failed we don't want
- * to overwrite the dp member of a.
- */
- tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * size);
- if (tmp == NULL) {
- /* reallocation failed but "a" is still valid [can be freed] */
- return MP_MEM;
- }
-
- /* reallocation succeeded so set a->dp */
- a->dp = tmp;
-
- /* zero excess digits */
- i = a->alloc;
- a->alloc = size;
- for (; i < a->alloc; i++) {
- a->dp[i] = 0;
- }
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_grow.c */
-
-/* Start: bn_mp_init.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* init a new mp_int */
-int mp_init (mp_int * a)
-{
- int i;
-
- /* allocate memory required and clear it */
- a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC);
- if (a->dp == NULL) {
- return MP_MEM;
- }
-
- /* set the digits to zero */
- for (i = 0; i < MP_PREC; i++) {
- a->dp[i] = 0;
- }
-
- /* set the used to zero, allocated digits to the default precision
- * and sign to positive */
- a->used = 0;
- a->alloc = MP_PREC;
- a->sign = MP_ZPOS;
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_init.c */
-
-/* Start: bn_mp_init_copy.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_COPY_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* creates "a" then copies b into it */
-int mp_init_copy (mp_int * a, mp_int * b)
-{
- int res;
-
- if ((res = mp_init (a)) != MP_OKAY) {
- return res;
- }
- return mp_copy (b, a);
-}
-#endif
-
-/* End: bn_mp_init_copy.c */
-
-/* Start: bn_mp_init_multi.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_MULTI_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-#include <stdarg.h>
-
-int mp_init_multi(mp_int *mp, ...)
-{
- mp_err res = MP_OKAY; /* Assume ok until proven otherwise */
- int n = 0; /* Number of ok inits */
- mp_int* cur_arg = mp;
- va_list args;
-
- va_start(args, mp); /* init args to next argument from caller */
- while (cur_arg != NULL) {
- if (mp_init(cur_arg) != MP_OKAY) {
- /* Oops - error! Back-track and mp_clear what we already
- succeeded in init-ing, then return error.
- */
- va_list clean_args;
-
- /* end the current list */
- va_end(args);
-
- /* now start cleaning up */
- cur_arg = mp;
- va_start(clean_args, mp);
- while (n--) {
- mp_clear(cur_arg);
- cur_arg = va_arg(clean_args, mp_int*);
- }
- va_end(clean_args);
- res = MP_MEM;
- break;
- }
- n++;
- cur_arg = va_arg(args, mp_int*);
- }
- va_end(args);
- return res; /* Assumed ok, if error flagged above. */
-}
-
-#endif
-
-/* End: bn_mp_init_multi.c */
-
-/* Start: bn_mp_init_set.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_SET_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* initialize and set a digit */
-int mp_init_set (mp_int * a, mp_digit b)
-{
- int err;
- if ((err = mp_init(a)) != MP_OKAY) {
- return err;
- }
- mp_set(a, b);
- return err;
-}
-#endif
-
-/* End: bn_mp_init_set.c */
-
-/* Start: bn_mp_init_set_int.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_SET_INT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* initialize and set a digit */
-int mp_init_set_int (mp_int * a, unsigned long b)
-{
- int err;
- if ((err = mp_init(a)) != MP_OKAY) {
- return err;
- }
- return mp_set_int(a, b);
-}
-#endif
-
-/* End: bn_mp_init_set_int.c */
-
-/* Start: bn_mp_init_size.c */
-#include <tommath.h>
-#ifdef BN_MP_INIT_SIZE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* init an mp_init for a given size */
-int mp_init_size (mp_int * a, int size)
-{
- int x;
-
- /* pad size so there are always extra digits */
- size += (MP_PREC * 2) - (size % MP_PREC);
-
- /* alloc mem */
- a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * size);
- if (a->dp == NULL) {
- return MP_MEM;
- }
-
- /* set the members */
- a->used = 0;
- a->alloc = size;
- a->sign = MP_ZPOS;
-
- /* zero the digits */
- for (x = 0; x < size; x++) {
- a->dp[x] = 0;
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_init_size.c */
-
-/* Start: bn_mp_invmod.c */
-#include <tommath.h>
-#ifdef BN_MP_INVMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* hac 14.61, pp608 */
-int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-{
- /* b cannot be negative */
- if (b->sign == MP_NEG || mp_iszero(b) == 1) {
- return MP_VAL;
- }
-
-#ifdef BN_FAST_MP_INVMOD_C
- /* if the modulus is odd we can use a faster routine instead */
- if (mp_isodd (b) == 1) {
- return fast_mp_invmod (a, b, c);
- }
-#endif
-
-#ifdef BN_MP_INVMOD_SLOW_C
- return mp_invmod_slow(a, b, c);
-#endif
-
- return MP_VAL;
-}
-#endif
-
-/* End: bn_mp_invmod.c */
-
-/* Start: bn_mp_invmod_slow.c */
-#include <tommath.h>
-#ifdef BN_MP_INVMOD_SLOW_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* hac 14.61, pp608 */
-int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int x, y, u, v, A, B, C, D;
- int res;
-
- /* b cannot be negative */
- if (b->sign == MP_NEG || mp_iszero(b) == 1) {
- return MP_VAL;
- }
-
- /* init temps */
- if ((res = mp_init_multi(&x, &y, &u, &v,
- &A, &B, &C, &D, NULL)) != MP_OKAY) {
- return res;
- }
-
- /* x = a, y = b */
- if ((res = mp_mod(a, b, &x)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_copy (b, &y)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- /* 2. [modified] if x,y are both even then return an error! */
- if (mp_iseven (&x) == 1 && mp_iseven (&y) == 1) {
- res = MP_VAL;
- goto LBL_ERR;
- }
-
- /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
- if ((res = mp_copy (&x, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_copy (&y, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
- mp_set (&A, 1);
- mp_set (&D, 1);
-
-top:
- /* 4. while u is even do */
- while (mp_iseven (&u) == 1) {
- /* 4.1 u = u/2 */
- if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
- /* 4.2 if A or B is odd then */
- if (mp_isodd (&A) == 1 || mp_isodd (&B) == 1) {
- /* A = (A+y)/2, B = (B-x)/2 */
- if ((res = mp_add (&A, &y, &A)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
- /* A = A/2, B = B/2 */
- if ((res = mp_div_2 (&A, &A)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* 5. while v is even do */
- while (mp_iseven (&v) == 1) {
- /* 5.1 v = v/2 */
- if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
- /* 5.2 if C or D is odd then */
- if (mp_isodd (&C) == 1 || mp_isodd (&D) == 1) {
- /* C = (C+y)/2, D = (D-x)/2 */
- if ((res = mp_add (&C, &y, &C)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
- /* C = C/2, D = D/2 */
- if ((res = mp_div_2 (&C, &C)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* 6. if u >= v then */
- if (mp_cmp (&u, &v) != MP_LT) {
- /* u = u - v, A = A - C, B = B - D */
- if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
- goto LBL_ERR;
- }
- } else {
- /* v - v - u, C = C - A, D = D - B */
- if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* if not zero goto step 4 */
- if (mp_iszero (&u) == 0)
- goto top;
-
- /* now a = C, b = D, gcd == g*v */
-
- /* if v != 1 then there is no inverse */
- if (mp_cmp_d (&v, 1) != MP_EQ) {
- res = MP_VAL;
- goto LBL_ERR;
- }
-
- /* if its too low */
- while (mp_cmp_d(&C, 0) == MP_LT) {
- if ((res = mp_add(&C, b, &C)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* too big */
- while (mp_cmp_mag(&C, b) != MP_LT) {
- if ((res = mp_sub(&C, b, &C)) != MP_OKAY) {
- goto LBL_ERR;
- }
- }
-
- /* C is now the inverse */
- mp_exch (&C, c);
- res = MP_OKAY;
-LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
- return res;
-}
-#endif
-
-/* End: bn_mp_invmod_slow.c */
-
-/* Start: bn_mp_is_square.c */
-#include <tommath.h>
-#ifdef BN_MP_IS_SQUARE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Check if remainders are possible squares - fast exclude non-squares */
-static const char rem_128[128] = {
- 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1
-};
-
-static const char rem_105[105] = {
- 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1,
- 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
- 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
- 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1,
- 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1
-};
-
-/* Store non-zero to ret if arg is square, and zero if not */
-int mp_is_square(mp_int *arg,int *ret)
-{
- int res;
- mp_digit c;
- mp_int t;
- unsigned long r;
-
- /* Default to Non-square :) */
- *ret = MP_NO;
-
- if (arg->sign == MP_NEG) {
- return MP_VAL;
- }
-
- /* digits used? (TSD) */
- if (arg->used == 0) {
- return MP_OKAY;
- }
-
- /* First check mod 128 (suppose that DIGIT_BIT is at least 7) */
- if (rem_128[127 & DIGIT(arg,0)] == 1) {
- return MP_OKAY;
- }
-
- /* Next check mod 105 (3*5*7) */
- if ((res = mp_mod_d(arg,105,&c)) != MP_OKAY) {
- return res;
- }
- if (rem_105[c] == 1) {
- return MP_OKAY;
- }
-
-
- if ((res = mp_init_set_int(&t,11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
- return res;
- }
- if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) {
- goto ERR;
- }
- r = mp_get_int(&t);
- /* Check for other prime modules, note it's not an ERROR but we must
- * free "t" so the easiest way is to goto ERR. We know that res
- * is already equal to MP_OKAY from the mp_mod call
- */
- if ( (1L<<(r%11)) & 0x5C4L ) goto ERR;
- if ( (1L<<(r%13)) & 0x9E4L ) goto ERR;
- if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR;
- if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR;
- if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR;
- if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR;
- if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR;
-
- /* Final check - is sqr(sqrt(arg)) == arg ? */
- if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sqr(&t,&t)) != MP_OKAY) {
- goto ERR;
- }
-
- *ret = (mp_cmp_mag(&t,arg) == MP_EQ) ? MP_YES : MP_NO;
-ERR:mp_clear(&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_is_square.c */
-
-/* Start: bn_mp_jacobi.c */
-#include <tommath.h>
-#ifdef BN_MP_JACOBI_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes the jacobi c = (a | n) (or Legendre if n is prime)
- * HAC pp. 73 Algorithm 2.149
- */
-int mp_jacobi (mp_int * a, mp_int * p, int *c)
-{
- mp_int a1, p1;
- int k, s, r, res;
- mp_digit residue;
-
- /* if p <= 0 return MP_VAL */
- if (mp_cmp_d(p, 0) != MP_GT) {
- return MP_VAL;
- }
-
- /* step 1. if a == 0, return 0 */
- if (mp_iszero (a) == 1) {
- *c = 0;
- return MP_OKAY;
- }
-
- /* step 2. if a == 1, return 1 */
- if (mp_cmp_d (a, 1) == MP_EQ) {
- *c = 1;
- return MP_OKAY;
- }
-
- /* default */
- s = 0;
-
- /* step 3. write a = a1 * 2**k */
- if ((res = mp_init_copy (&a1, a)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init (&p1)) != MP_OKAY) {
- goto LBL_A1;
- }
-
- /* divide out larger power of two */
- k = mp_cnt_lsb(&a1);
- if ((res = mp_div_2d(&a1, k, &a1, NULL)) != MP_OKAY) {
- goto LBL_P1;
- }
-
- /* step 4. if e is even set s=1 */
- if ((k & 1) == 0) {
- s = 1;
- } else {
- /* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */
- residue = p->dp[0] & 7;
-
- if (residue == 1 || residue == 7) {
- s = 1;
- } else if (residue == 3 || residue == 5) {
- s = -1;
- }
- }
-
- /* step 5. if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */
- if ( ((p->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) {
- s = -s;
- }
-
- /* if a1 == 1 we're done */
- if (mp_cmp_d (&a1, 1) == MP_EQ) {
- *c = s;
- } else {
- /* n1 = n mod a1 */
- if ((res = mp_mod (p, &a1, &p1)) != MP_OKAY) {
- goto LBL_P1;
- }
- if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) {
- goto LBL_P1;
- }
- *c = s * r;
- }
-
- /* done */
- res = MP_OKAY;
-LBL_P1:mp_clear (&p1);
-LBL_A1:mp_clear (&a1);
- return res;
-}
-#endif
-
-/* End: bn_mp_jacobi.c */
-
-/* Start: bn_mp_karatsuba_mul.c */
-#include <tommath.h>
-#ifdef BN_MP_KARATSUBA_MUL_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* c = |a| * |b| using Karatsuba Multiplication using
- * three half size multiplications
- *
- * Let B represent the radix [e.g. 2**DIGIT_BIT] and
- * let n represent half of the number of digits in
- * the min(a,b)
- *
- * a = a1 * B**n + a0
- * b = b1 * B**n + b0
- *
- * Then, a * b =>
- a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0
- *
- * Note that a1b1 and a0b0 are used twice and only need to be
- * computed once. So in total three half size (half # of
- * digit) multiplications are performed, a0b0, a1b1 and
- * (a1+b1)(a0+b0)
- *
- * Note that a multiplication of half the digits requires
- * 1/4th the number of single precision multiplications so in
- * total after one call 25% of the single precision multiplications
- * are saved. Note also that the call to mp_mul can end up back
- * in this function if the a0, a1, b0, or b1 are above the threshold.
- * This is known as divide-and-conquer and leads to the famous
- * O(N**lg(3)) or O(N**1.584) work which is asymptopically lower than
- * the standard O(N**2) that the baseline/comba methods use.
- * Generally though the overhead of this method doesn't pay off
- * until a certain size (N ~ 80) is reached.
- */
-int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int x0, x1, y0, y1, t1, x0y0, x1y1;
- int B, err;
-
- /* default the return code to an error */
- err = MP_MEM;
-
- /* min # of digits */
- B = MIN (a->used, b->used);
-
- /* now divide in two */
- B = B >> 1;
-
- /* init copy all the temps */
- if (mp_init_size (&x0, B) != MP_OKAY)
- goto ERR;
- if (mp_init_size (&x1, a->used - B) != MP_OKAY)
- goto X0;
- if (mp_init_size (&y0, B) != MP_OKAY)
- goto X1;
- if (mp_init_size (&y1, b->used - B) != MP_OKAY)
- goto Y0;
-
- /* init temps */
- if (mp_init_size (&t1, B * 2) != MP_OKAY)
- goto Y1;
- if (mp_init_size (&x0y0, B * 2) != MP_OKAY)
- goto T1;
- if (mp_init_size (&x1y1, B * 2) != MP_OKAY)
- goto X0Y0;
-
- /* now shift the digits */
- x0.used = y0.used = B;
- x1.used = a->used - B;
- y1.used = b->used - B;
-
- {
- register int x;
- register mp_digit *tmpa, *tmpb, *tmpx, *tmpy;
-
- /* we copy the digits directly instead of using higher level functions
- * since we also need to shift the digits
- */
- tmpa = a->dp;
- tmpb = b->dp;
-
- tmpx = x0.dp;
- tmpy = y0.dp;
- for (x = 0; x < B; x++) {
- *tmpx++ = *tmpa++;
- *tmpy++ = *tmpb++;
- }
-
- tmpx = x1.dp;
- for (x = B; x < a->used; x++) {
- *tmpx++ = *tmpa++;
- }
-
- tmpy = y1.dp;
- for (x = B; x < b->used; x++) {
- *tmpy++ = *tmpb++;
- }
- }
-
- /* only need to clamp the lower words since by definition the
- * upper words x1/y1 must have a known number of digits
- */
- mp_clamp (&x0);
- mp_clamp (&y0);
-
- /* now calc the products x0y0 and x1y1 */
- /* after this x0 is no longer required, free temp [x0==t2]! */
- if (mp_mul (&x0, &y0, &x0y0) != MP_OKAY)
- goto X1Y1; /* x0y0 = x0*y0 */
- if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY)
- goto X1Y1; /* x1y1 = x1*y1 */
-
- /* now calc x1+x0 and y1+y0 */
- if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
- goto X1Y1; /* t1 = x1 - x0 */
- if (s_mp_add (&y1, &y0, &x0) != MP_OKAY)
- goto X1Y1; /* t2 = y1 - y0 */
- if (mp_mul (&t1, &x0, &t1) != MP_OKAY)
- goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
-
- /* add x0y0 */
- if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY)
- goto X1Y1; /* t2 = x0y0 + x1y1 */
- if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY)
- goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
-
- /* shift by B */
- if (mp_lshd (&t1, B) != MP_OKAY)
- goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
- if (mp_lshd (&x1y1, B * 2) != MP_OKAY)
- goto X1Y1; /* x1y1 = x1y1 << 2*B */
-
- if (mp_add (&x0y0, &t1, &t1) != MP_OKAY)
- goto X1Y1; /* t1 = x0y0 + t1 */
- if (mp_add (&t1, &x1y1, c) != MP_OKAY)
- goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
-
- /* Algorithm succeeded set the return code to MP_OKAY */
- err = MP_OKAY;
-
-X1Y1:mp_clear (&x1y1);
-X0Y0:mp_clear (&x0y0);
-T1:mp_clear (&t1);
-Y1:mp_clear (&y1);
-Y0:mp_clear (&y0);
-X1:mp_clear (&x1);
-X0:mp_clear (&x0);
-ERR:
- return err;
-}
-#endif
-
-/* End: bn_mp_karatsuba_mul.c */
-
-/* Start: bn_mp_karatsuba_sqr.c */
-#include <tommath.h>
-#ifdef BN_MP_KARATSUBA_SQR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Karatsuba squaring, computes b = a*a using three
- * half size squarings
- *
- * See comments of karatsuba_mul for details. It
- * is essentially the same algorithm but merely
- * tuned to perform recursive squarings.
- */
-int mp_karatsuba_sqr (mp_int * a, mp_int * b)
-{
- mp_int x0, x1, t1, t2, x0x0, x1x1;
- int B, err;
-
- err = MP_MEM;
-
- /* min # of digits */
- B = a->used;
-
- /* now divide in two */
- B = B >> 1;
-
- /* init copy all the temps */
- if (mp_init_size (&x0, B) != MP_OKAY)
- goto ERR;
- if (mp_init_size (&x1, a->used - B) != MP_OKAY)
- goto X0;
-
- /* init temps */
- if (mp_init_size (&t1, a->used * 2) != MP_OKAY)
- goto X1;
- if (mp_init_size (&t2, a->used * 2) != MP_OKAY)
- goto T1;
- if (mp_init_size (&x0x0, B * 2) != MP_OKAY)
- goto T2;
- if (mp_init_size (&x1x1, (a->used - B) * 2) != MP_OKAY)
- goto X0X0;
-
- {
- register int x;
- register mp_digit *dst, *src;
-
- src = a->dp;
-
- /* now shift the digits */
- dst = x0.dp;
- for (x = 0; x < B; x++) {
- *dst++ = *src++;
- }
-
- dst = x1.dp;
- for (x = B; x < a->used; x++) {
- *dst++ = *src++;
- }
- }
-
- x0.used = B;
- x1.used = a->used - B;
-
- mp_clamp (&x0);
-
- /* now calc the products x0*x0 and x1*x1 */
- if (mp_sqr (&x0, &x0x0) != MP_OKAY)
- goto X1X1; /* x0x0 = x0*x0 */
- if (mp_sqr (&x1, &x1x1) != MP_OKAY)
- goto X1X1; /* x1x1 = x1*x1 */
-
- /* now calc (x1+x0)**2 */
- if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
- goto X1X1; /* t1 = x1 - x0 */
- if (mp_sqr (&t1, &t1) != MP_OKAY)
- goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */
-
- /* add x0y0 */
- if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
- goto X1X1; /* t2 = x0x0 + x1x1 */
- if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
- goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */
-
- /* shift by B */
- if (mp_lshd (&t1, B) != MP_OKAY)
- goto X1X1; /* t1 = (x0x0 + x1x1 - (x1-x0)*(x1-x0))<<B */
- if (mp_lshd (&x1x1, B * 2) != MP_OKAY)
- goto X1X1; /* x1x1 = x1x1 << 2*B */
-
- if (mp_add (&x0x0, &t1, &t1) != MP_OKAY)
- goto X1X1; /* t1 = x0x0 + t1 */
- if (mp_add (&t1, &x1x1, b) != MP_OKAY)
- goto X1X1; /* t1 = x0x0 + t1 + x1x1 */
-
- err = MP_OKAY;
-
-X1X1:mp_clear (&x1x1);
-X0X0:mp_clear (&x0x0);
-T2:mp_clear (&t2);
-T1:mp_clear (&t1);
-X1:mp_clear (&x1);
-X0:mp_clear (&x0);
-ERR:
- return err;
-}
-#endif
-
-/* End: bn_mp_karatsuba_sqr.c */
-
-/* Start: bn_mp_lcm.c */
-#include <tommath.h>
-#ifdef BN_MP_LCM_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes least common multiple as |a*b|/(a, b) */
-int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
-{
- int res;
- mp_int t1, t2;
-
-
- if ((res = mp_init_multi (&t1, &t2, NULL)) != MP_OKAY) {
- return res;
- }
-
- /* t1 = get the GCD of the two inputs */
- if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
- goto LBL_T;
- }
-
- /* divide the smallest by the GCD */
- if (mp_cmp_mag(a, b) == MP_LT) {
- /* store quotient in t2 such that t2 * b is the LCM */
- if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
- goto LBL_T;
- }
- res = mp_mul(b, &t2, c);
- } else {
- /* store quotient in t2 such that t2 * a is the LCM */
- if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
- goto LBL_T;
- }
- res = mp_mul(a, &t2, c);
- }
-
- /* fix the sign to positive */
- c->sign = MP_ZPOS;
-
-LBL_T:
- mp_clear_multi (&t1, &t2, NULL);
- return res;
-}
-#endif
-
-/* End: bn_mp_lcm.c */
-
-/* Start: bn_mp_lshd.c */
-#include <tommath.h>
-#ifdef BN_MP_LSHD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* shift left a certain amount of digits */
-int mp_lshd (mp_int * a, int b)
-{
- int x, res;
-
- /* if its less than zero return */
- if (b <= 0) {
- return MP_OKAY;
- }
-
- /* grow to fit the new digits */
- if (a->alloc < a->used + b) {
- if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
- return res;
- }
- }
-
- {
- register mp_digit *top, *bottom;
-
- /* increment the used by the shift amount then copy upwards */
- a->used += b;
-
- /* top */
- top = a->dp + a->used - 1;
-
- /* base */
- bottom = a->dp + a->used - 1 - b;
-
- /* much like mp_rshd this is implemented using a sliding window
- * except the window goes the otherway around. Copying from
- * the bottom to the top. see bn_mp_rshd.c for more info.
- */
- for (x = a->used - 1; x >= b; x--) {
- *top-- = *bottom--;
- }
-
- /* zero the lower digits */
- top = a->dp;
- for (x = 0; x < b; x++) {
- *top++ = 0;
- }
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_lshd.c */
-
-/* Start: bn_mp_mod.c */
-#include <tommath.h>
-#ifdef BN_MP_MOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* c = a mod b, 0 <= c < b */
-int
-mp_mod (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int t;
- int res;
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
-
- if (t.sign != b->sign) {
- res = mp_add (b, &t, c);
- } else {
- res = MP_OKAY;
- mp_exch (&t, c);
- }
-
- mp_clear (&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_mod.c */
-
-/* Start: bn_mp_mod_2d.c */
-#include <tommath.h>
-#ifdef BN_MP_MOD_2D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* calc a value mod 2**b */
-int
-mp_mod_2d (mp_int * a, int b, mp_int * c)
-{
- int x, res;
-
- /* if b is <= 0 then zero the int */
- if (b <= 0) {
- mp_zero (c);
- return MP_OKAY;
- }
-
- /* if the modulus is larger than the value than return */
- if (b >= (int) (a->used * DIGIT_BIT)) {
- res = mp_copy (a, c);
- return res;
- }
-
- /* copy */
- if ((res = mp_copy (a, c)) != MP_OKAY) {
- return res;
- }
-
- /* zero digits above the last digit of the modulus */
- for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) {
- c->dp[x] = 0;
- }
- /* clear the digit that is not completely outside/inside the modulus */
- c->dp[b / DIGIT_BIT] &=
- (mp_digit) ((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1));
- mp_clamp (c);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_mod_2d.c */
-
-/* Start: bn_mp_mod_d.c */
-#include <tommath.h>
-#ifdef BN_MP_MOD_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-int
-mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
-{
- return mp_div_d(a, b, NULL, c);
-}
-#endif
-
-/* End: bn_mp_mod_d.c */
-
-/* Start: bn_mp_montgomery_calc_normalization.c */
-#include <tommath.h>
-#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/*
- * shifts with subtractions when the result is greater than b.
- *
- * The method is slightly modified to shift B unconditionally upto just under
- * the leading bit of b. This saves alot of multiple precision shifting.
- */
-int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
-{
- int x, bits, res;
-
- /* how many bits of last digit does b use */
- bits = mp_count_bits (b) % DIGIT_BIT;
-
- if (b->used > 1) {
- if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
- return res;
- }
- } else {
- mp_set(a, 1);
- bits = 1;
- }
-
-
- /* now compute C = A * B mod b */
- for (x = bits - 1; x < (int)DIGIT_BIT; x++) {
- if ((res = mp_mul_2 (a, a)) != MP_OKAY) {
- return res;
- }
- if (mp_cmp_mag (a, b) != MP_LT) {
- if ((res = s_mp_sub (a, b, a)) != MP_OKAY) {
- return res;
- }
- }
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_montgomery_calc_normalization.c */
-
-/* Start: bn_mp_montgomery_reduce.c */
-#include <tommath.h>
-#ifdef BN_MP_MONTGOMERY_REDUCE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes xR**-1 == x (mod N) via Montgomery Reduction */
-int
-mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
-{
- int ix, res, digs;
- mp_digit mu;
-
- /* can the fast reduction [comba] method be used?
- *
- * Note that unlike in mul you're safely allowed *less*
- * than the available columns [255 per default] since carries
- * are fixed up in the inner loop.
- */
- digs = n->used * 2 + 1;
- if ((digs < MP_WARRAY) &&
- n->used <
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
- return fast_mp_montgomery_reduce (x, n, rho);
- }
-
- /* grow the input as required */
- if (x->alloc < digs) {
- if ((res = mp_grow (x, digs)) != MP_OKAY) {
- return res;
- }
- }
- x->used = digs;
-
- for (ix = 0; ix < n->used; ix++) {
- /* mu = ai * rho mod b
- *
- * The value of rho must be precalculated via
- * montgomery_setup() such that
- * it equals -1/n0 mod b this allows the
- * following inner loop to reduce the
- * input one digit at a time
- */
- mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK);
-
- /* a = a + mu * m * b**i */
- {
- register int iy;
- register mp_digit *tmpn, *tmpx, u;
- register mp_word r;
-
- /* alias for digits of the modulus */
- tmpn = n->dp;
-
- /* alias for the digits of x [the input] */
- tmpx = x->dp + ix;
-
- /* set the carry to zero */
- u = 0;
-
- /* Multiply and add in place */
- for (iy = 0; iy < n->used; iy++) {
- /* compute product and sum */
- r = ((mp_word)mu) * ((mp_word)*tmpn++) +
- ((mp_word) u) + ((mp_word) * tmpx);
-
- /* get carry */
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-
- /* fix digit */
- *tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK));
- }
- /* At this point the ix'th digit of x should be zero */
-
-
- /* propagate carries upwards as required*/
- while (u) {
- *tmpx += u;
- u = *tmpx >> DIGIT_BIT;
- *tmpx++ &= MP_MASK;
- }
- }
- }
-
- /* at this point the n.used'th least
- * significant digits of x are all zero
- * which means we can shift x to the
- * right by n.used digits and the
- * residue is unchanged.
- */
-
- /* x = x/b**n.used */
- mp_clamp(x);
- mp_rshd (x, n->used);
-
- /* if x >= n then x = x - n */
- if (mp_cmp_mag (x, n) != MP_LT) {
- return s_mp_sub (x, n, x);
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_montgomery_reduce.c */
-
-/* Start: bn_mp_montgomery_setup.c */
-#include <tommath.h>
-#ifdef BN_MP_MONTGOMERY_SETUP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* setups the montgomery reduction stuff */
-int
-mp_montgomery_setup (mp_int * n, mp_digit * rho)
-{
- mp_digit x, b;
-
-/* fast inversion mod 2**k
- *
- * Based on the fact that
- *
- * XA = 1 (mod 2**n) => (X(2-XA)) A = 1 (mod 2**2n)
- * => 2*X*A - X*X*A*A = 1
- * => 2*(1) - (1) = 1
- */
- b = n->dp[0];
-
- if ((b & 1) == 0) {
- return MP_VAL;
- }
-
- x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
- x *= 2 - b * x; /* here x*a==1 mod 2**8 */
-#if !defined(MP_8BIT)
- x *= 2 - b * x; /* here x*a==1 mod 2**16 */
-#endif
-#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT))
- x *= 2 - b * x; /* here x*a==1 mod 2**32 */
-#endif
-#ifdef MP_64BIT
- x *= 2 - b * x; /* here x*a==1 mod 2**64 */
-#endif
-
- /* rho = -1/m mod b */
- *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_montgomery_setup.c */
-
-/* Start: bn_mp_mul.c */
-#include <tommath.h>
-#ifdef BN_MP_MUL_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* high level multiplication (handles sign) */
-int mp_mul (mp_int * a, mp_int * b, mp_int * c)
-{
- int res, neg;
- neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
-
- /* use Toom-Cook? */
-#ifdef BN_MP_TOOM_MUL_C
- if (MIN (a->used, b->used) >= TOOM_MUL_CUTOFF) {
- res = mp_toom_mul(a, b, c);
- } else
-#endif
-#ifdef BN_MP_KARATSUBA_MUL_C
- /* use Karatsuba? */
- if (MIN (a->used, b->used) >= KARATSUBA_MUL_CUTOFF) {
- res = mp_karatsuba_mul (a, b, c);
- } else
-#endif
- {
- /* can we use the fast multiplier?
- *
- * The fast multiplier can be used if the output will
- * have less than MP_WARRAY digits and the number of
- * digits won't affect carry propagation
- */
- int digs = a->used + b->used + 1;
-
-#ifdef BN_FAST_S_MP_MUL_DIGS_C
- if ((digs < MP_WARRAY) &&
- MIN(a->used, b->used) <=
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
- res = fast_s_mp_mul_digs (a, b, c, digs);
- } else
-#endif
-#ifdef BN_S_MP_MUL_DIGS_C
- res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */
-#else
- res = MP_VAL;
-#endif
-
- }
- c->sign = (c->used > 0) ? neg : MP_ZPOS;
- return res;
-}
-#endif
-
-/* End: bn_mp_mul.c */
-
-/* Start: bn_mp_mul_2.c */
-#include <tommath.h>
-#ifdef BN_MP_MUL_2_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* b = a*2 */
-int mp_mul_2(mp_int * a, mp_int * b)
-{
- int x, res, oldused;
-
- /* grow to accomodate result */
- if (b->alloc < a->used + 1) {
- if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- oldused = b->used;
- b->used = a->used;
-
- {
- register mp_digit r, rr, *tmpa, *tmpb;
-
- /* alias for source */
- tmpa = a->dp;
-
- /* alias for dest */
- tmpb = b->dp;
-
- /* carry */
- r = 0;
- for (x = 0; x < a->used; x++) {
-
- /* get what will be the *next* carry bit from the
- * MSB of the current digit
- */
- rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1));
-
- /* now shift up this digit, add in the carry [from the previous] */
- *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK;
-
- /* copy the carry that would be from the source
- * digit into the next iteration
- */
- r = rr;
- }
-
- /* new leading digit? */
- if (r != 0) {
- /* add a MSB which is always 1 at this point */
- *tmpb = 1;
- ++(b->used);
- }
-
- /* now zero any excess digits on the destination
- * that we didn't write to
- */
- tmpb = b->dp + b->used;
- for (x = b->used; x < oldused; x++) {
- *tmpb++ = 0;
- }
- }
- b->sign = a->sign;
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_mul_2.c */
-
-/* Start: bn_mp_mul_2d.c */
-#include <tommath.h>
-#ifdef BN_MP_MUL_2D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* shift left by a certain bit count */
-int mp_mul_2d (mp_int * a, int b, mp_int * c)
-{
- mp_digit d;
- int res;
-
- /* copy */
- if (a != c) {
- if ((res = mp_copy (a, c)) != MP_OKAY) {
- return res;
- }
- }
-
- if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) {
- if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* shift by as many digits in the bit count */
- if (b >= (int)DIGIT_BIT) {
- if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) {
- return res;
- }
- }
-
- /* shift any bit count < DIGIT_BIT */
- d = (mp_digit) (b % DIGIT_BIT);
- if (d != 0) {
- register mp_digit *tmpc, shift, mask, r, rr;
- register int x;
-
- /* bitmask for carries */
- mask = (((mp_digit)1) << d) - 1;
-
- /* shift for msbs */
- shift = DIGIT_BIT - d;
-
- /* alias */
- tmpc = c->dp;
-
- /* carry */
- r = 0;
- for (x = 0; x < c->used; x++) {
- /* get the higher bits of the current word */
- rr = (*tmpc >> shift) & mask;
-
- /* shift the current word and OR in the carry */
- *tmpc = ((*tmpc << d) | r) & MP_MASK;
- ++tmpc;
-
- /* set the carry to the carry bits of the current word */
- r = rr;
- }
-
- /* set final carry */
- if (r != 0) {
- c->dp[(c->used)++] = r;
- }
- }
- mp_clamp (c);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_mul_2d.c */
-
-/* Start: bn_mp_mul_d.c */
-#include <tommath.h>
-#ifdef BN_MP_MUL_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* multiply by a digit */
-int
-mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
-{
- mp_digit u, *tmpa, *tmpc;
- mp_word r;
- int ix, res, olduse;
-
- /* make sure c is big enough to hold a*b */
- if (c->alloc < a->used + 1) {
- if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* get the original destinations used count */
- olduse = c->used;
-
- /* set the sign */
- c->sign = a->sign;
-
- /* alias for a->dp [source] */
- tmpa = a->dp;
-
- /* alias for c->dp [dest] */
- tmpc = c->dp;
-
- /* zero carry */
- u = 0;
-
- /* compute columns */
- for (ix = 0; ix < a->used; ix++) {
- /* compute product and carry sum for this term */
- r = ((mp_word) u) + ((mp_word)*tmpa++) * ((mp_word)b);
-
- /* mask off higher bits to get a single digit */
- *tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
- /* send carry into next iteration */
- u = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
- }
-
- /* store final carry [if any] and increment ix offset */
- *tmpc++ = u;
- ++ix;
-
- /* now zero digits above the top */
- while (ix++ < olduse) {
- *tmpc++ = 0;
- }
-
- /* set used count */
- c->used = a->used + 1;
- mp_clamp(c);
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_mul_d.c */
-
-/* Start: bn_mp_mulmod.c */
-#include <tommath.h>
-#ifdef BN_MP_MULMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* d = a * b (mod c) */
-int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
- int res;
- mp_int t;
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_mul (a, b, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- res = mp_mod (&t, c, d);
- mp_clear (&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_mulmod.c */
-
-/* Start: bn_mp_n_root.c */
-#include <tommath.h>
-#ifdef BN_MP_N_ROOT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* find the n'th root of an integer
- *
- * Result found such that (c)**b <= a and (c+1)**b > a
- *
- * This algorithm uses Newton's approximation
- * x[i+1] = x[i] - f(x[i])/f'(x[i])
- * which will find the root in log(N) time where
- * each step involves a fair bit. This is not meant to
- * find huge roots [square and cube, etc].
- */
-int mp_n_root (mp_int * a, mp_digit b, mp_int * c)
-{
- mp_int t1, t2, t3;
- int res, neg;
-
- /* input must be positive if b is even */
- if ((b & 1) == 0 && a->sign == MP_NEG) {
- return MP_VAL;
- }
-
- if ((res = mp_init (&t1)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init (&t2)) != MP_OKAY) {
- goto LBL_T1;
- }
-
- if ((res = mp_init (&t3)) != MP_OKAY) {
- goto LBL_T2;
- }
-
- /* if a is negative fudge the sign but keep track */
- neg = a->sign;
- a->sign = MP_ZPOS;
-
- /* t2 = 2 */
- mp_set (&t2, 2);
-
- do {
- /* t1 = t2 */
- if ((res = mp_copy (&t2, &t1)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */
-
- /* t3 = t1**(b-1) */
- if ((res = mp_expt_d (&t1, b - 1, &t3)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* numerator */
- /* t2 = t1**b */
- if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t2 = t1**b - a */
- if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* denominator */
- /* t3 = t1**(b-1) * b */
- if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- /* t3 = (t1**b - a)/(b * t1**(b-1)) */
- if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
- } while (mp_cmp (&t1, &t2) != MP_EQ);
-
- /* result can be off by a few so check */
- for (;;) {
- if ((res = mp_expt_d (&t1, b, &t2)) != MP_OKAY) {
- goto LBL_T3;
- }
-
- if (mp_cmp (&t2, a) == MP_GT) {
- if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) {
- goto LBL_T3;
- }
- } else {
- break;
- }
- }
-
- /* reset the sign of a first */
- a->sign = neg;
-
- /* set the result */
- mp_exch (&t1, c);
-
- /* set the sign of the result */
- c->sign = neg;
-
- res = MP_OKAY;
-
-LBL_T3:mp_clear (&t3);
-LBL_T2:mp_clear (&t2);
-LBL_T1:mp_clear (&t1);
- return res;
-}
-#endif
-
-/* End: bn_mp_n_root.c */
-
-/* Start: bn_mp_neg.c */
-#include <tommath.h>
-#ifdef BN_MP_NEG_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* b = -a */
-int mp_neg (mp_int * a, mp_int * b)
-{
- int res;
- if (a != b) {
- if ((res = mp_copy (a, b)) != MP_OKAY) {
- return res;
- }
- }
-
- if (mp_iszero(b) != MP_YES) {
- b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS;
- } else {
- b->sign = MP_ZPOS;
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_neg.c */
-
-/* Start: bn_mp_or.c */
-#include <tommath.h>
-#ifdef BN_MP_OR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* OR two ints together */
-int mp_or (mp_int * a, mp_int * b, mp_int * c)
-{
- int res, ix, px;
- mp_int t, *x;
-
- if (a->used > b->used) {
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
- px = b->used;
- x = b;
- } else {
- if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
- return res;
- }
- px = a->used;
- x = a;
- }
-
- for (ix = 0; ix < px; ix++) {
- t.dp[ix] |= x->dp[ix];
- }
- mp_clamp (&t);
- mp_exch (c, &t);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_or.c */
-
-/* Start: bn_mp_prime_fermat.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_FERMAT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* performs one Fermat test.
- *
- * If "a" were prime then b**a == b (mod a) since the order of
- * the multiplicative sub-group would be phi(a) = a-1. That means
- * it would be the same as b**(a mod (a-1)) == b**1 == b (mod a).
- *
- * Sets result to 1 if the congruence holds, or zero otherwise.
- */
-int mp_prime_fermat (mp_int * a, mp_int * b, int *result)
-{
- mp_int t;
- int err;
-
- /* default to composite */
- *result = MP_NO;
-
- /* ensure b > 1 */
- if (mp_cmp_d(b, 1) != MP_GT) {
- return MP_VAL;
- }
-
- /* init t */
- if ((err = mp_init (&t)) != MP_OKAY) {
- return err;
- }
-
- /* compute t = b**a mod a */
- if ((err = mp_exptmod (b, a, a, &t)) != MP_OKAY) {
- goto LBL_T;
- }
-
- /* is it equal to b? */
- if (mp_cmp (&t, b) == MP_EQ) {
- *result = MP_YES;
- }
-
- err = MP_OKAY;
-LBL_T:mp_clear (&t);
- return err;
-}
-#endif
-
-/* End: bn_mp_prime_fermat.c */
-
-/* Start: bn_mp_prime_is_divisible.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines if an integers is divisible by one
- * of the first PRIME_SIZE primes or not
- *
- * sets result to 0 if not, 1 if yes
- */
-int mp_prime_is_divisible (mp_int * a, int *result)
-{
- int err, ix;
- mp_digit res;
-
- /* default to not */
- *result = MP_NO;
-
- for (ix = 0; ix < PRIME_SIZE; ix++) {
- /* what is a mod LBL_prime_tab[ix] */
- if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) {
- return err;
- }
-
- /* is the residue zero? */
- if (res == 0) {
- *result = MP_YES;
- return MP_OKAY;
- }
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_prime_is_divisible.c */
-
-/* Start: bn_mp_prime_is_prime.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_IS_PRIME_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* performs a variable number of rounds of Miller-Rabin
- *
- * Probability of error after t rounds is no more than
-
- *
- * Sets result to 1 if probably prime, 0 otherwise
- */
-int mp_prime_is_prime (mp_int * a, int t, int *result)
-{
- mp_int b;
- int ix, err, res;
-
- /* default to no */
- *result = MP_NO;
-
- /* valid value of t? */
- if (t <= 0 || t > PRIME_SIZE) {
- return MP_VAL;
- }
-
- /* is the input equal to one of the primes in the table? */
- for (ix = 0; ix < PRIME_SIZE; ix++) {
- if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) {
- *result = 1;
- return MP_OKAY;
- }
- }
-
- /* first perform trial division */
- if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) {
- return err;
- }
-
- /* return if it was trivially divisible */
- if (res == MP_YES) {
- return MP_OKAY;
- }
-
- /* now perform the miller-rabin rounds */
- if ((err = mp_init (&b)) != MP_OKAY) {
- return err;
- }
-
- for (ix = 0; ix < t; ix++) {
- /* set the prime */
- mp_set (&b, ltm_prime_tab[ix]);
-
- if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) {
- goto LBL_B;
- }
-
- if (res == MP_NO) {
- goto LBL_B;
- }
- }
-
- /* passed the test */
- *result = MP_YES;
-LBL_B:mp_clear (&b);
- return err;
-}
-#endif
-
-/* End: bn_mp_prime_is_prime.c */
-
-/* Start: bn_mp_prime_miller_rabin.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_MILLER_RABIN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Miller-Rabin test of "a" to the base of "b" as described in
- * HAC pp. 139 Algorithm 4.24
- *
- * Sets result to 0 if definitely composite or 1 if probably prime.
- * Randomly the chance of error is no more than 1/4 and often
- * very much lower.
- */
-int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
-{
- mp_int n1, y, r;
- int s, j, err;
-
- /* default */
- *result = MP_NO;
-
- /* ensure b > 1 */
- if (mp_cmp_d(b, 1) != MP_GT) {
- return MP_VAL;
- }
-
- /* get n1 = a - 1 */
- if ((err = mp_init_copy (&n1, a)) != MP_OKAY) {
- return err;
- }
- if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) {
- goto LBL_N1;
- }
-
- /* set 2**s * r = n1 */
- if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) {
- goto LBL_N1;
- }
-
- /* count the number of least significant bits
- * which are zero
- */
- s = mp_cnt_lsb(&r);
-
- /* now divide n - 1 by 2**s */
- if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) {
- goto LBL_R;
- }
-
- /* compute y = b**r mod a */
- if ((err = mp_init (&y)) != MP_OKAY) {
- goto LBL_R;
- }
- if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- /* if y != 1 and y != n1 do */
- if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) {
- j = 1;
- /* while j <= s-1 and y != n1 */
- while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) {
- if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
- goto LBL_Y;
- }
-
- /* if y == 1 then composite */
- if (mp_cmp_d (&y, 1) == MP_EQ) {
- goto LBL_Y;
- }
-
- ++j;
- }
-
- /* if y != n1 then composite */
- if (mp_cmp (&y, &n1) != MP_EQ) {
- goto LBL_Y;
- }
- }
-
- /* probably prime now */
- *result = MP_YES;
-LBL_Y:mp_clear (&y);
-LBL_R:mp_clear (&r);
-LBL_N1:mp_clear (&n1);
- return err;
-}
-#endif
-
-/* End: bn_mp_prime_miller_rabin.c */
-
-/* Start: bn_mp_prime_next_prime.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_NEXT_PRIME_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* finds the next prime after the number "a" using "t" trials
- * of Miller-Rabin.
- *
- * bbs_style = 1 means the prime must be congruent to 3 mod 4
- */
-int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
-{
- int err, res, x, y;
- mp_digit res_tab[PRIME_SIZE], step, kstep;
- mp_int b;
-
- /* ensure t is valid */
- if (t <= 0 || t > PRIME_SIZE) {
- return MP_VAL;
- }
-
- /* force positive */
- a->sign = MP_ZPOS;
-
- /* simple algo if a is less than the largest prime in the table */
- if (mp_cmp_d(a, ltm_prime_tab[PRIME_SIZE-1]) == MP_LT) {
- /* find which prime it is bigger than */
- for (x = PRIME_SIZE - 2; x >= 0; x--) {
- if (mp_cmp_d(a, ltm_prime_tab[x]) != MP_LT) {
- if (bbs_style == 1) {
- /* ok we found a prime smaller or
- * equal [so the next is larger]
- *
- * however, the prime must be
- * congruent to 3 mod 4
- */
- if ((ltm_prime_tab[x + 1] & 3) != 3) {
- /* scan upwards for a prime congruent to 3 mod 4 */
- for (y = x + 1; y < PRIME_SIZE; y++) {
- if ((ltm_prime_tab[y] & 3) == 3) {
- mp_set(a, ltm_prime_tab[y]);
- return MP_OKAY;
- }
- }
- }
- } else {
- mp_set(a, ltm_prime_tab[x + 1]);
- return MP_OKAY;
- }
- }
- }
- /* at this point a maybe 1 */
- if (mp_cmp_d(a, 1) == MP_EQ) {
- mp_set(a, 2);
- return MP_OKAY;
- }
- /* fall through to the sieve */
- }
-
- /* generate a prime congruent to 3 mod 4 or 1/3 mod 4? */
- if (bbs_style == 1) {
- kstep = 4;
- } else {
- kstep = 2;
- }
-
- /* at this point we will use a combination of a sieve and Miller-Rabin */
-
- if (bbs_style == 1) {
- /* if a mod 4 != 3 subtract the correct value to make it so */
- if ((a->dp[0] & 3) != 3) {
- if ((err = mp_sub_d(a, (a->dp[0] & 3) + 1, a)) != MP_OKAY) { return err; };
- }
- } else {
- if (mp_iseven(a) == 1) {
- /* force odd */
- if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) {
- return err;
- }
- }
- }
-
- /* generate the restable */
- for (x = 1; x < PRIME_SIZE; x++) {
- if ((err = mp_mod_d(a, ltm_prime_tab[x], res_tab + x)) != MP_OKAY) {
- return err;
- }
- }
-
- /* init temp used for Miller-Rabin Testing */
- if ((err = mp_init(&b)) != MP_OKAY) {
- return err;
- }
-
- for (;;) {
- /* skip to the next non-trivially divisible candidate */
- step = 0;
- do {
- /* y == 1 if any residue was zero [e.g. cannot be prime] */
- y = 0;
-
- /* increase step to next candidate */
- step += kstep;
-
- /* compute the new residue without using division */
- for (x = 1; x < PRIME_SIZE; x++) {
- /* add the step to each residue */
- res_tab[x] += kstep;
-
- /* subtract the modulus [instead of using division] */
- if (res_tab[x] >= ltm_prime_tab[x]) {
- res_tab[x] -= ltm_prime_tab[x];
- }
-
- /* set flag if zero */
- if (res_tab[x] == 0) {
- y = 1;
- }
- }
- } while (y == 1 && step < ((((mp_digit)1)<<DIGIT_BIT) - kstep));
-
- /* add the step */
- if ((err = mp_add_d(a, step, a)) != MP_OKAY) {
- goto LBL_ERR;
- }
-
- /* if didn't pass sieve and step == MAX then skip test */
- if (y == 1 && step >= ((((mp_digit)1)<<DIGIT_BIT) - kstep)) {
- continue;
- }
-
- /* is this prime? */
- for (x = 0; x < t; x++) {
- mp_set(&b, ltm_prime_tab[x]);
- if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {
- goto LBL_ERR;
- }
- if (res == MP_NO) {
- break;
- }
- }
-
- if (res == MP_YES) {
- break;
- }
- }
-
- err = MP_OKAY;
-LBL_ERR:
- mp_clear(&b);
- return err;
-}
-
-#endif
-
-/* End: bn_mp_prime_next_prime.c */
-
-/* Start: bn_mp_prime_rabin_miller_trials.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-
-static const struct {
- int k, t;
-} sizes[] = {
-{ 128, 28 },
-{ 256, 16 },
-{ 384, 10 },
-{ 512, 7 },
-{ 640, 6 },
-{ 768, 5 },
-{ 896, 4 },
-{ 1024, 4 }
-};
-
-/* returns # of RM trials required for a given bit size */
-int mp_prime_rabin_miller_trials(int size)
-{
- int x;
-
- for (x = 0; x < (int)(sizeof(sizes)/(sizeof(sizes[0]))); x++) {
- if (sizes[x].k == size) {
- return sizes[x].t;
- } else if (sizes[x].k > size) {
- return (x == 0) ? sizes[0].t : sizes[x - 1].t;
- }
- }
- return sizes[x-1].t + 1;
-}
-
-
-#endif
-
-/* End: bn_mp_prime_rabin_miller_trials.c */
-
-/* Start: bn_mp_prime_random_ex.c */
-#include <tommath.h>
-#ifdef BN_MP_PRIME_RANDOM_EX_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* makes a truly random prime of a given size (bits),
- *
- * Flags are as follows:
- *
- * LTM_PRIME_BBS - make prime congruent to 3 mod 4
- * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
- * LTM_PRIME_2MSB_ON - make the 2nd highest bit one
- *
- * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
- * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
- * so it can be NULL
- *
- */
-
-/* This is possibly the mother of all prime generation functions, muahahahahaha! */
-int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat)
-{
- unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
- int res, err, bsize, maskOR_msb_offset;
-
- /* sanity check the input */
- if (size <= 1 || t <= 0) {
- return MP_VAL;
- }
-
- /* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
- if (flags & LTM_PRIME_SAFE) {
- flags |= LTM_PRIME_BBS;
- }
-
- /* calc the byte size */
- bsize = (size>>3) + ((size&7)?1:0);
-
- /* we need a buffer of bsize bytes */
- tmp = OPT_CAST(unsigned char) XMALLOC(bsize);
- if (tmp == NULL) {
- return MP_MEM;
- }
-
- /* calc the maskAND value for the MSbyte*/
- maskAND = ((size&7) == 0) ? 0xFF : (0xFF >> (8 - (size & 7)));
-
- /* calc the maskOR_msb */
- maskOR_msb = 0;
- maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
- if (flags & LTM_PRIME_2MSB_ON) {
- maskOR_msb |= 0x80 >> ((9 - size) & 7);
- }
-
- /* get the maskOR_lsb */
- maskOR_lsb = 1;
- if (flags & LTM_PRIME_BBS) {
- maskOR_lsb |= 3;
- }
-
- do {
- /* read the bytes */
- if (cb(tmp, bsize, dat) != bsize) {
- err = MP_VAL;
- goto error;
- }
-
- /* work over the MSbyte */
- tmp[0] &= maskAND;
- tmp[0] |= 1 << ((size - 1) & 7);
-
- /* mix in the maskORs */
- tmp[maskOR_msb_offset] |= maskOR_msb;
- tmp[bsize-1] |= maskOR_lsb;
-
- /* read it in */
- if ((err = mp_read_unsigned_bin(a, tmp, bsize)) != MP_OKAY) { goto error; }
-
- /* is it prime? */
- if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; }
- if (res == MP_NO) {
- continue;
- }
-
- if (flags & LTM_PRIME_SAFE) {
- /* see if (a-1)/2 is prime */
- if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
- if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
-
- /* is it prime? */
- if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; }
- }
- } while (res == MP_NO);
-
- if (flags & LTM_PRIME_SAFE) {
- /* restore a to the original value */
- if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
- if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }
- }
-
- err = MP_OKAY;
-error:
- XFREE(tmp);
- return err;
-}
-
-
-#endif
-
-/* End: bn_mp_prime_random_ex.c */
-
-/* Start: bn_mp_radix_size.c */
-#include <tommath.h>
-#ifdef BN_MP_RADIX_SIZE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* returns size of ASCII reprensentation */
-int mp_radix_size (mp_int * a, int radix, int *size)
-{
- int res, digs;
- mp_int t;
- mp_digit d;
-
- *size = 0;
-
- /* special case for binary */
- if (radix == 2) {
- *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1;
- return MP_OKAY;
- }
-
- /* make sure the radix is in range */
- if (radix < 2 || radix > 64) {
- return MP_VAL;
- }
-
- if (mp_iszero(a) == MP_YES) {
- *size = 2;
- return MP_OKAY;
- }
-
- /* digs is the digit count */
- digs = 0;
-
- /* if it's negative add one for the sign */
- if (a->sign == MP_NEG) {
- ++digs;
- }
-
- /* init a copy of the input */
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
-
- /* force temp to positive */
- t.sign = MP_ZPOS;
-
- /* fetch out all of the digits */
- while (mp_iszero (&t) == MP_NO) {
- if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- ++digs;
- }
- mp_clear (&t);
-
- /* return digs + 1, the 1 is for the NULL byte that would be required. */
- *size = digs + 1;
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_radix_size.c */
-
-/* Start: bn_mp_radix_smap.c */
-#include <tommath.h>
-#ifdef BN_MP_RADIX_SMAP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* chars used in radix conversions */
-const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-#endif
-
-/* End: bn_mp_radix_smap.c */
-
-/* Start: bn_mp_rand.c */
-#include <tommath.h>
-#ifdef BN_MP_RAND_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* makes a pseudo-random int of a given size */
-int
-mp_rand (mp_int * a, int digits)
-{
- int res;
- mp_digit d;
-
- mp_zero (a);
- if (digits <= 0) {
- return MP_OKAY;
- }
-
- /* first place a random non-zero digit */
- do {
- d = ((mp_digit) abs (rand ())) & MP_MASK;
- } while (d == 0);
-
- if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
- return res;
- }
-
- while (--digits > 0) {
- if ((res = mp_lshd (a, 1)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) {
- return res;
- }
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_rand.c */
-
-/* Start: bn_mp_read_radix.c */
-#include <tommath.h>
-#ifdef BN_MP_READ_RADIX_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* read a string [ASCII] in a given radix */
-int mp_read_radix (mp_int * a, const char *str, int radix)
-{
- int y, res, neg;
- char ch;
-
- /* zero the digit bignum */
- mp_zero(a);
-
- /* make sure the radix is ok */
- if (radix < 2 || radix > 64) {
- return MP_VAL;
- }
-
- /* if the leading digit is a
- * minus set the sign to negative.
- */
- if (*str == '-') {
- ++str;
- neg = MP_NEG;
- } else {
- neg = MP_ZPOS;
- }
-
- /* set the integer to the default of zero */
- mp_zero (a);
-
- /* process each digit of the string */
- while (*str) {
- /* if the radix < 36 the conversion is case insensitive
- * this allows numbers like 1AB and 1ab to represent the same value
- * [e.g. in hex]
- */
- ch = (char) ((radix < 36) ? toupper (*str) : *str);
- for (y = 0; y < 64; y++) {
- if (ch == mp_s_rmap[y]) {
- break;
- }
- }
-
- /* if the char was found in the map
- * and is less than the given radix add it
- * to the number, otherwise exit the loop.
- */
- if (y < radix) {
- if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) {
- return res;
- }
- if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) {
- return res;
- }
- } else {
- break;
- }
- ++str;
- }
-
- /* set the sign only if a != 0 */
- if (mp_iszero(a) != 1) {
- a->sign = neg;
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_read_radix.c */
-
-/* Start: bn_mp_read_signed_bin.c */
-#include <tommath.h>
-#ifdef BN_MP_READ_SIGNED_BIN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* read signed bin, big endian, first byte is 0==positive or 1==negative */
-int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
-{
- int res;
-
- /* read magnitude */
- if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) {
- return res;
- }
-
- /* first byte is 0 for positive, non-zero for negative */
- if (b[0] == 0) {
- a->sign = MP_ZPOS;
- } else {
- a->sign = MP_NEG;
- }
-
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_read_signed_bin.c */
-
-/* Start: bn_mp_read_unsigned_bin.c */
-#include <tommath.h>
-#ifdef BN_MP_READ_UNSIGNED_BIN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reads a unsigned char array, assumes the msb is stored first [big endian] */
-int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
-{
- int res;
-
- /* make sure there are at least two digits */
- if (a->alloc < 2) {
- if ((res = mp_grow(a, 2)) != MP_OKAY) {
- return res;
- }
- }
-
- /* zero the int */
- mp_zero (a);
-
- /* read the bytes in */
- while (c-- > 0) {
- if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) {
- return res;
- }
-
-#ifndef MP_8BIT
- a->dp[0] |= *b++;
- a->used += 1;
-#else
- a->dp[0] = (*b & MP_MASK);
- a->dp[1] |= ((*b++ >> 7U) & 1);
- a->used += 2;
-#endif
- }
- mp_clamp (a);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_read_unsigned_bin.c */
-
-/* Start: bn_mp_reduce.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reduces x mod m, assumes 0 < x < m**2, mu is
- * precomputed via mp_reduce_setup.
- * From HAC pp.604 Algorithm 14.42
- */
-int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
-{
- mp_int q;
- int res, um = m->used;
-
- /* q = x */
- if ((res = mp_init_copy (&q, x)) != MP_OKAY) {
- return res;
- }
-
- /* q1 = x / b**(k-1) */
- mp_rshd (&q, um - 1);
-
- /* according to HAC this optimization is ok */
- if (((unsigned long) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
- if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
- goto CLEANUP;
- }
- } else {
-#ifdef BN_S_MP_MUL_HIGH_DIGS_C
- if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
- goto CLEANUP;
- }
-#elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
- if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
- goto CLEANUP;
- }
-#else
- {
- res = MP_VAL;
- goto CLEANUP;
- }
-#endif
- }
-
- /* q3 = q2 / b**(k+1) */
- mp_rshd (&q, um + 1);
-
- /* x = x mod b**(k+1), quick (no division) */
- if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
- goto CLEANUP;
- }
-
- /* q = q * m mod b**(k+1), quick (no division) */
- if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) {
- goto CLEANUP;
- }
-
- /* x = x - q */
- if ((res = mp_sub (x, &q, x)) != MP_OKAY) {
- goto CLEANUP;
- }
-
- /* If x < 0, add b**(k+1) to it */
- if (mp_cmp_d (x, 0) == MP_LT) {
- mp_set (&q, 1);
- if ((res = mp_lshd (&q, um + 1)) != MP_OKAY)
- goto CLEANUP;
- if ((res = mp_add (x, &q, x)) != MP_OKAY)
- goto CLEANUP;
- }
-
- /* Back off if it's too big */
- while (mp_cmp (x, m) != MP_LT) {
- if ((res = s_mp_sub (x, m, x)) != MP_OKAY) {
- goto CLEANUP;
- }
- }
-
-CLEANUP:
- mp_clear (&q);
-
- return res;
-}
-#endif
-
-/* End: bn_mp_reduce.c */
-
-/* Start: bn_mp_reduce_2k.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_2K_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reduces a modulo n where n is of the form 2**p - d */
-int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d)
-{
- mp_int q;
- int p, res;
-
- if ((res = mp_init(&q)) != MP_OKAY) {
- return res;
- }
-
- p = mp_count_bits(n);
-top:
- /* q = a/2**p, a = a mod 2**p */
- if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
- }
-
- if (d != 1) {
- /* q = q * d */
- if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
- goto ERR;
- }
- }
-
- /* a = a + q */
- if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
- }
-
- if (mp_cmp_mag(a, n) != MP_LT) {
- s_mp_sub(a, n, a);
- goto top;
- }
-
-ERR:
- mp_clear(&q);
- return res;
-}
-
-#endif
-
-/* End: bn_mp_reduce_2k.c */
-
-/* Start: bn_mp_reduce_2k_l.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_2K_L_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reduces a modulo n where n is of the form 2**p - d
- This differs from reduce_2k since "d" can be larger
- than a single digit.
-*/
-int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d)
-{
- mp_int q;
- int p, res;
-
- if ((res = mp_init(&q)) != MP_OKAY) {
- return res;
- }
-
- p = mp_count_bits(n);
-top:
- /* q = a/2**p, a = a mod 2**p */
- if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
- }
-
- /* q = q * d */
- if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
- goto ERR;
- }
-
- /* a = a + q */
- if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
- }
-
- if (mp_cmp_mag(a, n) != MP_LT) {
- s_mp_sub(a, n, a);
- goto top;
- }
-
-ERR:
- mp_clear(&q);
- return res;
-}
-
-#endif
-
-/* End: bn_mp_reduce_2k_l.c */
-
-/* Start: bn_mp_reduce_2k_setup.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_2K_SETUP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines the setup value */
-int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
-{
- int res, p;
- mp_int tmp;
-
- if ((res = mp_init(&tmp)) != MP_OKAY) {
- return res;
- }
-
- p = mp_count_bits(a);
- if ((res = mp_2expt(&tmp, p)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
-
- if ((res = s_mp_sub(&tmp, a, &tmp)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
- }
-
- *d = tmp.dp[0];
- mp_clear(&tmp);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_reduce_2k_setup.c */
-
-/* Start: bn_mp_reduce_2k_setup_l.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_2K_SETUP_L_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines the setup value */
-int mp_reduce_2k_setup_l(mp_int *a, mp_int *d)
-{
- int res;
- mp_int tmp;
-
- if ((res = mp_init(&tmp)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
- goto ERR;
- }
-
-ERR:
- mp_clear(&tmp);
- return res;
-}
-#endif
-
-/* End: bn_mp_reduce_2k_setup_l.c */
-
-/* Start: bn_mp_reduce_is_2k.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_IS_2K_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines if mp_reduce_2k can be used */
-int mp_reduce_is_2k(mp_int *a)
-{
- int ix, iy, iw;
- mp_digit iz;
-
- if (a->used == 0) {
- return MP_NO;
- } else if (a->used == 1) {
- return MP_YES;
- } else if (a->used > 1) {
- iy = mp_count_bits(a);
- iz = 1;
- iw = 1;
-
- /* Test every bit from the second digit up, must be 1 */
- for (ix = DIGIT_BIT; ix < iy; ix++) {
- if ((a->dp[iw] & iz) == 0) {
- return MP_NO;
- }
- iz <<= 1;
- if (iz > (mp_digit)MP_MASK) {
- ++iw;
- iz = 1;
- }
- }
- }
- return MP_YES;
-}
-
-#endif
-
-/* End: bn_mp_reduce_is_2k.c */
-
-/* Start: bn_mp_reduce_is_2k_l.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_IS_2K_L_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* determines if reduce_2k_l can be used */
-int mp_reduce_is_2k_l(mp_int *a)
-{
- int ix, iy;
-
- if (a->used == 0) {
- return MP_NO;
- } else if (a->used == 1) {
- return MP_YES;
- } else if (a->used > 1) {
- /* if more than half of the digits are -1 we're sold */
- for (iy = ix = 0; ix < a->used; ix++) {
- if (a->dp[ix] == MP_MASK) {
- ++iy;
- }
- }
- return (iy >= (a->used/2)) ? MP_YES : MP_NO;
-
- }
- return MP_NO;
-}
-
-#endif
-
-/* End: bn_mp_reduce_is_2k_l.c */
-
-/* Start: bn_mp_reduce_setup.c */
-#include <tommath.h>
-#ifdef BN_MP_REDUCE_SETUP_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* pre-calculate the value required for Barrett reduction
- * For a given modulus "b" it calulates the value required in "a"
- */
-int mp_reduce_setup (mp_int * a, mp_int * b)
-{
- int res;
-
- if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
- return res;
- }
- return mp_div (a, b, a, NULL);
-}
-#endif
-
-/* End: bn_mp_reduce_setup.c */
-
-/* Start: bn_mp_rshd.c */
-#include <tommath.h>
-#ifdef BN_MP_RSHD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* shift right a certain amount of digits */
-void mp_rshd (mp_int * a, int b)
-{
- int x;
-
- /* if b <= 0 then ignore it */
- if (b <= 0) {
- return;
- }
-
- /* if b > used then simply zero it and return */
- if (a->used <= b) {
- mp_zero (a);
- return;
- }
-
- {
- register mp_digit *bottom, *top;
-
- /* shift the digits down */
-
- /* bottom */
- bottom = a->dp;
-
- /* top [offset into digits] */
- top = a->dp + b;
-
- /* this is implemented as a sliding window where
- * the window is b-digits long and digits from
- * the top of the window are copied to the bottom
- *
- * e.g.
-
- b-2 | b-1 | b0 | b1 | b2 | ... | bb | ---->
- /\ | ---->
- \-------------------/ ---->
- */
- for (x = 0; x < (a->used - b); x++) {
- *bottom++ = *top++;
- }
-
- /* zero the top digits */
- for (; x < a->used; x++) {
- *bottom++ = 0;
- }
- }
-
- /* remove excess digits */
- a->used -= b;
-}
-#endif
-
-/* End: bn_mp_rshd.c */
-
-/* Start: bn_mp_set.c */
-#include <tommath.h>
-#ifdef BN_MP_SET_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* set to a digit */
-void mp_set (mp_int * a, mp_digit b)
-{
- mp_zero (a);
- a->dp[0] = b & MP_MASK;
- a->used = (a->dp[0] != 0) ? 1 : 0;
-}
-#endif
-
-/* End: bn_mp_set.c */
-
-/* Start: bn_mp_set_int.c */
-#include <tommath.h>
-#ifdef BN_MP_SET_INT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* set a 32-bit const */
-int mp_set_int (mp_int * a, unsigned long b)
-{
- int x, res;
-
- mp_zero (a);
-
- /* set four bits at a time */
- for (x = 0; x < 8; x++) {
- /* shift the number up four bits */
- if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
- return res;
- }
-
- /* OR in the top four bits of the source */
- a->dp[0] |= (b >> 28) & 15;
-
- /* shift the source up to the next four bits */
- b <<= 4;
-
- /* ensure that digits are not clamped off */
- a->used += 1;
- }
- mp_clamp (a);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_set_int.c */
-
-/* Start: bn_mp_shrink.c */
-#include <tommath.h>
-#ifdef BN_MP_SHRINK_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* shrink a bignum */
-int mp_shrink (mp_int * a)
-{
- mp_digit *tmp;
- int used = 1;
-
- if(a->used > 0)
- used = a->used;
-
- if (a->alloc != used) {
- if ((tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * used)) == NULL) {
- return MP_MEM;
- }
- a->dp = tmp;
- a->alloc = used;
- }
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_shrink.c */
-
-/* Start: bn_mp_signed_bin_size.c */
-#include <tommath.h>
-#ifdef BN_MP_SIGNED_BIN_SIZE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* get the size for an signed equivalent */
-int mp_signed_bin_size (mp_int * a)
-{
- return 1 + mp_unsigned_bin_size (a);
-}
-#endif
-
-/* End: bn_mp_signed_bin_size.c */
-
-/* Start: bn_mp_sqr.c */
-#include <tommath.h>
-#ifdef BN_MP_SQR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* computes b = a*a */
-int
-mp_sqr (mp_int * a, mp_int * b)
-{
- int res;
-
-#ifdef BN_MP_TOOM_SQR_C
- /* use Toom-Cook? */
- if (a->used >= TOOM_SQR_CUTOFF) {
- res = mp_toom_sqr(a, b);
- /* Karatsuba? */
- } else
-#endif
-#ifdef BN_MP_KARATSUBA_SQR_C
-if (a->used >= KARATSUBA_SQR_CUTOFF) {
- res = mp_karatsuba_sqr (a, b);
- } else
-#endif
- {
-#ifdef BN_FAST_S_MP_SQR_C
- /* can we use the fast comba multiplier? */
- if ((a->used * 2 + 1) < MP_WARRAY &&
- a->used <
- (1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) {
- res = fast_s_mp_sqr (a, b);
- } else
-#endif
-#ifdef BN_S_MP_SQR_C
- res = s_mp_sqr (a, b);
-#else
- res = MP_VAL;
-#endif
- }
- b->sign = MP_ZPOS;
- return res;
-}
-#endif
-
-/* End: bn_mp_sqr.c */
-
-/* Start: bn_mp_sqrmod.c */
-#include <tommath.h>
-#ifdef BN_MP_SQRMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* c = a * a (mod b) */
-int
-mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
-{
- int res;
- mp_int t;
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_sqr (a, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- res = mp_mod (&t, b, c);
- mp_clear (&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_sqrmod.c */
-
-/* Start: bn_mp_sqrt.c */
-#include <tommath.h>
-
-#ifdef BN_MP_SQRT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* this function is less generic than mp_n_root, simpler and faster */
-int mp_sqrt(mp_int *arg, mp_int *ret)
-{
- int res;
- mp_int t1,t2;
-
- /* must be positive */
- if (arg->sign == MP_NEG) {
- return MP_VAL;
- }
-
- /* easy out */
- if (mp_iszero(arg) == MP_YES) {
- mp_zero(ret);
- return MP_OKAY;
- }
-
- if ((res = mp_init_copy(&t1, arg)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_init(&t2)) != MP_OKAY) {
- goto E2;
- }
-
- /* First approx. (not very bad for large arg) */
- mp_rshd (&t1,t1.used/2);
-
- /* t1 > 0 */
- if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
- goto E1;
- }
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
- goto E1;
- }
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
- goto E1;
- }
- /* And now t1 > sqrt(arg) */
- do {
- if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
- goto E1;
- }
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
- goto E1;
- }
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
- goto E1;
- }
- /* t1 >= sqrt(arg) >= t2 at this point */
- } while (mp_cmp_mag(&t1,&t2) == MP_GT);
-
- mp_exch(&t1,ret);
-
-E1: mp_clear(&t2);
-E2: mp_clear(&t1);
- return res;
-}
-
-#endif
-
-/* End: bn_mp_sqrt.c */
-
-/* Start: bn_mp_sub.c */
-#include <tommath.h>
-#ifdef BN_MP_SUB_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* high level subtraction (handles signs) */
-int
-mp_sub (mp_int * a, mp_int * b, mp_int * c)
-{
- int sa, sb, res;
-
- sa = a->sign;
- sb = b->sign;
-
- if (sa != sb) {
- /* subtract a negative from a positive, OR */
- /* subtract a positive from a negative. */
- /* In either case, ADD their magnitudes, */
- /* and use the sign of the first number. */
- c->sign = sa;
- res = s_mp_add (a, b, c);
- } else {
- /* subtract a positive from a positive, OR */
- /* subtract a negative from a negative. */
- /* First, take the difference between their */
- /* magnitudes, then... */
- if (mp_cmp_mag (a, b) != MP_LT) {
- /* Copy the sign from the first */
- c->sign = sa;
- /* The first has a larger or equal magnitude */
- res = s_mp_sub (a, b, c);
- } else {
- /* The result has the *opposite* sign from */
- /* the first number. */
- c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
- /* The second has a larger magnitude */
- res = s_mp_sub (b, a, c);
- }
- }
- return res;
-}
-
-#endif
-
-/* End: bn_mp_sub.c */
-
-/* Start: bn_mp_sub_d.c */
-#include <tommath.h>
-#ifdef BN_MP_SUB_D_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* single digit subtraction */
-int
-mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
-{
- mp_digit *tmpa, *tmpc, mu;
- int res, ix, oldused;
-
- /* grow c as required */
- if (c->alloc < a->used + 1) {
- if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* if a is negative just do an unsigned
- * addition [with fudged signs]
- */
- if (a->sign == MP_NEG) {
- a->sign = MP_ZPOS;
- res = mp_add_d(a, b, c);
- a->sign = c->sign = MP_NEG;
-
- /* clamp */
- mp_clamp(c);
-
- return res;
- }
-
- /* setup regs */
- oldused = c->used;
- tmpa = a->dp;
- tmpc = c->dp;
-
- /* if a <= b simply fix the single digit */
- if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) {
- if (a->used == 1) {
- *tmpc++ = b - *tmpa;
- } else {
- *tmpc++ = b;
- }
- ix = 1;
-
- /* negative/1digit */
- c->sign = MP_NEG;
- c->used = 1;
- } else {
- /* positive/size */
- c->sign = MP_ZPOS;
- c->used = a->used;
-
- /* subtract first digit */
- *tmpc = *tmpa++ - b;
- mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
- *tmpc++ &= MP_MASK;
-
- /* handle rest of the digits */
- for (ix = 1; ix < a->used; ix++) {
- *tmpc = *tmpa++ - mu;
- mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
- *tmpc++ &= MP_MASK;
- }
- }
-
- /* zero excess digits */
- while (ix++ < oldused) {
- *tmpc++ = 0;
- }
- mp_clamp(c);
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_sub_d.c */
-
-/* Start: bn_mp_submod.c */
-#include <tommath.h>
-#ifdef BN_MP_SUBMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* d = a - b (mod c) */
-int
-mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
- int res;
- mp_int t;
-
-
- if ((res = mp_init (&t)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_sub (a, b, &t)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- res = mp_mod (&t, c, d);
- mp_clear (&t);
- return res;
-}
-#endif
-
-/* End: bn_mp_submod.c */
-
-/* Start: bn_mp_to_signed_bin.c */
-#include <tommath.h>
-#ifdef BN_MP_TO_SIGNED_BIN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* store in signed [big endian] format */
-int mp_to_signed_bin (mp_int * a, unsigned char *b)
-{
- int res;
-
- if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) {
- return res;
- }
- b[0] = (unsigned char) ((a->sign == MP_ZPOS) ? 0 : 1);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_to_signed_bin.c */
-
-/* Start: bn_mp_to_signed_bin_n.c */
-#include <tommath.h>
-#ifdef BN_MP_TO_SIGNED_BIN_N_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* store in signed [big endian] format */
-int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen)
-{
- if (*outlen < (unsigned long)mp_signed_bin_size(a)) {
- return MP_VAL;
- }
- *outlen = mp_signed_bin_size(a);
- return mp_to_signed_bin(a, b);
-}
-#endif
-
-/* End: bn_mp_to_signed_bin_n.c */
-
-/* Start: bn_mp_to_unsigned_bin.c */
-#include <tommath.h>
-#ifdef BN_MP_TO_UNSIGNED_BIN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* store in unsigned [big endian] format */
-int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
-{
- int x, res;
- mp_int t;
-
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
-
- x = 0;
- while (mp_iszero (&t) == 0) {
-#ifndef MP_8BIT
- b[x++] = (unsigned char) (t.dp[0] & 255);
-#else
- b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7));
-#endif
- if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- }
- bn_reverse (b, x);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_to_unsigned_bin.c */
-
-/* Start: bn_mp_to_unsigned_bin_n.c */
-#include <tommath.h>
-#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* store in unsigned [big endian] format */
-int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen)
-{
- if (*outlen < (unsigned long)mp_unsigned_bin_size(a)) {
- return MP_VAL;
- }
- *outlen = mp_unsigned_bin_size(a);
- return mp_to_unsigned_bin(a, b);
-}
-#endif
-
-/* End: bn_mp_to_unsigned_bin_n.c */
-
-/* Start: bn_mp_toom_mul.c */
-#include <tommath.h>
-#ifdef BN_MP_TOOM_MUL_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* multiplication using the Toom-Cook 3-way algorithm
- *
- * Much more complicated than Karatsuba but has a lower
- * asymptotic running time of O(N**1.464). This algorithm is
- * only particularly useful on VERY large inputs
- * (we're talking 1000s of digits here...).
-*/
-int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
-{
- mp_int w0, w1, w2, w3, w4, tmp1, tmp2, a0, a1, a2, b0, b1, b2;
- int res, B;
-
- /* init temps */
- if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4,
- &a0, &a1, &a2, &b0, &b1,
- &b2, &tmp1, &tmp2, NULL)) != MP_OKAY) {
- return res;
- }
-
- /* B */
- B = MIN(a->used, b->used) / 3;
-
- /* a = a2 * B**2 + a1 * B + a0 */
- if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&a1, B);
- mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
-
- if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&a2, B*2);
-
- /* b = b2 * B**2 + b1 * B + b0 */
- if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_copy(b, &b1)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&b1, B);
- mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
-
- if ((res = mp_copy(b, &b2)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&b2, B*2);
-
- /* w0 = a0*b0 */
- if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w4 = a2 * b2 */
- if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */
- if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */
- if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
- goto ERR;
- }
-
-
- /* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */
- if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
- goto ERR;
- }
-
- /* now solve the matrix
-
- 0 0 0 0 1
- 1 2 4 8 16
- 1 1 1 1 1
- 16 8 4 2 1
- 1 0 0 0 0
-
- using 12 subtractions, 4 shifts,
- 2 small divisions and 1 small multiplication
- */
-
- /* r1 - r4 */
- if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r0 */
- if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/2 */
- if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/2 */
- if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r2 - r0 - r4 */
- if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - 8r0 */
- if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - 8r4 */
- if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* 3r2 - r1 - r3 */
- if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/3 */
- if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/3 */
- if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
- }
-
- /* at this point shift W[n] by B*n */
- if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
- goto ERR;
- }
-
-ERR:
- mp_clear_multi(&w0, &w1, &w2, &w3, &w4,
- &a0, &a1, &a2, &b0, &b1,
- &b2, &tmp1, &tmp2, NULL);
- return res;
-}
-
-#endif
-
-/* End: bn_mp_toom_mul.c */
-
-/* Start: bn_mp_toom_sqr.c */
-#include <tommath.h>
-#ifdef BN_MP_TOOM_SQR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* squaring using Toom-Cook 3-way algorithm */
-int
-mp_toom_sqr(mp_int *a, mp_int *b)
-{
- mp_int w0, w1, w2, w3, w4, tmp1, a0, a1, a2;
- int res, B;
-
- /* init temps */
- if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL)) != MP_OKAY) {
- return res;
- }
-
- /* B */
- B = a->used / 3;
-
- /* a = a2 * B**2 + a1 * B + a0 */
- if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&a1, B);
- mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
-
- if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
- }
- mp_rshd(&a2, B*2);
-
- /* w0 = a0*a0 */
- if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w4 = a2 * a2 */
- if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w1 = (a2 + 2(a1 + 2a0))**2 */
- if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) {
- goto ERR;
- }
-
- /* w3 = (a0 + 2(a1 + 2a2))**2 */
- if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) {
- goto ERR;
- }
-
-
- /* w2 = (a2 + a1 + a0)**2 */
- if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) {
- goto ERR;
- }
-
- /* now solve the matrix
-
- 0 0 0 0 1
- 1 2 4 8 16
- 1 1 1 1 1
- 16 8 4 2 1
- 1 0 0 0 0
-
- using 12 subtractions, 4 shifts, 2 small divisions and 1 small multiplication.
- */
-
- /* r1 - r4 */
- if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r0 */
- if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/2 */
- if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/2 */
- if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r2 - r0 - r4 */
- if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - 8r0 */
- if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - 8r4 */
- if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* 3r2 - r1 - r3 */
- if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
- }
- /* r1 - r2 */
- if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
- }
- /* r3 - r2 */
- if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
- }
- /* r1/3 */
- if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
- }
- /* r3/3 */
- if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
- }
-
- /* at this point shift W[n] by B*n */
- if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
- }
-
- if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
- }
- if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
- goto ERR;
- }
-
-ERR:
- mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
- return res;
-}
-
-#endif
-
-/* End: bn_mp_toom_sqr.c */
-
-/* Start: bn_mp_toradix.c */
-#include <tommath.h>
-#ifdef BN_MP_TORADIX_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* stores a bignum as a ASCII string in a given radix (2..64) */
-int mp_toradix (mp_int * a, char *str, int radix)
-{
- int res, digs;
- mp_int t;
- mp_digit d;
- char *_s = str;
-
- /* check range of the radix */
- if (radix < 2 || radix > 64) {
- return MP_VAL;
- }
-
- /* quick out if its zero */
- if (mp_iszero(a) == 1) {
- *str++ = '0';
- *str = '\0';
- return MP_OKAY;
- }
-
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
-
- /* if it is negative output a - */
- if (t.sign == MP_NEG) {
- ++_s;
- *str++ = '-';
- t.sign = MP_ZPOS;
- }
-
- digs = 0;
- while (mp_iszero (&t) == 0) {
- if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- *str++ = mp_s_rmap[d];
- ++digs;
- }
-
- /* reverse the digits of the string. In this case _s points
- * to the first digit [exluding the sign] of the number]
- */
- bn_reverse ((unsigned char *)_s, digs);
-
- /* append a NULL so the string is properly terminated */
- *str = '\0';
-
- mp_clear (&t);
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_toradix.c */
-
-/* Start: bn_mp_toradix_n.c */
-#include <tommath.h>
-#ifdef BN_MP_TORADIX_N_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* stores a bignum as a ASCII string in a given radix (2..64)
- *
- * Stores upto maxlen-1 chars and always a NULL byte
- */
-int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
-{
- int res, digs;
- mp_int t;
- mp_digit d;
- char *_s = str;
-
- /* check range of the maxlen, radix */
- if (maxlen < 2 || radix < 2 || radix > 64) {
- return MP_VAL;
- }
-
- /* quick out if its zero */
- if (mp_iszero(a) == MP_YES) {
- *str++ = '0';
- *str = '\0';
- return MP_OKAY;
- }
-
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
-
- /* if it is negative output a - */
- if (t.sign == MP_NEG) {
- /* we have to reverse our digits later... but not the - sign!! */
- ++_s;
-
- /* store the flag and mark the number as positive */
- *str++ = '-';
- t.sign = MP_ZPOS;
-
- /* subtract a char */
- --maxlen;
- }
-
- digs = 0;
- while (mp_iszero (&t) == 0) {
- if (--maxlen < 1) {
- /* no more room */
- break;
- }
- if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
- mp_clear (&t);
- return res;
- }
- *str++ = mp_s_rmap[d];
- ++digs;
- }
-
- /* reverse the digits of the string. In this case _s points
- * to the first digit [exluding the sign] of the number
- */
- bn_reverse ((unsigned char *)_s, digs);
-
- /* append a NULL so the string is properly terminated */
- *str = '\0';
-
- mp_clear (&t);
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_mp_toradix_n.c */
-
-/* Start: bn_mp_unsigned_bin_size.c */
-#include <tommath.h>
-#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* get the size for an unsigned equivalent */
-int mp_unsigned_bin_size (mp_int * a)
-{
- int size = mp_count_bits (a);
- return (size / 8 + ((size & 7) != 0 ? 1 : 0));
-}
-#endif
-
-/* End: bn_mp_unsigned_bin_size.c */
-
-/* Start: bn_mp_xor.c */
-#include <tommath.h>
-#ifdef BN_MP_XOR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* XOR two ints together */
-int
-mp_xor (mp_int * a, mp_int * b, mp_int * c)
-{
- int res, ix, px;
- mp_int t, *x;
-
- if (a->used > b->used) {
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
- }
- px = b->used;
- x = b;
- } else {
- if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
- return res;
- }
- px = a->used;
- x = a;
- }
-
- for (ix = 0; ix < px; ix++) {
- t.dp[ix] ^= x->dp[ix];
- }
- mp_clamp (&t);
- mp_exch (c, &t);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_mp_xor.c */
-
-/* Start: bn_mp_zero.c */
-#include <tommath.h>
-#ifdef BN_MP_ZERO_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* set to zero */
-void mp_zero (mp_int * a)
-{
- int n;
- mp_digit *tmp;
-
- a->sign = MP_ZPOS;
- a->used = 0;
-
- tmp = a->dp;
- for (n = 0; n < a->alloc; n++) {
- *tmp++ = 0;
- }
-}
-#endif
-
-/* End: bn_mp_zero.c */
-
-/* Start: bn_prime_tab.c */
-#include <tommath.h>
-#ifdef BN_PRIME_TAB_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-const mp_digit ltm_prime_tab[] = {
- 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
- 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035,
- 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059,
- 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F,
-#ifndef MP_8BIT
- 0x0083,
- 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD,
- 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF,
- 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107,
- 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137,
-
- 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167,
- 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199,
- 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9,
- 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7,
- 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239,
- 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265,
- 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293,
- 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF,
-
- 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301,
- 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B,
- 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371,
- 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD,
- 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5,
- 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419,
- 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449,
- 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B,
-
- 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7,
- 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503,
- 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529,
- 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F,
- 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3,
- 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7,
- 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623,
- 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653
-#endif
-};
-#endif
-
-/* End: bn_prime_tab.c */
-
-/* Start: bn_reverse.c */
-#include <tommath.h>
-#ifdef BN_REVERSE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* reverse an array, used for radix code */
-void
-bn_reverse (unsigned char *s, int len)
-{
- int ix, iy;
- unsigned char t;
-
- ix = 0;
- iy = len - 1;
- while (ix < iy) {
- t = s[ix];
- s[ix] = s[iy];
- s[iy] = t;
- ++ix;
- --iy;
- }
-}
-#endif
-
-/* End: bn_reverse.c */
-
-/* Start: bn_s_mp_add.c */
-#include <tommath.h>
-#ifdef BN_S_MP_ADD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* low level addition, based on HAC pp.594, Algorithm 14.7 */
-int
-s_mp_add (mp_int * a, mp_int * b, mp_int * c)
-{
- mp_int *x;
- int olduse, res, min, max;
-
- /* find sizes, we let |a| <= |b| which means we have to sort
- * them. "x" will point to the input with the most digits
- */
- if (a->used > b->used) {
- min = b->used;
- max = a->used;
- x = a;
- } else {
- min = a->used;
- max = b->used;
- x = b;
- }
-
- /* init result */
- if (c->alloc < max + 1) {
- if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
- return res;
- }
- }
-
- /* get old used digit count and set new one */
- olduse = c->used;
- c->used = max + 1;
-
- {
- register mp_digit u, *tmpa, *tmpb, *tmpc;
- register int i;
-
- /* alias for digit pointers */
-
- /* first input */
- tmpa = a->dp;
-
- /* second input */
- tmpb = b->dp;
-
- /* destination */
- tmpc = c->dp;
-
- /* zero the carry */
- u = 0;
- for (i = 0; i < min; i++) {
- /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */
- *tmpc = *tmpa++ + *tmpb++ + u;
-
- /* U = carry bit of T[i] */
- u = *tmpc >> ((mp_digit)DIGIT_BIT);
-
- /* take away carry bit from T[i] */
- *tmpc++ &= MP_MASK;
- }
-
- /* now copy higher words if any, that is in A+B
- * if A or B has more digits add those in
- */
- if (min != max) {
- for (; i < max; i++) {
- /* T[i] = X[i] + U */
- *tmpc = x->dp[i] + u;
-
- /* U = carry bit of T[i] */
- u = *tmpc >> ((mp_digit)DIGIT_BIT);
-
- /* take away carry bit from T[i] */
- *tmpc++ &= MP_MASK;
- }
- }
-
- /* add carry */
- *tmpc++ = u;
-
- /* clear digits above oldused */
- for (i = c->used; i < olduse; i++) {
- *tmpc++ = 0;
- }
- }
-
- mp_clamp (c);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_s_mp_add.c */
-
-/* Start: bn_s_mp_exptmod.c */
-#include <tommath.h>
-#ifdef BN_S_MP_EXPTMOD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-#ifdef MP_LOW_MEM
- #define TAB_SIZE 32
-#else
- #define TAB_SIZE 256
-#endif
-
-int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
-{
- mp_int M[TAB_SIZE], res, mu;
- mp_digit buf;
- int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
- int (*redux)(mp_int*,mp_int*,mp_int*);
-
- /* find window size */
- x = mp_count_bits (X);
- if (x <= 7) {
- winsize = 2;
- } else if (x <= 36) {
- winsize = 3;
- } else if (x <= 140) {
- winsize = 4;
- } else if (x <= 450) {
- winsize = 5;
- } else if (x <= 1303) {
- winsize = 6;
- } else if (x <= 3529) {
- winsize = 7;
- } else {
- winsize = 8;
- }
-
-#ifdef MP_LOW_MEM
- if (winsize > 5) {
- winsize = 5;
- }
-#endif
-
- /* init M array */
- /* init first cell */
- if ((err = mp_init(&M[1])) != MP_OKAY) {
- return err;
- }
-
- /* now init the second half of the array */
- for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
- if ((err = mp_init(&M[x])) != MP_OKAY) {
- for (y = 1<<(winsize-1); y < x; y++) {
- mp_clear (&M[y]);
- }
- mp_clear(&M[1]);
- return err;
- }
- }
-
- /* create mu, used for Barrett reduction */
- if ((err = mp_init (&mu)) != MP_OKAY) {
- goto LBL_M;
- }
-
- if (redmode == 0) {
- if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) {
- goto LBL_MU;
- }
- redux = mp_reduce;
- } else {
- if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) {
- goto LBL_MU;
- }
- redux = mp_reduce_2k_l;
- }
-
- /* create M table
- *
- * The M table contains powers of the base,
- * e.g. M[x] = G**x mod P
- *
- * The first half of the table is not
- * computed though accept for M[0] and M[1]
- */
- if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) {
- goto LBL_MU;
- }
-
- /* compute the value at M[1<<(winsize-1)] by squaring
- * M[1] (winsize-1) times
- */
- if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto LBL_MU;
- }
-
- for (x = 0; x < (winsize - 1); x++) {
- /* square it */
- if ((err = mp_sqr (&M[1 << (winsize - 1)],
- &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto LBL_MU;
- }
-
- /* reduce modulo P */
- if ((err = redux (&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
- goto LBL_MU;
- }
- }
-
- /* create upper table, that is M[x] = M[x-1] * M[1] (mod P)
- * for x = (2**(winsize - 1) + 1) to (2**winsize - 1)
- */
- for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
- if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
- goto LBL_MU;
- }
- if ((err = redux (&M[x], P, &mu)) != MP_OKAY) {
- goto LBL_MU;
- }
- }
-
- /* setup result */
- if ((err = mp_init (&res)) != MP_OKAY) {
- goto LBL_MU;
- }
- mp_set (&res, 1);
-
- /* set initial mode and bit cnt */
- mode = 0;
- bitcnt = 1;
- buf = 0;
- digidx = X->used - 1;
- bitcpy = 0;
- bitbuf = 0;
-
- for (;;) {
- /* grab next digit as required */
- if (--bitcnt == 0) {
- /* if digidx == -1 we are out of digits */
- if (digidx == -1) {
- break;
- }
- /* read next digit and reset the bitcnt */
- buf = X->dp[digidx--];
- bitcnt = (int) DIGIT_BIT;
- }
-
- /* grab the next msb from the exponent */
- y = (buf >> (mp_digit)(DIGIT_BIT - 1)) & 1;
- buf <<= (mp_digit)1;
-
- /* if the bit is zero and mode == 0 then we ignore it
- * These represent the leading zero bits before the first 1 bit
- * in the exponent. Technically this opt is not required but it
- * does lower the # of trivial squaring/reductions used
- */
- if (mode == 0 && y == 0) {
- continue;
- }
-
- /* if the bit is zero and mode == 1 then we square */
- if (mode == 1 && y == 0) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, &mu)) != MP_OKAY) {
- goto LBL_RES;
- }
- continue;
- }
-
- /* else we add it to the window */
- bitbuf |= (y << (winsize - ++bitcpy));
- mode = 2;
-
- if (bitcpy == winsize) {
- /* ok window is filled so square as required and multiply */
- /* square first */
- for (x = 0; x < winsize; x++) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, &mu)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
-
- /* then multiply */
- if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, &mu)) != MP_OKAY) {
- goto LBL_RES;
- }
-
- /* empty window and reset */
- bitcpy = 0;
- bitbuf = 0;
- mode = 1;
- }
- }
-
- /* if bits remain then square/multiply */
- if (mode == 2 && bitcpy > 0) {
- /* square then multiply if the bit is set */
- for (x = 0; x < bitcpy; x++) {
- if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, &mu)) != MP_OKAY) {
- goto LBL_RES;
- }
-
- bitbuf <<= 1;
- if ((bitbuf & (1 << winsize)) != 0) {
- /* then multiply */
- if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
- goto LBL_RES;
- }
- if ((err = redux (&res, P, &mu)) != MP_OKAY) {
- goto LBL_RES;
- }
- }
- }
- }
-
- mp_exch (&res, Y);
- err = MP_OKAY;
-LBL_RES:mp_clear (&res);
-LBL_MU:mp_clear (&mu);
-LBL_M:
- mp_clear(&M[1]);
- for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
- mp_clear (&M[x]);
- }
- return err;
-}
-#endif
-
-/* End: bn_s_mp_exptmod.c */
-
-/* Start: bn_s_mp_mul_digs.c */
-#include <tommath.h>
-#ifdef BN_S_MP_MUL_DIGS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* multiplies |a| * |b| and only computes upto digs digits of result
- * HAC pp. 595, Algorithm 14.12 Modified so you can control how
- * many digits of output are created.
- */
-int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
- mp_int t;
- int res, pa, pb, ix, iy;
- mp_digit u;
- mp_word r;
- mp_digit tmpx, *tmpt, *tmpy;
-
- /* can we use the fast multiplier? */
- if (((digs) < MP_WARRAY) &&
- MIN (a->used, b->used) <
- (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
- return fast_s_mp_mul_digs (a, b, c, digs);
- }
-
- if ((res = mp_init_size (&t, digs)) != MP_OKAY) {
- return res;
- }
- t.used = digs;
-
- /* compute the digits of the product directly */
- pa = a->used;
- for (ix = 0; ix < pa; ix++) {
- /* set the carry to zero */
- u = 0;
-
- /* limit ourselves to making digs digits of output */
- pb = MIN (b->used, digs - ix);
-
- /* setup some aliases */
- /* copy of the digit from a used within the nested loop */
- tmpx = a->dp[ix];
-
- /* an alias for the destination shifted ix places */
- tmpt = t.dp + ix;
-
- /* an alias for the digits of b */
- tmpy = b->dp;
-
- /* compute the columns of the output and propagate the carry */
- for (iy = 0; iy < pb; iy++) {
- /* compute the column as a mp_word */
- r = ((mp_word)*tmpt) +
- ((mp_word)tmpx) * ((mp_word)*tmpy++) +
- ((mp_word) u);
-
- /* the new column is the lower part of the result */
- *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
- /* get the carry word from the result */
- u = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
- }
- /* set carry if it is placed below digs */
- if (ix + iy < digs) {
- *tmpt = u;
- }
- }
-
- mp_clamp (&t);
- mp_exch (&t, c);
-
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_s_mp_mul_digs.c */
-
-/* Start: bn_s_mp_mul_high_digs.c */
-#include <tommath.h>
-#ifdef BN_S_MP_MUL_HIGH_DIGS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* multiplies |a| * |b| and does not compute the lower digs digits
- * [meant to get the higher part of the product]
- */
-int
-s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
- mp_int t;
- int res, pa, pb, ix, iy;
- mp_digit u;
- mp_word r;
- mp_digit tmpx, *tmpt, *tmpy;
-
- /* can we use the fast multiplier? */
-#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
- if (((a->used + b->used + 1) < MP_WARRAY)
- && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
- return fast_s_mp_mul_high_digs (a, b, c, digs);
- }
-#endif
-
- if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) {
- return res;
- }
- t.used = a->used + b->used + 1;
-
- pa = a->used;
- pb = b->used;
- for (ix = 0; ix < pa; ix++) {
- /* clear the carry */
- u = 0;
-
- /* left hand side of A[ix] * B[iy] */
- tmpx = a->dp[ix];
-
- /* alias to the address of where the digits will be stored */
- tmpt = &(t.dp[digs]);
-
- /* alias for where to read the right hand side from */
- tmpy = b->dp + (digs - ix);
-
- for (iy = digs - ix; iy < pb; iy++) {
- /* calculate the double precision result */
- r = ((mp_word)*tmpt) +
- ((mp_word)tmpx) * ((mp_word)*tmpy++) +
- ((mp_word) u);
-
- /* get the lower part */
- *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
- /* carry the carry */
- u = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
- }
- *tmpt = u;
- }
- mp_clamp (&t);
- mp_exch (&t, c);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_s_mp_mul_high_digs.c */
-
-/* Start: bn_s_mp_sqr.c */
-#include <tommath.h>
-#ifdef BN_S_MP_SQR_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
-int s_mp_sqr (mp_int * a, mp_int * b)
-{
- mp_int t;
- int res, ix, iy, pa;
- mp_word r;
- mp_digit u, tmpx, *tmpt;
-
- pa = a->used;
- if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) {
- return res;
- }
-
- /* default used is maximum possible size */
- t.used = 2*pa + 1;
-
- for (ix = 0; ix < pa; ix++) {
- /* first calculate the digit at 2*ix */
- /* calculate double precision result */
- r = ((mp_word) t.dp[2*ix]) +
- ((mp_word)a->dp[ix])*((mp_word)a->dp[ix]);
-
- /* store lower part in result */
- t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK));
-
- /* get the carry */
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-
- /* left hand side of A[ix] * A[iy] */
- tmpx = a->dp[ix];
-
- /* alias for where to store the results */
- tmpt = t.dp + (2*ix + 1);
-
- for (iy = ix + 1; iy < pa; iy++) {
- /* first calculate the product */
- r = ((mp_word)tmpx) * ((mp_word)a->dp[iy]);
-
- /* now calculate the double precision result, note we use
- * addition instead of *2 since it's easier to optimize
- */
- r = ((mp_word) *tmpt) + r + r + ((mp_word) u);
-
- /* store lower part */
- *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
- /* get carry */
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
- }
- /* propagate upwards */
- while (u != ((mp_digit) 0)) {
- r = ((mp_word) *tmpt) + ((mp_word) u);
- *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
- }
- }
-
- mp_clamp (&t);
- mp_exch (&t, b);
- mp_clear (&t);
- return MP_OKAY;
-}
-#endif
-
-/* End: bn_s_mp_sqr.c */
-
-/* Start: bn_s_mp_sub.c */
-#include <tommath.h>
-#ifdef BN_S_MP_SUB_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
-int
-s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
-{
- int olduse, res, min, max;
-
- /* find sizes */
- min = b->used;
- max = a->used;
-
- /* init result */
- if (c->alloc < max) {
- if ((res = mp_grow (c, max)) != MP_OKAY) {
- return res;
- }
- }
- olduse = c->used;
- c->used = max;
-
- {
- register mp_digit u, *tmpa, *tmpb, *tmpc;
- register int i;
-
- /* alias for digit pointers */
- tmpa = a->dp;
- tmpb = b->dp;
- tmpc = c->dp;
-
- /* set carry to zero */
- u = 0;
- for (i = 0; i < min; i++) {
- /* T[i] = A[i] - B[i] - U */
- *tmpc = *tmpa++ - *tmpb++ - u;
-
- /* U = carry bit of T[i]
- * Note this saves performing an AND operation since
- * if a carry does occur it will propagate all the way to the
- * MSB. As a result a single shift is enough to get the carry
- */
- u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
-
- /* Clear carry from T[i] */
- *tmpc++ &= MP_MASK;
- }
-
- /* now copy higher words if any, e.g. if A has more digits than B */
- for (; i < max; i++) {
- /* T[i] = A[i] - U */
- *tmpc = *tmpa++ - u;
-
- /* U = carry bit of T[i] */
- u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
-
- /* Clear carry from T[i] */
- *tmpc++ &= MP_MASK;
- }
-
- /* clear digits above used (since we may not have grown result above) */
- for (i = c->used; i < olduse; i++) {
- *tmpc++ = 0;
- }
- }
-
- mp_clamp (c);
- return MP_OKAY;
-}
-
-#endif
-
-/* End: bn_s_mp_sub.c */
-
-/* Start: bncore.c */
-#include <tommath.h>
-#ifdef BNCORE_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
- */
-
-/* Known optimal configurations
-
- CPU /Compiler /MUL CUTOFF/SQR CUTOFF
--------------------------------------------------------------
- Intel P4 Northwood /GCC v3.4.1 / 88/ 128/LTM 0.32 ;-)
- AMD Athlon64 /GCC v3.4.4 / 80/ 120/LTM 0.35
-
-*/
-
-int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsuba multiplication is used. */
- KARATSUBA_SQR_CUTOFF = 120, /* Min. number of digits before Karatsuba squaring is used. */
-
- TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */
- TOOM_SQR_CUTOFF = 400;
-#endif
-
-/* End: bncore.c */
-
-
-/* EOF */
diff --git a/libtommath/pretty.build b/libtommath/pretty.build
deleted file mode 100644
index a708b8a..0000000
--- a/libtommath/pretty.build
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/perl -w
-#
-# Cute little builder for perl
-# Total waste of development time...
-#
-# This will build all the object files and then the archive .a file
-# requires GCC, GNU make and a sense of humour.
-#
-# Tom St Denis
-use strict;
-
-my $count = 0;
-my $starttime = time;
-my $rate = 0;
-print "Scanning for source files...\n";
-foreach my $filename (glob "*.c") {
- ++$count;
-}
-print "Source files to build: $count\nBuilding...\n";
-my $i = 0;
-my $lines = 0;
-my $filesbuilt = 0;
-foreach my $filename (glob "*.c") {
- printf("Building %3.2f%%, ", (++$i/$count)*100.0);
- if ($i % 4 == 0) { print "/, "; }
- if ($i % 4 == 1) { print "-, "; }
- if ($i % 4 == 2) { print "\\, "; }
- if ($i % 4 == 3) { print "|, "; }
- if ($rate > 0) {
- my $tleft = ($count - $i) / $rate;
- my $tsec = $tleft%60;
- my $tmin = ($tleft/60)%60;
- my $thour = ($tleft/3600)%60;
- printf("%2d:%02d:%02d left, ", $thour, $tmin, $tsec);
- }
- my $cnt = ($i/$count)*30.0;
- my $x = 0;
- print "[";
- for (; $x < $cnt; $x++) { print "#"; }
- for (; $x < 30; $x++) { print " "; }
- print "]\r";
- my $tmp = $filename;
- $tmp =~ s/\.c/".o"/ge;
- if (open(SRC, "<$tmp")) {
- close SRC;
- } else {
- !system("make $tmp > /dev/null 2>/dev/null") or die "\nERROR: Failed to make $tmp!!!\n";
- open( SRC, "<$filename" ) or die "Couldn't open $filename for reading: $!";
- ++$lines while (<SRC>);
- close SRC or die "Error closing $filename after reading: $!";
- ++$filesbuilt;
- }
-
- # update timer
- if (time != $starttime) {
- my $delay = time - $starttime;
- $rate = $i/$delay;
- }
-}
-
-# finish building the library
-printf("\nFinished building source (%d seconds, %3.2f files per second).\n", time - $starttime, $rate);
-print "Compiled approximately $filesbuilt files and $lines lines of code.\n";
-print "Doing final make (building archive...)\n";
-!system("make > /dev/null 2>/dev/null") or die "\nERROR: Failed to perform last make command!!!\n";
-print "done.\n"; \ No newline at end of file
diff --git a/libtommath/tombc/grammar.txt b/libtommath/tombc/grammar.txt
deleted file mode 100644
index a780e75..0000000
--- a/libtommath/tombc/grammar.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-program := program statement | statement | empty
-statement := { statement } |
- identifier = numexpression; |
- identifier[numexpression] = numexpression; |
- function(expressionlist); |
- for (identifer = numexpression; numexpression; identifier = numexpression) { statement } |
- while (numexpression) { statement } |
- if (numexpresion) { statement } elif |
- break; |
- continue;
-
-elif := else statement | empty
-function := abs | countbits | exptmod | jacobi | print | isprime | nextprime | issquare | readinteger | exit
-expressionlist := expressionlist, expression | expression
-
-// LR(1) !!!?
-expression := string | numexpression
-numexpression := cmpexpr && cmpexpr | cmpexpr \|\| cmpexpr | cmpexpr
-cmpexpr := boolexpr < boolexpr | boolexpr > boolexpr | boolexpr == boolexpr |
- boolexpr <= boolexpr | boolexpr >= boolexpr | boolexpr
-boolexpr := shiftexpr & shiftexpr | shiftexpr ^ shiftexpr | shiftexpr \| shiftexpr | shiftexpr
-shiftexpr := addsubexpr << addsubexpr | addsubexpr >> addsubexpr | addsubexpr
-addsubexpr := mulexpr + mulexpr | mulexpr - mulexpr | mulexpr
-mulexpr := expr * expr | expr / expr | expr % expr | expr
-expr := -nexpr | nexpr
-nexpr := integer | identifier | ( numexpression ) | identifier[numexpression]
-
-identifier := identifer digits | identifier alpha | alpha
-alpha := a ... z | A ... Z
-integer := hexnumber | digits
-hexnumber := 0xhexdigits
-hexdigits := hexdigits hexdigit | hexdigit
-hexdigit := 0 ... 9 | a ... f | A ... F
-digits := digits digit | digit
-digit := 0 ... 9
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 4b3a76f..e696779 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -10,46 +10,27 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef BN_H_
#define BN_H_
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
+#include <stdint.h>
#include <limits.h>
#include <tommath_class.h>
-#ifndef MIN
-# define MIN(x,y) ((x)<(y)?(x):(y))
-#endif
-
-#ifndef MAX
-# define MAX(x,y) ((x)>(y)?(x):(y))
-#endif
-
#ifdef __cplusplus
extern "C" {
-
-/* C++ compilers don't like assigning void * to mp_digit * */
-#define OPT_CAST(x) (x *)
-
-#else
-
-/* C on the other hand doesn't care */
-#define OPT_CAST(x)
-
#endif
-
/* detect 64-bit mode if possible */
-#if defined(__x86_64__)
-# if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
-# define MP_64BIT
-# endif
+#if defined(__x86_64__)
+ #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
+ #define MP_64BIT
+ #endif
#endif
/* some default configurations.
@@ -61,70 +42,78 @@ extern "C" {
* [any size beyond that is ok provided it doesn't overflow the data type]
*/
#ifdef MP_8BIT
- typedef unsigned char mp_digit;
- typedef unsigned short mp_word;
+ typedef uint8_t mp_digit;
+ typedef uint16_t mp_word;
+#define MP_SIZEOF_MP_DIGIT 1
+#ifdef DIGIT_BIT
+#error You must not define DIGIT_BIT when using MP_8BIT
+#endif
#elif defined(MP_16BIT)
- typedef unsigned short mp_digit;
- typedef unsigned long mp_word;
+ typedef uint16_t mp_digit;
+ typedef uint32_t mp_word;
+#define MP_SIZEOF_MP_DIGIT 2
+#ifdef DIGIT_BIT
+#error You must not define DIGIT_BIT when using MP_16BIT
+#endif
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
#ifndef CRYPT
- typedef unsigned long long ulong64;
- typedef signed long long long64;
+ typedef unsigned long long ulong64;
+ typedef signed long long long64;
#endif
- typedef unsigned long mp_digit;
- typedef unsigned long mp_word __attribute__ ((mode(TI)));
+ typedef ulong64 mp_digit;
+#if defined(_WIN32)
+ typedef unsigned __int128 mp_word;
+#elif defined(__GNUC__)
+ typedef unsigned long mp_word __attribute__ ((mode(TI)));
+#else
+ /* it seems you have a problem
+ * but we assume you can somewhere define your own uint128_t */
+ typedef uint128_t mp_word;
+#endif
-# define DIGIT_BIT 60
+ #define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
-
+
/* this is to make porting into LibTomCrypt easier :-) */
#ifndef CRYPT
-# if defined(_MSC_VER) || defined(__BORLANDC__)
- typedef unsigned __int64 ulong64;
- typedef signed __int64 long64;
-# else
- typedef unsigned long long ulong64;
- typedef signed long long long64;
-# endif
+ typedef unsigned long long ulong64;
+ typedef signed long long long64;
#endif
- typedef unsigned long mp_digit;
- typedef ulong64 mp_word;
+ typedef uint32_t mp_digit;
+ typedef ulong64 mp_word;
-#ifdef MP_31BIT
+#ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
-# define DIGIT_BIT 31
+ #define DIGIT_BIT 31
#else
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
-# define DIGIT_BIT 28
-# define MP_28BIT
-#endif
+ #define DIGIT_BIT 28
+ #define MP_28BIT
#endif
-
-/* define heap macros */
-#ifndef CRYPT
- /* default to libc stuff */
-# ifndef XMALLOC
-# define XMALLOC malloc
-# define XFREE free
-# define XREALLOC realloc
-# define XCALLOC calloc
-# else
- /* prototypes for our heap functions */
- extern void *XMALLOC(size_t n);
- extern void *XREALLOC(void *p, size_t n);
- extern void *XCALLOC(size_t n, size_t s);
- extern void XFREE(void *p);
-# endif
#endif
-
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT
-# define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */
+ #define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
+ typedef uint_least32_t mp_min_u32;
+#else
+ typedef mp_digit mp_min_u32;
+#endif
+
+/* platforms that can use a better rand function */
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+ #define MP_USE_ALT_RAND 1
+#endif
+
+/* use arc4random on platforms that support it */
+#ifdef MP_USE_ALT_RAND
+ #define MP_GEN_RANDOM() arc4random()
+#else
+ #define MP_GEN_RANDOM() rand()
#endif
#define MP_DIGIT_BIT DIGIT_BIT
@@ -165,15 +154,15 @@ extern int KARATSUBA_MUL_CUTOFF,
/* default precision */
#ifndef MP_PREC
-# ifndef MP_LOW_MEM
-# define MP_PREC 32 /* default digits of precision */
-# else
-# define MP_PREC 8 /* default digits of precision */
-# endif
+ #ifndef MP_LOW_MEM
+ #define MP_PREC 32 /* default digits of precision */
+ #else
+ #define MP_PREC 8 /* default digits of precision */
+ #endif
#endif
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
+#define MP_WARRAY (1 << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1))
/* the infamous mp_int structure */
typedef struct {
@@ -190,7 +179,7 @@ typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
#define SIGN(m) ((m)->sign)
/* error code to char* string */
-char *mp_error_to_string(int code);
+const char *mp_error_to_string(int code);
/* ---> init and deinit bignum functions <--- */
/* init a bignum */
@@ -219,8 +208,9 @@ int mp_init_size(mp_int *a, int size);
/* ---> Basic Manipulations <--- */
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
-#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
+#define mp_iseven(a) ((((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO)
+#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO)
+#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
/* set to zero */
void mp_zero(mp_int *a);
@@ -231,9 +221,21 @@ void mp_set(mp_int *a, mp_digit b);
/* set a 32-bit const */
int mp_set_int(mp_int *a, unsigned long b);
+/* set a platform dependent unsigned long value */
+int mp_set_long(mp_int *a, unsigned long b);
+
+/* set a platform dependent unsigned long long value */
+int mp_set_long_long(mp_int *a, unsigned long long b);
+
/* get a 32-bit value */
unsigned long mp_get_int(mp_int * a);
+/* get a platform dependent unsigned long value */
+unsigned long mp_get_long(mp_int * a);
+
+/* get a platform dependent unsigned long long value */
+unsigned long long mp_get_long_long(mp_int * a);
+
/* initialize and set a digit */
int mp_init_set (mp_int * a, mp_digit b);
@@ -244,11 +246,17 @@ int mp_init_set_int (mp_int * a, unsigned long b);
int mp_copy(const mp_int *a, mp_int *b);
/* inits and copies, a = b */
-int mp_init_copy(mp_int *a, mp_int *b);
+int mp_init_copy(mp_int *a, const mp_int *b);
/* trim unused digits */
void mp_clamp(mp_int *a);
+/* import binary data */
+int mp_import(mp_int* rop, size_t count, int order, size_t size, int endian, size_t nails, const void* op);
+
+/* export binary data */
+int mp_export(void* rop, size_t* countp, int order, size_t size, int endian, size_t nails, mp_int* op);
+
/* ---> digit manipulation <--- */
/* right shift by "b" digits */
@@ -257,26 +265,26 @@ void mp_rshd(mp_int *a, int b);
/* left shift by "b" digits */
int mp_lshd(mp_int *a, int b);
-/* c = a / 2**b */
+/* c = a / 2**b, implemented as c = a >> b */
int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
/* b = a/2 */
int mp_div_2(mp_int *a, mp_int *b);
-/* c = a * 2**b */
+/* c = a * 2**b, implemented as c = a << b */
int mp_mul_2d(const mp_int *a, int b, mp_int *c);
/* b = a*2 */
int mp_mul_2(mp_int *a, mp_int *b);
-/* c = a mod 2**d */
+/* c = a mod 2**b */
int mp_mod_2d(const mp_int *a, int b, mp_int *c);
/* computes a = 2**b */
int mp_2expt(mp_int *a, int b);
/* Counts the number of lsbs which are zero before the first zero bit */
-int mp_cnt_lsb(mp_int *a);
+int mp_cnt_lsb(const mp_int *a);
/* I Love Earth! */
@@ -347,6 +355,7 @@ int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
/* c = a**b */
int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
+int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
/* c = a mod b, 0 <= c < b */
int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c);
@@ -382,10 +391,14 @@ int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
* returns error if a < 0 and b is even
*/
int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
+int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
/* special sqrt algo */
int mp_sqrt(mp_int *arg, mp_int *ret);
+/* special sqrt (mod prime) */
+int mp_sqrtmod_prime(mp_int *arg, mp_int *prime, mp_int *ret);
+
/* is number a square? */
int mp_is_square(mp_int *arg, int *ret);
@@ -453,7 +466,7 @@ int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
#endif
/* table of first PRIME_SIZE primes */
-extern const mp_digit ltm_prime_tab[];
+extern const mp_digit ltm_prime_tab[PRIME_SIZE];
/* result=1 if a is divisible by one of the first PRIME_SIZE primes */
int mp_prime_is_divisible(mp_int *a, int *result);
@@ -469,7 +482,7 @@ int mp_prime_fermat(mp_int *a, mp_int *b, int *result);
int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result);
/* This gives [for a given bit size] the number of trials required
- * such that Miller-Rabin gives a prob of failure lower than 2^-96
+ * such that Miller-Rabin gives a prob of failure lower than 2^-96
*/
int mp_prime_rabin_miller_trials(int size);
@@ -490,7 +503,7 @@ int mp_prime_is_prime(mp_int *a, int t, int *result);
int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
/* makes a truly random prime of a given size (bytes),
- * call with bbs = 1 if you want it to be congruent to 3 mod 4
+ * call with bbs = 1 if you want it to be congruent to 3 mod 4
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
* have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
@@ -503,10 +516,9 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
/* makes a truly random prime of a given size (bits),
*
* Flags are as follows:
- *
+ *
* LTM_PRIME_BBS - make prime congruent to 3 mod 4
* LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
* LTM_PRIME_2MSB_ON - make the 2nd highest bit one
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
@@ -532,10 +544,12 @@ int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
int mp_read_radix(mp_int *a, const char *str, int radix);
int mp_toradix(mp_int *a, char *str, int radix);
int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
-int mp_radix_size(mp_int *a, int radix, int *size);
+int mp_radix_size(const mp_int *a, int radix, int *size);
+#ifndef LTM_NO_FILE
int mp_fread(mp_int *a, int radix, FILE *stream);
int mp_fwrite(mp_int *a, int radix, FILE *stream);
+#endif
#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
#define mp_raw_size(mp) mp_signed_bin_size(mp)
@@ -549,31 +563,13 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream);
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
-/* lowlevel functions, do not call! */
-int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
-int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
-#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
-int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int fast_s_mp_sqr(mp_int *a, mp_int *b);
-int s_mp_sqr(mp_int *a, mp_int *b);
-int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
-int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
-int mp_karatsuba_sqr(mp_int *a, mp_int *b);
-int mp_toom_sqr(mp_int *a, mp_int *b);
-int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
-int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
-int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
-int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode);
-int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode);
-void bn_reverse(unsigned char *s, int len);
-
-extern const char *mp_s_rmap;
-
#ifdef __cplusplus
-}
+ }
#endif
#endif
+
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/tommath.out b/libtommath/tommath.out
deleted file mode 100644
index 9f62617..0000000
--- a/libtommath/tommath.out
+++ /dev/null
@@ -1,139 +0,0 @@
-\BOOKMARK [0][-]{chapter.1}{Introduction}{}
-\BOOKMARK [1][-]{section.1.1}{Multiple Precision Arithmetic}{chapter.1}
-\BOOKMARK [2][-]{subsection.1.1.1}{What is Multiple Precision Arithmetic?}{section.1.1}
-\BOOKMARK [2][-]{subsection.1.1.2}{The Need for Multiple Precision Arithmetic}{section.1.1}
-\BOOKMARK [2][-]{subsection.1.1.3}{Benefits of Multiple Precision Arithmetic}{section.1.1}
-\BOOKMARK [1][-]{section.1.2}{Purpose of This Text}{chapter.1}
-\BOOKMARK [1][-]{section.1.3}{Discussion and Notation}{chapter.1}
-\BOOKMARK [2][-]{subsection.1.3.1}{Notation}{section.1.3}
-\BOOKMARK [2][-]{subsection.1.3.2}{Precision Notation}{section.1.3}
-\BOOKMARK [2][-]{subsection.1.3.3}{Algorithm Inputs and Outputs}{section.1.3}
-\BOOKMARK [2][-]{subsection.1.3.4}{Mathematical Expressions}{section.1.3}
-\BOOKMARK [2][-]{subsection.1.3.5}{Work Effort}{section.1.3}
-\BOOKMARK [1][-]{section.1.4}{Exercises}{chapter.1}
-\BOOKMARK [1][-]{section.1.5}{Introduction to LibTomMath}{chapter.1}
-\BOOKMARK [2][-]{subsection.1.5.1}{What is LibTomMath?}{section.1.5}
-\BOOKMARK [2][-]{subsection.1.5.2}{Goals of LibTomMath}{section.1.5}
-\BOOKMARK [1][-]{section.1.6}{Choice of LibTomMath}{chapter.1}
-\BOOKMARK [2][-]{subsection.1.6.1}{Code Base}{section.1.6}
-\BOOKMARK [2][-]{subsection.1.6.2}{API Simplicity}{section.1.6}
-\BOOKMARK [2][-]{subsection.1.6.3}{Optimizations}{section.1.6}
-\BOOKMARK [2][-]{subsection.1.6.4}{Portability and Stability}{section.1.6}
-\BOOKMARK [2][-]{subsection.1.6.5}{Choice}{section.1.6}
-\BOOKMARK [0][-]{chapter.2}{Getting Started}{}
-\BOOKMARK [1][-]{section.2.1}{Library Basics}{chapter.2}
-\BOOKMARK [1][-]{section.2.2}{What is a Multiple Precision Integer?}{chapter.2}
-\BOOKMARK [2][-]{subsection.2.2.1}{The mp\137int Structure}{section.2.2}
-\BOOKMARK [1][-]{section.2.3}{Argument Passing}{chapter.2}
-\BOOKMARK [1][-]{section.2.4}{Return Values}{chapter.2}
-\BOOKMARK [1][-]{section.2.5}{Initialization and Clearing}{chapter.2}
-\BOOKMARK [2][-]{subsection.2.5.1}{Initializing an mp\137int}{section.2.5}
-\BOOKMARK [2][-]{subsection.2.5.2}{Clearing an mp\137int}{section.2.5}
-\BOOKMARK [1][-]{section.2.6}{Maintenance Algorithms}{chapter.2}
-\BOOKMARK [2][-]{subsection.2.6.1}{Augmenting an mp\137int's Precision}{section.2.6}
-\BOOKMARK [2][-]{subsection.2.6.2}{Initializing Variable Precision mp\137ints}{section.2.6}
-\BOOKMARK [2][-]{subsection.2.6.3}{Multiple Integer Initializations and Clearings}{section.2.6}
-\BOOKMARK [2][-]{subsection.2.6.4}{Clamping Excess Digits}{section.2.6}
-\BOOKMARK [0][-]{chapter.3}{Basic Operations}{}
-\BOOKMARK [1][-]{section.3.1}{Introduction}{chapter.3}
-\BOOKMARK [1][-]{section.3.2}{Assigning Values to mp\137int Structures}{chapter.3}
-\BOOKMARK [2][-]{subsection.3.2.1}{Copying an mp\137int}{section.3.2}
-\BOOKMARK [2][-]{subsection.3.2.2}{Creating a Clone}{section.3.2}
-\BOOKMARK [1][-]{section.3.3}{Zeroing an Integer}{chapter.3}
-\BOOKMARK [1][-]{section.3.4}{Sign Manipulation}{chapter.3}
-\BOOKMARK [2][-]{subsection.3.4.1}{Absolute Value}{section.3.4}
-\BOOKMARK [2][-]{subsection.3.4.2}{Integer Negation}{section.3.4}
-\BOOKMARK [1][-]{section.3.5}{Small Constants}{chapter.3}
-\BOOKMARK [2][-]{subsection.3.5.1}{Setting Small Constants}{section.3.5}
-\BOOKMARK [2][-]{subsection.3.5.2}{Setting Large Constants}{section.3.5}
-\BOOKMARK [1][-]{section.3.6}{Comparisons}{chapter.3}
-\BOOKMARK [2][-]{subsection.3.6.1}{Unsigned Comparisions}{section.3.6}
-\BOOKMARK [2][-]{subsection.3.6.2}{Signed Comparisons}{section.3.6}
-\BOOKMARK [0][-]{chapter.4}{Basic Arithmetic}{}
-\BOOKMARK [1][-]{section.4.1}{Introduction}{chapter.4}
-\BOOKMARK [1][-]{section.4.2}{Addition and Subtraction}{chapter.4}
-\BOOKMARK [2][-]{subsection.4.2.1}{Low Level Addition}{section.4.2}
-\BOOKMARK [2][-]{subsection.4.2.2}{Low Level Subtraction}{section.4.2}
-\BOOKMARK [2][-]{subsection.4.2.3}{High Level Addition}{section.4.2}
-\BOOKMARK [2][-]{subsection.4.2.4}{High Level Subtraction}{section.4.2}
-\BOOKMARK [1][-]{section.4.3}{Bit and Digit Shifting}{chapter.4}
-\BOOKMARK [2][-]{subsection.4.3.1}{Multiplication by Two}{section.4.3}
-\BOOKMARK [2][-]{subsection.4.3.2}{Division by Two}{section.4.3}
-\BOOKMARK [1][-]{section.4.4}{Polynomial Basis Operations}{chapter.4}
-\BOOKMARK [2][-]{subsection.4.4.1}{Multiplication by x}{section.4.4}
-\BOOKMARK [2][-]{subsection.4.4.2}{Division by x}{section.4.4}
-\BOOKMARK [1][-]{section.4.5}{Powers of Two}{chapter.4}
-\BOOKMARK [2][-]{subsection.4.5.1}{Multiplication by Power of Two}{section.4.5}
-\BOOKMARK [2][-]{subsection.4.5.2}{Division by Power of Two}{section.4.5}
-\BOOKMARK [2][-]{subsection.4.5.3}{Remainder of Division by Power of Two}{section.4.5}
-\BOOKMARK [0][-]{chapter.5}{Multiplication and Squaring}{}
-\BOOKMARK [1][-]{section.5.1}{The Multipliers}{chapter.5}
-\BOOKMARK [1][-]{section.5.2}{Multiplication}{chapter.5}
-\BOOKMARK [2][-]{subsection.5.2.1}{The Baseline Multiplication}{section.5.2}
-\BOOKMARK [2][-]{subsection.5.2.2}{Faster Multiplication by the ``Comba'' Method}{section.5.2}
-\BOOKMARK [2][-]{subsection.5.2.3}{Polynomial Basis Multiplication}{section.5.2}
-\BOOKMARK [2][-]{subsection.5.2.4}{Karatsuba Multiplication}{section.5.2}
-\BOOKMARK [2][-]{subsection.5.2.5}{Toom-Cook 3-Way Multiplication}{section.5.2}
-\BOOKMARK [2][-]{subsection.5.2.6}{Signed Multiplication}{section.5.2}
-\BOOKMARK [1][-]{section.5.3}{Squaring}{chapter.5}
-\BOOKMARK [2][-]{subsection.5.3.1}{The Baseline Squaring Algorithm}{section.5.3}
-\BOOKMARK [2][-]{subsection.5.3.2}{Faster Squaring by the ``Comba'' Method}{section.5.3}
-\BOOKMARK [2][-]{subsection.5.3.3}{Polynomial Basis Squaring}{section.5.3}
-\BOOKMARK [2][-]{subsection.5.3.4}{Karatsuba Squaring}{section.5.3}
-\BOOKMARK [2][-]{subsection.5.3.5}{Toom-Cook Squaring}{section.5.3}
-\BOOKMARK [2][-]{subsection.5.3.6}{High Level Squaring}{section.5.3}
-\BOOKMARK [0][-]{chapter.6}{Modular Reduction}{}
-\BOOKMARK [1][-]{section.6.1}{Basics of Modular Reduction}{chapter.6}
-\BOOKMARK [1][-]{section.6.2}{The Barrett Reduction}{chapter.6}
-\BOOKMARK [2][-]{subsection.6.2.1}{Fixed Point Arithmetic}{section.6.2}
-\BOOKMARK [2][-]{subsection.6.2.2}{Choosing a Radix Point}{section.6.2}
-\BOOKMARK [2][-]{subsection.6.2.3}{Trimming the Quotient}{section.6.2}
-\BOOKMARK [2][-]{subsection.6.2.4}{Trimming the Residue}{section.6.2}
-\BOOKMARK [2][-]{subsection.6.2.5}{The Barrett Algorithm}{section.6.2}
-\BOOKMARK [2][-]{subsection.6.2.6}{The Barrett Setup Algorithm}{section.6.2}
-\BOOKMARK [1][-]{section.6.3}{The Montgomery Reduction}{chapter.6}
-\BOOKMARK [2][-]{subsection.6.3.1}{Digit Based Montgomery Reduction}{section.6.3}
-\BOOKMARK [2][-]{subsection.6.3.2}{Baseline Montgomery Reduction}{section.6.3}
-\BOOKMARK [2][-]{subsection.6.3.3}{Faster ``Comba'' Montgomery Reduction}{section.6.3}
-\BOOKMARK [2][-]{subsection.6.3.4}{Montgomery Setup}{section.6.3}
-\BOOKMARK [1][-]{section.6.4}{The Diminished Radix Algorithm}{chapter.6}
-\BOOKMARK [2][-]{subsection.6.4.1}{Choice of Moduli}{section.6.4}
-\BOOKMARK [2][-]{subsection.6.4.2}{Choice of k}{section.6.4}
-\BOOKMARK [2][-]{subsection.6.4.3}{Restricted Diminished Radix Reduction}{section.6.4}
-\BOOKMARK [2][-]{subsection.6.4.4}{Unrestricted Diminished Radix Reduction}{section.6.4}
-\BOOKMARK [1][-]{section.6.5}{Algorithm Comparison}{chapter.6}
-\BOOKMARK [0][-]{chapter.7}{Exponentiation}{}
-\BOOKMARK [1][-]{section.7.1}{Exponentiation Basics}{chapter.7}
-\BOOKMARK [2][-]{subsection.7.1.1}{Single Digit Exponentiation}{section.7.1}
-\BOOKMARK [1][-]{section.7.2}{k-ary Exponentiation}{chapter.7}
-\BOOKMARK [2][-]{subsection.7.2.1}{Optimal Values of k}{section.7.2}
-\BOOKMARK [2][-]{subsection.7.2.2}{Sliding-Window Exponentiation}{section.7.2}
-\BOOKMARK [1][-]{section.7.3}{Modular Exponentiation}{chapter.7}
-\BOOKMARK [2][-]{subsection.7.3.1}{Barrett Modular Exponentiation}{section.7.3}
-\BOOKMARK [1][-]{section.7.4}{Quick Power of Two}{chapter.7}
-\BOOKMARK [0][-]{chapter.8}{Higher Level Algorithms}{}
-\BOOKMARK [1][-]{section.8.1}{Integer Division with Remainder}{chapter.8}
-\BOOKMARK [2][-]{subsection.8.1.1}{Quotient Estimation}{section.8.1}
-\BOOKMARK [2][-]{subsection.8.1.2}{Normalized Integers}{section.8.1}
-\BOOKMARK [2][-]{subsection.8.1.3}{Radix- Division with Remainder}{section.8.1}
-\BOOKMARK [1][-]{section.8.2}{Single Digit Helpers}{chapter.8}
-\BOOKMARK [2][-]{subsection.8.2.1}{Single Digit Addition and Subtraction}{section.8.2}
-\BOOKMARK [2][-]{subsection.8.2.2}{Single Digit Multiplication}{section.8.2}
-\BOOKMARK [2][-]{subsection.8.2.3}{Single Digit Division}{section.8.2}
-\BOOKMARK [2][-]{subsection.8.2.4}{Single Digit Root Extraction}{section.8.2}
-\BOOKMARK [1][-]{section.8.3}{Random Number Generation}{chapter.8}
-\BOOKMARK [1][-]{section.8.4}{Formatted Representations}{chapter.8}
-\BOOKMARK [2][-]{subsection.8.4.1}{Reading Radix-n Input}{section.8.4}
-\BOOKMARK [2][-]{subsection.8.4.2}{Generating Radix-n Output}{section.8.4}
-\BOOKMARK [0][-]{chapter.9}{Number Theoretic Algorithms}{}
-\BOOKMARK [1][-]{section.9.1}{Greatest Common Divisor}{chapter.9}
-\BOOKMARK [2][-]{subsection.9.1.1}{Complete Greatest Common Divisor}{section.9.1}
-\BOOKMARK [1][-]{section.9.2}{Least Common Multiple}{chapter.9}
-\BOOKMARK [1][-]{section.9.3}{Jacobi Symbol Computation}{chapter.9}
-\BOOKMARK [2][-]{subsection.9.3.1}{Jacobi Symbol}{section.9.3}
-\BOOKMARK [1][-]{section.9.4}{Modular Inverse}{chapter.9}
-\BOOKMARK [2][-]{subsection.9.4.1}{General Case}{section.9.4}
-\BOOKMARK [1][-]{section.9.5}{Primality Tests}{chapter.9}
-\BOOKMARK [2][-]{subsection.9.5.1}{Trial Division}{section.9.5}
-\BOOKMARK [2][-]{subsection.9.5.2}{The Fermat Test}{section.9.5}
-\BOOKMARK [2][-]{subsection.9.5.3}{The Miller-Rabin Test}{section.9.5}
diff --git a/libtommath/tommath.pdf b/libtommath/tommath.pdf
deleted file mode 100644
index c9571d8..0000000
--- a/libtommath/tommath.pdf
+++ /dev/null
Binary files differ
diff --git a/libtommath/tommath.src b/libtommath/tommath.src
deleted file mode 100644
index 4065822..0000000
--- a/libtommath/tommath.src
+++ /dev/null
@@ -1,6350 +0,0 @@
-\documentclass[b5paper]{book}
-\usepackage{hyperref}
-\usepackage{makeidx}
-\usepackage{amssymb}
-\usepackage{color}
-\usepackage{alltt}
-\usepackage{graphicx}
-\usepackage{layout}
-\def\union{\cup}
-\def\intersect{\cap}
-\def\getsrandom{\stackrel{\rm R}{\gets}}
-\def\cross{\times}
-\def\cat{\hspace{0.5em} \| \hspace{0.5em}}
-\def\catn{$\|$}
-\def\divides{\hspace{0.3em} | \hspace{0.3em}}
-\def\nequiv{\not\equiv}
-\def\approx{\raisebox{0.2ex}{\mbox{\small $\sim$}}}
-\def\lcm{{\rm lcm}}
-\def\gcd{{\rm gcd}}
-\def\log{{\rm log}}
-\def\ord{{\rm ord}}
-\def\abs{{\mathit abs}}
-\def\rep{{\mathit rep}}
-\def\mod{{\mathit\ mod\ }}
-\renewcommand{\pmod}[1]{\ ({\rm mod\ }{#1})}
-\newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor}
-\newcommand{\ceil}[1]{\left\lceil{#1}\right\rceil}
-\def\Or{{\rm\ or\ }}
-\def\And{{\rm\ and\ }}
-\def\iff{\hspace{1em}\Longleftrightarrow\hspace{1em}}
-\def\implies{\Rightarrow}
-\def\undefined{{\rm ``undefined"}}
-\def\Proof{\vspace{1ex}\noindent {\bf Proof:}\hspace{1em}}
-\let\oldphi\phi
-\def\phi{\varphi}
-\def\Pr{{\rm Pr}}
-\newcommand{\str}[1]{{\mathbf{#1}}}
-\def\F{{\mathbb F}}
-\def\N{{\mathbb N}}
-\def\Z{{\mathbb Z}}
-\def\R{{\mathbb R}}
-\def\C{{\mathbb C}}
-\def\Q{{\mathbb Q}}
-\definecolor{DGray}{gray}{0.5}
-\newcommand{\emailaddr}[1]{\mbox{$<${#1}$>$}}
-\def\twiddle{\raisebox{0.3ex}{\mbox{\tiny $\sim$}}}
-\def\gap{\vspace{0.5ex}}
-\makeindex
-\begin{document}
-\frontmatter
-\pagestyle{empty}
-\title{Multi--Precision Math}
-\author{\mbox{
-%\begin{small}
-\begin{tabular}{c}
-Tom St Denis \\
-Algonquin College \\
-\\
-Mads Rasmussen \\
-Open Communications Security \\
-\\
-Greg Rose \\
-QUALCOMM Australia \\
-\end{tabular}
-%\end{small}
-}
-}
-\maketitle
-This text has been placed in the public domain. This text corresponds to the v0.39 release of the
-LibTomMath project.
-
-\begin{alltt}
-Tom St Denis
-111 Banning Rd
-Ottawa, Ontario
-K2L 1C3
-Canada
-
-Phone: 1-613-836-3160
-Email: tomstdenis@gmail.com
-\end{alltt}
-
-This text is formatted to the international B5 paper size of 176mm wide by 250mm tall using the \LaTeX{}
-{\em book} macro package and the Perl {\em booker} package.
-
-\tableofcontents
-\listoffigures
-\chapter*{Prefaces}
-When I tell people about my LibTom projects and that I release them as public domain they are often puzzled.
-They ask why I did it and especially why I continue to work on them for free. The best I can explain it is ``Because I can.''
-Which seems odd and perhaps too terse for adult conversation. I often qualify it with ``I am able, I am willing.'' which
-perhaps explains it better. I am the first to admit there is not anything that special with what I have done. Perhaps
-others can see that too and then we would have a society to be proud of. My LibTom projects are what I am doing to give
-back to society in the form of tools and knowledge that can help others in their endeavours.
-
-I started writing this book because it was the most logical task to further my goal of open academia. The LibTomMath source
-code itself was written to be easy to follow and learn from. There are times, however, where pure C source code does not
-explain the algorithms properly. Hence this book. The book literally starts with the foundation of the library and works
-itself outwards to the more complicated algorithms. The use of both pseudo--code and verbatim source code provides a duality
-of ``theory'' and ``practice'' that the computer science students of the world shall appreciate. I never deviate too far
-from relatively straightforward algebra and I hope that this book can be a valuable learning asset.
-
-This book and indeed much of the LibTom projects would not exist in their current form if it was not for a plethora
-of kind people donating their time, resources and kind words to help support my work. Writing a text of significant
-length (along with the source code) is a tiresome and lengthy process. Currently the LibTom project is four years old,
-comprises of literally thousands of users and over 100,000 lines of source code, TeX and other material. People like Mads and Greg
-were there at the beginning to encourage me to work well. It is amazing how timely validation from others can boost morale to
-continue the project. Definitely my parents were there for me by providing room and board during the many months of work in 2003.
-
-To my many friends whom I have met through the years I thank you for the good times and the words of encouragement. I hope I
-honour your kind gestures with this project.
-
-Open Source. Open Academia. Open Minds.
-
-\begin{flushright} Tom St Denis \end{flushright}
-
-\newpage
-I found the opportunity to work with Tom appealing for several reasons, not only could I broaden my own horizons, but also
-contribute to educate others facing the problem of having to handle big number mathematical calculations.
-
-This book is Tom's child and he has been caring and fostering the project ever since the beginning with a clear mind of
-how he wanted the project to turn out. I have helped by proofreading the text and we have had several discussions about
-the layout and language used.
-
-I hold a masters degree in cryptography from the University of Southern Denmark and have always been interested in the
-practical aspects of cryptography.
-
-Having worked in the security consultancy business for several years in S\~{a}o Paulo, Brazil, I have been in touch with a
-great deal of work in which multiple precision mathematics was needed. Understanding the possibilities for speeding up
-multiple precision calculations is often very important since we deal with outdated machine architecture where modular
-reductions, for example, become painfully slow.
-
-This text is for people who stop and wonder when first examining algorithms such as RSA for the first time and asks
-themselves, ``You tell me this is only secure for large numbers, fine; but how do you implement these numbers?''
-
-\begin{flushright}
-Mads Rasmussen
-
-S\~{a}o Paulo - SP
-
-Brazil
-\end{flushright}
-
-\newpage
-It's all because I broke my leg. That just happened to be at about the same time that Tom asked for someone to review the section of the book about
-Karatsuba multiplication. I was laid up, alone and immobile, and thought ``Why not?'' I vaguely knew what Karatsuba multiplication was, but not
-really, so I thought I could help, learn, and stop myself from watching daytime cable TV, all at once.
-
-At the time of writing this, I've still not met Tom or Mads in meatspace. I've been following Tom's progress since his first splash on the
-sci.crypt Usenet news group. I watched him go from a clueless newbie, to the cryptographic equivalent of a reformed smoker, to a real
-contributor to the field, over a period of about two years. I've been impressed with his obvious intelligence, and astounded by his productivity.
-Of course, he's young enough to be my own child, so he doesn't have my problems with staying awake.
-
-When I reviewed that single section of the book, in its very earliest form, I was very pleasantly surprised. So I decided to collaborate more fully,
-and at least review all of it, and perhaps write some bits too. There's still a long way to go with it, and I have watched a number of close
-friends go through the mill of publication, so I think that the way to go is longer than Tom thinks it is. Nevertheless, it's a good effort,
-and I'm pleased to be involved with it.
-
-\begin{flushright}
-Greg Rose, Sydney, Australia, June 2003.
-\end{flushright}
-
-\mainmatter
-\pagestyle{headings}
-\chapter{Introduction}
-\section{Multiple Precision Arithmetic}
-
-\subsection{What is Multiple Precision Arithmetic?}
-When we think of long-hand arithmetic such as addition or multiplication we rarely consider the fact that we instinctively
-raise or lower the precision of the numbers we are dealing with. For example, in decimal we almost immediate can
-reason that $7$ times $6$ is $42$. However, $42$ has two digits of precision as opposed to one digit we started with.
-Further multiplications of say $3$ result in a larger precision result $126$. In these few examples we have multiple
-precisions for the numbers we are working with. Despite the various levels of precision a single subset\footnote{With the occasional optimization.}
- of algorithms can be designed to accomodate them.
-
-By way of comparison a fixed or single precision operation would lose precision on various operations. For example, in
-the decimal system with fixed precision $6 \cdot 7 = 2$.
-
-Essentially at the heart of computer based multiple precision arithmetic are the same long-hand algorithms taught in
-schools to manually add, subtract, multiply and divide.
-
-\subsection{The Need for Multiple Precision Arithmetic}
-The most prevalent need for multiple precision arithmetic, often referred to as ``bignum'' math, is within the implementation
-of public-key cryptography algorithms. Algorithms such as RSA \cite{RSAREF} and Diffie-Hellman \cite{DHREF} require
-integers of significant magnitude to resist known cryptanalytic attacks. For example, at the time of this writing a
-typical RSA modulus would be at least greater than $10^{309}$. However, modern programming languages such as ISO C \cite{ISOC} and
-Java \cite{JAVA} only provide instrinsic support for integers which are relatively small and single precision.
-
-\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{|r|c|}
-\hline \textbf{Data Type} & \textbf{Range} \\
-\hline char & $-128 \ldots 127$ \\
-\hline short & $-32768 \ldots 32767$ \\
-\hline long & $-2147483648 \ldots 2147483647$ \\
-\hline long long & $-9223372036854775808 \ldots 9223372036854775807$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Typical Data Types for the C Programming Language}
-\label{fig:ISOC}
-\end{figure}
-
-The largest data type guaranteed to be provided by the ISO C programming
-language\footnote{As per the ISO C standard. However, each compiler vendor is allowed to augment the precision as they
-see fit.} can only represent values up to $10^{19}$ as shown in figure \ref{fig:ISOC}. On its own the C language is
-insufficient to accomodate the magnitude required for the problem at hand. An RSA modulus of magnitude $10^{19}$ could be
-trivially factored\footnote{A Pollard-Rho factoring would take only $2^{16}$ time.} on the average desktop computer,
-rendering any protocol based on the algorithm insecure. Multiple precision algorithms solve this very problem by
-extending the range of representable integers while using single precision data types.
-
-Most advancements in fast multiple precision arithmetic stem from the need for faster and more efficient cryptographic
-primitives. Faster modular reduction and exponentiation algorithms such as Barrett's algorithm, which have appeared in
-various cryptographic journals, can render algorithms such as RSA and Diffie-Hellman more efficient. In fact, several
-major companies such as RSA Security, Certicom and Entrust have built entire product lines on the implementation and
-deployment of efficient algorithms.
-
-However, cryptography is not the only field of study that can benefit from fast multiple precision integer routines.
-Another auxiliary use of multiple precision integers is high precision floating point data types.
-The basic IEEE \cite{IEEE} standard floating point type is made up of an integer mantissa $q$, an exponent $e$ and a sign bit $s$.
-Numbers are given in the form $n = q \cdot b^e \cdot -1^s$ where $b = 2$ is the most common base for IEEE. Since IEEE
-floating point is meant to be implemented in hardware the precision of the mantissa is often fairly small
-(\textit{23, 48 and 64 bits}). The mantissa is merely an integer and a multiple precision integer could be used to create
-a mantissa of much larger precision than hardware alone can efficiently support. This approach could be useful where
-scientific applications must minimize the total output error over long calculations.
-
-Yet another use for large integers is within arithmetic on polynomials of large characteristic (i.e. $GF(p)[x]$ for large $p$).
-In fact the library discussed within this text has already been used to form a polynomial basis library\footnote{See \url{http://poly.libtomcrypt.org} for more details.}.
-
-\subsection{Benefits of Multiple Precision Arithmetic}
-\index{precision}
-The benefit of multiple precision representations over single or fixed precision representations is that
-no precision is lost while representing the result of an operation which requires excess precision. For example,
-the product of two $n$-bit integers requires at least $2n$ bits of precision to be represented faithfully. A multiple
-precision algorithm would augment the precision of the destination to accomodate the result while a single precision system
-would truncate excess bits to maintain a fixed level of precision.
-
-It is possible to implement algorithms which require large integers with fixed precision algorithms. For example, elliptic
-curve cryptography (\textit{ECC}) is often implemented on smartcards by fixing the precision of the integers to the maximum
-size the system will ever need. Such an approach can lead to vastly simpler algorithms which can accomodate the
-integers required even if the host platform cannot natively accomodate them\footnote{For example, the average smartcard
-processor has an 8 bit accumulator.}. However, as efficient as such an approach may be, the resulting source code is not
-normally very flexible. It cannot, at runtime, accomodate inputs of higher magnitude than the designer anticipated.
-
-Multiple precision algorithms have the most overhead of any style of arithmetic. For the the most part the
-overhead can be kept to a minimum with careful planning, but overall, it is not well suited for most memory starved
-platforms. However, multiple precision algorithms do offer the most flexibility in terms of the magnitude of the
-inputs. That is, the same algorithms based on multiple precision integers can accomodate any reasonable size input
-without the designer's explicit forethought. This leads to lower cost of ownership for the code as it only has to
-be written and tested once.
-
-\section{Purpose of This Text}
-The purpose of this text is to instruct the reader regarding how to implement efficient multiple precision algorithms.
-That is to not only explain a limited subset of the core theory behind the algorithms but also the various ``house keeping''
-elements that are neglected by authors of other texts on the subject. Several well reknowned texts \cite{TAOCPV2,HAC}
-give considerably detailed explanations of the theoretical aspects of algorithms and often very little information
-regarding the practical implementation aspects.
-
-In most cases how an algorithm is explained and how it is actually implemented are two very different concepts. For
-example, the Handbook of Applied Cryptography (\textit{HAC}), algorithm 14.7 on page 594, gives a relatively simple
-algorithm for performing multiple precision integer addition. However, the description lacks any discussion concerning
-the fact that the two integer inputs may be of differing magnitudes. As a result the implementation is not as simple
-as the text would lead people to believe. Similarly the division routine (\textit{algorithm 14.20, pp. 598}) does not
-discuss how to handle sign or handle the dividend's decreasing magnitude in the main loop (\textit{step \#3}).
-
-Both texts also do not discuss several key optimal algorithms required such as ``Comba'' and Karatsuba multipliers
-and fast modular inversion, which we consider practical oversights. These optimal algorithms are vital to achieve
-any form of useful performance in non-trivial applications.
-
-To solve this problem the focus of this text is on the practical aspects of implementing a multiple precision integer
-package. As a case study the ``LibTomMath''\footnote{Available at \url{http://math.libtomcrypt.com}} package is used
-to demonstrate algorithms with real implementations\footnote{In the ISO C programming language.} that have been field
-tested and work very well. The LibTomMath library is freely available on the Internet for all uses and this text
-discusses a very large portion of the inner workings of the library.
-
-The algorithms that are presented will always include at least one ``pseudo-code'' description followed
-by the actual C source code that implements the algorithm. The pseudo-code can be used to implement the same
-algorithm in other programming languages as the reader sees fit.
-
-This text shall also serve as a walkthrough of the creation of multiple precision algorithms from scratch. Showing
-the reader how the algorithms fit together as well as where to start on various taskings.
-
-\section{Discussion and Notation}
-\subsection{Notation}
-A multiple precision integer of $n$-digits shall be denoted as $x = (x_{n-1}, \ldots, x_1, x_0)_{ \beta }$ and represent
-the integer $x \equiv \sum_{i=0}^{n-1} x_i\beta^i$. The elements of the array $x$ are said to be the radix $\beta$ digits
-of the integer. For example, $x = (1,2,3)_{10}$ would represent the integer
-$1\cdot 10^2 + 2\cdot10^1 + 3\cdot10^0 = 123$.
-
-\index{mp\_int}
-The term ``mp\_int'' shall refer to a composite structure which contains the digits of the integer it represents, as well
-as auxilary data required to manipulate the data. These additional members are discussed further in section
-\ref{sec:MPINT}. For the purposes of this text a ``multiple precision integer'' and an ``mp\_int'' are assumed to be
-synonymous. When an algorithm is specified to accept an mp\_int variable it is assumed the various auxliary data members
-are present as well. An expression of the type \textit{variablename.item} implies that it should evaluate to the
-member named ``item'' of the variable. For example, a string of characters may have a member ``length'' which would
-evaluate to the number of characters in the string. If the string $a$ equals ``hello'' then it follows that
-$a.length = 5$.
-
-For certain discussions more generic algorithms are presented to help the reader understand the final algorithm used
-to solve a given problem. When an algorithm is described as accepting an integer input it is assumed the input is
-a plain integer with no additional multiple-precision members. That is, algorithms that use integers as opposed to
-mp\_ints as inputs do not concern themselves with the housekeeping operations required such as memory management. These
-algorithms will be used to establish the relevant theory which will subsequently be used to describe a multiple
-precision algorithm to solve the same problem.
-
-\subsection{Precision Notation}
-The variable $\beta$ represents the radix of a single digit of a multiple precision integer and
-must be of the form $q^p$ for $q, p \in \Z^+$. A single precision variable must be able to represent integers in
-the range $0 \le x < q \beta$ while a double precision variable must be able to represent integers in the range
-$0 \le x < q \beta^2$. The extra radix-$q$ factor allows additions and subtractions to proceed without truncation of the
-carry. Since all modern computers are binary, it is assumed that $q$ is two.
-
-\index{mp\_digit} \index{mp\_word}
-Within the source code that will be presented for each algorithm, the data type \textbf{mp\_digit} will represent
-a single precision integer type, while, the data type \textbf{mp\_word} will represent a double precision integer type. In
-several algorithms (notably the Comba routines) temporary results will be stored in arrays of double precision mp\_words.
-For the purposes of this text $x_j$ will refer to the $j$'th digit of a single precision array and $\hat x_j$ will refer to
-the $j$'th digit of a double precision array. Whenever an expression is to be assigned to a double precision
-variable it is assumed that all single precision variables are promoted to double precision during the evaluation.
-Expressions that are assigned to a single precision variable are truncated to fit within the precision of a single
-precision data type.
-
-For example, if $\beta = 10^2$ a single precision data type may represent a value in the
-range $0 \le x < 10^3$, while a double precision data type may represent a value in the range $0 \le x < 10^5$. Let
-$a = 23$ and $b = 49$ represent two single precision variables. The single precision product shall be written
-as $c \leftarrow a \cdot b$ while the double precision product shall be written as $\hat c \leftarrow a \cdot b$.
-In this particular case, $\hat c = 1127$ and $c = 127$. The most significant digit of the product would not fit
-in a single precision data type and as a result $c \ne \hat c$.
-
-\subsection{Algorithm Inputs and Outputs}
-Within the algorithm descriptions all variables are assumed to be scalars of either single or double precision
-as indicated. The only exception to this rule is when variables have been indicated to be of type mp\_int. This
-distinction is important as scalars are often used as array indicies and various other counters.
-
-\subsection{Mathematical Expressions}
-The $\lfloor \mbox{ } \rfloor$ brackets imply an expression truncated to an integer not greater than the expression
-itself. For example, $\lfloor 5.7 \rfloor = 5$. Similarly the $\lceil \mbox{ } \rceil$ brackets imply an expression
-rounded to an integer not less than the expression itself. For example, $\lceil 5.1 \rceil = 6$. Typically when
-the $/$ division symbol is used the intention is to perform an integer division with truncation. For example,
-$5/2 = 2$ which will often be written as $\lfloor 5/2 \rfloor = 2$ for clarity. When an expression is written as a
-fraction a real value division is implied, for example ${5 \over 2} = 2.5$.
-
-The norm of a multiple precision integer, for example $\vert \vert x \vert \vert$, will be used to represent the number of digits in the representation
-of the integer. For example, $\vert \vert 123 \vert \vert = 3$ and $\vert \vert 79452 \vert \vert = 5$.
-
-\subsection{Work Effort}
-\index{big-Oh}
-To measure the efficiency of the specified algorithms, a modified big-Oh notation is used. In this system all
-single precision operations are considered to have the same cost\footnote{Except where explicitly noted.}.
-That is a single precision addition, multiplication and division are assumed to take the same time to
-complete. While this is generally not true in practice, it will simplify the discussions considerably.
-
-Some algorithms have slight advantages over others which is why some constants will not be removed in
-the notation. For example, a normal baseline multiplication (section \ref{sec:basemult}) requires $O(n^2)$ work while a
-baseline squaring (section \ref{sec:basesquare}) requires $O({{n^2 + n}\over 2})$ work. In standard big-Oh notation these
-would both be said to be equivalent to $O(n^2)$. However,
-in the context of the this text this is not the case as the magnitude of the inputs will typically be rather small. As a
-result small constant factors in the work effort will make an observable difference in algorithm efficiency.
-
-All of the algorithms presented in this text have a polynomial time work level. That is, of the form
-$O(n^k)$ for $n, k \in \Z^{+}$. This will help make useful comparisons in terms of the speed of the algorithms and how
-various optimizations will help pay off in the long run.
-
-\section{Exercises}
-Within the more advanced chapters a section will be set aside to give the reader some challenging exercises related to
-the discussion at hand. These exercises are not designed to be prize winning problems, but instead to be thought
-provoking. Wherever possible the problems are forward minded, stating problems that will be answered in subsequent
-chapters. The reader is encouraged to finish the exercises as they appear to get a better understanding of the
-subject material.
-
-That being said, the problems are designed to affirm knowledge of a particular subject matter. Students in particular
-are encouraged to verify they can answer the problems correctly before moving on.
-
-Similar to the exercises of \cite[pp. ix]{TAOCPV2} these exercises are given a scoring system based on the difficulty of
-the problem. However, unlike \cite{TAOCPV2} the problems do not get nearly as hard. The scoring of these
-exercises ranges from one (the easiest) to five (the hardest). The following table sumarizes the
-scoring system used.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|l|}
-\hline $\left [ 1 \right ]$ & An easy problem that should only take the reader a manner of \\
- & minutes to solve. Usually does not involve much computer time \\
- & to solve. \\
-\hline $\left [ 2 \right ]$ & An easy problem that involves a marginal amount of computer \\
- & time usage. Usually requires a program to be written to \\
- & solve the problem. \\
-\hline $\left [ 3 \right ]$ & A moderately hard problem that requires a non-trivial amount \\
- & of work. Usually involves trivial research and development of \\
- & new theory from the perspective of a student. \\
-\hline $\left [ 4 \right ]$ & A moderately hard problem that involves a non-trivial amount \\
- & of work and research, the solution to which will demonstrate \\
- & a higher mastery of the subject matter. \\
-\hline $\left [ 5 \right ]$ & A hard problem that involves concepts that are difficult for a \\
- & novice to solve. Solutions to these problems will demonstrate a \\
- & complete mastery of the given subject. \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Exercise Scoring System}
-\end{figure}
-
-Problems at the first level are meant to be simple questions that the reader can answer quickly without programming a solution or
-devising new theory. These problems are quick tests to see if the material is understood. Problems at the second level
-are also designed to be easy but will require a program or algorithm to be implemented to arrive at the answer. These
-two levels are essentially entry level questions.
-
-Problems at the third level are meant to be a bit more difficult than the first two levels. The answer is often
-fairly obvious but arriving at an exacting solution requires some thought and skill. These problems will almost always
-involve devising a new algorithm or implementing a variation of another algorithm previously presented. Readers who can
-answer these questions will feel comfortable with the concepts behind the topic at hand.
-
-Problems at the fourth level are meant to be similar to those of the level three questions except they will require
-additional research to be completed. The reader will most likely not know the answer right away, nor will the text provide
-the exact details of the answer until a subsequent chapter.
-
-Problems at the fifth level are meant to be the hardest
-problems relative to all the other problems in the chapter. People who can correctly answer fifth level problems have a
-mastery of the subject matter at hand.
-
-Often problems will be tied together. The purpose of this is to start a chain of thought that will be discussed in future chapters. The reader
-is encouraged to answer the follow-up problems and try to draw the relevance of problems.
-
-\section{Introduction to LibTomMath}
-
-\subsection{What is LibTomMath?}
-LibTomMath is a free and open source multiple precision integer library written entirely in portable ISO C. By portable it
-is meant that the library does not contain any code that is computer platform dependent or otherwise problematic to use on
-any given platform.
-
-The library has been successfully tested under numerous operating systems including Unix\footnote{All of these
-trademarks belong to their respective rightful owners.}, MacOS, Windows, Linux, PalmOS and on standalone hardware such
-as the Gameboy Advance. The library is designed to contain enough functionality to be able to develop applications such
-as public key cryptosystems and still maintain a relatively small footprint.
-
-\subsection{Goals of LibTomMath}
-
-Libraries which obtain the most efficiency are rarely written in a high level programming language such as C. However,
-even though this library is written entirely in ISO C, considerable care has been taken to optimize the algorithm implementations within the
-library. Specifically the code has been written to work well with the GNU C Compiler (\textit{GCC}) on both x86 and ARM
-processors. Wherever possible, highly efficient algorithms, such as Karatsuba multiplication, sliding window
-exponentiation and Montgomery reduction have been provided to make the library more efficient.
-
-Even with the nearly optimal and specialized algorithms that have been included the Application Programing Interface
-(\textit{API}) has been kept as simple as possible. Often generic place holder routines will make use of specialized
-algorithms automatically without the developer's specific attention. One such example is the generic multiplication
-algorithm \textbf{mp\_mul()} which will automatically use Toom--Cook, Karatsuba, Comba or baseline multiplication
-based on the magnitude of the inputs and the configuration of the library.
-
-Making LibTomMath as efficient as possible is not the only goal of the LibTomMath project. Ideally the library should
-be source compatible with another popular library which makes it more attractive for developers to use. In this case the
-MPI library was used as a API template for all the basic functions. MPI was chosen because it is another library that fits
-in the same niche as LibTomMath. Even though LibTomMath uses MPI as the template for the function names and argument
-passing conventions, it has been written from scratch by Tom St Denis.
-
-The project is also meant to act as a learning tool for students, the logic being that no easy-to-follow ``bignum''
-library exists which can be used to teach computer science students how to perform fast and reliable multiple precision
-integer arithmetic. To this end the source code has been given quite a few comments and algorithm discussion points.
-
-\section{Choice of LibTomMath}
-LibTomMath was chosen as the case study of this text not only because the author of both projects is one and the same but
-for more worthy reasons. Other libraries such as GMP \cite{GMP}, MPI \cite{MPI}, LIP \cite{LIP} and OpenSSL
-\cite{OPENSSL} have multiple precision integer arithmetic routines but would not be ideal for this text for
-reasons that will be explained in the following sub-sections.
-
-\subsection{Code Base}
-The LibTomMath code base is all portable ISO C source code. This means that there are no platform dependent conditional
-segments of code littered throughout the source. This clean and uncluttered approach to the library means that a
-developer can more readily discern the true intent of a given section of source code without trying to keep track of
-what conditional code will be used.
-
-The code base of LibTomMath is well organized. Each function is in its own separate source code file
-which allows the reader to find a given function very quickly. On average there are $76$ lines of code per source
-file which makes the source very easily to follow. By comparison MPI and LIP are single file projects making code tracing
-very hard. GMP has many conditional code segments which also hinder tracing.
-
-When compiled with GCC for the x86 processor and optimized for speed the entire library is approximately $100$KiB\footnote{The notation ``KiB'' means $2^{10}$ octets, similarly ``MiB'' means $2^{20}$ octets.}
- which is fairly small compared to GMP (over $250$KiB). LibTomMath is slightly larger than MPI (which compiles to about
-$50$KiB) but LibTomMath is also much faster and more complete than MPI.
-
-\subsection{API Simplicity}
-LibTomMath is designed after the MPI library and shares the API design. Quite often programs that use MPI will build
-with LibTomMath without change. The function names correlate directly to the action they perform. Almost all of the
-functions share the same parameter passing convention. The learning curve is fairly shallow with the API provided
-which is an extremely valuable benefit for the student and developer alike.
-
-The LIP library is an example of a library with an API that is awkward to work with. LIP uses function names that are often ``compressed'' to
-illegible short hand. LibTomMath does not share this characteristic.
-
-The GMP library also does not return error codes. Instead it uses a POSIX.1 \cite{POSIX1} signal system where errors
-are signaled to the host application. This happens to be the fastest approach but definitely not the most versatile. In
-effect a math error (i.e. invalid input, heap error, etc) can cause a program to stop functioning which is definitely
-undersireable in many situations.
-
-\subsection{Optimizations}
-While LibTomMath is certainly not the fastest library (GMP often beats LibTomMath by a factor of two) it does
-feature a set of optimal algorithms for tasks such as modular reduction, exponentiation, multiplication and squaring. GMP
-and LIP also feature such optimizations while MPI only uses baseline algorithms with no optimizations. GMP lacks a few
-of the additional modular reduction optimizations that LibTomMath features\footnote{At the time of this writing GMP
-only had Barrett and Montgomery modular reduction algorithms.}.
-
-LibTomMath is almost always an order of magnitude faster than the MPI library at computationally expensive tasks such as modular
-exponentiation. In the grand scheme of ``bignum'' libraries LibTomMath is faster than the average library and usually
-slower than the best libraries such as GMP and OpenSSL by only a small factor.
-
-\subsection{Portability and Stability}
-LibTomMath will build ``out of the box'' on any platform equipped with a modern version of the GNU C Compiler
-(\textit{GCC}). This means that without changes the library will build without configuration or setting up any
-variables. LIP and MPI will build ``out of the box'' as well but have numerous known bugs. Most notably the author of
-MPI has recently stopped working on his library and LIP has long since been discontinued.
-
-GMP requires a configuration script to run and will not build out of the box. GMP and LibTomMath are still in active
-development and are very stable across a variety of platforms.
-
-\subsection{Choice}
-LibTomMath is a relatively compact, well documented, highly optimized and portable library which seems only natural for
-the case study of this text. Various source files from the LibTomMath project will be included within the text. However,
-the reader is encouraged to download their own copy of the library to actually be able to work with the library.
-
-\chapter{Getting Started}
-\section{Library Basics}
-The trick to writing any useful library of source code is to build a solid foundation and work outwards from it. First,
-a problem along with allowable solution parameters should be identified and analyzed. In this particular case the
-inability to accomodate multiple precision integers is the problem. Futhermore, the solution must be written
-as portable source code that is reasonably efficient across several different computer platforms.
-
-After a foundation is formed the remainder of the library can be designed and implemented in a hierarchical fashion.
-That is, to implement the lowest level dependencies first and work towards the most abstract functions last. For example,
-before implementing a modular exponentiation algorithm one would implement a modular reduction algorithm.
-By building outwards from a base foundation instead of using a parallel design methodology the resulting project is
-highly modular. Being highly modular is a desirable property of any project as it often means the resulting product
-has a small footprint and updates are easy to perform.
-
-Usually when I start a project I will begin with the header files. I define the data types I think I will need and
-prototype the initial functions that are not dependent on other functions (within the library). After I
-implement these base functions I prototype more dependent functions and implement them. The process repeats until
-I implement all of the functions I require. For example, in the case of LibTomMath I implemented functions such as
-mp\_init() well before I implemented mp\_mul() and even further before I implemented mp\_exptmod(). As an example as to
-why this design works note that the Karatsuba and Toom-Cook multipliers were written \textit{after} the
-dependent function mp\_exptmod() was written. Adding the new multiplication algorithms did not require changes to the
-mp\_exptmod() function itself and lowered the total cost of ownership (\textit{so to speak}) and of development
-for new algorithms. This methodology allows new algorithms to be tested in a complete framework with relative ease.
-
-FIGU,design_process,Design Flow of the First Few Original LibTomMath Functions.
-
-Only after the majority of the functions were in place did I pursue a less hierarchical approach to auditing and optimizing
-the source code. For example, one day I may audit the multipliers and the next day the polynomial basis functions.
-
-It only makes sense to begin the text with the preliminary data types and support algorithms required as well.
-This chapter discusses the core algorithms of the library which are the dependents for every other algorithm.
-
-\section{What is a Multiple Precision Integer?}
-Recall that most programming languages, in particular ISO C \cite{ISOC}, only have fixed precision data types that on their own cannot
-be used to represent values larger than their precision will allow. The purpose of multiple precision algorithms is
-to use fixed precision data types to create and manipulate multiple precision integers which may represent values
-that are very large.
-
-As a well known analogy, school children are taught how to form numbers larger than nine by prepending more radix ten digits. In the decimal system
-the largest single digit value is $9$. However, by concatenating digits together larger numbers may be represented. Newly prepended digits
-(\textit{to the left}) are said to be in a different power of ten column. That is, the number $123$ can be described as having a $1$ in the hundreds
-column, $2$ in the tens column and $3$ in the ones column. Or more formally $123 = 1 \cdot 10^2 + 2 \cdot 10^1 + 3 \cdot 10^0$. Computer based
-multiple precision arithmetic is essentially the same concept. Larger integers are represented by adjoining fixed
-precision computer words with the exception that a different radix is used.
-
-What most people probably do not think about explicitly are the various other attributes that describe a multiple precision
-integer. For example, the integer $154_{10}$ has two immediately obvious properties. First, the integer is positive,
-that is the sign of this particular integer is positive as opposed to negative. Second, the integer has three digits in
-its representation. There is an additional property that the integer posesses that does not concern pencil-and-paper
-arithmetic. The third property is how many digits placeholders are available to hold the integer.
-
-The human analogy of this third property is ensuring there is enough space on the paper to write the integer. For example,
-if one starts writing a large number too far to the right on a piece of paper they will have to erase it and move left.
-Similarly, computer algorithms must maintain strict control over memory usage to ensure that the digits of an integer
-will not exceed the allowed boundaries. These three properties make up what is known as a multiple precision
-integer or mp\_int for short.
-
-\subsection{The mp\_int Structure}
-\label{sec:MPINT}
-The mp\_int structure is the ISO C based manifestation of what represents a multiple precision integer. The ISO C standard does not provide for
-any such data type but it does provide for making composite data types known as structures. The following is the structure definition
-used within LibTomMath.
-
-\index{mp\_int}
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-%\begin{verbatim}
-\begin{tabular}{|l|}
-\hline
-typedef struct \{ \\
-\hspace{3mm}int used, alloc, sign;\\
-\hspace{3mm}mp\_digit *dp;\\
-\} \textbf{mp\_int}; \\
-\hline
-\end{tabular}
-%\end{verbatim}
-\end{small}
-\caption{The mp\_int Structure}
-\label{fig:mpint}
-\end{center}
-\end{figure}
-
-The mp\_int structure (fig. \ref{fig:mpint}) can be broken down as follows.
-
-\begin{enumerate}
-\item The \textbf{used} parameter denotes how many digits of the array \textbf{dp} contain the digits used to represent
-a given integer. The \textbf{used} count must be positive (or zero) and may not exceed the \textbf{alloc} count.
-
-\item The \textbf{alloc} parameter denotes how
-many digits are available in the array to use by functions before it has to increase in size. When the \textbf{used} count
-of a result would exceed the \textbf{alloc} count all of the algorithms will automatically increase the size of the
-array to accommodate the precision of the result.
-
-\item The pointer \textbf{dp} points to a dynamically allocated array of digits that represent the given multiple
-precision integer. It is padded with $(\textbf{alloc} - \textbf{used})$ zero digits. The array is maintained in a least
-significant digit order. As a pencil and paper analogy the array is organized such that the right most digits are stored
-first starting at the location indexed by zero\footnote{In C all arrays begin at zero.} in the array. For example,
-if \textbf{dp} contains $\lbrace a, b, c, \ldots \rbrace$ where \textbf{dp}$_0 = a$, \textbf{dp}$_1 = b$, \textbf{dp}$_2 = c$, $\ldots$ then
-it would represent the integer $a + b\beta + c\beta^2 + \ldots$
-
-\index{MP\_ZPOS} \index{MP\_NEG}
-\item The \textbf{sign} parameter denotes the sign as either zero/positive (\textbf{MP\_ZPOS}) or negative (\textbf{MP\_NEG}).
-\end{enumerate}
-
-\subsubsection{Valid mp\_int Structures}
-Several rules are placed on the state of an mp\_int structure and are assumed to be followed for reasons of efficiency.
-The only exceptions are when the structure is passed to initialization functions such as mp\_init() and mp\_init\_copy().
-
-\begin{enumerate}
-\item The value of \textbf{alloc} may not be less than one. That is \textbf{dp} always points to a previously allocated
-array of digits.
-\item The value of \textbf{used} may not exceed \textbf{alloc} and must be greater than or equal to zero.
-\item The value of \textbf{used} implies the digit at index $(used - 1)$ of the \textbf{dp} array is non-zero. That is,
-leading zero digits in the most significant positions must be trimmed.
- \begin{enumerate}
- \item Digits in the \textbf{dp} array at and above the \textbf{used} location must be zero.
- \end{enumerate}
-\item The value of \textbf{sign} must be \textbf{MP\_ZPOS} if \textbf{used} is zero;
-this represents the mp\_int value of zero.
-\end{enumerate}
-
-\section{Argument Passing}
-A convention of argument passing must be adopted early on in the development of any library. Making the function
-prototypes consistent will help eliminate many headaches in the future as the library grows to significant complexity.
-In LibTomMath the multiple precision integer functions accept parameters from left to right as pointers to mp\_int
-structures. That means that the source (input) operands are placed on the left and the destination (output) on the right.
-Consider the following examples.
-
-\begin{verbatim}
- mp_mul(&a, &b, &c); /* c = a * b */
- mp_add(&a, &b, &a); /* a = a + b */
- mp_sqr(&a, &b); /* b = a * a */
-\end{verbatim}
-
-The left to right order is a fairly natural way to implement the functions since it lets the developer read aloud the
-functions and make sense of them. For example, the first function would read ``multiply a and b and store in c''.
-
-Certain libraries (\textit{LIP by Lenstra for instance}) accept parameters the other way around, to mimic the order
-of assignment expressions. That is, the destination (output) is on the left and arguments (inputs) are on the right. In
-truth, it is entirely a matter of preference. In the case of LibTomMath the convention from the MPI library has been
-adopted.
-
-Another very useful design consideration, provided for in LibTomMath, is whether to allow argument sources to also be a
-destination. For example, the second example (\textit{mp\_add}) adds $a$ to $b$ and stores in $a$. This is an important
-feature to implement since it allows the calling functions to cut down on the number of variables it must maintain.
-However, to implement this feature specific care has to be given to ensure the destination is not modified before the
-source is fully read.
-
-\section{Return Values}
-A well implemented application, no matter what its purpose, should trap as many runtime errors as possible and return them
-to the caller. By catching runtime errors a library can be guaranteed to prevent undefined behaviour. However, the end
-developer can still manage to cause a library to crash. For example, by passing an invalid pointer an application may
-fault by dereferencing memory not owned by the application.
-
-In the case of LibTomMath the only errors that are checked for are related to inappropriate inputs (division by zero for
-instance) and memory allocation errors. It will not check that the mp\_int passed to any function is valid nor
-will it check pointers for validity. Any function that can cause a runtime error will return an error code as an
-\textbf{int} data type with one of the following values (fig \ref{fig:errcodes}).
-
-\index{MP\_OKAY} \index{MP\_VAL} \index{MP\_MEM}
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|l|l|}
-\hline \textbf{Value} & \textbf{Meaning} \\
-\hline \textbf{MP\_OKAY} & The function was successful \\
-\hline \textbf{MP\_VAL} & One of the input value(s) was invalid \\
-\hline \textbf{MP\_MEM} & The function ran out of heap memory \\
-\hline
-\end{tabular}
-\end{center}
-\caption{LibTomMath Error Codes}
-\label{fig:errcodes}
-\end{figure}
-
-When an error is detected within a function it should free any memory it allocated, often during the initialization of
-temporary mp\_ints, and return as soon as possible. The goal is to leave the system in the same state it was when the
-function was called. Error checking with this style of API is fairly simple.
-
-\begin{verbatim}
- int err;
- if ((err = mp_add(&a, &b, &c)) != MP_OKAY) {
- printf("Error: %s\n", mp_error_to_string(err));
- exit(EXIT_FAILURE);
- }
-\end{verbatim}
-
-The GMP \cite{GMP} library uses C style \textit{signals} to flag errors which is of questionable use. Not all errors are fatal
-and it was not deemed ideal by the author of LibTomMath to force developers to have signal handlers for such cases.
-
-\section{Initialization and Clearing}
-The logical starting point when actually writing multiple precision integer functions is the initialization and
-clearing of the mp\_int structures. These two algorithms will be used by the majority of the higher level algorithms.
-
-Given the basic mp\_int structure an initialization routine must first allocate memory to hold the digits of
-the integer. Often it is optimal to allocate a sufficiently large pre-set number of digits even though
-the initial integer will represent zero. If only a single digit were allocated quite a few subsequent re-allocations
-would occur when operations are performed on the integers. There is a tradeoff between how many default digits to allocate
-and how many re-allocations are tolerable. Obviously allocating an excessive amount of digits initially will waste
-memory and become unmanageable.
-
-If the memory for the digits has been successfully allocated then the rest of the members of the structure must
-be initialized. Since the initial state of an mp\_int is to represent the zero integer, the allocated digits must be set
-to zero. The \textbf{used} count set to zero and \textbf{sign} set to \textbf{MP\_ZPOS}.
-
-\subsection{Initializing an mp\_int}
-An mp\_int is said to be initialized if it is set to a valid, preferably default, state such that all of the members of the
-structure are set to valid values. The mp\_init algorithm will perform such an action.
-
-\index{mp\_init}
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Allocate memory and initialize $a$ to a known valid mp\_int state. \\
-\hline \\
-1. Allocate memory for \textbf{MP\_PREC} digits. \\
-2. If the allocation failed return(\textit{MP\_MEM}) \\
-3. for $n$ from $0$ to $MP\_PREC - 1$ do \\
-\hspace{3mm}3.1 $a_n \leftarrow 0$\\
-4. $a.sign \leftarrow MP\_ZPOS$\\
-5. $a.used \leftarrow 0$\\
-6. $a.alloc \leftarrow MP\_PREC$\\
-7. Return(\textit{MP\_OKAY})\\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init}
-\end{figure}
-
-\textbf{Algorithm mp\_init.}
-The purpose of this function is to initialize an mp\_int structure so that the rest of the library can properly
-manipulte it. It is assumed that the input may not have had any of its members previously initialized which is certainly
-a valid assumption if the input resides on the stack.
-
-Before any of the members such as \textbf{sign}, \textbf{used} or \textbf{alloc} are initialized the memory for
-the digits is allocated. If this fails the function returns before setting any of the other members. The \textbf{MP\_PREC}
-name represents a constant\footnote{Defined in the ``tommath.h'' header file within LibTomMath.}
-used to dictate the minimum precision of newly initialized mp\_int integers. Ideally, it is at least equal to the smallest
-precision number you'll be working with.
-
-Allocating a block of digits at first instead of a single digit has the benefit of lowering the number of usually slow
-heap operations later functions will have to perform in the future. If \textbf{MP\_PREC} is set correctly the slack
-memory and the number of heap operations will be trivial.
-
-Once the allocation has been made the digits have to be set to zero as well as the \textbf{used}, \textbf{sign} and
-\textbf{alloc} members initialized. This ensures that the mp\_int will always represent the default state of zero regardless
-of the original condition of the input.
-
-\textbf{Remark.}
-This function introduces the idiosyncrasy that all iterative loops, commonly initiated with the ``for'' keyword, iterate incrementally
-when the ``to'' keyword is placed between two expressions. For example, ``for $a$ from $b$ to $c$ do'' means that
-a subsequent expression (or body of expressions) are to be evaluated upto $c - b$ times so long as $b \le c$. In each
-iteration the variable $a$ is substituted for a new integer that lies inclusively between $b$ and $c$. If $b > c$ occured
-the loop would not iterate. By contrast if the ``downto'' keyword were used in place of ``to'' the loop would iterate
-decrementally.
-
-EXAM,bn_mp_init.c
-
-One immediate observation of this initializtion function is that it does not return a pointer to a mp\_int structure. It
-is assumed that the caller has already allocated memory for the mp\_int structure, typically on the application stack. The
-call to mp\_init() is used only to initialize the members of the structure to a known default state.
-
-Here we see (line @23,XMALLOC@) the memory allocation is performed first. This allows us to exit cleanly and quickly
-if there is an error. If the allocation fails the routine will return \textbf{MP\_MEM} to the caller to indicate there
-was a memory error. The function XMALLOC is what actually allocates the memory. Technically XMALLOC is not a function
-but a macro defined in ``tommath.h``. By default, XMALLOC will evaluate to malloc() which is the C library's built--in
-memory allocation routine.
-
-In order to assure the mp\_int is in a known state the digits must be set to zero. On most platforms this could have been
-accomplished by using calloc() instead of malloc(). However, to correctly initialize a integer type to a given value in a
-portable fashion you have to actually assign the value. The for loop (line @28,for@) performs this required
-operation.
-
-After the memory has been successfully initialized the remainder of the members are initialized
-(lines @29,used@ through @31,sign@) to their respective default states. At this point the algorithm has succeeded and
-a success code is returned to the calling function. If this function returns \textbf{MP\_OKAY} it is safe to assume the
-mp\_int structure has been properly initialized and is safe to use with other functions within the library.
-
-\subsection{Clearing an mp\_int}
-When an mp\_int is no longer required by the application, the memory that has been allocated for its digits must be
-returned to the application's memory pool with the mp\_clear algorithm.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_clear}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. The memory for $a$ shall be deallocated. \\
-\hline \\
-1. If $a$ has been previously freed then return(\textit{MP\_OKAY}). \\
-2. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}2.1 $a_n \leftarrow 0$ \\
-3. Free the memory allocated for the digits of $a$. \\
-4. $a.used \leftarrow 0$ \\
-5. $a.alloc \leftarrow 0$ \\
-6. $a.sign \leftarrow MP\_ZPOS$ \\
-7. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_clear}
-\end{figure}
-
-\textbf{Algorithm mp\_clear.}
-This algorithm accomplishes two goals. First, it clears the digits and the other mp\_int members. This ensures that
-if a developer accidentally re-uses a cleared structure it is less likely to cause problems. The second goal
-is to free the allocated memory.
-
-The logic behind the algorithm is extended by marking cleared mp\_int structures so that subsequent calls to this
-algorithm will not try to free the memory multiple times. Cleared mp\_ints are detectable by having a pre-defined invalid
-digit pointer \textbf{dp} setting.
-
-Once an mp\_int has been cleared the mp\_int structure is no longer in a valid state for any other algorithm
-with the exception of algorithms mp\_init, mp\_init\_copy, mp\_init\_size and mp\_clear.
-
-EXAM,bn_mp_clear.c
-
-The algorithm only operates on the mp\_int if it hasn't been previously cleared. The if statement (line @23,a->dp != NULL@)
-checks to see if the \textbf{dp} member is not \textbf{NULL}. If the mp\_int is a valid mp\_int then \textbf{dp} cannot be
-\textbf{NULL} in which case the if statement will evaluate to true.
-
-The digits of the mp\_int are cleared by the for loop (line @25,for@) which assigns a zero to every digit. Similar to mp\_init()
-the digits are assigned zero instead of using block memory operations (such as memset()) since this is more portable.
-
-The digits are deallocated off the heap via the XFREE macro. Similar to XMALLOC the XFREE macro actually evaluates to
-a standard C library function. In this case the free() function. Since free() only deallocates the memory the pointer
-still has to be reset to \textbf{NULL} manually (line @33,NULL@).
-
-Now that the digits have been cleared and deallocated the other members are set to their final values (lines @34,= 0@ and @35,ZPOS@).
-
-\section{Maintenance Algorithms}
-
-The previous sections describes how to initialize and clear an mp\_int structure. To further support operations
-that are to be performed on mp\_int structures (such as addition and multiplication) the dependent algorithms must be
-able to augment the precision of an mp\_int and
-initialize mp\_ints with differing initial conditions.
-
-These algorithms complete the set of low level algorithms required to work with mp\_int structures in the higher level
-algorithms such as addition, multiplication and modular exponentiation.
-
-\subsection{Augmenting an mp\_int's Precision}
-When storing a value in an mp\_int structure, a sufficient number of digits must be available to accomodate the entire
-result of an operation without loss of precision. Quite often the size of the array given by the \textbf{alloc} member
-is large enough to simply increase the \textbf{used} digit count. However, when the size of the array is too small it
-must be re-sized appropriately to accomodate the result. The mp\_grow algorithm will provide this functionality.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_grow}. \\
-\textbf{Input}. An mp\_int $a$ and an integer $b$. \\
-\textbf{Output}. $a$ is expanded to accomodate $b$ digits. \\
-\hline \\
-1. if $a.alloc \ge b$ then return(\textit{MP\_OKAY}) \\
-2. $u \leftarrow b\mbox{ (mod }MP\_PREC\mbox{)}$ \\
-3. $v \leftarrow b + 2 \cdot MP\_PREC - u$ \\
-4. Re-allocate the array of digits $a$ to size $v$ \\
-5. If the allocation failed then return(\textit{MP\_MEM}). \\
-6. for n from a.alloc to $v - 1$ do \\
-\hspace{+3mm}6.1 $a_n \leftarrow 0$ \\
-7. $a.alloc \leftarrow v$ \\
-8. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_grow}
-\end{figure}
-
-\textbf{Algorithm mp\_grow.}
-It is ideal to prevent re-allocations from being performed if they are not required (step one). This is useful to
-prevent mp\_ints from growing excessively in code that erroneously calls mp\_grow.
-
-The requested digit count is padded up to next multiple of \textbf{MP\_PREC} plus an additional \textbf{MP\_PREC} (steps two and three).
-This helps prevent many trivial reallocations that would grow an mp\_int by trivially small values.
-
-It is assumed that the reallocation (step four) leaves the lower $a.alloc$ digits of the mp\_int intact. This is much
-akin to how the \textit{realloc} function from the standard C library works. Since the newly allocated digits are
-assumed to contain undefined values they are initially set to zero.
-
-EXAM,bn_mp_grow.c
-
-A quick optimization is to first determine if a memory re-allocation is required at all. The if statement (line @24,alloc@) checks
-if the \textbf{alloc} member of the mp\_int is smaller than the requested digit count. If the count is not larger than \textbf{alloc}
-the function skips the re-allocation part thus saving time.
-
-When a re-allocation is performed it is turned into an optimal request to save time in the future. The requested digit count is
-padded upwards to 2nd multiple of \textbf{MP\_PREC} larger than \textbf{alloc} (line @25, size@). The XREALLOC function is used
-to re-allocate the memory. As per the other functions XREALLOC is actually a macro which evaluates to realloc by default. The realloc
-function leaves the base of the allocation intact which means the first \textbf{alloc} digits of the mp\_int are the same as before
-the re-allocation. All that is left is to clear the newly allocated digits and return.
-
-Note that the re-allocation result is actually stored in a temporary pointer $tmp$. This is to allow this function to return
-an error with a valid pointer. Earlier releases of the library stored the result of XREALLOC into the mp\_int $a$. That would
-result in a memory leak if XREALLOC ever failed.
-
-\subsection{Initializing Variable Precision mp\_ints}
-Occasionally the number of digits required will be known in advance of an initialization, based on, for example, the size
-of input mp\_ints to a given algorithm. The purpose of algorithm mp\_init\_size is similar to mp\_init except that it
-will allocate \textit{at least} a specified number of digits.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_size}. \\
-\textbf{Input}. An mp\_int $a$ and the requested number of digits $b$. \\
-\textbf{Output}. $a$ is initialized to hold at least $b$ digits. \\
-\hline \\
-1. $u \leftarrow b \mbox{ (mod }MP\_PREC\mbox{)}$ \\
-2. $v \leftarrow b + 2 \cdot MP\_PREC - u$ \\
-3. Allocate $v$ digits. \\
-4. for $n$ from $0$ to $v - 1$ do \\
-\hspace{3mm}4.1 $a_n \leftarrow 0$ \\
-5. $a.sign \leftarrow MP\_ZPOS$\\
-6. $a.used \leftarrow 0$\\
-7. $a.alloc \leftarrow v$\\
-8. Return(\textit{MP\_OKAY})\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_init\_size}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_size.}
-This algorithm will initialize an mp\_int structure $a$ like algorithm mp\_init with the exception that the number of
-digits allocated can be controlled by the second input argument $b$. The input size is padded upwards so it is a
-multiple of \textbf{MP\_PREC} plus an additional \textbf{MP\_PREC} digits. This padding is used to prevent trivial
-allocations from becoming a bottleneck in the rest of the algorithms.
-
-Like algorithm mp\_init, the mp\_int structure is initialized to a default state representing the integer zero. This
-particular algorithm is useful if it is known ahead of time the approximate size of the input. If the approximation is
-correct no further memory re-allocations are required to work with the mp\_int.
-
-EXAM,bn_mp_init_size.c
-
-The number of digits $b$ requested is padded (line @22,MP_PREC@) by first augmenting it to the next multiple of
-\textbf{MP\_PREC} and then adding \textbf{MP\_PREC} to the result. If the memory can be successfully allocated the
-mp\_int is placed in a default state representing the integer zero. Otherwise, the error code \textbf{MP\_MEM} will be
-returned (line @27,return@).
-
-The digits are allocated and set to zero at the same time with the calloc() function (line @25,XCALLOC@). The
-\textbf{used} count is set to zero, the \textbf{alloc} count set to the padded digit count and the \textbf{sign} flag set
-to \textbf{MP\_ZPOS} to achieve a default valid mp\_int state (lines @29,used@, @30,alloc@ and @31,sign@). If the function
-returns succesfully then it is correct to assume that the mp\_int structure is in a valid state for the remainder of the
-functions to work with.
-
-\subsection{Multiple Integer Initializations and Clearings}
-Occasionally a function will require a series of mp\_int data types to be made available simultaneously.
-The purpose of algorithm mp\_init\_multi is to initialize a variable length array of mp\_int structures in a single
-statement. It is essentially a shortcut to multiple initializations.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_multi}. \\
-\textbf{Input}. Variable length array $V_k$ of mp\_int variables of length $k$. \\
-\textbf{Output}. The array is initialized such that each mp\_int of $V_k$ is ready to use. \\
-\hline \\
-1. for $n$ from 0 to $k - 1$ do \\
-\hspace{+3mm}1.1. Initialize the mp\_int $V_n$ (\textit{mp\_init}) \\
-\hspace{+3mm}1.2. If initialization failed then do \\
-\hspace{+6mm}1.2.1. for $j$ from $0$ to $n$ do \\
-\hspace{+9mm}1.2.1.1. Free the mp\_int $V_j$ (\textit{mp\_clear}) \\
-\hspace{+6mm}1.2.2. Return(\textit{MP\_MEM}) \\
-2. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init\_multi}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_multi.}
-The algorithm will initialize the array of mp\_int variables one at a time. If a runtime error has been detected
-(\textit{step 1.2}) all of the previously initialized variables are cleared. The goal is an ``all or nothing''
-initialization which allows for quick recovery from runtime errors.
-
-EXAM,bn_mp_init_multi.c
-
-This function intializes a variable length list of mp\_int structure pointers. However, instead of having the mp\_int
-structures in an actual C array they are simply passed as arguments to the function. This function makes use of the
-``...'' argument syntax of the C programming language. The list is terminated with a final \textbf{NULL} argument
-appended on the right.
-
-The function uses the ``stdarg.h'' \textit{va} functions to step portably through the arguments to the function. A count
-$n$ of succesfully initialized mp\_int structures is maintained (line @47,n++@) such that if a failure does occur,
-the algorithm can backtrack and free the previously initialized structures (lines @27,if@ to @46,}@).
-
-
-\subsection{Clamping Excess Digits}
-When a function anticipates a result will be $n$ digits it is simpler to assume this is true within the body of
-the function instead of checking during the computation. For example, a multiplication of a $i$ digit number by a
-$j$ digit produces a result of at most $i + j$ digits. It is entirely possible that the result is $i + j - 1$
-though, with no final carry into the last position. However, suppose the destination had to be first expanded
-(\textit{via mp\_grow}) to accomodate $i + j - 1$ digits than further expanded to accomodate the final carry.
-That would be a considerable waste of time since heap operations are relatively slow.
-
-The ideal solution is to always assume the result is $i + j$ and fix up the \textbf{used} count after the function
-terminates. This way a single heap operation (\textit{at most}) is required. However, if the result was not checked
-there would be an excess high order zero digit.
-
-For example, suppose the product of two integers was $x_n = (0x_{n-1}x_{n-2}...x_0)_{\beta}$. The leading zero digit
-will not contribute to the precision of the result. In fact, through subsequent operations more leading zero digits would
-accumulate to the point the size of the integer would be prohibitive. As a result even though the precision is very
-low the representation is excessively large.
-
-The mp\_clamp algorithm is designed to solve this very problem. It will trim high-order zeros by decrementing the
-\textbf{used} count until a non-zero most significant digit is found. Also in this system, zero is considered to be a
-positive number which means that if the \textbf{used} count is decremented to zero, the sign must be set to
-\textbf{MP\_ZPOS}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_clamp}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Any excess leading zero digits of $a$ are removed \\
-\hline \\
-1. while $a.used > 0$ and $a_{a.used - 1} = 0$ do \\
-\hspace{+3mm}1.1 $a.used \leftarrow a.used - 1$ \\
-2. if $a.used = 0$ then do \\
-\hspace{+3mm}2.1 $a.sign \leftarrow MP\_ZPOS$ \\
-\hline \\
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_clamp}
-\end{figure}
-
-\textbf{Algorithm mp\_clamp.}
-As can be expected this algorithm is very simple. The loop on step one is expected to iterate only once or twice at
-the most. For example, this will happen in cases where there is not a carry to fill the last position. Step two fixes the sign for
-when all of the digits are zero to ensure that the mp\_int is valid at all times.
-
-EXAM,bn_mp_clamp.c
-
-Note on line @27,while@ how to test for the \textbf{used} count is made on the left of the \&\& operator. In the C programming
-language the terms to \&\& are evaluated left to right with a boolean short-circuit if any condition fails. This is
-important since if the \textbf{used} is zero the test on the right would fetch below the array. That is obviously
-undesirable. The parenthesis on line @28,a->used@ is used to make sure the \textbf{used} count is decremented and not
-the pointer ``a''.
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 1 \right ]$ & Discuss the relevance of the \textbf{used} member of the mp\_int structure. \\
- & \\
-$\left [ 1 \right ]$ & Discuss the consequences of not using padding when performing allocations. \\
- & \\
-$\left [ 2 \right ]$ & Estimate an ideal value for \textbf{MP\_PREC} when performing 1024-bit RSA \\
- & encryption when $\beta = 2^{28}$. \\
- & \\
-$\left [ 1 \right ]$ & Discuss the relevance of the algorithm mp\_clamp. What does it prevent? \\
- & \\
-$\left [ 1 \right ]$ & Give an example of when the algorithm mp\_init\_copy might be useful. \\
- & \\
-\end{tabular}
-
-
-%%%
-% CHAPTER FOUR
-%%%
-
-\chapter{Basic Operations}
-
-\section{Introduction}
-In the previous chapter a series of low level algorithms were established that dealt with initializing and maintaining
-mp\_int structures. This chapter will discuss another set of seemingly non-algebraic algorithms which will form the low
-level basis of the entire library. While these algorithm are relatively trivial it is important to understand how they
-work before proceeding since these algorithms will be used almost intrinsically in the following chapters.
-
-The algorithms in this chapter deal primarily with more ``programmer'' related tasks such as creating copies of
-mp\_int structures, assigning small values to mp\_int structures and comparisons of the values mp\_int structures
-represent.
-
-\section{Assigning Values to mp\_int Structures}
-\subsection{Copying an mp\_int}
-Assigning the value that a given mp\_int structure represents to another mp\_int structure shall be known as making
-a copy for the purposes of this text. The copy of the mp\_int will be a separate entity that represents the same
-value as the mp\_int it was copied from. The mp\_copy algorithm provides this functionality.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_copy}. \\
-\textbf{Input}. An mp\_int $a$ and $b$. \\
-\textbf{Output}. Store a copy of $a$ in $b$. \\
-\hline \\
-1. If $b.alloc < a.used$ then grow $b$ to $a.used$ digits. (\textit{mp\_grow}) \\
-2. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}2.1 $b_{n} \leftarrow a_{n}$ \\
-3. for $n$ from $a.used$ to $b.used - 1$ do \\
-\hspace{3mm}3.1 $b_{n} \leftarrow 0$ \\
-4. $b.used \leftarrow a.used$ \\
-5. $b.sign \leftarrow a.sign$ \\
-6. return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_copy}
-\end{figure}
-
-\textbf{Algorithm mp\_copy.}
-This algorithm copies the mp\_int $a$ such that upon succesful termination of the algorithm the mp\_int $b$ will
-represent the same integer as the mp\_int $a$. The mp\_int $b$ shall be a complete and distinct copy of the
-mp\_int $a$ meaing that the mp\_int $a$ can be modified and it shall not affect the value of the mp\_int $b$.
-
-If $b$ does not have enough room for the digits of $a$ it must first have its precision augmented via the mp\_grow
-algorithm. The digits of $a$ are copied over the digits of $b$ and any excess digits of $b$ are set to zero (step two
-and three). The \textbf{used} and \textbf{sign} members of $a$ are finally copied over the respective members of
-$b$.
-
-\textbf{Remark.} This algorithm also introduces a new idiosyncrasy that will be used throughout the rest of the
-text. The error return codes of other algorithms are not explicitly checked in the pseudo-code presented. For example, in
-step one of the mp\_copy algorithm the return of mp\_grow is not explicitly checked to ensure it succeeded. Text space is
-limited so it is assumed that if a algorithm fails it will clear all temporarily allocated mp\_ints and return
-the error code itself. However, the C code presented will demonstrate all of the error handling logic required to
-implement the pseudo-code.
-
-EXAM,bn_mp_copy.c
-
-Occasionally a dependent algorithm may copy an mp\_int effectively into itself such as when the input and output
-mp\_int structures passed to a function are one and the same. For this case it is optimal to return immediately without
-copying digits (line @24,a == b@).
-
-The mp\_int $b$ must have enough digits to accomodate the used digits of the mp\_int $a$. If $b.alloc$ is less than
-$a.used$ the algorithm mp\_grow is used to augment the precision of $b$ (lines @29,alloc@ to @33,}@). In order to
-simplify the inner loop that copies the digits from $a$ to $b$, two aliases $tmpa$ and $tmpb$ point directly at the digits
-of the mp\_ints $a$ and $b$ respectively. These aliases (lines @42,tmpa@ and @45,tmpb@) allow the compiler to access the digits without first dereferencing the
-mp\_int pointers and then subsequently the pointer to the digits.
-
-After the aliases are established the digits from $a$ are copied into $b$ (lines @48,for@ to @50,}@) and then the excess
-digits of $b$ are set to zero (lines @53,for@ to @55,}@). Both ``for'' loops make use of the pointer aliases and in
-fact the alias for $b$ is carried through into the second ``for'' loop to clear the excess digits. This optimization
-allows the alias to stay in a machine register fairly easy between the two loops.
-
-\textbf{Remarks.} The use of pointer aliases is an implementation methodology first introduced in this function that will
-be used considerably in other functions. Technically, a pointer alias is simply a short hand alias used to lower the
-number of pointer dereferencing operations required to access data. For example, a for loop may resemble
-
-\begin{alltt}
-for (x = 0; x < 100; x++) \{
- a->num[4]->dp[x] = 0;
-\}
-\end{alltt}
-
-This could be re-written using aliases as
-
-\begin{alltt}
-mp_digit *tmpa;
-a = a->num[4]->dp;
-for (x = 0; x < 100; x++) \{
- *a++ = 0;
-\}
-\end{alltt}
-
-In this case an alias is used to access the
-array of digits within an mp\_int structure directly. It may seem that a pointer alias is strictly not required
-as a compiler may optimize out the redundant pointer operations. However, there are two dominant reasons to use aliases.
-
-The first reason is that most compilers will not effectively optimize pointer arithmetic. For example, some optimizations
-may work for the Microsoft Visual C++ compiler (MSVC) and not for the GNU C Compiler (GCC). Also some optimizations may
-work for GCC and not MSVC. As such it is ideal to find a common ground for as many compilers as possible. Pointer
-aliases optimize the code considerably before the compiler even reads the source code which means the end compiled code
-stands a better chance of being faster.
-
-The second reason is that pointer aliases often can make an algorithm simpler to read. Consider the first ``for''
-loop of the function mp\_copy() re-written to not use pointer aliases.
-
-\begin{alltt}
- /* copy all the digits */
- for (n = 0; n < a->used; n++) \{
- b->dp[n] = a->dp[n];
- \}
-\end{alltt}
-
-Whether this code is harder to read depends strongly on the individual. However, it is quantifiably slightly more
-complicated as there are four variables within the statement instead of just two.
-
-\subsubsection{Nested Statements}
-Another commonly used technique in the source routines is that certain sections of code are nested. This is used in
-particular with the pointer aliases to highlight code phases. For example, a Comba multiplier (discussed in chapter six)
-will typically have three different phases. First the temporaries are initialized, then the columns calculated and
-finally the carries are propagated. In this example the middle column production phase will typically be nested as it
-uses temporary variables and aliases the most.
-
-The nesting also simplies the source code as variables that are nested are only valid for their scope. As a result
-the various temporary variables required do not propagate into other sections of code.
-
-
-\subsection{Creating a Clone}
-Another common operation is to make a local temporary copy of an mp\_int argument. To initialize an mp\_int
-and then copy another existing mp\_int into the newly intialized mp\_int will be known as creating a clone. This is
-useful within functions that need to modify an argument but do not wish to actually modify the original copy. The
-mp\_init\_copy algorithm has been designed to help perform this task.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_copy}. \\
-\textbf{Input}. An mp\_int $a$ and $b$\\
-\textbf{Output}. $a$ is initialized to be a copy of $b$. \\
-\hline \\
-1. Init $a$. (\textit{mp\_init}) \\
-2. Copy $b$ to $a$. (\textit{mp\_copy}) \\
-3. Return the status of the copy operation. \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init\_copy}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_copy.}
-This algorithm will initialize an mp\_int variable and copy another previously initialized mp\_int variable into it. As
-such this algorithm will perform two operations in one step.
-
-EXAM,bn_mp_init_copy.c
-
-This will initialize \textbf{a} and make it a verbatim copy of the contents of \textbf{b}. Note that
-\textbf{a} will have its own memory allocated which means that \textbf{b} may be cleared after the call
-and \textbf{a} will be left intact.
-
-\section{Zeroing an Integer}
-Reseting an mp\_int to the default state is a common step in many algorithms. The mp\_zero algorithm will be the algorithm used to
-perform this task.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_zero}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Zero the contents of $a$ \\
-\hline \\
-1. $a.used \leftarrow 0$ \\
-2. $a.sign \leftarrow$ MP\_ZPOS \\
-3. for $n$ from 0 to $a.alloc - 1$ do \\
-\hspace{3mm}3.1 $a_n \leftarrow 0$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_zero}
-\end{figure}
-
-\textbf{Algorithm mp\_zero.}
-This algorithm simply resets a mp\_int to the default state.
-
-EXAM,bn_mp_zero.c
-
-After the function is completed, all of the digits are zeroed, the \textbf{used} count is zeroed and the
-\textbf{sign} variable is set to \textbf{MP\_ZPOS}.
-
-\section{Sign Manipulation}
-\subsection{Absolute Value}
-With the mp\_int representation of an integer, calculating the absolute value is trivial. The mp\_abs algorithm will compute
-the absolute value of an mp\_int.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_abs}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Computes $b = \vert a \vert$ \\
-\hline \\
-1. Copy $a$ to $b$. (\textit{mp\_copy}) \\
-2. If the copy failed return(\textit{MP\_MEM}). \\
-3. $b.sign \leftarrow MP\_ZPOS$ \\
-4. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_abs}
-\end{figure}
-
-\textbf{Algorithm mp\_abs.}
-This algorithm computes the absolute of an mp\_int input. First it copies $a$ over $b$. This is an example of an
-algorithm where the check in mp\_copy that determines if the source and destination are equal proves useful. This allows,
-for instance, the developer to pass the same mp\_int as the source and destination to this function without addition
-logic to handle it.
-
-EXAM,bn_mp_abs.c
-
-This fairly trivial algorithm first eliminates non--required duplications (line @27,a != b@) and then sets the
-\textbf{sign} flag to \textbf{MP\_ZPOS}.
-
-\subsection{Integer Negation}
-With the mp\_int representation of an integer, calculating the negation is also trivial. The mp\_neg algorithm will compute
-the negative of an mp\_int input.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_neg}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Computes $b = -a$ \\
-\hline \\
-1. Copy $a$ to $b$. (\textit{mp\_copy}) \\
-2. If the copy failed return(\textit{MP\_MEM}). \\
-3. If $a.used = 0$ then return(\textit{MP\_OKAY}). \\
-4. If $a.sign = MP\_ZPOS$ then do \\
-\hspace{3mm}4.1 $b.sign = MP\_NEG$. \\
-5. else do \\
-\hspace{3mm}5.1 $b.sign = MP\_ZPOS$. \\
-6. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_neg}
-\end{figure}
-
-\textbf{Algorithm mp\_neg.}
-This algorithm computes the negation of an input. First it copies $a$ over $b$. If $a$ has no used digits then
-the algorithm returns immediately. Otherwise it flips the sign flag and stores the result in $b$. Note that if
-$a$ had no digits then it must be positive by definition. Had step three been omitted then the algorithm would return
-zero as negative.
-
-EXAM,bn_mp_neg.c
-
-Like mp\_abs() this function avoids non--required duplications (line @21,a != b@) and then sets the sign. We
-have to make sure that only non--zero values get a \textbf{sign} of \textbf{MP\_NEG}. If the mp\_int is zero
-than the \textbf{sign} is hard--coded to \textbf{MP\_ZPOS}.
-
-\section{Small Constants}
-\subsection{Setting Small Constants}
-Often a mp\_int must be set to a relatively small value such as $1$ or $2$. For these cases the mp\_set algorithm is useful.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_set}. \\
-\textbf{Input}. An mp\_int $a$ and a digit $b$ \\
-\textbf{Output}. Make $a$ equivalent to $b$ \\
-\hline \\
-1. Zero $a$ (\textit{mp\_zero}). \\
-2. $a_0 \leftarrow b \mbox{ (mod }\beta\mbox{)}$ \\
-3. $a.used \leftarrow \left \lbrace \begin{array}{ll}
- 1 & \mbox{if }a_0 > 0 \\
- 0 & \mbox{if }a_0 = 0
- \end{array} \right .$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_set}
-\end{figure}
-
-\textbf{Algorithm mp\_set.}
-This algorithm sets a mp\_int to a small single digit value. Step number 1 ensures that the integer is reset to the default state. The
-single digit is set (\textit{modulo $\beta$}) and the \textbf{used} count is adjusted accordingly.
-
-EXAM,bn_mp_set.c
-
-First we zero (line @21,mp_zero@) the mp\_int to make sure that the other members are initialized for a
-small positive constant. mp\_zero() ensures that the \textbf{sign} is positive and the \textbf{used} count
-is zero. Next we set the digit and reduce it modulo $\beta$ (line @22,MP_MASK@). After this step we have to
-check if the resulting digit is zero or not. If it is not then we set the \textbf{used} count to one, otherwise
-to zero.
-
-We can quickly reduce modulo $\beta$ since it is of the form $2^k$ and a quick binary AND operation with
-$2^k - 1$ will perform the same operation.
-
-One important limitation of this function is that it will only set one digit. The size of a digit is not fixed, meaning source that uses
-this function should take that into account. Only trivially small constants can be set using this function.
-
-\subsection{Setting Large Constants}
-To overcome the limitations of the mp\_set algorithm the mp\_set\_int algorithm is ideal. It accepts a ``long''
-data type as input and will always treat it as a 32-bit integer.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_set\_int}. \\
-\textbf{Input}. An mp\_int $a$ and a ``long'' integer $b$ \\
-\textbf{Output}. Make $a$ equivalent to $b$ \\
-\hline \\
-1. Zero $a$ (\textit{mp\_zero}) \\
-2. for $n$ from 0 to 7 do \\
-\hspace{3mm}2.1 $a \leftarrow a \cdot 16$ (\textit{mp\_mul2d}) \\
-\hspace{3mm}2.2 $u \leftarrow \lfloor b / 2^{4(7 - n)} \rfloor \mbox{ (mod }16\mbox{)}$\\
-\hspace{3mm}2.3 $a_0 \leftarrow a_0 + u$ \\
-\hspace{3mm}2.4 $a.used \leftarrow a.used + 1$ \\
-3. Clamp excess used digits (\textit{mp\_clamp}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_set\_int}
-\end{figure}
-
-\textbf{Algorithm mp\_set\_int.}
-The algorithm performs eight iterations of a simple loop where in each iteration four bits from the source are added to the
-mp\_int. Step 2.1 will multiply the current result by sixteen making room for four more bits in the less significant positions. In step 2.2 the
-next four bits from the source are extracted and are added to the mp\_int. The \textbf{used} digit count is
-incremented to reflect the addition. The \textbf{used} digit counter is incremented since if any of the leading digits were zero the mp\_int would have
-zero digits used and the newly added four bits would be ignored.
-
-Excess zero digits are trimmed in steps 2.1 and 3 by using higher level algorithms mp\_mul2d and mp\_clamp.
-
-EXAM,bn_mp_set_int.c
-
-This function sets four bits of the number at a time to handle all practical \textbf{DIGIT\_BIT} sizes. The weird
-addition on line @38,a->used@ ensures that the newly added in bits are added to the number of digits. While it may not
-seem obvious as to why the digit counter does not grow exceedingly large it is because of the shift on line @27,mp_mul_2d@
-as well as the call to mp\_clamp() on line @40,mp_clamp@. Both functions will clamp excess leading digits which keeps
-the number of used digits low.
-
-\section{Comparisons}
-\subsection{Unsigned Comparisions}
-Comparing a multiple precision integer is performed with the exact same algorithm used to compare two decimal numbers. For example,
-to compare $1,234$ to $1,264$ the digits are extracted by their positions. That is we compare $1 \cdot 10^3 + 2 \cdot 10^2 + 3 \cdot 10^1 + 4 \cdot 10^0$
-to $1 \cdot 10^3 + 2 \cdot 10^2 + 6 \cdot 10^1 + 4 \cdot 10^0$ by comparing single digits at a time starting with the highest magnitude
-positions. If any leading digit of one integer is greater than a digit in the same position of another integer then obviously it must be greater.
-
-The first comparision routine that will be developed is the unsigned magnitude compare which will perform a comparison based on the digits of two
-mp\_int variables alone. It will ignore the sign of the two inputs. Such a function is useful when an absolute comparison is required or if the
-signs are known to agree in advance.
-
-To facilitate working with the results of the comparison functions three constants are required.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|r|l|}
-\hline \textbf{Constant} & \textbf{Meaning} \\
-\hline \textbf{MP\_GT} & Greater Than \\
-\hline \textbf{MP\_EQ} & Equal To \\
-\hline \textbf{MP\_LT} & Less Than \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Comparison Return Codes}
-\end{figure}
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_cmp\_mag}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$. \\
-\textbf{Output}. Unsigned comparison results ($a$ to the left of $b$). \\
-\hline \\
-1. If $a.used > b.used$ then return(\textit{MP\_GT}) \\
-2. If $a.used < b.used$ then return(\textit{MP\_LT}) \\
-3. for n from $a.used - 1$ to 0 do \\
-\hspace{+3mm}3.1 if $a_n > b_n$ then return(\textit{MP\_GT}) \\
-\hspace{+3mm}3.2 if $a_n < b_n$ then return(\textit{MP\_LT}) \\
-4. Return(\textit{MP\_EQ}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_cmp\_mag}
-\end{figure}
-
-\textbf{Algorithm mp\_cmp\_mag.}
-By saying ``$a$ to the left of $b$'' it is meant that the comparison is with respect to $a$, that is if $a$ is greater than $b$ it will return
-\textbf{MP\_GT} and similar with respect to when $a = b$ and $a < b$. The first two steps compare the number of digits used in both $a$ and $b$.
-Obviously if the digit counts differ there would be an imaginary zero digit in the smaller number where the leading digit of the larger number is.
-If both have the same number of digits than the actual digits themselves must be compared starting at the leading digit.
-
-By step three both inputs must have the same number of digits so its safe to start from either $a.used - 1$ or $b.used - 1$ and count down to
-the zero'th digit. If after all of the digits have been compared, no difference is found, the algorithm returns \textbf{MP\_EQ}.
-
-EXAM,bn_mp_cmp_mag.c
-
-The two if statements (lines @24,if@ and @28,if@) compare the number of digits in the two inputs. These two are
-performed before all of the digits are compared since it is a very cheap test to perform and can potentially save
-considerable time. The implementation given is also not valid without those two statements. $b.alloc$ may be
-smaller than $a.used$, meaning that undefined values will be read from $b$ past the end of the array of digits.
-
-
-
-\subsection{Signed Comparisons}
-Comparing with sign considerations is also fairly critical in several routines (\textit{division for example}). Based on an unsigned magnitude
-comparison a trivial signed comparison algorithm can be written.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_cmp}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. Signed Comparison Results ($a$ to the left of $b$) \\
-\hline \\
-1. if $a.sign = MP\_NEG$ and $b.sign = MP\_ZPOS$ then return(\textit{MP\_LT}) \\
-2. if $a.sign = MP\_ZPOS$ and $b.sign = MP\_NEG$ then return(\textit{MP\_GT}) \\
-3. if $a.sign = MP\_NEG$ then \\
-\hspace{+3mm}3.1 Return the unsigned comparison of $b$ and $a$ (\textit{mp\_cmp\_mag}) \\
-4 Otherwise \\
-\hspace{+3mm}4.1 Return the unsigned comparison of $a$ and $b$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_cmp}
-\end{figure}
-
-\textbf{Algorithm mp\_cmp.}
-The first two steps compare the signs of the two inputs. If the signs do not agree then it can return right away with the appropriate
-comparison code. When the signs are equal the digits of the inputs must be compared to determine the correct result. In step
-three the unsigned comparision flips the order of the arguments since they are both negative. For instance, if $-a > -b$ then
-$\vert a \vert < \vert b \vert$. Step number four will compare the two when they are both positive.
-
-EXAM,bn_mp_cmp.c
-
-The two if statements (lines @22,if@ and @26,if@) perform the initial sign comparison. If the signs are not the equal then which ever
-has the positive sign is larger. The inputs are compared (line @30,if@) based on magnitudes. If the signs were both
-negative then the unsigned comparison is performed in the opposite direction (line @31,mp_cmp_mag@). Otherwise, the signs are assumed to
-be both positive and a forward direction unsigned comparison is performed.
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 2 \right ]$ & Modify algorithm mp\_set\_int to accept as input a variable length array of bits. \\
- & \\
-$\left [ 3 \right ]$ & Give the probability that algorithm mp\_cmp\_mag will have to compare $k$ digits \\
- & of two random digits (of equal magnitude) before a difference is found. \\
- & \\
-$\left [ 1 \right ]$ & Suggest a simple method to speed up the implementation of mp\_cmp\_mag based \\
- & on the observations made in the previous problem. \\
- &
-\end{tabular}
-
-\chapter{Basic Arithmetic}
-\section{Introduction}
-At this point algorithms for initialization, clearing, zeroing, copying, comparing and setting small constants have been
-established. The next logical set of algorithms to develop are addition, subtraction and digit shifting algorithms. These
-algorithms make use of the lower level algorithms and are the cruicial building block for the multiplication algorithms. It is very important
-that these algorithms are highly optimized. On their own they are simple $O(n)$ algorithms but they can be called from higher level algorithms
-which easily places them at $O(n^2)$ or even $O(n^3)$ work levels.
-
-MARK,SHIFTS
-All of the algorithms within this chapter make use of the logical bit shift operations denoted by $<<$ and $>>$ for left and right
-logical shifts respectively. A logical shift is analogous to sliding the decimal point of radix-10 representations. For example, the real
-number $0.9345$ is equivalent to $93.45\%$ which is found by sliding the the decimal two places to the right (\textit{multiplying by $\beta^2 = 10^2$}).
-Algebraically a binary logical shift is equivalent to a division or multiplication by a power of two.
-For example, $a << k = a \cdot 2^k$ while $a >> k = \lfloor a/2^k \rfloor$.
-
-One significant difference between a logical shift and the way decimals are shifted is that digits below the zero'th position are removed
-from the number. For example, consider $1101_2 >> 1$ using decimal notation this would produce $110.1_2$. However, with a logical shift the
-result is $110_2$.
-
-\section{Addition and Subtraction}
-In common twos complement fixed precision arithmetic negative numbers are easily represented by subtraction from the modulus. For example, with 32-bit integers
-$a - b\mbox{ (mod }2^{32}\mbox{)}$ is the same as $a + (2^{32} - b) \mbox{ (mod }2^{32}\mbox{)}$ since $2^{32} \equiv 0 \mbox{ (mod }2^{32}\mbox{)}$.
-As a result subtraction can be performed with a trivial series of logical operations and an addition.
-
-However, in multiple precision arithmetic negative numbers are not represented in the same way. Instead a sign flag is used to keep track of the
-sign of the integer. As a result signed addition and subtraction are actually implemented as conditional usage of lower level addition or
-subtraction algorithms with the sign fixed up appropriately.
-
-The lower level algorithms will add or subtract integers without regard to the sign flag. That is they will add or subtract the magnitude of
-the integers respectively.
-
-\subsection{Low Level Addition}
-An unsigned addition of multiple precision integers is performed with the same long-hand algorithm used to add decimal numbers. That is to add the
-trailing digits first and propagate the resulting carry upwards. Since this is a lower level algorithm the name will have a ``s\_'' prefix.
-Historically that convention stems from the MPI library where ``s\_'' stood for static functions that were hidden from the developer entirely.
-
-\newpage
-\begin{figure}[!here]
-\begin{center}
-\begin{small}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_add}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The unsigned addition $c = \vert a \vert + \vert b \vert$. \\
-\hline \\
-1. if $a.used > b.used$ then \\
-\hspace{+3mm}1.1 $min \leftarrow b.used$ \\
-\hspace{+3mm}1.2 $max \leftarrow a.used$ \\
-\hspace{+3mm}1.3 $x \leftarrow a$ \\
-2. else \\
-\hspace{+3mm}2.1 $min \leftarrow a.used$ \\
-\hspace{+3mm}2.2 $max \leftarrow b.used$ \\
-\hspace{+3mm}2.3 $x \leftarrow b$ \\
-3. If $c.alloc < max + 1$ then grow $c$ to hold at least $max + 1$ digits (\textit{mp\_grow}) \\
-4. $oldused \leftarrow c.used$ \\
-5. $c.used \leftarrow max + 1$ \\
-6. $u \leftarrow 0$ \\
-7. for $n$ from $0$ to $min - 1$ do \\
-\hspace{+3mm}7.1 $c_n \leftarrow a_n + b_n + u$ \\
-\hspace{+3mm}7.2 $u \leftarrow c_n >> lg(\beta)$ \\
-\hspace{+3mm}7.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-8. if $min \ne max$ then do \\
-\hspace{+3mm}8.1 for $n$ from $min$ to $max - 1$ do \\
-\hspace{+6mm}8.1.1 $c_n \leftarrow x_n + u$ \\
-\hspace{+6mm}8.1.2 $u \leftarrow c_n >> lg(\beta)$ \\
-\hspace{+6mm}8.1.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-9. $c_{max} \leftarrow u$ \\
-10. if $olduse > max$ then \\
-\hspace{+3mm}10.1 for $n$ from $max + 1$ to $oldused - 1$ do \\
-\hspace{+6mm}10.1.1 $c_n \leftarrow 0$ \\
-11. Clamp excess digits in $c$. (\textit{mp\_clamp}) \\
-12. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Algorithm s\_mp\_add}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_add.}
-This algorithm is loosely based on algorithm 14.7 of HAC \cite[pp. 594]{HAC} but has been extended to allow the inputs to have different magnitudes.
-Coincidentally the description of algorithm A in Knuth \cite[pp. 266]{TAOCPV2} shares the same deficiency as the algorithm from \cite{HAC}. Even the
-MIX pseudo machine code presented by Knuth \cite[pp. 266-267]{TAOCPV2} is incapable of handling inputs which are of different magnitudes.
-
-The first thing that has to be accomplished is to sort out which of the two inputs is the largest. The addition logic
-will simply add all of the smallest input to the largest input and store that first part of the result in the
-destination. Then it will apply a simpler addition loop to excess digits of the larger input.
-
-The first two steps will handle sorting the inputs such that $min$ and $max$ hold the digit counts of the two
-inputs. The variable $x$ will be an mp\_int alias for the largest input or the second input $b$ if they have the
-same number of digits. After the inputs are sorted the destination $c$ is grown as required to accomodate the sum
-of the two inputs. The original \textbf{used} count of $c$ is copied and set to the new used count.
-
-At this point the first addition loop will go through as many digit positions that both inputs have. The carry
-variable $\mu$ is set to zero outside the loop. Inside the loop an ``addition'' step requires three statements to produce
-one digit of the summand. First
-two digits from $a$ and $b$ are added together along with the carry $\mu$. The carry of this step is extracted and stored
-in $\mu$ and finally the digit of the result $c_n$ is truncated within the range $0 \le c_n < \beta$.
-
-Now all of the digit positions that both inputs have in common have been exhausted. If $min \ne max$ then $x$ is an alias
-for one of the inputs that has more digits. A simplified addition loop is then used to essentially copy the remaining digits
-and the carry to the destination.
-
-The final carry is stored in $c_{max}$ and digits above $max$ upto $oldused$ are zeroed which completes the addition.
-
-
-EXAM,bn_s_mp_add.c
-
-We first sort (lines @27,if@ to @35,}@) the inputs based on magnitude and determine the $min$ and $max$ variables.
-Note that $x$ is a pointer to an mp\_int assigned to the largest input, in effect it is a local alias. Next we
-grow the destination (@37,init@ to @42,}@) ensure that it can accomodate the result of the addition.
-
-Similar to the implementation of mp\_copy this function uses the braced code and local aliases coding style. The three aliases that are on
-lines @56,tmpa@, @59,tmpb@ and @62,tmpc@ represent the two inputs and destination variables respectively. These aliases are used to ensure the
-compiler does not have to dereference $a$, $b$ or $c$ (respectively) to access the digits of the respective mp\_int.
-
-The initial carry $u$ will be cleared (line @65,u = 0@), note that $u$ is of type mp\_digit which ensures type
-compatibility within the implementation. The initial addition (line @66,for@ to @75,}@) adds digits from
-both inputs until the smallest input runs out of digits. Similarly the conditional addition loop
-(line @81,for@ to @90,}@) adds the remaining digits from the larger of the two inputs. The addition is finished
-with the final carry being stored in $tmpc$ (line @94,tmpc++@). Note the ``++'' operator within the same expression.
-After line @94,tmpc++@, $tmpc$ will point to the $c.used$'th digit of the mp\_int $c$. This is useful
-for the next loop (line @97,for@ to @99,}@) which set any old upper digits to zero.
-
-\subsection{Low Level Subtraction}
-The low level unsigned subtraction algorithm is very similar to the low level unsigned addition algorithm. The principle difference is that the
-unsigned subtraction algorithm requires the result to be positive. That is when computing $a - b$ the condition $\vert a \vert \ge \vert b\vert$ must
-be met for this algorithm to function properly. Keep in mind this low level algorithm is not meant to be used in higher level algorithms directly.
-This algorithm as will be shown can be used to create functional signed addition and subtraction algorithms.
-
-MARK,GAMMA
-
-For this algorithm a new variable is required to make the description simpler. Recall from section 1.3.1 that a mp\_digit must be able to represent
-the range $0 \le x < 2\beta$ for the algorithms to work correctly. However, it is allowable that a mp\_digit represent a larger range of values. For
-this algorithm we will assume that the variable $\gamma$ represents the number of bits available in a
-mp\_digit (\textit{this implies $2^{\gamma} > \beta$}).
-
-For example, the default for LibTomMath is to use a ``unsigned long'' for the mp\_digit ``type'' while $\beta = 2^{28}$. In ISO C an ``unsigned long''
-data type must be able to represent $0 \le x < 2^{32}$ meaning that in this case $\gamma \ge 32$.
-
-\newpage\begin{figure}[!here]
-\begin{center}
-\begin{small}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_sub}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ ($\vert a \vert \ge \vert b \vert$) \\
-\textbf{Output}. The unsigned subtraction $c = \vert a \vert - \vert b \vert$. \\
-\hline \\
-1. $min \leftarrow b.used$ \\
-2. $max \leftarrow a.used$ \\
-3. If $c.alloc < max$ then grow $c$ to hold at least $max$ digits. (\textit{mp\_grow}) \\
-4. $oldused \leftarrow c.used$ \\
-5. $c.used \leftarrow max$ \\
-6. $u \leftarrow 0$ \\
-7. for $n$ from $0$ to $min - 1$ do \\
-\hspace{3mm}7.1 $c_n \leftarrow a_n - b_n - u$ \\
-\hspace{3mm}7.2 $u \leftarrow c_n >> (\gamma - 1)$ \\
-\hspace{3mm}7.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-8. if $min < max$ then do \\
-\hspace{3mm}8.1 for $n$ from $min$ to $max - 1$ do \\
-\hspace{6mm}8.1.1 $c_n \leftarrow a_n - u$ \\
-\hspace{6mm}8.1.2 $u \leftarrow c_n >> (\gamma - 1)$ \\
-\hspace{6mm}8.1.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-9. if $oldused > max$ then do \\
-\hspace{3mm}9.1 for $n$ from $max$ to $oldused - 1$ do \\
-\hspace{6mm}9.1.1 $c_n \leftarrow 0$ \\
-10. Clamp excess digits of $c$. (\textit{mp\_clamp}). \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Algorithm s\_mp\_sub}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_sub.}
-This algorithm performs the unsigned subtraction of two mp\_int variables under the restriction that the result must be positive. That is when
-passing variables $a$ and $b$ the condition that $\vert a \vert \ge \vert b \vert$ must be met for the algorithm to function correctly. This
-algorithm is loosely based on algorithm 14.9 \cite[pp. 595]{HAC} and is similar to algorithm S in \cite[pp. 267]{TAOCPV2} as well. As was the case
-of the algorithm s\_mp\_add both other references lack discussion concerning various practical details such as when the inputs differ in magnitude.
-
-The initial sorting of the inputs is trivial in this algorithm since $a$ is guaranteed to have at least the same magnitude of $b$. Steps 1 and 2
-set the $min$ and $max$ variables. Unlike the addition routine there is guaranteed to be no carry which means that the final result can be at
-most $max$ digits in length as opposed to $max + 1$. Similar to the addition algorithm the \textbf{used} count of $c$ is copied locally and
-set to the maximal count for the operation.
-
-The subtraction loop that begins on step seven is essentially the same as the addition loop of algorithm s\_mp\_add except single precision
-subtraction is used instead. Note the use of the $\gamma$ variable to extract the carry (\textit{also known as the borrow}) within the subtraction
-loops. Under the assumption that two's complement single precision arithmetic is used this will successfully extract the desired carry.
-
-For example, consider subtracting $0101_2$ from $0100_2$ where $\gamma = 4$ and $\beta = 2$. The least significant bit will force a carry upwards to
-the third bit which will be set to zero after the borrow. After the very first bit has been subtracted $4 - 1 \equiv 0011_2$ will remain, When the
-third bit of $0101_2$ is subtracted from the result it will cause another carry. In this case though the carry will be forced to propagate all the
-way to the most significant bit.
-
-Recall that $\beta < 2^{\gamma}$. This means that if a carry does occur just before the $lg(\beta)$'th bit it will propagate all the way to the most
-significant bit. Thus, the high order bits of the mp\_digit that are not part of the actual digit will either be all zero, or all one. All that
-is needed is a single zero or one bit for the carry. Therefore a single logical shift right by $\gamma - 1$ positions is sufficient to extract the
-carry. This method of carry extraction may seem awkward but the reason for it becomes apparent when the implementation is discussed.
-
-If $b$ has a smaller magnitude than $a$ then step 9 will force the carry and copy operation to propagate through the larger input $a$ into $c$. Step
-10 will ensure that any leading digits of $c$ above the $max$'th position are zeroed.
-
-EXAM,bn_s_mp_sub.c
-
-Like low level addition we ``sort'' the inputs. Except in this case the sorting is hardcoded
-(lines @24,min@ and @25,max@). In reality the $min$ and $max$ variables are only aliases and are only
-used to make the source code easier to read. Again the pointer alias optimization is used
-within this algorithm. The aliases $tmpa$, $tmpb$ and $tmpc$ are initialized
-(lines @42,tmpa@, @43,tmpb@ and @44,tmpc@) for $a$, $b$ and $c$ respectively.
-
-The first subtraction loop (lines @47,u = 0@ through @61,}@) subtract digits from both inputs until the smaller of
-the two inputs has been exhausted. As remarked earlier there is an implementation reason for using the ``awkward''
-method of extracting the carry (line @57, >>@). The traditional method for extracting the carry would be to shift
-by $lg(\beta)$ positions and logically AND the least significant bit. The AND operation is required because all of
-the bits above the $\lg(\beta)$'th bit will be set to one after a carry occurs from subtraction. This carry
-extraction requires two relatively cheap operations to extract the carry. The other method is to simply shift the
-most significant bit to the least significant bit thus extracting the carry with a single cheap operation. This
-optimization only works on twos compliment machines which is a safe assumption to make.
-
-If $a$ has a larger magnitude than $b$ an additional loop (lines @64,for@ through @73,}@) is required to propagate
-the carry through $a$ and copy the result to $c$.
-
-\subsection{High Level Addition}
-Now that both lower level addition and subtraction algorithms have been established an effective high level signed addition algorithm can be
-established. This high level addition algorithm will be what other algorithms and developers will use to perform addition of mp\_int data
-types.
-
-Recall from section 5.2 that an mp\_int represents an integer with an unsigned mantissa (\textit{the array of digits}) and a \textbf{sign}
-flag. A high level addition is actually performed as a series of eight separate cases which can be optimized down to three unique cases.
-
-\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_add}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The signed addition $c = a + b$. \\
-\hline \\
-1. if $a.sign = b.sign$ then do \\
-\hspace{3mm}1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{3mm}1.2 $c \leftarrow \vert a \vert + \vert b \vert$ (\textit{s\_mp\_add})\\
-2. else do \\
-\hspace{3mm}2.1 if $\vert a \vert < \vert b \vert$ then do (\textit{mp\_cmp\_mag}) \\
-\hspace{6mm}2.1.1 $c.sign \leftarrow b.sign$ \\
-\hspace{6mm}2.1.2 $c \leftarrow \vert b \vert - \vert a \vert$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c.sign \leftarrow a.sign$ \\
-\hspace{6mm}2.2.2 $c \leftarrow \vert a \vert - \vert b \vert$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_add}
-\end{figure}
-
-\textbf{Algorithm mp\_add.}
-This algorithm performs the signed addition of two mp\_int variables. There is no reference algorithm to draw upon from
-either \cite{TAOCPV2} or \cite{HAC} since they both only provide unsigned operations. The algorithm is fairly
-straightforward but restricted since subtraction can only produce positive results.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|}
-\hline \textbf{Sign of $a$} & \textbf{Sign of $b$} & \textbf{$\vert a \vert > \vert b \vert $} & \textbf{Unsigned Operation} & \textbf{Result Sign Flag} \\
-\hline $+$ & $+$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $+$ & $+$ & No & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $-$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $-$ & No & $c = a + b$ & $a.sign$ \\
-\hline &&&&\\
-
-\hline $+$ & $-$ & No & $c = b - a$ & $b.sign$ \\
-\hline $-$ & $+$ & No & $c = b - a$ & $b.sign$ \\
-
-\hline &&&&\\
-
-\hline $+$ & $-$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline $-$ & $+$ & Yes & $c = a - b$ & $a.sign$ \\
-
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Addition Guide Chart}
-\label{fig:AddChart}
-\end{figure}
-
-Figure~\ref{fig:AddChart} lists all of the eight possible input combinations and is sorted to show that only three
-specific cases need to be handled. The return code of the unsigned operations at step 1.2, 2.1.2 and 2.2.2 are
-forwarded to step three to check for errors. This simplifies the description of the algorithm considerably and best
-follows how the implementation actually was achieved.
-
-Also note how the \textbf{sign} is set before the unsigned addition or subtraction is performed. Recall from the descriptions of algorithms
-s\_mp\_add and s\_mp\_sub that the mp\_clamp function is used at the end to trim excess digits. The mp\_clamp algorithm will set the \textbf{sign}
-to \textbf{MP\_ZPOS} when the \textbf{used} digit count reaches zero.
-
-For example, consider performing $-a + a$ with algorithm mp\_add. By the description of the algorithm the sign is set to \textbf{MP\_NEG} which would
-produce a result of $-0$. However, since the sign is set first then the unsigned addition is performed the subsequent usage of algorithm mp\_clamp
-within algorithm s\_mp\_add will force $-0$ to become $0$.
-
-EXAM,bn_mp_add.c
-
-The source code follows the algorithm fairly closely. The most notable new source code addition is the usage of the $res$ integer variable which
-is used to pass result of the unsigned operations forward. Unlike in the algorithm, the variable $res$ is merely returned as is without
-explicitly checking it and returning the constant \textbf{MP\_OKAY}. The observation is this algorithm will succeed or fail only if the lower
-level functions do so. Returning their return code is sufficient.
-
-\subsection{High Level Subtraction}
-The high level signed subtraction algorithm is essentially the same as the high level signed addition algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_sub}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The signed subtraction $c = a - b$. \\
-\hline \\
-1. if $a.sign \ne b.sign$ then do \\
-\hspace{3mm}1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{3mm}1.2 $c \leftarrow \vert a \vert + \vert b \vert$ (\textit{s\_mp\_add}) \\
-2. else do \\
-\hspace{3mm}2.1 if $\vert a \vert \ge \vert b \vert$ then do (\textit{mp\_cmp\_mag}) \\
-\hspace{6mm}2.1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{6mm}2.1.2 $c \leftarrow \vert a \vert - \vert b \vert$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c.sign \leftarrow \left \lbrace \begin{array}{ll}
- MP\_ZPOS & \mbox{if }a.sign = MP\_NEG \\
- MP\_NEG & \mbox{otherwise} \\
- \end{array} \right .$ \\
-\hspace{6mm}2.2.2 $c \leftarrow \vert b \vert - \vert a \vert$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_sub}
-\end{figure}
-
-\textbf{Algorithm mp\_sub.}
-This algorithm performs the signed subtraction of two inputs. Similar to algorithm mp\_add there is no reference in either \cite{TAOCPV2} or
-\cite{HAC}. Also this algorithm is restricted by algorithm s\_mp\_sub. Chart \ref{fig:SubChart} lists the eight possible inputs and
-the operations required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|}
-\hline \textbf{Sign of $a$} & \textbf{Sign of $b$} & \textbf{$\vert a \vert \ge \vert b \vert $} & \textbf{Unsigned Operation} & \textbf{Result Sign Flag} \\
-\hline $+$ & $-$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $+$ & $-$ & No & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $+$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $+$ & No & $c = a + b$ & $a.sign$ \\
-\hline &&&& \\
-\hline $+$ & $+$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline $-$ & $-$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline &&&& \\
-\hline $+$ & $+$ & No & $c = b - a$ & $\mbox{opposite of }a.sign$ \\
-\hline $-$ & $-$ & No & $c = b - a$ & $\mbox{opposite of }a.sign$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Subtraction Guide Chart}
-\label{fig:SubChart}
-\end{figure}
-
-Similar to the case of algorithm mp\_add the \textbf{sign} is set first before the unsigned addition or subtraction. That is to prevent the
-algorithm from producing $-a - -a = -0$ as a result.
-
-EXAM,bn_mp_sub.c
-
-Much like the implementation of algorithm mp\_add the variable $res$ is used to catch the return code of the unsigned addition or subtraction operations
-and forward it to the end of the function. On line @38, != MP_LT@ the ``not equal to'' \textbf{MP\_LT} expression is used to emulate a
-``greater than or equal to'' comparison.
-
-\section{Bit and Digit Shifting}
-MARK,POLY
-It is quite common to think of a multiple precision integer as a polynomial in $x$, that is $y = f(\beta)$ where $f(x) = \sum_{i=0}^{n-1} a_i x^i$.
-This notation arises within discussion of Montgomery and Diminished Radix Reduction as well as Karatsuba multiplication and squaring.
-
-In order to facilitate operations on polynomials in $x$ as above a series of simple ``digit'' algorithms have to be established. That is to shift
-the digits left or right as well to shift individual bits of the digits left and right. It is important to note that not all ``shift'' operations
-are on radix-$\beta$ digits.
-
-\subsection{Multiplication by Two}
-
-In a binary system where the radix is a power of two multiplication by two not only arises often in other algorithms it is a fairly efficient
-operation to perform. A single precision logical shift left is sufficient to multiply a single digit by two.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_2}. \\
-\textbf{Input}. One mp\_int $a$ \\
-\textbf{Output}. $b = 2a$. \\
-\hline \\
-1. If $b.alloc < a.used + 1$ then grow $b$ to hold $a.used + 1$ digits. (\textit{mp\_grow}) \\
-2. $oldused \leftarrow b.used$ \\
-3. $b.used \leftarrow a.used$ \\
-4. $r \leftarrow 0$ \\
-5. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}5.1 $rr \leftarrow a_n >> (lg(\beta) - 1)$ \\
-\hspace{3mm}5.2 $b_n \leftarrow (a_n << 1) + r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}5.3 $r \leftarrow rr$ \\
-6. If $r \ne 0$ then do \\
-\hspace{3mm}6.1 $b_{n + 1} \leftarrow r$ \\
-\hspace{3mm}6.2 $b.used \leftarrow b.used + 1$ \\
-7. If $b.used < oldused - 1$ then do \\
-\hspace{3mm}7.1 for $n$ from $b.used$ to $oldused - 1$ do \\
-\hspace{6mm}7.1.1 $b_n \leftarrow 0$ \\
-8. $b.sign \leftarrow a.sign$ \\
-9. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_2}
-\end{figure}
-
-\textbf{Algorithm mp\_mul\_2.}
-This algorithm will quickly multiply a mp\_int by two provided $\beta$ is a power of two. Neither \cite{TAOCPV2} nor \cite{HAC} describe such
-an algorithm despite the fact it arises often in other algorithms. The algorithm is setup much like the lower level algorithm s\_mp\_add since
-it is for all intents and purposes equivalent to the operation $b = \vert a \vert + \vert a \vert$.
-
-Step 1 and 2 grow the input as required to accomodate the maximum number of \textbf{used} digits in the result. The initial \textbf{used} count
-is set to $a.used$ at step 4. Only if there is a final carry will the \textbf{used} count require adjustment.
-
-Step 6 is an optimization implementation of the addition loop for this specific case. That is since the two values being added together
-are the same there is no need to perform two reads from the digits of $a$. Step 6.1 performs a single precision shift on the current digit $a_n$ to
-obtain what will be the carry for the next iteration. Step 6.2 calculates the $n$'th digit of the result as single precision shift of $a_n$ plus
-the previous carry. Recall from ~SHIFTS~ that $a_n << 1$ is equivalent to $a_n \cdot 2$. An iteration of the addition loop is finished with
-forwarding the carry to the next iteration.
-
-Step 7 takes care of any final carry by setting the $a.used$'th digit of the result to the carry and augmenting the \textbf{used} count of $b$.
-Step 8 clears any leading digits of $b$ in case it originally had a larger magnitude than $a$.
-
-EXAM,bn_mp_mul_2.c
-
-This implementation is essentially an optimized implementation of s\_mp\_add for the case of doubling an input. The only noteworthy difference
-is the use of the logical shift operator on line @52,<<@ to perform a single precision doubling.
-
-\subsection{Division by Two}
-A division by two can just as easily be accomplished with a logical shift right as multiplication by two can be with a logical shift left.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_2}. \\
-\textbf{Input}. One mp\_int $a$ \\
-\textbf{Output}. $b = a/2$. \\
-\hline \\
-1. If $b.alloc < a.used$ then grow $b$ to hold $a.used$ digits. (\textit{mp\_grow}) \\
-2. If the reallocation failed return(\textit{MP\_MEM}). \\
-3. $oldused \leftarrow b.used$ \\
-4. $b.used \leftarrow a.used$ \\
-5. $r \leftarrow 0$ \\
-6. for $n$ from $b.used - 1$ to $0$ do \\
-\hspace{3mm}6.1 $rr \leftarrow a_n \mbox{ (mod }2\mbox{)}$\\
-\hspace{3mm}6.2 $b_n \leftarrow (a_n >> 1) + (r << (lg(\beta) - 1)) \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}6.3 $r \leftarrow rr$ \\
-7. If $b.used < oldused - 1$ then do \\
-\hspace{3mm}7.1 for $n$ from $b.used$ to $oldused - 1$ do \\
-\hspace{6mm}7.1.1 $b_n \leftarrow 0$ \\
-8. $b.sign \leftarrow a.sign$ \\
-9. Clamp excess digits of $b$. (\textit{mp\_clamp}) \\
-10. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_2}
-\end{figure}
-
-\textbf{Algorithm mp\_div\_2.}
-This algorithm will divide an mp\_int by two using logical shifts to the right. Like mp\_mul\_2 it uses a modified low level addition
-core as the basis of the algorithm. Unlike mp\_mul\_2 the shift operations work from the leading digit to the trailing digit. The algorithm
-could be written to work from the trailing digit to the leading digit however, it would have to stop one short of $a.used - 1$ digits to prevent
-reading past the end of the array of digits.
-
-Essentially the loop at step 6 is similar to that of mp\_mul\_2 except the logical shifts go in the opposite direction and the carry is at the
-least significant bit not the most significant bit.
-
-EXAM,bn_mp_div_2.c
-
-\section{Polynomial Basis Operations}
-Recall from ~POLY~ that any integer can be represented as a polynomial in $x$ as $y = f(\beta)$. Such a representation is also known as
-the polynomial basis \cite[pp. 48]{ROSE}. Given such a notation a multiplication or division by $x$ amounts to shifting whole digits a single
-place. The need for such operations arises in several other higher level algorithms such as Barrett and Montgomery reduction, integer
-division and Karatsuba multiplication.
-
-Converting from an array of digits to polynomial basis is very simple. Consider the integer $y \equiv (a_2, a_1, a_0)_{\beta}$ and recall that
-$y = \sum_{i=0}^{2} a_i \beta^i$. Simply replace $\beta$ with $x$ and the expression is in polynomial basis. For example, $f(x) = 8x + 9$ is the
-polynomial basis representation for $89$ using radix ten. That is, $f(10) = 8(10) + 9 = 89$.
-
-\subsection{Multiplication by $x$}
-
-Given a polynomial in $x$ such as $f(x) = a_n x^n + a_{n-1} x^{n-1} + ... + a_0$ multiplying by $x$ amounts to shifting the coefficients up one
-degree. In this case $f(x) \cdot x = a_n x^{n+1} + a_{n-1} x^n + ... + a_0 x$. From a scalar basis point of view multiplying by $x$ is equivalent to
-multiplying by the integer $\beta$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_lshd}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $a \leftarrow a \cdot \beta^b$ (equivalent to multiplication by $x^b$). \\
-\hline \\
-1. If $b \le 0$ then return(\textit{MP\_OKAY}). \\
-2. If $a.alloc < a.used + b$ then grow $a$ to at least $a.used + b$ digits. (\textit{mp\_grow}). \\
-3. If the reallocation failed return(\textit{MP\_MEM}). \\
-4. $a.used \leftarrow a.used + b$ \\
-5. $i \leftarrow a.used - 1$ \\
-6. $j \leftarrow a.used - 1 - b$ \\
-7. for $n$ from $a.used - 1$ to $b$ do \\
-\hspace{3mm}7.1 $a_{i} \leftarrow a_{j}$ \\
-\hspace{3mm}7.2 $i \leftarrow i - 1$ \\
-\hspace{3mm}7.3 $j \leftarrow j - 1$ \\
-8. for $n$ from 0 to $b - 1$ do \\
-\hspace{3mm}8.1 $a_n \leftarrow 0$ \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_lshd}
-\end{figure}
-
-\textbf{Algorithm mp\_lshd.}
-This algorithm multiplies an mp\_int by the $b$'th power of $x$. This is equivalent to multiplying by $\beta^b$. The algorithm differs
-from the other algorithms presented so far as it performs the operation in place instead storing the result in a separate location. The
-motivation behind this change is due to the way this function is typically used. Algorithms such as mp\_add store the result in an optionally
-different third mp\_int because the original inputs are often still required. Algorithm mp\_lshd (\textit{and similarly algorithm mp\_rshd}) is
-typically used on values where the original value is no longer required. The algorithm will return success immediately if
-$b \le 0$ since the rest of algorithm is only valid when $b > 0$.
-
-First the destination $a$ is grown as required to accomodate the result. The counters $i$ and $j$ are used to form a \textit{sliding window} over
-the digits of $a$ of length $b$. The head of the sliding window is at $i$ (\textit{the leading digit}) and the tail at $j$ (\textit{the trailing digit}).
-The loop on step 7 copies the digit from the tail to the head. In each iteration the window is moved down one digit. The last loop on
-step 8 sets the lower $b$ digits to zero.
-
-\newpage
-FIGU,sliding_window,Sliding Window Movement
-
-EXAM,bn_mp_lshd.c
-
-The if statement (line @24,if@) ensures that the $b$ variable is greater than zero since we do not interpret negative
-shift counts properly. The \textbf{used} count is incremented by $b$ before the copy loop begins. This elminates
-the need for an additional variable in the for loop. The variable $top$ (line @42,top@) is an alias
-for the leading digit while $bottom$ (line @45,bottom@) is an alias for the trailing edge. The aliases form a
-window of exactly $b$ digits over the input.
-
-\subsection{Division by $x$}
-
-Division by powers of $x$ is easily achieved by shifting the digits right and removing any that will end up to the right of the zero'th digit.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_rshd}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $a \leftarrow a / \beta^b$ (Divide by $x^b$). \\
-\hline \\
-1. If $b \le 0$ then return. \\
-2. If $a.used \le b$ then do \\
-\hspace{3mm}2.1 Zero $a$. (\textit{mp\_zero}). \\
-\hspace{3mm}2.2 Return. \\
-3. $i \leftarrow 0$ \\
-4. $j \leftarrow b$ \\
-5. for $n$ from 0 to $a.used - b - 1$ do \\
-\hspace{3mm}5.1 $a_i \leftarrow a_j$ \\
-\hspace{3mm}5.2 $i \leftarrow i + 1$ \\
-\hspace{3mm}5.3 $j \leftarrow j + 1$ \\
-6. for $n$ from $a.used - b$ to $a.used - 1$ do \\
-\hspace{3mm}6.1 $a_n \leftarrow 0$ \\
-7. $a.used \leftarrow a.used - b$ \\
-8. Return. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_rshd}
-\end{figure}
-
-\textbf{Algorithm mp\_rshd.}
-This algorithm divides the input in place by the $b$'th power of $x$. It is analogous to dividing by a $\beta^b$ but much quicker since
-it does not require single precision division. This algorithm does not actually return an error code as it cannot fail.
-
-If the input $b$ is less than one the algorithm quickly returns without performing any work. If the \textbf{used} count is less than or equal
-to the shift count $b$ then it will simply zero the input and return.
-
-After the trivial cases of inputs have been handled the sliding window is setup. Much like the case of algorithm mp\_lshd a sliding window that
-is $b$ digits wide is used to copy the digits. Unlike mp\_lshd the window slides in the opposite direction from the trailing to the leading digit.
-Also the digits are copied from the leading to the trailing edge.
-
-Once the window copy is complete the upper digits must be zeroed and the \textbf{used} count decremented.
-
-EXAM,bn_mp_rshd.c
-
-The only noteworthy element of this routine is the lack of a return type since it cannot fail. Like mp\_lshd() we
-form a sliding window except we copy in the other direction. After the window (line @59,for (;@) we then zero
-the upper digits of the input to make sure the result is correct.
-
-\section{Powers of Two}
-
-Now that algorithms for moving single bits as well as whole digits exist algorithms for moving the ``in between'' distances are required. For
-example, to quickly multiply by $2^k$ for any $k$ without using a full multiplier algorithm would prove useful. Instead of performing single
-shifts $k$ times to achieve a multiplication by $2^{\pm k}$ a mixture of whole digit shifting and partial digit shifting is employed.
-
-\subsection{Multiplication by Power of Two}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot 2^b$. \\
-\hline \\
-1. $c \leftarrow a$. (\textit{mp\_copy}) \\
-2. If $c.alloc < c.used + \lfloor b / lg(\beta) \rfloor + 2$ then grow $c$ accordingly. \\
-3. If the reallocation failed return(\textit{MP\_MEM}). \\
-4. If $b \ge lg(\beta)$ then \\
-\hspace{3mm}4.1 $c \leftarrow c \cdot \beta^{\lfloor b / lg(\beta) \rfloor}$ (\textit{mp\_lshd}). \\
-\hspace{3mm}4.2 If step 4.1 failed return(\textit{MP\_MEM}). \\
-5. $d \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-6. If $d \ne 0$ then do \\
-\hspace{3mm}6.1 $mask \leftarrow 2^d$ \\
-\hspace{3mm}6.2 $r \leftarrow 0$ \\
-\hspace{3mm}6.3 for $n$ from $0$ to $c.used - 1$ do \\
-\hspace{6mm}6.3.1 $rr \leftarrow c_n >> (lg(\beta) - d) \mbox{ (mod }mask\mbox{)}$ \\
-\hspace{6mm}6.3.2 $c_n \leftarrow (c_n << d) + r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}6.3.3 $r \leftarrow rr$ \\
-\hspace{3mm}6.4 If $r > 0$ then do \\
-\hspace{6mm}6.4.1 $c_{c.used} \leftarrow r$ \\
-\hspace{6mm}6.4.2 $c.used \leftarrow c.used + 1$ \\
-7. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_mul\_2d.}
-This algorithm multiplies $a$ by $2^b$ and stores the result in $c$. The algorithm uses algorithm mp\_lshd and a derivative of algorithm mp\_mul\_2 to
-quickly compute the product.
-
-First the algorithm will multiply $a$ by $x^{\lfloor b / lg(\beta) \rfloor}$ which will ensure that the remainder multiplicand is less than
-$\beta$. For example, if $b = 37$ and $\beta = 2^{28}$ then this step will multiply by $x$ leaving a multiplication by $2^{37 - 28} = 2^{9}$
-left.
-
-After the digits have been shifted appropriately at most $lg(\beta) - 1$ shifts are left to perform. Step 5 calculates the number of remaining shifts
-required. If it is non-zero a modified shift loop is used to calculate the remaining product.
-Essentially the loop is a generic version of algorithm mp\_mul\_2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
-variable is used to extract the upper $d$ bits to form the carry for the next iteration.
-
-This algorithm is loosely measured as a $O(2n)$ algorithm which means that if the input is $n$-digits that it takes $2n$ ``time'' to
-complete. It is possible to optimize this algorithm down to a $O(n)$ algorithm at a cost of making the algorithm slightly harder to follow.
-
-EXAM,bn_mp_mul_2d.c
-
-The shifting is performed in--place which means the first step (line @24,a != c@) is to copy the input to the
-destination. We avoid calling mp\_copy() by making sure the mp\_ints are different. The destination then
-has to be grown (line @31,grow@) to accomodate the result.
-
-If the shift count $b$ is larger than $lg(\beta)$ then a call to mp\_lshd() is used to handle all of the multiples
-of $lg(\beta)$. Leaving only a remaining shift of $lg(\beta) - 1$ or fewer bits left. Inside the actual shift
-loop (lines @45,if@ to @76,}@) we make use of pre--computed values $shift$ and $mask$. These are used to
-extract the carry bit(s) to pass into the next iteration of the loop. The $r$ and $rr$ variables form a
-chain between consecutive iterations to propagate the carry.
-
-\subsection{Division by Power of Two}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow \lfloor a / 2^b \rfloor, d \leftarrow a \mbox{ (mod }2^b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then do \\
-\hspace{3mm}1.1 $c \leftarrow a$ (\textit{mp\_copy}) \\
-\hspace{3mm}1.2 $d \leftarrow 0$ (\textit{mp\_zero}) \\
-\hspace{3mm}1.3 Return(\textit{MP\_OKAY}). \\
-2. $c \leftarrow a$ \\
-3. $d \leftarrow a \mbox{ (mod }2^b\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-4. If $b \ge lg(\beta)$ then do \\
-\hspace{3mm}4.1 $c \leftarrow \lfloor c/\beta^{\lfloor b/lg(\beta) \rfloor} \rfloor$ (\textit{mp\_rshd}). \\
-5. $k \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-6. If $k \ne 0$ then do \\
-\hspace{3mm}6.1 $mask \leftarrow 2^k$ \\
-\hspace{3mm}6.2 $r \leftarrow 0$ \\
-\hspace{3mm}6.3 for $n$ from $c.used - 1$ to $0$ do \\
-\hspace{6mm}6.3.1 $rr \leftarrow c_n \mbox{ (mod }mask\mbox{)}$ \\
-\hspace{6mm}6.3.2 $c_n \leftarrow (c_n >> k) + (r << (lg(\beta) - k))$ \\
-\hspace{6mm}6.3.3 $r \leftarrow rr$ \\
-7. Clamp excess digits of $c$. (\textit{mp\_clamp}) \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_div\_2d.}
-This algorithm will divide an input $a$ by $2^b$ and produce the quotient and remainder. The algorithm is designed much like algorithm
-mp\_mul\_2d by first using whole digit shifts then single precision shifts. This algorithm will also produce the remainder of the division
-by using algorithm mp\_mod\_2d.
-
-EXAM,bn_mp_div_2d.c
-
-The implementation of algorithm mp\_div\_2d is slightly different than the algorithm specifies. The remainder $d$ may be optionally
-ignored by passing \textbf{NULL} as the pointer to the mp\_int variable. The temporary mp\_int variable $t$ is used to hold the
-result of the remainder operation until the end. This allows $d$ and $a$ to represent the same mp\_int without modifying $a$ before
-the quotient is obtained.
-
-The remainder of the source code is essentially the same as the source code for mp\_mul\_2d. The only significant difference is
-the direction of the shifts.
-
-\subsection{Remainder of Division by Power of Two}
-
-The last algorithm in the series of polynomial basis power of two algorithms is calculating the remainder of division by $2^b$. This
-algorithm benefits from the fact that in twos complement arithmetic $a \mbox{ (mod }2^b\mbox{)}$ is the same as $a$ AND $2^b - 1$.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mod\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow a \mbox{ (mod }2^b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then do \\
-\hspace{3mm}1.1 $c \leftarrow 0$ (\textit{mp\_zero}) \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $b > a.used \cdot lg(\beta)$ then do \\
-\hspace{3mm}2.1 $c \leftarrow a$ (\textit{mp\_copy}) \\
-\hspace{3mm}2.2 Return the result of step 2.1. \\
-3. $c \leftarrow a$ \\
-4. If step 3 failed return(\textit{MP\_MEM}). \\
-5. for $n$ from $\lceil b / lg(\beta) \rceil$ to $c.used$ do \\
-\hspace{3mm}5.1 $c_n \leftarrow 0$ \\
-6. $k \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-7. $c_{\lfloor b / lg(\beta) \rfloor} \leftarrow c_{\lfloor b / lg(\beta) \rfloor} \mbox{ (mod }2^{k}\mbox{)}$. \\
-8. Clamp excess digits of $c$. (\textit{mp\_clamp}) \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mod\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_mod\_2d.}
-This algorithm will quickly calculate the value of $a \mbox{ (mod }2^b\mbox{)}$. First if $b$ is less than or equal to zero the
-result is set to zero. If $b$ is greater than the number of bits in $a$ then it simply copies $a$ to $c$ and returns. Otherwise, $a$
-is copied to $b$, leading digits are removed and the remaining leading digit is trimed to the exact bit count.
-
-EXAM,bn_mp_mod_2d.c
-
-We first avoid cases of $b \le 0$ by simply mp\_zero()'ing the destination in such cases. Next if $2^b$ is larger
-than the input we just mp\_copy() the input and return right away. After this point we know we must actually
-perform some work to produce the remainder.
-
-Recalling that reducing modulo $2^k$ and a binary ``and'' with $2^k - 1$ are numerically equivalent we can quickly reduce
-the number. First we zero any digits above the last digit in $2^b$ (line @41,for@). Next we reduce the
-leading digit of both (line @45,&=@) and then mp\_clamp().
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ] $ & Devise an algorithm that performs $a \cdot 2^b$ for generic values of $b$ \\
- & in $O(n)$ time. \\
- &\\
-$\left [ 3 \right ] $ & Devise an efficient algorithm to multiply by small low hamming \\
- & weight values such as $3$, $5$ and $9$. Extend it to handle all values \\
- & upto $64$ with a hamming weight less than three. \\
- &\\
-$\left [ 2 \right ] $ & Modify the preceding algorithm to handle values of the form \\
- & $2^k - 1$ as well. \\
- &\\
-$\left [ 3 \right ] $ & Using only algorithms mp\_mul\_2, mp\_div\_2 and mp\_add create an \\
- & algorithm to multiply two integers in roughly $O(2n^2)$ time for \\
- & any $n$-bit input. Note that the time of addition is ignored in the \\
- & calculation. \\
- & \\
-$\left [ 5 \right ] $ & Improve the previous algorithm to have a working time of at most \\
- & $O \left (2^{(k-1)}n + \left ({2n^2 \over k} \right ) \right )$ for an appropriate choice of $k$. Again ignore \\
- & the cost of addition. \\
- & \\
-$\left [ 2 \right ] $ & Devise a chart to find optimal values of $k$ for the previous problem \\
- & for $n = 64 \ldots 1024$ in steps of $64$. \\
- & \\
-$\left [ 2 \right ] $ & Using only algorithms mp\_abs and mp\_sub devise another method for \\
- & calculating the result of a signed comparison. \\
- &
-\end{tabular}
-
-\chapter{Multiplication and Squaring}
-\section{The Multipliers}
-For most number theoretic problems including certain public key cryptographic algorithms, the ``multipliers'' form the most important subset of
-algorithms of any multiple precision integer package. The set of multiplier algorithms include integer multiplication, squaring and modular reduction
-where in each of the algorithms single precision multiplication is the dominant operation performed. This chapter will discuss integer multiplication
-and squaring, leaving modular reductions for the subsequent chapter.
-
-The importance of the multiplier algorithms is for the most part driven by the fact that certain popular public key algorithms are based on modular
-exponentiation, that is computing $d \equiv a^b \mbox{ (mod }c\mbox{)}$ for some arbitrary choice of $a$, $b$, $c$ and $d$. During a modular
-exponentiation the majority\footnote{Roughly speaking a modular exponentiation will spend about 40\% of the time performing modular reductions,
-35\% of the time performing squaring and 25\% of the time performing multiplications.} of the processor time is spent performing single precision
-multiplications.
-
-For centuries general purpose multiplication has required a lengthly $O(n^2)$ process, whereby each digit of one multiplicand has to be multiplied
-against every digit of the other multiplicand. Traditional long-hand multiplication is based on this process; while the techniques can differ the
-overall algorithm used is essentially the same. Only ``recently'' have faster algorithms been studied. First Karatsuba multiplication was discovered in
-1962. This algorithm can multiply two numbers with considerably fewer single precision multiplications when compared to the long-hand approach.
-This technique led to the discovery of polynomial basis algorithms (\textit{good reference?}) and subquently Fourier Transform based solutions.
-
-\section{Multiplication}
-\subsection{The Baseline Multiplication}
-\label{sec:basemult}
-\index{baseline multiplication}
-Computing the product of two integers in software can be achieved using a trivial adaptation of the standard $O(n^2)$ long-hand multiplication
-algorithm that school children are taught. The algorithm is considered an $O(n^2)$ algorithm since for two $n$-digit inputs $n^2$ single precision
-multiplications are required. More specifically for a $m$ and $n$ digit input $m \cdot n$ single precision multiplications are required. To
-simplify most discussions, it will be assumed that the inputs have comparable number of digits.
-
-The ``baseline multiplication'' algorithm is designed to act as the ``catch-all'' algorithm, only to be used when the faster algorithms cannot be
-used. This algorithm does not use any particularly interesting optimizations and should ideally be avoided if possible. One important
-facet of this algorithm, is that it has been modified to only produce a certain amount of output digits as resolution. The importance of this
-modification will become evident during the discussion of Barrett modular reduction. Recall that for a $n$ and $m$ digit input the product
-will be at most $n + m$ digits. Therefore, this algorithm can be reduced to a full multiplier by having it produce $n + m$ digits of the product.
-
-Recall from ~GAMMA~ the definition of $\gamma$ as the number of bits in the type \textbf{mp\_digit}. We shall now extend the variable set to
-include $\alpha$ which shall represent the number of bits in the type \textbf{mp\_word}. This implies that $2^{\alpha} > 2 \cdot \beta^2$. The
-constant $\delta = 2^{\alpha - 2lg(\beta)}$ will represent the maximal weight of any column in a product (\textit{see ~COMBA~ for more information}).
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_mul\_digs}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and an integer $digs$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert \mbox{ (mod }\beta^{digs}\mbox{)}$. \\
-\hline \\
-1. If min$(a.used, b.used) < \delta$ then do \\
-\hspace{3mm}1.1 Calculate $c = \vert a \vert \cdot \vert b \vert$ by the Comba method (\textit{see algorithm~\ref{fig:COMBAMULT}}). \\
-\hspace{3mm}1.2 Return the result of step 1.1 \\
-\\
-Allocate and initialize a temporary mp\_int. \\
-2. Init $t$ to be of size $digs$ \\
-3. If step 2 failed return(\textit{MP\_MEM}). \\
-4. $t.used \leftarrow digs$ \\
-\\
-Compute the product. \\
-5. for $ix$ from $0$ to $a.used - 1$ do \\
-\hspace{3mm}5.1 $u \leftarrow 0$ \\
-\hspace{3mm}5.2 $pb \leftarrow \mbox{min}(b.used, digs - ix)$ \\
-\hspace{3mm}5.3 If $pb < 1$ then goto step 6. \\
-\hspace{3mm}5.4 for $iy$ from $0$ to $pb - 1$ do \\
-\hspace{6mm}5.4.1 $\hat r \leftarrow t_{iy + ix} + a_{ix} \cdot b_{iy} + u$ \\
-\hspace{6mm}5.4.2 $t_{iy + ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}5.4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}5.5 if $ix + pb < digs$ then do \\
-\hspace{6mm}5.5.1 $t_{ix + pb} \leftarrow u$ \\
-6. Clamp excess digits of $t$. \\
-7. Swap $c$ with $t$ \\
-8. Clear $t$ \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_mul\_digs}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_mul\_digs.}
-This algorithm computes the unsigned product of two inputs $a$ and $b$, limited to an output precision of $digs$ digits. While it may seem
-a bit awkward to modify the function from its simple $O(n^2)$ description, the usefulness of partial multipliers will arise in a subsequent
-algorithm. The algorithm is loosely based on algorithm 14.12 from \cite[pp. 595]{HAC} and is similar to Algorithm M of Knuth \cite[pp. 268]{TAOCPV2}.
-Algorithm s\_mp\_mul\_digs differs from these cited references since it can produce a variable output precision regardless of the precision of the
-inputs.
-
-The first thing this algorithm checks for is whether a Comba multiplier can be used instead. If the minimum digit count of either
-input is less than $\delta$, then the Comba method may be used instead. After the Comba method is ruled out, the baseline algorithm begins. A
-temporary mp\_int variable $t$ is used to hold the intermediate result of the product. This allows the algorithm to be used to
-compute products when either $a = c$ or $b = c$ without overwriting the inputs.
-
-All of step 5 is the infamous $O(n^2)$ multiplication loop slightly modified to only produce upto $digs$ digits of output. The $pb$ variable
-is given the count of digits to read from $b$ inside the nested loop. If $pb \le 1$ then no more output digits can be produced and the algorithm
-will exit the loop. The best way to think of the loops are as a series of $pb \times 1$ multiplications. That is, in each pass of the
-innermost loop $a_{ix}$ is multiplied against $b$ and the result is added (\textit{with an appropriate shift}) to $t$.
-
-For example, consider multiplying $576$ by $241$. That is equivalent to computing $10^0(1)(576) + 10^1(4)(576) + 10^2(2)(576)$ which is best
-visualized in the following table.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|c|l|}
-\hline && & 5 & 7 & 6 & \\
-\hline $\times$&& & 2 & 4 & 1 & \\
-\hline &&&&&&\\
- && & 5 & 7 & 6 & $10^0(1)(576)$ \\
- &2 & 3 & 6 & 1 & 6 & $10^1(4)(576) + 10^0(1)(576)$ \\
- 1 & 3 & 8 & 8 & 1 & 6 & $10^2(2)(576) + 10^1(4)(576) + 10^0(1)(576)$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Long-Hand Multiplication Diagram}
-\end{figure}
-
-Each row of the product is added to the result after being shifted to the left (\textit{multiplied by a power of the radix}) by the appropriate
-count. That is in pass $ix$ of the inner loop the product is added starting at the $ix$'th digit of the reult.
-
-Step 5.4.1 introduces the hat symbol (\textit{e.g. $\hat r$}) which represents a double precision variable. The multiplication on that step
-is assumed to be a double wide output single precision multiplication. That is, two single precision variables are multiplied to produce a
-double precision result. The step is somewhat optimized from a long-hand multiplication algorithm because the carry from the addition in step
-5.4.1 is propagated through the nested loop. If the carry was not propagated immediately it would overflow the single precision digit
-$t_{ix+iy}$ and the result would be lost.
-
-At step 5.5 the nested loop is finished and any carry that was left over should be forwarded. The carry does not have to be added to the $ix+pb$'th
-digit since that digit is assumed to be zero at this point. However, if $ix + pb \ge digs$ the carry is not set as it would make the result
-exceed the precision requested.
-
-EXAM,bn_s_mp_mul_digs.c
-
-First we determine (line @30,if@) if the Comba method can be used first since it's faster. The conditions for
-sing the Comba routine are that min$(a.used, b.used) < \delta$ and the number of digits of output is less than
-\textbf{MP\_WARRAY}. This new constant is used to control the stack usage in the Comba routines. By default it is
-set to $\delta$ but can be reduced when memory is at a premium.
-
-If we cannot use the Comba method we proceed to setup the baseline routine. We allocate the the destination mp\_int
-$t$ (line @36,init@) to the exact size of the output to avoid further re--allocations. At this point we now
-begin the $O(n^2)$ loop.
-
-This implementation of multiplication has the caveat that it can be trimmed to only produce a variable number of
-digits as output. In each iteration of the outer loop the $pb$ variable is set (line @48,MIN@) to the maximum
-number of inner loop iterations.
-
-Inside the inner loop we calculate $\hat r$ as the mp\_word product of the two mp\_digits and the addition of the
-carry from the previous iteration. A particularly important observation is that most modern optimizing
-C compilers (GCC for instance) can recognize that a $N \times N \rightarrow 2N$ multiplication is all that
-is required for the product. In x86 terms for example, this means using the MUL instruction.
-
-Each digit of the product is stored in turn (line @68,tmpt@) and the carry propagated (line @71,>>@) to the
-next iteration.
-
-\subsection{Faster Multiplication by the ``Comba'' Method}
-MARK,COMBA
-
-One of the huge drawbacks of the ``baseline'' algorithms is that at the $O(n^2)$ level the carry must be
-computed and propagated upwards. This makes the nested loop very sequential and hard to unroll and implement
-in parallel. The ``Comba'' \cite{COMBA} method is named after little known (\textit{in cryptographic venues}) Paul G.
-Comba who described a method of implementing fast multipliers that do not require nested carry fixup operations. As an
-interesting aside it seems that Paul Barrett describes a similar technique in his 1986 paper \cite{BARRETT} written
-five years before.
-
-At the heart of the Comba technique is once again the long-hand algorithm. Except in this case a slight
-twist is placed on how the columns of the result are produced. In the standard long-hand algorithm rows of products
-are produced then added together to form the final result. In the baseline algorithm the columns are added together
-after each iteration to get the result instantaneously.
-
-In the Comba algorithm the columns of the result are produced entirely independently of each other. That is at
-the $O(n^2)$ level a simple multiplication and addition step is performed. The carries of the columns are propagated
-after the nested loop to reduce the amount of work requiored. Succintly the first step of the algorithm is to compute
-the product vector $\vec x$ as follows.
-
-\begin{equation}
-\vec x_n = \sum_{i+j = n} a_ib_j, \forall n \in \lbrace 0, 1, 2, \ldots, i + j \rbrace
-\end{equation}
-
-Where $\vec x_n$ is the $n'th$ column of the output vector. Consider the following example which computes the vector $\vec x$ for the multiplication
-of $576$ and $241$.
-
-\newpage\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|c|}
- \hline & & 5 & 7 & 6 & First Input\\
- \hline $\times$ & & 2 & 4 & 1 & Second Input\\
-\hline & & $1 \cdot 5 = 5$ & $1 \cdot 7 = 7$ & $1 \cdot 6 = 6$ & First pass \\
- & $4 \cdot 5 = 20$ & $4 \cdot 7+5=33$ & $4 \cdot 6+7=31$ & 6 & Second pass \\
- $2 \cdot 5 = 10$ & $2 \cdot 7 + 20 = 34$ & $2 \cdot 6+33=45$ & 31 & 6 & Third pass \\
-\hline 10 & 34 & 45 & 31 & 6 & Final Result \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Comba Multiplication Diagram}
-\end{figure}
-
-At this point the vector $x = \left < 10, 34, 45, 31, 6 \right >$ is the result of the first step of the Comba multipler.
-Now the columns must be fixed by propagating the carry upwards. The resultant vector will have one extra dimension over the input vector which is
-congruent to adding a leading zero digit.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Comba Fixup}. \\
-\textbf{Input}. Vector $\vec x$ of dimension $k$ \\
-\textbf{Output}. Vector $\vec x$ such that the carries have been propagated. \\
-\hline \\
-1. for $n$ from $0$ to $k - 1$ do \\
-\hspace{3mm}1.1 $\vec x_{n+1} \leftarrow \vec x_{n+1} + \lfloor \vec x_{n}/\beta \rfloor$ \\
-\hspace{3mm}1.2 $\vec x_{n} \leftarrow \vec x_{n} \mbox{ (mod }\beta\mbox{)}$ \\
-2. Return($\vec x$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Comba Fixup}
-\end{figure}
-
-With that algorithm and $k = 5$ and $\beta = 10$ the following vector is produced $\vec x= \left < 1, 3, 8, 8, 1, 6 \right >$. In this case
-$241 \cdot 576$ is in fact $138816$ and the procedure succeeded. If the algorithm is correct and as will be demonstrated shortly more
-efficient than the baseline algorithm why not simply always use this algorithm?
-
-\subsubsection{Column Weight.}
-At the nested $O(n^2)$ level the Comba method adds the product of two single precision variables to each column of the output
-independently. A serious obstacle is if the carry is lost, due to lack of precision before the algorithm has a chance to fix
-the carries. For example, in the multiplication of two three-digit numbers the third column of output will be the sum of
-three single precision multiplications. If the precision of the accumulator for the output digits is less then $3 \cdot (\beta - 1)^2$ then
-an overflow can occur and the carry information will be lost. For any $m$ and $n$ digit inputs the maximum weight of any column is
-min$(m, n)$ which is fairly obvious.
-
-The maximum number of terms in any column of a product is known as the ``column weight'' and strictly governs when the algorithm can be used. Recall
-from earlier that a double precision type has $\alpha$ bits of resolution and a single precision digit has $lg(\beta)$ bits of precision. Given these
-two quantities we must not violate the following
-
-\begin{equation}
-k \cdot \left (\beta - 1 \right )^2 < 2^{\alpha}
-\end{equation}
-
-Which reduces to
-
-\begin{equation}
-k \cdot \left ( \beta^2 - 2\beta + 1 \right ) < 2^{\alpha}
-\end{equation}
-
-Let $\rho = lg(\beta)$ represent the number of bits in a single precision digit. By further re-arrangement of the equation the final solution is
-found.
-
-\begin{equation}
-k < {{2^{\alpha}} \over {\left (2^{2\rho} - 2^{\rho + 1} + 1 \right )}}
-\end{equation}
-
-The defaults for LibTomMath are $\beta = 2^{28}$ and $\alpha = 2^{64}$ which means that $k$ is bounded by $k < 257$. In this configuration
-the smaller input may not have more than $256$ digits if the Comba method is to be used. This is quite satisfactory for most applications since
-$256$ digits would allow for numbers in the range of $0 \le x < 2^{7168}$ which, is much larger than most public key cryptographic algorithms require.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_s\_mp\_mul\_digs}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and an integer $digs$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert \mbox{ (mod }\beta^{digs}\mbox{)}$. \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} single precision digits named $W$ on the stack. \\
-1. If $c.alloc < digs$ then grow $c$ to $digs$ digits. (\textit{mp\_grow}) \\
-2. If step 1 failed return(\textit{MP\_MEM}).\\
-\\
-3. $pa \leftarrow \mbox{MIN}(digs, a.used + b.used)$ \\
-\\
-4. $\_ \hat W \leftarrow 0$ \\
-5. for $ix$ from 0 to $pa - 1$ do \\
-\hspace{3mm}5.1 $ty \leftarrow \mbox{MIN}(b.used - 1, ix)$ \\
-\hspace{3mm}5.2 $tx \leftarrow ix - ty$ \\
-\hspace{3mm}5.3 $iy \leftarrow \mbox{MIN}(a.used - tx, ty + 1)$ \\
-\hspace{3mm}5.4 for $iz$ from 0 to $iy - 1$ do \\
-\hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
-\hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
-\hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
-\\
-6. $oldused \leftarrow c.used$ \\
-7. $c.used \leftarrow digs$ \\
-8. for $ix$ from $0$ to $pa$ do \\
-\hspace{3mm}8.1 $c_{ix} \leftarrow W_{ix}$ \\
-9. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
-\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
-\\
-10. Clamp $c$. \\
-11. Return MP\_OKAY. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_s\_mp\_mul\_digs}
-\label{fig:COMBAMULT}
-\end{figure}
-
-\textbf{Algorithm fast\_s\_mp\_mul\_digs.}
-This algorithm performs the unsigned multiplication of $a$ and $b$ using the Comba method limited to $digs$ digits of precision.
-
-The outer loop of this algorithm is more complicated than that of the baseline multiplier. This is because on the inside of the
-loop we want to produce one column per pass. This allows the accumulator $\_ \hat W$ to be placed in CPU registers and
-reduce the memory bandwidth to two \textbf{mp\_digit} reads per iteration.
-
-The $ty$ variable is set to the minimum count of $ix$ or the number of digits in $b$. That way if $a$ has more digits than
-$b$ this will be limited to $b.used - 1$. The $tx$ variable is set to the to the distance past $b.used$ the variable
-$ix$ is. This is used for the immediately subsequent statement where we find $iy$.
-
-The variable $iy$ is the minimum digits we can read from either $a$ or $b$ before running out. Computing one column at a time
-means we have to scan one integer upwards and the other downwards. $a$ starts at $tx$ and $b$ starts at $ty$. In each
-pass we are producing the $ix$'th output column and we note that $tx + ty = ix$. As we move $tx$ upwards we have to
-move $ty$ downards so the equality remains valid. The $iy$ variable is the number of iterations until
-$tx \ge a.used$ or $ty < 0$ occurs.
-
-After every inner pass we store the lower half of the accumulator into $W_{ix}$ and then propagate the carry of the accumulator
-into the next round by dividing $\_ \hat W$ by $\beta$.
-
-To measure the benefits of the Comba method over the baseline method consider the number of operations that are required. If the
-cost in terms of time of a multiply and addition is $p$ and the cost of a carry propagation is $q$ then a baseline multiplication would require
-$O \left ((p + q)n^2 \right )$ time to multiply two $n$-digit numbers. The Comba method requires only $O(pn^2 + qn)$ time, however in practice,
-the speed increase is actually much more. With $O(n)$ space the algorithm can be reduced to $O(pn + qn)$ time by implementing the $n$ multiply
-and addition operations in the nested loop in parallel.
-
-EXAM,bn_fast_s_mp_mul_digs.c
-
-As per the pseudo--code we first calculate $pa$ (line @47,MIN@) as the number of digits to output. Next we begin the outer loop
-to produce the individual columns of the product. We use the two aliases $tmpx$ and $tmpy$ (lines @61,tmpx@, @62,tmpy@) to point
-inside the two multiplicands quickly.
-
-The inner loop (lines @70,for@ to @72,}@) of this implementation is where the tradeoff come into play. Originally this comba
-implementation was ``row--major'' which means it adds to each of the columns in each pass. After the outer loop it would then fix
-the carries. This was very fast except it had an annoying drawback. You had to read a mp\_word and two mp\_digits and write
-one mp\_word per iteration. On processors such as the Athlon XP and P4 this did not matter much since the cache bandwidth
-is very high and it can keep the ALU fed with data. It did, however, matter on older and embedded cpus where cache is often
-slower and also often doesn't exist. This new algorithm only performs two reads per iteration under the assumption that the
-compiler has aliased $\_ \hat W$ to a CPU register.
-
-After the inner loop we store the current accumulator in $W$ and shift $\_ \hat W$ (lines @75,W[ix]@, @78,>>@) to forward it as
-a carry for the next pass. After the outer loop we use the final carry (line @82,W[ix]@) as the last digit of the product.
-
-\subsection{Polynomial Basis Multiplication}
-To break the $O(n^2)$ barrier in multiplication requires a completely different look at integer multiplication. In the following algorithms
-the use of polynomial basis representation for two integers $a$ and $b$ as $f(x) = \sum_{i=0}^{n} a_i x^i$ and
-$g(x) = \sum_{i=0}^{n} b_i x^i$ respectively, is required. In this system both $f(x)$ and $g(x)$ have $n + 1$ terms and are of the $n$'th degree.
-
-The product $a \cdot b \equiv f(x)g(x)$ is the polynomial $W(x) = \sum_{i=0}^{2n} w_i x^i$. The coefficients $w_i$ will
-directly yield the desired product when $\beta$ is substituted for $x$. The direct solution to solve for the $2n + 1$ coefficients
-requires $O(n^2)$ time and would in practice be slower than the Comba technique.
-
-However, numerical analysis theory indicates that only $2n + 1$ distinct points in $W(x)$ are required to determine the values of the $2n + 1$ unknown
-coefficients. This means by finding $\zeta_y = W(y)$ for $2n + 1$ small values of $y$ the coefficients of $W(x)$ can be found with
-Gaussian elimination. This technique is also occasionally refered to as the \textit{interpolation technique} (\textit{references please...}) since in
-effect an interpolation based on $2n + 1$ points will yield a polynomial equivalent to $W(x)$.
-
-The coefficients of the polynomial $W(x)$ are unknown which makes finding $W(y)$ for any value of $y$ impossible. However, since
-$W(x) = f(x)g(x)$ the equivalent $\zeta_y = f(y) g(y)$ can be used in its place. The benefit of this technique stems from the
-fact that $f(y)$ and $g(y)$ are much smaller than either $a$ or $b$ respectively. As a result finding the $2n + 1$ relations required
-by multiplying $f(y)g(y)$ involves multiplying integers that are much smaller than either of the inputs.
-
-When picking points to gather relations there are always three obvious points to choose, $y = 0, 1$ and $ \infty$. The $\zeta_0$ term
-is simply the product $W(0) = w_0 = a_0 \cdot b_0$. The $\zeta_1$ term is the product
-$W(1) = \left (\sum_{i = 0}^{n} a_i \right ) \left (\sum_{i = 0}^{n} b_i \right )$. The third point $\zeta_{\infty}$ is less obvious but rather
-simple to explain. The $2n + 1$'th coefficient of $W(x)$ is numerically equivalent to the most significant column in an integer multiplication.
-The point at $\infty$ is used symbolically to represent the most significant column, that is $W(\infty) = w_{2n} = a_nb_n$. Note that the
-points at $y = 0$ and $\infty$ yield the coefficients $w_0$ and $w_{2n}$ directly.
-
-If more points are required they should be of small values and powers of two such as $2^q$ and the related \textit{mirror points}
-$\left (2^q \right )^{2n} \cdot \zeta_{2^{-q}}$ for small values of $q$. The term ``mirror point'' stems from the fact that
-$\left (2^q \right )^{2n} \cdot \zeta_{2^{-q}}$ can be calculated in the exact opposite fashion as $\zeta_{2^q}$. For
-example, when $n = 2$ and $q = 1$ then following two equations are equivalent to the point $\zeta_{2}$ and its mirror.
-
-\begin{eqnarray}
-\zeta_{2} = f(2)g(2) = (4a_2 + 2a_1 + a_0)(4b_2 + 2b_1 + b_0) \nonumber \\
-16 \cdot \zeta_{1 \over 2} = 4f({1\over 2}) \cdot 4g({1 \over 2}) = (a_2 + 2a_1 + 4a_0)(b_2 + 2b_1 + 4b_0)
-\end{eqnarray}
-
-Using such points will allow the values of $f(y)$ and $g(y)$ to be independently calculated using only left shifts. For example, when $n = 2$ the
-polynomial $f(2^q)$ is equal to $2^q((2^qa_2) + a_1) + a_0$. This technique of polynomial representation is known as Horner's method.
-
-As a general rule of the algorithm when the inputs are split into $n$ parts each there are $2n - 1$ multiplications. Each multiplication is of
-multiplicands that have $n$ times fewer digits than the inputs. The asymptotic running time of this algorithm is
-$O \left ( k^{lg_n(2n - 1)} \right )$ for $k$ digit inputs (\textit{assuming they have the same number of digits}). Figure~\ref{fig:exponent}
-summarizes the exponents for various values of $n$.
-
-\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Split into $n$ Parts} & \textbf{Exponent} & \textbf{Notes}\\
-\hline $2$ & $1.584962501$ & This is Karatsuba Multiplication. \\
-\hline $3$ & $1.464973520$ & This is Toom-Cook Multiplication. \\
-\hline $4$ & $1.403677461$ &\\
-\hline $5$ & $1.365212389$ &\\
-\hline $10$ & $1.278753601$ &\\
-\hline $100$ & $1.149426538$ &\\
-\hline $1000$ & $1.100270931$ &\\
-\hline $10000$ & $1.075252070$ &\\
-\hline
-\end{tabular}
-\end{center}
-\caption{Asymptotic Running Time of Polynomial Basis Multiplication}
-\label{fig:exponent}
-\end{figure}
-
-At first it may seem like a good idea to choose $n = 1000$ since the exponent is approximately $1.1$. However, the overhead
-of solving for the 2001 terms of $W(x)$ will certainly consume any savings the algorithm could offer for all but exceedingly large
-numbers.
-
-\subsubsection{Cutoff Point}
-The polynomial basis multiplication algorithms all require fewer single precision multiplications than a straight Comba approach. However,
-the algorithms incur an overhead (\textit{at the $O(n)$ work level}) since they require a system of equations to be solved. This makes the
-polynomial basis approach more costly to use with small inputs.
-
-Let $m$ represent the number of digits in the multiplicands (\textit{assume both multiplicands have the same number of digits}). There exists a
-point $y$ such that when $m < y$ the polynomial basis algorithms are more costly than Comba, when $m = y$ they are roughly the same cost and
-when $m > y$ the Comba methods are slower than the polynomial basis algorithms.
-
-The exact location of $y$ depends on several key architectural elements of the computer platform in question.
-
-\begin{enumerate}
-\item The ratio of clock cycles for single precision multiplication versus other simpler operations such as addition, shifting, etc. For example
-on the AMD Athlon the ratio is roughly $17 : 1$ while on the Intel P4 it is $29 : 1$. The higher the ratio in favour of multiplication the lower
-the cutoff point $y$ will be.
-
-\item The complexity of the linear system of equations (\textit{for the coefficients of $W(x)$}) is. Generally speaking as the number of splits
-grows the complexity grows substantially. Ideally solving the system will only involve addition, subtraction and shifting of integers. This
-directly reflects on the ratio previous mentioned.
-
-\item To a lesser extent memory bandwidth and function call overheads. Provided the values are in the processor cache this is less of an
-influence over the cutoff point.
-
-\end{enumerate}
-
-A clean cutoff point separation occurs when a point $y$ is found such that all of the cutoff point conditions are met. For example, if the point
-is too low then there will be values of $m$ such that $m > y$ and the Comba method is still faster. Finding the cutoff points is fairly simple when
-a high resolution timer is available.
-
-\subsection{Karatsuba Multiplication}
-Karatsuba \cite{KARA} multiplication when originally proposed in 1962 was among the first set of algorithms to break the $O(n^2)$ barrier for
-general purpose multiplication. Given two polynomial basis representations $f(x) = ax + b$ and $g(x) = cx + d$, Karatsuba proved with
-light algebra \cite{KARAP} that the following polynomial is equivalent to multiplication of the two integers the polynomials represent.
-
-\begin{equation}
-f(x) \cdot g(x) = acx^2 + ((a + b)(c + d) - (ac + bd))x + bd
-\end{equation}
-
-Using the observation that $ac$ and $bd$ could be re-used only three half sized multiplications would be required to produce the product. Applying
-this algorithm recursively, the work factor becomes $O(n^{lg(3)})$ which is substantially better than the work factor $O(n^2)$ of the Comba technique. It turns
-out what Karatsuba did not know or at least did not publish was that this is simply polynomial basis multiplication with the points
-$\zeta_0$, $\zeta_{\infty}$ and $\zeta_{1}$. Consider the resultant system of equations.
-
-\begin{center}
-\begin{tabular}{rcrcrcrc}
-$\zeta_{0}$ & $=$ & & & & & $w_0$ \\
-$\zeta_{1}$ & $=$ & $w_2$ & $+$ & $w_1$ & $+$ & $w_0$ \\
-$\zeta_{\infty}$ & $=$ & $w_2$ & & & & \\
-\end{tabular}
-\end{center}
-
-By adding the first and last equation to the equation in the middle the term $w_1$ can be isolated and all three coefficients solved for. The simplicity
-of this system of equations has made Karatsuba fairly popular. In fact the cutoff point is often fairly low\footnote{With LibTomMath 0.18 it is 70 and 109 digits for the Intel P4 and AMD Athlon respectively.}
-making it an ideal algorithm to speed up certain public key cryptosystems such as RSA and Diffie-Hellman.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_karatsuba\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert$ \\
-\hline \\
-1. Init the following mp\_int variables: $x0$, $x1$, $y0$, $y1$, $t1$, $x0y0$, $x1y1$.\\
-2. If step 2 failed then return(\textit{MP\_MEM}). \\
-\\
-Split the input. e.g. $a = x1 \cdot \beta^B + x0$ \\
-3. $B \leftarrow \mbox{min}(a.used, b.used)/2$ \\
-4. $x0 \leftarrow a \mbox{ (mod }\beta^B\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-5. $y0 \leftarrow b \mbox{ (mod }\beta^B\mbox{)}$ \\
-6. $x1 \leftarrow \lfloor a / \beta^B \rfloor$ (\textit{mp\_rshd}) \\
-7. $y1 \leftarrow \lfloor b / \beta^B \rfloor$ \\
-\\
-Calculate the three products. \\
-8. $x0y0 \leftarrow x0 \cdot y0$ (\textit{mp\_mul}) \\
-9. $x1y1 \leftarrow x1 \cdot y1$ \\
-10. $t1 \leftarrow x1 + x0$ (\textit{mp\_add}) \\
-11. $x0 \leftarrow y1 + y0$ \\
-12. $t1 \leftarrow t1 \cdot x0$ \\
-\\
-Calculate the middle term. \\
-13. $x0 \leftarrow x0y0 + x1y1$ \\
-14. $t1 \leftarrow t1 - x0$ (\textit{s\_mp\_sub}) \\
-\\
-Calculate the final product. \\
-15. $t1 \leftarrow t1 \cdot \beta^B$ (\textit{mp\_lshd}) \\
-16. $x1y1 \leftarrow x1y1 \cdot \beta^{2B}$ \\
-17. $t1 \leftarrow x0y0 + t1$ \\
-18. $c \leftarrow t1 + x1y1$ \\
-19. Clear all of the temporary variables. \\
-20. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_karatsuba\_mul}
-\end{figure}
-
-\textbf{Algorithm mp\_karatsuba\_mul.}
-This algorithm computes the unsigned product of two inputs using the Karatsuba multiplication algorithm. It is loosely based on the description
-from Knuth \cite[pp. 294-295]{TAOCPV2}.
-
-\index{radix point}
-In order to split the two inputs into their respective halves, a suitable \textit{radix point} must be chosen. The radix point chosen must
-be used for both of the inputs meaning that it must be smaller than the smallest input. Step 3 chooses the radix point $B$ as half of the
-smallest input \textbf{used} count. After the radix point is chosen the inputs are split into lower and upper halves. Step 4 and 5
-compute the lower halves. Step 6 and 7 computer the upper halves.
-
-After the halves have been computed the three intermediate half-size products must be computed. Step 8 and 9 compute the trivial products
-$x0 \cdot y0$ and $x1 \cdot y1$. The mp\_int $x0$ is used as a temporary variable after $x1 + x0$ has been computed. By using $x0$ instead
-of an additional temporary variable, the algorithm can avoid an addition memory allocation operation.
-
-The remaining steps 13 through 18 compute the Karatsuba polynomial through a variety of digit shifting and addition operations.
-
-EXAM,bn_mp_karatsuba_mul.c
-
-The new coding element in this routine, not seen in previous routines, is the usage of goto statements. The conventional
-wisdom is that goto statements should be avoided. This is generally true, however when every single function call can fail, it makes sense
-to handle error recovery with a single piece of code. Lines @61,if@ to @75,if@ handle initializing all of the temporary variables
-required. Note how each of the if statements goes to a different label in case of failure. This allows the routine to correctly free only
-the temporaries that have been successfully allocated so far.
-
-The temporary variables are all initialized using the mp\_init\_size routine since they are expected to be large. This saves the
-additional reallocation that would have been necessary. Also $x0$, $x1$, $y0$ and $y1$ have to be able to hold at least their respective
-number of digits for the next section of code.
-
-The first algebraic portion of the algorithm is to split the two inputs into their halves. However, instead of using mp\_mod\_2d and mp\_rshd
-to extract the halves, the respective code has been placed inline within the body of the function. To initialize the halves, the \textbf{used} and
-\textbf{sign} members are copied first. The first for loop on line @98,for@ copies the lower halves. Since they are both the same magnitude it
-is simpler to calculate both lower halves in a single loop. The for loop on lines @104,for@ and @109,for@ calculate the upper halves $x1$ and
-$y1$ respectively.
-
-By inlining the calculation of the halves, the Karatsuba multiplier has a slightly lower overhead and can be used for smaller magnitude inputs.
-
-When line @152,err@ is reached, the algorithm has completed succesfully. The ``error status'' variable $err$ is set to \textbf{MP\_OKAY} so that
-the same code that handles errors can be used to clear the temporary variables and return.
-
-\subsection{Toom-Cook $3$-Way Multiplication}
-Toom-Cook $3$-Way \cite{TOOM} multiplication is essentially the polynomial basis algorithm for $n = 2$ except that the points are
-chosen such that $\zeta$ is easy to compute and the resulting system of equations easy to reduce. Here, the points $\zeta_{0}$,
-$16 \cdot \zeta_{1 \over 2}$, $\zeta_1$, $\zeta_2$ and $\zeta_{\infty}$ make up the five required points to solve for the coefficients
-of the $W(x)$.
-
-With the five relations that Toom-Cook specifies, the following system of equations is formed.
-
-\begin{center}
-\begin{tabular}{rcrcrcrcrcr}
-$\zeta_0$ & $=$ & $0w_4$ & $+$ & $0w_3$ & $+$ & $0w_2$ & $+$ & $0w_1$ & $+$ & $1w_0$ \\
-$16 \cdot \zeta_{1 \over 2}$ & $=$ & $1w_4$ & $+$ & $2w_3$ & $+$ & $4w_2$ & $+$ & $8w_1$ & $+$ & $16w_0$ \\
-$\zeta_1$ & $=$ & $1w_4$ & $+$ & $1w_3$ & $+$ & $1w_2$ & $+$ & $1w_1$ & $+$ & $1w_0$ \\
-$\zeta_2$ & $=$ & $16w_4$ & $+$ & $8w_3$ & $+$ & $4w_2$ & $+$ & $2w_1$ & $+$ & $1w_0$ \\
-$\zeta_{\infty}$ & $=$ & $1w_4$ & $+$ & $0w_3$ & $+$ & $0w_2$ & $+$ & $0w_1$ & $+$ & $0w_0$ \\
-\end{tabular}
-\end{center}
-
-A trivial solution to this matrix requires $12$ subtractions, two multiplications by a small power of two, two divisions by a small power
-of two, two divisions by three and one multiplication by three. All of these $19$ sub-operations require less than quadratic time, meaning that
-the algorithm can be faster than a baseline multiplication. However, the greater complexity of this algorithm places the cutoff point
-(\textbf{TOOM\_MUL\_CUTOFF}) where Toom-Cook becomes more efficient much higher than the Karatsuba cutoff point.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toom\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b $ \\
-\hline \\
-Split $a$ and $b$ into three pieces. E.g. $a = a_2 \beta^{2k} + a_1 \beta^{k} + a_0$ \\
-1. $k \leftarrow \lfloor \mbox{min}(a.used, b.used) / 3 \rfloor$ \\
-2. $a_0 \leftarrow a \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-3. $a_1 \leftarrow \lfloor a / \beta^k \rfloor$, $a_1 \leftarrow a_1 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-4. $a_2 \leftarrow \lfloor a / \beta^{2k} \rfloor$, $a_2 \leftarrow a_2 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-5. $b_0 \leftarrow a \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-6. $b_1 \leftarrow \lfloor a / \beta^k \rfloor$, $b_1 \leftarrow b_1 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-7. $b_2 \leftarrow \lfloor a / \beta^{2k} \rfloor$, $b_2 \leftarrow b_2 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-\\
-Find the five equations for $w_0, w_1, ..., w_4$. \\
-8. $w_0 \leftarrow a_0 \cdot b_0$ \\
-9. $w_4 \leftarrow a_2 \cdot b_2$ \\
-10. $tmp_1 \leftarrow 2 \cdot a_0$, $tmp_1 \leftarrow a_1 + tmp_1$, $tmp_1 \leftarrow 2 \cdot tmp_1$, $tmp_1 \leftarrow tmp_1 + a_2$ \\
-11. $tmp_2 \leftarrow 2 \cdot b_0$, $tmp_2 \leftarrow b_1 + tmp_2$, $tmp_2 \leftarrow 2 \cdot tmp_2$, $tmp_2 \leftarrow tmp_2 + b_2$ \\
-12. $w_1 \leftarrow tmp_1 \cdot tmp_2$ \\
-13. $tmp_1 \leftarrow 2 \cdot a_2$, $tmp_1 \leftarrow a_1 + tmp_1$, $tmp_1 \leftarrow 2 \cdot tmp_1$, $tmp_1 \leftarrow tmp_1 + a_0$ \\
-14. $tmp_2 \leftarrow 2 \cdot b_2$, $tmp_2 \leftarrow b_1 + tmp_2$, $tmp_2 \leftarrow 2 \cdot tmp_2$, $tmp_2 \leftarrow tmp_2 + b_0$ \\
-15. $w_3 \leftarrow tmp_1 \cdot tmp_2$ \\
-16. $tmp_1 \leftarrow a_0 + a_1$, $tmp_1 \leftarrow tmp_1 + a_2$, $tmp_2 \leftarrow b_0 + b_1$, $tmp_2 \leftarrow tmp_2 + b_2$ \\
-17. $w_2 \leftarrow tmp_1 \cdot tmp_2$ \\
-\\
-Continued on the next page.\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toom\_mul}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toom\_mul} (continued). \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b $ \\
-\hline \\
-Now solve the system of equations. \\
-18. $w_1 \leftarrow w_4 - w_1$, $w_3 \leftarrow w_3 - w_0$ \\
-19. $w_1 \leftarrow \lfloor w_1 / 2 \rfloor$, $w_3 \leftarrow \lfloor w_3 / 2 \rfloor$ \\
-20. $w_2 \leftarrow w_2 - w_0$, $w_2 \leftarrow w_2 - w_4$ \\
-21. $w_1 \leftarrow w_1 - w_2$, $w_3 \leftarrow w_3 - w_2$ \\
-22. $tmp_1 \leftarrow 8 \cdot w_0$, $w_1 \leftarrow w_1 - tmp_1$, $tmp_1 \leftarrow 8 \cdot w_4$, $w_3 \leftarrow w_3 - tmp_1$ \\
-23. $w_2 \leftarrow 3 \cdot w_2$, $w_2 \leftarrow w_2 - w_1$, $w_2 \leftarrow w_2 - w_3$ \\
-24. $w_1 \leftarrow w_1 - w_2$, $w_3 \leftarrow w_3 - w_2$ \\
-25. $w_1 \leftarrow \lfloor w_1 / 3 \rfloor, w_3 \leftarrow \lfloor w_3 / 3 \rfloor$ \\
-\\
-Now substitute $\beta^k$ for $x$ by shifting $w_0, w_1, ..., w_4$. \\
-26. for $n$ from $1$ to $4$ do \\
-\hspace{3mm}26.1 $w_n \leftarrow w_n \cdot \beta^{nk}$ \\
-27. $c \leftarrow w_0 + w_1$, $c \leftarrow c + w_2$, $c \leftarrow c + w_3$, $c \leftarrow c + w_4$ \\
-28. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toom\_mul (continued)}
-\end{figure}
-
-\textbf{Algorithm mp\_toom\_mul.}
-This algorithm computes the product of two mp\_int variables $a$ and $b$ using the Toom-Cook approach. Compared to the Karatsuba multiplication, this
-algorithm has a lower asymptotic running time of approximately $O(n^{1.464})$ but at an obvious cost in overhead. In this
-description, several statements have been compounded to save space. The intention is that the statements are executed from left to right across
-any given step.
-
-The two inputs $a$ and $b$ are first split into three $k$-digit integers $a_0, a_1, a_2$ and $b_0, b_1, b_2$ respectively. From these smaller
-integers the coefficients of the polynomial basis representations $f(x)$ and $g(x)$ are known and can be used to find the relations required.
-
-The first two relations $w_0$ and $w_4$ are the points $\zeta_{0}$ and $\zeta_{\infty}$ respectively. The relation $w_1, w_2$ and $w_3$ correspond
-to the points $16 \cdot \zeta_{1 \over 2}, \zeta_{2}$ and $\zeta_{1}$ respectively. These are found using logical shifts to independently find
-$f(y)$ and $g(y)$ which significantly speeds up the algorithm.
-
-After the five relations $w_0, w_1, \ldots, w_4$ have been computed, the system they represent must be solved in order for the unknown coefficients
-$w_1, w_2$ and $w_3$ to be isolated. The steps 18 through 25 perform the system reduction required as previously described. Each step of
-the reduction represents the comparable matrix operation that would be performed had this been performed by pencil. For example, step 18 indicates
-that row $1$ must be subtracted from row $4$ and simultaneously row $0$ subtracted from row $3$.
-
-Once the coeffients have been isolated, the polynomial $W(x) = \sum_{i=0}^{2n} w_i x^i$ is known. By substituting $\beta^{k}$ for $x$, the integer
-result $a \cdot b$ is produced.
-
-EXAM,bn_mp_toom_mul.c
-
-The first obvious thing to note is that this algorithm is complicated. The complexity is worth it if you are multiplying very
-large numbers. For example, a 10,000 digit multiplication takes approximaly 99,282,205 fewer single precision multiplications with
-Toom--Cook than a Comba or baseline approach (this is a savings of more than 99$\%$). For most ``crypto'' sized numbers this
-algorithm is not practical as Karatsuba has a much lower cutoff point.
-
-First we split $a$ and $b$ into three roughly equal portions. This has been accomplished (lines @40,mod@ to @69,rshd@) with
-combinations of mp\_rshd() and mp\_mod\_2d() function calls. At this point $a = a2 \cdot \beta^2 + a1 \cdot \beta + a0$ and similiarly
-for $b$.
-
-Next we compute the five points $w0, w1, w2, w3$ and $w4$. Recall that $w0$ and $w4$ can be computed directly from the portions so
-we get those out of the way first (lines @72,mul@ and @77,mul@). Next we compute $w1, w2$ and $w3$ using Horners method.
-
-After this point we solve for the actual values of $w1, w2$ and $w3$ by reducing the $5 \times 5$ system which is relatively
-straight forward.
-
-\subsection{Signed Multiplication}
-Now that algorithms to handle multiplications of every useful dimensions have been developed, a rather simple finishing touch is required. So far all
-of the multiplication algorithms have been unsigned multiplications which leaves only a signed multiplication algorithm to be established.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b$ \\
-\hline \\
-1. If $a.sign = b.sign$ then \\
-\hspace{3mm}1.1 $sign = MP\_ZPOS$ \\
-2. else \\
-\hspace{3mm}2.1 $sign = MP\_ZNEG$ \\
-3. If min$(a.used, b.used) \ge TOOM\_MUL\_CUTOFF$ then \\
-\hspace{3mm}3.1 $c \leftarrow a \cdot b$ using algorithm mp\_toom\_mul \\
-4. else if min$(a.used, b.used) \ge KARATSUBA\_MUL\_CUTOFF$ then \\
-\hspace{3mm}4.1 $c \leftarrow a \cdot b$ using algorithm mp\_karatsuba\_mul \\
-5. else \\
-\hspace{3mm}5.1 $digs \leftarrow a.used + b.used + 1$ \\
-\hspace{3mm}5.2 If $digs < MP\_ARRAY$ and min$(a.used, b.used) \le \delta$ then \\
-\hspace{6mm}5.2.1 $c \leftarrow a \cdot b \mbox{ (mod }\beta^{digs}\mbox{)}$ using algorithm fast\_s\_mp\_mul\_digs. \\
-\hspace{3mm}5.3 else \\
-\hspace{6mm}5.3.1 $c \leftarrow a \cdot b \mbox{ (mod }\beta^{digs}\mbox{)}$ using algorithm s\_mp\_mul\_digs. \\
-6. $c.sign \leftarrow sign$ \\
-7. Return the result of the unsigned multiplication performed. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul}
-\end{figure}
-
-\textbf{Algorithm mp\_mul.}
-This algorithm performs the signed multiplication of two inputs. It will make use of any of the three unsigned multiplication algorithms
-available when the input is of appropriate size. The \textbf{sign} of the result is not set until the end of the algorithm since algorithm
-s\_mp\_mul\_digs will clear it.
-
-EXAM,bn_mp_mul.c
-
-The implementation is rather simplistic and is not particularly noteworthy. Line @22,?@ computes the sign of the result using the ``?''
-operator from the C programming language. Line @37,<<@ computes $\delta$ using the fact that $1 << k$ is equal to $2^k$.
-
-\section{Squaring}
-\label{sec:basesquare}
-
-Squaring is a special case of multiplication where both multiplicands are equal. At first it may seem like there is no significant optimization
-available but in fact there is. Consider the multiplication of $576$ against $241$. In total there will be nine single precision multiplications
-performed which are $1\cdot 6$, $1 \cdot 7$, $1 \cdot 5$, $4 \cdot 6$, $4 \cdot 7$, $4 \cdot 5$, $2 \cdot 6$, $2 \cdot 7$ and $2 \cdot 5$. Now consider
-the multiplication of $123$ against $123$. The nine products are $3 \cdot 3$, $3 \cdot 2$, $3 \cdot 1$, $2 \cdot 3$, $2 \cdot 2$, $2 \cdot 1$,
-$1 \cdot 3$, $1 \cdot 2$ and $1 \cdot 1$. On closer inspection some of the products are equivalent. For example, $3 \cdot 2 = 2 \cdot 3$
-and $3 \cdot 1 = 1 \cdot 3$.
-
-For any $n$-digit input, there are ${{\left (n^2 + n \right)}\over 2}$ possible unique single precision multiplications required compared to the $n^2$
-required for multiplication. The following diagram gives an example of the operations required.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{ccccc|c}
-&&1&2&3&\\
-$\times$ &&1&2&3&\\
-\hline && $3 \cdot 1$ & $3 \cdot 2$ & $3 \cdot 3$ & Row 0\\
- & $2 \cdot 1$ & $2 \cdot 2$ & $2 \cdot 3$ && Row 1 \\
- $1 \cdot 1$ & $1 \cdot 2$ & $1 \cdot 3$ &&& Row 2 \\
-\end{tabular}
-\end{center}
-\caption{Squaring Optimization Diagram}
-\end{figure}
-
-MARK,SQUARE
-Starting from zero and numbering the columns from right to left a very simple pattern becomes obvious. For the purposes of this discussion let $x$
-represent the number being squared. The first observation is that in row $k$ the $2k$'th column of the product has a $\left (x_k \right)^2$ term in it.
-
-The second observation is that every column $j$ in row $k$ where $j \ne 2k$ is part of a double product. Every non-square term of a column will
-appear twice hence the name ``double product''. Every odd column is made up entirely of double products. In fact every column is made up of double
-products and at most one square (\textit{see the exercise section}).
-
-The third and final observation is that for row $k$ the first unique non-square term, that is, one that hasn't already appeared in an earlier row,
-occurs at column $2k + 1$. For example, on row $1$ of the previous squaring, column one is part of the double product with column one from row zero.
-Column two of row one is a square and column three is the first unique column.
-
-\subsection{The Baseline Squaring Algorithm}
-The baseline squaring algorithm is meant to be a catch-all squaring algorithm. It will handle any of the input sizes that the faster routines
-will not handle.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. Init a temporary mp\_int of at least $2 \cdot a.used +1$ digits. (\textit{mp\_init\_size}) \\
-2. If step 1 failed return(\textit{MP\_MEM}) \\
-3. $t.used \leftarrow 2 \cdot a.used + 1$ \\
-4. For $ix$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}Calculate the square. \\
-\hspace{3mm}4.1 $\hat r \leftarrow t_{2ix} + \left (a_{ix} \right )^2$ \\
-\hspace{3mm}4.2 $t_{2ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}Calculate the double products after the square. \\
-\hspace{3mm}4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}4.4 For $iy$ from $ix + 1$ to $a.used - 1$ do \\
-\hspace{6mm}4.4.1 $\hat r \leftarrow 2 \cdot a_{ix}a_{iy} + t_{ix + iy} + u$ \\
-\hspace{6mm}4.4.2 $t_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}4.4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}Set the last carry. \\
-\hspace{3mm}4.5 While $u > 0$ do \\
-\hspace{6mm}4.5.1 $iy \leftarrow iy + 1$ \\
-\hspace{6mm}4.5.2 $\hat r \leftarrow t_{ix + iy} + u$ \\
-\hspace{6mm}4.5.3 $t_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}4.5.4 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-5. Clamp excess digits of $t$. (\textit{mp\_clamp}) \\
-6. Exchange $b$ and $t$. \\
-7. Clear $t$ (\textit{mp\_clear}) \\
-8. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_sqr.}
-This algorithm computes the square of an input using the three observations on squaring. It is based fairly faithfully on algorithm 14.16 of HAC
-\cite[pp.596-597]{HAC}. Similar to algorithm s\_mp\_mul\_digs, a temporary mp\_int is allocated to hold the result of the squaring. This allows the
-destination mp\_int to be the same as the source mp\_int.
-
-The outer loop of this algorithm begins on step 4. It is best to think of the outer loop as walking down the rows of the partial results, while
-the inner loop computes the columns of the partial result. Step 4.1 and 4.2 compute the square term for each row, and step 4.3 and 4.4 propagate
-the carry and compute the double products.
-
-The requirement that a mp\_word be able to represent the range $0 \le x < 2 \beta^2$ arises from this
-very algorithm. The product $a_{ix}a_{iy}$ will lie in the range $0 \le x \le \beta^2 - 2\beta + 1$ which is obviously less than $\beta^2$ meaning that
-when it is multiplied by two, it can be properly represented by a mp\_word.
-
-Similar to algorithm s\_mp\_mul\_digs, after every pass of the inner loop, the destination is correctly set to the sum of all of the partial
-results calculated so far. This involves expensive carry propagation which will be eliminated in the next algorithm.
-
-EXAM,bn_s_mp_sqr.c
-
-Inside the outer loop (line @32,for@) the square term is calculated on line @35,r =@. The carry (line @42,>>@) has been
-extracted from the mp\_word accumulator using a right shift. Aliases for $a_{ix}$ and $t_{ix+iy}$ are initialized
-(lines @45,tmpx@ and @48,tmpt@) to simplify the inner loop. The doubling is performed using two
-additions (line @57,r + r@) since it is usually faster than shifting, if not at least as fast.
-
-The important observation is that the inner loop does not begin at $iy = 0$ like for multiplication. As such the inner loops
-get progressively shorter as the algorithm proceeds. This is what leads to the savings compared to using a multiplication to
-square a number.
-
-\subsection{Faster Squaring by the ``Comba'' Method}
-A major drawback to the baseline method is the requirement for single precision shifting inside the $O(n^2)$ nested loop. Squaring has an additional
-drawback that it must double the product inside the inner loop as well. As for multiplication, the Comba technique can be used to eliminate these
-performance hazards.
-
-The first obvious solution is to make an array of mp\_words which will hold all of the columns. This will indeed eliminate all of the carry
-propagation operations from the inner loop. However, the inner product must still be doubled $O(n^2)$ times. The solution stems from the simple fact
-that $2a + 2b + 2c = 2(a + b + c)$. That is the sum of all of the double products is equal to double the sum of all the products. For example,
-$ab + ba + ac + ca = 2ab + 2ac = 2(ab + ac)$.
-
-However, we cannot simply double all of the columns, since the squares appear only once per row. The most practical solution is to have two
-mp\_word arrays. One array will hold the squares and the other array will hold the double products. With both arrays the doubling and
-carry propagation can be moved to a $O(n)$ work level outside the $O(n^2)$ level. In this case, we have an even simpler solution in mind.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_s\_mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} mp\_digits named $W$ on the stack. \\
-1. If $b.alloc < 2a.used + 1$ then grow $b$ to $2a.used + 1$ digits. (\textit{mp\_grow}). \\
-2. If step 1 failed return(\textit{MP\_MEM}). \\
-\\
-3. $pa \leftarrow 2 \cdot a.used$ \\
-4. $\hat W1 \leftarrow 0$ \\
-5. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}5.1 $\_ \hat W \leftarrow 0$ \\
-\hspace{3mm}5.2 $ty \leftarrow \mbox{MIN}(a.used - 1, ix)$ \\
-\hspace{3mm}5.3 $tx \leftarrow ix - ty$ \\
-\hspace{3mm}5.4 $iy \leftarrow \mbox{MIN}(a.used - tx, ty + 1)$ \\
-\hspace{3mm}5.5 $iy \leftarrow \mbox{MIN}(iy, \lfloor \left (ty - tx + 1 \right )/2 \rfloor)$ \\
-\hspace{3mm}5.6 for $iz$ from $0$ to $iz - 1$ do \\
-\hspace{6mm}5.6.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx + iz}a_{ty - iz}$ \\
-\hspace{3mm}5.7 $\_ \hat W \leftarrow 2 \cdot \_ \hat W + \hat W1$ \\
-\hspace{3mm}5.8 if $ix$ is even then \\
-\hspace{6mm}5.8.1 $\_ \hat W \leftarrow \_ \hat W + \left ( a_{\lfloor ix/2 \rfloor}\right )^2$ \\
-\hspace{3mm}5.9 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
-\hspace{3mm}5.10 $\hat W1 \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
-\\
-6. $oldused \leftarrow b.used$ \\
-7. $b.used \leftarrow 2 \cdot a.used$ \\
-8. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}8.1 $b_{ix} \leftarrow W_{ix}$ \\
-9. for $ix$ from $pa$ to $oldused - 1$ do \\
-\hspace{3mm}9.1 $b_{ix} \leftarrow 0$ \\
-10. Clamp excess digits from $b$. (\textit{mp\_clamp}) \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_s\_mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm fast\_s\_mp\_sqr.}
-This algorithm computes the square of an input using the Comba technique. It is designed to be a replacement for algorithm
-s\_mp\_sqr when the number of input digits is less than \textbf{MP\_WARRAY} and less than $\delta \over 2$.
-This algorithm is very similar to the Comba multiplier except with a few key differences we shall make note of.
-
-First, we have an accumulator and carry variables $\_ \hat W$ and $\hat W1$ respectively. This is because the inner loop
-products are to be doubled. If we had added the previous carry in we would be doubling too much. Next we perform an
-addition MIN condition on $iy$ (step 5.5) to prevent overlapping digits. For example, $a_3 \cdot a_5$ is equal
-$a_5 \cdot a_3$. Whereas in the multiplication case we would have $5 < a.used$ and $3 \ge 0$ is maintained since we double the sum
-of the products just outside the inner loop we have to avoid doing this. This is also a good thing since we perform
-fewer multiplications and the routine ends up being faster.
-
-Finally the last difference is the addition of the ``square'' term outside the inner loop (step 5.8). We add in the square
-only to even outputs and it is the square of the term at the $\lfloor ix / 2 \rfloor$ position.
-
-EXAM,bn_fast_s_mp_sqr.c
-
-This implementation is essentially a copy of Comba multiplication with the appropriate changes added to make it faster for
-the special case of squaring.
-
-\subsection{Polynomial Basis Squaring}
-The same algorithm that performs optimal polynomial basis multiplication can be used to perform polynomial basis squaring. The minor exception
-is that $\zeta_y = f(y)g(y)$ is actually equivalent to $\zeta_y = f(y)^2$ since $f(y) = g(y)$. Instead of performing $2n + 1$
-multiplications to find the $\zeta$ relations, squaring operations are performed instead.
-
-\subsection{Karatsuba Squaring}
-Let $f(x) = ax + b$ represent the polynomial basis representation of a number to square.
-Let $h(x) = \left ( f(x) \right )^2$ represent the square of the polynomial. The Karatsuba equation can be modified to square a
-number with the following equation.
-
-\begin{equation}
-h(x) = a^2x^2 + \left ((a + b)^2 - (a^2 + b^2) \right )x + b^2
-\end{equation}
-
-Upon closer inspection this equation only requires the calculation of three half-sized squares: $a^2$, $b^2$ and $(a + b)^2$. As in
-Karatsuba multiplication, this algorithm can be applied recursively on the input and will achieve an asymptotic running time of
-$O \left ( n^{lg(3)} \right )$.
-
-If the asymptotic times of Karatsuba squaring and multiplication are the same, why not simply use the multiplication algorithm
-instead? The answer to this arises from the cutoff point for squaring. As in multiplication there exists a cutoff point, at which the
-time required for a Comba based squaring and a Karatsuba based squaring meet. Due to the overhead inherent in the Karatsuba method, the cutoff
-point is fairly high. For example, on an AMD Athlon XP processor with $\beta = 2^{28}$, the cutoff point is around 127 digits.
-
-Consider squaring a 200 digit number with this technique. It will be split into two 100 digit halves which are subsequently squared.
-The 100 digit halves will not be squared using Karatsuba, but instead using the faster Comba based squaring algorithm. If Karatsuba multiplication
-were used instead, the 100 digit numbers would be squared with a slower Comba based multiplication.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_karatsuba\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. Initialize the following temporary mp\_ints: $x0$, $x1$, $t1$, $t2$, $x0x0$ and $x1x1$. \\
-2. If any of the initializations on step 1 failed return(\textit{MP\_MEM}). \\
-\\
-Split the input. e.g. $a = x1\beta^B + x0$ \\
-3. $B \leftarrow \lfloor a.used / 2 \rfloor$ \\
-4. $x0 \leftarrow a \mbox{ (mod }\beta^B\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-5. $x1 \leftarrow \lfloor a / \beta^B \rfloor$ (\textit{mp\_lshd}) \\
-\\
-Calculate the three squares. \\
-6. $x0x0 \leftarrow x0^2$ (\textit{mp\_sqr}) \\
-7. $x1x1 \leftarrow x1^2$ \\
-8. $t1 \leftarrow x1 + x0$ (\textit{s\_mp\_add}) \\
-9. $t1 \leftarrow t1^2$ \\
-\\
-Compute the middle term. \\
-10. $t2 \leftarrow x0x0 + x1x1$ (\textit{s\_mp\_add}) \\
-11. $t1 \leftarrow t1 - t2$ \\
-\\
-Compute final product. \\
-12. $t1 \leftarrow t1\beta^B$ (\textit{mp\_lshd}) \\
-13. $x1x1 \leftarrow x1x1\beta^{2B}$ \\
-14. $t1 \leftarrow t1 + x0x0$ \\
-15. $b \leftarrow t1 + x1x1$ \\
-16. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_karatsuba\_sqr}
-\end{figure}
-
-\textbf{Algorithm mp\_karatsuba\_sqr.}
-This algorithm computes the square of an input $a$ using the Karatsuba technique. This algorithm is very similar to the Karatsuba based
-multiplication algorithm with the exception that the three half-size multiplications have been replaced with three half-size squarings.
-
-The radix point for squaring is simply placed exactly in the middle of the digits when the input has an odd number of digits, otherwise it is
-placed just below the middle. Step 3, 4 and 5 compute the two halves required using $B$
-as the radix point. The first two squares in steps 6 and 7 are rather straightforward while the last square is of a more compact form.
-
-By expanding $\left (x1 + x0 \right )^2$, the $x1^2$ and $x0^2$ terms in the middle disappear, that is $(x0 - x1)^2 - (x1^2 + x0^2) = 2 \cdot x0 \cdot x1$.
-Now if $5n$ single precision additions and a squaring of $n$-digits is faster than multiplying two $n$-digit numbers and doubling then
-this method is faster. Assuming no further recursions occur, the difference can be estimated with the following inequality.
-
-Let $p$ represent the cost of a single precision addition and $q$ the cost of a single precision multiplication both in terms of time\footnote{Or
-machine clock cycles.}.
-
-\begin{equation}
-5pn +{{q(n^2 + n)} \over 2} \le pn + qn^2
-\end{equation}
-
-For example, on an AMD Athlon XP processor $p = {1 \over 3}$ and $q = 6$. This implies that the following inequality should hold.
-\begin{center}
-\begin{tabular}{rcl}
-${5n \over 3} + 3n^2 + 3n$ & $<$ & ${n \over 3} + 6n^2$ \\
-${5 \over 3} + 3n + 3$ & $<$ & ${1 \over 3} + 6n$ \\
-${13 \over 9}$ & $<$ & $n$ \\
-\end{tabular}
-\end{center}
-
-This results in a cutoff point around $n = 2$. As a consequence it is actually faster to compute the middle term the ``long way'' on processors
-where multiplication is substantially slower\footnote{On the Athlon there is a 1:17 ratio between clock cycles for addition and multiplication. On
-the Intel P4 processor this ratio is 1:29 making this method even more beneficial. The only common exception is the ARMv4 processor which has a
-ratio of 1:7. } than simpler operations such as addition.
-
-EXAM,bn_mp_karatsuba_sqr.c
-
-This implementation is largely based on the implementation of algorithm mp\_karatsuba\_mul. It uses the same inline style to copy and
-shift the input into the two halves. The loop from line @54,{@ to line @70,}@ has been modified since only one input exists. The \textbf{used}
-count of both $x0$ and $x1$ is fixed up and $x0$ is clamped before the calculations begin. At this point $x1$ and $x0$ are valid equivalents
-to the respective halves as if mp\_rshd and mp\_mod\_2d had been used.
-
-By inlining the copy and shift operations the cutoff point for Karatsuba multiplication can be lowered. On the Athlon the cutoff point
-is exactly at the point where Comba squaring can no longer be used (\textit{128 digits}). On slower processors such as the Intel P4
-it is actually below the Comba limit (\textit{at 110 digits}).
-
-This routine uses the same error trap coding style as mp\_karatsuba\_sqr. As the temporary variables are initialized errors are
-redirected to the error trap higher up. If the algorithm completes without error the error code is set to \textbf{MP\_OKAY} and
-mp\_clears are executed normally.
-
-\subsection{Toom-Cook Squaring}
-The Toom-Cook squaring algorithm mp\_toom\_sqr is heavily based on the algorithm mp\_toom\_mul with the exception that squarings are used
-instead of multiplication to find the five relations. The reader is encouraged to read the description of the latter algorithm and try to
-derive their own Toom-Cook squaring algorithm.
-
-\subsection{High Level Squaring}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. If $a.used \ge TOOM\_SQR\_CUTOFF$ then \\
-\hspace{3mm}1.1 $b \leftarrow a^2$ using algorithm mp\_toom\_sqr \\
-2. else if $a.used \ge KARATSUBA\_SQR\_CUTOFF$ then \\
-\hspace{3mm}2.1 $b \leftarrow a^2$ using algorithm mp\_karatsuba\_sqr \\
-3. else \\
-\hspace{3mm}3.1 $digs \leftarrow a.used + b.used + 1$ \\
-\hspace{3mm}3.2 If $digs < MP\_ARRAY$ and $a.used \le \delta$ then \\
-\hspace{6mm}3.2.1 $b \leftarrow a^2$ using algorithm fast\_s\_mp\_sqr. \\
-\hspace{3mm}3.3 else \\
-\hspace{6mm}3.3.1 $b \leftarrow a^2$ using algorithm s\_mp\_sqr. \\
-4. $b.sign \leftarrow MP\_ZPOS$ \\
-5. Return the result of the unsigned squaring performed. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm mp\_sqr.}
-This algorithm computes the square of the input using one of four different algorithms. If the input is very large and has at least
-\textbf{TOOM\_SQR\_CUTOFF} or \textbf{KARATSUBA\_SQR\_CUTOFF} digits then either the Toom-Cook or the Karatsuba Squaring algorithm is used. If
-neither of the polynomial basis algorithms should be used then either the Comba or baseline algorithm is used.
-
-EXAM,bn_mp_sqr.c
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ] $ & Devise an efficient algorithm for selection of the radix point to handle inputs \\
- & that have different number of digits in Karatsuba multiplication. \\
- & \\
-$\left [ 2 \right ] $ & In ~SQUARE~ the fact that every column of a squaring is made up \\
- & of double products and at most one square is stated. Prove this statement. \\
- & \\
-$\left [ 3 \right ] $ & Prove the equation for Karatsuba squaring. \\
- & \\
-$\left [ 1 \right ] $ & Prove that Karatsuba squaring requires $O \left (n^{lg(3)} \right )$ time. \\
- & \\
-$\left [ 2 \right ] $ & Determine the minimal ratio between addition and multiplication clock cycles \\
- & required for equation $6.7$ to be true. \\
- & \\
-$\left [ 3 \right ] $ & Implement a threaded version of Comba multiplication (and squaring) where you \\
- & compute subsets of the columns in each thread. Determine a cutoff point where \\
- & it is effective and add the logic to mp\_mul() and mp\_sqr(). \\
- &\\
-$\left [ 4 \right ] $ & Same as the previous but also modify the Karatsuba and Toom-Cook. You must \\
- & increase the throughput of mp\_exptmod() for random odd moduli in the range \\
- & $512 \ldots 4096$ bits significantly ($> 2x$) to complete this challenge. \\
- & \\
-\end{tabular}
-
-\chapter{Modular Reduction}
-MARK,REDUCTION
-\section{Basics of Modular Reduction}
-\index{modular residue}
-Modular reduction is an operation that arises quite often within public key cryptography algorithms and various number theoretic algorithms,
-such as factoring. Modular reduction algorithms are the third class of algorithms of the ``multipliers'' set. A number $a$ is said to be \textit{reduced}
-modulo another number $b$ by finding the remainder of the division $a/b$. Full integer division with remainder is a topic to be covered
-in~\ref{sec:division}.
-
-Modular reduction is equivalent to solving for $r$ in the following equation. $a = bq + r$ where $q = \lfloor a/b \rfloor$. The result
-$r$ is said to be ``congruent to $a$ modulo $b$'' which is also written as $r \equiv a \mbox{ (mod }b\mbox{)}$. In other vernacular $r$ is known as the
-``modular residue'' which leads to ``quadratic residue''\footnote{That's fancy talk for $b \equiv a^2 \mbox{ (mod }p\mbox{)}$.} and
-other forms of residues.
-
-Modular reductions are normally used to create either finite groups, rings or fields. The most common usage for performance driven modular reductions
-is in modular exponentiation algorithms. That is to compute $d = a^b \mbox{ (mod }c\mbox{)}$ as fast as possible. This operation is used in the
-RSA and Diffie-Hellman public key algorithms, for example. Modular multiplication and squaring also appears as a fundamental operation in
-elliptic curve cryptographic algorithms. As will be discussed in the subsequent chapter there exist fast algorithms for computing modular
-exponentiations without having to perform (\textit{in this example}) $b - 1$ multiplications. These algorithms will produce partial results in the
-range $0 \le x < c^2$ which can be taken advantage of to create several efficient algorithms. They have also been used to create redundancy check
-algorithms known as CRCs, error correction codes such as Reed-Solomon and solve a variety of number theoeretic problems.
-
-\section{The Barrett Reduction}
-The Barrett reduction algorithm \cite{BARRETT} was inspired by fast division algorithms which multiply by the reciprocal to emulate
-division. Barretts observation was that the residue $c$ of $a$ modulo $b$ is equal to
-
-\begin{equation}
-c = a - b \cdot \lfloor a/b \rfloor
-\end{equation}
-
-Since algorithms such as modular exponentiation would be using the same modulus extensively, typical DSP\footnote{It is worth noting that Barrett's paper
-targeted the DSP56K processor.} intuition would indicate the next step would be to replace $a/b$ by a multiplication by the reciprocal. However,
-DSP intuition on its own will not work as these numbers are considerably larger than the precision of common DSP floating point data types.
-It would take another common optimization to optimize the algorithm.
-
-\subsection{Fixed Point Arithmetic}
-The trick used to optimize the above equation is based on a technique of emulating floating point data types with fixed precision integers. Fixed
-point arithmetic would become very popular as it greatly optimize the ``3d-shooter'' genre of games in the mid 1990s when floating point units were
-fairly slow if not unavailable. The idea behind fixed point arithmetic is to take a normal $k$-bit integer data type and break it into $p$-bit
-integer and a $q$-bit fraction part (\textit{where $p+q = k$}).
-
-In this system a $k$-bit integer $n$ would actually represent $n/2^q$. For example, with $q = 4$ the integer $n = 37$ would actually represent the
-value $2.3125$. To multiply two fixed point numbers the integers are multiplied using traditional arithmetic and subsequently normalized by
-moving the implied decimal point back to where it should be. For example, with $q = 4$ to multiply the integers $9$ and $5$ they must be converted
-to fixed point first by multiplying by $2^q$. Let $a = 9(2^q)$ represent the fixed point representation of $9$ and $b = 5(2^q)$ represent the
-fixed point representation of $5$. The product $ab$ is equal to $45(2^{2q})$ which when normalized by dividing by $2^q$ produces $45(2^q)$.
-
-This technique became popular since a normal integer multiplication and logical shift right are the only required operations to perform a multiplication
-of two fixed point numbers. Using fixed point arithmetic, division can be easily approximated by multiplying by the reciprocal. If $2^q$ is
-equivalent to one than $2^q/b$ is equivalent to the fixed point approximation of $1/b$ using real arithmetic. Using this fact dividing an integer
-$a$ by another integer $b$ can be achieved with the following expression.
-
-\begin{equation}
-\lfloor a / b \rfloor \mbox{ }\approx\mbox{ } \lfloor (a \cdot \lfloor 2^q / b \rfloor)/2^q \rfloor
-\end{equation}
-
-The precision of the division is proportional to the value of $q$. If the divisor $b$ is used frequently as is the case with
-modular exponentiation pre-computing $2^q/b$ will allow a division to be performed with a multiplication and a right shift. Both operations
-are considerably faster than division on most processors.
-
-Consider dividing $19$ by $5$. The correct result is $\lfloor 19/5 \rfloor = 3$. With $q = 3$ the reciprocal is $\lfloor 2^q/5 \rfloor = 1$ which
-leads to a product of $19$ which when divided by $2^q$ produces $2$. However, with $q = 4$ the reciprocal is $\lfloor 2^q/5 \rfloor = 3$ and
-the result of the emulated division is $\lfloor 3 \cdot 19 / 2^q \rfloor = 3$ which is correct. The value of $2^q$ must be close to or ideally
-larger than the dividend. In effect if $a$ is the dividend then $q$ should allow $0 \le \lfloor a/2^q \rfloor \le 1$ in order for this approach
-to work correctly. Plugging this form of divison into the original equation the following modular residue equation arises.
-
-\begin{equation}
-c = a - b \cdot \lfloor (a \cdot \lfloor 2^q / b \rfloor)/2^q \rfloor
-\end{equation}
-
-Using the notation from \cite{BARRETT} the value of $\lfloor 2^q / b \rfloor$ will be represented by the $\mu$ symbol. Using the $\mu$
-variable also helps re-inforce the idea that it is meant to be computed once and re-used.
-
-\begin{equation}
-c = a - b \cdot \lfloor (a \cdot \mu)/2^q \rfloor
-\end{equation}
-
-Provided that $2^q \ge a$ this algorithm will produce a quotient that is either exactly correct or off by a value of one. In the context of Barrett
-reduction the value of $a$ is bound by $0 \le a \le (b - 1)^2$ meaning that $2^q \ge b^2$ is sufficient to ensure the reciprocal will have enough
-precision.
-
-Let $n$ represent the number of digits in $b$. This algorithm requires approximately $2n^2$ single precision multiplications to produce the quotient and
-another $n^2$ single precision multiplications to find the residue. In total $3n^2$ single precision multiplications are required to
-reduce the number.
-
-For example, if $b = 1179677$ and $q = 41$ ($2^q > b^2$), then the reciprocal $\mu$ is equal to $\lfloor 2^q / b \rfloor = 1864089$. Consider reducing
-$a = 180388626447$ modulo $b$ using the above reduction equation. The quotient using the new formula is $\lfloor (a \cdot \mu) / 2^q \rfloor = 152913$.
-By subtracting $152913b$ from $a$ the correct residue $a \equiv 677346 \mbox{ (mod }b\mbox{)}$ is found.
-
-\subsection{Choosing a Radix Point}
-Using the fixed point representation a modular reduction can be performed with $3n^2$ single precision multiplications. If that were the best
-that could be achieved a full division\footnote{A division requires approximately $O(2cn^2)$ single precision multiplications for a small value of $c$.
-See~\ref{sec:division} for further details.} might as well be used in its place. The key to optimizing the reduction is to reduce the precision of
-the initial multiplication that finds the quotient.
-
-Let $a$ represent the number of which the residue is sought. Let $b$ represent the modulus used to find the residue. Let $m$ represent
-the number of digits in $b$. For the purposes of this discussion we will assume that the number of digits in $a$ is $2m$, which is generally true if
-two $m$-digit numbers have been multiplied. Dividing $a$ by $b$ is the same as dividing a $2m$ digit integer by a $m$ digit integer. Digits below the
-$m - 1$'th digit of $a$ will contribute at most a value of $1$ to the quotient because $\beta^k < b$ for any $0 \le k \le m - 1$. Another way to
-express this is by re-writing $a$ as two parts. If $a' \equiv a \mbox{ (mod }b^m\mbox{)}$ and $a'' = a - a'$ then
-${a \over b} \equiv {{a' + a''} \over b}$ which is equivalent to ${a' \over b} + {a'' \over b}$. Since $a'$ is bound to be less than $b$ the quotient
-is bound by $0 \le {a' \over b} < 1$.
-
-Since the digits of $a'$ do not contribute much to the quotient the observation is that they might as well be zero. However, if the digits
-``might as well be zero'' they might as well not be there in the first place. Let $q_0 = \lfloor a/\beta^{m-1} \rfloor$ represent the input
-with the irrelevant digits trimmed. Now the modular reduction is trimmed to the almost equivalent equation
-
-\begin{equation}
-c = a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor
-\end{equation}
-
-Note that the original divisor $2^q$ has been replaced with $\beta^{m+1}$ where in this case $q$ is a multiple of $lg(\beta)$. Also note that the
-exponent on the divisor when added to the amount $q_0$ was shifted by equals $2m$. If the optimization had not been performed the divisor
-would have the exponent $2m$ so in the end the exponents do ``add up''. Using the above equation the quotient
-$\lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ can be off from the true quotient by at most two. The original fixed point quotient can be off
-by as much as one (\textit{provided the radix point is chosen suitably}) and now that the lower irrelevent digits have been trimmed the quotient
-can be off by an additional value of one for a total of at most two. This implies that
-$0 \le a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor < 3b$. By first subtracting $b$ times the quotient and then conditionally subtracting
-$b$ once or twice the residue is found.
-
-The quotient is now found using $(m + 1)(m) = m^2 + m$ single precision multiplications and the residue with an additional $m^2$ single
-precision multiplications, ignoring the subtractions required. In total $2m^2 + m$ single precision multiplications are required to find the residue.
-This is considerably faster than the original attempt.
-
-For example, let $\beta = 10$ represent the radix of the digits. Let $b = 9999$ represent the modulus which implies $m = 4$. Let $a = 99929878$
-represent the value of which the residue is desired. In this case $q = 8$ since $10^7 < 9999^2$ meaning that $\mu = \lfloor \beta^{q}/b \rfloor = 10001$.
-With the new observation the multiplicand for the quotient is equal to $q_0 = \lfloor a / \beta^{m - 1} \rfloor = 99929$. The quotient is then
-$\lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor = 9993$. Subtracting $9993b$ from $a$ and the correct residue $a \equiv 9871 \mbox{ (mod }b\mbox{)}$
-is found.
-
-\subsection{Trimming the Quotient}
-So far the reduction algorithm has been optimized from $3m^2$ single precision multiplications down to $2m^2 + m$ single precision multiplications. As
-it stands now the algorithm is already fairly fast compared to a full integer division algorithm. However, there is still room for
-optimization.
-
-After the first multiplication inside the quotient ($q_0 \cdot \mu$) the value is shifted right by $m + 1$ places effectively nullifying the lower
-half of the product. It would be nice to be able to remove those digits from the product to effectively cut down the number of single precision
-multiplications. If the number of digits in the modulus $m$ is far less than $\beta$ a full product is not required for the algorithm to work properly.
-In fact the lower $m - 2$ digits will not affect the upper half of the product at all and do not need to be computed.
-
-The value of $\mu$ is a $m$-digit number and $q_0$ is a $m + 1$ digit number. Using a full multiplier $(m + 1)(m) = m^2 + m$ single precision
-multiplications would be required. Using a multiplier that will only produce digits at and above the $m - 1$'th digit reduces the number
-of single precision multiplications to ${m^2 + m} \over 2$ single precision multiplications.
-
-\subsection{Trimming the Residue}
-After the quotient has been calculated it is used to reduce the input. As previously noted the algorithm is not exact and it can be off by a small
-multiple of the modulus, that is $0 \le a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor < 3b$. If $b$ is $m$ digits than the
-result of reduction equation is a value of at most $m + 1$ digits (\textit{provided $3 < \beta$}) implying that the upper $m - 1$ digits are
-implicitly zero.
-
-The next optimization arises from this very fact. Instead of computing $b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ using a full
-$O(m^2)$ multiplication algorithm only the lower $m+1$ digits of the product have to be computed. Similarly the value of $a$ can
-be reduced modulo $\beta^{m+1}$ before the multiple of $b$ is subtracted which simplifes the subtraction as well. A multiplication that produces
-only the lower $m+1$ digits requires ${m^2 + 3m - 2} \over 2$ single precision multiplications.
-
-With both optimizations in place the algorithm is the algorithm Barrett proposed. It requires $m^2 + 2m - 1$ single precision multiplications which
-is considerably faster than the straightforward $3m^2$ method.
-
-\subsection{The Barrett Algorithm}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and $\mu = \lfloor \beta^{2m}/b \rfloor, m = \lceil lg_{\beta}(b) \rceil, (0 \le a < b^2, b > 1)$ \\
-\textbf{Output}. $a \mbox{ (mod }b\mbox{)}$ \\
-\hline \\
-Let $m$ represent the number of digits in $b$. \\
-1. Make a copy of $a$ and store it in $q$. (\textit{mp\_init\_copy}) \\
-2. $q \leftarrow \lfloor q / \beta^{m - 1} \rfloor$ (\textit{mp\_rshd}) \\
-\\
-Produce the quotient. \\
-3. $q \leftarrow q \cdot \mu$ (\textit{note: only produce digits at or above $m-1$}) \\
-4. $q \leftarrow \lfloor q / \beta^{m + 1} \rfloor$ \\
-\\
-Subtract the multiple of modulus from the input. \\
-5. $a \leftarrow a \mbox{ (mod }\beta^{m+1}\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-6. $q \leftarrow q \cdot b \mbox{ (mod }\beta^{m+1}\mbox{)}$ (\textit{s\_mp\_mul\_digs}) \\
-7. $a \leftarrow a - q$ (\textit{mp\_sub}) \\
-\\
-Add $\beta^{m+1}$ if a carry occured. \\
-8. If $a < 0$ then (\textit{mp\_cmp\_d}) \\
-\hspace{3mm}8.1 $q \leftarrow 1$ (\textit{mp\_set}) \\
-\hspace{3mm}8.2 $q \leftarrow q \cdot \beta^{m+1}$ (\textit{mp\_lshd}) \\
-\hspace{3mm}8.3 $a \leftarrow a + q$ \\
-\\
-Now subtract the modulus if the residue is too large (e.g. quotient too small). \\
-9. While $a \ge b$ do (\textit{mp\_cmp}) \\
-\hspace{3mm}9.1 $c \leftarrow a - b$ \\
-10. Clear $q$. \\
-11. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce.}
-This algorithm will reduce the input $a$ modulo $b$ in place using the Barrett algorithm. It is loosely based on algorithm 14.42 of HAC
-\cite[pp. 602]{HAC} which is based on the paper from Paul Barrett \cite{BARRETT}. The algorithm has several restrictions and assumptions which must
-be adhered to for the algorithm to work.
-
-First the modulus $b$ is assumed to be positive and greater than one. If the modulus were less than or equal to one than subtracting
-a multiple of it would either accomplish nothing or actually enlarge the input. The input $a$ must be in the range $0 \le a < b^2$ in order
-for the quotient to have enough precision. If $a$ is the product of two numbers that were already reduced modulo $b$, this will not be a problem.
-Technically the algorithm will still work if $a \ge b^2$ but it will take much longer to finish. The value of $\mu$ is passed as an argument to this
-algorithm and is assumed to be calculated and stored before the algorithm is used.
-
-Recall that the multiplication for the quotient on step 3 must only produce digits at or above the $m-1$'th position. An algorithm called
-$s\_mp\_mul\_high\_digs$ which has not been presented is used to accomplish this task. The algorithm is based on $s\_mp\_mul\_digs$ except that
-instead of stopping at a given level of precision it starts at a given level of precision. This optimal algorithm can only be used if the number
-of digits in $b$ is very much smaller than $\beta$.
-
-While it is known that
-$a \ge b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ only the lower $m+1$ digits are being used to compute the residue, so an implied
-``borrow'' from the higher digits might leave a negative result. After the multiple of the modulus has been subtracted from $a$ the residue must be
-fixed up in case it is negative. The invariant $\beta^{m+1}$ must be added to the residue to make it positive again.
-
-The while loop at step 9 will subtract $b$ until the residue is less than $b$. If the algorithm is performed correctly this step is
-performed at most twice, and on average once. However, if $a \ge b^2$ than it will iterate substantially more times than it should.
-
-EXAM,bn_mp_reduce.c
-
-The first multiplication that determines the quotient can be performed by only producing the digits from $m - 1$ and up. This essentially halves
-the number of single precision multiplications required. However, the optimization is only safe if $\beta$ is much larger than the number of digits
-in the modulus. In the source code this is evaluated on lines @36,if@ to @44,}@ where algorithm s\_mp\_mul\_high\_digs is used when it is
-safe to do so.
-
-\subsection{The Barrett Setup Algorithm}
-In order to use algorithm mp\_reduce the value of $\mu$ must be calculated in advance. Ideally this value should be computed once and stored for
-future use so that the Barrett algorithm can be used without delay.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_setup}. \\
-\textbf{Input}. mp\_int $a$ ($a > 1$) \\
-\textbf{Output}. $\mu \leftarrow \lfloor \beta^{2m}/a \rfloor$ \\
-\hline \\
-1. $\mu \leftarrow 2^{2 \cdot lg(\beta) \cdot m}$ (\textit{mp\_2expt}) \\
-2. $\mu \leftarrow \lfloor \mu / b \rfloor$ (\textit{mp\_div}) \\
-3. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_setup.}
-This algorithm computes the reciprocal $\mu$ required for Barrett reduction. First $\beta^{2m}$ is calculated as $2^{2 \cdot lg(\beta) \cdot m}$ which
-is equivalent and much faster. The final value is computed by taking the integer quotient of $\lfloor \mu / b \rfloor$.
-
-EXAM,bn_mp_reduce_setup.c
-
-This simple routine calculates the reciprocal $\mu$ required by Barrett reduction. Note the extended usage of algorithm mp\_div where the variable
-which would received the remainder is passed as NULL. As will be discussed in~\ref{sec:division} the division routine allows both the quotient and the
-remainder to be passed as NULL meaning to ignore the value.
-
-\section{The Montgomery Reduction}
-Montgomery reduction\footnote{Thanks to Niels Ferguson for his insightful explanation of the algorithm.} \cite{MONT} is by far the most interesting
-form of reduction in common use. It computes a modular residue which is not actually equal to the residue of the input yet instead equal to a
-residue times a constant. However, as perplexing as this may sound the algorithm is relatively simple and very efficient.
-
-Throughout this entire section the variable $n$ will represent the modulus used to form the residue. As will be discussed shortly the value of
-$n$ must be odd. The variable $x$ will represent the quantity of which the residue is sought. Similar to the Barrett algorithm the input
-is restricted to $0 \le x < n^2$. To begin the description some simple number theory facts must be established.
-
-\textbf{Fact 1.} Adding $n$ to $x$ does not change the residue since in effect it adds one to the quotient $\lfloor x / n \rfloor$. Another way
-to explain this is that $n$ is (\textit{or multiples of $n$ are}) congruent to zero modulo $n$. Adding zero will not change the value of the residue.
-
-\textbf{Fact 2.} If $x$ is even then performing a division by two in $\Z$ is congruent to $x \cdot 2^{-1} \mbox{ (mod }n\mbox{)}$. Actually
-this is an application of the fact that if $x$ is evenly divisible by any $k \in \Z$ then division in $\Z$ will be congruent to
-multiplication by $k^{-1}$ modulo $n$.
-
-From these two simple facts the following simple algorithm can be derived.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction}. \\
-\textbf{Input}. Integer $x$, $n$ and $k$ \\
-\textbf{Output}. $2^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $1$ to $k$ do \\
-\hspace{3mm}1.1 If $x$ is odd then \\
-\hspace{6mm}1.1.1 $x \leftarrow x + n$ \\
-\hspace{3mm}1.2 $x \leftarrow x/2$ \\
-2. Return $x$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction}
-\end{figure}
-
-The algorithm reduces the input one bit at a time using the two congruencies stated previously. Inside the loop $n$, which is odd, is
-added to $x$ if $x$ is odd. This forces $x$ to be even which allows the division by two in $\Z$ to be congruent to a modular division by two. Since
-$x$ is assumed to be initially much larger than $n$ the addition of $n$ will contribute an insignificant magnitude to $x$. Let $r$ represent the
-final result of the Montgomery algorithm. If $k > lg(n)$ and $0 \le x < n^2$ then the final result is limited to
-$0 \le r < \lfloor x/2^k \rfloor + n$. As a result at most a single subtraction is required to get the residue desired.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|l|}
-\hline \textbf{Step number ($t$)} & \textbf{Result ($x$)} \\
-\hline $1$ & $x + n = 5812$, $x/2 = 2906$ \\
-\hline $2$ & $x/2 = 1453$ \\
-\hline $3$ & $x + n = 1710$, $x/2 = 855$ \\
-\hline $4$ & $x + n = 1112$, $x/2 = 556$ \\
-\hline $5$ & $x/2 = 278$ \\
-\hline $6$ & $x/2 = 139$ \\
-\hline $7$ & $x + n = 396$, $x/2 = 198$ \\
-\hline $8$ & $x/2 = 99$ \\
-\hline $9$ & $x + n = 356$, $x/2 = 178$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example of Montgomery Reduction (I)}
-\label{fig:MONT1}
-\end{figure}
-
-Consider the example in figure~\ref{fig:MONT1} which reduces $x = 5555$ modulo $n = 257$ when $k = 9$ (note $\beta^k = 512$ which is larger than $n$). The result of
-the algorithm $r = 178$ is congruent to the value of $2^{-9} \cdot 5555 \mbox{ (mod }257\mbox{)}$. When $r$ is multiplied by $2^9$ modulo $257$ the correct residue
-$r \equiv 158$ is produced.
-
-Let $k = \lfloor lg(n) \rfloor + 1$ represent the number of bits in $n$. The current algorithm requires $2k^2$ single precision shifts
-and $k^2$ single precision additions. At this rate the algorithm is most certainly slower than Barrett reduction and not terribly useful.
-Fortunately there exists an alternative representation of the algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction} (modified I). \\
-\textbf{Input}. Integer $x$, $n$ and $k$ ($2^k > n$) \\
-\textbf{Output}. $2^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $1$ to $k$ do \\
-\hspace{3mm}1.1 If the $t$'th bit of $x$ is one then \\
-\hspace{6mm}1.1.1 $x \leftarrow x + 2^tn$ \\
-2. Return $x/2^k$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction (modified I)}
-\end{figure}
-
-This algorithm is equivalent since $2^tn$ is a multiple of $n$ and the lower $k$ bits of $x$ are zero by step 2. The number of single
-precision shifts has now been reduced from $2k^2$ to $k^2 + k$ which is only a small improvement.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|l|r|}
-\hline \textbf{Step number ($t$)} & \textbf{Result ($x$)} & \textbf{Result ($x$) in Binary} \\
-\hline -- & $5555$ & $1010110110011$ \\
-\hline $1$ & $x + 2^{0}n = 5812$ & $1011010110100$ \\
-\hline $2$ & $5812$ & $1011010110100$ \\
-\hline $3$ & $x + 2^{2}n = 6840$ & $1101010111000$ \\
-\hline $4$ & $x + 2^{3}n = 8896$ & $10001011000000$ \\
-\hline $5$ & $8896$ & $10001011000000$ \\
-\hline $6$ & $8896$ & $10001011000000$ \\
-\hline $7$ & $x + 2^{6}n = 25344$ & $110001100000000$ \\
-\hline $8$ & $25344$ & $110001100000000$ \\
-\hline $9$ & $x + 2^{7}n = 91136$ & $10110010000000000$ \\
-\hline -- & $x/2^k = 178$ & \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example of Montgomery Reduction (II)}
-\label{fig:MONT2}
-\end{figure}
-
-Figure~\ref{fig:MONT2} demonstrates the modified algorithm reducing $x = 5555$ modulo $n = 257$ with $k = 9$.
-With this algorithm a single shift right at the end is the only right shift required to reduce the input instead of $k$ right shifts inside the
-loop. Note that for the iterations $t = 2, 5, 6$ and $8$ where the result $x$ is not changed. In those iterations the $t$'th bit of $x$ is
-zero and the appropriate multiple of $n$ does not need to be added to force the $t$'th bit of the result to zero.
-
-\subsection{Digit Based Montgomery Reduction}
-Instead of computing the reduction on a bit-by-bit basis it is actually much faster to compute it on digit-by-digit basis. Consider the
-previous algorithm re-written to compute the Montgomery reduction in this new fashion.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction} (modified II). \\
-\textbf{Input}. Integer $x$, $n$ and $k$ ($\beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $0$ to $k - 1$ do \\
-\hspace{3mm}1.1 $x \leftarrow x + \mu n \beta^t$ \\
-2. Return $x/\beta^k$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction (modified II)}
-\end{figure}
-
-The value $\mu n \beta^t$ is a multiple of the modulus $n$ meaning that it will not change the residue. If the first digit of
-the value $\mu n \beta^t$ equals the negative (modulo $\beta$) of the $t$'th digit of $x$ then the addition will result in a zero digit. This
-problem breaks down to solving the following congruency.
-
-\begin{center}
-\begin{tabular}{rcl}
-$x_t + \mu n_0$ & $\equiv$ & $0 \mbox{ (mod }\beta\mbox{)}$ \\
-$\mu n_0$ & $\equiv$ & $-x_t \mbox{ (mod }\beta\mbox{)}$ \\
-$\mu$ & $\equiv$ & $-x_t/n_0 \mbox{ (mod }\beta\mbox{)}$ \\
-\end{tabular}
-\end{center}
-
-In each iteration of the loop on step 1 a new value of $\mu$ must be calculated. The value of $-1/n_0 \mbox{ (mod }\beta\mbox{)}$ is used
-extensively in this algorithm and should be precomputed. Let $\rho$ represent the negative of the modular inverse of $n_0$ modulo $\beta$.
-
-For example, let $\beta = 10$ represent the radix. Let $n = 17$ represent the modulus which implies $k = 2$ and $\rho \equiv 7$. Let $x = 33$
-represent the value to reduce.
-
-\newpage\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Step ($t$)} & \textbf{Value of $x$} & \textbf{Value of $\mu$} \\
-\hline -- & $33$ & --\\
-\hline $0$ & $33 + \mu n = 50$ & $1$ \\
-\hline $1$ & $50 + \mu n \beta = 900$ & $5$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Montgomery Reduction}
-\end{figure}
-
-The final result $900$ is then divided by $\beta^k$ to produce the final result $9$. The first observation is that $9 \nequiv x \mbox{ (mod }n\mbox{)}$
-which implies the result is not the modular residue of $x$ modulo $n$. However, recall that the residue is actually multiplied by $\beta^{-k}$ in
-the algorithm. To get the true residue the value must be multiplied by $\beta^k$. In this case $\beta^k \equiv 15 \mbox{ (mod }n\mbox{)}$ and
-the correct residue is $9 \cdot 15 \equiv 16 \mbox{ (mod }n\mbox{)}$.
-
-\subsection{Baseline Montgomery Reduction}
-The baseline Montgomery reduction algorithm will produce the residue for any size input. It is designed to be a catch-all algororithm for
-Montgomery reductions.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_montgomery\_reduce}. \\
-\textbf{Input}. mp\_int $x$, mp\_int $n$ and a digit $\rho \equiv -1/n_0 \mbox{ (mod }n\mbox{)}$. \\
-\hspace{11.5mm}($0 \le x < n^2, n > 1, (n, \beta) = 1, \beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. $digs \leftarrow 2n.used + 1$ \\
-2. If $digs < MP\_ARRAY$ and $m.used < \delta$ then \\
-\hspace{3mm}2.1 Use algorithm fast\_mp\_montgomery\_reduce instead. \\
-\\
-Setup $x$ for the reduction. \\
-3. If $x.alloc < digs$ then grow $x$ to $digs$ digits. \\
-4. $x.used \leftarrow digs$ \\
-\\
-Eliminate the lower $k$ digits. \\
-5. For $ix$ from $0$ to $k - 1$ do \\
-\hspace{3mm}5.1 $\mu \leftarrow x_{ix} \cdot \rho \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}5.2 $u \leftarrow 0$ \\
-\hspace{3mm}5.3 For $iy$ from $0$ to $k - 1$ do \\
-\hspace{6mm}5.3.1 $\hat r \leftarrow \mu n_{iy} + x_{ix + iy} + u$ \\
-\hspace{6mm}5.3.2 $x_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}5.3.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}5.4 While $u > 0$ do \\
-\hspace{6mm}5.4.1 $iy \leftarrow iy + 1$ \\
-\hspace{6mm}5.4.2 $x_{ix + iy} \leftarrow x_{ix + iy} + u$ \\
-\hspace{6mm}5.4.3 $u \leftarrow \lfloor x_{ix+iy} / \beta \rfloor$ \\
-\hspace{6mm}5.4.4 $x_{ix + iy} \leftarrow x_{ix+iy} \mbox{ (mod }\beta\mbox{)}$ \\
-\\
-Divide by $\beta^k$ and fix up as required. \\
-6. $x \leftarrow \lfloor x / \beta^k \rfloor$ \\
-7. If $x \ge n$ then \\
-\hspace{3mm}7.1 $x \leftarrow x - n$ \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_montgomery\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_montgomery\_reduce.}
-This algorithm reduces the input $x$ modulo $n$ in place using the Montgomery reduction algorithm. The algorithm is loosely based
-on algorithm 14.32 of \cite[pp.601]{HAC} except it merges the multiplication of $\mu n \beta^t$ with the addition in the inner loop. The
-restrictions on this algorithm are fairly easy to adapt to. First $0 \le x < n^2$ bounds the input to numbers in the same range as
-for the Barrett algorithm. Additionally if $n > 1$ and $n$ is odd there will exist a modular inverse $\rho$. $\rho$ must be calculated in
-advance of this algorithm. Finally the variable $k$ is fixed and a pseudonym for $n.used$.
-
-Step 2 decides whether a faster Montgomery algorithm can be used. It is based on the Comba technique meaning that there are limits on
-the size of the input. This algorithm is discussed in ~COMBARED~.
-
-Step 5 is the main reduction loop of the algorithm. The value of $\mu$ is calculated once per iteration in the outer loop. The inner loop
-calculates $x + \mu n \beta^{ix}$ by multiplying $\mu n$ and adding the result to $x$ shifted by $ix$ digits. Both the addition and
-multiplication are performed in the same loop to save time and memory. Step 5.4 will handle any additional carries that escape the inner loop.
-
-Using a quick inspection this algorithm requires $n$ single precision multiplications for the outer loop and $n^2$ single precision multiplications
-in the inner loop. In total $n^2 + n$ single precision multiplications which compares favourably to Barrett at $n^2 + 2n - 1$ single precision
-multiplications.
-
-EXAM,bn_mp_montgomery_reduce.c
-
-This is the baseline implementation of the Montgomery reduction algorithm. Lines @30,digs@ to @35,}@ determine if the Comba based
-routine can be used instead. Line @47,mu@ computes the value of $\mu$ for that particular iteration of the outer loop.
-
-The multiplication $\mu n \beta^{ix}$ is performed in one step in the inner loop. The alias $tmpx$ refers to the $ix$'th digit of $x$ and
-the alias $tmpn$ refers to the modulus $n$.
-
-\subsection{Faster ``Comba'' Montgomery Reduction}
-MARK,COMBARED
-
-The Montgomery reduction requires fewer single precision multiplications than a Barrett reduction, however it is much slower due to the serial
-nature of the inner loop. The Barrett reduction algorithm requires two slightly modified multipliers which can be implemented with the Comba
-technique. The Montgomery reduction algorithm cannot directly use the Comba technique to any significant advantage since the inner loop calculates
-a $k \times 1$ product $k$ times.
-
-The biggest obstacle is that at the $ix$'th iteration of the outer loop the value of $x_{ix}$ is required to calculate $\mu$. This means the
-carries from $0$ to $ix - 1$ must have been propagated upwards to form a valid $ix$'th digit. The solution as it turns out is very simple.
-Perform a Comba like multiplier and inside the outer loop just after the inner loop fix up the $ix + 1$'th digit by forwarding the carry.
-
-With this change in place the Montgomery reduction algorithm can be performed with a Comba style multiplication loop which substantially increases
-the speed of the algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_mp\_montgomery\_reduce}. \\
-\textbf{Input}. mp\_int $x$, mp\_int $n$ and a digit $\rho \equiv -1/n_0 \mbox{ (mod }n\mbox{)}$. \\
-\hspace{11.5mm}($0 \le x < n^2, n > 1, (n, \beta) = 1, \beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} mp\_word variables called $\hat W$ on the stack. \\
-1. if $x.alloc < n.used + 1$ then grow $x$ to $n.used + 1$ digits. \\
-Copy the digits of $x$ into the array $\hat W$ \\
-2. For $ix$ from $0$ to $x.used - 1$ do \\
-\hspace{3mm}2.1 $\hat W_{ix} \leftarrow x_{ix}$ \\
-3. For $ix$ from $x.used$ to $2n.used - 1$ do \\
-\hspace{3mm}3.1 $\hat W_{ix} \leftarrow 0$ \\
-Elimiate the lower $k$ digits. \\
-4. for $ix$ from $0$ to $n.used - 1$ do \\
-\hspace{3mm}4.1 $\mu \leftarrow \hat W_{ix} \cdot \rho \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}4.2 For $iy$ from $0$ to $n.used - 1$ do \\
-\hspace{6mm}4.2.1 $\hat W_{iy + ix} \leftarrow \hat W_{iy + ix} + \mu \cdot n_{iy}$ \\
-\hspace{3mm}4.3 $\hat W_{ix + 1} \leftarrow \hat W_{ix + 1} + \lfloor \hat W_{ix} / \beta \rfloor$ \\
-Propagate carries upwards. \\
-5. for $ix$ from $n.used$ to $2n.used + 1$ do \\
-\hspace{3mm}5.1 $\hat W_{ix + 1} \leftarrow \hat W_{ix + 1} + \lfloor \hat W_{ix} / \beta \rfloor$ \\
-Shift right and reduce modulo $\beta$ simultaneously. \\
-6. for $ix$ from $0$ to $n.used + 1$ do \\
-\hspace{3mm}6.1 $x_{ix} \leftarrow \hat W_{ix + n.used} \mbox{ (mod }\beta\mbox{)}$ \\
-Zero excess digits and fixup $x$. \\
-7. if $x.used > n.used + 1$ then do \\
-\hspace{3mm}7.1 for $ix$ from $n.used + 1$ to $x.used - 1$ do \\
-\hspace{6mm}7.1.1 $x_{ix} \leftarrow 0$ \\
-8. $x.used \leftarrow n.used + 1$ \\
-9. Clamp excessive digits of $x$. \\
-10. If $x \ge n$ then \\
-\hspace{3mm}10.1 $x \leftarrow x - n$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_mp\_montgomery\_reduce}
-\end{figure}
-
-\textbf{Algorithm fast\_mp\_montgomery\_reduce.}
-This algorithm will compute the Montgomery reduction of $x$ modulo $n$ using the Comba technique. It is on most computer platforms significantly
-faster than algorithm mp\_montgomery\_reduce and algorithm mp\_reduce (\textit{Barrett reduction}). The algorithm has the same restrictions
-on the input as the baseline reduction algorithm. An additional two restrictions are imposed on this algorithm. The number of digits $k$ in the
-the modulus $n$ must not violate $MP\_WARRAY > 2k +1$ and $n < \delta$. When $\beta = 2^{28}$ this algorithm can be used to reduce modulo
-a modulus of at most $3,556$ bits in length.
-
-As in the other Comba reduction algorithms there is a $\hat W$ array which stores the columns of the product. It is initially filled with the
-contents of $x$ with the excess digits zeroed. The reduction loop is very similar the to the baseline loop at heart. The multiplication on step
-4.1 can be single precision only since $ab \mbox{ (mod }\beta\mbox{)} \equiv (a \mbox{ mod }\beta)(b \mbox{ mod }\beta)$. Some multipliers such
-as those on the ARM processors take a variable length time to complete depending on the number of bytes of result it must produce. By performing
-a single precision multiplication instead half the amount of time is spent.
-
-Also note that digit $\hat W_{ix}$ must have the carry from the $ix - 1$'th digit propagated upwards in order for this to work. That is what step
-4.3 will do. In effect over the $n.used$ iterations of the outer loop the $n.used$'th lower columns all have the their carries propagated forwards. Note
-how the upper bits of those same words are not reduced modulo $\beta$. This is because those values will be discarded shortly and there is no
-point.
-
-Step 5 will propagate the remainder of the carries upwards. On step 6 the columns are reduced modulo $\beta$ and shifted simultaneously as they are
-stored in the destination $x$.
-
-EXAM,bn_fast_mp_montgomery_reduce.c
-
-The $\hat W$ array is first filled with digits of $x$ on line @49,for@ then the rest of the digits are zeroed on line @54,for@. Both loops share
-the same alias variables to make the code easier to read.
-
-The value of $\mu$ is calculated in an interesting fashion. First the value $\hat W_{ix}$ is reduced modulo $\beta$ and cast to a mp\_digit. This
-forces the compiler to use a single precision multiplication and prevents any concerns about loss of precision. Line @101,>>@ fixes the carry
-for the next iteration of the loop by propagating the carry from $\hat W_{ix}$ to $\hat W_{ix+1}$.
-
-The for loop on line @113,for@ propagates the rest of the carries upwards through the columns. The for loop on line @126,for@ reduces the columns
-modulo $\beta$ and shifts them $k$ places at the same time. The alias $\_ \hat W$ actually refers to the array $\hat W$ starting at the $n.used$'th
-digit, that is $\_ \hat W_{t} = \hat W_{n.used + t}$.
-
-\subsection{Montgomery Setup}
-To calculate the variable $\rho$ a relatively simple algorithm will be required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_montgomery\_setup}. \\
-\textbf{Input}. mp\_int $n$ ($n > 1$ and $(n, 2) = 1$) \\
-\textbf{Output}. $\rho \equiv -1/n_0 \mbox{ (mod }\beta\mbox{)}$ \\
-\hline \\
-1. $b \leftarrow n_0$ \\
-2. If $b$ is even return(\textit{MP\_VAL}) \\
-3. $x \leftarrow (((b + 2) \mbox{ AND } 4) << 1) + b$ \\
-4. for $k$ from 0 to $\lceil lg(lg(\beta)) \rceil - 2$ do \\
-\hspace{3mm}4.1 $x \leftarrow x \cdot (2 - bx)$ \\
-5. $\rho \leftarrow \beta - x \mbox{ (mod }\beta\mbox{)}$ \\
-6. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_montgomery\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_montgomery\_setup.}
-This algorithm will calculate the value of $\rho$ required within the Montgomery reduction algorithms. It uses a very interesting trick
-to calculate $1/n_0$ when $\beta$ is a power of two.
-
-EXAM,bn_mp_montgomery_setup.c
-
-This source code computes the value of $\rho$ required to perform Montgomery reduction. It has been modified to avoid performing excess
-multiplications when $\beta$ is not the default 28-bits.
-
-\section{The Diminished Radix Algorithm}
-The Diminished Radix method of modular reduction \cite{DRMET} is a fairly clever technique which can be more efficient than either the Barrett
-or Montgomery methods for certain forms of moduli. The technique is based on the following simple congruence.
-
-\begin{equation}
-(x \mbox{ mod } n) + k \lfloor x / n \rfloor \equiv x \mbox{ (mod }(n - k)\mbox{)}
-\end{equation}
-
-This observation was used in the MMB \cite{MMB} block cipher to create a diffusion primitive. It used the fact that if $n = 2^{31}$ and $k=1$ that
-then a x86 multiplier could produce the 62-bit product and use the ``shrd'' instruction to perform a double-precision right shift. The proof
-of the above equation is very simple. First write $x$ in the product form.
-
-\begin{equation}
-x = qn + r
-\end{equation}
-
-Now reduce both sides modulo $(n - k)$.
-
-\begin{equation}
-x \equiv qk + r \mbox{ (mod }(n-k)\mbox{)}
-\end{equation}
-
-The variable $n$ reduces modulo $n - k$ to $k$. By putting $q = \lfloor x/n \rfloor$ and $r = x \mbox{ mod } n$
-into the equation the original congruence is reproduced, thus concluding the proof. The following algorithm is based on this observation.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Diminished Radix Reduction}. \\
-\textbf{Input}. Integer $x$, $n$, $k$ \\
-\textbf{Output}. $x \mbox{ mod } (n - k)$ \\
-\hline \\
-1. $q \leftarrow \lfloor x / n \rfloor$ \\
-2. $q \leftarrow k \cdot q$ \\
-3. $x \leftarrow x \mbox{ (mod }n\mbox{)}$ \\
-4. $x \leftarrow x + q$ \\
-5. If $x \ge (n - k)$ then \\
-\hspace{3mm}5.1 $x \leftarrow x - (n - k)$ \\
-\hspace{3mm}5.2 Goto step 1. \\
-6. Return $x$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Diminished Radix Reduction}
-\label{fig:DR}
-\end{figure}
-
-This algorithm will reduce $x$ modulo $n - k$ and return the residue. If $0 \le x < (n - k)^2$ then the algorithm will loop almost always
-once or twice and occasionally three times. For simplicity sake the value of $x$ is bounded by the following simple polynomial.
-
-\begin{equation}
-0 \le x < n^2 + k^2 - 2nk
-\end{equation}
-
-The true bound is $0 \le x < (n - k - 1)^2$ but this has quite a few more terms. The value of $q$ after step 1 is bounded by the following.
-
-\begin{equation}
-q < n - 2k - k^2/n
-\end{equation}
-
-Since $k^2$ is going to be considerably smaller than $n$ that term will always be zero. The value of $x$ after step 3 is bounded trivially as
-$0 \le x < n$. By step four the sum $x + q$ is bounded by
-
-\begin{equation}
-0 \le q + x < (k + 1)n - 2k^2 - 1
-\end{equation}
-
-With a second pass $q$ will be loosely bounded by $0 \le q < k^2$ after step 2 while $x$ will still be loosely bounded by $0 \le x < n$ after step 3. After the second pass it is highly unlike that the
-sum in step 4 will exceed $n - k$. In practice fewer than three passes of the algorithm are required to reduce virtually every input in the
-range $0 \le x < (n - k - 1)^2$.
-
-\begin{figure}
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|}
-\hline
-$x = 123456789, n = 256, k = 3$ \\
-\hline $q \leftarrow \lfloor x/n \rfloor = 482253$ \\
-$q \leftarrow q*k = 1446759$ \\
-$x \leftarrow x \mbox{ mod } n = 21$ \\
-$x \leftarrow x + q = 1446780$ \\
-$x \leftarrow x - (n - k) = 1446527$ \\
-\hline
-$q \leftarrow \lfloor x/n \rfloor = 5650$ \\
-$q \leftarrow q*k = 16950$ \\
-$x \leftarrow x \mbox{ mod } n = 127$ \\
-$x \leftarrow x + q = 17077$ \\
-$x \leftarrow x - (n - k) = 16824$ \\
-\hline
-$q \leftarrow \lfloor x/n \rfloor = 65$ \\
-$q \leftarrow q*k = 195$ \\
-$x \leftarrow x \mbox{ mod } n = 184$ \\
-$x \leftarrow x + q = 379$ \\
-$x \leftarrow x - (n - k) = 126$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example Diminished Radix Reduction}
-\label{fig:EXDR}
-\end{figure}
-
-Figure~\ref{fig:EXDR} demonstrates the reduction of $x = 123456789$ modulo $n - k = 253$ when $n = 256$ and $k = 3$. Note that even while $x$
-is considerably larger than $(n - k - 1)^2 = 63504$ the algorithm still converges on the modular residue exceedingly fast. In this case only
-three passes were required to find the residue $x \equiv 126$.
-
-
-\subsection{Choice of Moduli}
-On the surface this algorithm looks like a very expensive algorithm. It requires a couple of subtractions followed by multiplication and other
-modular reductions. The usefulness of this algorithm becomes exceedingly clear when an appropriate modulus is chosen.
-
-Division in general is a very expensive operation to perform. The one exception is when the division is by a power of the radix of representation used.
-Division by ten for example is simple for pencil and paper mathematics since it amounts to shifting the decimal place to the right. Similarly division
-by two (\textit{or powers of two}) is very simple for binary computers to perform. It would therefore seem logical to choose $n$ of the form $2^p$
-which would imply that $\lfloor x / n \rfloor$ is a simple shift of $x$ right $p$ bits.
-
-However, there is one operation related to division of power of twos that is even faster than this. If $n = \beta^p$ then the division may be
-performed by moving whole digits to the right $p$ places. In practice division by $\beta^p$ is much faster than division by $2^p$ for any $p$.
-Also with the choice of $n = \beta^p$ reducing $x$ modulo $n$ merely requires zeroing the digits above the $p-1$'th digit of $x$.
-
-Throughout the next section the term ``restricted modulus'' will refer to a modulus of the form $\beta^p - k$ whereas the term ``unrestricted
-modulus'' will refer to a modulus of the form $2^p - k$. The word ``restricted'' in this case refers to the fact that it is based on the
-$2^p$ logic except $p$ must be a multiple of $lg(\beta)$.
-
-\subsection{Choice of $k$}
-Now that division and reduction (\textit{step 1 and 3 of figure~\ref{fig:DR}}) have been optimized to simple digit operations the multiplication by $k$
-in step 2 is the most expensive operation. Fortunately the choice of $k$ is not terribly limited. For all intents and purposes it might
-as well be a single digit. The smaller the value of $k$ is the faster the algorithm will be.
-
-\subsection{Restricted Diminished Radix Reduction}
-The restricted Diminished Radix algorithm can quickly reduce an input modulo a modulus of the form $n = \beta^p - k$. This algorithm can reduce
-an input $x$ within the range $0 \le x < n^2$ using only a couple passes of the algorithm demonstrated in figure~\ref{fig:DR}. The implementation
-of this algorithm has been optimized to avoid additional overhead associated with a division by $\beta^p$, the multiplication by $k$ or the addition
-of $x$ and $q$. The resulting algorithm is very efficient and can lead to substantial improvements over Barrett and Montgomery reduction when modular
-exponentiations are performed.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_reduce}. \\
-\textbf{Input}. mp\_int $x$, $n$ and a mp\_digit $k = \beta - n_0$ \\
-\hspace{11.5mm}($0 \le x < n^2$, $n > 1$, $0 < k < \beta$) \\
-\textbf{Output}. $x \mbox{ mod } n$ \\
-\hline \\
-1. $m \leftarrow n.used$ \\
-2. If $x.alloc < 2m$ then grow $x$ to $2m$ digits. \\
-3. $\mu \leftarrow 0$ \\
-4. for $i$ from $0$ to $m - 1$ do \\
-\hspace{3mm}4.1 $\hat r \leftarrow k \cdot x_{m+i} + x_{i} + \mu$ \\
-\hspace{3mm}4.2 $x_{i} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}4.3 $\mu \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-5. $x_{m} \leftarrow \mu$ \\
-6. for $i$ from $m + 1$ to $x.used - 1$ do \\
-\hspace{3mm}6.1 $x_{i} \leftarrow 0$ \\
-7. Clamp excess digits of $x$. \\
-8. If $x \ge n$ then \\
-\hspace{3mm}8.1 $x \leftarrow x - n$ \\
-\hspace{3mm}8.2 Goto step 3. \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_dr\_reduce.}
-This algorithm will perform the Dimished Radix reduction of $x$ modulo $n$. It has similar restrictions to that of the Barrett reduction
-with the addition that $n$ must be of the form $n = \beta^m - k$ where $0 < k <\beta$.
-
-This algorithm essentially implements the pseudo-code in figure~\ref{fig:DR} except with a slight optimization. The division by $\beta^m$, multiplication by $k$
-and addition of $x \mbox{ mod }\beta^m$ are all performed simultaneously inside the loop on step 4. The division by $\beta^m$ is emulated by accessing
-the term at the $m+i$'th position which is subsequently multiplied by $k$ and added to the term at the $i$'th position. After the loop the $m$'th
-digit is set to the carry and the upper digits are zeroed. Steps 5 and 6 emulate the reduction modulo $\beta^m$ that should have happend to
-$x$ before the addition of the multiple of the upper half.
-
-At step 8 if $x$ is still larger than $n$ another pass of the algorithm is required. First $n$ is subtracted from $x$ and then the algorithm resumes
-at step 3.
-
-EXAM,bn_mp_dr_reduce.c
-
-The first step is to grow $x$ as required to $2m$ digits since the reduction is performed in place on $x$. The label on line @49,top:@ is where
-the algorithm will resume if further reduction passes are required. In theory it could be placed at the top of the function however, the size of
-the modulus and question of whether $x$ is large enough are invariant after the first pass meaning that it would be a waste of time.
-
-The aliases $tmpx1$ and $tmpx2$ refer to the digits of $x$ where the latter is offset by $m$ digits. By reading digits from $x$ offset by $m$ digits
-a division by $\beta^m$ can be simulated virtually for free. The loop on line @61,for@ performs the bulk of the work (\textit{corresponds to step 4 of algorithm 7.11})
-in this algorithm.
-
-By line @68,mu@ the pointer $tmpx1$ points to the $m$'th digit of $x$ which is where the final carry will be placed. Similarly by line @71,for@ the
-same pointer will point to the $m+1$'th digit where the zeroes will be placed.
-
-Since the algorithm is only valid if both $x$ and $n$ are greater than zero an unsigned comparison suffices to determine if another pass is required.
-With the same logic at line @82,sub@ the value of $x$ is known to be greater than or equal to $n$ meaning that an unsigned subtraction can be used
-as well. Since the destination of the subtraction is the larger of the inputs the call to algorithm s\_mp\_sub cannot fail and the return code
-does not need to be checked.
-
-\subsubsection{Setup}
-To setup the restricted Diminished Radix algorithm the value $k = \beta - n_0$ is required. This algorithm is not really complicated but provided for
-completeness.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_setup}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $k = \beta - n_0$ \\
-\hline \\
-1. $k \leftarrow \beta - n_0$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_setup}
-\end{figure}
-
-EXAM,bn_mp_dr_setup.c
-
-\subsubsection{Modulus Detection}
-Another algorithm which will be useful is the ability to detect a restricted Diminished Radix modulus. An integer is said to be
-of restricted Diminished Radix form if all of the digits are equal to $\beta - 1$ except the trailing digit which may be any value.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_is\_modulus}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $1$ if $n$ is in D.R form, $0$ otherwise \\
-\hline
-1. If $n.used < 2$ then return($0$). \\
-2. for $ix$ from $1$ to $n.used - 1$ do \\
-\hspace{3mm}2.1 If $n_{ix} \ne \beta - 1$ return($0$). \\
-3. Return($1$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_is\_modulus}
-\end{figure}
-
-\textbf{Algorithm mp\_dr\_is\_modulus.}
-This algorithm determines if a value is in Diminished Radix form. Step 1 rejects obvious cases where fewer than two digits are
-in the mp\_int. Step 2 tests all but the first digit to see if they are equal to $\beta - 1$. If the algorithm manages to get to
-step 3 then $n$ must be of Diminished Radix form.
-
-EXAM,bn_mp_dr_is_modulus.c
-
-\subsection{Unrestricted Diminished Radix Reduction}
-The unrestricted Diminished Radix algorithm allows modular reductions to be performed when the modulus is of the form $2^p - k$. This algorithm
-is a straightforward adaptation of algorithm~\ref{fig:DR}.
-
-In general the restricted Diminished Radix reduction algorithm is much faster since it has considerably lower overhead. However, this new
-algorithm is much faster than either Montgomery or Barrett reduction when the moduli are of the appropriate form.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_2k}. \\
-\textbf{Input}. mp\_int $a$ and $n$. mp\_digit $k$ \\
-\hspace{11.5mm}($a \ge 0$, $n > 1$, $0 < k < \beta$, $n + k$ is a power of two) \\
-\textbf{Output}. $a \mbox{ (mod }n\mbox{)}$ \\
-\hline
-1. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-2. While $a \ge n$ do \\
-\hspace{3mm}2.1 $q \leftarrow \lfloor a / 2^p \rfloor$ (\textit{mp\_div\_2d}) \\
-\hspace{3mm}2.2 $a \leftarrow a \mbox{ (mod }2^p\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-\hspace{3mm}2.3 $q \leftarrow q \cdot k$ (\textit{mp\_mul\_d}) \\
-\hspace{3mm}2.4 $a \leftarrow a - q$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.5 If $a \ge n$ then do \\
-\hspace{6mm}2.5.1 $a \leftarrow a - n$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_2k}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_2k.}
-This algorithm quickly reduces an input $a$ modulo an unrestricted Diminished Radix modulus $n$. Division by $2^p$ is emulated with a right
-shift which makes the algorithm fairly inexpensive to use.
-
-EXAM,bn_mp_reduce_2k.c
-
-The algorithm mp\_count\_bits calculates the number of bits in an mp\_int which is used to find the initial value of $p$. The call to mp\_div\_2d
-on line @31,mp_div_2d@ calculates both the quotient $q$ and the remainder $a$ required. By doing both in a single function call the code size
-is kept fairly small. The multiplication by $k$ is only performed if $k > 1$. This allows reductions modulo $2^p - 1$ to be performed without
-any multiplications.
-
-The unsigned s\_mp\_add, mp\_cmp\_mag and s\_mp\_sub are used in place of their full sign counterparts since the inputs are only valid if they are
-positive. By using the unsigned versions the overhead is kept to a minimum.
-
-\subsubsection{Unrestricted Setup}
-To setup this reduction algorithm the value of $k = 2^p - n$ is required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_2k\_setup}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $k = 2^p - n$ \\
-\hline
-1. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-2. $x \leftarrow 2^p$ (\textit{mp\_2expt}) \\
-3. $x \leftarrow x - n$ (\textit{mp\_sub}) \\
-4. $k \leftarrow x_0$ \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_2k\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_2k\_setup.}
-This algorithm computes the value of $k$ required for the algorithm mp\_reduce\_2k. By making a temporary variable $x$ equal to $2^p$ a subtraction
-is sufficient to solve for $k$. Alternatively if $n$ has more than one digit the value of $k$ is simply $\beta - n_0$.
-
-EXAM,bn_mp_reduce_2k_setup.c
-
-\subsubsection{Unrestricted Detection}
-An integer $n$ is a valid unrestricted Diminished Radix modulus if either of the following are true.
-
-\begin{enumerate}
-\item The number has only one digit.
-\item The number has more than one digit and every bit from the $\beta$'th to the most significant is one.
-\end{enumerate}
-
-If either condition is true than there is a power of two $2^p$ such that $0 < 2^p - n < \beta$. If the input is only
-one digit than it will always be of the correct form. Otherwise all of the bits above the first digit must be one. This arises from the fact
-that there will be value of $k$ that when added to the modulus causes a carry in the first digit which propagates all the way to the most
-significant bit. The resulting sum will be a power of two.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_is\_2k}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $1$ if of proper form, $0$ otherwise \\
-\hline
-1. If $n.used = 0$ then return($0$). \\
-2. If $n.used = 1$ then return($1$). \\
-3. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-4. for $x$ from $lg(\beta)$ to $p$ do \\
-\hspace{3mm}4.1 If the ($x \mbox{ mod }lg(\beta)$)'th bit of the $\lfloor x / lg(\beta) \rfloor$ of $n$ is zero then return($0$). \\
-5. Return($1$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_is\_2k}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_is\_2k.}
-This algorithm quickly determines if a modulus is of the form required for algorithm mp\_reduce\_2k to function properly.
-
-EXAM,bn_mp_reduce_is_2k.c
-
-
-
-\section{Algorithm Comparison}
-So far three very different algorithms for modular reduction have been discussed. Each of the algorithms have their own strengths and weaknesses
-that makes having such a selection very useful. The following table sumarizes the three algorithms along with comparisons of work factors. Since
-all three algorithms have the restriction that $0 \le x < n^2$ and $n > 1$ those limitations are not included in the table.
-
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Method} & \textbf{Work Required} & \textbf{Limitations} & \textbf{$m = 8$} & \textbf{$m = 32$} & \textbf{$m = 64$} \\
-\hline Barrett & $m^2 + 2m - 1$ & None & $79$ & $1087$ & $4223$ \\
-\hline Montgomery & $m^2 + m$ & $n$ must be odd & $72$ & $1056$ & $4160$ \\
-\hline D.R. & $2m$ & $n = \beta^m - k$ & $16$ & $64$ & $128$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-
-In theory Montgomery and Barrett reductions would require roughly the same amount of time to complete. However, in practice since Montgomery
-reduction can be written as a single function with the Comba technique it is much faster. Barrett reduction suffers from the overhead of
-calling the half precision multipliers, addition and division by $\beta$ algorithms.
-
-For almost every cryptographic algorithm Montgomery reduction is the algorithm of choice. The one set of algorithms where Diminished Radix reduction truly
-shines are based on the discrete logarithm problem such as Diffie-Hellman \cite{DH} and ElGamal \cite{ELGAMAL}. In these algorithms
-primes of the form $\beta^m - k$ can be found and shared amongst users. These primes will allow the Diminished Radix algorithm to be used in
-modular exponentiation to greatly speed up the operation.
-
-
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ]$ & Prove that the ``trick'' in algorithm mp\_montgomery\_setup actually \\
- & calculates the correct value of $\rho$. \\
- & \\
-$\left [ 2 \right ]$ & Devise an algorithm to reduce modulo $n + k$ for small $k$ quickly. \\
- & \\
-$\left [ 4 \right ]$ & Prove that the pseudo-code algorithm ``Diminished Radix Reduction'' \\
- & (\textit{figure~\ref{fig:DR}}) terminates. Also prove the probability that it will \\
- & terminate within $1 \le k \le 10$ iterations. \\
- & \\
-\end{tabular}
-
-
-\chapter{Exponentiation}
-Exponentiation is the operation of raising one variable to the power of another, for example, $a^b$. A variant of exponentiation, computed
-in a finite field or ring, is called modular exponentiation. This latter style of operation is typically used in public key
-cryptosystems such as RSA and Diffie-Hellman. The ability to quickly compute modular exponentiations is of great benefit to any
-such cryptosystem and many methods have been sought to speed it up.
-
-\section{Exponentiation Basics}
-A trivial algorithm would simply multiply $a$ against itself $b - 1$ times to compute the exponentiation desired. However, as $b$ grows in size
-the number of multiplications becomes prohibitive. Imagine what would happen if $b$ $\approx$ $2^{1024}$ as is the case when computing an RSA signature
-with a $1024$-bit key. Such a calculation could never be completed as it would take simply far too long.
-
-Fortunately there is a very simple algorithm based on the laws of exponents. Recall that $lg_a(a^b) = b$ and that $lg_a(a^ba^c) = b + c$ which
-are two trivial relationships between the base and the exponent. Let $b_i$ represent the $i$'th bit of $b$ starting from the least
-significant bit. If $b$ is a $k$-bit integer than the following equation is true.
-
-\begin{equation}
-a^b = \prod_{i=0}^{k-1} a^{2^i \cdot b_i}
-\end{equation}
-
-By taking the base $a$ logarithm of both sides of the equation the following equation is the result.
-
-\begin{equation}
-b = \sum_{i=0}^{k-1}2^i \cdot b_i
-\end{equation}
-
-The term $a^{2^i}$ can be found from the $i - 1$'th term by squaring the term since $\left ( a^{2^i} \right )^2$ is equal to
-$a^{2^{i+1}}$. This observation forms the basis of essentially all fast exponentiation algorithms. It requires $k$ squarings and on average
-$k \over 2$ multiplications to compute the result. This is indeed quite an improvement over simply multiplying by $a$ a total of $b-1$ times.
-
-While this current method is a considerable speed up there are further improvements to be made. For example, the $a^{2^i}$ term does not need to
-be computed in an auxilary variable. Consider the following equivalent algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Left to Right Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$ and $k$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $k - 1$ to $0$ do \\
-\hspace{3mm}2.1 $c \leftarrow c^2$ \\
-\hspace{3mm}2.2 $c \leftarrow c \cdot a^{b_i}$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Left to Right Exponentiation}
-\label{fig:LTOR}
-\end{figure}
-
-This algorithm starts from the most significant bit and works towards the least significant bit. When the $i$'th bit of $b$ is set $a$ is
-multiplied against the current product. In each iteration the product is squared which doubles the exponent of the individual terms of the
-product.
-
-For example, let $b = 101100_2 \equiv 44_{10}$. The following chart demonstrates the actions of the algorithm.
-
-\newpage\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|}
-\hline \textbf{Value of $i$} & \textbf{Value of $c$} \\
-\hline - & $1$ \\
-\hline $5$ & $a$ \\
-\hline $4$ & $a^2$ \\
-\hline $3$ & $a^4 \cdot a$ \\
-\hline $2$ & $a^8 \cdot a^2 \cdot a$ \\
-\hline $1$ & $a^{16} \cdot a^4 \cdot a^2$ \\
-\hline $0$ & $a^{32} \cdot a^8 \cdot a^4$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Left to Right Exponentiation}
-\end{figure}
-
-When the product $a^{32} \cdot a^8 \cdot a^4$ is simplified it is equal $a^{44}$ which is the desired exponentiation. This particular algorithm is
-called ``Left to Right'' because it reads the exponent in that order. All of the exponentiation algorithms that will be presented are of this nature.
-
-\subsection{Single Digit Exponentiation}
-The first algorithm in the series of exponentiation algorithms will be an unbounded algorithm where the exponent is a single digit. It is intended
-to be used when a small power of an input is required (\textit{e.g. $a^5$}). It is faster than simply multiplying $b - 1$ times for all values of
-$b$ that are greater than three.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_expt\_d}. \\
-\textbf{Input}. mp\_int $a$ and mp\_digit $b$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $g \leftarrow a$ (\textit{mp\_init\_copy}) \\
-2. $c \leftarrow 1$ (\textit{mp\_set}) \\
-3. for $x$ from 1 to $lg(\beta)$ do \\
-\hspace{3mm}3.1 $c \leftarrow c^2$ (\textit{mp\_sqr}) \\
-\hspace{3mm}3.2 If $b$ AND $2^{lg(\beta) - 1} \ne 0$ then \\
-\hspace{6mm}3.2.1 $c \leftarrow c \cdot g$ (\textit{mp\_mul}) \\
-\hspace{3mm}3.3 $b \leftarrow b << 1$ \\
-4. Clear $g$. \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_expt\_d}
-\end{figure}
-
-\textbf{Algorithm mp\_expt\_d.}
-This algorithm computes the value of $a$ raised to the power of a single digit $b$. It uses the left to right exponentiation algorithm to
-quickly compute the exponentiation. It is loosely based on algorithm 14.79 of HAC \cite[pp. 615]{HAC} with the difference that the
-exponent is a fixed width.
-
-A copy of $a$ is made first to allow destination variable $c$ be the same as the source variable $a$. The result is set to the initial value of
-$1$ in the subsequent step.
-
-Inside the loop the exponent is read from the most significant bit first down to the least significant bit. First $c$ is invariably squared
-on step 3.1. In the following step if the most significant bit of $b$ is one the copy of $a$ is multiplied against $c$. The value
-of $b$ is shifted left one bit to make the next bit down from the most signficant bit the new most significant bit. In effect each
-iteration of the loop moves the bits of the exponent $b$ upwards to the most significant location.
-
-EXAM,bn_mp_expt_d.c
-
-Line @29,mp_set@ sets the initial value of the result to $1$. Next the loop on line @31,for@ steps through each bit of the exponent starting from
-the most significant down towards the least significant. The invariant squaring operation placed on line @333,mp_sqr@ is performed first. After
-the squaring the result $c$ is multiplied by the base $g$ if and only if the most significant bit of the exponent is set. The shift on line
-@47,<<@ moves all of the bits of the exponent upwards towards the most significant location.
-
-\section{$k$-ary Exponentiation}
-When calculating an exponentiation the most time consuming bottleneck is the multiplications which are in general a small factor
-slower than squaring. Recall from the previous algorithm that $b_{i}$ refers to the $i$'th bit of the exponent $b$. Suppose instead it referred to
-the $i$'th $k$-bit digit of the exponent of $b$. For $k = 1$ the definitions are synonymous and for $k > 1$ algorithm~\ref{fig:KARY}
-computes the same exponentiation. A group of $k$ bits from the exponent is called a \textit{window}. That is it is a small window on only a
-portion of the entire exponent. Consider the following modification to the basic left to right exponentiation algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{$k$-ary Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$, $k$ and $t$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $t - 1$ to $0$ do \\
-\hspace{3mm}2.1 $c \leftarrow c^{2^k} $ \\
-\hspace{3mm}2.2 Extract the $i$'th $k$-bit word from $b$ and store it in $g$. \\
-\hspace{3mm}2.3 $c \leftarrow c \cdot a^g$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{$k$-ary Exponentiation}
-\label{fig:KARY}
-\end{figure}
-
-The squaring on step 2.1 can be calculated by squaring the value $c$ successively $k$ times. If the values of $a^g$ for $0 < g < 2^k$ have been
-precomputed this algorithm requires only $t$ multiplications and $tk$ squarings. The table can be generated with $2^{k - 1} - 1$ squarings and
-$2^{k - 1} + 1$ multiplications. This algorithm assumes that the number of bits in the exponent is evenly divisible by $k$.
-However, when it is not the remaining $0 < x \le k - 1$ bits can be handled with algorithm~\ref{fig:LTOR}.
-
-Suppose $k = 4$ and $t = 100$. This modified algorithm will require $109$ multiplications and $408$ squarings to compute the exponentiation. The
-original algorithm would on average have required $200$ multiplications and $400$ squrings to compute the same value. The total number of squarings
-has increased slightly but the number of multiplications has nearly halved.
-
-\subsection{Optimal Values of $k$}
-An optimal value of $k$ will minimize $2^{k} + \lceil n / k \rceil + n - 1$ for a fixed number of bits in the exponent $n$. The simplest
-approach is to brute force search amongst the values $k = 2, 3, \ldots, 8$ for the lowest result. Table~\ref{fig:OPTK} lists optimal values of $k$
-for various exponent sizes and compares the number of multiplication and squarings required against algorithm~\ref{fig:LTOR}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Exponent (bits)} & \textbf{Optimal $k$} & \textbf{Work at $k$} & \textbf{Work with ~\ref{fig:LTOR}} \\
-\hline $16$ & $2$ & $27$ & $24$ \\
-\hline $32$ & $3$ & $49$ & $48$ \\
-\hline $64$ & $3$ & $92$ & $96$ \\
-\hline $128$ & $4$ & $175$ & $192$ \\
-\hline $256$ & $4$ & $335$ & $384$ \\
-\hline $512$ & $5$ & $645$ & $768$ \\
-\hline $1024$ & $6$ & $1257$ & $1536$ \\
-\hline $2048$ & $6$ & $2452$ & $3072$ \\
-\hline $4096$ & $7$ & $4808$ & $6144$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Optimal Values of $k$ for $k$-ary Exponentiation}
-\label{fig:OPTK}
-\end{figure}
-
-\subsection{Sliding-Window Exponentiation}
-A simple modification to the previous algorithm is only generate the upper half of the table in the range $2^{k-1} \le g < 2^k$. Essentially
-this is a table for all values of $g$ where the most significant bit of $g$ is a one. However, in order for this to be allowed in the
-algorithm values of $g$ in the range $0 \le g < 2^{k-1}$ must be avoided.
-
-Table~\ref{fig:OPTK2} lists optimal values of $k$ for various exponent sizes and compares the work required against algorithm~\ref{fig:KARY}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Exponent (bits)} & \textbf{Optimal $k$} & \textbf{Work at $k$} & \textbf{Work with ~\ref{fig:KARY}} \\
-\hline $16$ & $3$ & $24$ & $27$ \\
-\hline $32$ & $3$ & $45$ & $49$ \\
-\hline $64$ & $4$ & $87$ & $92$ \\
-\hline $128$ & $4$ & $167$ & $175$ \\
-\hline $256$ & $5$ & $322$ & $335$ \\
-\hline $512$ & $6$ & $628$ & $645$ \\
-\hline $1024$ & $6$ & $1225$ & $1257$ \\
-\hline $2048$ & $7$ & $2403$ & $2452$ \\
-\hline $4096$ & $8$ & $4735$ & $4808$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Optimal Values of $k$ for Sliding Window Exponentiation}
-\label{fig:OPTK2}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Sliding Window $k$-ary Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$, $k$ and $t$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $t - 1$ to $0$ do \\
-\hspace{3mm}2.1 If the $i$'th bit of $b$ is a zero then \\
-\hspace{6mm}2.1.1 $c \leftarrow c^2$ \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c \leftarrow c^{2^k}$ \\
-\hspace{6mm}2.2.2 Extract the $k$ bits from $(b_{i}b_{i-1}\ldots b_{i-(k-1)})$ and store it in $g$. \\
-\hspace{6mm}2.2.3 $c \leftarrow c \cdot a^g$ \\
-\hspace{6mm}2.2.4 $i \leftarrow i - k$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Sliding Window $k$-ary Exponentiation}
-\end{figure}
-
-Similar to the previous algorithm this algorithm must have a special handler when fewer than $k$ bits are left in the exponent. While this
-algorithm requires the same number of squarings it can potentially have fewer multiplications. The pre-computed table $a^g$ is also half
-the size as the previous table.
-
-Consider the exponent $b = 111101011001000_2 \equiv 31432_{10}$ with $k = 3$ using both algorithms. The first algorithm will divide the exponent up as
-the following five $3$-bit words $b \equiv \left ( 111, 101, 011, 001, 000 \right )_{2}$. The second algorithm will break the
-exponent as $b \equiv \left ( 111, 101, 0, 110, 0, 100, 0 \right )_{2}$. The single digit $0$ in the second representation are where
-a single squaring took place instead of a squaring and multiplication. In total the first method requires $10$ multiplications and $18$
-squarings. The second method requires $8$ multiplications and $18$ squarings.
-
-In general the sliding window method is never slower than the generic $k$-ary method and often it is slightly faster.
-
-\section{Modular Exponentiation}
-
-Modular exponentiation is essentially computing the power of a base within a finite field or ring. For example, computing
-$d \equiv a^b \mbox{ (mod }c\mbox{)}$ is a modular exponentiation. Instead of first computing $a^b$ and then reducing it
-modulo $c$ the intermediate result is reduced modulo $c$ after every squaring or multiplication operation.
-
-This guarantees that any intermediate result is bounded by $0 \le d \le c^2 - 2c + 1$ and can be reduced modulo $c$ quickly using
-one of the algorithms presented in ~REDUCTION~.
-
-Before the actual modular exponentiation algorithm can be written a wrapper algorithm must be written first. This algorithm
-will allow the exponent $b$ to be negative which is computed as $c \equiv \left (1 / a \right )^{\vert b \vert} \mbox{(mod }d\mbox{)}$. The
-value of $(1/a) \mbox{ mod }c$ is computed using the modular inverse (\textit{see \ref{sec;modinv}}). If no inverse exists the algorithm
-terminates with an error.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_exptmod}. \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-1. If $c.sign = MP\_NEG$ return(\textit{MP\_VAL}). \\
-2. If $b.sign = MP\_NEG$ then \\
-\hspace{3mm}2.1 $g' \leftarrow g^{-1} \mbox{ (mod }c\mbox{)}$ \\
-\hspace{3mm}2.2 $x' \leftarrow \vert x \vert$ \\
-\hspace{3mm}2.3 Compute $d \equiv g'^{x'} \mbox{ (mod }c\mbox{)}$ via recursion. \\
-3. if $p$ is odd \textbf{OR} $p$ is a D.R. modulus then \\
-\hspace{3mm}3.1 Compute $y \equiv g^{x} \mbox{ (mod }p\mbox{)}$ via algorithm mp\_exptmod\_fast. \\
-4. else \\
-\hspace{3mm}4.1 Compute $y \equiv g^{x} \mbox{ (mod }p\mbox{)}$ via algorithm s\_mp\_exptmod. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_exptmod}
-\end{figure}
-
-\textbf{Algorithm mp\_exptmod.}
-The first algorithm which actually performs modular exponentiation is algorithm s\_mp\_exptmod. It is a sliding window $k$-ary algorithm
-which uses Barrett reduction to reduce the product modulo $p$. The second algorithm mp\_exptmod\_fast performs the same operation
-except it uses either Montgomery or Diminished Radix reduction. The two latter reduction algorithms are clumped in the same exponentiation
-algorithm since their arguments are essentially the same (\textit{two mp\_ints and one mp\_digit}).
-
-EXAM,bn_mp_exptmod.c
-
-In order to keep the algorithms in a known state the first step on line @29,if@ is to reject any negative modulus as input. If the exponent is
-negative the algorithm tries to perform a modular exponentiation with the modular inverse of the base $G$. The temporary variable $tmpG$ is assigned
-the modular inverse of $G$ and $tmpX$ is assigned the absolute value of $X$. The algorithm will recuse with these new values with a positive
-exponent.
-
-If the exponent is positive the algorithm resumes the exponentiation. Line @63,dr_@ determines if the modulus is of the restricted Diminished Radix
-form. If it is not line @65,reduce@ attempts to determine if it is of a unrestricted Diminished Radix form. The integer $dr$ will take on one
-of three values.
-
-\begin{enumerate}
-\item $dr = 0$ means that the modulus is not of either restricted or unrestricted Diminished Radix form.
-\item $dr = 1$ means that the modulus is of restricted Diminished Radix form.
-\item $dr = 2$ means that the modulus is of unrestricted Diminished Radix form.
-\end{enumerate}
-
-Line @69,if@ determines if the fast modular exponentiation algorithm can be used. It is allowed if $dr \ne 0$ or if the modulus is odd. Otherwise,
-the slower s\_mp\_exptmod algorithm is used which uses Barrett reduction.
-
-\subsection{Barrett Modular Exponentiation}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_exptmod}. \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-1. $k \leftarrow lg(x)$ \\
-2. $winsize \leftarrow \left \lbrace \begin{array}{ll}
- 2 & \mbox{if }k \le 7 \\
- 3 & \mbox{if }7 < k \le 36 \\
- 4 & \mbox{if }36 < k \le 140 \\
- 5 & \mbox{if }140 < k \le 450 \\
- 6 & \mbox{if }450 < k \le 1303 \\
- 7 & \mbox{if }1303 < k \le 3529 \\
- 8 & \mbox{if }3529 < k \\
- \end{array} \right .$ \\
-3. Initialize $2^{winsize}$ mp\_ints in an array named $M$ and one mp\_int named $\mu$ \\
-4. Calculate the $\mu$ required for Barrett Reduction (\textit{mp\_reduce\_setup}). \\
-5. $M_1 \leftarrow g \mbox{ (mod }p\mbox{)}$ \\
-\\
-Setup the table of small powers of $g$. First find $g^{2^{winsize}}$ and then all multiples of it. \\
-6. $k \leftarrow 2^{winsize - 1}$ \\
-7. $M_{k} \leftarrow M_1$ \\
-8. for $ix$ from 0 to $winsize - 2$ do \\
-\hspace{3mm}8.1 $M_k \leftarrow \left ( M_k \right )^2$ (\textit{mp\_sqr}) \\
-\hspace{3mm}8.2 $M_k \leftarrow M_k \mbox{ (mod }p\mbox{)}$ (\textit{mp\_reduce}) \\
-9. for $ix$ from $2^{winsize - 1} + 1$ to $2^{winsize} - 1$ do \\
-\hspace{3mm}9.1 $M_{ix} \leftarrow M_{ix - 1} \cdot M_{1}$ (\textit{mp\_mul}) \\
-\hspace{3mm}9.2 $M_{ix} \leftarrow M_{ix} \mbox{ (mod }p\mbox{)}$ (\textit{mp\_reduce}) \\
-10. $res \leftarrow 1$ \\
-\\
-Start Sliding Window. \\
-11. $mode \leftarrow 0, bitcnt \leftarrow 1, buf \leftarrow 0, digidx \leftarrow x.used - 1, bitcpy \leftarrow 0, bitbuf \leftarrow 0$ \\
-12. Loop \\
-\hspace{3mm}12.1 $bitcnt \leftarrow bitcnt - 1$ \\
-\hspace{3mm}12.2 If $bitcnt = 0$ then do \\
-\hspace{6mm}12.2.1 If $digidx = -1$ goto step 13. \\
-\hspace{6mm}12.2.2 $buf \leftarrow x_{digidx}$ \\
-\hspace{6mm}12.2.3 $digidx \leftarrow digidx - 1$ \\
-\hspace{6mm}12.2.4 $bitcnt \leftarrow lg(\beta)$ \\
-Continued on next page. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_exptmod}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_exptmod} (\textit{continued}). \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-\hspace{3mm}12.3 $y \leftarrow (buf >> (lg(\beta) - 1))$ AND $1$ \\
-\hspace{3mm}12.4 $buf \leftarrow buf << 1$ \\
-\hspace{3mm}12.5 if $mode = 0$ and $y = 0$ then goto step 12. \\
-\hspace{3mm}12.6 if $mode = 1$ and $y = 0$ then do \\
-\hspace{6mm}12.6.1 $res \leftarrow res^2$ \\
-\hspace{6mm}12.6.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}12.6.3 Goto step 12. \\
-\hspace{3mm}12.7 $bitcpy \leftarrow bitcpy + 1$ \\
-\hspace{3mm}12.8 $bitbuf \leftarrow bitbuf + (y << (winsize - bitcpy))$ \\
-\hspace{3mm}12.9 $mode \leftarrow 2$ \\
-\hspace{3mm}12.10 If $bitcpy = winsize$ then do \\
-\hspace{6mm}Window is full so perform the squarings and single multiplication. \\
-\hspace{6mm}12.10.1 for $ix$ from $0$ to $winsize -1$ do \\
-\hspace{9mm}12.10.1.1 $res \leftarrow res^2$ \\
-\hspace{9mm}12.10.1.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}12.10.2 $res \leftarrow res \cdot M_{bitbuf}$ \\
-\hspace{6mm}12.10.3 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}Reset the window. \\
-\hspace{6mm}12.10.4 $bitcpy \leftarrow 0, bitbuf \leftarrow 0, mode \leftarrow 1$ \\
-\\
-No more windows left. Check for residual bits of exponent. \\
-13. If $mode = 2$ and $bitcpy > 0$ then do \\
-\hspace{3mm}13.1 for $ix$ form $0$ to $bitcpy - 1$ do \\
-\hspace{6mm}13.1.1 $res \leftarrow res^2$ \\
-\hspace{6mm}13.1.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}13.1.3 $bitbuf \leftarrow bitbuf << 1$ \\
-\hspace{6mm}13.1.4 If $bitbuf$ AND $2^{winsize} \ne 0$ then do \\
-\hspace{9mm}13.1.4.1 $res \leftarrow res \cdot M_{1}$ \\
-\hspace{9mm}13.1.4.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-14. $y \leftarrow res$ \\
-15. Clear $res$, $mu$ and the $M$ array. \\
-16. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_exptmod (continued)}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_exptmod.}
-This algorithm computes the $x$'th power of $g$ modulo $p$ and stores the result in $y$. It takes advantage of the Barrett reduction
-algorithm to keep the product small throughout the algorithm.
-
-The first two steps determine the optimal window size based on the number of bits in the exponent. The larger the exponent the
-larger the window size becomes. After a window size $winsize$ has been chosen an array of $2^{winsize}$ mp\_int variables is allocated. This
-table will hold the values of $g^x \mbox{ (mod }p\mbox{)}$ for $2^{winsize - 1} \le x < 2^{winsize}$.
-
-After the table is allocated the first power of $g$ is found. Since $g \ge p$ is allowed it must be first reduced modulo $p$ to make
-the rest of the algorithm more efficient. The first element of the table at $2^{winsize - 1}$ is found by squaring $M_1$ successively $winsize - 2$
-times. The rest of the table elements are found by multiplying the previous element by $M_1$ modulo $p$.
-
-Now that the table is available the sliding window may begin. The following list describes the functions of all the variables in the window.
-\begin{enumerate}
-\item The variable $mode$ dictates how the bits of the exponent are interpreted.
-\begin{enumerate}
- \item When $mode = 0$ the bits are ignored since no non-zero bit of the exponent has been seen yet. For example, if the exponent were simply
- $1$ then there would be $lg(\beta) - 1$ zero bits before the first non-zero bit. In this case bits are ignored until a non-zero bit is found.
- \item When $mode = 1$ a non-zero bit has been seen before and a new $winsize$-bit window has not been formed yet. In this mode leading $0$ bits
- are read and a single squaring is performed. If a non-zero bit is read a new window is created.
- \item When $mode = 2$ the algorithm is in the middle of forming a window and new bits are appended to the window from the most significant bit
- downwards.
-\end{enumerate}
-\item The variable $bitcnt$ indicates how many bits are left in the current digit of the exponent left to be read. When it reaches zero a new digit
- is fetched from the exponent.
-\item The variable $buf$ holds the currently read digit of the exponent.
-\item The variable $digidx$ is an index into the exponents digits. It starts at the leading digit $x.used - 1$ and moves towards the trailing digit.
-\item The variable $bitcpy$ indicates how many bits are in the currently formed window. When it reaches $winsize$ the window is flushed and
- the appropriate operations performed.
-\item The variable $bitbuf$ holds the current bits of the window being formed.
-\end{enumerate}
-
-All of step 12 is the window processing loop. It will iterate while there are digits available form the exponent to read. The first step
-inside this loop is to extract a new digit if no more bits are available in the current digit. If there are no bits left a new digit is
-read and if there are no digits left than the loop terminates.
-
-After a digit is made available step 12.3 will extract the most significant bit of the current digit and move all other bits in the digit
-upwards. In effect the digit is read from most significant bit to least significant bit and since the digits are read from leading to
-trailing edges the entire exponent is read from most significant bit to least significant bit.
-
-At step 12.5 if the $mode$ and currently extracted bit $y$ are both zero the bit is ignored and the next bit is read. This prevents the
-algorithm from having to perform trivial squaring and reduction operations before the first non-zero bit is read. Step 12.6 and 12.7-10 handle
-the two cases of $mode = 1$ and $mode = 2$ respectively.
-
-FIGU,expt_state,Sliding Window State Diagram
-
-By step 13 there are no more digits left in the exponent. However, there may be partial bits in the window left. If $mode = 2$ then
-a Left-to-Right algorithm is used to process the remaining few bits.
-
-EXAM,bn_s_mp_exptmod.c
-
-Lines @31,if@ through @45,}@ determine the optimal window size based on the length of the exponent in bits. The window divisions are sorted
-from smallest to greatest so that in each \textbf{if} statement only one condition must be tested. For example, by the \textbf{if} statement
-on line @37,if@ the value of $x$ is already known to be greater than $140$.
-
-The conditional piece of code beginning on line @42,ifdef@ allows the window size to be restricted to five bits. This logic is used to ensure
-the table of precomputed powers of $G$ remains relatively small.
-
-The for loop on line @60,for@ initializes the $M$ array while lines @71,mp_init@ and @75,mp_reduce@ through @85,}@ initialize the reduction
-function that will be used for this modulus.
-
--- More later.
-
-\section{Quick Power of Two}
-Calculating $b = 2^a$ can be performed much quicker than with any of the previous algorithms. Recall that a logical shift left $m << k$ is
-equivalent to $m \cdot 2^k$. By this logic when $m = 1$ a quick power of two can be achieved.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_2expt}. \\
-\textbf{Input}. integer $b$ \\
-\textbf{Output}. $a \leftarrow 2^b$ \\
-\hline \\
-1. $a \leftarrow 0$ \\
-2. If $a.alloc < \lfloor b / lg(\beta) \rfloor + 1$ then grow $a$ appropriately. \\
-3. $a.used \leftarrow \lfloor b / lg(\beta) \rfloor + 1$ \\
-4. $a_{\lfloor b / lg(\beta) \rfloor} \leftarrow 1 << (b \mbox{ mod } lg(\beta))$ \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_2expt}
-\end{figure}
-
-\textbf{Algorithm mp\_2expt.}
-
-EXAM,bn_mp_2expt.c
-
-\chapter{Higher Level Algorithms}
-
-This chapter discusses the various higher level algorithms that are required to complete a well rounded multiple precision integer package. These
-routines are less performance oriented than the algorithms of chapters five, six and seven but are no less important.
-
-The first section describes a method of integer division with remainder that is universally well known. It provides the signed division logic
-for the package. The subsequent section discusses a set of algorithms which allow a single digit to be the 2nd operand for a variety of operations.
-These algorithms serve mostly to simplify other algorithms where small constants are required. The last two sections discuss how to manipulate
-various representations of integers. For example, converting from an mp\_int to a string of character.
-
-\section{Integer Division with Remainder}
-\label{sec:division}
-
-Integer division aside from modular exponentiation is the most intensive algorithm to compute. Like addition, subtraction and multiplication
-the basis of this algorithm is the long-hand division algorithm taught to school children. Throughout this discussion several common variables
-will be used. Let $x$ represent the divisor and $y$ represent the dividend. Let $q$ represent the integer quotient $\lfloor y / x \rfloor$ and
-let $r$ represent the remainder $r = y - x \lfloor y / x \rfloor$. The following simple algorithm will be used to start the discussion.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Radix-$\beta$ Integer Division}. \\
-\textbf{Input}. integer $x$ and $y$ \\
-\textbf{Output}. $q = \lfloor y/x\rfloor, r = y - xq$ \\
-\hline \\
-1. $q \leftarrow 0$ \\
-2. $n \leftarrow \vert \vert y \vert \vert - \vert \vert x \vert \vert$ \\
-3. for $t$ from $n$ down to $0$ do \\
-\hspace{3mm}3.1 Maximize $k$ such that $kx\beta^t$ is less than or equal to $y$ and $(k + 1)x\beta^t$ is greater. \\
-\hspace{3mm}3.2 $q \leftarrow q + k\beta^t$ \\
-\hspace{3mm}3.3 $y \leftarrow y - kx\beta^t$ \\
-4. $r \leftarrow y$ \\
-5. Return($q, r$) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Radix-$\beta$ Integer Division}
-\label{fig:raddiv}
-\end{figure}
-
-As children we are taught this very simple algorithm for the case of $\beta = 10$. Almost instinctively several optimizations are taught for which
-their reason of existing are never explained. For this example let $y = 5471$ represent the dividend and $x = 23$ represent the divisor.
-
-To find the first digit of the quotient the value of $k$ must be maximized such that $kx\beta^t$ is less than or equal to $y$ and
-simultaneously $(k + 1)x\beta^t$ is greater than $y$. Implicitly $k$ is the maximum value the $t$'th digit of the quotient may have. The habitual method
-used to find the maximum is to ``eyeball'' the two numbers, typically only the leading digits and quickly estimate a quotient. By only using leading
-digits a much simpler division may be used to form an educated guess at what the value must be. In this case $k = \lfloor 54/23\rfloor = 2$ quickly
-arises as a possible solution. Indeed $2x\beta^2 = 4600$ is less than $y = 5471$ and simultaneously $(k + 1)x\beta^2 = 6900$ is larger than $y$.
-As a result $k\beta^2$ is added to the quotient which now equals $q = 200$ and $4600$ is subtracted from $y$ to give a remainder of $y = 841$.
-
-Again this process is repeated to produce the quotient digit $k = 3$ which makes the quotient $q = 200 + 3\beta = 230$ and the remainder
-$y = 841 - 3x\beta = 181$. Finally the last iteration of the loop produces $k = 7$ which leads to the quotient $q = 230 + 7 = 237$ and the
-remainder $y = 181 - 7x = 20$. The final quotient and remainder found are $q = 237$ and $r = y = 20$ which are indeed correct since
-$237 \cdot 23 + 20 = 5471$ is true.
-
-\subsection{Quotient Estimation}
-\label{sec:divest}
-As alluded to earlier the quotient digit $k$ can be estimated from only the leading digits of both the divisor and dividend. When $p$ leading
-digits are used from both the divisor and dividend to form an estimation the accuracy of the estimation rises as $p$ grows. Technically
-speaking the estimation is based on assuming the lower $\vert \vert y \vert \vert - p$ and $\vert \vert x \vert \vert - p$ lower digits of the
-dividend and divisor are zero.
-
-The value of the estimation may off by a few values in either direction and in general is fairly correct. A simplification \cite[pp. 271]{TAOCPV2}
-of the estimation technique is to use $t + 1$ digits of the dividend and $t$ digits of the divisor, in particularly when $t = 1$. The estimate
-using this technique is never too small. For the following proof let $t = \vert \vert y \vert \vert - 1$ and $s = \vert \vert x \vert \vert - 1$
-represent the most significant digits of the dividend and divisor respectively.
-
-\textbf{Proof.}\textit{ The quotient $\hat k = \lfloor (y_t\beta + y_{t-1}) / x_s \rfloor$ is greater than or equal to
-$k = \lfloor y / (x \cdot \beta^{\vert \vert y \vert \vert - \vert \vert x \vert \vert - 1}) \rfloor$. }
-The first obvious case is when $\hat k = \beta - 1$ in which case the proof is concluded since the real quotient cannot be larger. For all other
-cases $\hat k = \lfloor (y_t\beta + y_{t-1}) / x_s \rfloor$ and $\hat k x_s \ge y_t\beta + y_{t-1} - x_s + 1$. The latter portion of the inequalility
-$-x_s + 1$ arises from the fact that a truncated integer division will give the same quotient for at most $x_s - 1$ values. Next a series of
-inequalities will prove the hypothesis.
-
-\begin{equation}
-y - \hat k x \le y - \hat k x_s\beta^s
-\end{equation}
-
-This is trivially true since $x \ge x_s\beta^s$. Next we replace $\hat kx_s\beta^s$ by the previous inequality for $\hat kx_s$.
-
-\begin{equation}
-y - \hat k x \le y_t\beta^t + \ldots + y_0 - (y_t\beta^t + y_{t-1}\beta^{t-1} - x_s\beta^t + \beta^s)
-\end{equation}
-
-By simplifying the previous inequality the following inequality is formed.
-
-\begin{equation}
-y - \hat k x \le y_{t-2}\beta^{t-2} + \ldots + y_0 + x_s\beta^s - \beta^s
-\end{equation}
-
-Subsequently,
-
-\begin{equation}
-y_{t-2}\beta^{t-2} + \ldots + y_0 + x_s\beta^s - \beta^s < x_s\beta^s \le x
-\end{equation}
-
-Which proves that $y - \hat kx \le x$ and by consequence $\hat k \ge k$ which concludes the proof. \textbf{QED}
-
-
-\subsection{Normalized Integers}
-For the purposes of division a normalized input is when the divisors leading digit $x_n$ is greater than or equal to $\beta / 2$. By multiplying both
-$x$ and $y$ by $j = \lfloor (\beta / 2) / x_n \rfloor$ the quotient remains unchanged and the remainder is simply $j$ times the original
-remainder. The purpose of normalization is to ensure the leading digit of the divisor is sufficiently large such that the estimated quotient will
-lie in the domain of a single digit. Consider the maximum dividend $(\beta - 1) \cdot \beta + (\beta - 1)$ and the minimum divisor $\beta / 2$.
-
-\begin{equation}
-{{\beta^2 - 1} \over { \beta / 2}} \le 2\beta - {2 \over \beta}
-\end{equation}
-
-At most the quotient approaches $2\beta$, however, in practice this will not occur since that would imply the previous quotient digit was too small.
-
-\subsection{Radix-$\beta$ Division with Remainder}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div}. \\
-\textbf{Input}. mp\_int $a, b$ \\
-\textbf{Output}. $c = \lfloor a/b \rfloor$, $d = a - bc$ \\
-\hline \\
-1. If $b = 0$ return(\textit{MP\_VAL}). \\
-2. If $\vert a \vert < \vert b \vert$ then do \\
-\hspace{3mm}2.1 $d \leftarrow a$ \\
-\hspace{3mm}2.2 $c \leftarrow 0$ \\
-\hspace{3mm}2.3 Return(\textit{MP\_OKAY}). \\
-\\
-Setup the quotient to receive the digits. \\
-3. Grow $q$ to $a.used + 2$ digits. \\
-4. $q \leftarrow 0$ \\
-5. $x \leftarrow \vert a \vert , y \leftarrow \vert b \vert$ \\
-6. $sign \leftarrow \left \lbrace \begin{array}{ll}
- MP\_ZPOS & \mbox{if }a.sign = b.sign \\
- MP\_NEG & \mbox{otherwise} \\
- \end{array} \right .$ \\
-\\
-Normalize the inputs such that the leading digit of $y$ is greater than or equal to $\beta / 2$. \\
-7. $norm \leftarrow (lg(\beta) - 1) - (\lceil lg(y) \rceil \mbox{ (mod }lg(\beta)\mbox{)})$ \\
-8. $x \leftarrow x \cdot 2^{norm}, y \leftarrow y \cdot 2^{norm}$ \\
-\\
-Find the leading digit of the quotient. \\
-9. $n \leftarrow x.used - 1, t \leftarrow y.used - 1$ \\
-10. $y \leftarrow y \cdot \beta^{n - t}$ \\
-11. While ($x \ge y$) do \\
-\hspace{3mm}11.1 $q_{n - t} \leftarrow q_{n - t} + 1$ \\
-\hspace{3mm}11.2 $x \leftarrow x - y$ \\
-12. $y \leftarrow \lfloor y / \beta^{n-t} \rfloor$ \\
-\\
-Continued on the next page. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div} (continued). \\
-\textbf{Input}. mp\_int $a, b$ \\
-\textbf{Output}. $c = \lfloor a/b \rfloor$, $d = a - bc$ \\
-\hline \\
-Now find the remainder fo the digits. \\
-13. for $i$ from $n$ down to $(t + 1)$ do \\
-\hspace{3mm}13.1 If $i > x.used$ then jump to the next iteration of this loop. \\
-\hspace{3mm}13.2 If $x_{i} = y_{t}$ then \\
-\hspace{6mm}13.2.1 $q_{i - t - 1} \leftarrow \beta - 1$ \\
-\hspace{3mm}13.3 else \\
-\hspace{6mm}13.3.1 $\hat r \leftarrow x_{i} \cdot \beta + x_{i - 1}$ \\
-\hspace{6mm}13.3.2 $\hat r \leftarrow \lfloor \hat r / y_{t} \rfloor$ \\
-\hspace{6mm}13.3.3 $q_{i - t - 1} \leftarrow \hat r$ \\
-\hspace{3mm}13.4 $q_{i - t - 1} \leftarrow q_{i - t - 1} + 1$ \\
-\\
-Fixup quotient estimation. \\
-\hspace{3mm}13.5 Loop \\
-\hspace{6mm}13.5.1 $q_{i - t - 1} \leftarrow q_{i - t - 1} - 1$ \\
-\hspace{6mm}13.5.2 t$1 \leftarrow 0$ \\
-\hspace{6mm}13.5.3 t$1_0 \leftarrow y_{t - 1}, $ t$1_1 \leftarrow y_t,$ t$1.used \leftarrow 2$ \\
-\hspace{6mm}13.5.4 $t1 \leftarrow t1 \cdot q_{i - t - 1}$ \\
-\hspace{6mm}13.5.5 t$2_0 \leftarrow x_{i - 2}, $ t$2_1 \leftarrow x_{i - 1}, $ t$2_2 \leftarrow x_i, $ t$2.used \leftarrow 3$ \\
-\hspace{6mm}13.5.6 If $\vert t1 \vert > \vert t2 \vert$ then goto step 13.5. \\
-\hspace{3mm}13.6 t$1 \leftarrow y \cdot q_{i - t - 1}$ \\
-\hspace{3mm}13.7 t$1 \leftarrow $ t$1 \cdot \beta^{i - t - 1}$ \\
-\hspace{3mm}13.8 $x \leftarrow x - $ t$1$ \\
-\hspace{3mm}13.9 If $x.sign = MP\_NEG$ then \\
-\hspace{6mm}13.10 t$1 \leftarrow y$ \\
-\hspace{6mm}13.11 t$1 \leftarrow $ t$1 \cdot \beta^{i - t - 1}$ \\
-\hspace{6mm}13.12 $x \leftarrow x + $ t$1$ \\
-\hspace{6mm}13.13 $q_{i - t - 1} \leftarrow q_{i - t - 1} - 1$ \\
-\\
-Finalize the result. \\
-14. Clamp excess digits of $q$ \\
-15. $c \leftarrow q, c.sign \leftarrow sign$ \\
-16. $x.sign \leftarrow a.sign$ \\
-17. $d \leftarrow \lfloor x / 2^{norm} \rfloor$ \\
-18. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div (continued)}
-\end{figure}
-\textbf{Algorithm mp\_div.}
-This algorithm will calculate quotient and remainder from an integer division given a dividend and divisor. The algorithm is a signed
-division and will produce a fully qualified quotient and remainder.
-
-First the divisor $b$ must be non-zero which is enforced in step one. If the divisor is larger than the dividend than the quotient is implicitly
-zero and the remainder is the dividend.
-
-After the first two trivial cases of inputs are handled the variable $q$ is setup to receive the digits of the quotient. Two unsigned copies of the
-divisor $y$ and dividend $x$ are made as well. The core of the division algorithm is an unsigned division and will only work if the values are
-positive. Now the two values $x$ and $y$ must be normalized such that the leading digit of $y$ is greater than or equal to $\beta / 2$.
-This is performed by shifting both to the left by enough bits to get the desired normalization.
-
-At this point the division algorithm can begin producing digits of the quotient. Recall that maximum value of the estimation used is
-$2\beta - {2 \over \beta}$ which means that a digit of the quotient must be first produced by another means. In this case $y$ is shifted
-to the left (\textit{step ten}) so that it has the same number of digits as $x$. The loop on step eleven will subtract multiples of the
-shifted copy of $y$ until $x$ is smaller. Since the leading digit of $y$ is greater than or equal to $\beta/2$ this loop will iterate at most two
-times to produce the desired leading digit of the quotient.
-
-Now the remainder of the digits can be produced. The equation $\hat q = \lfloor {{x_i \beta + x_{i-1}}\over y_t} \rfloor$ is used to fairly
-accurately approximate the true quotient digit. The estimation can in theory produce an estimation as high as $2\beta - {2 \over \beta}$ but by
-induction the upper quotient digit is correct (\textit{as established on step eleven}) and the estimate must be less than $\beta$.
-
-Recall from section~\ref{sec:divest} that the estimation is never too low but may be too high. The next step of the estimation process is
-to refine the estimation. The loop on step 13.5 uses $x_i\beta^2 + x_{i-1}\beta + x_{i-2}$ and $q_{i - t - 1}(y_t\beta + y_{t-1})$ as a higher
-order approximation to adjust the quotient digit.
-
-After both phases of estimation the quotient digit may still be off by a value of one\footnote{This is similar to the error introduced
-by optimizing Barrett reduction.}. Steps 13.6 and 13.7 subtract the multiple of the divisor from the dividend (\textit{Similar to step 3.3 of
-algorithm~\ref{fig:raddiv}} and then subsequently add a multiple of the divisor if the quotient was too large.
-
-Now that the quotient has been determine finializing the result is a matter of clamping the quotient, fixing the sizes and de-normalizing the
-remainder. An important aspect of this algorithm seemingly overlooked in other descriptions such as that of Algorithm 14.20 HAC \cite[pp. 598]{HAC}
-is that when the estimations are being made (\textit{inside the loop on step 13.5}) that the digits $y_{t-1}$, $x_{i-2}$ and $x_{i-1}$ may lie
-outside their respective boundaries. For example, if $t = 0$ or $i \le 1$ then the digits would be undefined. In those cases the digits should
-respectively be replaced with a zero.
-
-EXAM,bn_mp_div.c
-
-The implementation of this algorithm differs slightly from the pseudo code presented previously. In this algorithm either of the quotient $c$ or
-remainder $d$ may be passed as a \textbf{NULL} pointer which indicates their value is not desired. For example, the C code to call the division
-algorithm with only the quotient is
-
-\begin{verbatim}
-mp_div(&a, &b, &c, NULL); /* c = [a/b] */
-\end{verbatim}
-
-Lines @108,if@ and @113,if@ handle the two trivial cases of inputs which are division by zero and dividend smaller than the divisor
-respectively. After the two trivial cases all of the temporary variables are initialized. Line @147,neg@ determines the sign of
-the quotient and line @148,sign@ ensures that both $x$ and $y$ are positive.
-
-The number of bits in the leading digit is calculated on line @151,norm@. Implictly an mp\_int with $r$ digits will require $lg(\beta)(r-1) + k$ bits
-of precision which when reduced modulo $lg(\beta)$ produces the value of $k$. In this case $k$ is the number of bits in the leading digit which is
-exactly what is required. For the algorithm to operate $k$ must equal $lg(\beta) - 1$ and when it does not the inputs must be normalized by shifting
-them to the left by $lg(\beta) - 1 - k$ bits.
-
-Throughout the variables $n$ and $t$ will represent the highest digit of $x$ and $y$ respectively. These are first used to produce the
-leading digit of the quotient. The loop beginning on line @184,for@ will produce the remainder of the quotient digits.
-
-The conditional ``continue'' on line @186,continue@ is used to prevent the algorithm from reading past the leading edge of $x$ which can occur when the
-algorithm eliminates multiple non-zero digits in a single iteration. This ensures that $x_i$ is always non-zero since by definition the digits
-above the $i$'th position $x$ must be zero in order for the quotient to be precise\footnote{Precise as far as integer division is concerned.}.
-
-Lines @214,t1@, @216,t1@ and @222,t2@ through @225,t2@ manually construct the high accuracy estimations by setting the digits of the two mp\_int
-variables directly.
-
-\section{Single Digit Helpers}
-
-This section briefly describes a series of single digit helper algorithms which come in handy when working with small constants. All of
-the helper functions assume the single digit input is positive and will treat them as such.
-
-\subsection{Single Digit Addition and Subtraction}
-
-Both addition and subtraction are performed by ``cheating'' and using mp\_set followed by the higher level addition or subtraction
-algorithms. As a result these algorithms are subtantially simpler with a slight cost in performance.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_add\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = a + b$ \\
-\hline \\
-1. $t \leftarrow b$ (\textit{mp\_set}) \\
-2. $c \leftarrow a + t$ \\
-3. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_add\_d}
-\end{figure}
-
-\textbf{Algorithm mp\_add\_d.}
-This algorithm initiates a temporary mp\_int with the value of the single digit and uses algorithm mp\_add to add the two values together.
-
-EXAM,bn_mp_add_d.c
-
-Clever use of the letter 't'.
-
-\subsubsection{Subtraction}
-The single digit subtraction algorithm mp\_sub\_d is essentially the same except it uses mp\_sub to subtract the digit from the mp\_int.
-
-\subsection{Single Digit Multiplication}
-Single digit multiplication arises enough in division and radix conversion that it ought to be implement as a special case of the baseline
-multiplication algorithm. Essentially this algorithm is a modified version of algorithm s\_mp\_mul\_digs where one of the multiplicands
-only has one digit.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = ab$ \\
-\hline \\
-1. $pa \leftarrow a.used$ \\
-2. Grow $c$ to at least $pa + 1$ digits. \\
-3. $oldused \leftarrow c.used$ \\
-4. $c.used \leftarrow pa + 1$ \\
-5. $c.sign \leftarrow a.sign$ \\
-6. $\mu \leftarrow 0$ \\
-7. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}7.1 $\hat r \leftarrow \mu + a_{ix}b$ \\
-\hspace{3mm}7.2 $c_{ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}7.3 $\mu \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-8. $c_{pa} \leftarrow \mu$ \\
-9. for $ix$ from $pa + 1$ to $oldused$ do \\
-\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
-10. Clamp excess digits of $c$. \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_d}
-\end{figure}
-\textbf{Algorithm mp\_mul\_d.}
-This algorithm quickly multiplies an mp\_int by a small single digit value. It is specially tailored to the job and has a minimal of overhead.
-Unlike the full multiplication algorithms this algorithm does not require any significnat temporary storage or memory allocations.
-
-EXAM,bn_mp_mul_d.c
-
-In this implementation the destination $c$ may point to the same mp\_int as the source $a$ since the result is written after the digit is
-read from the source. This function uses pointer aliases $tmpa$ and $tmpc$ for the digits of $a$ and $c$ respectively.
-
-\subsection{Single Digit Division}
-Like the single digit multiplication algorithm, single digit division is also a fairly common algorithm used in radix conversion. Since the
-divisor is only a single digit a specialized variant of the division algorithm can be used to compute the quotient.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = \lfloor a / b \rfloor, d = a - cb$ \\
-\hline \\
-1. If $b = 0$ then return(\textit{MP\_VAL}).\\
-2. If $b = 3$ then use algorithm mp\_div\_3 instead. \\
-3. Init $q$ to $a.used$ digits. \\
-4. $q.used \leftarrow a.used$ \\
-5. $q.sign \leftarrow a.sign$ \\
-6. $\hat w \leftarrow 0$ \\
-7. for $ix$ from $a.used - 1$ down to $0$ do \\
-\hspace{3mm}7.1 $\hat w \leftarrow \hat w \beta + a_{ix}$ \\
-\hspace{3mm}7.2 If $\hat w \ge b$ then \\
-\hspace{6mm}7.2.1 $t \leftarrow \lfloor \hat w / b \rfloor$ \\
-\hspace{6mm}7.2.2 $\hat w \leftarrow \hat w \mbox{ (mod }b\mbox{)}$ \\
-\hspace{3mm}7.3 else\\
-\hspace{6mm}7.3.1 $t \leftarrow 0$ \\
-\hspace{3mm}7.4 $q_{ix} \leftarrow t$ \\
-8. $d \leftarrow \hat w$ \\
-9. Clamp excess digits of $q$. \\
-10. $c \leftarrow q$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_d}
-\end{figure}
-\textbf{Algorithm mp\_div\_d.}
-This algorithm divides the mp\_int $a$ by the single mp\_digit $b$ using an optimized approach. Essentially in every iteration of the
-algorithm another digit of the dividend is reduced and another digit of quotient produced. Provided $b < \beta$ the value of $\hat w$
-after step 7.1 will be limited such that $0 \le \lfloor \hat w / b \rfloor < \beta$.
-
-If the divisor $b$ is equal to three a variant of this algorithm is used which is called mp\_div\_3. It replaces the division by three with
-a multiplication by $\lfloor \beta / 3 \rfloor$ and the appropriate shift and residual fixup. In essence it is much like the Barrett reduction
-from chapter seven.
-
-EXAM,bn_mp_div_d.c
-
-Like the implementation of algorithm mp\_div this algorithm allows either of the quotient or remainder to be passed as a \textbf{NULL} pointer to
-indicate the respective value is not required. This allows a trivial single digit modular reduction algorithm, mp\_mod\_d to be created.
-
-The division and remainder on lines @44,/@ and @45,%@ can be replaced often by a single division on most processors. For example, the 32-bit x86 based
-processors can divide a 64-bit quantity by a 32-bit quantity and produce the quotient and remainder simultaneously. Unfortunately the GCC
-compiler does not recognize that optimization and will actually produce two function calls to find the quotient and remainder respectively.
-
-\subsection{Single Digit Root Extraction}
-
-Finding the $n$'th root of an integer is fairly easy as far as numerical analysis is concerned. Algorithms such as the Newton-Raphson approximation
-(\ref{eqn:newton}) series will converge very quickly to a root for any continuous function $f(x)$.
-
-\begin{equation}
-x_{i+1} = x_i - {f(x_i) \over f'(x_i)}
-\label{eqn:newton}
-\end{equation}
-
-In this case the $n$'th root is desired and $f(x) = x^n - a$ where $a$ is the integer of which the root is desired. The derivative of $f(x)$ is
-simply $f'(x) = nx^{n - 1}$. Of particular importance is that this algorithm will be used over the integers not over the a more continuous domain
-such as the real numbers. As a result the root found can be above the true root by few and must be manually adjusted. Ideally at the end of the
-algorithm the $n$'th root $b$ of an integer $a$ is desired such that $b^n \le a$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_n\_root}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c^b \le a$ \\
-\hline \\
-1. If $b$ is even and $a.sign = MP\_NEG$ return(\textit{MP\_VAL}). \\
-2. $sign \leftarrow a.sign$ \\
-3. $a.sign \leftarrow MP\_ZPOS$ \\
-4. t$2 \leftarrow 2$ \\
-5. Loop \\
-\hspace{3mm}5.1 t$1 \leftarrow $ t$2$ \\
-\hspace{3mm}5.2 t$3 \leftarrow $ t$1^{b - 1}$ \\
-\hspace{3mm}5.3 t$2 \leftarrow $ t$3 $ $\cdot$ t$1$ \\
-\hspace{3mm}5.4 t$2 \leftarrow $ t$2 - a$ \\
-\hspace{3mm}5.5 t$3 \leftarrow $ t$3 \cdot b$ \\
-\hspace{3mm}5.6 t$3 \leftarrow \lfloor $t$2 / $t$3 \rfloor$ \\
-\hspace{3mm}5.7 t$2 \leftarrow $ t$1 - $ t$3$ \\
-\hspace{3mm}5.8 If t$1 \ne $ t$2$ then goto step 5. \\
-6. Loop \\
-\hspace{3mm}6.1 t$2 \leftarrow $ t$1^b$ \\
-\hspace{3mm}6.2 If t$2 > a$ then \\
-\hspace{6mm}6.2.1 t$1 \leftarrow $ t$1 - 1$ \\
-\hspace{6mm}6.2.2 Goto step 6. \\
-7. $a.sign \leftarrow sign$ \\
-8. $c \leftarrow $ t$1$ \\
-9. $c.sign \leftarrow sign$ \\
-10. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_n\_root}
-\end{figure}
-\textbf{Algorithm mp\_n\_root.}
-This algorithm finds the integer $n$'th root of an input using the Newton-Raphson approach. It is partially optimized based on the observation
-that the numerator of ${f(x) \over f'(x)}$ can be derived from a partial denominator. That is at first the denominator is calculated by finding
-$x^{b - 1}$. This value can then be multiplied by $x$ and have $a$ subtracted from it to find the numerator. This saves a total of $b - 1$
-multiplications by t$1$ inside the loop.
-
-The initial value of the approximation is t$2 = 2$ which allows the algorithm to start with very small values and quickly converge on the
-root. Ideally this algorithm is meant to find the $n$'th root of an input where $n$ is bounded by $2 \le n \le 5$.
-
-EXAM,bn_mp_n_root.c
-
-\section{Random Number Generation}
-
-Random numbers come up in a variety of activities from public key cryptography to simple simulations and various randomized algorithms. Pollard-Rho
-factoring for example, can make use of random values as starting points to find factors of a composite integer. In this case the algorithm presented
-is solely for simulations and not intended for cryptographic use.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_rand}. \\
-\textbf{Input}. An integer $b$ \\
-\textbf{Output}. A pseudo-random number of $b$ digits \\
-\hline \\
-1. $a \leftarrow 0$ \\
-2. If $b \le 0$ return(\textit{MP\_OKAY}) \\
-3. Pick a non-zero random digit $d$. \\
-4. $a \leftarrow a + d$ \\
-5. for $ix$ from 1 to $d - 1$ do \\
-\hspace{3mm}5.1 $a \leftarrow a \cdot \beta$ \\
-\hspace{3mm}5.2 Pick a random digit $d$. \\
-\hspace{3mm}5.3 $a \leftarrow a + d$ \\
-6. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_rand}
-\end{figure}
-\textbf{Algorithm mp\_rand.}
-This algorithm produces a pseudo-random integer of $b$ digits. By ensuring that the first digit is non-zero the algorithm also guarantees that the
-final result has at least $b$ digits. It relies heavily on a third-part random number generator which should ideally generate uniformly all of
-the integers from $0$ to $\beta - 1$.
-
-EXAM,bn_mp_rand.c
-
-\section{Formatted Representations}
-The ability to emit a radix-$n$ textual representation of an integer is useful for interacting with human parties. For example, the ability to
-be given a string of characters such as ``114585'' and turn it into the radix-$\beta$ equivalent would make it easier to enter numbers
-into a program.
-
-\subsection{Reading Radix-n Input}
-For the purposes of this text we will assume that a simple lower ASCII map (\ref{fig:ASC}) is used for the values of from $0$ to $63$ to
-printable characters. For example, when the character ``N'' is read it represents the integer $23$. The first $16$ characters of the
-map are for the common representations up to hexadecimal. After that they match the ``base64'' encoding scheme which are suitable chosen
-such that they are printable. While outputting as base64 may not be too helpful for human operators it does allow communication via non binary
-mediums.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{cc|cc|cc|cc}
-\hline \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} \\
-\hline
-0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 \\
-4 & 4 & 5 & 5 & 6 & 6 & 7 & 7 \\
-8 & 8 & 9 & 9 & 10 & A & 11 & B \\
-12 & C & 13 & D & 14 & E & 15 & F \\
-16 & G & 17 & H & 18 & I & 19 & J \\
-20 & K & 21 & L & 22 & M & 23 & N \\
-24 & O & 25 & P & 26 & Q & 27 & R \\
-28 & S & 29 & T & 30 & U & 31 & V \\
-32 & W & 33 & X & 34 & Y & 35 & Z \\
-36 & a & 37 & b & 38 & c & 39 & d \\
-40 & e & 41 & f & 42 & g & 43 & h \\
-44 & i & 45 & j & 46 & k & 47 & l \\
-48 & m & 49 & n & 50 & o & 51 & p \\
-52 & q & 53 & r & 54 & s & 55 & t \\
-56 & u & 57 & v & 58 & w & 59 & x \\
-60 & y & 61 & z & 62 & $+$ & 63 & $/$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Lower ASCII Map}
-\label{fig:ASC}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_read\_radix}. \\
-\textbf{Input}. A string $str$ of length $sn$ and radix $r$. \\
-\textbf{Output}. The radix-$\beta$ equivalent mp\_int. \\
-\hline \\
-1. If $r < 2$ or $r > 64$ return(\textit{MP\_VAL}). \\
-2. $ix \leftarrow 0$ \\
-3. If $str_0 =$ ``-'' then do \\
-\hspace{3mm}3.1 $ix \leftarrow ix + 1$ \\
-\hspace{3mm}3.2 $sign \leftarrow MP\_NEG$ \\
-4. else \\
-\hspace{3mm}4.1 $sign \leftarrow MP\_ZPOS$ \\
-5. $a \leftarrow 0$ \\
-6. for $iy$ from $ix$ to $sn - 1$ do \\
-\hspace{3mm}6.1 Let $y$ denote the position in the map of $str_{iy}$. \\
-\hspace{3mm}6.2 If $str_{iy}$ is not in the map or $y \ge r$ then goto step 7. \\
-\hspace{3mm}6.3 $a \leftarrow a \cdot r$ \\
-\hspace{3mm}6.4 $a \leftarrow a + y$ \\
-7. If $a \ne 0$ then $a.sign \leftarrow sign$ \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_read\_radix}
-\end{figure}
-\textbf{Algorithm mp\_read\_radix.}
-This algorithm will read an ASCII string and produce the radix-$\beta$ mp\_int representation of the same integer. A minus symbol ``-'' may precede the
-string to indicate the value is negative, otherwise it is assumed to be positive. The algorithm will read up to $sn$ characters from the input
-and will stop when it reads a character it cannot map the algorithm stops reading characters from the string. This allows numbers to be embedded
-as part of larger input without any significant problem.
-
-EXAM,bn_mp_read_radix.c
-
-\subsection{Generating Radix-$n$ Output}
-Generating radix-$n$ output is fairly trivial with a division and remainder algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toradix}. \\
-\textbf{Input}. A mp\_int $a$ and an integer $r$\\
-\textbf{Output}. The radix-$r$ representation of $a$ \\
-\hline \\
-1. If $r < 2$ or $r > 64$ return(\textit{MP\_VAL}). \\
-2. If $a = 0$ then $str = $ ``$0$'' and return(\textit{MP\_OKAY}). \\
-3. $t \leftarrow a$ \\
-4. $str \leftarrow$ ``'' \\
-5. if $t.sign = MP\_NEG$ then \\
-\hspace{3mm}5.1 $str \leftarrow str + $ ``-'' \\
-\hspace{3mm}5.2 $t.sign = MP\_ZPOS$ \\
-6. While ($t \ne 0$) do \\
-\hspace{3mm}6.1 $d \leftarrow t \mbox{ (mod }r\mbox{)}$ \\
-\hspace{3mm}6.2 $t \leftarrow \lfloor t / r \rfloor$ \\
-\hspace{3mm}6.3 Look up $d$ in the map and store the equivalent character in $y$. \\
-\hspace{3mm}6.4 $str \leftarrow str + y$ \\
-7. If $str_0 = $``$-$'' then \\
-\hspace{3mm}7.1 Reverse the digits $str_1, str_2, \ldots str_n$. \\
-8. Otherwise \\
-\hspace{3mm}8.1 Reverse the digits $str_0, str_1, \ldots str_n$. \\
-9. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toradix}
-\end{figure}
-\textbf{Algorithm mp\_toradix.}
-This algorithm computes the radix-$r$ representation of an mp\_int $a$. The ``digits'' of the representation are extracted by reducing
-successive powers of $\lfloor a / r^k \rfloor$ the input modulo $r$ until $r^k > a$. Note that instead of actually dividing by $r^k$ in
-each iteration the quotient $\lfloor a / r \rfloor$ is saved for the next iteration. As a result a series of trivial $n \times 1$ divisions
-are required instead of a series of $n \times k$ divisions. One design flaw of this approach is that the digits are produced in the reverse order
-(see~\ref{fig:mpradix}). To remedy this flaw the digits must be swapped or simply ``reversed''.
-
-\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Value of $a$} & \textbf{Value of $d$} & \textbf{Value of $str$} \\
-\hline $1234$ & -- & -- \\
-\hline $123$ & $4$ & ``4'' \\
-\hline $12$ & $3$ & ``43'' \\
-\hline $1$ & $2$ & ``432'' \\
-\hline $0$ & $1$ & ``4321'' \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Algorithm mp\_toradix.}
-\label{fig:mpradix}
-\end{figure}
-
-EXAM,bn_mp_toradix.c
-
-\chapter{Number Theoretic Algorithms}
-This chapter discusses several fundamental number theoretic algorithms such as the greatest common divisor, least common multiple and Jacobi
-symbol computation. These algorithms arise as essential components in several key cryptographic algorithms such as the RSA public key algorithm and
-various Sieve based factoring algorithms.
-
-\section{Greatest Common Divisor}
-The greatest common divisor of two integers $a$ and $b$, often denoted as $(a, b)$ is the largest integer $k$ that is a proper divisor of
-both $a$ and $b$. That is, $k$ is the largest integer such that $0 \equiv a \mbox{ (mod }k\mbox{)}$ and $0 \equiv b \mbox{ (mod }k\mbox{)}$ occur
-simultaneously.
-
-The most common approach (cite) is to reduce one input modulo another. That is if $a$ and $b$ are divisible by some integer $k$ and if $qa + r = b$ then
-$r$ is also divisible by $k$. The reduction pattern follows $\left < a , b \right > \rightarrow \left < b, a \mbox{ mod } b \right >$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (I)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. While ($b > 0$) do \\
-\hspace{3mm}1.1 $r \leftarrow a \mbox{ (mod }b\mbox{)}$ \\
-\hspace{3mm}1.2 $a \leftarrow b$ \\
-\hspace{3mm}1.3 $b \leftarrow r$ \\
-2. Return($a$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (I)}
-\label{fig:gcd1}
-\end{figure}
-
-This algorithm will quickly converge on the greatest common divisor since the residue $r$ tends diminish rapidly. However, divisions are
-relatively expensive operations to perform and should ideally be avoided. There is another approach based on a similar relationship of
-greatest common divisors. The faster approach is based on the observation that if $k$ divides both $a$ and $b$ it will also divide $a - b$.
-In particular, we would like $a - b$ to decrease in magnitude which implies that $b \ge a$.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (II)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. While ($b > 0$) do \\
-\hspace{3mm}1.1 Swap $a$ and $b$ such that $a$ is the smallest of the two. \\
-\hspace{3mm}1.2 $b \leftarrow b - a$ \\
-2. Return($a$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (II)}
-\label{fig:gcd2}
-\end{figure}
-
-\textbf{Proof} \textit{Algorithm~\ref{fig:gcd2} will return the greatest common divisor of $a$ and $b$.}
-The algorithm in figure~\ref{fig:gcd2} will eventually terminate since $b \ge a$ the subtraction in step 1.2 will be a value less than $b$. In other
-words in every iteration that tuple $\left < a, b \right >$ decrease in magnitude until eventually $a = b$. Since both $a$ and $b$ are always
-divisible by the greatest common divisor (\textit{until the last iteration}) and in the last iteration of the algorithm $b = 0$, therefore, in the
-second to last iteration of the algorithm $b = a$ and clearly $(a, a) = a$ which concludes the proof. \textbf{QED}.
-
-As a matter of practicality algorithm \ref{fig:gcd1} decreases far too slowly to be useful. Specially if $b$ is much larger than $a$ such that
-$b - a$ is still very much larger than $a$. A simple addition to the algorithm is to divide $b - a$ by a power of some integer $p$ which does
-not divide the greatest common divisor but will divide $b - a$. In this case ${b - a} \over p$ is also an integer and still divisible by
-the greatest common divisor.
-
-However, instead of factoring $b - a$ to find a suitable value of $p$ the powers of $p$ can be removed from $a$ and $b$ that are in common first.
-Then inside the loop whenever $b - a$ is divisible by some power of $p$ it can be safely removed.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (III)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. $k \leftarrow 0$ \\
-2. While $a$ and $b$ are both divisible by $p$ do \\
-\hspace{3mm}2.1 $a \leftarrow \lfloor a / p \rfloor$ \\
-\hspace{3mm}2.2 $b \leftarrow \lfloor b / p \rfloor$ \\
-\hspace{3mm}2.3 $k \leftarrow k + 1$ \\
-3. While $a$ is divisible by $p$ do \\
-\hspace{3mm}3.1 $a \leftarrow \lfloor a / p \rfloor$ \\
-4. While $b$ is divisible by $p$ do \\
-\hspace{3mm}4.1 $b \leftarrow \lfloor b / p \rfloor$ \\
-5. While ($b > 0$) do \\
-\hspace{3mm}5.1 Swap $a$ and $b$ such that $a$ is the smallest of the two. \\
-\hspace{3mm}5.2 $b \leftarrow b - a$ \\
-\hspace{3mm}5.3 While $b$ is divisible by $p$ do \\
-\hspace{6mm}5.3.1 $b \leftarrow \lfloor b / p \rfloor$ \\
-6. Return($a \cdot p^k$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (III)}
-\label{fig:gcd3}
-\end{figure}
-
-This algorithm is based on the first except it removes powers of $p$ first and inside the main loop to ensure the tuple $\left < a, b \right >$
-decreases more rapidly. The first loop on step two removes powers of $p$ that are in common. A count, $k$, is kept which will present a common
-divisor of $p^k$. After step two the remaining common divisor of $a$ and $b$ cannot be divisible by $p$. This means that $p$ can be safely
-divided out of the difference $b - a$ so long as the division leaves no remainder.
-
-In particular the value of $p$ should be chosen such that the division on step 5.3.1 occur often. It also helps that division by $p$ be easy
-to compute. The ideal choice of $p$ is two since division by two amounts to a right logical shift. Another important observation is that by
-step five both $a$ and $b$ are odd. Therefore, the diffrence $b - a$ must be even which means that each iteration removes one bit from the
-largest of the pair.
-
-\subsection{Complete Greatest Common Divisor}
-The algorithms presented so far cannot handle inputs which are zero or negative. The following algorithm can handle all input cases properly
-and will produce the greatest common divisor.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_gcd}. \\
-\textbf{Input}. mp\_int $a$ and $b$ \\
-\textbf{Output}. The greatest common divisor $c = (a, b)$. \\
-\hline \\
-1. If $a = 0$ then \\
-\hspace{3mm}1.1 $c \leftarrow \vert b \vert $ \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $b = 0$ then \\
-\hspace{3mm}2.1 $c \leftarrow \vert a \vert $ \\
-\hspace{3mm}2.2 Return(\textit{MP\_OKAY}). \\
-3. $u \leftarrow \vert a \vert, v \leftarrow \vert b \vert$ \\
-4. $k \leftarrow 0$ \\
-5. While $u.used > 0$ and $v.used > 0$ and $u_0 \equiv v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}5.1 $k \leftarrow k + 1$ \\
-\hspace{3mm}5.2 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-\hspace{3mm}5.3 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-6. While $u.used > 0$ and $u_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}6.1 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-7. While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}7.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-8. While $v.used > 0$ \\
-\hspace{3mm}8.1 If $\vert u \vert > \vert v \vert$ then \\
-\hspace{6mm}8.1.1 Swap $u$ and $v$. \\
-\hspace{3mm}8.2 $v \leftarrow \vert v \vert - \vert u \vert$ \\
-\hspace{3mm}8.3 While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{6mm}8.3.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-9. $c \leftarrow u \cdot 2^k$ \\
-10. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_gcd}
-\end{figure}
-\textbf{Algorithm mp\_gcd.}
-This algorithm will produce the greatest common divisor of two mp\_ints $a$ and $b$. The algorithm was originally based on Algorithm B of
-Knuth \cite[pp. 338]{TAOCPV2} but has been modified to be simpler to explain. In theory it achieves the same asymptotic working time as
-Algorithm B and in practice this appears to be true.
-
-The first two steps handle the cases where either one of or both inputs are zero. If either input is zero the greatest common divisor is the
-largest input or zero if they are both zero. If the inputs are not trivial than $u$ and $v$ are assigned the absolute values of
-$a$ and $b$ respectively and the algorithm will proceed to reduce the pair.
-
-Step five will divide out any common factors of two and keep track of the count in the variable $k$. After this step, two is no longer a
-factor of the remaining greatest common divisor between $u$ and $v$ and can be safely evenly divided out of either whenever they are even. Step
-six and seven ensure that the $u$ and $v$ respectively have no more factors of two. At most only one of the while--loops will iterate since
-they cannot both be even.
-
-By step eight both of $u$ and $v$ are odd which is required for the inner logic. First the pair are swapped such that $v$ is equal to
-or greater than $u$. This ensures that the subtraction on step 8.2 will always produce a positive and even result. Step 8.3 removes any
-factors of two from the difference $u$ to ensure that in the next iteration of the loop both are once again odd.
-
-After $v = 0$ occurs the variable $u$ has the greatest common divisor of the pair $\left < u, v \right >$ just after step six. The result
-must be adjusted by multiplying by the common factors of two ($2^k$) removed earlier.
-
-EXAM,bn_mp_gcd.c
-
-This function makes use of the macros mp\_iszero and mp\_iseven. The former evaluates to $1$ if the input mp\_int is equivalent to the
-integer zero otherwise it evaluates to $0$. The latter evaluates to $1$ if the input mp\_int represents a non-zero even integer otherwise
-it evaluates to $0$. Note that just because mp\_iseven may evaluate to $0$ does not mean the input is odd, it could also be zero. The three
-trivial cases of inputs are handled on lines @23,zero@ through @29,}@. After those lines the inputs are assumed to be non-zero.
-
-Lines @32,if@ and @36,if@ make local copies $u$ and $v$ of the inputs $a$ and $b$ respectively. At this point the common factors of two
-must be divided out of the two inputs. The block starting at line @43,common@ removes common factors of two by first counting the number of trailing
-zero bits in both. The local integer $k$ is used to keep track of how many factors of $2$ are pulled out of both values. It is assumed that
-the number of factors will not exceed the maximum value of a C ``int'' data type\footnote{Strictly speaking no array in C may have more than
-entries than are accessible by an ``int'' so this is not a limitation.}.
-
-At this point there are no more common factors of two in the two values. The divisions by a power of two on lines @60,div_2d@ and @67,div_2d@ remove
-any independent factors of two such that both $u$ and $v$ are guaranteed to be an odd integer before hitting the main body of the algorithm. The while loop
-on line @72, while@ performs the reduction of the pair until $v$ is equal to zero. The unsigned comparison and subtraction algorithms are used in
-place of the full signed routines since both values are guaranteed to be positive and the result of the subtraction is guaranteed to be non-negative.
-
-\section{Least Common Multiple}
-The least common multiple of a pair of integers is their product divided by their greatest common divisor. For two integers $a$ and $b$ the
-least common multiple is normally denoted as $[ a, b ]$ and numerically equivalent to ${ab} \over {(a, b)}$. For example, if $a = 2 \cdot 2 \cdot 3 = 12$
-and $b = 2 \cdot 3 \cdot 3 \cdot 7 = 126$ the least common multiple is ${126 \over {(12, 126)}} = {126 \over 6} = 21$.
-
-The least common multiple arises often in coding theory as well as number theory. If two functions have periods of $a$ and $b$ respectively they will
-collide, that is be in synchronous states, after only $[ a, b ]$ iterations. This is why, for example, random number generators based on
-Linear Feedback Shift Registers (LFSR) tend to use registers with periods which are co-prime (\textit{e.g. the greatest common divisor is one.}).
-Similarly in number theory if a composite $n$ has two prime factors $p$ and $q$ then maximal order of any unit of $\Z/n\Z$ will be $[ p - 1, q - 1] $.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_lcm}. \\
-\textbf{Input}. mp\_int $a$ and $b$ \\
-\textbf{Output}. The least common multiple $c = [a, b]$. \\
-\hline \\
-1. $c \leftarrow (a, b)$ \\
-2. $t \leftarrow a \cdot b$ \\
-3. $c \leftarrow \lfloor t / c \rfloor$ \\
-4. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_lcm}
-\end{figure}
-\textbf{Algorithm mp\_lcm.}
-This algorithm computes the least common multiple of two mp\_int inputs $a$ and $b$. It computes the least common multiple directly by
-dividing the product of the two inputs by their greatest common divisor.
-
-EXAM,bn_mp_lcm.c
-
-\section{Jacobi Symbol Computation}
-To explain the Jacobi Symbol we shall first discuss the Legendre function\footnote{Arrg. What is the name of this?} off which the Jacobi symbol is
-defined. The Legendre function computes whether or not an integer $a$ is a quadratic residue modulo an odd prime $p$. Numerically it is
-equivalent to equation \ref{eqn:legendre}.
-
-\textit{-- Tom, don't be an ass, cite your source here...!}
-
-\begin{equation}
-a^{(p-1)/2} \equiv \begin{array}{rl}
- -1 & \mbox{if }a\mbox{ is a quadratic non-residue.} \\
- 0 & \mbox{if }a\mbox{ divides }p\mbox{.} \\
- 1 & \mbox{if }a\mbox{ is a quadratic residue}.
- \end{array} \mbox{ (mod }p\mbox{)}
-\label{eqn:legendre}
-\end{equation}
-
-\textbf{Proof.} \textit{Equation \ref{eqn:legendre} correctly identifies the residue status of an integer $a$ modulo a prime $p$.}
-An integer $a$ is a quadratic residue if the following equation has a solution.
-
-\begin{equation}
-x^2 \equiv a \mbox{ (mod }p\mbox{)}
-\label{eqn:root}
-\end{equation}
-
-Consider the following equation.
-
-\begin{equation}
-0 \equiv x^{p-1} - 1 \equiv \left \lbrace \left (x^2 \right )^{(p-1)/2} - a^{(p-1)/2} \right \rbrace + \left ( a^{(p-1)/2} - 1 \right ) \mbox{ (mod }p\mbox{)}
-\label{eqn:rooti}
-\end{equation}
-
-Whether equation \ref{eqn:root} has a solution or not equation \ref{eqn:rooti} is always true. If $a^{(p-1)/2} - 1 \equiv 0 \mbox{ (mod }p\mbox{)}$
-then the quantity in the braces must be zero. By reduction,
-
-\begin{eqnarray}
-\left (x^2 \right )^{(p-1)/2} - a^{(p-1)/2} \equiv 0 \nonumber \\
-\left (x^2 \right )^{(p-1)/2} \equiv a^{(p-1)/2} \nonumber \\
-x^2 \equiv a \mbox{ (mod }p\mbox{)}
-\end{eqnarray}
-
-As a result there must be a solution to the quadratic equation and in turn $a$ must be a quadratic residue. If $a$ does not divide $p$ and $a$
-is not a quadratic residue then the only other value $a^{(p-1)/2}$ may be congruent to is $-1$ since
-\begin{equation}
-0 \equiv a^{p - 1} - 1 \equiv (a^{(p-1)/2} + 1)(a^{(p-1)/2} - 1) \mbox{ (mod }p\mbox{)}
-\end{equation}
-One of the terms on the right hand side must be zero. \textbf{QED}
-
-\subsection{Jacobi Symbol}
-The Jacobi symbol is a generalization of the Legendre function for any odd non prime moduli $p$ greater than 2. If $p = \prod_{i=0}^n p_i$ then
-the Jacobi symbol $\left ( { a \over p } \right )$ is equal to the following equation.
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { a \over p_0} \right ) \left ( { a \over p_1} \right ) \ldots \left ( { a \over p_n} \right )
-\end{equation}
-
-By inspection if $p$ is prime the Jacobi symbol is equivalent to the Legendre function. The following facts\footnote{See HAC \cite[pp. 72-74]{HAC} for
-further details.} will be used to derive an efficient Jacobi symbol algorithm. Where $p$ is an odd integer greater than two and $a, b \in \Z$ the
-following are true.
-
-\begin{enumerate}
-\item $\left ( { a \over p} \right )$ equals $-1$, $0$ or $1$.
-\item $\left ( { ab \over p} \right ) = \left ( { a \over p} \right )\left ( { b \over p} \right )$.
-\item If $a \equiv b$ then $\left ( { a \over p} \right ) = \left ( { b \over p} \right )$.
-\item $\left ( { 2 \over p} \right )$ equals $1$ if $p \equiv 1$ or $7 \mbox{ (mod }8\mbox{)}$. Otherwise, it equals $-1$.
-\item $\left ( { a \over p} \right ) \equiv \left ( { p \over a} \right ) \cdot (-1)^{(p-1)(a-1)/4}$. More specifically
-$\left ( { a \over p} \right ) = \left ( { p \over a} \right )$ if $p \equiv a \equiv 1 \mbox{ (mod }4\mbox{)}$.
-\end{enumerate}
-
-Using these facts if $a = 2^k \cdot a'$ then
-
-\begin{eqnarray}
-\left ( { a \over p } \right ) = \left ( {{2^k} \over p } \right ) \left ( {a' \over p} \right ) \nonumber \\
- = \left ( {2 \over p } \right )^k \left ( {a' \over p} \right )
-\label{eqn:jacobi}
-\end{eqnarray}
-
-By fact five,
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { p \over a } \right ) \cdot (-1)^{(p-1)(a-1)/4}
-\end{equation}
-
-Subsequently by fact three since $p \equiv (p \mbox{ mod }a) \mbox{ (mod }a\mbox{)}$ then
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { {p \mbox{ mod } a} \over a } \right ) \cdot (-1)^{(p-1)(a-1)/4}
-\end{equation}
-
-By putting both observations into equation \ref{eqn:jacobi} the following simplified equation is formed.
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( {2 \over p } \right )^k \left ( {{p\mbox{ mod }a'} \over a'} \right ) \cdot (-1)^{(p-1)(a'-1)/4}
-\end{equation}
-
-The value of $\left ( {{p \mbox{ mod }a'} \over a'} \right )$ can be found by using the same equation recursively. The value of
-$\left ( {2 \over p } \right )^k$ equals $1$ if $k$ is even otherwise it equals $\left ( {2 \over p } \right )$. Using this approach the
-factors of $p$ do not have to be known. Furthermore, if $(a, p) = 1$ then the algorithm will terminate when the recursion requests the
-Jacobi symbol computation of $\left ( {1 \over a'} \right )$ which is simply $1$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_jacobi}. \\
-\textbf{Input}. mp\_int $a$ and $p$, $a \ge 0$, $p \ge 3$, $p \equiv 1 \mbox{ (mod }2\mbox{)}$ \\
-\textbf{Output}. The Jacobi symbol $c = \left ( {a \over p } \right )$. \\
-\hline \\
-1. If $a = 0$ then \\
-\hspace{3mm}1.1 $c \leftarrow 0$ \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $a = 1$ then \\
-\hspace{3mm}2.1 $c \leftarrow 1$ \\
-\hspace{3mm}2.2 Return(\textit{MP\_OKAY}). \\
-3. $a' \leftarrow a$ \\
-4. $k \leftarrow 0$ \\
-5. While $a'.used > 0$ and $a'_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}5.1 $k \leftarrow k + 1$ \\
-\hspace{3mm}5.2 $a' \leftarrow \lfloor a' / 2 \rfloor$ \\
-6. If $k \equiv 0 \mbox{ (mod }2\mbox{)}$ then \\
-\hspace{3mm}6.1 $s \leftarrow 1$ \\
-7. else \\
-\hspace{3mm}7.1 $r \leftarrow p_0 \mbox{ (mod }8\mbox{)}$ \\
-\hspace{3mm}7.2 If $r = 1$ or $r = 7$ then \\
-\hspace{6mm}7.2.1 $s \leftarrow 1$ \\
-\hspace{3mm}7.3 else \\
-\hspace{6mm}7.3.1 $s \leftarrow -1$ \\
-8. If $p_0 \equiv a'_0 \equiv 3 \mbox{ (mod }4\mbox{)}$ then \\
-\hspace{3mm}8.1 $s \leftarrow -s$ \\
-9. If $a' \ne 1$ then \\
-\hspace{3mm}9.1 $p' \leftarrow p \mbox{ (mod }a'\mbox{)}$ \\
-\hspace{3mm}9.2 $s \leftarrow s \cdot \mbox{mp\_jacobi}(p', a')$ \\
-10. $c \leftarrow s$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_jacobi}
-\end{figure}
-\textbf{Algorithm mp\_jacobi.}
-This algorithm computes the Jacobi symbol for an arbitrary positive integer $a$ with respect to an odd integer $p$ greater than three. The algorithm
-is based on algorithm 2.149 of HAC \cite[pp. 73]{HAC}.
-
-Step numbers one and two handle the trivial cases of $a = 0$ and $a = 1$ respectively. Step five determines the number of two factors in the
-input $a$. If $k$ is even than the term $\left ( { 2 \over p } \right )^k$ must always evaluate to one. If $k$ is odd than the term evaluates to one
-if $p_0$ is congruent to one or seven modulo eight, otherwise it evaluates to $-1$. After the the $\left ( { 2 \over p } \right )^k$ term is handled
-the $(-1)^{(p-1)(a'-1)/4}$ is computed and multiplied against the current product $s$. The latter term evaluates to one if both $p$ and $a'$
-are congruent to one modulo four, otherwise it evaluates to negative one.
-
-By step nine if $a'$ does not equal one a recursion is required. Step 9.1 computes $p' \equiv p \mbox{ (mod }a'\mbox{)}$ and will recurse to compute
-$\left ( {p' \over a'} \right )$ which is multiplied against the current Jacobi product.
-
-EXAM,bn_mp_jacobi.c
-
-As a matter of practicality the variable $a'$ as per the pseudo-code is reprensented by the variable $a1$ since the $'$ symbol is not valid for a C
-variable name character.
-
-The two simple cases of $a = 0$ and $a = 1$ are handled at the very beginning to simplify the algorithm. If the input is non-trivial the algorithm
-has to proceed compute the Jacobi. The variable $s$ is used to hold the current Jacobi product. Note that $s$ is merely a C ``int'' data type since
-the values it may obtain are merely $-1$, $0$ and $1$.
-
-After a local copy of $a$ is made all of the factors of two are divided out and the total stored in $k$. Technically only the least significant
-bit of $k$ is required, however, it makes the algorithm simpler to follow to perform an addition. In practice an exclusive-or and addition have the same
-processor requirements and neither is faster than the other.
-
-Line @59, if@ through @70, }@ determines the value of $\left ( { 2 \over p } \right )^k$. If the least significant bit of $k$ is zero than
-$k$ is even and the value is one. Otherwise, the value of $s$ depends on which residue class $p$ belongs to modulo eight. The value of
-$(-1)^{(p-1)(a'-1)/4}$ is compute and multiplied against $s$ on lines @73, if@ through @75, }@.
-
-Finally, if $a1$ does not equal one the algorithm must recurse and compute $\left ( {p' \over a'} \right )$.
-
-\textit{-- Comment about default $s$ and such...}
-
-\section{Modular Inverse}
-\label{sec:modinv}
-The modular inverse of a number actually refers to the modular multiplicative inverse. Essentially for any integer $a$ such that $(a, p) = 1$ there
-exist another integer $b$ such that $ab \equiv 1 \mbox{ (mod }p\mbox{)}$. The integer $b$ is called the multiplicative inverse of $a$ which is
-denoted as $b = a^{-1}$. Technically speaking modular inversion is a well defined operation for any finite ring or field not just for rings and
-fields of integers. However, the former will be the matter of discussion.
-
-The simplest approach is to compute the algebraic inverse of the input. That is to compute $b \equiv a^{\Phi(p) - 1}$. If $\Phi(p)$ is the
-order of the multiplicative subgroup modulo $p$ then $b$ must be the multiplicative inverse of $a$. The proof of which is trivial.
-
-\begin{equation}
-ab \equiv a \left (a^{\Phi(p) - 1} \right ) \equiv a^{\Phi(p)} \equiv a^0 \equiv 1 \mbox{ (mod }p\mbox{)}
-\end{equation}
-
-However, as simple as this approach may be it has two serious flaws. It requires that the value of $\Phi(p)$ be known which if $p$ is composite
-requires all of the prime factors. This approach also is very slow as the size of $p$ grows.
-
-A simpler approach is based on the observation that solving for the multiplicative inverse is equivalent to solving the linear
-Diophantine\footnote{See LeVeque \cite[pp. 40-43]{LeVeque} for more information.} equation.
-
-\begin{equation}
-ab + pq = 1
-\end{equation}
-
-Where $a$, $b$, $p$ and $q$ are all integers. If such a pair of integers $ \left < b, q \right >$ exist than $b$ is the multiplicative inverse of
-$a$ modulo $p$. The extended Euclidean algorithm (Knuth \cite[pp. 342]{TAOCPV2}) can be used to solve such equations provided $(a, p) = 1$.
-However, instead of using that algorithm directly a variant known as the binary Extended Euclidean algorithm will be used in its place. The
-binary approach is very similar to the binary greatest common divisor algorithm except it will produce a full solution to the Diophantine
-equation.
-
-\subsection{General Case}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_invmod}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $(a, b) = 1$, $p \ge 2$, $0 < a < p$. \\
-\textbf{Output}. The modular inverse $c \equiv a^{-1} \mbox{ (mod }b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then return(\textit{MP\_VAL}). \\
-2. If $b_0 \equiv 1 \mbox{ (mod }2\mbox{)}$ then use algorithm fast\_mp\_invmod. \\
-3. $x \leftarrow \vert a \vert, y \leftarrow b$ \\
-4. If $x_0 \equiv y_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ then return(\textit{MP\_VAL}). \\
-5. $B \leftarrow 0, C \leftarrow 0, A \leftarrow 1, D \leftarrow 1$ \\
-6. While $u.used > 0$ and $u_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}6.1 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-\hspace{3mm}6.2 If ($A.used > 0$ and $A_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) or ($B.used > 0$ and $B_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) then \\
-\hspace{6mm}6.2.1 $A \leftarrow A + y$ \\
-\hspace{6mm}6.2.2 $B \leftarrow B - x$ \\
-\hspace{3mm}6.3 $A \leftarrow \lfloor A / 2 \rfloor$ \\
-\hspace{3mm}6.4 $B \leftarrow \lfloor B / 2 \rfloor$ \\
-7. While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}7.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-\hspace{3mm}7.2 If ($C.used > 0$ and $C_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) or ($D.used > 0$ and $D_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) then \\
-\hspace{6mm}7.2.1 $C \leftarrow C + y$ \\
-\hspace{6mm}7.2.2 $D \leftarrow D - x$ \\
-\hspace{3mm}7.3 $C \leftarrow \lfloor C / 2 \rfloor$ \\
-\hspace{3mm}7.4 $D \leftarrow \lfloor D / 2 \rfloor$ \\
-8. If $u \ge v$ then \\
-\hspace{3mm}8.1 $u \leftarrow u - v$ \\
-\hspace{3mm}8.2 $A \leftarrow A - C$ \\
-\hspace{3mm}8.3 $B \leftarrow B - D$ \\
-9. else \\
-\hspace{3mm}9.1 $v \leftarrow v - u$ \\
-\hspace{3mm}9.2 $C \leftarrow C - A$ \\
-\hspace{3mm}9.3 $D \leftarrow D - B$ \\
-10. If $u \ne 0$ goto step 6. \\
-11. If $v \ne 1$ return(\textit{MP\_VAL}). \\
-12. While $C \le 0$ do \\
-\hspace{3mm}12.1 $C \leftarrow C + b$ \\
-13. While $C \ge b$ do \\
-\hspace{3mm}13.1 $C \leftarrow C - b$ \\
-14. $c \leftarrow C$ \\
-15. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\end{figure}
-\textbf{Algorithm mp\_invmod.}
-This algorithm computes the modular multiplicative inverse of an integer $a$ modulo an integer $b$. This algorithm is a variation of the
-extended binary Euclidean algorithm from HAC \cite[pp. 608]{HAC}. It has been modified to only compute the modular inverse and not a complete
-Diophantine solution.
-
-If $b \le 0$ than the modulus is invalid and MP\_VAL is returned. Similarly if both $a$ and $b$ are even then there cannot be a multiplicative
-inverse for $a$ and the error is reported.
-
-The astute reader will observe that steps seven through nine are very similar to the binary greatest common divisor algorithm mp\_gcd. In this case
-the other variables to the Diophantine equation are solved. The algorithm terminates when $u = 0$ in which case the solution is
-
-\begin{equation}
-Ca + Db = v
-\end{equation}
-
-If $v$, the greatest common divisor of $a$ and $b$ is not equal to one then the algorithm will report an error as no inverse exists. Otherwise, $C$
-is the modular inverse of $a$. The actual value of $C$ is congruent to, but not necessarily equal to, the ideal modular inverse which should lie
-within $1 \le a^{-1} < b$. Step numbers twelve and thirteen adjust the inverse until it is in range. If the original input $a$ is within $0 < a < p$
-then only a couple of additions or subtractions will be required to adjust the inverse.
-
-EXAM,bn_mp_invmod.c
-
-\subsubsection{Odd Moduli}
-
-When the modulus $b$ is odd the variables $A$ and $C$ are fixed and are not required to compute the inverse. In particular by attempting to solve
-the Diophantine $Cb + Da = 1$ only $B$ and $D$ are required to find the inverse of $a$.
-
-The algorithm fast\_mp\_invmod is a direct adaptation of algorithm mp\_invmod with all all steps involving either $A$ or $C$ removed. This
-optimization will halve the time required to compute the modular inverse.
-
-\section{Primality Tests}
-
-A non-zero integer $a$ is said to be prime if it is not divisible by any other integer excluding one and itself. For example, $a = 7$ is prime
-since the integers $2 \ldots 6$ do not evenly divide $a$. By contrast, $a = 6$ is not prime since $a = 6 = 2 \cdot 3$.
-
-Prime numbers arise in cryptography considerably as they allow finite fields to be formed. The ability to determine whether an integer is prime or
-not quickly has been a viable subject in cryptography and number theory for considerable time. The algorithms that will be presented are all
-probablistic algorithms in that when they report an integer is composite it must be composite. However, when the algorithms report an integer is
-prime the algorithm may be incorrect.
-
-As will be discussed it is possible to limit the probability of error so well that for practical purposes the probablity of error might as
-well be zero. For the purposes of these discussions let $n$ represent the candidate integer of which the primality is in question.
-
-\subsection{Trial Division}
-
-Trial division means to attempt to evenly divide a candidate integer by small prime integers. If the candidate can be evenly divided it obviously
-cannot be prime. By dividing by all primes $1 < p \le \sqrt{n}$ this test can actually prove whether an integer is prime. However, such a test
-would require a prohibitive amount of time as $n$ grows.
-
-Instead of dividing by every prime, a smaller, more mangeable set of primes may be used instead. By performing trial division with only a subset
-of the primes less than $\sqrt{n} + 1$ the algorithm cannot prove if a candidate is prime. However, often it can prove a candidate is not prime.
-
-The benefit of this test is that trial division by small values is fairly efficient. Specially compared to the other algorithms that will be
-discussed shortly. The probability that this approach correctly identifies a composite candidate when tested with all primes upto $q$ is given by
-$1 - {1.12 \over ln(q)}$. The graph (\ref{pic:primality}, will be added later) demonstrates the probability of success for the range
-$3 \le q \le 100$.
-
-At approximately $q = 30$ the gain of performing further tests diminishes fairly quickly. At $q = 90$ further testing is generally not going to
-be of any practical use. In the case of LibTomMath the default limit $q = 256$ was chosen since it is not too high and will eliminate
-approximately $80\%$ of all candidate integers. The constant \textbf{PRIME\_SIZE} is equal to the number of primes in the test base. The
-array \_\_prime\_tab is an array of the first \textbf{PRIME\_SIZE} prime numbers.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_is\_divisible}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $c = 1$ if $n$ is divisible by a small prime, otherwise $c = 0$. \\
-\hline \\
-1. for $ix$ from $0$ to $PRIME\_SIZE$ do \\
-\hspace{3mm}1.1 $d \leftarrow n \mbox{ (mod }\_\_prime\_tab_{ix}\mbox{)}$ \\
-\hspace{3mm}1.2 If $d = 0$ then \\
-\hspace{6mm}1.2.1 $c \leftarrow 1$ \\
-\hspace{6mm}1.2.2 Return(\textit{MP\_OKAY}). \\
-2. $c \leftarrow 0$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_is\_divisible}
-\end{figure}
-\textbf{Algorithm mp\_prime\_is\_divisible.}
-This algorithm attempts to determine if a candidate integer $n$ is composite by performing trial divisions.
-
-EXAM,bn_mp_prime_is_divisible.c
-
-The algorithm defaults to a return of $0$ in case an error occurs. The values in the prime table are all specified to be in the range of a
-mp\_digit. The table \_\_prime\_tab is defined in the following file.
-
-EXAM,bn_prime_tab.c
-
-Note that there are two possible tables. When an mp\_digit is 7-bits long only the primes upto $127$ may be included, otherwise the primes
-upto $1619$ are used. Note that the value of \textbf{PRIME\_SIZE} is a constant dependent on the size of a mp\_digit.
-
-\subsection{The Fermat Test}
-The Fermat test is probably one the oldest tests to have a non-trivial probability of success. It is based on the fact that if $n$ is in
-fact prime then $a^{n} \equiv a \mbox{ (mod }n\mbox{)}$ for all $0 < a < n$. The reason being that if $n$ is prime than the order of
-the multiplicative sub group is $n - 1$. Any base $a$ must have an order which divides $n - 1$ and as such $a^n$ is equivalent to
-$a^1 = a$.
-
-If $n$ is composite then any given base $a$ does not have to have a period which divides $n - 1$. In which case
-it is possible that $a^n \nequiv a \mbox{ (mod }n\mbox{)}$. However, this test is not absolute as it is possible that the order
-of a base will divide $n - 1$ which would then be reported as prime. Such a base yields what is known as a Fermat pseudo-prime. Several
-integers known as Carmichael numbers will be a pseudo-prime to all valid bases. Fortunately such numbers are extremely rare as $n$ grows
-in size.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_fermat}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $a \ge 2$, $0 < b < a$. \\
-\textbf{Output}. $c = 1$ if $b^a \equiv b \mbox{ (mod }a\mbox{)}$, otherwise $c = 0$. \\
-\hline \\
-1. $t \leftarrow b^a \mbox{ (mod }a\mbox{)}$ \\
-2. If $t = b$ then \\
-\hspace{3mm}2.1 $c = 1$ \\
-3. else \\
-\hspace{3mm}3.1 $c = 0$ \\
-4. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_fermat}
-\end{figure}
-\textbf{Algorithm mp\_prime\_fermat.}
-This algorithm determines whether an mp\_int $a$ is a Fermat prime to the base $b$ or not. It uses a single modular exponentiation to
-determine the result.
-
-EXAM,bn_mp_prime_fermat.c
-
-\subsection{The Miller-Rabin Test}
-The Miller-Rabin (citation) test is another primality test which has tighter error bounds than the Fermat test specifically with sequentially chosen
-candidate integers. The algorithm is based on the observation that if $n - 1 = 2^kr$ and if $b^r \nequiv \pm 1$ then after upto $k - 1$ squarings the
-value must be equal to $-1$. The squarings are stopped as soon as $-1$ is observed. If the value of $1$ is observed first it means that
-some value not congruent to $\pm 1$ when squared equals one which cannot occur if $n$ is prime.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_miller\_rabin}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $a \ge 2$, $0 < b < a$. \\
-\textbf{Output}. $c = 1$ if $a$ is a Miller-Rabin prime to the base $a$, otherwise $c = 0$. \\
-\hline
-1. $a' \leftarrow a - 1$ \\
-2. $r \leftarrow n1$ \\
-3. $c \leftarrow 0, s \leftarrow 0$ \\
-4. While $r.used > 0$ and $r_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}4.1 $s \leftarrow s + 1$ \\
-\hspace{3mm}4.2 $r \leftarrow \lfloor r / 2 \rfloor$ \\
-5. $y \leftarrow b^r \mbox{ (mod }a\mbox{)}$ \\
-6. If $y \nequiv \pm 1$ then \\
-\hspace{3mm}6.1 $j \leftarrow 1$ \\
-\hspace{3mm}6.2 While $j \le (s - 1)$ and $y \nequiv a'$ \\
-\hspace{6mm}6.2.1 $y \leftarrow y^2 \mbox{ (mod }a\mbox{)}$ \\
-\hspace{6mm}6.2.2 If $y = 1$ then goto step 8. \\
-\hspace{6mm}6.2.3 $j \leftarrow j + 1$ \\
-\hspace{3mm}6.3 If $y \nequiv a'$ goto step 8. \\
-7. $c \leftarrow 1$\\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_miller\_rabin}
-\end{figure}
-\textbf{Algorithm mp\_prime\_miller\_rabin.}
-This algorithm performs one trial round of the Miller-Rabin algorithm to the base $b$. It will set $c = 1$ if the algorithm cannot determine
-if $b$ is composite or $c = 0$ if $b$ is provably composite. The values of $s$ and $r$ are computed such that $a' = a - 1 = 2^sr$.
-
-If the value $y \equiv b^r$ is congruent to $\pm 1$ then the algorithm cannot prove if $a$ is composite or not. Otherwise, the algorithm will
-square $y$ upto $s - 1$ times stopping only when $y \equiv -1$. If $y^2 \equiv 1$ and $y \nequiv \pm 1$ then the algorithm can report that $a$
-is provably composite. If the algorithm performs $s - 1$ squarings and $y \nequiv -1$ then $a$ is provably composite. If $a$ is not provably
-composite then it is \textit{probably} prime.
-
-EXAM,bn_mp_prime_miller_rabin.c
-
-
-
-
-\backmatter
-\appendix
-\begin{thebibliography}{ABCDEF}
-\bibitem[1]{TAOCPV2}
-Donald Knuth, \textit{The Art of Computer Programming}, Third Edition, Volume Two, Seminumerical Algorithms, Addison-Wesley, 1998
-
-\bibitem[2]{HAC}
-A. Menezes, P. van Oorschot, S. Vanstone, \textit{Handbook of Applied Cryptography}, CRC Press, 1996
-
-\bibitem[3]{ROSE}
-Michael Rosing, \textit{Implementing Elliptic Curve Cryptography}, Manning Publications, 1999
-
-\bibitem[4]{COMBA}
-Paul G. Comba, \textit{Exponentiation Cryptosystems on the IBM PC}. IBM Systems Journal 29(4): 526-538 (1990)
-
-\bibitem[5]{KARA}
-A. Karatsuba, Doklay Akad. Nauk SSSR 145 (1962), pp.293-294
-
-\bibitem[6]{KARAP}
-Andre Weimerskirch and Christof Paar, \textit{Generalizations of the Karatsuba Algorithm for Polynomial Multiplication}, Submitted to Design, Codes and Cryptography, March 2002
-
-\bibitem[7]{BARRETT}
-Paul Barrett, \textit{Implementing the Rivest Shamir and Adleman Public Key Encryption Algorithm on a Standard Digital Signal Processor}, Advances in Cryptology, Crypto '86, Springer-Verlag.
-
-\bibitem[8]{MONT}
-P.L.Montgomery. \textit{Modular multiplication without trial division}. Mathematics of Computation, 44(170):519-521, April 1985.
-
-\bibitem[9]{DRMET}
-Chae Hoon Lim and Pil Joong Lee, \textit{Generating Efficient Primes for Discrete Log Cryptosystems}, POSTECH Information Research Laboratories
-
-\bibitem[10]{MMB}
-J. Daemen and R. Govaerts and J. Vandewalle, \textit{Block ciphers based on Modular Arithmetic}, State and {P}rogress in the {R}esearch of {C}ryptography, 1993, pp. 80-89
-
-\bibitem[11]{RSAREF}
-R.L. Rivest, A. Shamir, L. Adleman, \textit{A Method for Obtaining Digital Signatures and Public-Key Cryptosystems}
-
-\bibitem[12]{DHREF}
-Whitfield Diffie, Martin E. Hellman, \textit{New Directions in Cryptography}, IEEE Transactions on Information Theory, 1976
-
-\bibitem[13]{IEEE}
-IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985)
-
-\bibitem[14]{GMP}
-GNU Multiple Precision (GMP), \url{http://www.swox.com/gmp/}
-
-\bibitem[15]{MPI}
-Multiple Precision Integer Library (MPI), Michael Fromberger, \url{http://thayer.dartmouth.edu/~sting/mpi/}
-
-\bibitem[16]{OPENSSL}
-OpenSSL Cryptographic Toolkit, \url{http://openssl.org}
-
-\bibitem[17]{LIP}
-Large Integer Package, \url{http://home.hetnet.nl/~ecstr/LIP.zip}
-
-\bibitem[18]{ISOC}
-JTC1/SC22/WG14, ISO/IEC 9899:1999, ``A draft rationale for the C99 standard.''
-
-\bibitem[19]{JAVA}
-The Sun Java Website, \url{http://java.sun.com/}
-
-\end{thebibliography}
-
-\input{tommath.ind}
-
-\end{document}
diff --git a/libtommath/tommath.tex b/libtommath/tommath.tex
deleted file mode 100644
index c79a537..0000000
--- a/libtommath/tommath.tex
+++ /dev/null
@@ -1,6691 +0,0 @@
-\documentclass[b5paper]{book}
-\usepackage{hyperref}
-\usepackage{makeidx}
-\usepackage{amssymb}
-\usepackage{color}
-\usepackage{alltt}
-\usepackage{graphicx}
-\usepackage{layout}
-\def\union{\cup}
-\def\intersect{\cap}
-\def\getsrandom{\stackrel{\rm R}{\gets}}
-\def\cross{\times}
-\def\cat{\hspace{0.5em} \| \hspace{0.5em}}
-\def\catn{$\|$}
-\def\divides{\hspace{0.3em} | \hspace{0.3em}}
-\def\nequiv{\not\equiv}
-\def\approx{\raisebox{0.2ex}{\mbox{\small $\sim$}}}
-\def\lcm{{\rm lcm}}
-\def\gcd{{\rm gcd}}
-\def\log{{\rm log}}
-\def\ord{{\rm ord}}
-\def\abs{{\mathit abs}}
-\def\rep{{\mathit rep}}
-\def\mod{{\mathit\ mod\ }}
-\renewcommand{\pmod}[1]{\ ({\rm mod\ }{#1})}
-\newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor}
-\newcommand{\ceil}[1]{\left\lceil{#1}\right\rceil}
-\def\Or{{\rm\ or\ }}
-\def\And{{\rm\ and\ }}
-\def\iff{\hspace{1em}\Longleftrightarrow\hspace{1em}}
-\def\implies{\Rightarrow}
-\def\undefined{{\rm ``undefined"}}
-\def\Proof{\vspace{1ex}\noindent {\bf Proof:}\hspace{1em}}
-\let\oldphi\phi
-\def\phi{\varphi}
-\def\Pr{{\rm Pr}}
-\newcommand{\str}[1]{{\mathbf{#1}}}
-\def\F{{\mathbb F}}
-\def\N{{\mathbb N}}
-\def\Z{{\mathbb Z}}
-\def\R{{\mathbb R}}
-\def\C{{\mathbb C}}
-\def\Q{{\mathbb Q}}
-\definecolor{DGray}{gray}{0.5}
-\newcommand{\emailaddr}[1]{\mbox{$<${#1}$>$}}
-\def\twiddle{\raisebox{0.3ex}{\mbox{\tiny $\sim$}}}
-\def\gap{\vspace{0.5ex}}
-\makeindex
-\begin{document}
-\frontmatter
-\pagestyle{empty}
-\title{Multi--Precision Math}
-\author{\mbox{
-%\begin{small}
-\begin{tabular}{c}
-Tom St Denis \\
-Algonquin College \\
-\\
-Mads Rasmussen \\
-Open Communications Security \\
-\\
-Greg Rose \\
-QUALCOMM Australia \\
-\end{tabular}
-%\end{small}
-}
-}
-\maketitle
-This text has been placed in the public domain. This text corresponds to the v0.39 release of the
-LibTomMath project.
-
-\begin{alltt}
-Tom St Denis
-111 Banning Rd
-Ottawa, Ontario
-K2L 1C3
-Canada
-
-Phone: 1-613-836-3160
-Email: tomstdenis@gmail.com
-\end{alltt}
-
-This text is formatted to the international B5 paper size of 176mm wide by 250mm tall using the \LaTeX{}
-{\em book} macro package and the Perl {\em booker} package.
-
-\tableofcontents
-\listoffigures
-\chapter*{Prefaces}
-When I tell people about my LibTom projects and that I release them as public domain they are often puzzled.
-They ask why I did it and especially why I continue to work on them for free. The best I can explain it is ``Because I can.''
-Which seems odd and perhaps too terse for adult conversation. I often qualify it with ``I am able, I am willing.'' which
-perhaps explains it better. I am the first to admit there is not anything that special with what I have done. Perhaps
-others can see that too and then we would have a society to be proud of. My LibTom projects are what I am doing to give
-back to society in the form of tools and knowledge that can help others in their endeavours.
-
-I started writing this book because it was the most logical task to further my goal of open academia. The LibTomMath source
-code itself was written to be easy to follow and learn from. There are times, however, where pure C source code does not
-explain the algorithms properly. Hence this book. The book literally starts with the foundation of the library and works
-itself outwards to the more complicated algorithms. The use of both pseudo--code and verbatim source code provides a duality
-of ``theory'' and ``practice'' that the computer science students of the world shall appreciate. I never deviate too far
-from relatively straightforward algebra and I hope that this book can be a valuable learning asset.
-
-This book and indeed much of the LibTom projects would not exist in their current form if it was not for a plethora
-of kind people donating their time, resources and kind words to help support my work. Writing a text of significant
-length (along with the source code) is a tiresome and lengthy process. Currently the LibTom project is four years old,
-comprises of literally thousands of users and over 100,000 lines of source code, TeX and other material. People like Mads and Greg
-were there at the beginning to encourage me to work well. It is amazing how timely validation from others can boost morale to
-continue the project. Definitely my parents were there for me by providing room and board during the many months of work in 2003.
-
-To my many friends whom I have met through the years I thank you for the good times and the words of encouragement. I hope I
-honour your kind gestures with this project.
-
-Open Source. Open Academia. Open Minds.
-
-\begin{flushright} Tom St Denis \end{flushright}
-
-\newpage
-I found the opportunity to work with Tom appealing for several reasons, not only could I broaden my own horizons, but also
-contribute to educate others facing the problem of having to handle big number mathematical calculations.
-
-This book is Tom's child and he has been caring and fostering the project ever since the beginning with a clear mind of
-how he wanted the project to turn out. I have helped by proofreading the text and we have had several discussions about
-the layout and language used.
-
-I hold a masters degree in cryptography from the University of Southern Denmark and have always been interested in the
-practical aspects of cryptography.
-
-Having worked in the security consultancy business for several years in S\~{a}o Paulo, Brazil, I have been in touch with a
-great deal of work in which multiple precision mathematics was needed. Understanding the possibilities for speeding up
-multiple precision calculations is often very important since we deal with outdated machine architecture where modular
-reductions, for example, become painfully slow.
-
-This text is for people who stop and wonder when first examining algorithms such as RSA for the first time and asks
-themselves, ``You tell me this is only secure for large numbers, fine; but how do you implement these numbers?''
-
-\begin{flushright}
-Mads Rasmussen
-
-S\~{a}o Paulo - SP
-
-Brazil
-\end{flushright}
-
-\newpage
-It's all because I broke my leg. That just happened to be at about the same time that Tom asked for someone to review the section of the book about
-Karatsuba multiplication. I was laid up, alone and immobile, and thought ``Why not?'' I vaguely knew what Karatsuba multiplication was, but not
-really, so I thought I could help, learn, and stop myself from watching daytime cable TV, all at once.
-
-At the time of writing this, I've still not met Tom or Mads in meatspace. I've been following Tom's progress since his first splash on the
-sci.crypt Usenet news group. I watched him go from a clueless newbie, to the cryptographic equivalent of a reformed smoker, to a real
-contributor to the field, over a period of about two years. I've been impressed with his obvious intelligence, and astounded by his productivity.
-Of course, he's young enough to be my own child, so he doesn't have my problems with staying awake.
-
-When I reviewed that single section of the book, in its very earliest form, I was very pleasantly surprised. So I decided to collaborate more fully,
-and at least review all of it, and perhaps write some bits too. There's still a long way to go with it, and I have watched a number of close
-friends go through the mill of publication, so I think that the way to go is longer than Tom thinks it is. Nevertheless, it's a good effort,
-and I'm pleased to be involved with it.
-
-\begin{flushright}
-Greg Rose, Sydney, Australia, June 2003.
-\end{flushright}
-
-\mainmatter
-\pagestyle{headings}
-\chapter{Introduction}
-\section{Multiple Precision Arithmetic}
-
-\subsection{What is Multiple Precision Arithmetic?}
-When we think of long-hand arithmetic such as addition or multiplication we rarely consider the fact that we instinctively
-raise or lower the precision of the numbers we are dealing with. For example, in decimal we almost immediate can
-reason that $7$ times $6$ is $42$. However, $42$ has two digits of precision as opposed to one digit we started with.
-Further multiplications of say $3$ result in a larger precision result $126$. In these few examples we have multiple
-precisions for the numbers we are working with. Despite the various levels of precision a single subset\footnote{With the occasional optimization.}
- of algorithms can be designed to accomodate them.
-
-By way of comparison a fixed or single precision operation would lose precision on various operations. For example, in
-the decimal system with fixed precision $6 \cdot 7 = 2$.
-
-Essentially at the heart of computer based multiple precision arithmetic are the same long-hand algorithms taught in
-schools to manually add, subtract, multiply and divide.
-
-\subsection{The Need for Multiple Precision Arithmetic}
-The most prevalent need for multiple precision arithmetic, often referred to as ``bignum'' math, is within the implementation
-of public-key cryptography algorithms. Algorithms such as RSA \cite{RSAREF} and Diffie-Hellman \cite{DHREF} require
-integers of significant magnitude to resist known cryptanalytic attacks. For example, at the time of this writing a
-typical RSA modulus would be at least greater than $10^{309}$. However, modern programming languages such as ISO C \cite{ISOC} and
-Java \cite{JAVA} only provide instrinsic support for integers which are relatively small and single precision.
-
-\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{|r|c|}
-\hline \textbf{Data Type} & \textbf{Range} \\
-\hline char & $-128 \ldots 127$ \\
-\hline short & $-32768 \ldots 32767$ \\
-\hline long & $-2147483648 \ldots 2147483647$ \\
-\hline long long & $-9223372036854775808 \ldots 9223372036854775807$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Typical Data Types for the C Programming Language}
-\label{fig:ISOC}
-\end{figure}
-
-The largest data type guaranteed to be provided by the ISO C programming
-language\footnote{As per the ISO C standard. However, each compiler vendor is allowed to augment the precision as they
-see fit.} can only represent values up to $10^{19}$ as shown in figure \ref{fig:ISOC}. On its own the C language is
-insufficient to accomodate the magnitude required for the problem at hand. An RSA modulus of magnitude $10^{19}$ could be
-trivially factored\footnote{A Pollard-Rho factoring would take only $2^{16}$ time.} on the average desktop computer,
-rendering any protocol based on the algorithm insecure. Multiple precision algorithms solve this very problem by
-extending the range of representable integers while using single precision data types.
-
-Most advancements in fast multiple precision arithmetic stem from the need for faster and more efficient cryptographic
-primitives. Faster modular reduction and exponentiation algorithms such as Barrett's algorithm, which have appeared in
-various cryptographic journals, can render algorithms such as RSA and Diffie-Hellman more efficient. In fact, several
-major companies such as RSA Security, Certicom and Entrust have built entire product lines on the implementation and
-deployment of efficient algorithms.
-
-However, cryptography is not the only field of study that can benefit from fast multiple precision integer routines.
-Another auxiliary use of multiple precision integers is high precision floating point data types.
-The basic IEEE \cite{IEEE} standard floating point type is made up of an integer mantissa $q$, an exponent $e$ and a sign bit $s$.
-Numbers are given in the form $n = q \cdot b^e \cdot -1^s$ where $b = 2$ is the most common base for IEEE. Since IEEE
-floating point is meant to be implemented in hardware the precision of the mantissa is often fairly small
-(\textit{23, 48 and 64 bits}). The mantissa is merely an integer and a multiple precision integer could be used to create
-a mantissa of much larger precision than hardware alone can efficiently support. This approach could be useful where
-scientific applications must minimize the total output error over long calculations.
-
-Yet another use for large integers is within arithmetic on polynomials of large characteristic (i.e. $GF(p)[x]$ for large $p$).
-In fact the library discussed within this text has already been used to form a polynomial basis library\footnote{See \url{http://poly.libtomcrypt.org} for more details.}.
-
-\subsection{Benefits of Multiple Precision Arithmetic}
-\index{precision}
-The benefit of multiple precision representations over single or fixed precision representations is that
-no precision is lost while representing the result of an operation which requires excess precision. For example,
-the product of two $n$-bit integers requires at least $2n$ bits of precision to be represented faithfully. A multiple
-precision algorithm would augment the precision of the destination to accomodate the result while a single precision system
-would truncate excess bits to maintain a fixed level of precision.
-
-It is possible to implement algorithms which require large integers with fixed precision algorithms. For example, elliptic
-curve cryptography (\textit{ECC}) is often implemented on smartcards by fixing the precision of the integers to the maximum
-size the system will ever need. Such an approach can lead to vastly simpler algorithms which can accomodate the
-integers required even if the host platform cannot natively accomodate them\footnote{For example, the average smartcard
-processor has an 8 bit accumulator.}. However, as efficient as such an approach may be, the resulting source code is not
-normally very flexible. It cannot, at runtime, accomodate inputs of higher magnitude than the designer anticipated.
-
-Multiple precision algorithms have the most overhead of any style of arithmetic. For the the most part the
-overhead can be kept to a minimum with careful planning, but overall, it is not well suited for most memory starved
-platforms. However, multiple precision algorithms do offer the most flexibility in terms of the magnitude of the
-inputs. That is, the same algorithms based on multiple precision integers can accomodate any reasonable size input
-without the designer's explicit forethought. This leads to lower cost of ownership for the code as it only has to
-be written and tested once.
-
-\section{Purpose of This Text}
-The purpose of this text is to instruct the reader regarding how to implement efficient multiple precision algorithms.
-That is to not only explain a limited subset of the core theory behind the algorithms but also the various ``house keeping''
-elements that are neglected by authors of other texts on the subject. Several well reknowned texts \cite{TAOCPV2,HAC}
-give considerably detailed explanations of the theoretical aspects of algorithms and often very little information
-regarding the practical implementation aspects.
-
-In most cases how an algorithm is explained and how it is actually implemented are two very different concepts. For
-example, the Handbook of Applied Cryptography (\textit{HAC}), algorithm 14.7 on page 594, gives a relatively simple
-algorithm for performing multiple precision integer addition. However, the description lacks any discussion concerning
-the fact that the two integer inputs may be of differing magnitudes. As a result the implementation is not as simple
-as the text would lead people to believe. Similarly the division routine (\textit{algorithm 14.20, pp. 598}) does not
-discuss how to handle sign or handle the dividend's decreasing magnitude in the main loop (\textit{step \#3}).
-
-Both texts also do not discuss several key optimal algorithms required such as ``Comba'' and Karatsuba multipliers
-and fast modular inversion, which we consider practical oversights. These optimal algorithms are vital to achieve
-any form of useful performance in non-trivial applications.
-
-To solve this problem the focus of this text is on the practical aspects of implementing a multiple precision integer
-package. As a case study the ``LibTomMath''\footnote{Available at \url{http://math.libtomcrypt.com}} package is used
-to demonstrate algorithms with real implementations\footnote{In the ISO C programming language.} that have been field
-tested and work very well. The LibTomMath library is freely available on the Internet for all uses and this text
-discusses a very large portion of the inner workings of the library.
-
-The algorithms that are presented will always include at least one ``pseudo-code'' description followed
-by the actual C source code that implements the algorithm. The pseudo-code can be used to implement the same
-algorithm in other programming languages as the reader sees fit.
-
-This text shall also serve as a walkthrough of the creation of multiple precision algorithms from scratch. Showing
-the reader how the algorithms fit together as well as where to start on various taskings.
-
-\section{Discussion and Notation}
-\subsection{Notation}
-A multiple precision integer of $n$-digits shall be denoted as $x = (x_{n-1}, \ldots, x_1, x_0)_{ \beta }$ and represent
-the integer $x \equiv \sum_{i=0}^{n-1} x_i\beta^i$. The elements of the array $x$ are said to be the radix $\beta$ digits
-of the integer. For example, $x = (1,2,3)_{10}$ would represent the integer
-$1\cdot 10^2 + 2\cdot10^1 + 3\cdot10^0 = 123$.
-
-\index{mp\_int}
-The term ``mp\_int'' shall refer to a composite structure which contains the digits of the integer it represents, as well
-as auxilary data required to manipulate the data. These additional members are discussed further in section
-\ref{sec:MPINT}. For the purposes of this text a ``multiple precision integer'' and an ``mp\_int'' are assumed to be
-synonymous. When an algorithm is specified to accept an mp\_int variable it is assumed the various auxliary data members
-are present as well. An expression of the type \textit{variablename.item} implies that it should evaluate to the
-member named ``item'' of the variable. For example, a string of characters may have a member ``length'' which would
-evaluate to the number of characters in the string. If the string $a$ equals ``hello'' then it follows that
-$a.length = 5$.
-
-For certain discussions more generic algorithms are presented to help the reader understand the final algorithm used
-to solve a given problem. When an algorithm is described as accepting an integer input it is assumed the input is
-a plain integer with no additional multiple-precision members. That is, algorithms that use integers as opposed to
-mp\_ints as inputs do not concern themselves with the housekeeping operations required such as memory management. These
-algorithms will be used to establish the relevant theory which will subsequently be used to describe a multiple
-precision algorithm to solve the same problem.
-
-\subsection{Precision Notation}
-The variable $\beta$ represents the radix of a single digit of a multiple precision integer and
-must be of the form $q^p$ for $q, p \in \Z^+$. A single precision variable must be able to represent integers in
-the range $0 \le x < q \beta$ while a double precision variable must be able to represent integers in the range
-$0 \le x < q \beta^2$. The extra radix-$q$ factor allows additions and subtractions to proceed without truncation of the
-carry. Since all modern computers are binary, it is assumed that $q$ is two.
-
-\index{mp\_digit} \index{mp\_word}
-Within the source code that will be presented for each algorithm, the data type \textbf{mp\_digit} will represent
-a single precision integer type, while, the data type \textbf{mp\_word} will represent a double precision integer type. In
-several algorithms (notably the Comba routines) temporary results will be stored in arrays of double precision mp\_words.
-For the purposes of this text $x_j$ will refer to the $j$'th digit of a single precision array and $\hat x_j$ will refer to
-the $j$'th digit of a double precision array. Whenever an expression is to be assigned to a double precision
-variable it is assumed that all single precision variables are promoted to double precision during the evaluation.
-Expressions that are assigned to a single precision variable are truncated to fit within the precision of a single
-precision data type.
-
-For example, if $\beta = 10^2$ a single precision data type may represent a value in the
-range $0 \le x < 10^3$, while a double precision data type may represent a value in the range $0 \le x < 10^5$. Let
-$a = 23$ and $b = 49$ represent two single precision variables. The single precision product shall be written
-as $c \leftarrow a \cdot b$ while the double precision product shall be written as $\hat c \leftarrow a \cdot b$.
-In this particular case, $\hat c = 1127$ and $c = 127$. The most significant digit of the product would not fit
-in a single precision data type and as a result $c \ne \hat c$.
-
-\subsection{Algorithm Inputs and Outputs}
-Within the algorithm descriptions all variables are assumed to be scalars of either single or double precision
-as indicated. The only exception to this rule is when variables have been indicated to be of type mp\_int. This
-distinction is important as scalars are often used as array indicies and various other counters.
-
-\subsection{Mathematical Expressions}
-The $\lfloor \mbox{ } \rfloor$ brackets imply an expression truncated to an integer not greater than the expression
-itself. For example, $\lfloor 5.7 \rfloor = 5$. Similarly the $\lceil \mbox{ } \rceil$ brackets imply an expression
-rounded to an integer not less than the expression itself. For example, $\lceil 5.1 \rceil = 6$. Typically when
-the $/$ division symbol is used the intention is to perform an integer division with truncation. For example,
-$5/2 = 2$ which will often be written as $\lfloor 5/2 \rfloor = 2$ for clarity. When an expression is written as a
-fraction a real value division is implied, for example ${5 \over 2} = 2.5$.
-
-The norm of a multiple precision integer, for example $\vert \vert x \vert \vert$, will be used to represent the number of digits in the representation
-of the integer. For example, $\vert \vert 123 \vert \vert = 3$ and $\vert \vert 79452 \vert \vert = 5$.
-
-\subsection{Work Effort}
-\index{big-Oh}
-To measure the efficiency of the specified algorithms, a modified big-Oh notation is used. In this system all
-single precision operations are considered to have the same cost\footnote{Except where explicitly noted.}.
-That is a single precision addition, multiplication and division are assumed to take the same time to
-complete. While this is generally not true in practice, it will simplify the discussions considerably.
-
-Some algorithms have slight advantages over others which is why some constants will not be removed in
-the notation. For example, a normal baseline multiplication (section \ref{sec:basemult}) requires $O(n^2)$ work while a
-baseline squaring (section \ref{sec:basesquare}) requires $O({{n^2 + n}\over 2})$ work. In standard big-Oh notation these
-would both be said to be equivalent to $O(n^2)$. However,
-in the context of the this text this is not the case as the magnitude of the inputs will typically be rather small. As a
-result small constant factors in the work effort will make an observable difference in algorithm efficiency.
-
-All of the algorithms presented in this text have a polynomial time work level. That is, of the form
-$O(n^k)$ for $n, k \in \Z^{+}$. This will help make useful comparisons in terms of the speed of the algorithms and how
-various optimizations will help pay off in the long run.
-
-\section{Exercises}
-Within the more advanced chapters a section will be set aside to give the reader some challenging exercises related to
-the discussion at hand. These exercises are not designed to be prize winning problems, but instead to be thought
-provoking. Wherever possible the problems are forward minded, stating problems that will be answered in subsequent
-chapters. The reader is encouraged to finish the exercises as they appear to get a better understanding of the
-subject material.
-
-That being said, the problems are designed to affirm knowledge of a particular subject matter. Students in particular
-are encouraged to verify they can answer the problems correctly before moving on.
-
-Similar to the exercises of \cite[pp. ix]{TAOCPV2} these exercises are given a scoring system based on the difficulty of
-the problem. However, unlike \cite{TAOCPV2} the problems do not get nearly as hard. The scoring of these
-exercises ranges from one (the easiest) to five (the hardest). The following table sumarizes the
-scoring system used.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|l|}
-\hline $\left [ 1 \right ]$ & An easy problem that should only take the reader a manner of \\
- & minutes to solve. Usually does not involve much computer time \\
- & to solve. \\
-\hline $\left [ 2 \right ]$ & An easy problem that involves a marginal amount of computer \\
- & time usage. Usually requires a program to be written to \\
- & solve the problem. \\
-\hline $\left [ 3 \right ]$ & A moderately hard problem that requires a non-trivial amount \\
- & of work. Usually involves trivial research and development of \\
- & new theory from the perspective of a student. \\
-\hline $\left [ 4 \right ]$ & A moderately hard problem that involves a non-trivial amount \\
- & of work and research, the solution to which will demonstrate \\
- & a higher mastery of the subject matter. \\
-\hline $\left [ 5 \right ]$ & A hard problem that involves concepts that are difficult for a \\
- & novice to solve. Solutions to these problems will demonstrate a \\
- & complete mastery of the given subject. \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Exercise Scoring System}
-\end{figure}
-
-Problems at the first level are meant to be simple questions that the reader can answer quickly without programming a solution or
-devising new theory. These problems are quick tests to see if the material is understood. Problems at the second level
-are also designed to be easy but will require a program or algorithm to be implemented to arrive at the answer. These
-two levels are essentially entry level questions.
-
-Problems at the third level are meant to be a bit more difficult than the first two levels. The answer is often
-fairly obvious but arriving at an exacting solution requires some thought and skill. These problems will almost always
-involve devising a new algorithm or implementing a variation of another algorithm previously presented. Readers who can
-answer these questions will feel comfortable with the concepts behind the topic at hand.
-
-Problems at the fourth level are meant to be similar to those of the level three questions except they will require
-additional research to be completed. The reader will most likely not know the answer right away, nor will the text provide
-the exact details of the answer until a subsequent chapter.
-
-Problems at the fifth level are meant to be the hardest
-problems relative to all the other problems in the chapter. People who can correctly answer fifth level problems have a
-mastery of the subject matter at hand.
-
-Often problems will be tied together. The purpose of this is to start a chain of thought that will be discussed in future chapters. The reader
-is encouraged to answer the follow-up problems and try to draw the relevance of problems.
-
-\section{Introduction to LibTomMath}
-
-\subsection{What is LibTomMath?}
-LibTomMath is a free and open source multiple precision integer library written entirely in portable ISO C. By portable it
-is meant that the library does not contain any code that is computer platform dependent or otherwise problematic to use on
-any given platform.
-
-The library has been successfully tested under numerous operating systems including Unix\footnote{All of these
-trademarks belong to their respective rightful owners.}, MacOS, Windows, Linux, PalmOS and on standalone hardware such
-as the Gameboy Advance. The library is designed to contain enough functionality to be able to develop applications such
-as public key cryptosystems and still maintain a relatively small footprint.
-
-\subsection{Goals of LibTomMath}
-
-Libraries which obtain the most efficiency are rarely written in a high level programming language such as C. However,
-even though this library is written entirely in ISO C, considerable care has been taken to optimize the algorithm implementations within the
-library. Specifically the code has been written to work well with the GNU C Compiler (\textit{GCC}) on both x86 and ARM
-processors. Wherever possible, highly efficient algorithms, such as Karatsuba multiplication, sliding window
-exponentiation and Montgomery reduction have been provided to make the library more efficient.
-
-Even with the nearly optimal and specialized algorithms that have been included the Application Programing Interface
-(\textit{API}) has been kept as simple as possible. Often generic place holder routines will make use of specialized
-algorithms automatically without the developer's specific attention. One such example is the generic multiplication
-algorithm \textbf{mp\_mul()} which will automatically use Toom--Cook, Karatsuba, Comba or baseline multiplication
-based on the magnitude of the inputs and the configuration of the library.
-
-Making LibTomMath as efficient as possible is not the only goal of the LibTomMath project. Ideally the library should
-be source compatible with another popular library which makes it more attractive for developers to use. In this case the
-MPI library was used as a API template for all the basic functions. MPI was chosen because it is another library that fits
-in the same niche as LibTomMath. Even though LibTomMath uses MPI as the template for the function names and argument
-passing conventions, it has been written from scratch by Tom St Denis.
-
-The project is also meant to act as a learning tool for students, the logic being that no easy-to-follow ``bignum''
-library exists which can be used to teach computer science students how to perform fast and reliable multiple precision
-integer arithmetic. To this end the source code has been given quite a few comments and algorithm discussion points.
-
-\section{Choice of LibTomMath}
-LibTomMath was chosen as the case study of this text not only because the author of both projects is one and the same but
-for more worthy reasons. Other libraries such as GMP \cite{GMP}, MPI \cite{MPI}, LIP \cite{LIP} and OpenSSL
-\cite{OPENSSL} have multiple precision integer arithmetic routines but would not be ideal for this text for
-reasons that will be explained in the following sub-sections.
-
-\subsection{Code Base}
-The LibTomMath code base is all portable ISO C source code. This means that there are no platform dependent conditional
-segments of code littered throughout the source. This clean and uncluttered approach to the library means that a
-developer can more readily discern the true intent of a given section of source code without trying to keep track of
-what conditional code will be used.
-
-The code base of LibTomMath is well organized. Each function is in its own separate source code file
-which allows the reader to find a given function very quickly. On average there are $76$ lines of code per source
-file which makes the source very easily to follow. By comparison MPI and LIP are single file projects making code tracing
-very hard. GMP has many conditional code segments which also hinder tracing.
-
-When compiled with GCC for the x86 processor and optimized for speed the entire library is approximately $100$KiB\footnote{The notation ``KiB'' means $2^{10}$ octets, similarly ``MiB'' means $2^{20}$ octets.}
- which is fairly small compared to GMP (over $250$KiB). LibTomMath is slightly larger than MPI (which compiles to about
-$50$KiB) but LibTomMath is also much faster and more complete than MPI.
-
-\subsection{API Simplicity}
-LibTomMath is designed after the MPI library and shares the API design. Quite often programs that use MPI will build
-with LibTomMath without change. The function names correlate directly to the action they perform. Almost all of the
-functions share the same parameter passing convention. The learning curve is fairly shallow with the API provided
-which is an extremely valuable benefit for the student and developer alike.
-
-The LIP library is an example of a library with an API that is awkward to work with. LIP uses function names that are often ``compressed'' to
-illegible short hand. LibTomMath does not share this characteristic.
-
-The GMP library also does not return error codes. Instead it uses a POSIX.1 \cite{POSIX1} signal system where errors
-are signaled to the host application. This happens to be the fastest approach but definitely not the most versatile. In
-effect a math error (i.e. invalid input, heap error, etc) can cause a program to stop functioning which is definitely
-undersireable in many situations.
-
-\subsection{Optimizations}
-While LibTomMath is certainly not the fastest library (GMP often beats LibTomMath by a factor of two) it does
-feature a set of optimal algorithms for tasks such as modular reduction, exponentiation, multiplication and squaring. GMP
-and LIP also feature such optimizations while MPI only uses baseline algorithms with no optimizations. GMP lacks a few
-of the additional modular reduction optimizations that LibTomMath features\footnote{At the time of this writing GMP
-only had Barrett and Montgomery modular reduction algorithms.}.
-
-LibTomMath is almost always an order of magnitude faster than the MPI library at computationally expensive tasks such as modular
-exponentiation. In the grand scheme of ``bignum'' libraries LibTomMath is faster than the average library and usually
-slower than the best libraries such as GMP and OpenSSL by only a small factor.
-
-\subsection{Portability and Stability}
-LibTomMath will build ``out of the box'' on any platform equipped with a modern version of the GNU C Compiler
-(\textit{GCC}). This means that without changes the library will build without configuration or setting up any
-variables. LIP and MPI will build ``out of the box'' as well but have numerous known bugs. Most notably the author of
-MPI has recently stopped working on his library and LIP has long since been discontinued.
-
-GMP requires a configuration script to run and will not build out of the box. GMP and LibTomMath are still in active
-development and are very stable across a variety of platforms.
-
-\subsection{Choice}
-LibTomMath is a relatively compact, well documented, highly optimized and portable library which seems only natural for
-the case study of this text. Various source files from the LibTomMath project will be included within the text. However,
-the reader is encouraged to download their own copy of the library to actually be able to work with the library.
-
-\chapter{Getting Started}
-\section{Library Basics}
-The trick to writing any useful library of source code is to build a solid foundation and work outwards from it. First,
-a problem along with allowable solution parameters should be identified and analyzed. In this particular case the
-inability to accomodate multiple precision integers is the problem. Futhermore, the solution must be written
-as portable source code that is reasonably efficient across several different computer platforms.
-
-After a foundation is formed the remainder of the library can be designed and implemented in a hierarchical fashion.
-That is, to implement the lowest level dependencies first and work towards the most abstract functions last. For example,
-before implementing a modular exponentiation algorithm one would implement a modular reduction algorithm.
-By building outwards from a base foundation instead of using a parallel design methodology the resulting project is
-highly modular. Being highly modular is a desirable property of any project as it often means the resulting product
-has a small footprint and updates are easy to perform.
-
-Usually when I start a project I will begin with the header files. I define the data types I think I will need and
-prototype the initial functions that are not dependent on other functions (within the library). After I
-implement these base functions I prototype more dependent functions and implement them. The process repeats until
-I implement all of the functions I require. For example, in the case of LibTomMath I implemented functions such as
-mp\_init() well before I implemented mp\_mul() and even further before I implemented mp\_exptmod(). As an example as to
-why this design works note that the Karatsuba and Toom-Cook multipliers were written \textit{after} the
-dependent function mp\_exptmod() was written. Adding the new multiplication algorithms did not require changes to the
-mp\_exptmod() function itself and lowered the total cost of ownership (\textit{so to speak}) and of development
-for new algorithms. This methodology allows new algorithms to be tested in a complete framework with relative ease.
-
-\begin{center}
-\begin{figure}[here]
-\includegraphics{pics/design_process.ps}
-\caption{Design Flow of the First Few Original LibTomMath Functions.}
-\label{pic:design_process}
-\end{figure}
-\end{center}
-
-Only after the majority of the functions were in place did I pursue a less hierarchical approach to auditing and optimizing
-the source code. For example, one day I may audit the multipliers and the next day the polynomial basis functions.
-
-It only makes sense to begin the text with the preliminary data types and support algorithms required as well.
-This chapter discusses the core algorithms of the library which are the dependents for every other algorithm.
-
-\section{What is a Multiple Precision Integer?}
-Recall that most programming languages, in particular ISO C \cite{ISOC}, only have fixed precision data types that on their own cannot
-be used to represent values larger than their precision will allow. The purpose of multiple precision algorithms is
-to use fixed precision data types to create and manipulate multiple precision integers which may represent values
-that are very large.
-
-As a well known analogy, school children are taught how to form numbers larger than nine by prepending more radix ten digits. In the decimal system
-the largest single digit value is $9$. However, by concatenating digits together larger numbers may be represented. Newly prepended digits
-(\textit{to the left}) are said to be in a different power of ten column. That is, the number $123$ can be described as having a $1$ in the hundreds
-column, $2$ in the tens column and $3$ in the ones column. Or more formally $123 = 1 \cdot 10^2 + 2 \cdot 10^1 + 3 \cdot 10^0$. Computer based
-multiple precision arithmetic is essentially the same concept. Larger integers are represented by adjoining fixed
-precision computer words with the exception that a different radix is used.
-
-What most people probably do not think about explicitly are the various other attributes that describe a multiple precision
-integer. For example, the integer $154_{10}$ has two immediately obvious properties. First, the integer is positive,
-that is the sign of this particular integer is positive as opposed to negative. Second, the integer has three digits in
-its representation. There is an additional property that the integer posesses that does not concern pencil-and-paper
-arithmetic. The third property is how many digits placeholders are available to hold the integer.
-
-The human analogy of this third property is ensuring there is enough space on the paper to write the integer. For example,
-if one starts writing a large number too far to the right on a piece of paper they will have to erase it and move left.
-Similarly, computer algorithms must maintain strict control over memory usage to ensure that the digits of an integer
-will not exceed the allowed boundaries. These three properties make up what is known as a multiple precision
-integer or mp\_int for short.
-
-\subsection{The mp\_int Structure}
-\label{sec:MPINT}
-The mp\_int structure is the ISO C based manifestation of what represents a multiple precision integer. The ISO C standard does not provide for
-any such data type but it does provide for making composite data types known as structures. The following is the structure definition
-used within LibTomMath.
-
-\index{mp\_int}
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-%\begin{verbatim}
-\begin{tabular}{|l|}
-\hline
-typedef struct \{ \\
-\hspace{3mm}int used, alloc, sign;\\
-\hspace{3mm}mp\_digit *dp;\\
-\} \textbf{mp\_int}; \\
-\hline
-\end{tabular}
-%\end{verbatim}
-\end{small}
-\caption{The mp\_int Structure}
-\label{fig:mpint}
-\end{center}
-\end{figure}
-
-The mp\_int structure (fig. \ref{fig:mpint}) can be broken down as follows.
-
-\begin{enumerate}
-\item The \textbf{used} parameter denotes how many digits of the array \textbf{dp} contain the digits used to represent
-a given integer. The \textbf{used} count must be positive (or zero) and may not exceed the \textbf{alloc} count.
-
-\item The \textbf{alloc} parameter denotes how
-many digits are available in the array to use by functions before it has to increase in size. When the \textbf{used} count
-of a result would exceed the \textbf{alloc} count all of the algorithms will automatically increase the size of the
-array to accommodate the precision of the result.
-
-\item The pointer \textbf{dp} points to a dynamically allocated array of digits that represent the given multiple
-precision integer. It is padded with $(\textbf{alloc} - \textbf{used})$ zero digits. The array is maintained in a least
-significant digit order. As a pencil and paper analogy the array is organized such that the right most digits are stored
-first starting at the location indexed by zero\footnote{In C all arrays begin at zero.} in the array. For example,
-if \textbf{dp} contains $\lbrace a, b, c, \ldots \rbrace$ where \textbf{dp}$_0 = a$, \textbf{dp}$_1 = b$, \textbf{dp}$_2 = c$, $\ldots$ then
-it would represent the integer $a + b\beta + c\beta^2 + \ldots$
-
-\index{MP\_ZPOS} \index{MP\_NEG}
-\item The \textbf{sign} parameter denotes the sign as either zero/positive (\textbf{MP\_ZPOS}) or negative (\textbf{MP\_NEG}).
-\end{enumerate}
-
-\subsubsection{Valid mp\_int Structures}
-Several rules are placed on the state of an mp\_int structure and are assumed to be followed for reasons of efficiency.
-The only exceptions are when the structure is passed to initialization functions such as mp\_init() and mp\_init\_copy().
-
-\begin{enumerate}
-\item The value of \textbf{alloc} may not be less than one. That is \textbf{dp} always points to a previously allocated
-array of digits.
-\item The value of \textbf{used} may not exceed \textbf{alloc} and must be greater than or equal to zero.
-\item The value of \textbf{used} implies the digit at index $(used - 1)$ of the \textbf{dp} array is non-zero. That is,
-leading zero digits in the most significant positions must be trimmed.
- \begin{enumerate}
- \item Digits in the \textbf{dp} array at and above the \textbf{used} location must be zero.
- \end{enumerate}
-\item The value of \textbf{sign} must be \textbf{MP\_ZPOS} if \textbf{used} is zero;
-this represents the mp\_int value of zero.
-\end{enumerate}
-
-\section{Argument Passing}
-A convention of argument passing must be adopted early on in the development of any library. Making the function
-prototypes consistent will help eliminate many headaches in the future as the library grows to significant complexity.
-In LibTomMath the multiple precision integer functions accept parameters from left to right as pointers to mp\_int
-structures. That means that the source (input) operands are placed on the left and the destination (output) on the right.
-Consider the following examples.
-
-\begin{verbatim}
- mp_mul(&a, &b, &c); /* c = a * b */
- mp_add(&a, &b, &a); /* a = a + b */
- mp_sqr(&a, &b); /* b = a * a */
-\end{verbatim}
-
-The left to right order is a fairly natural way to implement the functions since it lets the developer read aloud the
-functions and make sense of them. For example, the first function would read ``multiply a and b and store in c''.
-
-Certain libraries (\textit{LIP by Lenstra for instance}) accept parameters the other way around, to mimic the order
-of assignment expressions. That is, the destination (output) is on the left and arguments (inputs) are on the right. In
-truth, it is entirely a matter of preference. In the case of LibTomMath the convention from the MPI library has been
-adopted.
-
-Another very useful design consideration, provided for in LibTomMath, is whether to allow argument sources to also be a
-destination. For example, the second example (\textit{mp\_add}) adds $a$ to $b$ and stores in $a$. This is an important
-feature to implement since it allows the calling functions to cut down on the number of variables it must maintain.
-However, to implement this feature specific care has to be given to ensure the destination is not modified before the
-source is fully read.
-
-\section{Return Values}
-A well implemented application, no matter what its purpose, should trap as many runtime errors as possible and return them
-to the caller. By catching runtime errors a library can be guaranteed to prevent undefined behaviour. However, the end
-developer can still manage to cause a library to crash. For example, by passing an invalid pointer an application may
-fault by dereferencing memory not owned by the application.
-
-In the case of LibTomMath the only errors that are checked for are related to inappropriate inputs (division by zero for
-instance) and memory allocation errors. It will not check that the mp\_int passed to any function is valid nor
-will it check pointers for validity. Any function that can cause a runtime error will return an error code as an
-\textbf{int} data type with one of the following values (fig \ref{fig:errcodes}).
-
-\index{MP\_OKAY} \index{MP\_VAL} \index{MP\_MEM}
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|l|l|}
-\hline \textbf{Value} & \textbf{Meaning} \\
-\hline \textbf{MP\_OKAY} & The function was successful \\
-\hline \textbf{MP\_VAL} & One of the input value(s) was invalid \\
-\hline \textbf{MP\_MEM} & The function ran out of heap memory \\
-\hline
-\end{tabular}
-\end{center}
-\caption{LibTomMath Error Codes}
-\label{fig:errcodes}
-\end{figure}
-
-When an error is detected within a function it should free any memory it allocated, often during the initialization of
-temporary mp\_ints, and return as soon as possible. The goal is to leave the system in the same state it was when the
-function was called. Error checking with this style of API is fairly simple.
-
-\begin{verbatim}
- int err;
- if ((err = mp_add(&a, &b, &c)) != MP_OKAY) {
- printf("Error: %s\n", mp_error_to_string(err));
- exit(EXIT_FAILURE);
- }
-\end{verbatim}
-
-The GMP \cite{GMP} library uses C style \textit{signals} to flag errors which is of questionable use. Not all errors are fatal
-and it was not deemed ideal by the author of LibTomMath to force developers to have signal handlers for such cases.
-
-\section{Initialization and Clearing}
-The logical starting point when actually writing multiple precision integer functions is the initialization and
-clearing of the mp\_int structures. These two algorithms will be used by the majority of the higher level algorithms.
-
-Given the basic mp\_int structure an initialization routine must first allocate memory to hold the digits of
-the integer. Often it is optimal to allocate a sufficiently large pre-set number of digits even though
-the initial integer will represent zero. If only a single digit were allocated quite a few subsequent re-allocations
-would occur when operations are performed on the integers. There is a tradeoff between how many default digits to allocate
-and how many re-allocations are tolerable. Obviously allocating an excessive amount of digits initially will waste
-memory and become unmanageable.
-
-If the memory for the digits has been successfully allocated then the rest of the members of the structure must
-be initialized. Since the initial state of an mp\_int is to represent the zero integer, the allocated digits must be set
-to zero. The \textbf{used} count set to zero and \textbf{sign} set to \textbf{MP\_ZPOS}.
-
-\subsection{Initializing an mp\_int}
-An mp\_int is said to be initialized if it is set to a valid, preferably default, state such that all of the members of the
-structure are set to valid values. The mp\_init algorithm will perform such an action.
-
-\index{mp\_init}
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Allocate memory and initialize $a$ to a known valid mp\_int state. \\
-\hline \\
-1. Allocate memory for \textbf{MP\_PREC} digits. \\
-2. If the allocation failed return(\textit{MP\_MEM}) \\
-3. for $n$ from $0$ to $MP\_PREC - 1$ do \\
-\hspace{3mm}3.1 $a_n \leftarrow 0$\\
-4. $a.sign \leftarrow MP\_ZPOS$\\
-5. $a.used \leftarrow 0$\\
-6. $a.alloc \leftarrow MP\_PREC$\\
-7. Return(\textit{MP\_OKAY})\\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init}
-\end{figure}
-
-\textbf{Algorithm mp\_init.}
-The purpose of this function is to initialize an mp\_int structure so that the rest of the library can properly
-manipulte it. It is assumed that the input may not have had any of its members previously initialized which is certainly
-a valid assumption if the input resides on the stack.
-
-Before any of the members such as \textbf{sign}, \textbf{used} or \textbf{alloc} are initialized the memory for
-the digits is allocated. If this fails the function returns before setting any of the other members. The \textbf{MP\_PREC}
-name represents a constant\footnote{Defined in the ``tommath.h'' header file within LibTomMath.}
-used to dictate the minimum precision of newly initialized mp\_int integers. Ideally, it is at least equal to the smallest
-precision number you'll be working with.
-
-Allocating a block of digits at first instead of a single digit has the benefit of lowering the number of usually slow
-heap operations later functions will have to perform in the future. If \textbf{MP\_PREC} is set correctly the slack
-memory and the number of heap operations will be trivial.
-
-Once the allocation has been made the digits have to be set to zero as well as the \textbf{used}, \textbf{sign} and
-\textbf{alloc} members initialized. This ensures that the mp\_int will always represent the default state of zero regardless
-of the original condition of the input.
-
-\textbf{Remark.}
-This function introduces the idiosyncrasy that all iterative loops, commonly initiated with the ``for'' keyword, iterate incrementally
-when the ``to'' keyword is placed between two expressions. For example, ``for $a$ from $b$ to $c$ do'' means that
-a subsequent expression (or body of expressions) are to be evaluated upto $c - b$ times so long as $b \le c$. In each
-iteration the variable $a$ is substituted for a new integer that lies inclusively between $b$ and $c$. If $b > c$ occured
-the loop would not iterate. By contrast if the ``downto'' keyword were used in place of ``to'' the loop would iterate
-decrementally.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_init.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-One immediate observation of this initializtion function is that it does not return a pointer to a mp\_int structure. It
-is assumed that the caller has already allocated memory for the mp\_int structure, typically on the application stack. The
-call to mp\_init() is used only to initialize the members of the structure to a known default state.
-
-Here we see (line 24) the memory allocation is performed first. This allows us to exit cleanly and quickly
-if there is an error. If the allocation fails the routine will return \textbf{MP\_MEM} to the caller to indicate there
-was a memory error. The function XMALLOC is what actually allocates the memory. Technically XMALLOC is not a function
-but a macro defined in ``tommath.h``. By default, XMALLOC will evaluate to malloc() which is the C library's built--in
-memory allocation routine.
-
-In order to assure the mp\_int is in a known state the digits must be set to zero. On most platforms this could have been
-accomplished by using calloc() instead of malloc(). However, to correctly initialize a integer type to a given value in a
-portable fashion you have to actually assign the value. The for loop (line 30) performs this required
-operation.
-
-After the memory has been successfully initialized the remainder of the members are initialized
-(lines 34 through 35) to their respective default states. At this point the algorithm has succeeded and
-a success code is returned to the calling function. If this function returns \textbf{MP\_OKAY} it is safe to assume the
-mp\_int structure has been properly initialized and is safe to use with other functions within the library.
-
-\subsection{Clearing an mp\_int}
-When an mp\_int is no longer required by the application, the memory that has been allocated for its digits must be
-returned to the application's memory pool with the mp\_clear algorithm.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_clear}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. The memory for $a$ shall be deallocated. \\
-\hline \\
-1. If $a$ has been previously freed then return(\textit{MP\_OKAY}). \\
-2. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}2.1 $a_n \leftarrow 0$ \\
-3. Free the memory allocated for the digits of $a$. \\
-4. $a.used \leftarrow 0$ \\
-5. $a.alloc \leftarrow 0$ \\
-6. $a.sign \leftarrow MP\_ZPOS$ \\
-7. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_clear}
-\end{figure}
-
-\textbf{Algorithm mp\_clear.}
-This algorithm accomplishes two goals. First, it clears the digits and the other mp\_int members. This ensures that
-if a developer accidentally re-uses a cleared structure it is less likely to cause problems. The second goal
-is to free the allocated memory.
-
-The logic behind the algorithm is extended by marking cleared mp\_int structures so that subsequent calls to this
-algorithm will not try to free the memory multiple times. Cleared mp\_ints are detectable by having a pre-defined invalid
-digit pointer \textbf{dp} setting.
-
-Once an mp\_int has been cleared the mp\_int structure is no longer in a valid state for any other algorithm
-with the exception of algorithms mp\_init, mp\_init\_copy, mp\_init\_size and mp\_clear.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_clear.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The algorithm only operates on the mp\_int if it hasn't been previously cleared. The if statement (line 25)
-checks to see if the \textbf{dp} member is not \textbf{NULL}. If the mp\_int is a valid mp\_int then \textbf{dp} cannot be
-\textbf{NULL} in which case the if statement will evaluate to true.
-
-The digits of the mp\_int are cleared by the for loop (line 27) which assigns a zero to every digit. Similar to mp\_init()
-the digits are assigned zero instead of using block memory operations (such as memset()) since this is more portable.
-
-The digits are deallocated off the heap via the XFREE macro. Similar to XMALLOC the XFREE macro actually evaluates to
-a standard C library function. In this case the free() function. Since free() only deallocates the memory the pointer
-still has to be reset to \textbf{NULL} manually (line 35).
-
-Now that the digits have been cleared and deallocated the other members are set to their final values (lines 36 and 37).
-
-\section{Maintenance Algorithms}
-
-The previous sections describes how to initialize and clear an mp\_int structure. To further support operations
-that are to be performed on mp\_int structures (such as addition and multiplication) the dependent algorithms must be
-able to augment the precision of an mp\_int and
-initialize mp\_ints with differing initial conditions.
-
-These algorithms complete the set of low level algorithms required to work with mp\_int structures in the higher level
-algorithms such as addition, multiplication and modular exponentiation.
-
-\subsection{Augmenting an mp\_int's Precision}
-When storing a value in an mp\_int structure, a sufficient number of digits must be available to accomodate the entire
-result of an operation without loss of precision. Quite often the size of the array given by the \textbf{alloc} member
-is large enough to simply increase the \textbf{used} digit count. However, when the size of the array is too small it
-must be re-sized appropriately to accomodate the result. The mp\_grow algorithm will provide this functionality.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_grow}. \\
-\textbf{Input}. An mp\_int $a$ and an integer $b$. \\
-\textbf{Output}. $a$ is expanded to accomodate $b$ digits. \\
-\hline \\
-1. if $a.alloc \ge b$ then return(\textit{MP\_OKAY}) \\
-2. $u \leftarrow b\mbox{ (mod }MP\_PREC\mbox{)}$ \\
-3. $v \leftarrow b + 2 \cdot MP\_PREC - u$ \\
-4. Re-allocate the array of digits $a$ to size $v$ \\
-5. If the allocation failed then return(\textit{MP\_MEM}). \\
-6. for n from a.alloc to $v - 1$ do \\
-\hspace{+3mm}6.1 $a_n \leftarrow 0$ \\
-7. $a.alloc \leftarrow v$ \\
-8. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_grow}
-\end{figure}
-
-\textbf{Algorithm mp\_grow.}
-It is ideal to prevent re-allocations from being performed if they are not required (step one). This is useful to
-prevent mp\_ints from growing excessively in code that erroneously calls mp\_grow.
-
-The requested digit count is padded up to next multiple of \textbf{MP\_PREC} plus an additional \textbf{MP\_PREC} (steps two and three).
-This helps prevent many trivial reallocations that would grow an mp\_int by trivially small values.
-
-It is assumed that the reallocation (step four) leaves the lower $a.alloc$ digits of the mp\_int intact. This is much
-akin to how the \textit{realloc} function from the standard C library works. Since the newly allocated digits are
-assumed to contain undefined values they are initially set to zero.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_grow.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-A quick optimization is to first determine if a memory re-allocation is required at all. The if statement (line 24) checks
-if the \textbf{alloc} member of the mp\_int is smaller than the requested digit count. If the count is not larger than \textbf{alloc}
-the function skips the re-allocation part thus saving time.
-
-When a re-allocation is performed it is turned into an optimal request to save time in the future. The requested digit count is
-padded upwards to 2nd multiple of \textbf{MP\_PREC} larger than \textbf{alloc} (line 25). The XREALLOC function is used
-to re-allocate the memory. As per the other functions XREALLOC is actually a macro which evaluates to realloc by default. The realloc
-function leaves the base of the allocation intact which means the first \textbf{alloc} digits of the mp\_int are the same as before
-the re-allocation. All that is left is to clear the newly allocated digits and return.
-
-Note that the re-allocation result is actually stored in a temporary pointer $tmp$. This is to allow this function to return
-an error with a valid pointer. Earlier releases of the library stored the result of XREALLOC into the mp\_int $a$. That would
-result in a memory leak if XREALLOC ever failed.
-
-\subsection{Initializing Variable Precision mp\_ints}
-Occasionally the number of digits required will be known in advance of an initialization, based on, for example, the size
-of input mp\_ints to a given algorithm. The purpose of algorithm mp\_init\_size is similar to mp\_init except that it
-will allocate \textit{at least} a specified number of digits.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_size}. \\
-\textbf{Input}. An mp\_int $a$ and the requested number of digits $b$. \\
-\textbf{Output}. $a$ is initialized to hold at least $b$ digits. \\
-\hline \\
-1. $u \leftarrow b \mbox{ (mod }MP\_PREC\mbox{)}$ \\
-2. $v \leftarrow b + 2 \cdot MP\_PREC - u$ \\
-3. Allocate $v$ digits. \\
-4. for $n$ from $0$ to $v - 1$ do \\
-\hspace{3mm}4.1 $a_n \leftarrow 0$ \\
-5. $a.sign \leftarrow MP\_ZPOS$\\
-6. $a.used \leftarrow 0$\\
-7. $a.alloc \leftarrow v$\\
-8. Return(\textit{MP\_OKAY})\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_init\_size}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_size.}
-This algorithm will initialize an mp\_int structure $a$ like algorithm mp\_init with the exception that the number of
-digits allocated can be controlled by the second input argument $b$. The input size is padded upwards so it is a
-multiple of \textbf{MP\_PREC} plus an additional \textbf{MP\_PREC} digits. This padding is used to prevent trivial
-allocations from becoming a bottleneck in the rest of the algorithms.
-
-Like algorithm mp\_init, the mp\_int structure is initialized to a default state representing the integer zero. This
-particular algorithm is useful if it is known ahead of time the approximate size of the input. If the approximation is
-correct no further memory re-allocations are required to work with the mp\_int.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_init\_size.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The number of digits $b$ requested is padded (line 24) by first augmenting it to the next multiple of
-\textbf{MP\_PREC} and then adding \textbf{MP\_PREC} to the result. If the memory can be successfully allocated the
-mp\_int is placed in a default state representing the integer zero. Otherwise, the error code \textbf{MP\_MEM} will be
-returned (line 29).
-
-The digits are allocated and set to zero at the same time with the calloc() function (line @25,XCALLOC@). The
-\textbf{used} count is set to zero, the \textbf{alloc} count set to the padded digit count and the \textbf{sign} flag set
-to \textbf{MP\_ZPOS} to achieve a default valid mp\_int state (lines 33, 34 and 35). If the function
-returns succesfully then it is correct to assume that the mp\_int structure is in a valid state for the remainder of the
-functions to work with.
-
-\subsection{Multiple Integer Initializations and Clearings}
-Occasionally a function will require a series of mp\_int data types to be made available simultaneously.
-The purpose of algorithm mp\_init\_multi is to initialize a variable length array of mp\_int structures in a single
-statement. It is essentially a shortcut to multiple initializations.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_multi}. \\
-\textbf{Input}. Variable length array $V_k$ of mp\_int variables of length $k$. \\
-\textbf{Output}. The array is initialized such that each mp\_int of $V_k$ is ready to use. \\
-\hline \\
-1. for $n$ from 0 to $k - 1$ do \\
-\hspace{+3mm}1.1. Initialize the mp\_int $V_n$ (\textit{mp\_init}) \\
-\hspace{+3mm}1.2. If initialization failed then do \\
-\hspace{+6mm}1.2.1. for $j$ from $0$ to $n$ do \\
-\hspace{+9mm}1.2.1.1. Free the mp\_int $V_j$ (\textit{mp\_clear}) \\
-\hspace{+6mm}1.2.2. Return(\textit{MP\_MEM}) \\
-2. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init\_multi}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_multi.}
-The algorithm will initialize the array of mp\_int variables one at a time. If a runtime error has been detected
-(\textit{step 1.2}) all of the previously initialized variables are cleared. The goal is an ``all or nothing''
-initialization which allows for quick recovery from runtime errors.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_init\_multi.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This function intializes a variable length list of mp\_int structure pointers. However, instead of having the mp\_int
-structures in an actual C array they are simply passed as arguments to the function. This function makes use of the
-``...'' argument syntax of the C programming language. The list is terminated with a final \textbf{NULL} argument
-appended on the right.
-
-The function uses the ``stdarg.h'' \textit{va} functions to step portably through the arguments to the function. A count
-$n$ of succesfully initialized mp\_int structures is maintained (line 48) such that if a failure does occur,
-the algorithm can backtrack and free the previously initialized structures (lines 28 to 47).
-
-
-\subsection{Clamping Excess Digits}
-When a function anticipates a result will be $n$ digits it is simpler to assume this is true within the body of
-the function instead of checking during the computation. For example, a multiplication of a $i$ digit number by a
-$j$ digit produces a result of at most $i + j$ digits. It is entirely possible that the result is $i + j - 1$
-though, with no final carry into the last position. However, suppose the destination had to be first expanded
-(\textit{via mp\_grow}) to accomodate $i + j - 1$ digits than further expanded to accomodate the final carry.
-That would be a considerable waste of time since heap operations are relatively slow.
-
-The ideal solution is to always assume the result is $i + j$ and fix up the \textbf{used} count after the function
-terminates. This way a single heap operation (\textit{at most}) is required. However, if the result was not checked
-there would be an excess high order zero digit.
-
-For example, suppose the product of two integers was $x_n = (0x_{n-1}x_{n-2}...x_0)_{\beta}$. The leading zero digit
-will not contribute to the precision of the result. In fact, through subsequent operations more leading zero digits would
-accumulate to the point the size of the integer would be prohibitive. As a result even though the precision is very
-low the representation is excessively large.
-
-The mp\_clamp algorithm is designed to solve this very problem. It will trim high-order zeros by decrementing the
-\textbf{used} count until a non-zero most significant digit is found. Also in this system, zero is considered to be a
-positive number which means that if the \textbf{used} count is decremented to zero, the sign must be set to
-\textbf{MP\_ZPOS}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_clamp}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Any excess leading zero digits of $a$ are removed \\
-\hline \\
-1. while $a.used > 0$ and $a_{a.used - 1} = 0$ do \\
-\hspace{+3mm}1.1 $a.used \leftarrow a.used - 1$ \\
-2. if $a.used = 0$ then do \\
-\hspace{+3mm}2.1 $a.sign \leftarrow MP\_ZPOS$ \\
-\hline \\
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_clamp}
-\end{figure}
-
-\textbf{Algorithm mp\_clamp.}
-As can be expected this algorithm is very simple. The loop on step one is expected to iterate only once or twice at
-the most. For example, this will happen in cases where there is not a carry to fill the last position. Step two fixes the sign for
-when all of the digits are zero to ensure that the mp\_int is valid at all times.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_clamp.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Note on line 28 how to test for the \textbf{used} count is made on the left of the \&\& operator. In the C programming
-language the terms to \&\& are evaluated left to right with a boolean short-circuit if any condition fails. This is
-important since if the \textbf{used} is zero the test on the right would fetch below the array. That is obviously
-undesirable. The parenthesis on line 31 is used to make sure the \textbf{used} count is decremented and not
-the pointer ``a''.
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 1 \right ]$ & Discuss the relevance of the \textbf{used} member of the mp\_int structure. \\
- & \\
-$\left [ 1 \right ]$ & Discuss the consequences of not using padding when performing allocations. \\
- & \\
-$\left [ 2 \right ]$ & Estimate an ideal value for \textbf{MP\_PREC} when performing 1024-bit RSA \\
- & encryption when $\beta = 2^{28}$. \\
- & \\
-$\left [ 1 \right ]$ & Discuss the relevance of the algorithm mp\_clamp. What does it prevent? \\
- & \\
-$\left [ 1 \right ]$ & Give an example of when the algorithm mp\_init\_copy might be useful. \\
- & \\
-\end{tabular}
-
-
-%%%
-% CHAPTER FOUR
-%%%
-
-\chapter{Basic Operations}
-
-\section{Introduction}
-In the previous chapter a series of low level algorithms were established that dealt with initializing and maintaining
-mp\_int structures. This chapter will discuss another set of seemingly non-algebraic algorithms which will form the low
-level basis of the entire library. While these algorithm are relatively trivial it is important to understand how they
-work before proceeding since these algorithms will be used almost intrinsically in the following chapters.
-
-The algorithms in this chapter deal primarily with more ``programmer'' related tasks such as creating copies of
-mp\_int structures, assigning small values to mp\_int structures and comparisons of the values mp\_int structures
-represent.
-
-\section{Assigning Values to mp\_int Structures}
-\subsection{Copying an mp\_int}
-Assigning the value that a given mp\_int structure represents to another mp\_int structure shall be known as making
-a copy for the purposes of this text. The copy of the mp\_int will be a separate entity that represents the same
-value as the mp\_int it was copied from. The mp\_copy algorithm provides this functionality.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_copy}. \\
-\textbf{Input}. An mp\_int $a$ and $b$. \\
-\textbf{Output}. Store a copy of $a$ in $b$. \\
-\hline \\
-1. If $b.alloc < a.used$ then grow $b$ to $a.used$ digits. (\textit{mp\_grow}) \\
-2. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}2.1 $b_{n} \leftarrow a_{n}$ \\
-3. for $n$ from $a.used$ to $b.used - 1$ do \\
-\hspace{3mm}3.1 $b_{n} \leftarrow 0$ \\
-4. $b.used \leftarrow a.used$ \\
-5. $b.sign \leftarrow a.sign$ \\
-6. return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_copy}
-\end{figure}
-
-\textbf{Algorithm mp\_copy.}
-This algorithm copies the mp\_int $a$ such that upon succesful termination of the algorithm the mp\_int $b$ will
-represent the same integer as the mp\_int $a$. The mp\_int $b$ shall be a complete and distinct copy of the
-mp\_int $a$ meaing that the mp\_int $a$ can be modified and it shall not affect the value of the mp\_int $b$.
-
-If $b$ does not have enough room for the digits of $a$ it must first have its precision augmented via the mp\_grow
-algorithm. The digits of $a$ are copied over the digits of $b$ and any excess digits of $b$ are set to zero (step two
-and three). The \textbf{used} and \textbf{sign} members of $a$ are finally copied over the respective members of
-$b$.
-
-\textbf{Remark.} This algorithm also introduces a new idiosyncrasy that will be used throughout the rest of the
-text. The error return codes of other algorithms are not explicitly checked in the pseudo-code presented. For example, in
-step one of the mp\_copy algorithm the return of mp\_grow is not explicitly checked to ensure it succeeded. Text space is
-limited so it is assumed that if a algorithm fails it will clear all temporarily allocated mp\_ints and return
-the error code itself. However, the C code presented will demonstrate all of the error handling logic required to
-implement the pseudo-code.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_copy.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Occasionally a dependent algorithm may copy an mp\_int effectively into itself such as when the input and output
-mp\_int structures passed to a function are one and the same. For this case it is optimal to return immediately without
-copying digits (line 25).
-
-The mp\_int $b$ must have enough digits to accomodate the used digits of the mp\_int $a$. If $b.alloc$ is less than
-$a.used$ the algorithm mp\_grow is used to augment the precision of $b$ (lines 30 to 33). In order to
-simplify the inner loop that copies the digits from $a$ to $b$, two aliases $tmpa$ and $tmpb$ point directly at the digits
-of the mp\_ints $a$ and $b$ respectively. These aliases (lines 43 and 46) allow the compiler to access the digits without first dereferencing the
-mp\_int pointers and then subsequently the pointer to the digits.
-
-After the aliases are established the digits from $a$ are copied into $b$ (lines 49 to 51) and then the excess
-digits of $b$ are set to zero (lines 54 to 56). Both ``for'' loops make use of the pointer aliases and in
-fact the alias for $b$ is carried through into the second ``for'' loop to clear the excess digits. This optimization
-allows the alias to stay in a machine register fairly easy between the two loops.
-
-\textbf{Remarks.} The use of pointer aliases is an implementation methodology first introduced in this function that will
-be used considerably in other functions. Technically, a pointer alias is simply a short hand alias used to lower the
-number of pointer dereferencing operations required to access data. For example, a for loop may resemble
-
-\begin{alltt}
-for (x = 0; x < 100; x++) \{
- a->num[4]->dp[x] = 0;
-\}
-\end{alltt}
-
-This could be re-written using aliases as
-
-\begin{alltt}
-mp_digit *tmpa;
-a = a->num[4]->dp;
-for (x = 0; x < 100; x++) \{
- *a++ = 0;
-\}
-\end{alltt}
-
-In this case an alias is used to access the
-array of digits within an mp\_int structure directly. It may seem that a pointer alias is strictly not required
-as a compiler may optimize out the redundant pointer operations. However, there are two dominant reasons to use aliases.
-
-The first reason is that most compilers will not effectively optimize pointer arithmetic. For example, some optimizations
-may work for the Microsoft Visual C++ compiler (MSVC) and not for the GNU C Compiler (GCC). Also some optimizations may
-work for GCC and not MSVC. As such it is ideal to find a common ground for as many compilers as possible. Pointer
-aliases optimize the code considerably before the compiler even reads the source code which means the end compiled code
-stands a better chance of being faster.
-
-The second reason is that pointer aliases often can make an algorithm simpler to read. Consider the first ``for''
-loop of the function mp\_copy() re-written to not use pointer aliases.
-
-\begin{alltt}
- /* copy all the digits */
- for (n = 0; n < a->used; n++) \{
- b->dp[n] = a->dp[n];
- \}
-\end{alltt}
-
-Whether this code is harder to read depends strongly on the individual. However, it is quantifiably slightly more
-complicated as there are four variables within the statement instead of just two.
-
-\subsubsection{Nested Statements}
-Another commonly used technique in the source routines is that certain sections of code are nested. This is used in
-particular with the pointer aliases to highlight code phases. For example, a Comba multiplier (discussed in chapter six)
-will typically have three different phases. First the temporaries are initialized, then the columns calculated and
-finally the carries are propagated. In this example the middle column production phase will typically be nested as it
-uses temporary variables and aliases the most.
-
-The nesting also simplies the source code as variables that are nested are only valid for their scope. As a result
-the various temporary variables required do not propagate into other sections of code.
-
-
-\subsection{Creating a Clone}
-Another common operation is to make a local temporary copy of an mp\_int argument. To initialize an mp\_int
-and then copy another existing mp\_int into the newly intialized mp\_int will be known as creating a clone. This is
-useful within functions that need to modify an argument but do not wish to actually modify the original copy. The
-mp\_init\_copy algorithm has been designed to help perform this task.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_init\_copy}. \\
-\textbf{Input}. An mp\_int $a$ and $b$\\
-\textbf{Output}. $a$ is initialized to be a copy of $b$. \\
-\hline \\
-1. Init $a$. (\textit{mp\_init}) \\
-2. Copy $b$ to $a$. (\textit{mp\_copy}) \\
-3. Return the status of the copy operation. \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_init\_copy}
-\end{figure}
-
-\textbf{Algorithm mp\_init\_copy.}
-This algorithm will initialize an mp\_int variable and copy another previously initialized mp\_int variable into it. As
-such this algorithm will perform two operations in one step.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_init\_copy.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This will initialize \textbf{a} and make it a verbatim copy of the contents of \textbf{b}. Note that
-\textbf{a} will have its own memory allocated which means that \textbf{b} may be cleared after the call
-and \textbf{a} will be left intact.
-
-\section{Zeroing an Integer}
-Reseting an mp\_int to the default state is a common step in many algorithms. The mp\_zero algorithm will be the algorithm used to
-perform this task.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_zero}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Zero the contents of $a$ \\
-\hline \\
-1. $a.used \leftarrow 0$ \\
-2. $a.sign \leftarrow$ MP\_ZPOS \\
-3. for $n$ from 0 to $a.alloc - 1$ do \\
-\hspace{3mm}3.1 $a_n \leftarrow 0$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_zero}
-\end{figure}
-
-\textbf{Algorithm mp\_zero.}
-This algorithm simply resets a mp\_int to the default state.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_zero.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-After the function is completed, all of the digits are zeroed, the \textbf{used} count is zeroed and the
-\textbf{sign} variable is set to \textbf{MP\_ZPOS}.
-
-\section{Sign Manipulation}
-\subsection{Absolute Value}
-With the mp\_int representation of an integer, calculating the absolute value is trivial. The mp\_abs algorithm will compute
-the absolute value of an mp\_int.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_abs}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Computes $b = \vert a \vert$ \\
-\hline \\
-1. Copy $a$ to $b$. (\textit{mp\_copy}) \\
-2. If the copy failed return(\textit{MP\_MEM}). \\
-3. $b.sign \leftarrow MP\_ZPOS$ \\
-4. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_abs}
-\end{figure}
-
-\textbf{Algorithm mp\_abs.}
-This algorithm computes the absolute of an mp\_int input. First it copies $a$ over $b$. This is an example of an
-algorithm where the check in mp\_copy that determines if the source and destination are equal proves useful. This allows,
-for instance, the developer to pass the same mp\_int as the source and destination to this function without addition
-logic to handle it.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_abs.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This fairly trivial algorithm first eliminates non--required duplications (line 28) and then sets the
-\textbf{sign} flag to \textbf{MP\_ZPOS}.
-
-\subsection{Integer Negation}
-With the mp\_int representation of an integer, calculating the negation is also trivial. The mp\_neg algorithm will compute
-the negative of an mp\_int input.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_neg}. \\
-\textbf{Input}. An mp\_int $a$ \\
-\textbf{Output}. Computes $b = -a$ \\
-\hline \\
-1. Copy $a$ to $b$. (\textit{mp\_copy}) \\
-2. If the copy failed return(\textit{MP\_MEM}). \\
-3. If $a.used = 0$ then return(\textit{MP\_OKAY}). \\
-4. If $a.sign = MP\_ZPOS$ then do \\
-\hspace{3mm}4.1 $b.sign = MP\_NEG$. \\
-5. else do \\
-\hspace{3mm}5.1 $b.sign = MP\_ZPOS$. \\
-6. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_neg}
-\end{figure}
-
-\textbf{Algorithm mp\_neg.}
-This algorithm computes the negation of an input. First it copies $a$ over $b$. If $a$ has no used digits then
-the algorithm returns immediately. Otherwise it flips the sign flag and stores the result in $b$. Note that if
-$a$ had no digits then it must be positive by definition. Had step three been omitted then the algorithm would return
-zero as negative.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_neg.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Like mp\_abs() this function avoids non--required duplications (line 22) and then sets the sign. We
-have to make sure that only non--zero values get a \textbf{sign} of \textbf{MP\_NEG}. If the mp\_int is zero
-than the \textbf{sign} is hard--coded to \textbf{MP\_ZPOS}.
-
-\section{Small Constants}
-\subsection{Setting Small Constants}
-Often a mp\_int must be set to a relatively small value such as $1$ or $2$. For these cases the mp\_set algorithm is useful.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_set}. \\
-\textbf{Input}. An mp\_int $a$ and a digit $b$ \\
-\textbf{Output}. Make $a$ equivalent to $b$ \\
-\hline \\
-1. Zero $a$ (\textit{mp\_zero}). \\
-2. $a_0 \leftarrow b \mbox{ (mod }\beta\mbox{)}$ \\
-3. $a.used \leftarrow \left \lbrace \begin{array}{ll}
- 1 & \mbox{if }a_0 > 0 \\
- 0 & \mbox{if }a_0 = 0
- \end{array} \right .$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_set}
-\end{figure}
-
-\textbf{Algorithm mp\_set.}
-This algorithm sets a mp\_int to a small single digit value. Step number 1 ensures that the integer is reset to the default state. The
-single digit is set (\textit{modulo $\beta$}) and the \textbf{used} count is adjusted accordingly.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_set.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-First we zero (line 21) the mp\_int to make sure that the other members are initialized for a
-small positive constant. mp\_zero() ensures that the \textbf{sign} is positive and the \textbf{used} count
-is zero. Next we set the digit and reduce it modulo $\beta$ (line 22). After this step we have to
-check if the resulting digit is zero or not. If it is not then we set the \textbf{used} count to one, otherwise
-to zero.
-
-We can quickly reduce modulo $\beta$ since it is of the form $2^k$ and a quick binary AND operation with
-$2^k - 1$ will perform the same operation.
-
-One important limitation of this function is that it will only set one digit. The size of a digit is not fixed, meaning source that uses
-this function should take that into account. Only trivially small constants can be set using this function.
-
-\subsection{Setting Large Constants}
-To overcome the limitations of the mp\_set algorithm the mp\_set\_int algorithm is ideal. It accepts a ``long''
-data type as input and will always treat it as a 32-bit integer.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_set\_int}. \\
-\textbf{Input}. An mp\_int $a$ and a ``long'' integer $b$ \\
-\textbf{Output}. Make $a$ equivalent to $b$ \\
-\hline \\
-1. Zero $a$ (\textit{mp\_zero}) \\
-2. for $n$ from 0 to 7 do \\
-\hspace{3mm}2.1 $a \leftarrow a \cdot 16$ (\textit{mp\_mul2d}) \\
-\hspace{3mm}2.2 $u \leftarrow \lfloor b / 2^{4(7 - n)} \rfloor \mbox{ (mod }16\mbox{)}$\\
-\hspace{3mm}2.3 $a_0 \leftarrow a_0 + u$ \\
-\hspace{3mm}2.4 $a.used \leftarrow a.used + 1$ \\
-3. Clamp excess used digits (\textit{mp\_clamp}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_set\_int}
-\end{figure}
-
-\textbf{Algorithm mp\_set\_int.}
-The algorithm performs eight iterations of a simple loop where in each iteration four bits from the source are added to the
-mp\_int. Step 2.1 will multiply the current result by sixteen making room for four more bits in the less significant positions. In step 2.2 the
-next four bits from the source are extracted and are added to the mp\_int. The \textbf{used} digit count is
-incremented to reflect the addition. The \textbf{used} digit counter is incremented since if any of the leading digits were zero the mp\_int would have
-zero digits used and the newly added four bits would be ignored.
-
-Excess zero digits are trimmed in steps 2.1 and 3 by using higher level algorithms mp\_mul2d and mp\_clamp.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_set\_int.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This function sets four bits of the number at a time to handle all practical \textbf{DIGIT\_BIT} sizes. The weird
-addition on line 39 ensures that the newly added in bits are added to the number of digits. While it may not
-seem obvious as to why the digit counter does not grow exceedingly large it is because of the shift on line 28
-as well as the call to mp\_clamp() on line 41. Both functions will clamp excess leading digits which keeps
-the number of used digits low.
-
-\section{Comparisons}
-\subsection{Unsigned Comparisions}
-Comparing a multiple precision integer is performed with the exact same algorithm used to compare two decimal numbers. For example,
-to compare $1,234$ to $1,264$ the digits are extracted by their positions. That is we compare $1 \cdot 10^3 + 2 \cdot 10^2 + 3 \cdot 10^1 + 4 \cdot 10^0$
-to $1 \cdot 10^3 + 2 \cdot 10^2 + 6 \cdot 10^1 + 4 \cdot 10^0$ by comparing single digits at a time starting with the highest magnitude
-positions. If any leading digit of one integer is greater than a digit in the same position of another integer then obviously it must be greater.
-
-The first comparision routine that will be developed is the unsigned magnitude compare which will perform a comparison based on the digits of two
-mp\_int variables alone. It will ignore the sign of the two inputs. Such a function is useful when an absolute comparison is required or if the
-signs are known to agree in advance.
-
-To facilitate working with the results of the comparison functions three constants are required.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|r|l|}
-\hline \textbf{Constant} & \textbf{Meaning} \\
-\hline \textbf{MP\_GT} & Greater Than \\
-\hline \textbf{MP\_EQ} & Equal To \\
-\hline \textbf{MP\_LT} & Less Than \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Comparison Return Codes}
-\end{figure}
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_cmp\_mag}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$. \\
-\textbf{Output}. Unsigned comparison results ($a$ to the left of $b$). \\
-\hline \\
-1. If $a.used > b.used$ then return(\textit{MP\_GT}) \\
-2. If $a.used < b.used$ then return(\textit{MP\_LT}) \\
-3. for n from $a.used - 1$ to 0 do \\
-\hspace{+3mm}3.1 if $a_n > b_n$ then return(\textit{MP\_GT}) \\
-\hspace{+3mm}3.2 if $a_n < b_n$ then return(\textit{MP\_LT}) \\
-4. Return(\textit{MP\_EQ}) \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_cmp\_mag}
-\end{figure}
-
-\textbf{Algorithm mp\_cmp\_mag.}
-By saying ``$a$ to the left of $b$'' it is meant that the comparison is with respect to $a$, that is if $a$ is greater than $b$ it will return
-\textbf{MP\_GT} and similar with respect to when $a = b$ and $a < b$. The first two steps compare the number of digits used in both $a$ and $b$.
-Obviously if the digit counts differ there would be an imaginary zero digit in the smaller number where the leading digit of the larger number is.
-If both have the same number of digits than the actual digits themselves must be compared starting at the leading digit.
-
-By step three both inputs must have the same number of digits so its safe to start from either $a.used - 1$ or $b.used - 1$ and count down to
-the zero'th digit. If after all of the digits have been compared, no difference is found, the algorithm returns \textbf{MP\_EQ}.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_cmp\_mag.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The two if statements (lines 25 and 29) compare the number of digits in the two inputs. These two are
-performed before all of the digits are compared since it is a very cheap test to perform and can potentially save
-considerable time. The implementation given is also not valid without those two statements. $b.alloc$ may be
-smaller than $a.used$, meaning that undefined values will be read from $b$ past the end of the array of digits.
-
-
-
-\subsection{Signed Comparisons}
-Comparing with sign considerations is also fairly critical in several routines (\textit{division for example}). Based on an unsigned magnitude
-comparison a trivial signed comparison algorithm can be written.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_cmp}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. Signed Comparison Results ($a$ to the left of $b$) \\
-\hline \\
-1. if $a.sign = MP\_NEG$ and $b.sign = MP\_ZPOS$ then return(\textit{MP\_LT}) \\
-2. if $a.sign = MP\_ZPOS$ and $b.sign = MP\_NEG$ then return(\textit{MP\_GT}) \\
-3. if $a.sign = MP\_NEG$ then \\
-\hspace{+3mm}3.1 Return the unsigned comparison of $b$ and $a$ (\textit{mp\_cmp\_mag}) \\
-4 Otherwise \\
-\hspace{+3mm}4.1 Return the unsigned comparison of $a$ and $b$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_cmp}
-\end{figure}
-
-\textbf{Algorithm mp\_cmp.}
-The first two steps compare the signs of the two inputs. If the signs do not agree then it can return right away with the appropriate
-comparison code. When the signs are equal the digits of the inputs must be compared to determine the correct result. In step
-three the unsigned comparision flips the order of the arguments since they are both negative. For instance, if $-a > -b$ then
-$\vert a \vert < \vert b \vert$. Step number four will compare the two when they are both positive.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_cmp.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The two if statements (lines 23 and 24) perform the initial sign comparison. If the signs are not the equal then which ever
-has the positive sign is larger. The inputs are compared (line 32) based on magnitudes. If the signs were both
-negative then the unsigned comparison is performed in the opposite direction (line 34). Otherwise, the signs are assumed to
-be both positive and a forward direction unsigned comparison is performed.
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 2 \right ]$ & Modify algorithm mp\_set\_int to accept as input a variable length array of bits. \\
- & \\
-$\left [ 3 \right ]$ & Give the probability that algorithm mp\_cmp\_mag will have to compare $k$ digits \\
- & of two random digits (of equal magnitude) before a difference is found. \\
- & \\
-$\left [ 1 \right ]$ & Suggest a simple method to speed up the implementation of mp\_cmp\_mag based \\
- & on the observations made in the previous problem. \\
- &
-\end{tabular}
-
-\chapter{Basic Arithmetic}
-\section{Introduction}
-At this point algorithms for initialization, clearing, zeroing, copying, comparing and setting small constants have been
-established. The next logical set of algorithms to develop are addition, subtraction and digit shifting algorithms. These
-algorithms make use of the lower level algorithms and are the cruicial building block for the multiplication algorithms. It is very important
-that these algorithms are highly optimized. On their own they are simple $O(n)$ algorithms but they can be called from higher level algorithms
-which easily places them at $O(n^2)$ or even $O(n^3)$ work levels.
-
-All of the algorithms within this chapter make use of the logical bit shift operations denoted by $<<$ and $>>$ for left and right
-logical shifts respectively. A logical shift is analogous to sliding the decimal point of radix-10 representations. For example, the real
-number $0.9345$ is equivalent to $93.45\%$ which is found by sliding the the decimal two places to the right (\textit{multiplying by $\beta^2 = 10^2$}).
-Algebraically a binary logical shift is equivalent to a division or multiplication by a power of two.
-For example, $a << k = a \cdot 2^k$ while $a >> k = \lfloor a/2^k \rfloor$.
-
-One significant difference between a logical shift and the way decimals are shifted is that digits below the zero'th position are removed
-from the number. For example, consider $1101_2 >> 1$ using decimal notation this would produce $110.1_2$. However, with a logical shift the
-result is $110_2$.
-
-\section{Addition and Subtraction}
-In common twos complement fixed precision arithmetic negative numbers are easily represented by subtraction from the modulus. For example, with 32-bit integers
-$a - b\mbox{ (mod }2^{32}\mbox{)}$ is the same as $a + (2^{32} - b) \mbox{ (mod }2^{32}\mbox{)}$ since $2^{32} \equiv 0 \mbox{ (mod }2^{32}\mbox{)}$.
-As a result subtraction can be performed with a trivial series of logical operations and an addition.
-
-However, in multiple precision arithmetic negative numbers are not represented in the same way. Instead a sign flag is used to keep track of the
-sign of the integer. As a result signed addition and subtraction are actually implemented as conditional usage of lower level addition or
-subtraction algorithms with the sign fixed up appropriately.
-
-The lower level algorithms will add or subtract integers without regard to the sign flag. That is they will add or subtract the magnitude of
-the integers respectively.
-
-\subsection{Low Level Addition}
-An unsigned addition of multiple precision integers is performed with the same long-hand algorithm used to add decimal numbers. That is to add the
-trailing digits first and propagate the resulting carry upwards. Since this is a lower level algorithm the name will have a ``s\_'' prefix.
-Historically that convention stems from the MPI library where ``s\_'' stood for static functions that were hidden from the developer entirely.
-
-\newpage
-\begin{figure}[!here]
-\begin{center}
-\begin{small}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_add}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The unsigned addition $c = \vert a \vert + \vert b \vert$. \\
-\hline \\
-1. if $a.used > b.used$ then \\
-\hspace{+3mm}1.1 $min \leftarrow b.used$ \\
-\hspace{+3mm}1.2 $max \leftarrow a.used$ \\
-\hspace{+3mm}1.3 $x \leftarrow a$ \\
-2. else \\
-\hspace{+3mm}2.1 $min \leftarrow a.used$ \\
-\hspace{+3mm}2.2 $max \leftarrow b.used$ \\
-\hspace{+3mm}2.3 $x \leftarrow b$ \\
-3. If $c.alloc < max + 1$ then grow $c$ to hold at least $max + 1$ digits (\textit{mp\_grow}) \\
-4. $oldused \leftarrow c.used$ \\
-5. $c.used \leftarrow max + 1$ \\
-6. $u \leftarrow 0$ \\
-7. for $n$ from $0$ to $min - 1$ do \\
-\hspace{+3mm}7.1 $c_n \leftarrow a_n + b_n + u$ \\
-\hspace{+3mm}7.2 $u \leftarrow c_n >> lg(\beta)$ \\
-\hspace{+3mm}7.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-8. if $min \ne max$ then do \\
-\hspace{+3mm}8.1 for $n$ from $min$ to $max - 1$ do \\
-\hspace{+6mm}8.1.1 $c_n \leftarrow x_n + u$ \\
-\hspace{+6mm}8.1.2 $u \leftarrow c_n >> lg(\beta)$ \\
-\hspace{+6mm}8.1.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-9. $c_{max} \leftarrow u$ \\
-10. if $olduse > max$ then \\
-\hspace{+3mm}10.1 for $n$ from $max + 1$ to $oldused - 1$ do \\
-\hspace{+6mm}10.1.1 $c_n \leftarrow 0$ \\
-11. Clamp excess digits in $c$. (\textit{mp\_clamp}) \\
-12. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Algorithm s\_mp\_add}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_add.}
-This algorithm is loosely based on algorithm 14.7 of HAC \cite[pp. 594]{HAC} but has been extended to allow the inputs to have different magnitudes.
-Coincidentally the description of algorithm A in Knuth \cite[pp. 266]{TAOCPV2} shares the same deficiency as the algorithm from \cite{HAC}. Even the
-MIX pseudo machine code presented by Knuth \cite[pp. 266-267]{TAOCPV2} is incapable of handling inputs which are of different magnitudes.
-
-The first thing that has to be accomplished is to sort out which of the two inputs is the largest. The addition logic
-will simply add all of the smallest input to the largest input and store that first part of the result in the
-destination. Then it will apply a simpler addition loop to excess digits of the larger input.
-
-The first two steps will handle sorting the inputs such that $min$ and $max$ hold the digit counts of the two
-inputs. The variable $x$ will be an mp\_int alias for the largest input or the second input $b$ if they have the
-same number of digits. After the inputs are sorted the destination $c$ is grown as required to accomodate the sum
-of the two inputs. The original \textbf{used} count of $c$ is copied and set to the new used count.
-
-At this point the first addition loop will go through as many digit positions that both inputs have. The carry
-variable $\mu$ is set to zero outside the loop. Inside the loop an ``addition'' step requires three statements to produce
-one digit of the summand. First
-two digits from $a$ and $b$ are added together along with the carry $\mu$. The carry of this step is extracted and stored
-in $\mu$ and finally the digit of the result $c_n$ is truncated within the range $0 \le c_n < \beta$.
-
-Now all of the digit positions that both inputs have in common have been exhausted. If $min \ne max$ then $x$ is an alias
-for one of the inputs that has more digits. A simplified addition loop is then used to essentially copy the remaining digits
-and the carry to the destination.
-
-The final carry is stored in $c_{max}$ and digits above $max$ upto $oldused$ are zeroed which completes the addition.
-
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_s\_mp\_add.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-We first sort (lines 28 to 36) the inputs based on magnitude and determine the $min$ and $max$ variables.
-Note that $x$ is a pointer to an mp\_int assigned to the largest input, in effect it is a local alias. Next we
-grow the destination (38 to 42) ensure that it can accomodate the result of the addition.
-
-Similar to the implementation of mp\_copy this function uses the braced code and local aliases coding style. The three aliases that are on
-lines 56, 59 and 62 represent the two inputs and destination variables respectively. These aliases are used to ensure the
-compiler does not have to dereference $a$, $b$ or $c$ (respectively) to access the digits of the respective mp\_int.
-
-The initial carry $u$ will be cleared (line 65), note that $u$ is of type mp\_digit which ensures type
-compatibility within the implementation. The initial addition (line 66 to 75) adds digits from
-both inputs until the smallest input runs out of digits. Similarly the conditional addition loop
-(line 81 to 90) adds the remaining digits from the larger of the two inputs. The addition is finished
-with the final carry being stored in $tmpc$ (line 94). Note the ``++'' operator within the same expression.
-After line 94, $tmpc$ will point to the $c.used$'th digit of the mp\_int $c$. This is useful
-for the next loop (line 97 to 99) which set any old upper digits to zero.
-
-\subsection{Low Level Subtraction}
-The low level unsigned subtraction algorithm is very similar to the low level unsigned addition algorithm. The principle difference is that the
-unsigned subtraction algorithm requires the result to be positive. That is when computing $a - b$ the condition $\vert a \vert \ge \vert b\vert$ must
-be met for this algorithm to function properly. Keep in mind this low level algorithm is not meant to be used in higher level algorithms directly.
-This algorithm as will be shown can be used to create functional signed addition and subtraction algorithms.
-
-
-For this algorithm a new variable is required to make the description simpler. Recall from section 1.3.1 that a mp\_digit must be able to represent
-the range $0 \le x < 2\beta$ for the algorithms to work correctly. However, it is allowable that a mp\_digit represent a larger range of values. For
-this algorithm we will assume that the variable $\gamma$ represents the number of bits available in a
-mp\_digit (\textit{this implies $2^{\gamma} > \beta$}).
-
-For example, the default for LibTomMath is to use a ``unsigned long'' for the mp\_digit ``type'' while $\beta = 2^{28}$. In ISO C an ``unsigned long''
-data type must be able to represent $0 \le x < 2^{32}$ meaning that in this case $\gamma \ge 32$.
-
-\newpage\begin{figure}[!here]
-\begin{center}
-\begin{small}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_sub}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ ($\vert a \vert \ge \vert b \vert$) \\
-\textbf{Output}. The unsigned subtraction $c = \vert a \vert - \vert b \vert$. \\
-\hline \\
-1. $min \leftarrow b.used$ \\
-2. $max \leftarrow a.used$ \\
-3. If $c.alloc < max$ then grow $c$ to hold at least $max$ digits. (\textit{mp\_grow}) \\
-4. $oldused \leftarrow c.used$ \\
-5. $c.used \leftarrow max$ \\
-6. $u \leftarrow 0$ \\
-7. for $n$ from $0$ to $min - 1$ do \\
-\hspace{3mm}7.1 $c_n \leftarrow a_n - b_n - u$ \\
-\hspace{3mm}7.2 $u \leftarrow c_n >> (\gamma - 1)$ \\
-\hspace{3mm}7.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-8. if $min < max$ then do \\
-\hspace{3mm}8.1 for $n$ from $min$ to $max - 1$ do \\
-\hspace{6mm}8.1.1 $c_n \leftarrow a_n - u$ \\
-\hspace{6mm}8.1.2 $u \leftarrow c_n >> (\gamma - 1)$ \\
-\hspace{6mm}8.1.3 $c_n \leftarrow c_n \mbox{ (mod }\beta\mbox{)}$ \\
-9. if $oldused > max$ then do \\
-\hspace{3mm}9.1 for $n$ from $max$ to $oldused - 1$ do \\
-\hspace{6mm}9.1.1 $c_n \leftarrow 0$ \\
-10. Clamp excess digits of $c$. (\textit{mp\_clamp}). \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Algorithm s\_mp\_sub}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_sub.}
-This algorithm performs the unsigned subtraction of two mp\_int variables under the restriction that the result must be positive. That is when
-passing variables $a$ and $b$ the condition that $\vert a \vert \ge \vert b \vert$ must be met for the algorithm to function correctly. This
-algorithm is loosely based on algorithm 14.9 \cite[pp. 595]{HAC} and is similar to algorithm S in \cite[pp. 267]{TAOCPV2} as well. As was the case
-of the algorithm s\_mp\_add both other references lack discussion concerning various practical details such as when the inputs differ in magnitude.
-
-The initial sorting of the inputs is trivial in this algorithm since $a$ is guaranteed to have at least the same magnitude of $b$. Steps 1 and 2
-set the $min$ and $max$ variables. Unlike the addition routine there is guaranteed to be no carry which means that the final result can be at
-most $max$ digits in length as opposed to $max + 1$. Similar to the addition algorithm the \textbf{used} count of $c$ is copied locally and
-set to the maximal count for the operation.
-
-The subtraction loop that begins on step seven is essentially the same as the addition loop of algorithm s\_mp\_add except single precision
-subtraction is used instead. Note the use of the $\gamma$ variable to extract the carry (\textit{also known as the borrow}) within the subtraction
-loops. Under the assumption that two's complement single precision arithmetic is used this will successfully extract the desired carry.
-
-For example, consider subtracting $0101_2$ from $0100_2$ where $\gamma = 4$ and $\beta = 2$. The least significant bit will force a carry upwards to
-the third bit which will be set to zero after the borrow. After the very first bit has been subtracted $4 - 1 \equiv 0011_2$ will remain, When the
-third bit of $0101_2$ is subtracted from the result it will cause another carry. In this case though the carry will be forced to propagate all the
-way to the most significant bit.
-
-Recall that $\beta < 2^{\gamma}$. This means that if a carry does occur just before the $lg(\beta)$'th bit it will propagate all the way to the most
-significant bit. Thus, the high order bits of the mp\_digit that are not part of the actual digit will either be all zero, or all one. All that
-is needed is a single zero or one bit for the carry. Therefore a single logical shift right by $\gamma - 1$ positions is sufficient to extract the
-carry. This method of carry extraction may seem awkward but the reason for it becomes apparent when the implementation is discussed.
-
-If $b$ has a smaller magnitude than $a$ then step 9 will force the carry and copy operation to propagate through the larger input $a$ into $c$. Step
-10 will ensure that any leading digits of $c$ above the $max$'th position are zeroed.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_s\_mp\_sub.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Like low level addition we ``sort'' the inputs. Except in this case the sorting is hardcoded
-(lines 25 and 26). In reality the $min$ and $max$ variables are only aliases and are only
-used to make the source code easier to read. Again the pointer alias optimization is used
-within this algorithm. The aliases $tmpa$, $tmpb$ and $tmpc$ are initialized
-(lines 42, 43 and 44) for $a$, $b$ and $c$ respectively.
-
-The first subtraction loop (lines 47 through 61) subtract digits from both inputs until the smaller of
-the two inputs has been exhausted. As remarked earlier there is an implementation reason for using the ``awkward''
-method of extracting the carry (line 57). The traditional method for extracting the carry would be to shift
-by $lg(\beta)$ positions and logically AND the least significant bit. The AND operation is required because all of
-the bits above the $\lg(\beta)$'th bit will be set to one after a carry occurs from subtraction. This carry
-extraction requires two relatively cheap operations to extract the carry. The other method is to simply shift the
-most significant bit to the least significant bit thus extracting the carry with a single cheap operation. This
-optimization only works on twos compliment machines which is a safe assumption to make.
-
-If $a$ has a larger magnitude than $b$ an additional loop (lines 64 through 73) is required to propagate
-the carry through $a$ and copy the result to $c$.
-
-\subsection{High Level Addition}
-Now that both lower level addition and subtraction algorithms have been established an effective high level signed addition algorithm can be
-established. This high level addition algorithm will be what other algorithms and developers will use to perform addition of mp\_int data
-types.
-
-Recall from section 5.2 that an mp\_int represents an integer with an unsigned mantissa (\textit{the array of digits}) and a \textbf{sign}
-flag. A high level addition is actually performed as a series of eight separate cases which can be optimized down to three unique cases.
-
-\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_add}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The signed addition $c = a + b$. \\
-\hline \\
-1. if $a.sign = b.sign$ then do \\
-\hspace{3mm}1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{3mm}1.2 $c \leftarrow \vert a \vert + \vert b \vert$ (\textit{s\_mp\_add})\\
-2. else do \\
-\hspace{3mm}2.1 if $\vert a \vert < \vert b \vert$ then do (\textit{mp\_cmp\_mag}) \\
-\hspace{6mm}2.1.1 $c.sign \leftarrow b.sign$ \\
-\hspace{6mm}2.1.2 $c \leftarrow \vert b \vert - \vert a \vert$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c.sign \leftarrow a.sign$ \\
-\hspace{6mm}2.2.2 $c \leftarrow \vert a \vert - \vert b \vert$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_add}
-\end{figure}
-
-\textbf{Algorithm mp\_add.}
-This algorithm performs the signed addition of two mp\_int variables. There is no reference algorithm to draw upon from
-either \cite{TAOCPV2} or \cite{HAC} since they both only provide unsigned operations. The algorithm is fairly
-straightforward but restricted since subtraction can only produce positive results.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|}
-\hline \textbf{Sign of $a$} & \textbf{Sign of $b$} & \textbf{$\vert a \vert > \vert b \vert $} & \textbf{Unsigned Operation} & \textbf{Result Sign Flag} \\
-\hline $+$ & $+$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $+$ & $+$ & No & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $-$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $-$ & No & $c = a + b$ & $a.sign$ \\
-\hline &&&&\\
-
-\hline $+$ & $-$ & No & $c = b - a$ & $b.sign$ \\
-\hline $-$ & $+$ & No & $c = b - a$ & $b.sign$ \\
-
-\hline &&&&\\
-
-\hline $+$ & $-$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline $-$ & $+$ & Yes & $c = a - b$ & $a.sign$ \\
-
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Addition Guide Chart}
-\label{fig:AddChart}
-\end{figure}
-
-Figure~\ref{fig:AddChart} lists all of the eight possible input combinations and is sorted to show that only three
-specific cases need to be handled. The return code of the unsigned operations at step 1.2, 2.1.2 and 2.2.2 are
-forwarded to step three to check for errors. This simplifies the description of the algorithm considerably and best
-follows how the implementation actually was achieved.
-
-Also note how the \textbf{sign} is set before the unsigned addition or subtraction is performed. Recall from the descriptions of algorithms
-s\_mp\_add and s\_mp\_sub that the mp\_clamp function is used at the end to trim excess digits. The mp\_clamp algorithm will set the \textbf{sign}
-to \textbf{MP\_ZPOS} when the \textbf{used} digit count reaches zero.
-
-For example, consider performing $-a + a$ with algorithm mp\_add. By the description of the algorithm the sign is set to \textbf{MP\_NEG} which would
-produce a result of $-0$. However, since the sign is set first then the unsigned addition is performed the subsequent usage of algorithm mp\_clamp
-within algorithm s\_mp\_add will force $-0$ to become $0$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_add.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The source code follows the algorithm fairly closely. The most notable new source code addition is the usage of the $res$ integer variable which
-is used to pass result of the unsigned operations forward. Unlike in the algorithm, the variable $res$ is merely returned as is without
-explicitly checking it and returning the constant \textbf{MP\_OKAY}. The observation is this algorithm will succeed or fail only if the lower
-level functions do so. Returning their return code is sufficient.
-
-\subsection{High Level Subtraction}
-The high level signed subtraction algorithm is essentially the same as the high level signed addition algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_sub}. \\
-\textbf{Input}. Two mp\_ints $a$ and $b$ \\
-\textbf{Output}. The signed subtraction $c = a - b$. \\
-\hline \\
-1. if $a.sign \ne b.sign$ then do \\
-\hspace{3mm}1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{3mm}1.2 $c \leftarrow \vert a \vert + \vert b \vert$ (\textit{s\_mp\_add}) \\
-2. else do \\
-\hspace{3mm}2.1 if $\vert a \vert \ge \vert b \vert$ then do (\textit{mp\_cmp\_mag}) \\
-\hspace{6mm}2.1.1 $c.sign \leftarrow a.sign$ \\
-\hspace{6mm}2.1.2 $c \leftarrow \vert a \vert - \vert b \vert$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c.sign \leftarrow \left \lbrace \begin{array}{ll}
- MP\_ZPOS & \mbox{if }a.sign = MP\_NEG \\
- MP\_NEG & \mbox{otherwise} \\
- \end{array} \right .$ \\
-\hspace{6mm}2.2.2 $c \leftarrow \vert b \vert - \vert a \vert$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Algorithm mp\_sub}
-\end{figure}
-
-\textbf{Algorithm mp\_sub.}
-This algorithm performs the signed subtraction of two inputs. Similar to algorithm mp\_add there is no reference in either \cite{TAOCPV2} or
-\cite{HAC}. Also this algorithm is restricted by algorithm s\_mp\_sub. Chart \ref{fig:SubChart} lists the eight possible inputs and
-the operations required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|}
-\hline \textbf{Sign of $a$} & \textbf{Sign of $b$} & \textbf{$\vert a \vert \ge \vert b \vert $} & \textbf{Unsigned Operation} & \textbf{Result Sign Flag} \\
-\hline $+$ & $-$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $+$ & $-$ & No & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $+$ & Yes & $c = a + b$ & $a.sign$ \\
-\hline $-$ & $+$ & No & $c = a + b$ & $a.sign$ \\
-\hline &&&& \\
-\hline $+$ & $+$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline $-$ & $-$ & Yes & $c = a - b$ & $a.sign$ \\
-\hline &&&& \\
-\hline $+$ & $+$ & No & $c = b - a$ & $\mbox{opposite of }a.sign$ \\
-\hline $-$ & $-$ & No & $c = b - a$ & $\mbox{opposite of }a.sign$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Subtraction Guide Chart}
-\label{fig:SubChart}
-\end{figure}
-
-Similar to the case of algorithm mp\_add the \textbf{sign} is set first before the unsigned addition or subtraction. That is to prevent the
-algorithm from producing $-a - -a = -0$ as a result.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_sub.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Much like the implementation of algorithm mp\_add the variable $res$ is used to catch the return code of the unsigned addition or subtraction operations
-and forward it to the end of the function. On line 39 the ``not equal to'' \textbf{MP\_LT} expression is used to emulate a
-``greater than or equal to'' comparison.
-
-\section{Bit and Digit Shifting}
-It is quite common to think of a multiple precision integer as a polynomial in $x$, that is $y = f(\beta)$ where $f(x) = \sum_{i=0}^{n-1} a_i x^i$.
-This notation arises within discussion of Montgomery and Diminished Radix Reduction as well as Karatsuba multiplication and squaring.
-
-In order to facilitate operations on polynomials in $x$ as above a series of simple ``digit'' algorithms have to be established. That is to shift
-the digits left or right as well to shift individual bits of the digits left and right. It is important to note that not all ``shift'' operations
-are on radix-$\beta$ digits.
-
-\subsection{Multiplication by Two}
-
-In a binary system where the radix is a power of two multiplication by two not only arises often in other algorithms it is a fairly efficient
-operation to perform. A single precision logical shift left is sufficient to multiply a single digit by two.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_2}. \\
-\textbf{Input}. One mp\_int $a$ \\
-\textbf{Output}. $b = 2a$. \\
-\hline \\
-1. If $b.alloc < a.used + 1$ then grow $b$ to hold $a.used + 1$ digits. (\textit{mp\_grow}) \\
-2. $oldused \leftarrow b.used$ \\
-3. $b.used \leftarrow a.used$ \\
-4. $r \leftarrow 0$ \\
-5. for $n$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}5.1 $rr \leftarrow a_n >> (lg(\beta) - 1)$ \\
-\hspace{3mm}5.2 $b_n \leftarrow (a_n << 1) + r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}5.3 $r \leftarrow rr$ \\
-6. If $r \ne 0$ then do \\
-\hspace{3mm}6.1 $b_{n + 1} \leftarrow r$ \\
-\hspace{3mm}6.2 $b.used \leftarrow b.used + 1$ \\
-7. If $b.used < oldused - 1$ then do \\
-\hspace{3mm}7.1 for $n$ from $b.used$ to $oldused - 1$ do \\
-\hspace{6mm}7.1.1 $b_n \leftarrow 0$ \\
-8. $b.sign \leftarrow a.sign$ \\
-9. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_2}
-\end{figure}
-
-\textbf{Algorithm mp\_mul\_2.}
-This algorithm will quickly multiply a mp\_int by two provided $\beta$ is a power of two. Neither \cite{TAOCPV2} nor \cite{HAC} describe such
-an algorithm despite the fact it arises often in other algorithms. The algorithm is setup much like the lower level algorithm s\_mp\_add since
-it is for all intents and purposes equivalent to the operation $b = \vert a \vert + \vert a \vert$.
-
-Step 1 and 2 grow the input as required to accomodate the maximum number of \textbf{used} digits in the result. The initial \textbf{used} count
-is set to $a.used$ at step 4. Only if there is a final carry will the \textbf{used} count require adjustment.
-
-Step 6 is an optimization implementation of the addition loop for this specific case. That is since the two values being added together
-are the same there is no need to perform two reads from the digits of $a$. Step 6.1 performs a single precision shift on the current digit $a_n$ to
-obtain what will be the carry for the next iteration. Step 6.2 calculates the $n$'th digit of the result as single precision shift of $a_n$ plus
-the previous carry. Recall from section 4.1 that $a_n << 1$ is equivalent to $a_n \cdot 2$. An iteration of the addition loop is finished with
-forwarding the carry to the next iteration.
-
-Step 7 takes care of any final carry by setting the $a.used$'th digit of the result to the carry and augmenting the \textbf{used} count of $b$.
-Step 8 clears any leading digits of $b$ in case it originally had a larger magnitude than $a$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_mul\_2.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This implementation is essentially an optimized implementation of s\_mp\_add for the case of doubling an input. The only noteworthy difference
-is the use of the logical shift operator on line 52 to perform a single precision doubling.
-
-\subsection{Division by Two}
-A division by two can just as easily be accomplished with a logical shift right as multiplication by two can be with a logical shift left.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_2}. \\
-\textbf{Input}. One mp\_int $a$ \\
-\textbf{Output}. $b = a/2$. \\
-\hline \\
-1. If $b.alloc < a.used$ then grow $b$ to hold $a.used$ digits. (\textit{mp\_grow}) \\
-2. If the reallocation failed return(\textit{MP\_MEM}). \\
-3. $oldused \leftarrow b.used$ \\
-4. $b.used \leftarrow a.used$ \\
-5. $r \leftarrow 0$ \\
-6. for $n$ from $b.used - 1$ to $0$ do \\
-\hspace{3mm}6.1 $rr \leftarrow a_n \mbox{ (mod }2\mbox{)}$\\
-\hspace{3mm}6.2 $b_n \leftarrow (a_n >> 1) + (r << (lg(\beta) - 1)) \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}6.3 $r \leftarrow rr$ \\
-7. If $b.used < oldused - 1$ then do \\
-\hspace{3mm}7.1 for $n$ from $b.used$ to $oldused - 1$ do \\
-\hspace{6mm}7.1.1 $b_n \leftarrow 0$ \\
-8. $b.sign \leftarrow a.sign$ \\
-9. Clamp excess digits of $b$. (\textit{mp\_clamp}) \\
-10. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_2}
-\end{figure}
-
-\textbf{Algorithm mp\_div\_2.}
-This algorithm will divide an mp\_int by two using logical shifts to the right. Like mp\_mul\_2 it uses a modified low level addition
-core as the basis of the algorithm. Unlike mp\_mul\_2 the shift operations work from the leading digit to the trailing digit. The algorithm
-could be written to work from the trailing digit to the leading digit however, it would have to stop one short of $a.used - 1$ digits to prevent
-reading past the end of the array of digits.
-
-Essentially the loop at step 6 is similar to that of mp\_mul\_2 except the logical shifts go in the opposite direction and the carry is at the
-least significant bit not the most significant bit.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_div\_2.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\section{Polynomial Basis Operations}
-Recall from section 4.3 that any integer can be represented as a polynomial in $x$ as $y = f(\beta)$. Such a representation is also known as
-the polynomial basis \cite[pp. 48]{ROSE}. Given such a notation a multiplication or division by $x$ amounts to shifting whole digits a single
-place. The need for such operations arises in several other higher level algorithms such as Barrett and Montgomery reduction, integer
-division and Karatsuba multiplication.
-
-Converting from an array of digits to polynomial basis is very simple. Consider the integer $y \equiv (a_2, a_1, a_0)_{\beta}$ and recall that
-$y = \sum_{i=0}^{2} a_i \beta^i$. Simply replace $\beta$ with $x$ and the expression is in polynomial basis. For example, $f(x) = 8x + 9$ is the
-polynomial basis representation for $89$ using radix ten. That is, $f(10) = 8(10) + 9 = 89$.
-
-\subsection{Multiplication by $x$}
-
-Given a polynomial in $x$ such as $f(x) = a_n x^n + a_{n-1} x^{n-1} + ... + a_0$ multiplying by $x$ amounts to shifting the coefficients up one
-degree. In this case $f(x) \cdot x = a_n x^{n+1} + a_{n-1} x^n + ... + a_0 x$. From a scalar basis point of view multiplying by $x$ is equivalent to
-multiplying by the integer $\beta$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_lshd}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $a \leftarrow a \cdot \beta^b$ (equivalent to multiplication by $x^b$). \\
-\hline \\
-1. If $b \le 0$ then return(\textit{MP\_OKAY}). \\
-2. If $a.alloc < a.used + b$ then grow $a$ to at least $a.used + b$ digits. (\textit{mp\_grow}). \\
-3. If the reallocation failed return(\textit{MP\_MEM}). \\
-4. $a.used \leftarrow a.used + b$ \\
-5. $i \leftarrow a.used - 1$ \\
-6. $j \leftarrow a.used - 1 - b$ \\
-7. for $n$ from $a.used - 1$ to $b$ do \\
-\hspace{3mm}7.1 $a_{i} \leftarrow a_{j}$ \\
-\hspace{3mm}7.2 $i \leftarrow i - 1$ \\
-\hspace{3mm}7.3 $j \leftarrow j - 1$ \\
-8. for $n$ from 0 to $b - 1$ do \\
-\hspace{3mm}8.1 $a_n \leftarrow 0$ \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_lshd}
-\end{figure}
-
-\textbf{Algorithm mp\_lshd.}
-This algorithm multiplies an mp\_int by the $b$'th power of $x$. This is equivalent to multiplying by $\beta^b$. The algorithm differs
-from the other algorithms presented so far as it performs the operation in place instead storing the result in a separate location. The
-motivation behind this change is due to the way this function is typically used. Algorithms such as mp\_add store the result in an optionally
-different third mp\_int because the original inputs are often still required. Algorithm mp\_lshd (\textit{and similarly algorithm mp\_rshd}) is
-typically used on values where the original value is no longer required. The algorithm will return success immediately if
-$b \le 0$ since the rest of algorithm is only valid when $b > 0$.
-
-First the destination $a$ is grown as required to accomodate the result. The counters $i$ and $j$ are used to form a \textit{sliding window} over
-the digits of $a$ of length $b$. The head of the sliding window is at $i$ (\textit{the leading digit}) and the tail at $j$ (\textit{the trailing digit}).
-The loop on step 7 copies the digit from the tail to the head. In each iteration the window is moved down one digit. The last loop on
-step 8 sets the lower $b$ digits to zero.
-
-\newpage
-\begin{center}
-\begin{figure}[here]
-\includegraphics{pics/sliding_window.ps}
-\caption{Sliding Window Movement}
-\label{pic:sliding_window}
-\end{figure}
-\end{center}
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_lshd.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The if statement (line 24) ensures that the $b$ variable is greater than zero since we do not interpret negative
-shift counts properly. The \textbf{used} count is incremented by $b$ before the copy loop begins. This elminates
-the need for an additional variable in the for loop. The variable $top$ (line 42) is an alias
-for the leading digit while $bottom$ (line 45) is an alias for the trailing edge. The aliases form a
-window of exactly $b$ digits over the input.
-
-\subsection{Division by $x$}
-
-Division by powers of $x$ is easily achieved by shifting the digits right and removing any that will end up to the right of the zero'th digit.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_rshd}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $a \leftarrow a / \beta^b$ (Divide by $x^b$). \\
-\hline \\
-1. If $b \le 0$ then return. \\
-2. If $a.used \le b$ then do \\
-\hspace{3mm}2.1 Zero $a$. (\textit{mp\_zero}). \\
-\hspace{3mm}2.2 Return. \\
-3. $i \leftarrow 0$ \\
-4. $j \leftarrow b$ \\
-5. for $n$ from 0 to $a.used - b - 1$ do \\
-\hspace{3mm}5.1 $a_i \leftarrow a_j$ \\
-\hspace{3mm}5.2 $i \leftarrow i + 1$ \\
-\hspace{3mm}5.3 $j \leftarrow j + 1$ \\
-6. for $n$ from $a.used - b$ to $a.used - 1$ do \\
-\hspace{3mm}6.1 $a_n \leftarrow 0$ \\
-7. $a.used \leftarrow a.used - b$ \\
-8. Return. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_rshd}
-\end{figure}
-
-\textbf{Algorithm mp\_rshd.}
-This algorithm divides the input in place by the $b$'th power of $x$. It is analogous to dividing by a $\beta^b$ but much quicker since
-it does not require single precision division. This algorithm does not actually return an error code as it cannot fail.
-
-If the input $b$ is less than one the algorithm quickly returns without performing any work. If the \textbf{used} count is less than or equal
-to the shift count $b$ then it will simply zero the input and return.
-
-After the trivial cases of inputs have been handled the sliding window is setup. Much like the case of algorithm mp\_lshd a sliding window that
-is $b$ digits wide is used to copy the digits. Unlike mp\_lshd the window slides in the opposite direction from the trailing to the leading digit.
-Also the digits are copied from the leading to the trailing edge.
-
-Once the window copy is complete the upper digits must be zeroed and the \textbf{used} count decremented.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_rshd.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The only noteworthy element of this routine is the lack of a return type since it cannot fail. Like mp\_lshd() we
-form a sliding window except we copy in the other direction. After the window (line 60) we then zero
-the upper digits of the input to make sure the result is correct.
-
-\section{Powers of Two}
-
-Now that algorithms for moving single bits as well as whole digits exist algorithms for moving the ``in between'' distances are required. For
-example, to quickly multiply by $2^k$ for any $k$ without using a full multiplier algorithm would prove useful. Instead of performing single
-shifts $k$ times to achieve a multiplication by $2^{\pm k}$ a mixture of whole digit shifting and partial digit shifting is employed.
-
-\subsection{Multiplication by Power of Two}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot 2^b$. \\
-\hline \\
-1. $c \leftarrow a$. (\textit{mp\_copy}) \\
-2. If $c.alloc < c.used + \lfloor b / lg(\beta) \rfloor + 2$ then grow $c$ accordingly. \\
-3. If the reallocation failed return(\textit{MP\_MEM}). \\
-4. If $b \ge lg(\beta)$ then \\
-\hspace{3mm}4.1 $c \leftarrow c \cdot \beta^{\lfloor b / lg(\beta) \rfloor}$ (\textit{mp\_lshd}). \\
-\hspace{3mm}4.2 If step 4.1 failed return(\textit{MP\_MEM}). \\
-5. $d \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-6. If $d \ne 0$ then do \\
-\hspace{3mm}6.1 $mask \leftarrow 2^d$ \\
-\hspace{3mm}6.2 $r \leftarrow 0$ \\
-\hspace{3mm}6.3 for $n$ from $0$ to $c.used - 1$ do \\
-\hspace{6mm}6.3.1 $rr \leftarrow c_n >> (lg(\beta) - d) \mbox{ (mod }mask\mbox{)}$ \\
-\hspace{6mm}6.3.2 $c_n \leftarrow (c_n << d) + r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}6.3.3 $r \leftarrow rr$ \\
-\hspace{3mm}6.4 If $r > 0$ then do \\
-\hspace{6mm}6.4.1 $c_{c.used} \leftarrow r$ \\
-\hspace{6mm}6.4.2 $c.used \leftarrow c.used + 1$ \\
-7. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_mul\_2d.}
-This algorithm multiplies $a$ by $2^b$ and stores the result in $c$. The algorithm uses algorithm mp\_lshd and a derivative of algorithm mp\_mul\_2 to
-quickly compute the product.
-
-First the algorithm will multiply $a$ by $x^{\lfloor b / lg(\beta) \rfloor}$ which will ensure that the remainder multiplicand is less than
-$\beta$. For example, if $b = 37$ and $\beta = 2^{28}$ then this step will multiply by $x$ leaving a multiplication by $2^{37 - 28} = 2^{9}$
-left.
-
-After the digits have been shifted appropriately at most $lg(\beta) - 1$ shifts are left to perform. Step 5 calculates the number of remaining shifts
-required. If it is non-zero a modified shift loop is used to calculate the remaining product.
-Essentially the loop is a generic version of algorithm mp\_mul\_2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
-variable is used to extract the upper $d$ bits to form the carry for the next iteration.
-
-This algorithm is loosely measured as a $O(2n)$ algorithm which means that if the input is $n$-digits that it takes $2n$ ``time'' to
-complete. It is possible to optimize this algorithm down to a $O(n)$ algorithm at a cost of making the algorithm slightly harder to follow.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_mul\_2d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The shifting is performed in--place which means the first step (line 25) is to copy the input to the
-destination. We avoid calling mp\_copy() by making sure the mp\_ints are different. The destination then
-has to be grown (line 32) to accomodate the result.
-
-If the shift count $b$ is larger than $lg(\beta)$ then a call to mp\_lshd() is used to handle all of the multiples
-of $lg(\beta)$. Leaving only a remaining shift of $lg(\beta) - 1$ or fewer bits left. Inside the actual shift
-loop (lines 46 to 76) we make use of pre--computed values $shift$ and $mask$. These are used to
-extract the carry bit(s) to pass into the next iteration of the loop. The $r$ and $rr$ variables form a
-chain between consecutive iterations to propagate the carry.
-
-\subsection{Division by Power of Two}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow \lfloor a / 2^b \rfloor, d \leftarrow a \mbox{ (mod }2^b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then do \\
-\hspace{3mm}1.1 $c \leftarrow a$ (\textit{mp\_copy}) \\
-\hspace{3mm}1.2 $d \leftarrow 0$ (\textit{mp\_zero}) \\
-\hspace{3mm}1.3 Return(\textit{MP\_OKAY}). \\
-2. $c \leftarrow a$ \\
-3. $d \leftarrow a \mbox{ (mod }2^b\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-4. If $b \ge lg(\beta)$ then do \\
-\hspace{3mm}4.1 $c \leftarrow \lfloor c/\beta^{\lfloor b/lg(\beta) \rfloor} \rfloor$ (\textit{mp\_rshd}). \\
-5. $k \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-6. If $k \ne 0$ then do \\
-\hspace{3mm}6.1 $mask \leftarrow 2^k$ \\
-\hspace{3mm}6.2 $r \leftarrow 0$ \\
-\hspace{3mm}6.3 for $n$ from $c.used - 1$ to $0$ do \\
-\hspace{6mm}6.3.1 $rr \leftarrow c_n \mbox{ (mod }mask\mbox{)}$ \\
-\hspace{6mm}6.3.2 $c_n \leftarrow (c_n >> k) + (r << (lg(\beta) - k))$ \\
-\hspace{6mm}6.3.3 $r \leftarrow rr$ \\
-7. Clamp excess digits of $c$. (\textit{mp\_clamp}) \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_div\_2d.}
-This algorithm will divide an input $a$ by $2^b$ and produce the quotient and remainder. The algorithm is designed much like algorithm
-mp\_mul\_2d by first using whole digit shifts then single precision shifts. This algorithm will also produce the remainder of the division
-by using algorithm mp\_mod\_2d.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_div\_2d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The implementation of algorithm mp\_div\_2d is slightly different than the algorithm specifies. The remainder $d$ may be optionally
-ignored by passing \textbf{NULL} as the pointer to the mp\_int variable. The temporary mp\_int variable $t$ is used to hold the
-result of the remainder operation until the end. This allows $d$ and $a$ to represent the same mp\_int without modifying $a$ before
-the quotient is obtained.
-
-The remainder of the source code is essentially the same as the source code for mp\_mul\_2d. The only significant difference is
-the direction of the shifts.
-
-\subsection{Remainder of Division by Power of Two}
-
-The last algorithm in the series of polynomial basis power of two algorithms is calculating the remainder of division by $2^b$. This
-algorithm benefits from the fact that in twos complement arithmetic $a \mbox{ (mod }2^b\mbox{)}$ is the same as $a$ AND $2^b - 1$.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mod\_2d}. \\
-\textbf{Input}. One mp\_int $a$ and an integer $b$ \\
-\textbf{Output}. $c \leftarrow a \mbox{ (mod }2^b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then do \\
-\hspace{3mm}1.1 $c \leftarrow 0$ (\textit{mp\_zero}) \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $b > a.used \cdot lg(\beta)$ then do \\
-\hspace{3mm}2.1 $c \leftarrow a$ (\textit{mp\_copy}) \\
-\hspace{3mm}2.2 Return the result of step 2.1. \\
-3. $c \leftarrow a$ \\
-4. If step 3 failed return(\textit{MP\_MEM}). \\
-5. for $n$ from $\lceil b / lg(\beta) \rceil$ to $c.used$ do \\
-\hspace{3mm}5.1 $c_n \leftarrow 0$ \\
-6. $k \leftarrow b \mbox{ (mod }lg(\beta)\mbox{)}$ \\
-7. $c_{\lfloor b / lg(\beta) \rfloor} \leftarrow c_{\lfloor b / lg(\beta) \rfloor} \mbox{ (mod }2^{k}\mbox{)}$. \\
-8. Clamp excess digits of $c$. (\textit{mp\_clamp}) \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mod\_2d}
-\end{figure}
-
-\textbf{Algorithm mp\_mod\_2d.}
-This algorithm will quickly calculate the value of $a \mbox{ (mod }2^b\mbox{)}$. First if $b$ is less than or equal to zero the
-result is set to zero. If $b$ is greater than the number of bits in $a$ then it simply copies $a$ to $c$ and returns. Otherwise, $a$
-is copied to $b$, leading digits are removed and the remaining leading digit is trimed to the exact bit count.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_mod\_2d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-We first avoid cases of $b \le 0$ by simply mp\_zero()'ing the destination in such cases. Next if $2^b$ is larger
-than the input we just mp\_copy() the input and return right away. After this point we know we must actually
-perform some work to produce the remainder.
-
-Recalling that reducing modulo $2^k$ and a binary ``and'' with $2^k - 1$ are numerically equivalent we can quickly reduce
-the number. First we zero any digits above the last digit in $2^b$ (line 42). Next we reduce the
-leading digit of both (line 46) and then mp\_clamp().
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ] $ & Devise an algorithm that performs $a \cdot 2^b$ for generic values of $b$ \\
- & in $O(n)$ time. \\
- &\\
-$\left [ 3 \right ] $ & Devise an efficient algorithm to multiply by small low hamming \\
- & weight values such as $3$, $5$ and $9$. Extend it to handle all values \\
- & upto $64$ with a hamming weight less than three. \\
- &\\
-$\left [ 2 \right ] $ & Modify the preceding algorithm to handle values of the form \\
- & $2^k - 1$ as well. \\
- &\\
-$\left [ 3 \right ] $ & Using only algorithms mp\_mul\_2, mp\_div\_2 and mp\_add create an \\
- & algorithm to multiply two integers in roughly $O(2n^2)$ time for \\
- & any $n$-bit input. Note that the time of addition is ignored in the \\
- & calculation. \\
- & \\
-$\left [ 5 \right ] $ & Improve the previous algorithm to have a working time of at most \\
- & $O \left (2^{(k-1)}n + \left ({2n^2 \over k} \right ) \right )$ for an appropriate choice of $k$. Again ignore \\
- & the cost of addition. \\
- & \\
-$\left [ 2 \right ] $ & Devise a chart to find optimal values of $k$ for the previous problem \\
- & for $n = 64 \ldots 1024$ in steps of $64$. \\
- & \\
-$\left [ 2 \right ] $ & Using only algorithms mp\_abs and mp\_sub devise another method for \\
- & calculating the result of a signed comparison. \\
- &
-\end{tabular}
-
-\chapter{Multiplication and Squaring}
-\section{The Multipliers}
-For most number theoretic problems including certain public key cryptographic algorithms, the ``multipliers'' form the most important subset of
-algorithms of any multiple precision integer package. The set of multiplier algorithms include integer multiplication, squaring and modular reduction
-where in each of the algorithms single precision multiplication is the dominant operation performed. This chapter will discuss integer multiplication
-and squaring, leaving modular reductions for the subsequent chapter.
-
-The importance of the multiplier algorithms is for the most part driven by the fact that certain popular public key algorithms are based on modular
-exponentiation, that is computing $d \equiv a^b \mbox{ (mod }c\mbox{)}$ for some arbitrary choice of $a$, $b$, $c$ and $d$. During a modular
-exponentiation the majority\footnote{Roughly speaking a modular exponentiation will spend about 40\% of the time performing modular reductions,
-35\% of the time performing squaring and 25\% of the time performing multiplications.} of the processor time is spent performing single precision
-multiplications.
-
-For centuries general purpose multiplication has required a lengthly $O(n^2)$ process, whereby each digit of one multiplicand has to be multiplied
-against every digit of the other multiplicand. Traditional long-hand multiplication is based on this process; while the techniques can differ the
-overall algorithm used is essentially the same. Only ``recently'' have faster algorithms been studied. First Karatsuba multiplication was discovered in
-1962. This algorithm can multiply two numbers with considerably fewer single precision multiplications when compared to the long-hand approach.
-This technique led to the discovery of polynomial basis algorithms (\textit{good reference?}) and subquently Fourier Transform based solutions.
-
-\section{Multiplication}
-\subsection{The Baseline Multiplication}
-\label{sec:basemult}
-\index{baseline multiplication}
-Computing the product of two integers in software can be achieved using a trivial adaptation of the standard $O(n^2)$ long-hand multiplication
-algorithm that school children are taught. The algorithm is considered an $O(n^2)$ algorithm since for two $n$-digit inputs $n^2$ single precision
-multiplications are required. More specifically for a $m$ and $n$ digit input $m \cdot n$ single precision multiplications are required. To
-simplify most discussions, it will be assumed that the inputs have comparable number of digits.
-
-The ``baseline multiplication'' algorithm is designed to act as the ``catch-all'' algorithm, only to be used when the faster algorithms cannot be
-used. This algorithm does not use any particularly interesting optimizations and should ideally be avoided if possible. One important
-facet of this algorithm, is that it has been modified to only produce a certain amount of output digits as resolution. The importance of this
-modification will become evident during the discussion of Barrett modular reduction. Recall that for a $n$ and $m$ digit input the product
-will be at most $n + m$ digits. Therefore, this algorithm can be reduced to a full multiplier by having it produce $n + m$ digits of the product.
-
-Recall from sub-section 4.2.2 the definition of $\gamma$ as the number of bits in the type \textbf{mp\_digit}. We shall now extend the variable set to
-include $\alpha$ which shall represent the number of bits in the type \textbf{mp\_word}. This implies that $2^{\alpha} > 2 \cdot \beta^2$. The
-constant $\delta = 2^{\alpha - 2lg(\beta)}$ will represent the maximal weight of any column in a product (\textit{see sub-section 5.2.2 for more information}).
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_mul\_digs}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and an integer $digs$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert \mbox{ (mod }\beta^{digs}\mbox{)}$. \\
-\hline \\
-1. If min$(a.used, b.used) < \delta$ then do \\
-\hspace{3mm}1.1 Calculate $c = \vert a \vert \cdot \vert b \vert$ by the Comba method (\textit{see algorithm~\ref{fig:COMBAMULT}}). \\
-\hspace{3mm}1.2 Return the result of step 1.1 \\
-\\
-Allocate and initialize a temporary mp\_int. \\
-2. Init $t$ to be of size $digs$ \\
-3. If step 2 failed return(\textit{MP\_MEM}). \\
-4. $t.used \leftarrow digs$ \\
-\\
-Compute the product. \\
-5. for $ix$ from $0$ to $a.used - 1$ do \\
-\hspace{3mm}5.1 $u \leftarrow 0$ \\
-\hspace{3mm}5.2 $pb \leftarrow \mbox{min}(b.used, digs - ix)$ \\
-\hspace{3mm}5.3 If $pb < 1$ then goto step 6. \\
-\hspace{3mm}5.4 for $iy$ from $0$ to $pb - 1$ do \\
-\hspace{6mm}5.4.1 $\hat r \leftarrow t_{iy + ix} + a_{ix} \cdot b_{iy} + u$ \\
-\hspace{6mm}5.4.2 $t_{iy + ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}5.4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}5.5 if $ix + pb < digs$ then do \\
-\hspace{6mm}5.5.1 $t_{ix + pb} \leftarrow u$ \\
-6. Clamp excess digits of $t$. \\
-7. Swap $c$ with $t$ \\
-8. Clear $t$ \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_mul\_digs}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_mul\_digs.}
-This algorithm computes the unsigned product of two inputs $a$ and $b$, limited to an output precision of $digs$ digits. While it may seem
-a bit awkward to modify the function from its simple $O(n^2)$ description, the usefulness of partial multipliers will arise in a subsequent
-algorithm. The algorithm is loosely based on algorithm 14.12 from \cite[pp. 595]{HAC} and is similar to Algorithm M of Knuth \cite[pp. 268]{TAOCPV2}.
-Algorithm s\_mp\_mul\_digs differs from these cited references since it can produce a variable output precision regardless of the precision of the
-inputs.
-
-The first thing this algorithm checks for is whether a Comba multiplier can be used instead. If the minimum digit count of either
-input is less than $\delta$, then the Comba method may be used instead. After the Comba method is ruled out, the baseline algorithm begins. A
-temporary mp\_int variable $t$ is used to hold the intermediate result of the product. This allows the algorithm to be used to
-compute products when either $a = c$ or $b = c$ without overwriting the inputs.
-
-All of step 5 is the infamous $O(n^2)$ multiplication loop slightly modified to only produce upto $digs$ digits of output. The $pb$ variable
-is given the count of digits to read from $b$ inside the nested loop. If $pb \le 1$ then no more output digits can be produced and the algorithm
-will exit the loop. The best way to think of the loops are as a series of $pb \times 1$ multiplications. That is, in each pass of the
-innermost loop $a_{ix}$ is multiplied against $b$ and the result is added (\textit{with an appropriate shift}) to $t$.
-
-For example, consider multiplying $576$ by $241$. That is equivalent to computing $10^0(1)(576) + 10^1(4)(576) + 10^2(2)(576)$ which is best
-visualized in the following table.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|c|l|}
-\hline && & 5 & 7 & 6 & \\
-\hline $\times$&& & 2 & 4 & 1 & \\
-\hline &&&&&&\\
- && & 5 & 7 & 6 & $10^0(1)(576)$ \\
- &2 & 3 & 6 & 1 & 6 & $10^1(4)(576) + 10^0(1)(576)$ \\
- 1 & 3 & 8 & 8 & 1 & 6 & $10^2(2)(576) + 10^1(4)(576) + 10^0(1)(576)$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Long-Hand Multiplication Diagram}
-\end{figure}
-
-Each row of the product is added to the result after being shifted to the left (\textit{multiplied by a power of the radix}) by the appropriate
-count. That is in pass $ix$ of the inner loop the product is added starting at the $ix$'th digit of the reult.
-
-Step 5.4.1 introduces the hat symbol (\textit{e.g. $\hat r$}) which represents a double precision variable. The multiplication on that step
-is assumed to be a double wide output single precision multiplication. That is, two single precision variables are multiplied to produce a
-double precision result. The step is somewhat optimized from a long-hand multiplication algorithm because the carry from the addition in step
-5.4.1 is propagated through the nested loop. If the carry was not propagated immediately it would overflow the single precision digit
-$t_{ix+iy}$ and the result would be lost.
-
-At step 5.5 the nested loop is finished and any carry that was left over should be forwarded. The carry does not have to be added to the $ix+pb$'th
-digit since that digit is assumed to be zero at this point. However, if $ix + pb \ge digs$ the carry is not set as it would make the result
-exceed the precision requested.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_s\_mp\_mul\_digs.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-First we determine (line 31) if the Comba method can be used first since it's faster. The conditions for
-sing the Comba routine are that min$(a.used, b.used) < \delta$ and the number of digits of output is less than
-\textbf{MP\_WARRAY}. This new constant is used to control the stack usage in the Comba routines. By default it is
-set to $\delta$ but can be reduced when memory is at a premium.
-
-If we cannot use the Comba method we proceed to setup the baseline routine. We allocate the the destination mp\_int
-$t$ (line 37) to the exact size of the output to avoid further re--allocations. At this point we now
-begin the $O(n^2)$ loop.
-
-This implementation of multiplication has the caveat that it can be trimmed to only produce a variable number of
-digits as output. In each iteration of the outer loop the $pb$ variable is set (line 49) to the maximum
-number of inner loop iterations.
-
-Inside the inner loop we calculate $\hat r$ as the mp\_word product of the two mp\_digits and the addition of the
-carry from the previous iteration. A particularly important observation is that most modern optimizing
-C compilers (GCC for instance) can recognize that a $N \times N \rightarrow 2N$ multiplication is all that
-is required for the product. In x86 terms for example, this means using the MUL instruction.
-
-Each digit of the product is stored in turn (line 69) and the carry propagated (line 72) to the
-next iteration.
-
-\subsection{Faster Multiplication by the ``Comba'' Method}
-
-One of the huge drawbacks of the ``baseline'' algorithms is that at the $O(n^2)$ level the carry must be
-computed and propagated upwards. This makes the nested loop very sequential and hard to unroll and implement
-in parallel. The ``Comba'' \cite{COMBA} method is named after little known (\textit{in cryptographic venues}) Paul G.
-Comba who described a method of implementing fast multipliers that do not require nested carry fixup operations. As an
-interesting aside it seems that Paul Barrett describes a similar technique in his 1986 paper \cite{BARRETT} written
-five years before.
-
-At the heart of the Comba technique is once again the long-hand algorithm. Except in this case a slight
-twist is placed on how the columns of the result are produced. In the standard long-hand algorithm rows of products
-are produced then added together to form the final result. In the baseline algorithm the columns are added together
-after each iteration to get the result instantaneously.
-
-In the Comba algorithm the columns of the result are produced entirely independently of each other. That is at
-the $O(n^2)$ level a simple multiplication and addition step is performed. The carries of the columns are propagated
-after the nested loop to reduce the amount of work requiored. Succintly the first step of the algorithm is to compute
-the product vector $\vec x$ as follows.
-
-\begin{equation}
-\vec x_n = \sum_{i+j = n} a_ib_j, \forall n \in \lbrace 0, 1, 2, \ldots, i + j \rbrace
-\end{equation}
-
-Where $\vec x_n$ is the $n'th$ column of the output vector. Consider the following example which computes the vector $\vec x$ for the multiplication
-of $576$ and $241$.
-
-\newpage\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|c|c|c|c|c|}
- \hline & & 5 & 7 & 6 & First Input\\
- \hline $\times$ & & 2 & 4 & 1 & Second Input\\
-\hline & & $1 \cdot 5 = 5$ & $1 \cdot 7 = 7$ & $1 \cdot 6 = 6$ & First pass \\
- & $4 \cdot 5 = 20$ & $4 \cdot 7+5=33$ & $4 \cdot 6+7=31$ & 6 & Second pass \\
- $2 \cdot 5 = 10$ & $2 \cdot 7 + 20 = 34$ & $2 \cdot 6+33=45$ & 31 & 6 & Third pass \\
-\hline 10 & 34 & 45 & 31 & 6 & Final Result \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Comba Multiplication Diagram}
-\end{figure}
-
-At this point the vector $x = \left < 10, 34, 45, 31, 6 \right >$ is the result of the first step of the Comba multipler.
-Now the columns must be fixed by propagating the carry upwards. The resultant vector will have one extra dimension over the input vector which is
-congruent to adding a leading zero digit.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Comba Fixup}. \\
-\textbf{Input}. Vector $\vec x$ of dimension $k$ \\
-\textbf{Output}. Vector $\vec x$ such that the carries have been propagated. \\
-\hline \\
-1. for $n$ from $0$ to $k - 1$ do \\
-\hspace{3mm}1.1 $\vec x_{n+1} \leftarrow \vec x_{n+1} + \lfloor \vec x_{n}/\beta \rfloor$ \\
-\hspace{3mm}1.2 $\vec x_{n} \leftarrow \vec x_{n} \mbox{ (mod }\beta\mbox{)}$ \\
-2. Return($\vec x$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Comba Fixup}
-\end{figure}
-
-With that algorithm and $k = 5$ and $\beta = 10$ the following vector is produced $\vec x= \left < 1, 3, 8, 8, 1, 6 \right >$. In this case
-$241 \cdot 576$ is in fact $138816$ and the procedure succeeded. If the algorithm is correct and as will be demonstrated shortly more
-efficient than the baseline algorithm why not simply always use this algorithm?
-
-\subsubsection{Column Weight.}
-At the nested $O(n^2)$ level the Comba method adds the product of two single precision variables to each column of the output
-independently. A serious obstacle is if the carry is lost, due to lack of precision before the algorithm has a chance to fix
-the carries. For example, in the multiplication of two three-digit numbers the third column of output will be the sum of
-three single precision multiplications. If the precision of the accumulator for the output digits is less then $3 \cdot (\beta - 1)^2$ then
-an overflow can occur and the carry information will be lost. For any $m$ and $n$ digit inputs the maximum weight of any column is
-min$(m, n)$ which is fairly obvious.
-
-The maximum number of terms in any column of a product is known as the ``column weight'' and strictly governs when the algorithm can be used. Recall
-from earlier that a double precision type has $\alpha$ bits of resolution and a single precision digit has $lg(\beta)$ bits of precision. Given these
-two quantities we must not violate the following
-
-\begin{equation}
-k \cdot \left (\beta - 1 \right )^2 < 2^{\alpha}
-\end{equation}
-
-Which reduces to
-
-\begin{equation}
-k \cdot \left ( \beta^2 - 2\beta + 1 \right ) < 2^{\alpha}
-\end{equation}
-
-Let $\rho = lg(\beta)$ represent the number of bits in a single precision digit. By further re-arrangement of the equation the final solution is
-found.
-
-\begin{equation}
-k < {{2^{\alpha}} \over {\left (2^{2\rho} - 2^{\rho + 1} + 1 \right )}}
-\end{equation}
-
-The defaults for LibTomMath are $\beta = 2^{28}$ and $\alpha = 2^{64}$ which means that $k$ is bounded by $k < 257$. In this configuration
-the smaller input may not have more than $256$ digits if the Comba method is to be used. This is quite satisfactory for most applications since
-$256$ digits would allow for numbers in the range of $0 \le x < 2^{7168}$ which, is much larger than most public key cryptographic algorithms require.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_s\_mp\_mul\_digs}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and an integer $digs$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert \mbox{ (mod }\beta^{digs}\mbox{)}$. \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} single precision digits named $W$ on the stack. \\
-1. If $c.alloc < digs$ then grow $c$ to $digs$ digits. (\textit{mp\_grow}) \\
-2. If step 1 failed return(\textit{MP\_MEM}).\\
-\\
-3. $pa \leftarrow \mbox{MIN}(digs, a.used + b.used)$ \\
-\\
-4. $\_ \hat W \leftarrow 0$ \\
-5. for $ix$ from 0 to $pa - 1$ do \\
-\hspace{3mm}5.1 $ty \leftarrow \mbox{MIN}(b.used - 1, ix)$ \\
-\hspace{3mm}5.2 $tx \leftarrow ix - ty$ \\
-\hspace{3mm}5.3 $iy \leftarrow \mbox{MIN}(a.used - tx, ty + 1)$ \\
-\hspace{3mm}5.4 for $iz$ from 0 to $iy - 1$ do \\
-\hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
-\hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
-\hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
-\\
-6. $oldused \leftarrow c.used$ \\
-7. $c.used \leftarrow digs$ \\
-8. for $ix$ from $0$ to $pa$ do \\
-\hspace{3mm}8.1 $c_{ix} \leftarrow W_{ix}$ \\
-9. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
-\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
-\\
-10. Clamp $c$. \\
-11. Return MP\_OKAY. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_s\_mp\_mul\_digs}
-\label{fig:COMBAMULT}
-\end{figure}
-
-\textbf{Algorithm fast\_s\_mp\_mul\_digs.}
-This algorithm performs the unsigned multiplication of $a$ and $b$ using the Comba method limited to $digs$ digits of precision.
-
-The outer loop of this algorithm is more complicated than that of the baseline multiplier. This is because on the inside of the
-loop we want to produce one column per pass. This allows the accumulator $\_ \hat W$ to be placed in CPU registers and
-reduce the memory bandwidth to two \textbf{mp\_digit} reads per iteration.
-
-The $ty$ variable is set to the minimum count of $ix$ or the number of digits in $b$. That way if $a$ has more digits than
-$b$ this will be limited to $b.used - 1$. The $tx$ variable is set to the to the distance past $b.used$ the variable
-$ix$ is. This is used for the immediately subsequent statement where we find $iy$.
-
-The variable $iy$ is the minimum digits we can read from either $a$ or $b$ before running out. Computing one column at a time
-means we have to scan one integer upwards and the other downwards. $a$ starts at $tx$ and $b$ starts at $ty$. In each
-pass we are producing the $ix$'th output column and we note that $tx + ty = ix$. As we move $tx$ upwards we have to
-move $ty$ downards so the equality remains valid. The $iy$ variable is the number of iterations until
-$tx \ge a.used$ or $ty < 0$ occurs.
-
-After every inner pass we store the lower half of the accumulator into $W_{ix}$ and then propagate the carry of the accumulator
-into the next round by dividing $\_ \hat W$ by $\beta$.
-
-To measure the benefits of the Comba method over the baseline method consider the number of operations that are required. If the
-cost in terms of time of a multiply and addition is $p$ and the cost of a carry propagation is $q$ then a baseline multiplication would require
-$O \left ((p + q)n^2 \right )$ time to multiply two $n$-digit numbers. The Comba method requires only $O(pn^2 + qn)$ time, however in practice,
-the speed increase is actually much more. With $O(n)$ space the algorithm can be reduced to $O(pn + qn)$ time by implementing the $n$ multiply
-and addition operations in the nested loop in parallel.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_fast\_s\_mp\_mul\_digs.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-As per the pseudo--code we first calculate $pa$ (line 48) as the number of digits to output. Next we begin the outer loop
-to produce the individual columns of the product. We use the two aliases $tmpx$ and $tmpy$ (lines 62, 63) to point
-inside the two multiplicands quickly.
-
-The inner loop (lines 71 to 74) of this implementation is where the tradeoff come into play. Originally this comba
-implementation was ``row--major'' which means it adds to each of the columns in each pass. After the outer loop it would then fix
-the carries. This was very fast except it had an annoying drawback. You had to read a mp\_word and two mp\_digits and write
-one mp\_word per iteration. On processors such as the Athlon XP and P4 this did not matter much since the cache bandwidth
-is very high and it can keep the ALU fed with data. It did, however, matter on older and embedded cpus where cache is often
-slower and also often doesn't exist. This new algorithm only performs two reads per iteration under the assumption that the
-compiler has aliased $\_ \hat W$ to a CPU register.
-
-After the inner loop we store the current accumulator in $W$ and shift $\_ \hat W$ (lines 77, 80) to forward it as
-a carry for the next pass. After the outer loop we use the final carry (line 77) as the last digit of the product.
-
-\subsection{Polynomial Basis Multiplication}
-To break the $O(n^2)$ barrier in multiplication requires a completely different look at integer multiplication. In the following algorithms
-the use of polynomial basis representation for two integers $a$ and $b$ as $f(x) = \sum_{i=0}^{n} a_i x^i$ and
-$g(x) = \sum_{i=0}^{n} b_i x^i$ respectively, is required. In this system both $f(x)$ and $g(x)$ have $n + 1$ terms and are of the $n$'th degree.
-
-The product $a \cdot b \equiv f(x)g(x)$ is the polynomial $W(x) = \sum_{i=0}^{2n} w_i x^i$. The coefficients $w_i$ will
-directly yield the desired product when $\beta$ is substituted for $x$. The direct solution to solve for the $2n + 1$ coefficients
-requires $O(n^2)$ time and would in practice be slower than the Comba technique.
-
-However, numerical analysis theory indicates that only $2n + 1$ distinct points in $W(x)$ are required to determine the values of the $2n + 1$ unknown
-coefficients. This means by finding $\zeta_y = W(y)$ for $2n + 1$ small values of $y$ the coefficients of $W(x)$ can be found with
-Gaussian elimination. This technique is also occasionally refered to as the \textit{interpolation technique} (\textit{references please...}) since in
-effect an interpolation based on $2n + 1$ points will yield a polynomial equivalent to $W(x)$.
-
-The coefficients of the polynomial $W(x)$ are unknown which makes finding $W(y)$ for any value of $y$ impossible. However, since
-$W(x) = f(x)g(x)$ the equivalent $\zeta_y = f(y) g(y)$ can be used in its place. The benefit of this technique stems from the
-fact that $f(y)$ and $g(y)$ are much smaller than either $a$ or $b$ respectively. As a result finding the $2n + 1$ relations required
-by multiplying $f(y)g(y)$ involves multiplying integers that are much smaller than either of the inputs.
-
-When picking points to gather relations there are always three obvious points to choose, $y = 0, 1$ and $ \infty$. The $\zeta_0$ term
-is simply the product $W(0) = w_0 = a_0 \cdot b_0$. The $\zeta_1$ term is the product
-$W(1) = \left (\sum_{i = 0}^{n} a_i \right ) \left (\sum_{i = 0}^{n} b_i \right )$. The third point $\zeta_{\infty}$ is less obvious but rather
-simple to explain. The $2n + 1$'th coefficient of $W(x)$ is numerically equivalent to the most significant column in an integer multiplication.
-The point at $\infty$ is used symbolically to represent the most significant column, that is $W(\infty) = w_{2n} = a_nb_n$. Note that the
-points at $y = 0$ and $\infty$ yield the coefficients $w_0$ and $w_{2n}$ directly.
-
-If more points are required they should be of small values and powers of two such as $2^q$ and the related \textit{mirror points}
-$\left (2^q \right )^{2n} \cdot \zeta_{2^{-q}}$ for small values of $q$. The term ``mirror point'' stems from the fact that
-$\left (2^q \right )^{2n} \cdot \zeta_{2^{-q}}$ can be calculated in the exact opposite fashion as $\zeta_{2^q}$. For
-example, when $n = 2$ and $q = 1$ then following two equations are equivalent to the point $\zeta_{2}$ and its mirror.
-
-\begin{eqnarray}
-\zeta_{2} = f(2)g(2) = (4a_2 + 2a_1 + a_0)(4b_2 + 2b_1 + b_0) \nonumber \\
-16 \cdot \zeta_{1 \over 2} = 4f({1\over 2}) \cdot 4g({1 \over 2}) = (a_2 + 2a_1 + 4a_0)(b_2 + 2b_1 + 4b_0)
-\end{eqnarray}
-
-Using such points will allow the values of $f(y)$ and $g(y)$ to be independently calculated using only left shifts. For example, when $n = 2$ the
-polynomial $f(2^q)$ is equal to $2^q((2^qa_2) + a_1) + a_0$. This technique of polynomial representation is known as Horner's method.
-
-As a general rule of the algorithm when the inputs are split into $n$ parts each there are $2n - 1$ multiplications. Each multiplication is of
-multiplicands that have $n$ times fewer digits than the inputs. The asymptotic running time of this algorithm is
-$O \left ( k^{lg_n(2n - 1)} \right )$ for $k$ digit inputs (\textit{assuming they have the same number of digits}). Figure~\ref{fig:exponent}
-summarizes the exponents for various values of $n$.
-
-\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Split into $n$ Parts} & \textbf{Exponent} & \textbf{Notes}\\
-\hline $2$ & $1.584962501$ & This is Karatsuba Multiplication. \\
-\hline $3$ & $1.464973520$ & This is Toom-Cook Multiplication. \\
-\hline $4$ & $1.403677461$ &\\
-\hline $5$ & $1.365212389$ &\\
-\hline $10$ & $1.278753601$ &\\
-\hline $100$ & $1.149426538$ &\\
-\hline $1000$ & $1.100270931$ &\\
-\hline $10000$ & $1.075252070$ &\\
-\hline
-\end{tabular}
-\end{center}
-\caption{Asymptotic Running Time of Polynomial Basis Multiplication}
-\label{fig:exponent}
-\end{figure}
-
-At first it may seem like a good idea to choose $n = 1000$ since the exponent is approximately $1.1$. However, the overhead
-of solving for the 2001 terms of $W(x)$ will certainly consume any savings the algorithm could offer for all but exceedingly large
-numbers.
-
-\subsubsection{Cutoff Point}
-The polynomial basis multiplication algorithms all require fewer single precision multiplications than a straight Comba approach. However,
-the algorithms incur an overhead (\textit{at the $O(n)$ work level}) since they require a system of equations to be solved. This makes the
-polynomial basis approach more costly to use with small inputs.
-
-Let $m$ represent the number of digits in the multiplicands (\textit{assume both multiplicands have the same number of digits}). There exists a
-point $y$ such that when $m < y$ the polynomial basis algorithms are more costly than Comba, when $m = y$ they are roughly the same cost and
-when $m > y$ the Comba methods are slower than the polynomial basis algorithms.
-
-The exact location of $y$ depends on several key architectural elements of the computer platform in question.
-
-\begin{enumerate}
-\item The ratio of clock cycles for single precision multiplication versus other simpler operations such as addition, shifting, etc. For example
-on the AMD Athlon the ratio is roughly $17 : 1$ while on the Intel P4 it is $29 : 1$. The higher the ratio in favour of multiplication the lower
-the cutoff point $y$ will be.
-
-\item The complexity of the linear system of equations (\textit{for the coefficients of $W(x)$}) is. Generally speaking as the number of splits
-grows the complexity grows substantially. Ideally solving the system will only involve addition, subtraction and shifting of integers. This
-directly reflects on the ratio previous mentioned.
-
-\item To a lesser extent memory bandwidth and function call overheads. Provided the values are in the processor cache this is less of an
-influence over the cutoff point.
-
-\end{enumerate}
-
-A clean cutoff point separation occurs when a point $y$ is found such that all of the cutoff point conditions are met. For example, if the point
-is too low then there will be values of $m$ such that $m > y$ and the Comba method is still faster. Finding the cutoff points is fairly simple when
-a high resolution timer is available.
-
-\subsection{Karatsuba Multiplication}
-Karatsuba \cite{KARA} multiplication when originally proposed in 1962 was among the first set of algorithms to break the $O(n^2)$ barrier for
-general purpose multiplication. Given two polynomial basis representations $f(x) = ax + b$ and $g(x) = cx + d$, Karatsuba proved with
-light algebra \cite{KARAP} that the following polynomial is equivalent to multiplication of the two integers the polynomials represent.
-
-\begin{equation}
-f(x) \cdot g(x) = acx^2 + ((a + b)(c + d) - (ac + bd))x + bd
-\end{equation}
-
-Using the observation that $ac$ and $bd$ could be re-used only three half sized multiplications would be required to produce the product. Applying
-this algorithm recursively, the work factor becomes $O(n^{lg(3)})$ which is substantially better than the work factor $O(n^2)$ of the Comba technique. It turns
-out what Karatsuba did not know or at least did not publish was that this is simply polynomial basis multiplication with the points
-$\zeta_0$, $\zeta_{\infty}$ and $\zeta_{1}$. Consider the resultant system of equations.
-
-\begin{center}
-\begin{tabular}{rcrcrcrc}
-$\zeta_{0}$ & $=$ & & & & & $w_0$ \\
-$\zeta_{1}$ & $=$ & $w_2$ & $+$ & $w_1$ & $+$ & $w_0$ \\
-$\zeta_{\infty}$ & $=$ & $w_2$ & & & & \\
-\end{tabular}
-\end{center}
-
-By adding the first and last equation to the equation in the middle the term $w_1$ can be isolated and all three coefficients solved for. The simplicity
-of this system of equations has made Karatsuba fairly popular. In fact the cutoff point is often fairly low\footnote{With LibTomMath 0.18 it is 70 and 109 digits for the Intel P4 and AMD Athlon respectively.}
-making it an ideal algorithm to speed up certain public key cryptosystems such as RSA and Diffie-Hellman.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_karatsuba\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow \vert a \vert \cdot \vert b \vert$ \\
-\hline \\
-1. Init the following mp\_int variables: $x0$, $x1$, $y0$, $y1$, $t1$, $x0y0$, $x1y1$.\\
-2. If step 2 failed then return(\textit{MP\_MEM}). \\
-\\
-Split the input. e.g. $a = x1 \cdot \beta^B + x0$ \\
-3. $B \leftarrow \mbox{min}(a.used, b.used)/2$ \\
-4. $x0 \leftarrow a \mbox{ (mod }\beta^B\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-5. $y0 \leftarrow b \mbox{ (mod }\beta^B\mbox{)}$ \\
-6. $x1 \leftarrow \lfloor a / \beta^B \rfloor$ (\textit{mp\_rshd}) \\
-7. $y1 \leftarrow \lfloor b / \beta^B \rfloor$ \\
-\\
-Calculate the three products. \\
-8. $x0y0 \leftarrow x0 \cdot y0$ (\textit{mp\_mul}) \\
-9. $x1y1 \leftarrow x1 \cdot y1$ \\
-10. $t1 \leftarrow x1 + x0$ (\textit{mp\_add}) \\
-11. $x0 \leftarrow y1 + y0$ \\
-12. $t1 \leftarrow t1 \cdot x0$ \\
-\\
-Calculate the middle term. \\
-13. $x0 \leftarrow x0y0 + x1y1$ \\
-14. $t1 \leftarrow t1 - x0$ (\textit{s\_mp\_sub}) \\
-\\
-Calculate the final product. \\
-15. $t1 \leftarrow t1 \cdot \beta^B$ (\textit{mp\_lshd}) \\
-16. $x1y1 \leftarrow x1y1 \cdot \beta^{2B}$ \\
-17. $t1 \leftarrow x0y0 + t1$ \\
-18. $c \leftarrow t1 + x1y1$ \\
-19. Clear all of the temporary variables. \\
-20. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_karatsuba\_mul}
-\end{figure}
-
-\textbf{Algorithm mp\_karatsuba\_mul.}
-This algorithm computes the unsigned product of two inputs using the Karatsuba multiplication algorithm. It is loosely based on the description
-from Knuth \cite[pp. 294-295]{TAOCPV2}.
-
-\index{radix point}
-In order to split the two inputs into their respective halves, a suitable \textit{radix point} must be chosen. The radix point chosen must
-be used for both of the inputs meaning that it must be smaller than the smallest input. Step 3 chooses the radix point $B$ as half of the
-smallest input \textbf{used} count. After the radix point is chosen the inputs are split into lower and upper halves. Step 4 and 5
-compute the lower halves. Step 6 and 7 computer the upper halves.
-
-After the halves have been computed the three intermediate half-size products must be computed. Step 8 and 9 compute the trivial products
-$x0 \cdot y0$ and $x1 \cdot y1$. The mp\_int $x0$ is used as a temporary variable after $x1 + x0$ has been computed. By using $x0$ instead
-of an additional temporary variable, the algorithm can avoid an addition memory allocation operation.
-
-The remaining steps 13 through 18 compute the Karatsuba polynomial through a variety of digit shifting and addition operations.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_karatsuba\_mul.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The new coding element in this routine, not seen in previous routines, is the usage of goto statements. The conventional
-wisdom is that goto statements should be avoided. This is generally true, however when every single function call can fail, it makes sense
-to handle error recovery with a single piece of code. Lines 62 to 76 handle initializing all of the temporary variables
-required. Note how each of the if statements goes to a different label in case of failure. This allows the routine to correctly free only
-the temporaries that have been successfully allocated so far.
-
-The temporary variables are all initialized using the mp\_init\_size routine since they are expected to be large. This saves the
-additional reallocation that would have been necessary. Also $x0$, $x1$, $y0$ and $y1$ have to be able to hold at least their respective
-number of digits for the next section of code.
-
-The first algebraic portion of the algorithm is to split the two inputs into their halves. However, instead of using mp\_mod\_2d and mp\_rshd
-to extract the halves, the respective code has been placed inline within the body of the function. To initialize the halves, the \textbf{used} and
-\textbf{sign} members are copied first. The first for loop on line 96 copies the lower halves. Since they are both the same magnitude it
-is simpler to calculate both lower halves in a single loop. The for loop on lines 102 and 107 calculate the upper halves $x1$ and
-$y1$ respectively.
-
-By inlining the calculation of the halves, the Karatsuba multiplier has a slightly lower overhead and can be used for smaller magnitude inputs.
-
-When line 151 is reached, the algorithm has completed succesfully. The ``error status'' variable $err$ is set to \textbf{MP\_OKAY} so that
-the same code that handles errors can be used to clear the temporary variables and return.
-
-\subsection{Toom-Cook $3$-Way Multiplication}
-Toom-Cook $3$-Way \cite{TOOM} multiplication is essentially the polynomial basis algorithm for $n = 2$ except that the points are
-chosen such that $\zeta$ is easy to compute and the resulting system of equations easy to reduce. Here, the points $\zeta_{0}$,
-$16 \cdot \zeta_{1 \over 2}$, $\zeta_1$, $\zeta_2$ and $\zeta_{\infty}$ make up the five required points to solve for the coefficients
-of the $W(x)$.
-
-With the five relations that Toom-Cook specifies, the following system of equations is formed.
-
-\begin{center}
-\begin{tabular}{rcrcrcrcrcr}
-$\zeta_0$ & $=$ & $0w_4$ & $+$ & $0w_3$ & $+$ & $0w_2$ & $+$ & $0w_1$ & $+$ & $1w_0$ \\
-$16 \cdot \zeta_{1 \over 2}$ & $=$ & $1w_4$ & $+$ & $2w_3$ & $+$ & $4w_2$ & $+$ & $8w_1$ & $+$ & $16w_0$ \\
-$\zeta_1$ & $=$ & $1w_4$ & $+$ & $1w_3$ & $+$ & $1w_2$ & $+$ & $1w_1$ & $+$ & $1w_0$ \\
-$\zeta_2$ & $=$ & $16w_4$ & $+$ & $8w_3$ & $+$ & $4w_2$ & $+$ & $2w_1$ & $+$ & $1w_0$ \\
-$\zeta_{\infty}$ & $=$ & $1w_4$ & $+$ & $0w_3$ & $+$ & $0w_2$ & $+$ & $0w_1$ & $+$ & $0w_0$ \\
-\end{tabular}
-\end{center}
-
-A trivial solution to this matrix requires $12$ subtractions, two multiplications by a small power of two, two divisions by a small power
-of two, two divisions by three and one multiplication by three. All of these $19$ sub-operations require less than quadratic time, meaning that
-the algorithm can be faster than a baseline multiplication. However, the greater complexity of this algorithm places the cutoff point
-(\textbf{TOOM\_MUL\_CUTOFF}) where Toom-Cook becomes more efficient much higher than the Karatsuba cutoff point.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toom\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b $ \\
-\hline \\
-Split $a$ and $b$ into three pieces. E.g. $a = a_2 \beta^{2k} + a_1 \beta^{k} + a_0$ \\
-1. $k \leftarrow \lfloor \mbox{min}(a.used, b.used) / 3 \rfloor$ \\
-2. $a_0 \leftarrow a \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-3. $a_1 \leftarrow \lfloor a / \beta^k \rfloor$, $a_1 \leftarrow a_1 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-4. $a_2 \leftarrow \lfloor a / \beta^{2k} \rfloor$, $a_2 \leftarrow a_2 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-5. $b_0 \leftarrow a \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-6. $b_1 \leftarrow \lfloor a / \beta^k \rfloor$, $b_1 \leftarrow b_1 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-7. $b_2 \leftarrow \lfloor a / \beta^{2k} \rfloor$, $b_2 \leftarrow b_2 \mbox{ (mod }\beta^{k}\mbox{)}$ \\
-\\
-Find the five equations for $w_0, w_1, ..., w_4$. \\
-8. $w_0 \leftarrow a_0 \cdot b_0$ \\
-9. $w_4 \leftarrow a_2 \cdot b_2$ \\
-10. $tmp_1 \leftarrow 2 \cdot a_0$, $tmp_1 \leftarrow a_1 + tmp_1$, $tmp_1 \leftarrow 2 \cdot tmp_1$, $tmp_1 \leftarrow tmp_1 + a_2$ \\
-11. $tmp_2 \leftarrow 2 \cdot b_0$, $tmp_2 \leftarrow b_1 + tmp_2$, $tmp_2 \leftarrow 2 \cdot tmp_2$, $tmp_2 \leftarrow tmp_2 + b_2$ \\
-12. $w_1 \leftarrow tmp_1 \cdot tmp_2$ \\
-13. $tmp_1 \leftarrow 2 \cdot a_2$, $tmp_1 \leftarrow a_1 + tmp_1$, $tmp_1 \leftarrow 2 \cdot tmp_1$, $tmp_1 \leftarrow tmp_1 + a_0$ \\
-14. $tmp_2 \leftarrow 2 \cdot b_2$, $tmp_2 \leftarrow b_1 + tmp_2$, $tmp_2 \leftarrow 2 \cdot tmp_2$, $tmp_2 \leftarrow tmp_2 + b_0$ \\
-15. $w_3 \leftarrow tmp_1 \cdot tmp_2$ \\
-16. $tmp_1 \leftarrow a_0 + a_1$, $tmp_1 \leftarrow tmp_1 + a_2$, $tmp_2 \leftarrow b_0 + b_1$, $tmp_2 \leftarrow tmp_2 + b_2$ \\
-17. $w_2 \leftarrow tmp_1 \cdot tmp_2$ \\
-\\
-Continued on the next page.\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toom\_mul}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toom\_mul} (continued). \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b $ \\
-\hline \\
-Now solve the system of equations. \\
-18. $w_1 \leftarrow w_4 - w_1$, $w_3 \leftarrow w_3 - w_0$ \\
-19. $w_1 \leftarrow \lfloor w_1 / 2 \rfloor$, $w_3 \leftarrow \lfloor w_3 / 2 \rfloor$ \\
-20. $w_2 \leftarrow w_2 - w_0$, $w_2 \leftarrow w_2 - w_4$ \\
-21. $w_1 \leftarrow w_1 - w_2$, $w_3 \leftarrow w_3 - w_2$ \\
-22. $tmp_1 \leftarrow 8 \cdot w_0$, $w_1 \leftarrow w_1 - tmp_1$, $tmp_1 \leftarrow 8 \cdot w_4$, $w_3 \leftarrow w_3 - tmp_1$ \\
-23. $w_2 \leftarrow 3 \cdot w_2$, $w_2 \leftarrow w_2 - w_1$, $w_2 \leftarrow w_2 - w_3$ \\
-24. $w_1 \leftarrow w_1 - w_2$, $w_3 \leftarrow w_3 - w_2$ \\
-25. $w_1 \leftarrow \lfloor w_1 / 3 \rfloor, w_3 \leftarrow \lfloor w_3 / 3 \rfloor$ \\
-\\
-Now substitute $\beta^k$ for $x$ by shifting $w_0, w_1, ..., w_4$. \\
-26. for $n$ from $1$ to $4$ do \\
-\hspace{3mm}26.1 $w_n \leftarrow w_n \cdot \beta^{nk}$ \\
-27. $c \leftarrow w_0 + w_1$, $c \leftarrow c + w_2$, $c \leftarrow c + w_3$, $c \leftarrow c + w_4$ \\
-28. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toom\_mul (continued)}
-\end{figure}
-
-\textbf{Algorithm mp\_toom\_mul.}
-This algorithm computes the product of two mp\_int variables $a$ and $b$ using the Toom-Cook approach. Compared to the Karatsuba multiplication, this
-algorithm has a lower asymptotic running time of approximately $O(n^{1.464})$ but at an obvious cost in overhead. In this
-description, several statements have been compounded to save space. The intention is that the statements are executed from left to right across
-any given step.
-
-The two inputs $a$ and $b$ are first split into three $k$-digit integers $a_0, a_1, a_2$ and $b_0, b_1, b_2$ respectively. From these smaller
-integers the coefficients of the polynomial basis representations $f(x)$ and $g(x)$ are known and can be used to find the relations required.
-
-The first two relations $w_0$ and $w_4$ are the points $\zeta_{0}$ and $\zeta_{\infty}$ respectively. The relation $w_1, w_2$ and $w_3$ correspond
-to the points $16 \cdot \zeta_{1 \over 2}, \zeta_{2}$ and $\zeta_{1}$ respectively. These are found using logical shifts to independently find
-$f(y)$ and $g(y)$ which significantly speeds up the algorithm.
-
-After the five relations $w_0, w_1, \ldots, w_4$ have been computed, the system they represent must be solved in order for the unknown coefficients
-$w_1, w_2$ and $w_3$ to be isolated. The steps 18 through 25 perform the system reduction required as previously described. Each step of
-the reduction represents the comparable matrix operation that would be performed had this been performed by pencil. For example, step 18 indicates
-that row $1$ must be subtracted from row $4$ and simultaneously row $0$ subtracted from row $3$.
-
-Once the coeffients have been isolated, the polynomial $W(x) = \sum_{i=0}^{2n} w_i x^i$ is known. By substituting $\beta^{k}$ for $x$, the integer
-result $a \cdot b$ is produced.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_toom\_mul.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The first obvious thing to note is that this algorithm is complicated. The complexity is worth it if you are multiplying very
-large numbers. For example, a 10,000 digit multiplication takes approximaly 99,282,205 fewer single precision multiplications with
-Toom--Cook than a Comba or baseline approach (this is a savings of more than 99$\%$). For most ``crypto'' sized numbers this
-algorithm is not practical as Karatsuba has a much lower cutoff point.
-
-First we split $a$ and $b$ into three roughly equal portions. This has been accomplished (lines 41 to 70) with
-combinations of mp\_rshd() and mp\_mod\_2d() function calls. At this point $a = a2 \cdot \beta^2 + a1 \cdot \beta + a0$ and similiarly
-for $b$.
-
-Next we compute the five points $w0, w1, w2, w3$ and $w4$. Recall that $w0$ and $w4$ can be computed directly from the portions so
-we get those out of the way first (lines 73 and 78). Next we compute $w1, w2$ and $w3$ using Horners method.
-
-After this point we solve for the actual values of $w1, w2$ and $w3$ by reducing the $5 \times 5$ system which is relatively
-straight forward.
-
-\subsection{Signed Multiplication}
-Now that algorithms to handle multiplications of every useful dimensions have been developed, a rather simple finishing touch is required. So far all
-of the multiplication algorithms have been unsigned multiplications which leaves only a signed multiplication algorithm to be established.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul}. \\
-\textbf{Input}. mp\_int $a$ and mp\_int $b$ \\
-\textbf{Output}. $c \leftarrow a \cdot b$ \\
-\hline \\
-1. If $a.sign = b.sign$ then \\
-\hspace{3mm}1.1 $sign = MP\_ZPOS$ \\
-2. else \\
-\hspace{3mm}2.1 $sign = MP\_ZNEG$ \\
-3. If min$(a.used, b.used) \ge TOOM\_MUL\_CUTOFF$ then \\
-\hspace{3mm}3.1 $c \leftarrow a \cdot b$ using algorithm mp\_toom\_mul \\
-4. else if min$(a.used, b.used) \ge KARATSUBA\_MUL\_CUTOFF$ then \\
-\hspace{3mm}4.1 $c \leftarrow a \cdot b$ using algorithm mp\_karatsuba\_mul \\
-5. else \\
-\hspace{3mm}5.1 $digs \leftarrow a.used + b.used + 1$ \\
-\hspace{3mm}5.2 If $digs < MP\_ARRAY$ and min$(a.used, b.used) \le \delta$ then \\
-\hspace{6mm}5.2.1 $c \leftarrow a \cdot b \mbox{ (mod }\beta^{digs}\mbox{)}$ using algorithm fast\_s\_mp\_mul\_digs. \\
-\hspace{3mm}5.3 else \\
-\hspace{6mm}5.3.1 $c \leftarrow a \cdot b \mbox{ (mod }\beta^{digs}\mbox{)}$ using algorithm s\_mp\_mul\_digs. \\
-6. $c.sign \leftarrow sign$ \\
-7. Return the result of the unsigned multiplication performed. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul}
-\end{figure}
-
-\textbf{Algorithm mp\_mul.}
-This algorithm performs the signed multiplication of two inputs. It will make use of any of the three unsigned multiplication algorithms
-available when the input is of appropriate size. The \textbf{sign} of the result is not set until the end of the algorithm since algorithm
-s\_mp\_mul\_digs will clear it.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_mul.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The implementation is rather simplistic and is not particularly noteworthy. Line 22 computes the sign of the result using the ``?''
-operator from the C programming language. Line 48 computes $\delta$ using the fact that $1 << k$ is equal to $2^k$.
-
-\section{Squaring}
-\label{sec:basesquare}
-
-Squaring is a special case of multiplication where both multiplicands are equal. At first it may seem like there is no significant optimization
-available but in fact there is. Consider the multiplication of $576$ against $241$. In total there will be nine single precision multiplications
-performed which are $1\cdot 6$, $1 \cdot 7$, $1 \cdot 5$, $4 \cdot 6$, $4 \cdot 7$, $4 \cdot 5$, $2 \cdot 6$, $2 \cdot 7$ and $2 \cdot 5$. Now consider
-the multiplication of $123$ against $123$. The nine products are $3 \cdot 3$, $3 \cdot 2$, $3 \cdot 1$, $2 \cdot 3$, $2 \cdot 2$, $2 \cdot 1$,
-$1 \cdot 3$, $1 \cdot 2$ and $1 \cdot 1$. On closer inspection some of the products are equivalent. For example, $3 \cdot 2 = 2 \cdot 3$
-and $3 \cdot 1 = 1 \cdot 3$.
-
-For any $n$-digit input, there are ${{\left (n^2 + n \right)}\over 2}$ possible unique single precision multiplications required compared to the $n^2$
-required for multiplication. The following diagram gives an example of the operations required.
-
-\begin{figure}[here]
-\begin{center}
-\begin{tabular}{ccccc|c}
-&&1&2&3&\\
-$\times$ &&1&2&3&\\
-\hline && $3 \cdot 1$ & $3 \cdot 2$ & $3 \cdot 3$ & Row 0\\
- & $2 \cdot 1$ & $2 \cdot 2$ & $2 \cdot 3$ && Row 1 \\
- $1 \cdot 1$ & $1 \cdot 2$ & $1 \cdot 3$ &&& Row 2 \\
-\end{tabular}
-\end{center}
-\caption{Squaring Optimization Diagram}
-\end{figure}
-
-Starting from zero and numbering the columns from right to left a very simple pattern becomes obvious. For the purposes of this discussion let $x$
-represent the number being squared. The first observation is that in row $k$ the $2k$'th column of the product has a $\left (x_k \right)^2$ term in it.
-
-The second observation is that every column $j$ in row $k$ where $j \ne 2k$ is part of a double product. Every non-square term of a column will
-appear twice hence the name ``double product''. Every odd column is made up entirely of double products. In fact every column is made up of double
-products and at most one square (\textit{see the exercise section}).
-
-The third and final observation is that for row $k$ the first unique non-square term, that is, one that hasn't already appeared in an earlier row,
-occurs at column $2k + 1$. For example, on row $1$ of the previous squaring, column one is part of the double product with column one from row zero.
-Column two of row one is a square and column three is the first unique column.
-
-\subsection{The Baseline Squaring Algorithm}
-The baseline squaring algorithm is meant to be a catch-all squaring algorithm. It will handle any of the input sizes that the faster routines
-will not handle.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. Init a temporary mp\_int of at least $2 \cdot a.used +1$ digits. (\textit{mp\_init\_size}) \\
-2. If step 1 failed return(\textit{MP\_MEM}) \\
-3. $t.used \leftarrow 2 \cdot a.used + 1$ \\
-4. For $ix$ from 0 to $a.used - 1$ do \\
-\hspace{3mm}Calculate the square. \\
-\hspace{3mm}4.1 $\hat r \leftarrow t_{2ix} + \left (a_{ix} \right )^2$ \\
-\hspace{3mm}4.2 $t_{2ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}Calculate the double products after the square. \\
-\hspace{3mm}4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}4.4 For $iy$ from $ix + 1$ to $a.used - 1$ do \\
-\hspace{6mm}4.4.1 $\hat r \leftarrow 2 \cdot a_{ix}a_{iy} + t_{ix + iy} + u$ \\
-\hspace{6mm}4.4.2 $t_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}4.4.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}Set the last carry. \\
-\hspace{3mm}4.5 While $u > 0$ do \\
-\hspace{6mm}4.5.1 $iy \leftarrow iy + 1$ \\
-\hspace{6mm}4.5.2 $\hat r \leftarrow t_{ix + iy} + u$ \\
-\hspace{6mm}4.5.3 $t_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}4.5.4 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-5. Clamp excess digits of $t$. (\textit{mp\_clamp}) \\
-6. Exchange $b$ and $t$. \\
-7. Clear $t$ (\textit{mp\_clear}) \\
-8. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_sqr.}
-This algorithm computes the square of an input using the three observations on squaring. It is based fairly faithfully on algorithm 14.16 of HAC
-\cite[pp.596-597]{HAC}. Similar to algorithm s\_mp\_mul\_digs, a temporary mp\_int is allocated to hold the result of the squaring. This allows the
-destination mp\_int to be the same as the source mp\_int.
-
-The outer loop of this algorithm begins on step 4. It is best to think of the outer loop as walking down the rows of the partial results, while
-the inner loop computes the columns of the partial result. Step 4.1 and 4.2 compute the square term for each row, and step 4.3 and 4.4 propagate
-the carry and compute the double products.
-
-The requirement that a mp\_word be able to represent the range $0 \le x < 2 \beta^2$ arises from this
-very algorithm. The product $a_{ix}a_{iy}$ will lie in the range $0 \le x \le \beta^2 - 2\beta + 1$ which is obviously less than $\beta^2$ meaning that
-when it is multiplied by two, it can be properly represented by a mp\_word.
-
-Similar to algorithm s\_mp\_mul\_digs, after every pass of the inner loop, the destination is correctly set to the sum of all of the partial
-results calculated so far. This involves expensive carry propagation which will be eliminated in the next algorithm.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_s\_mp\_sqr.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Inside the outer loop (line 34) the square term is calculated on line 37. The carry (line 44) has been
-extracted from the mp\_word accumulator using a right shift. Aliases for $a_{ix}$ and $t_{ix+iy}$ are initialized
-(lines 47 and 50) to simplify the inner loop. The doubling is performed using two
-additions (line 59) since it is usually faster than shifting, if not at least as fast.
-
-The important observation is that the inner loop does not begin at $iy = 0$ like for multiplication. As such the inner loops
-get progressively shorter as the algorithm proceeds. This is what leads to the savings compared to using a multiplication to
-square a number.
-
-\subsection{Faster Squaring by the ``Comba'' Method}
-A major drawback to the baseline method is the requirement for single precision shifting inside the $O(n^2)$ nested loop. Squaring has an additional
-drawback that it must double the product inside the inner loop as well. As for multiplication, the Comba technique can be used to eliminate these
-performance hazards.
-
-The first obvious solution is to make an array of mp\_words which will hold all of the columns. This will indeed eliminate all of the carry
-propagation operations from the inner loop. However, the inner product must still be doubled $O(n^2)$ times. The solution stems from the simple fact
-that $2a + 2b + 2c = 2(a + b + c)$. That is the sum of all of the double products is equal to double the sum of all the products. For example,
-$ab + ba + ac + ca = 2ab + 2ac = 2(ab + ac)$.
-
-However, we cannot simply double all of the columns, since the squares appear only once per row. The most practical solution is to have two
-mp\_word arrays. One array will hold the squares and the other array will hold the double products. With both arrays the doubling and
-carry propagation can be moved to a $O(n)$ work level outside the $O(n^2)$ level. In this case, we have an even simpler solution in mind.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_s\_mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} mp\_digits named $W$ on the stack. \\
-1. If $b.alloc < 2a.used + 1$ then grow $b$ to $2a.used + 1$ digits. (\textit{mp\_grow}). \\
-2. If step 1 failed return(\textit{MP\_MEM}). \\
-\\
-3. $pa \leftarrow 2 \cdot a.used$ \\
-4. $\hat W1 \leftarrow 0$ \\
-5. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}5.1 $\_ \hat W \leftarrow 0$ \\
-\hspace{3mm}5.2 $ty \leftarrow \mbox{MIN}(a.used - 1, ix)$ \\
-\hspace{3mm}5.3 $tx \leftarrow ix - ty$ \\
-\hspace{3mm}5.4 $iy \leftarrow \mbox{MIN}(a.used - tx, ty + 1)$ \\
-\hspace{3mm}5.5 $iy \leftarrow \mbox{MIN}(iy, \lfloor \left (ty - tx + 1 \right )/2 \rfloor)$ \\
-\hspace{3mm}5.6 for $iz$ from $0$ to $iz - 1$ do \\
-\hspace{6mm}5.6.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx + iz}a_{ty - iz}$ \\
-\hspace{3mm}5.7 $\_ \hat W \leftarrow 2 \cdot \_ \hat W + \hat W1$ \\
-\hspace{3mm}5.8 if $ix$ is even then \\
-\hspace{6mm}5.8.1 $\_ \hat W \leftarrow \_ \hat W + \left ( a_{\lfloor ix/2 \rfloor}\right )^2$ \\
-\hspace{3mm}5.9 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
-\hspace{3mm}5.10 $\hat W1 \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
-\\
-6. $oldused \leftarrow b.used$ \\
-7. $b.used \leftarrow 2 \cdot a.used$ \\
-8. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}8.1 $b_{ix} \leftarrow W_{ix}$ \\
-9. for $ix$ from $pa$ to $oldused - 1$ do \\
-\hspace{3mm}9.1 $b_{ix} \leftarrow 0$ \\
-10. Clamp excess digits from $b$. (\textit{mp\_clamp}) \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_s\_mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm fast\_s\_mp\_sqr.}
-This algorithm computes the square of an input using the Comba technique. It is designed to be a replacement for algorithm
-s\_mp\_sqr when the number of input digits is less than \textbf{MP\_WARRAY} and less than $\delta \over 2$.
-This algorithm is very similar to the Comba multiplier except with a few key differences we shall make note of.
-
-First, we have an accumulator and carry variables $\_ \hat W$ and $\hat W1$ respectively. This is because the inner loop
-products are to be doubled. If we had added the previous carry in we would be doubling too much. Next we perform an
-addition MIN condition on $iy$ (step 5.5) to prevent overlapping digits. For example, $a_3 \cdot a_5$ is equal
-$a_5 \cdot a_3$. Whereas in the multiplication case we would have $5 < a.used$ and $3 \ge 0$ is maintained since we double the sum
-of the products just outside the inner loop we have to avoid doing this. This is also a good thing since we perform
-fewer multiplications and the routine ends up being faster.
-
-Finally the last difference is the addition of the ``square'' term outside the inner loop (step 5.8). We add in the square
-only to even outputs and it is the square of the term at the $\lfloor ix / 2 \rfloor$ position.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_fast\_s\_mp\_sqr.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This implementation is essentially a copy of Comba multiplication with the appropriate changes added to make it faster for
-the special case of squaring.
-
-\subsection{Polynomial Basis Squaring}
-The same algorithm that performs optimal polynomial basis multiplication can be used to perform polynomial basis squaring. The minor exception
-is that $\zeta_y = f(y)g(y)$ is actually equivalent to $\zeta_y = f(y)^2$ since $f(y) = g(y)$. Instead of performing $2n + 1$
-multiplications to find the $\zeta$ relations, squaring operations are performed instead.
-
-\subsection{Karatsuba Squaring}
-Let $f(x) = ax + b$ represent the polynomial basis representation of a number to square.
-Let $h(x) = \left ( f(x) \right )^2$ represent the square of the polynomial. The Karatsuba equation can be modified to square a
-number with the following equation.
-
-\begin{equation}
-h(x) = a^2x^2 + \left ((a + b)^2 - (a^2 + b^2) \right )x + b^2
-\end{equation}
-
-Upon closer inspection this equation only requires the calculation of three half-sized squares: $a^2$, $b^2$ and $(a + b)^2$. As in
-Karatsuba multiplication, this algorithm can be applied recursively on the input and will achieve an asymptotic running time of
-$O \left ( n^{lg(3)} \right )$.
-
-If the asymptotic times of Karatsuba squaring and multiplication are the same, why not simply use the multiplication algorithm
-instead? The answer to this arises from the cutoff point for squaring. As in multiplication there exists a cutoff point, at which the
-time required for a Comba based squaring and a Karatsuba based squaring meet. Due to the overhead inherent in the Karatsuba method, the cutoff
-point is fairly high. For example, on an AMD Athlon XP processor with $\beta = 2^{28}$, the cutoff point is around 127 digits.
-
-Consider squaring a 200 digit number with this technique. It will be split into two 100 digit halves which are subsequently squared.
-The 100 digit halves will not be squared using Karatsuba, but instead using the faster Comba based squaring algorithm. If Karatsuba multiplication
-were used instead, the 100 digit numbers would be squared with a slower Comba based multiplication.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_karatsuba\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. Initialize the following temporary mp\_ints: $x0$, $x1$, $t1$, $t2$, $x0x0$ and $x1x1$. \\
-2. If any of the initializations on step 1 failed return(\textit{MP\_MEM}). \\
-\\
-Split the input. e.g. $a = x1\beta^B + x0$ \\
-3. $B \leftarrow \lfloor a.used / 2 \rfloor$ \\
-4. $x0 \leftarrow a \mbox{ (mod }\beta^B\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-5. $x1 \leftarrow \lfloor a / \beta^B \rfloor$ (\textit{mp\_lshd}) \\
-\\
-Calculate the three squares. \\
-6. $x0x0 \leftarrow x0^2$ (\textit{mp\_sqr}) \\
-7. $x1x1 \leftarrow x1^2$ \\
-8. $t1 \leftarrow x1 + x0$ (\textit{s\_mp\_add}) \\
-9. $t1 \leftarrow t1^2$ \\
-\\
-Compute the middle term. \\
-10. $t2 \leftarrow x0x0 + x1x1$ (\textit{s\_mp\_add}) \\
-11. $t1 \leftarrow t1 - t2$ \\
-\\
-Compute final product. \\
-12. $t1 \leftarrow t1\beta^B$ (\textit{mp\_lshd}) \\
-13. $x1x1 \leftarrow x1x1\beta^{2B}$ \\
-14. $t1 \leftarrow t1 + x0x0$ \\
-15. $b \leftarrow t1 + x1x1$ \\
-16. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_karatsuba\_sqr}
-\end{figure}
-
-\textbf{Algorithm mp\_karatsuba\_sqr.}
-This algorithm computes the square of an input $a$ using the Karatsuba technique. This algorithm is very similar to the Karatsuba based
-multiplication algorithm with the exception that the three half-size multiplications have been replaced with three half-size squarings.
-
-The radix point for squaring is simply placed exactly in the middle of the digits when the input has an odd number of digits, otherwise it is
-placed just below the middle. Step 3, 4 and 5 compute the two halves required using $B$
-as the radix point. The first two squares in steps 6 and 7 are rather straightforward while the last square is of a more compact form.
-
-By expanding $\left (x1 + x0 \right )^2$, the $x1^2$ and $x0^2$ terms in the middle disappear, that is $(x0 - x1)^2 - (x1^2 + x0^2) = 2 \cdot x0 \cdot x1$.
-Now if $5n$ single precision additions and a squaring of $n$-digits is faster than multiplying two $n$-digit numbers and doubling then
-this method is faster. Assuming no further recursions occur, the difference can be estimated with the following inequality.
-
-Let $p$ represent the cost of a single precision addition and $q$ the cost of a single precision multiplication both in terms of time\footnote{Or
-machine clock cycles.}.
-
-\begin{equation}
-5pn +{{q(n^2 + n)} \over 2} \le pn + qn^2
-\end{equation}
-
-For example, on an AMD Athlon XP processor $p = {1 \over 3}$ and $q = 6$. This implies that the following inequality should hold.
-\begin{center}
-\begin{tabular}{rcl}
-${5n \over 3} + 3n^2 + 3n$ & $<$ & ${n \over 3} + 6n^2$ \\
-${5 \over 3} + 3n + 3$ & $<$ & ${1 \over 3} + 6n$ \\
-${13 \over 9}$ & $<$ & $n$ \\
-\end{tabular}
-\end{center}
-
-This results in a cutoff point around $n = 2$. As a consequence it is actually faster to compute the middle term the ``long way'' on processors
-where multiplication is substantially slower\footnote{On the Athlon there is a 1:17 ratio between clock cycles for addition and multiplication. On
-the Intel P4 processor this ratio is 1:29 making this method even more beneficial. The only common exception is the ARMv4 processor which has a
-ratio of 1:7. } than simpler operations such as addition.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_karatsuba\_sqr.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This implementation is largely based on the implementation of algorithm mp\_karatsuba\_mul. It uses the same inline style to copy and
-shift the input into the two halves. The loop from line 54 to line 70 has been modified since only one input exists. The \textbf{used}
-count of both $x0$ and $x1$ is fixed up and $x0$ is clamped before the calculations begin. At this point $x1$ and $x0$ are valid equivalents
-to the respective halves as if mp\_rshd and mp\_mod\_2d had been used.
-
-By inlining the copy and shift operations the cutoff point for Karatsuba multiplication can be lowered. On the Athlon the cutoff point
-is exactly at the point where Comba squaring can no longer be used (\textit{128 digits}). On slower processors such as the Intel P4
-it is actually below the Comba limit (\textit{at 110 digits}).
-
-This routine uses the same error trap coding style as mp\_karatsuba\_sqr. As the temporary variables are initialized errors are
-redirected to the error trap higher up. If the algorithm completes without error the error code is set to \textbf{MP\_OKAY} and
-mp\_clears are executed normally.
-
-\subsection{Toom-Cook Squaring}
-The Toom-Cook squaring algorithm mp\_toom\_sqr is heavily based on the algorithm mp\_toom\_mul with the exception that squarings are used
-instead of multiplication to find the five relations. The reader is encouraged to read the description of the latter algorithm and try to
-derive their own Toom-Cook squaring algorithm.
-
-\subsection{High Level Squaring}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_sqr}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $b \leftarrow a^2$ \\
-\hline \\
-1. If $a.used \ge TOOM\_SQR\_CUTOFF$ then \\
-\hspace{3mm}1.1 $b \leftarrow a^2$ using algorithm mp\_toom\_sqr \\
-2. else if $a.used \ge KARATSUBA\_SQR\_CUTOFF$ then \\
-\hspace{3mm}2.1 $b \leftarrow a^2$ using algorithm mp\_karatsuba\_sqr \\
-3. else \\
-\hspace{3mm}3.1 $digs \leftarrow a.used + b.used + 1$ \\
-\hspace{3mm}3.2 If $digs < MP\_ARRAY$ and $a.used \le \delta$ then \\
-\hspace{6mm}3.2.1 $b \leftarrow a^2$ using algorithm fast\_s\_mp\_sqr. \\
-\hspace{3mm}3.3 else \\
-\hspace{6mm}3.3.1 $b \leftarrow a^2$ using algorithm s\_mp\_sqr. \\
-4. $b.sign \leftarrow MP\_ZPOS$ \\
-5. Return the result of the unsigned squaring performed. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_sqr}
-\end{figure}
-
-\textbf{Algorithm mp\_sqr.}
-This algorithm computes the square of the input using one of four different algorithms. If the input is very large and has at least
-\textbf{TOOM\_SQR\_CUTOFF} or \textbf{KARATSUBA\_SQR\_CUTOFF} digits then either the Toom-Cook or the Karatsuba Squaring algorithm is used. If
-neither of the polynomial basis algorithms should be used then either the Comba or baseline algorithm is used.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_sqr.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ] $ & Devise an efficient algorithm for selection of the radix point to handle inputs \\
- & that have different number of digits in Karatsuba multiplication. \\
- & \\
-$\left [ 2 \right ] $ & In section 5.3 the fact that every column of a squaring is made up \\
- & of double products and at most one square is stated. Prove this statement. \\
- & \\
-$\left [ 3 \right ] $ & Prove the equation for Karatsuba squaring. \\
- & \\
-$\left [ 1 \right ] $ & Prove that Karatsuba squaring requires $O \left (n^{lg(3)} \right )$ time. \\
- & \\
-$\left [ 2 \right ] $ & Determine the minimal ratio between addition and multiplication clock cycles \\
- & required for equation $6.7$ to be true. \\
- & \\
-$\left [ 3 \right ] $ & Implement a threaded version of Comba multiplication (and squaring) where you \\
- & compute subsets of the columns in each thread. Determine a cutoff point where \\
- & it is effective and add the logic to mp\_mul() and mp\_sqr(). \\
- &\\
-$\left [ 4 \right ] $ & Same as the previous but also modify the Karatsuba and Toom-Cook. You must \\
- & increase the throughput of mp\_exptmod() for random odd moduli in the range \\
- & $512 \ldots 4096$ bits significantly ($> 2x$) to complete this challenge. \\
- & \\
-\end{tabular}
-
-\chapter{Modular Reduction}
-\section{Basics of Modular Reduction}
-\index{modular residue}
-Modular reduction is an operation that arises quite often within public key cryptography algorithms and various number theoretic algorithms,
-such as factoring. Modular reduction algorithms are the third class of algorithms of the ``multipliers'' set. A number $a$ is said to be \textit{reduced}
-modulo another number $b$ by finding the remainder of the division $a/b$. Full integer division with remainder is a topic to be covered
-in~\ref{sec:division}.
-
-Modular reduction is equivalent to solving for $r$ in the following equation. $a = bq + r$ where $q = \lfloor a/b \rfloor$. The result
-$r$ is said to be ``congruent to $a$ modulo $b$'' which is also written as $r \equiv a \mbox{ (mod }b\mbox{)}$. In other vernacular $r$ is known as the
-``modular residue'' which leads to ``quadratic residue''\footnote{That's fancy talk for $b \equiv a^2 \mbox{ (mod }p\mbox{)}$.} and
-other forms of residues.
-
-Modular reductions are normally used to create either finite groups, rings or fields. The most common usage for performance driven modular reductions
-is in modular exponentiation algorithms. That is to compute $d = a^b \mbox{ (mod }c\mbox{)}$ as fast as possible. This operation is used in the
-RSA and Diffie-Hellman public key algorithms, for example. Modular multiplication and squaring also appears as a fundamental operation in
-elliptic curve cryptographic algorithms. As will be discussed in the subsequent chapter there exist fast algorithms for computing modular
-exponentiations without having to perform (\textit{in this example}) $b - 1$ multiplications. These algorithms will produce partial results in the
-range $0 \le x < c^2$ which can be taken advantage of to create several efficient algorithms. They have also been used to create redundancy check
-algorithms known as CRCs, error correction codes such as Reed-Solomon and solve a variety of number theoeretic problems.
-
-\section{The Barrett Reduction}
-The Barrett reduction algorithm \cite{BARRETT} was inspired by fast division algorithms which multiply by the reciprocal to emulate
-division. Barretts observation was that the residue $c$ of $a$ modulo $b$ is equal to
-
-\begin{equation}
-c = a - b \cdot \lfloor a/b \rfloor
-\end{equation}
-
-Since algorithms such as modular exponentiation would be using the same modulus extensively, typical DSP\footnote{It is worth noting that Barrett's paper
-targeted the DSP56K processor.} intuition would indicate the next step would be to replace $a/b$ by a multiplication by the reciprocal. However,
-DSP intuition on its own will not work as these numbers are considerably larger than the precision of common DSP floating point data types.
-It would take another common optimization to optimize the algorithm.
-
-\subsection{Fixed Point Arithmetic}
-The trick used to optimize the above equation is based on a technique of emulating floating point data types with fixed precision integers. Fixed
-point arithmetic would become very popular as it greatly optimize the ``3d-shooter'' genre of games in the mid 1990s when floating point units were
-fairly slow if not unavailable. The idea behind fixed point arithmetic is to take a normal $k$-bit integer data type and break it into $p$-bit
-integer and a $q$-bit fraction part (\textit{where $p+q = k$}).
-
-In this system a $k$-bit integer $n$ would actually represent $n/2^q$. For example, with $q = 4$ the integer $n = 37$ would actually represent the
-value $2.3125$. To multiply two fixed point numbers the integers are multiplied using traditional arithmetic and subsequently normalized by
-moving the implied decimal point back to where it should be. For example, with $q = 4$ to multiply the integers $9$ and $5$ they must be converted
-to fixed point first by multiplying by $2^q$. Let $a = 9(2^q)$ represent the fixed point representation of $9$ and $b = 5(2^q)$ represent the
-fixed point representation of $5$. The product $ab$ is equal to $45(2^{2q})$ which when normalized by dividing by $2^q$ produces $45(2^q)$.
-
-This technique became popular since a normal integer multiplication and logical shift right are the only required operations to perform a multiplication
-of two fixed point numbers. Using fixed point arithmetic, division can be easily approximated by multiplying by the reciprocal. If $2^q$ is
-equivalent to one than $2^q/b$ is equivalent to the fixed point approximation of $1/b$ using real arithmetic. Using this fact dividing an integer
-$a$ by another integer $b$ can be achieved with the following expression.
-
-\begin{equation}
-\lfloor a / b \rfloor \mbox{ }\approx\mbox{ } \lfloor (a \cdot \lfloor 2^q / b \rfloor)/2^q \rfloor
-\end{equation}
-
-The precision of the division is proportional to the value of $q$. If the divisor $b$ is used frequently as is the case with
-modular exponentiation pre-computing $2^q/b$ will allow a division to be performed with a multiplication and a right shift. Both operations
-are considerably faster than division on most processors.
-
-Consider dividing $19$ by $5$. The correct result is $\lfloor 19/5 \rfloor = 3$. With $q = 3$ the reciprocal is $\lfloor 2^q/5 \rfloor = 1$ which
-leads to a product of $19$ which when divided by $2^q$ produces $2$. However, with $q = 4$ the reciprocal is $\lfloor 2^q/5 \rfloor = 3$ and
-the result of the emulated division is $\lfloor 3 \cdot 19 / 2^q \rfloor = 3$ which is correct. The value of $2^q$ must be close to or ideally
-larger than the dividend. In effect if $a$ is the dividend then $q$ should allow $0 \le \lfloor a/2^q \rfloor \le 1$ in order for this approach
-to work correctly. Plugging this form of divison into the original equation the following modular residue equation arises.
-
-\begin{equation}
-c = a - b \cdot \lfloor (a \cdot \lfloor 2^q / b \rfloor)/2^q \rfloor
-\end{equation}
-
-Using the notation from \cite{BARRETT} the value of $\lfloor 2^q / b \rfloor$ will be represented by the $\mu$ symbol. Using the $\mu$
-variable also helps re-inforce the idea that it is meant to be computed once and re-used.
-
-\begin{equation}
-c = a - b \cdot \lfloor (a \cdot \mu)/2^q \rfloor
-\end{equation}
-
-Provided that $2^q \ge a$ this algorithm will produce a quotient that is either exactly correct or off by a value of one. In the context of Barrett
-reduction the value of $a$ is bound by $0 \le a \le (b - 1)^2$ meaning that $2^q \ge b^2$ is sufficient to ensure the reciprocal will have enough
-precision.
-
-Let $n$ represent the number of digits in $b$. This algorithm requires approximately $2n^2$ single precision multiplications to produce the quotient and
-another $n^2$ single precision multiplications to find the residue. In total $3n^2$ single precision multiplications are required to
-reduce the number.
-
-For example, if $b = 1179677$ and $q = 41$ ($2^q > b^2$), then the reciprocal $\mu$ is equal to $\lfloor 2^q / b \rfloor = 1864089$. Consider reducing
-$a = 180388626447$ modulo $b$ using the above reduction equation. The quotient using the new formula is $\lfloor (a \cdot \mu) / 2^q \rfloor = 152913$.
-By subtracting $152913b$ from $a$ the correct residue $a \equiv 677346 \mbox{ (mod }b\mbox{)}$ is found.
-
-\subsection{Choosing a Radix Point}
-Using the fixed point representation a modular reduction can be performed with $3n^2$ single precision multiplications. If that were the best
-that could be achieved a full division\footnote{A division requires approximately $O(2cn^2)$ single precision multiplications for a small value of $c$.
-See~\ref{sec:division} for further details.} might as well be used in its place. The key to optimizing the reduction is to reduce the precision of
-the initial multiplication that finds the quotient.
-
-Let $a$ represent the number of which the residue is sought. Let $b$ represent the modulus used to find the residue. Let $m$ represent
-the number of digits in $b$. For the purposes of this discussion we will assume that the number of digits in $a$ is $2m$, which is generally true if
-two $m$-digit numbers have been multiplied. Dividing $a$ by $b$ is the same as dividing a $2m$ digit integer by a $m$ digit integer. Digits below the
-$m - 1$'th digit of $a$ will contribute at most a value of $1$ to the quotient because $\beta^k < b$ for any $0 \le k \le m - 1$. Another way to
-express this is by re-writing $a$ as two parts. If $a' \equiv a \mbox{ (mod }b^m\mbox{)}$ and $a'' = a - a'$ then
-${a \over b} \equiv {{a' + a''} \over b}$ which is equivalent to ${a' \over b} + {a'' \over b}$. Since $a'$ is bound to be less than $b$ the quotient
-is bound by $0 \le {a' \over b} < 1$.
-
-Since the digits of $a'$ do not contribute much to the quotient the observation is that they might as well be zero. However, if the digits
-``might as well be zero'' they might as well not be there in the first place. Let $q_0 = \lfloor a/\beta^{m-1} \rfloor$ represent the input
-with the irrelevant digits trimmed. Now the modular reduction is trimmed to the almost equivalent equation
-
-\begin{equation}
-c = a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor
-\end{equation}
-
-Note that the original divisor $2^q$ has been replaced with $\beta^{m+1}$ where in this case $q$ is a multiple of $lg(\beta)$. Also note that the
-exponent on the divisor when added to the amount $q_0$ was shifted by equals $2m$. If the optimization had not been performed the divisor
-would have the exponent $2m$ so in the end the exponents do ``add up''. Using the above equation the quotient
-$\lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ can be off from the true quotient by at most two. The original fixed point quotient can be off
-by as much as one (\textit{provided the radix point is chosen suitably}) and now that the lower irrelevent digits have been trimmed the quotient
-can be off by an additional value of one for a total of at most two. This implies that
-$0 \le a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor < 3b$. By first subtracting $b$ times the quotient and then conditionally subtracting
-$b$ once or twice the residue is found.
-
-The quotient is now found using $(m + 1)(m) = m^2 + m$ single precision multiplications and the residue with an additional $m^2$ single
-precision multiplications, ignoring the subtractions required. In total $2m^2 + m$ single precision multiplications are required to find the residue.
-This is considerably faster than the original attempt.
-
-For example, let $\beta = 10$ represent the radix of the digits. Let $b = 9999$ represent the modulus which implies $m = 4$. Let $a = 99929878$
-represent the value of which the residue is desired. In this case $q = 8$ since $10^7 < 9999^2$ meaning that $\mu = \lfloor \beta^{q}/b \rfloor = 10001$.
-With the new observation the multiplicand for the quotient is equal to $q_0 = \lfloor a / \beta^{m - 1} \rfloor = 99929$. The quotient is then
-$\lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor = 9993$. Subtracting $9993b$ from $a$ and the correct residue $a \equiv 9871 \mbox{ (mod }b\mbox{)}$
-is found.
-
-\subsection{Trimming the Quotient}
-So far the reduction algorithm has been optimized from $3m^2$ single precision multiplications down to $2m^2 + m$ single precision multiplications. As
-it stands now the algorithm is already fairly fast compared to a full integer division algorithm. However, there is still room for
-optimization.
-
-After the first multiplication inside the quotient ($q_0 \cdot \mu$) the value is shifted right by $m + 1$ places effectively nullifying the lower
-half of the product. It would be nice to be able to remove those digits from the product to effectively cut down the number of single precision
-multiplications. If the number of digits in the modulus $m$ is far less than $\beta$ a full product is not required for the algorithm to work properly.
-In fact the lower $m - 2$ digits will not affect the upper half of the product at all and do not need to be computed.
-
-The value of $\mu$ is a $m$-digit number and $q_0$ is a $m + 1$ digit number. Using a full multiplier $(m + 1)(m) = m^2 + m$ single precision
-multiplications would be required. Using a multiplier that will only produce digits at and above the $m - 1$'th digit reduces the number
-of single precision multiplications to ${m^2 + m} \over 2$ single precision multiplications.
-
-\subsection{Trimming the Residue}
-After the quotient has been calculated it is used to reduce the input. As previously noted the algorithm is not exact and it can be off by a small
-multiple of the modulus, that is $0 \le a - b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor < 3b$. If $b$ is $m$ digits than the
-result of reduction equation is a value of at most $m + 1$ digits (\textit{provided $3 < \beta$}) implying that the upper $m - 1$ digits are
-implicitly zero.
-
-The next optimization arises from this very fact. Instead of computing $b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ using a full
-$O(m^2)$ multiplication algorithm only the lower $m+1$ digits of the product have to be computed. Similarly the value of $a$ can
-be reduced modulo $\beta^{m+1}$ before the multiple of $b$ is subtracted which simplifes the subtraction as well. A multiplication that produces
-only the lower $m+1$ digits requires ${m^2 + 3m - 2} \over 2$ single precision multiplications.
-
-With both optimizations in place the algorithm is the algorithm Barrett proposed. It requires $m^2 + 2m - 1$ single precision multiplications which
-is considerably faster than the straightforward $3m^2$ method.
-
-\subsection{The Barrett Algorithm}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce}. \\
-\textbf{Input}. mp\_int $a$, mp\_int $b$ and $\mu = \lfloor \beta^{2m}/b \rfloor, m = \lceil lg_{\beta}(b) \rceil, (0 \le a < b^2, b > 1)$ \\
-\textbf{Output}. $a \mbox{ (mod }b\mbox{)}$ \\
-\hline \\
-Let $m$ represent the number of digits in $b$. \\
-1. Make a copy of $a$ and store it in $q$. (\textit{mp\_init\_copy}) \\
-2. $q \leftarrow \lfloor q / \beta^{m - 1} \rfloor$ (\textit{mp\_rshd}) \\
-\\
-Produce the quotient. \\
-3. $q \leftarrow q \cdot \mu$ (\textit{note: only produce digits at or above $m-1$}) \\
-4. $q \leftarrow \lfloor q / \beta^{m + 1} \rfloor$ \\
-\\
-Subtract the multiple of modulus from the input. \\
-5. $a \leftarrow a \mbox{ (mod }\beta^{m+1}\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-6. $q \leftarrow q \cdot b \mbox{ (mod }\beta^{m+1}\mbox{)}$ (\textit{s\_mp\_mul\_digs}) \\
-7. $a \leftarrow a - q$ (\textit{mp\_sub}) \\
-\\
-Add $\beta^{m+1}$ if a carry occured. \\
-8. If $a < 0$ then (\textit{mp\_cmp\_d}) \\
-\hspace{3mm}8.1 $q \leftarrow 1$ (\textit{mp\_set}) \\
-\hspace{3mm}8.2 $q \leftarrow q \cdot \beta^{m+1}$ (\textit{mp\_lshd}) \\
-\hspace{3mm}8.3 $a \leftarrow a + q$ \\
-\\
-Now subtract the modulus if the residue is too large (e.g. quotient too small). \\
-9. While $a \ge b$ do (\textit{mp\_cmp}) \\
-\hspace{3mm}9.1 $c \leftarrow a - b$ \\
-10. Clear $q$. \\
-11. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce.}
-This algorithm will reduce the input $a$ modulo $b$ in place using the Barrett algorithm. It is loosely based on algorithm 14.42 of HAC
-\cite[pp. 602]{HAC} which is based on the paper from Paul Barrett \cite{BARRETT}. The algorithm has several restrictions and assumptions which must
-be adhered to for the algorithm to work.
-
-First the modulus $b$ is assumed to be positive and greater than one. If the modulus were less than or equal to one than subtracting
-a multiple of it would either accomplish nothing or actually enlarge the input. The input $a$ must be in the range $0 \le a < b^2$ in order
-for the quotient to have enough precision. If $a$ is the product of two numbers that were already reduced modulo $b$, this will not be a problem.
-Technically the algorithm will still work if $a \ge b^2$ but it will take much longer to finish. The value of $\mu$ is passed as an argument to this
-algorithm and is assumed to be calculated and stored before the algorithm is used.
-
-Recall that the multiplication for the quotient on step 3 must only produce digits at or above the $m-1$'th position. An algorithm called
-$s\_mp\_mul\_high\_digs$ which has not been presented is used to accomplish this task. The algorithm is based on $s\_mp\_mul\_digs$ except that
-instead of stopping at a given level of precision it starts at a given level of precision. This optimal algorithm can only be used if the number
-of digits in $b$ is very much smaller than $\beta$.
-
-While it is known that
-$a \ge b \cdot \lfloor (q_0 \cdot \mu) / \beta^{m+1} \rfloor$ only the lower $m+1$ digits are being used to compute the residue, so an implied
-``borrow'' from the higher digits might leave a negative result. After the multiple of the modulus has been subtracted from $a$ the residue must be
-fixed up in case it is negative. The invariant $\beta^{m+1}$ must be added to the residue to make it positive again.
-
-The while loop at step 9 will subtract $b$ until the residue is less than $b$. If the algorithm is performed correctly this step is
-performed at most twice, and on average once. However, if $a \ge b^2$ than it will iterate substantially more times than it should.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_reduce.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The first multiplication that determines the quotient can be performed by only producing the digits from $m - 1$ and up. This essentially halves
-the number of single precision multiplications required. However, the optimization is only safe if $\beta$ is much larger than the number of digits
-in the modulus. In the source code this is evaluated on lines 36 to 44 where algorithm s\_mp\_mul\_high\_digs is used when it is
-safe to do so.
-
-\subsection{The Barrett Setup Algorithm}
-In order to use algorithm mp\_reduce the value of $\mu$ must be calculated in advance. Ideally this value should be computed once and stored for
-future use so that the Barrett algorithm can be used without delay.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_setup}. \\
-\textbf{Input}. mp\_int $a$ ($a > 1$) \\
-\textbf{Output}. $\mu \leftarrow \lfloor \beta^{2m}/a \rfloor$ \\
-\hline \\
-1. $\mu \leftarrow 2^{2 \cdot lg(\beta) \cdot m}$ (\textit{mp\_2expt}) \\
-2. $\mu \leftarrow \lfloor \mu / b \rfloor$ (\textit{mp\_div}) \\
-3. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_setup.}
-This algorithm computes the reciprocal $\mu$ required for Barrett reduction. First $\beta^{2m}$ is calculated as $2^{2 \cdot lg(\beta) \cdot m}$ which
-is equivalent and much faster. The final value is computed by taking the integer quotient of $\lfloor \mu / b \rfloor$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_reduce\_setup.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This simple routine calculates the reciprocal $\mu$ required by Barrett reduction. Note the extended usage of algorithm mp\_div where the variable
-which would received the remainder is passed as NULL. As will be discussed in~\ref{sec:division} the division routine allows both the quotient and the
-remainder to be passed as NULL meaning to ignore the value.
-
-\section{The Montgomery Reduction}
-Montgomery reduction\footnote{Thanks to Niels Ferguson for his insightful explanation of the algorithm.} \cite{MONT} is by far the most interesting
-form of reduction in common use. It computes a modular residue which is not actually equal to the residue of the input yet instead equal to a
-residue times a constant. However, as perplexing as this may sound the algorithm is relatively simple and very efficient.
-
-Throughout this entire section the variable $n$ will represent the modulus used to form the residue. As will be discussed shortly the value of
-$n$ must be odd. The variable $x$ will represent the quantity of which the residue is sought. Similar to the Barrett algorithm the input
-is restricted to $0 \le x < n^2$. To begin the description some simple number theory facts must be established.
-
-\textbf{Fact 1.} Adding $n$ to $x$ does not change the residue since in effect it adds one to the quotient $\lfloor x / n \rfloor$. Another way
-to explain this is that $n$ is (\textit{or multiples of $n$ are}) congruent to zero modulo $n$. Adding zero will not change the value of the residue.
-
-\textbf{Fact 2.} If $x$ is even then performing a division by two in $\Z$ is congruent to $x \cdot 2^{-1} \mbox{ (mod }n\mbox{)}$. Actually
-this is an application of the fact that if $x$ is evenly divisible by any $k \in \Z$ then division in $\Z$ will be congruent to
-multiplication by $k^{-1}$ modulo $n$.
-
-From these two simple facts the following simple algorithm can be derived.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction}. \\
-\textbf{Input}. Integer $x$, $n$ and $k$ \\
-\textbf{Output}. $2^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $1$ to $k$ do \\
-\hspace{3mm}1.1 If $x$ is odd then \\
-\hspace{6mm}1.1.1 $x \leftarrow x + n$ \\
-\hspace{3mm}1.2 $x \leftarrow x/2$ \\
-2. Return $x$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction}
-\end{figure}
-
-The algorithm reduces the input one bit at a time using the two congruencies stated previously. Inside the loop $n$, which is odd, is
-added to $x$ if $x$ is odd. This forces $x$ to be even which allows the division by two in $\Z$ to be congruent to a modular division by two. Since
-$x$ is assumed to be initially much larger than $n$ the addition of $n$ will contribute an insignificant magnitude to $x$. Let $r$ represent the
-final result of the Montgomery algorithm. If $k > lg(n)$ and $0 \le x < n^2$ then the final result is limited to
-$0 \le r < \lfloor x/2^k \rfloor + n$. As a result at most a single subtraction is required to get the residue desired.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|l|}
-\hline \textbf{Step number ($t$)} & \textbf{Result ($x$)} \\
-\hline $1$ & $x + n = 5812$, $x/2 = 2906$ \\
-\hline $2$ & $x/2 = 1453$ \\
-\hline $3$ & $x + n = 1710$, $x/2 = 855$ \\
-\hline $4$ & $x + n = 1112$, $x/2 = 556$ \\
-\hline $5$ & $x/2 = 278$ \\
-\hline $6$ & $x/2 = 139$ \\
-\hline $7$ & $x + n = 396$, $x/2 = 198$ \\
-\hline $8$ & $x/2 = 99$ \\
-\hline $9$ & $x + n = 356$, $x/2 = 178$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example of Montgomery Reduction (I)}
-\label{fig:MONT1}
-\end{figure}
-
-Consider the example in figure~\ref{fig:MONT1} which reduces $x = 5555$ modulo $n = 257$ when $k = 9$ (note $\beta^k = 512$ which is larger than $n$). The result of
-the algorithm $r = 178$ is congruent to the value of $2^{-9} \cdot 5555 \mbox{ (mod }257\mbox{)}$. When $r$ is multiplied by $2^9$ modulo $257$ the correct residue
-$r \equiv 158$ is produced.
-
-Let $k = \lfloor lg(n) \rfloor + 1$ represent the number of bits in $n$. The current algorithm requires $2k^2$ single precision shifts
-and $k^2$ single precision additions. At this rate the algorithm is most certainly slower than Barrett reduction and not terribly useful.
-Fortunately there exists an alternative representation of the algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction} (modified I). \\
-\textbf{Input}. Integer $x$, $n$ and $k$ ($2^k > n$) \\
-\textbf{Output}. $2^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $1$ to $k$ do \\
-\hspace{3mm}1.1 If the $t$'th bit of $x$ is one then \\
-\hspace{6mm}1.1.1 $x \leftarrow x + 2^tn$ \\
-2. Return $x/2^k$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction (modified I)}
-\end{figure}
-
-This algorithm is equivalent since $2^tn$ is a multiple of $n$ and the lower $k$ bits of $x$ are zero by step 2. The number of single
-precision shifts has now been reduced from $2k^2$ to $k^2 + k$ which is only a small improvement.
-
-\begin{figure}[here]
-\begin{small}
-\begin{center}
-\begin{tabular}{|c|l|r|}
-\hline \textbf{Step number ($t$)} & \textbf{Result ($x$)} & \textbf{Result ($x$) in Binary} \\
-\hline -- & $5555$ & $1010110110011$ \\
-\hline $1$ & $x + 2^{0}n = 5812$ & $1011010110100$ \\
-\hline $2$ & $5812$ & $1011010110100$ \\
-\hline $3$ & $x + 2^{2}n = 6840$ & $1101010111000$ \\
-\hline $4$ & $x + 2^{3}n = 8896$ & $10001011000000$ \\
-\hline $5$ & $8896$ & $10001011000000$ \\
-\hline $6$ & $8896$ & $10001011000000$ \\
-\hline $7$ & $x + 2^{6}n = 25344$ & $110001100000000$ \\
-\hline $8$ & $25344$ & $110001100000000$ \\
-\hline $9$ & $x + 2^{7}n = 91136$ & $10110010000000000$ \\
-\hline -- & $x/2^k = 178$ & \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example of Montgomery Reduction (II)}
-\label{fig:MONT2}
-\end{figure}
-
-Figure~\ref{fig:MONT2} demonstrates the modified algorithm reducing $x = 5555$ modulo $n = 257$ with $k = 9$.
-With this algorithm a single shift right at the end is the only right shift required to reduce the input instead of $k$ right shifts inside the
-loop. Note that for the iterations $t = 2, 5, 6$ and $8$ where the result $x$ is not changed. In those iterations the $t$'th bit of $x$ is
-zero and the appropriate multiple of $n$ does not need to be added to force the $t$'th bit of the result to zero.
-
-\subsection{Digit Based Montgomery Reduction}
-Instead of computing the reduction on a bit-by-bit basis it is actually much faster to compute it on digit-by-digit basis. Consider the
-previous algorithm re-written to compute the Montgomery reduction in this new fashion.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Montgomery Reduction} (modified II). \\
-\textbf{Input}. Integer $x$, $n$ and $k$ ($\beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. for $t$ from $0$ to $k - 1$ do \\
-\hspace{3mm}1.1 $x \leftarrow x + \mu n \beta^t$ \\
-2. Return $x/\beta^k$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Montgomery Reduction (modified II)}
-\end{figure}
-
-The value $\mu n \beta^t$ is a multiple of the modulus $n$ meaning that it will not change the residue. If the first digit of
-the value $\mu n \beta^t$ equals the negative (modulo $\beta$) of the $t$'th digit of $x$ then the addition will result in a zero digit. This
-problem breaks down to solving the following congruency.
-
-\begin{center}
-\begin{tabular}{rcl}
-$x_t + \mu n_0$ & $\equiv$ & $0 \mbox{ (mod }\beta\mbox{)}$ \\
-$\mu n_0$ & $\equiv$ & $-x_t \mbox{ (mod }\beta\mbox{)}$ \\
-$\mu$ & $\equiv$ & $-x_t/n_0 \mbox{ (mod }\beta\mbox{)}$ \\
-\end{tabular}
-\end{center}
-
-In each iteration of the loop on step 1 a new value of $\mu$ must be calculated. The value of $-1/n_0 \mbox{ (mod }\beta\mbox{)}$ is used
-extensively in this algorithm and should be precomputed. Let $\rho$ represent the negative of the modular inverse of $n_0$ modulo $\beta$.
-
-For example, let $\beta = 10$ represent the radix. Let $n = 17$ represent the modulus which implies $k = 2$ and $\rho \equiv 7$. Let $x = 33$
-represent the value to reduce.
-
-\newpage\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Step ($t$)} & \textbf{Value of $x$} & \textbf{Value of $\mu$} \\
-\hline -- & $33$ & --\\
-\hline $0$ & $33 + \mu n = 50$ & $1$ \\
-\hline $1$ & $50 + \mu n \beta = 900$ & $5$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Montgomery Reduction}
-\end{figure}
-
-The final result $900$ is then divided by $\beta^k$ to produce the final result $9$. The first observation is that $9 \nequiv x \mbox{ (mod }n\mbox{)}$
-which implies the result is not the modular residue of $x$ modulo $n$. However, recall that the residue is actually multiplied by $\beta^{-k}$ in
-the algorithm. To get the true residue the value must be multiplied by $\beta^k$. In this case $\beta^k \equiv 15 \mbox{ (mod }n\mbox{)}$ and
-the correct residue is $9 \cdot 15 \equiv 16 \mbox{ (mod }n\mbox{)}$.
-
-\subsection{Baseline Montgomery Reduction}
-The baseline Montgomery reduction algorithm will produce the residue for any size input. It is designed to be a catch-all algororithm for
-Montgomery reductions.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_montgomery\_reduce}. \\
-\textbf{Input}. mp\_int $x$, mp\_int $n$ and a digit $\rho \equiv -1/n_0 \mbox{ (mod }n\mbox{)}$. \\
-\hspace{11.5mm}($0 \le x < n^2, n > 1, (n, \beta) = 1, \beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-1. $digs \leftarrow 2n.used + 1$ \\
-2. If $digs < MP\_ARRAY$ and $m.used < \delta$ then \\
-\hspace{3mm}2.1 Use algorithm fast\_mp\_montgomery\_reduce instead. \\
-\\
-Setup $x$ for the reduction. \\
-3. If $x.alloc < digs$ then grow $x$ to $digs$ digits. \\
-4. $x.used \leftarrow digs$ \\
-\\
-Eliminate the lower $k$ digits. \\
-5. For $ix$ from $0$ to $k - 1$ do \\
-\hspace{3mm}5.1 $\mu \leftarrow x_{ix} \cdot \rho \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}5.2 $u \leftarrow 0$ \\
-\hspace{3mm}5.3 For $iy$ from $0$ to $k - 1$ do \\
-\hspace{6mm}5.3.1 $\hat r \leftarrow \mu n_{iy} + x_{ix + iy} + u$ \\
-\hspace{6mm}5.3.2 $x_{ix + iy} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{6mm}5.3.3 $u \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-\hspace{3mm}5.4 While $u > 0$ do \\
-\hspace{6mm}5.4.1 $iy \leftarrow iy + 1$ \\
-\hspace{6mm}5.4.2 $x_{ix + iy} \leftarrow x_{ix + iy} + u$ \\
-\hspace{6mm}5.4.3 $u \leftarrow \lfloor x_{ix+iy} / \beta \rfloor$ \\
-\hspace{6mm}5.4.4 $x_{ix + iy} \leftarrow x_{ix+iy} \mbox{ (mod }\beta\mbox{)}$ \\
-\\
-Divide by $\beta^k$ and fix up as required. \\
-6. $x \leftarrow \lfloor x / \beta^k \rfloor$ \\
-7. If $x \ge n$ then \\
-\hspace{3mm}7.1 $x \leftarrow x - n$ \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_montgomery\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_montgomery\_reduce.}
-This algorithm reduces the input $x$ modulo $n$ in place using the Montgomery reduction algorithm. The algorithm is loosely based
-on algorithm 14.32 of \cite[pp.601]{HAC} except it merges the multiplication of $\mu n \beta^t$ with the addition in the inner loop. The
-restrictions on this algorithm are fairly easy to adapt to. First $0 \le x < n^2$ bounds the input to numbers in the same range as
-for the Barrett algorithm. Additionally if $n > 1$ and $n$ is odd there will exist a modular inverse $\rho$. $\rho$ must be calculated in
-advance of this algorithm. Finally the variable $k$ is fixed and a pseudonym for $n.used$.
-
-Step 2 decides whether a faster Montgomery algorithm can be used. It is based on the Comba technique meaning that there are limits on
-the size of the input. This algorithm is discussed in sub-section 6.3.3.
-
-Step 5 is the main reduction loop of the algorithm. The value of $\mu$ is calculated once per iteration in the outer loop. The inner loop
-calculates $x + \mu n \beta^{ix}$ by multiplying $\mu n$ and adding the result to $x$ shifted by $ix$ digits. Both the addition and
-multiplication are performed in the same loop to save time and memory. Step 5.4 will handle any additional carries that escape the inner loop.
-
-Using a quick inspection this algorithm requires $n$ single precision multiplications for the outer loop and $n^2$ single precision multiplications
-in the inner loop. In total $n^2 + n$ single precision multiplications which compares favourably to Barrett at $n^2 + 2n - 1$ single precision
-multiplications.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_montgomery\_reduce.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This is the baseline implementation of the Montgomery reduction algorithm. Lines 31 to 36 determine if the Comba based
-routine can be used instead. Line 47 computes the value of $\mu$ for that particular iteration of the outer loop.
-
-The multiplication $\mu n \beta^{ix}$ is performed in one step in the inner loop. The alias $tmpx$ refers to the $ix$'th digit of $x$ and
-the alias $tmpn$ refers to the modulus $n$.
-
-\subsection{Faster ``Comba'' Montgomery Reduction}
-
-The Montgomery reduction requires fewer single precision multiplications than a Barrett reduction, however it is much slower due to the serial
-nature of the inner loop. The Barrett reduction algorithm requires two slightly modified multipliers which can be implemented with the Comba
-technique. The Montgomery reduction algorithm cannot directly use the Comba technique to any significant advantage since the inner loop calculates
-a $k \times 1$ product $k$ times.
-
-The biggest obstacle is that at the $ix$'th iteration of the outer loop the value of $x_{ix}$ is required to calculate $\mu$. This means the
-carries from $0$ to $ix - 1$ must have been propagated upwards to form a valid $ix$'th digit. The solution as it turns out is very simple.
-Perform a Comba like multiplier and inside the outer loop just after the inner loop fix up the $ix + 1$'th digit by forwarding the carry.
-
-With this change in place the Montgomery reduction algorithm can be performed with a Comba style multiplication loop which substantially increases
-the speed of the algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{fast\_mp\_montgomery\_reduce}. \\
-\textbf{Input}. mp\_int $x$, mp\_int $n$ and a digit $\rho \equiv -1/n_0 \mbox{ (mod }n\mbox{)}$. \\
-\hspace{11.5mm}($0 \le x < n^2, n > 1, (n, \beta) = 1, \beta^k > n$) \\
-\textbf{Output}. $\beta^{-k}x \mbox{ (mod }n\mbox{)}$ \\
-\hline \\
-Place an array of \textbf{MP\_WARRAY} mp\_word variables called $\hat W$ on the stack. \\
-1. if $x.alloc < n.used + 1$ then grow $x$ to $n.used + 1$ digits. \\
-Copy the digits of $x$ into the array $\hat W$ \\
-2. For $ix$ from $0$ to $x.used - 1$ do \\
-\hspace{3mm}2.1 $\hat W_{ix} \leftarrow x_{ix}$ \\
-3. For $ix$ from $x.used$ to $2n.used - 1$ do \\
-\hspace{3mm}3.1 $\hat W_{ix} \leftarrow 0$ \\
-Elimiate the lower $k$ digits. \\
-4. for $ix$ from $0$ to $n.used - 1$ do \\
-\hspace{3mm}4.1 $\mu \leftarrow \hat W_{ix} \cdot \rho \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}4.2 For $iy$ from $0$ to $n.used - 1$ do \\
-\hspace{6mm}4.2.1 $\hat W_{iy + ix} \leftarrow \hat W_{iy + ix} + \mu \cdot n_{iy}$ \\
-\hspace{3mm}4.3 $\hat W_{ix + 1} \leftarrow \hat W_{ix + 1} + \lfloor \hat W_{ix} / \beta \rfloor$ \\
-Propagate carries upwards. \\
-5. for $ix$ from $n.used$ to $2n.used + 1$ do \\
-\hspace{3mm}5.1 $\hat W_{ix + 1} \leftarrow \hat W_{ix + 1} + \lfloor \hat W_{ix} / \beta \rfloor$ \\
-Shift right and reduce modulo $\beta$ simultaneously. \\
-6. for $ix$ from $0$ to $n.used + 1$ do \\
-\hspace{3mm}6.1 $x_{ix} \leftarrow \hat W_{ix + n.used} \mbox{ (mod }\beta\mbox{)}$ \\
-Zero excess digits and fixup $x$. \\
-7. if $x.used > n.used + 1$ then do \\
-\hspace{3mm}7.1 for $ix$ from $n.used + 1$ to $x.used - 1$ do \\
-\hspace{6mm}7.1.1 $x_{ix} \leftarrow 0$ \\
-8. $x.used \leftarrow n.used + 1$ \\
-9. Clamp excessive digits of $x$. \\
-10. If $x \ge n$ then \\
-\hspace{3mm}10.1 $x \leftarrow x - n$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm fast\_mp\_montgomery\_reduce}
-\end{figure}
-
-\textbf{Algorithm fast\_mp\_montgomery\_reduce.}
-This algorithm will compute the Montgomery reduction of $x$ modulo $n$ using the Comba technique. It is on most computer platforms significantly
-faster than algorithm mp\_montgomery\_reduce and algorithm mp\_reduce (\textit{Barrett reduction}). The algorithm has the same restrictions
-on the input as the baseline reduction algorithm. An additional two restrictions are imposed on this algorithm. The number of digits $k$ in the
-the modulus $n$ must not violate $MP\_WARRAY > 2k +1$ and $n < \delta$. When $\beta = 2^{28}$ this algorithm can be used to reduce modulo
-a modulus of at most $3,556$ bits in length.
-
-As in the other Comba reduction algorithms there is a $\hat W$ array which stores the columns of the product. It is initially filled with the
-contents of $x$ with the excess digits zeroed. The reduction loop is very similar the to the baseline loop at heart. The multiplication on step
-4.1 can be single precision only since $ab \mbox{ (mod }\beta\mbox{)} \equiv (a \mbox{ mod }\beta)(b \mbox{ mod }\beta)$. Some multipliers such
-as those on the ARM processors take a variable length time to complete depending on the number of bytes of result it must produce. By performing
-a single precision multiplication instead half the amount of time is spent.
-
-Also note that digit $\hat W_{ix}$ must have the carry from the $ix - 1$'th digit propagated upwards in order for this to work. That is what step
-4.3 will do. In effect over the $n.used$ iterations of the outer loop the $n.used$'th lower columns all have the their carries propagated forwards. Note
-how the upper bits of those same words are not reduced modulo $\beta$. This is because those values will be discarded shortly and there is no
-point.
-
-Step 5 will propagate the remainder of the carries upwards. On step 6 the columns are reduced modulo $\beta$ and shifted simultaneously as they are
-stored in the destination $x$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_fast\_mp\_montgomery\_reduce.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The $\hat W$ array is first filled with digits of $x$ on line 48 then the rest of the digits are zeroed on line 55. Both loops share
-the same alias variables to make the code easier to read.
-
-The value of $\mu$ is calculated in an interesting fashion. First the value $\hat W_{ix}$ is reduced modulo $\beta$ and cast to a mp\_digit. This
-forces the compiler to use a single precision multiplication and prevents any concerns about loss of precision. Line 110 fixes the carry
-for the next iteration of the loop by propagating the carry from $\hat W_{ix}$ to $\hat W_{ix+1}$.
-
-The for loop on line 109 propagates the rest of the carries upwards through the columns. The for loop on line 126 reduces the columns
-modulo $\beta$ and shifts them $k$ places at the same time. The alias $\_ \hat W$ actually refers to the array $\hat W$ starting at the $n.used$'th
-digit, that is $\_ \hat W_{t} = \hat W_{n.used + t}$.
-
-\subsection{Montgomery Setup}
-To calculate the variable $\rho$ a relatively simple algorithm will be required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_montgomery\_setup}. \\
-\textbf{Input}. mp\_int $n$ ($n > 1$ and $(n, 2) = 1$) \\
-\textbf{Output}. $\rho \equiv -1/n_0 \mbox{ (mod }\beta\mbox{)}$ \\
-\hline \\
-1. $b \leftarrow n_0$ \\
-2. If $b$ is even return(\textit{MP\_VAL}) \\
-3. $x \leftarrow (((b + 2) \mbox{ AND } 4) << 1) + b$ \\
-4. for $k$ from 0 to $\lceil lg(lg(\beta)) \rceil - 2$ do \\
-\hspace{3mm}4.1 $x \leftarrow x \cdot (2 - bx)$ \\
-5. $\rho \leftarrow \beta - x \mbox{ (mod }\beta\mbox{)}$ \\
-6. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_montgomery\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_montgomery\_setup.}
-This algorithm will calculate the value of $\rho$ required within the Montgomery reduction algorithms. It uses a very interesting trick
-to calculate $1/n_0$ when $\beta$ is a power of two.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_montgomery\_setup.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This source code computes the value of $\rho$ required to perform Montgomery reduction. It has been modified to avoid performing excess
-multiplications when $\beta$ is not the default 28-bits.
-
-\section{The Diminished Radix Algorithm}
-The Diminished Radix method of modular reduction \cite{DRMET} is a fairly clever technique which can be more efficient than either the Barrett
-or Montgomery methods for certain forms of moduli. The technique is based on the following simple congruence.
-
-\begin{equation}
-(x \mbox{ mod } n) + k \lfloor x / n \rfloor \equiv x \mbox{ (mod }(n - k)\mbox{)}
-\end{equation}
-
-This observation was used in the MMB \cite{MMB} block cipher to create a diffusion primitive. It used the fact that if $n = 2^{31}$ and $k=1$ that
-then a x86 multiplier could produce the 62-bit product and use the ``shrd'' instruction to perform a double-precision right shift. The proof
-of the above equation is very simple. First write $x$ in the product form.
-
-\begin{equation}
-x = qn + r
-\end{equation}
-
-Now reduce both sides modulo $(n - k)$.
-
-\begin{equation}
-x \equiv qk + r \mbox{ (mod }(n-k)\mbox{)}
-\end{equation}
-
-The variable $n$ reduces modulo $n - k$ to $k$. By putting $q = \lfloor x/n \rfloor$ and $r = x \mbox{ mod } n$
-into the equation the original congruence is reproduced, thus concluding the proof. The following algorithm is based on this observation.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Diminished Radix Reduction}. \\
-\textbf{Input}. Integer $x$, $n$, $k$ \\
-\textbf{Output}. $x \mbox{ mod } (n - k)$ \\
-\hline \\
-1. $q \leftarrow \lfloor x / n \rfloor$ \\
-2. $q \leftarrow k \cdot q$ \\
-3. $x \leftarrow x \mbox{ (mod }n\mbox{)}$ \\
-4. $x \leftarrow x + q$ \\
-5. If $x \ge (n - k)$ then \\
-\hspace{3mm}5.1 $x \leftarrow x - (n - k)$ \\
-\hspace{3mm}5.2 Goto step 1. \\
-6. Return $x$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Diminished Radix Reduction}
-\label{fig:DR}
-\end{figure}
-
-This algorithm will reduce $x$ modulo $n - k$ and return the residue. If $0 \le x < (n - k)^2$ then the algorithm will loop almost always
-once or twice and occasionally three times. For simplicity sake the value of $x$ is bounded by the following simple polynomial.
-
-\begin{equation}
-0 \le x < n^2 + k^2 - 2nk
-\end{equation}
-
-The true bound is $0 \le x < (n - k - 1)^2$ but this has quite a few more terms. The value of $q$ after step 1 is bounded by the following.
-
-\begin{equation}
-q < n - 2k - k^2/n
-\end{equation}
-
-Since $k^2$ is going to be considerably smaller than $n$ that term will always be zero. The value of $x$ after step 3 is bounded trivially as
-$0 \le x < n$. By step four the sum $x + q$ is bounded by
-
-\begin{equation}
-0 \le q + x < (k + 1)n - 2k^2 - 1
-\end{equation}
-
-With a second pass $q$ will be loosely bounded by $0 \le q < k^2$ after step 2 while $x$ will still be loosely bounded by $0 \le x < n$ after step 3. After the second pass it is highly unlike that the
-sum in step 4 will exceed $n - k$. In practice fewer than three passes of the algorithm are required to reduce virtually every input in the
-range $0 \le x < (n - k - 1)^2$.
-
-\begin{figure}
-\begin{small}
-\begin{center}
-\begin{tabular}{|l|}
-\hline
-$x = 123456789, n = 256, k = 3$ \\
-\hline $q \leftarrow \lfloor x/n \rfloor = 482253$ \\
-$q \leftarrow q*k = 1446759$ \\
-$x \leftarrow x \mbox{ mod } n = 21$ \\
-$x \leftarrow x + q = 1446780$ \\
-$x \leftarrow x - (n - k) = 1446527$ \\
-\hline
-$q \leftarrow \lfloor x/n \rfloor = 5650$ \\
-$q \leftarrow q*k = 16950$ \\
-$x \leftarrow x \mbox{ mod } n = 127$ \\
-$x \leftarrow x + q = 17077$ \\
-$x \leftarrow x - (n - k) = 16824$ \\
-\hline
-$q \leftarrow \lfloor x/n \rfloor = 65$ \\
-$q \leftarrow q*k = 195$ \\
-$x \leftarrow x \mbox{ mod } n = 184$ \\
-$x \leftarrow x + q = 379$ \\
-$x \leftarrow x - (n - k) = 126$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Example Diminished Radix Reduction}
-\label{fig:EXDR}
-\end{figure}
-
-Figure~\ref{fig:EXDR} demonstrates the reduction of $x = 123456789$ modulo $n - k = 253$ when $n = 256$ and $k = 3$. Note that even while $x$
-is considerably larger than $(n - k - 1)^2 = 63504$ the algorithm still converges on the modular residue exceedingly fast. In this case only
-three passes were required to find the residue $x \equiv 126$.
-
-
-\subsection{Choice of Moduli}
-On the surface this algorithm looks like a very expensive algorithm. It requires a couple of subtractions followed by multiplication and other
-modular reductions. The usefulness of this algorithm becomes exceedingly clear when an appropriate modulus is chosen.
-
-Division in general is a very expensive operation to perform. The one exception is when the division is by a power of the radix of representation used.
-Division by ten for example is simple for pencil and paper mathematics since it amounts to shifting the decimal place to the right. Similarly division
-by two (\textit{or powers of two}) is very simple for binary computers to perform. It would therefore seem logical to choose $n$ of the form $2^p$
-which would imply that $\lfloor x / n \rfloor$ is a simple shift of $x$ right $p$ bits.
-
-However, there is one operation related to division of power of twos that is even faster than this. If $n = \beta^p$ then the division may be
-performed by moving whole digits to the right $p$ places. In practice division by $\beta^p$ is much faster than division by $2^p$ for any $p$.
-Also with the choice of $n = \beta^p$ reducing $x$ modulo $n$ merely requires zeroing the digits above the $p-1$'th digit of $x$.
-
-Throughout the next section the term ``restricted modulus'' will refer to a modulus of the form $\beta^p - k$ whereas the term ``unrestricted
-modulus'' will refer to a modulus of the form $2^p - k$. The word ``restricted'' in this case refers to the fact that it is based on the
-$2^p$ logic except $p$ must be a multiple of $lg(\beta)$.
-
-\subsection{Choice of $k$}
-Now that division and reduction (\textit{step 1 and 3 of figure~\ref{fig:DR}}) have been optimized to simple digit operations the multiplication by $k$
-in step 2 is the most expensive operation. Fortunately the choice of $k$ is not terribly limited. For all intents and purposes it might
-as well be a single digit. The smaller the value of $k$ is the faster the algorithm will be.
-
-\subsection{Restricted Diminished Radix Reduction}
-The restricted Diminished Radix algorithm can quickly reduce an input modulo a modulus of the form $n = \beta^p - k$. This algorithm can reduce
-an input $x$ within the range $0 \le x < n^2$ using only a couple passes of the algorithm demonstrated in figure~\ref{fig:DR}. The implementation
-of this algorithm has been optimized to avoid additional overhead associated with a division by $\beta^p$, the multiplication by $k$ or the addition
-of $x$ and $q$. The resulting algorithm is very efficient and can lead to substantial improvements over Barrett and Montgomery reduction when modular
-exponentiations are performed.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_reduce}. \\
-\textbf{Input}. mp\_int $x$, $n$ and a mp\_digit $k = \beta - n_0$ \\
-\hspace{11.5mm}($0 \le x < n^2$, $n > 1$, $0 < k < \beta$) \\
-\textbf{Output}. $x \mbox{ mod } n$ \\
-\hline \\
-1. $m \leftarrow n.used$ \\
-2. If $x.alloc < 2m$ then grow $x$ to $2m$ digits. \\
-3. $\mu \leftarrow 0$ \\
-4. for $i$ from $0$ to $m - 1$ do \\
-\hspace{3mm}4.1 $\hat r \leftarrow k \cdot x_{m+i} + x_{i} + \mu$ \\
-\hspace{3mm}4.2 $x_{i} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}4.3 $\mu \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-5. $x_{m} \leftarrow \mu$ \\
-6. for $i$ from $m + 1$ to $x.used - 1$ do \\
-\hspace{3mm}6.1 $x_{i} \leftarrow 0$ \\
-7. Clamp excess digits of $x$. \\
-8. If $x \ge n$ then \\
-\hspace{3mm}8.1 $x \leftarrow x - n$ \\
-\hspace{3mm}8.2 Goto step 3. \\
-9. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_reduce}
-\end{figure}
-
-\textbf{Algorithm mp\_dr\_reduce.}
-This algorithm will perform the Dimished Radix reduction of $x$ modulo $n$. It has similar restrictions to that of the Barrett reduction
-with the addition that $n$ must be of the form $n = \beta^m - k$ where $0 < k <\beta$.
-
-This algorithm essentially implements the pseudo-code in figure~\ref{fig:DR} except with a slight optimization. The division by $\beta^m$, multiplication by $k$
-and addition of $x \mbox{ mod }\beta^m$ are all performed simultaneously inside the loop on step 4. The division by $\beta^m$ is emulated by accessing
-the term at the $m+i$'th position which is subsequently multiplied by $k$ and added to the term at the $i$'th position. After the loop the $m$'th
-digit is set to the carry and the upper digits are zeroed. Steps 5 and 6 emulate the reduction modulo $\beta^m$ that should have happend to
-$x$ before the addition of the multiple of the upper half.
-
-At step 8 if $x$ is still larger than $n$ another pass of the algorithm is required. First $n$ is subtracted from $x$ and then the algorithm resumes
-at step 3.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_dr\_reduce.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The first step is to grow $x$ as required to $2m$ digits since the reduction is performed in place on $x$. The label on line 52 is where
-the algorithm will resume if further reduction passes are required. In theory it could be placed at the top of the function however, the size of
-the modulus and question of whether $x$ is large enough are invariant after the first pass meaning that it would be a waste of time.
-
-The aliases $tmpx1$ and $tmpx2$ refer to the digits of $x$ where the latter is offset by $m$ digits. By reading digits from $x$ offset by $m$ digits
-a division by $\beta^m$ can be simulated virtually for free. The loop on line 64 performs the bulk of the work (\textit{corresponds to step 4 of algorithm 7.11})
-in this algorithm.
-
-By line 67 the pointer $tmpx1$ points to the $m$'th digit of $x$ which is where the final carry will be placed. Similarly by line 74 the
-same pointer will point to the $m+1$'th digit where the zeroes will be placed.
-
-Since the algorithm is only valid if both $x$ and $n$ are greater than zero an unsigned comparison suffices to determine if another pass is required.
-With the same logic at line 81 the value of $x$ is known to be greater than or equal to $n$ meaning that an unsigned subtraction can be used
-as well. Since the destination of the subtraction is the larger of the inputs the call to algorithm s\_mp\_sub cannot fail and the return code
-does not need to be checked.
-
-\subsubsection{Setup}
-To setup the restricted Diminished Radix algorithm the value $k = \beta - n_0$ is required. This algorithm is not really complicated but provided for
-completeness.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_setup}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $k = \beta - n_0$ \\
-\hline \\
-1. $k \leftarrow \beta - n_0$ \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_setup}
-\end{figure}
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_dr\_setup.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsubsection{Modulus Detection}
-Another algorithm which will be useful is the ability to detect a restricted Diminished Radix modulus. An integer is said to be
-of restricted Diminished Radix form if all of the digits are equal to $\beta - 1$ except the trailing digit which may be any value.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_dr\_is\_modulus}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $1$ if $n$ is in D.R form, $0$ otherwise \\
-\hline
-1. If $n.used < 2$ then return($0$). \\
-2. for $ix$ from $1$ to $n.used - 1$ do \\
-\hspace{3mm}2.1 If $n_{ix} \ne \beta - 1$ return($0$). \\
-3. Return($1$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_dr\_is\_modulus}
-\end{figure}
-
-\textbf{Algorithm mp\_dr\_is\_modulus.}
-This algorithm determines if a value is in Diminished Radix form. Step 1 rejects obvious cases where fewer than two digits are
-in the mp\_int. Step 2 tests all but the first digit to see if they are equal to $\beta - 1$. If the algorithm manages to get to
-step 3 then $n$ must be of Diminished Radix form.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_dr\_is\_modulus.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsection{Unrestricted Diminished Radix Reduction}
-The unrestricted Diminished Radix algorithm allows modular reductions to be performed when the modulus is of the form $2^p - k$. This algorithm
-is a straightforward adaptation of algorithm~\ref{fig:DR}.
-
-In general the restricted Diminished Radix reduction algorithm is much faster since it has considerably lower overhead. However, this new
-algorithm is much faster than either Montgomery or Barrett reduction when the moduli are of the appropriate form.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_2k}. \\
-\textbf{Input}. mp\_int $a$ and $n$. mp\_digit $k$ \\
-\hspace{11.5mm}($a \ge 0$, $n > 1$, $0 < k < \beta$, $n + k$ is a power of two) \\
-\textbf{Output}. $a \mbox{ (mod }n\mbox{)}$ \\
-\hline
-1. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-2. While $a \ge n$ do \\
-\hspace{3mm}2.1 $q \leftarrow \lfloor a / 2^p \rfloor$ (\textit{mp\_div\_2d}) \\
-\hspace{3mm}2.2 $a \leftarrow a \mbox{ (mod }2^p\mbox{)}$ (\textit{mp\_mod\_2d}) \\
-\hspace{3mm}2.3 $q \leftarrow q \cdot k$ (\textit{mp\_mul\_d}) \\
-\hspace{3mm}2.4 $a \leftarrow a - q$ (\textit{s\_mp\_sub}) \\
-\hspace{3mm}2.5 If $a \ge n$ then do \\
-\hspace{6mm}2.5.1 $a \leftarrow a - n$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_2k}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_2k.}
-This algorithm quickly reduces an input $a$ modulo an unrestricted Diminished Radix modulus $n$. Division by $2^p$ is emulated with a right
-shift which makes the algorithm fairly inexpensive to use.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_reduce\_2k.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The algorithm mp\_count\_bits calculates the number of bits in an mp\_int which is used to find the initial value of $p$. The call to mp\_div\_2d
-on line 31 calculates both the quotient $q$ and the remainder $a$ required. By doing both in a single function call the code size
-is kept fairly small. The multiplication by $k$ is only performed if $k > 1$. This allows reductions modulo $2^p - 1$ to be performed without
-any multiplications.
-
-The unsigned s\_mp\_add, mp\_cmp\_mag and s\_mp\_sub are used in place of their full sign counterparts since the inputs are only valid if they are
-positive. By using the unsigned versions the overhead is kept to a minimum.
-
-\subsubsection{Unrestricted Setup}
-To setup this reduction algorithm the value of $k = 2^p - n$ is required.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_2k\_setup}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $k = 2^p - n$ \\
-\hline
-1. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-2. $x \leftarrow 2^p$ (\textit{mp\_2expt}) \\
-3. $x \leftarrow x - n$ (\textit{mp\_sub}) \\
-4. $k \leftarrow x_0$ \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_2k\_setup}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_2k\_setup.}
-This algorithm computes the value of $k$ required for the algorithm mp\_reduce\_2k. By making a temporary variable $x$ equal to $2^p$ a subtraction
-is sufficient to solve for $k$. Alternatively if $n$ has more than one digit the value of $k$ is simply $\beta - n_0$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_reduce\_2k\_setup.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsubsection{Unrestricted Detection}
-An integer $n$ is a valid unrestricted Diminished Radix modulus if either of the following are true.
-
-\begin{enumerate}
-\item The number has only one digit.
-\item The number has more than one digit and every bit from the $\beta$'th to the most significant is one.
-\end{enumerate}
-
-If either condition is true than there is a power of two $2^p$ such that $0 < 2^p - n < \beta$. If the input is only
-one digit than it will always be of the correct form. Otherwise all of the bits above the first digit must be one. This arises from the fact
-that there will be value of $k$ that when added to the modulus causes a carry in the first digit which propagates all the way to the most
-significant bit. The resulting sum will be a power of two.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_reduce\_is\_2k}. \\
-\textbf{Input}. mp\_int $n$ \\
-\textbf{Output}. $1$ if of proper form, $0$ otherwise \\
-\hline
-1. If $n.used = 0$ then return($0$). \\
-2. If $n.used = 1$ then return($1$). \\
-3. $p \leftarrow \lceil lg(n) \rceil$ (\textit{mp\_count\_bits}) \\
-4. for $x$ from $lg(\beta)$ to $p$ do \\
-\hspace{3mm}4.1 If the ($x \mbox{ mod }lg(\beta)$)'th bit of the $\lfloor x / lg(\beta) \rfloor$ of $n$ is zero then return($0$). \\
-5. Return($1$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_reduce\_is\_2k}
-\end{figure}
-
-\textbf{Algorithm mp\_reduce\_is\_2k.}
-This algorithm quickly determines if a modulus is of the form required for algorithm mp\_reduce\_2k to function properly.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_reduce\_is\_2k.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-
-
-\section{Algorithm Comparison}
-So far three very different algorithms for modular reduction have been discussed. Each of the algorithms have their own strengths and weaknesses
-that makes having such a selection very useful. The following table sumarizes the three algorithms along with comparisons of work factors. Since
-all three algorithms have the restriction that $0 \le x < n^2$ and $n > 1$ those limitations are not included in the table.
-
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Method} & \textbf{Work Required} & \textbf{Limitations} & \textbf{$m = 8$} & \textbf{$m = 32$} & \textbf{$m = 64$} \\
-\hline Barrett & $m^2 + 2m - 1$ & None & $79$ & $1087$ & $4223$ \\
-\hline Montgomery & $m^2 + m$ & $n$ must be odd & $72$ & $1056$ & $4160$ \\
-\hline D.R. & $2m$ & $n = \beta^m - k$ & $16$ & $64$ & $128$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-
-In theory Montgomery and Barrett reductions would require roughly the same amount of time to complete. However, in practice since Montgomery
-reduction can be written as a single function with the Comba technique it is much faster. Barrett reduction suffers from the overhead of
-calling the half precision multipliers, addition and division by $\beta$ algorithms.
-
-For almost every cryptographic algorithm Montgomery reduction is the algorithm of choice. The one set of algorithms where Diminished Radix reduction truly
-shines are based on the discrete logarithm problem such as Diffie-Hellman \cite{DH} and ElGamal \cite{ELGAMAL}. In these algorithms
-primes of the form $\beta^m - k$ can be found and shared amongst users. These primes will allow the Diminished Radix algorithm to be used in
-modular exponentiation to greatly speed up the operation.
-
-
-
-\section*{Exercises}
-\begin{tabular}{cl}
-$\left [ 3 \right ]$ & Prove that the ``trick'' in algorithm mp\_montgomery\_setup actually \\
- & calculates the correct value of $\rho$. \\
- & \\
-$\left [ 2 \right ]$ & Devise an algorithm to reduce modulo $n + k$ for small $k$ quickly. \\
- & \\
-$\left [ 4 \right ]$ & Prove that the pseudo-code algorithm ``Diminished Radix Reduction'' \\
- & (\textit{figure~\ref{fig:DR}}) terminates. Also prove the probability that it will \\
- & terminate within $1 \le k \le 10$ iterations. \\
- & \\
-\end{tabular}
-
-
-\chapter{Exponentiation}
-Exponentiation is the operation of raising one variable to the power of another, for example, $a^b$. A variant of exponentiation, computed
-in a finite field or ring, is called modular exponentiation. This latter style of operation is typically used in public key
-cryptosystems such as RSA and Diffie-Hellman. The ability to quickly compute modular exponentiations is of great benefit to any
-such cryptosystem and many methods have been sought to speed it up.
-
-\section{Exponentiation Basics}
-A trivial algorithm would simply multiply $a$ against itself $b - 1$ times to compute the exponentiation desired. However, as $b$ grows in size
-the number of multiplications becomes prohibitive. Imagine what would happen if $b$ $\approx$ $2^{1024}$ as is the case when computing an RSA signature
-with a $1024$-bit key. Such a calculation could never be completed as it would take simply far too long.
-
-Fortunately there is a very simple algorithm based on the laws of exponents. Recall that $lg_a(a^b) = b$ and that $lg_a(a^ba^c) = b + c$ which
-are two trivial relationships between the base and the exponent. Let $b_i$ represent the $i$'th bit of $b$ starting from the least
-significant bit. If $b$ is a $k$-bit integer than the following equation is true.
-
-\begin{equation}
-a^b = \prod_{i=0}^{k-1} a^{2^i \cdot b_i}
-\end{equation}
-
-By taking the base $a$ logarithm of both sides of the equation the following equation is the result.
-
-\begin{equation}
-b = \sum_{i=0}^{k-1}2^i \cdot b_i
-\end{equation}
-
-The term $a^{2^i}$ can be found from the $i - 1$'th term by squaring the term since $\left ( a^{2^i} \right )^2$ is equal to
-$a^{2^{i+1}}$. This observation forms the basis of essentially all fast exponentiation algorithms. It requires $k$ squarings and on average
-$k \over 2$ multiplications to compute the result. This is indeed quite an improvement over simply multiplying by $a$ a total of $b-1$ times.
-
-While this current method is a considerable speed up there are further improvements to be made. For example, the $a^{2^i}$ term does not need to
-be computed in an auxilary variable. Consider the following equivalent algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Left to Right Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$ and $k$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $k - 1$ to $0$ do \\
-\hspace{3mm}2.1 $c \leftarrow c^2$ \\
-\hspace{3mm}2.2 $c \leftarrow c \cdot a^{b_i}$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Left to Right Exponentiation}
-\label{fig:LTOR}
-\end{figure}
-
-This algorithm starts from the most significant bit and works towards the least significant bit. When the $i$'th bit of $b$ is set $a$ is
-multiplied against the current product. In each iteration the product is squared which doubles the exponent of the individual terms of the
-product.
-
-For example, let $b = 101100_2 \equiv 44_{10}$. The following chart demonstrates the actions of the algorithm.
-
-\newpage\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|}
-\hline \textbf{Value of $i$} & \textbf{Value of $c$} \\
-\hline - & $1$ \\
-\hline $5$ & $a$ \\
-\hline $4$ & $a^2$ \\
-\hline $3$ & $a^4 \cdot a$ \\
-\hline $2$ & $a^8 \cdot a^2 \cdot a$ \\
-\hline $1$ & $a^{16} \cdot a^4 \cdot a^2$ \\
-\hline $0$ & $a^{32} \cdot a^8 \cdot a^4$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Left to Right Exponentiation}
-\end{figure}
-
-When the product $a^{32} \cdot a^8 \cdot a^4$ is simplified it is equal $a^{44}$ which is the desired exponentiation. This particular algorithm is
-called ``Left to Right'' because it reads the exponent in that order. All of the exponentiation algorithms that will be presented are of this nature.
-
-\subsection{Single Digit Exponentiation}
-The first algorithm in the series of exponentiation algorithms will be an unbounded algorithm where the exponent is a single digit. It is intended
-to be used when a small power of an input is required (\textit{e.g. $a^5$}). It is faster than simply multiplying $b - 1$ times for all values of
-$b$ that are greater than three.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_expt\_d}. \\
-\textbf{Input}. mp\_int $a$ and mp\_digit $b$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $g \leftarrow a$ (\textit{mp\_init\_copy}) \\
-2. $c \leftarrow 1$ (\textit{mp\_set}) \\
-3. for $x$ from 1 to $lg(\beta)$ do \\
-\hspace{3mm}3.1 $c \leftarrow c^2$ (\textit{mp\_sqr}) \\
-\hspace{3mm}3.2 If $b$ AND $2^{lg(\beta) - 1} \ne 0$ then \\
-\hspace{6mm}3.2.1 $c \leftarrow c \cdot g$ (\textit{mp\_mul}) \\
-\hspace{3mm}3.3 $b \leftarrow b << 1$ \\
-4. Clear $g$. \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_expt\_d}
-\end{figure}
-
-\textbf{Algorithm mp\_expt\_d.}
-This algorithm computes the value of $a$ raised to the power of a single digit $b$. It uses the left to right exponentiation algorithm to
-quickly compute the exponentiation. It is loosely based on algorithm 14.79 of HAC \cite[pp. 615]{HAC} with the difference that the
-exponent is a fixed width.
-
-A copy of $a$ is made first to allow destination variable $c$ be the same as the source variable $a$. The result is set to the initial value of
-$1$ in the subsequent step.
-
-Inside the loop the exponent is read from the most significant bit first down to the least significant bit. First $c$ is invariably squared
-on step 3.1. In the following step if the most significant bit of $b$ is one the copy of $a$ is multiplied against $c$. The value
-of $b$ is shifted left one bit to make the next bit down from the most signficant bit the new most significant bit. In effect each
-iteration of the loop moves the bits of the exponent $b$ upwards to the most significant location.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_expt\_d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Line 29 sets the initial value of the result to $1$. Next the loop on line 31 steps through each bit of the exponent starting from
-the most significant down towards the least significant. The invariant squaring operation placed on line 33 is performed first. After
-the squaring the result $c$ is multiplied by the base $g$ if and only if the most significant bit of the exponent is set. The shift on line
-47 moves all of the bits of the exponent upwards towards the most significant location.
-
-\section{$k$-ary Exponentiation}
-When calculating an exponentiation the most time consuming bottleneck is the multiplications which are in general a small factor
-slower than squaring. Recall from the previous algorithm that $b_{i}$ refers to the $i$'th bit of the exponent $b$. Suppose instead it referred to
-the $i$'th $k$-bit digit of the exponent of $b$. For $k = 1$ the definitions are synonymous and for $k > 1$ algorithm~\ref{fig:KARY}
-computes the same exponentiation. A group of $k$ bits from the exponent is called a \textit{window}. That is it is a small window on only a
-portion of the entire exponent. Consider the following modification to the basic left to right exponentiation algorithm.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{$k$-ary Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$, $k$ and $t$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $t - 1$ to $0$ do \\
-\hspace{3mm}2.1 $c \leftarrow c^{2^k} $ \\
-\hspace{3mm}2.2 Extract the $i$'th $k$-bit word from $b$ and store it in $g$. \\
-\hspace{3mm}2.3 $c \leftarrow c \cdot a^g$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{$k$-ary Exponentiation}
-\label{fig:KARY}
-\end{figure}
-
-The squaring on step 2.1 can be calculated by squaring the value $c$ successively $k$ times. If the values of $a^g$ for $0 < g < 2^k$ have been
-precomputed this algorithm requires only $t$ multiplications and $tk$ squarings. The table can be generated with $2^{k - 1} - 1$ squarings and
-$2^{k - 1} + 1$ multiplications. This algorithm assumes that the number of bits in the exponent is evenly divisible by $k$.
-However, when it is not the remaining $0 < x \le k - 1$ bits can be handled with algorithm~\ref{fig:LTOR}.
-
-Suppose $k = 4$ and $t = 100$. This modified algorithm will require $109$ multiplications and $408$ squarings to compute the exponentiation. The
-original algorithm would on average have required $200$ multiplications and $400$ squrings to compute the same value. The total number of squarings
-has increased slightly but the number of multiplications has nearly halved.
-
-\subsection{Optimal Values of $k$}
-An optimal value of $k$ will minimize $2^{k} + \lceil n / k \rceil + n - 1$ for a fixed number of bits in the exponent $n$. The simplest
-approach is to brute force search amongst the values $k = 2, 3, \ldots, 8$ for the lowest result. Table~\ref{fig:OPTK} lists optimal values of $k$
-for various exponent sizes and compares the number of multiplication and squarings required against algorithm~\ref{fig:LTOR}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Exponent (bits)} & \textbf{Optimal $k$} & \textbf{Work at $k$} & \textbf{Work with ~\ref{fig:LTOR}} \\
-\hline $16$ & $2$ & $27$ & $24$ \\
-\hline $32$ & $3$ & $49$ & $48$ \\
-\hline $64$ & $3$ & $92$ & $96$ \\
-\hline $128$ & $4$ & $175$ & $192$ \\
-\hline $256$ & $4$ & $335$ & $384$ \\
-\hline $512$ & $5$ & $645$ & $768$ \\
-\hline $1024$ & $6$ & $1257$ & $1536$ \\
-\hline $2048$ & $6$ & $2452$ & $3072$ \\
-\hline $4096$ & $7$ & $4808$ & $6144$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Optimal Values of $k$ for $k$-ary Exponentiation}
-\label{fig:OPTK}
-\end{figure}
-
-\subsection{Sliding-Window Exponentiation}
-A simple modification to the previous algorithm is only generate the upper half of the table in the range $2^{k-1} \le g < 2^k$. Essentially
-this is a table for all values of $g$ where the most significant bit of $g$ is a one. However, in order for this to be allowed in the
-algorithm values of $g$ in the range $0 \le g < 2^{k-1}$ must be avoided.
-
-Table~\ref{fig:OPTK2} lists optimal values of $k$ for various exponent sizes and compares the work required against algorithm~\ref{fig:KARY}.
-
-\begin{figure}[here]
-\begin{center}
-\begin{small}
-\begin{tabular}{|c|c|c|c|c|c|}
-\hline \textbf{Exponent (bits)} & \textbf{Optimal $k$} & \textbf{Work at $k$} & \textbf{Work with ~\ref{fig:KARY}} \\
-\hline $16$ & $3$ & $24$ & $27$ \\
-\hline $32$ & $3$ & $45$ & $49$ \\
-\hline $64$ & $4$ & $87$ & $92$ \\
-\hline $128$ & $4$ & $167$ & $175$ \\
-\hline $256$ & $5$ & $322$ & $335$ \\
-\hline $512$ & $6$ & $628$ & $645$ \\
-\hline $1024$ & $6$ & $1225$ & $1257$ \\
-\hline $2048$ & $7$ & $2403$ & $2452$ \\
-\hline $4096$ & $8$ & $4735$ & $4808$ \\
-\hline
-\end{tabular}
-\end{small}
-\end{center}
-\caption{Optimal Values of $k$ for Sliding Window Exponentiation}
-\label{fig:OPTK2}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Sliding Window $k$-ary Exponentiation}. \\
-\textbf{Input}. Integer $a$, $b$, $k$ and $t$ \\
-\textbf{Output}. $c = a^b$ \\
-\hline \\
-1. $c \leftarrow 1$ \\
-2. for $i$ from $t - 1$ to $0$ do \\
-\hspace{3mm}2.1 If the $i$'th bit of $b$ is a zero then \\
-\hspace{6mm}2.1.1 $c \leftarrow c^2$ \\
-\hspace{3mm}2.2 else do \\
-\hspace{6mm}2.2.1 $c \leftarrow c^{2^k}$ \\
-\hspace{6mm}2.2.2 Extract the $k$ bits from $(b_{i}b_{i-1}\ldots b_{i-(k-1)})$ and store it in $g$. \\
-\hspace{6mm}2.2.3 $c \leftarrow c \cdot a^g$ \\
-\hspace{6mm}2.2.4 $i \leftarrow i - k$ \\
-3. Return $c$. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Sliding Window $k$-ary Exponentiation}
-\end{figure}
-
-Similar to the previous algorithm this algorithm must have a special handler when fewer than $k$ bits are left in the exponent. While this
-algorithm requires the same number of squarings it can potentially have fewer multiplications. The pre-computed table $a^g$ is also half
-the size as the previous table.
-
-Consider the exponent $b = 111101011001000_2 \equiv 31432_{10}$ with $k = 3$ using both algorithms. The first algorithm will divide the exponent up as
-the following five $3$-bit words $b \equiv \left ( 111, 101, 011, 001, 000 \right )_{2}$. The second algorithm will break the
-exponent as $b \equiv \left ( 111, 101, 0, 110, 0, 100, 0 \right )_{2}$. The single digit $0$ in the second representation are where
-a single squaring took place instead of a squaring and multiplication. In total the first method requires $10$ multiplications and $18$
-squarings. The second method requires $8$ multiplications and $18$ squarings.
-
-In general the sliding window method is never slower than the generic $k$-ary method and often it is slightly faster.
-
-\section{Modular Exponentiation}
-
-Modular exponentiation is essentially computing the power of a base within a finite field or ring. For example, computing
-$d \equiv a^b \mbox{ (mod }c\mbox{)}$ is a modular exponentiation. Instead of first computing $a^b$ and then reducing it
-modulo $c$ the intermediate result is reduced modulo $c$ after every squaring or multiplication operation.
-
-This guarantees that any intermediate result is bounded by $0 \le d \le c^2 - 2c + 1$ and can be reduced modulo $c$ quickly using
-one of the algorithms presented in chapter six.
-
-Before the actual modular exponentiation algorithm can be written a wrapper algorithm must be written first. This algorithm
-will allow the exponent $b$ to be negative which is computed as $c \equiv \left (1 / a \right )^{\vert b \vert} \mbox{(mod }d\mbox{)}$. The
-value of $(1/a) \mbox{ mod }c$ is computed using the modular inverse (\textit{see \ref{sec;modinv}}). If no inverse exists the algorithm
-terminates with an error.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_exptmod}. \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-1. If $c.sign = MP\_NEG$ return(\textit{MP\_VAL}). \\
-2. If $b.sign = MP\_NEG$ then \\
-\hspace{3mm}2.1 $g' \leftarrow g^{-1} \mbox{ (mod }c\mbox{)}$ \\
-\hspace{3mm}2.2 $x' \leftarrow \vert x \vert$ \\
-\hspace{3mm}2.3 Compute $d \equiv g'^{x'} \mbox{ (mod }c\mbox{)}$ via recursion. \\
-3. if $p$ is odd \textbf{OR} $p$ is a D.R. modulus then \\
-\hspace{3mm}3.1 Compute $y \equiv g^{x} \mbox{ (mod }p\mbox{)}$ via algorithm mp\_exptmod\_fast. \\
-4. else \\
-\hspace{3mm}4.1 Compute $y \equiv g^{x} \mbox{ (mod }p\mbox{)}$ via algorithm s\_mp\_exptmod. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_exptmod}
-\end{figure}
-
-\textbf{Algorithm mp\_exptmod.}
-The first algorithm which actually performs modular exponentiation is algorithm s\_mp\_exptmod. It is a sliding window $k$-ary algorithm
-which uses Barrett reduction to reduce the product modulo $p$. The second algorithm mp\_exptmod\_fast performs the same operation
-except it uses either Montgomery or Diminished Radix reduction. The two latter reduction algorithms are clumped in the same exponentiation
-algorithm since their arguments are essentially the same (\textit{two mp\_ints and one mp\_digit}).
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_exptmod.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-In order to keep the algorithms in a known state the first step on line 29 is to reject any negative modulus as input. If the exponent is
-negative the algorithm tries to perform a modular exponentiation with the modular inverse of the base $G$. The temporary variable $tmpG$ is assigned
-the modular inverse of $G$ and $tmpX$ is assigned the absolute value of $X$. The algorithm will recuse with these new values with a positive
-exponent.
-
-If the exponent is positive the algorithm resumes the exponentiation. Line 77 determines if the modulus is of the restricted Diminished Radix
-form. If it is not line 70 attempts to determine if it is of a unrestricted Diminished Radix form. The integer $dr$ will take on one
-of three values.
-
-\begin{enumerate}
-\item $dr = 0$ means that the modulus is not of either restricted or unrestricted Diminished Radix form.
-\item $dr = 1$ means that the modulus is of restricted Diminished Radix form.
-\item $dr = 2$ means that the modulus is of unrestricted Diminished Radix form.
-\end{enumerate}
-
-Line 69 determines if the fast modular exponentiation algorithm can be used. It is allowed if $dr \ne 0$ or if the modulus is odd. Otherwise,
-the slower s\_mp\_exptmod algorithm is used which uses Barrett reduction.
-
-\subsection{Barrett Modular Exponentiation}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_exptmod}. \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-1. $k \leftarrow lg(x)$ \\
-2. $winsize \leftarrow \left \lbrace \begin{array}{ll}
- 2 & \mbox{if }k \le 7 \\
- 3 & \mbox{if }7 < k \le 36 \\
- 4 & \mbox{if }36 < k \le 140 \\
- 5 & \mbox{if }140 < k \le 450 \\
- 6 & \mbox{if }450 < k \le 1303 \\
- 7 & \mbox{if }1303 < k \le 3529 \\
- 8 & \mbox{if }3529 < k \\
- \end{array} \right .$ \\
-3. Initialize $2^{winsize}$ mp\_ints in an array named $M$ and one mp\_int named $\mu$ \\
-4. Calculate the $\mu$ required for Barrett Reduction (\textit{mp\_reduce\_setup}). \\
-5. $M_1 \leftarrow g \mbox{ (mod }p\mbox{)}$ \\
-\\
-Setup the table of small powers of $g$. First find $g^{2^{winsize}}$ and then all multiples of it. \\
-6. $k \leftarrow 2^{winsize - 1}$ \\
-7. $M_{k} \leftarrow M_1$ \\
-8. for $ix$ from 0 to $winsize - 2$ do \\
-\hspace{3mm}8.1 $M_k \leftarrow \left ( M_k \right )^2$ (\textit{mp\_sqr}) \\
-\hspace{3mm}8.2 $M_k \leftarrow M_k \mbox{ (mod }p\mbox{)}$ (\textit{mp\_reduce}) \\
-9. for $ix$ from $2^{winsize - 1} + 1$ to $2^{winsize} - 1$ do \\
-\hspace{3mm}9.1 $M_{ix} \leftarrow M_{ix - 1} \cdot M_{1}$ (\textit{mp\_mul}) \\
-\hspace{3mm}9.2 $M_{ix} \leftarrow M_{ix} \mbox{ (mod }p\mbox{)}$ (\textit{mp\_reduce}) \\
-10. $res \leftarrow 1$ \\
-\\
-Start Sliding Window. \\
-11. $mode \leftarrow 0, bitcnt \leftarrow 1, buf \leftarrow 0, digidx \leftarrow x.used - 1, bitcpy \leftarrow 0, bitbuf \leftarrow 0$ \\
-12. Loop \\
-\hspace{3mm}12.1 $bitcnt \leftarrow bitcnt - 1$ \\
-\hspace{3mm}12.2 If $bitcnt = 0$ then do \\
-\hspace{6mm}12.2.1 If $digidx = -1$ goto step 13. \\
-\hspace{6mm}12.2.2 $buf \leftarrow x_{digidx}$ \\
-\hspace{6mm}12.2.3 $digidx \leftarrow digidx - 1$ \\
-\hspace{6mm}12.2.4 $bitcnt \leftarrow lg(\beta)$ \\
-Continued on next page. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_exptmod}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{s\_mp\_exptmod} (\textit{continued}). \\
-\textbf{Input}. mp\_int $a$, $b$ and $c$ \\
-\textbf{Output}. $y \equiv g^x \mbox{ (mod }p\mbox{)}$ \\
-\hline \\
-\hspace{3mm}12.3 $y \leftarrow (buf >> (lg(\beta) - 1))$ AND $1$ \\
-\hspace{3mm}12.4 $buf \leftarrow buf << 1$ \\
-\hspace{3mm}12.5 if $mode = 0$ and $y = 0$ then goto step 12. \\
-\hspace{3mm}12.6 if $mode = 1$ and $y = 0$ then do \\
-\hspace{6mm}12.6.1 $res \leftarrow res^2$ \\
-\hspace{6mm}12.6.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}12.6.3 Goto step 12. \\
-\hspace{3mm}12.7 $bitcpy \leftarrow bitcpy + 1$ \\
-\hspace{3mm}12.8 $bitbuf \leftarrow bitbuf + (y << (winsize - bitcpy))$ \\
-\hspace{3mm}12.9 $mode \leftarrow 2$ \\
-\hspace{3mm}12.10 If $bitcpy = winsize$ then do \\
-\hspace{6mm}Window is full so perform the squarings and single multiplication. \\
-\hspace{6mm}12.10.1 for $ix$ from $0$ to $winsize -1$ do \\
-\hspace{9mm}12.10.1.1 $res \leftarrow res^2$ \\
-\hspace{9mm}12.10.1.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}12.10.2 $res \leftarrow res \cdot M_{bitbuf}$ \\
-\hspace{6mm}12.10.3 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}Reset the window. \\
-\hspace{6mm}12.10.4 $bitcpy \leftarrow 0, bitbuf \leftarrow 0, mode \leftarrow 1$ \\
-\\
-No more windows left. Check for residual bits of exponent. \\
-13. If $mode = 2$ and $bitcpy > 0$ then do \\
-\hspace{3mm}13.1 for $ix$ form $0$ to $bitcpy - 1$ do \\
-\hspace{6mm}13.1.1 $res \leftarrow res^2$ \\
-\hspace{6mm}13.1.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-\hspace{6mm}13.1.3 $bitbuf \leftarrow bitbuf << 1$ \\
-\hspace{6mm}13.1.4 If $bitbuf$ AND $2^{winsize} \ne 0$ then do \\
-\hspace{9mm}13.1.4.1 $res \leftarrow res \cdot M_{1}$ \\
-\hspace{9mm}13.1.4.2 $res \leftarrow res \mbox{ (mod }p\mbox{)}$ \\
-14. $y \leftarrow res$ \\
-15. Clear $res$, $mu$ and the $M$ array. \\
-16. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm s\_mp\_exptmod (continued)}
-\end{figure}
-
-\textbf{Algorithm s\_mp\_exptmod.}
-This algorithm computes the $x$'th power of $g$ modulo $p$ and stores the result in $y$. It takes advantage of the Barrett reduction
-algorithm to keep the product small throughout the algorithm.
-
-The first two steps determine the optimal window size based on the number of bits in the exponent. The larger the exponent the
-larger the window size becomes. After a window size $winsize$ has been chosen an array of $2^{winsize}$ mp\_int variables is allocated. This
-table will hold the values of $g^x \mbox{ (mod }p\mbox{)}$ for $2^{winsize - 1} \le x < 2^{winsize}$.
-
-After the table is allocated the first power of $g$ is found. Since $g \ge p$ is allowed it must be first reduced modulo $p$ to make
-the rest of the algorithm more efficient. The first element of the table at $2^{winsize - 1}$ is found by squaring $M_1$ successively $winsize - 2$
-times. The rest of the table elements are found by multiplying the previous element by $M_1$ modulo $p$.
-
-Now that the table is available the sliding window may begin. The following list describes the functions of all the variables in the window.
-\begin{enumerate}
-\item The variable $mode$ dictates how the bits of the exponent are interpreted.
-\begin{enumerate}
- \item When $mode = 0$ the bits are ignored since no non-zero bit of the exponent has been seen yet. For example, if the exponent were simply
- $1$ then there would be $lg(\beta) - 1$ zero bits before the first non-zero bit. In this case bits are ignored until a non-zero bit is found.
- \item When $mode = 1$ a non-zero bit has been seen before and a new $winsize$-bit window has not been formed yet. In this mode leading $0$ bits
- are read and a single squaring is performed. If a non-zero bit is read a new window is created.
- \item When $mode = 2$ the algorithm is in the middle of forming a window and new bits are appended to the window from the most significant bit
- downwards.
-\end{enumerate}
-\item The variable $bitcnt$ indicates how many bits are left in the current digit of the exponent left to be read. When it reaches zero a new digit
- is fetched from the exponent.
-\item The variable $buf$ holds the currently read digit of the exponent.
-\item The variable $digidx$ is an index into the exponents digits. It starts at the leading digit $x.used - 1$ and moves towards the trailing digit.
-\item The variable $bitcpy$ indicates how many bits are in the currently formed window. When it reaches $winsize$ the window is flushed and
- the appropriate operations performed.
-\item The variable $bitbuf$ holds the current bits of the window being formed.
-\end{enumerate}
-
-All of step 12 is the window processing loop. It will iterate while there are digits available form the exponent to read. The first step
-inside this loop is to extract a new digit if no more bits are available in the current digit. If there are no bits left a new digit is
-read and if there are no digits left than the loop terminates.
-
-After a digit is made available step 12.3 will extract the most significant bit of the current digit and move all other bits in the digit
-upwards. In effect the digit is read from most significant bit to least significant bit and since the digits are read from leading to
-trailing edges the entire exponent is read from most significant bit to least significant bit.
-
-At step 12.5 if the $mode$ and currently extracted bit $y$ are both zero the bit is ignored and the next bit is read. This prevents the
-algorithm from having to perform trivial squaring and reduction operations before the first non-zero bit is read. Step 12.6 and 12.7-10 handle
-the two cases of $mode = 1$ and $mode = 2$ respectively.
-
-\begin{center}
-\begin{figure}[here]
-\includegraphics{pics/expt_state.ps}
-\caption{Sliding Window State Diagram}
-\label{pic:expt_state}
-\end{figure}
-\end{center}
-
-By step 13 there are no more digits left in the exponent. However, there may be partial bits in the window left. If $mode = 2$ then
-a Left-to-Right algorithm is used to process the remaining few bits.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_s\_mp\_exptmod.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Lines 32 through 46 determine the optimal window size based on the length of the exponent in bits. The window divisions are sorted
-from smallest to greatest so that in each \textbf{if} statement only one condition must be tested. For example, by the \textbf{if} statement
-on line 38 the value of $x$ is already known to be greater than $140$.
-
-The conditional piece of code beginning on line 48 allows the window size to be restricted to five bits. This logic is used to ensure
-the table of precomputed powers of $G$ remains relatively small.
-
-The for loop on line 61 initializes the $M$ array while lines 72 and 77 through 86 initialize the reduction
-function that will be used for this modulus.
-
--- More later.
-
-\section{Quick Power of Two}
-Calculating $b = 2^a$ can be performed much quicker than with any of the previous algorithms. Recall that a logical shift left $m << k$ is
-equivalent to $m \cdot 2^k$. By this logic when $m = 1$ a quick power of two can be achieved.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_2expt}. \\
-\textbf{Input}. integer $b$ \\
-\textbf{Output}. $a \leftarrow 2^b$ \\
-\hline \\
-1. $a \leftarrow 0$ \\
-2. If $a.alloc < \lfloor b / lg(\beta) \rfloor + 1$ then grow $a$ appropriately. \\
-3. $a.used \leftarrow \lfloor b / lg(\beta) \rfloor + 1$ \\
-4. $a_{\lfloor b / lg(\beta) \rfloor} \leftarrow 1 << (b \mbox{ mod } lg(\beta))$ \\
-5. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_2expt}
-\end{figure}
-
-\textbf{Algorithm mp\_2expt.}
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_2expt.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\chapter{Higher Level Algorithms}
-
-This chapter discusses the various higher level algorithms that are required to complete a well rounded multiple precision integer package. These
-routines are less performance oriented than the algorithms of chapters five, six and seven but are no less important.
-
-The first section describes a method of integer division with remainder that is universally well known. It provides the signed division logic
-for the package. The subsequent section discusses a set of algorithms which allow a single digit to be the 2nd operand for a variety of operations.
-These algorithms serve mostly to simplify other algorithms where small constants are required. The last two sections discuss how to manipulate
-various representations of integers. For example, converting from an mp\_int to a string of character.
-
-\section{Integer Division with Remainder}
-\label{sec:division}
-
-Integer division aside from modular exponentiation is the most intensive algorithm to compute. Like addition, subtraction and multiplication
-the basis of this algorithm is the long-hand division algorithm taught to school children. Throughout this discussion several common variables
-will be used. Let $x$ represent the divisor and $y$ represent the dividend. Let $q$ represent the integer quotient $\lfloor y / x \rfloor$ and
-let $r$ represent the remainder $r = y - x \lfloor y / x \rfloor$. The following simple algorithm will be used to start the discussion.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Radix-$\beta$ Integer Division}. \\
-\textbf{Input}. integer $x$ and $y$ \\
-\textbf{Output}. $q = \lfloor y/x\rfloor, r = y - xq$ \\
-\hline \\
-1. $q \leftarrow 0$ \\
-2. $n \leftarrow \vert \vert y \vert \vert - \vert \vert x \vert \vert$ \\
-3. for $t$ from $n$ down to $0$ do \\
-\hspace{3mm}3.1 Maximize $k$ such that $kx\beta^t$ is less than or equal to $y$ and $(k + 1)x\beta^t$ is greater. \\
-\hspace{3mm}3.2 $q \leftarrow q + k\beta^t$ \\
-\hspace{3mm}3.3 $y \leftarrow y - kx\beta^t$ \\
-4. $r \leftarrow y$ \\
-5. Return($q, r$) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Radix-$\beta$ Integer Division}
-\label{fig:raddiv}
-\end{figure}
-
-As children we are taught this very simple algorithm for the case of $\beta = 10$. Almost instinctively several optimizations are taught for which
-their reason of existing are never explained. For this example let $y = 5471$ represent the dividend and $x = 23$ represent the divisor.
-
-To find the first digit of the quotient the value of $k$ must be maximized such that $kx\beta^t$ is less than or equal to $y$ and
-simultaneously $(k + 1)x\beta^t$ is greater than $y$. Implicitly $k$ is the maximum value the $t$'th digit of the quotient may have. The habitual method
-used to find the maximum is to ``eyeball'' the two numbers, typically only the leading digits and quickly estimate a quotient. By only using leading
-digits a much simpler division may be used to form an educated guess at what the value must be. In this case $k = \lfloor 54/23\rfloor = 2$ quickly
-arises as a possible solution. Indeed $2x\beta^2 = 4600$ is less than $y = 5471$ and simultaneously $(k + 1)x\beta^2 = 6900$ is larger than $y$.
-As a result $k\beta^2$ is added to the quotient which now equals $q = 200$ and $4600$ is subtracted from $y$ to give a remainder of $y = 841$.
-
-Again this process is repeated to produce the quotient digit $k = 3$ which makes the quotient $q = 200 + 3\beta = 230$ and the remainder
-$y = 841 - 3x\beta = 181$. Finally the last iteration of the loop produces $k = 7$ which leads to the quotient $q = 230 + 7 = 237$ and the
-remainder $y = 181 - 7x = 20$. The final quotient and remainder found are $q = 237$ and $r = y = 20$ which are indeed correct since
-$237 \cdot 23 + 20 = 5471$ is true.
-
-\subsection{Quotient Estimation}
-\label{sec:divest}
-As alluded to earlier the quotient digit $k$ can be estimated from only the leading digits of both the divisor and dividend. When $p$ leading
-digits are used from both the divisor and dividend to form an estimation the accuracy of the estimation rises as $p$ grows. Technically
-speaking the estimation is based on assuming the lower $\vert \vert y \vert \vert - p$ and $\vert \vert x \vert \vert - p$ lower digits of the
-dividend and divisor are zero.
-
-The value of the estimation may off by a few values in either direction and in general is fairly correct. A simplification \cite[pp. 271]{TAOCPV2}
-of the estimation technique is to use $t + 1$ digits of the dividend and $t$ digits of the divisor, in particularly when $t = 1$. The estimate
-using this technique is never too small. For the following proof let $t = \vert \vert y \vert \vert - 1$ and $s = \vert \vert x \vert \vert - 1$
-represent the most significant digits of the dividend and divisor respectively.
-
-\textbf{Proof.}\textit{ The quotient $\hat k = \lfloor (y_t\beta + y_{t-1}) / x_s \rfloor$ is greater than or equal to
-$k = \lfloor y / (x \cdot \beta^{\vert \vert y \vert \vert - \vert \vert x \vert \vert - 1}) \rfloor$. }
-The first obvious case is when $\hat k = \beta - 1$ in which case the proof is concluded since the real quotient cannot be larger. For all other
-cases $\hat k = \lfloor (y_t\beta + y_{t-1}) / x_s \rfloor$ and $\hat k x_s \ge y_t\beta + y_{t-1} - x_s + 1$. The latter portion of the inequalility
-$-x_s + 1$ arises from the fact that a truncated integer division will give the same quotient for at most $x_s - 1$ values. Next a series of
-inequalities will prove the hypothesis.
-
-\begin{equation}
-y - \hat k x \le y - \hat k x_s\beta^s
-\end{equation}
-
-This is trivially true since $x \ge x_s\beta^s$. Next we replace $\hat kx_s\beta^s$ by the previous inequality for $\hat kx_s$.
-
-\begin{equation}
-y - \hat k x \le y_t\beta^t + \ldots + y_0 - (y_t\beta^t + y_{t-1}\beta^{t-1} - x_s\beta^t + \beta^s)
-\end{equation}
-
-By simplifying the previous inequality the following inequality is formed.
-
-\begin{equation}
-y - \hat k x \le y_{t-2}\beta^{t-2} + \ldots + y_0 + x_s\beta^s - \beta^s
-\end{equation}
-
-Subsequently,
-
-\begin{equation}
-y_{t-2}\beta^{t-2} + \ldots + y_0 + x_s\beta^s - \beta^s < x_s\beta^s \le x
-\end{equation}
-
-Which proves that $y - \hat kx \le x$ and by consequence $\hat k \ge k$ which concludes the proof. \textbf{QED}
-
-
-\subsection{Normalized Integers}
-For the purposes of division a normalized input is when the divisors leading digit $x_n$ is greater than or equal to $\beta / 2$. By multiplying both
-$x$ and $y$ by $j = \lfloor (\beta / 2) / x_n \rfloor$ the quotient remains unchanged and the remainder is simply $j$ times the original
-remainder. The purpose of normalization is to ensure the leading digit of the divisor is sufficiently large such that the estimated quotient will
-lie in the domain of a single digit. Consider the maximum dividend $(\beta - 1) \cdot \beta + (\beta - 1)$ and the minimum divisor $\beta / 2$.
-
-\begin{equation}
-{{\beta^2 - 1} \over { \beta / 2}} \le 2\beta - {2 \over \beta}
-\end{equation}
-
-At most the quotient approaches $2\beta$, however, in practice this will not occur since that would imply the previous quotient digit was too small.
-
-\subsection{Radix-$\beta$ Division with Remainder}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div}. \\
-\textbf{Input}. mp\_int $a, b$ \\
-\textbf{Output}. $c = \lfloor a/b \rfloor$, $d = a - bc$ \\
-\hline \\
-1. If $b = 0$ return(\textit{MP\_VAL}). \\
-2. If $\vert a \vert < \vert b \vert$ then do \\
-\hspace{3mm}2.1 $d \leftarrow a$ \\
-\hspace{3mm}2.2 $c \leftarrow 0$ \\
-\hspace{3mm}2.3 Return(\textit{MP\_OKAY}). \\
-\\
-Setup the quotient to receive the digits. \\
-3. Grow $q$ to $a.used + 2$ digits. \\
-4. $q \leftarrow 0$ \\
-5. $x \leftarrow \vert a \vert , y \leftarrow \vert b \vert$ \\
-6. $sign \leftarrow \left \lbrace \begin{array}{ll}
- MP\_ZPOS & \mbox{if }a.sign = b.sign \\
- MP\_NEG & \mbox{otherwise} \\
- \end{array} \right .$ \\
-\\
-Normalize the inputs such that the leading digit of $y$ is greater than or equal to $\beta / 2$. \\
-7. $norm \leftarrow (lg(\beta) - 1) - (\lceil lg(y) \rceil \mbox{ (mod }lg(\beta)\mbox{)})$ \\
-8. $x \leftarrow x \cdot 2^{norm}, y \leftarrow y \cdot 2^{norm}$ \\
-\\
-Find the leading digit of the quotient. \\
-9. $n \leftarrow x.used - 1, t \leftarrow y.used - 1$ \\
-10. $y \leftarrow y \cdot \beta^{n - t}$ \\
-11. While ($x \ge y$) do \\
-\hspace{3mm}11.1 $q_{n - t} \leftarrow q_{n - t} + 1$ \\
-\hspace{3mm}11.2 $x \leftarrow x - y$ \\
-12. $y \leftarrow \lfloor y / \beta^{n-t} \rfloor$ \\
-\\
-Continued on the next page. \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div} (continued). \\
-\textbf{Input}. mp\_int $a, b$ \\
-\textbf{Output}. $c = \lfloor a/b \rfloor$, $d = a - bc$ \\
-\hline \\
-Now find the remainder fo the digits. \\
-13. for $i$ from $n$ down to $(t + 1)$ do \\
-\hspace{3mm}13.1 If $i > x.used$ then jump to the next iteration of this loop. \\
-\hspace{3mm}13.2 If $x_{i} = y_{t}$ then \\
-\hspace{6mm}13.2.1 $q_{i - t - 1} \leftarrow \beta - 1$ \\
-\hspace{3mm}13.3 else \\
-\hspace{6mm}13.3.1 $\hat r \leftarrow x_{i} \cdot \beta + x_{i - 1}$ \\
-\hspace{6mm}13.3.2 $\hat r \leftarrow \lfloor \hat r / y_{t} \rfloor$ \\
-\hspace{6mm}13.3.3 $q_{i - t - 1} \leftarrow \hat r$ \\
-\hspace{3mm}13.4 $q_{i - t - 1} \leftarrow q_{i - t - 1} + 1$ \\
-\\
-Fixup quotient estimation. \\
-\hspace{3mm}13.5 Loop \\
-\hspace{6mm}13.5.1 $q_{i - t - 1} \leftarrow q_{i - t - 1} - 1$ \\
-\hspace{6mm}13.5.2 t$1 \leftarrow 0$ \\
-\hspace{6mm}13.5.3 t$1_0 \leftarrow y_{t - 1}, $ t$1_1 \leftarrow y_t,$ t$1.used \leftarrow 2$ \\
-\hspace{6mm}13.5.4 $t1 \leftarrow t1 \cdot q_{i - t - 1}$ \\
-\hspace{6mm}13.5.5 t$2_0 \leftarrow x_{i - 2}, $ t$2_1 \leftarrow x_{i - 1}, $ t$2_2 \leftarrow x_i, $ t$2.used \leftarrow 3$ \\
-\hspace{6mm}13.5.6 If $\vert t1 \vert > \vert t2 \vert$ then goto step 13.5. \\
-\hspace{3mm}13.6 t$1 \leftarrow y \cdot q_{i - t - 1}$ \\
-\hspace{3mm}13.7 t$1 \leftarrow $ t$1 \cdot \beta^{i - t - 1}$ \\
-\hspace{3mm}13.8 $x \leftarrow x - $ t$1$ \\
-\hspace{3mm}13.9 If $x.sign = MP\_NEG$ then \\
-\hspace{6mm}13.10 t$1 \leftarrow y$ \\
-\hspace{6mm}13.11 t$1 \leftarrow $ t$1 \cdot \beta^{i - t - 1}$ \\
-\hspace{6mm}13.12 $x \leftarrow x + $ t$1$ \\
-\hspace{6mm}13.13 $q_{i - t - 1} \leftarrow q_{i - t - 1} - 1$ \\
-\\
-Finalize the result. \\
-14. Clamp excess digits of $q$ \\
-15. $c \leftarrow q, c.sign \leftarrow sign$ \\
-16. $x.sign \leftarrow a.sign$ \\
-17. $d \leftarrow \lfloor x / 2^{norm} \rfloor$ \\
-18. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div (continued)}
-\end{figure}
-\textbf{Algorithm mp\_div.}
-This algorithm will calculate quotient and remainder from an integer division given a dividend and divisor. The algorithm is a signed
-division and will produce a fully qualified quotient and remainder.
-
-First the divisor $b$ must be non-zero which is enforced in step one. If the divisor is larger than the dividend than the quotient is implicitly
-zero and the remainder is the dividend.
-
-After the first two trivial cases of inputs are handled the variable $q$ is setup to receive the digits of the quotient. Two unsigned copies of the
-divisor $y$ and dividend $x$ are made as well. The core of the division algorithm is an unsigned division and will only work if the values are
-positive. Now the two values $x$ and $y$ must be normalized such that the leading digit of $y$ is greater than or equal to $\beta / 2$.
-This is performed by shifting both to the left by enough bits to get the desired normalization.
-
-At this point the division algorithm can begin producing digits of the quotient. Recall that maximum value of the estimation used is
-$2\beta - {2 \over \beta}$ which means that a digit of the quotient must be first produced by another means. In this case $y$ is shifted
-to the left (\textit{step ten}) so that it has the same number of digits as $x$. The loop on step eleven will subtract multiples of the
-shifted copy of $y$ until $x$ is smaller. Since the leading digit of $y$ is greater than or equal to $\beta/2$ this loop will iterate at most two
-times to produce the desired leading digit of the quotient.
-
-Now the remainder of the digits can be produced. The equation $\hat q = \lfloor {{x_i \beta + x_{i-1}}\over y_t} \rfloor$ is used to fairly
-accurately approximate the true quotient digit. The estimation can in theory produce an estimation as high as $2\beta - {2 \over \beta}$ but by
-induction the upper quotient digit is correct (\textit{as established on step eleven}) and the estimate must be less than $\beta$.
-
-Recall from section~\ref{sec:divest} that the estimation is never too low but may be too high. The next step of the estimation process is
-to refine the estimation. The loop on step 13.5 uses $x_i\beta^2 + x_{i-1}\beta + x_{i-2}$ and $q_{i - t - 1}(y_t\beta + y_{t-1})$ as a higher
-order approximation to adjust the quotient digit.
-
-After both phases of estimation the quotient digit may still be off by a value of one\footnote{This is similar to the error introduced
-by optimizing Barrett reduction.}. Steps 13.6 and 13.7 subtract the multiple of the divisor from the dividend (\textit{Similar to step 3.3 of
-algorithm~\ref{fig:raddiv}} and then subsequently add a multiple of the divisor if the quotient was too large.
-
-Now that the quotient has been determine finializing the result is a matter of clamping the quotient, fixing the sizes and de-normalizing the
-remainder. An important aspect of this algorithm seemingly overlooked in other descriptions such as that of Algorithm 14.20 HAC \cite[pp. 598]{HAC}
-is that when the estimations are being made (\textit{inside the loop on step 13.5}) that the digits $y_{t-1}$, $x_{i-2}$ and $x_{i-1}$ may lie
-outside their respective boundaries. For example, if $t = 0$ or $i \le 1$ then the digits would be undefined. In those cases the digits should
-respectively be replaced with a zero.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_div.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The implementation of this algorithm differs slightly from the pseudo code presented previously. In this algorithm either of the quotient $c$ or
-remainder $d$ may be passed as a \textbf{NULL} pointer which indicates their value is not desired. For example, the C code to call the division
-algorithm with only the quotient is
-
-\begin{verbatim}
-mp_div(&a, &b, &c, NULL); /* c = [a/b] */
-\end{verbatim}
-
-Lines 109 and 113 handle the two trivial cases of inputs which are division by zero and dividend smaller than the divisor
-respectively. After the two trivial cases all of the temporary variables are initialized. Line 148 determines the sign of
-the quotient and line 148 ensures that both $x$ and $y$ are positive.
-
-The number of bits in the leading digit is calculated on line 151. Implictly an mp\_int with $r$ digits will require $lg(\beta)(r-1) + k$ bits
-of precision which when reduced modulo $lg(\beta)$ produces the value of $k$. In this case $k$ is the number of bits in the leading digit which is
-exactly what is required. For the algorithm to operate $k$ must equal $lg(\beta) - 1$ and when it does not the inputs must be normalized by shifting
-them to the left by $lg(\beta) - 1 - k$ bits.
-
-Throughout the variables $n$ and $t$ will represent the highest digit of $x$ and $y$ respectively. These are first used to produce the
-leading digit of the quotient. The loop beginning on line 184 will produce the remainder of the quotient digits.
-
-The conditional ``continue'' on line 187 is used to prevent the algorithm from reading past the leading edge of $x$ which can occur when the
-algorithm eliminates multiple non-zero digits in a single iteration. This ensures that $x_i$ is always non-zero since by definition the digits
-above the $i$'th position $x$ must be zero in order for the quotient to be precise\footnote{Precise as far as integer division is concerned.}.
-
-Lines 214, 216 and 223 through 225 manually construct the high accuracy estimations by setting the digits of the two mp\_int
-variables directly.
-
-\section{Single Digit Helpers}
-
-This section briefly describes a series of single digit helper algorithms which come in handy when working with small constants. All of
-the helper functions assume the single digit input is positive and will treat them as such.
-
-\subsection{Single Digit Addition and Subtraction}
-
-Both addition and subtraction are performed by ``cheating'' and using mp\_set followed by the higher level addition or subtraction
-algorithms. As a result these algorithms are subtantially simpler with a slight cost in performance.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_add\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = a + b$ \\
-\hline \\
-1. $t \leftarrow b$ (\textit{mp\_set}) \\
-2. $c \leftarrow a + t$ \\
-3. Return(\textit{MP\_OKAY}) \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_add\_d}
-\end{figure}
-
-\textbf{Algorithm mp\_add\_d.}
-This algorithm initiates a temporary mp\_int with the value of the single digit and uses algorithm mp\_add to add the two values together.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_add\_d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Clever use of the letter 't'.
-
-\subsubsection{Subtraction}
-The single digit subtraction algorithm mp\_sub\_d is essentially the same except it uses mp\_sub to subtract the digit from the mp\_int.
-
-\subsection{Single Digit Multiplication}
-Single digit multiplication arises enough in division and radix conversion that it ought to be implement as a special case of the baseline
-multiplication algorithm. Essentially this algorithm is a modified version of algorithm s\_mp\_mul\_digs where one of the multiplicands
-only has one digit.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_mul\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = ab$ \\
-\hline \\
-1. $pa \leftarrow a.used$ \\
-2. Grow $c$ to at least $pa + 1$ digits. \\
-3. $oldused \leftarrow c.used$ \\
-4. $c.used \leftarrow pa + 1$ \\
-5. $c.sign \leftarrow a.sign$ \\
-6. $\mu \leftarrow 0$ \\
-7. for $ix$ from $0$ to $pa - 1$ do \\
-\hspace{3mm}7.1 $\hat r \leftarrow \mu + a_{ix}b$ \\
-\hspace{3mm}7.2 $c_{ix} \leftarrow \hat r \mbox{ (mod }\beta\mbox{)}$ \\
-\hspace{3mm}7.3 $\mu \leftarrow \lfloor \hat r / \beta \rfloor$ \\
-8. $c_{pa} \leftarrow \mu$ \\
-9. for $ix$ from $pa + 1$ to $oldused$ do \\
-\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
-10. Clamp excess digits of $c$. \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_mul\_d}
-\end{figure}
-\textbf{Algorithm mp\_mul\_d.}
-This algorithm quickly multiplies an mp\_int by a small single digit value. It is specially tailored to the job and has a minimal of overhead.
-Unlike the full multiplication algorithms this algorithm does not require any significnat temporary storage or memory allocations.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_mul\_d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-In this implementation the destination $c$ may point to the same mp\_int as the source $a$ since the result is written after the digit is
-read from the source. This function uses pointer aliases $tmpa$ and $tmpc$ for the digits of $a$ and $c$ respectively.
-
-\subsection{Single Digit Division}
-Like the single digit multiplication algorithm, single digit division is also a fairly common algorithm used in radix conversion. Since the
-divisor is only a single digit a specialized variant of the division algorithm can be used to compute the quotient.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_div\_d}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c = \lfloor a / b \rfloor, d = a - cb$ \\
-\hline \\
-1. If $b = 0$ then return(\textit{MP\_VAL}).\\
-2. If $b = 3$ then use algorithm mp\_div\_3 instead. \\
-3. Init $q$ to $a.used$ digits. \\
-4. $q.used \leftarrow a.used$ \\
-5. $q.sign \leftarrow a.sign$ \\
-6. $\hat w \leftarrow 0$ \\
-7. for $ix$ from $a.used - 1$ down to $0$ do \\
-\hspace{3mm}7.1 $\hat w \leftarrow \hat w \beta + a_{ix}$ \\
-\hspace{3mm}7.2 If $\hat w \ge b$ then \\
-\hspace{6mm}7.2.1 $t \leftarrow \lfloor \hat w / b \rfloor$ \\
-\hspace{6mm}7.2.2 $\hat w \leftarrow \hat w \mbox{ (mod }b\mbox{)}$ \\
-\hspace{3mm}7.3 else\\
-\hspace{6mm}7.3.1 $t \leftarrow 0$ \\
-\hspace{3mm}7.4 $q_{ix} \leftarrow t$ \\
-8. $d \leftarrow \hat w$ \\
-9. Clamp excess digits of $q$. \\
-10. $c \leftarrow q$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_div\_d}
-\end{figure}
-\textbf{Algorithm mp\_div\_d.}
-This algorithm divides the mp\_int $a$ by the single mp\_digit $b$ using an optimized approach. Essentially in every iteration of the
-algorithm another digit of the dividend is reduced and another digit of quotient produced. Provided $b < \beta$ the value of $\hat w$
-after step 7.1 will be limited such that $0 \le \lfloor \hat w / b \rfloor < \beta$.
-
-If the divisor $b$ is equal to three a variant of this algorithm is used which is called mp\_div\_3. It replaces the division by three with
-a multiplication by $\lfloor \beta / 3 \rfloor$ and the appropriate shift and residual fixup. In essence it is much like the Barrett reduction
-from chapter seven.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_div\_d.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Like the implementation of algorithm mp\_div this algorithm allows either of the quotient or remainder to be passed as a \textbf{NULL} pointer to
-indicate the respective value is not required. This allows a trivial single digit modular reduction algorithm, mp\_mod\_d to be created.
-
-The division and remainder on lines 44 and @45,%@ can be replaced often by a single division on most processors. For example, the 32-bit x86 based
-processors can divide a 64-bit quantity by a 32-bit quantity and produce the quotient and remainder simultaneously. Unfortunately the GCC
-compiler does not recognize that optimization and will actually produce two function calls to find the quotient and remainder respectively.
-
-\subsection{Single Digit Root Extraction}
-
-Finding the $n$'th root of an integer is fairly easy as far as numerical analysis is concerned. Algorithms such as the Newton-Raphson approximation
-(\ref{eqn:newton}) series will converge very quickly to a root for any continuous function $f(x)$.
-
-\begin{equation}
-x_{i+1} = x_i - {f(x_i) \over f'(x_i)}
-\label{eqn:newton}
-\end{equation}
-
-In this case the $n$'th root is desired and $f(x) = x^n - a$ where $a$ is the integer of which the root is desired. The derivative of $f(x)$ is
-simply $f'(x) = nx^{n - 1}$. Of particular importance is that this algorithm will be used over the integers not over the a more continuous domain
-such as the real numbers. As a result the root found can be above the true root by few and must be manually adjusted. Ideally at the end of the
-algorithm the $n$'th root $b$ of an integer $a$ is desired such that $b^n \le a$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_n\_root}. \\
-\textbf{Input}. mp\_int $a$ and a mp\_digit $b$ \\
-\textbf{Output}. $c^b \le a$ \\
-\hline \\
-1. If $b$ is even and $a.sign = MP\_NEG$ return(\textit{MP\_VAL}). \\
-2. $sign \leftarrow a.sign$ \\
-3. $a.sign \leftarrow MP\_ZPOS$ \\
-4. t$2 \leftarrow 2$ \\
-5. Loop \\
-\hspace{3mm}5.1 t$1 \leftarrow $ t$2$ \\
-\hspace{3mm}5.2 t$3 \leftarrow $ t$1^{b - 1}$ \\
-\hspace{3mm}5.3 t$2 \leftarrow $ t$3 $ $\cdot$ t$1$ \\
-\hspace{3mm}5.4 t$2 \leftarrow $ t$2 - a$ \\
-\hspace{3mm}5.5 t$3 \leftarrow $ t$3 \cdot b$ \\
-\hspace{3mm}5.6 t$3 \leftarrow \lfloor $t$2 / $t$3 \rfloor$ \\
-\hspace{3mm}5.7 t$2 \leftarrow $ t$1 - $ t$3$ \\
-\hspace{3mm}5.8 If t$1 \ne $ t$2$ then goto step 5. \\
-6. Loop \\
-\hspace{3mm}6.1 t$2 \leftarrow $ t$1^b$ \\
-\hspace{3mm}6.2 If t$2 > a$ then \\
-\hspace{6mm}6.2.1 t$1 \leftarrow $ t$1 - 1$ \\
-\hspace{6mm}6.2.2 Goto step 6. \\
-7. $a.sign \leftarrow sign$ \\
-8. $c \leftarrow $ t$1$ \\
-9. $c.sign \leftarrow sign$ \\
-10. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_n\_root}
-\end{figure}
-\textbf{Algorithm mp\_n\_root.}
-This algorithm finds the integer $n$'th root of an input using the Newton-Raphson approach. It is partially optimized based on the observation
-that the numerator of ${f(x) \over f'(x)}$ can be derived from a partial denominator. That is at first the denominator is calculated by finding
-$x^{b - 1}$. This value can then be multiplied by $x$ and have $a$ subtracted from it to find the numerator. This saves a total of $b - 1$
-multiplications by t$1$ inside the loop.
-
-The initial value of the approximation is t$2 = 2$ which allows the algorithm to start with very small values and quickly converge on the
-root. Ideally this algorithm is meant to find the $n$'th root of an input where $n$ is bounded by $2 \le n \le 5$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_n\_root.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\section{Random Number Generation}
-
-Random numbers come up in a variety of activities from public key cryptography to simple simulations and various randomized algorithms. Pollard-Rho
-factoring for example, can make use of random values as starting points to find factors of a composite integer. In this case the algorithm presented
-is solely for simulations and not intended for cryptographic use.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_rand}. \\
-\textbf{Input}. An integer $b$ \\
-\textbf{Output}. A pseudo-random number of $b$ digits \\
-\hline \\
-1. $a \leftarrow 0$ \\
-2. If $b \le 0$ return(\textit{MP\_OKAY}) \\
-3. Pick a non-zero random digit $d$. \\
-4. $a \leftarrow a + d$ \\
-5. for $ix$ from 1 to $d - 1$ do \\
-\hspace{3mm}5.1 $a \leftarrow a \cdot \beta$ \\
-\hspace{3mm}5.2 Pick a random digit $d$. \\
-\hspace{3mm}5.3 $a \leftarrow a + d$ \\
-6. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_rand}
-\end{figure}
-\textbf{Algorithm mp\_rand.}
-This algorithm produces a pseudo-random integer of $b$ digits. By ensuring that the first digit is non-zero the algorithm also guarantees that the
-final result has at least $b$ digits. It relies heavily on a third-part random number generator which should ideally generate uniformly all of
-the integers from $0$ to $\beta - 1$.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_rand.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\section{Formatted Representations}
-The ability to emit a radix-$n$ textual representation of an integer is useful for interacting with human parties. For example, the ability to
-be given a string of characters such as ``114585'' and turn it into the radix-$\beta$ equivalent would make it easier to enter numbers
-into a program.
-
-\subsection{Reading Radix-n Input}
-For the purposes of this text we will assume that a simple lower ASCII map (\ref{fig:ASC}) is used for the values of from $0$ to $63$ to
-printable characters. For example, when the character ``N'' is read it represents the integer $23$. The first $16$ characters of the
-map are for the common representations up to hexadecimal. After that they match the ``base64'' encoding scheme which are suitable chosen
-such that they are printable. While outputting as base64 may not be too helpful for human operators it does allow communication via non binary
-mediums.
-
-\newpage\begin{figure}[here]
-\begin{center}
-\begin{tabular}{cc|cc|cc|cc}
-\hline \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} & \textbf{Value} & \textbf{Char} \\
-\hline
-0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 \\
-4 & 4 & 5 & 5 & 6 & 6 & 7 & 7 \\
-8 & 8 & 9 & 9 & 10 & A & 11 & B \\
-12 & C & 13 & D & 14 & E & 15 & F \\
-16 & G & 17 & H & 18 & I & 19 & J \\
-20 & K & 21 & L & 22 & M & 23 & N \\
-24 & O & 25 & P & 26 & Q & 27 & R \\
-28 & S & 29 & T & 30 & U & 31 & V \\
-32 & W & 33 & X & 34 & Y & 35 & Z \\
-36 & a & 37 & b & 38 & c & 39 & d \\
-40 & e & 41 & f & 42 & g & 43 & h \\
-44 & i & 45 & j & 46 & k & 47 & l \\
-48 & m & 49 & n & 50 & o & 51 & p \\
-52 & q & 53 & r & 54 & s & 55 & t \\
-56 & u & 57 & v & 58 & w & 59 & x \\
-60 & y & 61 & z & 62 & $+$ & 63 & $/$ \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Lower ASCII Map}
-\label{fig:ASC}
-\end{figure}
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_read\_radix}. \\
-\textbf{Input}. A string $str$ of length $sn$ and radix $r$. \\
-\textbf{Output}. The radix-$\beta$ equivalent mp\_int. \\
-\hline \\
-1. If $r < 2$ or $r > 64$ return(\textit{MP\_VAL}). \\
-2. $ix \leftarrow 0$ \\
-3. If $str_0 =$ ``-'' then do \\
-\hspace{3mm}3.1 $ix \leftarrow ix + 1$ \\
-\hspace{3mm}3.2 $sign \leftarrow MP\_NEG$ \\
-4. else \\
-\hspace{3mm}4.1 $sign \leftarrow MP\_ZPOS$ \\
-5. $a \leftarrow 0$ \\
-6. for $iy$ from $ix$ to $sn - 1$ do \\
-\hspace{3mm}6.1 Let $y$ denote the position in the map of $str_{iy}$. \\
-\hspace{3mm}6.2 If $str_{iy}$ is not in the map or $y \ge r$ then goto step 7. \\
-\hspace{3mm}6.3 $a \leftarrow a \cdot r$ \\
-\hspace{3mm}6.4 $a \leftarrow a + y$ \\
-7. If $a \ne 0$ then $a.sign \leftarrow sign$ \\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_read\_radix}
-\end{figure}
-\textbf{Algorithm mp\_read\_radix.}
-This algorithm will read an ASCII string and produce the radix-$\beta$ mp\_int representation of the same integer. A minus symbol ``-'' may precede the
-string to indicate the value is negative, otherwise it is assumed to be positive. The algorithm will read up to $sn$ characters from the input
-and will stop when it reads a character it cannot map the algorithm stops reading characters from the string. This allows numbers to be embedded
-as part of larger input without any significant problem.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_read\_radix.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsection{Generating Radix-$n$ Output}
-Generating radix-$n$ output is fairly trivial with a division and remainder algorithm.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_toradix}. \\
-\textbf{Input}. A mp\_int $a$ and an integer $r$\\
-\textbf{Output}. The radix-$r$ representation of $a$ \\
-\hline \\
-1. If $r < 2$ or $r > 64$ return(\textit{MP\_VAL}). \\
-2. If $a = 0$ then $str = $ ``$0$'' and return(\textit{MP\_OKAY}). \\
-3. $t \leftarrow a$ \\
-4. $str \leftarrow$ ``'' \\
-5. if $t.sign = MP\_NEG$ then \\
-\hspace{3mm}5.1 $str \leftarrow str + $ ``-'' \\
-\hspace{3mm}5.2 $t.sign = MP\_ZPOS$ \\
-6. While ($t \ne 0$) do \\
-\hspace{3mm}6.1 $d \leftarrow t \mbox{ (mod }r\mbox{)}$ \\
-\hspace{3mm}6.2 $t \leftarrow \lfloor t / r \rfloor$ \\
-\hspace{3mm}6.3 Look up $d$ in the map and store the equivalent character in $y$. \\
-\hspace{3mm}6.4 $str \leftarrow str + y$ \\
-7. If $str_0 = $``$-$'' then \\
-\hspace{3mm}7.1 Reverse the digits $str_1, str_2, \ldots str_n$. \\
-8. Otherwise \\
-\hspace{3mm}8.1 Reverse the digits $str_0, str_1, \ldots str_n$. \\
-9. Return(\textit{MP\_OKAY}).\\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_toradix}
-\end{figure}
-\textbf{Algorithm mp\_toradix.}
-This algorithm computes the radix-$r$ representation of an mp\_int $a$. The ``digits'' of the representation are extracted by reducing
-successive powers of $\lfloor a / r^k \rfloor$ the input modulo $r$ until $r^k > a$. Note that instead of actually dividing by $r^k$ in
-each iteration the quotient $\lfloor a / r \rfloor$ is saved for the next iteration. As a result a series of trivial $n \times 1$ divisions
-are required instead of a series of $n \times k$ divisions. One design flaw of this approach is that the digits are produced in the reverse order
-(see~\ref{fig:mpradix}). To remedy this flaw the digits must be swapped or simply ``reversed''.
-
-\begin{figure}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-\hline \textbf{Value of $a$} & \textbf{Value of $d$} & \textbf{Value of $str$} \\
-\hline $1234$ & -- & -- \\
-\hline $123$ & $4$ & ``4'' \\
-\hline $12$ & $3$ & ``43'' \\
-\hline $1$ & $2$ & ``432'' \\
-\hline $0$ & $1$ & ``4321'' \\
-\hline
-\end{tabular}
-\end{center}
-\caption{Example of Algorithm mp\_toradix.}
-\label{fig:mpradix}
-\end{figure}
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_toradix.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\chapter{Number Theoretic Algorithms}
-This chapter discusses several fundamental number theoretic algorithms such as the greatest common divisor, least common multiple and Jacobi
-symbol computation. These algorithms arise as essential components in several key cryptographic algorithms such as the RSA public key algorithm and
-various Sieve based factoring algorithms.
-
-\section{Greatest Common Divisor}
-The greatest common divisor of two integers $a$ and $b$, often denoted as $(a, b)$ is the largest integer $k$ that is a proper divisor of
-both $a$ and $b$. That is, $k$ is the largest integer such that $0 \equiv a \mbox{ (mod }k\mbox{)}$ and $0 \equiv b \mbox{ (mod }k\mbox{)}$ occur
-simultaneously.
-
-The most common approach (cite) is to reduce one input modulo another. That is if $a$ and $b$ are divisible by some integer $k$ and if $qa + r = b$ then
-$r$ is also divisible by $k$. The reduction pattern follows $\left < a , b \right > \rightarrow \left < b, a \mbox{ mod } b \right >$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (I)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. While ($b > 0$) do \\
-\hspace{3mm}1.1 $r \leftarrow a \mbox{ (mod }b\mbox{)}$ \\
-\hspace{3mm}1.2 $a \leftarrow b$ \\
-\hspace{3mm}1.3 $b \leftarrow r$ \\
-2. Return($a$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (I)}
-\label{fig:gcd1}
-\end{figure}
-
-This algorithm will quickly converge on the greatest common divisor since the residue $r$ tends diminish rapidly. However, divisions are
-relatively expensive operations to perform and should ideally be avoided. There is another approach based on a similar relationship of
-greatest common divisors. The faster approach is based on the observation that if $k$ divides both $a$ and $b$ it will also divide $a - b$.
-In particular, we would like $a - b$ to decrease in magnitude which implies that $b \ge a$.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (II)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. While ($b > 0$) do \\
-\hspace{3mm}1.1 Swap $a$ and $b$ such that $a$ is the smallest of the two. \\
-\hspace{3mm}1.2 $b \leftarrow b - a$ \\
-2. Return($a$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (II)}
-\label{fig:gcd2}
-\end{figure}
-
-\textbf{Proof} \textit{Algorithm~\ref{fig:gcd2} will return the greatest common divisor of $a$ and $b$.}
-The algorithm in figure~\ref{fig:gcd2} will eventually terminate since $b \ge a$ the subtraction in step 1.2 will be a value less than $b$. In other
-words in every iteration that tuple $\left < a, b \right >$ decrease in magnitude until eventually $a = b$. Since both $a$ and $b$ are always
-divisible by the greatest common divisor (\textit{until the last iteration}) and in the last iteration of the algorithm $b = 0$, therefore, in the
-second to last iteration of the algorithm $b = a$ and clearly $(a, a) = a$ which concludes the proof. \textbf{QED}.
-
-As a matter of practicality algorithm \ref{fig:gcd1} decreases far too slowly to be useful. Specially if $b$ is much larger than $a$ such that
-$b - a$ is still very much larger than $a$. A simple addition to the algorithm is to divide $b - a$ by a power of some integer $p$ which does
-not divide the greatest common divisor but will divide $b - a$. In this case ${b - a} \over p$ is also an integer and still divisible by
-the greatest common divisor.
-
-However, instead of factoring $b - a$ to find a suitable value of $p$ the powers of $p$ can be removed from $a$ and $b$ that are in common first.
-Then inside the loop whenever $b - a$ is divisible by some power of $p$ it can be safely removed.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{Greatest Common Divisor (III)}. \\
-\textbf{Input}. Two positive integers $a$ and $b$ greater than zero. \\
-\textbf{Output}. The greatest common divisor $(a, b)$. \\
-\hline \\
-1. $k \leftarrow 0$ \\
-2. While $a$ and $b$ are both divisible by $p$ do \\
-\hspace{3mm}2.1 $a \leftarrow \lfloor a / p \rfloor$ \\
-\hspace{3mm}2.2 $b \leftarrow \lfloor b / p \rfloor$ \\
-\hspace{3mm}2.3 $k \leftarrow k + 1$ \\
-3. While $a$ is divisible by $p$ do \\
-\hspace{3mm}3.1 $a \leftarrow \lfloor a / p \rfloor$ \\
-4. While $b$ is divisible by $p$ do \\
-\hspace{3mm}4.1 $b \leftarrow \lfloor b / p \rfloor$ \\
-5. While ($b > 0$) do \\
-\hspace{3mm}5.1 Swap $a$ and $b$ such that $a$ is the smallest of the two. \\
-\hspace{3mm}5.2 $b \leftarrow b - a$ \\
-\hspace{3mm}5.3 While $b$ is divisible by $p$ do \\
-\hspace{6mm}5.3.1 $b \leftarrow \lfloor b / p \rfloor$ \\
-6. Return($a \cdot p^k$). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm Greatest Common Divisor (III)}
-\label{fig:gcd3}
-\end{figure}
-
-This algorithm is based on the first except it removes powers of $p$ first and inside the main loop to ensure the tuple $\left < a, b \right >$
-decreases more rapidly. The first loop on step two removes powers of $p$ that are in common. A count, $k$, is kept which will present a common
-divisor of $p^k$. After step two the remaining common divisor of $a$ and $b$ cannot be divisible by $p$. This means that $p$ can be safely
-divided out of the difference $b - a$ so long as the division leaves no remainder.
-
-In particular the value of $p$ should be chosen such that the division on step 5.3.1 occur often. It also helps that division by $p$ be easy
-to compute. The ideal choice of $p$ is two since division by two amounts to a right logical shift. Another important observation is that by
-step five both $a$ and $b$ are odd. Therefore, the diffrence $b - a$ must be even which means that each iteration removes one bit from the
-largest of the pair.
-
-\subsection{Complete Greatest Common Divisor}
-The algorithms presented so far cannot handle inputs which are zero or negative. The following algorithm can handle all input cases properly
-and will produce the greatest common divisor.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_gcd}. \\
-\textbf{Input}. mp\_int $a$ and $b$ \\
-\textbf{Output}. The greatest common divisor $c = (a, b)$. \\
-\hline \\
-1. If $a = 0$ then \\
-\hspace{3mm}1.1 $c \leftarrow \vert b \vert $ \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $b = 0$ then \\
-\hspace{3mm}2.1 $c \leftarrow \vert a \vert $ \\
-\hspace{3mm}2.2 Return(\textit{MP\_OKAY}). \\
-3. $u \leftarrow \vert a \vert, v \leftarrow \vert b \vert$ \\
-4. $k \leftarrow 0$ \\
-5. While $u.used > 0$ and $v.used > 0$ and $u_0 \equiv v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}5.1 $k \leftarrow k + 1$ \\
-\hspace{3mm}5.2 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-\hspace{3mm}5.3 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-6. While $u.used > 0$ and $u_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}6.1 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-7. While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}7.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-8. While $v.used > 0$ \\
-\hspace{3mm}8.1 If $\vert u \vert > \vert v \vert$ then \\
-\hspace{6mm}8.1.1 Swap $u$ and $v$. \\
-\hspace{3mm}8.2 $v \leftarrow \vert v \vert - \vert u \vert$ \\
-\hspace{3mm}8.3 While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{6mm}8.3.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-9. $c \leftarrow u \cdot 2^k$ \\
-10. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_gcd}
-\end{figure}
-\textbf{Algorithm mp\_gcd.}
-This algorithm will produce the greatest common divisor of two mp\_ints $a$ and $b$. The algorithm was originally based on Algorithm B of
-Knuth \cite[pp. 338]{TAOCPV2} but has been modified to be simpler to explain. In theory it achieves the same asymptotic working time as
-Algorithm B and in practice this appears to be true.
-
-The first two steps handle the cases where either one of or both inputs are zero. If either input is zero the greatest common divisor is the
-largest input or zero if they are both zero. If the inputs are not trivial than $u$ and $v$ are assigned the absolute values of
-$a$ and $b$ respectively and the algorithm will proceed to reduce the pair.
-
-Step five will divide out any common factors of two and keep track of the count in the variable $k$. After this step, two is no longer a
-factor of the remaining greatest common divisor between $u$ and $v$ and can be safely evenly divided out of either whenever they are even. Step
-six and seven ensure that the $u$ and $v$ respectively have no more factors of two. At most only one of the while--loops will iterate since
-they cannot both be even.
-
-By step eight both of $u$ and $v$ are odd which is required for the inner logic. First the pair are swapped such that $v$ is equal to
-or greater than $u$. This ensures that the subtraction on step 8.2 will always produce a positive and even result. Step 8.3 removes any
-factors of two from the difference $u$ to ensure that in the next iteration of the loop both are once again odd.
-
-After $v = 0$ occurs the variable $u$ has the greatest common divisor of the pair $\left < u, v \right >$ just after step six. The result
-must be adjusted by multiplying by the common factors of two ($2^k$) removed earlier.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_gcd.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-This function makes use of the macros mp\_iszero and mp\_iseven. The former evaluates to $1$ if the input mp\_int is equivalent to the
-integer zero otherwise it evaluates to $0$. The latter evaluates to $1$ if the input mp\_int represents a non-zero even integer otherwise
-it evaluates to $0$. Note that just because mp\_iseven may evaluate to $0$ does not mean the input is odd, it could also be zero. The three
-trivial cases of inputs are handled on lines 24 through 30. After those lines the inputs are assumed to be non-zero.
-
-Lines 32 and 37 make local copies $u$ and $v$ of the inputs $a$ and $b$ respectively. At this point the common factors of two
-must be divided out of the two inputs. The block starting at line 44 removes common factors of two by first counting the number of trailing
-zero bits in both. The local integer $k$ is used to keep track of how many factors of $2$ are pulled out of both values. It is assumed that
-the number of factors will not exceed the maximum value of a C ``int'' data type\footnote{Strictly speaking no array in C may have more than
-entries than are accessible by an ``int'' so this is not a limitation.}.
-
-At this point there are no more common factors of two in the two values. The divisions by a power of two on lines 62 and 68 remove
-any independent factors of two such that both $u$ and $v$ are guaranteed to be an odd integer before hitting the main body of the algorithm. The while loop
-on line 73 performs the reduction of the pair until $v$ is equal to zero. The unsigned comparison and subtraction algorithms are used in
-place of the full signed routines since both values are guaranteed to be positive and the result of the subtraction is guaranteed to be non-negative.
-
-\section{Least Common Multiple}
-The least common multiple of a pair of integers is their product divided by their greatest common divisor. For two integers $a$ and $b$ the
-least common multiple is normally denoted as $[ a, b ]$ and numerically equivalent to ${ab} \over {(a, b)}$. For example, if $a = 2 \cdot 2 \cdot 3 = 12$
-and $b = 2 \cdot 3 \cdot 3 \cdot 7 = 126$ the least common multiple is ${126 \over {(12, 126)}} = {126 \over 6} = 21$.
-
-The least common multiple arises often in coding theory as well as number theory. If two functions have periods of $a$ and $b$ respectively they will
-collide, that is be in synchronous states, after only $[ a, b ]$ iterations. This is why, for example, random number generators based on
-Linear Feedback Shift Registers (LFSR) tend to use registers with periods which are co-prime (\textit{e.g. the greatest common divisor is one.}).
-Similarly in number theory if a composite $n$ has two prime factors $p$ and $q$ then maximal order of any unit of $\Z/n\Z$ will be $[ p - 1, q - 1] $.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_lcm}. \\
-\textbf{Input}. mp\_int $a$ and $b$ \\
-\textbf{Output}. The least common multiple $c = [a, b]$. \\
-\hline \\
-1. $c \leftarrow (a, b)$ \\
-2. $t \leftarrow a \cdot b$ \\
-3. $c \leftarrow \lfloor t / c \rfloor$ \\
-4. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_lcm}
-\end{figure}
-\textbf{Algorithm mp\_lcm.}
-This algorithm computes the least common multiple of two mp\_int inputs $a$ and $b$. It computes the least common multiple directly by
-dividing the product of the two inputs by their greatest common divisor.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_lcm.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\section{Jacobi Symbol Computation}
-To explain the Jacobi Symbol we shall first discuss the Legendre function\footnote{Arrg. What is the name of this?} off which the Jacobi symbol is
-defined. The Legendre function computes whether or not an integer $a$ is a quadratic residue modulo an odd prime $p$. Numerically it is
-equivalent to equation \ref{eqn:legendre}.
-
-\textit{-- Tom, don't be an ass, cite your source here...!}
-
-\begin{equation}
-a^{(p-1)/2} \equiv \begin{array}{rl}
- -1 & \mbox{if }a\mbox{ is a quadratic non-residue.} \\
- 0 & \mbox{if }a\mbox{ divides }p\mbox{.} \\
- 1 & \mbox{if }a\mbox{ is a quadratic residue}.
- \end{array} \mbox{ (mod }p\mbox{)}
-\label{eqn:legendre}
-\end{equation}
-
-\textbf{Proof.} \textit{Equation \ref{eqn:legendre} correctly identifies the residue status of an integer $a$ modulo a prime $p$.}
-An integer $a$ is a quadratic residue if the following equation has a solution.
-
-\begin{equation}
-x^2 \equiv a \mbox{ (mod }p\mbox{)}
-\label{eqn:root}
-\end{equation}
-
-Consider the following equation.
-
-\begin{equation}
-0 \equiv x^{p-1} - 1 \equiv \left \lbrace \left (x^2 \right )^{(p-1)/2} - a^{(p-1)/2} \right \rbrace + \left ( a^{(p-1)/2} - 1 \right ) \mbox{ (mod }p\mbox{)}
-\label{eqn:rooti}
-\end{equation}
-
-Whether equation \ref{eqn:root} has a solution or not equation \ref{eqn:rooti} is always true. If $a^{(p-1)/2} - 1 \equiv 0 \mbox{ (mod }p\mbox{)}$
-then the quantity in the braces must be zero. By reduction,
-
-\begin{eqnarray}
-\left (x^2 \right )^{(p-1)/2} - a^{(p-1)/2} \equiv 0 \nonumber \\
-\left (x^2 \right )^{(p-1)/2} \equiv a^{(p-1)/2} \nonumber \\
-x^2 \equiv a \mbox{ (mod }p\mbox{)}
-\end{eqnarray}
-
-As a result there must be a solution to the quadratic equation and in turn $a$ must be a quadratic residue. If $a$ does not divide $p$ and $a$
-is not a quadratic residue then the only other value $a^{(p-1)/2}$ may be congruent to is $-1$ since
-\begin{equation}
-0 \equiv a^{p - 1} - 1 \equiv (a^{(p-1)/2} + 1)(a^{(p-1)/2} - 1) \mbox{ (mod }p\mbox{)}
-\end{equation}
-One of the terms on the right hand side must be zero. \textbf{QED}
-
-\subsection{Jacobi Symbol}
-The Jacobi symbol is a generalization of the Legendre function for any odd non prime moduli $p$ greater than 2. If $p = \prod_{i=0}^n p_i$ then
-the Jacobi symbol $\left ( { a \over p } \right )$ is equal to the following equation.
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { a \over p_0} \right ) \left ( { a \over p_1} \right ) \ldots \left ( { a \over p_n} \right )
-\end{equation}
-
-By inspection if $p$ is prime the Jacobi symbol is equivalent to the Legendre function. The following facts\footnote{See HAC \cite[pp. 72-74]{HAC} for
-further details.} will be used to derive an efficient Jacobi symbol algorithm. Where $p$ is an odd integer greater than two and $a, b \in \Z$ the
-following are true.
-
-\begin{enumerate}
-\item $\left ( { a \over p} \right )$ equals $-1$, $0$ or $1$.
-\item $\left ( { ab \over p} \right ) = \left ( { a \over p} \right )\left ( { b \over p} \right )$.
-\item If $a \equiv b$ then $\left ( { a \over p} \right ) = \left ( { b \over p} \right )$.
-\item $\left ( { 2 \over p} \right )$ equals $1$ if $p \equiv 1$ or $7 \mbox{ (mod }8\mbox{)}$. Otherwise, it equals $-1$.
-\item $\left ( { a \over p} \right ) \equiv \left ( { p \over a} \right ) \cdot (-1)^{(p-1)(a-1)/4}$. More specifically
-$\left ( { a \over p} \right ) = \left ( { p \over a} \right )$ if $p \equiv a \equiv 1 \mbox{ (mod }4\mbox{)}$.
-\end{enumerate}
-
-Using these facts if $a = 2^k \cdot a'$ then
-
-\begin{eqnarray}
-\left ( { a \over p } \right ) = \left ( {{2^k} \over p } \right ) \left ( {a' \over p} \right ) \nonumber \\
- = \left ( {2 \over p } \right )^k \left ( {a' \over p} \right )
-\label{eqn:jacobi}
-\end{eqnarray}
-
-By fact five,
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { p \over a } \right ) \cdot (-1)^{(p-1)(a-1)/4}
-\end{equation}
-
-Subsequently by fact three since $p \equiv (p \mbox{ mod }a) \mbox{ (mod }a\mbox{)}$ then
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( { {p \mbox{ mod } a} \over a } \right ) \cdot (-1)^{(p-1)(a-1)/4}
-\end{equation}
-
-By putting both observations into equation \ref{eqn:jacobi} the following simplified equation is formed.
-
-\begin{equation}
-\left ( { a \over p } \right ) = \left ( {2 \over p } \right )^k \left ( {{p\mbox{ mod }a'} \over a'} \right ) \cdot (-1)^{(p-1)(a'-1)/4}
-\end{equation}
-
-The value of $\left ( {{p \mbox{ mod }a'} \over a'} \right )$ can be found by using the same equation recursively. The value of
-$\left ( {2 \over p } \right )^k$ equals $1$ if $k$ is even otherwise it equals $\left ( {2 \over p } \right )$. Using this approach the
-factors of $p$ do not have to be known. Furthermore, if $(a, p) = 1$ then the algorithm will terminate when the recursion requests the
-Jacobi symbol computation of $\left ( {1 \over a'} \right )$ which is simply $1$.
-
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_jacobi}. \\
-\textbf{Input}. mp\_int $a$ and $p$, $a \ge 0$, $p \ge 3$, $p \equiv 1 \mbox{ (mod }2\mbox{)}$ \\
-\textbf{Output}. The Jacobi symbol $c = \left ( {a \over p } \right )$. \\
-\hline \\
-1. If $a = 0$ then \\
-\hspace{3mm}1.1 $c \leftarrow 0$ \\
-\hspace{3mm}1.2 Return(\textit{MP\_OKAY}). \\
-2. If $a = 1$ then \\
-\hspace{3mm}2.1 $c \leftarrow 1$ \\
-\hspace{3mm}2.2 Return(\textit{MP\_OKAY}). \\
-3. $a' \leftarrow a$ \\
-4. $k \leftarrow 0$ \\
-5. While $a'.used > 0$ and $a'_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}5.1 $k \leftarrow k + 1$ \\
-\hspace{3mm}5.2 $a' \leftarrow \lfloor a' / 2 \rfloor$ \\
-6. If $k \equiv 0 \mbox{ (mod }2\mbox{)}$ then \\
-\hspace{3mm}6.1 $s \leftarrow 1$ \\
-7. else \\
-\hspace{3mm}7.1 $r \leftarrow p_0 \mbox{ (mod }8\mbox{)}$ \\
-\hspace{3mm}7.2 If $r = 1$ or $r = 7$ then \\
-\hspace{6mm}7.2.1 $s \leftarrow 1$ \\
-\hspace{3mm}7.3 else \\
-\hspace{6mm}7.3.1 $s \leftarrow -1$ \\
-8. If $p_0 \equiv a'_0 \equiv 3 \mbox{ (mod }4\mbox{)}$ then \\
-\hspace{3mm}8.1 $s \leftarrow -s$ \\
-9. If $a' \ne 1$ then \\
-\hspace{3mm}9.1 $p' \leftarrow p \mbox{ (mod }a'\mbox{)}$ \\
-\hspace{3mm}9.2 $s \leftarrow s \cdot \mbox{mp\_jacobi}(p', a')$ \\
-10. $c \leftarrow s$ \\
-11. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_jacobi}
-\end{figure}
-\textbf{Algorithm mp\_jacobi.}
-This algorithm computes the Jacobi symbol for an arbitrary positive integer $a$ with respect to an odd integer $p$ greater than three. The algorithm
-is based on algorithm 2.149 of HAC \cite[pp. 73]{HAC}.
-
-Step numbers one and two handle the trivial cases of $a = 0$ and $a = 1$ respectively. Step five determines the number of two factors in the
-input $a$. If $k$ is even than the term $\left ( { 2 \over p } \right )^k$ must always evaluate to one. If $k$ is odd than the term evaluates to one
-if $p_0$ is congruent to one or seven modulo eight, otherwise it evaluates to $-1$. After the the $\left ( { 2 \over p } \right )^k$ term is handled
-the $(-1)^{(p-1)(a'-1)/4}$ is computed and multiplied against the current product $s$. The latter term evaluates to one if both $p$ and $a'$
-are congruent to one modulo four, otherwise it evaluates to negative one.
-
-By step nine if $a'$ does not equal one a recursion is required. Step 9.1 computes $p' \equiv p \mbox{ (mod }a'\mbox{)}$ and will recurse to compute
-$\left ( {p' \over a'} \right )$ which is multiplied against the current Jacobi product.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_jacobi.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-As a matter of practicality the variable $a'$ as per the pseudo-code is reprensented by the variable $a1$ since the $'$ symbol is not valid for a C
-variable name character.
-
-The two simple cases of $a = 0$ and $a = 1$ are handled at the very beginning to simplify the algorithm. If the input is non-trivial the algorithm
-has to proceed compute the Jacobi. The variable $s$ is used to hold the current Jacobi product. Note that $s$ is merely a C ``int'' data type since
-the values it may obtain are merely $-1$, $0$ and $1$.
-
-After a local copy of $a$ is made all of the factors of two are divided out and the total stored in $k$. Technically only the least significant
-bit of $k$ is required, however, it makes the algorithm simpler to follow to perform an addition. In practice an exclusive-or and addition have the same
-processor requirements and neither is faster than the other.
-
-Line 58 through 71 determines the value of $\left ( { 2 \over p } \right )^k$. If the least significant bit of $k$ is zero than
-$k$ is even and the value is one. Otherwise, the value of $s$ depends on which residue class $p$ belongs to modulo eight. The value of
-$(-1)^{(p-1)(a'-1)/4}$ is compute and multiplied against $s$ on lines 71 through 74.
-
-Finally, if $a1$ does not equal one the algorithm must recurse and compute $\left ( {p' \over a'} \right )$.
-
-\textit{-- Comment about default $s$ and such...}
-
-\section{Modular Inverse}
-\label{sec:modinv}
-The modular inverse of a number actually refers to the modular multiplicative inverse. Essentially for any integer $a$ such that $(a, p) = 1$ there
-exist another integer $b$ such that $ab \equiv 1 \mbox{ (mod }p\mbox{)}$. The integer $b$ is called the multiplicative inverse of $a$ which is
-denoted as $b = a^{-1}$. Technically speaking modular inversion is a well defined operation for any finite ring or field not just for rings and
-fields of integers. However, the former will be the matter of discussion.
-
-The simplest approach is to compute the algebraic inverse of the input. That is to compute $b \equiv a^{\Phi(p) - 1}$. If $\Phi(p)$ is the
-order of the multiplicative subgroup modulo $p$ then $b$ must be the multiplicative inverse of $a$. The proof of which is trivial.
-
-\begin{equation}
-ab \equiv a \left (a^{\Phi(p) - 1} \right ) \equiv a^{\Phi(p)} \equiv a^0 \equiv 1 \mbox{ (mod }p\mbox{)}
-\end{equation}
-
-However, as simple as this approach may be it has two serious flaws. It requires that the value of $\Phi(p)$ be known which if $p$ is composite
-requires all of the prime factors. This approach also is very slow as the size of $p$ grows.
-
-A simpler approach is based on the observation that solving for the multiplicative inverse is equivalent to solving the linear
-Diophantine\footnote{See LeVeque \cite[pp. 40-43]{LeVeque} for more information.} equation.
-
-\begin{equation}
-ab + pq = 1
-\end{equation}
-
-Where $a$, $b$, $p$ and $q$ are all integers. If such a pair of integers $ \left < b, q \right >$ exist than $b$ is the multiplicative inverse of
-$a$ modulo $p$. The extended Euclidean algorithm (Knuth \cite[pp. 342]{TAOCPV2}) can be used to solve such equations provided $(a, p) = 1$.
-However, instead of using that algorithm directly a variant known as the binary Extended Euclidean algorithm will be used in its place. The
-binary approach is very similar to the binary greatest common divisor algorithm except it will produce a full solution to the Diophantine
-equation.
-
-\subsection{General Case}
-\newpage\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_invmod}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $(a, b) = 1$, $p \ge 2$, $0 < a < p$. \\
-\textbf{Output}. The modular inverse $c \equiv a^{-1} \mbox{ (mod }b\mbox{)}$. \\
-\hline \\
-1. If $b \le 0$ then return(\textit{MP\_VAL}). \\
-2. If $b_0 \equiv 1 \mbox{ (mod }2\mbox{)}$ then use algorithm fast\_mp\_invmod. \\
-3. $x \leftarrow \vert a \vert, y \leftarrow b$ \\
-4. If $x_0 \equiv y_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ then return(\textit{MP\_VAL}). \\
-5. $B \leftarrow 0, C \leftarrow 0, A \leftarrow 1, D \leftarrow 1$ \\
-6. While $u.used > 0$ and $u_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}6.1 $u \leftarrow \lfloor u / 2 \rfloor$ \\
-\hspace{3mm}6.2 If ($A.used > 0$ and $A_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) or ($B.used > 0$ and $B_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) then \\
-\hspace{6mm}6.2.1 $A \leftarrow A + y$ \\
-\hspace{6mm}6.2.2 $B \leftarrow B - x$ \\
-\hspace{3mm}6.3 $A \leftarrow \lfloor A / 2 \rfloor$ \\
-\hspace{3mm}6.4 $B \leftarrow \lfloor B / 2 \rfloor$ \\
-7. While $v.used > 0$ and $v_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}7.1 $v \leftarrow \lfloor v / 2 \rfloor$ \\
-\hspace{3mm}7.2 If ($C.used > 0$ and $C_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) or ($D.used > 0$ and $D_0 \equiv 1 \mbox{ (mod }2\mbox{)}$) then \\
-\hspace{6mm}7.2.1 $C \leftarrow C + y$ \\
-\hspace{6mm}7.2.2 $D \leftarrow D - x$ \\
-\hspace{3mm}7.3 $C \leftarrow \lfloor C / 2 \rfloor$ \\
-\hspace{3mm}7.4 $D \leftarrow \lfloor D / 2 \rfloor$ \\
-8. If $u \ge v$ then \\
-\hspace{3mm}8.1 $u \leftarrow u - v$ \\
-\hspace{3mm}8.2 $A \leftarrow A - C$ \\
-\hspace{3mm}8.3 $B \leftarrow B - D$ \\
-9. else \\
-\hspace{3mm}9.1 $v \leftarrow v - u$ \\
-\hspace{3mm}9.2 $C \leftarrow C - A$ \\
-\hspace{3mm}9.3 $D \leftarrow D - B$ \\
-10. If $u \ne 0$ goto step 6. \\
-11. If $v \ne 1$ return(\textit{MP\_VAL}). \\
-12. While $C \le 0$ do \\
-\hspace{3mm}12.1 $C \leftarrow C + b$ \\
-13. While $C \ge b$ do \\
-\hspace{3mm}13.1 $C \leftarrow C - b$ \\
-14. $c \leftarrow C$ \\
-15. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\end{figure}
-\textbf{Algorithm mp\_invmod.}
-This algorithm computes the modular multiplicative inverse of an integer $a$ modulo an integer $b$. This algorithm is a variation of the
-extended binary Euclidean algorithm from HAC \cite[pp. 608]{HAC}. It has been modified to only compute the modular inverse and not a complete
-Diophantine solution.
-
-If $b \le 0$ than the modulus is invalid and MP\_VAL is returned. Similarly if both $a$ and $b$ are even then there cannot be a multiplicative
-inverse for $a$ and the error is reported.
-
-The astute reader will observe that steps seven through nine are very similar to the binary greatest common divisor algorithm mp\_gcd. In this case
-the other variables to the Diophantine equation are solved. The algorithm terminates when $u = 0$ in which case the solution is
-
-\begin{equation}
-Ca + Db = v
-\end{equation}
-
-If $v$, the greatest common divisor of $a$ and $b$ is not equal to one then the algorithm will report an error as no inverse exists. Otherwise, $C$
-is the modular inverse of $a$. The actual value of $C$ is congruent to, but not necessarily equal to, the ideal modular inverse which should lie
-within $1 \le a^{-1} < b$. Step numbers twelve and thirteen adjust the inverse until it is in range. If the original input $a$ is within $0 < a < p$
-then only a couple of additions or subtractions will be required to adjust the inverse.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_invmod.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsubsection{Odd Moduli}
-
-When the modulus $b$ is odd the variables $A$ and $C$ are fixed and are not required to compute the inverse. In particular by attempting to solve
-the Diophantine $Cb + Da = 1$ only $B$ and $D$ are required to find the inverse of $a$.
-
-The algorithm fast\_mp\_invmod is a direct adaptation of algorithm mp\_invmod with all all steps involving either $A$ or $C$ removed. This
-optimization will halve the time required to compute the modular inverse.
-
-\section{Primality Tests}
-
-A non-zero integer $a$ is said to be prime if it is not divisible by any other integer excluding one and itself. For example, $a = 7$ is prime
-since the integers $2 \ldots 6$ do not evenly divide $a$. By contrast, $a = 6$ is not prime since $a = 6 = 2 \cdot 3$.
-
-Prime numbers arise in cryptography considerably as they allow finite fields to be formed. The ability to determine whether an integer is prime or
-not quickly has been a viable subject in cryptography and number theory for considerable time. The algorithms that will be presented are all
-probablistic algorithms in that when they report an integer is composite it must be composite. However, when the algorithms report an integer is
-prime the algorithm may be incorrect.
-
-As will be discussed it is possible to limit the probability of error so well that for practical purposes the probablity of error might as
-well be zero. For the purposes of these discussions let $n$ represent the candidate integer of which the primality is in question.
-
-\subsection{Trial Division}
-
-Trial division means to attempt to evenly divide a candidate integer by small prime integers. If the candidate can be evenly divided it obviously
-cannot be prime. By dividing by all primes $1 < p \le \sqrt{n}$ this test can actually prove whether an integer is prime. However, such a test
-would require a prohibitive amount of time as $n$ grows.
-
-Instead of dividing by every prime, a smaller, more mangeable set of primes may be used instead. By performing trial division with only a subset
-of the primes less than $\sqrt{n} + 1$ the algorithm cannot prove if a candidate is prime. However, often it can prove a candidate is not prime.
-
-The benefit of this test is that trial division by small values is fairly efficient. Specially compared to the other algorithms that will be
-discussed shortly. The probability that this approach correctly identifies a composite candidate when tested with all primes upto $q$ is given by
-$1 - {1.12 \over ln(q)}$. The graph (\ref{pic:primality}, will be added later) demonstrates the probability of success for the range
-$3 \le q \le 100$.
-
-At approximately $q = 30$ the gain of performing further tests diminishes fairly quickly. At $q = 90$ further testing is generally not going to
-be of any practical use. In the case of LibTomMath the default limit $q = 256$ was chosen since it is not too high and will eliminate
-approximately $80\%$ of all candidate integers. The constant \textbf{PRIME\_SIZE} is equal to the number of primes in the test base. The
-array \_\_prime\_tab is an array of the first \textbf{PRIME\_SIZE} prime numbers.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_is\_divisible}. \\
-\textbf{Input}. mp\_int $a$ \\
-\textbf{Output}. $c = 1$ if $n$ is divisible by a small prime, otherwise $c = 0$. \\
-\hline \\
-1. for $ix$ from $0$ to $PRIME\_SIZE$ do \\
-\hspace{3mm}1.1 $d \leftarrow n \mbox{ (mod }\_\_prime\_tab_{ix}\mbox{)}$ \\
-\hspace{3mm}1.2 If $d = 0$ then \\
-\hspace{6mm}1.2.1 $c \leftarrow 1$ \\
-\hspace{6mm}1.2.2 Return(\textit{MP\_OKAY}). \\
-2. $c \leftarrow 0$ \\
-3. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_is\_divisible}
-\end{figure}
-\textbf{Algorithm mp\_prime\_is\_divisible.}
-This algorithm attempts to determine if a candidate integer $n$ is composite by performing trial divisions.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_prime\_is\_divisible.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-The algorithm defaults to a return of $0$ in case an error occurs. The values in the prime table are all specified to be in the range of a
-mp\_digit. The table \_\_prime\_tab is defined in the following file.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_prime\_tab.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-Note that there are two possible tables. When an mp\_digit is 7-bits long only the primes upto $127$ may be included, otherwise the primes
-upto $1619$ are used. Note that the value of \textbf{PRIME\_SIZE} is a constant dependent on the size of a mp\_digit.
-
-\subsection{The Fermat Test}
-The Fermat test is probably one the oldest tests to have a non-trivial probability of success. It is based on the fact that if $n$ is in
-fact prime then $a^{n} \equiv a \mbox{ (mod }n\mbox{)}$ for all $0 < a < n$. The reason being that if $n$ is prime than the order of
-the multiplicative sub group is $n - 1$. Any base $a$ must have an order which divides $n - 1$ and as such $a^n$ is equivalent to
-$a^1 = a$.
-
-If $n$ is composite then any given base $a$ does not have to have a period which divides $n - 1$. In which case
-it is possible that $a^n \nequiv a \mbox{ (mod }n\mbox{)}$. However, this test is not absolute as it is possible that the order
-of a base will divide $n - 1$ which would then be reported as prime. Such a base yields what is known as a Fermat pseudo-prime. Several
-integers known as Carmichael numbers will be a pseudo-prime to all valid bases. Fortunately such numbers are extremely rare as $n$ grows
-in size.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_fermat}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $a \ge 2$, $0 < b < a$. \\
-\textbf{Output}. $c = 1$ if $b^a \equiv b \mbox{ (mod }a\mbox{)}$, otherwise $c = 0$. \\
-\hline \\
-1. $t \leftarrow b^a \mbox{ (mod }a\mbox{)}$ \\
-2. If $t = b$ then \\
-\hspace{3mm}2.1 $c = 1$ \\
-3. else \\
-\hspace{3mm}3.1 $c = 0$ \\
-4. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_fermat}
-\end{figure}
-\textbf{Algorithm mp\_prime\_fermat.}
-This algorithm determines whether an mp\_int $a$ is a Fermat prime to the base $b$ or not. It uses a single modular exponentiation to
-determine the result.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_prime\_fermat.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-\subsection{The Miller-Rabin Test}
-The Miller-Rabin (citation) test is another primality test which has tighter error bounds than the Fermat test specifically with sequentially chosen
-candidate integers. The algorithm is based on the observation that if $n - 1 = 2^kr$ and if $b^r \nequiv \pm 1$ then after upto $k - 1$ squarings the
-value must be equal to $-1$. The squarings are stopped as soon as $-1$ is observed. If the value of $1$ is observed first it means that
-some value not congruent to $\pm 1$ when squared equals one which cannot occur if $n$ is prime.
-
-\begin{figure}[!here]
-\begin{small}
-\begin{center}
-\begin{tabular}{l}
-\hline Algorithm \textbf{mp\_prime\_miller\_rabin}. \\
-\textbf{Input}. mp\_int $a$ and $b$, $a \ge 2$, $0 < b < a$. \\
-\textbf{Output}. $c = 1$ if $a$ is a Miller-Rabin prime to the base $a$, otherwise $c = 0$. \\
-\hline
-1. $a' \leftarrow a - 1$ \\
-2. $r \leftarrow n1$ \\
-3. $c \leftarrow 0, s \leftarrow 0$ \\
-4. While $r.used > 0$ and $r_0 \equiv 0 \mbox{ (mod }2\mbox{)}$ \\
-\hspace{3mm}4.1 $s \leftarrow s + 1$ \\
-\hspace{3mm}4.2 $r \leftarrow \lfloor r / 2 \rfloor$ \\
-5. $y \leftarrow b^r \mbox{ (mod }a\mbox{)}$ \\
-6. If $y \nequiv \pm 1$ then \\
-\hspace{3mm}6.1 $j \leftarrow 1$ \\
-\hspace{3mm}6.2 While $j \le (s - 1)$ and $y \nequiv a'$ \\
-\hspace{6mm}6.2.1 $y \leftarrow y^2 \mbox{ (mod }a\mbox{)}$ \\
-\hspace{6mm}6.2.2 If $y = 1$ then goto step 8. \\
-\hspace{6mm}6.2.3 $j \leftarrow j + 1$ \\
-\hspace{3mm}6.3 If $y \nequiv a'$ goto step 8. \\
-7. $c \leftarrow 1$\\
-8. Return(\textit{MP\_OKAY}). \\
-\hline
-\end{tabular}
-\end{center}
-\end{small}
-\caption{Algorithm mp\_prime\_miller\_rabin}
-\end{figure}
-\textbf{Algorithm mp\_prime\_miller\_rabin.}
-This algorithm performs one trial round of the Miller-Rabin algorithm to the base $b$. It will set $c = 1$ if the algorithm cannot determine
-if $b$ is composite or $c = 0$ if $b$ is provably composite. The values of $s$ and $r$ are computed such that $a' = a - 1 = 2^sr$.
-
-If the value $y \equiv b^r$ is congruent to $\pm 1$ then the algorithm cannot prove if $a$ is composite or not. Otherwise, the algorithm will
-square $y$ upto $s - 1$ times stopping only when $y \equiv -1$. If $y^2 \equiv 1$ and $y \nequiv \pm 1$ then the algorithm can report that $a$
-is provably composite. If the algorithm performs $s - 1$ squarings and $y \nequiv -1$ then $a$ is provably composite. If $a$ is not provably
-composite then it is \textit{probably} prime.
-
-\vspace{+3mm}\begin{small}
-\hspace{-5.1mm}{\bf File}: bn\_mp\_prime\_miller\_rabin.c
-\vspace{-3mm}
-\begin{alltt}
-\end{alltt}
-\end{small}
-
-
-
-
-\backmatter
-\appendix
-\begin{thebibliography}{ABCDEF}
-\bibitem[1]{TAOCPV2}
-Donald Knuth, \textit{The Art of Computer Programming}, Third Edition, Volume Two, Seminumerical Algorithms, Addison-Wesley, 1998
-
-\bibitem[2]{HAC}
-A. Menezes, P. van Oorschot, S. Vanstone, \textit{Handbook of Applied Cryptography}, CRC Press, 1996
-
-\bibitem[3]{ROSE}
-Michael Rosing, \textit{Implementing Elliptic Curve Cryptography}, Manning Publications, 1999
-
-\bibitem[4]{COMBA}
-Paul G. Comba, \textit{Exponentiation Cryptosystems on the IBM PC}. IBM Systems Journal 29(4): 526-538 (1990)
-
-\bibitem[5]{KARA}
-A. Karatsuba, Doklay Akad. Nauk SSSR 145 (1962), pp.293-294
-
-\bibitem[6]{KARAP}
-Andre Weimerskirch and Christof Paar, \textit{Generalizations of the Karatsuba Algorithm for Polynomial Multiplication}, Submitted to Design, Codes and Cryptography, March 2002
-
-\bibitem[7]{BARRETT}
-Paul Barrett, \textit{Implementing the Rivest Shamir and Adleman Public Key Encryption Algorithm on a Standard Digital Signal Processor}, Advances in Cryptology, Crypto '86, Springer-Verlag.
-
-\bibitem[8]{MONT}
-P.L.Montgomery. \textit{Modular multiplication without trial division}. Mathematics of Computation, 44(170):519-521, April 1985.
-
-\bibitem[9]{DRMET}
-Chae Hoon Lim and Pil Joong Lee, \textit{Generating Efficient Primes for Discrete Log Cryptosystems}, POSTECH Information Research Laboratories
-
-\bibitem[10]{MMB}
-J. Daemen and R. Govaerts and J. Vandewalle, \textit{Block ciphers based on Modular Arithmetic}, State and {P}rogress in the {R}esearch of {C}ryptography, 1993, pp. 80-89
-
-\bibitem[11]{RSAREF}
-R.L. Rivest, A. Shamir, L. Adleman, \textit{A Method for Obtaining Digital Signatures and Public-Key Cryptosystems}
-
-\bibitem[12]{DHREF}
-Whitfield Diffie, Martin E. Hellman, \textit{New Directions in Cryptography}, IEEE Transactions on Information Theory, 1976
-
-\bibitem[13]{IEEE}
-IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985)
-
-\bibitem[14]{GMP}
-GNU Multiple Precision (GMP), \url{http://www.swox.com/gmp/}
-
-\bibitem[15]{MPI}
-Multiple Precision Integer Library (MPI), Michael Fromberger, \url{http://thayer.dartmouth.edu/~sting/mpi/}
-
-\bibitem[16]{OPENSSL}
-OpenSSL Cryptographic Toolkit, \url{http://openssl.org}
-
-\bibitem[17]{LIP}
-Large Integer Package, \url{http://home.hetnet.nl/~ecstr/LIP.zip}
-
-\bibitem[18]{ISOC}
-JTC1/SC22/WG14, ISO/IEC 9899:1999, ``A draft rationale for the C99 standard.''
-
-\bibitem[19]{JAVA}
-The Sun Java Website, \url{http://java.sun.com/}
-
-\end{thebibliography}
-
-\input{tommath.ind}
-
-\end{document}
diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h
index b9cc902..2085521 100644
--- a/libtommath/tommath_class.h
+++ b/libtommath/tommath_class.h
@@ -38,7 +38,9 @@
#define BN_MP_DR_REDUCE_C
#define BN_MP_DR_SETUP_C
#define BN_MP_EXCH_C
+#define BN_MP_EXPORT_C
#define BN_MP_EXPT_D_C
+#define BN_MP_EXPT_D_EX_C
#define BN_MP_EXPTMOD_C
#define BN_MP_EXPTMOD_FAST_C
#define BN_MP_EXTEUCLID_C
@@ -46,7 +48,10 @@
#define BN_MP_FWRITE_C
#define BN_MP_GCD_C
#define BN_MP_GET_INT_C
+#define BN_MP_GET_LONG_C
+#define BN_MP_GET_LONG_LONG_C
#define BN_MP_GROW_C
+#define BN_MP_IMPORT_C
#define BN_MP_INIT_C
#define BN_MP_INIT_COPY_C
#define BN_MP_INIT_MULTI_C
@@ -73,6 +78,7 @@
#define BN_MP_MUL_D_C
#define BN_MP_MULMOD_C
#define BN_MP_N_ROOT_C
+#define BN_MP_N_ROOT_EX_C
#define BN_MP_NEG_C
#define BN_MP_OR_C
#define BN_MP_PRIME_FERMAT_C
@@ -99,11 +105,14 @@
#define BN_MP_RSHD_C
#define BN_MP_SET_C
#define BN_MP_SET_INT_C
+#define BN_MP_SET_LONG_C
+#define BN_MP_SET_LONG_LONG_C
#define BN_MP_SHRINK_C
#define BN_MP_SIGNED_BIN_SIZE_C
#define BN_MP_SQR_C
#define BN_MP_SQRMOD_C
#define BN_MP_SQRT_C
+#define BN_MP_SQRTMOD_PRIME_C
#define BN_MP_SUB_C
#define BN_MP_SUB_D_C
#define BN_MP_SUBMOD_C
@@ -315,12 +324,23 @@
#if defined(BN_MP_EXCH_C)
#endif
+#if defined(BN_MP_EXPORT_C)
+ #define BN_MP_INIT_COPY_C
+ #define BN_MP_COUNT_BITS_C
+ #define BN_MP_DIV_2D_C
+ #define BN_MP_CLEAR_C
+#endif
+
#if defined(BN_MP_EXPT_D_C)
+ #define BN_MP_EXPT_D_EX_C
+#endif
+
+#if defined(BN_MP_EXPT_D_EX_C)
#define BN_MP_INIT_COPY_C
#define BN_MP_SET_C
- #define BN_MP_SQR_C
- #define BN_MP_CLEAR_C
#define BN_MP_MUL_C
+ #define BN_MP_CLEAR_C
+ #define BN_MP_SQR_C
#endif
#if defined(BN_MP_EXPTMOD_C)
@@ -387,7 +407,6 @@
#if defined(BN_MP_GCD_C)
#define BN_MP_ISZERO_C
#define BN_MP_ABS_C
- #define BN_MP_ZERO_C
#define BN_MP_INIT_COPY_C
#define BN_MP_CNT_LSB_C
#define BN_MP_DIV_2D_C
@@ -401,13 +420,26 @@
#if defined(BN_MP_GET_INT_C)
#endif
+#if defined(BN_MP_GET_LONG_C)
+#endif
+
+#if defined(BN_MP_GET_LONG_LONG_C)
+#endif
+
#if defined(BN_MP_GROW_C)
#endif
+#if defined(BN_MP_IMPORT_C)
+ #define BN_MP_ZERO_C
+ #define BN_MP_MUL_2D_C
+ #define BN_MP_CLAMP_C
+#endif
+
#if defined(BN_MP_INIT_C)
#endif
#if defined(BN_MP_INIT_COPY_C)
+ #define BN_MP_INIT_SIZE_C
#define BN_MP_COPY_C
#endif
@@ -481,8 +513,9 @@
#define BN_MP_MUL_C
#define BN_MP_INIT_SIZE_C
#define BN_MP_CLAMP_C
- #define BN_MP_SUB_C
+ #define BN_S_MP_ADD_C
#define BN_MP_ADD_C
+ #define BN_S_MP_SUB_C
#define BN_MP_LSHD_C
#define BN_MP_CLEAR_C
#endif
@@ -491,8 +524,8 @@
#define BN_MP_INIT_SIZE_C
#define BN_MP_CLAMP_C
#define BN_MP_SQR_C
- #define BN_MP_SUB_C
#define BN_S_MP_ADD_C
+ #define BN_S_MP_SUB_C
#define BN_MP_LSHD_C
#define BN_MP_ADD_C
#define BN_MP_CLEAR_C
@@ -516,8 +549,9 @@
#define BN_MP_INIT_C
#define BN_MP_DIV_C
#define BN_MP_CLEAR_C
- #define BN_MP_ADD_C
+ #define BN_MP_ISZERO_C
#define BN_MP_EXCH_C
+ #define BN_MP_ADD_C
#endif
#if defined(BN_MP_MOD_2D_C)
@@ -583,10 +617,14 @@
#endif
#if defined(BN_MP_N_ROOT_C)
+ #define BN_MP_N_ROOT_EX_C
+#endif
+
+#if defined(BN_MP_N_ROOT_EX_C)
#define BN_MP_INIT_C
#define BN_MP_SET_C
#define BN_MP_COPY_C
- #define BN_MP_EXPT_D_C
+ #define BN_MP_EXPT_D_EX_C
#define BN_MP_MUL_C
#define BN_MP_SUB_C
#define BN_MP_MUL_D_C
@@ -667,9 +705,9 @@
#endif
#if defined(BN_MP_RADIX_SIZE_C)
+ #define BN_MP_ISZERO_C
#define BN_MP_COUNT_BITS_C
#define BN_MP_INIT_COPY_C
- #define BN_MP_ISZERO_C
#define BN_MP_DIV_D_C
#define BN_MP_CLEAR_C
#endif
@@ -687,7 +725,6 @@
#if defined(BN_MP_READ_RADIX_C)
#define BN_MP_ZERO_C
#define BN_MP_S_RMAP_C
- #define BN_MP_RADIX_SMAP_C
#define BN_MP_MUL_D_C
#define BN_MP_ADD_D_C
#define BN_MP_ISZERO_C
@@ -788,6 +825,12 @@
#define BN_MP_CLAMP_C
#endif
+#if defined(BN_MP_SET_LONG_C)
+#endif
+
+#if defined(BN_MP_SET_LONG_LONG_C)
+#endif
+
#if defined(BN_MP_SHRINK_C)
#endif
@@ -823,6 +866,25 @@
#define BN_MP_CLEAR_C
#endif
+#if defined(BN_MP_SQRTMOD_PRIME_C)
+ #define BN_MP_CMP_D_C
+ #define BN_MP_ZERO_C
+ #define BN_MP_JACOBI_C
+ #define BN_MP_INIT_MULTI_C
+ #define BN_MP_MOD_D_C
+ #define BN_MP_ADD_D_C
+ #define BN_MP_DIV_2_C
+ #define BN_MP_EXPTMOD_C
+ #define BN_MP_COPY_C
+ #define BN_MP_SUB_D_C
+ #define BN_MP_ISEVEN_C
+ #define BN_MP_SET_INT_C
+ #define BN_MP_SQRMOD_C
+ #define BN_MP_MULMOD_C
+ #define BN_MP_SET_C
+ #define BN_MP_CLEAR_MULTI_C
+#endif
+
#if defined(BN_MP_SUB_C)
#define BN_S_MP_ADD_C
#define BN_MP_CMP_MAG_C
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
new file mode 100644
index 0000000..d23c333
--- /dev/null
+++ b/libtommath/tommath_private.h
@@ -0,0 +1,125 @@
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
+ */
+#ifndef TOMMATH_PRIV_H_
+#define TOMMATH_PRIV_H_
+
+#include <tommath.h>
+#include <ctype.h>
+
+#ifndef MIN
+#define MIN(x,y) (((x) < (y)) ? (x) : (y))
+#endif
+
+#ifndef MAX
+#define MAX(x,y) (((x) > (y)) ? (x) : (y))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+
+/* C++ compilers don't like assigning void * to mp_digit * */
+#define OPT_CAST(x) (x *)
+
+#else
+
+/* C on the other hand doesn't care */
+#define OPT_CAST(x)
+
+#endif
+
+/* define heap macros */
+#if 0
+#ifndef XMALLOC
+ /* default to libc stuff */
+ #define XMALLOC malloc
+ #define XFREE free
+ #define XREALLOC realloc
+ #define XCALLOC calloc
+#else
+ /* prototypes for our heap functions */
+ extern void *XMALLOC(size_t n);
+ extern void *XREALLOC(void *p, size_t n);
+ extern void *XCALLOC(size_t n, size_t s);
+ extern void XFREE(void *p);
+#endif
+#endif
+
+/* lowlevel functions, do not call! */
+int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
+int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
+#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
+int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
+int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
+int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
+int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
+int fast_s_mp_sqr(mp_int *a, mp_int *b);
+int s_mp_sqr(mp_int *a, mp_int *b);
+int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
+int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
+int mp_karatsuba_sqr(mp_int *a, mp_int *b);
+int mp_toom_sqr(mp_int *a, mp_int *b);
+int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
+int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
+int fast_mp_montgomery_reduce(mp_int *x, mp_int *n, mp_digit rho);
+int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int redmode);
+int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode);
+void bn_reverse(unsigned char *s, int len);
+
+extern const char *mp_s_rmap;
+
+/* Fancy macro to set an MPI from another type.
+ * There are several things assumed:
+ * x is the counter and unsigned
+ * a is the pointer to the MPI
+ * b is the original value that should be set in the MPI.
+ */
+#define MP_SET_XLONG(func_name, type) \
+int func_name (mp_int * a, type b) \
+{ \
+ unsigned int x; \
+ int res; \
+ \
+ mp_zero (a); \
+ \
+ /* set four bits at a time */ \
+ for (x = 0; x < (sizeof(type) * 2u); x++) { \
+ /* shift the number up four bits */ \
+ if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { \
+ return res; \
+ } \
+ \
+ /* OR in the top four bits of the source */ \
+ a->dp[0] |= (b >> ((sizeof(type) * 8u) - 4u)) & 15u; \
+ \
+ /* shift the source up to the next four bits */ \
+ b <<= 4; \
+ \
+ /* ensure that digits are not clamped off */ \
+ a->used += 1; \
+ } \
+ mp_clamp (a); \
+ return MP_OKAY; \
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
+
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/libtommath/tommath_superclass.h b/libtommath/tommath_superclass.h
index e3926df..0eeaf5f 100644
--- a/libtommath/tommath_superclass.h
+++ b/libtommath/tommath_superclass.h
@@ -60,9 +60,9 @@
#undef BN_FAST_MP_INVMOD_C
/* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
- * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
+ * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
* which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
- * trouble.
+ * trouble.
*/
#undef BN_S_MP_MUL_DIGS_C
#undef BN_S_MP_SQR_C
@@ -70,3 +70,7 @@
#endif
#endif
+
+/* $Source$ */
+/* $Revision$ */
+/* $Date$ */
diff --git a/macosx/Tcl-Common.xcconfig b/macosx/Tcl-Common.xcconfig
index f1ecee6..77402b7 100644
--- a/macosx/Tcl-Common.xcconfig
+++ b/macosx/Tcl-Common.xcconfig
@@ -19,7 +19,7 @@ GCC_NO_COMMON_BLOCKS = YES
GCC_DYNAMIC_NO_PIC = YES
GCC_VERSION = 4.2
GCC = gcc-$(GCC_VERSION)
-WARNING_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-value -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS)
+WARNING_CFLAGS = -Wall -Wwrite-strings -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-value -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS)
BINDIR = $(PREFIX)/bin
CFLAGS = $(CFLAGS)
CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS)
diff --git a/macosx/Tcl.xcode/project.pbxproj b/macosx/Tcl.xcode/project.pbxproj
index a99afc5..8c54b5d 100644
--- a/macosx/Tcl.xcode/project.pbxproj
+++ b/macosx/Tcl.xcode/project.pbxproj
@@ -166,6 +166,7 @@
F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
F9E61D2B090A48A4002B3151 /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426C08F272B3004A47F5 /* bn_mp_and.c */; };
F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */; };
+ F9E61D2C090A48AC002B3151 /* bn_mp_expt_d_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d_ex.c */; };
F9E61D2D090A48BB002B3151 /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */; };
F9E61D2E090A48BF002B3151 /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A308F272B3004A47F5 /* bn_mp_or.c */; };
F9E61D2F090A48C7002B3151 /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */; };
@@ -837,7 +838,6 @@
F96D447308F272BA004A47F5 /* coffbase.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = coffbase.txt; sourceTree = "<group>"; };
F96D447408F272BA004A47F5 /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
F96D447508F272BA004A47F5 /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
- F96D447608F272BA004A47F5 /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = "<group>"; };
F96D447708F272BA004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
F96D447808F272BA004A47F5 /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = "<group>"; };
F96D447908F272BA004A47F5 /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = "<group>"; };
@@ -1442,6 +1442,7 @@
F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */,
F96D427E08F272B3004A47F5 /* bn_mp_exch.c */,
F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */,
+ F96D427F08F272B3004A47F5 /* bn_mp_expt_d_ex.c */,
F96D428708F272B3004A47F5 /* bn_mp_grow.c */,
F96D428808F272B3004A47F5 /* bn_mp_init.c */,
F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */,
@@ -1759,7 +1760,6 @@
F96D447308F272BA004A47F5 /* coffbase.txt */,
F96D447408F272BA004A47F5 /* configure */,
F96D447508F272BA004A47F5 /* configure.ac */,
- F96D447608F272BA004A47F5 /* makefile.bc */,
F96D447708F272BA004A47F5 /* Makefile.in */,
F96D447808F272BA004A47F5 /* makefile.vc */,
F96D447908F272BA004A47F5 /* nmakehlp.c */,
@@ -2075,6 +2075,7 @@
F96D48F808F272C3004A47F5 /* bn_mp_div_d.c in Sources */,
F96D48FC08F272C3004A47F5 /* bn_mp_exch.c in Sources */,
F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */,
+ F9E61D2C090A48AC002B3151 /* bn_mp_expt_d_ex.c in Sources */,
F96D490508F272C3004A47F5 /* bn_mp_grow.c in Sources */,
F96D490608F272C3004A47F5 /* bn_mp_init.c in Sources */,
F96D490708F272C3004A47F5 /* bn_mp_init_copy.c in Sources */,
diff --git a/macosx/Tcl.xcodeproj/project.pbxproj b/macosx/Tcl.xcodeproj/project.pbxproj
index 393fd31..6c6acb2 100644
--- a/macosx/Tcl.xcodeproj/project.pbxproj
+++ b/macosx/Tcl.xcodeproj/project.pbxproj
@@ -165,7 +165,8 @@
F9E61D29090A486C002B3151 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A208F272B3004A47F5 /* bn_mp_neg.c */; };
F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
F9E61D2B090A48A4002B3151 /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426C08F272B3004A47F5 /* bn_mp_and.c */; };
- F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */; };
+ F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d_ex.c */; };
+ F9E61D2C090A48AC002B3151 /* bn_mp_expt_d_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */; };
F9E61D2D090A48BB002B3151 /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */; };
F9E61D2E090A48BF002B3151 /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A308F272B3004A47F5 /* bn_mp_or.c */; };
F9E61D2F090A48C7002B3151 /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */; };
@@ -579,6 +580,7 @@
F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_d.c; sourceTree = "<group>"; };
F96D427E08F272B3004A47F5 /* bn_mp_exch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exch.c; sourceTree = "<group>"; };
F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_expt_d.c; sourceTree = "<group>"; };
+ F96D427F08F272B3004A47F5 /* bn_mp_expt_d_ex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_expt_d_ex.c; sourceTree = "<group>"; };
F96D428708F272B3004A47F5 /* bn_mp_grow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_grow.c; sourceTree = "<group>"; };
F96D428808F272B3004A47F5 /* bn_mp_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init.c; sourceTree = "<group>"; };
F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_copy.c; sourceTree = "<group>"; };
@@ -837,7 +839,6 @@
F96D447308F272BA004A47F5 /* coffbase.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = coffbase.txt; sourceTree = "<group>"; };
F96D447408F272BA004A47F5 /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
F96D447508F272BA004A47F5 /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
- F96D447608F272BA004A47F5 /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = "<group>"; };
F96D447708F272BA004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
F96D447808F272BA004A47F5 /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = "<group>"; };
F96D447908F272BA004A47F5 /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = "<group>"; };
@@ -1442,6 +1443,7 @@
F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */,
F96D427E08F272B3004A47F5 /* bn_mp_exch.c */,
F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */,
+ F96D427F08F272B3004A47F5 /* bn_mp_expt_d_ex.c */,
F96D428708F272B3004A47F5 /* bn_mp_grow.c */,
F96D428808F272B3004A47F5 /* bn_mp_init.c */,
F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */,
@@ -1759,7 +1761,6 @@
F96D447308F272BA004A47F5 /* coffbase.txt */,
F96D447408F272BA004A47F5 /* configure */,
F96D447508F272BA004A47F5 /* configure.ac */,
- F96D447608F272BA004A47F5 /* makefile.bc */,
F96D447708F272BA004A47F5 /* Makefile.in */,
F96D447808F272BA004A47F5 /* makefile.vc */,
F96D447908F272BA004A47F5 /* nmakehlp.c */,
@@ -2075,6 +2076,7 @@
F96D48F808F272C3004A47F5 /* bn_mp_div_d.c in Sources */,
F96D48FC08F272C3004A47F5 /* bn_mp_exch.c in Sources */,
F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */,
+ F9E61D2C090A48AC002B3151 /* bn_mp_expt_d_ex.c in Sources */,
F96D490508F272C3004A47F5 /* bn_mp_grow.c in Sources */,
F96D490608F272C3004A47F5 /* bn_mp_init.c in Sources */,
F96D490708F272C3004A47F5 /* bn_mp_init_copy.c in Sources */,
diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c
index 946e350..75fda4b 100644
--- a/macosx/tclMacOSXFCmd.c
+++ b/macosx/tclMacOSXFCmd.c
@@ -636,12 +636,12 @@ SetOSTypeFromAny(
Tcl_Obj *objPtr) /* Pointer to the object to convert */
{
const char *string;
- int length, result = TCL_OK;
+ int result = TCL_OK;
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
- string = TclGetStringFromObj(objPtr, &length);
- Tcl_UtfToExternalDString(encoding, string, length, &ds);
+ string = TclGetString(objPtr);
+ Tcl_UtfToExternalDString(encoding, string, objPtr->length, &ds);
if (Tcl_DStringLength(&ds) > 4) {
if (interp) {
diff --git a/macosx/tclMacOSXNotify.c b/macosx/tclMacOSXNotify.c
index a7f26b7..1af73de 100644
--- a/macosx/tclMacOSXNotify.c
+++ b/macosx/tclMacOSXNotify.c
@@ -385,8 +385,7 @@ static CFStringRef tclEventsOnlyRunLoopMode = NULL;
*/
static void StartNotifierThread(void);
-static void NotifierThreadProc(ClientData clientData)
- __attribute__ ((__noreturn__));
+static TCL_NORETURN void NotifierThreadProc(ClientData clientData);
static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
static void TimerWakeUp(CFRunLoopTimerRef timer, void *info);
static void QueueFileEvents(void *info);
@@ -1753,7 +1752,7 @@ TclUnixWaitForFile(
*----------------------------------------------------------------------
*/
-static void
+static TCL_NORETURN void
NotifierThreadProc(
ClientData clientData) /* Not used. */
{
diff --git a/tests/all.tcl b/tests/all.tcl
index 0a6f57f..69a16ba 100644
--- a/tests/all.tcl
+++ b/tests/all.tcl
@@ -11,7 +11,7 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
package prefer latest
-package require Tcl 8.5
+package require Tcl 8.5-
package require tcltest 2.2
namespace import tcltest::*
configure {*}$argv -testdir [file dir [info script]]
diff --git a/tests/binary.test b/tests/binary.test
index 40b1315..7738f69 100644
--- a/tests/binary.test
+++ b/tests/binary.test
@@ -2837,6 +2837,19 @@ test binary-76.2 {binary string appending growth algorithm} win {
# Append to it
string length [append str [binary format a* foo]]
} 3
+
+test binary-77.1 {string cat ops on all bytearrays} {
+ apply {{a b} {
+ return [binary format H* $a][binary format H* $b]
+ }} ab cd
+} [binary format H* abcd]
+test binary-77.2 {string cat ops on all bytearrays} {
+ apply {{a b} {
+ set one [binary format H* $a]
+ return $one[binary format H* $b]
+ }} ab cd
+} [binary format H* abcd]
+
# ----------------------------------------------------------------------
# cleanup
diff --git a/tests/case.test b/tests/case.test
index 6d63cea..d7558a9 100644
--- a/tests/case.test
+++ b/tests/case.test
@@ -11,6 +11,11 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+if {![llength [info commands case]]} {
+ # No "case" command? So no need to test
+ return
+}
+
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
diff --git a/tests/chanio.test b/tests/chanio.test
index 075b64e..8e27af9 100644
--- a/tests/chanio.test
+++ b/tests/chanio.test
@@ -6775,7 +6775,7 @@ test chan-io-52.10 {TclCopyChannel & encodings} {fcopy} {
} 5
test chan-io-52.11 {TclCopyChannel & encodings} -setup {
set f [open $path(utf8-fcopy.txt) w]
- fconfigure $f -encoding utf-8
+ fconfigure $f -encoding utf-8 -translation lf
puts $f "\u0410\u0410"
close $f
} -constraints {fcopy} -body {
diff --git a/tests/clock.test b/tests/clock.test
index 08036ca..6a0fecd 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -37009,10 +37009,10 @@ test clock-67.5 {Change scan %x output on global locale change [Bug 4a0c163d24]}
set current [msgcat::mclocale]
} -body {
msgcat::mclocale de_de
- set res [clock scan "01.01.1970" -locale current -format %x]
+ set res [clock scan "01.01.1970" -locale current -format %x -gmt 1]
msgcat::mclocale en_uk
# This will fail without the bug fix, as still de_de is active
- expr {$res == [clock scan "01/01/1970" -locale current -format %x]}
+ expr {$res == [clock scan "01/01/1970" -locale current -format %x -gmt 1]}
} -cleanup {
msgcat::mclocale $current
} -result {1}
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index b4ef605..3c58c1b 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -167,10 +167,10 @@ test cmdAH-3.2 {Tcl_ContinueObjCmd, success} {
test cmdAH-4.1 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding
-} -result {wrong # args: should be "encoding option ?arg ...?"}
+} -result {wrong # args: should be "encoding subcommand ?arg ...?"}
test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding foo
-} -result {bad option "foo": must be convertfrom, convertto, dirs, names, or system}
+} -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system}
test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertto
} -result {wrong # args: should be "encoding convertto ?encoding? data"}
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test
index 2d68138..a5f3009 100644
--- a/tests/cmdMZ.test
+++ b/tests/cmdMZ.test
@@ -234,7 +234,7 @@ test cmdMZ-3.3 {Tcl_SourceObjCmd: error conditions} -constraints {
test cmdMZ-3.4 {Tcl_SourceObjCmd: error conditions} -constraints {
unixOrPc
} -returnCodes error -body {
- source a b
+ source a b c d e f
} -match glob -result {wrong # args: should be "source*fileName"}
test cmdMZ-3.5 {Tcl_SourceObjCmd: error in script} -body {
set file [makeFile {
diff --git a/tests/coroutine.test b/tests/coroutine.test
index 86fa6e3..07feb53 100644
--- a/tests/coroutine.test
+++ b/tests/coroutine.test
@@ -741,6 +741,45 @@ test coroutine-7.12 {coro floor above street level #3008307} -body {
list
} -result {}
+test coroutine-8.0.0 {coro inject executed} -body {
+ coroutine demo apply {{} { foreach i {1 2} yield }}
+ demo
+ set ::result none
+ tcl::unsupported::inject demo set ::result inject-executed
+ demo
+ set ::result
+} -result {inject-executed}
+test coroutine-8.0.1 {coro inject after error} -body {
+ coroutine demo apply {{} { foreach i {1 2} yield; error test }}
+ demo
+ set ::result none
+ tcl::unsupported::inject demo set ::result inject-executed
+ lappend ::result [catch {demo} err] $err
+} -result {inject-executed 1 test}
+test coroutine-8.1.1 {coro inject, ticket 42202ba1e5ff566e} -body {
+ interp create slave
+ slave eval {
+ coroutine demo apply {{} { while {1} yield }}
+ demo
+ tcl::unsupported::inject demo set ::result inject-executed
+ }
+ interp delete slave
+} -result {}
+test coroutine-8.1.2 {coro inject with result, ticket 42202ba1e5ff566e} -body {
+ interp create slave
+ slave eval {
+ coroutine demo apply {{} { while {1} yield }}
+ demo
+ tcl::unsupported::inject demo set ::result inject-executed
+ }
+ slave eval demo
+ set result [slave eval {set ::result}]
+
+ interp delete slave
+ set result
+} -result {inject-executed}
+
+
# cleanup
unset lambda
diff --git a/tests/expr.test b/tests/expr.test
index 4046411..8e083c5 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -910,6 +910,15 @@ test expr-22.9 {non-numeric floats: shared object equality and NaN} {
set x NaN
expr {$x == $x}
} 0
+# Make sure [Bug d0f7ba56f0] stays fixed.
+test expr-22.10 {non-numeric arguments: equality and NaN} {
+ set x NaN
+ expr {$x > "Gran"}
+} 1
+test expr-22.11 {non-numeric arguments: equality and NaN} {
+ set x NaN
+ expr {"Gran" < $x}
+} 1
# Tests for exponentiation handling
test expr-23.1 {CompileExponentialExpr: just exponential expr} {expr 4**2} 16
diff --git a/tests/fCmd.test b/tests/fCmd.test
index c8264b2..709bfb4 100644
--- a/tests/fCmd.test
+++ b/tests/fCmd.test
@@ -23,7 +23,7 @@ cd [temporaryDirectory]
testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testchmod [llength [info commands testchmod]]
testConstraint winVista 0
-testConstraint win2000orXP 0
+testConstraint winXP 0
# Don't know how to determine this constraint correctly
testConstraint notNetworkFilesystem 0
testConstraint reg 0
@@ -66,12 +66,10 @@ if {[testConstraint unix]} {
# Also used in winFCmd...
if {[testConstraint win]} {
set major [string index $tcl_platform(osVersion) 0]
- if {[testConstraint nt] && $major > 4} {
- if {$major > 5} {
- testConstraint winVista 1
- } elseif {$major == 5} {
- testConstraint win2000orXP 1
- }
+ if {$major > 5} {
+ testConstraint winVista 1
+ } else {
+ testConstraint winXP 1
}
}
@@ -792,7 +790,7 @@ test fCmd-9.3 {file rename: comprehensive: file to new name} -setup {
} -result {{tf3 tf4} 1 0}
test fCmd-9.4.a {file rename: comprehensive: dir to new name} -setup {
cleanup
-} -constraints {win win2000orXP testchmod} -body {
+} -constraints {win testchmod} -body {
file mkdir td1 td2
testchmod 0o555 td2
file rename td1 td3
@@ -824,7 +822,7 @@ test fCmd-9.5 {file rename: comprehensive: file to self} -setup {
} -result {tf1 tf2 1 0}
test fCmd-9.6.a {file rename: comprehensive: dir to self} -setup {
cleanup
-} -constraints {win win2000orXP testchmod} -body {
+} -constraints {win winXP testchmod} -body {
file mkdir td1
file mkdir td2
testchmod 0o555 td2
diff --git a/tests/format.test b/tests/format.test
index 27eac31..00b6939 100644
--- a/tests/format.test
+++ b/tests/format.test
@@ -21,6 +21,7 @@ testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}]
testConstraint wideIs64bit \
[expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}]
testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}]
+testConstraint pointerIs64bit [expr {$tcl_platform(pointerSize) >= 8}]
test format-1.1 {integer formatting} {
format "%*d %d %d %d" 6 34 16923 -12 -1
@@ -349,9 +350,9 @@ test format-8.19 {error conditions} {
catch {format %q x}
} 1
test format-8.20 {error conditions} {
- catch {format %q x} msg
+ catch {format %r x} msg
set msg
-} {bad field specifier "q"}
+} {bad field specifier "r"}
test format-8.21 {error conditions} {
catch {format %d}
} 1
@@ -363,6 +364,26 @@ test format-8.23 {error conditions} {
catch {format "%d %d" 24 xyz} msg
set msg
} {expected integer but got "xyz"}
+# Since "%zd" and "%td" are equivalent to "%lld" in 64-bit platforms and
+# equivalent to "%d" in 32-bit platforms, they are really not useful in
+# scripts, therefore they are not documented. It's intended use is through
+# the function Tcl_AppendPrintfToObj (et al).
+test format-8.24 {Undocumented formats} -body {
+ format "%zd %td %d" [expr 2**30] [expr 2**30] [expr 2**30]
+} -result {1073741824 1073741824 1073741824}
+test format-8.25 {Undocumented formats} -constraints pointerIs64bit -body {
+ format "%zd %td %lld" [expr 2**33] [expr 2**33] [expr 2**33]
+} -result {8589934592 8589934592 8589934592}
+# Since "%p" is equivalent to "%#llx" in 64-bit platforms and equivalent
+# to "%#x" in 32-bit platforms, it are really not useful in scripts,
+# therefore they are not documented. It's intended use is through the
+# function Tcl_AppendPrintfToObj (et al).
+test format-8.26 {Undocumented formats} -body {
+ format "%p %#x" [expr 2**31] [expr 2**31]
+} -result {0x80000000 0x80000000}
+test format-8.27 {Undocumented formats} -constraints pointerIs64bit -body {
+ format "%p %#llx" [expr 2**33] [expr 2**33]
+} -result {0x200000000 0x200000000}
test format-9.1 {long result} {
set a {1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
@@ -564,9 +585,12 @@ test format-19.3 {Bug 2830354} {
test format-20.1 {Bug 2932421: plain %s caused intrep change of args} -body {
set x [dict create a b c d]
format %s $x
- # After this, obj in $x should be a dict with a non-NULL bytes field
+ # After this, obj in $x should be a dict
+ # We are testing to make sure it has not been shimmered to a
+ # different intrep when that is not necessary.
+ # Whether or not there is a string rep - we should not care!
tcl::unsupported::representation $x
-} -match glob -result {value is a dict with *, string representation "*"}
+} -match glob -result {value is a dict *}
# cleanup
catch {unset a}
diff --git a/tests/get.test b/tests/get.test
index d51ec6d..d6a7206 100644
--- a/tests/get.test
+++ b/tests/get.test
@@ -19,9 +19,10 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testgetint [llength [info commands testgetint]]
+testConstraint testdoubleobj [llength [info commands testdoubleobj]]
testConstraint longIs32bit [expr {int(0x80000000) < 0}]
testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}]
-
+
test get-1.1 {Tcl_GetInt procedure} testgetint {
testgetint 44 { 22}
} {66}
@@ -95,7 +96,24 @@ test get-3.2 {Tcl_GetDouble(FromObj), bad numbers} {
}
set result
} {0 1 0 1 1 {expected floating-point number but got "++1.0"} 1 {expected floating-point number but got "+-1.0"} 1 {expected floating-point number but got "-+1.0"} 0 -1 1 {expected floating-point number but got "--1.0"} 1 {expected floating-point number but got "- +1.0"}}
-
+# Bug 7114ac6141
+test get-3.3 {tcl_GetInt with iffy numbers} testgetint {
+ lmap x {0 " 0" "0 " " 0 " " 0xa " " 007 " " 0o10 " " 0b10 "} {
+ catch {testgetint 44 $x} x
+ set x
+ }
+} {44 44 44 44 54 51 52 46}
+test get-3.4 {Tcl_GetDouble with iffy numbers} testdoubleobj {
+ lmap x {0 0.0 " .0" ".0 " " 0e0 " "07" "- 0" "-0" "0o12" "0b10"} {
+ catch {testdoubleobj set 1 $x} x
+ set x
+ }
+} {0.0 0.0 0.0 0.0 0.0 7.0 {expected floating-point number but got "- 0"} 0.0 10.0 2.0}
+
# cleanup
::tcltest::cleanupTests
return
+
+# Local Variables:
+# mode: tcl
+# End:
diff --git a/tests/history.test b/tests/history.test
index c2d2124..9ff41f2 100644
--- a/tests/history.test
+++ b/tests/history.test
@@ -11,8 +11,8 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
+if {"::tcltest" ni [namespace children]} {
+ package require tcltest 2
namespace import -force ::tcltest::*
}
@@ -245,6 +245,60 @@ test history-9.2 {miscellaneous} history {
catch {history gorp} msg
set msg
} {unknown or ambiguous subcommand "gorp": must be add, change, clear, event, info, keep, nextid, or redo}
+
+# History retains references; Bug 1ae12987cb
+test history-10.1 {references kept by history} -constraints history -setup {
+ interp create histtest
+ histtest eval {
+ # Trigger any autoloading that might be present
+ catch {history}
+ proc refcount {x} {
+ set rep [::tcl::unsupported::representation $x]
+ regexp {with a refcount of (\d+)} $rep -> rc
+ # Ignore the references due to calling this procedure
+ return [expr {$rc - 3}]
+ }
+ }
+} -body {
+ histtest eval {
+ # A fresh object, refcount 1 from the variable we write it to
+ set obj [expr rand()]
+ set baseline [refcount $obj]
+ lappend result [refcount $obj]
+ history add [list list $obj]
+ lappend result [refcount $obj]
+ history clear
+ lappend result [refcount $obj]
+ }
+} -cleanup {
+ interp delete histtest
+} -result {1 2 1}
+test history-10.2 {references kept by history} -constraints history -setup {
+ interp create histtest
+ histtest eval {
+ # Trigger any autoloading that might be present
+ catch {history}
+ proc refcount {x} {
+ set rep [::tcl::unsupported::representation $x]
+ regexp {with a refcount of (\d+)} $rep -> rc
+ # Ignore the references due to calling this procedure
+ return [expr {$rc - 3}]
+ }
+ }
+} -body {
+ histtest eval {
+ # A fresh object, refcount 1 from the variable we write it to
+ set obj [expr rand()]
+ set baseline [refcount $obj]
+ lappend result [refcount $obj]
+ history add [list list $obj]
+ lappend result [refcount $obj]
+ rename history {}
+ lappend result [refcount $obj]
+ }
+} -cleanup {
+ interp delete histtest
+} -result {1 2 1}
# cleanup
::tcltest::cleanupTests
diff --git a/tests/http.test b/tests/http.test
index 41820cb..75c963d 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -36,7 +36,6 @@ proc bgerror {args} {
puts stderr $errorInfo
}
-set port 8010
set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null"
catch {unset data}
@@ -55,9 +54,8 @@ catch {package require Thread 2.7-}
if {[catch {package present Thread}] == 0 && [file exists $httpdFile]} {
set httpthread [thread::create -preserved]
thread::send $httpthread [list source $httpdFile]
- thread::send $httpthread [list set port $port]
thread::send $httpthread [list set bindata $bindata]
- thread::send $httpthread {httpd_init $port}
+ thread::send $httpthread {httpd_init 0; set port} port
puts "Running httpd in thread $httpthread"
} else {
if {![file exists $httpdFile]} {
@@ -69,10 +67,8 @@ if {[catch {package present Thread}] == 0 && [file exists $httpdFile]} {
# Let the OS pick the port; that's much more flexible
if {[catch {httpd_init 0} listen]} {
puts "Cannot start http server, http test skipped"
- unset port
+ catch {unset port}
return
- } else {
- set port [lindex [fconfigure $listen -sockname] 2]
}
}
@@ -133,6 +129,7 @@ set tail /a/b/c
set url //[info hostname]:$port/a/b/c
set fullurl HTTP://user:pass@[info hostname]:$port/a/b/c
set binurl //[info hostname]:$port/binary
+set xmlurl //[info hostname]:$port/xml
set posturl //[info hostname]:$port/post
set badposturl //[info hostname]:$port/droppost
set authorityurl //[info hostname]:$port
@@ -431,6 +428,13 @@ Accept text/plain,application/tcl-test-value
Accept-Encoding .*
Content-Type application/x-www-form-urlencoded
Content-Length 5}
+# Bug 838e99a76d
+test http-3.33 {http::geturl application/xml is text} -body {
+ set token [http::geturl "$xmlurl"]
+ scan [http::data $token] "<%\[^>]>%c<%\[^>]>"
+} -cleanup {
+ catch { http::cleanup $token }
+} -result {test 4660 /test}
test http-4.1 {http::Event} -body {
set token [http::geturl $url -keepalive 0]
diff --git a/tests/httpd b/tests/httpd
index c934fac..f15d71b 100644
--- a/tests/httpd
+++ b/tests/httpd
@@ -11,7 +11,12 @@
#set httpLog 1
proc httpd_init {{port 8015}} {
- socket -server httpdAccept $port
+ set s [socket -server httpdAccept $port]
+ # Save the actual port number in a global variable.
+ # This is important when we're called with port 0
+ # for picking an unused port at random.
+ set ::port [lindex [chan configure $s -sockname] 2]
+ return $s
}
proc httpd_log {args} {
global httpLog
@@ -171,6 +176,10 @@ proc httpdRespond { sock } {
set html "$bindata[info hostname]:$port$data(url)"
set type application/octet-stream
}
+ *xml* {
+ set html [encoding convertto utf-8 "<test>\u1234</test>"]
+ set type "application/xml;charset=UTF-8"
+ }
*post* {
set html "Got [string length $data(query)] bytes"
set type text/plain
diff --git a/tests/httpd11.tcl b/tests/httpd11.tcl
index 6eae2b7..7880494 100644
--- a/tests/httpd11.tcl
+++ b/tests/httpd11.tcl
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-package require Tcl 8.6
+package require Tcl 8.6-
proc ::tcl::dict::get? {dict key} {
if {[dict exists $dict $key]} {
diff --git a/tests/httpold.test b/tests/httpold.test
index 5995bed..ab26613 100644
--- a/tests/httpold.test
+++ b/tests/httpold.test
@@ -1,3 +1,4 @@
+# -*- tcl -*-
# Commands covered: http_config, http_get, http_wait, http_reset
#
# This file contains a collection of tests for the http script library.
@@ -41,10 +42,9 @@ catch {unset data}
##
source [file join [file dirname [info script]] httpd]
-set port 8010
-if [catch {httpd_init $port} listen] {
+if [catch {httpd_init 0} listen] {
puts "Cannot start http server, http test skipped"
- unset port
+ catch {unset port}
::tcltest::cleanupTests
return
}
diff --git a/tests/incr.test b/tests/incr.test
index 9243be0..aa2872a 100644
--- a/tests/incr.test
+++ b/tests/incr.test
@@ -494,6 +494,18 @@ test incr-2.31 {incr command (compiled): bad increment} {
(reading increment)
invoked from within
"incr x 1a"}}
+test incr-2.32 {incr command (compiled): bad pure list increment} {
+ list [catch {incr x [list 1 2]} msg] $msg $::errorInfo
+} {1 {expected integer but got "1 2"} {expected integer but got "1 2"
+ (reading increment)
+ invoked from within
+"incr x [list 1 2]"}}
+test incr-2.33 {incr command (compiled): bad pure dict increment} {
+ list [catch {incr x [dict create 1 2]} msg] $msg $::errorInfo
+} {1 {expected integer but got "1 2"} {expected integer but got "1 2"
+ (reading increment)
+ invoked from within
+"incr x [dict create 1 2]"}}
test incr-3.1 {increment by wide amount: bytecode route} {
set x 0
diff --git a/tests/info.test b/tests/info.test
index a6a5919..fd89b47 100644
--- a/tests/info.test
+++ b/tests/info.test
@@ -397,8 +397,8 @@ test info-10.3 {info library option} -body {
set tcl_library $savedLibrary; unset savedLibrary
test info-11.1 {info loaded option} -body {
- info loaded a b
-} -returnCodes error -result {wrong # args: should be "info loaded ?interp?"}
+ info loaded a b c
+} -returnCodes error -result {wrong # args: should be "info loaded ?interp? ?packageName?"}
test info-11.2 {info loaded option} -body {
info loaded {}; info loaded gorp
} -returnCodes error -result {could not find interpreter "gorp"}
diff --git a/tests/interp.test b/tests/interp.test
index 34b5bf9..1389304 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -20,7 +20,7 @@ catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testinterpdelete [llength [info commands testinterpdelete]]
-set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source tcl:file:atime tcl:file:attributes tcl:file:copy tcl:file:delete tcl:file:dirname tcl:file:executable tcl:file:exists tcl:file:extension tcl:file:isdirectory tcl:file:isfile tcl:file:link tcl:file:lstat tcl:file:mkdir tcl:file:mtime tcl:file:nativename tcl:file:normalize tcl:file:owned tcl:file:readable tcl:file:readlink tcl:file:rename tcl:file:rootname tcl:file:size tcl:file:stat tcl:file:tail tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable unload}
+set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source tcl:encoding:dirs tcl:file:atime tcl:file:attributes tcl:file:copy tcl:file:delete tcl:file:dirname tcl:file:executable tcl:file:exists tcl:file:extension tcl:file:isdirectory tcl:file:isfile tcl:file:link tcl:file:lstat tcl:file:mkdir tcl:file:mtime tcl:file:nativename tcl:file:normalize tcl:file:owned tcl:file:readable tcl:file:readlink tcl:file:rename tcl:file:rootname tcl:file:size tcl:file:stat tcl:file:tail tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable unload}
foreach i [interp slaves] {
interp delete $i
@@ -606,6 +606,19 @@ test interp-14.10 {testing interp-alias: error messages} -setup {
invoked from within
"a 1"}
+test interp-14.11 {{interp alias} {target named the empty string} {bug 2bf56185}} -setup {
+ set interp [interp create [info cmdcount]]
+ interp eval $interp {
+ proc {} args {return $args}
+ }
+
+} -body {
+ interp alias {} p1 $interp {}
+ p1 one two three
+} -cleanup {
+ interp delete $interp
+} -result {one two three}
+
# part 15: testing file sharing
test interp-15.1 {testing file sharing} {
catch {interp delete z}
diff --git a/tests/link.test b/tests/link.test
index 00e490c..dda7d6b 100644
--- a/tests/link.test
+++ b/tests/link.test
@@ -89,6 +89,90 @@ test link-2.5 {writing bad values into variables} -setup {
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set wide gorp} msg] $msg $bool
} -result {1 {can't set "wide": variable must have integer value} 1}
+test link-2.6 {writing C variables from Tcl} -constraints {testlink} -setup {
+ testlink delete
+} -body {
+ testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ set int "+"
+ set real "+"
+ set bool 1
+ set string "+"
+ set wide "+"
+ set char "+"
+ set uchar "+"
+ set short "+"
+ set ushort "+"
+ set uint "+"
+ set long "+"
+ set ulong "+"
+ set float "+"
+ set uwide "+"
+ concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} -result {1 1.0 1 + 1 1 1 1 1 1 1 1 1.0 1 | + + 1 + + + + + + + + + + +}
+test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
+ testlink delete
+} -body {
+ testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ set int "-"
+ set real "-"
+ set bool 0
+ set string "-"
+ set wide "-"
+ set char "-"
+ set uchar "-"
+ set short "-"
+ set ushort "-"
+ set uint "-"
+ set long "-"
+ set ulong "-"
+ set float "-"
+ set uwide "-"
+ concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} -result {0 0.0 0 - 0 0 0 0 0 0 0 0 0.0 0 | - - 0 - - - - - - - - - - -}
+test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
+ testlink delete
+} -body {
+ testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ set int "0x"
+ set real "0b"
+ set bool 0
+ set string "0"
+ set wide "0O"
+ set char "0X"
+ set uchar "0B"
+ set short "0O"
+ set ushort "0x"
+ set uint "0b"
+ set long "0o"
+ set ulong "0X"
+ set float "0B"
+ set uwide "0O"
+ concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} -result {0 0.0 0 0 0 0 0 0 0 0 0 0 0.0 0 | 0x 0b 0 0 0O 0X 0B 0O 0x 0b 0o 0X 0B 0O}
+test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
+ testlink delete
+} -body {
+ testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ set int 0
+ set real 5000e
+ set bool 0
+ set string 0
+ set wide 0
+ set char 0
+ set uchar 0
+ set short 0
+ set ushort 0
+ set uint 0
+ set long 0
+ set ulong 0
+ set float -60.00e+
+ set uwide 0
+ concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} -result {0 5000.0 0 0 0 0 0 0 0 0 0 0 -60.0 0 | 0 5000e 0 0 0 0 0 0 0 0 0 0 -60.00e+ 0}
test link-3.1 {read-only variables} -constraints {testlink} -setup {
testlink delete
diff --git a/tests/load.test b/tests/load.test
index 7c4b47f..4cd1fcd 100644
--- a/tests/load.test
+++ b/tests/load.test
@@ -185,23 +185,30 @@ test load-7.4 {Tcl_StaticPackage procedure, redundant calls} -setup {
info loaded
} -result [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded]
-teststaticpkg Test 1 1
-teststaticpkg Another 0 1
-teststaticpkg More 0 1
-teststaticpkg Double 0 1
-test load-8.1 {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
+testConstraint teststaticpkg_8.x \
+ [if {[testConstraint teststaticpkg]} {
+ teststaticpkg Test 1 1
+ teststaticpkg Another 0 1
+ teststaticpkg More 0 1
+ teststaticpkg Double 0 1
+ expr 1
+ } else {
+ expr 0
+ }]
+
+test load-8.1 {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded]]
-test load-8.2 {TclGetLoadedPackages procedure} -body {
+test load-8.2 {TclGetLoadedPackages procedure} -constraints {teststaticpkg_8.x} -body {
info loaded gorp
} -returnCodes error -result {could not find interpreter "gorp"}
-test load-8.3a {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
+test load-8.3a {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded {}]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga] [list [file join $testDir pkgb$ext] Pkgb] {*}$alreadyLoaded]]
-test load-8.3b {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
+test load-8.3b {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded child]
} [lsort -index 1 [list {{} Test} [list [file join $testDir pkgb$ext] Pkgb]]]
-test load-8.4 {TclGetLoadedPackages procedure} [list $dll $loaded teststaticpkg] {
+test load-8.4 {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
load [file join $testDir pkgb$ext] pkgb
list [lsort -index 1 [info loaded {}]] [lsort [info commands pkgb_*]]
} [list [lsort -index 1 [concat [list [list [file join $testDir pkgb$ext] Pkgb] {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded]] {pkgb_demo pkgb_sub pkgb_unsafe}]
diff --git a/tests/main.test b/tests/main.test
index 96af066..ab66b38 100644
--- a/tests/main.test
+++ b/tests/main.test
@@ -16,7 +16,7 @@ namespace eval ::tcl::test::main {
# - tests use testing commands introduced in Tcltest 8.4
testConstraint Tcltest [expr {
[llength [package provide Tcltest]]
- && [package vsatisfies [package provide Tcltest] 8.4]}]
+ && [package vsatisfies [package provide Tcltest] 8.5-]}]
# Procedure to simulate interactive typing of commands, line by line
proc type {chan script} {
diff --git a/tests/msgcat.test b/tests/msgcat.test
index e69220e..1c3ce58 100644
--- a/tests/msgcat.test
+++ b/tests/msgcat.test
@@ -12,7 +12,7 @@
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.
-package require Tcl 8.5
+package require Tcl 8.5-
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
return
diff --git a/tests/nre.test b/tests/nre.test
index 3313df5..58f5511 100644
--- a/tests/nre.test
+++ b/tests/nre.test
@@ -64,9 +64,11 @@ if {[testConstraint testnrelevels]} {
namespace import testnre::*
}
-test nre-0.1 {levels while unwinding} {
+test nre-0.1 {levels while unwinding} -body {
testnreunwind
-} {0 0 0}
+} -constraints {
+ testnrelevels
+} -result {0 0 0}
test nre-1.1 {self-recursive procs} -setup {
proc a i [makebody {a $i}]
diff --git a/tests/obj.test b/tests/obj.test
index a8d2d20..833c906 100644
--- a/tests/obj.test
+++ b/tests/obj.test
@@ -625,6 +625,19 @@ test obj-33.7 {integer overflow on input} {
list [string is integer $x] [expr { wide($x) }]
} {0 -4294967296}
+test obj-34.1 {mp_iseven} testobj {
+ set result ""
+ lappend result [testbignumobj set 1 0]
+ lappend result [testbignumobj iseven 1] ;
+ lappend result [testobj type 1]
+} {0 1 int}
+test obj-34.2 {mp_radix_size} testobj {
+ set result ""
+ lappend result [testbignumobj set 1 9]
+ lappend result [testbignumobj radixsize 1] ;
+ lappend result [testobj type 1]
+} {9 2 int}
+
if {[testConstraint testobj]} {
testobj freeallvars
}
diff --git a/tests/oo.test b/tests/oo.test
index ccb05c1..e03911b 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -2241,6 +2241,44 @@ test oo-17.10 {OO: class introspection} -setup {
oo::define foo unexport {*}[info class methods foo -all]
info class methods foo -all
} -result {}
+set stdmethods {<cloned> destroy eval unknown variable varname}
+test oo-17.11 {OO: object method unexport (bug 900cb0284bc)} -setup {
+ oo::object create o
+ oo::objdefine o unexport m
+} -body {
+ lsort [info object methods o -all -private]
+} -cleanup {
+ o destroy
+} -result $stdmethods
+test oo-17.12 {OO: instance method unexport (bug 900cb0284bc)} -setup {
+ oo::class create c
+ c create o
+ oo::objdefine o unexport m
+} -body {
+ lsort [info object methods o -all -private]
+} -cleanup {
+ o destroy
+ c destroy
+} -result $stdmethods
+test oo-17.13 {OO: class method unexport (bug 900cb0284bc)} -setup {
+ oo::class create c
+ oo::define c unexport m
+} -body {
+ lsort [info class methods c -all -private]
+} -cleanup {
+ c destroy
+} -result $stdmethods
+test oo-17.14 {OO: instance method unexport (bug 900cb0284bc)} -setup {
+ oo::class create c
+ oo::define c unexport m
+ c create o
+} -body {
+ lsort [info object methods o -all -private]
+} -cleanup {
+ o destroy
+ c destroy
+} -result $stdmethods
+
test oo-18.1 {OO: define command support} {
list [catch {oo::define oo::object {error foo}} msg] $msg $errorInfo
diff --git a/tests/package.test b/tests/package.test
index 49346d8..99f9f06 100644
--- a/tests/package.test
+++ b/tests/package.test
@@ -832,7 +832,7 @@ test package-4.52 {Tcl_PackageCmd procedure, "vsatisfies" option} {
} {0}
test package-4.53 {Tcl_PackageCmd procedure, "versions" option} -body {
package foo
-} -returnCodes error -result {bad option "foo": must be forget, ifneeded, names, prefer, present, provide, require, unknown, vcompare, versions, or vsatisfies}
+} -returnCodes error -result {bad option "foo": must be files, forget, ifneeded, names, prefer, present, provide, require, unknown, vcompare, versions, or vsatisfies}
test package-4.54 {Tcl_PackageCmd procedure, "vsatisfies" option} -body {
package vsatisfies 2.1 2.1-3.2-4.5
} -returnCodes error -result {expected versionMin-versionMax but got "2.1-3.2-4.5"}
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
index fda25b7..47dbec5 100644
--- a/tests/parseExpr.test
+++ b/tests/parseExpr.test
@@ -1044,9 +1044,8 @@ test parseExpr-22.13 {Bug 3401704} -constraints testexprparser -body {
} -result {- {} 0 subexpr naner() 1 operator naner 0 {}}
test parseExpr-22.14 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 08 -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADNUMBER OCTAL}
+ testexprparser 07 -1
+} -result {- {} 0 subexpr 07 1 text 07 0 {}}
test parseExpr-22.15 {Bug 3401704} -constraints testexprparser -body {
catch {testexprparser 0o8 -1} m o
dict get $o -errorcode
diff --git a/tests/registry.test b/tests/registry.test
index 2072559..fec4cc0 100644
--- a/tests/registry.test
+++ b/tests/registry.test
@@ -283,7 +283,7 @@ test registry-4.7 {GetKeyNames: Unicode} {win reg english} {
registry delete HKEY_CURRENT_USER\\TclFoobar
set result
} "baz\u00c7bar blat"
-test registry-4.8 {GetKeyNames: Unicode} {win reg nt} {
+test registry-4.8 {GetKeyNames: Unicode} {win reg} {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar\\baz\u30b7bar
registry set HKEY_CURRENT_USER\\TclFoobar\\blat
@@ -487,7 +487,7 @@ test registry-6.17 {GetValue: Unicode value names} {win reg} {
registry delete HKEY_CURRENT_USER\\TclFoobar
set result
} foobar
-test registry-6.18 {GetValue: values with Unicode strings} {win reg nt} {
+test registry-6.18 {GetValue: values with Unicode strings} {win reg} {
registry set HKEY_CURRENT_USER\\TclFoobar val1 {foo ba\u30b7r baz} multi_sz
set result [registry get HKEY_CURRENT_USER\\TclFoobar val1]
registry delete HKEY_CURRENT_USER\\TclFoobar
@@ -505,7 +505,7 @@ test registry-6.20 {GetValue: values with Unicode strings with embedded nulls} {
registry delete HKEY_CURRENT_USER\\TclFoobar
set result
} "foo ba r baz"
-test registry-6.21 {GetValue: very long value names and values} {pcOnly reg} {
+test registry-6.21 {GetValue: very long value names and values} {win reg} {
registry set HKEY_CURRENT_USER\\TclFoobar [string repeat k 16383] [string repeat x 16383] multi_sz
set result [registry get HKEY_CURRENT_USER\\TclFoobar [string repeat k 16383]]
registry delete HKEY_CURRENT_USER\\TclFoobar
@@ -604,7 +604,7 @@ test registry-9.3 {ParseKeyName: bad keys} -constraints {win reg} -body {
test registry-9.4 {ParseKeyName: bad keys} -constraints {win reg} -body {
registry values \\\\\\
} -returnCodes error -result {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}
-test registry-9.5 {ParseKeyName: bad keys} -constraints {win reg english nt} -body {
+test registry-9.5 {ParseKeyName: bad keys} -constraints {win reg english} -body {
registry values \\\\\\HKEY_CLASSES_ROOT
} -returnCodes error -result {unable to open key: The network address is invalid.}
test registry-9.6 {ParseKeyName: bad keys} -constraints {win reg} -body {
diff --git a/tests/result.test b/tests/result.test
index 9e8a66b..859e546 100644
--- a/tests/result.test
+++ b/tests/result.test
@@ -31,7 +31,7 @@ test result-1.2 {Tcl_SaveInterpResult} {testsaveresult} {
} {append result}
test result-1.3 {Tcl_SaveInterpResult} {testsaveresult} {
testsaveresult dynamic {set x 42} 0
-} {dynamic result notCalled present}
+} {dynamic result presentOrFreed}
test result-1.4 {Tcl_SaveInterpResult} {testsaveresult} {
testsaveresult object {set x 42} 0
} {object result same}
@@ -43,7 +43,7 @@ test result-1.6 {Tcl_SaveInterpResult} {testsaveresult} {
} {42}
test result-1.7 {Tcl_SaveInterpResult} {testsaveresult} {
testsaveresult dynamic {set x 42} 1
-} {42 called missing}
+} {42 presentOrFreed}
test result-1.8 {Tcl_SaveInterpResult} {testsaveresult} {
testsaveresult object {set x 42} 1
} {42 different}
diff --git a/tests/safe.test b/tests/safe.test
index 6c9c6c9..e43ce12 100644
--- a/tests/safe.test
+++ b/tests/safe.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-package require Tcl 8.5
+package require Tcl 8.5-
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
diff --git a/tests/scan.test b/tests/scan.test
index b57b641..7540c9c 100644
--- a/tests/scan.test
+++ b/tests/scan.test
@@ -535,6 +535,12 @@ test scan-5.13 {integer scanning and overflow} {
test scan-5.14 {integer scanning} {
scan 0xff %u
} 0
+test scan-5.15 {Bug be003d570f} {
+ scan 0x40 %o
+} 0
+test scan-5.16 {Bug be003d570f} {
+ scan 0x40 %b
+} 0
test scan-6.1 {floating-point scanning} -setup {
set a {}; set b {}; set c {}; set d {}
diff --git a/tests/set-old.test b/tests/set-old.test
index 93169f1..309abaf 100644
--- a/tests/set-old.test
+++ b/tests/set-old.test
@@ -652,6 +652,13 @@ test set-old-8.52 {array command, array names -regexp on regexp pattern} {
set a(11) 1
list [catch {lsort [array names a -regexp ^1]} msg] $msg
} {0 {1*2 11 12}}
+test set-old-8.52.1 {array command, array names -regexp, backrefs} {
+ catch {unset a}
+ set a(1*2) 1
+ set a(12) 1
+ set a(11) 1
+ list [catch {lsort [array names a -regexp {^(.)\1}]} msg] $msg
+} {0 11}
test set-old-8.53 {array command, array names -regexp} {
catch {unset a}
set a(-glob) 1
diff --git a/tests/socket.test b/tests/socket.test
index d43c41c..d3d56fa 100644
--- a/tests/socket.test
+++ b/tests/socket.test
@@ -60,8 +60,13 @@
# listening at port 2048. If all fails, a message is printed and the tests
# using the remote server are not performed.
-package require tcltest 2
-namespace import -force ::tcltest::*
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
+
+::tcltest::loadTestedCommands
+catch [list package require -exact Tcltest [info patchlevel]]
# Some tests require the Thread package or exec command
testConstraint thread [expr {0 == [catch {package require Thread 2.7-}]}]
@@ -69,7 +74,30 @@ testConstraint exec [llength [info commands exec]]
# Produce a random port number in the Dynamic/Private range
# from 49152 through 65535.
-proc randport {} { expr {int(rand()*16383+49152)} }
+proc randport {} {
+ # firstly try dynamic port via server-socket(0):
+ set port 0x7fffffff
+ catch {
+ set port [lindex [fconfigure [set s [socket -server {} 0]] -sockname] 2]
+ close $s
+ }
+ while {[catch {
+ close [socket -server {} $port]
+ } msg]} {
+ if {[incr i] > 1000} {return -code error "too many iterations to get free random port: $msg"}
+ # try random port:
+ set port [expr {int(rand()*16383+49152)}]
+ }
+ return $port
+}
+
+# Check if testsocket testflags is available
+testConstraint testsocket_testflags [expr {![catch {
+ set h [socket -async localhost [randport]]
+ testsocket testflags $h 0
+ close $h
+ }]}]
+
# Test the latency of tcp connections over the loopback interface. Some OSes
# (e.g. NetBSD) seem to use the Nagle algorithm and delayed ACKs, so it takes
@@ -265,13 +293,13 @@ test socket_$af-1.1 {arg parsing for socket command} -constraints [list socket s
} -returnCodes error -result {no argument given for -server option}
test socket_$af-1.2 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -server foo
-} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-myaddr addr? port"}
+} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-reuseaddr boolean? ?-reuseport boolean? ?-myaddr addr? port"}
test socket_$af-1.3 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -myaddr
} -returnCodes error -result {no argument given for -myaddr option}
test socket_$af-1.4 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -myaddr $localhost
-} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-myaddr addr? port"}
+} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-reuseaddr boolean? ?-reuseport boolean? ?-myaddr addr? port"}
test socket_$af-1.5 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -myport
} -returnCodes error -result {no argument given for -myport option}
@@ -280,19 +308,19 @@ test socket_$af-1.6 {arg parsing for socket command} -constraints [list socket s
} -returnCodes error -result {expected integer but got "xxxx"}
test socket_$af-1.7 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -myport 2522
-} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-myaddr addr? port"}
+} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-reuseaddr boolean? ?-reuseport boolean? ?-myaddr addr? port"}
test socket_$af-1.8 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -froboz
-} -returnCodes error -result {bad option "-froboz": must be -async, -myaddr, -myport, or -server}
+} -returnCodes error -result {bad option "-froboz": must be -async, -myaddr, -myport, -reuseaddr, -reuseport, or -server}
test socket_$af-1.9 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -server foo -myport 2521 3333
} -returnCodes error -result {option -myport is not valid for servers}
test socket_$af-1.10 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket host 2528 -junk
-} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-myaddr addr? port"}
+} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-reuseaddr boolean? ?-reuseport boolean? ?-myaddr addr? port"}
test socket_$af-1.11 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -server callback 2520 --
-} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-myaddr addr? port"}
+} -returnCodes error -result {wrong # args: should be "socket ?-myaddr addr? ?-myport myport? ?-async? host port" or "socket -server command ?-reuseaddr boolean? ?-reuseport boolean? ?-myaddr addr? port"}
test socket_$af-1.12 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket foo badport
} -returnCodes error -result {expected integer but got "badport"}
@@ -302,6 +330,24 @@ test socket_$af-1.13 {arg parsing for socket command} -constraints [list socket
test socket_$af-1.14 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
socket -server foo -async
} -returnCodes error -result {cannot set -async option for server sockets}
+test socket_$af-1.15 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseaddr yes 4242
+} -returnCodes error -result {options -reuseaddr and -reuseport are only valid for servers}
+test socket_$af-1.16 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseaddr no 4242
+} -returnCodes error -result {options -reuseaddr and -reuseport are only valid for servers}
+test socket_$af-1.17 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseaddr
+} -returnCodes error -result {no argument given for -reuseaddr option}
+test socket_$af-1.18 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseport yes 4242
+} -returnCodes error -result {options -reuseaddr and -reuseport are only valid for servers}
+test socket_$af-1.19 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseport no 4242
+} -returnCodes error -result {options -reuseaddr and -reuseport are only valid for servers}
+test socket_$af-1.20 {arg parsing for socket command} -constraints [list socket supported_$af] -body {
+ socket -reuseport
+} -returnCodes error -result {no argument given for -reuseport option}
set path(script) [makeFile {} script]
@@ -2248,12 +2294,17 @@ test socket-14.11.0 {pending [socket -async] and nonblocking [puts], no listener
unset x
} -result {socket is not connected} -returnCodes 1
test socket-14.11.1 {pending [socket -async] and nonblocking [puts], no listener, flush} \
- -constraints {socket nonPortable} \
+ -constraints {socket testsocket_testflags} \
-body {
set sock [socket -async localhost [randport]]
+ # Set the socket in async test mode.
+ # The async connect will not be continued on the following fconfigure
+ # and puts/flush. Thus, the connect will fail after them.
+ testsocket testflags $sock 1
fconfigure $sock -blocking 0
puts $sock ok
flush $sock
+ testsocket testflags $sock 0
fileevent $sock writable {set x 1}
vwait x
close $sock
@@ -2360,6 +2411,19 @@ test socket-14.18 {bug c6ed4acfd8: running async socket connect made other conne
catch {close $csock2}
} -result {}
+test socket-14.19 {tip 456 -- introduce the -reuseport option} \
+ -constraints {socket} \
+ -body {
+ proc accept {channel address port} {}
+ set port [randport]
+ set ssock1 [socket -server accept -reuseport yes $port]
+ set ssock2 [socket -server accept -reuseport yes $port]
+ return ok
+} -cleanup {
+ catch {close $ssock1}
+ catch {close $ssock2}
+ } -result ok
+
set num 0
set x {localhost {socket} 127.0.0.1 {supported_inet} ::1 {supported_inet6}}
diff --git a/tests/string.test b/tests/string.test
index 418bc61..11cbcff 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -756,13 +756,13 @@ catch {rename largest_int {}}
test string-7.1 {string last, too few args} {
list [catch {string last a} msg] $msg
-} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}}
+} {1 {wrong # args: should be "string last needleString haystackString ?lastIndex?"}}
test string-7.2 {string last, bad args} {
list [catch {string last a b c} msg] $msg
} {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}}
test string-7.3 {string last, too many args} {
list [catch {string last a b c d} msg] $msg
-} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}}
+} {1 {wrong # args: should be "string last needleString haystackString ?lastIndex?"}}
test string-7.4 {string last} {
string la xxx xxxx123xx345x678
} 1
@@ -901,6 +901,10 @@ test string-10.20 {string map, dictionaries don't alter map ordering} {
set map {aa X a Y}
list [string map [dict create aa X a Y] aaa] [string map $map aaa] [dict size $map] [string map $map aaa]
} {XY XY 2 XY}
+test string-10.20.1 {string map, dictionaries don't alter map ordering} {
+ set map {a X b Y a Z}
+ list [string map [dict create a X b Y a Z] aaa] [string map $map aaa] [dict size $map] [string map $map aaa]
+} {ZZZ XXX 2 XXX}
test string-10.21 {string map, ABR checks} {
string map {longstring foob} long
} long
diff --git a/tests/stringComp.test b/tests/stringComp.test
index 140a270..2aeb08e 100644
--- a/tests/stringComp.test
+++ b/tests/stringComp.test
@@ -738,6 +738,9 @@ test stringComp-14.4 {Bug 1af8de570511} {
string replace $val[unset val] 1 1 $y
}} 4 x
} 0x00
+test stringComp-14.5 {} {
+ string length [string replace [string repeat a\u00fe 2] 3 end {}]
+} 3
## string tolower
## not yet bc
diff --git a/tests/tm.test b/tests/tm.test
index a4dafe0..567d351 100644
--- a/tests/tm.test
+++ b/tests/tm.test
@@ -6,7 +6,7 @@
# Copyright (c) 2004 by Donal K. Fellows.
# All rights reserved.
-package require Tcl 8.5
+package require Tcl 8.5-
if {"::tcltest" ni [namespace children]} {
package require tcltest 2
namespace import -force ::tcltest::*
diff --git a/tests/util.test b/tests/util.test
index 2ac11bf..22d120b 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -20,6 +20,7 @@ testConstraint testbytestring [llength [info commands testbytestring]]
testConstraint testdstring [llength [info commands testdstring]]
testConstraint testconcatobj [llength [info commands testconcatobj]]
testConstraint testdoubledigits [llength [info commands testdoubledigits]]
+testConstraint testprint [llength [info commands testprint]]
# Big test for correct ordering of data in [expr]
@@ -4017,6 +4018,54 @@ test util-17.1 {bankers' rounding [Bug 3349507]} {ieeeFloatingPoint} {
0x4400000000000000 0xc400000000000000
}]
+test util-18.1 {Tcl_ObjPrintf} {testprint} {
+ testprint %lld [expr 2**63-1]
+} {9223372036854775807}
+
+test util-18.2 {Tcl_ObjPrintf} {testprint} {
+ testprint %I64d [expr 2**63-1]
+} {9223372036854775807}
+
+test util-18.3 {Tcl_ObjPrintf} {testprint} {
+ testprint %qd [expr 2**63-1]
+} {9223372036854775807}
+
+test util-18.4 {Tcl_ObjPrintf} {testprint} {
+ testprint %jd [expr 2**63-1]
+} {9223372036854775807}
+
+test util-18.5 {Tcl_ObjPrintf} {testprint} {
+ testprint %lld [expr -2**63]
+} {-9223372036854775808}
+
+test util-18.6 {Tcl_ObjPrintf} {testprint} {
+ testprint %I64d [expr -2**63]
+} {-9223372036854775808}
+
+test util-18.7 {Tcl_ObjPrintf} {testprint} {
+ testprint %qd [expr -2**63]
+} {-9223372036854775808}
+
+test util-18.8 {Tcl_ObjPrintf} {testprint} {
+ testprint %jd [expr -2**63]
+} {-9223372036854775808}
+
+test util-18.9 {Tcl_ObjPrintf} {testprint} {
+ testprint "%I64d %I32d" [expr -2**63+2]
+} {-9223372036854775806 2}
+
+test util-18.10 {Tcl_ObjPrintf} {testprint} {
+ testprint "%I64d %p" 65535
+} {65535 0xffff}
+
+test util-18.11 {Tcl_ObjPrintf} {testprint} {
+ testprint "%I64d %td" 65536
+} {65536 65536}
+
+test util-18.12 {Tcl_ObjPrintf} {testprint} {
+ testprint "%I64d %Id" 65537
+} {65537 65537}
+
set ::tcl_precision $saved_precision
# cleanup
diff --git a/tests/winFCmd.test b/tests/winFCmd.test
index a808c82..294745c 100644
--- a/tests/winFCmd.test
+++ b/tests/winFCmd.test
@@ -21,8 +21,7 @@ catch [list package require -exact Tcltest [info patchlevel]]
# Initialise the test constraints
testConstraint winVista 0
-testConstraint win2000orXP 0
-testConstraint winOlderThan2000 0
+testConstraint winXP 0
testConstraint testvolumetype [llength [info commands testvolumetype]]
testConstraint testfile [llength [info commands testfile]]
testConstraint testchmod [llength [info commands testchmod]]
@@ -56,16 +55,12 @@ proc cleanup {args} {
}
}
-if {[testConstraint winOnly]} {
+if {[testConstraint win]} {
set major [string index $tcl_platform(osVersion) 0]
- if {[testConstraint nt] && $major > 4} {
- if {$major > 5} {
- testConstraint winVista 1
- } elseif {$major == 5} {
- testConstraint win2000orXP 1
- }
- } else {
- testConstraint winOlderThan2000 1
+ if {$major > 5} {
+ testConstraint winVista 1
+ } elseif {$major == 5} {
+ testConstraint winXP 1
}
}
@@ -205,17 +200,12 @@ test winFCmd-1.12 {TclpRenameFile: errno: EACCES} -setup {
} -returnCodes error -result EACCES
test winFCmd-1.13 {TclpRenameFile: errno: EACCES} -setup {
cleanup
-} -constraints {win win2000orXP testfile} -body {
+} -constraints {win winXP testfile} -body {
testfile mv nul tf1
} -returnCodes error -result EINVAL
-test winFCmd-1.14 {TclpRenameFile: errno: EACCES} -setup {
- cleanup
-} -constraints {win nt winOlderThan2000 testfile} -body {
- testfile mv nul tf1
-} -returnCodes error -result EACCES
test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} -setup {
cleanup
-} -constraints {win nt testfile} -body {
+} -constraints {win testfile} -body {
createfile tf1
testfile mv tf1 nul
} -returnCodes error -result EEXIST
@@ -238,19 +228,12 @@ test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} -setup {
} -returnCodes error -result ENOENT
test winFCmd-1.19 {TclpRenameFile: errno == EACCES} -setup {
cleanup
-} -constraints {win win2000orXP testfile} -body {
+} -constraints {win winXP testfile} -body {
testfile mv nul tf1
} -returnCodes error -result EINVAL
-test winFCmd-1.19.1 {TclpRenameFile: errno == EACCES} -setup {
- cleanup
-} -constraints {win nt winOlderThan2000 testfile} -body {
- testfile mv nul tf1
-} -returnCodes error -result EACCES
test winFCmd-1.20 {TclpRenameFile: src is dir} -setup {
cleanup
-} -constraints {win nt testfile} -body {
- # under 95, this would actually succeed and move the current dir out from
- # under the current process!
+} -constraints {win testfile} -body {
file delete /tf1
testfile mv [pwd] /tf1
} -returnCodes error -result EACCES
@@ -458,14 +441,9 @@ test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} -setup {
} -returnCodes error -result ENOENT
test winFCmd-2.7 {TclpCopyFile: errno: EACCES} -setup {
cleanup
-} -constraints {win win2000orXP testfile} -body {
+} -constraints {win winXP testfile} -body {
testfile cp nul tf1
} -returnCodes error -result EINVAL
-test winFCmd-2.8 {TclpCopyFile: errno: EACCES} -setup {
- cleanup
-} -constraints {win nt winOlderThan2000 testfile} -body {
- testfile cp nul tf1
-} -returnCodes error -result EACCES
test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} -setup {
cleanup
} -constraints {win testfile} -body {
@@ -623,7 +601,7 @@ test winFCmd-3.11 {TclpDeleteFile: still can't remove path} -setup {
test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} -body {
testfile mkdir $cdrom/dummy~~.dir
-} -constraints {win nt cdrom testfile} -returnCodes error -result EACCES
+} -constraints {win cdrom testfile} -returnCodes error -result EACCES
test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} -setup {
cleanup
} -constraints {win testfile} -body {
@@ -721,7 +699,7 @@ test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} -setup {
} -result {td1 EACCES}
test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} -setup {
cleanup
-} -constraints {win nt testfile} -body {
+} -constraints {win testfile} -body {
testfile rmdir /
# WinXP returns EEXIST, WinNT seems to return EACCES. No policy
# decision has been made as to which is correct.
@@ -819,7 +797,7 @@ test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} -setup {
} -result {tf1}
test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} -body {
testfile rmdir $cdrom/
-} -constraints {win nt cdrom testfile} -returnCodes error -match glob \
+} -constraints {win cdrom testfile} -returnCodes error -match glob \
-result {* EACCES}
test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \
{win emptyTest} {
@@ -857,7 +835,7 @@ test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} -setup {
} -result {tf1}
test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} -setup {
cleanup
-} -constraints {win nt testfile} -body {
+} -constraints {win testfile} -body {
file mkdir td1
testfile cpdir td1 /
} -cleanup {
@@ -1072,7 +1050,7 @@ test winFCmd-12.5 {ConvertFileNameFormat: absolute path} -body {
} -constraints {win} -result {/ /}
test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} -setup {
catch {file delete -force -- c:/td1}
-} -constraints {win win2000orXP} -body {
+} -constraints {win winXP} -body {
createfile c:/td1 {}
string tolower [file attributes c:/td1 -longname]
} -cleanup {
@@ -1350,13 +1328,13 @@ test winFCmd-18.8 {Windows reserved path names} -constraints win -body {
file normalize cOm1:
} -result COM1
-test winFCmd-19.1 {Windows extended path names} -constraints nt -body {
+test winFCmd-19.1 {Windows extended path names} -constraints win -body {
file normalize //?/c:/windows/win.ini
} -result //?/c:/windows/win.ini
-test winFCmd-19.2 {Windows extended path names} -constraints nt -body {
+test winFCmd-19.2 {Windows extended path names} -constraints win -body {
file normalize //?/c:/windows/../windows/win.ini
} -result //?/c:/windows/win.ini
-test winFCmd-19.3 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.3 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
set tmpfile [file normalize $tmpfile]
} -body {
@@ -1367,7 +1345,7 @@ test winFCmd-19.3 {Windows extended path names} -constraints nt -setup {
} -cleanup {
catch {file delete $tmpfile}
} -result [list 0 {}]
-test winFCmd-19.4 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.4 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
set tmpfile //?/[file normalize $tmpfile]
} -body {
@@ -1378,7 +1356,7 @@ test winFCmd-19.4 {Windows extended path names} -constraints nt -setup {
} -cleanup {
catch {file delete $tmpfile}
} -result [list 0 {}]
-test winFCmd-19.5 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.5 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
set tmpfile [file normalize $tmpfile]
} -body {
@@ -1389,7 +1367,7 @@ test winFCmd-19.5 {Windows extended path names} -constraints nt -setup {
} -cleanup {
catch {file delete $tmpfile}
} -result [list 0 {}]
-test winFCmd-19.6 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.6 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
set tmpfile //?/[file normalize $tmpfile]
} -body {
@@ -1400,7 +1378,7 @@ test winFCmd-19.6 {Windows extended path names} -constraints nt -setup {
} -cleanup {
catch {file delete $tmpfile}
} -result [list 0 {}]
-test winFCmd-19.7 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.7 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
set tmpfile [file normalize $tmpfile]
} -body {
@@ -1411,7 +1389,7 @@ test winFCmd-19.7 {Windows extended path names} -constraints nt -setup {
} -cleanup {
catch {file delete $tmpfile}
} -result [list 0 {} [list tcl[pid].tmp]]
-test winFCmd-19.8 {Windows extended path names} -constraints nt -setup {
+test winFCmd-19.8 {Windows extended path names} -constraints win -setup {
set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
set tmpfile //?/[file normalize $tmpfile]
} -body {
@@ -1423,7 +1401,7 @@ test winFCmd-19.8 {Windows extended path names} -constraints nt -setup {
catch {file delete $tmpfile}
} -result [list 0 {} [list "tcl[pid].tmp "]]
-test winFCmd-19.9 {Windows devices path names} -constraints nt -body {
+test winFCmd-19.9 {Windows devices path names} -constraints win -body {
file normalize //./com1
} -result //./com1
diff --git a/tests/winFile.test b/tests/winFile.test
index 2c47f5f..b2cdfa1 100644
--- a/tests/winFile.test
+++ b/tests/winFile.test
@@ -21,23 +21,19 @@ catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testvolumetype [llength [info commands testvolumetype]]
testConstraint notNTFS 0
-testConstraint win2000 0
if {[testConstraint testvolumetype]} {
testConstraint notNTFS [expr {[testvolumetype] eq "NTFS"}]
}
-if {[testConstraint nt] && $::tcl_platform(osVersion) >= 5.0} {
- testConstraint win2000 1
-}
test winFile-1.1 {TclpGetUserHome} -constraints {win} -body {
glob ~nosuchuser
} -returnCodes error -result {user "nosuchuser" doesn't exist}
-test winFile-1.2 {TclpGetUserHome} -constraints {win nt nonPortable} -body {
+test winFile-1.2 {TclpGetUserHome} -constraints {win nonPortable} -body {
# The administrator account should always exist.
glob ~administrator
} -match glob -result *
-test winFile-1.4 {TclpGetUserHome} {win nt nonPortable} {
+test winFile-1.4 {TclpGetUserHome} {win nonPortable} {
catch {glob ~stanton@workgroup}
} {0}
@@ -154,7 +150,7 @@ if {[testConstraint win]} {
test winFile-4.0 {
Enhanced NTFS user/group permissions: test no acccess
} -constraints {
- win nt notNTFS win2000
+ win notNTFS
} -setup {
set owner [getuser $fname]
set user $::env(USERDOMAIN)\\$::env(USERNAME)
@@ -169,7 +165,7 @@ test winFile-4.0 {
test winFile-4.1 {
Enhanced NTFS user/group permissions: test readable only
} -constraints {
- win nt notNTFS
+ win notNTFS
} -setup {
set user $::env(USERDOMAIN)\\$::env(USERNAME)
} -body {
@@ -180,7 +176,7 @@ test winFile-4.1 {
test winFile-4.2 {
Enhanced NTFS user/group permissions: test writable only
} -constraints {
- win nt notNTFS
+ win notNTFS
} -setup {
set user $::env(USERDOMAIN)\\$::env(USERNAME)
} -body {
@@ -192,7 +188,7 @@ test winFile-4.2 {
test winFile-4.3 {
Enhanced NTFS user/group permissions: test read+write
} -constraints {
- win nt notNTFS
+ win notNTFS
} -setup {
set user $::env(USERDOMAIN)\\$::env(USERNAME)
} -body {
@@ -205,7 +201,7 @@ test winFile-4.3 {
test winFile-4.4 {
Enhanced NTFS user/group permissions: test full access
} -constraints {
- win nt notNTFS
+ win notNTFS
} -setup {
set user $::env(USERDOMAIN)\\$::env(USERNAME)
} -body {
diff --git a/tests/winPipe.test b/tests/winPipe.test
index 8128fe2..53e46fc 100644
--- a/tests/winPipe.test
+++ b/tests/winPipe.test
@@ -74,11 +74,11 @@ test winpipe-1.2 {32 bit comprehensive tests: from big file} {win exec cat32} {
exec $cat32 < $path(big) > $path(stdout) 2> $path(stderr)
list [contents $path(stdout)] [contents $path(stderr)]
} "{$big} stderr32"
-test winpipe-1.3 {32 bit comprehensive tests: a little from pipe} {win nt exec cat32} {
+test winpipe-1.3 {32 bit comprehensive tests: a little from pipe} {win exec cat32} {
exec [interpreter] $path(more) < $path(little) | $cat32 > $path(stdout) 2> $path(stderr)
list [contents $path(stdout)] [contents $path(stderr)]
} {little stderr32}
-test winpipe-1.4 {32 bit comprehensive tests: a lot from pipe} {win nt exec cat32} {
+test winpipe-1.4 {32 bit comprehensive tests: a lot from pipe} {win exec cat32} {
exec [interpreter] $path(more) < $path(big) | $cat32 > $path(stdout) 2> $path(stderr)
list [contents $path(stdout)] [contents $path(stderr)]
} "{$big} stderr32"
@@ -171,7 +171,7 @@ test winpipe-1.21 {32 bit comprehensive tests: read/write application} \
set r
} "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-test winpipe-4.1 {Tcl_WaitPid} {win nt exec cat32} {
+test winpipe-4.1 {Tcl_WaitPid} {win exec cat32} {
proc readResults {f} {
global x result
if { [eof $f] } {
diff --git a/tests/zlib.test b/tests/zlib.test
index 15dbb34..9f06eb1 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -138,6 +138,67 @@ test zlib-7.7 {zlib stream: Bug 25842c161} -constraints zlib -body {
} -cleanup {
catch {$s close}
} -result ""
+# Also causes Tk Bug 10f2e7872b
+test zlib-7.8 {zlib stream: Bug b26e38a3e4} -constraints zlib -setup {
+ expr srand(12345)
+ set randdata {}
+ for {set i 0} {$i<6001} {incr i} {
+ append randdata [binary format c [expr {int(256*rand())}]]
+ }
+} -body {
+ set strm [zlib stream compress]
+ for {set i 1} {$i<3000} {incr i} {
+ $strm put $randdata
+ }
+ $strm put -finalize $randdata
+ set data [$strm get]
+ list [string length $data] [string length [zlib decompress $data]]
+} -cleanup {
+ catch {$strm close}
+ unset -nocomplain randdata data
+} -result {120185 18003000}
+test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set z1 [zlib stream gzip]
+ set z2 [zlib stream gzip]
+} -body {
+ $z1 put ABCDEedbca..
+ $z1 finalize
+ zlib gunzip [$z1 get]
+} -cleanup {
+ $z1 close
+} -result ABCDEedbca..
+test zlib-7.10 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set z2 [zlib stream gzip]
+} -body {
+ $z2 put -finalize ABCDEedbca..
+ zlib gunzip [$z2 get]
+} -cleanup {
+ $z2 close
+} -result ABCDEedbca..
+test zlib-7.11 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup {
+ set c [zlib stream gzip]
+ set d [zlib stream gunzip]
+} -body {
+ $c put abcdeEDCBA..
+ $c finalize
+ $d put [$c get]
+ $d finalize
+ $d get
+} -cleanup {
+ $c close
+ $d close
+} -result abcdeEDCBA..
+test zlib-7.12 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set c [zlib stream gzip]
+ set d [zlib stream gunzip]
+} -body {
+ $c put -finalize abcdeEDCBA..
+ $d put -finalize [$c get]
+ $d get
+} -cleanup {
+ $c close
+ $d close
+} -result abcdeEDCBA..
test zlib-8.1 {zlib transformation} -constraints zlib -setup {
set file [makeFile {} test.gz]
@@ -250,7 +311,7 @@ test zlib-8.8 {transformation and fconfigure} -setup {
lassign [chan pipe] inSide outSide
} -constraints zlib -body {
zlib push compress $outSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -269,7 +330,7 @@ test zlib-8.9 {transformation and fconfigure} -setup {
set strm [zlib stream decompress]
} -constraints zlib -body {
zlib push compress $outSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
set result [fconfigure $outSide -checksum]
@@ -286,7 +347,7 @@ test zlib-8.10 {transformation and fconfigure} -setup {
lassign [chan pipe] inSide outSide
} -constraints {zlib recentZlib} -body {
zlib push deflate $outSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -308,7 +369,7 @@ test zlib-8.11 {transformation and fconfigure} -setup {
set strm [zlib stream inflate]
} -constraints zlib -body {
zlib push deflate $outSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -326,7 +387,7 @@ test zlib-8.12 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -dictionary $spdyDict -finalize $spdyHeaders
zlib push decompress $inSide
- fconfigure $outSide -blocking 0 -translation binary
+ fconfigure $outSide -blocking 1 -translation binary
fconfigure $inSide -translation binary -dictionary $spdyDict
puts -nonewline $outSide [$strm get]
close $outSide
@@ -343,7 +404,7 @@ test zlib-8.13 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -dictionary $spdyDict -finalize $spdyHeaders
zlib push decompress $inSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -translation binary
+ fconfigure $outSide -blocking 1 -translation binary
fconfigure $inSide -translation binary
puts -nonewline $outSide [$strm get]
close $outSide
@@ -360,7 +421,7 @@ test zlib-8.14 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -finalize -dictionary $spdyDict $spdyHeaders
zlib push inflate $inSide
- fconfigure $outSide -blocking 0 -buffering none -translation binary
+ fconfigure $outSide -blocking 1 -buffering none -translation binary
fconfigure $inSide -translation binary -dictionary $spdyDict
puts -nonewline $outSide [$strm get]
close $outSide
@@ -376,7 +437,7 @@ test zlib-8.15 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -finalize -dictionary $spdyDict $spdyHeaders
zlib push inflate $inSide -dictionary $spdyDict
- fconfigure $outSide -blocking 0 -buffering none -translation binary
+ fconfigure $outSide -blocking 1 -buffering none -translation binary
fconfigure $inSide -translation binary
puts -nonewline $outSide [$strm get]
close $outSide
@@ -447,6 +508,7 @@ test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
chan configure $c -translation binary -buffering none -blocking 0
puts -nonewline $c [zlib gzip [string repeat a 81920]]
close $c
+ set ::total -1
}}} 0]
set file [makeFile {} test.gz]
} -body {
@@ -454,7 +516,10 @@ test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
set sin [socket $addr $port]
chan configure $sin -translation binary
zlib push gunzip $sin
- update
+ after 1000 {set ::total timeout}
+ vwait ::total
+ after cancel {set ::total timeout}
+ if {$::total != -1} {error "unexpected value $::total of ::total"}
set total [fcopy $sin [set fout [open $file wb]]]
close $sin
close $fout
diff --git a/tools/configure b/tools/configure
index 7c4d3db..5903cc8 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1681,7 +1681,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# not, assume that its top-level directory is a sibling of ours.
#--------------------------------------------------------------------
-DEF_VER=8.6
+DEF_VER=8.7
# Check whether --with-tcl was given.
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index 9f2c6ca..742aa46 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -199,6 +199,13 @@ proc genStubs::declare {args} {
set stubs($curName,$platform,lastNum) $index
}
}
+ if {$platformList eq "deprecated"} {
+ set stubs($curName,generic,$index) $decl
+ if {![info exists stubs($curName,generic,lastNum)] \
+ || ($index > $stubs($curName,generic,lastNum))} {
+ set stubs($curName,$platform,lastNum) $index
+ }
+ }
}
return
}
@@ -455,10 +462,16 @@ proc genStubs::parseArg {arg} {
proc genStubs::makeDecl {name decl index} {
variable scspec
+ variable stubs
+ variable libraryName
lassign $decl rtype fname args
append text "/* $index */\n"
+ if {[info exists stubs($name,deprecated,$index)]} {
+ set line "[string toupper $libraryName]_DEPRECATED $rtype"
+ } else {
set line "$scspec $rtype"
+ }
set count [expr {2 - ([string length $line] / 8)}]
append line [string range "\t\t\t" 0 $count]
set pad [expr {24 - [string length $line]}]
@@ -682,7 +695,10 @@ proc genStubs::forAllStubs {name slotProc onAll textVar
for {set i 0} {$i <= $lastNum} {incr i} {
set slots [array names stubs $name,*,$i]
set emit 0
- if {[info exists stubs($name,generic,$i)]} {
+ if {[info exists stubs($name,deprecated,$i)]} {
+ append text [$slotProc $name $stubs($name,generic,$i) $i]
+ set emit 1
+ } elseif {[info exists stubs($name,generic,$i)]} {
if {[llength $slots] > 1} {
puts stderr "conflicting generic and platform entries:\
$name $i"
diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl
index 8fd1245..b69e601 100644
--- a/tools/tcltk-man2html-utils.tcl
+++ b/tools/tcltk-man2html-utils.tcl
@@ -57,9 +57,14 @@ proc copyright {copyright {level {}}} {
}
proc copyout {copyrights {level {}}} {
+ set count 0
set out "<div class=\"copy\">"
foreach c $copyrights {
+ if {$count > 0} {
+ append out <BR>
+ }
append out "[copyright $c $level]\n"
+ incr count
}
append out "</div>"
return $out
@@ -150,8 +155,15 @@ proc process-text {text} {
{\fP} {\fR} \
{\.} . \
{\(bu} "&#8226;" \
- {\*(qo} "&ocirc;" \
]
+ # This might make a few invalid mappings, but we don't use them
+ foreach c {a e i o u y A E I O U Y} {
+ foreach {prefix suffix} {
+ o ring / slash : uml ' acute ^ circ ` grave
+ } {
+ lappend charmap "\\\[${prefix}${c}\]" "&${c}${suffix};"
+ }
+ }
lappend charmap {\-\|\-} -- ; # two hyphens
lappend charmap {\-} - ; # a hyphen
diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl
index 9a372b7..5d21866 100755
--- a/tools/tcltk-man2html.tcl
+++ b/tools/tcltk-man2html.tcl
@@ -4,7 +4,7 @@ if {[catch {package require Tcl 8.6-} msg]} {
puts stderr "ERROR: $msg"
puts stderr "If running this script from 'make html', set the\
NATIVE_TCLSH environment\nvariable to point to an installed\
- tclsh8.6 (or the equivalent tclsh86.exe\non Windows)."
+ tclsh8.7 (or the equivalent tclsh87.exe\non Windows)."
exit 1
}
@@ -22,7 +22,7 @@ if {[catch {package require Tcl 8.6-} msg]} {
# Copyright (c) 1995-1997 Roger E. Critchlow Jr
# Copyright (c) 2004-2010 Donal K. Fellows
-set ::Version "50/8.6"
+set ::Version "50/8.7"
set ::CSSFILE "docs.css"
##
diff --git a/tools/tsdPerf.c b/tools/tsdPerf.c
index 40004b1..a75e962 100644
--- a/tools/tsdPerf.c
+++ b/tools/tsdPerf.c
@@ -40,7 +40,7 @@ tsdPerfGetObjCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const
int
Tsdperf_Init(Tcl_Interp *interp) {
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
diff --git a/unix/Makefile.in b/unix/Makefile.in
index eb083e0..c4f6136 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -320,7 +320,7 @@ TOMMATH_OBJS = bncore.o bn_reverse.o bn_fast_s_mp_mul_digs.o \
bn_mp_cnt_lsb.o bn_mp_copy.o \
bn_mp_count_bits.o bn_mp_div.o bn_mp_div_d.o bn_mp_div_2.o \
bn_mp_div_2d.o bn_mp_div_3.o \
- bn_mp_exch.o bn_mp_expt_d.o bn_mp_grow.o bn_mp_init.o \
+ bn_mp_exch.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_grow.o bn_mp_init.o \
bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_karatsuba_mul.o \
bn_mp_karatsuba_sqr.o \
@@ -503,6 +503,7 @@ TOMMATH_SRCS = \
$(TOMMATH_DIR)/bn_mp_div_3.c \
$(TOMMATH_DIR)/bn_mp_exch.c \
$(TOMMATH_DIR)/bn_mp_expt_d.c \
+ $(TOMMATH_DIR)/bn_mp_expt_d_ex.c \
$(TOMMATH_DIR)/bn_mp_grow.c \
$(TOMMATH_DIR)/bn_mp_init.c \
$(TOMMATH_DIR)/bn_mp_init_copy.c \
@@ -840,8 +841,8 @@ install-libraries: libraries
do \
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/http1.0; \
done;
- @echo "Installing package http 2.8.9 as a Tcl Module";
- @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.9.tm;
+ @echo "Installing package http 2.8.10 as a Tcl Module";
+ @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.10.tm;
@echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/";
@for i in $(TOP_DIR)/library/opt/*.tcl ; \
do \
@@ -1420,6 +1421,9 @@ bn_mp_exch.o: $(TOMMATH_DIR)/bn_mp_exch.c $(MATHHDRS)
bn_mp_expt_d.o: $(TOMMATH_DIR)/bn_mp_expt_d.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_expt_d.c
+bn_mp_expt_d_ex.o: $(TOMMATH_DIR)/bn_mp_expt_d_ex.c $(MATHHDRS)
+ $(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_expt_d_ex.c
+
bn_mp_grow.o: $(TOMMATH_DIR)/bn_mp_grow.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_grow.c
diff --git a/unix/configure b/unix/configure
index 068503c..8a1891c 100755
--- a/unix/configure
+++ b/unix/configure
@@ -5038,7 +5038,7 @@ fi
if test "$GCC" = yes; then :
CFLAGS_OPTIMIZE=-O2
- CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
else
@@ -6910,9 +6910,6 @@ $as_echo "enabled $tcl_ok debugging" >&6; }
-$as_echo "#define TCL_TOMMATH 1" >>confdefs.h
-
-
$as_echo "#define MP_PREC 4" >>confdefs.h
diff --git a/unix/configure.ac b/unix/configure.ac
index 41a1f62..bafb970 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -182,7 +182,6 @@ SC_CONFIG_CFLAGS
SC_ENABLE_SYMBOLS(bccdebug)
-AC_DEFINE(TCL_TOMMATH, 1, [Build libtommath?])
AC_DEFINE(MP_PREC, 4, [Default libtommath precision.])
#--------------------------------------------------------------------
diff --git a/unix/dltest/pkga.c b/unix/dltest/pkga.c
index 2aee1b8..5bf3c1e 100644
--- a/unix/dltest/pkga.c
+++ b/unix/dltest/pkga.c
@@ -123,7 +123,7 @@ Pkga_Init(
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkga", "1.0");
diff --git a/unix/dltest/pkgc.c b/unix/dltest/pkgc.c
index 48e4d2a..983fcf3 100644
--- a/unix/dltest/pkgc.c
+++ b/unix/dltest/pkgc.c
@@ -113,7 +113,7 @@ Pkgc_Init(
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkgc", "1.7.2");
@@ -150,7 +150,7 @@ Pkgc_SafeInit(
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkgc", "1.7.2");
diff --git a/unix/dltest/pkgd.c b/unix/dltest/pkgd.c
index df7bbc9..c708df0 100644
--- a/unix/dltest/pkgd.c
+++ b/unix/dltest/pkgd.c
@@ -113,7 +113,7 @@ Pkgd_Init(
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkgd", "7.3");
@@ -150,7 +150,7 @@ Pkgd_SafeInit(
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkgd", "7.3");
diff --git a/unix/dltest/pkge.c b/unix/dltest/pkge.c
index 7160d90..f46ca74 100644
--- a/unix/dltest/pkge.c
+++ b/unix/dltest/pkge.c
@@ -38,7 +38,7 @@ Pkge_Init(
{
static const char script[] = "if 44 {open non_existent}";
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
return Tcl_EvalEx(interp, script, -1, 0);
diff --git a/unix/dltest/pkgooa.c b/unix/dltest/pkgooa.c
index 78af376..5a0b0ef 100644
--- a/unix/dltest/pkgooa.c
+++ b/unix/dltest/pkgooa.c
@@ -96,7 +96,7 @@ Pkgooa_Init(
* This worked in Tcl 8.6.0, and is expected
* to keep working in all future Tcl 8.x releases.
*/
- if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
if (tclStubsPtr == NULL) {
diff --git a/unix/dltest/pkgua.c b/unix/dltest/pkgua.c
index 8634a5e..9d5a9d9 100644
--- a/unix/dltest/pkgua.c
+++ b/unix/dltest/pkgua.c
@@ -199,7 +199,7 @@ Pkgua_Init(
int code, cmdIndex = 0;
Tcl_Command *cmdTokens;
- if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index f2827c6..47bfbf3 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1096,7 +1096,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
AS_IF([test "$GCC" = yes], [
CFLAGS_OPTIMIZE=-O2
- CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
], [
CFLAGS_OPTIMIZE=-O
CFLAGS_WARNING=""
@@ -2709,7 +2709,7 @@ AC_DEFUN([SC_TCL_CFG_ENCODING], [
# advancedTest - the advanced test to run if the function is present
#
# Results:
-# Might cause compatability versions of the function to be used.
+# Might cause compatibility versions of the function to be used.
# Might affect the following vars:
# USE_COMPAT (implicit)
#
diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in
index 6c2f47d..88e03aa 100644
--- a/unix/tclConfig.h.in
+++ b/unix/tclConfig.h.in
@@ -400,9 +400,6 @@
/* Are we building with threads enabled? */
#undef TCL_THREADS
-/* Build libtommath? */
-#undef TCL_TOMMATH
-
/* Do we allow unloading of shared libraries? */
#undef TCL_UNLOAD_DLLS
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 1247061..ea6067e 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -988,8 +988,8 @@ CopyString(
int
TclWinCPUID(
- unsigned int index, /* Which CPUID value to retrieve. */
- unsigned int *regsPtr) /* Registers after the CPUID. */
+ int index, /* Which CPUID value to retrieve. */
+ int *regsPtr) /* Registers after the CPUID. */
{
int status = TCL_ERROR;
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 4d38f8e..e156f77 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -1507,11 +1507,10 @@ SetGroupAttribute(
Tcl_DString ds;
struct group *groupPtr = NULL;
const char *string;
- int length;
- string = TclGetStringFromObj(attributePtr, &length);
+ string = TclGetString(attributePtr);
- native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
+ native = Tcl_UtfToExternalDString(NULL, string, attributePtr->length, &ds);
groupPtr = TclpGetGrNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
@@ -1574,11 +1573,10 @@ SetOwnerAttribute(
Tcl_DString ds;
struct passwd *pwPtr = NULL;
const char *string;
- int length;
- string = TclGetStringFromObj(attributePtr, &length);
+ string = TclGetString(attributePtr);
- native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
+ native = Tcl_UtfToExternalDString(NULL, string, attributePtr->length, &ds);
pwPtr = TclpGetPwNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
@@ -1946,9 +1944,9 @@ TclpObjNormalizePath(
int nextCheckpoint)
{
const char *currentPathEndPosition;
- int pathLen;
char cur;
- const char *path = TclGetStringFromObj(pathPtr, &pathLen);
+ const char *path = TclGetString(pathPtr);
+ size_t pathLen = pathPtr->length;
Tcl_DString ds;
const char *nativePath;
#ifndef NO_REALPATH
@@ -2177,15 +2175,15 @@ TclUnixOpenTemporaryFile(
{
Tcl_DString template, tmp;
const char *string;
- int len, fd;
+ int fd;
/*
* We should also check against making more then TMP_MAX of these.
*/
if (dirObj) {
- string = TclGetStringFromObj(dirObj, &len);
- Tcl_UtfToExternalDString(NULL, string, len, &template);
+ string = TclGetString(dirObj);
+ Tcl_UtfToExternalDString(NULL, string, dirObj->length, &template);
} else {
Tcl_DStringInit(&template);
Tcl_DStringAppend(&template, DefaultTempDir(), -1); /* INTL: native */
@@ -2194,8 +2192,8 @@ TclUnixOpenTemporaryFile(
TclDStringAppendLiteral(&template, "/");
if (basenameObj) {
- string = TclGetStringFromObj(basenameObj, &len);
- Tcl_UtfToExternalDString(NULL, string, len, &tmp);
+ string = TclGetString(basenameObj);
+ Tcl_UtfToExternalDString(NULL, string, basenameObj->length, &tmp);
TclDStringAppendDString(&template, &tmp);
Tcl_DStringFree(&tmp);
} else {
@@ -2206,8 +2204,8 @@ TclUnixOpenTemporaryFile(
#ifdef HAVE_MKSTEMPS
if (extensionObj) {
- string = TclGetStringFromObj(extensionObj, &len);
- Tcl_UtfToExternalDString(NULL, string, len, &tmp);
+ string = TclGetString(extensionObj);
+ Tcl_UtfToExternalDString(NULL, string, extensionObj->length, &tmp);
TclDStringAppendDString(&template, &tmp);
fd = mkstemps(Tcl_DStringValue(&template), Tcl_DStringLength(&tmp));
Tcl_DStringFree(&tmp);
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 886b5ad..5f5bfe0 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -262,14 +262,15 @@ TclpMatchInDirectory(
DIR *d;
Tcl_DirEntry *entryPtr;
const char *dirName;
- int dirLength, nativeDirLen;
+ size_t dirLength, nativeDirLen;
int matchHidden, matchHiddenPat;
Tcl_StatBuf statBuf;
Tcl_DString ds; /* native encoding of dir */
Tcl_DString dsOrig; /* utf-8 encoding of dir */
Tcl_DStringInit(&dsOrig);
- dirName = TclGetStringFromObj(fileNamePtr, &dirLength);
+ dirName = TclGetString(fileNamePtr);
+ dirLength = fileNamePtr->length;
Tcl_DStringAppend(&dsOrig, dirName, dirLength);
/*
@@ -937,7 +938,6 @@ TclpObjLink(
*/
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
- int targetLen;
Tcl_DString ds;
Tcl_Obj *transPtr;
@@ -951,8 +951,8 @@ TclpObjLink(
if (transPtr == NULL) {
return NULL;
}
- target = TclGetStringFromObj(transPtr, &targetLen);
- target = Tcl_UtfToExternalDString(NULL, target, targetLen, &ds);
+ target = TclGetString(transPtr);
+ target = Tcl_UtfToExternalDString(NULL, target, transPtr->length, &ds);
Tcl_DecrRefCount(transPtr);
if (symlink(target, src) != 0) {
@@ -1080,7 +1080,7 @@ TclNativeCreateNativeRep(
const char *str;
Tcl_DString ds;
Tcl_Obj *validPathPtr;
- int len;
+ size_t len;
if (TclFSCwdIsNative()) {
/*
@@ -1105,7 +1105,8 @@ TclNativeCreateNativeRep(
Tcl_IncrRefCount(validPathPtr);
}
- str = TclGetStringFromObj(validPathPtr, &len);
+ str = TclGetString(validPathPtr);
+ len = validPathPtr->length;
Tcl_UtfToExternalDString(NULL, str, len, &ds);
len = Tcl_DStringLength(&ds) + sizeof(char);
if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 91fb986..1e35b92 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -453,7 +453,7 @@ TclpInitPlatform(void)
void
TclpInitLibraryPath(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 32
@@ -542,9 +542,10 @@ TclpInitLibraryPath(
Tcl_DStringFree(&buffer);
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
- str = TclGetStringFromObj(pathPtr, lengthPtr);
- *valuePtr = ckalloc((*lengthPtr) + 1);
- memcpy(*valuePtr, str, (size_t)(*lengthPtr)+1);
+ str = TclGetString(pathPtr);
+ *lengthPtr = pathPtr->length;
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, str, *lengthPtr + 1);
Tcl_DecrRefCount(pathPtr);
}
@@ -761,7 +762,7 @@ TclpSetVariables(
CFLocaleRef localeRef;
- if (CFLocaleCopyCurrent != NULL && CFLocaleGetIdentifier != NULL &&
+ if (&CFLocaleCopyCurrent != NULL && &CFLocaleGetIdentifier != NULL &&
(localeRef = CFLocaleCopyCurrent())) {
CFStringRef locale = CFLocaleGetIdentifier(localeRef);
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 6ed9443..495632c 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -153,8 +153,8 @@ static int triggerPipe = -1;
* The notifierMutex locks access to all of the global notifier state.
*/
-pthread_mutex_t notifierInitMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t notifierMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t notifierInitMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t notifierMutex = PTHREAD_MUTEX_INITIALIZER;
/*
* The following static indicates if the notifier thread is running.
*
@@ -196,7 +196,7 @@ static Tcl_ThreadId notifierThread;
*/
#ifdef TCL_THREADS
-static void NotifierThreadProc(ClientData clientData);
+static TCL_NORETURN void NotifierThreadProc(ClientData clientData);
#if defined(HAVE_PTHREAD_ATFORK)
static int atForkInit = 0;
static void AtForkChild(void);
@@ -1172,7 +1172,7 @@ Tcl_WaitForEvent(
*----------------------------------------------------------------------
*/
-static void
+static TCL_NORETURN void
NotifierThreadProc(
ClientData clientData) /* Not used. */
{
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 8167077..b404080 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -19,6 +19,7 @@
#define SET_BITS(var, bits) ((var) |= (bits))
#define CLEAR_BITS(var, bits) ((var) &= ~(bits))
+#define GOT_BITS(var, bits) (((var) & (bits)) != 0)
/* "sock" + a pointer in hex + \0 */
#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
@@ -52,6 +53,8 @@ typedef struct TcpFdList {
struct TcpState {
Tcl_Channel channel; /* Channel associated with this file. */
+ int testFlags; /* bit field for tests. Is set by testsocket
+ * test procedure */
TcpFdList fds; /* The file descriptors of the sockets. */
int flags; /* ORed combination of the bitfields defined
* below. */
@@ -93,6 +96,15 @@ struct TcpState {
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */
/*
+ * These bits may be ORed together into the "testFlags" field of a TcpState
+ * structure.
+ */
+
+#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
+ * automatically continue connection
+ * process. */
+
+/*
* The following defines the maximum length of the listen queue. This is the
* number of outstanding yet-to-be-serviced requests for a connection on a
* server socket, more than this number of outstanding requests and the
@@ -117,8 +129,7 @@ struct TcpState {
* Static routines for this file:
*/
-static int TcpConnect(Tcl_Interp *interp,
- TcpState *state);
+static int TcpConnect(Tcl_Interp *interp, TcpState *state);
static void TcpAccept(ClientData data, int mask);
static int TcpBlockModeProc(ClientData data, int mode);
static int TcpCloseProc(ClientData instanceData,
@@ -173,21 +184,24 @@ static ProcessGlobalValue hostName =
#if 0
/* printf debugging */
-void printaddrinfo(struct addrinfo *addrlist, char *prefix)
+void
+printaddrinfo(
+ struct addrinfo *addrlist,
+ char *prefix)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
struct addrinfo *ai;
+
for (ai = addrlist; ai != NULL; ai = ai->ai_next) {
getnameinfo(ai->ai_addr, ai->ai_addrlen,
- host, sizeof(host),
- port, sizeof(port),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ host, sizeof(host), port, sizeof(port),
+ NI_NUMERICHOST|NI_NUMERICSERV);
fprintf(stderr,"%s: %s:%s\n", prefix, host, port);
}
}
#endif
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* InitializeHostName --
*
@@ -197,13 +211,13 @@ void printaddrinfo(struct addrinfo *addrlist, char *prefix)
* Results:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static void
InitializeHostName(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
const char *native = NULL;
@@ -240,7 +254,7 @@ InitializeHostName(
}
}
if (native == NULL) {
- native = tclEmptyStringRep;
+ native = &tclEmptyString;
}
#else /* !NO_UNAME */
/*
@@ -271,12 +285,12 @@ InitializeHostName(
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
*lengthPtr = strlen(native);
- *valuePtr = ckalloc((*lengthPtr) + 1);
- memcpy(*valuePtr, native, (size_t)(*lengthPtr)+1);
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, native, *lengthPtr + 1);
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* Tcl_GetHostName --
*
@@ -290,7 +304,7 @@ InitializeHostName(
* Side effects:
* Caches the name to return for future calls.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
const char *
@@ -300,7 +314,7 @@ Tcl_GetHostName(void)
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TclpHasSockets --
*
@@ -312,7 +326,7 @@ Tcl_GetHostName(void)
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
int
@@ -323,7 +337,7 @@ TclpHasSockets(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TclpFinalizeSockets --
*
@@ -335,7 +349,7 @@ TclpHasSockets(
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
void
@@ -345,7 +359,7 @@ TclpFinalizeSockets(void)
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpBlockModeProc --
*
@@ -358,7 +372,7 @@ TclpFinalizeSockets(void)
* Side effects:
* Sets the device into blocking or nonblocking mode.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
/* ARGSUSED */
@@ -376,7 +390,7 @@ TcpBlockModeProc(
} else {
SET_BITS(statePtr->flags, TCP_NONBLOCKING);
}
- if (statePtr->flags & TCP_ASYNC_CONNECT) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
statePtr->cachedBlocking = mode;
return 0;
}
@@ -387,33 +401,32 @@ TcpBlockModeProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* WaitForConnect --
*
- * Check the state of an async connect process. If a connection
- * attempt terminated, process it, which may finalize it or may
- * start the next attempt. If a connect error occures, it is saved
- * in statePtr->connectError to be reported by 'fconfigure -error'.
+ * Check the state of an async connect process. If a connection attempt
+ * terminated, process it, which may finalize it or may start the next
+ * attempt. If a connect error occures, it is saved in
+ * statePtr->connectError to be reported by 'fconfigure -error'.
*
* There are two modes of operation, defined by errorCodePtr:
- * * non-NULL: Called by explicite read/write command. block if
+ * * non-NULL: Called by explicite read/write command. Blocks if the
* socket is blocking.
* May return two error codes:
* * EWOULDBLOCK: if connect is still in progress
- * * ENOTCONN: if connect failed. This would be the error
- * message of a rect or sendto syscall so this is
- * emulated here.
- * * NULL: Called by a backround operation. Do not block and
- * don't return any error code.
+ * * ENOTCONN: if connect failed. This would be the error message
+ * of a rect or sendto syscall so this is emulated here.
+ * * NULL: Called by a backround operation. Do not block and do not
+ * return any error code.
*
* Results:
- * 0 if the connection has completed, -1 if still in progress
- * or there is an error.
+ * 0 if the connection has completed, -1 if still in progress or there is
+ * an error.
*
* Side effects:
- * Processes socket events off the system queue.
- * May process asynchroneous connect.
+ * Processes socket events off the system queue. May process
+ * asynchroneous connects.
*
*----------------------------------------------------------------------
*/
@@ -426,11 +439,11 @@ WaitForConnect(
int timeout;
/*
- * Check if an async connect failed already and error reporting is demanded,
- * return the error ENOTCONN
+ * Check if an async connect failed already and error reporting is
+ * demanded, return the error ENOTCONN
*/
- if (errorCodePtr != NULL && (statePtr->flags & TCP_ASYNC_FAILED)) {
+ if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
*errorCodePtr = ENOTCONN;
return -1;
}
@@ -439,26 +452,43 @@ WaitForConnect(
* Check if an async connect is running. If not return ok
*/
- if (!(statePtr->flags & TCP_ASYNC_PENDING)) {
+ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
return 0;
}
- if (errorCodePtr == NULL || (statePtr->flags & TCP_NONBLOCKING)) {
+ /*
+ * In socket test mode do not continue with the connect.
+ * Exceptions are:
+ * - Call by recv/send and blocking socket
+ * (errorCodePtr != NULL && !GOT_BITS(flags, TCP_NONBLOCKING))
+ */
+
+ if (GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)
+ && !(errorCodePtr != NULL
+ && !GOT_BITS(statePtr->flags, TCP_NONBLOCKING))) {
+ *errorCodePtr = EWOULDBLOCK;
+ return -1;
+ }
+
+ if (errorCodePtr == NULL || GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
timeout = 0;
} else {
timeout = -1;
}
do {
if (TclUnixWaitForFile(statePtr->fds.fd,
- TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
+ TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
TcpConnect(NULL, statePtr);
}
- /* Do this only once in the nonblocking case and repeat it until the
- * socket is final when blocking */
- } while (timeout == -1 && statePtr->flags & TCP_ASYNC_CONNECT);
+
+ /*
+ * Do this only once in the nonblocking case and repeat it until the
+ * socket is final when blocking.
+ */
+ } while (timeout == -1 && GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT));
if (errorCodePtr != NULL) {
- if (statePtr->flags & TCP_ASYNC_PENDING) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
*errorCodePtr = EAGAIN;
return -1;
} else if (statePtr->connectError != 0) {
@@ -615,6 +645,7 @@ TcpCloseProc(
fds = statePtr->fds.next;
while (fds != NULL) {
TcpFdList *next = fds->next;
+
ckfree(fds);
fds = next;
}
@@ -685,10 +716,9 @@ TcpClose2Proc(
*
* TcpHostPortList --
*
- * This function is called by the -gethostname and -getpeername
- * switches of TcpGetOptionProc() to add three list elements
- * with the textual representation of the given address to the
- * given DString.
+ * This function is called by the -gethostname and -getpeername switches
+ * of TcpGetOptionProc() to add three list elements with the textual
+ * representation of the given address to the given DString.
*
* Results:
* None.
@@ -709,22 +739,22 @@ TcpHostPortList(
char host[NI_MAXHOST], nhost[NI_MAXHOST], nport[NI_MAXSERV];
int flags = 0;
- getnameinfo(&addr.sa, salen,
- nhost, sizeof(nhost), nport, sizeof(nport),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ getnameinfo(&addr.sa, salen, nhost, sizeof(nhost), nport, sizeof(nport),
+ NI_NUMERICHOST | NI_NUMERICSERV);
Tcl_DStringAppendElement(dsPtr, nhost);
+
/*
- * We don't want to resolve INADDR_ANY and sin6addr_any; they
- * can sometimes cause problems (and never have a name).
+ * We don't want to resolve INADDR_ANY and sin6addr_any; they can
+ * sometimes cause problems (and never have a name).
*/
+
if (addr.sa.sa_family == AF_INET) {
if (addr.sa4.sin_addr.s_addr == INADDR_ANY) {
flags |= NI_NUMERICHOST;
}
#ifndef NEED_FAKE_RFC2553
} else if (addr.sa.sa_family == AF_INET6) {
- if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr,
- &in6addr_any))
+ if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr, &in6addr_any))
|| (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) &&
addr.sa6.sin6_addr.s6_addr[12] == 0 &&
addr.sa6.sin6_addr.s6_addr[13] == 0 &&
@@ -734,15 +764,27 @@ TcpHostPortList(
}
#endif /* NEED_FAKE_RFC2553 */
}
- /* Check if reverse DNS has been switched off globally */
- if (interp != NULL && Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
+
+ /*
+ * Check if reverse DNS has been switched off globally.
+ */
+
+ if (interp != NULL &&
+ Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
flags |= NI_NUMERICHOST;
}
- if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0, flags) == 0) {
- /* Reverse mapping worked */
+ if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0,
+ flags) == 0) {
+ /*
+ * Reverse mapping worked.
+ */
+
Tcl_DStringAppendElement(dsPtr, host);
} else {
- /* Reverse mappong failed - use the numeric rep once more */
+ /*
+ * Reverse mapping failed - use the numeric rep once more.
+ */
+
Tcl_DStringAppendElement(dsPtr, nhost);
}
Tcl_DStringAppendElement(dsPtr, nport);
@@ -792,16 +834,20 @@ TcpGetOptionProc(
(strncmp(optionName, "-error", len) == 0)) {
socklen_t optlen = sizeof(int);
- if (statePtr->flags & TCP_ASYNC_CONNECT) {
- /* Suppress errors as long as we are not done */
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
+ /*
+ * Suppress errors as long as we are not done.
+ */
+
errno = 0;
} else if (statePtr->connectError != 0) {
errno = statePtr->connectError;
statePtr->connectError = 0;
} else {
int err;
- getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
- (char *) &err, &optlen);
+
+ getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR, (char *) &err,
+ &optlen);
errno = err;
}
if (errno != 0) {
@@ -812,9 +858,8 @@ TcpGetOptionProc(
if ((len > 1) && (optionName[1] == 'c') &&
(strncmp(optionName, "-connecting", len) == 0)) {
-
Tcl_DStringAppend(dsPtr,
- (statePtr->flags & TCP_ASYNC_CONNECT) ? "1" : "0", -1);
+ GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT) ? "1" : "0", -1);
return TCL_OK;
}
@@ -823,10 +868,11 @@ TcpGetOptionProc(
address peername;
socklen_t size = sizeof(peername);
- if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
/*
* In async connect output an empty string
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringAppendElement(dsPtr, "");
@@ -837,6 +883,7 @@ TcpGetOptionProc(
/*
* Peername fetch succeeded - output list
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
@@ -876,11 +923,12 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-sockname");
Tcl_DStringStartSublist(dsPtr);
}
- if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
/*
* In async connect output an empty string
*/
- found = 1;
+
+ found = 1;
} else {
for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
size = sizeof(sockname);
@@ -905,14 +953,15 @@ TcpGetOptionProc(
}
if (len > 0) {
- return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
+ return Tcl_BadChannelOption(interp, optionName,
+ "connecting peername sockname");
}
return TCL_OK;
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpWatchProc --
*
@@ -925,7 +974,7 @@ TcpGetOptionProc(
* Sets up the notifier so that a future event on the channel will be
* seen by Tcl.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static void
@@ -938,17 +987,17 @@ WrapNotify(
if (newmask == 0) {
/*
- * There was no overlap between the states the channel is
- * interested in notifications for, and the states that are
- * reported present on the file descriptor by select(). The
- * only way that can happen is when the channel is interested
- * in a writable condition, and only a readable state is reported
- * present (see TcpWatchProc() below). In that case, signal back
- * to the caller the writable state, which is really an error
- * condition. As an extra check on that assumption, check for
- * a non-zero value of errno before reporting an artificial
+ * There was no overlap between the states the channel is interested
+ * in notifications for, and the states that are reported present on
+ * the file descriptor by select(). The only way that can happen is
+ * when the channel is interested in a writable condition, and only a
+ * readable state is reported present (see TcpWatchProc() below). In
+ * that case, signal back to the caller the writable state, which is
+ * really an error condition. As an extra check on that assumption,
+ * check for a non-zero value of errno before reporting an artificial
* writable state.
*/
+
if (errno == 0) {
return;
}
@@ -972,33 +1021,36 @@ TcpWatchProc(
* be readable or writable at the Tcl level. This keeps Tcl scripts
* from interfering with the -accept behavior (bug #3394732).
*/
+
return;
}
- if (statePtr->flags & TCP_ASYNC_PENDING) {
- /* Async sockets use a FileHandler internally while connecting, so we
- * need to cache this request until the connection has succeeded. */
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
+ /*
+ * Async sockets use a FileHandler internally while connecting, so we
+ * need to cache this request until the connection has succeeded.
+ */
+
statePtr->filehandlers = mask;
} else if (mask) {
/*
- * Whether it is a bug or feature or otherwise, it is a fact
- * of life that on at least some Linux kernels select() fails
- * to report that a socket file descriptor is writable when
- * the other end of the socket is closed. This is in contrast
- * to the guarantees Tcl makes that its channels become
- * writable and fire writable events on an error conditon.
- * This has caused a leak of file descriptors in a state of
+ * Whether it is a bug or feature or otherwise, it is a fact of life
+ * that on at least some Linux kernels select() fails to report that a
+ * socket file descriptor is writable when the other end of the socket
+ * is closed. This is in contrast to the guarantees Tcl makes that
+ * its channels become writable and fire writable events on an error
+ * conditon. This has caused a leak of file descriptors in a state of
* background flushing. See Tcl ticket 1758a0b603.
*
- * As a workaround, when our caller indicates an interest in
- * writable notifications, we must tell the notifier built
- * around select() that we are interested in the readable state
- * of the file descriptor as well, as that is the only reliable
- * means to get notified of error conditions. Then it is the
- * task of WrapNotify() above to untangle the meaning of these
- * channel states and report the chan events as best it can.
- * We save a copy of the mask passed in to assist with that.
+ * As a workaround, when our caller indicates an interest in writable
+ * notifications, we must tell the notifier built around select() that
+ * we are interested in the readable state of the file descriptor as
+ * well, as that is the only reliable means to get notified of error
+ * conditions. Then it is the task of WrapNotify() above to untangle
+ * the meaning of these channel states and report the chan events as
+ * best it can. We save a copy of the mask passed in to assist with
+ * that.
*/
statePtr->interest = mask;
@@ -1010,7 +1062,7 @@ TcpWatchProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpGetHandleProc --
*
@@ -1024,7 +1076,7 @@ TcpWatchProc(
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
/* ARGSUSED */
@@ -1041,16 +1093,17 @@ TcpGetHandleProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpAsyncCallback --
*
- * Called by the event handler that TcpConnect sets up
- * internally for [socket -async] to get notified when the
- * asyncronous connection attempt has succeeded or failed.
+ * Called by the event handler that TcpConnect sets up internally for
+ * [socket -async] to get notified when the asyncronous connection
+ * attempt has succeeded or failed.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
+
static void
TcpAsyncCallback(
ClientData clientData, /* The socket state. */
@@ -1062,7 +1115,7 @@ TcpAsyncCallback(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpConnect --
*
@@ -1088,7 +1141,7 @@ TcpAsyncCallback(
* return and the loops resume as if they had never been interrupted.
* For syncronously connecting sockets, the loops work the usual way.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static int
@@ -1097,9 +1150,9 @@ TcpConnect(
TcpState *statePtr)
{
socklen_t optlen;
- int async_callback = statePtr->flags & TCP_ASYNC_PENDING;
- int ret = -1, error = errno;
- int async = statePtr->flags & TCP_ASYNC_CONNECT;
+ int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING);
+ int ret = -1, error = EHOSTUNREACH;
+ int async = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
goto reenter;
@@ -1107,8 +1160,8 @@ TcpConnect(
for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL;
statePtr->addr = statePtr->addr->ai_next) {
-
- for (statePtr->myaddr = statePtr->myaddrlist; statePtr->myaddr != NULL;
+ for (statePtr->myaddr = statePtr->myaddrlist;
+ statePtr->myaddr != NULL;
statePtr->myaddr = statePtr->myaddr->ai_next) {
int reuseaddr = 1;
@@ -1132,7 +1185,8 @@ TcpConnect(
errno = 0;
}
- statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM, 0);
+ statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM,
+ 0);
if (statePtr->fds.fd < 0) {
continue;
}
@@ -1151,14 +1205,18 @@ TcpConnect(
TclSockMinimumBuffers(INT2PTR(statePtr->fds.fd), SOCKET_BUFSIZE);
if (async) {
- ret = TclUnixSetBlockingMode(statePtr->fds.fd,TCL_MODE_NONBLOCKING);
+ ret = TclUnixSetBlockingMode(statePtr->fds.fd,
+ TCL_MODE_NONBLOCKING);
if (ret < 0) {
continue;
}
}
- /* Gotta reset the error variable here, before we use it for the
- * first time in this iteration. */
+ /*
+ * Must reset the error variable here, before we use it for the
+ * first time in this iteration.
+ */
+
error = 0;
(void) setsockopt(statePtr->fds.fd, SOL_SOCKET, SO_REUSEADDR,
@@ -1179,10 +1237,13 @@ TcpConnect(
ret = connect(statePtr->fds.fd, statePtr->addr->ai_addr,
statePtr->addr->ai_addrlen);
- if (ret < 0) error = errno;
+ if (ret < 0) {
+ error = errno;
+ }
if (ret < 0 && errno == EINPROGRESS) {
Tcl_CreateFileHandler(statePtr->fds.fd,
- TCL_WRITABLE|TCL_EXCEPTION, TcpAsyncCallback, statePtr);
+ TCL_WRITABLE | TCL_EXCEPTION, TcpAsyncCallback,
+ statePtr);
errno = EWOULDBLOCK;
SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
return TCL_OK;
@@ -1210,7 +1271,7 @@ TcpConnect(
}
}
-out:
+ out:
statePtr->connectError = error;
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
@@ -1308,6 +1369,7 @@ Tcl_OpenTcpClient(
/*
* Allocate a new TcpState for this socket.
*/
+
statePtr = ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->flags = async ? TCP_ASYNC_CONNECT : 0;
@@ -1319,6 +1381,7 @@ Tcl_OpenTcpClient(
/*
* Create a new client socket and wrap it in a channel.
*/
+
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
@@ -1326,8 +1389,8 @@ Tcl_OpenTcpClient(
sprintf(channelName, SOCK_TEMPLATE, (long) statePtr);
- statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, statePtr,
- (TCL_READABLE | TCL_WRITABLE));
+ statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
+ statePtr, TCL_READABLE | TCL_WRITABLE);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_Close(NULL, statePtr->channel);
@@ -1356,7 +1419,8 @@ Tcl_Channel
Tcl_MakeTcpClientChannel(
ClientData sock) /* The socket to wrap up into a channel. */
{
- return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
+ return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
+ TCL_READABLE | TCL_WRITABLE);
}
/*
@@ -1405,7 +1469,7 @@ TclpMakeTcpClientChannelMode(
/*
*----------------------------------------------------------------------
*
- * Tcl_OpenTcpServer --
+ * Tcl_OpenTcpServerEx --
*
* Opens a TCP server socket and creates a channel around it.
*
@@ -1420,16 +1484,17 @@ TclpMakeTcpClientChannelMode(
*/
Tcl_Channel
-Tcl_OpenTcpServer(
+Tcl_OpenTcpServerEx(
Tcl_Interp *interp, /* For error reporting - may be NULL. */
- int port, /* Port number to open. */
+ const char *service, /* Port number to open. */
const char *myHost, /* Name of local host. */
+ unsigned int flags, /* Flags. */
Tcl_TcpAcceptProc *acceptProc,
/* Callback for accepting connections from new
* clients. */
ClientData acceptProcData) /* Data for the callback. */
{
- int status = 0, sock = -1, reuseaddr = 1, chosenport = 0;
+ int status = 0, sock = -1, optvalue, port, chosenport;
struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */
TcpState *statePtr = NULL;
char channelName[SOCK_CHAN_LENGTH];
@@ -1444,7 +1509,45 @@ Tcl_OpenTcpServer(
enum { LOOKUP, SOCKET, BIND, LISTEN } howfar = LOOKUP;
int my_errno = 0;
- if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) {
+ /*
+ * If we were called with port 0 to listen on a random port number, we
+ * copy the port number from the first member of the addrinfo list to all
+ * subsequent members, so that IPv4 and IPv6 listen on the same port. This
+ * might fail to bind() with EADDRINUSE if a port is free on the first
+ * address family in the list but already used on the other. In this case
+ * we revert everything we've done so far and start from scratch hoping
+ * that next time we'll find a port number that is usable on all address
+ * families. We try this at most MAXRETRY times to avoid an endless loop
+ * if all ports are taken.
+ */
+
+ int retry = 0;
+#define MAXRETRY 10
+
+ repeat:
+ if (retry > 0) {
+ if (statePtr != NULL) {
+ TcpCloseProc(statePtr, NULL);
+ statePtr = NULL;
+ }
+ if (addrlist != NULL) {
+ freeaddrinfo(addrlist);
+ addrlist = NULL;
+ }
+ if (retry >= MAXRETRY) {
+ goto error;
+ }
+ }
+ retry++;
+ chosenport = 0;
+
+ if (TclSockGetPort(interp, service, "tcp", &port) != TCL_OK) {
+ errorMsg = "invalid port number";
+ goto error;
+ }
+
+ if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1,
+ &errorMsg)) {
my_errno = errno;
goto error;
}
@@ -1474,12 +1577,30 @@ Tcl_OpenTcpServer(
TclSockMinimumBuffers(INT2PTR(sock), SOCKET_BUFSIZE);
/*
- * Set up to reuse server addresses automatically and bind to the
- * specified port.
+ * Set up to reuse server addresses and/or ports if requested.
*/
- (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
- (char *) &reuseaddr, sizeof(reuseaddr));
+ if (GOT_BITS(flags, TCL_TCPSERVER_REUSEADDR)) {
+ optvalue = 1;
+ (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &optvalue, sizeof(optvalue));
+ }
+
+ if (GOT_BITS(flags, TCL_TCPSERVER_REUSEPORT)) {
+#ifndef SO_REUSEPORT
+ /*
+ * If the platform doesn't support the SO_REUSEPORT flag we can't
+ * do much beside erroring out.
+ */
+
+ errorMsg = "SO_REUSEPORT isn't supported by this platform";
+ goto error;
+#else
+ optvalue = 1;
+ (void) setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
+ (char *) &optvalue, sizeof(optvalue));
+#endif
+ }
/*
* Make sure we use the same port number when opening two server
@@ -1495,7 +1616,10 @@ Tcl_OpenTcpServer(
}
#ifdef IPV6_V6ONLY
- /* Missing on: Solaris 2.8 */
+ /*
+ * Missing on: Solaris 2.8
+ */
+
if (addrPtr->ai_family == AF_INET6) {
int v6only = 1;
@@ -1512,6 +1636,9 @@ Tcl_OpenTcpServer(
}
close(sock);
sock = -1;
+ if (port == 0 && errno == EADDRINUSE) {
+ goto repeat;
+ }
continue;
}
if (port == 0 && chosenport == 0) {
@@ -1535,6 +1662,9 @@ Tcl_OpenTcpServer(
}
close(sock);
sock = -1;
+ if (port == 0 && errno == EADDRINUSE) {
+ goto repeat;
+ }
continue;
}
if (statePtr == NULL) {
@@ -1641,7 +1771,7 @@ TcpAccept(
sprintf(channelName, SOCK_TEMPLATE, (long) newSockState);
newSockState->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
- newSockState, (TCL_READABLE | TCL_WRITABLE));
+ newSockState, TCL_READABLE | TCL_WRITABLE);
Tcl_SetChannelOption(NULL, newSockState->channel, "-translation",
"auto crlf");
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 02f255f..33d88c2 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -673,6 +673,7 @@ TclpFinalizeCondition(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
Tcl_DirEntry *
TclpReaddir(
DIR * dir)
@@ -695,6 +696,7 @@ TclpInetNtoa(
return inet_ntoa(addr);
#endif
}
+#endif /* TCL_NO_DEPRECATED */
#ifdef TCL_THREADS
/*
@@ -740,9 +742,7 @@ TclpFreeAllocMutex(
void
TclpInitAllocCache(void)
{
- pthread_mutex_lock(allocLockPtr);
- pthread_key_create(&key, TclpFreeAllocCache);
- pthread_mutex_unlock(allocLockPtr);
+ pthread_key_create(&key, NULL);
}
void
@@ -751,13 +751,19 @@ TclpFreeAllocCache(
{
if (ptr != NULL) {
/*
- * Called by the pthread lib when a thread exits
+ * Called by TclFinalizeThreadAllocThread() during the thread
+ * finalization initiated from Tcl_FinalizeThread()
*/
TclFreeAllocCache(ptr);
pthread_setspecific(key, NULL);
} else {
+ /*
+ * Called by TclFinalizeThreadAlloc() during the process
+ * finalization initiated from Tcl_Finalize()
+ */
+
pthread_key_delete(key);
}
}
diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c
index ae758de..3c32070 100644
--- a/unix/tclUnixTime.c
+++ b/unix/tclUnixTime.c
@@ -22,6 +22,7 @@
* variable is the key to this buffer.
*/
+#ifndef TCL_NO_DEPRECATED
static Tcl_ThreadDataKey tmKey;
typedef struct {
struct tm gmtime_buf;
@@ -45,6 +46,8 @@ static char *lastTZ = NULL; /* Holds the last setting of the TZ
static void SetTZIfNecessary(void);
static void CleanupMemory(ClientData clientData);
+#endif /* TCL_NO_DEPRECATED */
+
static void NativeScaleTime(Tcl_Time *timebuf,
ClientData clientData);
static void NativeGetTime(Tcl_Time *timebuf,
@@ -165,7 +168,7 @@ TclpGetWideClicks(void)
Tcl_Time time;
tclGetTimeProcPtr(&time, tclTimeClientData);
- now = (Tcl_WideInt) (time.sec*1000000 + time.usec);
+ now = ((Tcl_WideInt)time.sec)*1000000 + time.usec;
} else {
#ifdef MAC_OSX_TCL
now = (Tcl_WideInt) (mach_absolute_time() & INT64_MAX);
@@ -270,6 +273,7 @@ Tcl_GetTime(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
struct tm *
TclpGetDate(
const time_t *time,
@@ -359,6 +363,7 @@ TclpLocaltime(
return &tsdPtr->localtime_buf;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -495,6 +500,7 @@ NativeGetTime(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
static void
SetTZIfNecessary(void)
{
@@ -540,6 +546,7 @@ CleanupMemory(
{
ckfree(lastTZ);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
diff --git a/unix/tclXtTest.c b/unix/tclXtTest.c
index f7c2652..cb70b58 100644
--- a/unix/tclXtTest.c
+++ b/unix/tclXtTest.c
@@ -48,7 +48,7 @@ int
Tclxttest_Init(
Tcl_Interp *interp) /* Interpreter for application. */
{
- if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
XtToolkitInitialize();
diff --git a/win/Makefile.in b/win/Makefile.in
index 066e6b1..e967ef3 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -197,7 +197,7 @@ RM = rm -f
COPY = cp
CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${TCL_SHLIB_CFLAGS} \
--I"${ZLIB_DIR_NATIVE}" -I"${GENERIC_DIR_NATIVE}" -DTCL_TOMMATH \
+-I"${ZLIB_DIR_NATIVE}" -I"${GENERIC_DIR_NATIVE}" \
-DMP_PREC=4 -I"${TOMMATH_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" \
${AC_FLAGS} ${COMPILE_DEBUG_FLAGS} ${NO_DEPRECATED_FLAGS}
@@ -205,7 +205,7 @@ CC_OBJNAME = @CC_OBJNAME@
CC_EXENAME = @CC_EXENAME@
STUB_CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
--I"${GENERIC_DIR_NATIVE}" -DTCL_TOMMATH -DMP_PREC=4 -I"${TOMMATH_DIR_NATIVE}" \
+-I"${GENERIC_DIR_NATIVE}" -DMP_PREC=4 -I"${TOMMATH_DIR_NATIVE}" \
-I"${WIN_DIR_NATIVE}" ${AC_FLAGS} \
${COMPILE_DEBUG_FLAGS}
@@ -328,6 +328,7 @@ TOMMATH_OBJS = \
bn_mp_div_3.${OBJEXT} \
bn_mp_exch.${OBJEXT} \
bn_mp_expt_d.${OBJEXT} \
+ bn_mp_expt_d_ex.${OBJEXT} \
bn_mp_grow.${OBJEXT} \
bn_mp_init.${OBJEXT} \
bn_mp_init_copy.${OBJEXT} \
@@ -651,8 +652,8 @@ install-libraries: libraries install-tzdata install-msgs
do \
$(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/http1.0"; \
done;
- @echo "Installing package http 2.8.9 as a Tcl Module";
- @$(COPY) $(ROOT_DIR)/library/http/http.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.6/http-2.8.9.tm;
+ @echo "Installing package http 2.8.10 as a Tcl Module";
+ @$(COPY) $(ROOT_DIR)/library/http/http.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.6/http-2.8.10.tm;
@echo "Installing library opt0.4 directory";
@for j in $(ROOT_DIR)/library/opt/*.tcl; \
do \
diff --git a/win/configure b/win/configure
index b8c4d0f..1eba1c0 100755
--- a/win/configure
+++ b/win/configure
@@ -4167,7 +4167,7 @@ $as_echo "using shared flags" >&6; }
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
diff --git a/win/makefile.bc b/win/makefile.bc
deleted file mode 100644
index bee61d7..0000000
--- a/win/makefile.bc
+++ /dev/null
@@ -1,594 +0,0 @@
-#
-# Makefile for Borland C++ 5.5 (or C++ Builder 5), adapted from the makefile
-# for Visual C++ that came with tcl 8.3.3
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# Copyright (c) 1995-1996 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-
-# TIP #59 information.
-#
-# This makefile does not set the following configuration cpp
-# defines. Behind the defines are the makefile variables listed to set
-# to -D... when that feature is enabled.
-#
-# - TCL_CFG_PROFILED PROFDEFINES
-# - TCL_CFG_OPTIMIZED OPTDEFINES
-# - TCL_CFG_DO64BIT SIXFOURDEFINES
-
-# Have a look at the complete description on how to build and test Tcl with
-# the current Borland compilers at www.ratiosoft.com/tcl/borland.
-#
-# Usage:
-# - Adapt the paths below to match your compiler's location
-# - Make sure the compiler's bin directory is on your path
-# - Open a console
-# - To make a debug version enter
-# make -fmakefile.bc -DNODEBUG=0 xxx
-# where 'xxx' is the target you want (e.g. 'all', 'test', ...)
-# Please note: I omitted the 'd' suffix for debug versions because Tcl
-# will always call tclpip83.dll and not tclpip83d.dll, causing an error.
-# ^
-# Besides, the debug version goes into a separate directory, so there
-# should be no problem having DLLs and EXEs with the same name.
-# If you prefer your debug version having the 'd' suffix just uncomment
-# the line
-# #DBGX = d
-#
-# - To make a 'normal' version enter
-# make -fmakefile.bc xxx
-# where 'xxx' is the target you want (e.g. 'all', 'test', ...)
-#
-# DISCLAIMER:
-# This makefile has an experimental status - that is those targets which
-# have been modified do in fact compile and link with Borland's C++
-# Builder 5 and with the free Borland compiler (Borland C++ 5.5).
-# However the author assumes no responsiblity for any effect which the use of
-# this makefile or of the resulting programs might have on your system.
-#
-# Not yet modified:
-# - The 'plug-in-DLL' and the associated shell.
-#
-# Suggestions and / or improvements are always welcome.
-#
-# May 2001, H. Giese (hgiese@ratiosoft.com)
-#
-
-# Does not depend on the presence of any environment variables in
-# order to compile tcl; all needed information is derived from
-# location of the compiler directories.
-
-#
-# Project directories
-#
-# ROOT = top of source tree
-#
-# TOOLS32 = location of Borland development tools.
-#
-# INSTALLDIR = where the install-targets should copy the binaries and
-# support files
-#
-
-ROOT = ..
-INSTALLDIR = c:\program files\tcl
-
-# If you have C++ Builder 5 or the free Borland C++ 5.5 compiler
-# adapt the following paths as appropriate for your system
-TOOLS32 = c:\dev\bcc55
-TOOLS32_rc = c:\dev\bcc55
-#TOOLS32 = c:\bc55
-#TOOLS32_rc = c:\bc55
-
-cc32 = "$(TOOLS32)\bin\bcc32.exe"
-link32 = "$(TOOLS32)\bin\ilink32.exe"
-lib32 = "$(TOOLS32)\bin\tlib.exe"
-rc32 = "$(TOOLS32_rc)\bin\brcc32.exe"
-include32 = -I"$(TOOLS32)\include"
-libpath32 = -L"$(TOOLS32)\lib"
-
-# Uncomment the following line to compile with thread support
-#THREADDEFINES = -DTCL_THREADS=1
-
-# Allow definition of NDEBUG via command line
-# Set NODEBUG to 0 to compile with symbols
-!if !defined(NODEBUG)
-NODEBUG = 1
-!endif
-
-# CFG_ENCODING=encoding
-# name of encoding for configuration information. Defaults
-# to cp1252
-!if !defined(CFG_ENCODING)
-CFG_ENCODING = \"cp1252\"
-!endif
-
-# The following defines can be used to control the amount of debugging
-# code that is added to the compilation.
-#
-# -DTCL_MEM_DEBUG Enables the debugging memory allocator.
-# -DTCL_COMPILE_DEBUG Enables byte compilation logging.
-# -DTCL_COMPILE_STATS Enables byte compilation statistics gathering.
-# -DUSE_TCLALLOC=0 Disables the Tcl memory allocator in favor
-# of the native malloc implementation. This is
-# needed when using Purify.
-#
-#DEBUGDEFINES = -DTCL_MEM_DEBUG -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
-#DEBUGDEFINES = -DUSE_TCLALLOC=0
-
-######################################################################
-# Do not modify below this line
-######################################################################
-
-NAMEPREFIX = tcl
-STUBPREFIX = $(NAMEPREFIX)stub
-DOTVERSION = 8.7
-VERSION = 87
-
-DDEVERSION = 14
-DDEDOTVERSION = 1.4
-
-REGVERSION = 13
-REGDOTVERSION = 1.3
-
-BINROOT = ..
-!IF "$(NODEBUG)" == "1"
-TMPDIRNAME = Release
-DBGX =
-SYMDEFINES = -DNDEBUG
-!ELSE
-TMPDIRNAME = Debug
-#DBGX = d
-DBGX =
-SYMDEFINES = -DTCL_CFG_DEBUG
-!ENDIF
-TMPDIR = $(BINROOT)\$(TMPDIRNAME)
-OUTDIRNAME = $(TMPDIRNAME)
-OUTDIR = $(TMPDIR)
-
-TCLLIB = $(OUTDIR)\$(NAMEPREFIX)$(VERSION)$(DBGX).lib
-TCLDLLNAME = $(NAMEPREFIX)$(VERSION)$(DBGX).dll
-TCLDLL = $(OUTDIR)\$(TCLDLLNAME)
-
-TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION)$(DBGX).lib
-TCLSTUBLIB = $(OUTDIR)\$(TCLSTUBLIBNAME)
-
-TCLPLUGINLIB = $(OUTDIR)\$(NAMEPREFIX)$(VERSION)p$(DBGX).lib
-TCLPLUGINDLLNAME = $(NAMEPREFIX)$(VERSION)p$(DBGX).dll
-TCLPLUGINDLL = $(OUTDIR)\$(TCLPLUGINDLLNAME)
-TCLSH = $(OUTDIR)\$(NAMEPREFIX)sh$(VERSION)$(DBGX).exe
-TCLSHP = $(OUTDIR)\$(NAMEPREFIX)shp$(VERSION)$(DBGX).exe
-TCLREGDLLNAME = $(NAMEPREFIX)reg$(REGVERSION)$(DBGX).dll
-TCLREGDLL = $(OUTDIR)\$(TCLREGDLLNAME)
-TCLDDEDLLNAME = $(NAMEPREFIX)dde$(DDEVERSION)$(DBGX).dll
-TCLDDEDLL = $(OUTDIR)\$(TCLDDEDLLNAME)
-TCLTEST = $(OUTDIR)\$(NAMEPREFIX)test.exe
-CAT32 = $(TMPDIR)\cat32.exe
-RMDIR = .\rmd.bat
-MKDIR = .\mkd.bat
-RM = del
-
-LIB_INSTALL_DIR = $(INSTALLDIR)\lib
-BIN_INSTALL_DIR = $(INSTALLDIR)\bin
-SCRIPT_INSTALL_DIR = $(INSTALLDIR)\lib\tcl$(DOTVERSION)
-INCLUDE_INSTALL_DIR = $(INSTALLDIR)\include
-
-TCLSHOBJS = \
- $(TMPDIR)\tclAppInit.obj
-
-TCLTESTOBJS = \
- $(TMPDIR)\tclTest.obj \
- $(TMPDIR)\tclTestObj.obj \
- $(TMPDIR)\tclTestProcBodyObj.obj \
- $(TMPDIR)\tclThreadTest.obj \
- $(TMPDIR)\tclWinTest.obj \
- $(TMPDIR)\testMain.obj
-
-TCLOBJS = \
- $(TMPDIR)\regcomp.obj \
- $(TMPDIR)\regexec.obj \
- $(TMPDIR)\regfree.obj \
- $(TMPDIR)\regerror.obj \
- $(TMPDIR)\tclAlloc.obj \
- $(TMPDIR)\tclAsync.obj \
- $(TMPDIR)\tclBasic.obj \
- $(TMPDIR)\tclBinary.obj \
- $(TMPDIR)\tclCkalloc.obj \
- $(TMPDIR)\tclClock.obj \
- $(TMPDIR)\tclCmdAH.obj \
- $(TMPDIR)\tclCmdIL.obj \
- $(TMPDIR)\tclCmdMZ.obj \
- $(TMPDIR)\tclCompCmds.obj \
- $(TMPDIR)\tclCompCmdsGR.obj \
- $(TMPDIR)\tclCompCmdsSZ.obj \
- $(TMPDIR)\tclCompExpr.obj \
- $(TMPDIR)\tclCompile.obj \
- $(TMPDIR)\tclConfig.obj \
- $(TMPDIR)\tclDate.obj \
- $(TMPDIR)\tclDictObj.obj \
- $(TMPDIR)\tclDisassemble.obj \
- $(TMPDIR)\tclEncoding.obj \
- $(TMPDIR)\tclEnsemble.obj \
- $(TMPDIR)\tclEnv.obj \
- $(TMPDIR)\tclEvent.obj \
- $(TMPDIR)\tclExecute.obj \
- $(TMPDIR)\tclFCmd.obj \
- $(TMPDIR)\tclFileName.obj \
- $(TMPDIR)\tclGet.obj \
- $(TMPDIR)\tclHash.obj \
- $(TMPDIR)\tclHistory.obj \
- $(TMPDIR)\tclIndexObj.obj \
- $(TMPDIR)\tclInterp.obj \
- $(TMPDIR)\tclIO.obj \
- $(TMPDIR)\tclIOCmd.obj \
- $(TMPDIR)\tclIOGT.obj \
- $(TMPDIR)\tclIOSock.obj \
- $(TMPDIR)\tclIOUtil.obj \
- $(TMPDIR)\tclLink.obj \
- $(TMPDIR)\tclLiteral.obj \
- $(TMPDIR)\tclListObj.obj \
- $(TMPDIR)\tclLoad.obj \
- $(TMPDIR)\tclMain.obj \
- $(TMPDIR)\tclNamesp.obj \
- $(TMPDIR)\tclNotify.obj \
- $(TMPDIR)\tclOO.obj \
- $(TMPDIR)\tclOOBasic.obj \
- $(TMPDIR)\tclOOCall.obj \
- $(TMPDIR)\tclOODefineCmds.obj \
- $(TMPDIR)\tclOOInfo.obj \
- $(TMPDIR)\tclOOMethod.obj \
- $(TMPDIR)\tclOOStubInit.obj \
- $(TMPDIR)\tclObj.obj \
- $(TMPDIR)\tclOptimize.obj \
- $(TMPDIR)\tclPanic.obj \
- $(TMPDIR)\tclParse.obj \
- $(TMPDIR)\tclPipe.obj \
- $(TMPDIR)\tclPkg.obj \
- $(TMPDIR)\tclPkgConfig.obj \
- $(TMPDIR)\tclPosixStr.obj \
- $(TMPDIR)\tclPreserve.obj \
- $(TMPDIR)\tclProc.obj \
- $(TMPDIR)\tclRegexp.obj \
- $(TMPDIR)\tclResolve.obj \
- $(TMPDIR)\tclResult.obj \
- $(TMPDIR)\tclScan.obj \
- $(TMPDIR)\tclStringObj.obj \
- $(TMPDIR)\tclStubInit.obj \
- $(TMPDIR)\tclThread.obj \
- $(TMPDIR)\tclThreadJoin.obj \
- $(TMPDIR)\tclTimer.obj \
- $(TMPDIR)\tclTrace.obj \
- $(TMPDIR)\tclUtf.obj \
- $(TMPDIR)\tclUtil.obj \
- $(TMPDIR)\tclVar.obj \
- $(TMPDIR)\tclWin32Dll.obj \
- $(TMPDIR)\tclWinChan.obj \
- $(TMPDIR)\tclWinConsole.obj \
- $(TMPDIR)\tclWinSerial.obj \
- $(TMPDIR)\tclWinError.obj \
- $(TMPDIR)\tclWinFCmd.obj \
- $(TMPDIR)\tclWinFile.obj \
- $(TMPDIR)\tclWinInit.obj \
- $(TMPDIR)\tclWinLoad.obj \
- $(TMPDIR)\tclWinNotify.obj \
- $(TMPDIR)\tclWinPipe.obj \
- $(TMPDIR)\tclWinSock.obj \
- $(TMPDIR)\tclWinThrd.obj \
- $(TMPDIR)\tclWinTime.obj \
- $(TMPDIR)\tclZlib.obj
-
-TCLSTUBOBJS = \
- $(TMPDIR)\tclStubLib.obj \
- $(TMPDIR)\tclTomMathStubLib.obj \
- $(TMPDIR)\tclOOStubLib.obj
-
-WINDIR = $(ROOT)\win
-GENERICDIR = $(ROOT)\generic
-
-TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
-TCL_DEFINES = $(DEBUGDEFINES) $(THREADDEFINES) $(SYMDEFINES) \
- $(PROFDEFINES) $(OPTDEFINES) $(SIXFOURDEFINES) \
- -DTCL_CFGVAL_ENCODING=${CFG_ENCODING}
-### TODO: Add -DHAVE_ZLIB=1
-
-######################################################################
-# Compiler flags
-######################################################################
-
-!IF "$(NODEBUG)" == "1"
-# these macros cause maximum optimization and no symbols
-cdebug = -v- -vi- -O2 -D_DEBUG
-!ELSE
-# these macros enable debugging
-cdebug = -k -Od -r- -v -vi- -y
-!ENDIF
-
-SYSDEFINES = _MT;NO_STRICT;_NO_VCL
-
-# declarations common to all compiler options
-cbase = -c -q -3 -a4 -g0 -tWM -Ve -Vx -X-
-WARNINGS = -w-rch -w-pch -w-par -w-dup -w-pro -w-dpu
-
-ccons = -tWC
-
-INCLUDEPATH = $(include32) $(TCL_INCLUDES)
-
-CFLAGS = $(cdebug) $(cbase) $(INCLUDEPATH) $(WARNINGS) -D$(SYSDEFINES)
-TCL_CFLAGS = $(CFLAGS) $(TCL_DEFINES)
-CONS_CFLAGS = $(CFLAGS) $(TCL_DEFINES) $(ccons)
-
-######################################################################
-# Linker flags
-######################################################################
-
-!IF "$(NODEBUG)" == "1"
-ldebug =
-!ELSE
-ldebug = -v
-!ENDIF
-
-# declarations common to all linker options
-LNFLAGS = -D"" -Gn -I$(TMPDIR) -x $(ldebug) $(libpath32)
-# -Gi: create lib file (is -Gl in doc)
-# -aa: Windows app, -ap: Windows console app
-LNFLAGS_DLL = -ap -Gi -Tpd
-LNFLAGS_CONS = -ap -Tpe
-
-LNLIBS = import32 cw32mt
-
-
-######################################################################
-# Project specific targets
-######################################################################
-
-release: setup $(TCLSH) dlls
-dlls: setup $(TCLREGDLL) $(TCLDDEDLL)
-all: setup $(TCLSH) dlls $(CAT32)
-tcltest: setup $(TCLTEST) dlls $(CAT32)
-plugin: setup $(TCLPLUGINDLL) $(TCLSHP)
-install: install-binaries install-libraries
-
-test: setup $(TCLTEST) dlls $(CAT32)
- set TCL_LIBRARY=$(ROOT)/library
- $(TCLTEST) $(ROOT)/tests/all.tcl
-
-setup:
- @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) &\
- echo *** Created directory '$(OUT_DIR)'
- @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) &\
- echo *** Created directory '$(TMP_DIR)'
-
-
-$(TCLLIB): $(TCLDLL)
-
-$(TCLDLL): $(TCLOBJS) $(TMPDIR)\$(NAMEPREFIX).res
- $(link32) $(ldebug) $(LNFLAGS) $(LNFLAGS_DLL) $(TOOLS32)\lib\c0d32 @&&!
- $(TCLOBJS), $@, -x, $(LNLIBS),, $(TMPDIR)\$(NAMEPREFIX).res
-!
-
-$(TCLSTUBLIB): $(TCLSTUBOBJS)
- $(lib32) /u $@ $(TCLSTUBOBJS)
-
-$(TCLPLUGINLIB): $(TCLPLUGINDLL)
-
-$(TCLPLUGINDLL): $(TCLOBJS) $(TMPDIR)\tcl.res
- $(link32) $(ldebug) $(dlllflags) \
- -out:$@ $(TMPDIR)\tcl.res $(guilibsdll) @&&!
-$(TCLOBJS)
-!
-
-$(TCLSH): $(TCLSHOBJS) $(TCLLIB) $(TMPDIR)\$(NAMEPREFIX)sh.res
- $(link32) $(ldebug) -S:2400000 $(LNFLAGS) $(LNFLAGS_CONS) $(TOOLS32)\lib\c0x32 @&&!
- $(TCLSHOBJS), $@, -x, $(LNLIBS) $(TCLLIB),, $(TMPDIR)\$(NAMEPREFIX)sh.res
-!
-
-$(TCLSHP): $(TCLSHOBJS) $(TCLPLUGINLIB) $(TMPDIR)\tclsh.res
- $(link32) $(ldebug) $(conlflags) $(TMPDIR)\tclsh.res -stack:2300000 \
- -out:$@ $(conlibsdll) $(TCLPLUGINLIB) $(TCLSHOBJS)
-
-$(TCLTEST): $(TCLTESTOBJS) $(TCLLIB) $(TMPDIR)\$(NAMEPREFIX)sh.res
- $(link32) $(ldebug) -S:2400000 $(LNFLAGS) $(LNFLAGS_CONS) $(TOOLS32)\lib\c0x32 @&&!
- $(TCLTESTOBJS), $@, -x, $(LNLIBS) $(TCLLIB),, $(TMPDIR)\$(NAMEPREFIX)sh.res
-!
-
-$(TCLDDEDLL): $(TMPDIR)\tclWinDde.obj $(TCLSTUBLIB)
- $(link32) $(ldebug) $(LNFLAGS) $(LNFLAGS_DLL) $(TOOLS32)\lib\c0d32 \
- $(TMPDIR)\tclWinDde.obj, $@, -x, $(LNLIBS) $(TCLSTUBLIB),, \
- $(TMPDIR)\$(NAMEPREFIX).res
-
-$(TCLREGDLL): $(TMPDIR)\tclWinReg.obj $(TCLSTUBLIB)
- $(link32) $(ldebug) $(LNFLAGS) $(LNFLAGS_DLL) $(TOOLS32)\lib\c0d32 \
- $(TMPDIR)\tclWinReg.obj, $@, -x, $(LNLIBS) $(TCLSTUBLIB),, \
- $(TMPDIR)\$(NAMEPREFIX).res
-
-$(CAT32): $(WINDIR)\cat.c
- $(cc32) $(CONS_CFLAGS) -o$(TMPDIR)\cat.obj $?
- $(link32) $(ldebug) $(LNFLAGS) $(LNFLAGS_CONS) $(TOOLS32)\lib\c0x32 \
- $(TMPDIR)\cat.obj, $@, -x, $(LNLIBS),,
-
-install-binaries: $(TCLSH)
- $(MKDIR) "$(BIN_INSTALL_DIR)"
- $(MKDIR) "$(LIB_INSTALL_DIR)"
- @echo Installing $(TCLDLLNAME)
- @copy "$(TCLDLL)" "$(BIN_INSTALL_DIR)"
- @copy "$(TCLLIB)" "$(LIB_INSTALL_DIR)"
- @echo Installing "$(TCLSH)"
- @copy "$(TCLSH)" "$(BIN_INSTALL_DIR)"
- @echo Installing $(TCLSTUBLIBNAME)
- @copy "$(TCLSTUBLIB)" "$(LIB_INSTALL_DIR)"
- @echo Installing $(WINDIR)\tclooConfig.sh
- @copy "$(WINDIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)"
-
-install-libraries:
- -@$(MKDIR) "$(LIB_INSTALL_DIR)"
- -@$(MKDIR) "$(INCLUDE_INSTALL_DIR)"
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)"
- @echo Installing http1.0
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http1.0"
- -@copy "$(ROOT)\library\http1.0\http.tcl" "$(SCRIPT_INSTALL_DIR)\http1.0"
- -@copy "$(ROOT)\library\http1.0\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http1.0"
- @echo Installing http2.8
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http2.8"
- -@copy "$(ROOT)\library\http\http.tcl" "$(SCRIPT_INSTALL_DIR)\http2.8"
- -@copy "$(ROOT)\library\http\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http2.8"
- @echo Installing opt0.4
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\opt0.4"
- -@copy "$(ROOT)\library\opt\optparse.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
- -@copy "$(ROOT)\library\opt\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
- @echo Installing msgcat1.5
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\msgcat1.5"
- -@copy "$(ROOT)\library\msgcat\msgcat.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.5"
- -@copy "$(ROOT)\library\msgcat\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.5"
- @echo Installing tcltest2.3
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\tcltest2.3"
- -@copy "$(ROOT)\library\tcltest\tcltest.tcl" "$(SCRIPT_INSTALL_DIR)\tcltest2.3"
- -@copy "$(ROOT)\library\tcltest\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\tcltest2.3"
- @echo Installing platform1.0
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\platform1.0"
- -@copy "$(ROOT)\library\platform\platform.tcl" "$(SCRIPT_INSTALL_DIR)\platform1.0"
- -@copy "$(ROOT)\library\platform\shell.tcl" "$(SCRIPT_INSTALL_DIR)\platform1.0"
- -@copy "$(ROOT)\library\platform\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\platform1.0"
- @echo Installing $(TCLDDEDLLNAME)
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\dde1.3"
- -@copy "$(TCLDDEDLL)" "$(SCRIPT_INSTALL_DIR)\dde1.3"
- -@copy "$(ROOT)\library\dde\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\dde1.3"
- @echo Installing $(TCLREGDLLNAME)
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\reg1.2"
- -@copy "$(TCLREGDLL)" "$(SCRIPT_INSTALL_DIR)\reg1.3"
- -@copy "$(ROOT)\library\reg\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\reg1.2"
- @echo Installing encoding files
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\encoding"
- -@copy "$(ROOT)\library\encoding\*.enc" "$(SCRIPT_INSTALL_DIR)\encoding"
- @echo Installing library files
- -@copy "$(GENERICDIR)\tcl.h" "$(INCLUDE_INSTALL_DIR)"
- -@copy "$(GENERICDIR)\tclDecls.h" "$(INCLUDE_INSTALL_DIR)"
- -@copy "$(GENERICDIR)\tclOO.h" "$(INCLUDE_INSTALL_DIR)"
- -@copy "$(GENERICDIR)\tclOODecls.h" "$(INCLUDE_INSTALL_DIR)"
- -@copy "$(GENERICDIR)\tclPlatDecls.h" "$(INCLUDE_INSTALL_DIR)"
- -@copy "$(ROOT)\library\history.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\init.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\parray.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\safe.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\tclIndex" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\package.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\word.tcl" "$(SCRIPT_INSTALL_DIR)"
- -@copy "$(ROOT)\library\auto.tcl" "$(SCRIPT_INSTALL_DIR)"
-
-#
-# Regenerate the stubs files.
-#
-
-genstubs:
- tclsh$(VERSION) $(ROOT)\tools\genStubs.tcl $(GENERICDIR) \
- $(GENERICDIR)\tcl.decls $(GENERICDIR)\tclInt.decls
-
-#
-# Special case object file targets
-#
-$(TMPDIR)\tclWinInit.obj: $(WINDIR)\tclWinInit.c
- $(cc32) -DBUILD_tcl $(TCL_CFLAGS) -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\testMain.obj: $(WINDIR)\tclAppInit.c
- $(cc32) $(TCL_CFLAGS) -DTCL_TEST -o$(TMPDIR)\testMain.obj $?
-
-$(TMPDIR)\tclTest.obj: $(GENERICDIR)\tclTest.c
- $(cc32) $(TCL_CFLAGS) -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c
- $(cc32) $(TCL_CFLAGS) -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c
- $(cc32) $(TCL_CFLAGS) -o$(TMPDIR)\$@ $?
-
-$(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c
- $(cc32) $(TCL_CFLAGS) \
- -DCFG_INSTALL_EXEC_PREFIX=\"$(INSTALL_EXEC_PREFIX)\" \
- -DCFG_INSTALL_PREFIX=\"$(INSTALL_PREFIX)\" \
- -DCFG_RUNTIME_EXEC_PREFIX=\"$(RUNTIME_EXEC_PREFIX)\" \
- -DCFG_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
- -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\tclAppInit.obj : $(WINDIR)\tclAppInit.c
- $(cc32) $(TCL_CFLAGS) -o$(TMPDIR)\$@ $?
-
-# The following objects should be built using the stub interfaces
-
-# tclWinReg: Produces errors in ANSI mode
-$(TMPDIR)\tclWinReg.obj : $(WINDIR)\tclWinReg.c
- $(cc32) $(TCL_CFLAGS) -DUSE_TCL_STUBS -o$(TMPDIR)\$@ $?
-
-# tclWinDde: Produces errors in ANSI mode
-$(TMPDIR)\tclWinDde.obj : $(WINDIR)\tclWinDde.c
- $(cc32) $(TCL_CFLAGS) -DUSE_TCL_STUBS -o$(TMPDIR)\$@ $?
-
-
-# The following objects are part of the stub library and should not
-# be built as DLL objects but none of the symbols should be exported
-
-$(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c
- $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\tclTomMathStubLib.obj : $(GENERICDIR)\tclTomMathStubLib.c
- $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
-
-$(TMPDIR)\tclOOStubLib.obj : $(GENERICDIR)\tclOOStubLib.c
- $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
-
-
-# Dedependency rules
-
-$(GENERICDIR)\regcomp.c: \
- $(GENERICDIR)\regguts.h \
- $(GENERICDIR)\regc_lex.c \
- $(GENERICDIR)\regc_color.c \
- $(GENERICDIR)\regc_nfa.c \
- $(GENERICDIR)\regc_cvec.c \
- $(GENERICDIR)\regc_locale.c
-
-$(GENERICDIR)\regcustom.h: \
- $(GENERICDIR)\tclInt.h \
- $(GENERICDIR)\tclPort.h \
- $(GENERICDIR)\regex.h
-
-$(GENERICDIR)\regexec.c: \
- $(GENERICDIR)\rege_dfa.c \
- $(GENERICDIR)\regguts.h
-
-$(GENERICDIR)\regerror.c: $(GENERICDIR)\regguts.h
-$(GENERICDIR)\regfree.c: $(GENERICDIR)\regguts.h
-$(GENERICDIR)\regfronts.c: $(GENERICDIR)\regguts.h
-$(GENERICDIR)\regguts.h: $(GENERICDIR)\regcustom.h
-
-#
-# Implicit rules
-#
-
-{$(WINDIR)}.c{$(TMPDIR)}.obj:
- $(cc32) -DBUILD_tcl $(TCL_CFLAGS) -o$@ $<
-
-{$(GENERICDIR)}.c{$(TMPDIR)}.obj:
- $(cc32) -DBUILD_tcl $(TCL_CFLAGS) -o$@ $<
-
-{$(ROOT)\compat}.c{$(TMPDIR)}.obj:
- $(cc32) -DBUILD_tcl $(TCL_CFLAGS) -o$@ $<
-
-{$(WINDIR)}.rc{$(TMPDIR)}.res:
- $(rc32) $(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $<
-
-clean:
- -@$(RM) $(OUTDIR)\*.exp
- -@$(RM) $(OUTDIR)\*.lib
- -@$(RM) $(OUTDIR)\*.dll
- -@$(RM) $(OUTDIR)\*.exe
- -@$(RM) $(OUTDIR)\*.pdb
- -@$(RM) $(TMPDIR)\*.pch
- -@$(RM) $(TMPDIR)\*.obj
- -@$(RM) $(TMPDIR)\*.res
- -@$(RM) $(TMPDIR)\*.exe
- -@$(RMDIR) $(OUTDIR)
- -@$(RMDIR) $(TMPDIR)
-
-# Local Variables:
-# mode: makefile
-# End:
diff --git a/win/makefile.vc b/win/makefile.vc
index f401541..d6de5e1 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -113,12 +113,12 @@ the build instructions.
# memdbg = Enables the debugging memory allocator.
#
# CHECKS=64bit,fullwarn,nodep,none
-# Sets special macros for checking compatability.
+# Sets special macros for checking compatibility.
#
# 64bit = Enable 64bit portability warnings (if available)
# fullwarn = Builds with full compiler and link warnings enabled.
# Very verbose.
-# nodep = Turns off compatability macros to ensure the core
+# nodep = Turns off compatibility macros to ensure the core
# isn't being built with deprecated functions.
#
# MACHINE=(ALPHA|AMD64|IA64|IX86)
@@ -383,6 +383,7 @@ TOMMATHOBJS = \
$(TMP_DIR)\bn_mp_div_3.obj \
$(TMP_DIR)\bn_mp_exch.obj \
$(TMP_DIR)\bn_mp_expt_d.obj \
+ $(TMP_DIR)\bn_mp_expt_d_ex.obj \
$(TMP_DIR)\bn_mp_grow.obj \
$(TMP_DIR)\bn_mp_init.obj \
$(TMP_DIR)\bn_mp_init_copy.obj \
@@ -503,7 +504,7 @@ crt = -MT
!endif
TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)"
-TCL_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1
+TCL_DEFINES = -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1
BASE_CFLAGS = $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) $(TCL_DEFINES)
CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE
TCL_CFLAGS = $(BASE_CFLAGS) $(OPTDEFINES)
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 84cf75c..22b7b06 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -43,7 +43,7 @@
/* protos */
static int CheckForCompilerFeature(const char *option);
-static int CheckForLinkerFeature(const char *option);
+static int CheckForLinkerFeature(const char **options, int count);
static int IsIn(const char *string, const char *substring);
static int SubstituteFile(const char *substs, const char *filename);
static int QualifyPath(const char *path);
@@ -102,16 +102,16 @@ main(
}
return CheckForCompilerFeature(argv[2]);
case 'l':
- if (argc != 3) {
+ if (argc < 3) {
chars = snprintf(msg, sizeof(msg) - 1,
- "usage: %s -l <linker option>\n"
+ "usage: %s -l <linker option> ?<mandatory option> ...?\n"
"Tests for whether link.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
}
- return CheckForLinkerFeature(argv[2]);
+ return CheckForLinkerFeature(&argv[2], argc-2);
case 'f':
if (argc == 2) {
chars = snprintf(msg, sizeof(msg) - 1,
@@ -313,7 +313,8 @@ CheckForCompilerFeature(
static int
CheckForLinkerFeature(
- const char *option)
+ const char **options,
+ int count)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
@@ -322,7 +323,8 @@ CheckForLinkerFeature(
char msg[300];
BOOL ok;
HANDLE hProcess, h, pipeThreads[2];
- char cmdline[100];
+ int i;
+ char cmdline[255];
hProcess = GetCurrentProcess();
@@ -368,7 +370,11 @@ CheckForLinkerFeature(
* Append our option for testing.
*/
- lstrcat(cmdline, option);
+ for (i = 0; i < count; i++) {
+ lstrcat(cmdline, " \"");
+ lstrcat(cmdline, options[i]);
+ lstrcat(cmdline, "\"");
+ }
ok = CreateProcess(
NULL, /* Module name. */
@@ -433,7 +439,9 @@ CheckForLinkerFeature(
return !(strstr(Out.buffer, "LNK1117") != NULL ||
strstr(Err.buffer, "LNK1117") != NULL ||
strstr(Out.buffer, "LNK4044") != NULL ||
- strstr(Err.buffer, "LNK4044") != NULL);
+ strstr(Err.buffer, "LNK4044") != NULL ||
+ strstr(Out.buffer, "LNK4224") != NULL ||
+ strstr(Err.buffer, "LNK4224") != NULL);
}
static DWORD WINAPI
diff --git a/win/rules.vc b/win/rules.vc
index e12854d..4a3ae26 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -188,9 +188,14 @@ COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx
!endif
!endif
+# Prevents "LNK1561: entry point must be defined" error compiling from VS-IDE:
+!ifndef LINKER_TESTFLAGS
+LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmhlp-out.txt
+!endif
+
!if "$(MACHINE)" == "IX86"
### test for -align:4096, when align:512 will do.
-!if [nmakehlp -l -opt:nowin98]
+!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
!message *** Linker has 'Win98 alignment problem'
ALIGN98_HACK = 1
!else
@@ -203,7 +208,7 @@ ALIGN98_HACK = 0
LINKERFLAGS =
-!if [nmakehlp -l -ltcg]
+!if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
LINKERFLAGS =-ltcg
!endif
@@ -417,7 +422,7 @@ TCL_NO_DEPRECATED = 0
!if [nmakehlp -f $(CHECKS) "fullwarn"]
!message *** Doing full warnings check
WARNINGS = -W4
-!if [nmakehlp -l -warn:3]
+!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
LINKERFLAGS = $(LINKERFLAGS) -warn:3
!endif
!else
@@ -430,7 +435,7 @@ WARNINGS = $(WARNINGS) -Wp64
!endif
!if $(PGO) > 1
-!if [nmakehlp -l -ltcg:pgoptimize]
+!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
!else
MSG=^
@@ -438,7 +443,7 @@ This compiler does not support profile guided optimization.
!error $(MSG)
!endif
!elseif $(PGO) > 0
-!if [nmakehlp -l -ltcg:pginstrument]
+!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
!else
MSG=^
diff --git a/win/tcl.dsp b/win/tcl.dsp
index 9ea990b..48eae9d 100644
--- a/win/tcl.dsp
+++ b/win/tcl.dsp
@@ -36,7 +36,7 @@ CFG=tcl - Win32 Debug Static
# PROP BASE Intermediate_Dir "Release\tcl_Dynamic"
# PROP BASE Cmd_Line "nmake -nologo -f makefile.vc OPTS=none MSVCDIR=IDE"
# PROP BASE Rebuild_Opt "-a"
-# PROP BASE Target_File "Release\tclsh85.exe"
+# PROP BASE Target_File "Release\tclsh87.exe"
# PROP BASE Bsc_Name ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
@@ -45,7 +45,7 @@ CFG=tcl - Win32 Debug Static
# PROP Intermediate_Dir "Release\tcl_Dynamic"
# PROP Cmd_Line "nmake -nologo -f makefile.vc OPTS=threads MSVCDIR=IDE"
# PROP Rebuild_Opt "clean release"
-# PROP Target_File "Release\tclsh85t.exe"
+# PROP Target_File "Release\tclsh87t.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
@@ -57,7 +57,7 @@ CFG=tcl - Win32 Debug Static
# PROP BASE Intermediate_Dir "Debug\tcl_Dynamic"
# PROP BASE Cmd_Line "nmake -nologo -f makefile.vc OPTS=symbols MSVCDIR=IDE"
# PROP BASE Rebuild_Opt "-a"
-# PROP BASE Target_File "Debug\tclsh85g.exe"
+# PROP BASE Target_File "Debug\tclsh87g.exe"
# PROP BASE Bsc_Name ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
@@ -66,7 +66,7 @@ CFG=tcl - Win32 Debug Static
# PROP Intermediate_Dir "Debug\tcl_Dynamic"
# PROP Cmd_Line "nmake -nologo -f makefile.vc OPTS=threads,symbols MSVCDIR=IDE"
# PROP Rebuild_Opt "clean release"
-# PROP Target_File "Debug\tclsh85tg.exe"
+# PROP Target_File "Debug\tclsh87tg.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
@@ -78,7 +78,7 @@ CFG=tcl - Win32 Debug Static
# PROP BASE Intermediate_Dir "Debug\tcl_Static"
# PROP BASE Cmd_Line "nmake -nologo -f makefile.vc OPTS=symbols,static MSVCDIR=IDE"
# PROP BASE Rebuild_Opt "-a"
-# PROP BASE Target_File "Debug\tclsh85sg.exe"
+# PROP BASE Target_File "Debug\tclsh87sg.exe"
# PROP BASE Bsc_Name ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
@@ -87,7 +87,7 @@ CFG=tcl - Win32 Debug Static
# PROP Intermediate_Dir "Debug\tcl_Static"
# PROP Cmd_Line "nmake -nologo -f makefile.vc OPTS=symbols,static MSVCDIR=IDE"
# PROP Rebuild_Opt "-a"
-# PROP Target_File "Debug\tclsh85sg.exe"
+# PROP Target_File "Debug\tclsh87sg.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
@@ -99,7 +99,7 @@ CFG=tcl - Win32 Debug Static
# PROP BASE Intermediate_Dir "Release\tcl_Static"
# PROP BASE Cmd_Line "nmake -nologo -f makefile.vc OPTS=static MSVCDIR=IDE"
# PROP BASE Rebuild_Opt "-a"
-# PROP BASE Target_File "Release\tclsh85s.exe"
+# PROP BASE Target_File "Release\tclsh87s.exe"
# PROP BASE Bsc_Name ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
@@ -108,7 +108,7 @@ CFG=tcl - Win32 Debug Static
# PROP Intermediate_Dir "Release\tcl_Static"
# PROP Cmd_Line "nmake -nologo -f makefile.vc OPTS=static MSVCDIR=IDE"
# PROP Rebuild_Opt "-a"
-# PROP Target_File "Release\tclsh85s.exe"
+# PROP Target_File "Release\tclsh87s.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
@@ -1428,10 +1428,6 @@ SOURCE=.\configure.ac
# End Source File
# Begin Source File
-SOURCE=.\makefile.bc
-# End Source File
-# Begin Source File
-
SOURCE=.\Makefile.in
# End Source File
# Begin Source File
diff --git a/win/tcl.m4 b/win/tcl.m4
index 7eff8e8..b4fbcce 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -727,7 +727,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 688fa8d..e4adb1d 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -49,7 +49,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
*/
typedef struct MountPointMap {
- const TCHAR *volumeName; /* Native wide string volume name. */
+ TCHAR *volumeName; /* Native wide string volume name. */
TCHAR driveLetter; /* Drive letter corresponding to the volume
* name. */
struct MountPointMap *nextPtr;
@@ -603,8 +603,8 @@ Tcl_WinTCharToUtf(
int
TclWinCPUID(
- unsigned int index, /* Which CPUID value to retrieve. */
- unsigned int *regsPtr) /* Registers after the CPUID. */
+ int index, /* Which CPUID value to retrieve. */
+ int *regsPtr) /* Registers after the CPUID. */
{
int status = TCL_ERROR;
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index 8904a05..01af950 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.c
@@ -1525,8 +1525,8 @@ GetWinFileAttributes(
* We test for, and fix that case, here.
*/
- int len;
- const char *str = TclGetStringFromObj(fileName,&len);
+ const char *str = TclGetString(fileName);
+ size_t len = fileName->length;
if (len < 4) {
if (len == 0) {
@@ -1611,11 +1611,12 @@ ConvertFileNameFormat(
for (i = 0; i < pathc; i++) {
Tcl_Obj *elt;
char *pathv;
- int pathLen;
+ size_t pathLen;
Tcl_ListObjIndex(NULL, splitPath, i, &elt);
- pathv = TclGetStringFromObj(elt, &pathLen);
+ pathv = TclGetString(elt);
+ pathLen = elt->length;
if ((pathv[0] == '/') || ((pathLen == 3) && (pathv[1] == ':'))
|| (strcmp(pathv, ".") == 0) || (strcmp(pathv, "..") == 0)) {
/*
@@ -1639,7 +1640,6 @@ ConvertFileNameFormat(
Tcl_DString dsTemp;
const TCHAR *nativeName;
const char *tempString;
- int tempLen;
WIN32_FIND_DATA data;
HANDLE handle;
DWORD attr;
@@ -1653,8 +1653,8 @@ ConvertFileNameFormat(
*/
Tcl_DStringInit(&ds);
- tempString = TclGetStringFromObj(tempPath,&tempLen);
- nativeName = Tcl_WinUtfToTChar(tempString, tempLen, &ds);
+ tempString = TclGetString(tempPath);
+ nativeName = Tcl_WinUtfToTChar(tempString, tempPath->length, &ds);
Tcl_DecrRefCount(tempPath);
handle = FindFirstFile(nativeName, &data);
if (handle == INVALID_HANDLE_VALUE) {
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 9458933..e61d619 100755..100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -169,7 +169,7 @@ static int NativeWriteReparse(const TCHAR *LinkDirectory,
REPARSE_DATA_BUFFER *buffer);
static int NativeMatchType(int isDrive, DWORD attr,
const TCHAR *nativeName, Tcl_GlobTypeData *types);
-static int WinIsDrive(const char *name, int nameLen);
+static int WinIsDrive(const char *name, size_t nameLen);
static int WinIsReserved(const char *path);
static Tcl_Obj * WinReadLink(const TCHAR *LinkSource);
static Tcl_Obj * WinReadLinkDirectory(const TCHAR *LinkDirectory);
@@ -933,10 +933,9 @@ TclpMatchInDirectory(
* Match a single file directly.
*/
- int len;
DWORD attr;
WIN32_FILE_ATTRIBUTE_DATA data;
- const char *str = TclGetStringFromObj(norm,&len);
+ const char *str = TclGetString(norm);
native = Tcl_FSGetNativePath(pathPtr);
@@ -946,7 +945,7 @@ TclpMatchInDirectory(
}
attr = data.dwFileAttributes;
- if (NativeMatchType(WinIsDrive(str,len), attr, native, types)) {
+ if (NativeMatchType(WinIsDrive(str,norm->length), attr, native, types)) {
Tcl_ListObjAppendElement(interp, resultPtr, pathPtr);
}
}
@@ -957,7 +956,7 @@ TclpMatchInDirectory(
WIN32_FIND_DATA data;
const char *dirName; /* UTF-8 dir name, later with pattern
* appended. */
- int dirLength;
+ size_t dirLength;
int matchSpecialDots;
Tcl_DString ds; /* Native encoding of dir, also used
* temporarily for other things. */
@@ -996,7 +995,8 @@ TclpMatchInDirectory(
*/
Tcl_DStringInit(&dsOrig);
- dirName = TclGetStringFromObj(fileNamePtr, &dirLength);
+ dirName = TclGetString(fileNamePtr);
+ dirLength = fileNamePtr->length;
Tcl_DStringAppend(&dsOrig, dirName, dirLength);
lastChar = dirName[dirLength -1];
@@ -1174,7 +1174,7 @@ TclpMatchInDirectory(
static int
WinIsDrive(
const char *name, /* Name (UTF-8) */
- int len) /* Length of name */
+ size_t len) /* Length of name */
{
int remove = 0;
@@ -2705,15 +2705,14 @@ TclpObjNormalizePath(
* Not the end of the string.
*/
- int len;
char *path;
Tcl_Obj *tmpPathPtr;
tmpPathPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds),
nextCheckpoint);
Tcl_AppendToObj(tmpPathPtr, lastValidPathEnd, -1);
- path = TclGetStringFromObj(tmpPathPtr, &len);
- Tcl_SetStringObj(pathPtr, path, len);
+ path = TclGetString(tmpPathPtr);
+ Tcl_SetStringObj(pathPtr, path, tmpPathPtr->length);
Tcl_DecrRefCount(tmpPathPtr);
} else {
/*
@@ -2796,9 +2795,8 @@ TclWinVolumeRelativeNormalize(
* also on drive C.
*/
- int cwdLen;
- const char *drive =
- TclGetStringFromObj(useThisCwd, &cwdLen);
+ const char *drive = TclGetString(useThisCwd);
+ size_t cwdLen = useThisCwd->length;
char drive_cur = path[0];
if (drive_cur >= 'a') {
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 66d971b..ca72a35 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -207,7 +207,7 @@ TclpInitPlatform(void)
void
TclpInitLibraryPath(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 64
@@ -249,9 +249,10 @@ TclpInitLibraryPath(
TclGetProcessGlobalValue(&sourceLibraryDir));
*encodingPtr = NULL;
- bytes = TclGetStringFromObj(pathPtr, lengthPtr);
- *valuePtr = ckalloc((*lengthPtr) + 1);
- memcpy(*valuePtr, bytes, (size_t)(*lengthPtr)+1);
+ bytes = TclGetString(pathPtr);
+ *lengthPtr = pathPtr->length;
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, bytes, *lengthPtr + 1);
Tcl_DecrRefCount(pathPtr);
}
@@ -369,7 +370,7 @@ AppendEnvironment(
static void
InitializeDefaultLibraryDir(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
HMODULE hModule = TclWinGetTclInstance();
@@ -396,7 +397,7 @@ InitializeDefaultLibraryDir(
*lengthPtr = strlen(name);
*valuePtr = ckalloc(*lengthPtr + 1);
*encodingPtr = NULL;
- memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
+ memcpy(*valuePtr, name, *lengthPtr + 1);
}
/*
@@ -420,7 +421,7 @@ InitializeDefaultLibraryDir(
static void
InitializeSourceLibraryDir(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
HMODULE hModule = TclWinGetTclInstance();
@@ -447,7 +448,7 @@ InitializeSourceLibraryDir(
*lengthPtr = strlen(name);
*valuePtr = ckalloc(*lengthPtr + 1);
*encodingPtr = NULL;
- memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
+ memcpy(*valuePtr, name, *lengthPtr + 1);
}
/*
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index 159a708..41201c7 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -551,7 +551,7 @@ typedef DWORD_PTR * PDWORD_PTR;
* address platform-specific issues.
*/
-#define TclpReleaseFile(file) ckfree((char *) file)
+#define TclpReleaseFile(file) ckfree(file)
/*
* The following macros and declarations wrap the C runtime library
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 4690708..ee6be96 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -69,6 +69,7 @@
#define SET_BITS(var, bits) ((var) |= (bits))
#define CLEAR_BITS(var, bits) ((var) &= ~(bits))
+#define GOT_BITS(var, bits) (((var) & (bits)) != 0)
/* "sock" + a pointer in hex + \0 */
#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
@@ -124,6 +125,8 @@ typedef struct TcpFdList {
struct TcpState {
Tcl_Channel channel; /* Channel associated with this socket. */
+ int testFlags; /* bit field for tests. Is set by testsocket
+ * test procedure */
struct TcpFdList *sockets; /* Windows SOCKET handle. */
int flags; /* Bit field comprised of the flags described
* below. */
@@ -184,6 +187,15 @@ struct TcpState {
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */
/*
+ * These bits may be ORed together into the "testFlags" field of a TcpState
+ * structure.
+ */
+
+#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
+ * automatically continue connection
+ * process */
+
+/*
* The following structure is what is added to the Tcl event queue when a
* socket event occurs.
*/
@@ -292,22 +304,39 @@ static const Tcl_ChannelType tcpChannelType = {
static TclInitProcessGlobalValueProc InitializeHostName;
static ProcessGlobalValue hostName =
{0, 0, NULL, NULL, InitializeHostName, NULL, NULL};
+
+/*
+ * Simple wrapper round the SendMessage syscall.
+ */
+
+#define SendSelectMessage(tsdPtr, message, payload) \
+ SendMessage((tsdPtr)->hwnd, SOCKET_SELECT, \
+ (WPARAM) (message), (LPARAM) (payload))
+
/*
* Address print debug functions
*/
#if 0
-void printaddrinfo(struct addrinfo *ai, char *prefix)
+void
+printaddrinfo(
+ struct addrinfo *ai,
+ char *prefix)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
+
getnameinfo(ai->ai_addr, ai->ai_addrlen,
- host, sizeof(host),
- port, sizeof(port),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ host, sizeof(host), port, sizeof(port),
+ NI_NUMERICHOST|NI_NUMERICSERV);
}
-void printaddrinfolist(struct addrinfo *addrlist, char *prefix)
+
+void
+printaddrinfolist(
+ struct addrinfo *addrlist,
+ char *prefix)
{
struct addrinfo *ai;
+
for (ai = addrlist; ai != NULL; ai = ai->ai_next) {
printaddrinfo(ai, prefix);
}
@@ -331,7 +360,7 @@ void printaddrinfolist(struct addrinfo *addrlist, char *prefix)
void
InitializeHostName(
char **valuePtr,
- int *lengthPtr,
+ size_t *lengthPtr,
Tcl_Encoding *encodingPtr)
{
TCHAR tbuf[MAX_COMPUTERNAME_LENGTH + 1];
@@ -368,8 +397,8 @@ InitializeHostName(
*encodingPtr = Tcl_GetEncoding(NULL, "utf-8");
*lengthPtr = Tcl_DStringLength(&ds);
- *valuePtr = ckalloc((*lengthPtr) + 1);
- memcpy(*valuePtr, Tcl_DStringValue(&ds), (size_t)(*lengthPtr)+1);
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, Tcl_DStringValue(&ds), *lengthPtr + 1);
Tcl_DStringFree(&ds);
}
@@ -524,9 +553,9 @@ TcpBlockModeProc(
TcpState *statePtr = instanceData;
if (mode == TCL_MODE_NONBLOCKING) {
- statePtr->flags |= TCP_NONBLOCKING;
+ SET_BITS(statePtr->flags, TCP_NONBLOCKING);
} else {
- statePtr->flags &= ~(TCP_NONBLOCKING);
+ CLEAR_BITS(statePtr->flags, TCP_NONBLOCKING);
}
return 0;
}
@@ -536,29 +565,28 @@ TcpBlockModeProc(
*
* WaitForConnect --
*
- * Check the state of an async connect process. If a connection
- * attempt terminated, process it, which may finalize it or may
- * start the next attempt. If a connect error occures, it is saved
- * in statePtr->connectError to be reported by 'fconfigure -error'.
+ * Check the state of an async connect process. If a connection attempt
+ * terminated, process it, which may finalize it or may start the next
+ * attempt. If a connect error occures, it is saved in
+ * statePtr->connectError to be reported by 'fconfigure -error'.
*
* There are two modes of operation, defined by errorCodePtr:
- * * non-NULL: Called by explicite read/write command. block if
- * socket is blocking.
+ * * non-NULL: Called by explicite read/write command. Block if socket
+ * is blocking.
* May return two error codes:
* * EWOULDBLOCK: if connect is still in progress
- * * ENOTCONN: if connect failed. This would be the error
- * message of a rect or sendto syscall so this is
- * emulated here.
- * * Null: Called by a backround operation. Do not block and
- * don't return any error code.
+ * * ENOTCONN: if connect failed. This would be the error message
+ * of a rect or sendto syscall so this is emulated here.
+ * * Null: Called by a backround operation. Do not block and don't
+ * return any error code.
*
* Results:
- * 0 if the connection has completed, -1 if still in progress
- * or there is an error.
+ * 0 if the connection has completed, -1 if still in progress or there is
+ * an error.
*
* Side effects:
- * Processes socket events off the system queue.
- * May process asynchroneous connect.
+ * Processes socket events off the system queue. May process
+ * asynchroneous connect.
*
*----------------------------------------------------------------------
*/
@@ -566,20 +594,19 @@ TcpBlockModeProc(
static int
WaitForConnect(
TcpState *statePtr, /* State of the socket. */
- int *errorCodePtr) /* Where to store errors?
- * A passed null-pointer activates background mode.
- */
+ int *errorCodePtr) /* Where to store errors? A passed
+ * null-pointer activates background mode. */
{
int result;
int oldMode;
ThreadSpecificData *tsdPtr;
/*
- * Check if an async connect failed already and error reporting is demanded,
- * return the error ENOTCONN
+ * Check if an async connect failed already and error reporting is
+ * demanded, return the error ENOTCONN.
*/
- if (errorCodePtr != NULL && (statePtr->flags & TCP_ASYNC_FAILED)) {
+ if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
*errorCodePtr = ENOTCONN;
return -1;
}
@@ -588,11 +615,26 @@ WaitForConnect(
* Check if an async connect is running. If not return ok
*/
- if (!(statePtr->flags & TCP_ASYNC_CONNECT)) {
+ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
return 0;
}
/*
+ * In socket test mode do not continue with the connect
+ * Exceptions are:
+ * - Call by recv/send and blocking socket
+ * (errorCodePtr != NULL && !GOT_BITS(flags, TCP_NONBLOCKING))
+ * - Call by the event queue (errorCodePtr == NULL)
+ */
+
+ if (GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)
+ && errorCodePtr != NULL
+ && GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
+ *errorCodePtr = EWOULDBLOCK;
+ return -1;
+ }
+
+ /*
* Be sure to disable event servicing so we are truly modal.
*/
@@ -603,36 +645,51 @@ WaitForConnect(
*/
while (1) {
+ /*
+ * Get the statePtr lock.
+ */
- /* get statePtr lock */
tsdPtr = TclThreadDataKeyGet(&dataKey);
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
- /* Check for connect event */
- if (statePtr->readyEvents & FD_CONNECT) {
+ /*
+ * Check for connect event.
+ */
+
+ if (GOT_BITS(statePtr->readyEvents, FD_CONNECT)) {
+ /*
+ * Consume the connect event.
+ */
- /* Consume the connect event */
- statePtr->readyEvents &= ~(FD_CONNECT);
+ CLEAR_BITS(statePtr->readyEvents, FD_CONNECT);
/*
- * For blocking sockets and foreground processing
- * disable async connect as we continue now synchoneously
+ * For blocking sockets and foreground processing, disable async
+ * connect as we continue now synchoneously.
*/
- if ( errorCodePtr != NULL &&
- ! (statePtr->flags & TCP_NONBLOCKING) ) {
+
+ if (errorCodePtr != NULL &&
+ !GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
}
- /* Free list lock */
+ /*
+ * Free list lock.
+ */
+
SetEvent(tsdPtr->socketListLock);
/*
- * Continue connect.
- * If switched to synchroneous connect, the connect is terminated.
+ * Continue connect. If switched to synchroneous connect, the
+ * connect is terminated.
*/
+
result = TcpConnect(NULL, statePtr);
- /* Restore event service mode */
+ /*
+ * Restore event service mode.
+ */
+
(void) Tcl_SetServiceMode(oldMode);
/*
@@ -641,10 +698,11 @@ WaitForConnect(
if (result == TCL_OK) {
/*
- * Check for async connect restart
- * (not possible for foreground blocking operation)
+ * Check for async connect restart (not possible for
+ * foreground blocking operation)
*/
- if ( statePtr->flags & TCP_ASYNC_PENDING ) {
+
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
if (errorCodePtr != NULL) {
*errorCodePtr = EWOULDBLOCK;
}
@@ -654,8 +712,8 @@ WaitForConnect(
}
/*
- * Connect finally failed.
- * For foreground operation return ENOTCONN.
+ * Connect finally failed. For foreground operation return
+ * ENOTCONN.
*/
if (errorCodePtr != NULL) {
@@ -664,7 +722,10 @@ WaitForConnect(
return -1;
}
- /* Free list lock */
+ /*
+ * Free list lock.
+ */
+
SetEvent(tsdPtr->socketListLock);
/*
@@ -672,16 +733,16 @@ WaitForConnect(
* event
*/
- if ( errorCodePtr == NULL ) {
+ if (errorCodePtr == NULL) {
return -1;
}
/*
- * A non blocking socket waiting for an asyncronous connect
- * returns directly the error EWOULDBLOCK
+ * A non blocking socket waiting for an asyncronous connect returns
+ * directly the error EWOULDBLOCK.
*/
- if (statePtr->flags & TCP_NONBLOCKING) {
+ if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
*errorCodePtr = EWOULDBLOCK;
return -1;
}
@@ -745,7 +806,7 @@ TcpInputProc(
* socket stack after the first time EOF is detected.
*/
- if (statePtr->flags & SOCKET_EOF) {
+ if (GOT_BITS(statePtr->flags, SOCKET_EOF)) {
return 0;
}
@@ -768,18 +829,22 @@ TcpInputProc(
*/
while (1) {
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
- (WPARAM) UNSELECT, (LPARAM) statePtr);
- /* single fd operation: this proc is only called for a connected socket. */
+ SendSelectMessage(tsdPtr, UNSELECT, statePtr);
+
+ /*
+ * Single fd operation: this proc is only called for a connected
+ * socket.
+ */
+
bytesRead = recv(statePtr->sockets->fd, buf, bufSize, 0);
- statePtr->readyEvents &= ~(FD_READ);
+ CLEAR_BITS(statePtr->readyEvents, FD_READ);
/*
* Check for end-of-file condition or successful read.
*/
if (bytesRead == 0) {
- statePtr->flags |= SOCKET_EOF;
+ SET_BITS(statePtr->flags, SOCKET_EOF);
}
if (bytesRead != SOCKET_ERROR) {
break;
@@ -790,8 +855,8 @@ TcpInputProc(
* error and report an EOF.
*/
- if (statePtr->readyEvents & FD_CLOSE) {
- statePtr->flags |= SOCKET_EOF;
+ if (GOT_BITS(statePtr->readyEvents, FD_CLOSE)) {
+ SET_BITS(statePtr->flags, SOCKET_EOF);
bytesRead = 0;
break;
}
@@ -804,7 +869,7 @@ TcpInputProc(
*/
if (error == WSAECONNRESET) {
- statePtr->flags |= SOCKET_EOF;
+ SET_BITS(statePtr->flags, SOCKET_EOF);
bytesRead = 0;
break;
}
@@ -813,7 +878,8 @@ TcpInputProc(
* Check for error condition or underflow in non-blocking case.
*/
- if ((statePtr->flags & TCP_NONBLOCKING) || (error != WSAEWOULDBLOCK)) {
+ if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)
+ || (error != WSAEWOULDBLOCK)) {
TclWinConvertError(error);
*errorCodePtr = Tcl_GetErrno();
bytesRead = -1;
@@ -831,7 +897,7 @@ TcpInputProc(
}
}
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
return bytesRead;
}
@@ -889,10 +955,13 @@ TcpOutputProc(
}
while (1) {
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
- (WPARAM) UNSELECT, (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, UNSELECT, statePtr);
+
+ /*
+ * Single fd operation: this proc is only called for a connected
+ * socket.
+ */
- /* single fd operation: this proc is only called for a connected socket. */
written = send(statePtr->sockets->fd, buf, toWrite, 0);
if (written != SOCKET_ERROR) {
/*
@@ -901,8 +970,9 @@ TcpOutputProc(
* until the condition changes.
*/
- if (statePtr->watchEvents & FD_WRITE) {
+ if (GOT_BITS(statePtr->watchEvents, FD_WRITE)) {
Tcl_Time blockTime = { 0, 0 };
+
Tcl_SetMaxBlockTime(&blockTime);
}
break;
@@ -917,8 +987,8 @@ TcpOutputProc(
error = WSAGetLastError();
if (error == WSAEWOULDBLOCK) {
- statePtr->readyEvents &= ~(FD_WRITE);
- if (statePtr->flags & TCP_NONBLOCKING) {
+ CLEAR_BITS(statePtr->readyEvents, FD_WRITE);
+ if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
*errorCodePtr = EWOULDBLOCK;
written = -1;
break;
@@ -941,7 +1011,7 @@ TcpOutputProc(
}
}
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
return written;
}
@@ -988,10 +1058,10 @@ TcpCloseProc(
* background.
*/
- while ( statePtr->sockets != NULL ) {
+ while (statePtr->sockets != NULL) {
TcpFdList *thisfd = statePtr->sockets;
- statePtr->sockets = thisfd->next;
+ statePtr->sockets = thisfd->next;
if (closesocket(thisfd->fd) == SOCKET_ERROR) {
TclWinConvertError((DWORD) WSAGetLastError());
errorCode = Tcl_GetErrno();
@@ -1009,18 +1079,25 @@ TcpCloseProc(
/*
* Clear an eventual tsd info list pointer.
+ *
* This may be called, if an async socket connect fails or is closed
* between connect and thread action callback.
*/
+
if (tsdPtr->pendingTcpState != NULL
&& tsdPtr->pendingTcpState == statePtr) {
+ /*
+ * Get infoPtr lock, because this concerns the notifier thread.
+ */
- /* get infoPtr lock, because this concerns the notifier thread */
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
tsdPtr->pendingTcpState = NULL;
- /* Free list lock */
+ /*
+ * Free list lock.
+ */
+
SetEvent(tsdPtr->socketListLock);
}
@@ -1081,8 +1158,11 @@ TcpClose2Proc(
return TCL_ERROR;
}
- /* single fd operation: Tcl_OpenTcpServer() does not set TCL_READABLE or
- * TCL_WRITABLE so this should never be called for a server socket. */
+ /*
+ * Single fd operation: Tcl_OpenTcpServer() does not set TCL_READABLE or
+ * TCL_WRITABLE so this should never be called for a server socket.
+ */
+
if (shutdown(statePtr->sockets->fd, sd) == SOCKET_ERROR) {
TclWinConvertError((DWORD) WSAGetLastError());
errorCode = Tcl_GetErrno();
@@ -1134,7 +1214,7 @@ TcpSetOptionProc(
}
#ifdef TCL_FEATURE_KEEPALIVE_NAGLE
- #error "TCL_FEATURE_KEEPALIVE_NAGLE not reviewed for whether to treat statePtr->sockets as single fd or list"
+#error "TCL_FEATURE_KEEPALIVE_NAGLE not reviewed for whether to treat statePtr->sockets as single fd or list"
sock = statePtr->sockets->fd;
if (!strcasecmp(optionName, "-keepalive")) {
@@ -1243,9 +1323,14 @@ TcpGetOptionProc(
/*
* Go one step in async connect
- * If any error is thrown save it as backround error to report eventually below
+ *
+ * If any error is thrown save it as backround error to report eventually
+ * below.
*/
- WaitForConnect(statePtr, NULL);
+
+ if (!GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)) {
+ WaitForConnect(statePtr, NULL);
+ }
sock = statePtr->sockets->fd;
if (optionName != NULL) {
@@ -1254,31 +1339,26 @@ TcpGetOptionProc(
if ((len > 1) && (optionName[1] == 'e') &&
(strncmp(optionName, "-error", len) == 0)) {
-
/*
- * Do not return any errors if async connect is running
- */
- if ( ! (statePtr->flags & TCP_ASYNC_PENDING) ) {
-
-
- if ( statePtr->flags & TCP_ASYNC_FAILED ) {
+ * Do not return any errors if async connect is running.
+ */
+ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
/*
* In case of a failed async connect, eventually report the
- * connect error only once.
- * Do not report the system error, as this comes again and again.
+ * connect error only once. Do not report the system error,
+ * as this comes again and again.
*/
- if ( statePtr->connectError != 0 ) {
+ if (statePtr->connectError != 0) {
Tcl_DStringAppend(dsPtr,
Tcl_ErrnoMsg(statePtr->connectError), -1);
statePtr->connectError = 0;
}
-
} else {
-
/*
- * Report an eventual last error of the socket system
+ * Report an eventual last error of the socket system.
*/
int optlen;
@@ -1286,24 +1366,30 @@ TcpGetOptionProc(
DWORD err;
/*
- * Populater the err Variable with a possix error
+ * Populate the err variable with a POSIX error
*/
+
optlen = sizeof(int);
ret = getsockopt(sock, SOL_SOCKET, SO_ERROR,
(char *)&err, &optlen);
+
/*
- * The error was not returned directly but should be
- * taken from WSA
+ * The error was not returned directly but should be taken
+ * from WSA.
*/
+
if (ret == SOCKET_ERROR) {
err = WSAGetLastError();
}
+
/*
- * Return error message
+ * Return error message.
*/
+
if (err) {
TclWinConvertError(err);
- Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()), -1);
+ Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()),
+ -1);
}
}
}
@@ -1312,14 +1398,14 @@ TcpGetOptionProc(
if ((len > 1) && (optionName[1] == 'c') &&
(strncmp(optionName, "-connecting", len) == 0)) {
-
Tcl_DStringAppend(dsPtr,
- (statePtr->flags & TCP_ASYNC_PENDING)
+ GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)
? "1" : "0", -1);
return TCL_OK;
}
- if (interp != NULL && Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
+ if (interp != NULL
+ && Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
reverseDNS = NI_NUMERICHOST;
}
@@ -1328,20 +1414,23 @@ TcpGetOptionProc(
address peername;
socklen_t size = sizeof(peername);
- if ( (statePtr->flags & TCP_ASYNC_PENDING) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
/*
* In async connect output an empty string
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringAppendElement(dsPtr, "");
} else {
return TCL_OK;
}
- } else if ( getpeername(sock, (LPSOCKADDR) &(peername.sa), &size) == 0) {
+ } else if (getpeername(sock, (LPSOCKADDR) &(peername.sa),
+ &size) == 0) {
/*
* Peername fetch succeeded - output list
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
@@ -1390,11 +1479,12 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-sockname");
Tcl_DStringStartSublist(dsPtr);
}
- if ( (statePtr->flags & TCP_ASYNC_PENDING ) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
/*
* In async connect output an empty string
*/
- found = 1;
+
+ found = 1;
} else {
for (fds = statePtr->sockets; fds != NULL; fds = fds->next) {
sock = fds->fd;
@@ -1408,9 +1498,11 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, host);
/*
- * We don't want to resolve INADDR_ANY and sin6addr_any; they
- * can sometimes cause problems (and never have a name).
+ * We don't want to resolve INADDR_ANY and sin6addr_any;
+ * they can sometimes cause problems (and never have a
+ * name).
*/
+
flags |= NI_NUMERICSERV;
if (sockname.sa.sa_family == AF_INET) {
if (sockname.sa4.sin_addr.s_addr == INADDR_ANY) {
@@ -1494,7 +1586,8 @@ TcpGetOptionProc(
return Tcl_BadChannelOption(interp, optionName,
"connecting peername sockname keepalive nagle");
#else
- return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
+ return Tcl_BadChannelOption(interp, optionName,
+ "connecting peername sockname");
#endif /*TCL_FEATURE_KEEPALIVE_NAGLE*/
}
@@ -1535,11 +1628,11 @@ TcpWatchProc(
if (!statePtr->acceptProc) {
statePtr->watchEvents = 0;
- if (mask & TCL_READABLE) {
- statePtr->watchEvents |= (FD_READ|FD_CLOSE);
+ if (GOT_BITS(mask, TCL_READABLE)) {
+ SET_BITS(statePtr->watchEvents, FD_READ | FD_CLOSE);
}
- if (mask & TCL_WRITABLE) {
- statePtr->watchEvents |= (FD_WRITE|FD_CLOSE);
+ if (GOT_BITS(mask, TCL_WRITABLE)) {
+ SET_BITS(statePtr->watchEvents, FD_WRITE | FD_CLOSE);
}
/*
@@ -1630,13 +1723,13 @@ TcpConnect(
TcpState *statePtr)
{
DWORD error;
- /*
- * We are started with async connect and the connect notification
- * was not jet received
- */
- int async_connect = statePtr->flags & TCP_ASYNC_CONNECT;
- /* We were called by the event procedure and continue our loop */
- int async_callback = statePtr->flags & TCP_ASYNC_PENDING;
+ int async_connect = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
+ /* We are started with async connect and the
+ * connect notification was not yet
+ * received. */
+ int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING);
+ /* We were called by the event procedure and
+ * continue our loop. */
ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
if (async_callback) {
@@ -1644,11 +1737,10 @@ TcpConnect(
}
for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL;
- statePtr->addr = statePtr->addr->ai_next) {
-
- for (statePtr->myaddr = statePtr->myaddrlist; statePtr->myaddr != NULL;
- statePtr->myaddr = statePtr->myaddr->ai_next) {
-
+ statePtr->addr = statePtr->addr->ai_next) {
+ for (statePtr->myaddr = statePtr->myaddrlist;
+ statePtr->myaddr != NULL;
+ statePtr->myaddr = statePtr->myaddr->ai_next) {
/*
* No need to try combinations of local and remote addresses
* of different families.
@@ -1662,25 +1754,37 @@ TcpConnect(
* Close the socket if it is still open from the last unsuccessful
* iteration.
*/
+
if (statePtr->sockets->fd != INVALID_SOCKET) {
closesocket(statePtr->sockets->fd);
}
- /* get statePtr lock */
+ /*
+ * Get statePtr lock.
+ */
+
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
* Reset last error from last try
*/
+
statePtr->notifierConnectError = 0;
Tcl_SetErrno(0);
- statePtr->sockets->fd = socket(statePtr->myaddr->ai_family, SOCK_STREAM, 0);
+ statePtr->sockets->fd = socket(statePtr->myaddr->ai_family,
+ SOCK_STREAM, 0);
+
+ /*
+ * Free list lock.
+ */
- /* Free list lock */
SetEvent(tsdPtr->socketListLock);
- /* continue on socket creation error */
+ /*
+ * Continue on socket creation error.
+ */
+
if (statePtr->sockets->fd == INVALID_SOCKET) {
TclWinConvertError((DWORD) WSAGetLastError());
continue;
@@ -1691,31 +1795,39 @@ TcpConnect(
* processes by default. Turn off the inherit bit.
*/
- SetHandleInformation((HANDLE) statePtr->sockets->fd, HANDLE_FLAG_INHERIT, 0);
+ SetHandleInformation((HANDLE) statePtr->sockets->fd,
+ HANDLE_FLAG_INHERIT, 0);
/*
* Set kernel space buffering
*/
- TclSockMinimumBuffers((void *) statePtr->sockets->fd, TCP_BUFFER_SIZE);
+ TclSockMinimumBuffers((void *) statePtr->sockets->fd,
+ TCP_BUFFER_SIZE);
/*
* Try to bind to a local port.
*/
if (bind(statePtr->sockets->fd, statePtr->myaddr->ai_addr,
- statePtr->myaddr->ai_addrlen) == SOCKET_ERROR) {
+ statePtr->myaddr->ai_addrlen) == SOCKET_ERROR) {
TclWinConvertError((DWORD) WSAGetLastError());
continue;
}
+
/*
* For asyncroneous connect set the socket in nonblocking mode
* and activate connect notification
*/
+
if (async_connect) {
TcpState *statePtr2;
int in_socket_list = 0;
- /* get statePtr lock */
+
+ /*
+ * Get statePtr lock.
+ */
+
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
@@ -1725,8 +1837,8 @@ TcpConnect(
* It is set after this call by TcpThreadActionProc and is set
* on a second round.
*
- * If not, we buffer my statePtr in the tsd memory so it is not
- * lost by the event procedure
+ * If not, we buffer my statePtr in the tsd memory so it is
+ * not lost by the event procedure
*/
for (statePtr2 = tsdPtr->socketList; statePtr2 != NULL;
@@ -1739,21 +1851,27 @@ TcpConnect(
if (!in_socket_list) {
tsdPtr->pendingTcpState = statePtr;
}
+
/*
* Set connect mask to connect events
- * This is activated by a SOCKET_SELECT message to the notifier
- * thread.
+ *
+ * This is activated by a SOCKET_SELECT message to the
+ * notifier thread.
*/
- statePtr->selectEvents |= FD_CONNECT;
+
+ SET_BITS(statePtr->selectEvents, FD_CONNECT);
/*
- * Free list lock
+ * Free list lock.
*/
+
SetEvent(tsdPtr->socketListLock);
- /* activate accept notification */
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) statePtr);
+ /*
+ * Activate accept notification.
+ */
+
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
}
/*
@@ -1769,12 +1887,11 @@ TcpConnect(
if (async_connect && error == WSAEWOULDBLOCK) {
/*
* Asynchroneous connect
- */
-
- /*
+ *
* Remember that we jump back behind this next round
*/
- statePtr->flags |= TCP_ASYNC_PENDING;
+
+ SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
return TCL_OK;
reenter:
@@ -1784,21 +1901,39 @@ TcpConnect(
*
* Clear the reenter flag
*/
- statePtr->flags &= ~(TCP_ASYNC_PENDING);
- /* get statePtr lock */
+
+ CLEAR_BITS(statePtr->flags, TCP_ASYNC_PENDING);
+
+ /*
+ * Get statePtr lock.
+ */
+
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
- /* Get signaled connect error */
+
+ /*
+ * Get signaled connect error.
+ */
+
TclWinConvertError((DWORD) statePtr->notifierConnectError);
- /* Clear eventual connect flag */
- statePtr->selectEvents &= ~(FD_CONNECT);
- /* Free list lock */
+
+ /*
+ * Clear eventual connect flag.
+ */
+
+ CLEAR_BITS(statePtr->selectEvents, FD_CONNECT);
+
+ /*
+ * Free list lock.
+ */
+
SetEvent(tsdPtr->socketListLock);
}
/*
- * Clear the tsd socket list pointer if we did not wait for
- * the FD_CONNECT asyncroneously
+ * Clear the tsd socket list pointer if we did not wait for the
+ * FD_CONNECT asynchronously.
*/
+
tsdPtr->pendingTcpState = NULL;
if (Tcl_GetErrno() == 0) {
@@ -1807,7 +1942,7 @@ TcpConnect(
}
}
-out:
+ out:
/*
* Socket connected or connection failed
*/
@@ -1818,13 +1953,13 @@ out:
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
- if ( Tcl_GetErrno() == 0 ) {
+ if (Tcl_GetErrno() == 0) {
/*
* Succesfully connected
- */
- /*
+ *
* Set up the select mask for read/write events.
*/
+
statePtr->selectEvents = FD_READ | FD_WRITE | FD_CLOSE;
/*
@@ -1832,35 +1967,56 @@ out:
* automatically places the socket into non-blocking mode.
*/
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
} else {
/*
* Connect failed
- */
-
- /*
+ *
* For async connect schedule a writable event to report the fail.
*/
+
if (async_callback) {
/*
* Set up the select mask for read/write events.
*/
+
statePtr->selectEvents = FD_WRITE|FD_READ;
- /* get statePtr lock */
+
+ /*
+ * Get statePtr lock.
+ */
+
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
- /* Signal ready readable and writable events */
- statePtr->readyEvents |= FD_WRITE | FD_READ;
- /* Flag error to event routine */
- statePtr->flags |= TCP_ASYNC_FAILED;
- /* Save connect error to be reported by 'fconfigure -error' */
+
+ /*
+ * Signal ready readable and writable events.
+ */
+
+ SET_BITS(statePtr->readyEvents, FD_WRITE | FD_READ);
+
+ /*
+ * Flag error to event routine.
+ */
+
+ SET_BITS(statePtr->flags, TCP_ASYNC_FAILED);
+
+ /*
+ * Save connect error to be reported by 'fconfigure -error'.
+ */
+
statePtr->connectError = Tcl_GetErrno();
- /* Free list lock */
+
+ /*
+ * Free list lock.
+ */
+
SetEvent(tsdPtr->socketListLock);
}
+
/*
* Error message on syncroneous connect
*/
+
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't open socket: %s", Tcl_PosixError(interp)));
@@ -1938,7 +2094,7 @@ Tcl_OpenTcpClient(
statePtr->addrlist = addrlist;
statePtr->myaddrlist = myaddrlist;
if (async) {
- statePtr->flags |= TCP_ASYNC_CONNECT;
+ SET_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
}
/*
@@ -2008,7 +2164,7 @@ Tcl_MakeTcpClientChannel(
*/
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
sprintf(channelName, SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
@@ -2020,7 +2176,7 @@ Tcl_MakeTcpClientChannel(
/*
*----------------------------------------------------------------------
*
- * Tcl_OpenTcpServer --
+ * Tcl_OpenTcpServerEx --
*
* Opens a TCP server socket and creates a channel around it.
*
@@ -2035,10 +2191,11 @@ Tcl_MakeTcpClientChannel(
*/
Tcl_Channel
-Tcl_OpenTcpServer(
+Tcl_OpenTcpServerEx(
Tcl_Interp *interp, /* For error reporting - may be NULL. */
- int port, /* Port number to open. */
+ const char *service, /* Port number to open. */
const char *myHost, /* Name of local host. */
+ unsigned int flags, /* Flags. */
Tcl_TcpAcceptProc *acceptProc,
/* Callback for accepting connections from new
* clients. */
@@ -2052,6 +2209,7 @@ Tcl_OpenTcpServer(
char channelName[SOCK_CHAN_LENGTH];
u_long flag = 1; /* Indicates nonblocking mode. */
const char *errorMsg = NULL;
+ int optvalue, port;
if (TclpHasSockets(interp) != TCL_OK) {
return NULL;
@@ -2071,7 +2229,13 @@ Tcl_OpenTcpServer(
* Construct the addresses for each end of the socket.
*/
- if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) {
+ if (TclSockGetPort(interp, service, "tcp", &port) != TCL_OK) {
+ errorMsg = "invalid port number";
+ goto error;
+ }
+
+ if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1,
+ &errorMsg)) {
goto error;
}
@@ -2110,17 +2274,26 @@ Tcl_OpenTcpServer(
}
/*
- * Bind to the specified port. Note that we must not call
- * setsockopt with SO_REUSEADDR because Microsoft allows addresses
- * to be reused even if they are still in use.
+ * The SO_REUSEADDR option on Windows behaves like SO_REUSEPORT on
+ * unix systems.
+ */
+
+ if (GOT_BITS(flags, TCL_TCPSERVER_REUSEPORT)) {
+ optvalue = 1;
+ (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &optvalue, sizeof(optvalue));
+ }
+
+ /*
+ * Bind to the specified port.
*
* Bind should not be affected by the socket having already been
* set into nonblocking mode. If there is trouble, this is one
* place to look for bugs.
*/
- if (bind(sock, addrPtr->ai_addr, addrPtr->ai_addrlen)
- == SOCKET_ERROR) {
+ if (bind(sock, addrPtr->ai_addr,
+ addrPtr->ai_addrlen) == SOCKET_ERROR) {
TclWinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
continue;
@@ -2155,13 +2328,14 @@ Tcl_OpenTcpServer(
/*
* Add this socket to the global list of sockets.
*/
+
statePtr = NewSocketInfo(sock);
} else {
- AddSocketInfoFd( statePtr, sock );
+ AddSocketInfoFd(statePtr, sock);
}
}
-error:
+ error:
if (addrlist != NULL) {
freeaddrinfo(addrlist);
}
@@ -2186,8 +2360,7 @@ error:
*/
ioctlsocket(sock, (long) FIONBIO, &flag);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-eofchar", "")
== TCL_ERROR) {
Tcl_Close(NULL, statePtr->channel);
@@ -2256,8 +2429,7 @@ TcpAccept(
*/
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) newInfoPtr);
+ SendSelectMessage(tsdPtr, SELECT, newInfoPtr);
sprintf(channelName, SOCK_TEMPLATE, newInfoPtr);
newInfoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
@@ -2488,7 +2660,7 @@ SocketSetupProc(
Tcl_Time blockTime = { 0, 0 };
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
- if (!(flags & TCL_FILE_EVENTS)) {
+ if (!GOT_BITS(flags, TCL_FILE_EVENTS)) {
return;
}
@@ -2498,9 +2670,8 @@ SocketSetupProc(
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
for (statePtr = tsdPtr->socketList; statePtr != NULL;
statePtr = statePtr->nextPtr) {
- if (statePtr->readyEvents &
- (statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)
- ) {
+ if (GOT_BITS(statePtr->readyEvents,
+ statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)) {
Tcl_SetMaxBlockTime(&blockTime);
break;
}
@@ -2534,7 +2705,7 @@ SocketCheckProc(
SocketEvent *evPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
- if (!(flags & TCL_FILE_EVENTS)) {
+ if (!GOT_BITS(flags, TCL_FILE_EVENTS)) {
return;
}
@@ -2547,11 +2718,10 @@ SocketCheckProc(
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
for (statePtr = tsdPtr->socketList; statePtr != NULL;
statePtr = statePtr->nextPtr) {
- if ((statePtr->readyEvents &
- (statePtr->watchEvents | FD_CONNECT | FD_ACCEPT))
- && !(statePtr->flags & SOCKET_PENDING)
- ) {
- statePtr->flags |= SOCKET_PENDING;
+ if (GOT_BITS(statePtr->readyEvents,
+ statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)
+ && !GOT_BITS(statePtr->flags, SOCKET_PENDING)) {
+ SET_BITS(statePtr->flags, SOCKET_PENDING);
evPtr = ckalloc(sizeof(SocketEvent));
evPtr->header.proc = SocketEventProc;
evPtr->socket = statePtr->sockets->fd;
@@ -2597,7 +2767,7 @@ SocketEventProc(
address addr;
int len;
- if (!(flags & TCL_FILE_EVENTS)) {
+ if (!GOT_BITS(flags, TCL_FILE_EVENTS)) {
return 0;
}
@@ -2626,29 +2796,26 @@ SocketEventProc(
* Clear flag that (this) event is pending
*/
- statePtr->flags &= ~SOCKET_PENDING;
+ CLEAR_BITS(statePtr->flags, SOCKET_PENDING);
/*
* Continue async connect if pending and ready
*/
- if ( statePtr->readyEvents & FD_CONNECT ) {
- if ( statePtr->flags & TCP_ASYNC_PENDING ) {
-
+ if (GOT_BITS(statePtr->readyEvents, FD_CONNECT)) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
/*
* Do one step and save eventual connect error
*/
SetEvent(tsdPtr->socketListLock);
WaitForConnect(statePtr,NULL);
-
} else {
-
/*
* No async connect reenter pending. Just clear event.
*/
- statePtr->readyEvents &= ~(FD_CONNECT);
+ CLEAR_BITS(statePtr->readyEvents, FD_CONNECT);
SetEvent(tsdPtr->socketListLock);
}
return 1;
@@ -2657,20 +2824,23 @@ SocketEventProc(
/*
* Handle connection requests directly.
*/
- if (statePtr->readyEvents & FD_ACCEPT) {
- for (fds = statePtr->sockets; fds != NULL; fds = fds->next) {
+ if (GOT_BITS(statePtr->readyEvents, FD_ACCEPT)) {
+ for (fds = statePtr->sockets; fds != NULL; fds = fds->next) {
/*
- * Accept the incoming connection request.
- */
- len = sizeof(address);
+ * Accept the incoming connection request.
+ */
+ len = sizeof(address);
newSocket = accept(fds->fd, &(addr.sa), &len);
- /* On Tcl server sockets with multiple OS fds we loop over the fds trying
- * an accept() on each, so we expect INVALID_SOCKET. There are also other
- * network stack conditions that can result in FD_ACCEPT but a subsequent
- * failure on accept() by the time we get around to it.
+ /*
+ * On Tcl server sockets with multiple OS fds we loop over the fds
+ * trying an accept() on each, so we expect INVALID_SOCKET. There
+ * are also other network stack conditions that can result in
+ * FD_ACCEPT but a subsequent failure on accept() by the time we
+ * get around to it.
+ *
* Access to sockets (acceptEventCount, readyEvents) in socketList
* is still protected by the lock (prevents reintroduction of
* SF Tcl Bug 3056775.
@@ -2682,35 +2852,40 @@ SocketEventProc(
}
/*
- * It is possible that more than one FD_ACCEPT has been sent, so an extra
- * count must be kept. Decrement the count, and reset the readyEvent bit
- * if the count is no longer > 0.
+ * It is possible that more than one FD_ACCEPT has been sent, so
+ * an extra count must be kept. Decrement the count, and reset the
+ * readyEvent bit if the count is no longer > 0.
*/
+
statePtr->acceptEventCount--;
if (statePtr->acceptEventCount <= 0) {
- statePtr->readyEvents &= ~(FD_ACCEPT);
+ CLEAR_BITS(statePtr->readyEvents, FD_ACCEPT);
}
SetEvent(tsdPtr->socketListLock);
- /* Caution: TcpAccept() has the side-effect of evaluating the server
- * accept script (via AcceptCallbackProc() in tclIOCmd.c), which can
- * close the server socket and invalidate statePtr and fds.
- * If TcpAccept() accepts a socket we must return immediately and let
- * SocketCheckProc queue additional FD_ACCEPT events.
+ /*
+ * Caution: TcpAccept() has the side-effect of evaluating the
+ * server accept script (via AcceptCallbackProc() in tclIOCmd.c),
+ * which can close the server socket and invalidate statePtr and
+ * fds. If TcpAccept() accepts a socket we must return immediately
+ * and let SocketCheckProc queue additional FD_ACCEPT events.
*/
+
TcpAccept(fds, newSocket, addr);
return 1;
}
- /* Loop terminated with no sockets accepted; clear the ready mask so
+ /*
+ * Loop terminated with no sockets accepted; clear the ready mask so
* we can detect the next connection request. Note that connection
* requests are level triggered, so if there is a request already
* pending, a new event will be generated.
*/
+
statePtr->acceptEventCount = 0;
- statePtr->readyEvents &= ~(FD_ACCEPT);
+ CLEAR_BITS(statePtr->readyEvents, FD_ACCEPT);
SetEvent(tsdPtr->socketListLock);
return 1;
@@ -2725,7 +2900,7 @@ SocketEventProc(
events = statePtr->readyEvents & statePtr->watchEvents;
- if (events & FD_CLOSE) {
+ if (GOT_BITS(events, FD_CLOSE)) {
/*
* If the socket was closed and the channel is still interested in
* read events, then we need to ensure that we keep polling for this
@@ -2739,17 +2914,14 @@ SocketEventProc(
Tcl_Time blockTime = { 0, 0 };
Tcl_SetMaxBlockTime(&blockTime);
- mask |= TCL_READABLE|TCL_WRITABLE;
- } else if (events & FD_READ) {
-
+ SET_BITS(mask, TCL_READABLE | TCL_WRITABLE);
+ } else if (GOT_BITS(events, FD_READ)) {
/*
* Throw the readable event if an async connect failed.
*/
- if ( statePtr->flags & TCP_ASYNC_FAILED ) {
-
- mask |= TCL_READABLE;
-
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
+ SET_BITS(mask, TCL_READABLE);
} else {
fd_set readFds;
struct timeval timeout;
@@ -2762,8 +2934,7 @@ SocketEventProc(
* async select handler and keep waiting.
*/
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
- (WPARAM) UNSELECT, (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, UNSELECT, statePtr);
FD_ZERO(&readFds);
FD_SET(statePtr->sockets->fd, &readFds);
@@ -2771,11 +2942,10 @@ SocketEventProc(
timeout.tv_sec = 0;
if (select(0, &readFds, NULL, NULL, &timeout) != 0) {
- mask |= TCL_READABLE;
+ SET_BITS(mask, TCL_READABLE);
} else {
- statePtr->readyEvents &= ~(FD_READ);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
- (WPARAM) SELECT, (LPARAM) statePtr);
+ CLEAR_BITS(statePtr->readyEvents, FD_READ);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
}
}
}
@@ -2784,8 +2954,8 @@ SocketEventProc(
* writable event
*/
- if (events & FD_WRITE) {
- mask |= TCL_WRITABLE;
+ if (GOT_BITS(events, FD_WRITE)) {
+ SET_BITS(mask, TCL_WRITABLE);
}
/*
@@ -2822,13 +2992,19 @@ AddSocketInfoFd(
{
TcpFdList *fds = statePtr->sockets;
- if ( fds == NULL ) {
- /* Add the first FD */
+ if (fds == NULL) {
+ /*
+ * Add the first FD.
+ */
+
statePtr->sockets = ckalloc(sizeof(TcpFdList));
fds = statePtr->sockets;
} else {
- /* Find end of list and append FD */
- while ( fds->next != NULL ) {
+ /*
+ * Find end of list and append FD.
+ */
+
+ while (fds->next != NULL) {
fds = fds->next;
}
@@ -2836,7 +3012,10 @@ AddSocketInfoFd(
fds = fds->next;
}
- /* Populate new FD */
+ /*
+ * Populate new FD.
+ */
+
fds->fd = socket;
fds->statePtr = statePtr;
fds->next = NULL;
@@ -2906,6 +3085,7 @@ WaitForSocketEvent(
int result = 1;
int oldMode;
ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
+
/*
* Be sure to disable event servicing so we are truly modal.
*/
@@ -2916,29 +3096,42 @@ WaitForSocketEvent(
* Reset WSAAsyncSelect so we have a fresh set of events pending.
*/
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) UNSELECT,
- (LPARAM) statePtr);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, UNSELECT, statePtr);
+ SendSelectMessage(tsdPtr, SELECT, statePtr);
while (1) {
int event_found;
- /* get statePtr lock */
+ /*
+ * Get statePtr lock.
+ */
+
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
- /* Check if event occured */
- event_found = (statePtr->readyEvents & events);
+ /*
+ * Check if event occured.
+ */
+
+ event_found = GOT_BITS(statePtr->readyEvents, events);
+
+ /*
+ * Free list lock.
+ */
- /* Free list lock */
SetEvent(tsdPtr->socketListLock);
- /* exit loop if event occured */
+ /*
+ * Exit loop if event occured.
+ */
+
if (event_found) {
break;
}
- /* Exit loop if event did not occur but this is a non-blocking channel */
+ /*
+ * Exit loop if event did not occur but this is a non-blocking channel
+ */
+
if (statePtr->flags & TCP_NONBLOCKING) {
*errorCodePtr = EWOULDBLOCK;
result = 0;
@@ -3095,55 +3288,59 @@ SocketProc(
for (statePtr = tsdPtr->socketList; statePtr != NULL;
statePtr = statePtr->nextPtr) {
- if ( FindFDInList(statePtr,socket) ) {
+ if (FindFDInList(statePtr, socket)) {
info_found = 1;
break;
}
}
+
/*
- * Check if there is a pending info structure not jet in the
- * list
+ * Check if there is a pending info structure not jet in the list.
*/
- if ( !info_found
+
+ if (!info_found
&& tsdPtr->pendingTcpState != NULL
- && FindFDInList(tsdPtr->pendingTcpState,socket) ) {
+ && FindFDInList(tsdPtr->pendingTcpState, socket)) {
statePtr = tsdPtr->pendingTcpState;
info_found = 1;
}
if (info_found) {
-
/*
* Update the socket state.
*
* A count of FD_ACCEPTS is stored, so if an FD_CLOSE event
- * happens, then clear the FD_ACCEPT count. Otherwise,
- * increment the count if the current event is an FD_ACCEPT.
+ * happens, then clear the FD_ACCEPT count. Otherwise, increment
+ * the count if the current event is an FD_ACCEPT.
*/
- if (event & FD_CLOSE) {
+ if (GOT_BITS(event, FD_CLOSE)) {
statePtr->acceptEventCount = 0;
- statePtr->readyEvents &= ~(FD_WRITE|FD_ACCEPT);
- } else if (event & FD_ACCEPT) {
+ CLEAR_BITS(statePtr->readyEvents, FD_WRITE | FD_ACCEPT);
+ } else if (GOT_BITS(event, FD_ACCEPT)) {
statePtr->acceptEventCount++;
}
- if (event & FD_CONNECT) {
+ if (GOT_BITS(event, FD_CONNECT)) {
/*
* Remember any error that occurred so we can report
* connection failures.
*/
+
if (error != ERROR_SUCCESS) {
statePtr->notifierConnectError = error;
}
}
+
/*
* Inform main thread about signaled events
*/
- statePtr->readyEvents |= event;
+
+ SET_BITS(statePtr->readyEvents, event);
/*
* Wake up the Main Thread.
*/
+
SetEvent(tsdPtr->readyEvent);
Tcl_ThreadAlert(tsdPtr->threadId);
}
@@ -3224,6 +3421,7 @@ FindFDInList(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
#undef TclWinGetSockOpt
int
TclWinGetSockOpt(
@@ -3263,6 +3461,7 @@ TclWinGetServByName(
{
return getservbyname(name, proto);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -3352,8 +3551,7 @@ TcpThreadActionProc(
* thread.
*/
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
- (WPARAM) notifyCmd, (LPARAM) statePtr);
+ SendSelectMessage(tsdPtr, notifyCmd, statePtr);
}
/*
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index 26d745d..b9cde72 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -180,7 +180,7 @@ TclWinThreadStart(
lpOrigStartAddress = winThreadPtr->lpStartAddress;
lpOrigParameter = winThreadPtr->lpParameter;
- ckfree((char *)winThreadPtr);
+ ckfree(winThreadPtr);
return lpOrigStartAddress(lpOrigParameter);
}
@@ -1008,8 +1008,10 @@ TclpFreeAllocCache(
if (ptr != NULL) {
/*
- * Called by us in TclpFinalizeThreadData when a thread exits and
- * destroys the tsd key which stores allocator caches.
+ * Called by TclFinalizeThreadAlloc() and
+ * TclFinalizeThreadAllocThread() during Tcl_Finalize() or
+ * Tcl_FinalizeThread(). This function destroys the tsd key which
+ * stores allocator caches in thread local storage.
*/
TclFreeAllocCache(ptr);
diff --git a/win/tclWinTime.c b/win/tclWinTime.c
index e0d4219..e138664 100644
--- a/win/tclWinTime.c
+++ b/win/tclWinTime.c
@@ -27,6 +27,7 @@
* month, where index 1 is January.
*/
+#ifndef TCL_NO_DEPRECATED
static const int normalDays[] = {
-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364
};
@@ -40,6 +41,7 @@ typedef struct {
struct tm tm; /* time information */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
+#endif /* TCL_NO_DEPRECATED */
/*
* Data for managing high-resolution timers.
@@ -113,7 +115,9 @@ static TimeInfo timeInfo = {
* Declarations for functions defined later in this file.
*/
+#ifndef TCL_NO_DEPRECATED
static struct tm * ComputeGMT(const time_t *tp);
+#endif /* TCL_NO_DEPRECATED */
static void StopCalibration(ClientData clientData);
static DWORD WINAPI CalibrationThread(LPVOID arg);
static void UpdateTimeEachSecond(void);
@@ -281,8 +285,6 @@ NativeGetTime(
ClientData clientData)
{
struct _timeb t;
- int useFtime = 1; /* Flag == TRUE if we need to fall back on
- * ftime rather than using the perf counter. */
/*
* Initialize static storage on the first trip through.
@@ -341,7 +343,7 @@ NativeGetTime(
*/
SYSTEM_INFO systemInfo;
- unsigned int regs[4];
+ int regs[4];
GetSystemInfo(&systemInfo);
if (TclWinCPUID(0, regs) == TCL_OK
@@ -353,7 +355,7 @@ NativeGetTime(
|| ((regs[0] & 0x00F00000) /* Extended family */
&& (regs[3] & 0x10000000))) /* Hyperthread */
&& (((regs[1]&0x00FF0000) >> 16)/* CPU count */
- == systemInfo.dwNumberOfProcessors)) {
+ == (int)systemInfo.dwNumberOfProcessors)) {
timeInfo.perfCounterAvailable = TRUE;
} else {
timeInfo.perfCounterAvailable = FALSE;
@@ -398,6 +400,10 @@ NativeGetTime(
* time.
*/
+ ULARGE_INTEGER fileTimeLastCall;
+ LARGE_INTEGER perfCounterLastCall, curCounterFreq;
+ /* Copy with current data of calibration cycle */
+
LARGE_INTEGER curCounter;
/* Current performance counter. */
Tcl_WideInt curFileTime;/* Current estimated time, expressed as 100-ns
@@ -411,9 +417,29 @@ NativeGetTime(
posixEpoch.LowPart = 0xD53E8000;
posixEpoch.HighPart = 0x019DB1DE;
+ QueryPerformanceCounter(&curCounter);
+
+ /*
+ * Hold time section locked as short as possible
+ */
EnterCriticalSection(&timeInfo.cs);
- QueryPerformanceCounter(&curCounter);
+ fileTimeLastCall.QuadPart = timeInfo.fileTimeLastCall.QuadPart;
+ perfCounterLastCall.QuadPart = timeInfo.perfCounterLastCall.QuadPart;
+ curCounterFreq.QuadPart = timeInfo.curCounterFreq.QuadPart;
+
+ LeaveCriticalSection(&timeInfo.cs);
+
+ /*
+ * If calibration cycle occurred after we get curCounter
+ */
+ if (curCounter.QuadPart <= perfCounterLastCall.QuadPart) {
+ usecSincePosixEpoch =
+ (fileTimeLastCall.QuadPart - posixEpoch.QuadPart) / 10;
+ timePtr->sec = (long) (usecSincePosixEpoch / 1000000);
+ timePtr->usec = (unsigned long) (usecSincePosixEpoch % 1000000);
+ return;
+ }
/*
* If it appears to be more than 1.1 seconds since the last trip
@@ -425,31 +451,27 @@ NativeGetTime(
* loop should recover.
*/
- if (curCounter.QuadPart - timeInfo.perfCounterLastCall.QuadPart <
- 11 * timeInfo.curCounterFreq.QuadPart / 10) {
- curFileTime = timeInfo.fileTimeLastCall.QuadPart +
- ((curCounter.QuadPart - timeInfo.perfCounterLastCall.QuadPart)
- * 10000000 / timeInfo.curCounterFreq.QuadPart);
- timeInfo.fileTimeLastCall.QuadPart = curFileTime;
- timeInfo.perfCounterLastCall.QuadPart = curCounter.QuadPart;
+ if (curCounter.QuadPart - perfCounterLastCall.QuadPart <
+ 11 * curCounterFreq.QuadPart / 10
+ ) {
+ curFileTime = fileTimeLastCall.QuadPart +
+ ((curCounter.QuadPart - perfCounterLastCall.QuadPart)
+ * 10000000 / curCounterFreq.QuadPart);
+
usecSincePosixEpoch = (curFileTime - posixEpoch.QuadPart) / 10;
timePtr->sec = (long) (usecSincePosixEpoch / 1000000);
timePtr->usec = (unsigned long) (usecSincePosixEpoch % 1000000);
- useFtime = 0;
+ return;
}
-
- LeaveCriticalSection(&timeInfo.cs);
}
- if (useFtime) {
- /*
- * High resolution timer is not available. Just use ftime.
- */
+ /*
+ * High resolution timer is not available. Just use ftime.
+ */
- _ftime(&t);
- timePtr->sec = (long)t.time;
- timePtr->usec = t.millitm * 1000;
- }
+ _ftime(&t);
+ timePtr->sec = (long)t.time;
+ timePtr->usec = t.millitm * 1000;
}
/*
@@ -504,6 +526,7 @@ StopCalibration(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
struct tm *
TclpGetDate(
const time_t *t,
@@ -706,6 +729,7 @@ ComputeGMT(
return tmPtr;
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -1050,6 +1074,7 @@ AccumulateSample(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
struct tm *
TclpGmtime(
const time_t *timePtr) /* Pointer to the number of seconds since the
@@ -1094,6 +1119,7 @@ TclpLocaltime(
return localtime(timePtr);
}
+#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------