Fix POST with streams to use chunked encoding, add http-put word
[factor/jcg.git] / vm / bignumint.h
bloba101473fc64f370849cca35b6c1af74564281ee9
1 /* -*-C-*-
3 $Id: s48_bignumint.h,v 1.14 2005/12/21 02:36:52 spestov Exp $
5 Copyright (c) 1989-1992 Massachusetts Institute of Technology
7 This material was developed by the Scheme project at the Massachusetts
8 Institute of Technology, Department of Electrical Engineering and
9 Computer Science. Permission to copy and modify this software, to
10 redistribute either the original software or a modified version, and
11 to use this software for any purpose is granted, subject to the
12 following restrictions and understandings.
14 1. Any copy made of this software must include this copyright notice
15 in full.
17 2. Users of this software agree to make their best efforts (a) to
18 return to the MIT Scheme project any improvements or extensions that
19 they make, so that these may be included in future releases; and (b)
20 to inform MIT of noteworthy uses of this software.
22 3. All materials developed as a consequence of the use of this
23 software shall duly acknowledge such use, in accordance with the usual
24 standards of acknowledging credit in academic research.
26 4. MIT has made no warrantee or representation that the operation of
27 this software will be error-free, and MIT is under no obligation to
28 provide any services, by way of maintenance, update, or otherwise.
30 5. In conjunction with products arising from the use of this material,
31 there shall be no use of the name of the Massachusetts Institute of
32 Technology nor of any adaptation thereof in any advertising,
33 promotional, or sales literature without prior written consent from
34 MIT in each case. */
36 /* Internal Interface to Bignum Code */
37 #undef BIGNUM_ZERO_P
38 #undef BIGNUM_NEGATIVE_P
40 /* The memory model is based on the following definitions, and on the
41 definition of the type `bignum_type'. The only other special
42 definition is `CHAR_BIT', which is defined in the Ansi C header
43 file "limits.h". */
45 typedef F_FIXNUM bignum_digit_type;
46 typedef F_FIXNUM bignum_length_type;
48 /* BIGNUM_TO_POINTER casts a bignum object to a digit array pointer. */
49 #define BIGNUM_TO_POINTER(bignum) ((bignum_digit_type *)AREF(bignum,0))
51 /* BIGNUM_EXCEPTION is invoked to handle assertion violations. */
52 #define BIGNUM_EXCEPTION abort
55 #define BIGNUM_DIGIT_LENGTH (((sizeof (bignum_digit_type)) * CHAR_BIT) - 2)
56 #define BIGNUM_HALF_DIGIT_LENGTH (BIGNUM_DIGIT_LENGTH / 2)
57 #define BIGNUM_RADIX (((CELL) 1) << BIGNUM_DIGIT_LENGTH)
58 #define BIGNUM_RADIX_ROOT (((CELL) 1) << BIGNUM_HALF_DIGIT_LENGTH)
59 #define BIGNUM_DIGIT_MASK (BIGNUM_RADIX - 1)
60 #define BIGNUM_HALF_DIGIT_MASK (BIGNUM_RADIX_ROOT - 1)
62 #define BIGNUM_START_PTR(bignum) \
63 ((BIGNUM_TO_POINTER (bignum)) + 1)
65 #define BIGNUM_LENGTH(bignum) (untag_fixnum_fast((bignum)->capacity) - 1)
67 #define BIGNUM_NEGATIVE_P(bignum) (array_nth(bignum,0) != 0)
68 #define BIGNUM_SET_NEGATIVE_P(bignum,neg) put(AREF(bignum,0),neg)
70 #define BIGNUM_ZERO_P(bignum) \
71 ((BIGNUM_LENGTH (bignum)) == 0)
73 #define BIGNUM_REF(bignum, index) \
74 (* ((BIGNUM_START_PTR (bignum)) + (index)))
76 /* These definitions are here to facilitate caching of the constants
77 0, 1, and -1. */
78 #define BIGNUM_ZERO() untag_object(bignum_zero)
79 #define BIGNUM_ONE(neg_p) \
80 untag_object(neg_p ? bignum_neg_one : bignum_pos_one)
82 #define HD_LOW(digit) ((digit) & BIGNUM_HALF_DIGIT_MASK)
83 #define HD_HIGH(digit) ((digit) >> BIGNUM_HALF_DIGIT_LENGTH)
84 #define HD_CONS(high, low) (((high) << BIGNUM_HALF_DIGIT_LENGTH) | (low))
86 #define BIGNUM_BITS_TO_DIGITS(n) \
87 (((n) + (BIGNUM_DIGIT_LENGTH - 1)) / BIGNUM_DIGIT_LENGTH)
89 #define BIGNUM_DIGITS_FOR(type) \
90 (BIGNUM_BITS_TO_DIGITS ((sizeof (type)) * CHAR_BIT))
92 #ifndef BIGNUM_DISABLE_ASSERTION_CHECKS
94 #define BIGNUM_ASSERT(expression) \
95 { \
96 if (! (expression)) \
97 BIGNUM_EXCEPTION (); \
100 #endif /* not BIGNUM_DISABLE_ASSERTION_CHECKS */