3 .\" Manual for CRC table generator
5 .\" (c) 2003, 2005, 2007, 2009, 2019, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH crc-mktab 1 "9 November 2003" "Straylight/Edgeware" "mLib utilities library"
33 .\"--------------------------------------------------------------------------
35 crc-mktab \- construct CRC tables for efficient computation
37 .\"--------------------------------------------------------------------------
63 .\"--------------------------------------------------------------------------
68 program constructs tables for efficient computation of CRC (cyclic
69 redundancy check) values. It will produce the table as either an array
70 defined in a C source file or as an initializer macro defined in a C
73 The program accepts no non-option arguments. At least one of
77 must be given. The options are as follows.
80 Print a help message to standard output and exit successfully.
83 Print the program's version number to standard output and exit
87 Print a one-line usage summary to standard output and exit successfully.
90 When producing C source (the
92 option), rather than a header, define the table to be
94 .B "\-c, \-\-c-source"
95 Produce a C source file which exports a symbol naming the array, instead
98 .BI "\-s, \-\-symbol=" symbol
101 This is the name of the macro defined by a header file, or the array
102 exported by a C source. The default macro name is
104 the default array name is
107 .BI "\-t, \-\-type=" type
108 Specify the element type of the array defined by a C source output. The
111 if the polynomial has degree 16 or less, or
113 otherwise. This option does nothing without the
117 .BI "\-i, \-\-include=" header
119 Request that generated C source include the named
124 .BI "#include """ header """"
126 at the top of the generated C source. The default is not to include a
127 header file. This option does nothing without the
132 .BI "\-g, \-\-guard=" macro
136 as a guard against multiple inclusion of the generated header file.
137 Inserts a pair of lines of the form
144 at the top of the generated header, and a line
148 at the end. The default guard macro name is built from the output file
151 by uppercasing all alphabetic characters in the name and replacing
152 nonalphanumeric characters by underscores
154 This option does nothing with the
159 .BI "\-b, \-\-bits=" bits
160 Specifies the degree of the CRC polynomial or, equivalently, the length
161 of the generated CRC. This must be an integer between 1 and 32
162 inclusive. If it is not specified, the polynomial given by
164 is examined and an educated guess made. (Currently we choose the
165 smallest multiple of 8 which is large enough.)
167 .BI "\-B, \-\-bit-chunk=" chunk
168 Chunk size in which bits are taken from the input. The number of
169 entries in the table is precisely
170 .RI 2\*(ss chunk \*(se.
171 The default chunk size is 8.
173 .BI "\-p, \-\-polynomial=" poly
174 Specifies the CRC polynomial as an integer. The polynomial has a
175 nonzero coefficient in its
177 term if and only if bit
181 is nonzero. Note that if you want to specify the polynomial in
182 hexadecimal, you must prefix it with
184 Default polynomials of degree 16 and 32 are known.
186 .B "\-r, \-\-reverse"
187 Construct the table to compensate for unusual bit-ordering. Without
188 this option, you'd have to reverse the order of all input chunks and the
190 .SS "The table and how to use it"
191 Describing in detail the contents of the table would take too long. For
192 an example of use, see the header file
195 .\"--------------------------------------------------------------------------
200 .I A painless guide to CRC error detection algorithms
203 .\"--------------------------------------------------------------------------
206 Mark Wooding, <mdw@distorted.org.uk>
208 .\"----- That's all, folks --------------------------------------------------