4f3f36ac |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: mpw.h,v 1.1 1999/11/13 01:52:34 mdw Exp $ |
4 | * |
5 | * Very low-level multiprecision definitions |
6 | * |
7 | * (c) 1999 Straylight/Edgeware |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of Catacomb. |
13 | * |
14 | * Catacomb is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU Library General Public License as |
16 | * published by the Free Software Foundation; either version 2 of the |
17 | * License, or (at your option) any later version. |
18 | * |
19 | * Catacomb is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU Library General Public License for more details. |
23 | * |
24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with Catacomb; if not, write to the Free |
26 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
27 | * MA 02111-1307, USA. |
28 | */ |
29 | |
30 | /*----- Revision history --------------------------------------------------* |
31 | * |
32 | * $Log: mpw.h,v $ |
33 | * Revision 1.1 1999/11/13 01:52:34 mdw |
34 | * Very low-level definitions for MP types. |
35 | * |
36 | * Revision 1.1 1999/11/13 01:50:17 mdw |
37 | * Veyr low level definitions for MP types. |
38 | * |
39 | */ |
40 | |
41 | #ifndef MPW_H |
42 | #define MPW_H |
43 | |
44 | #ifdef __cplusplus |
45 | extern "C" { |
46 | #endif |
47 | |
48 | /*----- Header files ------------------------------------------------------*/ |
49 | |
50 | #ifndef BITS_H |
51 | # include <mLib/bits.h> |
52 | #endif |
53 | |
54 | #ifndef MPTYPES_H |
55 | # include "mptypes.h" |
56 | #endif |
57 | |
58 | /*----- Useful macros -----------------------------------------------------*/ |
59 | |
60 | /* --- @MPW@ --- * |
61 | * |
62 | * Arguments: @x@ = an unsigned value |
63 | * |
64 | * Use: Expands to the value of @x@ masked and typecast to a |
65 | * multiprecision integer word. |
66 | */ |
67 | |
68 | #define MPW(x) ((mpw)((x) & MPW_MAX)) |
69 | |
70 | /* --- @MPWS@ --- * |
71 | * |
72 | * Arguments: @n@ = number of words |
73 | * |
74 | * Use: Expands to the number of bytes occupied by a given number of |
75 | * words. |
76 | */ |
77 | |
78 | #define MPWS(n) ((n) * sizeof(mpw)) |
79 | |
80 | /* --- @MPW_RQ@ --- * |
81 | * |
82 | * Arguments: @sz@ = size of an octet array, in octets |
83 | * |
84 | * Use: Expands to the number of @mpw@ words required to represent |
85 | * the number held in the octet array. |
86 | */ |
87 | |
88 | #define MPW_RQ(sz) (((sz) * 8 + MPW_BITS - 1) / MPW_BITS) |
89 | |
90 | /*----- That's all, folks -------------------------------------------------*/ |
91 | |
92 | #ifdef __cplusplus |
93 | } |
94 | #endif |
95 | |
96 | #endif |