Fix POST with streams to use chunked encoding, add http-put word
[factor/jcg.git] / vm / bignum.h
blob02309cad34516b1835b26cb614a92824700c7461
1 /* :tabSize=2:indentSize=2:noTabs=true:
3 Copyright (C) 1989-1992 Massachusetts Institute of Technology
4 Portions copyright (C) 2004-2007 Slava Pestov
6 This material was developed by the Scheme project at the Massachusetts
7 Institute of Technology, Department of Electrical Engineering and
8 Computer Science. Permission to copy and modify this software, to
9 redistribute either the original software or a modified version, and
10 to use this software for any purpose is granted, subject to the
11 following restrictions and understandings.
13 1. Any copy made of this software must include this copyright notice
14 in full.
16 2. Users of this software agree to make their best efforts (a) to
17 return to the MIT Scheme project any improvements or extensions that
18 they make, so that these may be included in future releases; and (b)
19 to inform MIT of noteworthy uses of this software.
21 3. All materials developed as a consequence of the use of this
22 software shall duly acknowledge such use, in accordance with the usual
23 standards of acknowledging credit in academic research.
25 4. MIT has made no warrantee or representation that the operation of
26 this software will be error-free, and MIT is under no obligation to
27 provide any services, by way of maintenance, update, or otherwise.
29 5. In conjunction with products arising from the use of this material,
30 there shall be no use of the name of the Massachusetts Institute of
31 Technology nor of any adaptation thereof in any advertising,
32 promotional, or sales literature without prior written consent from
33 MIT in each case. */
35 typedef F_ARRAY * bignum_type;
36 #define BIGNUM_OUT_OF_BAND ((bignum_type) 0)
38 enum bignum_comparison
40 bignum_comparison_equal = 0,
41 bignum_comparison_less = -1,
42 bignum_comparison_greater = 1
45 int bignum_equal_p(bignum_type, bignum_type);
46 enum bignum_comparison bignum_compare(bignum_type, bignum_type);
47 bignum_type bignum_add(bignum_type, bignum_type);
48 bignum_type bignum_subtract(bignum_type, bignum_type);
49 bignum_type bignum_negate(bignum_type);
50 bignum_type bignum_multiply(bignum_type, bignum_type);
51 void
52 bignum_divide(bignum_type numerator, bignum_type denominator,
53 bignum_type * quotient, bignum_type * remainder);
54 bignum_type bignum_quotient(bignum_type, bignum_type);
55 bignum_type bignum_remainder(bignum_type, bignum_type);
56 DLLEXPORT bignum_type fixnum_to_bignum(F_FIXNUM);
57 DLLEXPORT bignum_type cell_to_bignum(CELL);
58 DLLEXPORT bignum_type long_long_to_bignum(s64 n);
59 DLLEXPORT bignum_type ulong_long_to_bignum(u64 n);
60 F_FIXNUM bignum_to_fixnum(bignum_type);
61 CELL bignum_to_cell(bignum_type);
62 s64 bignum_to_long_long(bignum_type);
63 u64 bignum_to_ulong_long(bignum_type);
64 bignum_type double_to_bignum(double);
65 double bignum_to_double(bignum_type);
67 /* Added bitwise operators. */
69 DLLEXPORT bignum_type bignum_bitwise_not(bignum_type),
70 bignum_arithmetic_shift(bignum_type, F_FIXNUM),
71 bignum_bitwise_and(bignum_type, bignum_type),
72 bignum_bitwise_ior(bignum_type, bignum_type),
73 bignum_bitwise_xor(bignum_type, bignum_type);
75 /* Forward references */
76 int bignum_equal_p_unsigned(bignum_type, bignum_type);
77 enum bignum_comparison bignum_compare_unsigned(bignum_type, bignum_type);
78 bignum_type bignum_add_unsigned(bignum_type, bignum_type, int);
79 bignum_type bignum_subtract_unsigned(bignum_type, bignum_type);
80 bignum_type bignum_multiply_unsigned(bignum_type, bignum_type, int);
81 bignum_type bignum_multiply_unsigned_small_factor
82 (bignum_type, bignum_digit_type, int);
83 void bignum_destructive_scale_up(bignum_type, bignum_digit_type);
84 void bignum_destructive_add(bignum_type, bignum_digit_type);
85 void bignum_divide_unsigned_large_denominator
86 (bignum_type, bignum_type, bignum_type *, bignum_type *, int, int);
87 void bignum_destructive_normalization(bignum_type, bignum_type, int);
88 void bignum_destructive_unnormalization(bignum_type, int);
89 void bignum_divide_unsigned_normalized(bignum_type, bignum_type, bignum_type);
90 bignum_digit_type bignum_divide_subtract
91 (bignum_digit_type *, bignum_digit_type *, bignum_digit_type,
92 bignum_digit_type *);
93 void bignum_divide_unsigned_medium_denominator
94 (bignum_type, bignum_digit_type, bignum_type *, bignum_type *, int, int);
95 bignum_digit_type bignum_digit_divide
96 (bignum_digit_type, bignum_digit_type, bignum_digit_type, bignum_digit_type *);
97 bignum_digit_type bignum_digit_divide_subtract
98 (bignum_digit_type, bignum_digit_type, bignum_digit_type, bignum_digit_type *);
99 void bignum_divide_unsigned_small_denominator
100 (bignum_type, bignum_digit_type, bignum_type *, bignum_type *, int, int);
101 bignum_digit_type bignum_destructive_scale_down
102 (bignum_type, bignum_digit_type);
103 bignum_type bignum_remainder_unsigned_small_denominator
104 (bignum_type, bignum_digit_type, int);
105 bignum_type bignum_digit_to_bignum(bignum_digit_type, int);
106 bignum_type allot_bignum(bignum_length_type, int);
107 bignum_type allot_bignum_zeroed(bignum_length_type, int);
108 bignum_type bignum_shorten_length(bignum_type, bignum_length_type);
109 bignum_type bignum_trim(bignum_type);
110 bignum_type bignum_new_sign(bignum_type, int);
111 bignum_type bignum_maybe_new_sign(bignum_type, int);
112 void bignum_destructive_copy(bignum_type, bignum_type);
114 /* Added for bitwise operations. */
115 bignum_type bignum_magnitude_ash(bignum_type arg1, F_FIXNUM n);
116 bignum_type bignum_pospos_bitwise_op(int op, bignum_type, bignum_type);
117 bignum_type bignum_posneg_bitwise_op(int op, bignum_type, bignum_type);
118 bignum_type bignum_negneg_bitwise_op(int op, bignum_type, bignum_type);
119 void bignum_negate_magnitude(bignum_type);
121 bignum_type bignum_integer_length(bignum_type arg1);
122 int bignum_unsigned_logbitp(int shift, bignum_type bignum);
123 int bignum_logbitp(int shift, bignum_type arg);
124 bignum_type digit_stream_to_bignum(unsigned int n_digits,
125 unsigned int (*producer)(unsigned int),
126 unsigned int radix,
127 int negative_p);