summaryrefslogtreecommitdiffstats
path: root/generic/tclLink.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-15 10:57:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-15 10:57:59 (GMT)
commit79f559fdb5b42afb0b51a81227aea6038d338b15 (patch)
tree61fe5131a4b0623f70121aa1120dced613dc624f /generic/tclLink.c
parent14225bf18403da5689ee38fe70343b877b7bc571 (diff)
downloadtcl-79f559fdb5b42afb0b51a81227aea6038d338b15.zip
tcl-79f559fdb5b42afb0b51a81227aea6038d338b15.tar.gz
tcl-79f559fdb5b42afb0b51a81227aea6038d338b15.tar.bz2
Add mp_pack to the libtommath stub-table: it's easier to work with than mp_to_ubin
Diffstat (limited to 'generic/tclLink.c')
-rw-r--r--generic/tclLink.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/generic/tclLink.c b/generic/tclLink.c
index 1973067..397c9bc 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -537,15 +537,10 @@ GetUWide(
} else if (type == TCL_NUMBER_BIG) {
mp_int *numPtr = (mp_int *)clientData;
Tcl_WideUInt value = 0;
- union {
- Tcl_WideUInt value;
- unsigned char bytes[sizeof(Tcl_WideUInt)];
- } scratch;
size_t numBytes;
- unsigned char *bytes = scratch.bytes;
- if (numPtr->sign || (MP_OKAY != mp_to_ubin(numPtr,
- bytes, sizeof(Tcl_WideUInt), &numBytes))) {
+ if (numPtr->sign || (MP_OKAY != mp_pack(&value, 1,
+ &numBytes, 0, sizeof(Tcl_WideUInt), 0, 0, numPtr))) {
/*
* If the sign bit is set (a negative value) or if the value
* can't possibly fit in the bits of an unsigned wide, there's
@@ -553,16 +548,6 @@ GetUWide(
*/
return 1;
}
-#ifndef WORDS_BIGENDIAN
- while (numBytes-- > 0) {
- value = (value << CHAR_BIT) | *bytes++;
- }
-#else /* WORDS_BIGENDIAN */
- /*
- * Big-endian can read the value directly.
- */
- value = scratch.value;
-#endif /* WORDS_BIGENDIAN */
*uwidePtr = value;
return 0;
}