summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-10-24 02:00:15 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-10-24 02:00:15 (GMT)
commitf338047c195aac7e3ac7bb3485da02b33fd868a2 (patch)
tree159ec7baa48a4fae2ac0fceb40eb4306dea28539
parent90221ac971708ce2bd09ffff98b55b8198513808 (diff)
parent335774aef1d1e39ff22a1024aaa062106f99390b (diff)
downloadtcl-f338047c195aac7e3ac7bb3485da02b33fd868a2.zip
tcl-f338047c195aac7e3ac7bb3485da02b33fd868a2.tar.gz
tcl-f338047c195aac7e3ac7bb3485da02b33fd868a2.tar.bz2
merge 8.7
-rw-r--r--doc/CrtObjCmd.32
-rw-r--r--generic/tclDisassemble.c2
-rw-r--r--generic/tclInt.h8
-rw-r--r--generic/tclOO.c96
-rw-r--r--generic/tclOOCall.c1
-rw-r--r--generic/tclOODefineCmds.c32
-rw-r--r--generic/tclOOInt.h11
-rw-r--r--generic/tclScan.c3
-rw-r--r--generic/tclTest.c4
-rw-r--r--generic/tclTomMath.h93
-rw-r--r--generic/tclUtil.c187
-rw-r--r--library/tzdata/Africa/Ceuta1
-rw-r--r--library/tzdata/America/Santiago324
-rw-r--r--library/tzdata/Asia/Macau68
-rw-r--r--library/tzdata/Asia/Manila18
-rw-r--r--library/tzdata/Asia/Pyongyang2
-rw-r--r--library/tzdata/Asia/Shanghai43
-rw-r--r--library/tzdata/Asia/Tokyo8
-rw-r--r--library/tzdata/Europe/Volgograd1
-rw-r--r--library/tzdata/Pacific/Easter324
-rw-r--r--library/tzdata/Pacific/Fiji24
-rw-r--r--libtommath/README.md6
-rw-r--r--libtommath/bn_error.c4
-rw-r--r--libtommath/bn_fast_mp_invmod.c12
-rw-r--r--libtommath/bn_fast_mp_montgomery_reduce.c4
-rw-r--r--libtommath/bn_fast_s_mp_mul_digs.c4
-rw-r--r--libtommath/bn_fast_s_mp_mul_high_digs.c4
-rw-r--r--libtommath/bn_fast_s_mp_sqr.c4
-rw-r--r--libtommath/bn_mp_2expt.c4
-rw-r--r--libtommath/bn_mp_abs.c4
-rw-r--r--libtommath/bn_mp_add.c4
-rw-r--r--libtommath/bn_mp_add_d.c4
-rw-r--r--libtommath/bn_mp_addmod.c4
-rw-r--r--libtommath/bn_mp_and.c4
-rw-r--r--libtommath/bn_mp_clamp.c4
-rw-r--r--libtommath/bn_mp_clear.c4
-rw-r--r--libtommath/bn_mp_clear_multi.c4
-rw-r--r--libtommath/bn_mp_cmp.c4
-rw-r--r--libtommath/bn_mp_cmp_d.c4
-rw-r--r--libtommath/bn_mp_cmp_mag.c4
-rw-r--r--libtommath/bn_mp_cnt_lsb.c4
-rw-r--r--libtommath/bn_mp_complement.c26
-rw-r--r--libtommath/bn_mp_copy.c4
-rw-r--r--libtommath/bn_mp_count_bits.c4
-rw-r--r--libtommath/bn_mp_div.c4
-rw-r--r--libtommath/bn_mp_div_2.c4
-rw-r--r--libtommath/bn_mp_div_2d.c4
-rw-r--r--libtommath/bn_mp_div_3.c4
-rw-r--r--libtommath/bn_mp_div_d.c4
-rw-r--r--libtommath/bn_mp_dr_is_modulus.c4
-rw-r--r--libtommath/bn_mp_dr_reduce.c4
-rw-r--r--libtommath/bn_mp_dr_setup.c4
-rw-r--r--libtommath/bn_mp_exch.c4
-rw-r--r--libtommath/bn_mp_export.c4
-rw-r--r--libtommath/bn_mp_expt_d.c4
-rw-r--r--libtommath/bn_mp_expt_d_ex.c4
-rw-r--r--libtommath/bn_mp_exptmod.c4
-rw-r--r--libtommath/bn_mp_exptmod_fast.c4
-rw-r--r--libtommath/bn_mp_exteuclid.c4
-rw-r--r--libtommath/bn_mp_fread.c4
-rw-r--r--libtommath/bn_mp_fwrite.c4
-rw-r--r--libtommath/bn_mp_gcd.c4
-rw-r--r--libtommath/bn_mp_get_int.c4
-rw-r--r--libtommath/bn_mp_get_long.c4
-rw-r--r--libtommath/bn_mp_get_long_long.c4
-rw-r--r--libtommath/bn_mp_grow.c4
-rw-r--r--libtommath/bn_mp_import.c4
-rw-r--r--libtommath/bn_mp_init.c4
-rw-r--r--libtommath/bn_mp_init_copy.c4
-rw-r--r--libtommath/bn_mp_init_multi.c4
-rw-r--r--libtommath/bn_mp_init_set.c4
-rw-r--r--libtommath/bn_mp_init_set_int.c4
-rw-r--r--libtommath/bn_mp_init_size.c4
-rw-r--r--libtommath/bn_mp_invmod.c4
-rw-r--r--libtommath/bn_mp_invmod_slow.c4
-rw-r--r--libtommath/bn_mp_is_square.c28
-rw-r--r--libtommath/bn_mp_jacobi.c4
-rw-r--r--libtommath/bn_mp_karatsuba_mul.c8
-rw-r--r--libtommath/bn_mp_karatsuba_sqr.c8
-rw-r--r--libtommath/bn_mp_lcm.c4
-rw-r--r--libtommath/bn_mp_lshd.c4
-rw-r--r--libtommath/bn_mp_mod.c4
-rw-r--r--libtommath/bn_mp_mod_2d.c4
-rw-r--r--libtommath/bn_mp_mod_d.c4
-rw-r--r--libtommath/bn_mp_montgomery_calc_normalization.c4
-rw-r--r--libtommath/bn_mp_montgomery_reduce.c4
-rw-r--r--libtommath/bn_mp_montgomery_setup.c4
-rw-r--r--libtommath/bn_mp_mul.c4
-rw-r--r--libtommath/bn_mp_mul_2.c4
-rw-r--r--libtommath/bn_mp_mul_2d.c4
-rw-r--r--libtommath/bn_mp_mul_d.c4
-rw-r--r--libtommath/bn_mp_mulmod.c4
-rw-r--r--libtommath/bn_mp_n_root.c4
-rw-r--r--libtommath/bn_mp_n_root_ex.c4
-rw-r--r--libtommath/bn_mp_neg.c4
-rw-r--r--libtommath/bn_mp_or.c4
-rw-r--r--libtommath/bn_mp_prime_fermat.c4
-rw-r--r--libtommath/bn_mp_prime_is_divisible.c4
-rw-r--r--libtommath/bn_mp_prime_is_prime.c4
-rw-r--r--libtommath/bn_mp_prime_miller_rabin.c4
-rw-r--r--libtommath/bn_mp_prime_next_prime.c4
-rw-r--r--libtommath/bn_mp_prime_rabin_miller_trials.c4
-rw-r--r--libtommath/bn_mp_prime_random_ex.c4
-rw-r--r--libtommath/bn_mp_radix_size.c4
-rw-r--r--libtommath/bn_mp_radix_smap.c28
-rw-r--r--libtommath/bn_mp_rand.c190
-rw-r--r--libtommath/bn_mp_read_radix.c4
-rw-r--r--libtommath/bn_mp_read_signed_bin.c4
-rw-r--r--libtommath/bn_mp_read_unsigned_bin.c4
-rw-r--r--libtommath/bn_mp_reduce.c4
-rw-r--r--libtommath/bn_mp_reduce_2k.c14
-rw-r--r--libtommath/bn_mp_reduce_2k_l.c14
-rw-r--r--libtommath/bn_mp_reduce_2k_setup.c4
-rw-r--r--libtommath/bn_mp_reduce_2k_setup_l.c10
-rw-r--r--libtommath/bn_mp_reduce_is_2k.c4
-rw-r--r--libtommath/bn_mp_reduce_is_2k_l.c4
-rw-r--r--libtommath/bn_mp_reduce_setup.c4
-rw-r--r--libtommath/bn_mp_rshd.c4
-rw-r--r--libtommath/bn_mp_set.c4
-rw-r--r--libtommath/bn_mp_set_int.c4
-rw-r--r--libtommath/bn_mp_set_long.c4
-rw-r--r--libtommath/bn_mp_set_long_long.c4
-rw-r--r--libtommath/bn_mp_shrink.c4
-rw-r--r--libtommath/bn_mp_signed_bin_size.c4
-rw-r--r--libtommath/bn_mp_sqr.c4
-rw-r--r--libtommath/bn_mp_sqrmod.c4
-rw-r--r--libtommath/bn_mp_sqrt.c22
-rw-r--r--libtommath/bn_mp_sqrtmod_prime.c2
-rw-r--r--libtommath/bn_mp_sub.c4
-rw-r--r--libtommath/bn_mp_sub_d.c4
-rw-r--r--libtommath/bn_mp_submod.c4
-rw-r--r--libtommath/bn_mp_tc_and.c89
-rw-r--r--libtommath/bn_mp_tc_div_2d.c36
-rw-r--r--libtommath/bn_mp_tc_or.c89
-rw-r--r--libtommath/bn_mp_tc_xor.c89
-rw-r--r--libtommath/bn_mp_to_signed_bin.c4
-rw-r--r--libtommath/bn_mp_to_signed_bin_n.c4
-rw-r--r--libtommath/bn_mp_to_unsigned_bin.c4
-rw-r--r--libtommath/bn_mp_to_unsigned_bin_n.c4
-rw-r--r--libtommath/bn_mp_toom_mul.c124
-rw-r--r--libtommath/bn_mp_toom_sqr.c98
-rw-r--r--libtommath/bn_mp_toradix.c4
-rw-r--r--libtommath/bn_mp_toradix_n.c4
-rw-r--r--libtommath/bn_mp_unsigned_bin_size.c4
-rw-r--r--libtommath/bn_mp_xor.c4
-rw-r--r--libtommath/bn_mp_zero.c4
-rw-r--r--libtommath/bn_prime_tab.c4
-rw-r--r--libtommath/bn_reverse.c4
-rw-r--r--libtommath/bn_s_mp_add.c4
-rw-r--r--libtommath/bn_s_mp_exptmod.c4
-rw-r--r--libtommath/bn_s_mp_mul_digs.c4
-rw-r--r--libtommath/bn_s_mp_mul_high_digs.c4
-rw-r--r--libtommath/bn_s_mp_sqr.c4
-rw-r--r--libtommath/bn_s_mp_sub.c4
-rw-r--r--libtommath/bncore.c4
-rw-r--r--libtommath/callgraph.txt177
-rw-r--r--libtommath/makefile52
-rw-r--r--libtommath/makefile.bcc32
-rw-r--r--libtommath/makefile.cygwin_dll32
-rw-r--r--libtommath/makefile.icc48
-rw-r--r--libtommath/makefile.msvc39
-rw-r--r--libtommath/makefile.shared54
-rw-r--r--libtommath/makefile_include.mk37
-rw-r--r--libtommath/tommath.h77
-rw-r--r--libtommath/tommath_class.h67
-rw-r--r--libtommath/tommath_private.h4
-rw-r--r--macosx/tclMacOSXNotify.c101
-rw-r--r--tests/oo.test100
-rw-r--r--tests/registry.test4
-rw-r--r--tests/util.test45
-rw-r--r--tools/genStubs.tcl12
-rw-r--r--unix/Makefile.in3
-rw-r--r--unix/tclEpollNotfy.c225
-rw-r--r--unix/tclKqueueNotfy.c231
-rw-r--r--unix/tclSelectNotfy.c125
-rw-r--r--unix/tclUnixNotfy.c52
-rw-r--r--win/Makefile.in4
-rw-r--r--win/makefile.vc2
178 files changed, 2480 insertions, 1648 deletions
diff --git a/doc/CrtObjCmd.3 b/doc/CrtObjCmd.3
index 87ce07e..2cd9222 100644
--- a/doc/CrtObjCmd.3
+++ b/doc/CrtObjCmd.3
@@ -8,7 +8,7 @@
.so man.macros
.BS
.SH NAME
-Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj Tcl_RegisterCommandTypeName, Tcl_GetCommandTypeName \- implement new commands in C
+Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj, Tcl_RegisterCommandTypeName, Tcl_GetCommandTypeName \- implement new commands in C
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 46012c5..6ea3397 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -1622,7 +1622,7 @@ Tcl_DisassembleObjCmd(
"BYTECODE", NULL);
return TCL_ERROR;
}
- if (PTR2INT(clientData)) {
+ if (clientData) {
Tcl_SetObjResult(interp,
DisassembleByteCodeAsDicts(interp, codeObjPtr));
} else {
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 334ae20..453c10f 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -120,19 +120,19 @@ typedef int ptrdiff_t;
#if !defined(INT2PTR) && !defined(PTR2INT)
# if defined(HAVE_INTPTR_T) || defined(intptr_t)
# define INT2PTR(p) ((void *)(intptr_t)(p))
-# define PTR2INT(p) ((int)(intptr_t)(p))
+# define PTR2INT(p) ((intptr_t)(p))
# else
# define INT2PTR(p) ((void *)(p))
-# define PTR2INT(p) ((int)(p))
+# define PTR2INT(p) ((long)(p))
# endif
#endif
#if !defined(UINT2PTR) && !defined(PTR2UINT)
# if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
# define UINT2PTR(p) ((void *)(uintptr_t)(p))
-# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p))
+# define PTR2UINT(p) ((uintptr_t)(p))
# else
# define UINT2PTR(p) ((void *)(p))
-# define PTR2UINT(p) ((unsigned int)(p))
+# define PTR2UINT(p) ((unsigned long)(p))
# endif
#endif
diff --git a/generic/tclOO.c b/generic/tclOO.c
index c8471d5..2491c2f 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -59,7 +59,6 @@ static const struct {
* Function declarations for things defined in this file.
*/
-static Class * AllocClass(Tcl_Interp *interp, Object *useThisObj);
static Object * AllocObject(Tcl_Interp *interp, const char *nameStr,
Namespace *nsPtr, const char *nsNameStr);
static int CloneClassMethod(Tcl_Interp *interp, Class *clsPtr,
@@ -84,8 +83,6 @@ static void ObjectNamespaceDeleted(ClientData clientData);
static void ObjectRenamedTrace(ClientData clientData,
Tcl_Interp *interp, const char *oldName,
const char *newName, int flags);
-static void ReleaseClassContents(Tcl_Interp *interp,Object *oPtr);
-static void DeleteDescendants(Tcl_Interp *interp,Object *oPtr);
static inline void RemoveClass(Class **list, int num, int idx);
static inline void RemoveObject(Object **list, int num, int idx);
static inline void SquelchCachedName(Object *oPtr);
@@ -451,10 +448,10 @@ InitClassSystemRoots(
/* Stand up a phony class for bootstrapping. */
fPtr->objectCls = &fakeCls;
- /* referenced in AllocClass to increment the refCount. */
+ /* referenced in TclOOAllocClass to increment the refCount. */
fakeCls.thisPtr = &fakeObject;
- fPtr->objectCls = AllocClass(interp,
+ fPtr->objectCls = TclOOAllocClass(interp,
AllocObject(interp, "object", (Namespace *)fPtr->ooNs, NULL));
/* Corresponding TclOODecrRefCount in KillFoudation */
AddRef(fPtr->objectCls->thisPtr);
@@ -470,7 +467,7 @@ InitClassSystemRoots(
fPtr->objectCls->thisPtr->flags |= ROOT_OBJECT;
fPtr->objectCls->flags |= ROOT_OBJECT;
- fPtr->classCls = AllocClass(interp,
+ fPtr->classCls = TclOOAllocClass(interp,
AllocObject(interp, "class", (Namespace *)fPtr->ooNs, NULL));
/* Corresponding TclOODecrRefCount in KillFoudation */
AddRef(fPtr->classCls->thisPtr);
@@ -839,15 +836,15 @@ ObjectRenamedTrace(
/*
* ----------------------------------------------------------------------
*
- * DeleteDescendants --
+ * TclOODeleteDescendants --
*
* Delete all descendants of a particular class.
*
* ----------------------------------------------------------------------
*/
-static void
-DeleteDescendants(
+void
+TclOODeleteDescendants(
Tcl_Interp *interp, /* The interpreter containing the class. */
Object *oPtr) /* The object representing the class. */
{
@@ -864,7 +861,8 @@ DeleteDescendants(
/* This condition also covers the case where mixinSubclassPtr ==
* clsPtr
*/
- if (!Deleted(mixinSubclassPtr->thisPtr)) {
+ if (!Deleted(mixinSubclassPtr->thisPtr)
+ && !(mixinSubclassPtr->thisPtr->flags & DONT_DELETE)) {
Tcl_DeleteCommandFromToken(interp,
mixinSubclassPtr->thisPtr->command);
}
@@ -883,8 +881,10 @@ DeleteDescendants(
if (clsPtr->subclasses.num > 0) {
while (clsPtr->subclasses.num > 0) {
subclassPtr = clsPtr->subclasses.list[clsPtr->subclasses.num-1];
- if (!Deleted(subclassPtr->thisPtr) && !IsRoot(subclassPtr)) {
- Tcl_DeleteCommandFromToken(interp, subclassPtr->thisPtr->command);
+ if (!Deleted(subclassPtr->thisPtr) && !IsRoot(subclassPtr)
+ && !(subclassPtr->thisPtr->flags & DONT_DELETE)) {
+ Tcl_DeleteCommandFromToken(interp,
+ subclassPtr->thisPtr->command);
}
TclOORemoveFromSubclasses(subclassPtr, clsPtr);
}
@@ -906,7 +906,8 @@ DeleteDescendants(
* This condition also covers the case where instancePtr == oPtr
*/
- if (!Deleted(instancePtr) && !IsRoot(instancePtr)) {
+ if (!Deleted(instancePtr) && !IsRoot(instancePtr) &&
+ !(instancePtr->flags & DONT_DELETE)) {
Tcl_DeleteCommandFromToken(interp, instancePtr->command);
}
TclOORemoveFromInstances(instancePtr, clsPtr);
@@ -922,7 +923,7 @@ DeleteDescendants(
/*
* ----------------------------------------------------------------------
*
- * ReleaseClassContents --
+ * TclOOReleaseClassContents --
*
* Tear down the special class data structure, including deleting all
* dependent classes and objects.
@@ -930,8 +931,8 @@ DeleteDescendants(
* ----------------------------------------------------------------------
*/
-static void
-ReleaseClassContents(
+void
+TclOOReleaseClassContents(
Tcl_Interp *interp, /* The interpreter containing the class. */
Object *oPtr) /* The object representing the class. */
{
@@ -954,9 +955,6 @@ ReleaseClassContents(
} else if (IsRootObject(oPtr)) {
Tcl_Panic("deleting class structure for non-deleted %s",
"::oo::object");
- } else {
- Tcl_Panic("deleting class structure for non-deleted %s",
- "general object");
}
}
@@ -1059,6 +1057,7 @@ ReleaseClassContents(
if (IsRootClass(oPtr) && !Deleted(fPtr->objectCls->thisPtr)) {
Tcl_DeleteCommandFromToken(interp, fPtr->objectCls->thisPtr->command);
}
+ oPtr->classPtr = NULL;
}
/*
@@ -1108,7 +1107,7 @@ ObjectNamespaceDeleted(
/* Let the dominoes fall */
if (oPtr->classPtr) {
- DeleteDescendants(interp, oPtr);
+ TclOODeleteDescendants(interp, oPtr);
}
/*
@@ -1237,8 +1236,8 @@ ObjectNamespaceDeleted(
/*
* Because an object can be a class that is an instance of itself, the
- * class object's class structure should only be cleaned after most of the
- * cleanup on the object is done.
+ * class object's class structure should only be cleaned after most of
+ * the cleanup on the object is done.
*
* The class of objects needs some special care; if it is deleted (and
* we're not killing the whole interpreter) we force the delete of the
@@ -1253,7 +1252,7 @@ ObjectNamespaceDeleted(
}
if (oPtr->classPtr != NULL) {
- ReleaseClassContents(interp, oPtr);
+ TclOOReleaseClassContents(interp, oPtr);
}
/*
@@ -1360,6 +1359,37 @@ TclOOAddToInstances(
/*
* ----------------------------------------------------------------------
*
+ * TclOORemoveFromMixins --
+ *
+ * Utility function to remove a class from the list of mixins within an
+ * object.
+ *
+ * ----------------------------------------------------------------------
+ */
+
+int
+TclOORemoveFromMixins(
+ Class *mixinPtr, /* The mixin to remove. */
+ Object *oPtr) /* The object (possibly) containing the
+ * reference to the mixin. */
+{
+ int i, res = 0;
+ Class *mixPtr;
+
+ FOREACH(mixPtr, oPtr->mixins) {
+ if (mixinPtr == mixPtr) {
+ RemoveItem(Class, oPtr->mixins, i);
+ TclOODecrRefCount(mixPtr->thisPtr);
+ res++;
+ break;
+ }
+ }
+ return res;
+}
+
+/*
+ * ----------------------------------------------------------------------
+ *
* TclOORemoveFromSubclasses --
*
* Utility function to remove a class from the list of subclasses within
@@ -1489,10 +1519,10 @@ TclOOAddToMixinSubs(
/*
* ----------------------------------------------------------------------
*
- * AllocClass --
+ * TclOOAllocClass --
*
- * Allocate a basic class. Does not add class to its
- * class's instance list.
+ * Allocate a basic class. Does not add class to its class's instance
+ * list.
*
* ----------------------------------------------------------------------
*/
@@ -1516,8 +1546,8 @@ InitClassPath(
}
}
-static Class *
-AllocClass(
+Class *
+TclOOAllocClass(
Tcl_Interp *interp, /* Interpreter within which to allocate the
* class. */
Object *useThisObj) /* Object that is to act as the class
@@ -1758,13 +1788,13 @@ TclNewObjectInstanceCommon(
if (TclOOIsReachable(fPtr->classCls, classPtr)) {
/*
- * Is a class, so attach a class structure. Note that the AllocClass
- * function splices the structure into the object, so we don't have
- * to. Once that's done, we need to repatch the object to have the
- * right class since AllocClass interferes with that.
+ * Is a class, so attach a class structure. Note that the
+ * TclOOAllocClass function splices the structure into the object, so
+ * we don't have to. Once that's done, we need to repatch the object
+ * to have the right class since TclOOAllocClass interferes with that.
*/
- AllocClass(interp, oPtr);
+ TclOOAllocClass(interp, oPtr);
TclOOAddToSubclasses(oPtr->classPtr, fPtr->objectCls);
} else {
oPtr->classPtr = NULL;
diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c
index 1b4f587..50a9c80 100644
--- a/generic/tclOOCall.c
+++ b/generic/tclOOCall.c
@@ -1703,7 +1703,6 @@ AddSimpleClassChainToCallContext(
if (flags & CONSTRUCTOR) {
AddMethodToCallChain(classPtr->constructorPtr, cbPtr, doneFilters,
filterDecl, flags);
-
} else if (flags & DESTRUCTOR) {
AddMethodToCallChain(classPtr->destructorPtr, cbPtr, doneFilters,
filterDecl, flags);
diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c
index 17680a0..b4ff283 100644
--- a/generic/tclOODefineCmds.c
+++ b/generic/tclOODefineCmds.c
@@ -1375,6 +1375,8 @@ TclOODefineClassObjCmd(
{
Object *oPtr;
Class *clsPtr;
+ Foundation *fPtr = TclOOGetFoundation(interp);
+ int wasClass, willBeClass;
/*
* Parse the context to get the object to operate on.
@@ -1410,12 +1412,20 @@ TclOODefineClassObjCmd(
if (clsPtr == NULL) {
return TCL_ERROR;
}
-
+ if (oPtr == clsPtr->thisPtr) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "may not change classes into an instance of themselves", -1));
+ Tcl_SetErrorCode(interp, "TCL", "OO", "MONKEY_BUSINESS", NULL);
+ return TCL_ERROR;
+ }
/*
* Set the object's class.
*/
+ wasClass = (oPtr->classPtr != NULL);
+ willBeClass = (TclOOIsReachable(fPtr->classCls, clsPtr));
+
if (oPtr->selfCls != clsPtr) {
TclOORemoveFromInstances(oPtr, oPtr->selfCls);
TclOODecrRefCount(oPtr->selfCls->thisPtr);
@@ -1423,6 +1433,26 @@ TclOODefineClassObjCmd(
AddRef(oPtr->selfCls->thisPtr);
TclOOAddToInstances(oPtr, oPtr->selfCls);
+ /*
+ * Create or delete the class guts if necessary.
+ */
+
+ if (wasClass && !willBeClass) {
+ /*
+ * This is the most global of all epochs. Bump it! No cache can be
+ * trusted!
+ */
+
+ TclOORemoveFromMixins(oPtr->classPtr, oPtr);
+ oPtr->fPtr->epoch++;
+ oPtr->flags |= DONT_DELETE;
+ TclOODeleteDescendants(interp, oPtr);
+ oPtr->flags &= ~DONT_DELETE;
+ TclOOReleaseClassContents(interp, oPtr);
+ } else if (!wasClass && willBeClass) {
+ TclOOAllocClass(interp, oPtr);
+ }
+
if (oPtr->classPtr != NULL) {
BumpGlobalEpoch(interp, oPtr->classPtr);
} else {
diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h
index 1f30fed..47e5cf0 100644
--- a/generic/tclOOInt.h
+++ b/generic/tclOOInt.h
@@ -242,6 +242,10 @@ typedef struct Object {
/* Object/class has (or had) private methods,
* and so shouldn't be cached so
* aggressively. */
+#define DONT_DELETE 0x40000 /* Inhibit deletion of this object. Used
+ * during fundamental object type mutation to
+ * make sure that the object actually survives
+ * to the end of the operation. */
/*
* And the definition of a class. Note that every class also has an associated
@@ -526,6 +530,8 @@ MODULE_SCOPE int TclOO_Object_VarName(ClientData clientData,
MODULE_SCOPE void TclOOAddToInstances(Object *oPtr, Class *clsPtr);
MODULE_SCOPE void TclOOAddToMixinSubs(Class *subPtr, Class *mixinPtr);
MODULE_SCOPE void TclOOAddToSubclasses(Class *subPtr, Class *superPtr);
+MODULE_SCOPE Class * TclOOAllocClass(Tcl_Interp *interp,
+ Object *useThisObj);
MODULE_SCOPE int TclNRNewObjectInstance(Tcl_Interp *interp,
Tcl_Class cls, const char *nameStr,
const char *nsNameStr, int objc,
@@ -540,6 +546,8 @@ MODULE_SCOPE int TclOODefineSlots(Foundation *fPtr);
MODULE_SCOPE void TclOODeleteChain(CallChain *callPtr);
MODULE_SCOPE void TclOODeleteChainCache(Tcl_HashTable *tablePtr);
MODULE_SCOPE void TclOODeleteContext(CallContext *contextPtr);
+MODULE_SCOPE void TclOODeleteDescendants(Tcl_Interp *interp,
+ Object *oPtr);
MODULE_SCOPE void TclOODelMethodRef(Method *method);
MODULE_SCOPE CallContext *TclOOGetCallContext(Object *oPtr,
Tcl_Obj *methodNameObj, int flags,
@@ -567,7 +575,10 @@ MODULE_SCOPE int TclNRObjectContextInvokeNext(Tcl_Interp *interp,
MODULE_SCOPE void TclOONewBasicMethod(Tcl_Interp *interp, Class *clsPtr,
const DeclaredClassMethod *dcm);
MODULE_SCOPE Tcl_Obj * TclOOObjectName(Tcl_Interp *interp, Object *oPtr);
+MODULE_SCOPE void TclOOReleaseClassContents(Tcl_Interp *interp,
+ Object *oPtr);
MODULE_SCOPE int TclOORemoveFromInstances(Object *oPtr, Class *clsPtr);
+MODULE_SCOPE int TclOORemoveFromMixins(Class *mixinPtr, Object *oPtr);
MODULE_SCOPE int TclOORemoveFromMixinSubs(Class *subPtr,
Class *mixinPtr);
MODULE_SCOPE int TclOORemoveFromSubclasses(Class *subPtr,
diff --git a/generic/tclScan.c b/generic/tclScan.c
index da6a52f..745f05b 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -932,8 +932,7 @@ Tcl_ScanObjCmd(
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
- sprintf(buf, "%" TCL_LL_MODIFIER "u",
- (Tcl_WideUInt)wideValue);
+ sprintf(buf, "%" TCL_LL_MODIFIER "u", wideValue);
Tcl_SetStringObj(objPtr, buf, -1);
} else {
TclSetIntObj(objPtr, wideValue);
diff --git a/generic/tclTest.c b/generic/tclTest.c
index f680ff5..fb8857c 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -2394,7 +2394,7 @@ ExitProcOdd(
char buf[16 + TCL_INTEGER_SPACE];
size_t len;
- sprintf(buf, "odd %d\n", PTR2INT(clientData));
+ sprintf(buf, "odd %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData));
len = strlen(buf);
if (len != (size_t) write(1, buf, len)) {
Tcl_Panic("ExitProcOdd: unable to write to stdout");
@@ -2408,7 +2408,7 @@ ExitProcEven(
char buf[16 + TCL_INTEGER_SPACE];
size_t len;
- sprintf(buf, "even %d\n", PTR2INT(clientData));
+ sprintf(buf, "even %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData));
len = strlen(buf);
if (len != (size_t) write(1, buf, len)) {
Tcl_Panic("ExitProcEven: unable to write to stdout");
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index e0f8497..fbf0d35 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -9,8 +9,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef BN_H_
#define BN_H_
@@ -27,14 +25,20 @@ extern "C" {
#endif
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
-#if defined(_MSC_VER) || defined(__LLP64__)
+#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
# define MP_32BIT
#endif
/* detect 64-bit mode if possible */
#if defined(NEVER)
-# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT) || defined(_MSC_VER))
-# define MP_64BIT
+# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
+# if defined(__GNUC__)
+/* we support 128bit integers only via: __attribute__((mode(TI))) */
+# define MP_64BIT
+# else
+/* otherwise we fall back to MP_32BIT even on 64bit platforms */
+# define MP_32BIT
+# endif
# endif
#endif
@@ -48,11 +52,11 @@ extern "C" {
*/
#ifdef MP_8BIT
#ifndef MP_DIGIT_DECLARED
-typedef uint8_t mp_digit;
+typedef unsigned char mp_digit;
#define MP_DIGIT_DECLARED
#endif
#ifndef MP_WORD_DECLARED
-typedef uint16_t mp_word;
+typedef unsigned short mp_word;
#define MP_WORD_DECLARED
#endif
# define MP_SIZEOF_MP_DIGIT 1
@@ -61,11 +65,11 @@ typedef uint16_t mp_word;
# endif
#elif defined(MP_16BIT)
#ifndef MP_DIGIT_DECLARED
-typedef uint16_t mp_digit;
+typedef unsigned short mp_digit;
#define MP_DIGIT_DECLARED
#endif
#ifndef MP_WORD_DECLARED
-typedef uint32_t mp_word;
+typedef unsigned int mp_word;
#define MP_WORD_DECLARED
#endif
# define MP_SIZEOF_MP_DIGIT 2
@@ -75,31 +79,21 @@ typedef uint32_t mp_word;
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
#ifndef MP_DIGIT_DECLARED
-typedef uint64_t mp_digit;
+typedef unsigned long long mp_digit;
#define MP_DIGIT_DECLARED
#endif
-# if 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 */
-#ifndef MP_WORD_DECLARED
-typedef uint128_t mp_word;
-#define MP_WORD_DECLARED
-#endif
-# endif
-
# define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
/* this is to make porting into LibTomCrypt easier :-) */
#ifndef MP_DIGIT_DECLARED
-typedef uint32_t mp_digit;
+typedef unsigned int mp_digit;
#define MP_DIGIT_DECLARED
#endif
#ifndef MP_WORD_DECLARED
-typedef uint64_t mp_word;
+typedef unsigned long long mp_word;
#define MP_WORD_DECLARED
#endif
@@ -116,23 +110,11 @@ typedef uint64_t mp_word;
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT
# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
-typedef uint_least32_t mp_min_u32;
+typedef unsigned long mp_min_u32;
#else
typedef mp_digit mp_min_u32;
#endif
-/* use arc4random on platforms that support it */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
-# define MP_GEN_RANDOM() arc4random()
-# define MP_GEN_RANDOM_MAX 0xffffffffu
-#endif
-
-/* use rand() as fall-back if there's no better rand function */
-#ifndef MP_GEN_RANDOM
-# define MP_GEN_RANDOM() rand()
-# define MP_GEN_RANDOM_MAX RAND_MAX
-#endif
-
#define MP_DIGIT_BIT DIGIT_BIT
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
#define MP_DIGIT_MAX MP_MASK
@@ -271,9 +253,9 @@ int mp_set_int(mp_int *a, unsigned long b);
int mp_set_long(mp_int *a, unsigned long b);
*/
-/* set a platform dependent Tcl_WideUInt value */
+/* set a platform dependent unsigned long long value */
/*
-int mp_set_long_long(mp_int *a, Tcl_WideUInt b);
+int mp_set_long_long(mp_int *a, unsigned long long b);
*/
/* get a 32-bit value */
@@ -286,9 +268,9 @@ unsigned long mp_get_int(const mp_int *a);
unsigned long mp_get_long(const mp_int *a);
*/
-/* get a platform dependent Tcl_WideUInt value */
+/* get a platform dependent unsigned long long value */
/*
-Tcl_WideUInt mp_get_long_long(const mp_int *a);
+unsigned long long mp_get_long_long(const mp_int *a);
*/
/* initialize and set a digit */
@@ -380,6 +362,14 @@ int mp_cnt_lsb(const mp_int *a);
int mp_rand(mp_int *a, int digits);
*/
+#ifdef MP_PRNG_ENABLE_LTM_RNG
+/* as last resort we will fall back to libtomcrypt's rng_get_bytes()
+ * in case you don't use libtomcrypt or use it w/o rng_get_bytes()
+ * you have to implement it somewhere else, as it's required */
+extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
+extern void (*ltm_rng_callback)(void);
+#endif
+
/* ---> binary operations <--- */
/* c = a XOR b */
/*
@@ -396,8 +386,33 @@ int mp_or(const mp_int *a, const mp_int *b, mp_int *c);
int mp_and(const mp_int *a, const mp_int *b, mp_int *c);
*/
+/* c = a XOR b (two complement) */
+/*
+int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c);
+*/
+
+/* c = a OR b (two complement) */
+/*
+int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c);
+*/
+
+/* c = a AND b (two complement) */
+/*
+int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c);
+*/
+
+/* right shift (two complement) */
+/*
+int mp_tc_div_2d(const mp_int *a, int b, mp_int *c);
+*/
+
/* ---> Basic arithmetic <--- */
+/* b = ~a */
+/*
+int mp_complement(const mp_int *a, mp_int *b);
+*/
+
/* b = -a */
/*
int mp_neg(const mp_int *a, mp_int *b);
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 97ddea7..af63822 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -113,8 +113,6 @@ static int GetEndOffsetFromObj(Tcl_Obj *objPtr,
static Tcl_HashTable * GetThreadHash(Tcl_ThreadDataKey *keyPtr);
static int GetWideForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr,
Tcl_WideInt endValue, Tcl_WideInt *widePtr);
-static int SetEndOffsetFromAny(Tcl_Interp *interp,
- Tcl_Obj *objPtr);
static int FindElement(Tcl_Interp *interp, const char *string,
int stringLength, const char *typeStr,
const char *typeCode, const char **elementPtr,
@@ -127,7 +125,8 @@ static int FindElement(Tcl_Interp *interp, const char *string,
* stored directly in the wideValue, so no memory management is required
* for it. This is a caching intrep, keeping the result of a parse
* around. This type is only created from a pre-existing string, so an
- * updateStringProc will never be called and need not exist.
+ * updateStringProc will never be called and need not exist. The type
+ * is unregistered, so has no need of a setFromAnyProc either.
*/
static const Tcl_ObjType endOffsetType = {
@@ -135,7 +134,7 @@ static const Tcl_ObjType endOffsetType = {
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL
+ NULL /* setFromAnyProc */
};
/*
@@ -3660,10 +3659,12 @@ TclFormatInt(
* GetWideForIndex --
*
* This function produces a wide integer value corresponding to the
- * list index held in *objPtr. The parsing supports all values
+ * index value held in *objPtr. The parsing supports all values
* recognized as any size of integer, and the syntaxes end[-+]$integer
* and $integer[-+]$integer. The argument endValue is used to give
- * the meaning of the literal index value "end".
+ * the meaning of the literal index value "end". Index arithmetic
+ * on arguments outside the wide integer range are only accepted
+ * when interp is a working interpreter, not NULL.
*
* Results:
* When parsing of *objPtr successfully recognizes an index value,
@@ -3927,131 +3928,87 @@ GetEndOffsetFromObj(
Tcl_WideInt *widePtr) /* Location filled in with an integer
* representing an index. */
{
- if (SetEndOffsetFromAny(NULL, objPtr) == TCL_OK) {
- Tcl_WideInt offset = objPtr->internalRep.wideValue;
+ Tcl_ObjIntRep *irPtr;
+ Tcl_WideInt offset = 0; /* Offset in the "end-offset" expression */
- if ((endValue ^ offset) < 0) {
- /* Different signs, sum cannot overflow */
- *widePtr = endValue + offset;
- } else if (endValue >= 0) {
- if (endValue < LLONG_MAX - offset) {
- *widePtr = endValue + offset;
- } else {
- *widePtr = LLONG_MAX;
- }
- } else {
- if (endValue > LLONG_MIN - offset) {
- *widePtr = endValue + offset;
- } else {
- *widePtr = LLONG_MIN;
- }
+ while ((irPtr = Tcl_FetchIntRep(objPtr, &endOffsetType)) == NULL) {
+ Tcl_ObjIntRep ir;
+ int length;
+ const char *bytes = TclGetStringFromObj(objPtr, &length);
+
+ if ((length < 3) || (length == 4)) {
+ /* Too short to be "end" or to be "end-$integer" */
+ return TCL_ERROR;
+ }
+ if ((*bytes != 'e') || (strncmp(bytes, "end", 3) != 0)) {
+ /* Value doesn't start with "end" */
+ return TCL_ERROR;
}
- return TCL_OK;
- }
- return TCL_ERROR;
-}
-/*
- *----------------------------------------------------------------------
- *
- * SetEndOffsetFromAny --
- *
- * Look for a string of the form "end[+-]offset" and convert it to an
- * internal representation holding the offset.
- *
- * Results:
- * Returns TCL_OK if ok, TCL_ERROR if the string was badly formed.
- *
- * Side effects:
- * If interp is not NULL, stores an error message in the interpreter
- * result.
- *
- *----------------------------------------------------------------------
- */
+ if (length > 4) {
+ ClientData cd;
+ int t;
-static int
-SetEndOffsetFromAny(
- Tcl_Interp *interp, /* Tcl interpreter or NULL */
- Tcl_Obj *objPtr) /* Pointer to the object to parse */
-{
- Tcl_WideInt offset; /* Offset in the "end-offset" expression */
- register const char *bytes; /* String rep of the object */
- int length; /* Length of the object's string rep */
+ /* Parse for the "end-..." or "end+..." formats */
- /*
- * If it's already the right type, we're fine.
- */
+ if ((bytes[3] != '-') && (bytes[3] != '+')) {
+ /* No operator where we need one */
+ return TCL_ERROR;
+ }
+ if (TclIsSpaceProc(bytes[4])) {
+ /* Space after + or - not permitted. */
+ return TCL_ERROR;
+ }
- if (objPtr->typePtr == &endOffsetType) {
- return TCL_OK;
- }
+ /* Parse the integer offset */
+ if (TCL_OK != TclParseNumber(NULL, objPtr, NULL,
+ bytes+4, length-4, NULL, TCL_PARSE_INTEGER_ONLY)) {
+ /* Not a recognized integer format */
+ return TCL_ERROR;
+ }
- /*
- * Check for a string rep of the right form.
- */
+ /* Got an integer offset; pull it from where parser left it. */
+ TclGetNumberFromObj(NULL, objPtr, &cd, &t);
- bytes = TclGetStringFromObj(objPtr, &length);
- if ((*bytes != 'e') || (strncmp(bytes, "end",
- (size_t)((length > 3) ? 3 : length)) != 0)) {
- if (interp != NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad index \"%s\": must be end?[+-]integer?", bytes));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", NULL);
+ if (t == TCL_NUMBER_BIG) {
+ /* Truncate to the signed wide range. */
+ if (mp_isneg((mp_int *)cd)) {
+ offset = (bytes[3] == '-') ? LLONG_MAX : LLONG_MIN;
+ } else {
+ offset = (bytes[3] == '-') ? LLONG_MIN : LLONG_MAX;
+ }
+ } else {
+ /* assert (t == TCL_NUMBER_INT); */
+ offset = (*(Tcl_WideInt *)cd);
+ if (bytes[3] == '-') {
+ offset = (offset == LLONG_MIN) ? LLONG_MAX : -offset;
+ }
+ }
}
- return TCL_ERROR;
- }
- /*
- * Convert the string rep.
- */
+ /* Success. Store the new internal rep. */
+ ir.wideValue = offset;
+ Tcl_StoreIntRep(objPtr, &endOffsetType, &ir);
+ }
- if (length <= 3) {
- offset = 0;
- } else if ((length > 4) && ((bytes[3] == '-') || (bytes[3] == '+'))) {
- /*
- * This is our limited string expression evaluator. Pass everything
- * after "end-" to TclParseNumber.
- */
+ offset = irPtr->wideValue;
- if (TclIsSpaceProc(bytes[4])) {
- goto badIndexFormat;
- }
- if (TclParseNumber(NULL, objPtr, NULL, bytes+4, length-4, NULL,
- TCL_PARSE_INTEGER_ONLY) != TCL_OK) {
- return TCL_ERROR;
- }
- if (objPtr->typePtr != &tclIntType) {
- goto badIndexFormat;
- }
- offset = objPtr->internalRep.wideValue;
- if (bytes[3] == '-') {
-
- /* TODO: Review overflow concerns here! */
- offset = -offset;
+ if ((endValue ^ offset) < 0) {
+ /* Different signs, sum cannot overflow */
+ *widePtr = endValue + offset;
+ } else if (endValue >= 0) {
+ if (endValue < LLONG_MAX - offset) {
+ *widePtr = endValue + offset;
+ } else {
+ *widePtr = LLONG_MAX;
}
} else {
- /*
- * Conversion failed. Report the error.
- */
-
- badIndexFormat:
- if (interp != NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad index \"%s\": must be end?[+-]integer?", bytes));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", NULL);
+ if (endValue > LLONG_MIN - offset) {
+ *widePtr = endValue + offset;
+ } else {
+ *widePtr = LLONG_MIN;
}
- return TCL_ERROR;
}
-
- /*
- * The conversion succeeded. Free the old internal rep and set the new
- * one.
- */
-
- TclFreeIntRep(objPtr);
- objPtr->internalRep.wideValue = offset;
- objPtr->typePtr = &endOffsetType;
-
return TCL_OK;
}
diff --git a/library/tzdata/Africa/Ceuta b/library/tzdata/Africa/Ceuta
index 057ca22..18af8c1 100644
--- a/library/tzdata/Africa/Ceuta
+++ b/library/tzdata/Africa/Ceuta
@@ -15,6 +15,7 @@ set TZData(:Africa/Ceuta) {
{-1316390400 3600 1 WEST}
{-1301270400 0 0 WET}
{-1293840000 0 0 WET}
+ {-94694400 0 0 WET}
{-81432000 3600 1 WEST}
{-71110800 0 0 WET}
{141264000 3600 1 WEST}
diff --git a/library/tzdata/America/Santiago b/library/tzdata/America/Santiago
index 67d5b5c..55212b9 100644
--- a/library/tzdata/America/Santiago
+++ b/library/tzdata/America/Santiago
@@ -124,166 +124,166 @@ set TZData(:America/Santiago) {
{1502596800 -10800 1 -04}
{1526180400 -14400 0 -04}
{1534046400 -10800 1 -04}
- {1557630000 -14400 0 -04}
- {1565496000 -10800 1 -04}
- {1589079600 -14400 0 -04}
- {1596945600 -10800 1 -04}
- {1620529200 -14400 0 -04}
- {1629000000 -10800 1 -04}
- {1652583600 -14400 0 -04}
- {1660449600 -10800 1 -04}
- {1684033200 -14400 0 -04}
- {1691899200 -10800 1 -04}
- {1715482800 -14400 0 -04}
- {1723348800 -10800 1 -04}
- {1746932400 -14400 0 -04}
- {1754798400 -10800 1 -04}
- {1778382000 -14400 0 -04}
- {1786248000 -10800 1 -04}
- {1809831600 -14400 0 -04}
- {1818302400 -10800 1 -04}
- {1841886000 -14400 0 -04}
- {1849752000 -10800 1 -04}
- {1873335600 -14400 0 -04}
- {1881201600 -10800 1 -04}
- {1904785200 -14400 0 -04}
- {1912651200 -10800 1 -04}
- {1936234800 -14400 0 -04}
- {1944100800 -10800 1 -04}
- {1967684400 -14400 0 -04}
- {1976155200 -10800 1 -04}
- {1999738800 -14400 0 -04}
- {2007604800 -10800 1 -04}
- {2031188400 -14400 0 -04}
- {2039054400 -10800 1 -04}
- {2062638000 -14400 0 -04}
- {2070504000 -10800 1 -04}
- {2094087600 -14400 0 -04}
- {2101953600 -10800 1 -04}
- {2125537200 -14400 0 -04}
- {2133403200 -10800 1 -04}
- {2156986800 -14400 0 -04}
- {2165457600 -10800 1 -04}
- {2189041200 -14400 0 -04}
- {2196907200 -10800 1 -04}
- {2220490800 -14400 0 -04}
- {2228356800 -10800 1 -04}
- {2251940400 -14400 0 -04}
- {2259806400 -10800 1 -04}
- {2283390000 -14400 0 -04}
- {2291256000 -10800 1 -04}
- {2314839600 -14400 0 -04}
- {2322705600 -10800 1 -04}
- {2346894000 -14400 0 -04}
- {2354760000 -10800 1 -04}
- {2378343600 -14400 0 -04}
- {2386209600 -10800 1 -04}
- {2409793200 -14400 0 -04}
- {2417659200 -10800 1 -04}
- {2441242800 -14400 0 -04}
- {2449108800 -10800 1 -04}
- {2472692400 -14400 0 -04}
- {2480558400 -10800 1 -04}
- {2504142000 -14400 0 -04}
- {2512612800 -10800 1 -04}
- {2536196400 -14400 0 -04}
- {2544062400 -10800 1 -04}
- {2567646000 -14400 0 -04}
- {2575512000 -10800 1 -04}
- {2599095600 -14400 0 -04}
- {2606961600 -10800 1 -04}
- {2630545200 -14400 0 -04}
- {2638411200 -10800 1 -04}
- {2661994800 -14400 0 -04}
- {2669860800 -10800 1 -04}
- {2693444400 -14400 0 -04}
- {2701915200 -10800 1 -04}
- {2725498800 -14400 0 -04}
- {2733364800 -10800 1 -04}
- {2756948400 -14400 0 -04}
- {2764814400 -10800 1 -04}
- {2788398000 -14400 0 -04}
- {2796264000 -10800 1 -04}
- {2819847600 -14400 0 -04}
- {2827713600 -10800 1 -04}
- {2851297200 -14400 0 -04}
- {2859768000 -10800 1 -04}
- {2883351600 -14400 0 -04}
- {2891217600 -10800 1 -04}
- {2914801200 -14400 0 -04}
- {2922667200 -10800 1 -04}
- {2946250800 -14400 0 -04}
- {2954116800 -10800 1 -04}
- {2977700400 -14400 0 -04}
- {2985566400 -10800 1 -04}
- {3009150000 -14400 0 -04}
- {3017016000 -10800 1 -04}
- {3040599600 -14400 0 -04}
- {3049070400 -10800 1 -04}
- {3072654000 -14400 0 -04}
- {3080520000 -10800 1 -04}
- {3104103600 -14400 0 -04}
- {3111969600 -10800 1 -04}
- {3135553200 -14400 0 -04}
- {3143419200 -10800 1 -04}
- {3167002800 -14400 0 -04}
- {3174868800 -10800 1 -04}
- {3198452400 -14400 0 -04}
- {3206318400 -10800 1 -04}
- {3230506800 -14400 0 -04}
- {3238372800 -10800 1 -04}
- {3261956400 -14400 0 -04}
- {3269822400 -10800 1 -04}
- {3293406000 -14400 0 -04}
- {3301272000 -10800 1 -04}
- {3324855600 -14400 0 -04}
- {3332721600 -10800 1 -04}
- {3356305200 -14400 0 -04}
- {3364171200 -10800 1 -04}
- {3387754800 -14400 0 -04}
- {3396225600 -10800 1 -04}
- {3419809200 -14400 0 -04}
- {3427675200 -10800 1 -04}
- {3451258800 -14400 0 -04}
- {3459124800 -10800 1 -04}
- {3482708400 -14400 0 -04}
- {3490574400 -10800 1 -04}
- {3514158000 -14400 0 -04}
- {3522024000 -10800 1 -04}
- {3545607600 -14400 0 -04}
- {3553473600 -10800 1 -04}
- {3577057200 -14400 0 -04}
- {3585528000 -10800 1 -04}
- {3609111600 -14400 0 -04}
- {3616977600 -10800 1 -04}
- {3640561200 -14400 0 -04}
- {3648427200 -10800 1 -04}
- {3672010800 -14400 0 -04}
- {3679876800 -10800 1 -04}
- {3703460400 -14400 0 -04}
- {3711326400 -10800 1 -04}
- {3734910000 -14400 0 -04}
- {3743380800 -10800 1 -04}
- {3766964400 -14400 0 -04}
- {3774830400 -10800 1 -04}
- {3798414000 -14400 0 -04}
- {3806280000 -10800 1 -04}
- {3829863600 -14400 0 -04}
- {3837729600 -10800 1 -04}
- {3861313200 -14400 0 -04}
- {3869179200 -10800 1 -04}
- {3892762800 -14400 0 -04}
- {3900628800 -10800 1 -04}
- {3924212400 -14400 0 -04}
- {3932683200 -10800 1 -04}
- {3956266800 -14400 0 -04}
- {3964132800 -10800 1 -04}
- {3987716400 -14400 0 -04}
- {3995582400 -10800 1 -04}
- {4019166000 -14400 0 -04}
- {4027032000 -10800 1 -04}
- {4050615600 -14400 0 -04}
- {4058481600 -10800 1 -04}
- {4082065200 -14400 0 -04}
- {4089931200 -10800 1 -04}
+ {1554606000 -14400 0 -04}
+ {1567915200 -10800 1 -04}
+ {1586055600 -14400 0 -04}
+ {1599364800 -10800 1 -04}
+ {1617505200 -14400 0 -04}
+ {1630814400 -10800 1 -04}
+ {1648954800 -14400 0 -04}
+ {1662264000 -10800 1 -04}
+ {1680404400 -14400 0 -04}
+ {1693713600 -10800 1 -04}
+ {1712458800 -14400 0 -04}
+ {1725768000 -10800 1 -04}
+ {1743908400 -14400 0 -04}
+ {1757217600 -10800 1 -04}
+ {1775358000 -14400 0 -04}
+ {1788667200 -10800 1 -04}
+ {1806807600 -14400 0 -04}
+ {1820116800 -10800 1 -04}
+ {1838257200 -14400 0 -04}
+ {1851566400 -10800 1 -04}
+ {1870311600 -14400 0 -04}
+ {1883016000 -10800 1 -04}
+ {1901761200 -14400 0 -04}
+ {1915070400 -10800 1 -04}
+ {1933210800 -14400 0 -04}
+ {1946520000 -10800 1 -04}
+ {1964660400 -14400 0 -04}
+ {1977969600 -10800 1 -04}
+ {1996110000 -14400 0 -04}
+ {2009419200 -10800 1 -04}
+ {2027559600 -14400 0 -04}
+ {2040868800 -10800 1 -04}
+ {2059614000 -14400 0 -04}
+ {2072318400 -10800 1 -04}
+ {2091063600 -14400 0 -04}
+ {2104372800 -10800 1 -04}
+ {2122513200 -14400 0 -04}
+ {2135822400 -10800 1 -04}
+ {2153962800 -14400 0 -04}
+ {2167272000 -10800 1 -04}
+ {2185412400 -14400 0 -04}
+ {2198721600 -10800 1 -04}
+ {2217466800 -14400 0 -04}
+ {2230171200 -10800 1 -04}
+ {2248916400 -14400 0 -04}
+ {2262225600 -10800 1 -04}
+ {2280366000 -14400 0 -04}
+ {2293675200 -10800 1 -04}
+ {2311815600 -14400 0 -04}
+ {2325124800 -10800 1 -04}
+ {2343265200 -14400 0 -04}
+ {2356574400 -10800 1 -04}
+ {2374714800 -14400 0 -04}
+ {2388024000 -10800 1 -04}
+ {2406769200 -14400 0 -04}
+ {2419473600 -10800 1 -04}
+ {2438218800 -14400 0 -04}
+ {2451528000 -10800 1 -04}
+ {2469668400 -14400 0 -04}
+ {2482977600 -10800 1 -04}
+ {2501118000 -14400 0 -04}
+ {2514427200 -10800 1 -04}
+ {2532567600 -14400 0 -04}
+ {2545876800 -10800 1 -04}
+ {2564017200 -14400 0 -04}
+ {2577326400 -10800 1 -04}
+ {2596071600 -14400 0 -04}
+ {2609380800 -10800 1 -04}
+ {2627521200 -14400 0 -04}
+ {2640830400 -10800 1 -04}
+ {2658970800 -14400 0 -04}
+ {2672280000 -10800 1 -04}
+ {2690420400 -14400 0 -04}
+ {2703729600 -10800 1 -04}
+ {2721870000 -14400 0 -04}
+ {2735179200 -10800 1 -04}
+ {2753924400 -14400 0 -04}
+ {2766628800 -10800 1 -04}
+ {2785374000 -14400 0 -04}
+ {2798683200 -10800 1 -04}
+ {2816823600 -14400 0 -04}
+ {2830132800 -10800 1 -04}
+ {2848273200 -14400 0 -04}
+ {2861582400 -10800 1 -04}
+ {2879722800 -14400 0 -04}
+ {2893032000 -10800 1 -04}
+ {2911172400 -14400 0 -04}
+ {2924481600 -10800 1 -04}
+ {2943226800 -14400 0 -04}
+ {2955931200 -10800 1 -04}
+ {2974676400 -14400 0 -04}
+ {2987985600 -10800 1 -04}
+ {3006126000 -14400 0 -04}
+ {3019435200 -10800 1 -04}
+ {3037575600 -14400 0 -04}
+ {3050884800 -10800 1 -04}
+ {3069025200 -14400 0 -04}
+ {3082334400 -10800 1 -04}
+ {3101079600 -14400 0 -04}
+ {3113784000 -10800 1 -04}
+ {3132529200 -14400 0 -04}
+ {3145838400 -10800 1 -04}
+ {3163978800 -14400 0 -04}
+ {3177288000 -10800 1 -04}
+ {3195428400 -14400 0 -04}
+ {3208737600 -10800 1 -04}
+ {3226878000 -14400 0 -04}
+ {3240187200 -10800 1 -04}
+ {3258327600 -14400 0 -04}
+ {3271636800 -10800 1 -04}
+ {3290382000 -14400 0 -04}
+ {3303086400 -10800 1 -04}
+ {3321831600 -14400 0 -04}
+ {3335140800 -10800 1 -04}
+ {3353281200 -14400 0 -04}
+ {3366590400 -10800 1 -04}
+ {3384730800 -14400 0 -04}
+ {3398040000 -10800 1 -04}
+ {3416180400 -14400 0 -04}
+ {3429489600 -10800 1 -04}
+ {3447630000 -14400 0 -04}
+ {3460939200 -10800 1 -04}
+ {3479684400 -14400 0 -04}
+ {3492993600 -10800 1 -04}
+ {3511134000 -14400 0 -04}
+ {3524443200 -10800 1 -04}
+ {3542583600 -14400 0 -04}
+ {3555892800 -10800 1 -04}
+ {3574033200 -14400 0 -04}
+ {3587342400 -10800 1 -04}
+ {3605482800 -14400 0 -04}
+ {3618792000 -10800 1 -04}
+ {3637537200 -14400 0 -04}
+ {3650241600 -10800 1 -04}
+ {3668986800 -14400 0 -04}
+ {3682296000 -10800 1 -04}
+ {3700436400 -14400 0 -04}
+ {3713745600 -10800 1 -04}
+ {3731886000 -14400 0 -04}
+ {3745195200 -10800 1 -04}
+ {3763335600 -14400 0 -04}
+ {3776644800 -10800 1 -04}
+ {3794785200 -14400 0 -04}
+ {3808094400 -10800 1 -04}
+ {3826839600 -14400 0 -04}
+ {3839544000 -10800 1 -04}
+ {3858289200 -14400 0 -04}
+ {3871598400 -10800 1 -04}
+ {3889738800 -14400 0 -04}
+ {3903048000 -10800 1 -04}
+ {3921188400 -14400 0 -04}
+ {3934497600 -10800 1 -04}
+ {3952638000 -14400 0 -04}
+ {3965947200 -10800 1 -04}
+ {3984692400 -14400 0 -04}
+ {3997396800 -10800 1 -04}
+ {4016142000 -14400 0 -04}
+ {4029451200 -10800 1 -04}
+ {4047591600 -14400 0 -04}
+ {4060900800 -10800 1 -04}
+ {4079041200 -14400 0 -04}
+ {4092350400 -10800 1 -04}
}
diff --git a/library/tzdata/Asia/Macau b/library/tzdata/Asia/Macau
index 76a00aa..cbafd0e 100644
--- a/library/tzdata/Asia/Macau
+++ b/library/tzdata/Asia/Macau
@@ -1,20 +1,56 @@
# created by tools/tclZIC.tcl - do not edit
set TZData(:Asia/Macau) {
- {-9223372036854775808 27260 0 LMT}
- {-1830412800 28800 0 CST}
+ {-9223372036854775808 27250 0 LMT}
+ {-2056692850 28800 0 CST}
+ {-884509200 32400 0 +09}
+ {-873280800 36000 1 +09}
+ {-855918000 32400 0 +09}
+ {-841744800 36000 1 +09}
+ {-828529200 32400 0 +10}
+ {-765363600 28800 0 CT}
+ {-747046800 32400 1 CDT}
+ {-733827600 28800 0 CST}
+ {-716461200 32400 1 CDT}
+ {-697021200 28800 0 CST}
+ {-683715600 32400 1 CDT}
+ {-667990800 28800 0 CST}
+ {-654771600 32400 1 CDT}
+ {-636627600 28800 0 CST}
+ {-623322000 32400 1 CDT}
+ {-605178000 28800 0 CST}
+ {-591872400 32400 1 CDT}
+ {-573642000 28800 0 CST}
+ {-559818000 32400 1 CDT}
+ {-541674000 28800 0 CST}
+ {-528368400 32400 1 CDT}
+ {-510224400 28800 0 CST}
+ {-498128400 32400 1 CDT}
+ {-478774800 28800 0 CST}
+ {-466678800 32400 1 CDT}
+ {-446720400 28800 0 CST}
+ {-435229200 32400 1 CDT}
+ {-415258200 28800 0 CST}
+ {-403158600 32400 1 CDT}
+ {-383808600 28800 0 CST}
+ {-371709000 32400 1 CDT}
+ {-352359000 28800 0 CST}
+ {-340259400 32400 1 CDT}
+ {-320909400 28800 0 CST}
+ {-308809800 32400 1 CDT}
+ {-288855000 28800 0 CST}
{-277360200 32400 1 CDT}
{-257405400 28800 0 CST}
{-245910600 32400 1 CDT}
{-225955800 28800 0 CST}
- {-214473600 32400 1 CDT}
+ {-213856200 32400 1 CDT}
{-194506200 28800 0 CST}
{-182406600 32400 1 CDT}
{-163056600 28800 0 CST}
- {-150969600 32400 1 CDT}
- {-131619600 28800 0 CST}
+ {-148537800 32400 1 CDT}
+ {-132820200 28800 0 CST}
{-117088200 32400 1 CDT}
- {-101367000 28800 0 CST}
+ {-101370600 28800 0 CST}
{-85638600 32400 1 CDT}
{-69312600 28800 0 CST}
{-53584200 32400 1 CDT}
@@ -25,22 +61,16 @@ set TZData(:Asia/Macau) {
{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}
+ {72214200 32400 1 CDT}
+ {88540200 28800 0 CST}
+ {104268600 32400 1 CDT}
+ {119989800 28800 0 CST}
+ {126041400 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}
+ {295385400 32400 1 CDT}
+ {309292200 28800 0 CST}
}
diff --git a/library/tzdata/Asia/Manila b/library/tzdata/Asia/Manila
index b7ffa7a..6eb1db3 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 +08}
- {-1046678400 32400 1 +08}
- {-1038733200 28800 0 +08}
- {-873273600 32400 0 +09}
- {-794221200 28800 0 +08}
- {-496224000 32400 1 +08}
- {-489315600 28800 0 +08}
- {259344000 32400 1 +08}
- {275151600 28800 0 +08}
+ {-2229321840 28800 0 PST}
+ {-1046678400 32400 1 PDT}
+ {-1038733200 28800 0 PST}
+ {-873273600 32400 0 JST}
+ {-794221200 28800 0 PST}
+ {-496224000 32400 1 PDT}
+ {-489315600 28800 0 PST}
+ {259344000 32400 1 PDT}
+ {275151600 28800 0 PST}
}
diff --git a/library/tzdata/Asia/Pyongyang b/library/tzdata/Asia/Pyongyang
index 5746472..5351736 100644
--- a/library/tzdata/Asia/Pyongyang
+++ b/library/tzdata/Asia/Pyongyang
@@ -6,5 +6,5 @@ set TZData(:Asia/Pyongyang) {
{-1830414600 32400 0 JST}
{-768646800 32400 0 KST}
{1439564400 30600 0 KST}
- {1525447800 32400 0 KST}
+ {1525446000 32400 0 KST}
}
diff --git a/library/tzdata/Asia/Shanghai b/library/tzdata/Asia/Shanghai
index ff2d2b5..66bc4339 100644
--- a/library/tzdata/Asia/Shanghai
+++ b/library/tzdata/Asia/Shanghai
@@ -3,21 +3,30 @@
set TZData(:Asia/Shanghai) {
{-9223372036854775808 29143 0 LMT}
{-2177481943 28800 0 CST}
- {-933494400 32400 1 CDT}
- {-923130000 28800 0 CST}
- {-908784000 32400 1 CDT}
- {-891594000 28800 0 CST}
- {-662716800 28800 0 CST}
- {515520000 32400 1 CDT}
- {527007600 28800 0 CST}
- {545155200 32400 1 CDT}
- {558457200 28800 0 CST}
- {576604800 32400 1 CDT}
- {589906800 28800 0 CST}
- {608659200 32400 1 CDT}
- {621961200 28800 0 CST}
- {640108800 32400 1 CDT}
- {653410800 28800 0 CST}
- {671558400 32400 1 CDT}
- {684860400 28800 0 CST}
+ {-933667200 32400 1 CDT}
+ {-922093200 28800 0 CST}
+ {-908870400 32400 1 CDT}
+ {-888829200 28800 0 CST}
+ {-881049600 32400 1 CDT}
+ {-767869200 28800 0 CST}
+ {-745833600 32400 1 CDT}
+ {-733827600 28800 0 CST}
+ {-716889600 32400 1 CDT}
+ {-699613200 28800 0 CST}
+ {-683884800 32400 1 CDT}
+ {-670669200 28800 0 CST}
+ {-652348800 32400 1 CDT}
+ {-650016000 28800 0 CST}
+ {515527200 32400 1 CDT}
+ {527014800 28800 0 CST}
+ {545162400 32400 1 CDT}
+ {558464400 28800 0 CST}
+ {577216800 32400 1 CDT}
+ {589914000 28800 0 CST}
+ {608666400 32400 1 CDT}
+ {621968400 28800 0 CST}
+ {640116000 32400 1 CDT}
+ {653418000 28800 0 CST}
+ {671565600 32400 1 CDT}
+ {684867600 28800 0 CST}
}
diff --git a/library/tzdata/Asia/Tokyo b/library/tzdata/Asia/Tokyo
index 790df0a..cc7a857 100644
--- a/library/tzdata/Asia/Tokyo
+++ b/library/tzdata/Asia/Tokyo
@@ -4,11 +4,11 @@ set TZData(:Asia/Tokyo) {
{-9223372036854775808 33539 0 LMT}
{-2587712400 32400 0 JST}
{-683802000 36000 1 JDT}
- {-672314400 32400 0 JST}
+ {-672310800 32400 0 JST}
{-654771600 36000 1 JDT}
- {-640864800 32400 0 JST}
+ {-640861200 32400 0 JST}
{-620298000 36000 1 JDT}
- {-609415200 32400 0 JST}
+ {-609411600 32400 0 JST}
{-588848400 36000 1 JDT}
- {-577965600 32400 0 JST}
+ {-577962000 32400 0 JST}
}
diff --git a/library/tzdata/Europe/Volgograd b/library/tzdata/Europe/Volgograd
index 05e1044..3938683 100644
--- a/library/tzdata/Europe/Volgograd
+++ b/library/tzdata/Europe/Volgograd
@@ -68,4 +68,5 @@ set TZData(:Europe/Volgograd) {
{1288479600 10800 0 +03}
{1301180400 14400 0 +04}
{1414274400 10800 0 +03}
+ {1540681200 14400 0 +04}
}
diff --git a/library/tzdata/Pacific/Easter b/library/tzdata/Pacific/Easter
index a087cd0..7a8d525 100644
--- a/library/tzdata/Pacific/Easter
+++ b/library/tzdata/Pacific/Easter
@@ -103,166 +103,166 @@ set TZData(:Pacific/Easter) {
{1502596800 -18000 1 -06}
{1526180400 -21600 0 -06}
{1534046400 -18000 1 -06}
- {1557630000 -21600 0 -06}
- {1565496000 -18000 1 -06}
- {1589079600 -21600 0 -06}
- {1596945600 -18000 1 -06}
- {1620529200 -21600 0 -06}
- {1629000000 -18000 1 -06}
- {1652583600 -21600 0 -06}
- {1660449600 -18000 1 -06}
- {1684033200 -21600 0 -06}
- {1691899200 -18000 1 -06}
- {1715482800 -21600 0 -06}
- {1723348800 -18000 1 -06}
- {1746932400 -21600 0 -06}
- {1754798400 -18000 1 -06}
- {1778382000 -21600 0 -06}
- {1786248000 -18000 1 -06}
- {1809831600 -21600 0 -06}
- {1818302400 -18000 1 -06}
- {1841886000 -21600 0 -06}
- {1849752000 -18000 1 -06}
- {1873335600 -21600 0 -06}
- {1881201600 -18000 1 -06}
- {1904785200 -21600 0 -06}
- {1912651200 -18000 1 -06}
- {1936234800 -21600 0 -06}
- {1944100800 -18000 1 -06}
- {1967684400 -21600 0 -06}
- {1976155200 -18000 1 -06}
- {1999738800 -21600 0 -06}
- {2007604800 -18000 1 -06}
- {2031188400 -21600 0 -06}
- {2039054400 -18000 1 -06}
- {2062638000 -21600 0 -06}
- {2070504000 -18000 1 -06}
- {2094087600 -21600 0 -06}
- {2101953600 -18000 1 -06}
- {2125537200 -21600 0 -06}
- {2133403200 -18000 1 -06}
- {2156986800 -21600 0 -06}
- {2165457600 -18000 1 -06}
- {2189041200 -21600 0 -06}
- {2196907200 -18000 1 -06}
- {2220490800 -21600 0 -06}
- {2228356800 -18000 1 -06}
- {2251940400 -21600 0 -06}
- {2259806400 -18000 1 -06}
- {2283390000 -21600 0 -06}
- {2291256000 -18000 1 -06}
- {2314839600 -21600 0 -06}
- {2322705600 -18000 1 -06}
- {2346894000 -21600 0 -06}
- {2354760000 -18000 1 -06}
- {2378343600 -21600 0 -06}
- {2386209600 -18000 1 -06}
- {2409793200 -21600 0 -06}
- {2417659200 -18000 1 -06}
- {2441242800 -21600 0 -06}
- {2449108800 -18000 1 -06}
- {2472692400 -21600 0 -06}
- {2480558400 -18000 1 -06}
- {2504142000 -21600 0 -06}
- {2512612800 -18000 1 -06}
- {2536196400 -21600 0 -06}
- {2544062400 -18000 1 -06}
- {2567646000 -21600 0 -06}
- {2575512000 -18000 1 -06}
- {2599095600 -21600 0 -06}
- {2606961600 -18000 1 -06}
- {2630545200 -21600 0 -06}
- {2638411200 -18000 1 -06}
- {2661994800 -21600 0 -06}
- {2669860800 -18000 1 -06}
- {2693444400 -21600 0 -06}
- {2701915200 -18000 1 -06}
- {2725498800 -21600 0 -06}
- {2733364800 -18000 1 -06}
- {2756948400 -21600 0 -06}
- {2764814400 -18000 1 -06}
- {2788398000 -21600 0 -06}
- {2796264000 -18000 1 -06}
- {2819847600 -21600 0 -06}
- {2827713600 -18000 1 -06}
- {2851297200 -21600 0 -06}
- {2859768000 -18000 1 -06}
- {2883351600 -21600 0 -06}
- {2891217600 -18000 1 -06}
- {2914801200 -21600 0 -06}
- {2922667200 -18000 1 -06}
- {2946250800 -21600 0 -06}
- {2954116800 -18000 1 -06}
- {2977700400 -21600 0 -06}
- {2985566400 -18000 1 -06}
- {3009150000 -21600 0 -06}
- {3017016000 -18000 1 -06}
- {3040599600 -21600 0 -06}
- {3049070400 -18000 1 -06}
- {3072654000 -21600 0 -06}
- {3080520000 -18000 1 -06}
- {3104103600 -21600 0 -06}
- {3111969600 -18000 1 -06}
- {3135553200 -21600 0 -06}
- {3143419200 -18000 1 -06}
- {3167002800 -21600 0 -06}
- {3174868800 -18000 1 -06}
- {3198452400 -21600 0 -06}
- {3206318400 -18000 1 -06}
- {3230506800 -21600 0 -06}
- {3238372800 -18000 1 -06}
- {3261956400 -21600 0 -06}
- {3269822400 -18000 1 -06}
- {3293406000 -21600 0 -06}
- {3301272000 -18000 1 -06}
- {3324855600 -21600 0 -06}
- {3332721600 -18000 1 -06}
- {3356305200 -21600 0 -06}
- {3364171200 -18000 1 -06}
- {3387754800 -21600 0 -06}
- {3396225600 -18000 1 -06}
- {3419809200 -21600 0 -06}
- {3427675200 -18000 1 -06}
- {3451258800 -21600 0 -06}
- {3459124800 -18000 1 -06}
- {3482708400 -21600 0 -06}
- {3490574400 -18000 1 -06}
- {3514158000 -21600 0 -06}
- {3522024000 -18000 1 -06}
- {3545607600 -21600 0 -06}
- {3553473600 -18000 1 -06}
- {3577057200 -21600 0 -06}
- {3585528000 -18000 1 -06}
- {3609111600 -21600 0 -06}
- {3616977600 -18000 1 -06}
- {3640561200 -21600 0 -06}
- {3648427200 -18000 1 -06}
- {3672010800 -21600 0 -06}
- {3679876800 -18000 1 -06}
- {3703460400 -21600 0 -06}
- {3711326400 -18000 1 -06}
- {3734910000 -21600 0 -06}
- {3743380800 -18000 1 -06}
- {3766964400 -21600 0 -06}
- {3774830400 -18000 1 -06}
- {3798414000 -21600 0 -06}
- {3806280000 -18000 1 -06}
- {3829863600 -21600 0 -06}
- {3837729600 -18000 1 -06}
- {3861313200 -21600 0 -06}
- {3869179200 -18000 1 -06}
- {3892762800 -21600 0 -06}
- {3900628800 -18000 1 -06}
- {3924212400 -21600 0 -06}
- {3932683200 -18000 1 -06}
- {3956266800 -21600 0 -06}
- {3964132800 -18000 1 -06}
- {3987716400 -21600 0 -06}
- {3995582400 -18000 1 -06}
- {4019166000 -21600 0 -06}
- {4027032000 -18000 1 -06}
- {4050615600 -21600 0 -06}
- {4058481600 -18000 1 -06}
- {4082065200 -21600 0 -06}
- {4089931200 -18000 1 -06}
+ {1554606000 -21600 0 -06}
+ {1567915200 -18000 1 -06}
+ {1586055600 -21600 0 -06}
+ {1599364800 -18000 1 -06}
+ {1617505200 -21600 0 -06}
+ {1630814400 -18000 1 -06}
+ {1648954800 -21600 0 -06}
+ {1662264000 -18000 1 -06}
+ {1680404400 -21600 0 -06}
+ {1693713600 -18000 1 -06}
+ {1712458800 -21600 0 -06}
+ {1725768000 -18000 1 -06}
+ {1743908400 -21600 0 -06}
+ {1757217600 -18000 1 -06}
+ {1775358000 -21600 0 -06}
+ {1788667200 -18000 1 -06}
+ {1806807600 -21600 0 -06}
+ {1820116800 -18000 1 -06}
+ {1838257200 -21600 0 -06}
+ {1851566400 -18000 1 -06}
+ {1870311600 -21600 0 -06}
+ {1883016000 -18000 1 -06}
+ {1901761200 -21600 0 -06}
+ {1915070400 -18000 1 -06}
+ {1933210800 -21600 0 -06}
+ {1946520000 -18000 1 -06}
+ {1964660400 -21600 0 -06}
+ {1977969600 -18000 1 -06}
+ {1996110000 -21600 0 -06}
+ {2009419200 -18000 1 -06}
+ {2027559600 -21600 0 -06}
+ {2040868800 -18000 1 -06}
+ {2059614000 -21600 0 -06}
+ {2072318400 -18000 1 -06}
+ {2091063600 -21600 0 -06}
+ {2104372800 -18000 1 -06}
+ {2122513200 -21600 0 -06}
+ {2135822400 -18000 1 -06}
+ {2153962800 -21600 0 -06}
+ {2167272000 -18000 1 -06}
+ {2185412400 -21600 0 -06}
+ {2198721600 -18000 1 -06}
+ {2217466800 -21600 0 -06}
+ {2230171200 -18000 1 -06}
+ {2248916400 -21600 0 -06}
+ {2262225600 -18000 1 -06}
+ {2280366000 -21600 0 -06}
+ {2293675200 -18000 1 -06}
+ {2311815600 -21600 0 -06}
+ {2325124800 -18000 1 -06}
+ {2343265200 -21600 0 -06}
+ {2356574400 -18000 1 -06}
+ {2374714800 -21600 0 -06}
+ {2388024000 -18000 1 -06}
+ {2406769200 -21600 0 -06}
+ {2419473600 -18000 1 -06}
+ {2438218800 -21600 0 -06}
+ {2451528000 -18000 1 -06}
+ {2469668400 -21600 0 -06}
+ {2482977600 -18000 1 -06}
+ {2501118000 -21600 0 -06}
+ {2514427200 -18000 1 -06}
+ {2532567600 -21600 0 -06}
+ {2545876800 -18000 1 -06}
+ {2564017200 -21600 0 -06}
+ {2577326400 -18000 1 -06}
+ {2596071600 -21600 0 -06}
+ {2609380800 -18000 1 -06}
+ {2627521200 -21600 0 -06}
+ {2640830400 -18000 1 -06}
+ {2658970800 -21600 0 -06}
+ {2672280000 -18000 1 -06}
+ {2690420400 -21600 0 -06}
+ {2703729600 -18000 1 -06}
+ {2721870000 -21600 0 -06}
+ {2735179200 -18000 1 -06}
+ {2753924400 -21600 0 -06}
+ {2766628800 -18000 1 -06}
+ {2785374000 -21600 0 -06}
+ {2798683200 -18000 1 -06}
+ {2816823600 -21600 0 -06}
+ {2830132800 -18000 1 -06}
+ {2848273200 -21600 0 -06}
+ {2861582400 -18000 1 -06}
+ {2879722800 -21600 0 -06}
+ {2893032000 -18000 1 -06}
+ {2911172400 -21600 0 -06}
+ {2924481600 -18000 1 -06}
+ {2943226800 -21600 0 -06}
+ {2955931200 -18000 1 -06}
+ {2974676400 -21600 0 -06}
+ {2987985600 -18000 1 -06}
+ {3006126000 -21600 0 -06}
+ {3019435200 -18000 1 -06}
+ {3037575600 -21600 0 -06}
+ {3050884800 -18000 1 -06}
+ {3069025200 -21600 0 -06}
+ {3082334400 -18000 1 -06}
+ {3101079600 -21600 0 -06}
+ {3113784000 -18000 1 -06}
+ {3132529200 -21600 0 -06}
+ {3145838400 -18000 1 -06}
+ {3163978800 -21600 0 -06}
+ {3177288000 -18000 1 -06}
+ {3195428400 -21600 0 -06}
+ {3208737600 -18000 1 -06}
+ {3226878000 -21600 0 -06}
+ {3240187200 -18000 1 -06}
+ {3258327600 -21600 0 -06}
+ {3271636800 -18000 1 -06}
+ {3290382000 -21600 0 -06}
+ {3303086400 -18000 1 -06}
+ {3321831600 -21600 0 -06}
+ {3335140800 -18000 1 -06}
+ {3353281200 -21600 0 -06}
+ {3366590400 -18000 1 -06}
+ {3384730800 -21600 0 -06}
+ {3398040000 -18000 1 -06}
+ {3416180400 -21600 0 -06}
+ {3429489600 -18000 1 -06}
+ {3447630000 -21600 0 -06}
+ {3460939200 -18000 1 -06}
+ {3479684400 -21600 0 -06}
+ {3492993600 -18000 1 -06}
+ {3511134000 -21600 0 -06}
+ {3524443200 -18000 1 -06}
+ {3542583600 -21600 0 -06}
+ {3555892800 -18000 1 -06}
+ {3574033200 -21600 0 -06}
+ {3587342400 -18000 1 -06}
+ {3605482800 -21600 0 -06}
+ {3618792000 -18000 1 -06}
+ {3637537200 -21600 0 -06}
+ {3650241600 -18000 1 -06}
+ {3668986800 -21600 0 -06}
+ {3682296000 -18000 1 -06}
+ {3700436400 -21600 0 -06}
+ {3713745600 -18000 1 -06}
+ {3731886000 -21600 0 -06}
+ {3745195200 -18000 1 -06}
+ {3763335600 -21600 0 -06}
+ {3776644800 -18000 1 -06}
+ {3794785200 -21600 0 -06}
+ {3808094400 -18000 1 -06}
+ {3826839600 -21600 0 -06}
+ {3839544000 -18000 1 -06}
+ {3858289200 -21600 0 -06}
+ {3871598400 -18000 1 -06}
+ {3889738800 -21600 0 -06}
+ {3903048000 -18000 1 -06}
+ {3921188400 -21600 0 -06}
+ {3934497600 -18000 1 -06}
+ {3952638000 -21600 0 -06}
+ {3965947200 -18000 1 -06}
+ {3984692400 -21600 0 -06}
+ {3997396800 -18000 1 -06}
+ {4016142000 -21600 0 -06}
+ {4029451200 -18000 1 -06}
+ {4047591600 -21600 0 -06}
+ {4060900800 -18000 1 -06}
+ {4079041200 -21600 0 -06}
+ {4092350400 -18000 1 -06}
}
diff --git a/library/tzdata/Pacific/Fiji b/library/tzdata/Pacific/Fiji
index 610c191..b05985c 100644
--- a/library/tzdata/Pacific/Fiji
+++ b/library/tzdata/Pacific/Fiji
@@ -26,7 +26,7 @@ set TZData(:Pacific/Fiji) {
{1509804000 46800 1 +12}
{1515852000 43200 0 +12}
{1541253600 46800 1 +12}
- {1547906400 43200 0 +12}
+ {1547301600 43200 0 +12}
{1572703200 46800 1 +12}
{1579356000 43200 0 +12}
{1604152800 46800 1 +12}
@@ -48,7 +48,7 @@ set TZData(:Pacific/Fiji) {
{1856959200 46800 1 +12}
{1863007200 43200 0 +12}
{1888408800 46800 1 +12}
- {1895061600 43200 0 +12}
+ {1894456800 43200 0 +12}
{1919858400 46800 1 +12}
{1926511200 43200 0 +12}
{1951308000 46800 1 +12}
@@ -60,7 +60,7 @@ set TZData(:Pacific/Fiji) {
{2046261600 46800 1 +12}
{2052309600 43200 0 +12}
{2077711200 46800 1 +12}
- {2084364000 43200 0 +12}
+ {2083759200 43200 0 +12}
{2109160800 46800 1 +12}
{2115813600 43200 0 +12}
{2140610400 46800 1 +12}
@@ -70,7 +70,7 @@ set TZData(:Pacific/Fiji) {
{2204114400 46800 1 +12}
{2210162400 43200 0 +12}
{2235564000 46800 1 +12}
- {2242216800 43200 0 +12}
+ {2241612000 43200 0 +12}
{2267013600 46800 1 +12}
{2273666400 43200 0 +12}
{2298463200 46800 1 +12}
@@ -82,7 +82,7 @@ set TZData(:Pacific/Fiji) {
{2393416800 46800 1 +12}
{2399464800 43200 0 +12}
{2424866400 46800 1 +12}
- {2431519200 43200 0 +12}
+ {2430914400 43200 0 +12}
{2456316000 46800 1 +12}
{2462968800 43200 0 +12}
{2487765600 46800 1 +12}
@@ -104,7 +104,7 @@ set TZData(:Pacific/Fiji) {
{2740572000 46800 1 +12}
{2746620000 43200 0 +12}
{2772021600 46800 1 +12}
- {2778674400 43200 0 +12}
+ {2778069600 43200 0 +12}
{2803471200 46800 1 +12}
{2810124000 43200 0 +12}
{2834920800 46800 1 +12}
@@ -116,7 +116,7 @@ set TZData(:Pacific/Fiji) {
{2929874400 46800 1 +12}
{2935922400 43200 0 +12}
{2961324000 46800 1 +12}
- {2967976800 43200 0 +12}
+ {2967372000 43200 0 +12}
{2992773600 46800 1 +12}
{2999426400 43200 0 +12}
{3024223200 46800 1 +12}
@@ -126,7 +126,7 @@ set TZData(:Pacific/Fiji) {
{3087727200 46800 1 +12}
{3093775200 43200 0 +12}
{3119176800 46800 1 +12}
- {3125829600 43200 0 +12}
+ {3125224800 43200 0 +12}
{3150626400 46800 1 +12}
{3157279200 43200 0 +12}
{3182076000 46800 1 +12}
@@ -138,7 +138,7 @@ set TZData(:Pacific/Fiji) {
{3277029600 46800 1 +12}
{3283077600 43200 0 +12}
{3308479200 46800 1 +12}
- {3315132000 43200 0 +12}
+ {3314527200 43200 0 +12}
{3339928800 46800 1 +12}
{3346581600 43200 0 +12}
{3371378400 46800 1 +12}
@@ -160,7 +160,7 @@ set TZData(:Pacific/Fiji) {
{3624184800 46800 1 +12}
{3630232800 43200 0 +12}
{3655634400 46800 1 +12}
- {3662287200 43200 0 +12}
+ {3661682400 43200 0 +12}
{3687084000 46800 1 +12}
{3693736800 43200 0 +12}
{3718533600 46800 1 +12}
@@ -172,7 +172,7 @@ set TZData(:Pacific/Fiji) {
{3813487200 46800 1 +12}
{3819535200 43200 0 +12}
{3844936800 46800 1 +12}
- {3851589600 43200 0 +12}
+ {3850984800 43200 0 +12}
{3876386400 46800 1 +12}
{3883039200 43200 0 +12}
{3907836000 46800 1 +12}
@@ -182,7 +182,7 @@ set TZData(:Pacific/Fiji) {
{3971340000 46800 1 +12}
{3977388000 43200 0 +12}
{4002789600 46800 1 +12}
- {4009442400 43200 0 +12}
+ {4008837600 43200 0 +12}
{4034239200 46800 1 +12}
{4040892000 43200 0 +12}
{4065688800 46800 1 +12}
diff --git a/libtommath/README.md b/libtommath/README.md
index 3bc491d..0e57a4d 100644
--- a/libtommath/README.md
+++ b/libtommath/README.md
@@ -4,9 +4,11 @@ This is the git repository for [LibTomMath](http://www.libtom.net/LibTomMath/),
## Build Status
-master - [![Build Status - master](https://travis-ci.org/libtom/libtommath.png?branch=master)](https://travis-ci.org/libtom/libtommath)
+master: [![Build Status](https://api.travis-ci.org/libtom/libtommath.png?branch=master)](https://travis-ci.org/libtom/libtommath)
-develop - [![Build Status - develop](https://travis-ci.org/libtom/libtommath.png?branch=develop)](https://travis-ci.org/libtom/libtommath)
+develop: [![Build Status](https://api.travis-ci.org/libtom/libtommath.png?branch=develop)](https://travis-ci.org/libtom/libtommath)
+
+API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtommath/)
## Summary
diff --git a/libtommath/bn_error.c b/libtommath/bn_error.c
index 7e816bf..05b398a 100644
--- a/libtommath/bn_error.c
+++ b/libtommath/bn_error.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_ERROR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const struct {
diff --git a/libtommath/bn_fast_mp_invmod.c b/libtommath/bn_fast_mp_invmod.c
index 6be44f8..be1a810 100644
--- a/libtommath/bn_fast_mp_invmod.c
+++ b/libtommath/bn_fast_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the modular inverse via binary extended euclidean algorithm,
@@ -140,6 +138,14 @@ top:
goto LBL_ERR;
}
}
+
+ /* too big */
+ while (mp_cmp_mag(&D, b) != MP_LT) {
+ if ((res = mp_sub(&D, b, &D)) != MP_OKAY) {
+ goto LBL_ERR;
+ }
+ }
+
mp_exch(&D, c);
c->sign = neg;
res = MP_OKAY;
diff --git a/libtommath/bn_fast_mp_montgomery_reduce.c b/libtommath/bn_fast_mp_montgomery_reduce.c
index 8f91196..3454f58 100644
--- a/libtommath/bn_fast_mp_montgomery_reduce.c
+++ b/libtommath/bn_fast_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction
diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c
index e542c2e..1da314c 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_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Fast (comba) multiplier
diff --git a/libtommath/bn_fast_s_mp_mul_high_digs.c b/libtommath/bn_fast_s_mp_mul_high_digs.c
index 6ea8a6c..45d30ca 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_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* this is a modified version of fast_s_mul_digs that only produces
diff --git a/libtommath/bn_fast_s_mp_sqr.c b/libtommath/bn_fast_s_mp_sqr.c
index 1050121..3614a44 100644
--- a/libtommath/bn_fast_s_mp_sqr.c
+++ b/libtommath/bn_fast_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* the jist of squaring...
diff --git a/libtommath/bn_mp_2expt.c b/libtommath/bn_mp_2expt.c
index 5333d48..6737a55 100644
--- a/libtommath/bn_mp_2expt.c
+++ b/libtommath/bn_mp_2expt.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_2EXPT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes a = 2**b
diff --git a/libtommath/bn_mp_abs.c b/libtommath/bn_mp_abs.c
index 9b6bcec..7c60014 100644
--- a/libtommath/bn_mp_abs.c
+++ b/libtommath/bn_mp_abs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ABS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = |a|
diff --git a/libtommath/bn_mp_add.c b/libtommath/bn_mp_add.c
index d31d5a0..af53713 100644
--- a/libtommath/bn_mp_add.c
+++ b/libtommath/bn_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level addition (handles signs) */
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c
index e5ede1f..69cbd12 100644
--- a/libtommath/bn_mp_add_d.c
+++ b/libtommath/bn_mp_add_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit addition */
diff --git a/libtommath/bn_mp_addmod.c b/libtommath/bn_mp_addmod.c
index 0d612c3..b7907e5 100644
--- a/libtommath/bn_mp_addmod.c
+++ b/libtommath/bn_mp_addmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADDMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a + b (mod c) */
diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c
index 09ff772..24f380e 100644
--- a/libtommath/bn_mp_and.c
+++ b/libtommath/bn_mp_and.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_AND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* AND two ints together */
diff --git a/libtommath/bn_mp_clamp.c b/libtommath/bn_mp_clamp.c
index 79a5b20..1bdfdc9 100644
--- a/libtommath/bn_mp_clamp.c
+++ b/libtommath/bn_mp_clamp.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLAMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* trim unused digits
diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c
index fcf4d61..fc01cb8 100644
--- a/libtommath/bn_mp_clear.c
+++ b/libtommath/bn_mp_clear.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLEAR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* clear one (frees) */
diff --git a/libtommath/bn_mp_clear_multi.c b/libtommath/bn_mp_clear_multi.c
index ac3949a..9d7d9da 100644
--- a/libtommath/bn_mp_clear_multi.c
+++ b/libtommath/bn_mp_clear_multi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLEAR_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
diff --git a/libtommath/bn_mp_cmp.c b/libtommath/bn_mp_cmp.c
index a33d483..d6e3761 100644
--- a/libtommath/bn_mp_cmp.c
+++ b/libtommath/bn_mp_cmp.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare two ints (signed)*/
diff --git a/libtommath/bn_mp_cmp_d.c b/libtommath/bn_mp_cmp_d.c
index 576a073..9816018 100644
--- a/libtommath/bn_mp_cmp_d.c
+++ b/libtommath/bn_mp_cmp_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare a digit */
diff --git a/libtommath/bn_mp_cmp_mag.c b/libtommath/bn_mp_cmp_mag.c
index e2c723f..a5f629a 100644
--- a/libtommath/bn_mp_cmp_mag.c
+++ b/libtommath/bn_mp_cmp_mag.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_MAG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare maginitude of two ints (unsigned) */
diff --git a/libtommath/bn_mp_cnt_lsb.c b/libtommath/bn_mp_cnt_lsb.c
index 219c369..8e8f488 100644
--- a/libtommath/bn_mp_cnt_lsb.c
+++ b/libtommath/bn_mp_cnt_lsb.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CNT_LSB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const int lnz[16] = {
diff --git a/libtommath/bn_mp_complement.c b/libtommath/bn_mp_complement.c
new file mode 100644
index 0000000..9dfddc3
--- /dev/null
+++ b/libtommath/bn_mp_complement.c
@@ -0,0 +1,26 @@
+#include "tommath_private.h"
+#ifdef BN_MP_COMPLEMENT_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.
+ */
+
+/* b = ~a */
+int mp_complement(const mp_int *a, mp_int *b)
+{
+ int res = mp_neg(a, b);
+ return (res == MP_OKAY) ? mp_sub_d(b, 1uL, b) : res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_copy.c b/libtommath/bn_mp_copy.c
index 17816e8..718febd 100644
--- a/libtommath/bn_mp_copy.c
+++ b/libtommath/bn_mp_copy.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* copy, b = a */
diff --git a/libtommath/bn_mp_count_bits.c b/libtommath/bn_mp_count_bits.c
index 4530c92..11b84b2 100644
--- a/libtommath/bn_mp_count_bits.c
+++ b/libtommath/bn_mp_count_bits.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_COUNT_BITS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns the number of bits in an int */
diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c
index f64f485..0d459d1 100644
--- a/libtommath/bn_mp_div.c
+++ b/libtommath/bn_mp_div.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef BN_MP_DIV_SMALL
diff --git a/libtommath/bn_mp_div_2.c b/libtommath/bn_mp_div_2.c
index 2907a1b..7ced424 100644
--- a/libtommath/bn_mp_div_2.c
+++ b/libtommath/bn_mp_div_2.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a/2 */
diff --git a/libtommath/bn_mp_div_2d.c b/libtommath/bn_mp_div_2d.c
index aeaa8f2..3fb822c 100644
--- a/libtommath/bn_mp_div_2d.c
+++ b/libtommath/bn_mp_div_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c
index 9d41793..c5ca137 100644
--- a/libtommath/bn_mp_div_3.c
+++ b/libtommath/bn_mp_div_3.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_3_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* divide by three (based on routine from MPI and the GMP manual) */
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c
index 7c0ab0b..93cae1e 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit division (based on routine from MPI) */
diff --git a/libtommath/bn_mp_dr_is_modulus.c b/libtommath/bn_mp_dr_is_modulus.c
index bf4ed8b..b01c77c 100644
--- a/libtommath/bn_mp_dr_is_modulus.c
+++ b/libtommath/bn_mp_dr_is_modulus.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_IS_MODULUS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if a number is a valid DR modulus */
diff --git a/libtommath/bn_mp_dr_reduce.c b/libtommath/bn_mp_dr_reduce.c
index d677b03..da36b85 100644
--- a/libtommath/bn_mp_dr_reduce.c
+++ b/libtommath/bn_mp_dr_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
diff --git a/libtommath/bn_mp_dr_setup.c b/libtommath/bn_mp_dr_setup.c
index 32aa582..afcdaf0 100644
--- a/libtommath/bn_mp_dr_setup.c
+++ b/libtommath/bn_mp_dr_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
diff --git a/libtommath/bn_mp_exch.c b/libtommath/bn_mp_exch.c
index 2bc635f..b846928 100644
--- a/libtommath/bn_mp_exch.c
+++ b/libtommath/bn_mp_exch.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXCH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* swap the elements of two integers, for cases where you can't simply swap the
diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c
index 92a85d5..e55101a 100644
--- a/libtommath/bn_mp_export.c
+++ b/libtommath/bn_mp_export.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPORT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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.
diff --git a/libtommath/bn_mp_expt_d.c b/libtommath/bn_mp_expt_d.c
index f5ce3c1..7aff105 100644
--- a/libtommath/bn_mp_expt_d.c
+++ b/libtommath/bn_mp_expt_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPT_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* wrapper function for mp_expt_d_ex() */
diff --git a/libtommath/bn_mp_expt_d_ex.c b/libtommath/bn_mp_expt_d_ex.c
index d363d59..53e880c 100644
--- a/libtommath/bn_mp_expt_d_ex.c
+++ b/libtommath/bn_mp_expt_d_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPT_D_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 */
diff --git a/libtommath/bn_mp_exptmod.c b/libtommath/bn_mp_exptmod.c
index 934fd25..ec0cf7e 100644
--- a/libtommath/bn_mp_exptmod.c
+++ b/libtommath/bn_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
diff --git a/libtommath/bn_mp_exptmod_fast.c b/libtommath/bn_mp_exptmod_fast.c
index 52d4a55..0d01e38 100644
--- a/libtommath/bn_mp_exptmod_fast.c
+++ b/libtommath/bn_mp_exptmod_fast.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPTMOD_FAST_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c
index 29bad83..b13ee30 100644
--- a/libtommath/bn_mp_exteuclid.c
+++ b/libtommath/bn_mp_exteuclid.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXTEUCLID_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Extended euclidean algorithm of (a, b) produces
diff --git a/libtommath/bn_mp_fread.c b/libtommath/bn_mp_fread.c
index 6922183..7652aac 100644
--- a/libtommath/bn_mp_fread.c
+++ b/libtommath/bn_mp_fread.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_FREAD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef LTM_NO_FILE
diff --git a/libtommath/bn_mp_fwrite.c b/libtommath/bn_mp_fwrite.c
index 8541bc7..8df2134 100644
--- a/libtommath/bn_mp_fwrite.c
+++ b/libtommath/bn_mp_fwrite.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_FWRITE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef LTM_NO_FILE
diff --git a/libtommath/bn_mp_gcd.c b/libtommath/bn_mp_gcd.c
index f5aa78b..0a5000e 100644
--- a/libtommath/bn_mp_gcd.c
+++ b/libtommath/bn_mp_gcd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GCD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Greatest Common Divisor using the binary method */
diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c
index d99a0a0..4f99363 100644
--- a/libtommath/bn_mp_get_int.c
+++ b/libtommath/bn_mp_get_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 32-bits of an mp_int */
diff --git a/libtommath/bn_mp_get_long.c b/libtommath/bn_mp_get_long.c
index 9ec2664..bb9bd75 100644
--- a/libtommath/bn_mp_get_long.c
+++ b/libtommath/bn_mp_get_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 */
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
index df2aa77..6eb33c9 100644
--- a/libtommath/bn_mp_get_long_long.c
+++ b/libtommath/bn_mp_get_long_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_LONG_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 */
diff --git a/libtommath/bn_mp_grow.c b/libtommath/bn_mp_grow.c
index 60f8f32..d336ba1 100644
--- a/libtommath/bn_mp_grow.c
+++ b/libtommath/bn_mp_grow.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GROW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* grow as required */
diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c
index 9bbd215..e28d20e 100644
--- a/libtommath/bn_mp_import.c
+++ b/libtommath/bn_mp_import.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_IMPORT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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.
diff --git a/libtommath/bn_mp_init.c b/libtommath/bn_mp_init.c
index ad630e3..cdc0bd2 100644
--- a/libtommath/bn_mp_init.c
+++ b/libtommath/bn_mp_init.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init a new mp_int */
diff --git a/libtommath/bn_mp_init_copy.c b/libtommath/bn_mp_init_copy.c
index 5681015..3d3e6cd 100644
--- a/libtommath/bn_mp_init_copy.c
+++ b/libtommath/bn_mp_init_copy.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* creates "a" then copies b into it */
diff --git a/libtommath/bn_mp_init_multi.c b/libtommath/bn_mp_init_multi.c
index 9ed777c..d254696 100644
--- a/libtommath/bn_mp_init_multi.c
+++ b/libtommath/bn_mp_init_multi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
diff --git a/libtommath/bn_mp_init_set.c b/libtommath/bn_mp_init_set.c
index e9c1b12..4bce757 100644
--- a/libtommath/bn_mp_init_set.c
+++ b/libtommath/bn_mp_init_set.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
diff --git a/libtommath/bn_mp_init_set_int.c b/libtommath/bn_mp_init_set_int.c
index 8e7441a..10c5bb7 100644
--- a/libtommath/bn_mp_init_set_int.c
+++ b/libtommath/bn_mp_init_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
diff --git a/libtommath/bn_mp_init_size.c b/libtommath/bn_mp_init_size.c
index 35713ac..ccca5b9 100644
--- a/libtommath/bn_mp_init_size.c
+++ b/libtommath/bn_mp_init_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init an mp_init for a given size */
diff --git a/libtommath/bn_mp_invmod.c b/libtommath/bn_mp_invmod.c
index 96717ea..8dd188c 100644
--- a/libtommath/bn_mp_invmod.c
+++ b/libtommath/bn_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
diff --git a/libtommath/bn_mp_invmod_slow.c b/libtommath/bn_mp_invmod_slow.c
index 360f161..49ed095 100644
--- a/libtommath/bn_mp_invmod_slow.c
+++ b/libtommath/bn_mp_invmod_slow.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INVMOD_SLOW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 329d727..6e3cb56 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_IS_SQUARE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Check if remainders are possible squares - fast exclude non-squares */
@@ -75,31 +73,31 @@ int mp_is_square(const mp_int *arg, int *ret)
return res;
}
if ((res = mp_mod(arg, &t, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_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
+ * free "t" so the easiest way is to goto LBL_ERR. We know that res
* is already equal to MP_OKAY from the mp_mod call
*/
- if (((1uL<<(r%11uL)) & 0x5C4uL) != 0uL) goto ERR;
- if (((1uL<<(r%13uL)) & 0x9E4uL) != 0uL) goto ERR;
- if (((1uL<<(r%17uL)) & 0x5CE8uL) != 0uL) goto ERR;
- if (((1uL<<(r%19uL)) & 0x4F50CuL) != 0uL) goto ERR;
- if (((1uL<<(r%23uL)) & 0x7ACCA0uL) != 0uL) goto ERR;
- if (((1uL<<(r%29uL)) & 0xC2EDD0CuL) != 0uL) goto ERR;
- if (((1uL<<(r%31uL)) & 0x6DE2B848uL) != 0uL) goto ERR;
+ if (((1uL<<(r%11uL)) & 0x5C4uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%13uL)) & 0x9E4uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%17uL)) & 0x5CE8uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%19uL)) & 0x4F50CuL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%23uL)) & 0x7ACCA0uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%29uL)) & 0xC2EDD0CuL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%31uL)) & 0x6DE2B848uL) != 0uL) goto LBL_ERR;
/* Final check - is sqr(sqrt(arg)) == arg ? */
if ((res = mp_sqrt(arg, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&t, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
*ret = (mp_cmp_mag(&t, arg) == MP_EQ) ? MP_YES : MP_NO;
-ERR:
+LBL_ERR:
mp_clear(&t);
return res;
}
diff --git a/libtommath/bn_mp_jacobi.c b/libtommath/bn_mp_jacobi.c
index ef2e72f..fe37f22 100644
--- a/libtommath/bn_mp_jacobi.c
+++ b/libtommath/bn_mp_jacobi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_JACOBI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the jacobi c = (a | n) (or Legendre if n is prime)
diff --git a/libtommath/bn_mp_karatsuba_mul.c b/libtommath/bn_mp_karatsuba_mul.c
index 1a84211..af12c55 100644
--- a/libtommath/bn_mp_karatsuba_mul.c
+++ b/libtommath/bn_mp_karatsuba_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_KARATSUBA_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = |a| * |b| using Karatsuba Multiplication using
@@ -60,7 +58,7 @@ int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* init copy all the temps */
if (mp_init_size(&x0, B) != MP_OKAY)
- goto ERR;
+ goto LBL_ERR;
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
goto X0;
if (mp_init_size(&y0, B) != MP_OKAY)
@@ -164,7 +162,7 @@ X1:
mp_clear(&x1);
X0:
mp_clear(&x0);
-ERR:
+LBL_ERR:
return err;
}
#endif
diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c
index c566b06..99a31b8 100644
--- a/libtommath/bn_mp_karatsuba_sqr.c
+++ b/libtommath/bn_mp_karatsuba_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_KARATSUBA_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Karatsuba squaring, computes b = a*a using three
@@ -37,7 +35,7 @@ int mp_karatsuba_sqr(const mp_int *a, mp_int *b)
/* init copy all the temps */
if (mp_init_size(&x0, B) != MP_OKAY)
- goto ERR;
+ goto LBL_ERR;
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
goto X0;
@@ -117,7 +115,7 @@ X1:
mp_clear(&x1);
X0:
mp_clear(&x0);
-ERR:
+LBL_ERR:
return err;
}
#endif
diff --git a/libtommath/bn_mp_lcm.c b/libtommath/bn_mp_lcm.c
index 24b621c..3798afc 100644
--- a/libtommath/bn_mp_lcm.c
+++ b/libtommath/bn_mp_lcm.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_LCM_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes least common multiple as |a*b|/(a, b) */
diff --git a/libtommath/bn_mp_lshd.c b/libtommath/bn_mp_lshd.c
index b49b545..649df90 100644
--- a/libtommath/bn_mp_lshd.c
+++ b/libtommath/bn_mp_lshd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_LSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left a certain amount of digits */
diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c
index 64e73ea..21acf8c 100644
--- a/libtommath/bn_mp_mod.c
+++ b/libtommath/bn_mp_mod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */
diff --git a/libtommath/bn_mp_mod_2d.c b/libtommath/bn_mp_mod_2d.c
index 7a74746..bf69221 100644
--- a/libtommath/bn_mp_mod_2d.c
+++ b/libtommath/bn_mp_mod_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* calc a value mod 2**b */
diff --git a/libtommath/bn_mp_mod_d.c b/libtommath/bn_mp_mod_d.c
index 9a24e78..5252c4f 100644
--- a/libtommath/bn_mp_mod_d.c
+++ b/libtommath/bn_mp_mod_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c)
diff --git a/libtommath/bn_mp_montgomery_calc_normalization.c b/libtommath/bn_mp_montgomery_calc_normalization.c
index 360e3e5..8b0a320 100644
--- a/libtommath/bn_mp_montgomery_calc_normalization.c
+++ b/libtommath/bn_mp_montgomery_calc_normalization.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/*
diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c
index e3a0eaa..2def073 100644
--- a/libtommath/bn_mp_montgomery_reduce.c
+++ b/libtommath/bn_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
diff --git a/libtommath/bn_mp_montgomery_setup.c b/libtommath/bn_mp_montgomery_setup.c
index 75da42b..cd53b6d 100644
--- a/libtommath/bn_mp_montgomery_setup.c
+++ b/libtommath/bn_mp_montgomery_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* setups the montgomery reduction stuff */
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index babb12b..e7613a3 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level multiplication (handles sign) */
diff --git a/libtommath/bn_mp_mul_2.c b/libtommath/bn_mp_mul_2.c
index 7611536..e0f051f 100644
--- a/libtommath/bn_mp_mul_2.c
+++ b/libtommath/bn_mp_mul_2.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a*2 */
diff --git a/libtommath/bn_mp_mul_2d.c b/libtommath/bn_mp_mul_2d.c
index 96aef85..42c6535 100644
--- a/libtommath/bn_mp_mul_2d.c
+++ b/libtommath/bn_mp_mul_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left by a certain bit count */
diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c
index 13f94a2..d6bddfd 100644
--- a/libtommath/bn_mp_mul_d.c
+++ b/libtommath/bn_mp_mul_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiply by a digit */
diff --git a/libtommath/bn_mp_mulmod.c b/libtommath/bn_mp_mulmod.c
index aeee4ee..ca9ef3e 100644
--- a/libtommath/bn_mp_mulmod.c
+++ b/libtommath/bn_mp_mulmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MULMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a * b (mod c) */
diff --git a/libtommath/bn_mp_n_root.c b/libtommath/bn_mp_n_root.c
index a09804f..16232d8 100644
--- a/libtommath/bn_mp_n_root.c
+++ b/libtommath/bn_mp_n_root.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_N_ROOT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* wrapper function for mp_n_root_ex()
diff --git a/libtommath/bn_mp_n_root_ex.c b/libtommath/bn_mp_n_root_ex.c
index 60c9929..9fd7098 100644
--- a/libtommath/bn_mp_n_root_ex.c
+++ b/libtommath/bn_mp_n_root_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_N_ROOT_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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
diff --git a/libtommath/bn_mp_neg.c b/libtommath/bn_mp_neg.c
index 75f8bbd..612b9c7 100644
--- a/libtommath/bn_mp_neg.c
+++ b/libtommath/bn_mp_neg.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_NEG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = -a */
diff --git a/libtommath/bn_mp_or.c b/libtommath/bn_mp_or.c
index f411509..151dfff 100644
--- a/libtommath/bn_mp_or.c
+++ b/libtommath/bn_mp_or.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_OR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* OR two ints together */
diff --git a/libtommath/bn_mp_prime_fermat.c b/libtommath/bn_mp_prime_fermat.c
index e71e0ae..7cd39bd 100644
--- a/libtommath/bn_mp_prime_fermat.c
+++ b/libtommath/bn_mp_prime_fermat.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_FERMAT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs one Fermat test.
diff --git a/libtommath/bn_mp_prime_is_divisible.c b/libtommath/bn_mp_prime_is_divisible.c
index c49fdd2..706521e 100644
--- a/libtommath/bn_mp_prime_is_divisible.c
+++ b/libtommath/bn_mp_prime_is_divisible.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if an integers is divisible by one
diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c
index e97712d..209fba0 100644
--- a/libtommath/bn_mp_prime_is_prime.c
+++ b/libtommath/bn_mp_prime_is_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_IS_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs a variable number of rounds of Miller-Rabin
diff --git a/libtommath/bn_mp_prime_miller_rabin.c b/libtommath/bn_mp_prime_miller_rabin.c
index 34c4d1c..5d94e36 100644
--- a/libtommath/bn_mp_prime_miller_rabin.c
+++ b/libtommath/bn_mp_prime_miller_rabin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_MILLER_RABIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Miller-Rabin test of "a" to the base of "b" as described in
diff --git a/libtommath/bn_mp_prime_next_prime.c b/libtommath/bn_mp_prime_next_prime.c
index b106a74..89e2841 100644
--- a/libtommath/bn_mp_prime_next_prime.c
+++ b/libtommath/bn_mp_prime_next_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_NEXT_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* finds the next prime after the number "a" using "t" trials
diff --git a/libtommath/bn_mp_prime_rabin_miller_trials.c b/libtommath/bn_mp_prime_rabin_miller_trials.c
index cde309a..d400902 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_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
diff --git a/libtommath/bn_mp_prime_random_ex.c b/libtommath/bn_mp_prime_random_ex.c
index 1ae2934..13fdcdf 100644
--- a/libtommath/bn_mp_prime_random_ex.c
+++ b/libtommath/bn_mp_prime_random_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_RANDOM_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* makes a truly random prime of a given size (bits),
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c
index 29355cb..1e286ed 100644
--- a/libtommath/bn_mp_radix_size.c
+++ b/libtommath/bn_mp_radix_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RADIX_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns size of ASCII reprensentation */
diff --git a/libtommath/bn_mp_radix_smap.c b/libtommath/bn_mp_radix_smap.c
index 5d449f1..caba69f 100644
--- a/libtommath/bn_mp_radix_smap.c
+++ b/libtommath/bn_mp_radix_smap.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RADIX_SMAP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,24 +11,22 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* chars used in radix conversions */
-const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
+const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
const unsigned char mp_s_rmap_reverse[] = {
- 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
- 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
- 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* @ABCDEFG */
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* HIJKLMNO */
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /* PQRSTUVW */
- 0x21, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, /* XYZ[\]^_ */
- 0xff, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* `abcdefg */
- 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, /* hijklmno */
- 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
- 0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
+ 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
+ 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
+ 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* @ABCDEFG */
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* HIJKLMNO */
+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /* PQRSTUVW */
+ 0x21, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, /* XYZ[\]^_ */
+ 0xff, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* `abcdefg */
+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, /* hijklmno */
+ 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
+ 0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
};
const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
#endif
diff --git a/libtommath/bn_mp_rand.c b/libtommath/bn_mp_rand.c
index 2ed665e..af017f2 100644
--- a/libtommath/bn_mp_rand.c
+++ b/libtommath/bn_mp_rand.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RAND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,38 +11,173 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-#if defined(MP_8BIT) || defined(MP_16BIT)
-#define MP_GEN_RANDOM_SHIFT DIGIT_BIT
-#else
-#if MP_GEN_RANDOM_MAX == 0xffffffffu
-#define MP_GEN_RANDOM_SHIFT 32
-#elif MP_GEN_RANDOM_MAX == 32767
-/* SHRT_MAX */
-#define MP_GEN_RANDOM_SHIFT 15
-#elif MP_GEN_RANDOM_MAX == 2147483647
-/* INT_MAX */
-#define MP_GEN_RANDOM_SHIFT 31
-#elif !defined(MP_GEN_RANDOM_SHIFT)
-#error Thou shalt define their own valid MP_GEN_RANDOM_SHIFT
-#endif
-#endif
+/* First the OS-specific special cases
+ * - *BSD
+ * - Windows
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+#define MP_ARC4RANDOM
+#define MP_GEN_RANDOM_MAX 0xffffffffu
+#define MP_GEN_RANDOM_SHIFT 32
-/* makes a pseudo-random int of a given size */
-static mp_digit s_gen_random(void)
+static int s_read_arc4random(mp_digit *p)
{
mp_digit d = 0, msk = 0;
do {
d <<= MP_GEN_RANDOM_SHIFT;
- d |= ((mp_digit) MP_GEN_RANDOM());
+ d |= ((mp_digit) arc4random());
msk <<= MP_GEN_RANDOM_SHIFT;
msk |= (MP_MASK & MP_GEN_RANDOM_MAX);
} while ((MP_MASK & msk) != MP_MASK);
- d &= MP_MASK;
- return d;
+ *p = d;
+ return MP_OKAY;
+}
+#endif
+
+#if defined(_WIN32) || defined(_WIN32_WCE)
+#define MP_WIN_CSP
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#ifdef _WIN32_WCE
+#define UNDER_CE
+#define ARM
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <wincrypt.h>
+
+static HCRYPTPROV hProv = 0;
+
+static void s_cleanup_win_csp(void)
+{
+ CryptReleaseContext(hProv, 0);
+ hProv = 0;
+}
+
+static int s_read_win_csp(mp_digit *p)
+{
+ int ret = -1;
+ if (hProv == 0) {
+ if (!CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
+ (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) &&
+ !CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET)) {
+ hProv = 0;
+ return ret;
+ }
+ atexit(s_cleanup_win_csp);
+ }
+ if (CryptGenRandom(hProv, sizeof(*p), (void *)p) == TRUE) {
+ ret = MP_OKAY;
+ }
+ return ret;
+}
+#endif /* WIN32 */
+
+#if !defined(MP_WIN_CSP) && defined(__linux__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 25)
+#define MP_GETRANDOM
+#include <sys/random.h>
+#include <errno.h>
+
+static int s_read_getrandom(mp_digit *p)
+{
+ int ret;
+ do {
+ ret = getrandom(p, sizeof(*p), 0);
+ } while ((ret == -1) && (errno == EINTR));
+ if (ret == sizeof(*p)) return MP_OKAY;
+ return -1;
+}
+#endif
+#endif
+
+/* We assume all platforms besides windows provide "/dev/urandom".
+ * In case yours doesn't, define MP_NO_DEV_URANDOM at compile-time.
+ */
+#if !defined(MP_WIN_CSP) && !defined(MP_NO_DEV_URANDOM)
+#ifndef MP_DEV_URANDOM
+#define MP_DEV_URANDOM "/dev/urandom"
+#endif
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+static int s_read_dev_urandom(mp_digit *p)
+{
+ ssize_t r;
+ int fd;
+ do {
+ fd = open(MP_DEV_URANDOM, O_RDONLY);
+ } while ((fd == -1) && (errno == EINTR));
+ if (fd == -1) return -1;
+ do {
+ r = read(fd, p, sizeof(*p));
+ } while ((r == -1) && (errno == EINTR));
+ close(fd);
+ if (r != sizeof(*p)) return -1;
+ return MP_OKAY;
+}
+#endif
+
+#if defined(MP_PRNG_ENABLE_LTM_RNG)
+unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
+void (*ltm_rng_callback)(void);
+
+static int s_read_ltm_rng(mp_digit *p)
+{
+ unsigned long ret;
+ if (ltm_rng == NULL) return -1;
+ ret = ltm_rng((void *)p, sizeof(*p), ltm_rng_callback);
+ if (ret != sizeof(*p)) return -1;
+ return MP_OKAY;
+}
+#endif
+
+static int s_rand_digit(mp_digit *p)
+{
+ int ret = -1;
+
+#if defined(MP_ARC4RANDOM)
+ ret = s_read_arc4random(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+#if defined(MP_WIN_CSP)
+ ret = s_read_win_csp(p);
+ if (ret == MP_OKAY) return ret;
+#else
+
+#if defined(MP_GETRANDOM)
+ ret = s_read_getrandom(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+#if defined(MP_DEV_URANDOM)
+ ret = s_read_dev_urandom(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+#endif /* MP_WIN_CSP */
+
+#if defined(MP_PRNG_ENABLE_LTM_RNG)
+ ret = s_read_ltm_rng(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+ return ret;
+}
+
+/* makes a pseudo-random int of a given size */
+static int s_gen_random(mp_digit *r)
+{
+ int ret = s_rand_digit(r);
+ *r &= MP_MASK;
+ return ret;
}
int mp_rand(mp_int *a, int digits)
@@ -57,7 +192,9 @@ int mp_rand(mp_int *a, int digits)
/* first place a random non-zero digit */
do {
- d = s_gen_random();
+ if (s_gen_random(&d) != MP_OKAY) {
+ return MP_VAL;
+ }
} while (d == 0u);
if ((res = mp_add_d(a, d, a)) != MP_OKAY) {
@@ -69,7 +206,10 @@ int mp_rand(mp_int *a, int digits)
return res;
}
- if ((res = mp_add_d(a, s_gen_random(), a)) != MP_OKAY) {
+ if (s_gen_random(&d) != MP_OKAY) {
+ return MP_VAL;
+ }
+ if ((res = mp_add_d(a, d, a)) != MP_OKAY) {
return res;
}
}
diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c
index 55c5ee1..02ba113 100644
--- a/libtommath/bn_mp_read_radix.c
+++ b/libtommath/bn_mp_read_radix.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_RADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read a string [ASCII] in a given radix */
diff --git a/libtommath/bn_mp_read_signed_bin.c b/libtommath/bn_mp_read_signed_bin.c
index 17bc6ce..3a0e231 100644
--- a/libtommath/bn_mp_read_signed_bin.c
+++ b/libtommath/bn_mp_read_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
diff --git a/libtommath/bn_mp_read_unsigned_bin.c b/libtommath/bn_mp_read_unsigned_bin.c
index 6398c43..f29e7e6 100644
--- a/libtommath/bn_mp_read_unsigned_bin.c
+++ b/libtommath/bn_mp_read_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
diff --git a/libtommath/bn_mp_reduce.c b/libtommath/bn_mp_reduce.c
index 5b1d405..3f93387 100644
--- a/libtommath/bn_mp_reduce.c
+++ b/libtommath/bn_mp_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces x mod m, assumes 0 < x < m**2, mu is
diff --git a/libtommath/bn_mp_reduce_2k.c b/libtommath/bn_mp_reduce_2k.c
index e1e2bc8..f5c74b8 100644
--- a/libtommath/bn_mp_reduce_2k.c
+++ b/libtommath/bn_mp_reduce_2k.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces a modulo n where n is of the form 2**p - d */
@@ -29,29 +27,29 @@ int mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d)
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (d != 1u) {
/* q = q * d */
if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
}
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (mp_cmp_mag(a, n) != MP_LT) {
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
goto top;
}
-ERR:
+LBL_ERR:
mp_clear(&q);
return res;
}
diff --git a/libtommath/bn_mp_reduce_2k_l.c b/libtommath/bn_mp_reduce_2k_l.c
index 23381bf..cbdfad7 100644
--- a/libtommath/bn_mp_reduce_2k_l.c
+++ b/libtommath/bn_mp_reduce_2k_l.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces a modulo n where n is of the form 2**p - d
@@ -32,27 +30,27 @@ int mp_reduce_2k_l(mp_int *a, const mp_int *n, const mp_int *d)
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* q = q * d */
if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (mp_cmp_mag(a, n) != MP_LT) {
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
goto top;
}
-ERR:
+LBL_ERR:
mp_clear(&q);
return res;
}
diff --git a/libtommath/bn_mp_reduce_2k_setup.c b/libtommath/bn_mp_reduce_2k_setup.c
index e6ae839..11248a3 100644
--- a/libtommath/bn_mp_reduce_2k_setup.c
+++ b/libtommath/bn_mp_reduce_2k_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
diff --git a/libtommath/bn_mp_reduce_2k_setup_l.c b/libtommath/bn_mp_reduce_2k_setup_l.c
index af81b5b..04c7634 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_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_SETUP_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
@@ -26,14 +24,14 @@ int mp_reduce_2k_setup_l(const mp_int *a, mp_int *d)
}
if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear(&tmp);
return res;
}
diff --git a/libtommath/bn_mp_reduce_is_2k.c b/libtommath/bn_mp_reduce_is_2k.c
index f59d535..14612c0 100644
--- a/libtommath/bn_mp_reduce_is_2k.c
+++ b/libtommath/bn_mp_reduce_is_2k.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_IS_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if mp_reduce_2k can be used */
diff --git a/libtommath/bn_mp_reduce_is_2k_l.c b/libtommath/bn_mp_reduce_is_2k_l.c
index 22c7582..7c9cacf 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_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_IS_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if reduce_2k_l can be used */
diff --git a/libtommath/bn_mp_reduce_setup.c b/libtommath/bn_mp_reduce_setup.c
index 70e193a..92d03fc 100644
--- a/libtommath/bn_mp_reduce_setup.c
+++ b/libtommath/bn_mp_reduce_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* pre-calculate the value required for Barrett reduction
diff --git a/libtommath/bn_mp_rshd.c b/libtommath/bn_mp_rshd.c
index fd06735..d17ad00 100644
--- a/libtommath/bn_mp_rshd.c
+++ b/libtommath/bn_mp_rshd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right a certain amount of digits */
diff --git a/libtommath/bn_mp_set.c b/libtommath/bn_mp_set.c
index 952d080..dc03f4c 100644
--- a/libtommath/bn_mp_set.c
+++ b/libtommath/bn_mp_set.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to a digit */
diff --git a/libtommath/bn_mp_set_int.c b/libtommath/bn_mp_set_int.c
index 006f263..4d6e580 100644
--- a/libtommath/bn_mp_set_int.c
+++ b/libtommath/bn_mp_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set a 32-bit const */
diff --git a/libtommath/bn_mp_set_long.c b/libtommath/bn_mp_set_long.c
index 8cbb811..f842632 100644
--- a/libtommath/bn_mp_set_long.c
+++ b/libtommath/bn_mp_set_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 */
diff --git a/libtommath/bn_mp_set_long_long.c b/libtommath/bn_mp_set_long_long.c
index 0b8be33..0c550a8 100644
--- a/libtommath/bn_mp_set_long_long.c
+++ b/libtommath/bn_mp_set_long_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_LONG_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* 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 */
diff --git a/libtommath/bn_mp_shrink.c b/libtommath/bn_mp_shrink.c
index 3e4dde0..b2e9d89 100644
--- a/libtommath/bn_mp_shrink.c
+++ b/libtommath/bn_mp_shrink.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SHRINK_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shrink a bignum */
diff --git a/libtommath/bn_mp_signed_bin_size.c b/libtommath/bn_mp_signed_bin_size.c
index 1fdfd85..529482f 100644
--- a/libtommath/bn_mp_signed_bin_size.c
+++ b/libtommath/bn_mp_signed_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an signed equivalent */
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index a98f16c..237c919 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes b = a*a */
diff --git a/libtommath/bn_mp_sqrmod.c b/libtommath/bn_mp_sqrmod.c
index c3c7ec9..f3ed8a8 100644
--- a/libtommath/bn_mp_sqrmod.c
+++ b/libtommath/bn_mp_sqrmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = a * a (mod b) */
diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c
index 49a1bd0..d342a32 100644
--- a/libtommath/bn_mp_sqrt.c
+++ b/libtommath/bn_mp_sqrt.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef NO_FLOATING_POINT
@@ -23,7 +21,7 @@
int mp_sqrt(const mp_int *arg, mp_int *ret)
{
int res;
- mp_int t1,t2;
+ mp_int t1, t2;
int i, j, k;
#ifndef NO_FLOATING_POINT
volatile double d;
@@ -108,30 +106,30 @@ int mp_sqrt(const mp_int *arg, mp_int *ret)
#endif
/* t1 > 0 */
- if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
+ if ((res = mp_div(arg, &t1, &t2, NULL)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
+ if ((res = mp_add(&t1, &t2, &t1)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
+ 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) {
+ if ((res = mp_div(arg, &t1, &t2, NULL)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
+ if ((res = mp_add(&t1, &t2, &t1)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
+ 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);
+ } while (mp_cmp_mag(&t1, &t2) == MP_GT);
- mp_exch(&t1,ret);
+ mp_exch(&t1, ret);
E1:
mp_clear(&t2);
diff --git a/libtommath/bn_mp_sqrtmod_prime.c b/libtommath/bn_mp_sqrtmod_prime.c
index d4cf3de..f7647b9 100644
--- a/libtommath/bn_mp_sqrtmod_prime.c
+++ b/libtommath/bn_mp_sqrtmod_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRTMOD_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c
index 19cb65e..9ef1059 100644
--- a/libtommath/bn_mp_sub.c
+++ b/libtommath/bn_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level subtraction (handles signs) */
diff --git a/libtommath/bn_mp_sub_d.c b/libtommath/bn_mp_sub_d.c
index e5fbfff..1ac9859 100644
--- a/libtommath/bn_mp_sub_d.c
+++ b/libtommath/bn_mp_sub_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUB_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit subtraction */
diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c
index c4db397..0325b9d 100644
--- a/libtommath/bn_mp_submod.c
+++ b/libtommath/bn_mp_submod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUBMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a - b (mod c) */
diff --git a/libtommath/bn_mp_tc_and.c b/libtommath/bn_mp_tc_and.c
new file mode 100644
index 0000000..e9fe4c6
--- /dev/null
+++ b/libtommath/bn_mp_tc_and.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_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.
+ */
+
+/* two complement and */
+int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_and(a, b, c);
+
+ if ((as != MP_NO) && (bs != MP_NO) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_div_2d.c b/libtommath/bn_mp_tc_div_2d.c
new file mode 100644
index 0000000..ea190c3
--- /dev/null
+++ b/libtommath/bn_mp_tc_div_2d.c
@@ -0,0 +1,36 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_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.
+ */
+
+/* two complement right shift */
+int mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
+{
+ int res;
+ if (mp_isneg(a) == MP_NO) {
+ return mp_div_2d(a, b, c, NULL);
+ }
+
+ res = mp_add_d(a, 1uL, c);
+ if (res != MP_OKAY) {
+ return res;
+ }
+
+ res = mp_div_2d(c, b, c, NULL);
+ return (res == MP_OKAY) ? mp_sub_d(c, 1uL, c) : res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_or.c b/libtommath/bn_mp_tc_or.c
new file mode 100644
index 0000000..91b6b40
--- /dev/null
+++ b/libtommath/bn_mp_tc_or.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_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.
+ */
+
+/* two complement or */
+int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_or(a, b, c);
+
+ if (((as != MP_NO) || (bs != MP_NO)) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_xor.c b/libtommath/bn_mp_tc_xor.c
new file mode 100644
index 0000000..50fb12d
--- /dev/null
+++ b/libtommath/bn_mp_tc_xor.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_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.
+ */
+
+/* two complement xor */
+int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_xor(a, b, c);
+
+ if ((as != bs) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_to_signed_bin.c b/libtommath/bn_mp_to_signed_bin.c
index 4d4be88..22a938e 100644
--- a/libtommath/bn_mp_to_signed_bin.c
+++ b/libtommath/bn_mp_to_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
diff --git a/libtommath/bn_mp_to_signed_bin_n.c b/libtommath/bn_mp_to_signed_bin_n.c
index f1d7c8b..417a380 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_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_SIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
diff --git a/libtommath/bn_mp_to_unsigned_bin.c b/libtommath/bn_mp_to_unsigned_bin.c
index a53f711..aa719ae 100644
--- a/libtommath/bn_mp_to_unsigned_bin.c
+++ b/libtommath/bn_mp_to_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
diff --git a/libtommath/bn_mp_to_unsigned_bin_n.c b/libtommath/bn_mp_to_unsigned_bin_n.c
index e7d303c..43676e8 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_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
diff --git a/libtommath/bn_mp_toom_mul.c b/libtommath/bn_mp_toom_mul.c
index 00b6bfb..ff7df02 100644
--- a/libtommath/bn_mp_toom_mul.c
+++ b/libtommath/bn_mp_toom_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TOOM_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplication using the Toom-Cook 3-way algorithm
@@ -39,126 +37,126 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* a = a2 * B**2 + a1 * B + a0 */
if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a1, B);
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_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;
+ goto LBL_ERR;
}
if ((res = mp_copy(b, &b1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&b1, B);
(void)mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
if ((res = mp_copy(b, &b2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&b2, B*2);
/* w0 = a0*b0 */
if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w4 = a2 * b2 */
if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */
if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */
if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */
if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* now solve the matrix
@@ -175,104 +173,104 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* r1 - r4 */
if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r0 */
if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/2 */
if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/2 */
if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r2 - r0 - r4 */
if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - 8r0 */
if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - 8r4 */
if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* 3r2 - r1 - r3 */
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/3 */
if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/3 */
if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* at this point shift W[n] by B*n */
if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear_multi(&w0, &w1, &w2, &w3, &w4,
&a0, &a1, &a2, &b0, &b1,
&b2, &tmp1, &tmp2, NULL);
diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c
index 183de20..edc89cd 100644
--- a/libtommath/bn_mp_toom_sqr.c
+++ b/libtommath/bn_mp_toom_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TOOM_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* squaring using Toom-Cook 3-way algorithm */
@@ -31,78 +29,78 @@ int mp_toom_sqr(const mp_int *a, mp_int *b)
/* a = a2 * B**2 + a1 * B + a0 */
if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a1, B);
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a2, B*2);
/* w0 = a0*a0 */
if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w4 = a2 * a2 */
if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w1 = (a2 + 2(a1 + 2a0))**2 */
if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w3 = (a0 + 2(a1 + 2a2))**2 */
if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w2 = (a2 + a1 + a0)**2 */
if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* now solve the matrix
@@ -118,104 +116,104 @@ int mp_toom_sqr(const mp_int *a, mp_int *b)
/* r1 - r4 */
if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r0 */
if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/2 */
if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/2 */
if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r2 - r0 - r4 */
if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - 8r0 */
if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - 8r4 */
if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* 3r2 - r1 - r3 */
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/3 */
if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/3 */
if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* at this point shift W[n] by B*n */
if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
return res;
}
diff --git a/libtommath/bn_mp_toradix.c b/libtommath/bn_mp_toradix.c
index 7dd6e4f..8c05e75 100644
--- a/libtommath/bn_mp_toradix.c
+++ b/libtommath/bn_mp_toradix.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TORADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64) */
diff --git a/libtommath/bn_mp_toradix_n.c b/libtommath/bn_mp_toradix_n.c
index ef885fc..27cb401 100644
--- a/libtommath/bn_mp_toradix_n.c
+++ b/libtommath/bn_mp_toradix_n.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TORADIX_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64)
diff --git a/libtommath/bn_mp_unsigned_bin_size.c b/libtommath/bn_mp_unsigned_bin_size.c
index 2b9ce8a..bc9b853 100644
--- a/libtommath/bn_mp_unsigned_bin_size.c
+++ b/libtommath/bn_mp_unsigned_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an unsigned equivalent */
diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c
index 9ebc53a..b502eb0 100644
--- a/libtommath/bn_mp_xor.c
+++ b/libtommath/bn_mp_xor.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_XOR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* XOR two ints together */
diff --git a/libtommath/bn_mp_zero.c b/libtommath/bn_mp_zero.c
index 08aac2a..78f165b 100644
--- a/libtommath/bn_mp_zero.c
+++ b/libtommath/bn_mp_zero.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ZERO_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to zero */
diff --git a/libtommath/bn_prime_tab.c b/libtommath/bn_prime_tab.c
index bcd23ed..f23afcb 100644
--- a/libtommath/bn_prime_tab.c
+++ b/libtommath/bn_prime_tab.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_PRIME_TAB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
const mp_digit ltm_prime_tab[] = {
diff --git a/libtommath/bn_reverse.c b/libtommath/bn_reverse.c
index 71e3d03..5b49172 100644
--- a/libtommath/bn_reverse.c
+++ b/libtommath/bn_reverse.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_REVERSE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reverse an array, used for radix code */
diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c
index 3f908ef..8a3bc82 100644
--- a/libtommath/bn_s_mp_add.c
+++ b/libtommath/bn_s_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level addition, based on HAC pp.594, Algorithm 14.7 */
diff --git a/libtommath/bn_s_mp_exptmod.c b/libtommath/bn_s_mp_exptmod.c
index a954757..f84da21 100644
--- a/libtommath/bn_s_mp_exptmod.c
+++ b/libtommath/bn_s_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef MP_LOW_MEM
diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c
index 214ae31..442c803 100644
--- a/libtommath/bn_s_mp_mul_digs.c
+++ b/libtommath/bn_s_mp_mul_digs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and only computes upto digs digits of result
diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c
index 3c0418a..e6efd4e 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_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and does not compute the lower digs digits
diff --git a/libtommath/bn_s_mp_sqr.c b/libtommath/bn_s_mp_sqr.c
index 71bbccd..4cab045 100644
--- a/libtommath/bn_s_mp_sqr.c
+++ b/libtommath/bn_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c
index c8472af..fbce7ca 100644
--- a/libtommath/bn_s_mp_sub.c
+++ b/libtommath/bn_s_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
diff --git a/libtommath/bncore.c b/libtommath/bncore.c
index cfd19f0..916712d 100644
--- a/libtommath/bncore.c
+++ b/libtommath/bncore.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BNCORE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Known optimal configurations
diff --git a/libtommath/callgraph.txt b/libtommath/callgraph.txt
index 52007c0..6cc4e45 100644
--- a/libtommath/callgraph.txt
+++ b/libtommath/callgraph.txt
@@ -237,6 +237,17 @@ BN_MP_CMP_MAG_C
BN_MP_CNT_LSB_C
+BN_MP_COMPLEMENT_C
++--->BN_MP_NEG_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_COPY_C
+--->BN_MP_GROW_C
@@ -12382,6 +12393,172 @@ BN_MP_SUB_D_C
+--->BN_MP_CLAMP_C
+BN_MP_TC_AND_C
++--->BN_MP_COUNT_BITS_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_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_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_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_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_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_TC_DIV_2D_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_ADD_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_TC_OR_C
++--->BN_MP_COUNT_BITS_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_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_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_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_OR_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_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_TC_XOR_C
++--->BN_MP_COUNT_BITS_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_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_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_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_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_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_TOOM_MUL_C
+--->BN_MP_INIT_MULTI_C
| +--->BN_MP_INIT_C
diff --git a/libtommath/makefile b/libtommath/makefile
index 5eddae4..7b8f422 100644
--- a/libtommath/makefile
+++ b/libtommath/makefile
@@ -29,27 +29,27 @@ LCOV_ARGS=--directory .
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_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.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
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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
@@ -67,17 +67,17 @@ $(LIBNAME): $(OBJECTS)
# So far I've seen improvements in the MP math
profiled:
make CFLAGS="$(CFLAGS) -fprofile-arcs -DTESTING" timing
- ./ltmtest
- rm -f *.a *.o ltmtest
+ ./timing
+ rm -f *.a *.o timing
make CFLAGS="$(CFLAGS) -fbranch-probabilities"
#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 -lgcov -o ltmtest
- ./ltmtest
- rm -f *.o ltmtest
+ $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o timing
+ ./timing
+ rm -f *.o timing
$(CC) $(CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) $(LIBNAME) mpi.o
ranlib $(LIBNAME)
@@ -102,8 +102,8 @@ test_standalone: $(LIBNAME) demo/demo.o
mtest:
cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LFLAGS) -o mtest
-timing: $(LIBNAME)
- $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o ltmtest
+timing: $(LIBNAME) demo/timing.c
+ $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o timing
# You have to create a file .coveralls.yml with the content "repo_token: <the token>"
# in the base folder to be able to submit to coveralls
@@ -118,11 +118,12 @@ pretty:
.PHONY: pre_gen
pre_gen:
+ mkdir -p pre_gen
perl gen.pl
sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
rm mpi.c
-zipup: clean pre_gen new_file manual poster docs
+zipup: clean astyle new_file manual poster docs
@# Update the index, so diff-index won't fail in case the pdf has been created.
@# As the pdf creation modifies the tex files, git sometimes detects the
@# modified files, but misses that it's put back to its original version.
@@ -131,8 +132,11 @@ zipup: clean pre_gen new_file manual poster docs
rm -rf libtommath-$(VERSION) ltm-$(VERSION).*
@# files/dirs excluded from "git archive" are defined in .gitattributes
git archive --format=tar --prefix=libtommath-$(VERSION)/ HEAD | tar x
+ @echo 'fixme check'
+ -@(find libtommath-$(VERSION)/ -type f | xargs grep 'FIXM[E]') && echo '############## BEWARE: the "fixme" marker was found !!! ##############' || true
mkdir -p libtommath-$(VERSION)/doc
cp doc/bn.pdf doc/tommath.pdf doc/poster.pdf libtommath-$(VERSION)/doc/
+ $(MAKE) -C libtommath-$(VERSION)/ pre_gen
tar -c libtommath-$(VERSION)/ | xz -6e -c - > ltm-$(VERSION).tar.xz
zip -9rq ltm-$(VERSION).zip libtommath-$(VERSION)
rm -rf libtommath-$(VERSION)
diff --git a/libtommath/makefile.bcc b/libtommath/makefile.bcc
index a0cfd74..7a64695 100644
--- a/libtommath/makefile.bcc
+++ b/libtommath/makefile.bcc
@@ -11,27 +11,27 @@ CFLAGS = -c -O2 -I.
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_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_complement.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
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_tc_and.obj \
+bn_mp_tc_div_2d.obj bn_mp_tc_or.obj bn_mp_tc_xor.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
diff --git a/libtommath/makefile.cygwin_dll b/libtommath/makefile.cygwin_dll
index 6feb5b4..fbec3bf 100644
--- a/libtommath/makefile.cygwin_dll
+++ b/libtommath/makefile.cygwin_dll
@@ -16,27 +16,27 @@ default: windll
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_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.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
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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
diff --git a/libtommath/makefile.icc b/libtommath/makefile.icc
index 1563802..e3cfb00 100644
--- a/libtommath/makefile.icc
+++ b/libtommath/makefile.icc
@@ -42,27 +42,27 @@ DATAPATH=/usr/share/doc/libtommath/pdf
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_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.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
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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
@@ -80,17 +80,17 @@ libtommath.a: $(OBJECTS)
# So far I've seen improvements in the MP math
profiled:
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_gen -DTESTING" timing
- ./ltmtest
- rm -f *.a *.o ltmtest
+ ./timing
+ rm -f *.a *.o timing
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_use"
#make a single object profiled library
profiled_single:
perl gen.pl
$(CC) $(CFLAGS) -prof_gen -DTESTING -c mpi.c -o mpi.o
- $(CC) $(CFLAGS) -DTESTING -DTIMER demo/demo.c mpi.o -o ltmtest
- ./ltmtest
- rm -f *.o ltmtest
+ $(CC) $(CFLAGS) -DTESTING -DTIMER demo/demo.c mpi.o -o timing
+ ./timing
+ rm -f *.o timing
$(CC) $(CFLAGS) -prof_use -ip -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) libtommath.a mpi.o
ranlib libtommath.a
@@ -107,11 +107,11 @@ test: libtommath.a demo/demo.o
mtest: test
cd mtest ; $(CC) $(CFLAGS) mtest.c -o mtest
-timing: libtommath.a
- $(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o ltmtest
+timing: libtommath.a demo/timing.c
+ $(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o timing
clean:
- rm -f *.bat *.pdf *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
+ rm -f *.bat *.pdf *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test timing mpitest mtest/mtest mtest/mtest.exe \
*.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.il etc/*.il *.dyn
cd etc ; make clean
cd pics ; make clean
diff --git a/libtommath/makefile.msvc b/libtommath/makefile.msvc
index a47aadd..22a27fe 100644
--- a/libtommath/makefile.msvc
+++ b/libtommath/makefile.msvc
@@ -2,7 +2,7 @@
#
#Tom St Denis
-CFLAGS = /I. /Ox /DWIN32 /W3 /Fo$@
+LTM_CFLAGS = /Ox /nologo /I. /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
default: library
@@ -10,31 +10,34 @@ default: library
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_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_complement.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
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_tc_and.obj \
+bn_mp_tc_div_2d.obj bn_mp_tc_or.obj bn_mp_tc_xor.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
+HEADERS=tommath.h tommath_class.h tommath_private.h tommath_superclass.h
library: $(OBJECTS)
lib /out:tommath.lib $(OBJECTS)
+
+.c.obj:
+ $(CC) $(LTM_CFLAGS) /c $< /Fo$@
diff --git a/libtommath/makefile.shared b/libtommath/makefile.shared
index 67213a2..79e5f86 100644
--- a/libtommath/makefile.shared
+++ b/libtommath/makefile.shared
@@ -10,14 +10,14 @@ endif
include makefile_include.mk
-ifndef LT
+ifndef LIBTOOL
ifeq ($(PLATFORM), Darwin)
- LT:=glibtool
+ LIBTOOL:=glibtool
else
- LT:=libtool
+ LIBTOOL:=libtool
endif
endif
-LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
+LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
LCOV_ARGS=--directory .libs --directory .
@@ -25,27 +25,27 @@ LCOV_ARGS=--directory .libs --directory .
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_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.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
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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
@@ -57,32 +57,32 @@ objs: $(OBJECTS)
LOBJECTS = $(OBJECTS:.o=.lo)
$(LIBNAME): $(OBJECTS)
- $(LT) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
install: $(LIBNAME)
install -d $(DESTDIR)$(LIBPATH)
install -d $(DESTDIR)$(INCPATH)
- $(LT) --mode=install install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+ $(LIBTOOL) --mode=install install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtommath.pc.in > libtommath.pc
install -d $(DESTDIR)$(LIBPATH)/pkgconfig
install -m 644 libtommath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
uninstall:
- $(LT) --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+ $(LIBTOOL) --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
test: $(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)
+ $(LIBTOOL) --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)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
mtest:
cd mtest ; $(CC) $(CFLAGS) $(LDFLAGS) mtest.c -o mtest
-timing: $(LIBNAME)
- $(LT) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o ltmtest
+timing: $(LIBNAME) demo/timing.c
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
diff --git a/libtommath/makefile_include.mk b/libtommath/makefile_include.mk
index 45a4895..c4ba8db 100644
--- a/libtommath/makefile_include.mk
+++ b/libtommath/makefile_include.mk
@@ -17,15 +17,34 @@ ifndef CROSS_COMPILE
CROSS_COMPILE=
endif
-ifeq ($(CC),cc)
- CC = $(CROSS_COMPILE)gcc
+# We only need to go through this dance of determining the right compiler if we're using
+# cross compilation, otherwise $(CC) is fine as-is.
+ifneq (,$(CROSS_COMPILE))
+ifeq ($(origin CC),default)
+CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
+ifeq ($(PLATFORM),FreeBSD)
+ # XXX: FreeBSD needs extra escaping for some reason
+ CSTR := $$$(CSTR)
endif
+ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
+ CC := $(CROSS_COMPILE)clang
+else
+ CC := $(CROSS_COMPILE)gcc
+endif # Clang
+endif # cc is Make's default
+endif # CROSS_COMPILE non-empty
+
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
RANLIB=$(CROSS_COMPILE)ranlib
ifndef MAKE
- MAKE=make
+# BSDs refer to GNU Make as gmake
+ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
+ MAKE=gmake
+else
+ MAKE=make
+endif
endif
CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
@@ -67,10 +86,16 @@ ifeq ($(PLATFORM), Darwin)
CFLAGS += -Wno-nullability-completeness
endif
+ifeq ($(PLATFORM),FreeBSD)
+ _ARCH := $(shell sysctl -b hw.machine_arch)
+else
+ _ARCH := $(shell arch)
+endif
+
# adjust coverage set
-ifneq ($(filter $(shell arch), i386 i686 x86_64 amd64 ia64),)
+ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
COVERAGE = test_standalone timing
- COVERAGE_APP = ./test && ./ltmtest
+ COVERAGE_APP = ./test && ./timing
else
COVERAGE = test_standalone
COVERAGE_APP = ./test
@@ -113,7 +138,7 @@ cleancov-clean:
cleancov: cleancov-clean clean
clean:
- rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
+ rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test timing 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/
${MAKE} -C etc/ clean MAKE=${MAKE}
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 51f703b..5d229e8 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -9,15 +9,12 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef BN_H_
#define BN_H_
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
#include <limits.h>
#include <tommath_class.h>
@@ -27,7 +24,7 @@ extern "C" {
#endif
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
-#if defined(_MSC_VER) || defined(__LLP64__)
+#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
# define MP_32BIT
#endif
@@ -38,8 +35,14 @@ extern "C" {
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
-# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT) || defined(_MSC_VER))
-# define MP_64BIT
+# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
+# if defined(__GNUC__)
+/* we support 128bit integers only via: __attribute__((mode(TI))) */
+# define MP_64BIT
+# else
+/* otherwise we fall back to MP_32BIT even on 64bit platforms */
+# define MP_32BIT
+# endif
# endif
#endif
@@ -54,37 +57,30 @@ typedef unsigned long long Tcl_WideUInt;
* [any size beyond that is ok provided it doesn't overflow the data type]
*/
#ifdef MP_8BIT
-typedef uint8_t mp_digit;
-typedef uint16_t mp_word;
+typedef unsigned char mp_digit;
+typedef unsigned short 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 uint16_t mp_digit;
-typedef uint32_t mp_word;
+typedef unsigned short mp_digit;
+typedef unsigned int 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 */
-typedef uint64_t mp_digit;
-# if defined(__GNUC__)
+typedef unsigned long long mp_digit;
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
#else
/* this is the default case, 28-bit digits */
/* this is to make porting into LibTomCrypt easier :-) */
-typedef uint32_t mp_digit;
-typedef uint64_t mp_word;
+typedef unsigned int mp_digit;
+typedef unsigned long long mp_word;
# ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
@@ -99,23 +95,11 @@ typedef uint64_t mp_word;
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT
# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
-typedef uint_least32_t mp_min_u32;
+typedef unsigned long mp_min_u32;
#else
typedef mp_digit mp_min_u32;
#endif
-/* use arc4random on platforms that support it */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
-# define MP_GEN_RANDOM() arc4random()
-# define MP_GEN_RANDOM_MAX 0xffffffffu
-#endif
-
-/* use rand() as fall-back if there's no better rand function */
-#ifndef MP_GEN_RANDOM
-# define MP_GEN_RANDOM() rand()
-# define MP_GEN_RANDOM_MAX RAND_MAX
-#endif
-
#define MP_DIGIT_BIT DIGIT_BIT
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
#define MP_DIGIT_MAX MP_MASK
@@ -225,7 +209,7 @@ int mp_set_int(mp_int *a, unsigned long b);
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, Tcl_WideUInt b);
+int mp_set_long_long(mp_int *a, unsigned long long b);
/* get a 32-bit value */
unsigned long mp_get_int(const mp_int *a);
@@ -234,7 +218,7 @@ unsigned long mp_get_int(const mp_int *a);
unsigned long mp_get_long(const mp_int *a);
/* get a platform dependent unsigned long long value */
-Tcl_WideUInt mp_get_long_long(const mp_int *a);
+unsigned long long mp_get_long_long(const mp_int *a);
/* initialize and set a digit */
int mp_init_set(mp_int *a, mp_digit b);
@@ -291,6 +275,14 @@ int mp_cnt_lsb(const mp_int *a);
/* makes a pseudo-random int of a given size */
int mp_rand(mp_int *a, int digits);
+#ifdef MP_PRNG_ENABLE_LTM_RNG
+/* as last resort we will fall back to libtomcrypt's rng_get_bytes()
+ * in case you don't use libtomcrypt or use it w/o rng_get_bytes()
+ * you have to implement it somewhere else, as it's required */
+extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
+extern void (*ltm_rng_callback)(void);
+#endif
+
/* ---> binary operations <--- */
/* c = a XOR b */
int mp_xor(const mp_int *a, const mp_int *b, mp_int *c);
@@ -301,8 +293,23 @@ int mp_or(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a AND b */
int mp_and(const mp_int *a, const mp_int *b, mp_int *c);
+/* c = a XOR b (two complement) */
+int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* c = a OR b (two complement) */
+int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* c = a AND b (two complement) */
+int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* right shift (two complement) */
+int mp_tc_div_2d(const mp_int *a, int b, mp_int *c);
+
/* ---> Basic arithmetic <--- */
+/* b = ~a */
+int mp_complement(const mp_int *a, mp_int *b);
+
/* b = -a */
int mp_neg(const mp_int *a, mp_int *b);
diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h
index f700d66..1989054 100644
--- a/libtommath/tommath_class.h
+++ b/libtommath/tommath_class.h
@@ -27,6 +27,7 @@
# define BN_MP_CMP_D_C
# define BN_MP_CMP_MAG_C
# define BN_MP_CNT_LSB_C
+# define BN_MP_COMPLEMENT_C
# define BN_MP_COPY_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_DIV_C
@@ -116,6 +117,10 @@
# define BN_MP_SUB_C
# define BN_MP_SUB_D_C
# define BN_MP_SUBMOD_C
+# define BN_MP_TC_AND_C
+# define BN_MP_TC_DIV_2D_C
+# define BN_MP_TC_OR_C
+# define BN_MP_TC_XOR_C
# define BN_MP_TO_SIGNED_BIN_C
# define BN_MP_TO_SIGNED_BIN_N_C
# define BN_MP_TO_UNSIGNED_BIN_C
@@ -147,12 +152,12 @@
# define BN_MP_INIT_MULTI_C
# define BN_MP_COPY_C
# define BN_MP_MOD_C
+# define BN_MP_ISZERO_C
# define BN_MP_SET_C
# define BN_MP_DIV_2_C
# define BN_MP_ISODD_C
# define BN_MP_SUB_C
# define BN_MP_CMP_C
-# define BN_MP_ISZERO_C
# define BN_MP_CMP_D_C
# define BN_MP_ADD_C
# define BN_MP_EXCH_C
@@ -241,6 +246,11 @@
# define BN_MP_ISZERO_C
#endif
+#if defined(BN_MP_COMPLEMENT_C)
+# define BN_MP_NEG_C
+# define BN_MP_SUB_D_C
+#endif
+
#if defined(BN_MP_COPY_C)
# define BN_MP_GROW_C
#endif
@@ -390,7 +400,8 @@
#if defined(BN_MP_FREAD_C)
# define BN_MP_ZERO_C
-# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
+# define BN_MP_S_RMAP_REVERSE_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
# define BN_MP_CMP_D_C
@@ -462,9 +473,8 @@
#endif
#if defined(BN_MP_INVMOD_C)
-# define BN_MP_ISZERO_C
-# define BN_MP_ISODD_C
# define BN_MP_CMP_D_C
+# define BN_MP_ISODD_C
# define BN_FAST_MP_INVMOD_C
# define BN_MP_INVMOD_SLOW_C
#endif
@@ -541,6 +551,7 @@
#endif
#if defined(BN_MP_LSHD_C)
+# define BN_MP_ISZERO_C
# define BN_MP_GROW_C
# define BN_MP_RSHD_C
#endif
@@ -714,6 +725,8 @@
#if defined(BN_MP_RADIX_SMAP_C)
# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
#endif
#if defined(BN_MP_RAND_C)
@@ -724,7 +737,8 @@
#if defined(BN_MP_READ_RADIX_C)
# define BN_MP_ZERO_C
-# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
+# define BN_MP_S_RMAP_REVERSE_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
# define BN_MP_ISZERO_C
@@ -904,6 +918,49 @@
# define BN_MP_MOD_C
#endif
+#if defined(BN_MP_TC_AND_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_AND_C
+# define BN_MP_SUB_C
+#endif
+
+#if defined(BN_MP_TC_DIV_2D_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_DIV_2D_C
+# define BN_MP_ADD_D_C
+# define BN_MP_SUB_D_C
+#endif
+
+#if defined(BN_MP_TC_OR_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_OR_C
+# define BN_MP_SUB_C
+#endif
+
+#if defined(BN_MP_TC_XOR_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_XOR_C
+# define BN_MP_SUB_C
+#endif
+
#if defined(BN_MP_TO_SIGNED_BIN_C)
# define BN_MP_TO_UNSIGNED_BIN_C
#endif
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index fd25141..f042684 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -9,8 +9,6 @@
*
* 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_
@@ -75,7 +73,7 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode);
void bn_reverse(unsigned char *s, int len);
-extern const char *mp_s_rmap;
+extern const char *const mp_s_rmap;
extern const unsigned char mp_s_rmap_reverse[];
extern const size_t mp_s_rmap_reverse_sz;
diff --git a/macosx/tclMacOSXNotify.c b/macosx/tclMacOSXNotify.c
index 1af73de..b21130b 100644
--- a/macosx/tclMacOSXNotify.c
+++ b/macosx/tclMacOSXNotify.c
@@ -31,6 +31,9 @@
*/
#if defined(HAVE_LIBKERN_OSATOMIC_H) && defined(HAVE_OSSPINLOCKLOCK)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#pragma GCC diagnostic ignored "-Wunused-function"
/*
* Use OSSpinLock API where available (Tiger or later).
*/
@@ -42,14 +45,17 @@
* Support for weakly importing spinlock API.
*/
#define WEAK_IMPORT_SPINLOCKLOCK
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#define VOLATILE volatile
#else
#define VOLATILE
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 */
+
#ifndef bool
#define bool int
#endif
+
extern void OSSpinLockLock(VOLATILE OSSpinLock *lock)
WEAK_IMPORT_ATTRIBUTE;
extern void OSSpinLockUnlock(VOLATILE OSSpinLock *lock)
@@ -77,13 +83,54 @@ SpinLockLockInit(void)
Tcl_Panic("SpinLockLockInit: no spinlock API available");
}
}
-#define SpinLockLock(p) lockLock(p)
-#define SpinLockUnlock(p) lockUnlock(p)
-#define SpinLockTry(p) lockTry(p)
-#else
-#define SpinLockLock(p) OSSpinLockLock(p)
-#define SpinLockUnlock(p) OSSpinLockUnlock(p)
-#define SpinLockTry(p) OSSpinLockTry(p)
+
+/*
+ * Wrappers so that we get warnings in just one small part of this file.
+ */
+
+static inline void
+SpinLockLock(
+ VOLATILE OSSpinLock *lock)
+{
+ lockLock(lock);
+}
+static inline void
+SpinLockUnlock(
+ VOLATILE OSSpinLock *lock)
+{
+ lockUnlock(lock);
+}
+static inline bool
+SpinLockTry(
+ VOLATILE OSSpinLock *lock)
+{
+ return lockTry(lock);
+}
+
+#else /* !HAVE_WEAK_IMPORT */
+
+/*
+ * Wrappers so that we get warnings in just one small part of this file.
+ */
+
+static inline void
+SpinLockLock(
+ OSSpinLock *lock)
+{
+ OSSpinLockLock(lock);
+}
+static inline void
+SpinLockUnlock(
+ OSSpinLock *lock)
+{
+ OSSpinLockUnlock(lock);
+}
+static inline bool
+SpinLockTry(
+ OSSpinLock *lock)
+{
+ return OSSpinLockTry(lock);
+}
#endif /* HAVE_WEAK_IMPORT */
#define SPINLOCK_INIT OS_SPINLOCK_INIT
@@ -93,14 +140,37 @@ SpinLockLockInit(void)
*/
typedef uint32_t OSSpinLock;
-extern void _spin_lock(OSSpinLock *lock);
-extern void _spin_unlock(OSSpinLock *lock);
-extern int _spin_lock_try(OSSpinLock *lock);
-#define SpinLockLock(p) _spin_lock(p)
-#define SpinLockUnlock(p) _spin_unlock(p)
-#define SpinLockTry(p) _spin_lock_try(p)
+
+static inline void
+SpinLockLock(
+ OSSpinLock *lock)
+{
+ extern void _spin_lock(OSSpinLock *lock);
+
+ _spin_lock(lock);
+}
+
+static inline void
+SpinLockUnlock(
+ OSSpinLock *lock)
+{
+ extern void _spin_unlock(OSSpinLock *lock);
+
+ _spin_unlock(lock);
+}
+
+static inline int
+SpinLockTry(
+ OSSpinLock *lock)
+{
+ extern int _spin_lock_try(OSSpinLock *lock);
+
+ return _spin_lock_try(lock);
+}
+
#define SPINLOCK_INIT 0
+#pragma GCC diagnostic pop
#endif /* HAVE_LIBKERN_OSATOMIC_H && HAVE_OSSPINLOCKLOCK */
/*
@@ -1411,7 +1481,10 @@ UpdateWaitingListAndServiceEvents(
(tsdPtr->runLoopNestingLevel > 1
|| !tsdPtr->runLoopRunning)) {
tsdPtr->runLoopServicingEvents = 1;
- /* This call seems to simply force event processing through and prevents hangups that have long been observed with Tk-Cocoa. */
+ /*
+ * This call seems to simply force event processing through and
+ * prevents hangups that have long been observed with Tk-Cocoa.
+ */
Tcl_ServiceAll();
tsdPtr->runLoopServicingEvents = 0;
}
diff --git a/tests/oo.test b/tests/oo.test
index 4e50904..37c4495 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -1802,6 +1802,106 @@ test oo-13.4 {OO: changing an object's class} -body {
foo destroy
bar destroy
} -result {::foo ::foo ::foo ::bar}
+test oo-13.5 {OO: changing an object's class: non-class to class} -setup {
+ oo::object create fooObj
+} -body {
+ oo::objdefine fooObj {
+ class oo::class
+ }
+ oo::define fooObj {
+ method x {} {expr 1+2+3}
+ }
+ [fooObj new] x
+} -cleanup {
+ fooObj destroy
+} -result 6
+test oo-13.6 {OO: changing an object's class: class to non-class} -setup {
+ oo::class create foo
+ unset -nocomplain ::result
+} -body {
+ set result dangling
+ oo::define foo {
+ method x {} {expr 1+2+3}
+ }
+ oo::class create boo {
+ superclass foo
+ destructor {set ::result "ok"}
+ }
+ boo new
+ foo create bar
+ oo::objdefine foo {
+ class oo::object
+ }
+ list $result [catch {bar x} msg] $msg
+} -cleanup {
+ catch {bar destroy}
+ foo destroy
+} -result {ok 1 {invalid command name "bar"}}
+test oo-13.7 {OO: changing an object's class} -setup {
+ oo::class create foo
+ oo::class create bar
+ unset -nocomplain result
+} -body {
+ oo::define bar method x {} {return ok}
+ oo::define foo {
+ method x {} {expr 1+2+3}
+ self mixin foo
+ }
+ lappend result [foo x]
+ oo::objdefine foo class bar
+ lappend result [foo x]
+} -cleanup {
+ foo destroy
+ bar destroy
+} -result {6 ok}
+test oo-13.8 {OO: changing an object's class to itself} -setup {
+ oo::class create foo
+} -body {
+ oo::define foo {
+ method x {} {expr 1+2+3}
+ }
+ oo::objdefine foo class foo
+} -cleanup {
+ foo destroy
+} -returnCodes error -result {may not change classes into an instance of themselves}
+test oo-13.9 {OO: changing an object's class: roots are special} -setup {
+ set i [interp create]
+} -body {
+ $i eval {
+ oo::objdefine oo::object {
+ class oo::class
+ }
+ }
+} -cleanup {
+ interp delete $i
+} -returnCodes error -result {may not modify the class of the root object class}
+test oo-13.10 {OO: changing an object's class: roots are special} -setup {
+ set i [interp create]
+} -body {
+ $i eval {
+ oo::objdefine oo::class {
+ class oo::object
+ }
+ }
+} -cleanup {
+ interp delete $i
+} -returnCodes error -result {may not modify the class of the class of classes}
+test oo-13.11 {OO: changing an object's class in a tricky place} -setup {
+ oo::class create cls
+ unset -nocomplain result
+} -body {
+ set result gorp
+ list [catch {
+ oo::define cls {
+ method x {} {return}
+ self class oo::object
+ ::set ::result ok
+ method y {} {return}; # I'm sorry, Dave. I'm afraid I can't do that.
+ }
+ } msg] $msg $result
+} -cleanup {
+ cls destroy
+} -result {1 {attempt to misuse API} ok}
# todo: changing a class subtype (metaclass) to another class subtype
test oo-14.1 {OO: mixins} {
diff --git a/tests/registry.test b/tests/registry.test
index fec4cc0..539ba2d 100644
--- a/tests/registry.test
+++ b/tests/registry.test
@@ -19,7 +19,7 @@ testConstraint reg 0
if {[testConstraint win]} {
if {![catch {
::tcltest::loadTestedCommands
- set ::regver [package require registry 1.3.2]
+ set ::regver [package require registry 1.3.3]
}]} {
testConstraint reg 1
}
@@ -33,7 +33,7 @@ testConstraint english [expr {
test registry-1.0 {check if we are testing the right dll} {win reg} {
set ::regver
-} {1.3.2}
+} {1.3.3}
test registry-1.1 {argument parsing for registry command} {win reg} {
list [catch {registry} msg] $msg
} {1 {wrong # args: should be "registry ?-32bit|-64bit? option ?arg ...?"}}
diff --git a/tests/util.test b/tests/util.test
index 34113c0..5079a89 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -586,14 +586,14 @@ test util-9.2.1 {TclGetIntForIndex} -body {
test util-9.2.2 {TclGetIntForIndex} -body {
string index abcd {end }
} -returnCodes error -match glob -result *
-test util-9.3 {TclGetIntForIndex} {
+test util-9.3 {TclGetIntForIndex} -body {
# Deprecated
string index abcd en
-} d
-test util-9.4 {TclGetIntForIndex} {
+} -returnCodes error -match glob -result *
+test util-9.4 {TclGetIntForIndex} -body {
# Deprecated
string index abcd e
-} d
+} -returnCodes error -match glob -result *
test util-9.5.0 {TclGetIntForIndex} {
string index abcd end-1
} c
@@ -735,6 +735,43 @@ test util-9.45 {TclGetIntForIndex} {
test util-9.46 {TclGetIntForIndex} {
string index abcd end+4294967294
} {}
+# TIP 502
+test util-9.47 {TclGetIntForIndex} {
+ string index abcd 0x10000000000000000
+} {}
+test util-9.48 {TclGetIntForIndex} {
+ string index abcd -0x10000000000000000
+} {}
+test util-9.49 {TclGetIntForIndex} -body {
+ string index abcd end*1
+} -returnCodes error -match glob -result *
+test util-9.50 {TclGetIntForIndex} -body {
+ string index abcd {end- 1}
+} -returnCodes error -match glob -result *
+test util-9.51 {TclGetIntForIndex} -body {
+ string index abcd end-end
+} -returnCodes error -match glob -result *
+test util-9.52 {TclGetIntForIndex} -body {
+ string index abcd end-x
+} -returnCodes error -match glob -result *
+test util-9.53 {TclGetIntForIndex} -body {
+ string index abcd end-0.1
+} -returnCodes error -match glob -result *
+test util-9.54 {TclGetIntForIndex} {
+ string index abcd end-0x10000000000000000
+} {}
+test util-9.55 {TclGetIntForIndex} {
+ string index abcd end+0x10000000000000000
+} {}
+test util-9.56 {TclGetIntForIndex} {
+ string index abcd end--0x10000000000000000
+} {}
+test util-9.57 {TclGetIntForIndex} {
+ string index abcd end+-0x10000000000000000
+} {}
+test util-9.58 {TclGetIntForIndex} {
+ string index abcd end--0x8000000000000000
+} {}
test util-10.1 {Tcl_PrintDouble - rounding} {ieeeFloatingPoint} {
convertDouble 0x0000000000000000
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index 830ba2b..f2f410f 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -198,6 +198,13 @@ proc genStubs::declare {args} {
|| ($index > $stubs($curName,generic,lastNum))} {
set stubs($curName,generic,lastNum) $index
}
+ } elseif {([lindex $platformList 0] eq "nostub")} {
+ set stubs($curName,nostub,$index) [lindex $platformList 1]
+ set stubs($curName,generic,$index) $decl
+ if {![info exists stubs($curName,generic,lastNum)] \
+ || ($index > $stubs($curName,generic,lastNum))} {
+ set stubs($curName,generic,lastNum) $index
+ }
} else {
foreach platform $platformList {
if {$decl ne ""} {
@@ -593,6 +600,8 @@ proc genStubs::makeSlot {name decl index} {
set text " "
if {[info exists stubs($name,deprecated,$index)]} {
append text "TCL_DEPRECATED_API(\"$stubs($name,deprecated,$index)\") "
+ } elseif {[info exists stubs($name,nostub,$index)]} {
+ append text "TCL_DEPRECATED_API(\"$stubs($name,nostub,$index)\") "
}
if {$args eq ""} {
append text $rtype " *" $lfname "; /* $index */\n"
@@ -705,6 +714,9 @@ proc genStubs::forAllStubs {name slotProc onAll textVar
if {[info exists stubs($name,deprecated,$i)]} {
append text [$slotProc $name $stubs($name,generic,$i) $i]
set emit 1
+ } elseif {[info exists stubs($name,nostub,$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:\
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 487ae61..b2ea458 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -858,8 +858,7 @@ install: $(INSTALL_TARGETS)
install-strip:
$(MAKE) $(INSTALL_TARGETS) \
- INSTALL_PROGRAM="$(INSTALL_PROGRAM) ${INSTALL_STRIP_PROGRAM}" \
- INSTALL_LIBRARY="$(INSTALL_LIBRARY) ${INSTALL_STRIP_LIBRARY}"
+ INSTALL_PROGRAM="$(INSTALL_PROGRAM) ${INSTALL_STRIP_PROGRAM}"
install-binaries: binaries
@for i in "$(LIB_INSTALL_DIR)" "$(BIN_INSTALL_DIR)" \
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 2abfd47..7a5e09d 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -2,8 +2,8 @@
* tclEpollNotfy.c --
*
* This file contains the implementation of the epoll()-based
- * Linux-specific notifier, which is the lowest-level part of the
- * Tcl event loop. This file works together with generic/tclNotify.c.
+ * Linux-specific notifier, which is the lowest-level part of the Tcl
+ * event loop. This file works together with generic/tclNotify.c.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 2016 Lucio Andrés Illanes Albornoz <l.illanes@gmx.de>
@@ -13,11 +13,10 @@
*/
#include "tclInt.h"
-#if defined(NOTIFIER_EPOLL) && TCL_THREADS
-
-#define _GNU_SOURCE /* For pipe2(2) */
#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier is
* in tclMacOSXNotify.c */
+#if defined(NOTIFIER_EPOLL) && TCL_THREADS
+#define _GNU_SOURCE /* For pipe2(2) */
#include <fcntl.h>
#include <signal.h>
#include <sys/epoll.h>
@@ -54,9 +53,9 @@ typedef struct FileHandler {
} FileHandler;
/*
- * The following structure associates a FileHandler and the thread that owns it
- * with the file descriptors of interest and their event masks passed to epoll_ctl(2)
- * and their corresponding event(s) returned by epoll_wait(2).
+ * The following structure associates a FileHandler and the thread that owns
+ * it with the file descriptors of interest and their event masks passed to
+ * epoll_ctl(2) and their corresponding event(s) returned by epoll_wait(2).
*/
struct ThreadSpecificData;
@@ -105,7 +104,8 @@ typedef struct ThreadSpecificData {
int triggerPipe[2]; /* pipe(2) used by other threads to wake
* up this thread for inter-thread IPC. */
#endif /* HAVE_EVENTFD */
- int eventsFd; /* epoll(7) file descriptor used to wait for fds */
+ int eventsFd; /* epoll(7) file descriptor used to wait for
+ * fds */
struct epoll_event *readyEvents;
/* Pointer to at most maxReadyEvents events
* returned by epoll_wait(2). */
@@ -113,13 +113,23 @@ typedef struct ThreadSpecificData {
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-
-static void PlatformEventsControl(FileHandler *filePtr, ThreadSpecificData *tsdPtr, int op, int isNew);
-static void PlatformEventsFinalize(void);
-static void PlatformEventsInit(void);
-static int PlatformEventsTranslate(struct epoll_event *event);
-static int PlatformEventsWait(struct epoll_event *events, size_t numEvents, struct timeval *timePtr);
-
+
+/*
+ * Forward declarations.
+ */
+
+static void PlatformEventsControl(FileHandler *filePtr,
+ ThreadSpecificData *tsdPtr, int op, int isNew);
+static void PlatformEventsFinalize(void);
+static void PlatformEventsInit(void);
+static int PlatformEventsTranslate(struct epoll_event *event);
+static int PlatformEventsWait(struct epoll_event *events,
+ size_t numEvents, struct timeval *timePtr);
+
+/*
+ * Incorporate the base notifier API.
+ */
+
#include "tclUnixNotfy.c"
/*
@@ -190,31 +200,32 @@ Tcl_FinalizeNotifier(
* This function registers interest for the file descriptor and the mask
* of TCL_* bits associated with filePtr on the epoll file descriptor
* associated with tsdPtr.
- * Future calls to epoll_wait will return filePtr and tsdPtr alongside with
- * the event registered here via the PlatformEventData struct.
+ *
+ * Future calls to epoll_wait will return filePtr and tsdPtr alongside
+ * with the event registered here via the PlatformEventData struct.
*
* Results:
* None.
*
* Side effects:
- * If adding a new file descriptor, a PlatformEventData struct will be
- * allocated and associated with filePtr.
- * fstat is called on the file descriptor; if it is associated with
- * a regular file (S_IFREG,) filePtr is considered to be ready for I/O
- * and added to or deleted from the corresponding list in tsdPtr.
- * If it is not associated with a regular file, the file descriptor is
- * added, modified concerning its mask of events of interest, or deleted
- * from the epoll file descriptor of the calling thread.
+ * - If adding a new file descriptor, a PlatformEventData struct will be
+ * allocated and associated with filePtr.
+ * - fstat is called on the file descriptor; if it is associated with a
+ * regular file (S_IFREG,) filePtr is considered to be ready for I/O
+ * and added to or deleted from the corresponding list in tsdPtr.
+ * - If it is not associated with a regular file, the file descriptor is
+ * added, modified concerning its mask of events of interest, or
+ * deleted from the epoll file descriptor of the calling thread.
*
*----------------------------------------------------------------------
*/
void
PlatformEventsControl(
- FileHandler *filePtr,
- ThreadSpecificData *tsdPtr,
- int op,
- int isNew)
+ FileHandler *filePtr,
+ ThreadSpecificData *tsdPtr,
+ int op,
+ int isNew)
{
struct epoll_event newEvent;
struct PlatformEventData *newPedPtr;
@@ -236,10 +247,10 @@ PlatformEventsControl(
newEvent.data.ptr = filePtr->pedPtr;
/*
- * N.B. As discussed in Tcl_WaitForEvent(), epoll(7) does not sup-
- * port regular files (S_IFREG.) Therefore, filePtr is in these
- * cases simply added or deleted from the list of FileHandlers
- * associated with regular files belonging to tsdPtr.
+ * N.B. As discussed in Tcl_WaitForEvent(), epoll(7) does not support
+ * regular files (S_IFREG.) Therefore, filePtr is in these cases simply
+ * added or deleted from the list of FileHandlers associated with regular
+ * files belonging to tsdPtr.
*/
if (fstat(filePtr->fd, &fdStat) == -1) {
@@ -248,7 +259,8 @@ PlatformEventsControl(
switch (op) {
case EPOLL_CTL_ADD:
if (isNew) {
- LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr, filePtr, readyNode);
+ LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr, filePtr,
+ readyNode);
}
break;
case EPOLL_CTL_DEL:
@@ -267,18 +279,18 @@ PlatformEventsControl(
* PlatformEventsFinalize --
*
* This function closes the eventfd and the epoll file descriptor and
- * frees the epoll_event structs owned by the thread of the caller.
- * The above operations are protected by tsdPtr->notifierMutex, which
- * is destroyed thereafter.
+ * frees the epoll_event structs owned by the thread of the caller. The
+ * above operations are protected by tsdPtr->notifierMutex, which is
+ * destroyed thereafter.
*
* Results:
* None.
*
* Side effects:
* While tsdPtr->notifierMutex is held:
- * The per-thread eventfd(2) is closed, if non-zero, and set to -1.
- * The per-thread epoll(7) fd is closed, if non-zero, and set to 0.
- * The per-thread epoll_event structs are freed, if any, and set to 0.
+ * - The per-thread eventfd(2) is closed, if non-zero, and set to -1.
+ * - The per-thread epoll(7) fd is closed, if non-zero, and set to 0.
+ * - The per-thread epoll_event structs are freed, if any, and set to 0.
*
* tsdPtr->notifierMutex is destroyed.
*
@@ -297,7 +309,7 @@ PlatformEventsFinalize(
close(tsdPtr->triggerEventFd);
tsdPtr->triggerEventFd = -1;
}
-#else
+#else /* !HAVE_EVENTFD */
if (tsdPtr->triggerPipe[0]) {
close(tsdPtr->triggerPipe[0]);
tsdPtr->triggerPipe[0] = -1;
@@ -337,20 +349,20 @@ PlatformEventsFinalize(
*
* Side effects:
* The following per-thread entities are initialised:
- * notifierMutex is initialised.
- * The eventfd(2) is created w/ EFD_CLOEXEC and EFD_NONBLOCK.
- * The epoll(7) fd is created w/ EPOLL_CLOEXEC.
- * A FileHandler struct is allocated and initialised for the event-
- * fd(2), registering interest for TCL_READABLE on it via Platform-
- * EventsControl().
- * readyEvents and maxReadyEvents are initialised with 512 epoll_events.
+ * - notifierMutex is initialised.
+ * - The eventfd(2) is created w/ EFD_CLOEXEC and EFD_NONBLOCK.
+ * - The epoll(7) fd is created w/ EPOLL_CLOEXEC.
+ * - A FileHandler struct is allocated and initialised for the
+ * eventfd(2), registering interest for TCL_READABLE on it via
+ * PlatformEventsControl().
+ * - readyEvents and maxReadyEvents are initialised with 512
+ * epoll_events.
*
*----------------------------------------------------------------------
*/
void
-PlatformEventsInit(
- void)
+PlatformEventsInit(void)
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr;
@@ -361,16 +373,17 @@ PlatformEventsInit(
}
filePtr = ckalloc(sizeof(*filePtr));
#ifdef HAVE_EVENTFD
- if ((tsdPtr->triggerEventFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)) <= 0) {
+ tsdPtr->triggerEventFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+ if (tsdPtr->triggerEventFd <= 0) {
Tcl_Panic("Tcl_InitNotifier: %s", "could not create trigger eventfd");
}
filePtr->fd = tsdPtr->triggerEventFd;
-#else
+#else /* !HAVE_EVENTFD */
if (pipe2(tsdPtr->triggerPipe, O_CLOEXEC | O_NONBLOCK) != 0) {
Tcl_Panic("Tcl_InitNotifier: %s", "could not create trigger pipe");
}
filePtr->fd = tsdPtr->triggerPipe[0];
-#endif
+#endif /* HAVE_EVENTFD */
tsdPtr->triggerFilePtr = filePtr;
if ((tsdPtr->eventsFd = epoll_create1(EPOLL_CLOEXEC)) == -1) {
Tcl_Panic("epoll_create1: %s", strerror(errno));
@@ -379,8 +392,8 @@ PlatformEventsInit(
PlatformEventsControl(filePtr, tsdPtr, EPOLL_CTL_ADD, 1);
if (!tsdPtr->readyEvents) {
tsdPtr->maxReadyEvents = 512;
- tsdPtr->readyEvents = ckalloc(tsdPtr->maxReadyEvents
- * sizeof(tsdPtr->readyEvents[0]));
+ tsdPtr->readyEvents = ckalloc(
+ tsdPtr->maxReadyEvents * sizeof(tsdPtr->readyEvents[0]));
}
LIST_INIT(&tsdPtr->firstReadyFileHandlerPtr);
}
@@ -390,8 +403,8 @@ PlatformEventsInit(
*
* PlatformEventsTranslate --
*
- * This function translates the platform-specific mask of returned
- * events in eventPtr to a mask of TCL_* bits.
+ * This function translates the platform-specific mask of returned events
+ * in eventPtr to a mask of TCL_* bits.
*
* Results:
* Returns the translated mask.
@@ -404,7 +417,7 @@ PlatformEventsInit(
int
PlatformEventsTranslate(
- struct epoll_event *eventPtr)
+ struct epoll_event *eventPtr)
{
int mask;
@@ -429,16 +442,16 @@ PlatformEventsTranslate(
* This function abstracts waiting for I/O events via epoll_wait.
*
* Results:
- * Returns -1 if epoll_wait failed. Returns 0 if polling and if no
- * events became available whilst polling. Returns a pointer to and
- * the count of all returned events in all other cases.
+ * Returns -1 if epoll_wait failed. Returns 0 if polling and if no events
+ * became available whilst polling. Returns a pointer to and the count of
+ * all returned events in all other cases.
*
* Side effects:
- * gettimeofday(2), epoll_wait(2), and gettimeofday(2) are called,
- * in the specified order.
- * If timePtr specifies a positive value, it is updated to reflect
- * the amount of time that has passed; if its value would {under,
- * over}flow, it is set to zero.
+ * gettimeofday(2), epoll_wait(2), and gettimeofday(2) are called, in the
+ * specified order.
+ * If timePtr specifies a positive value, it is updated to reflect the
+ * amount of time that has passed; if its value would {under, over}flow,
+ * it is set to zero.
*
*----------------------------------------------------------------------
*/
@@ -457,8 +470,8 @@ PlatformEventsWait(
/*
* If timePtr is NULL, epoll_wait(2) will wait indefinitely. If it
- * specifies a timeout of {0,0}, epoll_wait(2) will poll. Otherwise,
- * the timeout will simply be converted to milliseconds.
+ * specifies a timeout of {0,0}, epoll_wait(2) will poll. Otherwise, the
+ * timeout will simply be converted to milliseconds.
*/
if (!timePtr) {
@@ -473,9 +486,9 @@ PlatformEventsWait(
}
/*
- * Call (and possibly block on) epoll_wait(2) and substract the delta
- * of gettimeofday(2) before and after the call from timePtr if the
- * latter is not NULL. Return the number of events returned by epoll_wait(2).
+ * Call (and possibly block on) epoll_wait(2) and substract the delta of
+ * gettimeofday(2) before and after the call from timePtr if the latter is
+ * not NULL. Return the number of events returned by epoll_wait(2).
*/
gettimeofday(&tv0, NULL);
@@ -484,10 +497,10 @@ PlatformEventsWait(
if (timePtr && (timePtr->tv_sec && timePtr->tv_usec)) {
timersub(&tv1, &tv0, &tv_delta);
if (!timercmp(&tv_delta, timePtr, >)) {
- timersub(timePtr, &tv_delta, timePtr);
+ timersub(timePtr, &tv_delta, timePtr);
} else {
- timePtr->tv_sec = 0;
- timePtr->tv_usec = 0;
+ timePtr->tv_sec = 0;
+ timePtr->tv_usec = 0;
}
}
return numFound;
@@ -498,8 +511,8 @@ PlatformEventsWait(
*
* Tcl_CreateFileHandler --
*
- * This function registers a file handler with the epoll notifier
- * of the thread of the caller.
+ * This function registers a file handler with the epoll notifier of the
+ * thread of the caller.
*
* Results:
* None.
@@ -551,8 +564,8 @@ Tcl_CreateFileHandler(
filePtr->clientData = clientData;
filePtr->mask = mask;
- PlatformEventsControl(filePtr, tsdPtr, isNew ?
- EPOLL_CTL_ADD : EPOLL_CTL_MOD, isNew);
+ PlatformEventsControl(filePtr, tsdPtr,
+ isNew ? EPOLL_CTL_ADD : EPOLL_CTL_MOD, isNew);
}
}
@@ -561,8 +574,8 @@ Tcl_CreateFileHandler(
*
* Tcl_DeleteFileHandler --
*
- * Cancel a previously-arranged callback arrangement for a file on
- * the epoll file descriptor of the thread of the caller.
+ * Cancel a previously-arranged callback arrangement for a file on the
+ * epoll file descriptor of the thread of the caller.
*
* Results:
* None.
@@ -632,6 +645,7 @@ Tcl_DeleteFileHandler(
* This function is called by Tcl_DoOneEvent to wait for new events on
* the message queue. If the block time is 0, then Tcl_WaitForEvent just
* polls without blocking.
+ *
* The waiting logic is implemented in PlatformEventsWait.
*
* Results:
@@ -646,7 +660,7 @@ Tcl_DeleteFileHandler(
int
Tcl_WaitForEvent(
- const Tcl_Time *timePtr) /* Maximum block time, or NULL. */
+ const Tcl_Time *timePtr) /* Maximum block time, or NULL. */
{
if (tclNotifierHooks.waitForEventProc) {
return tclNotifierHooks.waitForEventProc(timePtr);
@@ -696,10 +710,11 @@ Tcl_WaitForEvent(
* Walk the list of FileHandlers associated with regular files
* (S_IFREG) belonging to tsdPtr, queue Tcl events for them, and
* update their mask of events of interest.
+ *
* As epoll(7) does not support regular files, the behaviour of
* {select,poll}(2) is simply simulated here: fds associated with
- * regular files are added to this list by PlatformEventsControl()
- * and processed here before calling (and possibly blocking) on
+ * regular files are added to this list by PlatformEventsControl() and
+ * processed here before calling (and possibly blocking) on
* PlatformEventsWait().
*/
@@ -720,7 +735,7 @@ Tcl_WaitForEvent(
if (filePtr->readyMask == 0) {
FileHandlerEvent *fileEvPtr =
- ckalloc(sizeof(FileHandlerEvent));
+ ckalloc(sizeof(FileHandlerEvent));
fileEvPtr->header.proc = FileHandlerEventProc;
fileEvPtr->fd = filePtr->fd;
@@ -731,9 +746,9 @@ Tcl_WaitForEvent(
}
/*
- * If any events were queued in the above loop, force PlatformEvents-
- * Wait() to poll as there already are events that need to be processed
- * at this point.
+ * If any events were queued in the above loop, force
+ * PlatformEventsWait() to poll as there already are events that need
+ * to be processed at this point.
*/
if (numQueued) {
@@ -751,10 +766,12 @@ Tcl_WaitForEvent(
* to facilitate inter-thread IPC. If another thread intends to wake
* up this thread whilst it's blocking on PlatformEventsWait(), it
* write(2)s to the eventfd(2)/trigger pipe (see Tcl_AlertNotifier(),)
- * which in turn will cause PlatformEventsWait() to return immediately.
+ * which in turn will cause PlatformEventsWait() to return
+ * immediately.
*/
- numFound = PlatformEventsWait(tsdPtr->readyEvents, tsdPtr->maxReadyEvents, timeoutPtr);
+ numFound = PlatformEventsWait(tsdPtr->readyEvents,
+ tsdPtr->maxReadyEvents, timeoutPtr);
for (numEvent = 0; numEvent < numFound; numEvent++) {
pedPtr = tsdPtr->readyEvents[numEvent].data.ptr;
filePtr = pedPtr->filePtr;
@@ -762,21 +779,28 @@ Tcl_WaitForEvent(
#ifdef HAVE_EVENTFD
if (filePtr->fd == tsdPtr->triggerEventFd) {
uint64_t eventFdVal;
- i = read(tsdPtr->triggerEventFd, &eventFdVal, sizeof(eventFdVal));
+ i = read(tsdPtr->triggerEventFd, &eventFdVal,
+ sizeof(eventFdVal));
if ((i != sizeof(eventFdVal)) && (errno != EAGAIN)) {
-#else
+ Tcl_Panic(
+ "Tcl_WaitForEvent: read from %p->triggerEventFd: %s",
+ (void *) tsdPtr, strerror(errno));
+ }
+ continue;
+ }
+#else /* !HAVE_EVENTFD */
if (filePtr->fd == tsdPtr->triggerPipe[0]) {
char triggerPipeVal;
- i = read(tsdPtr->triggerPipe[0], &triggerPipeVal, sizeof(triggerPipeVal));
+ i = read(tsdPtr->triggerPipe[0], &triggerPipeVal,
+ sizeof(triggerPipeVal));
if ((i != sizeof(triggerPipeVal)) && (errno != EAGAIN)) {
-#endif
- Tcl_Panic("Tcl_WaitForEvent: "
- "read from %p->triggerEventFd: %s",
- (void *)tsdPtr, strerror(errno));
- } else {
- continue;
+ Tcl_Panic(
+ "Tcl_WaitForEvent: read from %p->triggerPipe[0]: %s",
+ (void *) tsdPtr, strerror(errno));
}
+ continue;
}
+#endif /* HAVE_EVENTFD */
if (!mask) {
continue;
}
@@ -800,9 +824,8 @@ Tcl_WaitForEvent(
}
}
+#endif /* NOTIFIER_EPOLL && TCL_THREADS */
#endif /* !HAVE_COREFOUNDATION */
-
-#endif /* NOTIFIER_EPOLL */
/*
* Local Variables:
diff --git a/unix/tclKqueueNotfy.c b/unix/tclKqueueNotfy.c
index 6d685ad..99d794e 100644
--- a/unix/tclKqueueNotfy.c
+++ b/unix/tclKqueueNotfy.c
@@ -14,10 +14,10 @@
*/
#include "tclInt.h"
-#if defined(NOTIFIER_KQUEUE) && TCL_THREADS
-
#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier is
* in tclMacOSXNotify.c */
+#if defined(NOTIFIER_KQUEUE) && TCL_THREADS
+
#include <signal.h>
#include <sys/types.h>
#include <sys/event.h>
@@ -51,9 +51,9 @@ typedef struct FileHandler {
} FileHandler;
/*
- * The following structure associates a FileHandler and the thread that owns it
- * with the file descriptors of interest and their event masks passed to kevent(2)
- * and their corresponding event(s) returned by kevent(2).
+ * The following structure associates a FileHandler and the thread that owns
+ * it with the file descriptors of interest and their event masks passed to
+ * kevent(2) and their corresponding event(s) returned by kevent(2).
*/
struct ThreadSpecificData;
@@ -96,20 +96,27 @@ typedef struct ThreadSpecificData {
* PlatformEventsFinalize. */
int triggerPipe[2]; /* pipe(2) used by other threads to wake
* up this thread for inter-thread IPC. */
- int eventsFd; /* kqueue(2) file descriptor used to wait for fds. */
+ int eventsFd; /* kqueue(2) file descriptor used to wait for
+ * fds. */
struct kevent *readyEvents; /* Pointer to at most maxReadyEvents events
* returned by kevent(2). */
size_t maxReadyEvents; /* Count of kevents in readyEvents. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-
-static void PlatformEventsControl(FileHandler *filePtr, ThreadSpecificData *tsdPtr, int op, int isNew);
-static void PlatformEventsFinalize(void);
-static void PlatformEventsInit(void);
-static int PlatformEventsTranslate(struct kevent *eventPtr);
-static int PlatformEventsWait(struct kevent *events, size_t numEvents, struct timeval *timePtr);
-
+
+/*
+ * Forward declarations of internal functions.
+ */
+
+static void PlatformEventsControl(FileHandler *filePtr,
+ ThreadSpecificData *tsdPtr, int op, int isNew);
+static void PlatformEventsFinalize(void);
+static void PlatformEventsInit(void);
+static int PlatformEventsTranslate(struct kevent *eventPtr);
+static int PlatformEventsWait(struct kevent *events,
+ size_t numEvents, struct timeval *timePtr);
+
#include "tclUnixNotfy.c"
/*
@@ -180,6 +187,7 @@ Tcl_FinalizeNotifier(
* This function registers interest for the file descriptor and the mask
* of TCL_* bits associated with filePtr on the kqueue file descriptor
* associated with tsdPtr.
+ *
* Future calls to kevent will return filePtr and tsdPtr alongside with
* the event registered here via the PlatformEventData struct.
*
@@ -187,26 +195,26 @@ Tcl_FinalizeNotifier(
* None.
*
* Side effects:
- * If adding a new file descriptor, a PlatformEventData struct will be
- * allocated and associated with filePtr.
- * fstat is called on the file descriptor; if it is associated with
- * a regular file (S_IFREG,) filePtr is considered to be ready for I/O
- * and added to or deleted from the corresponding list in tsdPtr.
- * If it is not associated with a regular file, the file descriptor is
- * added, modified concerning its mask of events of interest, or deleted
- * from the epoll file descriptor of the calling thread.
- * If deleting a file descriptor, kevent(2) is called twice specifying
- * EVFILT_READ first and then EVFILT_WRITE (see note below.)
+ * - If adding a new file descriptor, a PlatformEventData struct will be
+ * allocated and associated with filePtr.
+ * - fstat is called on the file descriptor; if it is associated with
+ * a regular file (S_IFREG,) filePtr is considered to be ready for I/O
+ * and added to or deleted from the corresponding list in tsdPtr.
+ * - If it is not associated with a regular file, the file descriptor is
+ * added, modified concerning its mask of events of interest, or
+ * deleted from the epoll file descriptor of the calling thread.
+ * - If deleting a file descriptor, kevent(2) is called twice specifying
+ * EVFILT_READ first and then EVFILT_WRITE (see note below.)
*
*----------------------------------------------------------------------
*/
void
PlatformEventsControl(
- FileHandler *filePtr,
- ThreadSpecificData *tsdPtr,
- int op,
- int isNew)
+ FileHandler *filePtr,
+ ThreadSpecificData *tsdPtr,
+ int op,
+ int isNew)
{
int numChanges;
struct kevent changeList[2];
@@ -221,11 +229,11 @@ PlatformEventsControl(
}
/*
- * N.B. As discussed in Tcl_WaitForEvent(), kqueue(2) does not repro-
- * duce the `always ready' {select,poll}(2) behaviour for regular
- * files (S_IFREG) prior to FreeBSD 11.0-RELEASE. Therefore, file-
- * Ptr is in these cases simply added or deleted from the list of
- * FileHandlers associated with regular files belonging to tsdPtr.
+ * N.B. As discussed in Tcl_WaitForEvent(), kqueue(2) does not reproduce
+ * the `always ready' {select,poll}(2) behaviour for regular files
+ * (S_IFREG) prior to FreeBSD 11.0-RELEASE. Therefore, filePtr is in these
+ * cases simply added or deleted from the list of FileHandlers associated
+ * with regular files belonging to tsdPtr.
*/
if (fstat(filePtr->fd, &fdStat) == -1) {
@@ -234,7 +242,8 @@ PlatformEventsControl(
switch (op) {
case EV_ADD:
if (isNew) {
- LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr, filePtr, readyNode);
+ LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr, filePtr,
+ readyNode);
}
break;
case EV_DELETE:
@@ -248,38 +257,41 @@ PlatformEventsControl(
switch (op) {
case EV_ADD:
if (filePtr->mask & (TCL_READABLE | TCL_EXCEPTION)) {
- EV_SET(&changeList[numChanges], (uintptr_t)filePtr->fd, EVFILT_READ,
- op, 0, 0, filePtr->pedPtr);
+ EV_SET(&changeList[numChanges], (uintptr_t)filePtr->fd,
+ EVFILT_READ, op, 0, 0, filePtr->pedPtr);
numChanges++;
}
if (filePtr->mask & TCL_WRITABLE) {
- EV_SET(&changeList[numChanges], (uintptr_t)filePtr->fd, EVFILT_WRITE,
- op, 0, 0, filePtr->pedPtr);
+ EV_SET(&changeList[numChanges], (uintptr_t)filePtr->fd,
+ EVFILT_WRITE, op, 0, 0, filePtr->pedPtr);
numChanges++;
}
if (numChanges) {
- if (kevent(tsdPtr->eventsFd, changeList, numChanges, NULL, 0, NULL) == -1) {
+ if (kevent(tsdPtr->eventsFd, changeList, numChanges, NULL, 0,
+ NULL) == -1) {
Tcl_Panic("kevent: %s", strerror(errno));
}
}
break;
case EV_DELETE:
/*
- * N.B. kqueue(2) has separate filters for readability and writabi-
- * lity fd events. We therefore need to ensure that fds are
- * ompletely removed from the kqueue(2) fd when deleting.
- * This is exacerbated by changes to filePtr->mask w/o calls
- * to PlatforEventsControl() after e.g. an exec(3) in a child
- * process.
- * As one of these calls can fail, two separate kevent(2) calls
- * are made for EVFILT_{READ,WRITE}.
+ * N.B. kqueue(2) has separate filters for readability and writability
+ * fd events. We therefore need to ensure that fds are ompletely
+ * removed from the kqueue(2) fd when deleting. This is exacerbated
+ * by changes to filePtr->mask w/o calls to PlatforEventsControl()
+ * after e.g. an exec(3) in a child process.
+ *
+ * As one of these calls can fail, two separate kevent(2) calls are
+ * made for EVFILT_{READ,WRITE}.
*/
- EV_SET(&changeList[0], (uintptr_t)filePtr->fd, EVFILT_READ, op, 0, 0, NULL);
+ EV_SET(&changeList[0], (uintptr_t)filePtr->fd, EVFILT_READ, op, 0, 0,
+ NULL);
if ((kevent(tsdPtr->eventsFd, changeList, 1, NULL, 0, NULL) == -1)
&& (errno != ENOENT)) {
Tcl_Panic("kevent: %s", strerror(errno));
}
- EV_SET(&changeList[0], (uintptr_t)filePtr->fd, EVFILT_WRITE, op, 0, 0, NULL);
+ EV_SET(&changeList[0], (uintptr_t)filePtr->fd, EVFILT_WRITE, op, 0, 0,
+ NULL);
if ((kevent(tsdPtr->eventsFd, changeList, 1, NULL, 0, NULL) == -1)
&& (errno != ENOENT)) {
Tcl_Panic("kevent: %s", strerror(errno));
@@ -293,10 +305,10 @@ PlatformEventsControl(
*
* PlatformEventsFinalize --
*
- * This function closes the pipe and the kqueue file descriptors
- * and frees the kevent structs owned by the thread of the caller.
- * The above operations are protected by tsdPtr->notifierMutex, which
- * is destroyed thereafter.
+ * This function closes the pipe and the kqueue file descriptors and
+ * frees the kevent structs owned by the thread of the caller. The above
+ * operations are protected by tsdPtr->notifierMutex, which is destroyed
+ * thereafter.
*
* Results:
* None.
@@ -314,7 +326,7 @@ PlatformEventsControl(
void
PlatformEventsFinalize(
- void)
+ void)
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
@@ -346,31 +358,30 @@ PlatformEventsFinalize(
*
* PlatformEventsInit --
*
- * This function abstracts creating a kqueue fd via the kqueue
- * system call and allocating memory for the kevents structs in
- * tsdPtr for the thread of the caller.
+ * This function abstracts creating a kqueue fd via the kqueue system
+ * call and allocating memory for the kevents structs in tsdPtr for the
+ * thread of the caller.
*
* Results:
* None.
*
* Side effects:
* The following per-thread entities are initialised:
- * notifierMutex is initialised.
- * The pipe(2) is created; fcntl(2) is called on both fds to set
- * FD_CLOEXEC and O_NONBLOCK.
- * The kqueue(2) fd is created; fcntl(2) is called on it to set
- * FD_CLOEXEC.
- * A FileHandler struct is allocated and initialised for the event-
- * fd(2), registering interest for TCL_READABLE on it via Platform-
- * EventsControl().
- * readyEvents and maxReadyEvents are initialised with 512 kevents.
-
+ * - notifierMutex is initialised.
+ * - The pipe(2) is created; fcntl(2) is called on both fds to set
+ * FD_CLOEXEC and O_NONBLOCK.
+ * - The kqueue(2) fd is created; fcntl(2) is called on it to set
+ * FD_CLOEXEC.
+ * - A FileHandler struct is allocated and initialised for the event-
+ * fd(2), registering interest for TCL_READABLE on it via Platform-
+ * EventsControl().
+ * - readyEvents and maxReadyEvents are initialised with 512 kevents.
+ *
*----------------------------------------------------------------------
*/
void
-PlatformEventsInit(
- void)
+PlatformEventsInit(void)
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
int i, fdFl;
@@ -404,8 +415,8 @@ PlatformEventsInit(
PlatformEventsControl(filePtr, tsdPtr, EV_ADD, 1);
if (!tsdPtr->readyEvents) {
tsdPtr->maxReadyEvents = 512;
- tsdPtr->readyEvents = ckalloc(tsdPtr->maxReadyEvents
- * sizeof(tsdPtr->readyEvents[0]));
+ tsdPtr->readyEvents = ckalloc(
+ tsdPtr->maxReadyEvents * sizeof(tsdPtr->readyEvents[0]));
}
LIST_INIT(&tsdPtr->firstReadyFileHandlerPtr);
}
@@ -429,7 +440,7 @@ PlatformEventsInit(
int
PlatformEventsTranslate(
- struct kevent *eventPtr)
+ struct kevent *eventPtr)
{
int mask;
@@ -454,20 +465,20 @@ PlatformEventsTranslate(
*
* PlatformEventsWait --
*
- * This function abstracts waiting for I/O events via the kevent
- * system call.
+ * This function abstracts waiting for I/O events via the kevent system
+ * call.
*
* Results:
* Returns -1 if kevent failed. Returns 0 if polling and if no events
- * became available whilst polling. Returns a pointer to and the count
- * of all returned events in all other cases.
+ * became available whilst polling. Returns a pointer to and the count of
+ * all returned events in all other cases.
*
* Side effects:
- * gettimeofday(2), kevent(2), and gettimeofday(2) are called,
- * in the specified order.
- * If timePtr specifies a positive value, it is updated to reflect
- * the amount of time that has passed; if its value would {under,
- * over}flow, it is set to zero.
+ * gettimeofday(2), kevent(2), and gettimeofday(2) are called, in the
+ * specified order.
+ * If timePtr specifies a positive value, it is updated to reflect the
+ * amount of time that has passed; if its value would {under, over}flow,
+ * it is set to zero.
*
*----------------------------------------------------------------------
*/
@@ -485,9 +496,9 @@ PlatformEventsWait(
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
- * If timePtr is NULL, kevent(2) will wait indefinitely. If it speci-
- * fies a timeout of {0,0}, kevent(2) will poll. Otherwise, the time-
- * out will simply be converted to a timespec.
+ * If timePtr is NULL, kevent(2) will wait indefinitely. If it specifies a
+ * timeout of {0,0}, kevent(2) will poll. Otherwise, the timeout will
+ * simply be converted to a timespec.
*/
if (!timePtr) {
@@ -504,20 +515,21 @@ PlatformEventsWait(
/*
* Call (and possibly block on) kevent(2) and substract the delta of
- * gettimeofday(2) before and after the call from timePtr if the latter
- * is not NULL. Return the number of events returned by kevent(2).
+ * gettimeofday(2) before and after the call from timePtr if the latter is
+ * not NULL. Return the number of events returned by kevent(2).
*/
gettimeofday(&tv0, NULL);
- numFound = kevent(tsdPtr->eventsFd, NULL, 0, events, (int)numEvents, timeoutPtr);
+ numFound = kevent(tsdPtr->eventsFd, NULL, 0, events, (int) numEvents,
+ timeoutPtr);
gettimeofday(&tv1, NULL);
if (timePtr && (timePtr->tv_sec && timePtr->tv_usec)) {
timersub(&tv1, &tv0, &tv_delta);
if (!timercmp(&tv_delta, timePtr, >)) {
- timersub(timePtr, &tv_delta, timePtr);
+ timersub(timePtr, &tv_delta, timePtr);
} else {
- timePtr->tv_sec = 0;
- timePtr->tv_usec = 0;
+ timePtr->tv_sec = 0;
+ timePtr->tv_usec = 0;
}
}
return numFound;
@@ -590,8 +602,8 @@ Tcl_CreateFileHandler(
*
* Tcl_DeleteFileHandler --
*
- * Cancel a previously-arranged callback arrangement for a file on
- * the kqueue of the thread of the caller.
+ * Cancel a previously-arranged callback arrangement for a file on the
+ * kqueue of the thread of the caller.
*
* Results:
* None.
@@ -661,6 +673,7 @@ Tcl_DeleteFileHandler(
* This function is called by Tcl_DoOneEvent to wait for new events on
* the message queue. If the block time is 0, then Tcl_WaitForEvent just
* polls without blocking.
+ *
* The waiting logic is implemented in PlatformEventsWait.
*
* Results:
@@ -726,11 +739,13 @@ Tcl_WaitForEvent(
* Walk the list of FileHandlers associated with regular files
* (S_IFREG) belonging to tsdPtr, queue Tcl events for them, and
* update their mask of events of interest.
+ *
* kqueue(2), unlike epoll(7), does support regular files, but
- * EVFILT_READ only `[r]eturns when the file pointer is not at
- * the end of file' as opposed to unconditionally. While FreeBSD
- * 11.0-RELEASE adds support for this mode (NOTE_FILE_POLL,) this
- * is not used for reasons of compatibility.
+ * EVFILT_READ only `[r]eturns when the file pointer is not at the end
+ * of file' as opposed to unconditionally. While FreeBSD 11.0-RELEASE
+ * adds support for this mode (NOTE_FILE_POLL,) this is not used for
+ * reasons of compatibility.
+ *
* Therefore, the behaviour of {select,poll}(2) is simply simulated
* here: fds associated with regular files are added to this list by
* PlatformEventsControl() and processed here before calling (and
@@ -754,7 +769,7 @@ Tcl_WaitForEvent(
if (filePtr->readyMask == 0) {
FileHandlerEvent *fileEvPtr =
- ckalloc(sizeof(FileHandlerEvent));
+ ckalloc(sizeof(FileHandlerEvent));
fileEvPtr->header.proc = FileHandlerEventProc;
fileEvPtr->fd = filePtr->fd;
@@ -788,22 +803,19 @@ Tcl_WaitForEvent(
* cause PlatformEventsWait() to return immediately.
*/
- numFound = PlatformEventsWait(tsdPtr->readyEvents, tsdPtr->maxReadyEvents, timeoutPtr);
+ numFound = PlatformEventsWait(tsdPtr->readyEvents,
+ tsdPtr->maxReadyEvents, timeoutPtr);
for (numEvent = 0; numEvent < numFound; numEvent++) {
- pedPtr = (struct PlatformEventData *)tsdPtr->readyEvents[numEvent].udata;
+ pedPtr = (struct PlatformEventData *)
+ tsdPtr->readyEvents[numEvent].udata;
filePtr = pedPtr->filePtr;
mask = PlatformEventsTranslate(&tsdPtr->readyEvents[numEvent]);
if (filePtr->fd == tsdPtr->triggerPipe[0]) {
- do {
- i = read(tsdPtr->triggerPipe[0], buf, 1);
- if ((i == -1) && (errno != EAGAIN)) {
- Tcl_Panic("Tcl_WaitForEvent: "
- "read from %p->triggerPipe: %s",
- (void *)tsdPtr, strerror(errno));
- } else {
- break;
- }
- } while (1);
+ i = read(tsdPtr->triggerPipe[0], buf, 1);
+ if ((i == -1) && (errno != EAGAIN)) {
+ Tcl_Panic("Tcl_WaitForEvent: read from %p->triggerPipe: %s",
+ (void *) tsdPtr, strerror(errno));
+ }
continue;
}
if (!mask) {
@@ -829,9 +841,8 @@ Tcl_WaitForEvent(
}
}
+#endif /* NOTIFIER_KQUEUE && TCL_THREADS */
#endif /* !HAVE_COREFOUNDATION */
-
-#endif /* NOTIFIER_KQUEUE */
/*
* Local Variables:
diff --git a/unix/tclSelectNotfy.c b/unix/tclSelectNotfy.c
index 811b49a..a0dea57 100644
--- a/unix/tclSelectNotfy.c
+++ b/unix/tclSelectNotfy.c
@@ -1,9 +1,9 @@
/*
* tclSelectNotfy.c --
*
- * This file contains the implementation of the select()-based
- * generic Unix notifier, which is the lowest-level part of the
- * Tcl event loop. This file works together with generic/tclNotify.c.
+ * This file contains the implementation of the select()-based generic
+ * Unix notifier, which is the lowest-level part of the Tcl event loop.
+ * This file works together with generic/tclNotify.c.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
@@ -12,10 +12,10 @@
*/
#include "tclInt.h"
-#if (!defined(NOTIFIER_EPOLL) && !defined(NOTIFIER_KQUEUE)) || !TCL_THREADS
-
#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier is
* in tclMacOSXNotify.c */
+#if (!defined(NOTIFIER_EPOLL) && !defined(NOTIFIER_KQUEUE)) || !TCL_THREADS
+
#include <signal.h>
/*
@@ -94,16 +94,17 @@ typedef struct ThreadSpecificData {
* notifierMutex lock before accessing these
* fields. */
#ifdef __CYGWIN__
- void *event; /* Any other thread alerts a notifier
- * that an event is ready to be processed
- * by sending this event. */
+ void *event; /* Any other thread alerts a notifier that an
+ * event is ready to be processed by sending
+ * this event. */
void *hwnd; /* Messaging window. */
#else /* !__CYGWIN__ */
pthread_cond_t waitCV; /* Any other thread alerts a notifier that an
* event is ready to be processed by signaling
* this condition variable. */
#endif /* __CYGWIN__ */
- int waitCVinitialized; /* Variable to flag initialization of the structure */
+ int waitCVinitialized; /* Variable to flag initialization of the
+ * structure. */
int eventReady; /* True if an event is ready to be processed.
* Used as condition flag together with waitCV
* above. */
@@ -171,12 +172,14 @@ static int notifierThreadRunning = 0;
static pthread_cond_t notifierCV = PTHREAD_COND_INITIALIZER;
/*
- * The pollState bits
- * POLL_WANT is set by each thread before it waits on its condition
- * variable. It is checked by the notifier before it does select.
- * POLL_DONE is set by the notifier if it goes into select after seeing
- * POLL_WANT. The idea is to ensure it tries a select with the
- * same bits the initial thread had set.
+ * The pollState bits:
+ *
+ * POLL_WANT is set by each thread before it waits on its condition variable.
+ * It is checked by the notifier before it does select.
+ *
+ * POLL_DONE is set by the notifier if it goes into select after seeing
+ * POLL_WANT. The idea is to ensure it tries a select with the same bits
+ * the initial thread had set.
*/
#define POLL_WANT 0x1
@@ -196,24 +199,24 @@ static Tcl_ThreadId notifierThread;
#if TCL_THREADS
static TCL_NORETURN void NotifierThreadProc(ClientData clientData);
#if defined(HAVE_PTHREAD_ATFORK)
-static int atForkInit = 0;
-static void AtForkChild(void);
+static int atForkInit = 0;
+static void AtForkChild(void);
#endif /* HAVE_PTHREAD_ATFORK */
#endif /* TCL_THREADS */
-static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
+static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
/*
- * Import of Windows API when building threaded with Cygwin.
+ * Import of critical bits of Windows API when building threaded with Cygwin.
*/
#if defined(__CYGWIN__)
typedef struct {
- void *hwnd;
- unsigned int *message;
- int wParam;
- int lParam;
- int time;
- int x;
+ void *hwnd; /* Messaging window. */
+ unsigned int *message; /* Message payload. */
+ int wParam; /* Event-specific "word" parameter. */
+ int lParam; /* Event-specific "long" parameter. */
+ int time; /* Event timestamp. */
+ int x; /* Event location (where meaningful). */
int y;
} MSG;
@@ -233,8 +236,9 @@ typedef struct {
extern void __stdcall CloseHandle(void *);
extern void *__stdcall CreateEventW(void *, unsigned char, unsigned char,
void *);
-extern void * __stdcall CreateWindowExW(void *, const void *, const void *,
- DWORD, int, int, int, int, void *, void *, void *, void *);
+extern void *__stdcall CreateWindowExW(void *, const void *, const void *,
+ DWORD, int, int, int, int, void *, void *, void *,
+ void *);
extern DWORD __stdcall DefWindowProcW(void *, int, void *, void *);
extern unsigned char __stdcall DestroyWindow(void *);
extern int __stdcall DispatchMessageW(const MSG *);
@@ -336,7 +340,6 @@ Tcl_InitNotifier(void)
#endif /* HAVE_PTHREAD_ATFORK */
notifierCount++;
-
pthread_mutex_unlock(&notifierInitMutex);
#endif /* TCL_THREADS */
@@ -381,28 +384,25 @@ Tcl_FinalizeNotifier(
* pipe and wait for the background thread to terminate.
*/
- if (notifierCount == 0) {
+ if (notifierCount == 0 && triggerPipe != -1) {
+ if (write(triggerPipe, "q", 1) != 1) {
+ Tcl_Panic("Tcl_FinalizeNotifier: %s",
+ "unable to write 'q' to triggerPipe");
+ }
+ close(triggerPipe);
+ pthread_mutex_lock(&notifierMutex);
+ while(triggerPipe != -1) {
+ pthread_cond_wait(&notifierCV, &notifierMutex);
+ }
+ pthread_mutex_unlock(&notifierMutex);
+ if (notifierThreadRunning) {
+ int result = pthread_join((pthread_t) notifierThread, NULL);
- if (triggerPipe != -1) {
- if (write(triggerPipe, "q", 1) != 1) {
+ if (result) {
Tcl_Panic("Tcl_FinalizeNotifier: %s",
- "unable to write q to triggerPipe");
- }
- close(triggerPipe);
- pthread_mutex_lock(&notifierMutex);
- while(triggerPipe != -1) {
- pthread_cond_wait(&notifierCV, &notifierMutex);
- }
- pthread_mutex_unlock(&notifierMutex);
- if (notifierThreadRunning) {
- int result = pthread_join((pthread_t) notifierThread, NULL);
-
- if (result) {
- Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier "
- "thread");
- }
- notifierThreadRunning = 0;
+ "unable to join notifier thread");
}
+ notifierThreadRunning = 0;
}
}
@@ -645,7 +645,7 @@ Tcl_WaitForEvent(
# ifdef __CYGWIN__
MSG msg;
# endif /* __CYGWIN__ */
-#else
+#else /* !TCL_THREADS */
/*
* Impl. notes: timeout & timeoutPtr are used if, and only if threads
* are not enabled. They are the arguments for the regular select()
@@ -771,18 +771,19 @@ Tcl_WaitForEvent(
MsgWaitForMultipleObjects(1, &tsdPtr->event, 0, timeout, 1279);
pthread_mutex_lock(&notifierMutex);
}
-#else
+#else /* !__CYGWIN__ */
if (timePtr != NULL) {
- Tcl_Time now;
- struct timespec ptime;
+ Tcl_Time now;
+ struct timespec ptime;
- Tcl_GetTime(&now);
- ptime.tv_sec = timePtr->sec + now.sec + (timePtr->usec + now.usec) / 1000000;
- ptime.tv_nsec = 1000 * ((timePtr->usec + now.usec) % 1000000);
+ Tcl_GetTime(&now);
+ ptime.tv_sec = timePtr->sec + now.sec +
+ (timePtr->usec + now.usec) / 1000000;
+ ptime.tv_nsec = 1000 * ((timePtr->usec + now.usec) % 1000000);
- pthread_cond_timedwait(&tsdPtr->waitCV, &notifierMutex, &ptime);
+ pthread_cond_timedwait(&tsdPtr->waitCV, &notifierMutex, &ptime);
} else {
- pthread_cond_wait(&tsdPtr->waitCV, &notifierMutex);
+ pthread_cond_wait(&tsdPtr->waitCV, &notifierMutex);
}
#endif /* __CYGWIN__ */
}
@@ -830,8 +831,7 @@ Tcl_WaitForEvent(
"unable to write to triggerPipe");
}
}
-
-#else
+#else /* !TCL_THREADS */
tsdPtr->readyMasks = tsdPtr->checkMasks;
numFound = select(tsdPtr->numFdBits, &tsdPtr->readyMasks.readable,
&tsdPtr->readyMasks.writable, &tsdPtr->readyMasks.exception,
@@ -892,8 +892,6 @@ Tcl_WaitForEvent(
}
}
-#if TCL_THREADS
-
/*
*----------------------------------------------------------------------
*
@@ -918,6 +916,7 @@ Tcl_WaitForEvent(
*----------------------------------------------------------------------
*/
+#if TCL_THREADS
static TCL_NORETURN void
NotifierThreadProc(
ClientData clientData) /* Not used. */
@@ -1101,12 +1100,10 @@ NotifierThreadProc(
TclpThreadExit(0);
}
-
#endif /* TCL_THREADS */
-
+
+#endif /* (!NOTIFIER_EPOLL && !NOTIFIER_KQUEUE) || !TCL_THREADS */
#endif /* !HAVE_COREFOUNDATION */
-
-#endif /* !NOTIFIER_EPOLL && !NOTIFIER_KQUEUE */
/*
* Local Variables:
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index fb7e569..3817071 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -18,7 +18,7 @@
* Static routines defined in this file.
*/
-static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
+static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
#if !TCL_THREADS
# undef NOTIFIER_EPOLL
# undef NOTIFIER_KQUEUE
@@ -27,7 +27,7 @@ static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
# define NOTIFIER_SELECT
static TCL_NORETURN void NotifierThreadProc(ClientData clientData);
# if defined(HAVE_PTHREAD_ATFORK)
-static void AtForkChild(void);
+static void AtForkChild(void);
# endif /* HAVE_PTHREAD_ATFORK */
/*
@@ -120,7 +120,7 @@ Tcl_AlertNotifier(
# endif /* __CYGWIN__ */
pthread_mutex_unlock(&notifierMutex);
#endif /* TCL_THREADS */
-#else
+#else /* !NOTIFIER_SELECT */
ThreadSpecificData *tsdPtr = clientData;
#if defined(NOTIFIER_EPOLL) && defined(HAVE_EVENTFD)
uint64_t eventFdVal = 1;
@@ -128,12 +128,13 @@ Tcl_AlertNotifier(
sizeof(eventFdVal)) != sizeof(eventFdVal)) {
Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerEventFd",
(void *)tsdPtr);
+ }
#else
if (write(tsdPtr->triggerPipe[1], "", 1) != 1) {
Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerPipe",
(void *)tsdPtr);
-#endif /* NOTIFIER_EPOLL && HAVE_EVENTFD */
}
+#endif /* NOTIFIER_EPOLL && HAVE_EVENTFD */
#endif /* NOTIFIER_SELECT */
}
}
@@ -301,15 +302,15 @@ FileHandlerEventProc(
static void
AlertSingleThread(
- ThreadSpecificData *tsdPtr)
+ ThreadSpecificData *tsdPtr)
{
tsdPtr->eventReady = 1;
if (tsdPtr->onList) {
/*
- * Remove the ThreadSpecificData structure of this thread
- * from the waiting list. This prevents us from
- * continuously spinning on epoll_wait until the other
- * threads runs and services the file event.
+ * Remove the ThreadSpecificData structure of this thread from the
+ * waiting list. This prevents us from continuously spinning on
+ * epoll_wait until the other threads runs and services the file
+ * event.
*/
if (tsdPtr->prevPtr) {
@@ -326,7 +327,7 @@ AlertSingleThread(
}
#ifdef __CYGWIN__
PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
-#else /* __CYGWIN__ */
+#else /* !__CYGWIN__ */
pthread_cond_broadcast(&tsdPtr->waitCV);
#endif /* __CYGWIN__ */
}
@@ -359,9 +360,10 @@ AtForkChild(void)
pthread_cond_init(&notifierCV, NULL);
/*
- * notifierThreadRunning == 1: thread is running, (there might be data in notifier lists)
+ * notifierThreadRunning == 1: thread is running, (there might be data in
+ * notifier lists)
* atForkInit == 0: InitNotifier was never called
- * notifierCount != 0: unbalanced InitNotifier() / FinalizeNotifier calls
+ * notifierCount != 0: unbalanced InitNotifier() / FinalizeNotifier calls
* waitingListPtr != 0: there are threads currently waiting for events.
*/
@@ -382,8 +384,8 @@ AtForkChild(void)
waitingListPtr = NULL;
/*
- * The tsdPtr from before the fork is copied as well. But since
- * we are paranoic, we don't trust its condvar and reset it.
+ * The tsdPtr from before the fork is copied as well. But since we
+ * are paranoic, we don't trust its condvar and reset it.
*/
#ifdef __CYGWIN__
DestroyWindow(tsdPtr->hwnd);
@@ -391,10 +393,10 @@ AtForkChild(void)
className, 0, 0, 0, 0, 0, NULL, NULL,
TclWinGetTclInstance(), NULL);
ResetEvent(tsdPtr->event);
-#else
+#else /* !__CYGWIN__ */
pthread_cond_destroy(&tsdPtr->waitCV);
pthread_cond_init(&tsdPtr->waitCV, NULL);
-#endif
+#endif /* __CYGWIN__ */
/*
* In case, we had multiple threads running before the fork,
@@ -465,8 +467,8 @@ TclUnixWaitForFile(
if (timeout > 0) {
Tcl_GetTime(&now);
- abortTime.sec = now.sec + timeout/1000;
- abortTime.usec = now.usec + (timeout%1000)*1000;
+ abortTime.sec = now.sec + timeout / 1000;
+ abortTime.usec = now.usec + (timeout % 1000) * 1000;
if (abortTime.usec >= 1000000) {
abortTime.usec -= 1000000;
abortTime.sec += 1;
@@ -501,7 +503,7 @@ TclUnixWaitForFile(
* become ready or a timeout to occur.
*/
- while (1) {
+ do {
if (timeout > 0) {
blockTime.tv_sec = abortTime.sec - now.sec;
blockTime.tv_usec = abortTime.usec - now.usec;
@@ -524,9 +526,9 @@ TclUnixWaitForFile(
} else if (!timeoutPtr->tv_sec && !timeoutPtr->tv_usec) {
pollTimeout = 0;
} else {
- pollTimeout = (int)timeoutPtr->tv_sec * 1000;
+ pollTimeout = (int) timeoutPtr->tv_sec * 1000;
if (timeoutPtr->tv_usec) {
- pollTimeout += ((int)timeoutPtr->tv_usec / 1000);
+ pollTimeout += (int) timeoutPtr->tv_usec / 1000;
}
}
numFound = poll(pollFds, 1, pollTimeout);
@@ -557,13 +559,11 @@ TclUnixWaitForFile(
*/
Tcl_GetTime(&now);
- if ((abortTime.sec < now.sec)
- || (abortTime.sec==now.sec && abortTime.usec<=now.usec)) {
- break;
- }
- }
+ } while ((abortTime.sec > now.sec)
+ || (abortTime.sec == now.sec && abortTime.usec > now.usec));
return result;
}
+
#endif /* !HAVE_COREFOUNDATION */
/*
diff --git a/win/Makefile.in b/win/Makefile.in
index 99cf327..2148e3e 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -869,7 +869,7 @@ test-tcl: binaries $(TCLSH) $(CAT32) $(TEST_DLL_FILE)
-load "package ifneeded Tcltest ${VERSION}@TCL_PATCH_LEVEL@ [list load [file normalize ${TEST_DLL_FILE}] Tcltest]; \
package ifneeded tcltests 0.1 \"[list source [file normalize $(ROOT_DIR_NATIVE)/tests/tcltests.tcl]];package provide tcltests 0.1\"; \
package ifneeded dde 1.4.0 [list load [file normalize ${DDE_DLL_FILE}] dde]; \
- package ifneeded registry 1.3.2 [list load [file normalize ${REG_DLL_FILE}] registry]" | $(WINE) ./$(CAT32)
+ package ifneeded registry 1.3.3 [list load [file normalize ${REG_DLL_FILE}] registry]" | $(WINE) ./$(CAT32)
# Useful target to launch a built tclsh with the proper path,...
runtest: binaries $(TCLSH) $(TEST_DLL_FILE)
@@ -877,7 +877,7 @@ runtest: binaries $(TCLSH) $(TEST_DLL_FILE)
$(WINE) ./$(TCLSH) $(TESTFLAGS) -load "package ifneeded Tcltest ${VERSION}@TCL_PATCH_LEVEL@ [list load [file normalize ${TEST_DLL_FILE}] Tcltest]; \
package ifneeded tcltests 0.1 \"[list source [file normalize $(ROOT_DIR_NATIVE)/tests/tcltests.tcl]];package provide tcltests 0.1\"; \
package ifneeded dde 1.4.0 [list load [file normalize ${DDE_DLL_FILE}] dde]; \
- package ifneeded registry 1.3.2 [list load [file normalize ${REG_DLL_FILE}] registry]" $(SCRIPT)
+ package ifneeded registry 1.3.3 [list load [file normalize ${REG_DLL_FILE}] registry]" $(SCRIPT)
# This target can be used to run tclsh from the build directory via
# `make shell SCRIPT=foo.tcl`
diff --git a/win/makefile.vc b/win/makefile.vc
index 2554893..392e6b4 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -393,7 +393,7 @@ test-core: setup $(TCLTEST) dlls
set TCL_LIBRARY=$(ROOT:\=/)/library
$(DEBUGGER) $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile <<
package ifneeded dde 1.4.0 [list load "$(TCLDDELIB:\=/)" dde]
- package ifneeded registry 1.3.2 [list load "$(TCLREGLIB:\=/)" registry]
+ package ifneeded registry 1.3.3 [list load "$(TCLREGLIB:\=/)" registry]
<<
runtest: setup $(TCLTEST) dlls