71f3e391b3
* system.h: Include "safe-ctype.h" instead of <safe-ctype.h>. Include <signal.h>, <sys/mman.h>, <sys/resource.h> and <sys/times.h>. (O_BINARY, SIGCHLD, MAP_FAILED, MAP_ANONYMOUS, kill): Conditionally define. (GET_ENVIRONMENT): Poison. * configure.ac: Don't test for mincore. * configure: Regenerate. * config.in: Regenerate. * collect2-aix.c: Don't include <sys/mman.h>. * collect2.c: Don't include <signal.h>. (SIGCHLD): Don't define. (prefix_from_env): Use getenv instead of GET_ENVIRONMENT. * config/alpha/alpha.c: Include "splay-tree.h" instead of <splay-tree.h>. * config/arm/arm.c (arm_target_help): Use getenv instead of GET_ENVIRONMENT. * config/avr/driver-avr.c: Don't include <stdlib.h>. * config/frv/frv.c: Don't include <ctype.h>. * config/host-darwin.c: Don't include <sys/mman.h>. * config/host-hpux.c: Don't include <sys/mman.h> or <unistd.h>. (MAP_FAILED): Don't define. * config/host-linux.c: Don't include <sys/mman.h> or <limits.h>. * config/host-solaris.c: Don't include <sys/mman.h>. * config/i386/cygming.h: Don't include <stdio.h>. * config/i386/driver-i386.c: Don't include <stdlib.h>. * config/i386/host-cygwin.c: Don't include <sys/mman.h>. * config/iq2000/iq2000.c: Don't include <signal.h>. * config/m32c/m32c-pragma.c: Don't include <stdio.h>. * config/m68hc11/m68hc11.c: Don't include <stdio.h>. * config/mep/mep-pragma.c: Don't include <stdio.h>. * config/microblaze/microblaze.c: Don't include <signal.h>. * config/mips/mips.c: Don't include <signal.h>. * config/rs6000/host-darwin.c: Don't include <signal.h>. * cppdefault.c (cpp_relocated): Use getenv instead of GET_ENVIRONMENT. * defaults.h (GET_ENVIRONMENT): Don't define. * et-forest.h: Don't include <ansidecl.h> or <stddef.h>. * gcc.c: Don't include <signal.h>, <sys/mman.h> or <sys/types.h>. (SIGCHLD, MAP_FAILED, kill): Don't define. (process_command): Use getenv instead of GET_ENVIRONMENT. * genhooks.c: Don't include <string.h>. * ggc-common.c: Don't include <sys/resource.h>, <sys/mman.h> or <sys/types.h>. (MAP_FAILED): Don't define. * ggc-page.c Don't include <sys/mman.h>. (MAP_ANONYMOUS, MAP_FAILED): Don't define. * ggc-zone.c: Don't include <sys/mman.h>. (MAP_ANONYMOUS, MAP_FAILED): Don't define. * graph.c: Include "config.h" instead of <config.h>. * incpath.c (add_env_var_paths): Use getenv instead of GET_ENVIRONMENT. * lto-wrapper.c: Don't include <errno.h>, <signal.h> or "libiberty.h". (SIGCHLD, kill): Don't define. * mips-tfile.c: Don't include <signal.h>. * opts.c: Don't include <signal.h> or <sys/resource.h>. (print_specific_help): Use getenv instead of GET_ENVIRONMENT. * passes.c: Don't include <signal.h>, <sys/resource.h> or <sys/times.h>. * sparseset.h: Don't include <assert.h>. * timevar.c: Don't include <sys/times.h> or <sys/resource.h>. * tlink.c: Don't include "libiberty.h". * toplev.c: Don't include <signal.h> or <sys/times.h>. * tree-mudflap.c: Include "demangle.h" instead of <demangle.h>. * tree-switch-conversion.c: Don't include <signal.h>. * vmsdbgout.c: Don't include <errno.h> or <string.h>. c-family: * c-opts.c (check_deps_environment_vars): Use getenv instead of GET_ENVIRONMENT. * c-pch.c (O_BINARY): Don't define here. * c-pragma.h: Include "cpplib.h" instead of <cpplib.h>. fortran: * gfortran.h (alloca): Don't include definitions. (NULL): Don't define. java: * boehm.c: Include "config.h" instead of <config.h>. * builtins.c: Don't include <stdarg.h>. * class.c: Don't include "stdio.h". (O_BINARY): Don't define here. * jcf-depend.c: Don't include <assert.h>. (jcf_dependency_set_dep_file, jcf_dependency_init, jcf_dependency_write): Use gcc_assert. * jcf-io.c (O_BINARY): Don't define here. * jcf-path.c: Don't include "tm.h". (jcf_path_init): Use getenv instead of GET_ENVIRONMENT. * resource.c: Don't include "stdio.h". (O_BINARY): Don't define here. * verify-impl.c: Don't include <stdio.h>. lto: * lto-endian.h: Delete. * lto-object.c: Don't include "libiberty.h". (O_BINARY): Don't define. * lto.c: Don't include "libiberty.h" or <sys/mman.h>. (O_BINARY): Don't define. From-SVN: r167241
160 lines
4.1 KiB
C
160 lines
4.1 KiB
C
/* SparseSet implementation.
|
|
Copyright (C) 2007, 2010 Free Software Foundation, Inc.
|
|
Contributed by Peter Bergner <bergner@vnet.ibm.com>
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef GCC_SPARSESET_H
|
|
#define GCC_SPARSESET_H
|
|
|
|
#define SPARSESET_ELT_BITS ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
|
|
#define SPARSESET_ELT_TYPE unsigned int
|
|
|
|
/* Data Structure used for the SparseSet representation. */
|
|
|
|
typedef struct sparseset_def
|
|
{
|
|
SPARSESET_ELT_TYPE *dense; /* Dense array. */
|
|
SPARSESET_ELT_TYPE *sparse; /* Sparse array. */
|
|
SPARSESET_ELT_TYPE members; /* Number of elements. */
|
|
SPARSESET_ELT_TYPE size; /* Maximum number of elements. */
|
|
SPARSESET_ELT_TYPE iter; /* Iterator index. */
|
|
unsigned char iter_inc; /* Iteration increment amount. */
|
|
bool iterating;
|
|
SPARSESET_ELT_TYPE elms[2]; /* Combined dense and sparse arrays. */
|
|
} *sparseset;
|
|
|
|
#define sparseset_free(MAP) free(MAP)
|
|
extern sparseset sparseset_alloc (SPARSESET_ELT_TYPE n_elms);
|
|
extern void sparseset_clear_bit (sparseset, SPARSESET_ELT_TYPE);
|
|
extern void sparseset_copy (sparseset, sparseset);
|
|
extern void sparseset_and (sparseset, sparseset, sparseset);
|
|
extern void sparseset_and_compl (sparseset, sparseset, sparseset);
|
|
extern void sparseset_ior (sparseset, sparseset, sparseset);
|
|
extern bool sparseset_equal_p (sparseset, sparseset);
|
|
|
|
/* Operation: S = {}
|
|
Clear the set of all elements. */
|
|
|
|
static inline void
|
|
sparseset_clear (sparseset s)
|
|
{
|
|
s->members = 0;
|
|
s->iterating = false;
|
|
}
|
|
|
|
/* Return the number of elements currently in the set. */
|
|
|
|
static inline SPARSESET_ELT_TYPE
|
|
sparseset_cardinality (sparseset s)
|
|
{
|
|
return s->members;
|
|
}
|
|
|
|
/* Return the maximum number of elements this set can hold. */
|
|
|
|
static inline SPARSESET_ELT_TYPE
|
|
sparseset_size (sparseset s)
|
|
{
|
|
return s->size;
|
|
}
|
|
|
|
/* Return true if e is a member of the set S, otherwise return false. */
|
|
|
|
static inline bool
|
|
sparseset_bit_p (sparseset s, SPARSESET_ELT_TYPE e)
|
|
{
|
|
SPARSESET_ELT_TYPE idx;
|
|
|
|
gcc_assert (e < s->size);
|
|
|
|
idx = s->sparse[e];
|
|
|
|
return idx < s->members && s->dense[idx] == e;
|
|
}
|
|
|
|
/* Low level insertion routine not meant for use outside of sparseset.[ch].
|
|
Assumes E is valid and not already a member of the set S. */
|
|
|
|
static inline void
|
|
sparseset_insert_bit (sparseset s, SPARSESET_ELT_TYPE e, SPARSESET_ELT_TYPE idx)
|
|
{
|
|
s->sparse[e] = idx;
|
|
s->dense[idx] = e;
|
|
}
|
|
|
|
/* Operation: S = S + {e}
|
|
Insert E into the set S, if it isn't already a member. */
|
|
|
|
static inline void
|
|
sparseset_set_bit (sparseset s, SPARSESET_ELT_TYPE e)
|
|
{
|
|
if (!sparseset_bit_p (s, e))
|
|
sparseset_insert_bit (s, e, s->members++);
|
|
}
|
|
|
|
/* Return and remove an arbitrary element from the set S. */
|
|
|
|
static inline SPARSESET_ELT_TYPE
|
|
sparseset_pop (sparseset s)
|
|
{
|
|
SPARSESET_ELT_TYPE mem = s->members;
|
|
|
|
gcc_assert (mem != 0);
|
|
|
|
s->members = mem - 1;
|
|
return s->dense[mem];
|
|
}
|
|
|
|
static inline void
|
|
sparseset_iter_init (sparseset s)
|
|
{
|
|
s->iter = 0;
|
|
s->iter_inc = 1;
|
|
s->iterating = true;
|
|
}
|
|
|
|
static inline bool
|
|
sparseset_iter_p (sparseset s)
|
|
{
|
|
if (s->iterating && s->iter < s->members)
|
|
return true;
|
|
else
|
|
return s->iterating = false;
|
|
}
|
|
|
|
static inline SPARSESET_ELT_TYPE
|
|
sparseset_iter_elm (sparseset s)
|
|
{
|
|
return s->dense[s->iter];
|
|
}
|
|
|
|
static inline void
|
|
sparseset_iter_next (sparseset s)
|
|
{
|
|
s->iter += s->iter_inc;
|
|
s->iter_inc = 1;
|
|
}
|
|
|
|
#define EXECUTE_IF_SET_IN_SPARSESET(SPARSESET, ITER) \
|
|
for (sparseset_iter_init (SPARSESET); \
|
|
sparseset_iter_p (SPARSESET) \
|
|
&& (((ITER) = sparseset_iter_elm (SPARSESET)) || 1); \
|
|
sparseset_iter_next (SPARSESET))
|
|
|
|
#endif /* GCC_SPARSESET_H */
|