Check-in [5198b4c951]
Not logged in

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

Overview
Comment:merge with trunk
Timelines: family | ancestors | descendants | both | wtf-8-experiment
Files: files | file ages | folders
SHA1: 5198b4c9512526397da98491aaf5ecdb21942a82
User & Date: chw 2019-05-30 15:11:28.232
Context
2019-05-31
17:24
merge with trunk check-in: 9e57d32c2f user: chw tags: wtf-8-experiment
2019-05-30
15:11
merge with trunk check-in: 5198b4c951 user: chw tags: wtf-8-experiment
15:10
improve tcl-fuse w.r.t. [de97313b0b] check-in: acb4d8bdc9 user: chw tags: trunk
2019-05-29
03:58
merge with trunk check-in: b0632ecbad user: chw tags: wtf-8-experiment
Changes
Unified Diff Ignore Whitespace Patch
Changes to assets/materialicons0.2/show.tcl.
1
2
3

4
5
6
7
8
9
10
# Simple viewer for MaterialIcons package.
#
# chw January 2019


package require Tk
package require MaterialIcons
package require tooltip

wm title . "MaterialIcons"




>







1
2
3
4
5
6
7
8
9
10
11
# Simple viewer for MaterialIcons package.
#
# chw January 2019
# search facility: dzach May 2019

package require Tk
package require MaterialIcons
package require tooltip

wm title . "MaterialIcons"

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
48
49
50
51
52
53
54
55
56
57
58


59
60
61
62


63
64
65
66
67
68
69
	return
    }
    clipboard clear
    clipboard append -type STRING -- $::name
}

proc showicons {} {







    canvas .v -yscrollcommand {.y set} -xscrollcommand {.x set}
    grid .v -row 0 -column 0 -sticky news
    ttk::scrollbar .y -orient vertical -command {.v yview}
    grid .y -row 0 -column 1 -sticky ns
    ttk::scrollbar .x -orient horizontal -command {.v xview}
    grid .x -row 1 -column 0 -sticky ew
    label .l -textvariable name
    grid .l -row 2 -column 0 -sticky ew
    grid rowconfigure . 0 -weight 1
    grid columnconfigure . 0 -weight 1












    set ::name ""
    set x 20
    set y 20


    set xmax [expr {[winfo screenwidth .] - 80}]






    foreach n [MaterialIcons names] {
	set i [MaterialIcons image $n 20]
	set c [.v create image $x $y -anchor nw -image $i \
	    -tags [list _icons $n]]
	lassign [.v bbox $c] x1 y1 x2 y2
	if {$x1 > $xmax} {
	    set y [expr {$y2 + 10}]
	    set x 20
	    .v coords $c $x $y
	    lassign [.v bbox $c] x1 y1 x2 y2
	}
	set x [expr {$x2 + 10}]
	tooltip::tooltip .v -items $c $n
    }



    lassign [.v bbox _icons] x1 y1 x2 y2
    .v configure -scrollregion \
	[list [expr {$x1 - 20}] [expr {$y1 - 20}] \
	     [expr {$x2 + 20}] [expr {$y2 + 20}]]



    .v bind _icons <Enter> {showname 1}
    .v bind _icons <Leave> {showname 0}
    .v bind _icons <1> putclipboard
}

showicons







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



>
>
|
|
>
>
>
>
>
|














>
>
|
|
<
|
>
>
|
<
<
<



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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

89
90
91
92



93
94
95
	return
    }
    clipboard clear
    clipboard append -type STRING -- $::name
}

proc showicons {} {
    if {![winfo exists .v]} {
	set ::pattern *
	frame .f
	label .f.s -text "Search: "
	entry .f.e -textvariable ::pattern -width 30
	pack .f.s .f.e -side left
	grid .f -row 0 -column 0 -padx 4 -pady 4 -columnspan 2 -sticky w
	canvas .v -yscrollcommand {.y set} -xscrollcommand {.x set} -bg white
	grid .v -row 1 -column 0 -sticky news
	ttk::scrollbar .y -orient vertical -command {.v yview}
	grid .y -row 1 -column 1 -sticky ns
	ttk::scrollbar .x -orient horizontal -command {.v xview}
	grid .x -row 2 -column 0 -sticky ew
	label .l -textvariable name
	grid .l -row 3 -column 0 -sticky ew
	grid rowconfigure . 1 -weight 1
	grid columnconfigure . 0 -weight 1
	bind .f.e <Return> {showicons ; break}
	bind .f.e <KP_Enter> {showicons ; break}
	bind . <Configure> {showicons ; break}
	.f.e icursor end
	.v bind _icons <Enter> {showname 1}
	.v bind _icons <Leave> {showname 0}
	.v bind _icons <1> putclipboard
    } else {
	.v delete all
	tooltip::tooltip .v -items {} {}
    }

    set ::name ""
    set x 20
    set y 20
    set xmax [winfo width .]
    if {$xmax == 1} {
	set xmax [expr {[winfo reqwidth .v] + [winfo reqwidth .y]}]
    }
    set xmax [expr {$xmax - 64}]
    if {$xmax < 200} {
	set xmax 200
    }

    foreach n [MaterialIcons names $::pattern] {
	set i [MaterialIcons image $n 20]
	set c [.v create image $x $y -anchor nw -image $i \
	    -tags [list _icons $n]]
	lassign [.v bbox $c] x1 y1 x2 y2
	if {$x1 > $xmax} {
	    set y [expr {$y2 + 10}]
	    set x 20
	    .v coords $c $x $y
	    lassign [.v bbox $c] x1 y1 x2 y2
	}
	set x [expr {$x2 + 10}]
	tooltip::tooltip .v -items $c $n
    }

    set bbox [.v bbox _icons]
    if {[llength $bbox]} {
	lassign [.v bbox _icons] x1 y1 x2 y2
	.v configure -scrollregion [list [expr {$x1 - 20}] [expr {$y1 - 20}] \

	    [expr {$x2 + 20}] [expr {$y2 + 20}]]
    } else {
	.v configure -scrollregion {}
    }



}

showicons
Changes to jni/tcl/generic/tclExecute.c.
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
	    Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);

	    mp_init(&bigResult);

	    switch (opcode) {
	    case INST_BITAND:
		mp_tc_and(&big1, &big2, &bigResult);
		break;

	    case INST_BITOR:
		mp_tc_or(&big1, &big2, &bigResult);
		break;

	    case INST_BITXOR:
		mp_tc_xor(&big1, &big2, &bigResult);
		break;
	    }

	    mp_clear(&big1);
	    mp_clear(&big2);
	    BIG_RESULT(&bigResult);
	}







|



|



|







8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
	    Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);

	    mp_init(&bigResult);

	    switch (opcode) {
	    case INST_BITAND:
		mp_and(&big1, &big2, &bigResult);
		break;

	    case INST_BITOR:
		mp_or(&big1, &big2, &bigResult);
		break;

	    case INST_BITXOR:
		mp_xor(&big1, &big2, &bigResult);
		break;
	    }

	    mp_clear(&big1);
	    mp_clear(&big2);
	    BIG_RESULT(&bigResult);
	}
Changes to jni/tcl/generic/tclStringObj.c.
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
	    } else if (useWide) {
		if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
		    Tcl_Obj *objPtr;

		    if (Tcl_GetBignumFromObj(interp,segment,&big) != TCL_OK) {
			goto error;
		    }
		    mp_mod_2d(&big, (int) CHAR_BIT*sizeof(Tcl_WideInt), &big);
		    objPtr = Tcl_NewBignumObj(&big);
		    Tcl_IncrRefCount(objPtr);
		    Tcl_GetWideIntFromObj(NULL, objPtr, &w);
		    Tcl_DecrRefCount(objPtr);
		}
		isNegative = (w < (Tcl_WideInt) 0);
#endif
	    } else if (TclGetLongFromObj(NULL, segment, &l) != TCL_OK) {
		if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
		    Tcl_Obj *objPtr;

		    if (Tcl_GetBignumFromObj(interp,segment,&big) != TCL_OK) {
			goto error;
		    }
		    mp_mod_2d(&big, (int) CHAR_BIT * sizeof(long), &big);
		    objPtr = Tcl_NewBignumObj(&big);
		    Tcl_IncrRefCount(objPtr);
		    TclGetLongFromObj(NULL, objPtr, &l);
		    Tcl_DecrRefCount(objPtr);
		} else {
		    l = Tcl_WideAsLong(w);
		}







|














|







2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
	    } else if (useWide) {
		if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
		    Tcl_Obj *objPtr;

		    if (Tcl_GetBignumFromObj(interp,segment,&big) != TCL_OK) {
			goto error;
		    }
		    mp_mod_2d(&big, CHAR_BIT*sizeof(Tcl_WideInt), &big);
		    objPtr = Tcl_NewBignumObj(&big);
		    Tcl_IncrRefCount(objPtr);
		    Tcl_GetWideIntFromObj(NULL, objPtr, &w);
		    Tcl_DecrRefCount(objPtr);
		}
		isNegative = (w < (Tcl_WideInt) 0);
#endif
	    } else if (TclGetLongFromObj(NULL, segment, &l) != TCL_OK) {
		if (Tcl_GetWideIntFromObj(NULL, segment, &w) != TCL_OK) {
		    Tcl_Obj *objPtr;

		    if (Tcl_GetBignumFromObj(interp,segment,&big) != TCL_OK) {
			goto error;
		    }
		    mp_mod_2d(&big, CHAR_BIT * sizeof(long), &big);
		    objPtr = Tcl_NewBignumObj(&big);
		    Tcl_IncrRefCount(objPtr);
		    TclGetLongFromObj(NULL, objPtr, &l);
		    Tcl_DecrRefCount(objPtr);
		} else {
		    l = Tcl_WideAsLong(w);
		}
Changes to jni/tcl/libtommath/bn_mp_and.c.
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
48
49
50
51
52
53
54
#include "tommath_private.h"
#ifdef BN_MP_AND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* AND two ints together */
int mp_and(const mp_int *a, const mp_int *b, mp_int *c)
{
   int     res, ix, px;
   mp_int  t;
   const mp_int *x;


   if (a->used > b->used) {
      if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
         return res;
      }

      px = b->used;






      x = b;

   } else {
      if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
         return res;
      }
      px = a->used;



      x = a;



   }

   for (ix = 0; ix < px; ix++) {
      t.dp[ix] &= x->dp[ix];
   }






   /* zero digits above the last from the smallest mp_int */
   for (; ix < t.used; ix++) {
      t.dp[ix] = 0;
   }



   mp_clamp(&t);
   mp_exch(c, &t);
   mp_clear(&t);
   return MP_OKAY;
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */


|
<
<
<
<
<
<
<
<
|
<

|
|

|
|
|
>

|
|
|

>
|
>
>
>
>
>
>
|
>
|
|
<

|
>
>
>
|
>
>
>
|

<
|
|
>
>
>
>
>
|
<
<
<


>
>
|
<
<



<
<
<
<
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
48



49
50
51
52
53


54
55
56




#include "tommath_private.h"
#ifdef BN_MP_AND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* two complement and */
mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
{
   int used = MAX(a->used, b->used) + 1, i;
   mp_err err;
   mp_digit ac = 1, bc = 1, cc = 1;
   mp_sign csign = ((a->sign == MP_NEG) && (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;

   if (c->alloc < used) {
      if ((err = mp_grow(c, used)) != MP_OKAY) {
         return err;
      }
   }

   for (i = 0; i < used; i++) {
      mp_digit x, y;

      /* convert to two complement if negative */
      if (a->sign == MP_NEG) {
         ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
         x = ac & MP_MASK;
         ac >>= MP_DIGIT_BIT;
      } else {
         x = (i >= a->used) ? 0uL : a->dp[i];

      }

      /* convert to two complement if negative */
      if (b->sign == MP_NEG) {
         bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
         y = bc & MP_MASK;
         bc >>= MP_DIGIT_BIT;
      } else {
         y = (i >= b->used) ? 0uL : b->dp[i];
      }


      c->dp[i] = x & y;

      /* convert to to sign-magnitude if negative */
      if (csign == MP_NEG) {
         cc += ~c->dp[i] & MP_MASK;
         c->dp[i] = cc & MP_MASK;
         cc >>= MP_DIGIT_BIT;
      }



   }

   c->used = used;
   c->sign = csign;
   mp_clamp(c);


   return MP_OKAY;
}
#endif




Changes to jni/tcl/libtommath/bn_mp_cmp.c.
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
#include "tommath_private.h"
#ifdef BN_MP_CMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* compare two ints (signed)*/
int mp_cmp(const mp_int *a, const mp_int *b)
{
   /* compare based on sign */
   if (a->sign != b->sign) {
      if (a->sign == MP_NEG) {
         return MP_LT;
      } else {
         return MP_GT;
      }
   }

   /* compare digits */
   if (a->sign == MP_NEG) {
      /* if negative compare opposite direction */
      return mp_cmp_mag(b, a);
   } else {
      return mp_cmp_mag(a, b);
   }
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */


|
<
<
<
<
<
<
<
<
|
<


|



















<
<
<
<
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




#include "tommath_private.h"
#ifdef BN_MP_CMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* compare two ints (signed)*/
mp_ord mp_cmp(const mp_int *a, const mp_int *b)
{
   /* compare based on sign */
   if (a->sign != b->sign) {
      if (a->sign == MP_NEG) {
         return MP_LT;
      } else {
         return MP_GT;
      }
   }

   /* compare digits */
   if (a->sign == MP_NEG) {
      /* if negative compare opposite direction */
      return mp_cmp_mag(b, a);
   } else {
      return mp_cmp_mag(a, b);
   }
}
#endif




Changes to jni/tcl/libtommath/bn_mp_cmp_d.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "tommath_private.h"
#ifdef BN_MP_CMP_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* compare a digit */
int mp_cmp_d(const mp_int *a, mp_digit b)
{
   /* compare based on sign */
   if (a->sign == MP_NEG) {
      return MP_LT;
   }

   /* compare based on magnitude */


|
<
<
<
<
<
<
<
<
|
<


|







1
2
3








4

5
6
7
8
9
10
11
12
13
14
#include "tommath_private.h"
#ifdef BN_MP_CMP_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* compare a digit */
mp_ord mp_cmp_d(const mp_int *a, mp_digit b)
{
   /* compare based on sign */
   if (a->sign == MP_NEG) {
      return MP_LT;
   }

   /* compare based on magnitude */
31
32
33
34
35
36
37
38
39
40
41
   } else if (a->dp[0] < b) {
      return MP_LT;
   } else {
      return MP_EQ;
   }
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */







<
<
<
<
22
23
24
25
26
27
28




   } else if (a->dp[0] < b) {
      return MP_LT;
   } else {
      return MP_EQ;
   }
}
#endif




Changes to jni/tcl/libtommath/bn_mp_cmp_mag.c.
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
#include "tommath_private.h"
#ifdef BN_MP_CMP_MAG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* compare maginitude of two ints (unsigned) */
int mp_cmp_mag(const mp_int *a, const mp_int *b)
{
   int     n;
   mp_digit *tmpa, *tmpb;

   /* compare based on # of non-zero digits */
   if (a->used > b->used) {
      return MP_GT;
   }

   if (a->used < b->used) {


|
<
<
<
<
<
<
<
<
|
<


|


|







1
2
3








4

5
6
7
8
9
10
11
12
13
14
15
16
17
#include "tommath_private.h"
#ifdef BN_MP_CMP_MAG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* compare maginitude of two ints (unsigned) */
mp_ord mp_cmp_mag(const mp_int *a, const mp_int *b)
{
   int     n;
   const mp_digit *tmpa, *tmpb;

   /* compare based on # of non-zero digits */
   if (a->used > b->used) {
      return MP_GT;
   }

   if (a->used < b->used) {
42
43
44
45
46
47
48
49
50
51
52
      if (*tmpa < *tmpb) {
         return MP_LT;
      }
   }
   return MP_EQ;
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */







<
<
<
<
33
34
35
36
37
38
39




      if (*tmpa < *tmpb) {
         return MP_LT;
      }
   }
   return MP_EQ;
}
#endif




Changes to jni/tcl/libtommath/bn_mp_or.c.
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
48
#include "tommath_private.h"
#ifdef BN_MP_OR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* OR two ints together */
int mp_or(const mp_int *a, const mp_int *b, mp_int *c)
{
   int     res, ix, px;
   mp_int  t;
   const mp_int *x;


   if (a->used > b->used) {
      if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
         return res;
      }

      px = b->used;






      x = b;

   } else {
      if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
         return res;
      }
      px = a->used;



      x = a;



   }


   for (ix = 0; ix < px; ix++) {



      t.dp[ix] |= x->dp[ix];

   }




   mp_clamp(&t);
   mp_exch(c, &t);
   mp_clear(&t);
   return MP_OKAY;
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */


|
<
<
<
<
<
<
<
<
|
<

|
|

|
|
|
>

|
|
|

>
|
>
>
>
>
>
>
|
>
|
|
<

|
>
>
>
|
>
>
>
|

>
|
>
>
>
|
>
|
>
>
>
>
|
<
<



<
<
<
<
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
48
49
50
51
52
53


54
55
56




#include "tommath_private.h"
#ifdef BN_MP_OR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* two complement or */
mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c)
{
   int used = MAX(a->used, b->used) + 1, i;
   mp_err err;
   mp_digit ac = 1, bc = 1, cc = 1;
   mp_sign csign = ((a->sign == MP_NEG) || (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;

   if (c->alloc < used) {
      if ((err = mp_grow(c, used)) != MP_OKAY) {
         return err;
      }
   }

   for (i = 0; i < used; i++) {
      mp_digit x, y;

      /* convert to two complement if negative */
      if (a->sign == MP_NEG) {
         ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
         x = ac & MP_MASK;
         ac >>= MP_DIGIT_BIT;
      } else {
         x = (i >= a->used) ? 0uL : a->dp[i];

      }

      /* convert to two complement if negative */
      if (b->sign == MP_NEG) {
         bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
         y = bc & MP_MASK;
         bc >>= MP_DIGIT_BIT;
      } else {
         y = (i >= b->used) ? 0uL : b->dp[i];
      }

      c->dp[i] = x | y;

      /* convert to to sign-magnitude if negative */
      if (csign == MP_NEG) {
         cc += ~c->dp[i] & MP_MASK;
         c->dp[i] = cc & MP_MASK;
         cc >>= MP_DIGIT_BIT;
      }
   }

   c->used = used;
   c->sign = csign;
   mp_clamp(c);


   return MP_OKAY;
}
#endif




Changes to jni/tcl/libtommath/bn_mp_xor.c.
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
48
#include "tommath_private.h"
#ifdef BN_MP_XOR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * SPDX-License-Identifier: Unlicense
 */

/* XOR two ints together */
int mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
{
   int     res, ix, px;
   mp_int  t;
   const mp_int *x;


   if (a->used > b->used) {
      if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
         return res;
      }

      px = b->used;






      x = b;

   } else {
      if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
         return res;
      }
      px = a->used;



      x = a;



   }


   for (ix = 0; ix < px; ix++) {



      t.dp[ix] ^= x->dp[ix];

   }




   mp_clamp(&t);
   mp_exch(c, &t);
   mp_clear(&t);
   return MP_OKAY;
}
#endif

/* ref:         $Format:%D$ */
/* git commit:  $Format:%H$ */
/* commit time: $Format:%ai$ */


|
<
<
<
<
<
<
<
<
|
<

|
|

|
|
|
>

|
|
|

>
|
>
>
>
>
>
>
|
>
|
|
<

|
>
>
>
|
>
>
>
|

>
|
>
>
>
|
>
|
>
>
>
>
|
<
<



<
<
<
<
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
48
49
50
51
52
53


54
55
56




#include "tommath_private.h"
#ifdef BN_MP_XOR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */








/* SPDX-License-Identifier: Unlicense */


/* two complement xor */
mp_err mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
{
   int used = MAX(a->used, b->used) + 1, i;
   mp_err err;
   mp_digit ac = 1, bc = 1, cc = 1;
   mp_sign csign = (a->sign != b->sign) ? MP_NEG : MP_ZPOS;

   if (c->alloc < used) {
      if ((err = mp_grow(c, used)) != MP_OKAY) {
         return err;
      }
   }

   for (i = 0; i < used; i++) {
      mp_digit x, y;

      /* convert to two complement if negative */
      if (a->sign == MP_NEG) {
         ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
         x = ac & MP_MASK;
         ac >>= MP_DIGIT_BIT;
      } else {
         x = (i >= a->used) ? 0uL : a->dp[i];

      }

      /* convert to two complement if negative */
      if (b->sign == MP_NEG) {
         bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
         y = bc & MP_MASK;
         bc >>= MP_DIGIT_BIT;
      } else {
         y = (i >= b->used) ? 0uL : b->dp[i];
      }

      c->dp[i] = x ^ y;

      /* convert to to sign-magnitude if negative */
      if (csign == MP_NEG) {
         cc += ~c->dp[i] & MP_MASK;
         c->dp[i] = cc & MP_MASK;
         cc >>= MP_DIGIT_BIT;
      }
   }

   c->used = used;
   c->sign = csign;
   mp_clamp(c);


   return MP_OKAY;
}
#endif




Changes to undroid/tcl-fuse/unix/tclfuse.c.
383
384
385
386
387
388
389


390
391
392
393
394
395
396
    if (!buf) {
        Tcl_SetResult(mp->fsdata->interp, "fuse: failed to allocate read buffer", TCL_STATIC);
        Tcl_BackgroundError(mp->fsdata->interp);
        // NOTE: We don't teardown in this case, we just don't process the request.
        return;
    }



    while (!(exited = fuse_session_exited(se))) {
        struct fuse_chan *tmpch = ch;
        res = fuse_chan_recv(&tmpch, buf, bufsize);
        if (res == -EINTR)
            continue;
        if (res == 0)
            exited = fuse_session_exited(se);







>
>







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
    if (!buf) {
        Tcl_SetResult(mp->fsdata->interp, "fuse: failed to allocate read buffer", TCL_STATIC);
        Tcl_BackgroundError(mp->fsdata->interp);
        // NOTE: We don't teardown in this case, we just don't process the request.
        return;
    }

    Tcl_DeleteChannelHandler(mp->chan, ChannelEventHandler, (void *) mp);

    while (!(exited = fuse_session_exited(se))) {
        struct fuse_chan *tmpch = ch;
        res = fuse_chan_recv(&tmpch, buf, bufsize);
        if (res == -EINTR)
            continue;
        if (res == 0)
            exited = fuse_session_exited(se);
423
424
425
426
427
428
429


430
431
432
433
434
435
436
                Tcl_BackgroundError(mp->fsdata->interp);
                return;
            }
            ckfree((char *) mp);
        }
        return;
    }


}

static struct fuse *tclfuse_setup(int argc, const char *argv[],
                      const struct fuse_operations *op,
                      size_t op_size,
                      char **mountpoint,
                      int *multithreaded,







>
>







425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
                Tcl_BackgroundError(mp->fsdata->interp);
                return;
            }
            ckfree((char *) mp);
        }
        return;
    }

    Tcl_CreateChannelHandler(mp->chan, TCL_READABLE, ChannelEventHandler, (void *) mp);
}

static struct fuse *tclfuse_setup(int argc, const char *argv[],
                      const struct fuse_operations *op,
                      size_t op_size,
                      char **mountpoint,
                      int *multithreaded,