Add `-C' option to produce `const' tables.
I'd probably like this to be the default, at least for `crc-mktab', but
currently it isn't for (a) compatibility and (b) consistency between the
two.
crc-mktab \- construct CRC tables for efficient computation
.SH SYNOPSIS
.B crc-mktab
crc-mktab \- construct CRC tables for efficient computation
.SH SYNOPSIS
.B crc-mktab
.RB [ \-s
.IR symbol ]
.RB [ \-t
.RB [ \-s
.IR symbol ]
.RB [ \-t
.B "\-u, \-\-usage"
Print a one-line usage summary to standard output and exit successfully.
.TP
.B "\-u, \-\-usage"
Print a one-line usage summary to standard output and exit successfully.
.TP
+.B "\-C, \-\-const"
+When producing C source (the
+.B \-c
+option), rather than a header, define the table to be
+.BR const .
.B "\-c, \-\-c-source"
Produce a C source file which exports a symbol naming the array, instead
of a C header file.
.B "\-c, \-\-c-source"
Produce a C source file which exports a symbol naming the array, instead
of a C header file.
#define f_bogus 1u
#define f_ctab 2u
#define f_reverse 4u
#define f_bogus 1u
#define f_ctab 2u
#define f_reverse 4u
static void usage(FILE *fp)
{
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-cr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
+ pquis(fp, "Usage: $ [-Ccr] [-o FILE] [-g GUARD] [-s SYM] [-i HEADER]\n\
[-t TYPE] [-b BITS] [-B BITS] [-p POLY]\n");
}
[-t TYPE] [-b BITS] [-B BITS] [-p POLY]\n");
}
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\n\
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\n\
+-C, --const Declare table to be `const' (only useful with `-c').\n\
-b, --bits=BITS Emit a table for a BITS bits-wide CRC.\n\
-B, --bit-chunk=BITS Emit a table to process BITS bits at a time.\n\
-p, --polynomial=POLY Use the POLY as the dividing polynomial.\n\
-b, --bits=BITS Emit a table for a BITS bits-wide CRC.\n\
-B, --bit-chunk=BITS Emit a table to process BITS bits at a time.\n\
-p, --polynomial=POLY Use the POLY as the dividing polynomial.\n\
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
+ { "const", 0, 0, 'C' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "type", OPTF_ARGREQ, 0, 't' },
{ "include", OPTF_ARGREQ, 0, 'i' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "type", OPTF_ARGREQ, 0, 't' },
{ "include", OPTF_ARGREQ, 0, 'i' },
- int i = mdwopt(argc, argv, "hvu o:cs:t:i:g: b:B:p:r", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hvu o:cCs:t:i:g: b:B:p:r", opts, 0, 0, 0);
case 'c':
flags |= f_ctab;
break;
case 'c':
flags |= f_ctab;
break;
+ case 'C':
+ flags |= f_const;
+ break;
case 's':
sym = optarg;
break;
case 's':
sym = optarg;
break;
if (flags & f_ctab) {
if (inc)
fprintf(fp, "#include \"%s\"\n\n", inc);
if (flags & f_ctab) {
if (inc)
fprintf(fp, "#include \"%s\"\n\n", inc);
- fprintf(fp, "%s %s[] = {\n", type, sym);
+ fprintf(fp, "%s%s %s[] = {\n",
+ (flags&f_const) ? "const " : "", type, sym);
} else {
int n;
if (guard)
} else {
int n;
if (guard)
unihash-mkstatic \- construct tables for universal hashing
.SH SYNOPSIS
.B unihash-mkstatic
unihash-mkstatic \- construct tables for universal hashing
.SH SYNOPSIS
.B unihash-mkstatic
.RB [ \-s
.IR symbol ]
.RB [ \-i
.RB [ \-s
.IR symbol ]
.RB [ \-i
.B "\-u, \-\-usage"
Print a one-line usage summary to standard output and exit successfully.
.TP
.B "\-u, \-\-usage"
Print a one-line usage summary to standard output and exit successfully.
.TP
+.B "\-C, \-\-const"
+When producing C source (the
+.B \-c
+option), rather than a header, define the table to be
+.BR const .
+.TP
.B "\-c, \-\-c-source"
Produce a C source file which exports a symbol naming the array, instead
of a C header file.
.B "\-c, \-\-c-source"
Produce a C source file which exports a symbol naming the array, instead
of a C header file.
static void usage(FILE *fp)
{
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-c] [-o FILE] [-g GUARD] [-i HEADER] [-s SYM]\n\
+ pquis(fp, "Usage: $ [-Cc] [-o FILE] [-g GUARD] [-i HEADER] [-s SYM]\n\
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\n\
-u, --usage Show a terse usage message.\n\
\n\
-c, --c-source Emit a C source file rather than a header.\n\
+-C, --const Declare table to be `const' (only useful with `-c').\n\
-k, --key=KEY Use KEY as the universal hashing key.\n\
-g, --guard=GUARD Use GUARD as a multiple-inclusion guard constant.\n\
-i, --include=HEADER Include HEADER at top of C source file.\n\
-k, --key=KEY Use KEY as the universal hashing key.\n\
-g, --guard=GUARD Use GUARD as a multiple-inclusion guard constant.\n\
-i, --include=HEADER Include HEADER at top of C source file.\n\
#define f_bogus 1u
#define f_ctab 2u
#define f_bogus 1u
#define f_ctab 2u
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
{ "output", OPTF_ARGREQ, 0, 'o' },
{ "c-source", 0, 0, 'c' },
+ { "const", 0, 0, 'C' },
{ "key", OPTF_ARGREQ, 0, 'k' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "include", OPTF_ARGREQ, 0, 'i' },
{ "key", OPTF_ARGREQ, 0, 'k' },
{ "symbol", OPTF_ARGREQ, 0, 's' },
{ "include", OPTF_ARGREQ, 0, 'i' },
- int i = mdwopt(argc, argv, "hvu o:ck:s:i:g:", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hvu o:cCk:s:i:g:", opts, 0, 0, 0);
case 'c':
flags |= f_ctab;
break;
case 'c':
flags |= f_ctab;
break;
+ case 'C':
+ flags |= f_const;
+ break;
case 's':
sym = optarg;
break;
case 's':
sym = optarg;
break;
fprintf(fp, "#include \"%s\"\n\n", inc);
else
fputs("#include <mLib/unihash.h>\n\n", fp);
fprintf(fp, "#include \"%s\"\n\n", inc);
else
fputs("#include <mLib/unihash.h>\n\n", fp);
- fprintf(fp, "unihash_info %s = { {\n", sym);
+ fprintf(fp, "%sunihash_info %s = { {\n",
+ (flags&f_const) ? "const " : "", sym);
} else {
int n;
if (guard)
} else {
int n;
if (guard)