3 * Sequential bit scan of multiprecision integers
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Header files ------------------------------------------------------*/
32 /*----- Right-to-left scanning --------------------------------------------*/
34 /* --- @mpscan_initx@ --- *
36 * Arguments: @mpscan *m@ = pointer to bitscanner structure
37 * @const mpw *v, *vl@ = vector of words to scan
41 * Use: Initializes a bitscanner from a low-level vector-and-length
42 * representation of an integer. Initially no bit is ready; you
43 * must call @mpscan_step@ before anything useful will come
47 void mpscan_initx(mpscan *m, const mpw *v, const mpw *vl)
49 MPSCAN_INITX(m, v, vl);
52 /* --- @mpscan_step@ --- *
54 * Arguments: @mpscan *m@ = pointer to bitscanner
56 * Returns: Nonzero if there is another bit to read.
58 * Use: Steps on to the next bit in the integer. The macro version
59 * evaluates its argument multiple times.
62 int mpscan_step(mpscan *m) { return (MPSCAN_STEP(m)); }
64 /* --- @mpscan_bit@ --- *
66 * Arguments: @const mpscan *m@ = pointer to bitscanner
68 * Returns: The value of the current bit.
70 * Use: Reads the value of the current bit looked at by a
74 int mpscan_bit(const mpscan *m) { return (MPSCAN_BIT(m)); }
76 /*----- Left-to right-scanning --------------------------------------------*/
78 /* --- @mpscan_rinitx@ --- *
80 * Arguments: @mpscan *m@ = pointer to bitscanner structure
81 * @const mpw *v, *vl@ = vector of words to scan
85 * Use: Initializes a reverse bitscanner from a low-level
86 * vector-and-length representation of an integer. Initially no
87 * bit is ready; you must call @mpscan_rstep@ before anything
88 * useful will come out.
91 void mpscan_rinitx(mpscan *m, const mpw *v, const mpw *vl)
93 MPSCAN_RINITX(m, v, vl);
96 /* --- @mpscan_rstep@ --- *
98 * Arguments: @mpscan *m@ = pointer to bitscanner
100 * Returns: Nonzero if there is another bit to read.
102 * Use: Steps on to the next bit in the integer. The macro version
103 * evaluates its argument multiple times.
106 int mpscan_rstep(mpscan *m) { return (MPSCAN_RSTEP(m)); }
108 /* --- @mpscan_rbit@ --- *
110 * Arguments: @const mpscan *m@ = pointer to bitscanner
112 * Returns: The value of the current bit.
114 * Use: Reads the value of the current bit looked at by a
115 * reverse bitscanner.
118 int mpscan_rbit(const mpscan *m) { return (MPSCAN_RBIT(m)); }
120 /*----- That's all, folks -------------------------------------------------*/