added arduino, modified build
This commit is contained in:
346
arduino/hardware/tools/avr/include/gdb/jit-reader.h
Normal file
346
arduino/hardware/tools/avr/include/gdb/jit-reader.h
Normal file
@@ -0,0 +1,346 @@
|
||||
/* JIT declarations for GDB, the GNU Debugger.
|
||||
|
||||
Copyright (C) 2011-2014 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
This program 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 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GDB_JIT_READER_H
|
||||
#define GDB_JIT_READER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Versioning information. See gdb_reader_funcs. */
|
||||
|
||||
#define GDB_READER_INTERFACE_VERSION 1
|
||||
|
||||
/* Readers must be released under a GPL compatible license. To
|
||||
declare that the reader is indeed released under a GPL compatible
|
||||
license, invoke the macro GDB_DECLARE_GPL_COMPATIBLE in a source
|
||||
file. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define GDB_DECLARE_GPL_COMPATIBLE_READER \
|
||||
extern "C" { \
|
||||
extern int plugin_is_GPL_compatible (void); \
|
||||
extern int plugin_is_GPL_compatible (void) \
|
||||
{ \
|
||||
return 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define GDB_DECLARE_GPL_COMPATIBLE_READER \
|
||||
extern int plugin_is_GPL_compatible (void); \
|
||||
extern int plugin_is_GPL_compatible (void) \
|
||||
{ \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Represents an address on the target system. */
|
||||
|
||||
typedef unsigned long GDB_CORE_ADDR;
|
||||
|
||||
/* Return status codes. */
|
||||
|
||||
enum gdb_status {
|
||||
GDB_FAIL = 0,
|
||||
GDB_SUCCESS = 1
|
||||
};
|
||||
|
||||
struct gdb_object;
|
||||
struct gdb_symtab;
|
||||
struct gdb_block;
|
||||
struct gdb_symbol_callbacks;
|
||||
|
||||
/* An array of these are used to represent a map from code addresses to line
|
||||
numbers in the source file. */
|
||||
|
||||
struct gdb_line_mapping
|
||||
{
|
||||
int line;
|
||||
GDB_CORE_ADDR pc;
|
||||
};
|
||||
|
||||
/* Create a new GDB code object. Each code object can have one or
|
||||
more symbol tables, each representing a compiled source file. */
|
||||
|
||||
typedef struct gdb_object *(gdb_object_open) (struct gdb_symbol_callbacks *cb);
|
||||
|
||||
/* The callback used to create new symbol table. CB is the
|
||||
gdb_symbol_callbacks which the structure is part of. FILE_NAME is
|
||||
an (optionally NULL) file name to associate with this new symbol
|
||||
table.
|
||||
|
||||
Returns a new instance to gdb_symtab that can later be passed to
|
||||
gdb_block_new, gdb_symtab_add_line_mapping and gdb_symtab_close. */
|
||||
|
||||
typedef struct gdb_symtab *(gdb_symtab_open) (struct gdb_symbol_callbacks *cb,
|
||||
struct gdb_object *obj,
|
||||
const char *file_name);
|
||||
|
||||
/* Creates a new block in a given symbol table. A symbol table is a
|
||||
forest of blocks, each block representing an code address range and
|
||||
a corresponding (optionally NULL) NAME. In case the block
|
||||
corresponds to a function, the NAME passed should be the name of
|
||||
the function.
|
||||
|
||||
If the new block to be created is a child of (i.e. is nested in)
|
||||
another block, the parent block can be passed in PARENT. SYMTAB is
|
||||
the symbol table the new block is to belong in. BEGIN, END is the
|
||||
code address range the block corresponds to.
|
||||
|
||||
Returns a new instance of gdb_block, which, as of now, has no use.
|
||||
Note that the gdb_block returned must not be freed by the
|
||||
caller. */
|
||||
|
||||
typedef struct gdb_block *(gdb_block_open) (struct gdb_symbol_callbacks *cb,
|
||||
struct gdb_symtab *symtab,
|
||||
struct gdb_block *parent,
|
||||
GDB_CORE_ADDR begin,
|
||||
GDB_CORE_ADDR end,
|
||||
const char *name);
|
||||
|
||||
/* Adds a PC to line number mapping for the symbol table SYMTAB.
|
||||
NLINES is the number of elements in LINES, each element
|
||||
corresponding to one (PC, line) pair. */
|
||||
|
||||
typedef void (gdb_symtab_add_line_mapping) (struct gdb_symbol_callbacks *cb,
|
||||
struct gdb_symtab *symtab,
|
||||
int nlines,
|
||||
struct gdb_line_mapping *lines);
|
||||
|
||||
/* Close the symtab SYMTAB. This signals to GDB that no more blocks
|
||||
will be opened on this symtab. */
|
||||
|
||||
typedef void (gdb_symtab_close) (struct gdb_symbol_callbacks *cb,
|
||||
struct gdb_symtab *symtab);
|
||||
|
||||
|
||||
/* Closes the gdb_object OBJ and adds the emitted information into
|
||||
GDB's internal structures. Once this is done, the debug
|
||||
information will be picked up and used; this will usually be the
|
||||
last operation in gdb_read_debug_info. */
|
||||
|
||||
typedef void (gdb_object_close) (struct gdb_symbol_callbacks *cb,
|
||||
struct gdb_object *obj);
|
||||
|
||||
/* Reads LEN bytes from TARGET_MEM in the target's virtual address
|
||||
space into GDB_BUF.
|
||||
|
||||
Returns GDB_FAIL on failure, and GDB_SUCCESS on success. */
|
||||
|
||||
typedef enum gdb_status (gdb_target_read) (GDB_CORE_ADDR target_mem,
|
||||
void *gdb_buf, int len);
|
||||
|
||||
/* The list of callbacks that are passed to read. These callbacks are
|
||||
to be used to construct the symbol table. The functions have been
|
||||
described above. */
|
||||
|
||||
struct gdb_symbol_callbacks
|
||||
{
|
||||
gdb_object_open *object_open;
|
||||
gdb_symtab_open *symtab_open;
|
||||
gdb_block_open *block_open;
|
||||
gdb_symtab_close *symtab_close;
|
||||
gdb_object_close *object_close;
|
||||
|
||||
gdb_symtab_add_line_mapping *line_mapping_add;
|
||||
gdb_target_read *target_read;
|
||||
|
||||
/* For internal use by GDB. */
|
||||
void *priv_data;
|
||||
};
|
||||
|
||||
/* Forward declaration. */
|
||||
|
||||
struct gdb_reg_value;
|
||||
|
||||
/* A function of this type is used to free a gdb_reg_value. See the
|
||||
comment on `free' in struct gdb_reg_value. */
|
||||
|
||||
typedef void (gdb_reg_value_free) (struct gdb_reg_value *);
|
||||
|
||||
/* Denotes the value of a register. */
|
||||
|
||||
struct gdb_reg_value
|
||||
{
|
||||
/* The size of the register in bytes. The reader need not set this
|
||||
field. This will be set for (defined) register values being read
|
||||
from GDB using reg_get. */
|
||||
int size;
|
||||
|
||||
/* Set to non-zero if the value for the register is known. The
|
||||
registers for which the reader does not call reg_set are also
|
||||
assumed to be undefined */
|
||||
int defined;
|
||||
|
||||
/* Since gdb_reg_value is a variable sized structure, it will
|
||||
usually be allocated on the heap. This function is expected to
|
||||
contain the corresponding "free" function.
|
||||
|
||||
When a pointer to gdb_reg_value is being sent from GDB to the
|
||||
reader (via gdb_unwind_reg_get), the reader is expected to call
|
||||
this function (with the same gdb_reg_value as argument) once it
|
||||
is done with the value.
|
||||
|
||||
When the function sends the a gdb_reg_value to GDB (via
|
||||
gdb_unwind_reg_set), it is expected to set this field to point to
|
||||
an appropriate cleanup routine (or to NULL if no cleanup is
|
||||
required). */
|
||||
gdb_reg_value_free *free;
|
||||
|
||||
/* The value of the register. */
|
||||
unsigned char value[1];
|
||||
};
|
||||
|
||||
/* get_frame_id in gdb_reader_funcs is to return a gdb_frame_id
|
||||
corresponding to the current frame. The registers corresponding to
|
||||
the current frame can be read using reg_get. Calling get_frame_id
|
||||
on a particular frame should return the same gdb_frame_id
|
||||
throughout its lifetime (i.e. till before it gets unwound). One
|
||||
way to do this is by having the CODE_ADDRESS point to the
|
||||
function's first instruction and STACK_ADDRESS point to the value
|
||||
of the stack pointer when entering the function. */
|
||||
|
||||
struct gdb_frame_id
|
||||
{
|
||||
GDB_CORE_ADDR code_address;
|
||||
GDB_CORE_ADDR stack_address;
|
||||
};
|
||||
|
||||
/* Forward declaration. */
|
||||
|
||||
struct gdb_unwind_callbacks;
|
||||
|
||||
/* Returns the value of a particular register in the current frame.
|
||||
The current frame is the frame that needs to be unwound into the
|
||||
outer (earlier) frame.
|
||||
|
||||
CB is the struct gdb_unwind_callbacks * the callback belongs to.
|
||||
REGNUM is the DWARF register number of the register that needs to
|
||||
be unwound.
|
||||
|
||||
Returns the gdb_reg_value corresponding to the register requested.
|
||||
In case the value of the register has been optimized away or
|
||||
otherwise unavailable, the defined flag in the returned
|
||||
gdb_reg_value will be zero. */
|
||||
|
||||
typedef struct gdb_reg_value *(gdb_unwind_reg_get)
|
||||
(struct gdb_unwind_callbacks *cb, int regnum);
|
||||
|
||||
/* Sets the previous value of a particular register. REGNUM is the
|
||||
(DWARF) register number whose value is to be set. VAL is the value
|
||||
the register is to be set to.
|
||||
|
||||
VAL is *not* copied, so the memory allocated to it cannot be
|
||||
reused. Once GDB no longer needs the value, it is deallocated
|
||||
using the FREE function (see gdb_reg_value).
|
||||
|
||||
A register can also be "set" to an undefined value by setting the
|
||||
defined in VAL to zero. */
|
||||
|
||||
typedef void (gdb_unwind_reg_set) (struct gdb_unwind_callbacks *cb, int regnum,
|
||||
struct gdb_reg_value *val);
|
||||
|
||||
/* This struct is passed to unwind in gdb_reader_funcs, and is to be
|
||||
used to unwind the current frame (current being the frame whose
|
||||
registers can be read using reg_get) into the earlier frame. The
|
||||
functions have been described above. */
|
||||
|
||||
struct gdb_unwind_callbacks
|
||||
{
|
||||
gdb_unwind_reg_get *reg_get;
|
||||
gdb_unwind_reg_set *reg_set;
|
||||
gdb_target_read *target_read;
|
||||
|
||||
/* For internal use by GDB. */
|
||||
void *priv_data;
|
||||
};
|
||||
|
||||
/* Forward declaration. */
|
||||
|
||||
struct gdb_reader_funcs;
|
||||
|
||||
/* Parse the debug info off a block of memory, pointed to by MEMORY
|
||||
(already copied to GDB's address space) and MEMORY_SZ bytes long.
|
||||
The implementation has to use the functions in CB to actually emit
|
||||
the parsed data into GDB. SELF is the same structure returned by
|
||||
gdb_init_reader.
|
||||
|
||||
Return GDB_FAIL on failure and GDB_SUCCESS on success. */
|
||||
|
||||
typedef enum gdb_status (gdb_read_debug_info) (struct gdb_reader_funcs *self,
|
||||
struct gdb_symbol_callbacks *cb,
|
||||
void *memory, long memory_sz);
|
||||
|
||||
/* Unwind the current frame, CB is the set of unwind callbacks that
|
||||
are to be used to do this.
|
||||
|
||||
Return GDB_FAIL on failure and GDB_SUCCESS on success. */
|
||||
|
||||
typedef enum gdb_status (gdb_unwind_frame) (struct gdb_reader_funcs *self,
|
||||
struct gdb_unwind_callbacks *cb);
|
||||
|
||||
/* Return the frame ID corresponding to the current frame, using C to
|
||||
read the current register values. See the comment on struct
|
||||
gdb_frame_id. */
|
||||
|
||||
typedef struct gdb_frame_id (gdb_get_frame_id) (struct gdb_reader_funcs *self,
|
||||
struct gdb_unwind_callbacks *c);
|
||||
|
||||
/* Called when a reader is being unloaded. This function should also
|
||||
free SELF, if required. */
|
||||
|
||||
typedef void (gdb_destroy_reader) (struct gdb_reader_funcs *self);
|
||||
|
||||
/* Called when the reader is loaded. Must either return a properly
|
||||
populated gdb_reader_funcs or NULL. The memory allocated for the
|
||||
gdb_reader_funcs is to be managed by the reader itself (i.e. if it
|
||||
is allocated from the heap, it must also be freed in
|
||||
gdb_destroy_reader). */
|
||||
|
||||
extern struct gdb_reader_funcs *gdb_init_reader (void);
|
||||
|
||||
/* Pointer to the functions which implement the reader's
|
||||
functionality. The individual functions have been documented
|
||||
above.
|
||||
|
||||
None of the fields are optional. */
|
||||
|
||||
struct gdb_reader_funcs
|
||||
{
|
||||
/* Must be set to GDB_READER_INTERFACE_VERSION. */
|
||||
int reader_version;
|
||||
|
||||
/* For use by the reader. */
|
||||
void *priv_data;
|
||||
|
||||
gdb_read_debug_info *read;
|
||||
gdb_unwind_frame *unwind;
|
||||
gdb_get_frame_id *get_frame_id;
|
||||
gdb_destroy_reader *destroy;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
329
arduino/hardware/tools/avr/include/libiberty/ansidecl.h
Normal file
329
arduino/hardware/tools/avr/include/libiberty/ansidecl.h
Normal file
@@ -0,0 +1,329 @@
|
||||
/* ANSI and traditional C compatability macros
|
||||
Copyright (C) 1991-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* ANSI and traditional C compatibility macros
|
||||
|
||||
ANSI C is assumed if __STDC__ is #defined.
|
||||
|
||||
Macro ANSI C definition Traditional C definition
|
||||
----- ---- - ---------- ----------- - ----------
|
||||
PTR `void *' `char *'
|
||||
const not defined `'
|
||||
volatile not defined `'
|
||||
signed not defined `'
|
||||
|
||||
For ease of writing code which uses GCC extensions but needs to be
|
||||
portable to other compilers, we provide the GCC_VERSION macro that
|
||||
simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
|
||||
wrappers around __attribute__. Also, __extension__ will be #defined
|
||||
to nothing if it doesn't work. See below. */
|
||||
|
||||
#ifndef _ANSIDECL_H
|
||||
#define _ANSIDECL_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Every source file includes this file,
|
||||
so they will all get the switch for lint. */
|
||||
/* LINTLIBRARY */
|
||||
|
||||
/* Using MACRO(x,y) in cpp #if conditionals does not work with some
|
||||
older preprocessors. Thus we can't define something like this:
|
||||
|
||||
#define HAVE_GCC_VERSION(MAJOR, MINOR) \
|
||||
(__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
|
||||
|
||||
and then test "#if HAVE_GCC_VERSION(2,7)".
|
||||
|
||||
So instead we use the macro below and test it against specific values. */
|
||||
|
||||
/* This macro simplifies testing whether we are using gcc, and if it
|
||||
is of a particular minimum version. (Both major & minor numbers are
|
||||
significant.) This macro will evaluate to 0 if we are not using
|
||||
gcc at all. */
|
||||
#ifndef GCC_VERSION
|
||||
#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif /* GCC_VERSION */
|
||||
|
||||
#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
|
||||
/* All known AIX compilers implement these things (but don't always
|
||||
define __STDC__). The RISC/OS MIPS compiler defines these things
|
||||
in SVR4 mode, but does not define __STDC__. */
|
||||
/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
|
||||
C++ compilers, does not define __STDC__, though it acts as if this
|
||||
was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
|
||||
|
||||
#define PTR void *
|
||||
|
||||
#undef const
|
||||
#undef volatile
|
||||
#undef signed
|
||||
|
||||
/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
|
||||
it too, but it's not in C89. */
|
||||
#undef inline
|
||||
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
|
||||
/* it's a keyword */
|
||||
#else
|
||||
# if GCC_VERSION >= 2007
|
||||
# define inline __inline__ /* __inline__ prevents -pedantic warnings */
|
||||
# else
|
||||
# define inline /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else /* Not ANSI C. */
|
||||
|
||||
#define PTR char *
|
||||
|
||||
/* some systems define these in header files for non-ansi mode */
|
||||
#undef const
|
||||
#undef volatile
|
||||
#undef signed
|
||||
#undef inline
|
||||
#define const
|
||||
#define volatile
|
||||
#define signed
|
||||
#define inline
|
||||
|
||||
#endif /* ANSI C. */
|
||||
|
||||
/* Define macros for some gcc attributes. This permits us to use the
|
||||
macros freely, and know that they will come into play for the
|
||||
version of gcc in which they are supported. */
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
|
||||
#ifndef ATTRIBUTE_MALLOC
|
||||
# if (GCC_VERSION >= 2096)
|
||||
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
# else
|
||||
# define ATTRIBUTE_MALLOC
|
||||
# endif /* GNUC >= 2.96 */
|
||||
#endif /* ATTRIBUTE_MALLOC */
|
||||
|
||||
/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5. For
|
||||
g++ an attribute on a label must be followed by a semicolon. */
|
||||
#ifndef ATTRIBUTE_UNUSED_LABEL
|
||||
# ifndef __cplusplus
|
||||
# if GCC_VERSION >= 2093
|
||||
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
|
||||
# else
|
||||
# define ATTRIBUTE_UNUSED_LABEL
|
||||
# endif
|
||||
# else
|
||||
# if GCC_VERSION >= 4005
|
||||
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
|
||||
# else
|
||||
# define ATTRIBUTE_UNUSED_LABEL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Similarly to ARG_UNUSED below. Prior to GCC 3.4, the C++ frontend
|
||||
couldn't parse attributes placed after the identifier name, and now
|
||||
the entire compiler is built with C++. */
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
#if GCC_VERSION >= 3004
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#else
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
#endif /* ATTRIBUTE_UNUSED */
|
||||
|
||||
/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
|
||||
identifier name. */
|
||||
#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
|
||||
# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
|
||||
#else /* !__cplusplus || GNUC >= 3.4 */
|
||||
# define ARG_UNUSED(NAME) NAME
|
||||
#endif /* !__cplusplus || GNUC >= 3.4 */
|
||||
|
||||
#ifndef ATTRIBUTE_NORETURN
|
||||
#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
#endif /* ATTRIBUTE_NORETURN */
|
||||
|
||||
/* Attribute `nonnull' was valid as of gcc 3.3. */
|
||||
#ifndef ATTRIBUTE_NONNULL
|
||||
# if (GCC_VERSION >= 3003)
|
||||
# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
|
||||
# else
|
||||
# define ATTRIBUTE_NONNULL(m)
|
||||
# endif /* GNUC >= 3.3 */
|
||||
#endif /* ATTRIBUTE_NONNULL */
|
||||
|
||||
/* Attribute `returns_nonnull' was valid as of gcc 4.9. */
|
||||
#ifndef ATTRIBUTE_RETURNS_NONNULL
|
||||
# if (GCC_VERSION >= 4009)
|
||||
# define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
|
||||
# else
|
||||
# define ATTRIBUTE_RETURNS_NONNULL
|
||||
# endif /* GNUC >= 4.9 */
|
||||
#endif /* ATTRIBUTE_RETURNS_NONNULL */
|
||||
|
||||
/* Attribute `pure' was valid as of gcc 3.0. */
|
||||
#ifndef ATTRIBUTE_PURE
|
||||
# if (GCC_VERSION >= 3000)
|
||||
# define ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# else
|
||||
# define ATTRIBUTE_PURE
|
||||
# endif /* GNUC >= 3.0 */
|
||||
#endif /* ATTRIBUTE_PURE */
|
||||
|
||||
/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
|
||||
This was the case for the `printf' format attribute by itself
|
||||
before GCC 3.3, but as of 3.3 we need to add the `nonnull'
|
||||
attribute to retain this behavior. */
|
||||
#ifndef ATTRIBUTE_PRINTF
|
||||
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
|
||||
#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
|
||||
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
|
||||
#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
|
||||
#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
|
||||
#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_PRINTF */
|
||||
|
||||
/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
|
||||
a function pointer. Format attributes were allowed on function
|
||||
pointers as of gcc 3.1. */
|
||||
#ifndef ATTRIBUTE_FPTR_PRINTF
|
||||
# if (GCC_VERSION >= 3001)
|
||||
# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
|
||||
# else
|
||||
# define ATTRIBUTE_FPTR_PRINTF(m, n)
|
||||
# endif /* GNUC >= 3.1 */
|
||||
# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_FPTR_PRINTF */
|
||||
|
||||
/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A
|
||||
NULL format specifier was allowed as of gcc 3.3. */
|
||||
#ifndef ATTRIBUTE_NULL_PRINTF
|
||||
# if (GCC_VERSION >= 3003)
|
||||
# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
|
||||
# else
|
||||
# define ATTRIBUTE_NULL_PRINTF(m, n)
|
||||
# endif /* GNUC >= 3.3 */
|
||||
# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
|
||||
# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
|
||||
# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
|
||||
# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
|
||||
# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_NULL_PRINTF */
|
||||
|
||||
/* Attribute `sentinel' was valid as of gcc 3.5. */
|
||||
#ifndef ATTRIBUTE_SENTINEL
|
||||
# if (GCC_VERSION >= 3005)
|
||||
# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
|
||||
# else
|
||||
# define ATTRIBUTE_SENTINEL
|
||||
# endif /* GNUC >= 3.5 */
|
||||
#endif /* ATTRIBUTE_SENTINEL */
|
||||
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
|
||||
# if (GCC_VERSION >= 3000)
|
||||
# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
|
||||
# else
|
||||
# define ATTRIBUTE_ALIGNED_ALIGNOF(m)
|
||||
# endif /* GNUC >= 3.0 */
|
||||
#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
|
||||
|
||||
/* Useful for structures whose layout must much some binary specification
|
||||
regardless of the alignment and padding qualities of the compiler. */
|
||||
#ifndef ATTRIBUTE_PACKED
|
||||
# define ATTRIBUTE_PACKED __attribute__ ((packed))
|
||||
#endif
|
||||
|
||||
/* Attribute `hot' and `cold' was valid as of gcc 4.3. */
|
||||
#ifndef ATTRIBUTE_COLD
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_COLD __attribute__ ((__cold__))
|
||||
# else
|
||||
# define ATTRIBUTE_COLD
|
||||
# endif /* GNUC >= 4.3 */
|
||||
#endif /* ATTRIBUTE_COLD */
|
||||
#ifndef ATTRIBUTE_HOT
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_HOT __attribute__ ((__hot__))
|
||||
# else
|
||||
# define ATTRIBUTE_HOT
|
||||
# endif /* GNUC >= 4.3 */
|
||||
#endif /* ATTRIBUTE_HOT */
|
||||
|
||||
/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9. */
|
||||
#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED
|
||||
# if (GCC_VERSION >= 4009)
|
||||
# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
|
||||
# else
|
||||
# define ATTRIBUTE_NO_SANITIZE_UNDEFINED
|
||||
# endif /* GNUC >= 4.9 */
|
||||
#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
|
||||
|
||||
/* We use __extension__ in some places to suppress -pedantic warnings
|
||||
about GCC extensions. This feature didn't work properly before
|
||||
gcc 2.8. */
|
||||
#if GCC_VERSION < 2008
|
||||
#define __extension__
|
||||
#endif
|
||||
|
||||
/* This is used to declare a const variable which should be visible
|
||||
outside of the current compilation unit. Use it as
|
||||
EXPORTED_CONST int i = 1;
|
||||
This is because the semantics of const are different in C and C++.
|
||||
"extern const" is permitted in C but it looks strange, and gcc
|
||||
warns about it when -Wc++-compat is not used. */
|
||||
#ifdef __cplusplus
|
||||
#define EXPORTED_CONST extern const
|
||||
#else
|
||||
#define EXPORTED_CONST const
|
||||
#endif
|
||||
|
||||
/* Be conservative and only use enum bitfields with C++ or GCC.
|
||||
FIXME: provide a complete autoconf test for buggy enum bitfields. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define ENUM_BITFIELD(TYPE) enum TYPE
|
||||
#elif (GCC_VERSION > 2000)
|
||||
#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
|
||||
#else
|
||||
#define ENUM_BITFIELD(TYPE) unsigned int
|
||||
#endif
|
||||
|
||||
/* This is used to mark a class or virtual function as final. */
|
||||
#if __cplusplus >= 201103L
|
||||
#define GCC_FINAL final
|
||||
#elif GCC_VERSION >= 4007
|
||||
#define GCC_FINAL __final
|
||||
#else
|
||||
#define GCC_FINAL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ansidecl.h */
|
||||
685
arduino/hardware/tools/avr/include/libiberty/demangle.h
Normal file
685
arduino/hardware/tools/avr/include/libiberty/demangle.h
Normal file
@@ -0,0 +1,685 @@
|
||||
/* Defs for interface to demanglers.
|
||||
Copyright (C) 1992-2015 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Library General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Library Public License restrictions do apply in other
|
||||
respects; for example, they cover modification of the file, and
|
||||
distribution when not linked into a combined executable.)
|
||||
|
||||
This program 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
|
||||
#if !defined (DEMANGLE_H)
|
||||
#define DEMANGLE_H
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Options passed to cplus_demangle (in 2nd parameter). */
|
||||
|
||||
#define DMGL_NO_OPTS 0 /* For readability... */
|
||||
#define DMGL_PARAMS (1 << 0) /* Include function args */
|
||||
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
|
||||
#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */
|
||||
#define DMGL_VERBOSE (1 << 3) /* Include implementation details. */
|
||||
#define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */
|
||||
#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when
|
||||
present) after function signature.
|
||||
It applies only to the toplevel
|
||||
function type. */
|
||||
#define DMGL_RET_DROP (1 << 6) /* Suppress printing function return
|
||||
types, even if present. It applies
|
||||
only to the toplevel function type.
|
||||
*/
|
||||
|
||||
#define DMGL_AUTO (1 << 8)
|
||||
#define DMGL_GNU (1 << 9)
|
||||
#define DMGL_LUCID (1 << 10)
|
||||
#define DMGL_ARM (1 << 11)
|
||||
#define DMGL_HP (1 << 12) /* For the HP aCC compiler;
|
||||
same as ARM except for
|
||||
template arguments, etc. */
|
||||
#define DMGL_EDG (1 << 13)
|
||||
#define DMGL_GNU_V3 (1 << 14)
|
||||
#define DMGL_GNAT (1 << 15)
|
||||
#define DMGL_DLANG (1 << 16)
|
||||
|
||||
/* If none of these are set, use 'current_demangling_style' as the default. */
|
||||
#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_DLANG)
|
||||
|
||||
/* Enumeration of possible demangling styles.
|
||||
|
||||
Lucid and ARM styles are still kept logically distinct, even though
|
||||
they now both behave identically. The resulting style is actual the
|
||||
union of both. I.E. either style recognizes both "__pt__" and "__rf__"
|
||||
for operator "->", even though the first is lucid style and the second
|
||||
is ARM style. (FIXME?) */
|
||||
|
||||
extern enum demangling_styles
|
||||
{
|
||||
no_demangling = -1,
|
||||
unknown_demangling = 0,
|
||||
auto_demangling = DMGL_AUTO,
|
||||
gnu_demangling = DMGL_GNU,
|
||||
lucid_demangling = DMGL_LUCID,
|
||||
arm_demangling = DMGL_ARM,
|
||||
hp_demangling = DMGL_HP,
|
||||
edg_demangling = DMGL_EDG,
|
||||
gnu_v3_demangling = DMGL_GNU_V3,
|
||||
java_demangling = DMGL_JAVA,
|
||||
gnat_demangling = DMGL_GNAT,
|
||||
dlang_demangling = DMGL_DLANG
|
||||
} current_demangling_style;
|
||||
|
||||
/* Define string names for the various demangling styles. */
|
||||
|
||||
#define NO_DEMANGLING_STYLE_STRING "none"
|
||||
#define AUTO_DEMANGLING_STYLE_STRING "auto"
|
||||
#define GNU_DEMANGLING_STYLE_STRING "gnu"
|
||||
#define LUCID_DEMANGLING_STYLE_STRING "lucid"
|
||||
#define ARM_DEMANGLING_STYLE_STRING "arm"
|
||||
#define HP_DEMANGLING_STYLE_STRING "hp"
|
||||
#define EDG_DEMANGLING_STYLE_STRING "edg"
|
||||
#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3"
|
||||
#define JAVA_DEMANGLING_STYLE_STRING "java"
|
||||
#define GNAT_DEMANGLING_STYLE_STRING "gnat"
|
||||
#define DLANG_DEMANGLING_STYLE_STRING "dlang"
|
||||
|
||||
/* Some macros to test what demangling style is active. */
|
||||
|
||||
#define CURRENT_DEMANGLING_STYLE current_demangling_style
|
||||
#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
|
||||
#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
|
||||
#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
|
||||
#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
|
||||
#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
|
||||
#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
|
||||
#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
|
||||
#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
|
||||
#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
|
||||
#define DLANG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_DLANG)
|
||||
|
||||
/* Provide information about the available demangle styles. This code is
|
||||
pulled from gdb into libiberty because it is useful to binutils also. */
|
||||
|
||||
extern const struct demangler_engine
|
||||
{
|
||||
const char *const demangling_style_name;
|
||||
const enum demangling_styles demangling_style;
|
||||
const char *const demangling_style_doc;
|
||||
} libiberty_demanglers[];
|
||||
|
||||
extern char *
|
||||
cplus_demangle (const char *mangled, int options);
|
||||
|
||||
extern int
|
||||
cplus_demangle_opname (const char *opname, char *result, int options);
|
||||
|
||||
extern const char *
|
||||
cplus_mangle_opname (const char *opname, int options);
|
||||
|
||||
/* Note: This sets global state. FIXME if you care about multi-threading. */
|
||||
|
||||
extern void
|
||||
set_cplus_marker_for_demangling (int ch);
|
||||
|
||||
extern enum demangling_styles
|
||||
cplus_demangle_set_style (enum demangling_styles style);
|
||||
|
||||
extern enum demangling_styles
|
||||
cplus_demangle_name_to_style (const char *name);
|
||||
|
||||
/* Callback typedef for allocation-less demangler interfaces. */
|
||||
typedef void (*demangle_callbackref) (const char *, size_t, void *);
|
||||
|
||||
/* V3 ABI demangling entry points, defined in cp-demangle.c. Callback
|
||||
variants return non-zero on success, zero on error. char* variants
|
||||
return a string allocated by malloc on success, NULL on error. */
|
||||
extern int
|
||||
cplus_demangle_v3_callback (const char *mangled, int options,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
extern char*
|
||||
cplus_demangle_v3 (const char *mangled, int options);
|
||||
|
||||
extern int
|
||||
java_demangle_v3_callback (const char *mangled,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
extern char*
|
||||
java_demangle_v3 (const char *mangled);
|
||||
|
||||
char *
|
||||
ada_demangle (const char *mangled, int options);
|
||||
|
||||
extern char *
|
||||
dlang_demangle (const char *mangled, int options);
|
||||
|
||||
enum gnu_v3_ctor_kinds {
|
||||
gnu_v3_complete_object_ctor = 1,
|
||||
gnu_v3_base_object_ctor,
|
||||
gnu_v3_complete_object_allocating_ctor,
|
||||
/* These are not part of the V3 ABI. Unified constructors are generated
|
||||
as a speed-for-space optimization when the -fdeclone-ctor-dtor option
|
||||
is used, and are always internal symbols. */
|
||||
gnu_v3_unified_ctor,
|
||||
gnu_v3_object_ctor_group
|
||||
};
|
||||
|
||||
/* Return non-zero iff NAME is the mangled form of a constructor name
|
||||
in the G++ V3 ABI demangling style. Specifically, return an `enum
|
||||
gnu_v3_ctor_kinds' value indicating what kind of constructor
|
||||
it is. */
|
||||
extern enum gnu_v3_ctor_kinds
|
||||
is_gnu_v3_mangled_ctor (const char *name);
|
||||
|
||||
|
||||
enum gnu_v3_dtor_kinds {
|
||||
gnu_v3_deleting_dtor = 1,
|
||||
gnu_v3_complete_object_dtor,
|
||||
gnu_v3_base_object_dtor,
|
||||
/* These are not part of the V3 ABI. Unified destructors are generated
|
||||
as a speed-for-space optimization when the -fdeclone-ctor-dtor option
|
||||
is used, and are always internal symbols. */
|
||||
gnu_v3_unified_dtor,
|
||||
gnu_v3_object_dtor_group
|
||||
};
|
||||
|
||||
/* Return non-zero iff NAME is the mangled form of a destructor name
|
||||
in the G++ V3 ABI demangling style. Specifically, return an `enum
|
||||
gnu_v3_dtor_kinds' value, indicating what kind of destructor
|
||||
it is. */
|
||||
extern enum gnu_v3_dtor_kinds
|
||||
is_gnu_v3_mangled_dtor (const char *name);
|
||||
|
||||
/* The V3 demangler works in two passes. The first pass builds a tree
|
||||
representation of the mangled name, and the second pass turns the
|
||||
tree representation into a demangled string. Here we define an
|
||||
interface to permit a caller to build their own tree
|
||||
representation, which they can pass to the demangler to get a
|
||||
demangled string. This can be used to canonicalize user input into
|
||||
something which the demangler might output. It could also be used
|
||||
by other demanglers in the future. */
|
||||
|
||||
/* These are the component types which may be found in the tree. Many
|
||||
component types have one or two subtrees, referred to as left and
|
||||
right (a component type with only one subtree puts it in the left
|
||||
subtree). */
|
||||
|
||||
enum demangle_component_type
|
||||
{
|
||||
/* A name, with a length and a pointer to a string. */
|
||||
DEMANGLE_COMPONENT_NAME,
|
||||
/* A qualified name. The left subtree is a class or namespace or
|
||||
some such thing, and the right subtree is a name qualified by
|
||||
that class. */
|
||||
DEMANGLE_COMPONENT_QUAL_NAME,
|
||||
/* A local name. The left subtree describes a function, and the
|
||||
right subtree is a name which is local to that function. */
|
||||
DEMANGLE_COMPONENT_LOCAL_NAME,
|
||||
/* A typed name. The left subtree is a name, and the right subtree
|
||||
describes that name as a function. */
|
||||
DEMANGLE_COMPONENT_TYPED_NAME,
|
||||
/* A template. The left subtree is a template name, and the right
|
||||
subtree is a template argument list. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE,
|
||||
/* A template parameter. This holds a number, which is the template
|
||||
parameter index. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE_PARAM,
|
||||
/* A function parameter. This holds a number, which is the index. */
|
||||
DEMANGLE_COMPONENT_FUNCTION_PARAM,
|
||||
/* A constructor. This holds a name and the kind of
|
||||
constructor. */
|
||||
DEMANGLE_COMPONENT_CTOR,
|
||||
/* A destructor. This holds a name and the kind of destructor. */
|
||||
DEMANGLE_COMPONENT_DTOR,
|
||||
/* A vtable. This has one subtree, the type for which this is a
|
||||
vtable. */
|
||||
DEMANGLE_COMPONENT_VTABLE,
|
||||
/* A VTT structure. This has one subtree, the type for which this
|
||||
is a VTT. */
|
||||
DEMANGLE_COMPONENT_VTT,
|
||||
/* A construction vtable. The left subtree is the type for which
|
||||
this is a vtable, and the right subtree is the derived type for
|
||||
which this vtable is built. */
|
||||
DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
|
||||
/* A typeinfo structure. This has one subtree, the type for which
|
||||
this is the tpeinfo structure. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO,
|
||||
/* A typeinfo name. This has one subtree, the type for which this
|
||||
is the typeinfo name. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO_NAME,
|
||||
/* A typeinfo function. This has one subtree, the type for which
|
||||
this is the tpyeinfo function. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO_FN,
|
||||
/* A thunk. This has one subtree, the name for which this is a
|
||||
thunk. */
|
||||
DEMANGLE_COMPONENT_THUNK,
|
||||
/* A virtual thunk. This has one subtree, the name for which this
|
||||
is a virtual thunk. */
|
||||
DEMANGLE_COMPONENT_VIRTUAL_THUNK,
|
||||
/* A covariant thunk. This has one subtree, the name for which this
|
||||
is a covariant thunk. */
|
||||
DEMANGLE_COMPONENT_COVARIANT_THUNK,
|
||||
/* A Java class. This has one subtree, the type. */
|
||||
DEMANGLE_COMPONENT_JAVA_CLASS,
|
||||
/* A guard variable. This has one subtree, the name for which this
|
||||
is a guard variable. */
|
||||
DEMANGLE_COMPONENT_GUARD,
|
||||
/* The init and wrapper functions for C++11 thread_local variables. */
|
||||
DEMANGLE_COMPONENT_TLS_INIT,
|
||||
DEMANGLE_COMPONENT_TLS_WRAPPER,
|
||||
/* A reference temporary. This has one subtree, the name for which
|
||||
this is a temporary. */
|
||||
DEMANGLE_COMPONENT_REFTEMP,
|
||||
/* A hidden alias. This has one subtree, the encoding for which it
|
||||
is providing alternative linkage. */
|
||||
DEMANGLE_COMPONENT_HIDDEN_ALIAS,
|
||||
/* A standard substitution. This holds the name of the
|
||||
substitution. */
|
||||
DEMANGLE_COMPONENT_SUB_STD,
|
||||
/* The restrict qualifier. The one subtree is the type which is
|
||||
being qualified. */
|
||||
DEMANGLE_COMPONENT_RESTRICT,
|
||||
/* The volatile qualifier. The one subtree is the type which is
|
||||
being qualified. */
|
||||
DEMANGLE_COMPONENT_VOLATILE,
|
||||
/* The const qualifier. The one subtree is the type which is being
|
||||
qualified. */
|
||||
DEMANGLE_COMPONENT_CONST,
|
||||
/* The restrict qualifier modifying a member function. The one
|
||||
subtree is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_RESTRICT_THIS,
|
||||
/* The volatile qualifier modifying a member function. The one
|
||||
subtree is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_VOLATILE_THIS,
|
||||
/* The const qualifier modifying a member function. The one subtree
|
||||
is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_CONST_THIS,
|
||||
/* C++11 A reference modifying a member function. The one subtree is the
|
||||
type which is being referenced. */
|
||||
DEMANGLE_COMPONENT_REFERENCE_THIS,
|
||||
/* C++11: An rvalue reference modifying a member function. The one
|
||||
subtree is the type which is being referenced. */
|
||||
DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS,
|
||||
/* A vendor qualifier. The left subtree is the type which is being
|
||||
qualified, and the right subtree is the name of the
|
||||
qualifier. */
|
||||
DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
|
||||
/* A pointer. The one subtree is the type which is being pointed
|
||||
to. */
|
||||
DEMANGLE_COMPONENT_POINTER,
|
||||
/* A reference. The one subtree is the type which is being
|
||||
referenced. */
|
||||
DEMANGLE_COMPONENT_REFERENCE,
|
||||
/* C++0x: An rvalue reference. The one subtree is the type which is
|
||||
being referenced. */
|
||||
DEMANGLE_COMPONENT_RVALUE_REFERENCE,
|
||||
/* A complex type. The one subtree is the base type. */
|
||||
DEMANGLE_COMPONENT_COMPLEX,
|
||||
/* An imaginary type. The one subtree is the base type. */
|
||||
DEMANGLE_COMPONENT_IMAGINARY,
|
||||
/* A builtin type. This holds the builtin type information. */
|
||||
DEMANGLE_COMPONENT_BUILTIN_TYPE,
|
||||
/* A vendor's builtin type. This holds the name of the type. */
|
||||
DEMANGLE_COMPONENT_VENDOR_TYPE,
|
||||
/* A function type. The left subtree is the return type. The right
|
||||
subtree is a list of ARGLIST nodes. Either or both may be
|
||||
NULL. */
|
||||
DEMANGLE_COMPONENT_FUNCTION_TYPE,
|
||||
/* An array type. The left subtree is the dimension, which may be
|
||||
NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
|
||||
expression. The right subtree is the element type. */
|
||||
DEMANGLE_COMPONENT_ARRAY_TYPE,
|
||||
/* A pointer to member type. The left subtree is the class type,
|
||||
and the right subtree is the member type. CV-qualifiers appear
|
||||
on the latter. */
|
||||
DEMANGLE_COMPONENT_PTRMEM_TYPE,
|
||||
/* A fixed-point type. */
|
||||
DEMANGLE_COMPONENT_FIXED_TYPE,
|
||||
/* A vector type. The left subtree is the number of elements,
|
||||
the right subtree is the element type. */
|
||||
DEMANGLE_COMPONENT_VECTOR_TYPE,
|
||||
/* An argument list. The left subtree is the current argument, and
|
||||
the right subtree is either NULL or another ARGLIST node. */
|
||||
DEMANGLE_COMPONENT_ARGLIST,
|
||||
/* A template argument list. The left subtree is the current
|
||||
template argument, and the right subtree is either NULL or
|
||||
another TEMPLATE_ARGLIST node. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
|
||||
/* An initializer list. The left subtree is either an explicit type or
|
||||
NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */
|
||||
DEMANGLE_COMPONENT_INITIALIZER_LIST,
|
||||
/* An operator. This holds information about a standard
|
||||
operator. */
|
||||
DEMANGLE_COMPONENT_OPERATOR,
|
||||
/* An extended operator. This holds the number of arguments, and
|
||||
the name of the extended operator. */
|
||||
DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
|
||||
/* A typecast, represented as a unary operator. The one subtree is
|
||||
the type to which the argument should be cast. */
|
||||
DEMANGLE_COMPONENT_CAST,
|
||||
/* A nullary expression. The left subtree is the operator. */
|
||||
DEMANGLE_COMPONENT_NULLARY,
|
||||
/* A unary expression. The left subtree is the operator, and the
|
||||
right subtree is the single argument. */
|
||||
DEMANGLE_COMPONENT_UNARY,
|
||||
/* A binary expression. The left subtree is the operator, and the
|
||||
right subtree is a BINARY_ARGS. */
|
||||
DEMANGLE_COMPONENT_BINARY,
|
||||
/* Arguments to a binary expression. The left subtree is the first
|
||||
argument, and the right subtree is the second argument. */
|
||||
DEMANGLE_COMPONENT_BINARY_ARGS,
|
||||
/* A trinary expression. The left subtree is the operator, and the
|
||||
right subtree is a TRINARY_ARG1. */
|
||||
DEMANGLE_COMPONENT_TRINARY,
|
||||
/* Arguments to a trinary expression. The left subtree is the first
|
||||
argument, and the right subtree is a TRINARY_ARG2. */
|
||||
DEMANGLE_COMPONENT_TRINARY_ARG1,
|
||||
/* More arguments to a trinary expression. The left subtree is the
|
||||
second argument, and the right subtree is the third argument. */
|
||||
DEMANGLE_COMPONENT_TRINARY_ARG2,
|
||||
/* A literal. The left subtree is the type, and the right subtree
|
||||
is the value, represented as a DEMANGLE_COMPONENT_NAME. */
|
||||
DEMANGLE_COMPONENT_LITERAL,
|
||||
/* A negative literal. Like LITERAL, but the value is negated.
|
||||
This is a minor hack: the NAME used for LITERAL points directly
|
||||
to the mangled string, but since negative numbers are mangled
|
||||
using 'n' instead of '-', we want a way to indicate a negative
|
||||
number which involves neither modifying the mangled string nor
|
||||
allocating a new copy of the literal in memory. */
|
||||
DEMANGLE_COMPONENT_LITERAL_NEG,
|
||||
/* A libgcj compiled resource. The left subtree is the name of the
|
||||
resource. */
|
||||
DEMANGLE_COMPONENT_JAVA_RESOURCE,
|
||||
/* A name formed by the concatenation of two parts. The left
|
||||
subtree is the first part and the right subtree the second. */
|
||||
DEMANGLE_COMPONENT_COMPOUND_NAME,
|
||||
/* A name formed by a single character. */
|
||||
DEMANGLE_COMPONENT_CHARACTER,
|
||||
/* A number. */
|
||||
DEMANGLE_COMPONENT_NUMBER,
|
||||
/* A decltype type. */
|
||||
DEMANGLE_COMPONENT_DECLTYPE,
|
||||
/* Global constructors keyed to name. */
|
||||
DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
|
||||
/* Global destructors keyed to name. */
|
||||
DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
|
||||
/* A lambda closure type. */
|
||||
DEMANGLE_COMPONENT_LAMBDA,
|
||||
/* A default argument scope. */
|
||||
DEMANGLE_COMPONENT_DEFAULT_ARG,
|
||||
/* An unnamed type. */
|
||||
DEMANGLE_COMPONENT_UNNAMED_TYPE,
|
||||
/* A transactional clone. This has one subtree, the encoding for
|
||||
which it is providing alternative linkage. */
|
||||
DEMANGLE_COMPONENT_TRANSACTION_CLONE,
|
||||
/* A non-transactional clone entry point. In the i386/x86_64 abi,
|
||||
the unmangled symbol of a tm_callable becomes a thunk and the
|
||||
non-transactional function version is mangled thus. */
|
||||
DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
|
||||
/* A pack expansion. */
|
||||
DEMANGLE_COMPONENT_PACK_EXPANSION,
|
||||
/* A name with an ABI tag. */
|
||||
DEMANGLE_COMPONENT_TAGGED_NAME,
|
||||
/* A cloned function. */
|
||||
DEMANGLE_COMPONENT_CLONE
|
||||
};
|
||||
|
||||
/* Types which are only used internally. */
|
||||
|
||||
struct demangle_operator_info;
|
||||
struct demangle_builtin_type_info;
|
||||
|
||||
/* A node in the tree representation is an instance of a struct
|
||||
demangle_component. Note that the field names of the struct are
|
||||
not well protected against macros defined by the file including
|
||||
this one. We can fix this if it ever becomes a problem. */
|
||||
|
||||
struct demangle_component
|
||||
{
|
||||
/* The type of this component. */
|
||||
enum demangle_component_type type;
|
||||
|
||||
union
|
||||
{
|
||||
/* For DEMANGLE_COMPONENT_NAME. */
|
||||
struct
|
||||
{
|
||||
/* A pointer to the name (which need not NULL terminated) and
|
||||
its length. */
|
||||
const char *s;
|
||||
int len;
|
||||
} s_name;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_OPERATOR. */
|
||||
struct
|
||||
{
|
||||
/* Operator. */
|
||||
const struct demangle_operator_info *op;
|
||||
} s_operator;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */
|
||||
struct
|
||||
{
|
||||
/* Number of arguments. */
|
||||
int args;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_extended_operator;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_FIXED_TYPE. */
|
||||
struct
|
||||
{
|
||||
/* The length, indicated by a C integer type name. */
|
||||
struct demangle_component *length;
|
||||
/* _Accum or _Fract? */
|
||||
short accum;
|
||||
/* Saturating or not? */
|
||||
short sat;
|
||||
} s_fixed;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_CTOR. */
|
||||
struct
|
||||
{
|
||||
/* Kind of constructor. */
|
||||
enum gnu_v3_ctor_kinds kind;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_ctor;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_DTOR. */
|
||||
struct
|
||||
{
|
||||
/* Kind of destructor. */
|
||||
enum gnu_v3_dtor_kinds kind;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_dtor;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */
|
||||
struct
|
||||
{
|
||||
/* Builtin type. */
|
||||
const struct demangle_builtin_type_info *type;
|
||||
} s_builtin;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_SUB_STD. */
|
||||
struct
|
||||
{
|
||||
/* Standard substitution string. */
|
||||
const char* string;
|
||||
/* Length of string. */
|
||||
int len;
|
||||
} s_string;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_*_PARAM. */
|
||||
struct
|
||||
{
|
||||
/* Parameter index. */
|
||||
long number;
|
||||
} s_number;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_CHARACTER. */
|
||||
struct
|
||||
{
|
||||
int character;
|
||||
} s_character;
|
||||
|
||||
/* For other types. */
|
||||
struct
|
||||
{
|
||||
/* Left (or only) subtree. */
|
||||
struct demangle_component *left;
|
||||
/* Right subtree. */
|
||||
struct demangle_component *right;
|
||||
} s_binary;
|
||||
|
||||
struct
|
||||
{
|
||||
/* subtree, same place as d_left. */
|
||||
struct demangle_component *sub;
|
||||
/* integer. */
|
||||
int num;
|
||||
} s_unary_num;
|
||||
|
||||
} u;
|
||||
};
|
||||
|
||||
/* People building mangled trees are expected to allocate instances of
|
||||
struct demangle_component themselves. They can then call one of
|
||||
the following functions to fill them in. */
|
||||
|
||||
/* Fill in most component types with a left subtree and a right
|
||||
subtree. Returns non-zero on success, zero on failure, such as an
|
||||
unrecognized or inappropriate component type. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_component (struct demangle_component *fill,
|
||||
enum demangle_component_type,
|
||||
struct demangle_component *left,
|
||||
struct demangle_component *right);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_name (struct demangle_component *fill,
|
||||
const char *, int);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
|
||||
builtin type (e.g., "int", etc.). Returns non-zero on success,
|
||||
zero if the type is not recognized. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_builtin_type (struct demangle_component *fill,
|
||||
const char *type_name);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
|
||||
operator and the number of arguments which it takes (the latter is
|
||||
used to disambiguate operators which can be both binary and unary,
|
||||
such as '-'). Returns non-zero on success, zero if the operator is
|
||||
not recognized. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_operator (struct demangle_component *fill,
|
||||
const char *opname, int args);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
|
||||
number of arguments and the name. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_extended_operator (struct demangle_component *fill,
|
||||
int numargs,
|
||||
struct demangle_component *nm);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_ctor (struct demangle_component *fill,
|
||||
enum gnu_v3_ctor_kinds kind,
|
||||
struct demangle_component *name);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_dtor (struct demangle_component *fill,
|
||||
enum gnu_v3_dtor_kinds kind,
|
||||
struct demangle_component *name);
|
||||
|
||||
/* This function translates a mangled name into a struct
|
||||
demangle_component tree. The first argument is the mangled name.
|
||||
The second argument is DMGL_* options. This returns a pointer to a
|
||||
tree on success, or NULL on failure. On success, the third
|
||||
argument is set to a block of memory allocated by malloc. This
|
||||
block should be passed to free when the tree is no longer
|
||||
needed. */
|
||||
|
||||
extern struct demangle_component *
|
||||
cplus_demangle_v3_components (const char *mangled, int options, void **mem);
|
||||
|
||||
/* This function takes a struct demangle_component tree and returns
|
||||
the corresponding demangled string. The first argument is DMGL_*
|
||||
options. The second is the tree to demangle. The third is a guess
|
||||
at the length of the demangled string, used to initially allocate
|
||||
the return buffer. The fourth is a pointer to a size_t. On
|
||||
success, this function returns a buffer allocated by malloc(), and
|
||||
sets the size_t pointed to by the fourth argument to the size of
|
||||
the allocated buffer (not the length of the returned string). On
|
||||
failure, this function returns NULL, and sets the size_t pointed to
|
||||
by the fourth argument to 0 for an invalid tree, or to 1 for a
|
||||
memory allocation error. */
|
||||
|
||||
extern char *
|
||||
cplus_demangle_print (int options,
|
||||
const struct demangle_component *tree,
|
||||
int estimated_length,
|
||||
size_t *p_allocated_size);
|
||||
|
||||
/* This function takes a struct demangle_component tree and passes back
|
||||
a demangled string in one or more calls to a callback function.
|
||||
The first argument is DMGL_* options. The second is the tree to
|
||||
demangle. The third is a pointer to a callback function; on each call
|
||||
this receives an element of the demangled string, its length, and an
|
||||
opaque value. The fourth is the opaque value passed to the callback.
|
||||
The callback is called once or more to return the full demangled
|
||||
string. The demangled element string is always nul-terminated, though
|
||||
its length is also provided for convenience. In contrast to
|
||||
cplus_demangle_print(), this function does not allocate heap memory
|
||||
to grow output strings (except perhaps where alloca() is implemented
|
||||
by malloc()), and so is normally safe for use where the heap has been
|
||||
corrupted. On success, this function returns 1; on failure, 0. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_print_callback (int options,
|
||||
const struct demangle_component *tree,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* DEMANGLE_H */
|
||||
72
arduino/hardware/tools/avr/include/libiberty/dyn-string.h
Normal file
72
arduino/hardware/tools/avr/include/libiberty/dyn-string.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* An abstract string datatype.
|
||||
Copyright (C) 1998-2015 Free Software Foundation, Inc.
|
||||
Contributed by Mark Mitchell (mark@markmitchell.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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef DYN_STRING_H
|
||||
#define DYN_STRING_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct dyn_string
|
||||
{
|
||||
int allocated; /* The amount of space allocated for the string. */
|
||||
int length; /* The actual length of the string. */
|
||||
char *s; /* The string itself, NUL-terminated. */
|
||||
}* dyn_string_t;
|
||||
|
||||
/* The length STR, in bytes, not including the terminating NUL. */
|
||||
#define dyn_string_length(STR) \
|
||||
((STR)->length)
|
||||
|
||||
/* The NTBS in which the contents of STR are stored. */
|
||||
#define dyn_string_buf(STR) \
|
||||
((STR)->s)
|
||||
|
||||
/* Compare DS1 to DS2 with strcmp. */
|
||||
#define dyn_string_compare(DS1, DS2) \
|
||||
(strcmp ((DS1)->s, (DS2)->s))
|
||||
|
||||
|
||||
extern int dyn_string_init (struct dyn_string *, int);
|
||||
extern dyn_string_t dyn_string_new (int);
|
||||
extern void dyn_string_delete (dyn_string_t);
|
||||
extern char *dyn_string_release (dyn_string_t);
|
||||
extern dyn_string_t dyn_string_resize (dyn_string_t, int);
|
||||
extern void dyn_string_clear (dyn_string_t);
|
||||
extern int dyn_string_copy (dyn_string_t, dyn_string_t);
|
||||
extern int dyn_string_copy_cstr (dyn_string_t, const char *);
|
||||
extern int dyn_string_prepend (dyn_string_t, dyn_string_t);
|
||||
extern int dyn_string_prepend_cstr (dyn_string_t, const char *);
|
||||
extern int dyn_string_insert (dyn_string_t, int, dyn_string_t);
|
||||
extern int dyn_string_insert_cstr (dyn_string_t, int, const char *);
|
||||
extern int dyn_string_insert_char (dyn_string_t, int, int);
|
||||
extern int dyn_string_append (dyn_string_t, dyn_string_t);
|
||||
extern int dyn_string_append_cstr (dyn_string_t, const char *);
|
||||
extern int dyn_string_append_char (dyn_string_t, int);
|
||||
extern int dyn_string_substring (dyn_string_t, dyn_string_t, int, int);
|
||||
extern int dyn_string_eq (dyn_string_t, dyn_string_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined (DYN_STRING_H) */
|
||||
94
arduino/hardware/tools/avr/include/libiberty/fibheap.h
Normal file
94
arduino/hardware/tools/avr/include/libiberty/fibheap.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* A Fibonacci heap datatype.
|
||||
Copyright (C) 1998-2015 Free Software Foundation, Inc.
|
||||
Contributed by Daniel Berlin (dan@cgsoftware.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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Fibonacci heaps are somewhat complex, but, there's an article in
|
||||
DDJ that explains them pretty well:
|
||||
|
||||
http://www.ddj.com/articles/1997/9701/9701o/9701o.htm?topic=algoritms
|
||||
|
||||
Introduction to algorithms by Corman and Rivest also goes over them.
|
||||
|
||||
The original paper that introduced them is "Fibonacci heaps and their
|
||||
uses in improved network optimization algorithms" by Tarjan and
|
||||
Fredman (JACM 34(3), July 1987).
|
||||
|
||||
Amortized and real worst case time for operations:
|
||||
|
||||
ExtractMin: O(lg n) amortized. O(n) worst case.
|
||||
DecreaseKey: O(1) amortized. O(lg n) worst case.
|
||||
Insert: O(2) amortized. O(1) actual.
|
||||
Union: O(1) amortized. O(1) actual. */
|
||||
|
||||
#ifndef _FIBHEAP_H_
|
||||
#define _FIBHEAP_H_
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef long fibheapkey_t;
|
||||
|
||||
typedef struct fibheap
|
||||
{
|
||||
size_t nodes;
|
||||
struct fibnode *min;
|
||||
struct fibnode *root;
|
||||
} *fibheap_t;
|
||||
|
||||
typedef struct fibnode
|
||||
{
|
||||
struct fibnode *parent;
|
||||
struct fibnode *child;
|
||||
struct fibnode *left;
|
||||
struct fibnode *right;
|
||||
fibheapkey_t key;
|
||||
void *data;
|
||||
#if defined (__GNUC__) && (!defined (SIZEOF_INT) || SIZEOF_INT < 4)
|
||||
__extension__ unsigned long int degree : 31;
|
||||
__extension__ unsigned long int mark : 1;
|
||||
#else
|
||||
unsigned int degree : 31;
|
||||
unsigned int mark : 1;
|
||||
#endif
|
||||
} *fibnode_t;
|
||||
|
||||
extern fibheap_t fibheap_new (void);
|
||||
extern fibnode_t fibheap_insert (fibheap_t, fibheapkey_t, void *);
|
||||
extern int fibheap_empty (fibheap_t);
|
||||
extern fibheapkey_t fibheap_min_key (fibheap_t);
|
||||
extern fibheapkey_t fibheap_replace_key (fibheap_t, fibnode_t,
|
||||
fibheapkey_t);
|
||||
extern void *fibheap_replace_key_data (fibheap_t, fibnode_t,
|
||||
fibheapkey_t, void *);
|
||||
extern void *fibheap_extract_min (fibheap_t);
|
||||
extern void *fibheap_min (fibheap_t);
|
||||
extern void *fibheap_replace_data (fibheap_t, fibnode_t, void *);
|
||||
extern void *fibheap_delete_node (fibheap_t, fibnode_t);
|
||||
extern void fibheap_delete (fibheap_t);
|
||||
extern fibheap_t fibheap_union (fibheap_t, fibheap_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FIBHEAP_H_ */
|
||||
159
arduino/hardware/tools/avr/include/libiberty/floatformat.h
Normal file
159
arduino/hardware/tools/avr/include/libiberty/floatformat.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* IEEE floating point support declarations, for GDB, the GNU Debugger.
|
||||
Copyright (C) 1991-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#if !defined (FLOATFORMAT_H)
|
||||
#define FLOATFORMAT_H 1
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
|
||||
bytes are concatenated according to the byteorder flag, then each of those
|
||||
fields is contiguous. We number the bits with 0 being the most significant
|
||||
(i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
|
||||
contains with the *_start and *_len fields. */
|
||||
|
||||
/* What is the order of the bytes? */
|
||||
|
||||
enum floatformat_byteorders {
|
||||
/* Standard little endian byte order.
|
||||
EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
|
||||
floatformat_little,
|
||||
|
||||
/* Standard big endian byte order.
|
||||
EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
|
||||
floatformat_big,
|
||||
|
||||
/* Little endian byte order but big endian word order.
|
||||
EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
|
||||
floatformat_littlebyte_bigword,
|
||||
|
||||
/* VAX byte order. Little endian byte order with 16-bit words. The
|
||||
following example is an illustration of the byte order only; VAX
|
||||
doesn't have a fully IEEE compliant floating-point format.
|
||||
EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
|
||||
floatformat_vax
|
||||
};
|
||||
|
||||
enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
|
||||
|
||||
struct floatformat
|
||||
{
|
||||
enum floatformat_byteorders byteorder;
|
||||
unsigned int totalsize; /* Total size of number in bits */
|
||||
|
||||
/* Sign bit is always one bit long. 1 means negative, 0 means positive. */
|
||||
unsigned int sign_start;
|
||||
|
||||
unsigned int exp_start;
|
||||
unsigned int exp_len;
|
||||
/* Bias added to a "true" exponent to form the biased exponent. It
|
||||
is intentionally signed as, otherwize, -exp_bias can turn into a
|
||||
very large number (e.g., given the exp_bias of 0x3fff and a 64
|
||||
bit long, the equation (long)(1 - exp_bias) evaluates to
|
||||
4294950914) instead of -16382). */
|
||||
int exp_bias;
|
||||
/* Exponent value which indicates NaN. This is the actual value stored in
|
||||
the float, not adjusted by the exp_bias. This usually consists of all
|
||||
one bits. */
|
||||
unsigned int exp_nan;
|
||||
|
||||
unsigned int man_start;
|
||||
unsigned int man_len;
|
||||
|
||||
/* Is the integer bit explicit or implicit? */
|
||||
enum floatformat_intbit intbit;
|
||||
|
||||
/* Internal name for debugging. */
|
||||
const char *name;
|
||||
|
||||
/* Validator method. */
|
||||
int (*is_valid) (const struct floatformat *fmt, const void *from);
|
||||
|
||||
/* Is the format actually the sum of two smaller floating point
|
||||
formats (IBM long double, as described in
|
||||
gcc/config/rs6000/darwin-ldouble-format)? If so, this is the
|
||||
smaller format in question, and the fields sign_start through
|
||||
intbit describe the first half. If not, this is NULL. */
|
||||
const struct floatformat *split_half;
|
||||
};
|
||||
|
||||
/* floatformats for IEEE single and double, big and little endian. */
|
||||
|
||||
extern const struct floatformat floatformat_ieee_half_big;
|
||||
extern const struct floatformat floatformat_ieee_half_little;
|
||||
extern const struct floatformat floatformat_ieee_single_big;
|
||||
extern const struct floatformat floatformat_ieee_single_little;
|
||||
extern const struct floatformat floatformat_ieee_double_big;
|
||||
extern const struct floatformat floatformat_ieee_double_little;
|
||||
|
||||
/* floatformat for ARM IEEE double, little endian bytes and big endian words */
|
||||
|
||||
extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
|
||||
|
||||
/* floatformats for VAX. */
|
||||
|
||||
extern const struct floatformat floatformat_vax_f;
|
||||
extern const struct floatformat floatformat_vax_d;
|
||||
extern const struct floatformat floatformat_vax_g;
|
||||
|
||||
/* floatformats for various extendeds. */
|
||||
|
||||
extern const struct floatformat floatformat_i387_ext;
|
||||
extern const struct floatformat floatformat_m68881_ext;
|
||||
extern const struct floatformat floatformat_i960_ext;
|
||||
extern const struct floatformat floatformat_m88110_ext;
|
||||
extern const struct floatformat floatformat_m88110_harris_ext;
|
||||
extern const struct floatformat floatformat_arm_ext_big;
|
||||
extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
|
||||
/* IA-64 Floating Point register spilt into memory. */
|
||||
extern const struct floatformat floatformat_ia64_spill_big;
|
||||
extern const struct floatformat floatformat_ia64_spill_little;
|
||||
extern const struct floatformat floatformat_ia64_quad_big;
|
||||
extern const struct floatformat floatformat_ia64_quad_little;
|
||||
/* IBM long double (double+double). */
|
||||
extern const struct floatformat floatformat_ibm_long_double_big;
|
||||
extern const struct floatformat floatformat_ibm_long_double_little;
|
||||
|
||||
/* Convert from FMT to a double.
|
||||
FROM is the address of the extended float.
|
||||
Store the double in *TO. */
|
||||
|
||||
extern void
|
||||
floatformat_to_double (const struct floatformat *, const void *, double *);
|
||||
|
||||
/* The converse: convert the double *FROM to FMT
|
||||
and store where TO points. */
|
||||
|
||||
extern void
|
||||
floatformat_from_double (const struct floatformat *, const double *, void *);
|
||||
|
||||
/* Return non-zero iff the data at FROM is a valid number in format FMT. */
|
||||
|
||||
extern int
|
||||
floatformat_is_valid (const struct floatformat *fmt, const void *from);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* defined (FLOATFORMAT_H) */
|
||||
204
arduino/hardware/tools/avr/include/libiberty/hashtab.h
Normal file
204
arduino/hardware/tools/avr/include/libiberty/hashtab.h
Normal file
@@ -0,0 +1,204 @@
|
||||
/* An expandable hash tables datatype.
|
||||
Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
||||
Contributed by Vladimir Makarov (vmakarov@cygnus.com).
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* This package implements basic hash table functionality. It is possible
|
||||
to search for an entry, create an entry and destroy an entry.
|
||||
|
||||
Elements in the table are generic pointers.
|
||||
|
||||
The size of the table is not fixed; if the occupancy of the table
|
||||
grows too high the hash table will be expanded.
|
||||
|
||||
The abstract data implementation is based on generalized Algorithm D
|
||||
from Knuth's book "The art of computer programming". Hash table is
|
||||
expanded by creation of new hash table and transferring elements from
|
||||
the old table to the new table. */
|
||||
|
||||
#ifndef __HASHTAB_H__
|
||||
#define __HASHTAB_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* The type for a hash code. */
|
||||
typedef unsigned int hashval_t;
|
||||
|
||||
/* Callback function pointer types. */
|
||||
|
||||
/* Calculate hash of a table entry. */
|
||||
typedef hashval_t (*htab_hash) (const void *);
|
||||
|
||||
/* Compare a table entry with a possible entry. The entry already in
|
||||
the table always comes first, so the second element can be of a
|
||||
different type (but in this case htab_find and htab_find_slot
|
||||
cannot be used; instead the variants that accept a hash value
|
||||
must be used). */
|
||||
typedef int (*htab_eq) (const void *, const void *);
|
||||
|
||||
/* Cleanup function called whenever a live element is removed from
|
||||
the hash table. */
|
||||
typedef void (*htab_del) (void *);
|
||||
|
||||
/* Function called by htab_traverse for each live element. The first
|
||||
arg is the slot of the element (which can be passed to htab_clear_slot
|
||||
if desired), the second arg is the auxiliary pointer handed to
|
||||
htab_traverse. Return 1 to continue scan, 0 to stop. */
|
||||
typedef int (*htab_trav) (void **, void *);
|
||||
|
||||
/* Memory-allocation function, with the same functionality as calloc().
|
||||
Iff it returns NULL, the hash table implementation will pass an error
|
||||
code back to the user, so if your code doesn't handle errors,
|
||||
best if you use xcalloc instead. */
|
||||
typedef void *(*htab_alloc) (size_t, size_t);
|
||||
|
||||
/* We also need a free() routine. */
|
||||
typedef void (*htab_free) (void *);
|
||||
|
||||
/* Memory allocation and deallocation; variants which take an extra
|
||||
argument. */
|
||||
typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t);
|
||||
typedef void (*htab_free_with_arg) (void *, void *);
|
||||
|
||||
/* This macro defines reserved value for empty table entry. */
|
||||
|
||||
#define HTAB_EMPTY_ENTRY ((PTR) 0)
|
||||
|
||||
/* This macro defines reserved value for table entry which contained
|
||||
a deleted element. */
|
||||
|
||||
#define HTAB_DELETED_ENTRY ((PTR) 1)
|
||||
|
||||
/* Hash tables are of the following type. The structure
|
||||
(implementation) of this type is not needed for using the hash
|
||||
tables. All work with hash table should be executed only through
|
||||
functions mentioned below. The size of this structure is subject to
|
||||
change. */
|
||||
|
||||
struct htab {
|
||||
/* Pointer to hash function. */
|
||||
htab_hash hash_f;
|
||||
|
||||
/* Pointer to comparison function. */
|
||||
htab_eq eq_f;
|
||||
|
||||
/* Pointer to cleanup function. */
|
||||
htab_del del_f;
|
||||
|
||||
/* Table itself. */
|
||||
void **entries;
|
||||
|
||||
/* Current size (in entries) of the hash table. */
|
||||
size_t size;
|
||||
|
||||
/* Current number of elements including also deleted elements. */
|
||||
size_t n_elements;
|
||||
|
||||
/* Current number of deleted elements in the table. */
|
||||
size_t n_deleted;
|
||||
|
||||
/* The following member is used for debugging. Its value is number
|
||||
of all calls of `htab_find_slot' for the hash table. */
|
||||
unsigned int searches;
|
||||
|
||||
/* The following member is used for debugging. Its value is number
|
||||
of collisions fixed for time of work with the hash table. */
|
||||
unsigned int collisions;
|
||||
|
||||
/* Pointers to allocate/free functions. */
|
||||
htab_alloc alloc_f;
|
||||
htab_free free_f;
|
||||
|
||||
/* Alternate allocate/free functions, which take an extra argument. */
|
||||
void *alloc_arg;
|
||||
htab_alloc_with_arg alloc_with_arg_f;
|
||||
htab_free_with_arg free_with_arg_f;
|
||||
|
||||
/* Current size (in entries) of the hash table, as an index into the
|
||||
table of primes. */
|
||||
unsigned int size_prime_index;
|
||||
};
|
||||
|
||||
typedef struct htab *htab_t;
|
||||
|
||||
/* An enum saying whether we insert into the hash table or not. */
|
||||
enum insert_option {NO_INSERT, INSERT};
|
||||
|
||||
/* The prototypes of the package functions. */
|
||||
|
||||
extern htab_t htab_create_alloc (size_t, htab_hash,
|
||||
htab_eq, htab_del,
|
||||
htab_alloc, htab_free);
|
||||
|
||||
extern htab_t htab_create_alloc_ex (size_t, htab_hash,
|
||||
htab_eq, htab_del,
|
||||
void *, htab_alloc_with_arg,
|
||||
htab_free_with_arg);
|
||||
|
||||
extern htab_t htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del,
|
||||
htab_alloc, htab_alloc, htab_free);
|
||||
|
||||
/* Backward-compatibility functions. */
|
||||
extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del);
|
||||
extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del);
|
||||
|
||||
extern void htab_set_functions_ex (htab_t, htab_hash,
|
||||
htab_eq, htab_del,
|
||||
void *, htab_alloc_with_arg,
|
||||
htab_free_with_arg);
|
||||
|
||||
extern void htab_delete (htab_t);
|
||||
extern void htab_empty (htab_t);
|
||||
|
||||
extern void * htab_find (htab_t, const void *);
|
||||
extern void ** htab_find_slot (htab_t, const void *, enum insert_option);
|
||||
extern void * htab_find_with_hash (htab_t, const void *, hashval_t);
|
||||
extern void ** htab_find_slot_with_hash (htab_t, const void *,
|
||||
hashval_t, enum insert_option);
|
||||
extern void htab_clear_slot (htab_t, void **);
|
||||
extern void htab_remove_elt (htab_t, void *);
|
||||
extern void htab_remove_elt_with_hash (htab_t, void *, hashval_t);
|
||||
|
||||
extern void htab_traverse (htab_t, htab_trav, void *);
|
||||
extern void htab_traverse_noresize (htab_t, htab_trav, void *);
|
||||
|
||||
extern size_t htab_size (htab_t);
|
||||
extern size_t htab_elements (htab_t);
|
||||
extern double htab_collisions (htab_t);
|
||||
|
||||
/* A hash function for pointers. */
|
||||
extern htab_hash htab_hash_pointer;
|
||||
|
||||
/* An equality function for pointers. */
|
||||
extern htab_eq htab_eq_pointer;
|
||||
|
||||
/* A hash function for null-terminated strings. */
|
||||
extern hashval_t htab_hash_string (const void *);
|
||||
|
||||
/* An iterative hash function for arbitrary data. */
|
||||
extern hashval_t iterative_hash (const void *, size_t, hashval_t);
|
||||
/* Shorthand for hashing something with an intrinsic size. */
|
||||
#define iterative_hash_object(OB,INIT) iterative_hash (&OB, sizeof (OB), INIT)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __HASHTAB_H */
|
||||
739
arduino/hardware/tools/avr/include/libiberty/libiberty.h
Normal file
739
arduino/hardware/tools/avr/include/libiberty/libiberty.h
Normal file
@@ -0,0 +1,739 @@
|
||||
/* Function declarations for libiberty.
|
||||
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
|
||||
Note - certain prototypes declared in this header file are for
|
||||
functions whoes implementation copyright does not belong to the
|
||||
FSF. Those prototypes are present in this file for reference
|
||||
purposes only and their presence in this file should not construed
|
||||
as an indication of ownership by the FSF of the implementation of
|
||||
those functions in any way or form whatsoever.
|
||||
|
||||
This program 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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
Written by Cygnus Support, 1994.
|
||||
|
||||
The libiberty library provides a number of functions which are
|
||||
missing on some operating systems. We do not declare those here,
|
||||
to avoid conflicts with the system header files on operating
|
||||
systems that do support those functions. In this file we only
|
||||
declare those functions which are specific to libiberty. */
|
||||
|
||||
#ifndef LIBIBERTY_H
|
||||
#define LIBIBERTY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* Get a definition for size_t. */
|
||||
#include <stddef.h>
|
||||
/* Get a definition for va_list. */
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* If the OS supports it, ensure that the supplied stream is setup to
|
||||
avoid any multi-threaded locking. Otherwise leave the FILE pointer
|
||||
unchanged. If the stream is NULL do nothing. */
|
||||
|
||||
extern void unlock_stream (FILE *);
|
||||
|
||||
/* If the OS supports it, ensure that the standard I/O streams, stdin,
|
||||
stdout and stderr are setup to avoid any multi-threaded locking.
|
||||
Otherwise do nothing. */
|
||||
|
||||
extern void unlock_std_streams (void);
|
||||
|
||||
/* Open and return a FILE pointer. If the OS supports it, ensure that
|
||||
the stream is setup to avoid any multi-threaded locking. Otherwise
|
||||
return the FILE pointer unchanged. */
|
||||
|
||||
extern FILE *fopen_unlocked (const char *, const char *);
|
||||
extern FILE *fdopen_unlocked (int, const char *);
|
||||
extern FILE *freopen_unlocked (const char *, const char *, FILE *);
|
||||
|
||||
/* Build an argument vector from a string. Allocates memory using
|
||||
malloc. Use freeargv to free the vector. */
|
||||
|
||||
extern char **buildargv (const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Free a vector returned by buildargv. */
|
||||
|
||||
extern void freeargv (char **);
|
||||
|
||||
/* Duplicate an argument vector. Allocates memory using malloc. Use
|
||||
freeargv to free the vector. */
|
||||
|
||||
extern char **dupargv (char **) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Expand "@file" arguments in argv. */
|
||||
|
||||
extern void expandargv (int *, char ***);
|
||||
|
||||
/* Write argv to an @-file, inserting necessary quoting. */
|
||||
|
||||
extern int writeargv (char **, FILE *);
|
||||
|
||||
/* Return the number of elements in argv. */
|
||||
|
||||
extern int countargv (char**);
|
||||
|
||||
/* Return the last component of a path name. Note that we can't use a
|
||||
prototype here because the parameter is declared inconsistently
|
||||
across different systems, sometimes as "char *" and sometimes as
|
||||
"const char *" */
|
||||
|
||||
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
|
||||
undefined, we haven't run the autoconf check so provide the
|
||||
declaration without arguments. If it is 0, we checked and failed
|
||||
to find the declaration so provide a fully prototyped one. If it
|
||||
is 1, we found it so don't provide any declaration at all. */
|
||||
#if !HAVE_DECL_BASENAME
|
||||
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) \
|
||||
|| defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \
|
||||
|| defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \
|
||||
|| defined (__DragonFly__) || defined (HAVE_DECL_BASENAME)
|
||||
extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
#else
|
||||
/* Do not allow basename to be used if there is no prototype seen. We
|
||||
either need to use the above prototype or have one from
|
||||
autoconf which would result in HAVE_DECL_BASENAME being set. */
|
||||
#define basename basename_cannot_be_used_without_a_prototype
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* A well-defined basename () that is always compiled in. */
|
||||
|
||||
extern const char *lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* Same, but assumes DOS semantics (drive name, backslash is also a
|
||||
dir separator) regardless of host. */
|
||||
|
||||
extern const char *dos_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* Same, but assumes Unix semantics (absolute paths always start with
|
||||
a slash, only forward slash is accepted as dir separator)
|
||||
regardless of host. */
|
||||
|
||||
extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* A well-defined realpath () that is always compiled in. */
|
||||
|
||||
extern char *lrealpath (const char *);
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using xmalloc. */
|
||||
|
||||
extern char *concat (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using xmalloc. The first argument is
|
||||
not one of the strings to be concatenated, but if not NULL is a
|
||||
pointer to be freed after the new string is created, similar to the
|
||||
way xrealloc works. */
|
||||
|
||||
extern char *reconcat (char *, const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Determine the length of concatenating an arbitrary number of
|
||||
strings. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. */
|
||||
|
||||
extern unsigned long concat_length (const char *, ...) ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings into a SUPPLIED area of
|
||||
memory. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. The supplied memory is assumed
|
||||
to be large enough. */
|
||||
|
||||
extern char *concat_copy (char *, const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings into a GLOBAL area of
|
||||
memory. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. The supplied memory is assumed
|
||||
to be large enough. */
|
||||
|
||||
extern char *concat_copy2 (const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* This is the global area used by concat_copy2. */
|
||||
|
||||
extern char *libiberty_concat_ptr;
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using alloca. The arguments are
|
||||
evaluated twice! */
|
||||
#define ACONCAT(ACONCAT_PARAMS) \
|
||||
(libiberty_concat_ptr = (char *) alloca (concat_length ACONCAT_PARAMS + 1), \
|
||||
concat_copy2 ACONCAT_PARAMS)
|
||||
|
||||
/* Check whether two file descriptors refer to the same file. */
|
||||
|
||||
extern int fdmatch (int fd1, int fd2);
|
||||
|
||||
/* Return the position of the first bit set in the argument. */
|
||||
/* Prototypes vary from system to system, so we only provide a
|
||||
prototype on systems where we know that we need it. */
|
||||
#if defined (HAVE_DECL_FFS) && !HAVE_DECL_FFS
|
||||
extern int ffs(int);
|
||||
#endif
|
||||
|
||||
/* Get the working directory. The result is cached, so don't call
|
||||
chdir() between calls to getpwd(). */
|
||||
|
||||
extern char * getpwd (void);
|
||||
|
||||
/* Get the current time. */
|
||||
/* Prototypes vary from system to system, so we only provide a
|
||||
prototype on systems where we know that we need it. */
|
||||
#ifdef __MINGW32__
|
||||
/* Forward declaration to avoid #include <sys/time.h>. */
|
||||
struct timeval;
|
||||
extern int gettimeofday (struct timeval *, void *);
|
||||
#endif
|
||||
|
||||
/* Get the amount of time the process has run, in microseconds. */
|
||||
|
||||
extern long get_run_time (void);
|
||||
|
||||
/* Generate a relocated path to some installation directory. Allocates
|
||||
return value using malloc. */
|
||||
|
||||
extern char *make_relative_prefix (const char *, const char *,
|
||||
const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Generate a relocated path to some installation directory without
|
||||
attempting to follow any soft links. Allocates
|
||||
return value using malloc. */
|
||||
|
||||
extern char *make_relative_prefix_ignore_links (const char *, const char *,
|
||||
const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Returns a pointer to a directory path suitable for creating temporary
|
||||
files in. */
|
||||
|
||||
extern const char *choose_tmpdir (void) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Choose a temporary directory to use for scratch files. */
|
||||
|
||||
extern char *choose_temp_base (void) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Return a temporary file name or NULL if unable to create one. */
|
||||
|
||||
extern char *make_temp_file (const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Remove a link to a file unless it is special. */
|
||||
|
||||
extern int unlink_if_ordinary (const char *);
|
||||
|
||||
/* Allocate memory filled with spaces. Allocates using malloc. */
|
||||
|
||||
extern const char *spaces (int count);
|
||||
|
||||
/* Return the maximum error number for which strerror will return a
|
||||
string. */
|
||||
|
||||
extern int errno_max (void);
|
||||
|
||||
/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
|
||||
"EINVAL"). */
|
||||
|
||||
extern const char *strerrno (int);
|
||||
|
||||
/* Given the name of an errno value, return the value. */
|
||||
|
||||
extern int strtoerrno (const char *);
|
||||
|
||||
/* ANSI's strerror(), but more robust. */
|
||||
|
||||
extern char *xstrerror (int) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Return the maximum signal number for which strsignal will return a
|
||||
string. */
|
||||
|
||||
extern int signo_max (void);
|
||||
|
||||
/* Return a signal message string for a signal number
|
||||
(e.g., strsignal (SIGHUP) returns something like "Hangup"). */
|
||||
/* This is commented out as it can conflict with one in system headers.
|
||||
We still document its existence though. */
|
||||
|
||||
/*extern const char *strsignal (int);*/
|
||||
|
||||
/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
|
||||
"SIGHUP"). */
|
||||
|
||||
extern const char *strsigno (int);
|
||||
|
||||
/* Given the name of a signal, return its number. */
|
||||
|
||||
extern int strtosigno (const char *);
|
||||
|
||||
/* Register a function to be run by xexit. Returns 0 on success. */
|
||||
|
||||
extern int xatexit (void (*fn) (void));
|
||||
|
||||
/* Exit, calling all the functions registered with xatexit. */
|
||||
|
||||
extern void xexit (int status) ATTRIBUTE_NORETURN;
|
||||
|
||||
/* Set the program name used by xmalloc. */
|
||||
|
||||
extern void xmalloc_set_program_name (const char *);
|
||||
|
||||
/* Report an allocation failure. */
|
||||
extern void xmalloc_failed (size_t) ATTRIBUTE_NORETURN;
|
||||
|
||||
/* Allocate memory without fail. If malloc fails, this will print a
|
||||
message to stderr (using the name set by xmalloc_set_program_name,
|
||||
if any) and then call xexit. */
|
||||
|
||||
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Reallocate memory without fail. This works like xmalloc. Note,
|
||||
realloc type functions are not suitable for attribute malloc since
|
||||
they may return the same address across multiple calls. */
|
||||
|
||||
extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Allocate memory without fail and set it to zero. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Copy a string into a memory buffer without fail. */
|
||||
|
||||
extern char *xstrdup (const char *) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Copy at most N characters from string into a buffer without fail. */
|
||||
|
||||
extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Copy an existing memory buffer to a new memory buffer without fail. */
|
||||
|
||||
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Physical memory routines. Return values are in BYTES. */
|
||||
extern double physmem_total (void);
|
||||
extern double physmem_available (void);
|
||||
|
||||
/* Compute the 32-bit CRC of a block of memory. */
|
||||
extern unsigned int xcrc32 (const unsigned char *, int, unsigned int);
|
||||
|
||||
/* These macros provide a K&R/C89/C++-friendly way of allocating structures
|
||||
with nice encapsulation. The XDELETE*() macros are technically
|
||||
superfluous, but provided here for symmetry. Using them consistently
|
||||
makes it easier to update client code to use different allocators such
|
||||
as new/delete and new[]/delete[]. */
|
||||
|
||||
/* Scalar allocators. */
|
||||
|
||||
#define XALLOCA(T) ((T *) alloca (sizeof (T)))
|
||||
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
|
||||
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
|
||||
#define XDUP(T, P) ((T *) xmemdup ((P), sizeof (T), sizeof (T)))
|
||||
#define XDELETE(P) free ((void*) (P))
|
||||
|
||||
/* Array allocators. */
|
||||
|
||||
#define XALLOCAVEC(T, N) ((T *) alloca (sizeof (T) * (N)))
|
||||
#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N)))
|
||||
#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T)))
|
||||
#define XDUPVEC(T, P, N) ((T *) xmemdup ((P), sizeof (T) * (N), sizeof (T) * (N)))
|
||||
#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))
|
||||
#define XDELETEVEC(P) free ((void*) (P))
|
||||
|
||||
/* Allocators for variable-sized structures and raw buffers. */
|
||||
|
||||
#define XALLOCAVAR(T, S) ((T *) alloca ((S)))
|
||||
#define XNEWVAR(T, S) ((T *) xmalloc ((S)))
|
||||
#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S)))
|
||||
#define XDUPVAR(T, P, S1, S2) ((T *) xmemdup ((P), (S1), (S2)))
|
||||
#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S)))
|
||||
|
||||
/* Type-safe obstack allocator. */
|
||||
|
||||
#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T)))
|
||||
#define XOBNEWVEC(O, T, N) ((T *) obstack_alloc ((O), sizeof (T) * (N)))
|
||||
#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
|
||||
#define XOBFINISH(O, T) ((T) obstack_finish ((O)))
|
||||
|
||||
/* hex character manipulation routines */
|
||||
|
||||
#define _hex_array_size 256
|
||||
#define _hex_bad 99
|
||||
extern const unsigned char _hex_value[_hex_array_size];
|
||||
extern void hex_init (void);
|
||||
#define hex_p(c) (hex_value (c) != _hex_bad)
|
||||
/* If you change this, note well: Some code relies on side effects in
|
||||
the argument being performed exactly once. */
|
||||
#define hex_value(c) ((unsigned int) _hex_value[(unsigned char) (c)])
|
||||
|
||||
/* Flags for pex_init. These are bits to be or'ed together. */
|
||||
|
||||
/* Record subprocess times, if possible. */
|
||||
#define PEX_RECORD_TIMES 0x1
|
||||
|
||||
/* Use pipes for communication between processes, if possible. */
|
||||
#define PEX_USE_PIPES 0x2
|
||||
|
||||
/* Save files used for communication between processes. */
|
||||
#define PEX_SAVE_TEMPS 0x4
|
||||
|
||||
/* Prepare to execute one or more programs, with standard output of
|
||||
each program fed to standard input of the next.
|
||||
FLAGS As above.
|
||||
PNAME The name of the program to report in error messages.
|
||||
TEMPBASE A base name to use for temporary files; may be NULL to
|
||||
use a random name.
|
||||
Returns NULL on error. */
|
||||
|
||||
extern struct pex_obj *pex_init (int flags, const char *pname,
|
||||
const char *tempbase) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Flags for pex_run. These are bits to be or'ed together. */
|
||||
|
||||
/* Last program in pipeline. Standard output of program goes to
|
||||
OUTNAME, or, if OUTNAME is NULL, to standard output of caller. Do
|
||||
not set this if you want to call pex_read_output. After this is
|
||||
set, pex_run may no longer be called with the same struct
|
||||
pex_obj. */
|
||||
#define PEX_LAST 0x1
|
||||
|
||||
/* Search for program in executable search path. */
|
||||
#define PEX_SEARCH 0x2
|
||||
|
||||
/* OUTNAME is a suffix. */
|
||||
#define PEX_SUFFIX 0x4
|
||||
|
||||
/* Send program's standard error to standard output. */
|
||||
#define PEX_STDERR_TO_STDOUT 0x8
|
||||
|
||||
/* Input file should be opened in binary mode. This flag is ignored
|
||||
on Unix. */
|
||||
#define PEX_BINARY_INPUT 0x10
|
||||
|
||||
/* Output file should be opened in binary mode. This flag is ignored
|
||||
on Unix. For proper behaviour PEX_BINARY_INPUT and
|
||||
PEX_BINARY_OUTPUT have to match appropriately--i.e., a call using
|
||||
PEX_BINARY_OUTPUT should be followed by a call using
|
||||
PEX_BINARY_INPUT. */
|
||||
#define PEX_BINARY_OUTPUT 0x20
|
||||
|
||||
/* Capture stderr to a pipe. The output can be read by
|
||||
calling pex_read_err and reading from the returned
|
||||
FILE object. This flag may be specified only for
|
||||
the last program in a pipeline.
|
||||
|
||||
This flag is supported only on Unix and Windows. */
|
||||
#define PEX_STDERR_TO_PIPE 0x40
|
||||
|
||||
/* Capture stderr in binary mode. This flag is ignored
|
||||
on Unix. */
|
||||
#define PEX_BINARY_ERROR 0x80
|
||||
|
||||
/* Append stdout to existing file instead of truncating it. */
|
||||
#define PEX_STDOUT_APPEND 0x100
|
||||
|
||||
/* Thes same as PEX_STDOUT_APPEND, but for STDERR. */
|
||||
#define PEX_STDERR_APPEND 0x200
|
||||
|
||||
/* Execute one program. Returns NULL on success. On error returns an
|
||||
error string (typically just the name of a system call); the error
|
||||
string is statically allocated.
|
||||
|
||||
OBJ Returned by pex_init.
|
||||
|
||||
FLAGS As above.
|
||||
|
||||
EXECUTABLE The program to execute.
|
||||
|
||||
ARGV NULL terminated array of arguments to pass to the program.
|
||||
|
||||
OUTNAME Sets the output file name as follows:
|
||||
|
||||
PEX_SUFFIX set (OUTNAME may not be NULL):
|
||||
TEMPBASE parameter to pex_init not NULL:
|
||||
Output file name is the concatenation of TEMPBASE
|
||||
and OUTNAME.
|
||||
TEMPBASE is NULL:
|
||||
Output file name is a random file name ending in
|
||||
OUTNAME.
|
||||
PEX_SUFFIX not set:
|
||||
OUTNAME not NULL:
|
||||
Output file name is OUTNAME.
|
||||
OUTNAME NULL, TEMPBASE not NULL:
|
||||
Output file name is randomly chosen using
|
||||
TEMPBASE.
|
||||
OUTNAME NULL, TEMPBASE NULL:
|
||||
Output file name is randomly chosen.
|
||||
|
||||
If PEX_LAST is not set, the output file name is the
|
||||
name to use for a temporary file holding stdout, if
|
||||
any (there will not be a file if PEX_USE_PIPES is set
|
||||
and the system supports pipes). If a file is used, it
|
||||
will be removed when no longer needed unless
|
||||
PEX_SAVE_TEMPS is set.
|
||||
|
||||
If PEX_LAST is set, and OUTNAME is not NULL, standard
|
||||
output is written to the output file name. The file
|
||||
will not be removed. If PEX_LAST and PEX_SUFFIX are
|
||||
both set, TEMPBASE may not be NULL.
|
||||
|
||||
ERRNAME If not NULL, this is the name of a file to which
|
||||
standard error is written. If NULL, standard error of
|
||||
the program is standard error of the caller.
|
||||
|
||||
ERR On an error return, *ERR is set to an errno value, or
|
||||
to 0 if there is no relevant errno.
|
||||
*/
|
||||
|
||||
extern const char *pex_run (struct pex_obj *obj, int flags,
|
||||
const char *executable, char * const *argv,
|
||||
const char *outname, const char *errname,
|
||||
int *err);
|
||||
|
||||
/* As for pex_run (), but takes an extra parameter to enable the
|
||||
environment for the child process to be specified.
|
||||
|
||||
ENV The environment for the child process, specified as
|
||||
an array of character pointers. Each element of the
|
||||
array should point to a string of the form VAR=VALUE,
|
||||
with the exception of the last element which must be
|
||||
a null pointer.
|
||||
*/
|
||||
|
||||
extern const char *pex_run_in_environment (struct pex_obj *obj, int flags,
|
||||
const char *executable,
|
||||
char * const *argv,
|
||||
char * const *env,
|
||||
const char *outname,
|
||||
const char *errname, int *err);
|
||||
|
||||
/* Return a stream for a temporary file to pass to the first program
|
||||
in the pipeline as input. The file name is chosen as for pex_run.
|
||||
pex_run closes the file automatically; don't close it yourself. */
|
||||
|
||||
extern FILE *pex_input_file (struct pex_obj *obj, int flags,
|
||||
const char *in_name);
|
||||
|
||||
/* Return a stream for a pipe connected to the standard input of the
|
||||
first program in the pipeline. You must have passed
|
||||
`PEX_USE_PIPES' to `pex_init'. Close the returned stream
|
||||
yourself. */
|
||||
|
||||
extern FILE *pex_input_pipe (struct pex_obj *obj, int binary);
|
||||
|
||||
/* Read the standard output of the last program to be executed.
|
||||
pex_run can not be called after this. BINARY should be non-zero if
|
||||
the file should be opened in binary mode; this is ignored on Unix.
|
||||
Returns NULL on error. Don't call fclose on the returned FILE; it
|
||||
will be closed by pex_free. */
|
||||
|
||||
extern FILE *pex_read_output (struct pex_obj *, int binary);
|
||||
|
||||
/* Read the standard error of the last program to be executed.
|
||||
pex_run can not be called after this. BINARY should be non-zero if
|
||||
the file should be opened in binary mode; this is ignored on Unix.
|
||||
Returns NULL on error. Don't call fclose on the returned FILE; it
|
||||
will be closed by pex_free. */
|
||||
|
||||
extern FILE *pex_read_err (struct pex_obj *, int binary);
|
||||
|
||||
/* Return exit status of all programs in VECTOR. COUNT indicates the
|
||||
size of VECTOR. The status codes in the vector are in the order of
|
||||
the calls to pex_run. Returns 0 on error, 1 on success. */
|
||||
|
||||
extern int pex_get_status (struct pex_obj *, int count, int *vector);
|
||||
|
||||
/* Return times of all programs in VECTOR. COUNT indicates the size
|
||||
of VECTOR. struct pex_time is really just struct timeval, but that
|
||||
is not portable to all systems. Returns 0 on error, 1 on
|
||||
success. */
|
||||
|
||||
struct pex_time
|
||||
{
|
||||
unsigned long user_seconds;
|
||||
unsigned long user_microseconds;
|
||||
unsigned long system_seconds;
|
||||
unsigned long system_microseconds;
|
||||
};
|
||||
|
||||
extern int pex_get_times (struct pex_obj *, int count,
|
||||
struct pex_time *vector);
|
||||
|
||||
/* Clean up a pex_obj. If you have not called pex_get_times or
|
||||
pex_get_status, this will try to kill the subprocesses. */
|
||||
|
||||
extern void pex_free (struct pex_obj *);
|
||||
|
||||
/* Just execute one program. Return value is as for pex_run.
|
||||
FLAGS Combination of PEX_SEARCH and PEX_STDERR_TO_STDOUT.
|
||||
EXECUTABLE As for pex_run.
|
||||
ARGV As for pex_run.
|
||||
PNAME As for pex_init.
|
||||
OUTNAME As for pex_run when PEX_LAST is set.
|
||||
ERRNAME As for pex_run.
|
||||
STATUS Set to exit status on success.
|
||||
ERR As for pex_run.
|
||||
*/
|
||||
|
||||
extern const char *pex_one (int flags, const char *executable,
|
||||
char * const *argv, const char *pname,
|
||||
const char *outname, const char *errname,
|
||||
int *status, int *err);
|
||||
|
||||
/* pexecute and pwait are the old pexecute interface, still here for
|
||||
backward compatibility. Don't use these for new code. Instead,
|
||||
use pex_init/pex_run/pex_get_status/pex_free, or pex_one. */
|
||||
|
||||
/* Definitions used by the pexecute routine. */
|
||||
|
||||
#define PEXECUTE_FIRST 1
|
||||
#define PEXECUTE_LAST 2
|
||||
#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
|
||||
#define PEXECUTE_SEARCH 4
|
||||
#define PEXECUTE_VERBOSE 8
|
||||
|
||||
/* Execute a program. */
|
||||
|
||||
extern int pexecute (const char *, char * const *, const char *,
|
||||
const char *, char **, char **, int);
|
||||
|
||||
/* Wait for pexecute to finish. */
|
||||
|
||||
extern int pwait (int, int *, int);
|
||||
|
||||
#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
|
||||
/* Like sprintf but provides a pointer to malloc'd storage, which must
|
||||
be freed by the caller. */
|
||||
|
||||
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
|
||||
#endif
|
||||
|
||||
/* Like asprintf but allocates memory without fail. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
|
||||
|
||||
#if !HAVE_DECL_VASPRINTF
|
||||
/* Like vsprintf but provides a pointer to malloc'd storage, which
|
||||
must be freed by the caller. */
|
||||
|
||||
extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
|
||||
#endif
|
||||
|
||||
/* Like vasprintf but allocates memory without fail. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern char *xvasprintf (const char *, va_list) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF(1,0);
|
||||
|
||||
#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
|
||||
/* Like sprintf but prints at most N characters. */
|
||||
extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
|
||||
/* Like vsprintf but prints at most N characters. */
|
||||
extern int vsnprintf (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_DECL_STRNLEN) && !HAVE_DECL_STRNLEN
|
||||
extern size_t strnlen (const char *, size_t);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
|
||||
/* Compare version strings. */
|
||||
extern int strverscmp (const char *, const char *);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
|
||||
extern long int strtol (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
|
||||
extern unsigned long int strtoul (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOLL
|
||||
__extension__
|
||||
extern long long int strtoll (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOULL
|
||||
__extension__
|
||||
extern unsigned long long int strtoull (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
|
||||
/* Compare version strings. */
|
||||
extern int strverscmp (const char *, const char *);
|
||||
#endif
|
||||
|
||||
/* Set the title of a process */
|
||||
extern void setproctitle (const char *name, ...);
|
||||
|
||||
/* Increase stack limit if possible. */
|
||||
extern void stack_limit_increase (unsigned long);
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
/* Drastically simplified alloca configurator. If we're using GCC,
|
||||
we use __builtin_alloca; otherwise we use the C alloca. The C
|
||||
alloca is always available. You can override GCC by defining
|
||||
USE_C_ALLOCA yourself. The canonical autoconf macro C_ALLOCA is
|
||||
also set/unset as it is often used to indicate whether code needs
|
||||
to call alloca(0). */
|
||||
extern void *C_alloca (size_t) ATTRIBUTE_MALLOC;
|
||||
#undef alloca
|
||||
#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
|
||||
# define alloca(x) __builtin_alloca(x)
|
||||
# undef C_ALLOCA
|
||||
# define ASTRDUP(X) \
|
||||
(__extension__ ({ const char *const libiberty_optr = (X); \
|
||||
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
|
||||
char *const libiberty_nptr = (char *const) alloca (libiberty_len); \
|
||||
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
|
||||
#else
|
||||
# define alloca(x) C_alloca(x)
|
||||
# undef USE_C_ALLOCA
|
||||
# define USE_C_ALLOCA 1
|
||||
# undef C_ALLOCA
|
||||
# define C_ALLOCA 1
|
||||
extern const char *libiberty_optr;
|
||||
extern char *libiberty_nptr;
|
||||
extern unsigned long libiberty_len;
|
||||
# define ASTRDUP(X) \
|
||||
(libiberty_optr = (X), \
|
||||
libiberty_len = strlen (libiberty_optr) + 1, \
|
||||
libiberty_nptr = (char *) alloca (libiberty_len), \
|
||||
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! defined (LIBIBERTY_H) */
|
||||
115
arduino/hardware/tools/avr/include/libiberty/objalloc.h
Normal file
115
arduino/hardware/tools/avr/include/libiberty/objalloc.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/* objalloc.h -- routines to allocate memory for objects
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Cygnus Solutions.
|
||||
|
||||
This program 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 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef OBJALLOC_H
|
||||
#define OBJALLOC_H
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* These routines allocate space for an object. The assumption is
|
||||
that the object will want to allocate space as it goes along, but
|
||||
will never want to free any particular block. There is a function
|
||||
to free a block, which also frees all more recently allocated
|
||||
blocks. There is also a function to free all the allocated space.
|
||||
|
||||
This is essentially a specialization of obstacks. The main
|
||||
difference is that a block may not be allocated a bit at a time.
|
||||
Another difference is that these routines are always built on top
|
||||
of malloc, and always pass an malloc failure back to the caller,
|
||||
unlike more recent versions of obstacks. */
|
||||
|
||||
/* This is what an objalloc structure looks like. Callers should not
|
||||
refer to these fields, nor should they allocate these structure
|
||||
themselves. Instead, they should only create them via
|
||||
objalloc_init, and only access them via the functions and macros
|
||||
listed below. The structure is only defined here so that we can
|
||||
access it via macros. */
|
||||
|
||||
struct objalloc
|
||||
{
|
||||
char *current_ptr;
|
||||
unsigned int current_space;
|
||||
void *chunks;
|
||||
};
|
||||
|
||||
/* Work out the required alignment. */
|
||||
|
||||
struct objalloc_align { char x; double d; };
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#ifndef offsetof
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
#define OBJALLOC_ALIGN offsetof (struct objalloc_align, d)
|
||||
|
||||
/* Create an objalloc structure. Returns NULL if malloc fails. */
|
||||
|
||||
extern struct objalloc *objalloc_create (void);
|
||||
|
||||
/* Allocate space from an objalloc structure. Returns NULL if malloc
|
||||
fails. */
|
||||
|
||||
extern void *_objalloc_alloc (struct objalloc *, unsigned long);
|
||||
|
||||
/* The macro version of objalloc_alloc. We only define this if using
|
||||
gcc, because otherwise we would have to evaluate the arguments
|
||||
multiple times, or use a temporary field as obstack.h does. */
|
||||
|
||||
#if defined (__GNUC__) && defined (__STDC__) && __STDC__
|
||||
|
||||
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
|
||||
does not implement __extension__. But that compiler doesn't define
|
||||
__GNUC_MINOR__. */
|
||||
#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
|
||||
#define __extension__
|
||||
#endif
|
||||
|
||||
#define objalloc_alloc(o, l) \
|
||||
__extension__ \
|
||||
({ struct objalloc *__o = (o); \
|
||||
unsigned long __len = (l); \
|
||||
if (__len == 0) \
|
||||
__len = 1; \
|
||||
__len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); \
|
||||
(__len != 0 && __len <= __o->current_space \
|
||||
? (__o->current_ptr += __len, \
|
||||
__o->current_space -= __len, \
|
||||
(void *) (__o->current_ptr - __len)) \
|
||||
: _objalloc_alloc (__o, __len)); })
|
||||
|
||||
#else /* ! __GNUC__ */
|
||||
|
||||
#define objalloc_alloc(o, l) _objalloc_alloc ((o), (l))
|
||||
|
||||
#endif /* ! __GNUC__ */
|
||||
|
||||
/* Free an entire objalloc structure. */
|
||||
|
||||
extern void objalloc_free (struct objalloc *);
|
||||
|
||||
/* Free a block allocated by objalloc_alloc. This also frees all more
|
||||
recently allocated blocks. */
|
||||
|
||||
extern void objalloc_free_block (struct objalloc *, void *);
|
||||
|
||||
#endif /* OBJALLOC_H */
|
||||
82
arduino/hardware/tools/avr/include/libiberty/partition.h
Normal file
82
arduino/hardware/tools/avr/include/libiberty/partition.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* List implementation of a partition of consecutive integers.
|
||||
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
Contributed by CodeSourcery, LLC.
|
||||
|
||||
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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* This package implements a partition of consecutive integers. The
|
||||
elements are partitioned into classes. Each class is represented
|
||||
by one of its elements, the canonical element, which is chosen
|
||||
arbitrarily from elements in the class. The principal operations
|
||||
on a partition are FIND, which takes an element, determines its
|
||||
class, and returns the canonical element for that class, and UNION,
|
||||
which unites the two classes that contain two given elements into a
|
||||
single class.
|
||||
|
||||
The list implementation used here provides constant-time finds. By
|
||||
storing the size of each class with the class's canonical element,
|
||||
it is able to perform unions over all the classes in the partition
|
||||
in O (N log N) time. */
|
||||
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include <stdio.h>
|
||||
|
||||
struct partition_elem
|
||||
{
|
||||
/* The next element in this class. Elements in each class form a
|
||||
circular list. */
|
||||
struct partition_elem* next;
|
||||
/* The canonical element that represents the class containing this
|
||||
element. */
|
||||
int class_element;
|
||||
/* The number of elements in this class. Valid only if this is the
|
||||
canonical element for its class. */
|
||||
unsigned class_count;
|
||||
};
|
||||
|
||||
typedef struct partition_def
|
||||
{
|
||||
/* The number of elements in this partition. */
|
||||
int num_elements;
|
||||
/* The elements in the partition. */
|
||||
struct partition_elem elements[1];
|
||||
} *partition;
|
||||
|
||||
extern partition partition_new (int);
|
||||
extern void partition_delete (partition);
|
||||
extern int partition_union (partition, int, int);
|
||||
extern void partition_print (partition, FILE*);
|
||||
|
||||
/* Returns the canonical element corresponding to the class containing
|
||||
ELEMENT__ in PARTITION__. */
|
||||
|
||||
#define partition_find(partition__, element__) \
|
||||
((partition__)->elements[(element__)].class_element)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _PARTITION_H */
|
||||
150
arduino/hardware/tools/avr/include/libiberty/safe-ctype.h
Normal file
150
arduino/hardware/tools/avr/include/libiberty/safe-ctype.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/* <ctype.h> replacement macros.
|
||||
|
||||
Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
Contributed by Zack Weinberg <zackw@stanford.edu>.
|
||||
|
||||
This file is part of the libiberty library.
|
||||
Libiberty is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
Libiberty 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with libiberty; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* This is a compatible replacement of the standard C library's <ctype.h>
|
||||
with the following properties:
|
||||
|
||||
- Implements all isxxx() macros required by C99.
|
||||
- Also implements some character classes useful when
|
||||
parsing C-like languages.
|
||||
- Does not change behavior depending on the current locale.
|
||||
- Behaves properly for all values in the range of a signed or
|
||||
unsigned char.
|
||||
|
||||
To avoid conflicts, this header defines the isxxx functions in upper
|
||||
case, e.g. ISALPHA not isalpha. */
|
||||
|
||||
#ifndef SAFE_CTYPE_H
|
||||
#define SAFE_CTYPE_H
|
||||
|
||||
/* Determine host character set. */
|
||||
#define HOST_CHARSET_UNKNOWN 0
|
||||
#define HOST_CHARSET_ASCII 1
|
||||
#define HOST_CHARSET_EBCDIC 2
|
||||
|
||||
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
|
||||
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
|
||||
# define HOST_CHARSET HOST_CHARSET_ASCII
|
||||
#else
|
||||
# if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
|
||||
&& 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
|
||||
# define HOST_CHARSET HOST_CHARSET_EBCDIC
|
||||
# else
|
||||
# define HOST_CHARSET HOST_CHARSET_UNKNOWN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Categories. */
|
||||
|
||||
enum {
|
||||
/* In C99 */
|
||||
_sch_isblank = 0x0001, /* space \t */
|
||||
_sch_iscntrl = 0x0002, /* nonprinting characters */
|
||||
_sch_isdigit = 0x0004, /* 0-9 */
|
||||
_sch_islower = 0x0008, /* a-z */
|
||||
_sch_isprint = 0x0010, /* any printing character including ' ' */
|
||||
_sch_ispunct = 0x0020, /* all punctuation */
|
||||
_sch_isspace = 0x0040, /* space \t \n \r \f \v */
|
||||
_sch_isupper = 0x0080, /* A-Z */
|
||||
_sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
|
||||
|
||||
/* Extra categories useful to cpplib. */
|
||||
_sch_isidst = 0x0200, /* A-Za-z_ */
|
||||
_sch_isvsp = 0x0400, /* \n \r */
|
||||
_sch_isnvsp = 0x0800, /* space \t \f \v \0 */
|
||||
|
||||
/* Combinations of the above. */
|
||||
_sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
|
||||
_sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
|
||||
_sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
|
||||
_sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
|
||||
_sch_iscppsp = _sch_isvsp|_sch_isnvsp, /* isspace + \0 */
|
||||
_sch_isbasic = _sch_isprint|_sch_iscppsp /* basic charset of ISO C
|
||||
(plus ` and @) */
|
||||
};
|
||||
|
||||
/* Character classification. */
|
||||
extern const unsigned short _sch_istable[256];
|
||||
|
||||
#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
|
||||
|
||||
#define ISALPHA(c) _sch_test(c, _sch_isalpha)
|
||||
#define ISALNUM(c) _sch_test(c, _sch_isalnum)
|
||||
#define ISBLANK(c) _sch_test(c, _sch_isblank)
|
||||
#define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
|
||||
#define ISDIGIT(c) _sch_test(c, _sch_isdigit)
|
||||
#define ISGRAPH(c) _sch_test(c, _sch_isgraph)
|
||||
#define ISLOWER(c) _sch_test(c, _sch_islower)
|
||||
#define ISPRINT(c) _sch_test(c, _sch_isprint)
|
||||
#define ISPUNCT(c) _sch_test(c, _sch_ispunct)
|
||||
#define ISSPACE(c) _sch_test(c, _sch_isspace)
|
||||
#define ISUPPER(c) _sch_test(c, _sch_isupper)
|
||||
#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
|
||||
|
||||
#define ISIDNUM(c) _sch_test(c, _sch_isidnum)
|
||||
#define ISIDST(c) _sch_test(c, _sch_isidst)
|
||||
#define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic)
|
||||
#define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
|
||||
#define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
|
||||
#define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
|
||||
|
||||
/* Character transformation. */
|
||||
extern const unsigned char _sch_toupper[256];
|
||||
extern const unsigned char _sch_tolower[256];
|
||||
#define TOUPPER(c) _sch_toupper[(c) & 0xff]
|
||||
#define TOLOWER(c) _sch_tolower[(c) & 0xff]
|
||||
|
||||
/* Prevent the users of safe-ctype.h from accidently using the routines
|
||||
from ctype.h. Initially, the approach was to produce an error when
|
||||
detecting that ctype.h has been included. But this was causing
|
||||
trouble as ctype.h might get indirectly included as a result of
|
||||
including another system header (for instance gnulib's stdint.h).
|
||||
So we include ctype.h here and then immediately redefine its macros. */
|
||||
|
||||
#include <ctype.h>
|
||||
#undef isalpha
|
||||
#define isalpha(c) do_not_use_isalpha_with_safe_ctype
|
||||
#undef isalnum
|
||||
#define isalnum(c) do_not_use_isalnum_with_safe_ctype
|
||||
#undef iscntrl
|
||||
#define iscntrl(c) do_not_use_iscntrl_with_safe_ctype
|
||||
#undef isdigit
|
||||
#define isdigit(c) do_not_use_isdigit_with_safe_ctype
|
||||
#undef isgraph
|
||||
#define isgraph(c) do_not_use_isgraph_with_safe_ctype
|
||||
#undef islower
|
||||
#define islower(c) do_not_use_islower_with_safe_ctype
|
||||
#undef isprint
|
||||
#define isprint(c) do_not_use_isprint_with_safe_ctype
|
||||
#undef ispunct
|
||||
#define ispunct(c) do_not_use_ispunct_with_safe_ctype
|
||||
#undef isspace
|
||||
#define isspace(c) do_not_use_isspace_with_safe_ctype
|
||||
#undef isupper
|
||||
#define isupper(c) do_not_use_isupper_with_safe_ctype
|
||||
#undef isxdigit
|
||||
#define isxdigit(c) do_not_use_isxdigit_with_safe_ctype
|
||||
#undef toupper
|
||||
#define toupper(c) do_not_use_toupper_with_safe_ctype
|
||||
#undef tolower
|
||||
#define tolower(c) do_not_use_tolower_with_safe_ctype
|
||||
|
||||
#endif /* SAFE_CTYPE_H */
|
||||
48
arduino/hardware/tools/avr/include/libiberty/sort.h
Normal file
48
arduino/hardware/tools/avr/include/libiberty/sort.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Sorting algorithms.
|
||||
Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
Contributed by Mark Mitchell <mark@codesourcery.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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef SORT_H
|
||||
#define SORT_H
|
||||
|
||||
#include <sys/types.h> /* For size_t */
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* Sort an array of pointers. */
|
||||
|
||||
extern void sort_pointers (size_t, void **, void **);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* SORT_H */
|
||||
|
||||
|
||||
|
||||
|
||||
156
arduino/hardware/tools/avr/include/libiberty/splay-tree.h
Normal file
156
arduino/hardware/tools/avr/include/libiberty/splay-tree.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/* A splay-tree datatype.
|
||||
Copyright (C) 1998-2015 Free Software Foundation, Inc.
|
||||
Contributed by Mark Mitchell (mark@markmitchell.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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* For an easily readable description of splay-trees, see:
|
||||
|
||||
Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
|
||||
Algorithms. Harper-Collins, Inc. 1991.
|
||||
|
||||
The major feature of splay trees is that all basic tree operations
|
||||
are amortized O(log n) time for a tree with n nodes. */
|
||||
|
||||
#ifndef _SPLAY_TREE_H
|
||||
#define _SPLAY_TREE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Use typedefs for the key and data types to facilitate changing
|
||||
these types, if necessary. These types should be sufficiently wide
|
||||
that any pointer or scalar can be cast to these types, and then
|
||||
cast back, without loss of precision. */
|
||||
typedef uintptr_t splay_tree_key;
|
||||
typedef uintptr_t splay_tree_value;
|
||||
|
||||
/* Forward declaration for a node in the tree. */
|
||||
typedef struct splay_tree_node_s *splay_tree_node;
|
||||
|
||||
/* The type of a function which compares two splay-tree keys. The
|
||||
function should return values as for qsort. */
|
||||
typedef int (*splay_tree_compare_fn) (splay_tree_key, splay_tree_key);
|
||||
|
||||
/* The type of a function used to deallocate any resources associated
|
||||
with the key. */
|
||||
typedef void (*splay_tree_delete_key_fn) (splay_tree_key);
|
||||
|
||||
/* The type of a function used to deallocate any resources associated
|
||||
with the value. */
|
||||
typedef void (*splay_tree_delete_value_fn) (splay_tree_value);
|
||||
|
||||
/* The type of a function used to iterate over the tree. */
|
||||
typedef int (*splay_tree_foreach_fn) (splay_tree_node, void*);
|
||||
|
||||
/* The type of a function used to allocate memory for tree root and
|
||||
node structures. The first argument is the number of bytes needed;
|
||||
the second is a data pointer the splay tree functions pass through
|
||||
to the allocator. This function must never return zero. */
|
||||
typedef void *(*splay_tree_allocate_fn) (int, void *);
|
||||
|
||||
/* The type of a function used to free memory allocated using the
|
||||
corresponding splay_tree_allocate_fn. The first argument is the
|
||||
memory to be freed; the latter is a data pointer the splay tree
|
||||
functions pass through to the freer. */
|
||||
typedef void (*splay_tree_deallocate_fn) (void *, void *);
|
||||
|
||||
/* The nodes in the splay tree. */
|
||||
struct splay_tree_node_s {
|
||||
/* The key. */
|
||||
splay_tree_key key;
|
||||
|
||||
/* The value. */
|
||||
splay_tree_value value;
|
||||
|
||||
/* The left and right children, respectively. */
|
||||
splay_tree_node left;
|
||||
splay_tree_node right;
|
||||
};
|
||||
|
||||
/* The splay tree itself. */
|
||||
struct splay_tree_s {
|
||||
/* The root of the tree. */
|
||||
splay_tree_node root;
|
||||
|
||||
/* The comparision function. */
|
||||
splay_tree_compare_fn comp;
|
||||
|
||||
/* The deallocate-key function. NULL if no cleanup is necessary. */
|
||||
splay_tree_delete_key_fn delete_key;
|
||||
|
||||
/* The deallocate-value function. NULL if no cleanup is necessary. */
|
||||
splay_tree_delete_value_fn delete_value;
|
||||
|
||||
/* Node allocate function. Takes allocate_data as a parameter. */
|
||||
splay_tree_allocate_fn allocate;
|
||||
|
||||
/* Free function for nodes and trees. Takes allocate_data as a parameter. */
|
||||
splay_tree_deallocate_fn deallocate;
|
||||
|
||||
/* Parameter for allocate/free functions. */
|
||||
void *allocate_data;
|
||||
};
|
||||
|
||||
typedef struct splay_tree_s *splay_tree;
|
||||
|
||||
extern splay_tree splay_tree_new (splay_tree_compare_fn,
|
||||
splay_tree_delete_key_fn,
|
||||
splay_tree_delete_value_fn);
|
||||
extern splay_tree splay_tree_new_with_allocator (splay_tree_compare_fn,
|
||||
splay_tree_delete_key_fn,
|
||||
splay_tree_delete_value_fn,
|
||||
splay_tree_allocate_fn,
|
||||
splay_tree_deallocate_fn,
|
||||
void *);
|
||||
extern splay_tree splay_tree_new_typed_alloc (splay_tree_compare_fn,
|
||||
splay_tree_delete_key_fn,
|
||||
splay_tree_delete_value_fn,
|
||||
splay_tree_allocate_fn,
|
||||
splay_tree_allocate_fn,
|
||||
splay_tree_deallocate_fn,
|
||||
void *);
|
||||
extern void splay_tree_delete (splay_tree);
|
||||
extern splay_tree_node splay_tree_insert (splay_tree,
|
||||
splay_tree_key,
|
||||
splay_tree_value);
|
||||
extern void splay_tree_remove (splay_tree, splay_tree_key);
|
||||
extern splay_tree_node splay_tree_lookup (splay_tree, splay_tree_key);
|
||||
extern splay_tree_node splay_tree_predecessor (splay_tree, splay_tree_key);
|
||||
extern splay_tree_node splay_tree_successor (splay_tree, splay_tree_key);
|
||||
extern splay_tree_node splay_tree_max (splay_tree);
|
||||
extern splay_tree_node splay_tree_min (splay_tree);
|
||||
extern int splay_tree_foreach (splay_tree, splay_tree_foreach_fn, void*);
|
||||
extern int splay_tree_compare_ints (splay_tree_key, splay_tree_key);
|
||||
extern int splay_tree_compare_pointers (splay_tree_key, splay_tree_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _SPLAY_TREE_H */
|
||||
40
arduino/hardware/tools/avr/include/libiberty/timeval-utils.h
Normal file
40
arduino/hardware/tools/avr/include/libiberty/timeval-utils.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Basic struct timeval utilities.
|
||||
Copyright (C) 2011-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the libiberty library.
|
||||
Libiberty is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
Libiberty 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with libiberty; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef TIMEVAL_UTILS_H
|
||||
#define TIMEVAL_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* forward decl */
|
||||
struct timeval;
|
||||
|
||||
extern void timeval_add (struct timeval *result,
|
||||
const struct timeval *a, const struct timeval *b);
|
||||
|
||||
extern void timeval_sub (struct timeval *result,
|
||||
const struct timeval *a, const struct timeval *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* TIMEVAL_UTILS_H */
|
||||
Reference in New Issue
Block a user