Commit 589005ff by Kazu Hirata Committed by Kazu Hirata

gbl-ctors.h: Fix formatting.

	* gbl-ctors.h: Fix formatting.
	* gcc.c: Likewise.
	* gccspec.c: Likewise.
	* gcov.c: Likewise.
	* gcov-io.h: Likewise.
	* gcse.c: Likewise.
	* ggc-common.c: Likewise.
	* ggc.h: Likewise.
	* ggc-page.c: Likewise.
	* ggc-simple.c: Likewise.
	* global.c: Likewise.
	* graph.h: Likewise.
	* gthr-dce.h: Likewise.
	* gthr.h: Likewise.
	* gthr-posix.h: Likewise.
	* gthr-rtems.h: Likewise.
	* gthr-solaris.h: Likewise.
	* gthr-win32.h: Likewise.

From-SVN: r54240
parent 94213cff
2002-06-04 Kazu Hirata <kazu@cs.umass.edu>
* gbl-ctors.h: Fix formatting.
* gcc.c: Likewise.
* gccspec.c: Likewise.
* gcov.c: Likewise.
* gcov-io.h: Likewise.
* gcse.c: Likewise.
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* ggc-page.c: Likewise.
* ggc-simple.c: Likewise.
* global.c: Likewise.
* graph.h: Likewise.
* gthr-dce.h: Likewise.
* gthr.h: Likewise.
* gthr-posix.h: Likewise.
* gthr-rtems.h: Likewise.
* gthr-solaris.h: Likewise.
* gthr-win32.h: Likewise.
2002-06-03 Geoffrey Keating <geoffk@redhat.com> 2002-06-03 Geoffrey Keating <geoffk@redhat.com>
Merge from pch-branch: Merge from pch-branch:
...@@ -1206,7 +1227,7 @@ Mon Jun 3 11:53:01 CEST 2002 Jan Hubicka <jh@suse.cz> ...@@ -1206,7 +1227,7 @@ Mon Jun 3 11:53:01 CEST 2002 Jan Hubicka <jh@suse.cz>
2002-06-02 Kazu Hirata <kazu@cs.umass.edu> 2002-06-02 Kazu Hirata <kazu@cs.umass.edu>
* emit-rtl.c: Likewise. * emit-rtl.c: Fix formatting.
* errors.h: Likewise. * errors.h: Likewise.
* except.c: Likewise. * except.c: Likewise.
* explow.c: Likewise. * explow.c: Likewise.
......
...@@ -78,6 +78,6 @@ do { \ ...@@ -78,6 +78,6 @@ do { \
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \ for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
for (i = nptrs; i >= 1; i--) \ for (i = nptrs; i >= 1; i--) \
__CTOR_LIST__[i] (); \ __CTOR_LIST__[i] (); \
} while (0) } while (0)
#endif #endif
...@@ -242,7 +242,7 @@ static const struct modify_target ...@@ -242,7 +242,7 @@ static const struct modify_target
} }
modify_target[] = MODIFY_TARGET_NAME; modify_target[] = MODIFY_TARGET_NAME;
#endif #endif
/* The number of errors that have occurred; the link phase will not be /* The number of errors that have occurred; the link phase will not be
run if this is non-zero. */ run if this is non-zero. */
static int error_count = 0; static int error_count = 0;
...@@ -1522,12 +1522,12 @@ init_spec () ...@@ -1522,12 +1522,12 @@ init_spec ()
{ {
const char *p = libgcc_spec; const char *p = libgcc_spec;
int in_sep = 1; int in_sep = 1;
/* Transform the extant libgcc_spec into one that uses the shared libgcc /* Transform the extant libgcc_spec into one that uses the shared libgcc
when given the proper command line arguments. */ when given the proper command line arguments. */
while (*p) while (*p)
{ {
if (in_sep && *p == '-' && strncmp (p, "-lgcc", 5) == 0) if (in_sep && *p == '-' && strncmp (p, "-lgcc", 5) == 0)
{ {
init_gcc_specs (&obstack, init_gcc_specs (&obstack,
#ifdef NO_SHARED_LIBGCC_MULTILIB #ifdef NO_SHARED_LIBGCC_MULTILIB
...@@ -2758,8 +2758,8 @@ execute () ...@@ -2758,8 +2758,8 @@ execute ()
{ {
const char *const *j; const char *const *j;
if (verbose_only_flag) if (verbose_only_flag)
{ {
for (j = commands[i].argv; *j; j++) for (j = commands[i].argv; *j; j++)
{ {
const char *p; const char *p;
...@@ -2772,8 +2772,8 @@ execute () ...@@ -2772,8 +2772,8 @@ execute ()
} }
fputc ('"', stderr); fputc ('"', stderr);
} }
} }
else else
for (j = commands[i].argv; *j; j++) for (j = commands[i].argv; *j; j++)
fprintf (stderr, " %s", *j); fprintf (stderr, " %s", *j);
...@@ -2784,7 +2784,7 @@ execute () ...@@ -2784,7 +2784,7 @@ execute ()
} }
fflush (stderr); fflush (stderr);
if (verbose_only_flag != 0) if (verbose_only_flag != 0)
return 0; return 0;
#ifdef DEBUG #ifdef DEBUG
notice ("\nGo ahead? (y or n) "); notice ("\nGo ahead? (y or n) ");
fflush (stderr); fflush (stderr);
...@@ -3384,20 +3384,20 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -3384,20 +3384,20 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
add_linker_option ("--help", 6); add_linker_option ("--help", 6);
} }
else if (strcmp (argv[i], "-ftarget-help") == 0) else if (strcmp (argv[i], "-ftarget-help") == 0)
{ {
/* translate_options() has turned --target-help into -ftarget-help. */ /* translate_options() has turned --target-help into -ftarget-help. */
target_help_flag = 1; target_help_flag = 1;
/* We will be passing a dummy file on to the sub-processes. */ /* We will be passing a dummy file on to the sub-processes. */
n_infiles++; n_infiles++;
n_switches++; n_switches++;
/* CPP driver cannot obtain switch from cc1_options. */ /* CPP driver cannot obtain switch from cc1_options. */
if (is_cpp_driver) if (is_cpp_driver)
add_preprocessor_option ("--target-help", 13); add_preprocessor_option ("--target-help", 13);
add_assembler_option ("--target-help", 13); add_assembler_option ("--target-help", 13);
add_linker_option ("--target-help", 13); add_linker_option ("--target-help", 13);
} }
else if (! strcmp (argv[i], "-pass-exit-codes")) else if (! strcmp (argv[i], "-pass-exit-codes"))
{ {
pass_exit_codes = 1; pass_exit_codes = 1;
...@@ -3572,7 +3572,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -3572,7 +3572,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
tmp[++ len] = 0; tmp[++ len] = 0;
value = tmp; value = tmp;
} }
/* As a kludge, if the arg is "[foo/]stageN/", just /* As a kludge, if the arg is "[foo/]stageN/", just
add "[foo/]include" to the include prefix. */ add "[foo/]include" to the include prefix. */
if ((len == 7 if ((len == 7
...@@ -3703,7 +3703,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -3703,7 +3703,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
if (is_modify_target_name) if (is_modify_target_name)
break; break;
#endif #endif
n_switches++; n_switches++;
...@@ -3893,7 +3893,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -3893,7 +3893,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
/* -save-temps overrides -pipe, so that temp files are produced */ /* -save-temps overrides -pipe, so that temp files are produced */
if (save_temps_flag) if (save_temps_flag)
error ("warning: -pipe ignored because -save-temps specified"); error ("warning: -pipe ignored because -save-temps specified");
/* -time overrides -pipe because we can't get correct stats when /* -time overrides -pipe because we can't get correct stats when
multiple children are running at once. */ multiple children are running at once. */
else if (report_times) else if (report_times)
error ("warning: -pipe ignored because -time specified"); error ("warning: -pipe ignored because -time specified");
...@@ -4509,7 +4509,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4509,7 +4509,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
} }
suffix_length += strlen (TARGET_OBJECT_SUFFIX); suffix_length += strlen (TARGET_OBJECT_SUFFIX);
} }
/* If the input_filename has the same suffix specified /* If the input_filename has the same suffix specified
for the %g, %u, or %U, and -save-temps is specified, for the %g, %u, or %U, and -save-temps is specified,
we could end up using that file as an intermediate we could end up using that file as an intermediate
...@@ -4517,7 +4517,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4517,7 +4517,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
gcc -save-temps foo.s would clobber foo.s with the gcc -save-temps foo.s would clobber foo.s with the
output of cpp0). So check for this condition and output of cpp0). So check for this condition and
generate a temp file as the intermediate. */ generate a temp file as the intermediate. */
if (save_temps_flag) if (save_temps_flag)
{ {
temp_filename_length = basename_length + suffix_length; temp_filename_length = basename_length + suffix_length;
...@@ -4529,7 +4529,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4529,7 +4529,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
if (strcmp (temp_filename, input_filename) != 0) if (strcmp (temp_filename, input_filename) != 0)
{ {
struct stat st_temp; struct stat st_temp;
/* Note, set_input() resets input_stat_set to 0. */ /* Note, set_input() resets input_stat_set to 0. */
if (input_stat_set == 0) if (input_stat_set == 0)
{ {
...@@ -4537,17 +4537,17 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4537,17 +4537,17 @@ do_spec_1 (spec, inswitch, soft_matched_part)
if (input_stat_set >= 0) if (input_stat_set >= 0)
input_stat_set = 1; input_stat_set = 1;
} }
/* If we have the stat for the input_filename /* If we have the stat for the input_filename
and we can do the stat for the temp_filename and we can do the stat for the temp_filename
then the they could still refer to the same then the they could still refer to the same
file if st_dev/st_ino's are the same. */ file if st_dev/st_ino's are the same. */
if (input_stat_set != 1 if (input_stat_set != 1
|| stat (temp_filename, &st_temp) < 0 || stat (temp_filename, &st_temp) < 0
|| input_stat.st_dev != st_temp.st_dev || input_stat.st_dev != st_temp.st_dev
|| input_stat.st_ino != st_temp.st_ino) || input_stat.st_ino != st_temp.st_ino)
{ {
temp_filename = save_string (temp_filename, temp_filename = save_string (temp_filename,
temp_filename_length + 1); temp_filename_length + 1);
obstack_grow (&obstack, temp_filename, obstack_grow (&obstack, temp_filename,
...@@ -4755,8 +4755,8 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4755,8 +4755,8 @@ do_spec_1 (spec, inswitch, soft_matched_part)
case 'C': case 'C':
{ {
const char *const spec const char *const spec
= (input_file_compiler->cpp_spec = (input_file_compiler->cpp_spec
? input_file_compiler->cpp_spec ? input_file_compiler->cpp_spec
: cpp_spec); : cpp_spec);
value = do_spec_1 (spec, 0, NULL); value = do_spec_1 (spec, 0, NULL);
if (value != 0) if (value != 0)
...@@ -4984,17 +4984,17 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4984,17 +4984,17 @@ do_spec_1 (spec, inswitch, soft_matched_part)
obstack_1grow (&obstack, '%'); obstack_1grow (&obstack, '%');
break; break;
case '.': case '.':
{ {
unsigned len = 0; unsigned len = 0;
while (p[len] && p[len] != ' ' && p[len] != '%') while (p[len] && p[len] != ' ' && p[len] != '%')
len++; len++;
suffix_subst = save_string (p - 1, len + 1); suffix_subst = save_string (p - 1, len + 1);
p += len; p += len;
} }
break; break;
case '*': case '*':
if (soft_matched_part) if (soft_matched_part)
{ {
...@@ -5693,7 +5693,7 @@ set_input (filename) ...@@ -5693,7 +5693,7 @@ set_input (filename)
} }
else else
input_suffix = ""; input_suffix = "";
/* If a spec for 'g', 'u', or 'U' is seen with -save-temps then /* If a spec for 'g', 'u', or 'U' is seen with -save-temps then
we will need to do a stat on the input_filename. The we will need to do a stat on the input_filename. The
INPUT_STAT_SET signals that the stat is needed. */ INPUT_STAT_SET signals that the stat is needed. */
...@@ -6095,7 +6095,7 @@ main (argc, argv) ...@@ -6095,7 +6095,7 @@ main (argc, argv)
input_file_compiler input_file_compiler
= lookup_compiler (infiles[i].name, input_filename_length, = lookup_compiler (infiles[i].name, input_filename_length,
infiles[i].language); infiles[i].language);
if (input_file_compiler) if (input_file_compiler)
{ {
/* Ok, we found an applicable compiler. Run its spec. */ /* Ok, we found an applicable compiler. Run its spec. */
...@@ -6234,7 +6234,7 @@ lookup_compiler (name, length, language) ...@@ -6234,7 +6234,7 @@ lookup_compiler (name, length, language)
&& !strcmp (cp->suffix, && !strcmp (cp->suffix,
name + length - strlen (cp->suffix)) name + length - strlen (cp->suffix))
)) ))
break; break;
} }
#if defined (OS2) ||defined (HAVE_DOS_BASED_FILE_SYSTEM) #if defined (OS2) ||defined (HAVE_DOS_BASED_FILE_SYSTEM)
......
...@@ -57,7 +57,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) ...@@ -57,7 +57,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
} }
else else
{ {
int len; int len;
/* If the filename ends in .m or .mi, we are compiling ObjC /* If the filename ends in .m or .mi, we are compiling ObjC
and want to pass -shared-libgcc. */ and want to pass -shared-libgcc. */
......
...@@ -74,7 +74,7 @@ __store_gcov_type (value, dest, bytes) ...@@ -74,7 +74,7 @@ __store_gcov_type (value, dest, bytes)
if (value && value != -1) if (value && value != -1)
return 1; return 1;
for(; i < bytes ; i++) for(; i < bytes ; i++)
dest[i] = 0; dest[i] = 0;
dest[bytes - 1] |= upper_bit; dest[bytes - 1] |= upper_bit;
return 0; return 0;
......
...@@ -687,7 +687,7 @@ create_program_flow_graph (bptr) ...@@ -687,7 +687,7 @@ create_program_flow_graph (bptr)
__read_long (&function_name_len, bbg_file, 4); __read_long (&function_name_len, bbg_file, 4);
function_name = xmalloc (function_name_len + 1); function_name = xmalloc (function_name_len + 1);
fread (function_name, 1, function_name_len + 1, bbg_file); fread (function_name, 1, function_name_len + 1, bbg_file);
/* Skip padding. */ /* Skip padding. */
tmp = (function_name_len + 1) % 4; tmp = (function_name_len + 1) % 4;
...@@ -695,7 +695,7 @@ create_program_flow_graph (bptr) ...@@ -695,7 +695,7 @@ create_program_flow_graph (bptr)
fseek (bbg_file, 4 - tmp, SEEK_CUR); fseek (bbg_file, 4 - tmp, SEEK_CUR);
__read_long (&tmp, bbg_file, 4); /* ignore -1. */ __read_long (&tmp, bbg_file, 4); /* ignore -1. */
/* Read the cfg checksum. */ /* Read the cfg checksum. */
__read_long (&cfg_checksum, bbg_file, 4); __read_long (&cfg_checksum, bbg_file, 4);
...@@ -729,7 +729,7 @@ create_program_flow_graph (bptr) ...@@ -729,7 +729,7 @@ create_program_flow_graph (bptr)
__read_long (&flag_bits, bbg_file, 4); __read_long (&flag_bits, bbg_file, 4);
if (flag_bits & 0x1) if (flag_bits & 0x1)
arcptr->on_tree++; arcptr->on_tree++;
else else
instr_arcs++; instr_arcs++;
arcptr->fake = !! (flag_bits & 0x2); arcptr->fake = !! (flag_bits & 0x2);
arcptr->fall_through = !! (flag_bits & 0x4); arcptr->fall_through = !! (flag_bits & 0x4);
...@@ -1063,9 +1063,9 @@ calculate_branch_probs (current_graph, block_num, branch_probs, last_line_num) ...@@ -1063,9 +1063,9 @@ calculate_branch_probs (current_graph, block_num, branch_probs, last_line_num)
a_ptr = (struct arcdata *) xmalloc (sizeof (struct arcdata)); a_ptr = (struct arcdata *) xmalloc (sizeof (struct arcdata));
a_ptr->total = total; a_ptr->total = total;
if (total == 0) if (total == 0)
a_ptr->hits = 0; a_ptr->hits = 0;
else else
a_ptr->hits = arcptr->arc_count; a_ptr->hits = arcptr->arc_count;
a_ptr->call_insn = arcptr->fake; a_ptr->call_insn = arcptr->fake;
if (output_function_summary) if (output_function_summary)
...@@ -1565,8 +1565,8 @@ output_data () ...@@ -1565,8 +1565,8 @@ output_data ()
((a_ptr->hits * 100) ((a_ptr->hits * 100)
+ (a_ptr->total >> 1)) + (a_ptr->total >> 1))
/ a_ptr->total); / a_ptr->total);
fnotice (gcov_file, fnotice (gcov_file,
"branch %d taken = %s%%\n", i, c); "branch %d taken = %s%%\n", i, c);
} }
} }
} }
......
...@@ -53,7 +53,7 @@ struct ggc_root ...@@ -53,7 +53,7 @@ struct ggc_root
static struct ggc_root *roots; static struct ggc_root *roots;
/* Add BASE as a new garbage collection root. It is an array of /* Add BASE as a new garbage collection root. It is an array of
length NELT with each element SIZE bytes long. CB is a length NELT with each element SIZE bytes long. CB is a
function that will be called with a pointer to each element function that will be called with a pointer to each element
of the array; it is the intention that CB call the appropriate of the array; it is the intention that CB call the appropriate
routine to mark gc-able memory for that element. */ routine to mark gc-able memory for that element. */
...@@ -103,7 +103,7 @@ ggc_mark_roots () ...@@ -103,7 +103,7 @@ ggc_mark_roots ()
const struct ggc_cache_tab *const *ct; const struct ggc_cache_tab *const *ct;
const struct ggc_cache_tab *cti; const struct ggc_cache_tab *cti;
size_t i; size_t i;
for (rt = gt_ggc_deletable_rtab; *rt; rt++) for (rt = gt_ggc_deletable_rtab; *rt; rt++)
for (rti = *rt; rti->base != NULL; rti++) for (rti = *rt; rti->base != NULL; rti++)
memset (rti->base, 0, rti->stride); memset (rti->base, 0, rti->stride);
...@@ -179,7 +179,7 @@ ggc_mark_rtx_children_1 (r) ...@@ -179,7 +179,7 @@ ggc_mark_rtx_children_1 (r)
int i; int i;
rtx next_rtx; rtx next_rtx;
do do
{ {
enum rtx_code code = GET_CODE (r); enum rtx_code code = GET_CODE (r);
/* This gets set to a child rtx to eliminate tail recursion. */ /* This gets set to a child rtx to eliminate tail recursion. */
...@@ -244,12 +244,12 @@ ggc_mark_rtx_children_1 (r) ...@@ -244,12 +244,12 @@ ggc_mark_rtx_children_1 (r)
case 'e': case 'u': case 'e': case 'u':
exp = XEXP (r, i); exp = XEXP (r, i);
if (ggc_test_and_set_mark (exp)) if (ggc_test_and_set_mark (exp))
{ {
if (next_rtx == NULL) if (next_rtx == NULL)
next_rtx = exp; next_rtx = exp;
else else
ggc_mark_rtx_children (exp); ggc_mark_rtx_children (exp);
} }
break; break;
case 'V': case 'E': case 'V': case 'E':
gt_ggc_m_rtvec_def (XVEC (r, i)); gt_ggc_m_rtvec_def (XVEC (r, i));
...@@ -342,17 +342,17 @@ ggc_print_common_statistics (stream, stats) ...@@ -342,17 +342,17 @@ ggc_print_common_statistics (stream, stats)
} }
/* Print the statistics for trees. */ /* Print the statistics for trees. */
fprintf (stream, "\n%-17s%10s %16s %10s\n", "Tree", fprintf (stream, "\n%-17s%10s %16s %10s\n", "Tree",
"Number", "Bytes", "% Total"); "Number", "Bytes", "% Total");
for (code = 0; code < MAX_TREE_CODES; ++code) for (code = 0; code < MAX_TREE_CODES; ++code)
if (ggc_stats->num_trees[code]) if (ggc_stats->num_trees[code])
{ {
fprintf (stream, "%-17s%10u%16ld%c %10.3f\n", fprintf (stream, "%-17s%10u%16ld%c %10.3f\n",
tree_code_name[code], tree_code_name[code],
ggc_stats->num_trees[code], ggc_stats->num_trees[code],
SCALE (ggc_stats->size_trees[code]), SCALE (ggc_stats->size_trees[code]),
LABEL (ggc_stats->size_trees[code]), LABEL (ggc_stats->size_trees[code]),
(100 * ((double) ggc_stats->size_trees[code]) (100 * ((double) ggc_stats->size_trees[code])
/ ggc_stats->total_size_trees)); / ggc_stats->total_size_trees));
} }
fprintf (stream, fprintf (stream,
...@@ -362,17 +362,17 @@ ggc_print_common_statistics (stream, stats) ...@@ -362,17 +362,17 @@ ggc_print_common_statistics (stream, stats)
LABEL (ggc_stats->total_size_trees)); LABEL (ggc_stats->total_size_trees));
/* Print the statistics for RTL. */ /* Print the statistics for RTL. */
fprintf (stream, "\n%-17s%10s %16s %10s\n", "RTX", fprintf (stream, "\n%-17s%10s %16s %10s\n", "RTX",
"Number", "Bytes", "% Total"); "Number", "Bytes", "% Total");
for (code = 0; code < NUM_RTX_CODE; ++code) for (code = 0; code < NUM_RTX_CODE; ++code)
if (ggc_stats->num_rtxs[code]) if (ggc_stats->num_rtxs[code])
{ {
fprintf (stream, "%-17s%10u%16ld%c %10.3f\n", fprintf (stream, "%-17s%10u%16ld%c %10.3f\n",
rtx_name[code], rtx_name[code],
ggc_stats->num_rtxs[code], ggc_stats->num_rtxs[code],
SCALE (ggc_stats->size_rtxs[code]), SCALE (ggc_stats->size_rtxs[code]),
LABEL (ggc_stats->size_rtxs[code]), LABEL (ggc_stats->size_rtxs[code]),
(100 * ((double) ggc_stats->size_rtxs[code]) (100 * ((double) ggc_stats->size_rtxs[code])
/ ggc_stats->total_size_rtxs)); / ggc_stats->total_size_rtxs));
} }
fprintf (stream, fprintf (stream,
......
...@@ -59,7 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -59,7 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define USING_MALLOC_PAGE_GROUPS #define USING_MALLOC_PAGE_GROUPS
#endif #endif
/* Stategy: /* Stategy:
This garbage-collecting allocator allocates objects on one of a set This garbage-collecting allocator allocates objects on one of a set
of pages. Each page can allocate objects of a single size only; of pages. Each page can allocate objects of a single size only;
...@@ -74,7 +74,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -74,7 +74,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
Each page-entry also has a context depth, which is used to track Each page-entry also has a context depth, which is used to track
pushing and popping of allocation contexts. Only objects allocated pushing and popping of allocation contexts. Only objects allocated
in the current (highest-numbered) context may be collected. in the current (highest-numbered) context may be collected.
Page entries are arranged in an array of singly-linked lists. The Page entries are arranged in an array of singly-linked lists. The
array is indexed by the allocation size, in bits, of the pages on array is indexed by the allocation size, in bits, of the pages on
...@@ -133,7 +133,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -133,7 +133,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
The bottommost HOST_PAGE_SIZE_BITS are ignored, since page-entry The bottommost HOST_PAGE_SIZE_BITS are ignored, since page-entry
pages are aligned on system page boundaries. The next most pages are aligned on system page boundaries. The next most
significant PAGE_L2_BITS and PAGE_L1_BITS are the second and first significant PAGE_L2_BITS and PAGE_L1_BITS are the second and first
index values in the lookup table, respectively. index values in the lookup table, respectively.
For 32-bit architectures and the settings below, there are no For 32-bit architectures and the settings below, there are no
leftover bits. For architectures with wider pointers, the lookup leftover bits. For architectures with wider pointers, the lookup
...@@ -206,7 +206,7 @@ static size_t object_size_table[NUM_ORDERS]; ...@@ -206,7 +206,7 @@ static size_t object_size_table[NUM_ORDERS];
/* A page_entry records the status of an allocation page. This /* A page_entry records the status of an allocation page. This
structure is dynamically sized to fit the bitmap in_use_p. */ structure is dynamically sized to fit the bitmap in_use_p. */
typedef struct page_entry typedef struct page_entry
{ {
/* The next page-entry with objects of the same size, or NULL if /* The next page-entry with objects of the same size, or NULL if
this is the last page-entry. */ this is the last page-entry. */
...@@ -411,7 +411,7 @@ ggc_allocated_p (p) ...@@ -411,7 +411,7 @@ ggc_allocated_p (p)
return base[L1] && base[L1][L2]; return base[L1] && base[L1][L2];
} }
/* Traverse the page table and find the entry for a page. /* Traverse the page table and find the entry for a page.
Die (probably) if the object wasn't allocated via GC. */ Die (probably) if the object wasn't allocated via GC. */
static inline page_entry * static inline page_entry *
...@@ -731,7 +731,7 @@ alloc_page (order) ...@@ -731,7 +731,7 @@ alloc_page (order)
set_page_table_entry (page, entry); set_page_table_entry (page, entry);
if (GGC_DEBUG_LEVEL >= 2) if (GGC_DEBUG_LEVEL >= 2)
fprintf (G.debug_file, fprintf (G.debug_file,
"Allocating page at %p, object size=%lu, data %p-%p\n", "Allocating page at %p, object size=%lu, data %p-%p\n",
(PTR) entry, (unsigned long) OBJECT_SIZE (order), page, (PTR) entry, (unsigned long) OBJECT_SIZE (order), page,
page + entry_size - 1); page + entry_size - 1);
...@@ -746,7 +746,7 @@ free_page (entry) ...@@ -746,7 +746,7 @@ free_page (entry)
page_entry *entry; page_entry *entry;
{ {
if (GGC_DEBUG_LEVEL >= 2) if (GGC_DEBUG_LEVEL >= 2)
fprintf (G.debug_file, fprintf (G.debug_file,
"Deallocating page at %p, data %p-%p\n", (PTR) entry, "Deallocating page at %p, data %p-%p\n", (PTR) entry,
entry->page, entry->page + entry->bytes - 1); entry->page, entry->page + entry->bytes - 1);
...@@ -816,7 +816,7 @@ release_pages () ...@@ -816,7 +816,7 @@ release_pages ()
if (g->in_use == 0) if (g->in_use == 0)
{ {
*gp = g->next; *gp = g->next;
G.bytes_mapped -= g->alloc_size; G.bytes_mapped -= g->alloc_size;
free (g->allocation); free (g->allocation);
} }
else else
...@@ -827,16 +827,16 @@ release_pages () ...@@ -827,16 +827,16 @@ release_pages ()
/* This table provides a fast way to determine ceil(log_2(size)) for /* This table provides a fast way to determine ceil(log_2(size)) for
allocation requests. The minimum allocation size is eight bytes. */ allocation requests. The minimum allocation size is eight bytes. */
static unsigned char size_lookup[257] = static unsigned char size_lookup[257] =
{ {
3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
...@@ -878,11 +878,11 @@ ggc_alloc (size) ...@@ -878,11 +878,11 @@ ggc_alloc (size)
{ {
struct page_entry *new_entry; struct page_entry *new_entry;
new_entry = alloc_page (order); new_entry = alloc_page (order);
/* If this is the only entry, it's also the tail. */ /* If this is the only entry, it's also the tail. */
if (entry == NULL) if (entry == NULL)
G.page_tails[order] = new_entry; G.page_tails[order] = new_entry;
/* Put new pages at the head of the page list. */ /* Put new pages at the head of the page list. */
new_entry->next = entry; new_entry->next = entry;
entry = new_entry; entry = new_entry;
...@@ -904,7 +904,7 @@ ggc_alloc (size) ...@@ -904,7 +904,7 @@ ggc_alloc (size)
unsigned hint = entry->next_bit_hint; unsigned hint = entry->next_bit_hint;
word = hint / HOST_BITS_PER_LONG; word = hint / HOST_BITS_PER_LONG;
bit = hint % HOST_BITS_PER_LONG; bit = hint % HOST_BITS_PER_LONG;
/* If the hint didn't work, scan the bitmap from the beginning. */ /* If the hint didn't work, scan the bitmap from the beginning. */
if ((entry->in_use_p[word] >> bit) & 1) if ((entry->in_use_p[word] >> bit) & 1)
{ {
...@@ -953,7 +953,7 @@ ggc_alloc (size) ...@@ -953,7 +953,7 @@ ggc_alloc (size)
G.allocated += OBJECT_SIZE (order); G.allocated += OBJECT_SIZE (order);
if (GGC_DEBUG_LEVEL >= 3) if (GGC_DEBUG_LEVEL >= 3)
fprintf (G.debug_file, fprintf (G.debug_file,
"Allocating object, requested size=%lu, actual=%lu at %p on %p\n", "Allocating object, requested size=%lu, actual=%lu at %p on %p\n",
(unsigned long) size, (unsigned long) OBJECT_SIZE (order), result, (unsigned long) size, (unsigned long) OBJECT_SIZE (order), result,
(PTR) entry); (PTR) entry);
...@@ -986,7 +986,7 @@ ggc_set_mark (p) ...@@ -986,7 +986,7 @@ ggc_set_mark (p)
bit = (((const char *) p) - entry->page) / OBJECT_SIZE (entry->order); bit = (((const char *) p) - entry->page) / OBJECT_SIZE (entry->order);
word = bit / HOST_BITS_PER_LONG; word = bit / HOST_BITS_PER_LONG;
mask = (unsigned long) 1 << (bit % HOST_BITS_PER_LONG); mask = (unsigned long) 1 << (bit % HOST_BITS_PER_LONG);
/* If the bit was previously set, skip it. */ /* If the bit was previously set, skip it. */
if (entry->in_use_p[word] & mask) if (entry->in_use_p[word] & mask)
return 1; return 1;
...@@ -1001,7 +1001,7 @@ ggc_set_mark (p) ...@@ -1001,7 +1001,7 @@ ggc_set_mark (p)
return 0; return 0;
} }
/* Return 1 if P has been marked, zero otherwise. /* Return 1 if P has been marked, zero otherwise.
P must have been allocated by the GC allocator; it mustn't point to P must have been allocated by the GC allocator; it mustn't point to
static objects, stack variables, or memory allocated with malloc. */ static objects, stack variables, or memory allocated with malloc. */
...@@ -1026,7 +1026,7 @@ ggc_marked_p (p) ...@@ -1026,7 +1026,7 @@ ggc_marked_p (p)
bit = (((const char *) p) - entry->page) / OBJECT_SIZE (entry->order); bit = (((const char *) p) - entry->page) / OBJECT_SIZE (entry->order);
word = bit / HOST_BITS_PER_LONG; word = bit / HOST_BITS_PER_LONG;
mask = (unsigned long) 1 << (bit % HOST_BITS_PER_LONG); mask = (unsigned long) 1 << (bit % HOST_BITS_PER_LONG);
return (entry->in_use_p[word] & mask) != 0; return (entry->in_use_p[word] & mask) != 0;
} }
...@@ -1150,7 +1150,7 @@ ggc_recalculate_in_use_p (p) ...@@ -1150,7 +1150,7 @@ ggc_recalculate_in_use_p (p)
unsigned int i; unsigned int i;
size_t num_objects; size_t num_objects;
/* Because the past-the-end bit in in_use_p is always set, we /* Because the past-the-end bit in in_use_p is always set, we
pretend there is one additional object. */ pretend there is one additional object. */
num_objects = OBJECTS_PER_PAGE (p->order) + 1; num_objects = OBJECTS_PER_PAGE (p->order) + 1;
...@@ -1158,7 +1158,7 @@ ggc_recalculate_in_use_p (p) ...@@ -1158,7 +1158,7 @@ ggc_recalculate_in_use_p (p)
p->num_free_objects = num_objects; p->num_free_objects = num_objects;
/* Combine the IN_USE_P and SAVE_IN_USE_P arrays. */ /* Combine the IN_USE_P and SAVE_IN_USE_P arrays. */
for (i = 0; for (i = 0;
i < CEIL (BITMAP_SIZE (num_objects), i < CEIL (BITMAP_SIZE (num_objects),
sizeof (*p->in_use_p)); sizeof (*p->in_use_p));
++i) ++i)
...@@ -1178,7 +1178,7 @@ ggc_recalculate_in_use_p (p) ...@@ -1178,7 +1178,7 @@ ggc_recalculate_in_use_p (p)
abort (); abort ();
} }
/* Decrement the `GC context'. All objects allocated since the /* Decrement the `GC context'. All objects allocated since the
previous ggc_push_context are migrated to the outer context. */ previous ggc_push_context are migrated to the outer context. */
void void
...@@ -1249,7 +1249,7 @@ clear_marks () ...@@ -1249,7 +1249,7 @@ clear_marks ()
memset (p->in_use_p, 0, bitmap_size); memset (p->in_use_p, 0, bitmap_size);
/* Make sure the one-past-the-end bit is always set. */ /* Make sure the one-past-the-end bit is always set. */
p->in_use_p[num_objects / HOST_BITS_PER_LONG] p->in_use_p[num_objects / HOST_BITS_PER_LONG]
= ((unsigned long) 1 << (num_objects % HOST_BITS_PER_LONG)); = ((unsigned long) 1 << (num_objects % HOST_BITS_PER_LONG));
} }
} }
...@@ -1273,7 +1273,7 @@ sweep_pages () ...@@ -1273,7 +1273,7 @@ sweep_pages ()
size_t live_objects; size_t live_objects;
page_entry *p, *previous; page_entry *p, *previous;
int done; int done;
p = G.pages[order]; p = G.pages[order];
if (p == NULL) if (p == NULL)
continue; continue;
...@@ -1351,7 +1351,7 @@ sweep_pages () ...@@ -1351,7 +1351,7 @@ sweep_pages ()
previous = p; previous = p;
p = next; p = next;
} }
while (! done); while (! done);
/* Now, restore the in_use_p vectors for any pages from contexts /* Now, restore the in_use_p vectors for any pages from contexts
...@@ -1421,13 +1421,13 @@ ggc_collect () ...@@ -1421,13 +1421,13 @@ ggc_collect ()
sweep phase. */ sweep phase. */
G.allocated = 0; G.allocated = 0;
/* Release the pages we freed the last time we collected, but didn't /* Release the pages we freed the last time we collected, but didn't
reuse in the interim. */ reuse in the interim. */
release_pages (); release_pages ();
clear_marks (); clear_marks ();
ggc_mark_roots (); ggc_mark_roots ();
#ifdef GGC_POISON #ifdef GGC_POISON
poison_pages (); poison_pages ();
#endif #endif
...@@ -1461,7 +1461,7 @@ ggc_print_statistics () ...@@ -1461,7 +1461,7 @@ ggc_print_statistics ()
/* Clear the statistics. */ /* Clear the statistics. */
memset (&stats, 0, sizeof (stats)); memset (&stats, 0, sizeof (stats));
/* Make sure collection will really occur. */ /* Make sure collection will really occur. */
G.allocated_last_gc = 0; G.allocated_last_gc = 0;
...@@ -1472,7 +1472,7 @@ ggc_print_statistics () ...@@ -1472,7 +1472,7 @@ ggc_print_statistics ()
there as part of the total allocated memory. */ there as part of the total allocated memory. */
release_pages (); release_pages ();
/* Collect some information about the various sizes of /* Collect some information about the various sizes of
allocation. */ allocation. */
fprintf (stderr, "\n%-5s %10s %10s %10s\n", fprintf (stderr, "\n%-5s %10s %10s %10s\n",
"Size", "Allocated", "Used", "Overhead"); "Size", "Allocated", "Used", "Overhead");
...@@ -1495,7 +1495,7 @@ ggc_print_statistics () ...@@ -1495,7 +1495,7 @@ ggc_print_statistics ()
for (p = G.pages[i]; p; p = p->next) for (p = G.pages[i]; p; p = p->next)
{ {
allocated += p->bytes; allocated += p->bytes;
in_use += in_use +=
(OBJECTS_PER_PAGE (i) - p->num_free_objects) * OBJECT_SIZE (i); (OBJECTS_PER_PAGE (i) - p->num_free_objects) * OBJECT_SIZE (i);
overhead += (sizeof (page_entry) - sizeof (long) overhead += (sizeof (page_entry) - sizeof (long)
......
...@@ -251,7 +251,7 @@ size_t ...@@ -251,7 +251,7 @@ size_t
ggc_get_size (p) ggc_get_size (p)
const void *p; const void *p;
{ {
struct ggc_mem *x struct ggc_mem *x
= (struct ggc_mem *) ((const char *)p - offsetof (struct ggc_mem, u)); = (struct ggc_mem *) ((const char *)p - offsetof (struct ggc_mem, u));
return x->size; return x->size;
} }
...@@ -360,7 +360,7 @@ ggc_collect () ...@@ -360,7 +360,7 @@ ggc_collect ()
/* Called once to initialize the garbage collector. */ /* Called once to initialize the garbage collector. */
void void
init_ggc () init_ggc ()
{ {
G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED; G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
...@@ -383,7 +383,7 @@ ggc_push_context () ...@@ -383,7 +383,7 @@ ggc_push_context ()
/* Finish a GC context. Any uncollected memory in the new context /* Finish a GC context. Any uncollected memory in the new context
will be merged with the old context. */ will be merged with the old context. */
void void
ggc_pop_context () ggc_pop_context ()
{ {
G.context--; G.context--;
...@@ -425,7 +425,7 @@ debug_ggc_tree (p, indent) ...@@ -425,7 +425,7 @@ debug_ggc_tree (p, indent)
for (i = 0; i < indent; ++i) for (i = 0; i < indent; ++i)
putc (' ', stderr); putc (' ', stderr);
fprintf (stderr, "%lx %p\n", (unsigned long)PTR_KEY (p), p); fprintf (stderr, "%lx %p\n", (unsigned long)PTR_KEY (p), p);
if (p->sub[1]) if (p->sub[1])
debug_ggc_tree (p->sub[1], indent + 1); debug_ggc_tree (p->sub[1], indent + 1);
} }
...@@ -490,7 +490,7 @@ ggc_print_statistics () ...@@ -490,7 +490,7 @@ ggc_print_statistics ()
/* Clear the statistics. */ /* Clear the statistics. */
memset (&stats, 0, sizeof (stats)); memset (&stats, 0, sizeof (stats));
/* Make sure collection will really occur. */ /* Make sure collection will really occur. */
G.allocated_last_gc = 0; G.allocated_last_gc = 0;
......
...@@ -33,7 +33,7 @@ extern const char digit_vector[]; /* "0" .. "9" */ ...@@ -33,7 +33,7 @@ extern const char digit_vector[]; /* "0" .. "9" */
extern void ggc_add_root PARAMS ((void *base, int nelt, extern void ggc_add_root PARAMS ((void *base, int nelt,
int size, void (*)(void *))); int size, void (*)(void *)));
/* Structures for the easy way to mark roots. /* Structures for the easy way to mark roots.
In an array, terminated by having base == NULL.*/ In an array, terminated by having base == NULL.*/
struct ggc_root_tab { struct ggc_root_tab {
void *base; void *base;
...@@ -142,7 +142,7 @@ extern void ggc_collect PARAMS ((void)); ...@@ -142,7 +142,7 @@ extern void ggc_collect PARAMS ((void));
pointers in this data structure should not be traversed. */ pointers in this data structure should not be traversed. */
extern int ggc_set_mark PARAMS ((const void *)); extern int ggc_set_mark PARAMS ((const void *));
/* Return 1 if P has been marked, zero otherwise. /* Return 1 if P has been marked, zero otherwise.
P must have been allocated by the GC allocator; it mustn't point to P must have been allocated by the GC allocator; it mustn't point to
static objects, stack variables, or memory allocated with malloc. */ static objects, stack variables, or memory allocated with malloc. */
extern int ggc_marked_p PARAMS ((const void *)); extern int ggc_marked_p PARAMS ((const void *));
...@@ -151,16 +151,16 @@ extern int ggc_marked_p PARAMS ((const void *)); ...@@ -151,16 +151,16 @@ extern int ggc_marked_p PARAMS ((const void *));
/* This structure contains the statistics common to all collectors. /* This structure contains the statistics common to all collectors.
Particular collectors can extend this structure. */ Particular collectors can extend this structure. */
typedef struct ggc_statistics typedef struct ggc_statistics
{ {
/* The Ith element is the number of nodes allocated with code I. */ /* The Ith element is the number of nodes allocated with code I. */
unsigned num_trees[256]; unsigned num_trees[256];
/* The Ith element is the number of bytes allocated by nodes with /* The Ith element is the number of bytes allocated by nodes with
code I. */ code I. */
size_t size_trees[256]; size_t size_trees[256];
/* The Ith element is the number of nodes allocated with code I. */ /* The Ith element is the number of nodes allocated with code I. */
unsigned num_rtxs[256]; unsigned num_rtxs[256];
/* The Ith element is the number of bytes allocated by nodes with /* The Ith element is the number of bytes allocated by nodes with
code I. */ code I. */
size_t size_rtxs[256]; size_t size_rtxs[256];
/* The total size of the tree nodes allocated. */ /* The total size of the tree nodes allocated. */
......
...@@ -52,7 +52,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -52,7 +52,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1. Assign allocation-numbers (allocnos) to the pseudo-registers 1. Assign allocation-numbers (allocnos) to the pseudo-registers
still needing allocations and to the pseudo-registers currently still needing allocations and to the pseudo-registers currently
allocated by local-alloc which may be spilled by reload. allocated by local-alloc which may be spilled by reload.
Set up tables reg_allocno and allocno_reg to map Set up tables reg_allocno and allocno_reg to map
reg numbers to allocnos and vice versa. reg numbers to allocnos and vice versa.
max_allocno gets the number of allocnos in use. max_allocno gets the number of allocnos in use.
...@@ -483,7 +483,7 @@ global_alloc (file) ...@@ -483,7 +483,7 @@ global_alloc (file)
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (regs_ever_live[i]) if (regs_ever_live[i])
local_reg_n_refs[i] = 0, local_reg_freq[i] = 0; local_reg_n_refs[i] = 0, local_reg_freq[i] = 0;
allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS; allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS;
/* We used to use alloca here, but the size of what it would try to /* We used to use alloca here, but the size of what it would try to
...@@ -549,7 +549,7 @@ global_alloc (file) ...@@ -549,7 +549,7 @@ global_alloc (file)
} }
qsort (allocno_order, max_allocno, sizeof (int), allocno_compare); qsort (allocno_order, max_allocno, sizeof (int), allocno_compare);
prune_preferences (); prune_preferences ();
if (file) if (file)
...@@ -884,18 +884,18 @@ expand_preferences () ...@@ -884,18 +884,18 @@ expand_preferences ()
/* Prune the preferences for global registers to exclude registers that cannot /* Prune the preferences for global registers to exclude registers that cannot
be used. be used.
Compute `regs_someone_prefers', which is a bitmask of the hard registers Compute `regs_someone_prefers', which is a bitmask of the hard registers
that are preferred by conflicting registers of lower priority. If possible, that are preferred by conflicting registers of lower priority. If possible,
we will avoid using these registers. */ we will avoid using these registers. */
static void static void
prune_preferences () prune_preferences ()
{ {
int i; int i;
int num; int num;
int *allocno_to_order = (int *) xmalloc (max_allocno * sizeof (int)); int *allocno_to_order = (int *) xmalloc (max_allocno * sizeof (int));
/* Scan least most important to most important. /* Scan least most important to most important.
For each allocno, remove from preferences registers that cannot be used, For each allocno, remove from preferences registers that cannot be used,
either because of conflicts or register type. Then compute all registers either because of conflicts or register type. Then compute all registers
...@@ -1028,7 +1028,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) ...@@ -1028,7 +1028,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
COPY_HARD_REG_SET (used, used1); COPY_HARD_REG_SET (used, used1);
IOR_COMPL_HARD_REG_SET (used, regs_used_so_far); IOR_COMPL_HARD_REG_SET (used, regs_used_so_far);
IOR_HARD_REG_SET (used, allocno[num].regs_someone_prefers); IOR_HARD_REG_SET (used, allocno[num].regs_someone_prefers);
best_reg = -1; best_reg = -1;
for (i = FIRST_PSEUDO_REGISTER, pass = 0; for (i = FIRST_PSEUDO_REGISTER, pass = 0;
pass <= 1 && i >= FIRST_PSEUDO_REGISTER; pass <= 1 && i >= FIRST_PSEUDO_REGISTER;
...@@ -1073,7 +1073,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) ...@@ -1073,7 +1073,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
Remove from the preferred registers and conflicting registers. Note that Remove from the preferred registers and conflicting registers. Note that
additional conflicts may have been added after `prune_preferences' was additional conflicts may have been added after `prune_preferences' was
called. called.
First do this for those register with copy preferences, then all First do this for those register with copy preferences, then all
preferred registers. */ preferred registers. */
...@@ -1156,7 +1156,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) ...@@ -1156,7 +1156,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
} }
no_prefs: no_prefs:
/* If we haven't succeeded yet, try with caller-saves. /* If we haven't succeeded yet, try with caller-saves.
We need not check to see if the current function has nonlocal We need not check to see if the current function has nonlocal
labels because we don't put any pseudos that are live over calls in labels because we don't put any pseudos that are live over calls in
registers in that case. */ registers in that case. */
...@@ -1176,7 +1176,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) ...@@ -1176,7 +1176,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
CLEAR_HARD_REG_SET (new_losers); CLEAR_HARD_REG_SET (new_losers);
else else
COPY_HARD_REG_SET (new_losers, losers); COPY_HARD_REG_SET (new_losers, losers);
IOR_HARD_REG_SET(new_losers, losing_caller_save_reg_set); IOR_HARD_REG_SET(new_losers, losing_caller_save_reg_set);
find_reg (num, new_losers, alt_regs_p, 1, retrying); find_reg (num, new_losers, alt_regs_p, 1, retrying);
if (reg_renumber[allocno[num].reg] >= 0) if (reg_renumber[allocno[num].reg] >= 0)
...@@ -1223,7 +1223,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) ...@@ -1223,7 +1223,7 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
/* We explicitly evaluate the divide results into temporary /* We explicitly evaluate the divide results into temporary
variables so as to avoid excess precision problems that occur variables so as to avoid excess precision problems that occur
on an i386-unknown-sysv4.2 (unixware) host. */ on an i386-unknown-sysv4.2 (unixware) host. */
double tmp1 = ((double) local_reg_freq[regno] double tmp1 = ((double) local_reg_freq[regno]
/ local_reg_live_length[regno]); / local_reg_live_length[regno]);
double tmp2 = ((double) allocno[num].freq double tmp2 = ((double) allocno[num].freq
...@@ -1593,7 +1593,7 @@ mark_reg_live_nc (regno, mode) ...@@ -1593,7 +1593,7 @@ mark_reg_live_nc (regno, mode)
that SRC is a register. If SRC or the first operand of SRC is a register, that SRC is a register. If SRC or the first operand of SRC is a register,
try to set a preference. If one of the two is a hard register and the other try to set a preference. If one of the two is a hard register and the other
is a pseudo-register, mark the preference. is a pseudo-register, mark the preference.
Note that we are not as aggressive as local-alloc in trying to tie a Note that we are not as aggressive as local-alloc in trying to tie a
pseudo-register to a hard register. */ pseudo-register to a hard register. */
...@@ -1713,7 +1713,7 @@ mark_elimination (from, to) ...@@ -1713,7 +1713,7 @@ mark_elimination (from, to)
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {
regset r = bb->global_live_at_start; regset r = bb->global_live_at_start;
if (REGNO_REG_SET_P (r, from)) if (REGNO_REG_SET_P (r, from))
{ {
CLEAR_REGNO_REG_SET (r, from); CLEAR_REGNO_REG_SET (r, from);
...@@ -1741,7 +1741,7 @@ reg_becomes_live (reg, setter, regs_set) ...@@ -1741,7 +1741,7 @@ reg_becomes_live (reg, setter, regs_set)
if (GET_CODE (reg) != REG) if (GET_CODE (reg) != REG)
return; return;
regno = REGNO (reg); regno = REGNO (reg);
if (regno < FIRST_PSEUDO_REGISTER) if (regno < FIRST_PSEUDO_REGISTER)
{ {
...@@ -1818,7 +1818,7 @@ build_insn_chain (first) ...@@ -1818,7 +1818,7 @@ build_insn_chain (first)
: reg_renumber[i] >= 0) : reg_renumber[i] >= 0)
SET_REGNO_REG_SET (live_relevant_regs, i); SET_REGNO_REG_SET (live_relevant_regs, i);
}); });
} }
if (GET_CODE (first) != NOTE && GET_CODE (first) != BARRIER) if (GET_CODE (first) != NOTE && GET_CODE (first) != BARRIER)
{ {
...@@ -1906,7 +1906,7 @@ dump_conflicts (file) ...@@ -1906,7 +1906,7 @@ dump_conflicts (file)
for (i = 0; i < max_allocno; i++) for (i = 0; i < max_allocno; i++)
{ {
if (reg_renumber[allocno[allocno_order[i]].reg] >= 0) if (reg_renumber[allocno[allocno_order[i]].reg] >= 0)
continue; continue;
nregs++; nregs++;
} }
fprintf (file, ";; %d regs to allocate:", nregs); fprintf (file, ";; %d regs to allocate:", nregs);
...@@ -1958,13 +1958,13 @@ dump_global_regs (file) ...@@ -1958,13 +1958,13 @@ dump_global_regs (file)
FILE *file; FILE *file;
{ {
int i, j; int i, j;
fprintf (file, ";; Register dispositions:\n"); fprintf (file, ";; Register dispositions:\n");
for (i = FIRST_PSEUDO_REGISTER, j = 0; i < max_regno; i++) for (i = FIRST_PSEUDO_REGISTER, j = 0; i < max_regno; i++)
if (reg_renumber[i] >= 0) if (reg_renumber[i] >= 0)
{ {
fprintf (file, "%d in %d ", i, reg_renumber[i]); fprintf (file, "%d in %d ", i, reg_renumber[i]);
if (++j % 6 == 0) if (++j % 6 == 0)
fprintf (file, "\n"); fprintf (file, "\n");
} }
......
/* Header file for graph routines. /* Header file for graph routines.
Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
......
...@@ -146,9 +146,9 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg) ...@@ -146,9 +146,9 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
if (!__gthread_active_p ()) if (!__gthread_active_p ())
return NULL; return NULL;
if ( !(pthread_create(&new_thread_handle, pthread_attr_default, if ( !(pthread_create(&new_thread_handle, pthread_attr_default,
(void *)func, arg)) ) (void *)func, arg)) )
{ {
/* ??? May not work! (64bit) */ /* ??? May not work! (64bit) */
thread_id = *(objc_thread_t *)&new_thread_handle; thread_id = *(objc_thread_t *)&new_thread_handle;
...@@ -156,7 +156,7 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg) ...@@ -156,7 +156,7 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
} }
else else
thread_id = NULL; thread_id = NULL;
return thread_id; return thread_id;
} }
...@@ -182,7 +182,7 @@ __gthread_objc_thread_set_priority(int priority) ...@@ -182,7 +182,7 @@ __gthread_objc_thread_set_priority(int priority)
sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2; sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2;
break; break;
} }
/* Change the priority. */ /* Change the priority. */
if (pthread_setprio(pthread_self(), sys_priority) >= 0) if (pthread_setprio(pthread_self(), sys_priority) >= 0)
return 0; return 0;
...@@ -200,7 +200,7 @@ __gthread_objc_thread_get_priority(void) ...@@ -200,7 +200,7 @@ __gthread_objc_thread_get_priority(void)
if (__gthread_active_p ()) if (__gthread_active_p ())
{ {
if ((sys_priority = pthread_getprio(pthread_self())) >= 0) if ((sys_priority = pthread_getprio(pthread_self())) >= 0)
{ {
if (sys_priority >= PRI_FG_MIN_NP if (sys_priority >= PRI_FG_MIN_NP
&& sys_priority <= PRI_FG_MAX_NP) && sys_priority <= PRI_FG_MAX_NP)
return OBJC_THREAD_INTERACTIVE_PRIORITY; return OBJC_THREAD_INTERACTIVE_PRIORITY;
...@@ -292,12 +292,12 @@ __gthread_objc_mutex_allocate(objc_mutex_t mutex) ...@@ -292,12 +292,12 @@ __gthread_objc_mutex_allocate(objc_mutex_t mutex)
mutex->backend = objc_malloc(sizeof(pthread_mutex_t)); mutex->backend = objc_malloc(sizeof(pthread_mutex_t));
if (pthread_mutex_init((pthread_mutex_t *)mutex->backend, if (pthread_mutex_init((pthread_mutex_t *)mutex->backend,
pthread_mutexattr_default)) pthread_mutexattr_default))
{ {
objc_free(mutex->backend); objc_free(mutex->backend);
mutex->backend = NULL; mutex->backend = NULL;
return -1; return -1;
} }
} }
return 0; return 0;
...@@ -310,7 +310,7 @@ __gthread_objc_mutex_deallocate(objc_mutex_t mutex) ...@@ -310,7 +310,7 @@ __gthread_objc_mutex_deallocate(objc_mutex_t mutex)
if (__gthread_active_p ()) if (__gthread_active_p ())
{ {
if (pthread_mutex_destroy((pthread_mutex_t *)mutex->backend)) if (pthread_mutex_destroy((pthread_mutex_t *)mutex->backend))
return -1; return -1;
objc_free(mutex->backend); objc_free(mutex->backend);
mutex->backend = NULL; mutex->backend = NULL;
......
...@@ -52,9 +52,9 @@ typedef pthread_mutex_t __gthread_mutex_t; ...@@ -52,9 +52,9 @@ typedef pthread_mutex_t __gthread_mutex_t;
#pragma weak pthread_setspecific #pragma weak pthread_setspecific
#pragma weak pthread_create #pragma weak pthread_create
#pragma weak pthread_mutex_lock #pragma weak pthread_mutex_lock
#pragma weak pthread_mutex_trylock #pragma weak pthread_mutex_trylock
#pragma weak pthread_mutex_unlock #pragma weak pthread_mutex_unlock
#ifdef _LIBOBJC #ifdef _LIBOBJC
/* Objective C. */ /* Objective C. */
...@@ -120,15 +120,15 @@ __gthread_objc_init_thread_system(void) ...@@ -120,15 +120,15 @@ __gthread_objc_init_thread_system(void)
{ {
/* Initialize the thread storage key */ /* Initialize the thread storage key */
if (pthread_key_create(&_objc_thread_storage, NULL) == 0) if (pthread_key_create(&_objc_thread_storage, NULL) == 0)
{ {
/* The normal default detach state for threads is /* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die * PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */ * when you think they should. */
if (pthread_attr_init(&_objc_thread_attribs) == 0 if (pthread_attr_init(&_objc_thread_attribs) == 0
&& pthread_attr_setdetachstate(&_objc_thread_attribs, && pthread_attr_setdetachstate(&_objc_thread_attribs,
PTHREAD_CREATE_DETACHED) == 0) PTHREAD_CREATE_DETACHED) == 0)
return 0; return 0;
} }
} }
return -1; return -1;
...@@ -157,12 +157,12 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg) ...@@ -157,12 +157,12 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
if (!__gthread_active_p ()) if (!__gthread_active_p ())
return NULL; return NULL;
if ( !(pthread_create(&new_thread_handle, NULL, (void *)func, arg)) ) if ( !(pthread_create(&new_thread_handle, NULL, (void *)func, arg)) )
thread_id = (objc_thread_t) new_thread_handle; thread_id = (objc_thread_t) new_thread_handle;
else else
thread_id = NULL; thread_id = NULL;
return thread_id; return thread_id;
} }
...@@ -180,25 +180,25 @@ __gthread_objc_thread_set_priority(int priority) ...@@ -180,25 +180,25 @@ __gthread_objc_thread_set_priority(int priority)
if (pthread_getschedparam(thread_id, &policy, &params) == 0) if (pthread_getschedparam(thread_id, &policy, &params) == 0)
{ {
if ((priority_max = sched_get_priority_max(policy)) != 0) if ((priority_max = sched_get_priority_max(policy)) != 0)
return -1; return -1;
if ((priority_min = sched_get_priority_min(policy)) != 0) if ((priority_min = sched_get_priority_min(policy)) != 0)
return -1; return -1;
if (priority > priority_max) if (priority > priority_max)
priority = priority_max; priority = priority_max;
else if (priority < priority_min) else if (priority < priority_min)
priority = priority_min; priority = priority_min;
params.sched_priority = priority; params.sched_priority = priority;
/* /*
* The solaris 7 and several other man pages incorrectly state that * The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally * this should be a pointer to policy but pthread.h is universally
* at odds with this. * at odds with this.
*/ */
if (pthread_setschedparam(thread_id, policy, &params) == 0) if (pthread_setschedparam(thread_id, policy, &params) == 0)
return 0; return 0;
} }
return -1; return -1;
} }
...@@ -214,9 +214,9 @@ __gthread_objc_thread_get_priority(void) ...@@ -214,9 +214,9 @@ __gthread_objc_thread_get_priority(void)
struct sched_param params; struct sched_param params;
if (pthread_getschedparam(pthread_self(), &policy, &params) == 0) if (pthread_getschedparam(pthread_self(), &policy, &params) == 0)
return params.sched_priority; return params.sched_priority;
else else
return -1; return -1;
} }
else else
return OBJC_THREAD_INTERACTIVE_PRIORITY; return OBJC_THREAD_INTERACTIVE_PRIORITY;
...@@ -330,7 +330,7 @@ __gthread_objc_mutex_deallocate(objc_mutex_t mutex) ...@@ -330,7 +330,7 @@ __gthread_objc_mutex_deallocate(objc_mutex_t mutex)
static inline int static inline int
__gthread_objc_mutex_lock(objc_mutex_t mutex) __gthread_objc_mutex_lock(objc_mutex_t mutex)
{ {
if (__gthread_active_p () if (__gthread_active_p ()
&& pthread_mutex_lock((pthread_mutex_t *)mutex->backend) != 0) && pthread_mutex_lock((pthread_mutex_t *)mutex->backend) != 0)
{ {
return -1; return -1;
...@@ -343,7 +343,7 @@ __gthread_objc_mutex_lock(objc_mutex_t mutex) ...@@ -343,7 +343,7 @@ __gthread_objc_mutex_lock(objc_mutex_t mutex)
static inline int static inline int
__gthread_objc_mutex_trylock(objc_mutex_t mutex) __gthread_objc_mutex_trylock(objc_mutex_t mutex)
{ {
if (__gthread_active_p () if (__gthread_active_p ()
&& pthread_mutex_trylock((pthread_mutex_t *)mutex->backend) != 0) && pthread_mutex_trylock((pthread_mutex_t *)mutex->backend) != 0)
{ {
return -1; return -1;
...@@ -356,7 +356,7 @@ __gthread_objc_mutex_trylock(objc_mutex_t mutex) ...@@ -356,7 +356,7 @@ __gthread_objc_mutex_trylock(objc_mutex_t mutex)
static inline int static inline int
__gthread_objc_mutex_unlock(objc_mutex_t mutex) __gthread_objc_mutex_unlock(objc_mutex_t mutex)
{ {
if (__gthread_active_p () if (__gthread_active_p ()
&& pthread_mutex_unlock((pthread_mutex_t *)mutex->backend) != 0) && pthread_mutex_unlock((pthread_mutex_t *)mutex->backend) != 0)
{ {
return -1; return -1;
......
...@@ -45,7 +45,7 @@ typedef int __gthread_once_t; ...@@ -45,7 +45,7 @@ typedef int __gthread_once_t;
typedef void *__gthread_mutex_t; typedef void *__gthread_mutex_t;
/* /*
* External functions provided by RTEMS. They are very similar to their POSIX * External functions provided by RTEMS. They are very similar to their POSIX
* counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS
* header files. * header files.
*/ */
......
...@@ -141,14 +141,14 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg) ...@@ -141,14 +141,14 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
if (!__gthread_active_p ()) if (!__gthread_active_p ())
return NULL; return NULL;
if (thr_create(NULL, 0, (void *)func, arg, if (thr_create(NULL, 0, (void *)func, arg,
THR_DETACHED | THR_NEW_LWP, THR_DETACHED | THR_NEW_LWP,
&new_thread_id) == 0) &new_thread_id) == 0)
thread_id = *(objc_thread_t *)&new_thread_id; thread_id = *(objc_thread_t *)&new_thread_id;
else else
thread_id = NULL; thread_id = NULL;
return thread_id; return thread_id;
} }
...@@ -190,7 +190,7 @@ __gthread_objc_thread_get_priority(void) ...@@ -190,7 +190,7 @@ __gthread_objc_thread_get_priority(void)
if (!__gthread_active_p ()) if (!__gthread_active_p ())
return OBJC_THREAD_INTERACTIVE_PRIORITY; return OBJC_THREAD_INTERACTIVE_PRIORITY;
if (thr_getprio(thr_self(), &sys_priority) == 0) if (thr_getprio(thr_self(), &sys_priority) == 0)
{ {
if (sys_priority >= 250) if (sys_priority >= 250)
...@@ -333,7 +333,7 @@ __gthread_objc_condition_allocate(objc_condition_t condition) ...@@ -333,7 +333,7 @@ __gthread_objc_condition_allocate(objc_condition_t condition)
{ {
if (__gthread_active_p ()) if (__gthread_active_p ())
return cond_init((cond_t *)(&(condition->backend)), USYNC_THREAD, return cond_init((cond_t *)(&(condition->backend)), USYNC_THREAD,
NULL); NULL);
else else
return 0; return 0;
} }
...@@ -354,7 +354,7 @@ __gthread_objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex) ...@@ -354,7 +354,7 @@ __gthread_objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
{ {
if (__gthread_active_p ()) if (__gthread_active_p ())
return cond_wait((cond_t *)(&(condition->backend)), return cond_wait((cond_t *)(&(condition->backend)),
(mutex_t *)(&(mutex->backend))); (mutex_t *)(&(mutex->backend)));
else else
return 0; return 0;
} }
......
...@@ -31,12 +31,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -31,12 +31,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define GCC_GTHR_WIN32_H #define GCC_GTHR_WIN32_H
/* Windows32 threads specific definitions. The windows32 threading model /* Windows32 threads specific definitions. The windows32 threading model
does not map well into pthread-inspired gcc's threading model, and so does not map well into pthread-inspired gcc's threading model, and so
there are caveats one needs to be aware of. there are caveats one needs to be aware of.
1. The destructor supplied to __gthread_key_create is ignored for 1. The destructor supplied to __gthread_key_create is ignored for
generic x86-win32 ports. This will certainly cause memory leaks generic x86-win32 ports. This will certainly cause memory leaks
due to unreclaimed eh contexts (sizeof (eh_context) is at least due to unreclaimed eh contexts (sizeof (eh_context) is at least
24 bytes for x86 currently). 24 bytes for x86 currently).
This memory leak may be significant for long-running applications This memory leak may be significant for long-running applications
...@@ -47,18 +47,18 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -47,18 +47,18 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
linked in if -mthreads option is specified, that runs the dtors in linked in if -mthreads option is specified, that runs the dtors in
the reverse order of registration when each thread exits. If the reverse order of registration when each thread exits. If
-mthreads option is not given, a stub is linked in instead of the -mthreads option is not given, a stub is linked in instead of the
DLL, which results in memory leak. Other x86-win32 ports can use DLL, which results in memory leak. Other x86-win32 ports can use
the same technique of course to avoid the leak. the same technique of course to avoid the leak.
2. The error codes returned are non-POSIX like, and cast into ints. 2. The error codes returned are non-POSIX like, and cast into ints.
This may cause incorrect error return due to truncation values on This may cause incorrect error return due to truncation values on
hw where sizeof (DWORD) > sizeof (int). hw where sizeof (DWORD) > sizeof (int).
3. We might consider using Critical Sections instead of Windows32 3. We might consider using Critical Sections instead of Windows32
mutexes for better performance, but emulating __gthread_mutex_trylock mutexes for better performance, but emulating __gthread_mutex_trylock
interface becomes more complicated (Win9x does not support interface becomes more complicated (Win9x does not support
TryEnterCriticalSectioni, while NT does). TryEnterCriticalSectioni, while NT does).
The basic framework should work well enough. In the long term, GCC The basic framework should work well enough. In the long term, GCC
needs to use Structured Exception Handling on Windows32. */ needs to use Structured Exception Handling on Windows32. */
...@@ -72,12 +72,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -72,12 +72,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifdef _LIBOBJC #ifdef _LIBOBJC
/* This is necessary to prevent windef.h (included from windows.h) from /* This is necessary to prevent windef.h (included from windows.h) from
defining it's own BOOL as a typedef. */ defining it's own BOOL as a typedef. */
#ifndef __OBJC__ #ifndef __OBJC__
#define __OBJC__ #define __OBJC__
#endif #endif
#include <windows.h> #include <windows.h>
/* Now undef the windows BOOL. */ /* Now undef the windows BOOL. */
#undef BOOL #undef BOOL
/* Key structure for maintaining thread specific storage */ /* Key structure for maintaining thread specific storage */
...@@ -115,9 +115,9 @@ __gthread_objc_thread_detach(void (*func)(void *arg), void *arg) ...@@ -115,9 +115,9 @@ __gthread_objc_thread_detach(void (*func)(void *arg), void *arg)
HANDLE win32_handle; HANDLE win32_handle;
if (!(win32_handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, if (!(win32_handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func,
arg, 0, &thread_id))) arg, 0, &thread_id)))
thread_id = 0; thread_id = 0;
return (objc_thread_t)thread_id; return (objc_thread_t)thread_id;
} }
...@@ -155,7 +155,7 @@ __gthread_objc_thread_get_priority(void) ...@@ -155,7 +155,7 @@ __gthread_objc_thread_get_priority(void)
int sys_priority; int sys_priority;
sys_priority = GetThreadPriority(GetCurrentThread()); sys_priority = GetThreadPriority(GetCurrentThread());
switch (sys_priority) switch (sys_priority)
{ {
case THREAD_PRIORITY_HIGHEST: case THREAD_PRIORITY_HIGHEST:
...@@ -167,7 +167,7 @@ __gthread_objc_thread_get_priority(void) ...@@ -167,7 +167,7 @@ __gthread_objc_thread_get_priority(void)
default: default:
case THREAD_PRIORITY_BELOW_NORMAL: case THREAD_PRIORITY_BELOW_NORMAL:
return OBJC_THREAD_BACKGROUND_PRIORITY; return OBJC_THREAD_BACKGROUND_PRIORITY;
case THREAD_PRIORITY_IDLE: case THREAD_PRIORITY_IDLE:
case THREAD_PRIORITY_LOWEST: case THREAD_PRIORITY_LOWEST:
return OBJC_THREAD_LOW_PRIORITY; return OBJC_THREAD_LOW_PRIORITY;
...@@ -355,7 +355,7 @@ extern int __mingwthr_key_dtor (DWORD, void (*) (void *)); ...@@ -355,7 +355,7 @@ extern int __mingwthr_key_dtor (DWORD, void (*) (void *));
#endif #endif
/* Mingw runtime >= v0.3 provides a magic variable that is set to non-zero /* Mingw runtime >= v0.3 provides a magic variable that is set to non-zero
if -mthreads option was specified, or 0 otherwise. This is to get around if -mthreads option was specified, or 0 otherwise. This is to get around
the lack of weak symbols in PE-COFF. */ the lack of weak symbols in PE-COFF. */
extern int _CRT_MT; extern int _CRT_MT;
#endif #endif
...@@ -381,27 +381,27 @@ __gthread_once (__gthread_once_t *once, void (*func) (void)) ...@@ -381,27 +381,27 @@ __gthread_once (__gthread_once_t *once, void (*func) (void))
if (! once->done) if (! once->done)
{ {
if (InterlockedIncrement (&(once->started)) == 0) if (InterlockedIncrement (&(once->started)) == 0)
{ {
(*func) (); (*func) ();
once->done = TRUE; once->done = TRUE;
} }
else else
{ {
/* Another thread is currently executing the code, so wait for it /* Another thread is currently executing the code, so wait for it
to finish; yield the CPU in the meantime. If performance to finish; yield the CPU in the meantime. If performance
does become an issue, the solution is to use an Event that does become an issue, the solution is to use an Event that
we wait on here (and set above), but that implies a place to we wait on here (and set above), but that implies a place to
create the event before this routine is called. */ create the event before this routine is called. */
while (! once->done) while (! once->done)
Sleep (0); Sleep (0);
} }
} }
return 0; return 0;
} }
/* Windows32 thread local keys don't support destructors; this leads to /* Windows32 thread local keys don't support destructors; this leads to
leaks, especially in threaded applications making extensive use of leaks, especially in threaded applications making extensive use of
C++ EH. Mingw uses a thread-support DLL to work-around this problem. */ C++ EH. Mingw uses a thread-support DLL to work-around this problem. */
static inline int static inline int
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *)) __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
...@@ -423,7 +423,7 @@ __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *)) ...@@ -423,7 +423,7 @@ __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
} }
/* Currently, this routine is called only for Mingw runtime, and if /* Currently, this routine is called only for Mingw runtime, and if
-mthreads option is chosen to link in the thread support DLL. */ -mthreads option is chosen to link in the thread support DLL. */
static inline int static inline int
__gthread_key_dtor (__gthread_key_t key, void *ptr) __gthread_key_dtor (__gthread_key_t key, void *ptr)
{ {
...@@ -461,7 +461,7 @@ __gthread_setspecific (__gthread_key_t key, const void *ptr) ...@@ -461,7 +461,7 @@ __gthread_setspecific (__gthread_key_t key, const void *ptr)
static inline void static inline void
__gthread_mutex_init_function (__gthread_mutex_t *mutex) __gthread_mutex_init_function (__gthread_mutex_t *mutex)
{ {
/* Create unnamed mutex with default security attr and no initial owner. */ /* Create unnamed mutex with default security attr and no initial owner. */
*mutex = CreateMutex (NULL, 0, NULL); *mutex = CreateMutex (NULL, 0, NULL);
} }
......
...@@ -32,7 +32,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -32,7 +32,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* If this file is compiled with threads support, it must /* If this file is compiled with threads support, it must
#define __GTHREADS 1 #define __GTHREADS 1
to indicate that threads support is present. Also it has define to indicate that threads support is present. Also it has define
function function
int __gthread_active_p () int __gthread_active_p ()
that returns 1 if thread system is active, 0 if not. that returns 1 if thread system is active, 0 if not.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment