summaryrefslogtreecommitdiffstats
path: root/baseline/source/ammunition/arithm.h
diff options
context:
space:
mode:
Diffstat (limited to 'baseline/source/ammunition/arithm.h')
-rw-r--r--baseline/source/ammunition/arithm.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/baseline/source/ammunition/arithm.h b/baseline/source/ammunition/arithm.h
new file mode 100644
index 0000000..8ed78bf
--- /dev/null
+++ b/baseline/source/ammunition/arithm.h
@@ -0,0 +1,123 @@
1/*
2 FILE NAME: arithm.h
3
4 TITLE: Include file of package for arbitrary precision integer
5 arithmetic
6
7 DESCRIPTION: This header file contains ANSI C prototype definitions of
8 the package functions and definitions of external
9 variable of the package and C++ classes for arbitrary
10 precision integer arithmetic.
11
12*/
13
14
15#ifndef __ARITHMETIC__
16#define __ARITHMETIC__
17
18#include "ammunition_limits.h"
19
20
21/* This page contains definitions of variables and macros common for
22 all package functions. */
23
24/* The value of macro is suggested to be maximum length of integer operands
25 The length of use integers should be not greater than this value. */
26
27#define MAX_INTEGER_OPERAND_SIZE 128
28
29/* The following macro value is sign of integer number (0 or 1) given
30 as macro parameter. */
31
32#define INTEGER_SIGN(operand) (*(unsigned char *) (operand) >> (CHAR_BIT - 1))
33
34extern int ammunition_overflow_bit;
35
36extern void ammunition_add_unsigned_integer ( int size, const void *op1,
37 const void *op2,
38 void *result );
39extern void ammunition_add_integer ( int size, const void *op1, const void *op2,
40 void *result );
41extern void ammunition_subtract_unsigned_integer ( int size, const void *op1,
42 const void *op2, void *result );
43extern void ammunition_subtract_integer ( int size, const void *op1,
44 const void *op2,
45 void *result );
46extern void ammunition_multiply_unsigned_integer ( int size, const void *op1,
47 const void *op2, void *result );
48extern void ammunition_multiply_integer ( int size, const void *op1,
49 const void *op2,
50 void *result );
51extern void ammunition_divide_unsigned_integer ( int size, const void *op1,
52 const void *op2, void *result );
53extern void ammunition_divide_integer ( int size, const void *op1,
54 const void *op2,
55 void *result );
56extern void ammunition_unsigned_integer_remainder ( int size, const void *op1,
57 const void *op2, void *result );
58
59extern void ammunition_unsigned_integer_shift_right ( int size,
60 const void *operand,
61 int bits, void *result );
62extern void ammunition_integer_shift_right ( int size, const void *operand,
63 int bits, void *result );
64extern void ammunition_integer_shift_left ( int size, const void *operand,
65 int bits, void *result );
66extern void ammunition_unsigned_integer_shift_left ( int size,
67 const void *operand,
68 int bits, void *result );
69
70extern void ammunition_integer_or ( int size, const void *op1,
71 const void *op2, void *result );
72extern void ammunition_unsigned_integer_or ( int size, const void *op1,
73 const void *op2, void *result );
74extern void ammunition_integer_and ( int size, const void *op1,
75 const void *op2, void *result );
76extern void ammunition_unsigned_integer_and ( int size, const void *op1,
77 const void *op2, void *result );
78extern void ammunition_integer_not ( int size, const void *operand,
79 void *result );
80extern void ammunition_unsigned_integer_not ( int size, const void *operand,
81 void *result );
82
83extern int ammunition_eq_unsigned_integer ( int size, const void *op1,
84 const void *op2 );
85extern int ammunition_eq_integer ( int size, const void *op1, const void *op2 );
86extern int ammunition_ne_unsigned_integer ( int size, const void *op1,
87 const void *op2 );
88extern int ammunition_ne_integer ( int size, const void *op1, const void *op2 );
89extern int ammunition_gt_unsigned_integer ( int size, const void *op1,
90 const void *op2 );
91extern int ammunition_gt_integer ( int size, const void *op1, const void *op2 );
92extern int ammunition_lt_unsigned_integer ( int size, const void *op1,
93 const void *op2 );
94extern int ammunition_lt_integer ( int size, const void *op1, const void *op2 );
95extern int ammunition_ge_unsigned_integer ( int size, const void *op1,
96 const void *op2 );
97extern int ammunition_ge_integer ( int size, const void *op1, const void *op2 );
98extern int ammunition_le_unsigned_integer ( int size, const void *op1,
99 const void *op2 );
100extern int ammunition_le_integer ( int size, const void *op1, const void *op2 );
101
102extern void ammunition_change_unsigned_integer_size
103( int operand_size, const void *operand, int result_size, void *result );
104extern void ammunition_change_integer_size ( int operand_size,
105 const void *operand,
106 int result_size, void *result );
107
108extern char *ammunition_unsigned_integer_to_string ( int size,
109 const void *operand,
110 char *result );
111extern char *ammunition_integer_to_string ( int size, const void *operand,
112 char *result );
113
114extern char *ammunition_unsigned_integer_from_string ( int size,
115 const char *operand,
116 void *result );
117extern char *ammunition_integer_from_string ( int size, const char *operand,
118 void *result );
119
120char ammunition_isdigit( unsigned char c );
121int ammunition_isspace( int c );
122
123#endif /* #ifndef __ARITHMETIC__ */