Tcl Source Code

Check-in [1baf516ed4]
Login

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

Overview
Comment:Possible simple solution for [4663e0636]: If TCL_NO_TOMMATH_H is defined, tclTomMath.h provides its own usable mp_int type (and some more) without the need for <tommath.h>
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | bug-4663e0636
Files: files | file ages | folders
SHA3-256: 1baf516ed4f18e088b3fefec81c8a34bb1a463d5223175454d02146c677f49a9
User & Date: jan.nijtmans 2020-05-19 15:42:53.152
References
2023-04-22
12:41 New ticket [2a5cb49733] Make TCL_NO_TOMMATH_H sufficient for tclTomMathDecls.h. artifact: fbec7a1e1d user: chrstphrchvz
2020-05-19
15:51 Ticket [4663e0636f] TIP 538 and Tcl extensions: 'tommath.h' file not found status still Open with 3 other changes artifact: 8c5f7cae39 user: jan.nijtmans
Context
2020-05-31
20:24
Make tclTomMath.h usable without tommath.h by defining TCL_NO_TOMMATH_H check-in: 4e9dafc4fe user: jan.nijtmans tags: core-8-branch
2020-05-19
15:42
Possible simple solution for [4663e0636]: If TCL_NO_TOMMATH_H is defined, tclTomMath.h provides its ... Closed-Leaf check-in: 1baf516ed4 user: jan.nijtmans tags: bug-4663e0636
2020-05-18
20:25
Merge-mark check-in: 4427efd83c user: jan.nijtmans tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclTomMath.h.
1
2
3
4
5
6
7
8
9
10































11
12
13
14
15
16
#ifndef BN_TCL_H_
#define BN_TCL_H_

#ifdef MP_NO_STDINT
#   ifdef HAVE_STDINT_H
#	include <stdint.h>
#else
#	include "../compat/stdint.h"
#   endif
#endif































#ifndef BN_H_ /* If BN_H_ already defined, don't try to include tommath.h again. */
#   include "tommath.h"
#endif
#include "tclTomMathDecls.h"

#endif










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





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef BN_TCL_H_
#define BN_TCL_H_

#ifdef MP_NO_STDINT
#   ifdef HAVE_STDINT_H
#	include <stdint.h>
#else
#	include "../compat/stdint.h"
#   endif
#endif
#if defined(TCL_NO_TOMMATH_H)
    typedef size_t mp_digit;
    typedef int mp_sign;
#   define MP_ZPOS       0   /* positive integer */
#   define MP_NEG        1   /* negative */
    typedef int mp_ord;
#   define MP_LT        -1   /* less than */
#   define MP_EQ         0   /* equal to */
#   define MP_GT         1   /* greater than */
    typedef int mp_err;
#   define MP_OKAY       0   /* no error */
#   define MP_ERR        -1  /* unknown error */
#   define MP_MEM        -2  /* out of mem */
#   define MP_VAL        -3  /* invalid input */
#   define MP_ITER       -4  /* maximum iterations reached */
#   define MP_BUF        -5  /* buffer overflow, supplied buffer too small */
#   define MP_WUR            /* nothing */
#   define mp_iszero(a) ((a)->used == 0)
#   define mp_isneg(a)  ((a)->sign != 0)

    /* the infamous mp_int structure */
#   ifndef MP_INT_DECLARED
#	define MP_INT_DECLARED
	typedef struct mp_int mp_int;
#   endif
    struct mp_int {
	int used, alloc;
	mp_sign sign;
	mp_digit *dp;
};

#elif !defined(BN_H_) /* If BN_H_ already defined, don't try to include tommath.h again. */
#   include "tommath.h"
#endif
#include "tclTomMathDecls.h"

#endif
Changes to generic/tclTomMathDecls.h.
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
#define mp_init_i32(a,b) mp_init_i64((a),(int32_t)(b))
#define mp_init_l(a,b) mp_init_i64((a),(long)(b))
#define mp_init_u32(a,b) mp_init_u64((a),(uint32_t)(b))
#define mp_init_ul(a,b) mp_init_u64((a),(unsigned long)(b))
#undef mp_iseven
#undef mp_isodd
#define mp_iseven(a) (!mp_isodd(a))
#define mp_isodd(a)  (((a)->used != 0 && (((a)->dp[0] & 1) != 0)) ? MP_YES : MP_NO)
#undef mp_sqr
#define mp_sqr(a,b) mp_mul(a,a,b)

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

#endif /* _TCLINTDECLS */







|







740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
#define mp_init_i32(a,b) mp_init_i64((a),(int32_t)(b))
#define mp_init_l(a,b) mp_init_i64((a),(long)(b))
#define mp_init_u32(a,b) mp_init_u64((a),(uint32_t)(b))
#define mp_init_ul(a,b) mp_init_u64((a),(unsigned long)(b))
#undef mp_iseven
#undef mp_isodd
#define mp_iseven(a) (!mp_isodd(a))
#define mp_isodd(a)  (((a)->used != 0) && (((a)->dp[0] & 1) != 0))
#undef mp_sqr
#define mp_sqr(a,b) mp_mul(a,a,b)

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

#endif /* _TCLINTDECLS */