mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
New option for position-independent code.
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
|||||||
|
2002-12-10 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
* src/options.h (SHAREDLIB): New enum value.
|
||||||
|
* src/options.cc (Options::short_usage): Mention option -P.
|
||||||
|
(Options::long_usage): Document option -P.
|
||||||
|
(long_options): Add option --pic.
|
||||||
|
(Options::parse_options): Handle option -P/--pic.
|
||||||
|
* src/output.cc (output_keyword_blank_entries): When SHAREDLIB is
|
||||||
|
specified, emit NULL pointers instead of "".
|
||||||
|
(Output::output_lookup_function_body): When SHAREDLIB is specified
|
||||||
|
and SWITCH and DUP and not specified, test the table entry against
|
||||||
|
NULL before the string comparison.
|
||||||
|
* tests/test-6.exp: Update.
|
||||||
|
* doc/gperf.texi (Output Details): Document option -P.
|
||||||
|
* NEWS: Update.
|
||||||
|
Suggested by Ulrich Drepper.
|
||||||
|
|
||||||
2002-12-08 Bruno Haible <bruno@clisp.org>
|
2002-12-08 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
* tests/permut2.gperf, tests/permut2.exp: New files.
|
* tests/permut2.gperf, tests/permut2.exp: New files.
|
||||||
|
|||||||
4
NEWS
4
NEWS
@@ -1,4 +1,4 @@
|
|||||||
New in 2.96:
|
New in 2.97:
|
||||||
|
|
||||||
* Added option --output that allows to specify the output file name.
|
* Added option --output that allows to specify the output file name.
|
||||||
* Some options have been renamed:
|
* Some options have been renamed:
|
||||||
@@ -40,6 +40,8 @@ New in 2.96:
|
|||||||
the table's size will grow as needed. Earlier versions of gperf bailed
|
the table's size will grow as needed. Earlier versions of gperf bailed
|
||||||
out with an "Internal error, duplicate hash code value".
|
out with an "Internal error, duplicate hash code value".
|
||||||
* The options -f/--fast and -o/--occurrence-sort have no effect any more.
|
* The options -f/--fast and -o/--occurrence-sort have no effect any more.
|
||||||
|
* Added option -P/--pic that optimizes the generated code for use in shared
|
||||||
|
libraries.
|
||||||
* Bug fixes.
|
* Bug fixes.
|
||||||
|
|
||||||
New in 2.7.2:
|
New in 2.7.2:
|
||||||
|
|||||||
@@ -931,6 +931,13 @@ Generate the static table of keywords as a static global variable,
|
|||||||
rather than hiding it inside of the lookup function (which is the
|
rather than hiding it inside of the lookup function (which is the
|
||||||
default behavior).
|
default behavior).
|
||||||
|
|
||||||
|
@item -P
|
||||||
|
@itemx --pic
|
||||||
|
Optimize the generated table for inclusion in shared libraries. This
|
||||||
|
reduces the startup time of programs using a shared library containing
|
||||||
|
the generated code, at the expense of one more test-and-branch instruction
|
||||||
|
at run time.
|
||||||
|
|
||||||
@item -W @var{hash-table-array-name}
|
@item -W @var{hash-table-array-name}
|
||||||
@itemx --word-array-name=@var{hash-table-array-name}
|
@itemx --word-array-name=@var{hash-table-array-name}
|
||||||
@cindex Array name
|
@cindex Array name
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static const char *const DEFAULT_DELIMITERS = ",";
|
|||||||
void
|
void
|
||||||
Options::short_usage (FILE * stream) const
|
Options::short_usage (FILE * stream) const
|
||||||
{
|
{
|
||||||
fprintf (stream, "Usage: %s [-cCdDef[num]F<initializers>GhH<hashname>i<init>Ij<jump>k<keys>K<keyname>lL<language>m<num>nN<function name>ors<size>S<switches>tTvW<wordlistname>Z<class name>7] [input-file]\n"
|
fprintf (stream, "Usage: %s [-cCdDef[num]F<initializers>GhH<hashname>i<init>Ij<jump>k<keys>K<keyname>lL<language>m<num>nN<function name>oPrs<size>S<switches>tTvW<wordlistname>Z<class name>7] [input-file]\n"
|
||||||
"Try '%s --help' for more information.\n",
|
"Try '%s --help' for more information.\n",
|
||||||
program_name, program_name);
|
program_name, program_name);
|
||||||
}
|
}
|
||||||
@@ -158,6 +158,10 @@ Options::long_usage (FILE * stream) const
|
|||||||
" -G, --global-table Generate the static table of keywords as a static\n"
|
" -G, --global-table Generate the static table of keywords as a static\n"
|
||||||
" global variable, rather than hiding it inside of the\n"
|
" global variable, rather than hiding it inside of the\n"
|
||||||
" lookup function (which is the default behavior).\n");
|
" lookup function (which is the default behavior).\n");
|
||||||
|
fprintf (stream,
|
||||||
|
" -P, --pic Optimize the generated table for inclusion in shared\n"
|
||||||
|
" libraries. This reduces the startup time of programs\n"
|
||||||
|
" using a shared library containing the generated code.\n");
|
||||||
fprintf (stream,
|
fprintf (stream,
|
||||||
" -W, --word-array-name=NAME\n"
|
" -W, --word-array-name=NAME\n"
|
||||||
" Specify name of word list array. Default name is\n"
|
" Specify name of word list array. Default name is\n"
|
||||||
@@ -631,6 +635,7 @@ static const struct option long_options[] =
|
|||||||
{ "no-strlen", no_argument, NULL, 'n' },
|
{ "no-strlen", no_argument, NULL, 'n' },
|
||||||
{ "occurrence-sort", no_argument, NULL, 'o' },
|
{ "occurrence-sort", no_argument, NULL, 'o' },
|
||||||
{ "optimized-collision-resolution", no_argument, NULL, 'O' },
|
{ "optimized-collision-resolution", no_argument, NULL, 'O' },
|
||||||
|
{ "pic", no_argument, NULL, 'P' },
|
||||||
{ "random", no_argument, NULL, 'r' },
|
{ "random", no_argument, NULL, 'r' },
|
||||||
{ "size-multiple", required_argument, NULL, 's' },
|
{ "size-multiple", required_argument, NULL, 's' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
@@ -650,7 +655,7 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
|
|
||||||
while ((option_char =
|
while ((option_char =
|
||||||
getopt_long (_argument_count, _argument_vector,
|
getopt_long (_argument_count, _argument_vector,
|
||||||
"acCdDe:Ef:F:gGhH:i:Ij:k:K:lL:m:nN:oOprs:S:tTvW:Z:7",
|
"acCdDe:Ef:F:gGhH:i:Ij:k:K:lL:m:nN:oOpPrs:S:tTvW:Z:7",
|
||||||
long_options, NULL))
|
long_options, NULL))
|
||||||
!= -1)
|
!= -1)
|
||||||
{
|
{
|
||||||
@@ -838,6 +843,11 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
break; /* Not needed any more. */
|
break; /* Not needed any more. */
|
||||||
case 'p': /* Generated lookup function a pointer instead of int. */
|
case 'p': /* Generated lookup function a pointer instead of int. */
|
||||||
break; /* This is now the default. */
|
break; /* This is now the default. */
|
||||||
|
case 'P': /* Optimize for position-independent code. */
|
||||||
|
{
|
||||||
|
_option_word |= SHAREDLIB;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'r': /* Utilize randomness to initialize the associated values table. */
|
case 'r': /* Utilize randomness to initialize the associated values table. */
|
||||||
{
|
{
|
||||||
_option_word |= RANDOM;
|
_option_word |= RANDOM;
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ enum Option_Type
|
|||||||
INCLUDE = 1 << 18,
|
INCLUDE = 1 << 18,
|
||||||
|
|
||||||
/* Assume 7-bit, not 8-bit, characters. */
|
/* Assume 7-bit, not 8-bit, characters. */
|
||||||
SEVENBIT = 1 << 19
|
SEVENBIT = 1 << 19,
|
||||||
|
|
||||||
|
/* Optimize for position-independent code. */
|
||||||
|
SHAREDLIB = 1 << 20
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Class manager for gperf program Options. */
|
/* Class manager for gperf program Options. */
|
||||||
|
|||||||
@@ -726,13 +726,14 @@ output_keyword_blank_entries (int count, const char *indent)
|
|||||||
int columns;
|
int columns;
|
||||||
if (option[TYPE])
|
if (option[TYPE])
|
||||||
{
|
{
|
||||||
columns = 58 / (6 + strlen (option.get_initializer_suffix()));
|
columns = 58 / (4 + (option[SHAREDLIB] ? 8 : 2)
|
||||||
|
+ strlen (option.get_initializer_suffix()));
|
||||||
if (columns == 0)
|
if (columns == 0)
|
||||||
columns = 1;
|
columns = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
columns = 9;
|
columns = (option[SHAREDLIB] ? 4 : 9);
|
||||||
}
|
}
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
@@ -749,9 +750,13 @@ output_keyword_blank_entries (int count, const char *indent)
|
|||||||
printf (", ");
|
printf (", ");
|
||||||
}
|
}
|
||||||
if (option[TYPE])
|
if (option[TYPE])
|
||||||
printf ("{\"\"%s}", option.get_initializer_suffix());
|
printf ("{");
|
||||||
|
if (option[SHAREDLIB])
|
||||||
|
printf ("(char*)0");
|
||||||
else
|
else
|
||||||
printf ("\"\"");
|
printf ("\"\"");
|
||||||
|
if (option[TYPE])
|
||||||
|
printf ("%s}", option.get_initializer_suffix());
|
||||||
column++;
|
column++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1362,6 +1367,8 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
printf (";\n\n"
|
printf (";\n\n"
|
||||||
"%*s if (",
|
"%*s if (",
|
||||||
indent, "");
|
indent, "");
|
||||||
|
if (option[SHAREDLIB])
|
||||||
|
printf ("s && ");
|
||||||
comparison.output_comparison (Output_Expr1 ("str"), Output_Expr1 ("s"));
|
comparison.output_comparison (Output_Expr1 ("str"), Output_Expr1 ("s"));
|
||||||
printf (")\n"
|
printf (")\n"
|
||||||
"%*s return ",
|
"%*s return ",
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ Details in the output code:
|
|||||||
-G, --global-table Generate the static table of keywords as a static
|
-G, --global-table Generate the static table of keywords as a static
|
||||||
global variable, rather than hiding it inside of the
|
global variable, rather than hiding it inside of the
|
||||||
lookup function (which is the default behavior).
|
lookup function (which is the default behavior).
|
||||||
|
-P, --pic Optimize the generated table for inclusion in shared
|
||||||
|
libraries. This reduces the startup time of programs
|
||||||
|
using a shared library containing the generated code.
|
||||||
-W, --word-array-name=NAME
|
-W, --word-array-name=NAME
|
||||||
Specify name of word list array. Default name is
|
Specify name of word list array. Default name is
|
||||||
'wordlist'.
|
'wordlist'.
|
||||||
|
|||||||
Reference in New Issue
Block a user