1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
/* Install modified versions of certain ANSI-incompatible system header
|
|
|
|
files which are fixed to work correctly with ANSI C and placed in a
|
2003-05-23 22:48:48 +02:00
|
|
|
directory that GCC will search.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2004-10-20 10:21:09 +02:00
|
|
|
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
|
2003-05-23 22:48:48 +02:00
|
|
|
Free Software Foundation, Inc.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
This file is part of GCC.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1999-10-12 16:44:18 +02:00
|
|
|
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.
|
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1999-10-12 16:44:18 +02:00
|
|
|
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
|
2003-05-23 22:48:48 +02:00
|
|
|
along with GCC; see the file COPYING. If not, write to
|
1999-10-12 16:44:18 +02:00
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
2001-05-26 03:31:47 +02:00
|
|
|
#ifndef GCC_FIXLIB_H
|
|
|
|
#define GCC_FIXLIB_H
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2001-05-25 23:36:08 +02:00
|
|
|
#include "config.h"
|
1999-10-12 16:44:18 +02:00
|
|
|
#include "system.h"
|
2002-12-16 19:58:42 +01:00
|
|
|
#include <signal.h>
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-07-08 22:42:19 +02:00
|
|
|
#include "xregex.h"
|
2000-07-12 16:45:05 +02:00
|
|
|
#include "libiberty.h"
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
#ifndef STDIN_FILENO
|
|
|
|
# define STDIN_FILENO 0
|
|
|
|
#endif
|
|
|
|
#ifndef STDOUT_FILENO
|
|
|
|
# define STDOUT_FILENO 1
|
|
|
|
#endif
|
|
|
|
|
2004-10-20 10:21:09 +02:00
|
|
|
#if ! defined( SIGCHLD ) && defined( SIGCLD )
|
|
|
|
# define SIGCHLD SIGCLD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SIGQUIT
|
|
|
|
#define SIGQUIT SIGTERM
|
|
|
|
#endif
|
|
|
|
#ifndef SIGIOT
|
|
|
|
#define SIGIOT SIGTERM
|
|
|
|
#endif
|
|
|
|
#ifndef SIGPIPE
|
|
|
|
#define SIGPIPE SIGTERM
|
|
|
|
#endif
|
|
|
|
#ifndef SIGALRM
|
|
|
|
#define SIGALRM SIGTERM
|
|
|
|
#endif
|
|
|
|
#ifndef SIGKILL
|
|
|
|
#define SIGKILL SIGTERM
|
|
|
|
#endif
|
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
typedef int t_success;
|
|
|
|
|
|
|
|
#define FAILURE (-1)
|
|
|
|
#define SUCCESS 0
|
|
|
|
#define PROBLEM 1
|
|
|
|
|
|
|
|
#define SUCCEEDED(p) ((p) == SUCCESS)
|
|
|
|
#define SUCCESSFUL(p) SUCCEEDED (p)
|
|
|
|
#define FAILED(p) ((p) < SUCCESS)
|
|
|
|
#define HADGLITCH(p) ((p) > SUCCESS)
|
|
|
|
|
2000-12-13 21:07:46 +01:00
|
|
|
#ifndef DEBUG
|
|
|
|
# define STATIC static
|
|
|
|
#else
|
|
|
|
# define STATIC
|
|
|
|
#endif
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
#define tSCC static const char
|
|
|
|
#define tCC const char
|
|
|
|
#define tSC static char
|
|
|
|
|
|
|
|
/* If this particular system's header files define the macro `MAXPATHLEN',
|
|
|
|
we happily take advantage of it; otherwise we use a value which ought
|
|
|
|
to be large enough. */
|
|
|
|
#ifndef MAXPATHLEN
|
|
|
|
# define MAXPATHLEN 4096
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
# define EXIT_SUCCESS 0
|
|
|
|
#endif
|
|
|
|
#ifndef EXIT_FAILURE
|
|
|
|
# define EXIT_FAILURE 1
|
|
|
|
#endif
|
|
|
|
|
2000-07-13 16:47:55 +02:00
|
|
|
#define EXIT_BROKEN 3
|
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
#define NUL '\0'
|
|
|
|
|
|
|
|
#ifndef NOPROCESS
|
|
|
|
#define NOPROCESS ((pid_t) -1)
|
|
|
|
#define NULLPROCESS ((pid_t)0)
|
|
|
|
|
|
|
|
#define EXIT_PANIC 99
|
2000-09-12 16:28:55 +02:00
|
|
|
#endif /* NOPROCESS */
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-12-13 21:07:46 +01:00
|
|
|
#define IGNORE_ARG(a) ((void)(a))
|
|
|
|
|
2001-03-03 20:05:00 +01:00
|
|
|
typedef enum t_bool
|
1999-10-12 16:44:18 +02:00
|
|
|
{
|
|
|
|
BOOL_FALSE, BOOL_TRUE
|
|
|
|
} t_bool;
|
|
|
|
|
1999-12-29 23:59:16 +01:00
|
|
|
typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
|
|
|
|
|
|
|
|
#define APPLY_FIX 0
|
|
|
|
#define SKIP_FIX 1
|
|
|
|
|
2000-07-19 16:10:41 +02:00
|
|
|
#define ENV_TABLE \
|
|
|
|
_ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
|
|
|
|
"output from config.guess" ) \
|
|
|
|
\
|
2000-08-04 16:16:57 +02:00
|
|
|
_ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \
|
|
|
|
"directory of fixincl and applyfix" ) \
|
|
|
|
\
|
2000-07-19 16:10:41 +02:00
|
|
|
_ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
|
|
|
|
"directory of original files" ) \
|
|
|
|
\
|
|
|
|
_ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \
|
|
|
|
"current directory for fixincl" ) \
|
|
|
|
\
|
|
|
|
_ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \
|
|
|
|
"output directory" ) \
|
|
|
|
\
|
2004-08-30 15:32:57 +02:00
|
|
|
_ENV_( pz_mn_name_pat, BOOL_FALSE, "MN_NAME_PAT", \
|
|
|
|
"regex matching forbidden identifiers" ) \
|
|
|
|
\
|
2000-07-19 16:10:41 +02:00
|
|
|
_ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \
|
|
|
|
"amount of user entertainment" ) \
|
|
|
|
\
|
|
|
|
_ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \
|
|
|
|
"leader to trim from file names" )
|
|
|
|
|
2004-08-30 15:32:57 +02:00
|
|
|
#define _ENV_(v,m,n,t) extern tCC* v;
|
|
|
|
ENV_TABLE
|
|
|
|
#undef _ENV_
|
|
|
|
|
2000-05-11 15:41:12 +02:00
|
|
|
/* Test Descriptor
|
|
|
|
|
|
|
|
Each fix may have associated tests that determine
|
|
|
|
whether the fix needs to be applied or not.
|
|
|
|
Each test has a type (from the te_test_type enumeration);
|
|
|
|
associated test text; and, if the test is TT_EGREP or
|
|
|
|
the negated form TT_NEGREP, a pointer to the compiled
|
|
|
|
version of the text string.
|
|
|
|
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
|
|
|
|
} te_test_type;
|
|
|
|
|
|
|
|
typedef struct test_desc tTestDesc;
|
|
|
|
|
|
|
|
struct test_desc
|
|
|
|
{
|
|
|
|
te_test_type type;
|
|
|
|
const char *pz_test_text;
|
|
|
|
regex_t *p_test_regex;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct patch_desc tPatchDesc;
|
|
|
|
|
|
|
|
/* Fix Descriptor
|
|
|
|
|
|
|
|
Everything you ever wanted to know about how to apply
|
|
|
|
a particular fix (which files, how to qualify them,
|
|
|
|
how to actually make the fix, etc...)
|
|
|
|
|
2000-07-27 15:29:21 +02:00
|
|
|
NB: the FD_ defines are BIT FLAGS, even though
|
|
|
|
some are mutually exclusive
|
2000-05-11 15:41:12 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
#define FD_MACH_ONLY 0x0000
|
|
|
|
#define FD_MACH_IFNOT 0x0001
|
|
|
|
#define FD_SHELL_SCRIPT 0x0002
|
|
|
|
#define FD_SUBROUTINE 0x0004
|
|
|
|
#define FD_REPLACEMENT 0x0008
|
|
|
|
#define FD_SKIP_TEST 0x8000
|
|
|
|
|
|
|
|
typedef struct fix_desc tFixDesc;
|
|
|
|
struct fix_desc
|
|
|
|
{
|
2000-05-14 21:29:02 +02:00
|
|
|
tCC* fix_name; /* Name of the fix */
|
|
|
|
tCC* file_list; /* List of files it applies to */
|
|
|
|
tCC** papz_machs; /* List of machine/os-es it applies to */
|
|
|
|
int test_ct;
|
|
|
|
int fd_flags;
|
|
|
|
tTestDesc* p_test_desc;
|
|
|
|
tCC** patch_args;
|
|
|
|
long unused;
|
2000-05-11 15:41:12 +02:00
|
|
|
};
|
|
|
|
|
2000-07-13 16:47:55 +02:00
|
|
|
typedef struct {
|
|
|
|
int type_name_len;
|
|
|
|
tCC* pz_type;
|
|
|
|
tCC* pz_TYPE;
|
|
|
|
tCC* pz_gtype;
|
|
|
|
} t_gnu_type_map;
|
|
|
|
|
|
|
|
extern int gnu_type_map_ct;
|
|
|
|
|
2000-07-19 16:10:41 +02:00
|
|
|
#ifdef HAVE_MMAP_FILE
|
|
|
|
#define UNLOAD_DATA() do { if (curr_data_mapped) { \
|
|
|
|
munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
|
|
|
|
else free ((void*)pz_curr_data); } while(0)
|
|
|
|
#else
|
|
|
|
#define UNLOAD_DATA() free ((void*)pz_curr_data)
|
|
|
|
#endif
|
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
/*
|
|
|
|
* Exported procedures
|
|
|
|
*/
|
2003-08-02 01:07:04 +02:00
|
|
|
char * load_file_data ( FILE* fp );
|
2000-09-12 16:28:55 +02:00
|
|
|
|
2000-07-12 16:45:05 +02:00
|
|
|
#ifdef IS_CXX_HEADER_NEEDED
|
2003-08-02 01:07:04 +02:00
|
|
|
t_bool is_cxx_header ( tCC* filename, tCC* filetext );
|
2000-07-12 16:45:05 +02:00
|
|
|
#endif /* IS_CXX_HEADER_NEEDED */
|
2000-09-12 16:28:55 +02:00
|
|
|
|
2000-07-12 16:45:05 +02:00
|
|
|
#ifdef SKIP_QUOTE_NEEDED
|
2003-08-02 01:07:04 +02:00
|
|
|
tCC* skip_quote ( char q, char* text );
|
2000-07-12 16:45:05 +02:00
|
|
|
#endif
|
2000-05-11 15:41:12 +02:00
|
|
|
|
2003-08-02 01:07:04 +02:00
|
|
|
void compile_re ( tCC* pat, regex_t* re, int match, tCC *e1, tCC *e2 );
|
2000-09-12 16:28:55 +02:00
|
|
|
|
2003-08-02 01:07:04 +02:00
|
|
|
void apply_fix ( tFixDesc* p_fixd, tCC* filname );
|
2000-09-12 16:28:55 +02:00
|
|
|
apply_fix_p_t
|
2003-08-02 01:07:04 +02:00
|
|
|
run_test ( tCC* t_name, tCC* f_name, tCC* text );
|
2000-05-11 15:41:12 +02:00
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
#ifdef SEPARATE_FIX_PROC
|
2003-08-02 01:07:04 +02:00
|
|
|
char* make_raw_shell_str ( char* pz_d, tCC* pz_s, size_t smax );
|
2000-08-04 16:16:57 +02:00
|
|
|
#endif
|
|
|
|
|
2004-08-30 15:32:57 +02:00
|
|
|
t_bool mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who );
|
2004-10-15 09:58:38 +02:00
|
|
|
|
|
|
|
void initialize_opts ( void );
|
2001-05-26 03:31:47 +02:00
|
|
|
#endif /* ! GCC_FIXLIB_H */
|