Tcl Source Code

Check-in [4d1f47dcd2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge 8.6. Add support for libtommath's mp_set_ll() function, since that's the replacement for the deprecated TclBNInitBignumFromWideInt() function.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: 4d1f47dcd2bd4d842a5f3fc6239e0f25d2d81f4cedb7fdce3f63175e93789ad7
User & Date: jan.nijtmans 2019-11-08 09:01:43.196
Context
2019-11-08
15:57
Merge 8.6 check-in: 9b19022f67 user: jan.nijtmans tags: core-8-branch
11:44
Merge 8.7 check-in: d01b6ba893 user: jan.nijtmans tags: trunk
09:01
Merge 8.6. Add support for libtommath's mp_set_ll() function, since that's the replacement for the ... check-in: 4d1f47dcd2 user: jan.nijtmans tags: core-8-branch
07:58
For long/wide "scans"'s of negative numbers, but scanned as unsigned, generate binary representation... check-in: ea950e9e42 user: jan.nijtmans tags: core-8-6-branch
2019-11-07
18:36
added removal of timeout-event in cleanup of io-44.6 (can bother followed tests), removed unneeded c... check-in: a62c53b7b7 user: sebres tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclBinary.c.
2345
2346
2347
2348
2349
2350
2351

2352
2353

2354
2355
2356
2357
2358
2359
2360
		    | (((Tcl_WideUInt) buffer[1]) << 48)
		    | (((Tcl_WideUInt) buffer[0]) << 56);
	}
	if (flags & BINARY_UNSIGNED) {
	    Tcl_Obj *bigObj = NULL;
	    mp_int big;


	    TclBNInitBignumFromWideUInt(&big, uwvalue);
	    bigObj = Tcl_NewBignumObj(&big);

	    return bigObj;
	}
	return Tcl_NewWideIntObj((Tcl_WideInt) uwvalue);

	/*
	 * Do not cache double values; they are already too large to use as
	 * keys and the values stored are utterly incompatible with the







>
|
|
>







2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
		    | (((Tcl_WideUInt) buffer[1]) << 48)
		    | (((Tcl_WideUInt) buffer[0]) << 56);
	}
	if (flags & BINARY_UNSIGNED) {
	    Tcl_Obj *bigObj = NULL;
	    mp_int big;

	    if (mp_init(&big) == MP_OKAY) {
		mp_set_ull(&big, uwvalue);
		bigObj = Tcl_NewBignumObj(&big);
	    }
	    return bigObj;
	}
	return Tcl_NewWideIntObj((Tcl_WideInt) uwvalue);

	/*
	 * Do not cache double values; they are already too large to use as
	 * keys and the values stored are utterly incompatible with the
Changes to generic/tclScan.c.
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
    const char *string, *end, *baseString;
    char op = 0;
    int width, underflow = 0;
    Tcl_WideInt wideValue;
    Tcl_UniChar ch = 0, sch = 0;
    Tcl_Obj **objs = NULL, *objPtr = NULL;
    int flags;
    char buf[513];		/* Temporary buffer to hold scanned number
				 * strings before they are passed to
				 * strtoul. */

    if (objc < 3) {
	Tcl_WrongNumArgs(interp, 1, objv,
		"string format ?varName ...?");
	return TCL_ERROR;
    }








<
<
<







575
576
577
578
579
580
581



582
583
584
585
586
587
588
    const char *string, *end, *baseString;
    char op = 0;
    int width, underflow = 0;
    Tcl_WideInt wideValue;
    Tcl_UniChar ch = 0, sch = 0;
    Tcl_Obj **objs = NULL, *objPtr = NULL;
    int flags;




    if (objc < 3) {
	Tcl_WrongNumArgs(interp, 1, objv,
		"string format ?varName ...?");
	return TCL_ERROR;
    }

927
928
929
930
931
932
933







934
935

936
937
938
939
940
941
942
		if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) {
		    wideValue = WIDE_MAX;
		    if (TclGetString(objPtr)[0] == '-') {
			wideValue = WIDE_MIN;
		    }
		}
		if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {







		    sprintf(buf, "%" TCL_LL_MODIFIER "u", wideValue);
		    Tcl_SetStringObj(objPtr, buf, -1);

		} else {
		    TclSetIntObj(objPtr, wideValue);
		}
	    } else if (flags & SCAN_BIG) {
		if (flags & SCAN_UNSIGNED) {
		    mp_int big;
		    int code = Tcl_GetBignumFromObj(interp, objPtr, &big);







>
>
>
>
>
>
>
|
|
>







924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
		if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) {
		    wideValue = WIDE_MAX;
		    if (TclGetString(objPtr)[0] == '-') {
			wideValue = WIDE_MIN;
		    }
		}
		if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
		    mp_int big;
		    if (mp_init(&big) != MP_OKAY) {
			Tcl_SetObjResult(interp, Tcl_NewStringObj(
				"insufficient memory to create bignum", -1));
			Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
			return TCL_ERROR;
		    } else {
			mp_set_ull(&big, (Tcl_WideUInt)wideValue);    
			Tcl_SetBignumObj(objPtr, &big);
		    }
		} else {
		    TclSetIntObj(objPtr, wideValue);
		}
	    } else if (flags & SCAN_BIG) {
		if (flags & SCAN_UNSIGNED) {
		    mp_int big;
		    int code = Tcl_GetBignumFromObj(interp, objPtr, &big);
965
966
967
968
969
970
971








972
973




974
975
976
977
978
979
980
		    if (TclGetString(objPtr)[0] == '-') {
			value = LONG_MIN;
		    } else {
			value = LONG_MAX;
		    }
		}
		if ((flags & SCAN_UNSIGNED) && (value < 0)) {








		    sprintf(buf, "%lu", value);	/* INTL: ISO digit */
		    Tcl_SetStringObj(objPtr, buf, -1);




		} else {
		    TclSetIntObj(objPtr, value);
		}
	    }
	    objs[objIndex++] = objPtr;
	    break;








>
>
>
>
>
>
>
>
|
|
>
>
>
>







970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
		    if (TclGetString(objPtr)[0] == '-') {
			value = LONG_MIN;
		    } else {
			value = LONG_MAX;
		    }
		}
		if ((flags & SCAN_UNSIGNED) && (value < 0)) {
#ifdef TCL_WIDE_INT_IS_LONG
		    mp_int big;
		    if (mp_init(&big) != MP_OKAY) {
			Tcl_SetObjResult(interp, Tcl_NewStringObj(
				"insufficient memory to create bignum", -1));
			Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
			return TCL_ERROR;
		    } else {
			mp_set_ull(&big, (unsigned long)value);
			Tcl_SetBignumObj(objPtr, &big);
		    }
#else
		    Tcl_SetWideIntObj(objPtr, (unsigned long)value);
#endif
		} else {
		    TclSetIntObj(objPtr, value);
		}
	    }
	    objs[objIndex++] = objPtr;
	    break;

Changes to generic/tclStubInit.c.
79
80
81
82
83
84
85

86
87
88
89
90
91
92
static int TclSockMinimumBuffersOld(int sock, int size)
{
    return TclSockMinimumBuffers(INT2PTR(sock), size);
}
#endif

MP_SET_UNSIGNED(mp_set_ull, Tcl_WideUInt)

MP_GET_MAG(mp_get_mag_ull, Tcl_WideUInt)

mp_err TclBN_mp_set_int(mp_int *a, unsigned long i)
{
    mp_set_ul(a, i);
    return MP_OKAY;
}







>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
static int TclSockMinimumBuffersOld(int sock, int size)
{
    return TclSockMinimumBuffers(INT2PTR(sock), size);
}
#endif

MP_SET_UNSIGNED(mp_set_ull, Tcl_WideUInt)
MP_SET_SIGNED(mp_set_ll, mp_set_ull, Tcl_WideInt, Tcl_WideUInt)
MP_GET_MAG(mp_get_mag_ull, Tcl_WideUInt)

mp_err TclBN_mp_set_int(mp_int *a, unsigned long i)
{
    mp_set_ul(a, i);
    return MP_OKAY;
}
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
    TclBN_mp_cnt_lsb, /* 63 */
    TclBNInitBignumFromLong, /* 64 */
    TclBNInitBignumFromWideInt, /* 65 */
    TclBNInitBignumFromWideUInt, /* 66 */
    TclBN_mp_expt_d_ex, /* 67 */
    TclBN_mp_set_ull, /* 68 */
    TclBN_mp_get_mag_ull, /* 69 */
    0, /* 70 */
    TclBN_mp_get_mag_ul, /* 71 */
    0, /* 72 */
    TclBN_mp_tc_and, /* 73 */
    TclBN_mp_tc_or, /* 74 */
    TclBN_mp_tc_xor, /* 75 */
    TclBN_mp_signed_rsh, /* 76 */
    TclBN_mp_get_bit, /* 77 */







|







1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
    TclBN_mp_cnt_lsb, /* 63 */
    TclBNInitBignumFromLong, /* 64 */
    TclBNInitBignumFromWideInt, /* 65 */
    TclBNInitBignumFromWideUInt, /* 66 */
    TclBN_mp_expt_d_ex, /* 67 */
    TclBN_mp_set_ull, /* 68 */
    TclBN_mp_get_mag_ull, /* 69 */
    TclBN_mp_set_ll, /* 70 */
    TclBN_mp_get_mag_ul, /* 71 */
    0, /* 72 */
    TclBN_mp_tc_and, /* 73 */
    TclBN_mp_tc_or, /* 74 */
    TclBN_mp_tc_xor, /* 75 */
    TclBN_mp_signed_rsh, /* 76 */
    TclBN_mp_get_bit, /* 77 */
Changes to generic/tclTomMath.decls.
240
241
242
243
244
245
246



247
248
249
250
251
252
253
# Added in libtommath 1.0.1
declare 68 {
    void TclBN_mp_set_ull(mp_int *a, Tcl_WideUInt i)
}
declare 69 {
    Tcl_WideUInt MP_WUR TclBN_mp_get_mag_ull(const mp_int *a)
}



declare 71 {
    unsigned long MP_WUR TclBN_mp_get_mag_ul(const mp_int *a)
}

# Added in libtommath 1.1.0
declare 73 {
    mp_err MP_WUR TclBN_mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)







>
>
>







240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Added in libtommath 1.0.1
declare 68 {
    void TclBN_mp_set_ull(mp_int *a, Tcl_WideUInt i)
}
declare 69 {
    Tcl_WideUInt MP_WUR TclBN_mp_get_mag_ull(const mp_int *a)
}
declare 70 {
    void TclBN_mp_set_ll(mp_int *a, Tcl_WideInt i)
}
declare 71 {
    unsigned long MP_WUR TclBN_mp_get_mag_ul(const mp_int *a)
}

# Added in libtommath 1.1.0
declare 73 {
    mp_err MP_WUR TclBN_mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
Changes to generic/tclTomMath.h.
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
uint64_t mp_get_mag_u64(const mp_int *a) MP_WUR;
*/
#endif
/*
unsigned long mp_get_mag_ul(const mp_int *a) MP_WUR;
*/
/*
Tcl_WideUInt mp_get_mag_ull(const mp_int *a) MP_WUR;
*/

/* get integer, set integer (long) */
/*
long mp_get_l(const mp_int *a) MP_WUR;
*/
/*







|







364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
uint64_t mp_get_mag_u64(const mp_int *a) MP_WUR;
*/
#endif
/*
unsigned long mp_get_mag_ul(const mp_int *a) MP_WUR;
*/
/*
unsigned long long mp_get_mag_ull(const mp_int *a) MP_WUR;
*/

/* get integer, set integer (long) */
/*
long mp_get_l(const mp_int *a) MP_WUR;
*/
/*
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/*
void mp_set_ul(mp_int *a, unsigned long b);
*/
/*
mp_err mp_init_ul(mp_int *a, unsigned long b) MP_WUR;
*/

/* get integer, set integer (Tcl_WideInt) */
/*
Tcl_WideInt mp_get_ll(const mp_int *a) MP_WUR;
*/
/*
void mp_set_ll(mp_int *a, Tcl_WideInt b);
*/
/*
mp_err mp_init_ll(mp_int *a, Tcl_WideInt b) MP_WUR;
*/

/* get integer, set integer (Tcl_WideUInt) */
#define mp_get_ull(a) ((Tcl_WideUInt)mp_get_ll(a))
/*
void mp_set_ull(mp_int *a, Tcl_WideUInt b);
*/
/*
mp_err mp_init_ull(mp_int *a, Tcl_WideUInt b) MP_WUR;
*/

/* set to single unsigned digit, up to MP_DIGIT_MAX */
/*
void mp_set(mp_int *a, mp_digit b);
*/
/*
mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
*/

/* get integer, set integer and init with integer (deprecated) */
/*
MP_DEPRECATED(mp_get_mag_u32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_get_mag_ul/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_get_mag_ull/mp_get_ull) Tcl_WideUInt mp_get_long_long(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_set_ul) mp_err mp_set_int(mp_int *a, unsigned long b);
*/
/*
MP_DEPRECATED(mp_set_ul) mp_err mp_set_long(mp_int *a, unsigned long b);
*/
/*
MP_DEPRECATED(mp_set_ull) mp_err mp_set_long_long(mp_int *a, Tcl_WideUInt b);
*/
/*
MP_DEPRECATED(mp_init_ul) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
*/

/* copy, b = a */
/*







|

|


|


|


|


|


|


















|








|







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/*
void mp_set_ul(mp_int *a, unsigned long b);
*/
/*
mp_err mp_init_ul(mp_int *a, unsigned long b) MP_WUR;
*/

/* get integer, set integer (long long) */
/*
long long mp_get_ll(const mp_int *a) MP_WUR;
*/
/*
void mp_set_ll(mp_int *a, long long b);
*/
/*
mp_err mp_init_ll(mp_int *a, long long b) MP_WUR;
*/

/* get integer, set integer (unsigned long long) */
#define mp_get_ull(a) ((Tcl_WideUInt)mp_get_ll(a))
/*
void mp_set_ull(mp_int *a, unsigned long long b);
*/
/*
mp_err mp_init_ull(mp_int *a, unsigned long long b) MP_WUR;
*/

/* set to single unsigned digit, up to MP_DIGIT_MAX */
/*
void mp_set(mp_int *a, mp_digit b);
*/
/*
mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
*/

/* get integer, set integer and init with integer (deprecated) */
/*
MP_DEPRECATED(mp_get_mag_u32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_get_mag_ul/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_get_mag_ull/mp_get_ull) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
*/
/*
MP_DEPRECATED(mp_set_ul) mp_err mp_set_int(mp_int *a, unsigned long b);
*/
/*
MP_DEPRECATED(mp_set_ul) mp_err mp_set_long(mp_int *a, unsigned long b);
*/
/*
MP_DEPRECATED(mp_set_ull) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
*/
/*
MP_DEPRECATED(mp_init_ul) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
*/

/* copy, b = a */
/*
Changes to generic/tclTomMathDecls.h.
97
98
99
100
101
102
103

104
105
106
107
108
109
110
#define mp_mul_2d TclBN_mp_mul_2d
#define mp_neg TclBN_mp_neg
#define mp_or TclBN_mp_or
#define mp_radix_size TclBN_mp_radix_size
#define mp_read_radix TclBN_mp_read_radix
#define mp_rshd TclBN_mp_rshd
#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),((unsigned int)(b))),MP_OKAY))

#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),(b)),MP_OKAY))
#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ull") (TclBN_mp_set_ull((a),(b)),MP_OKAY))
#define mp_set_ul TclBN_mp_set_ul
#define mp_set_ull TclBN_mp_set_ull
#define mp_shrink TclBN_mp_shrink
#define mp_sqrt TclBN_mp_sqrt
#define mp_sub TclBN_mp_sub







>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#define mp_mul_2d TclBN_mp_mul_2d
#define mp_neg TclBN_mp_neg
#define mp_or TclBN_mp_or
#define mp_radix_size TclBN_mp_radix_size
#define mp_read_radix TclBN_mp_read_radix
#define mp_rshd TclBN_mp_rshd
#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),((unsigned int)(b))),MP_OKAY))
#define mp_set_ll TclBN_mp_set_ll
#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),(b)),MP_OKAY))
#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ull") (TclBN_mp_set_ull((a),(b)),MP_OKAY))
#define mp_set_ul TclBN_mp_set_ul
#define mp_set_ull TclBN_mp_set_ull
#define mp_shrink TclBN_mp_shrink
#define mp_sqrt TclBN_mp_sqrt
#define mp_sub TclBN_mp_sub
347
348
349
350
351
352
353
354

355
356
357
358
359
360
361
TCL_DEPRECATED("Use mp_expt_u32")
mp_err			TclBN_mp_expt_d_ex(const mp_int *a, unsigned int b,
				mp_int *c, int fast);
/* 68 */
EXTERN void		TclBN_mp_set_ull(mp_int *a, Tcl_WideUInt i);
/* 69 */
EXTERN Tcl_WideUInt	TclBN_mp_get_mag_ull(const mp_int *a) MP_WUR;
/* Slot 70 is reserved */

/* 71 */
EXTERN unsigned long	TclBN_mp_get_mag_ul(const mp_int *a) MP_WUR;
/* Slot 72 is reserved */
/* 73 */
EXTERN mp_err		TclBN_mp_tc_and(const mp_int *a, const mp_int *b,
				mp_int *c) MP_WUR;
/* 74 */







|
>







348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
TCL_DEPRECATED("Use mp_expt_u32")
mp_err			TclBN_mp_expt_d_ex(const mp_int *a, unsigned int b,
				mp_int *c, int fast);
/* 68 */
EXTERN void		TclBN_mp_set_ull(mp_int *a, Tcl_WideUInt i);
/* 69 */
EXTERN Tcl_WideUInt	TclBN_mp_get_mag_ull(const mp_int *a) MP_WUR;
/* 70 */
EXTERN void		TclBN_mp_set_ll(mp_int *a, Tcl_WideInt i);
/* 71 */
EXTERN unsigned long	TclBN_mp_get_mag_ul(const mp_int *a) MP_WUR;
/* Slot 72 is reserved */
/* 73 */
EXTERN mp_err		TclBN_mp_tc_and(const mp_int *a, const mp_int *b,
				mp_int *c) MP_WUR;
/* 74 */
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
    int (*tclBN_mp_cnt_lsb) (const mp_int *a) MP_WUR; /* 63 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_l()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_ll()") void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_ull()") void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
    TCL_DEPRECATED_API("Use mp_expt_u32") mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, unsigned int b, mp_int *c, int fast); /* 67 */
    void (*tclBN_mp_set_ull) (mp_int *a, Tcl_WideUInt i); /* 68 */
    Tcl_WideUInt (*tclBN_mp_get_mag_ull) (const mp_int *a) MP_WUR; /* 69 */
    void (*reserved70)(void);
    unsigned long (*tclBN_mp_get_mag_ul) (const mp_int *a) MP_WUR; /* 71 */
    void (*reserved72)(void);
    mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 73 */
    mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 74 */
    mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 75 */
    mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 76 */
    TCL_DEPRECATED_API("is private function in libtommath") mp_bool (*tclBN_mp_get_bit) (const mp_int *a, unsigned int b); /* 77 */







|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    int (*tclBN_mp_cnt_lsb) (const mp_int *a) MP_WUR; /* 63 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_l()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_ll()") void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
    TCL_DEPRECATED_API("Use mp_init() + mp_set_ull()") void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
    TCL_DEPRECATED_API("Use mp_expt_u32") mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, unsigned int b, mp_int *c, int fast); /* 67 */
    void (*tclBN_mp_set_ull) (mp_int *a, Tcl_WideUInt i); /* 68 */
    Tcl_WideUInt (*tclBN_mp_get_mag_ull) (const mp_int *a) MP_WUR; /* 69 */
    void (*tclBN_mp_set_ll) (mp_int *a, Tcl_WideInt i); /* 70 */
    unsigned long (*tclBN_mp_get_mag_ul) (const mp_int *a) MP_WUR; /* 71 */
    void (*reserved72)(void);
    mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 73 */
    mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 74 */
    mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 75 */
    mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 76 */
    TCL_DEPRECATED_API("is private function in libtommath") mp_bool (*tclBN_mp_get_bit) (const mp_int *a, unsigned int b); /* 77 */
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
	(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
#define TclBN_mp_expt_d_ex \
	(tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
#define TclBN_mp_set_ull \
	(tclTomMathStubsPtr->tclBN_mp_set_ull) /* 68 */
#define TclBN_mp_get_mag_ull \
	(tclTomMathStubsPtr->tclBN_mp_get_mag_ull) /* 69 */
/* Slot 70 is reserved */

#define TclBN_mp_get_mag_ul \
	(tclTomMathStubsPtr->tclBN_mp_get_mag_ul) /* 71 */
/* Slot 72 is reserved */
#define TclBN_mp_tc_and \
	(tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */
#define TclBN_mp_tc_or \
	(tclTomMathStubsPtr->tclBN_mp_tc_or) /* 74 */







|
>







615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
	(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
#define TclBN_mp_expt_d_ex \
	(tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
#define TclBN_mp_set_ull \
	(tclTomMathStubsPtr->tclBN_mp_set_ull) /* 68 */
#define TclBN_mp_get_mag_ull \
	(tclTomMathStubsPtr->tclBN_mp_get_mag_ull) /* 69 */
#define TclBN_mp_set_ll \
	(tclTomMathStubsPtr->tclBN_mp_set_ll) /* 70 */
#define TclBN_mp_get_mag_ul \
	(tclTomMathStubsPtr->tclBN_mp_get_mag_ul) /* 71 */
/* Slot 72 is reserved */
#define TclBN_mp_tc_and \
	(tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */
#define TclBN_mp_tc_or \
	(tclTomMathStubsPtr->tclBN_mp_tc_or) /* 74 */
Changes to generic/tclTomMathInterface.c.
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 */

void
TclBNInitBignumFromWideInt(
    mp_int *a,			/* Bignum to initialize */
    Tcl_WideInt v)		/* Initial value */
{
	if (mp_init(a) != MP_OKAY) {
	wipanic:
	    Tcl_Panic("initialization failure in TclBNInitBignumFromWideInt");
	}
    if (v < 0) {
	mp_set_ull(a, (Tcl_WideUInt)(-v));
	if (mp_neg(a, a) != MP_OKAY) goto wipanic;
    } else {
	mp_set_ull(a, (Tcl_WideUInt)v);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TclBNInitBignumFromWideUInt --
 *







|
<
|
|
<
<
<
<
|
<







107
108
109
110
111
112
113
114

115
116




117

118
119
120
121
122
123
124
 */

void
TclBNInitBignumFromWideInt(
    mp_int *a,			/* Bignum to initialize */
    Tcl_WideInt v)		/* Initial value */
{
    if (mp_init(a) != MP_OKAY) {

	Tcl_Panic("insufficient memory to create bignum");
    }




    mp_set_ll(a, v);

}

/*
 *----------------------------------------------------------------------
 *
 * TclBNInitBignumFromWideUInt --
 *
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 */

void
TclBNInitBignumFromWideUInt(
    mp_int *a,			/* Bignum to initialize */
    Tcl_WideUInt v)		/* Initial value */
{
	if (mp_init(a) != MP_OKAY) {
	    Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt");
	}
	mp_set_ull(a, v);
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */







|
|
|
|









134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 */

void
TclBNInitBignumFromWideUInt(
    mp_int *a,			/* Bignum to initialize */
    Tcl_WideUInt v)		/* Initial value */
{
    if (mp_init(a) != MP_OKAY) {
	Tcl_Panic("insufficient memory to create bignum");
    }
    mp_set_ull(a, v);
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */