+2009-03-28 Joseph Myers <joseph@codesourcery.com>
+
+ * inclhack.def (aix_syswait, exception_structure,
+ pthread_page_size): Remove.
+ (math_exception): Remove mention of fixproto in comment.
+ * fixincl.x: Regenerate.
+ * mkheaders.in: Do not handle STMP_FIXPROTO.
+
2009-03-27 Sandra Loosemore <sandra@codesourcery.com>
* server.c (run_shell): Quote directory name passed to cd.
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed Saturday February 28, 2009 at 10:11:41 AM PST
+ * It has been AutoGen-ed Saturday March 28, 2009 at 12:12:55 AM UTC
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Feb 28 10:11:41 PST 2009
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Mar 28 00:12:55 UTC 2009
*
* You must regenerate it. Use the ./genfixes script.
*
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 180 fixup descriptions.
+ * This file contains 177 fixup descriptions.
*
* See README for more information.
*
"\\\n",
(char*)NULL };
-/* * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Description of Aix_Syswait fix
- */
-tSCC zAix_SyswaitName[] =
- "aix_syswait";
-
-/*
- * File name selection pattern
- */
-tSCC zAix_SyswaitList[] =
- "sys/wait.h\0";
-/*
- * Machine/OS name selection pattern
- */
-#define apzAix_SyswaitMachs (const char**)NULL
-
-/*
- * content selection pattern - do fix if pattern found
- */
-tSCC zAix_SyswaitSelect0[] =
- "^extern pid_t wait3\\(\\);\n";
-tSCC zAix_SyswaitSelect1[] =
- "bos325,";
-
-#define AIX_SYSWAIT_TEST_CT 2
-static tTestDesc aAix_SyswaitTests[] = {
- { TT_EGREP, zAix_SyswaitSelect0, (regex_t*)NULL },
- { TT_EGREP, zAix_SyswaitSelect1, (regex_t*)NULL }, };
-
-/*
- * Fix Command Arguments for Aix_Syswait
- */
-static const char* apzAix_SyswaitPatch[] = {
- "format",
- "struct rusage;\n\
-%0",
- (char*)NULL };
-
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description of Aix_Syswait_2 fix
"ecd_cursor",
(char*)NULL };
-/* * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Description of Exception_Structure fix
- */
-tSCC zException_StructureName[] =
- "exception_structure";
-
-/*
- * File name selection pattern
- */
-tSCC zException_StructureList[] =
- "math.h\0";
-/*
- * Machine/OS name selection pattern
- */
-#define apzException_StructureMachs (const char**)NULL
-
-/*
- * content selection pattern - do fix if pattern found
- */
-tSCC zException_StructureSelect0[] =
- "matherr";
-
-/*
- * content bypass pattern - skip fix if pattern found
- */
-tSCC zException_StructureBypass0[] =
- "matherr.*(struct exception|__MATH_EXCEPTION|[ \\t]*__FP_EXCEPTION[ \\t]*\\*[ \\t]*)";
-
-#define EXCEPTION_STRUCTURE_TEST_CT 2
-static tTestDesc aException_StructureTests[] = {
- { TT_NEGREP, zException_StructureBypass0, (regex_t*)NULL },
- { TT_EGREP, zException_StructureSelect0, (regex_t*)NULL }, };
-
-/*
- * Fix Command Arguments for Exception_Structure
- */
-static const char* apzException_StructurePatch[] = {
- "wrap",
- "struct exception;\n",
- (char*)NULL };
-
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description of Freebsd_Gcc3_Breakage fix
typedef __regmatch_t\tregmatch_t;",
(char*)NULL };
-/* * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Description of Pthread_Page_Size fix
- */
-tSCC zPthread_Page_SizeName[] =
- "pthread_page_size";
-
-/*
- * File name selection pattern
- */
-tSCC zPthread_Page_SizeList[] =
- "pthread.h\0";
-/*
- * Machine/OS name selection pattern
- */
-#define apzPthread_Page_SizeMachs (const char**)NULL
-
-/*
- * content selection pattern - do fix if pattern found
- */
-tSCC zPthread_Page_SizeSelect0[] =
- "^int __page_size";
-
-#define PTHREAD_PAGE_SIZE_TEST_CT 1
-static tTestDesc aPthread_Page_SizeTests[] = {
- { TT_EGREP, zPthread_Page_SizeSelect0, (regex_t*)NULL }, };
-
-/*
- * Fix Command Arguments for Pthread_Page_Size
- */
-static const char* apzPthread_Page_SizePatch[] = {
- "format",
- "extern %0",
- (char*)NULL };
-
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description of Pthread_Incomplete_Struct_Argument fix
*
* List of all fixes
*/
-#define REGEX_COUNT 226
+#define REGEX_COUNT 221
#define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT 180
+#define FIX_COUNT 177
/*
* Enumerate the fixes
AAB_SUN_MEMCPY_FIXIDX,
AIX_PTHREAD_FIXIDX,
AIX_SYSMACHINE_FIXIDX,
- AIX_SYSWAIT_FIXIDX,
AIX_SYSWAIT_2_FIXIDX,
AIX_VOLATILE_FIXIDX,
ALPHA___ASSERT_FIXIDX,
DEC_INTERN_ASM_FIXIDX,
DJGPP_WCHAR_H_FIXIDX,
ECD_CURSOR_FIXIDX,
- EXCEPTION_STRUCTURE_FIXIDX,
FREEBSD_GCC3_BREAKAGE_FIXIDX,
FREEBSD_GCC4_BREAKAGE_FIXIDX,
GLIBC_C99_INLINE_1_FIXIDX,
OPENBSD_VA_START_FIXIDX,
OSF_NAMESPACE_A_FIXIDX,
OSF_NAMESPACE_C_FIXIDX,
- PTHREAD_PAGE_SIZE_FIXIDX,
PTHREAD_INCOMPLETE_STRUCT_ARGUMENT_FIXIDX,
READ_RET_TYPE_FIXIDX,
RPC_XDR_LVALUE_CAST_A_FIXIDX,
AIX_SYSMACHINE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aAix_SysmachineTests, apzAix_SysmachinePatch, 0 },
- { zAix_SyswaitName, zAix_SyswaitList,
- apzAix_SyswaitMachs,
- AIX_SYSWAIT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
- aAix_SyswaitTests, apzAix_SyswaitPatch, 0 },
-
{ zAix_Syswait_2Name, zAix_Syswait_2List,
apzAix_Syswait_2Machs,
AIX_SYSWAIT_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
ECD_CURSOR_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aEcd_CursorTests, apzEcd_CursorPatch, 0 },
- { zException_StructureName, zException_StructureList,
- apzException_StructureMachs,
- EXCEPTION_STRUCTURE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
- aException_StructureTests, apzException_StructurePatch, 0 },
-
{ zFreebsd_Gcc3_BreakageName, zFreebsd_Gcc3_BreakageList,
apzFreebsd_Gcc3_BreakageMachs,
FREEBSD_GCC3_BREAKAGE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
OSF_NAMESPACE_C_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aOsf_Namespace_CTests, apzOsf_Namespace_CPatch, 0 },
- { zPthread_Page_SizeName, zPthread_Page_SizeList,
- apzPthread_Page_SizeMachs,
- PTHREAD_PAGE_SIZE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
- aPthread_Page_SizeTests, apzPthread_Page_SizePatch, 0 },
-
{ zPthread_Incomplete_Struct_ArgumentName, zPthread_Incomplete_Struct_ArgumentList,
apzPthread_Incomplete_Struct_ArgumentMachs,
PTHREAD_INCOMPLETE_STRUCT_ARGUMENT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
};
-/*
- * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
- * definition of struct rusage, so the prototype added by fixproto fails.
- */
-fix = {
- hackname = aix_syswait;
- files = sys/wait.h;
- select = "^extern pid_t wait3\\(\\);\n";
- select = "bos325,";
- c_fix = format;
- c_fix_arg = "struct rusage;\n%0";
- test_text = "/* bos325, */\n"
- "extern pid_t wait3();\n"
- "\t/* pid_t wait3(int *, int, struct rusage *); */";
-};
-
-
/*
* sys/wait.h on AIX 5.2 defines macros that have both signed and
* unsigned types in conditional expressions.
};
-/*
- * math.h on SunOS 4 puts the declaration of matherr before the definition
- * of struct exception, so the prototype (added by fixproto) causes havoc.
- * This must appear before the math_exception fix.
- */
-fix = {
- hackname = exception_structure;
- files = math.h;
-
- /* If matherr has a prototype already, the header needs no fix. */
- bypass = 'matherr.*(struct exception|__MATH_EXCEPTION|[ \t]*__FP_EXCEPTION[ \t]*\*[ \t]*)';
- select = matherr;
-
- c_fix = wrap;
- c_fix_arg = "struct exception;\n";
-
- test_text = "extern int matherr();";
-};
-
-
/*
* Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
* neither the existence of GCC 3 nor its exact feature set yet break
* Interface Definition), which conflicts with the class exception defined
* in the C++ file std/stdexcept.h. We redefine it to __math_exception.
* This is not a great fix, but I haven't been able to think of anything
- * better. Note that we have to put the #ifdef/#endif blocks at beginning
- * and end of file, because fixproto runs after us and may insert
- * additional references to struct exception.
+ * better.
*/
fix = {
hackname = math_exception;
};
-/*
- * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
- * The original ones fail if uninitialized externs are not common.
- * This is the default for all ANSI standard C++ compilers.
- */
-fix = {
- hackname = pthread_page_size;
- files = pthread.h;
- select = "^int __page_size";
- c_fix = format;
- c_fix_arg = "extern %0";
- test_text = "int __page_size;";
-};
-
/*
* On broken glibc-2.3.3 systems an array of incomplete structures is
* passed to __sigsetjmp. Fix that to take a pointer instead.
#!/bin/sh
-# Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation, Inc.
#This file is part of GCC.
fi
cp ${itoolsdatadir}/include${multi_dir}/limits.h ${subincdir}
-
- if [ x${STMP_FIXPROTO} != x ] ; then
- export FIXPROTO_DEFINES mkinstalldirs
- @SHELL@ fixproto ${subincdir} ${subincdir} ${isysroot}${SYSTEM_HEADER_DIR} || exit 1
- fi
done
+2009-03-28 Joseph Myers <joseph@codesourcery.com>
+
+ * config/arm/t-arm-coff, config/h8300/coff.h,
+ config/i386/i386-aout.h, config/i386/i386-coff.h,
+ config/libgloss.h, config/m68k/coff.h, config/m68k/m68k-aout.h,
+ config/pdp11/2bsd.h, config/rs6000/aix41.h,
+ config/rs6000/aix41.opt, config/rs6000/t-newas, config/sh/coff.h,
+ fix-header.c, fixproto, gen-protos.c, protoize.c, scan-decls.c,
+ scan-types.sh, scan.c, scan.h, sort-protos, sys-protos.h,
+ sys-types.h: Remove.
+ * Makefile.in: Remove protoize and fixproto support and references
+ in comments.
+ (SYSCALLS.c.X-warn, TARGET_GETGROUPS_T, STMP_FIXPROTO,
+ PROTOIZE_INSTALL_NAME, UNPROTOIZE_INSTALL_NAME, FIXPROTO_DEFINES):
+ Remove.
+ (ALL_HOST_OBJS): Remove $(PROTO_OBJS).
+ (MOSTLYCLEANFILES): Remove protoize$(exeext) and
+ unprotoize$(exeext).
+ (rest.encap): Don't depend on $(STMP_FIXPROTO)
+ (.PHONY): Don't depend on proto.
+ (libgcc-support): Don't depend on $(STMP_FIXPROTO).
+ (proto, PROTO_OBJS, protoize$(exeext), unprotoize$(exeext),
+ protoize.o, unprotoize.o, SYSCALLS.c.X, test-protoize-simple,
+ deduced.h, GEN_PROTOS_OBJS, build/gen-protos$(build_exeext),
+ build/gen-protos.o, build/scan.o, xsys-protos.h,
+ build/fix-header$(build_exeext), build/fix-header.o,
+ build/scan-decls.o, fixhdr.ready, stmp-fixproto,
+ stmp-install-fixproto): Remove.
+ (mostlyclean): Don't remove xsys-protos.hT, SYSCALLS.c.X,
+ SYSCALLS.c or fixproto files.
+ (install-common): Don't install protoize.
+ (install-headers-tar, install-headers-cpio, install-headers-cp):
+ Don't depend on $(STMP_FIXPROTO).
+ (install-mkheaders): Don't depend on $(STMP_FIXPROTO). Don't
+ install fixproto files or write out fixproto settings.
+ (uninstall): Don't uninstall protoize.
+ * config.gcc (use_fixproto): Remove.
+ (arm-*-coff*, armel-*-coff*, h8300-*-*, i[34567]86-*-aout*,
+ i[34567]86-*-coff*, m68k-*-aout*, m68k-*-coff*, pdp11-*-bsd,
+ rs6000-ibm-aix4.[12]*, powerpc-ibm-aix4.[12]*, sh-*-*): Remove.
+ * config/m32r/t-linux (STMP_FIXPROTO): Remove.
+ * config/m68k/m68k.c: Remove M68K_TARGET_COFF-conditional code.
+ * config/mips/t-iris (FIXPROTO_DEFINES): Remove.
+ * config/pa/t-pa-hpux (FIXPROTO_DEFINES): Remove.
+ * config/pdp11/pdp11.c: Remove TWO_BSD-conditional code.
+ * config/t-svr4 (FIXPROTO_DEFINES): Remove.
+ * config/t-vxworks (STMP_FIXPROTO): Remove.
+ * configure.ac (AC_TYPE_GETGROUPS, TARGET_GETGROUPS_T,
+ STMP_FIXPROTO): Remove.
+ * config.in, configure: Regenerate.
+ * crtstuff.c (gid_t, uid_t): Don't undefine.
+ * doc/install.texi: Change m68k-coff to m68k-elf in example.
+ (arm-*-coff, arm-*-aout: Remove target entries.
+ (*-ibm-aix*): Mention removal of support for AIX 4.2 and older.
+ Remove mention of AIX 4.1.
+ (m68k-*-*): Remove mention of m68k-*-aout and m68k-*-coff*.
+ * doc/invoke.texi (Running Protoize): Remove.
+ * doc/trouble.texi (Actual Bugs): Remove mention of fixproto.
+ (Protoize Caveats): Remove.
+ * tsystem.h: Update comments on headers assumed to exist.
+
2009-03-27 Vladimir Makarov <vmakarov@redhat.com>
* genautomata.c: Add a new year to the copyright. Add a new
#<http://www.gnu.org/licenses/>.
# The targets for external use include:
-# all, doc, proto, install, install-cross, install-cross-rest,
+# all, doc, install, install-cross, install-cross-rest,
# uninstall, TAGS, mostlyclean, clean, distclean, maintainer-clean.
# This is the default target.
# be subject to -Werror:
# flex output may yield harmless "no previous prototype" warnings
build/gengtype-lex.o-warn = -Wno-error
-# SYSCALLS.c misses prototypes
-SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
# dfp.c contains many alias violations
dfp.o-warn = -fno-strict-aliasing
# mips-tfile.c contains -Wcast-qual warnings.
DECNUMINC = -I$(DECNUM) -I$(DECNUMFMT) -I../libdecnumber
LIBDECNUMBER = ../libdecnumber/libdecnumber.a
-# Substitution type for target's getgroups 2nd arg.
-TARGET_GETGROUPS_T = @TARGET_GETGROUPS_T@
-
# Target to use when installing include directory. Either
# install-headers-tar, install-headers-cpio or install-headers-cp.
INSTALL_HEADERS_DIR = @build_install_headers_dir@
# macro is also used in a double-quoted context.
SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`
-# Control whether to run fixproto and fixincludes.
-STMP_FIXPROTO = @STMP_FIXPROTO@
+# Control whether to run fixincludes.
STMP_FIXINC = @STMP_FIXINC@
# Test to see whether <limits.h> exists in the system header files.
GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
GCC_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcc|sed '$(program_transform_name)')
CPP_INSTALL_NAME := $(shell echo cpp|sed '$(program_transform_name)')
-PROTOIZE_INSTALL_NAME := $(shell echo protoize|sed '$(program_transform_name)')
-UNPROTOIZE_INSTALL_NAME := $(shell echo unprotoize|sed '$(program_transform_name)')
GCOV_INSTALL_NAME := $(shell echo gcov|sed '$(program_transform_name)')
GCCBUG_INSTALL_NAME := $(shell echo gccbug|sed '$(program_transform_name)')
else echo runtest; fi`
RUNTESTFLAGS =
-# Extra symbols for fixproto to define when parsing headers.
-FIXPROTO_DEFINES =
-
# Extra flags to use when compiling crt{begin,end}.o.
CRTSTUFF_T_CFLAGS =
$(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS)) \
$(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) \
mips-tfile.o mips-tdump.o \
- $(PROTO_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS)
+ $(GCOV_OBJS) $(GCOV_DUMP_OBJS)
BACKEND = main.o @TREEBROWSER@ libbackend.a $(CPPLIB) $(LIBDECNUMBER)
genrtl.c genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
xgcc$(exeext) cpp$(exeext) cc1$(exeext) cc1*-dummy$(exeext) $(EXTRA_PASSES) \
$(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
- protoize$(exeext) unprotoize$(exeext) \
$(SPECS) collect2$(exeext) \
gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
*.[0-9][0-9].* *.[si] *-checksum.c libbackend.a libgcc.mk
start.encap: native xgcc$(exeext) cpp$(exeext) specs \
libgcc-support lang.start.encap @GENINSRC@ srcextra
# These can't be made until after GCC can run.
-rest.encap: $(STMP_FIXPROTO) lang.rest.encap
+rest.encap: lang.rest.encap
# This is what is made with the host's compiler
# whether making a cross compiler or not.
native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
c: cc1$(exeext)
# Tell GNU make these are phony targets.
-.PHONY: c proto
+.PHONY: c
# On the target machine, finish building a cross compiler.
# This does the things that can't be done on the host machine.
# so we combine them. Sort removes duplicates.
GCC_EXTRA_PARTS := $(sort $(EXTRA_MULTILIB_PARTS) $(EXTRA_PARTS))
-libgcc-support: libgcc.mvars stmp-int-hdrs $(STMP_FIXPROTO) $(TCONFIG_H) \
+libgcc-support: libgcc.mvars stmp-int-hdrs $(TCONFIG_H) \
$(MACHMODE_H) $(FPBIT) $(DPBIT) $(TPBIT) $(LIB2ADD) \
$(LIB2ADD_ST) $(LIB2ADDEH) $(srcdir)/emutls.c gcov-iov.h $(SFP_MACHINE)
-c $(srcdir)/intl.c $(OUTPUT_OPTION)
#\f
-# Remake cpp and protoize.
+# Remake cpp.
PREPROCESSOR_DEFINES = \
-DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
# Note for the stamp targets, we run the program `true' instead of
# having an empty command (nothing following the semicolon).
-proto: config.status protoize$(exeext) unprotoize$(exeext) SYSCALLS.c.X
-
-PROTO_OBJS = intl.o version.o cppdefault.o errors.o
-
-protoize$(exeext): protoize.o $(PROTO_OBJS) $(LIBDEPS)
- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ protoize.o $(PROTO_OBJS) $(LIBS)
-
-unprotoize$(exeext): unprotoize.o $(PROTO_OBJS) $(LIBDEPS)
- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ unprotoize.o $(PROTO_OBJS) $(LIBS)
-
-protoize.o: protoize.c $(srcdir)/../include/getopt.h $(CONFIG_H) $(SYSTEM_H) \
- coretypes.h $(TM_H) Makefile version.h cppdefault.h intl.h
- (SHLIB_LINK='$(SHLIB_LINK)'; \
- $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
- $(DRIVER_DEFINES) \
- $(srcdir)/protoize.c $(OUTPUT_OPTION))
-
-unprotoize.o: protoize.c $(srcdir)/../include/getopt.h $(CONFIG_H) \
- $(SYSTEM_H) coretypes.h $(TM_H) Makefile version.h cppdefault.h intl.h
- (SHLIB_LINK='$(SHLIB_LINK)'; \
- $(CC) -c -DUNPROTOIZE $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
- $(DRIVER_DEFINES) \
- $(srcdir)/protoize.c $(OUTPUT_OPTION))
-
-# This info describes the target machine, so compile with GCC just built.
-SYSCALLS.c.X: $(srcdir)/sys-types.h $(srcdir)/sys-protos.h $(GCC_PASSES) \
- stmp-int-hdrs
- -rm -f SYSCALLS.c tmp-SYSCALLS.s
- sed -e s/TARGET_GETGROUPS_T/$(TARGET_GETGROUPS_T)/ \
- $(srcdir)/sys-types.h $(srcdir)/sys-protos.h > SYSCALLS.c
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) \
- -aux-info $@ -S -o tmp-SYSCALLS.s SYSCALLS.c
- -rm -f SYSCALLS.c tmp-SYSCALLS.s
-
-
-test-protoize-simple: ./protoize ./unprotoize $(GCC_PASSES)
- -rm -f tmp-proto.[cso]
- cp $(srcdir)/protoize.c tmp-proto.c
- chmod u+w tmp-proto.c
- ./protoize -N -B ./ -x getopt.h -c "-B./ -Wall -Wwrite-strings \
- $(GCC_CFLAGS) $(INCLUDES) \
- -DGCC_INCLUDE_DIR=0 \
- -DFIXED_INCLUDE_DIR=0 \
- -DGPLUSPLUS_INCLUDE_DIR=0 \
- -DCROSS_INCLUDE_DIR=0 \
- -DTOOL_INCLUDE_DIR=0 \
- -DSTANDARD_EXEC_PREFIX=0 \
- -DDEFAULT_TARGET_MACHINE=0 \
- -DDEFAULT_TARGET_VERSION=0" tmp-proto.c
- @echo '**********' Expect 400 lines of differences.
- -diff $(srcdir)/protoize.c tmp-proto.c > tmp-proto.diff
- -wc -l tmp-proto.diff
- ./unprotoize -N -x getopt.h -c "-B./ -Wall -Wwrite-strings \
- $(GCC_CFLAGS) $(INCLUDES) \
- -DGCC_INCLUDE_DIR=0 \
- -DFIXED_INCLUDE_DIR=0 \
- -DGPLUSPLUS_INCLUDE_DIR=0 \
- -DCROSS_INCLUDE_DIR=0 \
- -DTOOL_INCLUDE_DIR=0 \
- -DSTANDARD_EXEC_PREFIX=0 \
- -DDEFAULT_TARGET_MACHINE=0 \
- -DDEFAULT_TARGET_VERSION=0" tmp-proto.c
- @echo Expect zero differences.
- diff $(srcdir)/protoize.c tmp-proto.c | cat
- -rm -f tmp-proto.[cs] tmp-proto$(objext)
-
# gcov-iov.c is run on the build machine to generate gcov-iov.h from version.c
build/gcov-iov.o: gcov-iov.c $(BCONFIG_H) coretypes.h $(GTM_H) \
$(SYSTEM_H) coretypes.h $(TM_H)
done; \
fi
$(STAMP) stmp-fixinc
-
-# Files related to the fixproto script.
-# gen-protos and fix-header are compiled with CC_FOR_BUILD, but they are only
-# used in native and host-x-target builds, so it's safe to link them with
-# libiberty.a.
-
-deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
- if [ -d "$(SYSTEM_HEADER_DIR)" ]; \
- then \
- CC="$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -I. -I$(srcdir) -isystem include -isystem ${SYSTEM_HEADER_DIR}"; \
- export CC; \
- $(SHELL) $(srcdir)/scan-types.sh "$(srcdir)" >tmp-deduced.h; \
- mv tmp-deduced.h deduced.h; \
- else \
- $(STAMP) deduced.h; \
- fi
-
-GEN_PROTOS_OBJS = build/gen-protos.o build/scan.o $(BUILD_ERRORS)
-build/gen-protos$(build_exeext): $(GEN_PROTOS_OBJS)
- ${CC_FOR_BUILD} $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
- $(GEN_PROTOS_OBJS) $(BUILD_LIBS)
-
-build/gen-protos.o: gen-protos.c scan.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
- $(GTM_H) errors.h
-
-build/scan.o: scan.c scan.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H)
-
-xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h \
- build/gen-protos$(build_exeext) Makefile
- sed -e s/TARGET_GETGROUPS_T/$(TARGET_GETGROUPS_T)/ \
- deduced.h $(srcdir)/sys-protos.h > tmp-fixtmp.c
- mv tmp-fixtmp.c fixtmp.c
- $(GCC_FOR_TARGET) fixtmp.c -w -U__SIZE_TYPE__ -U__PTRDIFF_TYPE__ -U__WCHAR_TYPE__ -E \
- | sed -e 's/ / /g' -e 's/ *(/ (/g' -e 's/ [ ]*/ /g' -e 's/( )/()/' \
- | $(RUN_GEN) build/gen-protos >xsys-protos.hT
- mv xsys-protos.hT xsys-protos.h
- rm -rf fixtmp.c
-
-# This is nominally a 'build' program, but it's run only when host==build,
-# so we can (indeed, must) use $(LIBDEPS) and $(LIBS).
-build/fix-header$(build_exeext): build/fix-header.o build/scan-decls.o \
- build/scan.o xsys-protos.h \
- $(BUILD_ERRORS) $(LIBDEPS)
- $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
- build/fix-header.o incpath.o cppdefault.o build/scan-decls.o prefix.o \
- build/scan.o $(BUILD_ERRORS) $(LIBS)
-
-build/fix-header.o: fix-header.c $(OBSTACK_H) scan.h errors.h \
- xsys-protos.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(CPPLIB_H)
-
-build/scan-decls.o: scan-decls.c scan.h $(CPPLIB_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H)
-
-# stmp-fixproto depends on this, not on fix-header directly.
-# The idea is to make sure fix-header gets built,
-# but not rerun fixproto after each stage
-# just because fix-header's mtime has changed.
-fixhdr.ready: build/fix-header$(build_exeext)
- -if [ -f fixhdr.ready ] ; then \
- true; \
- else \
- $(STAMP) fixhdr.ready; \
- fi
-
-# stmp-int-hdrs is to make sure fixincludes has already finished.
-# The if statement is so that we don't run fixproto a second time
-# if it has already been run on the files in `include-fixed'.
-stmp-fixproto: fixhdr.ready fixproto fixinc_list stmp-int-hdrs
- set -e; for ml in `cat fixinc_list`; do \
- sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
- multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
- fix_dir=include-fixed$${multi_dir}; \
- if [ -f $${fix_dir}/fixed ] ; then true; \
- else \
- : This line works around a 'make' bug in BSDI 1.1.; \
- FIXPROTO_DEFINES="$(FIXPROTO_DEFINES)"; export FIXPROTO_DEFINES; \
- FIX_HEADER="build/fix-header$(build_exeext)"; export FIX_HEADER; \
- mkinstalldirs="$(mkinstalldirs)"; \
- export mkinstalldirs; \
- if [ -d "$(SYSTEM_HEADER_DIR)" ]; then \
- $(SHELL) ${srcdir}/fixproto $${fix_dir} $${fix_dir} $(SYSTEM_HEADER_DIR); \
- if [ $$? -eq 0 ] ; then true ; else exit 1 ; fi ; \
- else true; fi; \
- $(STAMP) $${fix_dir}/fixed; \
- fi; \
- done
- $(STAMP) stmp-fixproto
-
-# We can't run fixproto (it's being built for a different host), but we still
-# need to install it so that the user can run it when the compiler is
-# installed.
-stmp-install-fixproto: fixproto
- $(STAMP) $@
#\f
# Remake the info files.
-rm -f build/*
-rm -f mddeps.mk
# Delete other built files.
- -rm -f xsys-protos.hT
-rm -f specs.h options.c options.h
# Delete the stamp and temporary files.
-rm -f s-* tmp-* stamp-* stmp-*
# Delete debugging dump files.
-rm -f *.[0-9][0-9].* */*.[0-9][0-9].*
# Delete some files made during installation.
- -rm -f specs $(SPECS) SYSCALLS.c.X SYSCALLS.c
+ -rm -f specs $(SPECS)
-rm -f collect collect2 mips-tfile mips-tdump
-# Delete files generated for fixproto
- -rm -rf $(build_exeext) xsys-protos.h deduced.h tmp-deduced.h \
- gen-protos$(build_exeext) fixproto.list fixtmp.* fixhdr.ready
# Delete unwanted output files from TeX.
-rm -f *.toc *.log *.vr *.fn *.cp *.tp *.ky *.pg
-rm -f */*.toc */*.log */*.vr */*.fn */*.cp */*.tp */*.ky */*.pg
# using -dumpspecs. We remove any old version because it would
# otherwise override the specs built into the driver.
rm -f $(DESTDIR)$(libsubdir)/specs
-# Install protoize if it was compiled.
- -if [ -f protoize$(exeext) ]; then \
- rm -f $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
- $(INSTALL_PROGRAM) protoize$(exeext) $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
- rm -f $(DESTDIR)$(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
- $(INSTALL_PROGRAM) unprotoize$(exeext) $(DESTDIR)$(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
- rm -f $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
- $(INSTALL_DATA) SYSCALLS.c.X $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
- chmod a-x $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
- fi
# Install gcov if it was compiled.
-if [ -f gcov$(exeext) ]; \
then \
$(mkinstalldirs) $(DESTDIR)$(itoolsdir)
# Install the include directory using tar.
-install-headers-tar: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
+install-headers-tar: stmp-int-hdrs install-include-dir
# We use `pwd`/include instead of just include to problems with CDPATH
# Unless a full pathname is provided, some shells would print the new CWD,
# found in CDPATH, corrupting the output. We could just redirect the
# So use `exit 0' to ignore its exit status.
# Install the include directory using cpio.
-install-headers-cpio: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
+install-headers-cpio: stmp-int-hdrs install-include-dir
# See discussion about the use of `pwd` above
cd `${PWD_COMMAND}`/include ; \
find . -print | cpio -pdum $(DESTDIR)$(libsubdir)/include
find . -print | cpio -pdum $(DESTDIR)$(libsubdir)/include-fixed
# Install the include directory using cp.
-install-headers-cp: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
+install-headers-cp: stmp-int-hdrs install-include-dir
cp -p -r include $(DESTDIR)$(libsubdir)
cp -p -r include-fixed $(DESTDIR)$(libsubdir)
cp -p -r include-fixed $(DESTDIR)$(libsubdir)
# Install supporting files for fixincludes to be run later.
-install-mkheaders: stmp-int-hdrs $(STMP_FIXPROTO) install-itoolsdirs \
+install-mkheaders: stmp-int-hdrs install-itoolsdirs \
macro_list fixinc_list
$(INSTALL_DATA) $(srcdir)/gsyslimits.h \
$(DESTDIR)$(itoolsdatadir)/gsyslimits.h
done
$(INSTALL_SCRIPT) $(srcdir)/../mkinstalldirs \
$(DESTDIR)$(itoolsdir)/mkinstalldirs ; \
- if [ x$(STMP_FIXPROTO) != x ] ; then \
- $(INSTALL_SCRIPT) $(srcdir)/fixproto $(DESTDIR)$(itoolsdir)/fixproto ; \
- $(INSTALL_PROGRAM) build/fix-header$(build_exeext) \
- $(DESTDIR)$(itoolsdir)/fix-header$(build_exeext) ; \
- else :; fi
sysroot_headers_suffix='$${sysroot_headers_suffix}'; \
echo 'SYSTEM_HEADER_DIR="'"$(SYSTEM_HEADER_DIR)"'"' \
> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
echo 'OTHER_FIXINCLUDES_DIRS="$(OTHER_FIXINCLUDES_DIRS)"' \
>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
- echo 'FIXPROTO_DEFINES="$(FIXPROTO_DEFINES)"' \
- >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
- echo 'STMP_FIXPROTO="$(STMP_FIXPROTO)"' \
- >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
echo 'STMP_FIXINC="$(STMP_FIXINC)"' \
>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
-if [ x$(cpp_install_dir) != x ]; then \
rm -f $(DESTDIR)$(prefix)/$(cpp_install_dir)/$(CPP_INSTALL_NAME)$(exeext); \
else true; fi
- -rm -rf $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext)
- -rm -rf $(DESTDIR)$(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext)
-rm -rf $(DESTDIR)$(bindir)/$(GCOV_INSTALL_NAME)$(exeext)
-rm -rf $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
- -rm -rf $(DESTDIR)$(man1dir)/protoize$(man1ext)
- -rm -rf $(DESTDIR)$(man1dir)/unprotoize$(man1ext)
-rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
-rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
#\f
# configure_default_options
# Set to an initializer for configure_default_options
# in configargs.h, based on --with-cpu et cetera.
-#
-# use_fixproto Set to "yes" if fixproto should be run normally,
-# "no" if fixproto should never be run.
# The following variables are used in each case-construct to build up the
# outgoing variables:
target_gtfiles=
need_64bit_hwint=
-# Default to not using fixproto. Targets which need fixproto should
-# specifically set this to 'yes'.
-use_fixproto=no
-
# Don't carry these over build->host->target. Please.
xm_file=
md_file=
# Obsolete configurations.
-case ${target} in
-# Avoid generic cases below matching.
- h8300-*-rtems* | h8300-*-elf* \
- | sh-*-elf* | sh-*-symbianelf* | sh-*-linux* | sh-*-netbsdelf* \
- | sh-*-rtems* | sh-wrs-vxworks) ;;
- arm-*-coff* \
- | armel-*-coff* \
- | h8300-*-* \
- | i[34567]86-*-aout* \
- | i[34567]86-*-coff* \
- | m68k-*-aout* \
- | m68k-*-coff* \
- | sh-*-* \
- | pdp11-*-bsd \
- | rs6000-ibm-aix4.[12]* \
- | powerpc-ibm-aix4.[12]* \
- )
- if test "x$enable_obsolete" != xyes; then
- echo "*** Configuration ${target} is obsolete." >&2
- echo "*** Specify --enable-obsolete to build it anyway." >&2
- echo "*** Support will be REMOVED in the next major release of GCC," >&2
- echo "*** unless a maintainer comes forward." >&2
- exit 1
- fi;;
-esac
+#case ${target} in
+# )
+# if test "x$enable_obsolete" != xyes; then
+# echo "*** Configuration ${target} is obsolete." >&2
+# echo "*** Specify --enable-obsolete to build it anyway." >&2
+# echo "*** Support will be REMOVED in the next major release of GCC," >&2
+# echo "*** unless a maintainer comes forward." >&2
+# exit 1
+# fi;;
+#esac
# Unsupported targets list. Do not put an entry in this list unless
# it would otherwise be caught by a more permissive pattern. The list
i[34567]86-go32-* \
| i[34567]86-*-go32* \
| mips64orion*-*-rtems* \
+ | pdp11-*-bsd \
| sparc-hal-solaris2* \
| thumb-*-* \
| *-*-linux*aout* \
tm_file="dbxelf.h elfos.h svr4.h ${tm_file}"
extra_parts="crtinit.o crtfini.o"
;;
-arm-*-coff* | armel-*-coff*)
- tm_file="arm/semi.h arm/aout.h arm/arm.h arm/coff.h dbxcoff.h"
- tmake_file="arm/t-arm arm/t-arm-coff"
- ;;
arm-wrs-vxworks)
tm_file="elfos.h arm/elf.h arm/aout.h ${tm_file} vx-common.h vxworks.h arm/vxworks.h"
tmake_file="${tmake_file} arm/t-arm arm/t-vxworks"
tmake_file="h8300/t-h8300 h8300/t-elf"
tm_file="h8300/h8300.h dbxelf.h elfos.h h8300/elf.h"
;;
-h8300-*-*)
- tm_file="h8300/h8300.h dbxcoff.h h8300/coff.h"
- ;;
hppa*64*-*-linux*)
target_cpu_default="MASK_PA_11|MASK_PA_20"
tm_file="pa/pa64-start.h ${tm_file} dbxelf.h elfos.h svr4.h linux.h \
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h i386/x86-64.h"
tmake_file="${tmake_file} i386/t-i386elf t-svr4"
;;
-i[34567]86-*-aout*)
- tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h i386/i386-aout.h"
- ;;
i[34567]86-*-freebsd*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/freebsd.h"
;;
gas=yes
gnu_ld=yes
;;
-i[34567]86-*-coff*)
- tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/i386-coff.h"
- ;;
i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu)
# Intel 80386's running GNU/*
# with ELF format using glibc 2
tmake_file="m68hc11/t-m68hc11"
extra_options="${extra_options} m68hc11/m68hc11.opt"
;;
-m68k-*-aout*)
- default_m68k_cpu=68020
- default_cf_cpu=5206
- tmake_file="m68k/t-floatlib m68k/t-m68kbare m68k/t-mlibs"
- tm_file="${tm_file} m68k/m68k-none.h m68k/m68kemb.h m68k/m68k-aout.h libgloss.h"
- ;;
-m68k-*-coff*)
- default_m68k_cpu=68020
- default_cf_cpu=5206
- tmake_file="m68k/t-floatlib m68k/t-m68kbare m68k/t-mlibs"
- tm_defines="${tm_defines} MOTOROLA=1"
- tm_file="${tm_file} m68k/m68k-none.h m68k/m68kemb.h dbxcoff.h m68k/coff.h dbx.h"
- ;;
m68k-*-elf* | fido-*-elf*)
case ${target} in
fido-*-elf*)
fi
use_collect2=no
;;
-pdp11-*-bsd)
- tm_file="${tm_file} pdp11/2bsd.h"
- use_fixproto=yes
- ;;
pdp11-*-*)
;;
picochip-*)
extra_options="${extra_options} rs6000/sysv4.opt"
tmake_file="rs6000/t-fprules rs6000/t-fprules-fpbit rs6000/t-ppcgas rs6000/t-ppccomm"
;;
-rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4.[12]*)
- tm_file="${tm_file} rs6000/aix.h rs6000/aix41.h rs6000/xcoff.h"
- tmake_file="rs6000/t-fprules rs6000/t-fprules-fpbit rs6000/t-newas"
- extra_options="${extra_options} rs6000/aix41.opt"
- use_collect2=yes
- extra_headers=
- use_fixproto=yes
- ;;
rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix43.h rs6000/xcoff.h"
tmake_file=rs6000/t-aix43
tmake_file="$tmake_file sh/t-sh sh/t-elf sh/t-vxworks"
tm_file="${tm_file} elfos.h svr4.h sh/elf.h sh/embed-elf.h vx-common.h vxworks.h sh/vxworks.h"
;;
-sh-*-*)
- tm_file="${tm_file} dbxcoff.h sh/coff.h"
- ;;
sparc-*-netbsdelf*)
tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h netbsd.h netbsd-elf.h sparc/netbsd-elf.h"
extra_options="${extra_options} sparc/long-double-switch.opt"
#endif
-/* Define to the type of elements in the array set by `getgroups'. Usually
- this is either `int' or `gid_t'. */
-#ifndef USED_FOR_TARGET
-#undef GETGROUPS_T
-#endif
-
-
/* Define if the zone collector is in use */
#ifndef USED_FOR_TARGET
#undef GGC_ZONE
#endif
-/* Define to `int' if <sys/types.h> doesn't define. */
-#ifndef USED_FOR_TARGET
-#undef gid_t
-#endif
-
-
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#endif
-/* Define to `int' if <sys/types.h> doesn't define. */
-#ifndef USED_FOR_TARGET
-#undef uid_t
-#endif
-
-
/* Define as `fork' if `vfork' does not work. */
#ifndef USED_FOR_TARGET
#undef vfork
+++ /dev/null
-LIB1ASMSRC = arm/lib1funcs.asm
-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX _clzsi2 _clzdi2
-
-# We want fine grained libraries, so use the new code to build the
-# floating point emulation libraries.
-FPBIT = fp-bit.c
-DPBIT = dp-bit.c
-
-fp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define FLOAT' > fp-bit.c
- echo '#ifndef __ARMEB__' >> fp-bit.c
- echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
- echo '#endif' >> fp-bit.c
- cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-
-dp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#ifndef __ARMEB__' > dp-bit.c
- echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
- echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
- echo '#endif' >> dp-bit.c
- cat $(srcdir)/config/fp-bit.c >> dp-bit.c
-
-MULTILIB_OPTIONS = mlittle-endian/mbig-endian mhard-float/msoft-float marm/mthumb mno-thumb-interwork/mthumb-interwork
-MULTILIB_DIRNAMES = le be fpu soft arm thumb normal interwork
-MULTILIB_MATCHES =
-EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
-
-# Currently there is a bug somewhere in GCC's alias analysis
-# or scheduling code that is breaking _fpmul_parts in fp-bit.c.
-# Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -fno-inline
+++ /dev/null
-/* Definitions of target machine for GNU compiler.
- Renesas H8/300 version generating coff
- Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
- Contributed by Steve Chamberlain (sac@cygnus.com),
- Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#ifndef GCC_H8300_COFF_H
-#define GCC_H8300_COFF_H
-
-#define SDB_DEBUGGING_INFO 1
-#define SDB_DELIM "\n"
-
-/* Generate a blank trailing N_SO to mark the end of the .o file, since
- we can't depend upon the linker to mark .o file boundaries with
- embedded stabs. */
-
-#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
-
-/* This is how to output an assembler line
- that says to advance the location counter by SIZE bytes. */
-
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
- fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME)
-
-#define IDENT_ASM_OP "\t.ident\t"
-#define INIT_SECTION_ASM_OP "\t.section .init"
-#define READONLY_DATA_SECTION_ASM_OP "\t.section .rodata"
-
-/* Switch into a generic section. */
-#define TARGET_ASM_NAMED_SECTION h8300_asm_named_section
-
-/* A bit-field declared as `int' forces `int' alignment for the struct. */
-#define PCC_BITFIELD_TYPE_MATTERS 0
-
-#endif /* h8300/coff.h */
+++ /dev/null
-/* Definitions for "naked" Intel 386 using a.out (or coff encap'd
- a.out) object format and stabs debugging info.
-
- Copyright (C) 1994, 2002, 2007 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-
-#define TARGET_VERSION fprintf (stderr, " (80386, BSD a.out syntax)");
-
-/* end of i386-aout.h */
+++ /dev/null
-/* Definitions for "naked" Intel 386 using coff object format files
- and coff debugging info.
-
- Copyright (C) 1994, 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-
-#define TARGET_VERSION fprintf (stderr, " (80386, COFF BSD syntax)");
-
-#define TARGET_OS_CPP_BUILTINS() /* Sweet FA. */
-
-/* We want to be able to get DBX debugging information via -gstabs. */
-
-#define DBX_DEBUGGING_INFO 1
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
-
-/* Switch into a generic section. */
-#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
-
-/* Prefix for internally generated assembler labels. If we aren't using
- underscores, we are using prefix `.'s to identify labels that should
- be ignored, as in `i386/gas.h' --karl@cs.umb.edu */
-
-#undef LPREFIX
-#define LPREFIX ".L"
-
-/* The prefix to add to user-visible assembler symbols. */
-
-#undef USER_LABEL_PREFIX
-#define USER_LABEL_PREFIX ""
-
-/* If user-symbols don't have underscores,
- then it must take more than `L' to identify
- a label that should be ignored. */
-
-/* This is how to store into the string BUF
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \
- sprintf ((BUF), ".%s%ld", (PREFIX), (long)(NUMBER))
-
-/* GNU as expects alignment to be the number of bytes instead of the log for
- COFF targets. */
-
-#undef ASM_OUTPUT_ALIGN
-#define ASM_OUTPUT_ALIGN(FILE,LOG) \
- if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
-
-/* end of i386-coff.h */
+++ /dev/null
-/* libgloss.h -- operating system specific defines to be used when
- targeting GCC for Libgloss supported targets.
- Copyright (C) 1996, 2004, 2007 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-/* This file should not be used for ELF targets, as this definition of
- STARTFILE_SPEC is all wrong. */
-
-/* The libgloss standard for crt0.s has the name based on the command line
- option. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared:%{pg:pgcrt0%O%s}%{!pg:%{p:pcrt0%O%s}%{!p:crt0%O%s}}}"
-
-/* This file used to force LINK_SPEC to be the null string, but that is not
- correct. LINK_SPEC is used to pass machine specific arguments to the
- linker and hence cannot be redefined here. LINK_SPEC is never used to
- specify startup files or libraries, so it should never conflict with
- libgloss. */
-
-/* Don't set the target flags, this is done by the linker script */
-#undef LIB_SPEC
-#define LIB_SPEC ""
CRTSTUFF_T_CFLAGS_S = -fPIC
-
-# Don't run fixproto
-STMP_FIXPROTO =
-
# Don't install "assert.h" in gcc. We use the one in glibc.
INSTALL_ASSERT_H =
+++ /dev/null
-/* Definitions of target machine for GNU compiler.
- m68k series COFF object files and debugging, version.
- Copyright (C) 1994, 1996, 1997, 2000, 2002, 2003, 2004, 2007
- Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-/* This file is included after m68k.h by CPU COFF specific files. It
- is not a complete target itself. */
-
-/* Used in m68k.c to include required support code. */
-
-#define M68K_TARGET_COFF 1
-
-/* Generate sdb debugging information. */
-
-#define SDB_DEBUGGING_INFO 1
-
-/* COFF symbols don't start with an underscore. */
-
-#undef USER_LABEL_PREFIX
-#define USER_LABEL_PREFIX ""
-
-/* Use a prefix for local labels, just to be on the save side. */
-
-#undef LOCAL_LABEL_PREFIX
-#define LOCAL_LABEL_PREFIX "."
-
-/* Use a register prefix to avoid clashes with external symbols (classic
- example: `extern char PC;' in termcap). */
-
-#undef REGISTER_PREFIX
-#define REGISTER_PREFIX "%"
-
-/* config/m68k.md has an explicit reference to the program counter,
- prefix this by the register prefix. */
-
-#define ASM_RETURN_CASE_JUMP \
- do { \
- if (TARGET_COLDFIRE) \
- { \
- if (ADDRESS_REG_P (operands[0])) \
- return "jmp %%pc@(2,%0:l)"; \
- else \
- return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \
- } \
- else \
- return "jmp %%pc@(2,%0:w)"; \
- } while (0)
-
-#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
-
-/* If defined, a C expression whose value is a string containing the
- assembler operation to identify the following data as uninitialized global
- data. */
-
-#define BSS_SECTION_ASM_OP "\t.section\t.bss"
-
-/* A C statement (sans semicolon) to output to the stdio stream
- FILE the assembler definition of uninitialized global DECL named
- NAME whose size is SIZE bytes and alignment is ALIGN bytes.
- Try to use asm_output_aligned_bss to implement this macro. */
-
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
- asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
-
-/* Switch into a generic section. */
-#undef TARGET_ASM_NAMED_SECTION
-#define TARGET_ASM_NAMED_SECTION m68k_coff_asm_named_section
-
-/* Don't assume anything about startfiles. */
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC ""
+++ /dev/null
-/* Definitions of target machine for GNU compiler. "naked" 68020,
- a.out object files and debugging, version.
- Copyright (C) 1994, 1996, 2003, 2007 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#define DBX_DEBUGGING_INFO 1
-#undef SDB_DEBUGGING_INFO
-
-/* If defined, a C expression whose value is a string containing the
- assembler operation to identify the following data as uninitialized global
- data. */
-#define BSS_SECTION_ASM_OP "\t.bss"
-
-/* A C statement (sans semicolon) to output to the stdio stream
- FILE the assembler definition of uninitialized global DECL named
- NAME whose size is SIZE bytes. The variable ROUNDED
- is the size rounded up to whatever alignment the caller wants.
- Try to use asm_output_bss to implement this macro. */
-/* a.out files typically can't handle arbitrary variable alignments so
- define ASM_OUTPUT_BSS instead of ASM_OUTPUT_ALIGNED_BSS. */
-#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
- asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
/* Subroutines for insn-output.c for Motorola 68000 family.
Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2003, 2004, 2005, 2006, 2007, 2008
+ 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
static bool m68k_handle_option (size_t, const char *, int);
static rtx find_addr_reg (rtx);
static const char *singlemove_string (rtx *);
-#ifdef M68K_TARGET_COFF
-static void m68k_coff_asm_named_section (const char *, unsigned int, tree);
-#endif /* M68K_TARGET_COFF */
static void m68k_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
HOST_WIDE_INT, tree);
static rtx m68k_struct_value_rtx (tree, int);
return "jmp %a0";
}
-#ifdef M68K_TARGET_COFF
-
-/* Output assembly to switch to section NAME with attribute FLAGS. */
-
-static void
-m68k_coff_asm_named_section (const char *name, unsigned int flags,
- tree decl ATTRIBUTE_UNUSED)
-{
- char flagchar;
-
- if (flags & SECTION_WRITE)
- flagchar = 'd';
- else
- flagchar = 'x';
-
- fprintf (asm_out_file, "\t.section\t%s,\"%c\"\n", name, flagchar);
-}
-
-#endif /* M68K_TARGET_COFF */
-
static void
m68k_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset,
-# Find all of the declarations from the header files
-FIXPROTO_DEFINES = -D__EXTENSIONS__ -D_SGI_SOURCE -D_LANGUAGE_C_PLUS_PLUS
-
$(T)irix-crti.o: $(srcdir)/config/mips/irix-crti.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $@ -x assembler-with-cpp $<
-# So putenv and other functions get seen by fixproto.
-FIXPROTO_DEFINES = -D_HPUX_SOURCE -D_HIUX_SOURCE
-
lib2funcs.asm: $(srcdir)/config/pa/lib2funcs.asm
rm -f lib2funcs.asm
cp $(srcdir)/config/pa/lib2funcs.asm .
+++ /dev/null
-/* Definitions of target machine for GNU compiler, for a PDP with 2BSD
- Copyright (C) 1995, 1996, 1999, 2000, 2007 Free Software Foundation, Inc.
- Contributed by Michael K. Gschwind (mike@vlsivie.tuwien.ac.at).
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#define TWO_BSD
-
-/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
- the stack pointer does not matter. The value is tested only in
- functions that have frame pointers.
- No definition is equivalent to always zero. */
-
-#undef EXIT_IGNORE_STACK
-#define EXIT_IGNORE_STACK 1
-
-#undef INITIAL_FRAME_POINTER_OFFSET
-#define INITIAL_FRAME_POINTER_OFFSET(DEPTH_VAR) \
-{ \
- int offset; \
- offset = get_frame_size(); \
- offset = (offset <= 2)? 0: (offset -2); \
- (DEPTH_VAR) = offset+10; \
-}
-
-/* Value should be nonzero if functions must have frame pointers.
- Zero means the frame pointer need not be set up (and parms
- may be accessed via the stack pointer) in functions that seem suitable.
- This is computed in `reload', in reload1.c.
- */
-
-#undef FRAME_POINTER_REQUIRED
-#define FRAME_POINTER_REQUIRED 1
-
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET -8
-
-
-#undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
-do { \
-ASM_OUTPUT_LABEL (STREAM, NAME); \
-fprintf (STREAM, "~~%s:\n", NAME); \
-} while (0)
-
-#undef TARGET_UNIX_ASM_DEFAULT
-#define TARGET_UNIX_ASM_DEFAULT MASK_UNIX_ASM
/* Subroutines for gcc2 for pdp11.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Michael K. Gschwind (mike@vlsivie.tuwien.ac.at).
This file is part of GCC.
knowing which registers should not be saved even if used.
*/
-#ifdef TWO_BSD
-
-static void
-pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
-{
- fprintf (stream, "\tjsr r5, csv\n");
- if (size)
- {
- fprintf (stream, "\t/*abuse empty parameter slot for locals!*/\n");
- if (size > 2)
- asm_fprintf (stream, "\tsub $%#wo, sp\n", size - 2);
-
- }
-}
-
-#else /* !TWO_BSD */
-
static void
pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
{
fprintf (stream, "\t;/* end of prologue */\n\n");
}
-#endif /* !TWO_BSD */
-
/*
The function epilogue should not depend on the current stack pointer!
It should use the frame pointer only. This is mandatory because
maybe as option if you want to generate code for kernel mode? */
-#ifdef TWO_BSD
-
-static void
-pdp11_output_function_epilogue (FILE *stream,
- HOST_WIDE_INT size ATTRIBUTE_UNUSED)
-{
- fprintf (stream, "\t/* SP ignored by cret? */\n");
- fprintf (stream, "\tjmp cret\n");
-}
-
-#else /* !TWO_BSD */
-
static void
pdp11_output_function_epilogue (FILE *stream, HOST_WIDE_INT size)
{
fprintf (stream, "\t;/* end of epilogue*/\n\n\n");
}
-#endif /* !TWO_BSD */
-
/* Return the best assembler insn template
for moving operands[1] into operands[0] as a fullword. */
static const char *
+++ /dev/null
-/* Definitions of target machine for GNU compiler,
- for IBM RS/6000 POWER running AIX version 4.1.
- Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
- 2005, 2007
- Free Software Foundation, Inc.
- Contributed by David Edelsohn (edelsohn@gnu.org).
-
- This file is part of GCC.
-
- GCC is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GCC is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GCC; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-#undef ASM_SPEC
-#define ASM_SPEC "-u %(asm_cpu)"
-
-#undef ASM_DEFAULT_SPEC
-#define ASM_DEFAULT_SPEC "-mcom"
-
-#undef TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS() \
- do \
- { \
- TARGET_OS_AIX_CPP_BUILTINS (); \
- } \
- while (0)
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
- %{ansi: -D_ANSI_C_SOURCE}\
- %{mpe: -I/usr/lpp/ppe.poe/include}\
- %{pthread: -D_THREAD_SAFE}"
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT MASK_NEW_MNEMONICS
-
-#undef PROCESSOR_DEFAULT
-#define PROCESSOR_DEFAULT PROCESSOR_PPC601
-
-/* AIX does not support Altivec. */
-#undef TARGET_ALTIVEC
-#define TARGET_ALTIVEC 0
-#undef TARGET_ALTIVEC_ABI
-#define TARGET_ALTIVEC_ABI 0
-
-/* Define this macro as a C expression for the initializer of an
- array of string to tell the driver program which options are
- defaults for this target and thus do not need to be handled
- specially when using `MULTILIB_OPTIONS'.
-
- Do not define this macro if `MULTILIB_OPTIONS' is not defined in
- the target makefile fragment or if none of the options listed in
- `MULTILIB_OPTIONS' are set by default. *Note Target Fragment::. */
-
-#undef MULTILIB_DEFAULTS
-#define MULTILIB_DEFAULTS { "mcpu=common" }
-
-#undef LIB_SPEC
-#define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
- %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}}\
- %{mpe:-L/usr/lpp/ppe.poe/lib -lmpi -lvtd}\
- %{pthread: -L/usr/lib/threads -lpthreads -lc_r /usr/lib/libc.a}\
- %{!pthread: -lc}"
-
-#undef LINK_SPEC
-#define LINK_SPEC "-bpT:0x10000000 -bpD:0x20000000 %{!r:-btextro} -bnodelcsect\
- %{static:-bnso %(link_syscalls) } %{!shared: %{g*: %(link_libg) }}\
- %{shared:-bM:SRE %{!e:-bnoentry}}"
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared:\
- %{mpe:%{pg:/usr/lpp/ppe.poe/lib/gcrt0.o}\
- %{!pg:%{p:/usr/lpp/ppe.poe/lib/mcrt0.o}\
- %{!p:/usr/lpp/ppe.poe/lib/crt0.o}}}\
- %{!mpe:\
- %{pthread:%{pg:gcrt0_r%O%s}%{!pg:%{p:mcrt0_r%O%s}%{!p:crt0_r%O%s}}}\
- %{!pthread:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}}}"
-
-/* AIX 4 uses PowerPC nop (ori 0,0,0) instruction as call glue for PowerPC
- and "cror 31,31,31" for POWER architecture. */
-
-#undef RS6000_CALL_GLUE
-#define RS6000_CALL_GLUE "{cror 31,31,31|nop}"
-
-/* The IBM AIX 4.x assembler doesn't support forward references in
- .set directives. We handle this by deferring the output of .set
- directives to the end of the compilation unit. */
-#define TARGET_DEFERRED_OUTPUT_DEFS(DECL,TARGET) true
-
-#undef TARGET_64BIT
-#define TARGET_64BIT 0
+++ /dev/null
-; Options for AIX4.1.
-;
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
-; Contributed by Aldy Hernandez <aldy@quesejoda.com>.
-;
-; This file is part of GCC.
-;
-; GCC is free software; you can redistribute it and/or modify it under
-; the terms of the GNU General Public License as published by the Free
-; Software Foundation; either version 3, or (at your option) any later
-; version.
-;
-; GCC is distributed in the hope that it will be useful, but WITHOUT
-; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-; License for more details.
-;
-; You should have received a copy of the GNU General Public License
-; along with GCC; see the file COPYING3. If not see
-; <http://www.gnu.org/licenses/>.
-
-mpe
-Target Report RejectNegative Var(internal_nothing_1)
-Support message passing with the Parallel Environment
+++ /dev/null
-# Build the libraries for both hard and soft floating point and all of the
-# different processor models
-
-MULTILIB_OPTIONS = msoft-float \
- mcpu=common/mcpu=power/mcpu=powerpc
-
-MULTILIB_DIRNAMES = soft-float \
- common power powerpc
-
-MULTILIB_MATCHES = $(MULTILIB_MATCHES_FLOAT) \
- mcpu?power=mpower \
- mcpu?power=mrios1 \
- mcpu?power=mcpu?rios1 \
- mcpu?power=mcpu?rsc \
- mcpu?power=mcpu?rsc1 \
- mcpu?power=mpower2 \
- mcpu?power=mrios2 \
- mcpu?power=mcpu=rios2 \
- mcpu?powerpc=mcpu?601 \
- mcpu?powerpc=mcpu?602 \
- mcpu?powerpc=mcpu?603 \
- mcpu?powerpc=mcpu?603e \
- mcpu?powerpc=mcpu?604 \
- mcpu?powerpc=mcpu?620 \
- mcpu?powerpc=mcpu?403 \
- mcpu?powerpc=mpowerpc \
- mcpu?powerpc=mpowerpc-gpopt \
- mcpu?powerpc=mpowerpc-gfxopt
-
-# GCC 128-bit long double support routines.
-LIB2FUNCS_EXTRA = $(srcdir)/config/rs6000/darwin-ldouble.c
-
-# Aix 3.2.x needs milli.exp for -mcpu=common
-EXTRA_PARTS = milli.exp
-$(T)milli.exp: $(srcdir)/config/rs6000/milli.exp
- rm -f $(T)milli.exp
- cp $(srcdir)/config/rs6000/milli.exp $(T)milli.exp
+++ /dev/null
-/* Definitions of target machine for gcc for Renesas / SuperH SH using ELF.
- Copyright (C) 1997, 1998, 2001, 2002, 2007 Free Software Foundation, Inc.
- Contributed by Jörn Rennecke <joern.rennecke@superh.com>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-/* Generate SDB debugging information. */
-
-#define SDB_DEBUGGING_INFO 1
-
-#define SDB_DELIM ";"
-
-#ifndef MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT 128
-#endif
-
-#define IDENT_ASM_OP "\t.ident\t"
-
-/* Switch into a generic section. */
-#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
-
-/* The prefix to add to user-visible assembler symbols. */
-
-#define USER_LABEL_PREFIX "_"
-
-/* The prefix to add to an internally generated label. */
-
-#define LOCAL_LABEL_PREFIX ""
-
-/* Make an internal label into a string. */
-#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
- sprintf ((STRING), "*%s%s%ld", LOCAL_LABEL_PREFIX, (PREFIX), (long)(NUM))
-
-/* This is how to output an assembler line
- that says to advance the location counter by SIZE bytes. */
-
-#define ASM_OUTPUT_SKIP(FILE,SIZE) \
- fprintf ((FILE), "\t.space %d\n", (int)(SIZE))
-
-/* This says how to output an assembler line
- to define a global common symbol. */
-
-#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
-( fputs ("\t.comm ", (FILE)), \
- assemble_name ((FILE), (NAME)), \
- fprintf ((FILE), ",%d\n", (int)(SIZE)))
-
-/* This says how to output an assembler line
- to define a local common symbol. */
-
-#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
-( fputs ("\t.lcomm ", (FILE)), \
- assemble_name ((FILE), (NAME)), \
- fprintf ((FILE), ",%d\n", (int)(SIZE)))
-
-#define DWARF2_UNWIND_INFO 0
CRTSTUFF_T_CFLAGS_S = $(CRTSTUFF_T_CFLAGS) -fPIC
TARGET_LIBGCC2_CFLAGS = -fPIC
-
-# See all the declarations.
-FIXPROTO_DEFINES = -D_XOPEN_SOURCE
-# Don't run fixproto.
-STMP_FIXPROTO =
-
# Build libgcc using the multilib mechanism
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_libsubdir build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP loose_warn strict_warn warn_cflags nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_decimal_float enable_fixed_point enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI datarootdir docdir htmldir SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS BUILD_LDFLAGS STMP_FIXINC STMP_FIXPROTO collect2 LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN OBJDUMP ac_ct_OBJDUMP ac_ct_AR STRIP ac_ct_STRIP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 objdir enable_fast_install gcc_cv_as ORIGINAL_AS_FOR_TARGET gcc_cv_ld ORIGINAL_LD_FOR_TARGET gcc_cv_nm ORIGINAL_NM_FOR_TARGET gcc_cv_objdump gcc_cv_readelf libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir subdirs srcdir all_compilers all_gtfiles all_lang_makefrags all_lang_makefiles all_languages all_selected_languages build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines build_file_translate check_languages cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs fortran_target_objs target_cpu_default GMPLIBS GMPINC PPLLIBS PPLINC CLOOGLIBS CLOOGINC LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_libsubdir build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP loose_warn strict_warn warn_cflags nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_decimal_float enable_fixed_point enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI datarootdir docdir htmldir SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS BUILD_LDFLAGS STMP_FIXINC collect2 LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN OBJDUMP ac_ct_OBJDUMP ac_ct_AR STRIP ac_ct_STRIP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 objdir enable_fast_install gcc_cv_as ORIGINAL_AS_FOR_TARGET gcc_cv_ld ORIGINAL_LD_FOR_TARGET gcc_cv_nm ORIGINAL_NM_FOR_TARGET gcc_cv_objdump gcc_cv_readelf libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir subdirs srcdir all_compilers all_gtfiles all_lang_makefrags all_lang_makefiles all_languages all_selected_languages build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines build_file_translate check_languages cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs fortran_target_objs target_cpu_default GMPLIBS GMPINC PPLLIBS PPLINC CLOOGLIBS CLOOGINC LIBOBJS LTLIBOBJS'
ac_subst_files='language_hooks'
ac_pwd=`pwd`
fi
-# Try to determine the array type of the second argument of getgroups
-# for the target system (int or gid_t).
-echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5
-echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6
-if test "${ac_cv_type_uid_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "uid_t" >/dev/null 2>&1; then
- ac_cv_type_uid_t=yes
-else
- ac_cv_type_uid_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
-echo "${ECHO_T}$ac_cv_type_uid_t" >&6
-if test $ac_cv_type_uid_t = no; then
-
-cat >>confdefs.h <<\_ACEOF
-#define uid_t int
-_ACEOF
-
-
-cat >>confdefs.h <<\_ACEOF
-#define gid_t int
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking type of array argument to getgroups" >&5
-echo $ECHO_N "checking type of array argument to getgroups... $ECHO_C" >&6
-if test "${ac_cv_type_getgroups+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_type_getgroups=cross
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Thanks to Mike Rendell for this test. */
-#include <sys/types.h>
-#define NGID 256
-#undef MAX
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-
-int
-main ()
-{
- gid_t gidset[NGID];
- int i, n;
- union { gid_t gval; long lval; } val;
-
- val.lval = -1;
- for (i = 0; i < NGID; i++)
- gidset[i] = val.gval;
- n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
- gidset);
- /* Exit non-zero if getgroups seems to require an array of ints. This
- happens when gid_t is short but getgroups modifies an array of ints. */
- exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_getgroups=gid_t
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_type_getgroups=int
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-if test $ac_cv_type_getgroups = cross; then
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <unistd.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then
- ac_cv_type_getgroups=gid_t
-else
- ac_cv_type_getgroups=int
-fi
-rm -f conftest*
-
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_getgroups" >&5
-echo "${ECHO_T}$ac_cv_type_getgroups" >&6
-
-cat >>confdefs.h <<_ACEOF
-#define GETGROUPS_T $ac_cv_type_getgroups
-_ACEOF
-
-
-if test "${target}" = "${build}"; then
- TARGET_GETGROUPS_T=$ac_cv_type_getgroups
-else
- case "${target}" in
- # This condition may need some tweaking. It should include all
- # targets where the array type of the second argument of getgroups
- # is int and the type of gid_t is not equivalent to int.
- *-*-sunos* | *-*-ultrix*)
- TARGET_GETGROUPS_T=int
- ;;
- *)
- TARGET_GETGROUPS_T=gid_t
- ;;
- esac
-fi
-
-
echo "$as_me:$LINENO: checking for sys/mman.h" >&5
echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6
# When building gcc with a cross-compiler, we need to adjust things so
# that the generator programs are still built with the native compiler.
-# Also, we cannot run fixincludes or fix-header.
+# Also, we cannot run fixincludes.
# These are the normal (build=host) settings:
CC_FOR_BUILD='$(CC)'
BUILD_LDFLAGS='$(LDFLAGS)'
STMP_FIXINC=stmp-fixinc
-# Possibly disable fixproto, on a per-target basis.
-case ${use_fixproto} in
- no)
- STMP_FIXPROTO=
- ;;
- yes)
- STMP_FIXPROTO=stmp-fixproto
- ;;
-esac
-
-
# And these apply if build != host, or we are generating coverage data
if test x$build != x$host || test "x$coverage_flags" != x
then
BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
-
- if test "x$TARGET_SYSTEM_ROOT" = x; then
- if test "x$STMP_FIXPROTO" != x; then
- STMP_FIXPROTO=stmp-install-fixproto
- fi
- fi
fi
# Expand extra_headers to include complete path.
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:14512: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:14351: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:14515: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:14354: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:14518: output\"" >&5)
+ (eval echo "\"\$as_me:14357: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 15675 "configure"' > conftest.$ac_ext
+ echo '#line 15514 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16974: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16813: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16978: \$? = $ac_status" >&5
+ echo "$as_me:16817: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17313: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17152: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:17317: \$? = $ac_status" >&5
+ echo "$as_me:17156: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17418: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17257: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:17422: \$? = $ac_status" >&5
+ echo "$as_me:17261: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17473: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17312: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:17477: \$? = $ac_status" >&5
+ echo "$as_me:17316: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 20285 "configure"
+#line 20124 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 20381 "configure"
+#line 20220 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
s,@COLLECT2_LIBS@,$COLLECT2_LIBS,;t t
s,@GNAT_LIBEXC@,$GNAT_LIBEXC,;t t
s,@LDEXP_LIB@,$LDEXP_LIB,;t t
-s,@TARGET_GETGROUPS_T@,$TARGET_GETGROUPS_T,;t t
s,@LIBICONV@,$LIBICONV,;t t
s,@LTLIBICONV@,$LTLIBICONV,;t t
s,@LIBICONV_DEP@,$LIBICONV_DEP,;t t
s,@BUILD_CFLAGS@,$BUILD_CFLAGS,;t t
s,@BUILD_LDFLAGS@,$BUILD_LDFLAGS,;t t
s,@STMP_FIXINC@,$STMP_FIXINC,;t t
-s,@STMP_FIXPROTO@,$STMP_FIXPROTO,;t t
s,@collect2@,$collect2,;t t
s,@LIBTOOL@,$LIBTOOL,;t t
s,@SED@,$SED,;t t
# Process this file with autoconf to generate a configuration script.
# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-# 2007, 2008 Free Software Foundation, Inc.
+# 2007, 2008, 2009 Free Software Foundation, Inc.
#This file is part of GCC.
AC_CHECK_TYPE(ssize_t, int)
AC_CHECK_TYPE(caddr_t, char *)
-# Try to determine the array type of the second argument of getgroups
-# for the target system (int or gid_t).
-AC_TYPE_GETGROUPS
-if test "${target}" = "${build}"; then
- TARGET_GETGROUPS_T=$ac_cv_type_getgroups
-else
- case "${target}" in
- # This condition may need some tweaking. It should include all
- # targets where the array type of the second argument of getgroups
- # is int and the type of gid_t is not equivalent to int.
- *-*-sunos* | *-*-ultrix*)
- TARGET_GETGROUPS_T=int
- ;;
- *)
- TARGET_GETGROUPS_T=gid_t
- ;;
- esac
-fi
-AC_SUBST(TARGET_GETGROUPS_T)
-
gcc_AC_FUNC_MMAP_BLACKLIST
case "${host}" in
# When building gcc with a cross-compiler, we need to adjust things so
# that the generator programs are still built with the native compiler.
-# Also, we cannot run fixincludes or fix-header.
+# Also, we cannot run fixincludes.
# These are the normal (build=host) settings:
CC_FOR_BUILD='$(CC)' AC_SUBST(CC_FOR_BUILD)
BUILD_LDFLAGS='$(LDFLAGS)' AC_SUBST(BUILD_LDFLAGS)
STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_FIXINC)
-# Possibly disable fixproto, on a per-target basis.
-case ${use_fixproto} in
- no)
- STMP_FIXPROTO=
- ;;
- yes)
- STMP_FIXPROTO=stmp-fixproto
- ;;
-esac
-AC_SUBST(STMP_FIXPROTO)
-
# And these apply if build != host, or we are generating coverage data
if test x$build != x$host || test "x$coverage_flags" != x
then
BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
-
- if test "x$TARGET_SYSTEM_ROOT" = x; then
- if test "x$STMP_FIXPROTO" != x; then
- STMP_FIXPROTO=stmp-install-fixproto
- fi
- fi
fi
# Expand extra_headers to include complete path.
/* Specialized bits of code needed to support construction and
destruction of file-scope objects in C++ code.
- Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com).
This file is part of GCC.
identified the set of defines that need to go into auto-target.h,
this will have to do. */
#include "auto-host.h"
-#undef gid_t
#undef pid_t
#undef rlim_t
#undef ssize_t
-#undef uid_t
#undef vfork
#include "tconfig.h"
#include "tsystem.h"
@item
@var{target} must be specified as @option{--target=@var{target}}
when configuring a cross compiler; examples of valid targets would be
-m68k-coff, sh-elf, etc.
+m68k-elf, sh-elf, etc.
@item
Specifying just @var{target} instead of @option{--target=@var{target}}
@uref{#arc-x-elf,,arc-*-elf}
@item
@uref{#arm-x-elf,,arm-*-elf}
-@uref{#arm-x-coff,,arm-*-coff}
-@uref{#arm-x-aout,,arm-*-aout}
@item
@uref{#avr,,avr}
@item
@code{arm-*-freebsd}, @code{arm-*-netbsdelf}, @code{arm-*-*linux}
and @code{arm-*-rtems}.
-@html
-<hr />
-@end html
-@heading @anchor{arm-x-coff}arm-*-coff
-ARM-family processors. Note that there are two different varieties
-of PE format subtarget supported: @code{arm-wince-pe} and
-@code{arm-pe} as well as a standard COFF target @code{arm-*-coff}.
-
-@html
-<hr />
-@end html
-@heading @anchor{arm-x-aout}arm-*-aout
-ARM-family processors. These targets support the AOUT file format:
-@code{arm-*-aout}, @code{arm-*-netbsd}.
-
@html
<hr />
@end html
@end html
@heading @anchor{x-ibm-aix}*-ibm-aix*
Support for AIX version 3 and older was discontinued in GCC 3.4.
+Support for AIX version 4.2 and older was discontinued in GCC 4.5.
``out of memory'' bootstrap failures may indicate a problem with
process resource limits (ulimit). Hard limits are configured in the
expects. If one encounters this problem, set the @env{LANG}
environment variable to @samp{C} or @samp{En_US}.
-By default, GCC for AIX 4.1 and above produces code that can be used on
-both Power or PowerPC processors.
-
A default can be specified with the @option{-mcpu=@var{cpu_type}}
switch and using the configure option @option{--with-cpu-@var{cpu_type}}.
<hr />
@end html
@heading @anchor{m68k-x-x}m68k-*-*
-By default, @samp{m68k-*-aout}, @samp{m68k-*-coff*},
+By default,
@samp{m68k-*-elf*}, @samp{m68k-*-rtems}, @samp{m68k-*-uclinux} and
@samp{m68k-*-linux}
build libraries for both M680x0 and ColdFire processors. If you only
and register usage.
* Environment Variables:: Env vars that affect GCC.
* Precompiled Headers:: Compiling a header once, and using it many times.
-* Running Protoize:: Automatically adding or removing function prototypes.
@end menu
@c man begin OPTIONS
behavior for the options. For instance, if you use @option{-g} to
generate the precompiled header but not when using it, you may or may
not get debugging information for routines in the precompiled header.
-
-@node Running Protoize
-@section Running Protoize
-
-The program @code{protoize} is an optional part of GCC@. You can use
-it to add prototypes to a program, thus converting the program to ISO
-C in one respect. The companion program @code{unprotoize} does the
-reverse: it removes argument types from any prototypes that are found.
-
-When you run these programs, you must specify a set of source files as
-command line arguments. The conversion programs start out by compiling
-these files to see what functions they define. The information gathered
-about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
-
-After scanning comes actual conversion. The specified files are all
-eligible to be converted; any files they include (whether sources or
-just headers) are eligible as well.
-
-But not all the eligible files are converted. By default,
-@code{protoize} and @code{unprotoize} convert only source and header
-files in the current directory. You can specify additional directories
-whose files should be converted with the @option{-d @var{directory}}
-option. You can also specify particular files to exclude with the
-@option{-x @var{file}} option. A file is converted if it is eligible, its
-directory name matches one of the specified directory names, and its
-name within the directory has not been excluded.
-
-Basic conversion with @code{protoize} consists of rewriting most
-function definitions and function declarations to specify the types of
-the arguments. The only ones not rewritten are those for varargs
-functions.
-
-@code{protoize} optionally inserts prototype declarations at the
-beginning of the source file, to make them available for any calls that
-precede the function's definition. Or it can insert prototype
-declarations with block scope in the blocks where undeclared functions
-are called.
-
-Basic conversion with @code{unprotoize} consists of rewriting most
-function declarations to remove any argument types, and rewriting
-function definitions to the old-style pre-ISO form.
-
-Both conversion programs print a warning for any function declaration or
-definition that they can't convert. You can suppress these warnings
-with @option{-q}.
-
-The output from @code{protoize} or @code{unprotoize} replaces the
-original source file. The original file is renamed to a name ending
-with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
-without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
-for DOS) file already exists, then the source file is simply discarded.
-
-@code{protoize} and @code{unprotoize} both depend on GCC itself to
-scan the program and collect information about the functions it uses.
-So neither of these programs will work until GCC is installed.
-
-Here is a table of the options you can use with @code{protoize} and
-@code{unprotoize}. Each option works with both programs unless
-otherwise stated.
-
-@table @code
-@item -B @var{directory}
-Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
-usual directory (normally @file{/usr/local/lib}). This file contains
-prototype information about standard system functions. This option
-applies only to @code{protoize}.
-
-@item -c @var{compilation-options}
-Use @var{compilation-options} as the options when running @command{gcc} to
-produce the @samp{.X} files. The special option @option{-aux-info} is
-always passed in addition, to tell @command{gcc} to write a @samp{.X} file.
-
-Note that the compilation options must be given as a single argument to
-@code{protoize} or @code{unprotoize}. If you want to specify several
-@command{gcc} options, you must quote the entire set of compilation options
-to make them a single word in the shell.
-
-There are certain @command{gcc} arguments that you cannot use, because they
-would produce the wrong kind of output. These include @option{-g},
-@option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in
-the @var{compilation-options}, they are ignored.
-
-@item -C
-Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
-systems) instead of @samp{.c}. This is convenient if you are converting
-a C program to C++. This option applies only to @code{protoize}.
-
-@item -g
-Add explicit global declarations. This means inserting explicit
-declarations at the beginning of each source file for each function
-that is called in the file and was not declared. These declarations
-precede the first function definition that contains a call to an
-undeclared function. This option applies only to @code{protoize}.
-
-@item -i @var{string}
-Indent old-style parameter declarations with the string @var{string}.
-This option applies only to @code{protoize}.
-
-@code{unprotoize} converts prototyped function definitions to old-style
-function definitions, where the arguments are declared between the
-argument list and the initial @samp{@{}. By default, @code{unprotoize}
-uses five spaces as the indentation. If you want to indent with just
-one space instead, use @option{-i " "}.
-
-@item -k
-Keep the @samp{.X} files. Normally, they are deleted after conversion
-is finished.
-
-@item -l
-Add explicit local declarations. @code{protoize} with @option{-l} inserts
-a prototype declaration for each function in each block which calls the
-function without any declaration. This option applies only to
-@code{protoize}.
-
-@item -n
-Make no real changes. This mode just prints information about the conversions
-that would have been done without @option{-n}.
-
-@item -N
-Make no @samp{.save} files. The original files are simply deleted.
-Use this option with caution.
-
-@item -p @var{program}
-Use the program @var{program} as the compiler. Normally, the name
-@file{gcc} is used.
-
-@item -q
-Work quietly. Most warnings are suppressed.
-
-@item -v
-Print the version number, just like @option{-v} for @command{gcc}.
-@end table
-
-If you need special compiler options to compile one of your program's
-source files, then you should generate that file's @samp{.X} file
-specially, by running @command{gcc} on that source file with the
-appropriate options and the option @option{-aux-info}. Then run
-@code{protoize} on the entire set of files. @code{protoize} will use
-the existing @samp{.X} file because it is newer than the source file.
-For example:
-
-@smallexample
-gcc -Dfoo=bar file1.c -aux-info file1.X
-protoize *.c
-@end smallexample
-
-@noindent
-You need to include the special files along with the rest in the
-@code{protoize} command, even though their @samp{.X} files already
-exist, because otherwise they won't get converted.
-
-@xref{Protoize Caveats}, for more information on how to use
-@code{protoize} successfully.
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-@c 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+@c 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
@c Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
compliant with the ISO C standard.
* Disappointments:: Regrettable things we can't change, but not quite bugs.
* C++ Misunderstandings:: Common misunderstandings with GNU C++.
-* Protoize Caveats:: Things to watch out for when using @code{protoize}.
* Non-bugs:: Things we think are right, but some others disagree.
* Warnings and Errors:: Which problems in your code get warnings,
and which get errors.
directory of system header files is automounted, it tends to be
unmounted while @code{fixincludes} is running. This would seem to be a
bug in the automounter. We don't know any good way to work around it.
-
-@item
-The @code{fixproto} script will sometimes add prototypes for the
-@code{sigsetjmp} and @code{siglongjmp} functions that reference the
-@code{jmp_buf} type before that type is defined. To work around this,
-edit the offending file and place the typedef in front of the
-prototypes.
@end itemize
@node Cross-Compiler Problems
operator, the application can define whether and how the virtual base
subobject is assigned.
-@node Protoize Caveats
-@section Caveats of using @command{protoize}
-
-The conversion programs @command{protoize} and @command{unprotoize} can
-sometimes change a source file in a way that won't work unless you
-rearrange it.
-
-@itemize @bullet
-@item
-@command{protoize} can insert references to a type name or type tag before
-the definition, or in a file where they are not defined.
-
-If this happens, compiler error messages should show you where the new
-references are, so fixing the file by hand is straightforward.
-
-@item
-There are some C constructs which @command{protoize} cannot figure out.
-For example, it can't determine argument types for declaring a
-pointer-to-function variable; this you must do by hand. @command{protoize}
-inserts a comment containing @samp{???} each time it finds such a
-variable; so you can find all such variables by searching for this
-string. ISO C does not require declaring the argument types of
-pointer-to-function types.
-
-@item
-Using @command{unprotoize} can easily introduce bugs. If the program
-relied on prototypes to bring about conversion of arguments, these
-conversions will not take place in the program without prototypes.
-One case in which you can be sure @command{unprotoize} is safe is when
-you are removing prototypes that were made with @command{protoize}; if
-the program worked before without any prototypes, it will work again
-without them.
-
-@opindex Wtraditional-conversion
-You can find all the places where this problem might occur by compiling
-the program with the @option{-Wtraditional-conversion} option. It
-prints a warning whenever an argument is converted.
-
-@item
-Both conversion programs can be confused if there are macro calls in and
-around the text to be converted. In other words, the standard syntax
-for a declaration or definition must not result from expanding a macro.
-This problem is inherent in the design of C and cannot be fixed. If
-only a few functions have confusing macro calls, you can easily convert
-them manually.
-
-@item
-@command{protoize} cannot get the argument types for a function whose
-definition was not actually compiled due to preprocessing conditionals.
-When this happens, @command{protoize} changes nothing in regard to such
-a function. @command{protoize} tries to detect such instances and warn
-about them.
-
-You can generally work around this problem by using @command{protoize} step
-by step, each time specifying a different set of @option{-D} options for
-compilation, until all of the functions have been converted. There is
-no automatic way to verify that you have got them all, however.
-
-@item
-Confusion may result if there is an occasion to convert a function
-declaration or definition in a region of source code where there is more
-than one formal parameter list present. Thus, attempts to convert code
-containing multiple (conditionally compiled) versions of a single
-function header (in the same vicinity) may not produce the desired (or
-expected) results.
-
-If you plan on converting source files which contain such code, it is
-recommended that you first make sure that each conditionally compiled
-region of source code which contains an alternative function header also
-contains at least one additional follower token (past the final right
-parenthesis of the function header). This should circumvent the
-problem.
-
-@item
-@command{unprotoize} can become confused when trying to convert a function
-definition or declaration which contains a declaration for a
-pointer-to-function formal argument which has the same name as the
-function being defined or declared. We recommend you avoid such choices
-of formal parameter names.
-
-@item
-You might also want to correct some of the indentation by hand and break
-long lines. (The conversion programs don't write lines longer than
-eighty characters in any case.)
-@end itemize
-
@node Non-bugs
@section Certain Changes We Don't Want to Make
+++ /dev/null
-/* fix-header.c - Make C header file suitable for C++.
- Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
-
- 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, 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; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-/* This program massages a system include file (such as stdio.h),
- into a form that is compatible with GNU C and GNU C++.
-
- * extern "C" { ... } braces are added (inside #ifndef __cplusplus),
- if they seem to be needed. These prevent C++ compilers from name
- mangling the functions inside the braces.
-
- * If an old-style incomplete function declaration is seen (without
- an argument list), and it is a "standard" function listed in
- the file sys-protos.h (and with a non-empty argument list), then
- the declaration is converted to a complete prototype by replacing
- the empty parameter list with the argument list from sys-protos.h.
-
- * The program can be given a list of (names of) required standard
- functions (such as fclose for stdio.h). If a required function
- is not seen in the input, then a prototype for it will be
- written to the output.
-
- * If all of the non-comment code of the original file is protected
- against multiple inclusion:
- #ifndef FOO
- #define FOO
- <body of include file>
- #endif
- then extra matter added to the include file is placed inside the <body>.
-
- * If the input file is OK (nothing needs to be done);
- the output file is not written (nor removed if it exists).
-
- There are also some special actions that are done for certain
- well-known standard include files:
-
- * If argv[1] is "sys/stat.h", the Posix.1 macros
- S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK, S_ISREG are added if
- they were missing, and the corresponding "traditional" S_IFxxx
- macros were defined.
-
- * If argv[1] is "errno.h", errno is declared if it was missing.
-
- * TODO: The input file should be read complete into memory, because:
- a) it needs to be scanned twice anyway, and
- b) it would be nice to allow update in place.
-
- Usage:
- fix-header FOO.H INFILE.H OUTFILE.H [OPTIONS]
- where:
- * FOO.H is the relative file name of the include file,
- as it would be #include'd by a C file. (E.g. stdio.h)
- * INFILE.H is a full pathname for the input file (e.g. /usr/include/stdio.h)
- * OUTFILE.H is the full pathname for where to write the output file,
- if anything needs to be done. (e.g. ./include/stdio.h)
- * OPTIONS can be -D or -I switches as you would pass to cpp.
-
- Written by Per Bothner <bothner@cygnus.com>, July 1993. */
-
-#include "bconfig.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "obstack.h"
-#include "scan.h"
-#include "cpplib.h"
-#include "incpath.h"
-#include "errors.h"
-
-#ifdef TARGET_EXTRA_INCLUDES
-void
-TARGET_EXTRA_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
- const char *iprefix ATTRIBUTE_UNUSED,
- int stdinc ATTRIBUTE_UNUSED)
-{
-}
-#endif
-
-#ifdef TARGET_EXTRA_PRE_INCLUDES
-void
-TARGET_EXTRA_PRE_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
- const char *iprefix ATTRIBUTE_UNUSED,
- int stdinc ATTRIBUTE_UNUSED)
-{
-}
-#endif
-
-struct line_maps line_table;
-
-sstring buf;
-
-int verbose = 0;
-int partial_count = 0;
-int warnings = 0;
-
-#if ADD_MISSING_EXTERN_C
-int missing_extern_C_count = 0;
-#endif
-
-#include "xsys-protos.h"
-
-#ifdef FIXPROTO_IGNORE_LIST
-/* This is a currently unused feature. */
-
-/* List of files and directories to ignore.
- A directory name (ending in '/') means ignore anything in that
- directory. (It might be more efficient to do directory pruning
- earlier in fixproto, but this is simpler and easier to customize.) */
-
-static const char *const files_to_ignore[] = {
- "X11/",
- FIXPROTO_IGNORE_LIST
- 0
-};
-#endif
-
-char *inf_buffer;
-char *inf_limit;
-char *inf_ptr;
-static const char *cur_file;
-
-/* Certain standard files get extra treatment */
-
-enum special_file
-{
- no_special,
-#ifdef errno_h
-#undef errno_h
-#endif
- errno_h,
-#ifdef stdio_h
-#undef stdio_h
-#endif
- stdio_h,
-#ifdef stdlib_h
-#undef stdlib_h
-#endif
- stdlib_h,
-#ifdef sys_stat_h
-#undef sys_stat_h
-#endif
- sys_stat_h
-};
-
-/* A NAMELIST is a sequence of names, separated by '\0', and terminated
- by an empty name (i.e. by "\0\0"). */
-
-typedef const char *namelist;
-
-/* The following macros provide the bits for symbol_flags. */
-typedef int symbol_flags;
-
-/* Used to mark names defined in the ANSI/ISO C standard. */
-#define ANSI_SYMBOL 1
-
-/* We no longer massage include files for POSIX or XOPEN symbols,
- as there are now several versions of the POSIX and XOPEN standards,
- and it would be a maintenance nightmare for us to track them all.
- Better to be compatible with the system include files. */
-/*#define ADD_MISSING_POSIX 1 */
-/*#define ADD_MISSING_XOPEN 1 */
-
-#if ADD_MISSING_POSIX
-/* Used to mark names defined in the Posix.1 or Posix.2 standard. */
-#define POSIX1_SYMBOL 2
-#define POSIX2_SYMBOL 4
-#else
-#define POSIX1_SYMBOL 0
-#define POSIX2_SYMBOL 0
-#endif
-
-#if ADD_MISSING_XOPEN
-/* Used to mark names defined in X/Open Portability Guide. */
-#define XOPEN_SYMBOL 8
-/* Used to mark names defined in X/Open UNIX Extensions. */
-#define XOPEN_EXTENDED_SYMBOL 16
-#else
-#define XOPEN_SYMBOL 0
-#define XOPEN_EXTENDED_SYMBOL 0
-#endif
-
-/* Used to indicate names that are not functions */
-#define MACRO_SYMBOL 512
-
-struct symbol_list {
- symbol_flags flags;
- namelist names;
-};
-
-#define SYMBOL_TABLE_SIZE 10
-struct symbol_list symbol_table[SYMBOL_TABLE_SIZE];
-int cur_symbol_table_size;
-
-static void add_symbols (symbol_flags, namelist);
-static struct fn_decl *lookup_std_proto (const char *, int);
-static void write_lbrac (void);
-static void recognized_macro (const char *);
-static void check_macro_names (cpp_reader *, namelist);
-static void read_scan_file (char *, int, char **);
-static void write_rbrac (void);
-static int inf_skip_spaces (int);
-static int inf_read_upto (sstring *, int);
-static int inf_scan_ident (sstring *, int);
-static int check_protection (int *, int *);
-static void cb_file_change (cpp_reader *, const struct line_map *);
-
-static void
-add_symbols (symbol_flags flags, namelist names)
-{
- symbol_table[cur_symbol_table_size].flags = flags;
- symbol_table[cur_symbol_table_size].names = names;
- cur_symbol_table_size++;
- if (cur_symbol_table_size >= SYMBOL_TABLE_SIZE)
- fatal ("too many calls to add_symbols");
- symbol_table[cur_symbol_table_size].names = NULL; /* Termination. */
-}
-
-struct std_include_entry {
- const char *const name;
- const symbol_flags flags;
- const namelist names;
-};
-
-const char NONE[] = ""; /* The empty namelist. */
-
-/* Special name to indicate a continuation line in std_include_table. */
-const char CONTINUED[] = "";
-
-const struct std_include_entry *include_entry;
-
-const struct std_include_entry std_include_table [] = {
- { "ctype.h", ANSI_SYMBOL,
- "isalnum\0isalpha\0iscntrl\0isdigit\0isgraph\0islower\0\
-isprint\0ispunct\0isspace\0isupper\0isxdigit\0tolower\0toupper\0" },
-
- { "dirent.h", POSIX1_SYMBOL, "closedir\0opendir\0readdir\0rewinddir\0"},
-
- { "errno.h", ANSI_SYMBOL|MACRO_SYMBOL, "errno\0" },
-
- /* ANSI_SYMBOL is wrong, but ... */
- { "curses.h", ANSI_SYMBOL, "box\0delwin\0endwin\0getcurx\0getcury\0initscr\0\
-mvcur\0mvwprintw\0mvwscanw\0newwin\0overlay\0overwrite\0\
-scroll\0subwin\0touchwin\0waddstr\0wclear\0wclrtobot\0wclrtoeol\0\
-waddch\0wdelch\0wdeleteln\0werase\0wgetch\0wgetstr\0winsch\0winsertln\0\
-wmove\0wprintw\0wrefresh\0wscanw\0wstandend\0wstandout\0" },
-
- { "fcntl.h", POSIX1_SYMBOL, "creat\0fcntl\0open\0" },
-
- /* Maybe also "getgrent fgetgrent setgrent endgrent" */
- { "grp.h", POSIX1_SYMBOL, "getgrgid\0getgrnam\0" },
-
-/*{ "limit.h", ... provided by gcc }, */
-
- { "locale.h", ANSI_SYMBOL, "localeconv\0setlocale\0" },
-
- { "math.h", ANSI_SYMBOL,
- "acos\0asin\0atan\0atan2\0ceil\0cos\0cosh\0exp\0\
-fabs\0floor\0fmod\0frexp\0ldexp\0log10\0log\0modf\0pow\0sin\0sinh\0sqrt\0\
-tan\0tanh\0" },
-
- { CONTINUED, ANSI_SYMBOL|MACRO_SYMBOL, "HUGE_VAL\0" },
-
- { "pwd.h", POSIX1_SYMBOL, "getpwnam\0getpwuid\0" },
-
- /* Left out siglongjmp sigsetjmp - these depend on sigjmp_buf. */
- { "setjmp.h", ANSI_SYMBOL, "longjmp\0setjmp\0" },
-
- /* Left out signal() - its prototype is too complex for us!
- Also left out "sigaction sigaddset sigdelset sigemptyset
- sigfillset sigismember sigpending sigprocmask sigsuspend"
- because these need sigset_t or struct sigaction.
- Most systems that provide them will also declare them. */
- { "signal.h", ANSI_SYMBOL, "raise\0" },
- { CONTINUED, POSIX1_SYMBOL, "kill\0" },
-
- { "stdio.h", ANSI_SYMBOL,
- "clearerr\0fclose\0feof\0ferror\0fflush\0fgetc\0fgetpos\0\
-fgets\0fopen\0fprintf\0fputc\0fputs\0fread\0freopen\0fscanf\0fseek\0\
-fsetpos\0ftell\0fwrite\0getc\0getchar\0gets\0perror\0\
-printf\0putc\0putchar\0puts\0remove\0rename\0rewind\0scanf\0setbuf\0\
-setvbuf\0sprintf\0sscanf\0vprintf\0vsprintf\0vfprintf\0tmpfile\0\
-tmpnam\0ungetc\0" },
- { CONTINUED, POSIX1_SYMBOL, "fdopen\0fileno\0" },
- { CONTINUED, POSIX2_SYMBOL, "pclose\0popen\0" }, /* I think ... */
-/* Should perhaps also handle NULL, EOF, ... ? */
-
- /* "div ldiv", - ignored because these depend on div_t, ldiv_t
- ignore these: "mblen mbstowcs mbstowc wcstombs wctomb"
- Left out getgroups, because SunOS4 has incompatible BSD and SVR4 versions.
- Should perhaps also add NULL */
- { "stdlib.h", ANSI_SYMBOL,
- "abort\0abs\0atexit\0atof\0atoi\0atol\0bsearch\0calloc\0\
-exit\0free\0getenv\0labs\0malloc\0qsort\0rand\0realloc\0\
-srand\0strtod\0strtol\0strtoul\0system\0" },
- { CONTINUED, ANSI_SYMBOL|MACRO_SYMBOL, "EXIT_FAILURE\0EXIT_SUCCESS\0" },
- { CONTINUED, POSIX1_SYMBOL, "putenv\0" },
-
- { "string.h", ANSI_SYMBOL, "memchr\0memcmp\0memcpy\0memmove\0memset\0\
-strcat\0strchr\0strcmp\0strcoll\0strcpy\0strcspn\0strerror\0\
-strlen\0strncat\0strncmp\0strncpy\0strpbrk\0strrchr\0strspn\0strstr\0\
-strtok\0strxfrm\0" },
-/* Should perhaps also add NULL and size_t */
-
- { "strings.h", XOPEN_EXTENDED_SYMBOL,
- "bcmp\0bcopy\0bzero\0ffs\0index\0rindex\0strcasecmp\0strncasecmp\0" },
-
- { "strops.h", XOPEN_EXTENDED_SYMBOL, "ioctl\0" },
-
- /* Actually, XPG4 does not seem to have <sys/ioctl.h>, but defines
- ioctl in <strops.h>. However, many systems have it is sys/ioctl.h,
- and many systems do have <sys/ioctl.h> but not <strops.h>. */
- { "sys/ioctl.h", XOPEN_EXTENDED_SYMBOL, "ioctl\0" },
-
- { "sys/socket.h", XOPEN_EXTENDED_SYMBOL, "socket\0" },
-
- { "sys/stat.h", POSIX1_SYMBOL,
- "chmod\0fstat\0mkdir\0mkfifo\0stat\0lstat\0umask\0" },
- { CONTINUED, POSIX1_SYMBOL|MACRO_SYMBOL,
- "S_ISDIR\0S_ISBLK\0S_ISCHR\0S_ISFIFO\0S_ISREG\0S_ISLNK\0S_IFDIR\0\
-S_IFBLK\0S_IFCHR\0S_IFIFO\0S_IFREG\0S_IFLNK\0" },
- { CONTINUED, XOPEN_EXTENDED_SYMBOL, "fchmod\0" },
-
-#if 0
-/* How do we handle fd_set? */
- { "sys/time.h", XOPEN_EXTENDED_SYMBOL, "select\0" },
- { "sys/select.h", XOPEN_EXTENDED_SYMBOL /* fake */, "select\0" },
-#endif
-
- { "sys/times.h", POSIX1_SYMBOL, "times\0" },
- /* "sys/types.h" add types (not in old g++-include) */
-
- { "sys/utsname.h", POSIX1_SYMBOL, "uname\0" },
-
- { "sys/wait.h", POSIX1_SYMBOL, "wait\0waitpid\0" },
- { CONTINUED, POSIX1_SYMBOL|MACRO_SYMBOL,
- "WEXITSTATUS\0WIFEXITED\0WIFSIGNALED\0WIFSTOPPED\0WSTOPSIG\0\
-WTERMSIG\0WNOHANG\0WNOTRACED\0" },
-
- { "tar.h", POSIX1_SYMBOL, NONE },
-
- { "termios.h", POSIX1_SYMBOL,
- "cfgetispeed\0cfgetospeed\0cfsetispeed\0cfsetospeed\0tcdrain\0tcflow\0tcflush\0tcgetattr\0tcsendbreak\0tcsetattr\0" },
-
- { "time.h", ANSI_SYMBOL,
- "asctime\0clock\0ctime\0difftime\0gmtime\0localtime\0mktime\0strftime\0time\0" },
- { CONTINUED, POSIX1_SYMBOL, "tzset\0" },
-
- { "unistd.h", POSIX1_SYMBOL,
- "_exit\0access\0alarm\0chdir\0chown\0close\0ctermid\0cuserid\0\
-dup\0dup2\0execl\0execle\0execlp\0execv\0execve\0execvp\0fork\0fpathconf\0\
-getcwd\0getegid\0geteuid\0getgid\0getlogin\0getpgrp\0getpid\0\
-getppid\0getuid\0isatty\0link\0lseek\0pathconf\0pause\0pipe\0read\0rmdir\0\
-setgid\0setpgid\0setsid\0setuid\0sleep\0sysconf\0tcgetpgrp\0tcsetpgrp\0\
-ttyname\0unlink\0write\0" },
- { CONTINUED, POSIX2_SYMBOL, "getopt\0" },
- { CONTINUED, XOPEN_EXTENDED_SYMBOL,
- "lockf\0gethostid\0gethostname\0readlink\0symlink\0" },
-
- { "utime.h", POSIX1_SYMBOL, "utime\0" },
-
- { NULL, 0, NONE }
-};
-
-enum special_file special_file_handling = no_special;
-
-/* They are set if the corresponding macro has been seen. */
-/* The following are only used when handling sys/stat.h */
-int seen_S_IFBLK = 0, seen_S_ISBLK = 0;
-int seen_S_IFCHR = 0, seen_S_ISCHR = 0;
-int seen_S_IFDIR = 0, seen_S_ISDIR = 0;
-int seen_S_IFIFO = 0, seen_S_ISFIFO = 0;
-int seen_S_IFLNK = 0, seen_S_ISLNK = 0;
-int seen_S_IFREG = 0, seen_S_ISREG = 0;
-/* The following are only used when handling errno.h */
-int seen_errno = 0;
-/* The following are only used when handling stdlib.h */
-int seen_EXIT_FAILURE = 0, seen_EXIT_SUCCESS = 0;
-\f
-struct obstack scan_file_obstack;
-
-/* NOTE: If you edit this, also edit gen-protos.c !! */
-
-static struct fn_decl *
-lookup_std_proto (const char *name, int name_length)
-{
- int i = hashstr (name, name_length) % HASH_SIZE;
- int i0 = i;
- for (;;)
- {
- struct fn_decl *fn;
- if (hash_tab[i] == 0)
- return NULL;
- fn = &std_protos[hash_tab[i]];
- if ((int) strlen (fn->fname) == name_length
- && strncmp (fn->fname, name, name_length) == 0)
- return fn;
- i = (i+1) % HASH_SIZE;
- gcc_assert (i != i0);
- }
-}
-
-char *inc_filename;
-int inc_filename_length;
-FILE *outf;
-sstring line;
-
-int lbrac_line, rbrac_line;
-
-int required_unseen_count = 0;
-int required_other = 0;
-
-static void
-write_lbrac (void)
-{
- if (partial_count)
- {
- fprintf (outf, "#ifndef _PARAMS\n");
- fprintf (outf, "#if defined(__STDC__) || defined(__cplusplus)\n");
- fprintf (outf, "#define _PARAMS(ARGS) ARGS\n");
- fprintf (outf, "#else\n");
- fprintf (outf, "#define _PARAMS(ARGS) ()\n");
- fprintf (outf, "#endif\n#endif /* _PARAMS */\n");
- }
-}
-
-struct partial_proto
-{
- struct partial_proto *next;
- struct fn_decl *fn;
- int line_seen;
-};
-
-struct partial_proto *partial_proto_list = NULL;
-
-struct partial_proto required_dummy_proto, seen_dummy_proto;
-#define REQUIRED(FN) ((FN)->partial == &required_dummy_proto)
-#define SET_REQUIRED(FN) ((FN)->partial = &required_dummy_proto)
-#define SET_SEEN(FN) ((FN)->partial = &seen_dummy_proto)
-#define SEEN(FN) ((FN)->partial == &seen_dummy_proto)
-
-static void
-recognized_macro (const char *fname)
-{
- /* The original include file defines fname as a macro. */
- struct fn_decl *fn = lookup_std_proto (fname, strlen (fname));
-
- /* Since fname is a macro, don't require a prototype for it. */
- if (fn)
- {
- if (REQUIRED (fn))
- required_unseen_count--;
- SET_SEEN (fn);
- }
-
- switch (special_file_handling)
- {
- case errno_h:
- if (strcmp (fname, "errno") == 0 && !seen_errno)
- seen_errno = 1, required_other--;
- break;
- case stdlib_h:
- if (strcmp (fname, "EXIT_FAILURE") == 0 && !seen_EXIT_FAILURE)
- seen_EXIT_FAILURE = 1, required_other--;
- if (strcmp (fname, "EXIT_SUCCESS") == 0 && !seen_EXIT_SUCCESS)
- seen_EXIT_SUCCESS = 1, required_other--;
- break;
- case sys_stat_h:
- if (fname[0] == 'S' && fname[1] == '_')
- {
- if (strcmp (fname, "S_IFBLK") == 0) seen_S_IFBLK++;
- else if (strcmp (fname, "S_ISBLK") == 0) seen_S_ISBLK++;
- else if (strcmp (fname, "S_IFCHR") == 0) seen_S_IFCHR++;
- else if (strcmp (fname, "S_ISCHR") == 0) seen_S_ISCHR++;
- else if (strcmp (fname, "S_IFDIR") == 0) seen_S_IFDIR++;
- else if (strcmp (fname, "S_ISDIR") == 0) seen_S_ISDIR++;
- else if (strcmp (fname, "S_IFIFO") == 0) seen_S_IFIFO++;
- else if (strcmp (fname, "S_ISFIFO") == 0) seen_S_ISFIFO++;
- else if (strcmp (fname, "S_IFLNK") == 0) seen_S_IFLNK++;
- else if (strcmp (fname, "S_ISLNK") == 0) seen_S_ISLNK++;
- else if (strcmp (fname, "S_IFREG") == 0) seen_S_IFREG++;
- else if (strcmp (fname, "S_ISREG") == 0) seen_S_ISREG++;
- }
- break;
-
- default:
- break;
- }
-}
-
-void
-recognized_extern (const cpp_token *name)
-{
- switch (special_file_handling)
- {
- case errno_h:
- if (cpp_ideq (name, "errno"))
- seen_errno = 1, required_other--;
- break;
-
- default:
- break;
- }
-}
-
-/* Called by scan_decls if it saw a function definition for a function
- named FNAME. KIND is 'I' for an inline function; 'F' if a normal
- function declaration preceded by 'extern "C"' (or nested inside
- 'extern "C"' braces); or 'f' for other function declarations. */
-
-void
-recognized_function (const cpp_token *fname, unsigned int line, int kind,
- int have_arg_list)
-{
- struct partial_proto *partial;
- int i;
- struct fn_decl *fn;
-
- fn = lookup_std_proto ((const char *) NODE_NAME (fname->val.node),
- NODE_LEN (fname->val.node));
-
- /* Remove the function from the list of required function. */
- if (fn)
- {
- if (REQUIRED (fn))
- required_unseen_count--;
- SET_SEEN (fn);
- }
-
- /* If we have a full prototype, we're done. */
- if (have_arg_list)
- return;
-
- if (kind == 'I') /* don't edit inline function */
- return;
-
- /* If the partial prototype was included from some other file,
- we don't need to patch it up (in this run). */
- i = strlen (cur_file);
- if (i < inc_filename_length
- || strcmp (inc_filename, cur_file + (i - inc_filename_length)) != 0)
- return;
-
- if (fn == NULL)
- return;
- if (fn->params[0] == '\0')
- return;
-
- /* We only have a partial function declaration,
- so remember that we have to add a complete prototype. */
- partial_count++;
- partial
- = (struct partial_proto *)
- obstack_alloc (&scan_file_obstack,
- sizeof (struct partial_proto));
- partial->line_seen = line;
- partial->fn = fn;
- fn->partial = partial;
- partial->next = partial_proto_list;
- partial_proto_list = partial;
- if (verbose)
- {
- fprintf (stderr, "(%s: %s non-prototype function declaration.)\n",
- inc_filename, fn->fname);
- }
-}
-
-/* For any name in NAMES that is defined as a macro,
- call recognized_macro on it. */
-
-static void
-check_macro_names (cpp_reader *pfile, namelist names)
-{
- size_t len;
- while (*names)
- {
- len = strlen (names);
- if (cpp_defined (pfile, (const unsigned char *)names, len))
- recognized_macro (names);
- names += len + 1;
- }
-}
-
-static void
-cb_file_change (cpp_reader *pfile ATTRIBUTE_UNUSED,
- const struct line_map *map)
-{
- /* Just keep track of current file name. */
- cur_file = map == NULL ? NULL : map->to_file;
-}
-
-static void
-read_scan_file (char *in_fname, int argc, char **argv)
-{
- cpp_reader *scan_in;
- cpp_callbacks *cb;
- cpp_options *options;
- struct fn_decl *fn;
- int i, strings_processed;
- struct symbol_list *cur_symbols;
-
- obstack_init (&scan_file_obstack);
-
- linemap_init (&line_table);
- scan_in = cpp_create_reader (CLK_GNUC89, NULL, &line_table);
- cb = cpp_get_callbacks (scan_in);
- cb->file_change = cb_file_change;
-
- /* We are going to be scanning a header file out of its proper context,
- so ignore warnings and errors. */
- options = cpp_get_options (scan_in);
- options->inhibit_warnings = 1;
- options->inhibit_errors = 1;
- cpp_post_options (scan_in);
-
- if (!cpp_read_main_file (scan_in, in_fname))
- exit (FATAL_EXIT_CODE);
-
- cpp_change_file (scan_in, LC_RENAME, "<built-in>");
- cpp_init_builtins (scan_in, true);
- cpp_change_file (scan_in, LC_RENAME, in_fname);
-
- /* Process switches after builtins so -D can override them. */
- for (i = 0; i < argc; i += strings_processed)
- {
- strings_processed = 0;
- if (argv[i][0] == '-')
- {
- if (argv[i][1] == 'I')
- {
- if (argv[i][2] != '\0')
- {
- strings_processed = 1;
- add_path (xstrdup (argv[i] + 2), BRACKET, false, false);
- }
- else if (i + 1 != argc)
- {
- strings_processed = 2;
- add_path (xstrdup (argv[i + 1]), BRACKET, false, false);
- }
- }
- else if (argv[i][1] == 'D')
- {
- if (argv[i][2] != '\0')
- strings_processed = 1, cpp_define (scan_in, argv[i] + 2);
- else if (i + 1 != argc)
- strings_processed = 2, cpp_define (scan_in, argv[i + 1]);
- }
- }
-
- if (strings_processed == 0)
- break;
- }
-
- if (i < argc)
- cpp_error (scan_in, CPP_DL_ERROR, "invalid option `%s'", argv[i]);
- if (cpp_errors (scan_in))
- exit (FATAL_EXIT_CODE);
-
- register_include_chains (scan_in, NULL /* sysroot */, NULL /* iprefix */,
- NULL /* imultilib */, true /* stdinc */,
- false /* cxx_stdinc */, false /* verbose */);
-
- /* We are scanning a system header, so mark it as such. */
- cpp_make_system_header (scan_in, 1, 0);
-
- scan_decls (scan_in, argc, argv);
- for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++)
- check_macro_names (scan_in, cur_symbols->names);
-
- /* Traditionally, getc and putc are defined in terms of _filbuf and _flsbuf.
- If so, those functions are also required. */
- if (special_file_handling == stdio_h
- && (fn = lookup_std_proto ("_filbuf", 7)) != NULL)
- {
- unsigned char getchar_call[] = "getchar();\n";
- int seen_filbuf = 0;
-
- /* Scan the macro expansion of "getchar();". */
- cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1,
- /* from_stage3 */ true);
- for (;;)
- {
- const cpp_token *t = cpp_get_token (scan_in);
-
- if (t->type == CPP_EOF)
- break;
- else if (cpp_ideq (t, "_filbuf"))
- seen_filbuf++;
- }
-
- if (seen_filbuf)
- {
- int need_filbuf = !SEEN (fn) && !REQUIRED (fn);
- struct fn_decl *flsbuf_fn = lookup_std_proto ("_flsbuf", 7);
- int need_flsbuf
- = flsbuf_fn && !SEEN (flsbuf_fn) && !REQUIRED (flsbuf_fn);
-
- /* Append "_filbuf" and/or "_flsbuf" to the required functions. */
- if (need_filbuf + need_flsbuf)
- {
- const char *new_list;
- if (need_filbuf)
- SET_REQUIRED (fn);
- if (need_flsbuf)
- SET_REQUIRED (flsbuf_fn);
- if (need_flsbuf && need_filbuf)
- new_list = "_filbuf\0_flsbuf\0";
- else if (need_flsbuf)
- new_list = "_flsbuf\0";
- else /* if (need_flsbuf) */
- new_list = "_filbuf\0";
- add_symbols (ANSI_SYMBOL, new_list);
- required_unseen_count += need_filbuf + need_flsbuf;
- }
- }
- }
-
- if (required_unseen_count + partial_count + required_other == 0)
- {
- if (verbose)
- fprintf (stderr, "%s: OK, nothing needs to be done.\n", inc_filename);
- exit (SUCCESS_EXIT_CODE);
- }
- if (!verbose)
- fprintf (stderr, "%s: fixing %s\n", progname, inc_filename);
- else
- {
- if (required_unseen_count)
- fprintf (stderr, "%s: %d missing function declarations.\n",
- inc_filename, required_unseen_count);
- if (partial_count)
- fprintf (stderr, "%s: %d non-prototype function declarations.\n",
- inc_filename, partial_count);
- }
-}
-
-static void
-write_rbrac (void)
-{
- struct fn_decl *fn;
- const char *cptr;
- struct symbol_list *cur_symbols;
-
- if (required_unseen_count)
- {
-#ifdef NO_IMPLICIT_EXTERN_C
- fprintf (outf, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
-#endif
- }
-
- /* Now we print out prototypes for those functions that we haven't seen. */
- for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++)
- {
- int if_was_emitted = 0;
- int name_len;
- cptr = cur_symbols->names;
- for ( ; (name_len = strlen (cptr)) != 0; cptr+= name_len + 1)
- {
- int macro_protect = 0;
-
- if (cur_symbols->flags & MACRO_SYMBOL)
- continue;
-
- fn = lookup_std_proto (cptr, name_len);
- if (fn == NULL || !REQUIRED (fn))
- continue;
-
- if (!if_was_emitted)
- {
-/* what about curses. ??? or _flsbuf/_filbuf ??? */
- if (cur_symbols->flags & ANSI_SYMBOL)
- fprintf (outf,
- "#if defined(__USE_FIXED_PROTOTYPES__) || defined(__cplusplus) || defined (__STRICT_ANSI__)\n");
- else if (cur_symbols->flags & (POSIX1_SYMBOL|POSIX2_SYMBOL))
- fprintf (outf,
- "#if defined(__USE_FIXED_PROTOTYPES__) || (defined(__cplusplus) \\\n\
- ? (!defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)) \\\n\
- : (defined(__STRICT_ANSI__) && defined(_POSIX_SOURCE)))\n");
- else if (cur_symbols->flags & XOPEN_SYMBOL)
- {
- fprintf (outf,
- "#if defined(__USE_FIXED_PROTOTYPES__) \\\n\
- || (defined(__STRICT_ANSI__) && defined(_XOPEN_SOURCE))\n");
- }
- else if (cur_symbols->flags & XOPEN_EXTENDED_SYMBOL)
- {
- fprintf (outf,
- "#if defined(__USE_FIXED_PROTOTYPES__) \\\n\
- || (defined(__STRICT_ANSI__) && defined(_XOPEN_EXTENDED_SOURCE))\n");
- }
- else
- {
- fatal ("internal error for function %s", fn->fname);
- }
- if_was_emitted = 1;
- }
-
- /* In the case of memmove, protect in case the application
- defines it as a macro before including the header. */
- if (!strcmp (fn->fname, "memmove")
- || !strcmp (fn->fname, "putc")
- || !strcmp (fn->fname, "getc")
- || !strcmp (fn->fname, "vprintf")
- || !strcmp (fn->fname, "vfprintf")
- || !strcmp (fn->fname, "vsprintf")
- || !strcmp (fn->fname, "rewinddir")
- || !strcmp (fn->fname, "abort"))
- macro_protect = 1;
-
- if (macro_protect)
- fprintf (outf, "#ifndef %s\n", fn->fname);
- fprintf (outf, "extern %s %s (%s);\n",
- fn->rtype, fn->fname, fn->params);
- if (macro_protect)
- fprintf (outf, "#endif\n");
- }
- if (if_was_emitted)
- fprintf (outf,
- "#endif /* defined(__USE_FIXED_PROTOTYPES__) || ... */\n");
- }
- if (required_unseen_count)
- {
-#ifdef NO_IMPLICIT_EXTERN_C
- fprintf (outf, "#ifdef __cplusplus\n}\n#endif\n");
-#endif
- }
-
- switch (special_file_handling)
- {
- case errno_h:
- if (!seen_errno)
- fprintf (outf, "extern int errno;\n");
- break;
- case stdlib_h:
- if (!seen_EXIT_FAILURE)
- fprintf (outf, "#define EXIT_FAILURE 1\n");
- if (!seen_EXIT_SUCCESS)
- fprintf (outf, "#define EXIT_SUCCESS 0\n");
- break;
- case sys_stat_h:
- if (!seen_S_ISBLK && seen_S_IFBLK)
- fprintf (outf,
- "#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)\n");
- if (!seen_S_ISCHR && seen_S_IFCHR)
- fprintf (outf,
- "#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)\n");
- if (!seen_S_ISDIR && seen_S_IFDIR)
- fprintf (outf,
- "#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)\n");
- if (!seen_S_ISFIFO && seen_S_IFIFO)
- fprintf (outf,
- "#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)\n");
- if (!seen_S_ISLNK && seen_S_IFLNK)
- fprintf (outf,
- "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\n");
- if (!seen_S_ISREG && seen_S_IFREG)
- fprintf (outf,
- "#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)\n");
- break;
-
- default:
- break;
- }
-
-}
-
-/* Returns 1 iff the file is properly protected from multiple inclusion:
- #ifndef PROTECT_NAME
- #define PROTECT_NAME
- #endif
-
- */
-
-#define INF_GET() (inf_ptr < inf_limit ? *(unsigned char *) inf_ptr++ : EOF)
-#define INF_UNGET(c) ((c)!=EOF && inf_ptr--)
-
-static int
-inf_skip_spaces (int c)
-{
- for (;;)
- {
- if (c == ' ' || c == '\t')
- c = INF_GET ();
- else if (c == '/')
- {
- c = INF_GET ();
- if (c != '*')
- {
- (void) INF_UNGET (c);
- return '/';
- }
- c = INF_GET ();
- for (;;)
- {
- if (c == EOF)
- return EOF;
- else if (c != '*')
- {
- if (c == '\n')
- source_lineno++, lineno++;
- c = INF_GET ();
- }
- else if ((c = INF_GET ()) == '/')
- return INF_GET ();
- }
- }
- else
- break;
- }
- return c;
-}
-
-/* Read into STR from inf_buffer upto DELIM. */
-
-static int
-inf_read_upto (sstring *str, int delim)
-{
- int ch;
- for (;;)
- {
- ch = INF_GET ();
- if (ch == EOF || ch == delim)
- break;
- SSTRING_PUT (str, ch);
- }
- MAKE_SSTRING_SPACE (str, 1);
- *str->ptr = 0;
- return ch;
-}
-
-static int
-inf_scan_ident (sstring *s, int c)
-{
- s->ptr = s->base;
- if (ISIDST (c))
- {
- for (;;)
- {
- SSTRING_PUT (s, c);
- c = INF_GET ();
- if (c == EOF || !(ISIDNUM (c)))
- break;
- }
- }
- MAKE_SSTRING_SPACE (s, 1);
- *s->ptr = 0;
- return c;
-}
-
-/* Returns 1 if the file is correctly protected against multiple
- inclusion, setting *ifndef_line to the line number of the initial #ifndef
- and setting *endif_line to the final #endif.
- Otherwise return 0. */
-
-static int
-check_protection (int *ifndef_line, int *endif_line)
-{
- int c;
- int if_nesting = 1; /* Level of nesting of #if's */
- char *protect_name = NULL; /* Identifier following initial #ifndef */
- int define_seen = 0;
-
- /* Skip initial white space (including comments). */
- for (;; lineno++)
- {
- c = inf_skip_spaces (' ');
- if (c == EOF)
- return 0;
- if (c != '\n')
- break;
- }
- if (c != '#')
- return 0;
- c = inf_scan_ident (&buf, inf_skip_spaces (' '));
- if (SSTRING_LENGTH (&buf) == 0 || strcmp (buf.base, "ifndef") != 0)
- return 0;
-
- /* So far so good: We've seen an initial #ifndef. */
- *ifndef_line = lineno;
- c = inf_scan_ident (&buf, inf_skip_spaces (c));
- if (SSTRING_LENGTH (&buf) == 0 || c == EOF)
- return 0;
- protect_name = xstrdup (buf.base);
-
- (void) INF_UNGET (c);
- c = inf_read_upto (&buf, '\n');
- if (c == EOF)
- return 0;
- lineno++;
-
- for (;;)
- {
- c = inf_skip_spaces (' ');
- if (c == EOF)
- return 0;
- if (c == '\n')
- {
- lineno++;
- continue;
- }
- if (c != '#')
- goto skip_to_eol;
- c = inf_scan_ident (&buf, inf_skip_spaces (' '));
- if (SSTRING_LENGTH (&buf) == 0)
- ;
- else if (!strcmp (buf.base, "ifndef")
- || !strcmp (buf.base, "ifdef") || !strcmp (buf.base, "if"))
- {
- if_nesting++;
- }
- else if (!strcmp (buf.base, "endif"))
- {
- if_nesting--;
- if (if_nesting == 0)
- break;
- }
- else if (!strcmp (buf.base, "else"))
- {
- if (if_nesting == 1)
- return 0;
- }
- else if (!strcmp (buf.base, "define"))
- {
- c = inf_skip_spaces (c);
- c = inf_scan_ident (&buf, c);
- if (buf.base[0] > 0 && strcmp (buf.base, protect_name) == 0)
- define_seen = 1;
- }
- skip_to_eol:
- for (;;)
- {
- if (c == '\n' || c == EOF)
- break;
- c = INF_GET ();
- }
- if (c == EOF)
- return 0;
- lineno++;
- }
-
- if (!define_seen)
- return 0;
- *endif_line = lineno;
- /* Skip final white space (including comments). */
- for (;;)
- {
- c = inf_skip_spaces (' ');
- if (c == EOF)
- break;
- if (c != '\n')
- return 0;
- }
-
- return 1;
-}
-
-extern int main (int, char **);
-
-int
-main (int argc, char **argv)
-{
- int inf_fd;
- struct stat sbuf;
- int c;
-#ifdef FIXPROTO_IGNORE_LIST
- int i;
-#endif
- const char *cptr;
- int ifndef_line;
- int endif_line;
- long to_read;
- long int inf_size;
- struct symbol_list *cur_symbols;
-
- progname = "fix-header";
- if (argv[0] && argv[0][0])
- {
- char *p;
-
- progname = 0;
- for (p = argv[0]; *p; p++)
- if (*p == '/')
- progname = p;
- progname = progname ? progname+1 : argv[0];
- }
-
- if (argc < 4)
- {
- fprintf (stderr, "%s: Usage: foo.h infile.h outfile.h options\n",
- progname);
- exit (FATAL_EXIT_CODE);
- }
-
- inc_filename = argv[1];
- inc_filename_length = strlen (inc_filename);
-
-#ifdef FIXPROTO_IGNORE_LIST
- for (i = 0; files_to_ignore[i] != NULL; i++)
- {
- const char *const ignore_name = files_to_ignore[i];
- int ignore_len = strlen (ignore_name);
- if (strncmp (inc_filename, ignore_name, ignore_len) == 0)
- {
- if (ignore_name[ignore_len-1] == '/'
- || inc_filename[ignore_len] == '\0')
- {
- if (verbose)
- fprintf (stderr, "%s: ignoring %s\n", progname, inc_filename);
- exit (SUCCESS_EXIT_CODE);
- }
- }
-
- }
-#endif
-
- if (strcmp (inc_filename, "sys/stat.h") == 0)
- special_file_handling = sys_stat_h;
- else if (strcmp (inc_filename, "errno.h") == 0)
- special_file_handling = errno_h, required_other++;
- else if (strcmp (inc_filename, "stdlib.h") == 0)
- special_file_handling = stdlib_h, required_other+=2;
- else if (strcmp (inc_filename, "stdio.h") == 0)
- special_file_handling = stdio_h;
- include_entry = std_include_table;
- while (include_entry->name != NULL
- && ((strcmp (include_entry->name, CONTINUED) == 0)
- || strcmp (inc_filename, include_entry->name) != 0))
- include_entry++;
-
- if (include_entry->name != NULL)
- {
- const struct std_include_entry *entry;
- cur_symbol_table_size = 0;
- for (entry = include_entry; ;)
- {
- if (entry->flags)
- add_symbols (entry->flags, entry->names);
- entry++;
- if (!entry->name || strcmp (entry->name, CONTINUED) != 0)
- break;
- }
- }
- else
- symbol_table[0].names = NULL;
-
- /* Count and mark the prototypes required for this include file. */
- for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++)
- {
- int name_len;
- if (cur_symbols->flags & MACRO_SYMBOL)
- continue;
- cptr = cur_symbols->names;
- for ( ; (name_len = strlen (cptr)) != 0; cptr+= name_len + 1)
- {
- struct fn_decl *fn = lookup_std_proto (cptr, name_len);
- required_unseen_count++;
- if (fn == NULL)
- fprintf (stderr, "Internal error: No prototype for %s\n", cptr);
- else
- SET_REQUIRED (fn);
- }
- }
-
- read_scan_file (argv[2], argc - 4, argv + 4);
-
- inf_fd = open (argv[2], O_RDONLY, 0666);
- if (inf_fd < 0)
- {
- fprintf (stderr, "%s: Cannot open '%s' for reading -",
- progname, argv[2]);
- perror (NULL);
- exit (FATAL_EXIT_CODE);
- }
- if (fstat (inf_fd, &sbuf) < 0)
- {
- fprintf (stderr, "%s: Cannot get size of '%s' -", progname, argv[2]);
- perror (NULL);
- exit (FATAL_EXIT_CODE);
- }
- inf_size = sbuf.st_size;
- inf_buffer = XNEWVEC (char, inf_size + 2);
- inf_ptr = inf_buffer;
-
- to_read = inf_size;
- while (to_read > 0)
- {
- long i = read (inf_fd, inf_buffer + inf_size - to_read, to_read);
- if (i < 0)
- {
- fprintf (stderr, "%s: Failed to read '%s' -", progname, argv[2]);
- perror (NULL);
- exit (FATAL_EXIT_CODE);
- }
- if (i == 0)
- {
- inf_size -= to_read;
- break;
- }
- to_read -= i;
- }
-
- close (inf_fd);
-
- /* Inf_size may have changed if read was short (as on VMS) */
- inf_buffer[inf_size] = '\n';
- inf_buffer[inf_size + 1] = '\0';
- inf_limit = inf_buffer + inf_size;
-
- /* If file doesn't end with '\n', add one. */
- if (inf_limit > inf_buffer && inf_limit[-1] != '\n')
- inf_limit++;
-
- unlink (argv[3]);
- outf = fopen (argv[3], "w");
- if (outf == NULL)
- {
- fprintf (stderr, "%s: Cannot open '%s' for writing -",
- progname, argv[3]);
- perror (NULL);
- exit (FATAL_EXIT_CODE);
- }
-
- lineno = 1;
-
- if (check_protection (&ifndef_line, &endif_line))
- {
- lbrac_line = ifndef_line+1;
- rbrac_line = endif_line;
- }
- else
- {
- lbrac_line = 1;
- rbrac_line = -1;
- }
-
- /* Reset input file. */
- inf_ptr = inf_buffer;
- lineno = 1;
-
- for (;;)
- {
- if (lineno == lbrac_line)
- write_lbrac ();
- if (lineno == rbrac_line)
- write_rbrac ();
- for (;;)
- {
- struct fn_decl *fn;
- c = INF_GET ();
- if (c == EOF)
- break;
- if (ISIDST (c))
- {
- c = inf_scan_ident (&buf, c);
- (void) INF_UNGET (c);
- fputs (buf.base, outf);
- fn = lookup_std_proto (buf.base, strlen (buf.base));
- /* We only want to edit the declaration matching the one
- seen by scan-decls, as there can be multiple
- declarations, selected by #ifdef __STDC__ or whatever. */
- if (fn && fn->partial && fn->partial->line_seen == lineno)
- {
- c = inf_skip_spaces (' ');
- if (c == EOF)
- break;
- if (c == '(')
- {
- c = inf_skip_spaces (' ');
- if (c == ')')
- {
- fprintf (outf, " _PARAMS((%s))", fn->params);
- }
- else
- {
- putc ('(', outf);
- (void) INF_UNGET (c);
- }
- }
- else
- fprintf (outf, " %c", c);
- }
- }
- else
- {
- putc (c, outf);
- if (c == '\n')
- break;
- }
- }
- if (c == EOF)
- break;
- lineno++;
- }
- if (rbrac_line < 0)
- write_rbrac ();
-
- fclose (outf);
-
- return 0;
-}
+++ /dev/null
-#!/bin/sh
-#
-# SYNOPSIS
-# fixproto TARGET-DIR SOURCE-DIR-ALL SOURCE-DIR-STD
-#
-# COPYRIGHT
-# Copyright (C) 1993, 1994, 1997, 1998, 2002, 2003, 2007, 2008
-# Free Software Foundation, Inc.
-# This file is part of GCC.
-#
-# GCC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GCC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3. If not see
-# <http://www.gnu.org/licenses/>.
-#
-# DESCRIPTION
-# Adjunct script for GCC to populate a directory with ANSI,
-# Posix.1, and C++ compatible header files.
-#
-# Each file found under SOURCE-DIR-ALL is analyzed and "fixed."
-# Only standard ANSI/POSIX files found under SOURCE-DIR-STD
-# are analyzed and "fixed."
-# The SOURCE-DIRs are searched in order; a file found
-# under multiple SOURCE-DIRs is only handled for the first one.
-#
-# STRATEGY
-# Each include file is fed through cpp, and the scan-decls program
-# parses it, and emits any found function declarations.
-# The fix-header program analyzes the scan-decls output,
-# together with the original include file, and writes a "fixed"
-# include file, if needed.
-#
-# The comment at the beginning of fix-header.c lists specifically
-# what kind of changes are made.
-#
-# NOTE
-# Some file space will be wasted, because the original header
-# files are copied. An earlier version just included the original
-# by "reference", using GNU cpp's #include_next mechanism.
-# This is currently not done, partly because #include_next is
-# fragile (susceptible to version incompatibilities, and depends
-# and GCC-specific features), and partly for performance reasons.
-#
-# AUTHORS
-# Ron Guilmette (rfg@netcom.com) (original idea and code)
-# Per Bothner (bothner@cygnus.com) (major re-write)
-
-dirname=`echo "$0" | sed 's,^[^/]*$,.,;s,//*[^/]*$,,'`
-progname=`echo "$0" | sed 's,.*/,,'`
-original_dir=`${PWDCMD-pwd}`
-FIX_HEADER=${FIX_HEADER-$original_dir/fix-header}
-DEFINES="-D__STDC__=0 -D__cplusplus ${FIXPROTO_DEFINES}"
-
-if mkdir -p . 2> /dev/null; then
- # Great, mkdir accepts -p
- mkinstalldirs="mkdir -p"
-else
- # We expect mkinstalldirs to be passed in the environment.
- # If it is not, assume it is in the directory that contains this script.
- mkinstalldirs=${mkinstalldirs-"/bin/sh $dirname/mkinstalldirs"}
- if $mkinstalldirs . 2> /dev/null; then
- :
- else
- # But, in case of failure, fallback to plain mkdir, and hope it works
- mkinstalldirs=mkdir
- fi
-fi
-
-if [ `echo $1 | wc -w` = 0 ] ; then
- echo $progname\: usage\: $progname target-dir \[ source-dir \.\.\. \]
- exit 1
-fi
-
-std_files="ctype.h dirent.h errno.h curses.h fcntl.h grp.h locale.h math.h pwd.h setjmp.h signal.h stdio.h stdlib.h string.h sys/socket.h sys/stat.h sys/times.h sys/resource.h sys/utsname.h sys/wait.h tar.h termios.h time.h unistd.h utime.h"
-
-rel_target_dir=$1
-# All files in $src_dir_all (normally same as $rel_target_dir) are
-# processed.
-src_dir_all=$2
-# In $src_dir_std (normally same as /usr/include), only the
-# "standard" ANSI/POSIX files listed in $std_files are processed.
-src_dir_std=$3
-
-case $rel_target_dir in
- /* | [A-Za-z]:[\\/]*)
- abs_target_dir=$rel_target_dir
- ;;
- *)
- abs_target_dir=$original_dir/$rel_target_dir
- ;;
-esac
-
-# Determine whether this system has symbolic links.
-if ln -s X $rel_target_dir/ShouldNotExist 2>/dev/null; then
- rm -f $rel_target_dir/ShouldNotExist
- LINKS=true
-elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
- rm -f /tmp/ShouldNotExist
- LINKS=true
-else
- LINKS=false
-fi
-
-if [ \! -d $abs_target_dir ] ; then
- echo $progname\: creating directory $rel_target_dir
- $mkinstalldirs $abs_target_dir
-fi
-
-echo $progname\: populating \`$rel_target_dir\'
-
-include_path=""
-
-if [ `echo $* | wc -w` != 0 ] ; then
- for rel_source_dir in $src_dir_all $src_dir_std; do
- case $rel_source_dir in
- /* | [A-Za-z]:[\\/]*)
- abs_source_dir=$rel_source_dir
- ;;
- *)
- abs_source_dir=$original_dir/$rel_source_dir
- ;;
- esac
- include_path="$include_path -I$abs_source_dir"
- done
-fi
-
-done_dirs=""
-subdirs_made=""
-echo "" >fixproto.list
-
-for code in ALL STD ; do
-
- subdirs="."
-
- case $code in
- ALL)
- rel_source_dir=$src_dir_all
-
- dirs="."
- levels=2
- while $LINKS && test -n "$dirs" -a $levels -gt 0
- do
- levels=`expr $levels - 1`
- newdirs=
- for d in $dirs ; do
- # Find all directories under $d, relative to $d, excluding $d itself.
- # Assume directory names ending in CC or containing ++ are
- # for C++, so skip those.
- subdirs="$subdirs "`cd $rel_source_dir/$d; find . -type d -print | \
- sed -e '/^\.$/d' -e "s|^\./|${d}/|" -e 's|^\./||' \
- -e '/CC$/d' -e '/[+][+]/d'`
- links=
- links=`cd $rel_source_dir; find $d/. -type l -print | \
- sed -e "s|$d/./|$d/|" -e 's|^\./||'`
- for link in $links --dummy-- ; do
- test -d $rel_source_dir/$link/. && newdirs="$newdirs $link"
- done
- done
- dirs="$newdirs"
- subdirs="$subdirs $newdirs"
- done
- ;;
- STD)
- rel_source_dir=$src_dir_std
- ;;
- esac
-
- case $rel_source_dir in
- /* | [A-Za-z]:[\\/]*)
- abs_source_dir=$rel_source_dir
- ;;
- *)
- abs_source_dir=$original_dir/$rel_source_dir
- ;;
- esac
-
- if [ \! -d $abs_source_dir ] ; then
- echo $progname\: warning\: no such directory\: \`$rel_source_dir\'
- continue
- fi
-
- for rel_source_subdir in $subdirs; do
-
- abs_target_subdir=${abs_target_dir}/${rel_source_subdir}
- if [ \! -d $abs_target_subdir ] ; then
- if $mkinstalldirs $abs_target_subdir ; then
- subdirs_made="$abs_target_subdir $subdirs_made"
- fi
- fi
- # Append "/"; remove initial "./". Hence "." -> "" and "sys" -> "sys/".
- rel_source_prefix=`echo $rel_source_subdir | sed -e 's|$|/|' -e 's|^\./||'`
-
- case $code in
- ALL)
- # The 'sed' is in case the *.h matches nothing, which yields "*.h"
- # which would then get re-globbed in the current directory. Sigh.
- rel_source_files=`cd ${abs_source_dir}/${rel_source_subdir}; echo *.h | sed -e 's|[*].h|NONE|'`
- ;;
-
- STD)
- files_to_check="$std_files"
- rel_source_files=""
-
- # Also process files #included by the $std_files.
- while [ -n "${files_to_check}" ]
- do
- new_files_to_check=""
- for file in $files_to_check ; do
- xxfile=`echo $file | sed -e 's|/\([^/\.][^/\.]*\)/\.\./|/|'`
- # Create the dir where this file will go when fixed.
- xxdir=`echo ./$file | sed -e 's|/[^/]*$||'`
- if [ \! -d $abs_target_subdir/$xxdir ] ; then
- if $mkinstalldirs $abs_target_subdir/$xxdir ; then
- subdirs_made="$abs_target_subdir/$xxdir $subdirs_made"
- fi
- fi
- # Just in case we have edited out a symbolic link
- if [ -f $src_dir_std/$file -a -f $src_dir_std/$xxfile ] ; then
- file=$xxfile
- fi
- case " $rel_source_files " in
- *" ${file} "*)
- # Already seen $file; nothing to do
- ;;
- *)
- if test -f $src_dir_std/$file ; then
- rel_dir=`echo $file | sed -n -e 's|^\(.*/\)[^/]*$|\1|p'`
- # For #include "foo.h", that might be either "foo.h"
- # or "${rel_dir}foo.h (or something bogus).
- new_files_to_check="$new_files_to_check "`sed -n \
- -e 's@ @ @g' \
- -e 's@^ *# *include *<\([^>]*\)>.*$@\1@p' -e \
- 's@^ *# *include *\"\([^\"]*\)\".*$@\1 '$rel_dir'\1@p'\
- <$src_dir_std/$file`
- rel_source_files="$rel_source_files $file"
- fi
- ;;
- esac
- done
- files_to_check="$new_files_to_check"
- done
- rel_source_files="$rel_source_files"
- ;;
- esac
-
- for filename in $rel_source_files ; do
- rel_source_file=${rel_source_prefix}${filename}
- abs_source_file=$abs_source_dir/$rel_source_file
- abs_target_file=$abs_target_dir/$rel_source_file
-
- if test "$filename" = 'NONE' ; then
- echo "(No *.h files in $abs_source_dir/$rel_source_subdir)"
- # If target file exists, check if was written while processing one
- # of the earlier source directories; if so ignore it.
- elif test -f $abs_target_file -a -n "$done_dirs" \
- && grep "$rel_source_file" fixproto.list >/dev/null
- then true
- else
- $FIX_HEADER $rel_source_file $abs_source_file $abs_target_file ${DEFINES} $include_path
- if test $? != 0 ; then exit 1 ; fi
- echo "${rel_source_file}" >>fixproto.list
- fi
- done
- done
- done_dirs="$done_dir $rel_source_dir"
-done
-
-# This might be more cleanly moved into the main loop, by adding
-# a <dummy> source directory at the end. FIXME!
-
-# All the headers we create define size_t and NULL.
-for rel_source_file in unistd.h stdlib.h string.h time.h ; do
- if grep "$rel_source_file" fixproto.list >/dev/null ; then
- : # It exists, we don't need to make it
- else
- echo Adding missing $rel_source_file
- rel_source_ident=`echo $rel_source_file | tr ./ __`
- cat >tmp.h <<EOF
-/* Fake ${rel_source_file}, created by GCC.
- The functions declared in this file do not necessarily exist in
- your C library. */
-#ifndef __${rel_source_ident}
-#define __${rel_source_ident}
-
-#define __need_NULL
-#define __need_size_t
-#include <stddef.h>
-EOF
- # Insert special stuff for particular files here.
- case ${rel_source_file} in
- time.h)
- # If time.h doesn't exist, find out if sys/time.h does.
- if test -f $src_dir_std/sys/time.h \
- || grep "sys/time.h" fixproto.list >/dev/null ; then
- # It does; include it and hope it has the needed declarations.
- # Some versions require sys/types.h.
- cat >>tmp.h <<EOF
-
-#include <sys/types.h>
-#include <sys/time.h>
-EOF
- else
- # It doesn't. Make up plausible definitions for time_t, clock_t.
- # Forward-declare struct tm. Hope nobody tries to use it. (Odds
- # are they won't.)
- cat >>tmp.h <<EOF
-
-typedef long time_t;
-typedef long clock_t;
-struct tm;
-EOF
- fi ;;
- esac
- cat >>tmp.h <<EOF
-
-#endif /* __${rel_source_ident} */
-EOF
- ${FIX_HEADER} $rel_source_file tmp.h $abs_target_dir/$rel_source_file ${DEFINES} $include_path
- if test $? != 0 ; then exit 1 ; fi
- if test -f $abs_target_dir/$rel_source_file ; then
- rm tmp.h
- else
- mv tmp.h $abs_target_dir/$rel_source_file
- fi
- fi
-done
-
-# Remove any directories that we made that are still empty.
-rmdir $subdirs_made 2>/dev/null
-
-exit 0
+++ /dev/null
-/* gen-protos.c - massages a list of prototypes, for use by fixproto.
- Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2003, 2004, 2005, 2007
- Free Software Foundation, Inc.
-
- 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, 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; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-#include "bconfig.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "scan.h"
-#include "errors.h"
-
-int verbose = 0;
-
-static void add_hash (const char *);
-static int parse_fn_proto (char *, char *, struct fn_decl *);
-
-#define HASH_SIZE 2503 /* a prime */
-int hash_tab[HASH_SIZE];
-int next_index;
-int collisions;
-
-static void
-add_hash (const char *fname)
-{
- int i, i0;
-
- /* NOTE: If you edit this, also edit lookup_std_proto in fix-header.c !! */
- i = hashstr (fname, strlen (fname)) % HASH_SIZE;
- i0 = i;
- if (hash_tab[i] != 0)
- {
- collisions++;
- for (;;)
- {
- i = (i+1) % HASH_SIZE;
- gcc_assert (i != i0);
- if (hash_tab[i] == 0)
- break;
- }
- }
- hash_tab[i] = next_index;
-
- next_index++;
-}
-
-/* Given a function prototype, fill in the fields of FN.
- The result is a boolean indicating if a function prototype was found.
-
- The input string is modified (trailing NULs are inserted).
- The fields of FN point to the input string. */
-
-static int
-parse_fn_proto (char *start, char *end, struct fn_decl *fn)
-{
- char *ptr;
- int param_nesting = 1;
- char *param_start, *param_end, *decl_start, *name_start, *name_end;
-
- ptr = end - 1;
- while (*ptr == ' ' || *ptr == '\t') ptr--;
- if (*ptr-- != ';')
- {
- fprintf (stderr, "Funny input line: %s\n", start);
- return 0;
- }
- while (*ptr == ' ' || *ptr == '\t') ptr--;
- if (*ptr != ')')
- {
- fprintf (stderr, "Funny input line: %s\n", start);
- return 0;
- }
- param_end = ptr;
- for (;;)
- {
- int c = *--ptr;
- if (c == '(' && --param_nesting == 0)
- break;
- else if (c == ')')
- param_nesting++;
- }
- param_start = ptr+1;
-
- ptr--;
- while (*ptr == ' ' || *ptr == '\t') ptr--;
-
- if (!ISALNUM ((unsigned char)*ptr))
- {
- if (verbose)
- fprintf (stderr, "%s: Can't handle this complex prototype: %s\n",
- progname, start);
- return 0;
- }
- name_end = ptr+1;
-
- while (ISIDNUM (*ptr))
- --ptr;
- name_start = ptr+1;
- while (*ptr == ' ' || *ptr == '\t') ptr--;
- ptr[1] = 0;
- *param_end = 0;
- *name_end = 0;
-
- decl_start = start;
- if (strncmp (decl_start, "typedef ", 8) == 0)
- return 0;
- if (strncmp (decl_start, "extern ", 7) == 0)
- decl_start += 7;
-
- fn->fname = name_start;
- fn->rtype = decl_start;
- fn->params = param_start;
- return 1;
-}
-
-int
-main (int argc ATTRIBUTE_UNUSED, char **argv)
-{
- FILE *inf = stdin;
- FILE *outf = stdout;
- int i;
- sstring linebuf;
- struct fn_decl fn_decl;
-
- i = strlen (argv[0]);
- while (i > 0 && argv[0][i-1] != '/') --i;
- progname = &argv[0][i];
-
- /* Unlock the stdio streams. */
- unlock_std_streams ();
-
- INIT_SSTRING (&linebuf);
-
- fprintf (outf, "struct fn_decl std_protos[] = {\n");
-
- /* A hash table entry of 0 means "unused" so reserve it. */
- fprintf (outf, " {\"\", \"\", \"\", 0},\n");
- next_index = 1;
-
- for (;;)
- {
- int c = skip_spaces (inf, ' ');
-
- if (c == EOF)
- break;
- linebuf.ptr = linebuf.base;
- ungetc (c, inf);
- c = read_upto (inf, &linebuf, '\n');
- if (linebuf.base[0] == '#') /* skip cpp command */
- continue;
- if (linebuf.base[0] == '\0') /* skip empty line */
- continue;
-
- if (! parse_fn_proto (linebuf.base, linebuf.ptr, &fn_decl))
- continue;
-
- add_hash (fn_decl.fname);
-
- fprintf (outf, " {\"%s\", \"%s\", \"%s\", 0},\n",
- fn_decl.fname, fn_decl.rtype, fn_decl.params);
-
- if (c == EOF)
- break;
- }
- fprintf (outf, " {0, 0, 0, 0}\n};\n");
-
-
- fprintf (outf, "#define HASH_SIZE %d\n", HASH_SIZE);
- fprintf (outf, "short hash_tab[HASH_SIZE] = {\n");
- for (i = 0; i < HASH_SIZE; i++)
- fprintf (outf, " %d,\n", hash_tab[i]);
- fprintf (outf, "};\n");
-
- fprintf (stderr, "gen-protos: %d entries %d collisions\n",
- next_index, collisions);
-
- return 0;
-}
+2009-03-28 Joseph Myers <joseph@codesourcery.com>
+
+ * EXCLUDES (fix-header.c, gen-protos.c, scan-decls.c, scan.c,
+ scan.h): Remove.
+
2009-03-03 Joseph Myers <joseph@codesourcery.com>
* es.po: Update.
# These programs are meant to be executed only by GCC maintainers or
# installers. Such files do not need to be translated, as these
# people typically need to be able to read English anyway.
-fix-header.c
-gen-protos.c
genattr.c
genattrtab.c
genautomata.c
genrecog.c
gensupport.c
gensupport.h
-scan-decls.c
-scan.c
-scan.h
# These files are not yet internationalized, because they contain
# many strings that require a lot of analysis, and are little-used.
+++ /dev/null
-/* Protoize program - Original version by Ron Guilmette (rfg@segfault.us.com).
- Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 Free Software
- Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "intl.h"
-#include "cppdefault.h"
-
-#include <setjmp.h>
-#include <signal.h>
-#if ! defined( SIGCHLD ) && defined( SIGCLD )
-# define SIGCHLD SIGCLD
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "version.h"
-
-/* Include getopt.h for the sake of getopt_long. */
-#include "getopt.h"
-
-/* Macro to see if the path elements match. */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-#define IS_SAME_PATH_CHAR(a,b) (TOUPPER (a) == TOUPPER (b))
-#else
-#define IS_SAME_PATH_CHAR(a,b) ((a) == (b))
-#endif
-
-/* Macro to see if the paths match. */
-#define IS_SAME_PATH(a,b) (FILENAME_CMP (a, b) == 0)
-
-/* Suffix for aux-info files. */
-#ifdef __MSDOS__
-#define AUX_INFO_SUFFIX "X"
-#else
-#define AUX_INFO_SUFFIX ".X"
-#endif
-
-/* Suffix for saved files. */
-#ifdef __MSDOS__
-#define SAVE_SUFFIX "sav"
-#else
-#define SAVE_SUFFIX ".save"
-#endif
-
-/* Suffix for renamed C++ files. */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-#define CPLUS_FILE_SUFFIX "cc"
-#else
-#define CPLUS_FILE_SUFFIX "C"
-#endif
-
-static void usage (void) ATTRIBUTE_NORETURN;
-static void aux_info_corrupted (void) ATTRIBUTE_NORETURN;
-static void declare_source_confusing (const char *) ATTRIBUTE_NORETURN;
-static const char *shortpath (const char *, const char *);
-static void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
-static char *savestring (const char *, unsigned int);
-static char *dupnstr (const char *, size_t);
-static int safe_read (int, void *, int);
-static void safe_write (int, void *, int, const char *);
-static void save_pointers (void);
-static void restore_pointers (void);
-static int is_id_char (int);
-static int in_system_include_dir (const char *);
-static int directory_specified_p (const char *);
-static int file_excluded_p (const char *);
-static char *unexpand_if_needed (const char *);
-static char *abspath (const char *, const char *);
-static void check_aux_info (int);
-static const char *find_corresponding_lparen (const char *);
-static int referenced_file_is_newer (const char *, time_t);
-static void save_def_or_dec (const char *, int);
-static void munge_compile_params (const char *);
-static int gen_aux_info_file (const char *);
-static void process_aux_info_file (const char *, int, int);
-static int identify_lineno (const char *);
-static void check_source (int, const char *);
-static const char *seek_to_line (int);
-static const char *forward_to_next_token_char (const char *);
-static void output_bytes (const char *, size_t);
-static void output_string (const char *);
-static void output_up_to (const char *);
-static int other_variable_style_function (const char *);
-static const char *find_rightmost_formals_list (const char *);
-static void do_cleaning (char *, const char *);
-static const char *careful_find_l_paren (const char *);
-static void do_processing (void);
-
-/* Look for these where the `const' qualifier is intentionally cast aside. */
-#define NONCONST
-
-/* Define a default place to find the SYSCALLS.X file. */
-
-#ifndef UNPROTOIZE
-
-#ifndef STANDARD_EXEC_PREFIX
-#define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc-lib/"
-#endif /* !defined STANDARD_EXEC_PREFIX */
-
-static const char * const standard_exec_prefix = STANDARD_EXEC_PREFIX;
-static const char * const target_machine = DEFAULT_TARGET_MACHINE;
-static const char * const target_version = DEFAULT_TARGET_VERSION;
-
-#endif /* !defined (UNPROTOIZE) */
-
-/* Suffix of aux_info files. */
-
-static const char * const aux_info_suffix = AUX_INFO_SUFFIX;
-
-/* String to attach to filenames for saved versions of original files. */
-
-static const char * const save_suffix = SAVE_SUFFIX;
-
-#ifndef UNPROTOIZE
-
-/* String to attach to C filenames renamed to C++. */
-
-static const char * const cplus_suffix = CPLUS_FILE_SUFFIX;
-
-/* File name of the file which contains descriptions of standard system
- routines. Note that we never actually do anything with this file per se,
- but we do read in its corresponding aux_info file. */
-
-static const char syscalls_filename[] = "SYSCALLS.c";
-
-/* Default place to find the above file. */
-
-static const char * default_syscalls_dir;
-
-/* Variable to hold the complete absolutized filename of the SYSCALLS.c.X
- file. */
-
-static char * syscalls_absolute_filename;
-
-#endif /* !defined (UNPROTOIZE) */
-
-/* Type of the structure that holds information about macro unexpansions. */
-
-struct unexpansion_struct {
- const char *const expanded;
- const char *const contracted;
-};
-typedef struct unexpansion_struct unexpansion;
-
-/* A table of conversions that may need to be made for some (stupid) older
- operating systems where these types are preprocessor macros rather than
- typedefs (as they really ought to be).
-
- WARNING: The contracted forms must be as small (or smaller) as the
- expanded forms, or else havoc will ensue. */
-
-static const unexpansion unexpansions[] = {
- { "struct _iobuf", "FILE" },
- { 0, 0 }
-};
-
-/* The number of "primary" slots in the hash tables for filenames and for
- function names. This can be as big or as small as you like, except that
- it must be a power of two. */
-
-#define HASH_TABLE_SIZE (1 << 9)
-
-/* Bit mask to use when computing hash values. */
-
-static const int hash_mask = (HASH_TABLE_SIZE - 1);
-
-
-/* Datatype for lists of directories or filenames. */
-struct string_list
-{
- const char *name;
- struct string_list *next;
-};
-
-static struct string_list *string_list_cons (const char *,
- struct string_list *);
-
-/* List of directories in which files should be converted. */
-
-struct string_list *directory_list;
-
-/* List of file names which should not be converted.
- A file is excluded if the end of its name, following a /,
- matches one of the names in this list. */
-
-struct string_list *exclude_list;
-
-/* The name of the other style of variable-number-of-parameters functions
- (i.e. the style that we want to leave unconverted because we don't yet
- know how to convert them to this style. This string is used in warning
- messages. */
-
-/* Also define here the string that we can search for in the parameter lists
- taken from the .X files which will unambiguously indicate that we have
- found a varargs style function. */
-
-#ifdef UNPROTOIZE
-static const char * const other_var_style = "stdarg";
-#else /* !defined (UNPROTOIZE) */
-static const char * const other_var_style = "varargs";
-static const char *varargs_style_indicator = "va_alist";
-#endif /* !defined (UNPROTOIZE) */
-
-/* The following two types are used to create hash tables. In this program,
- there are two hash tables which are used to store and quickly lookup two
- different classes of strings. The first type of strings stored in the
- first hash table are absolute filenames of files which protoize needs to
- know about. The second type of strings (stored in the second hash table)
- are function names. It is this second class of strings which really
- inspired the use of the hash tables, because there may be a lot of them. */
-
-typedef struct hash_table_entry_struct hash_table_entry;
-
-/* Do some typedefs so that we don't have to write "struct" so often. */
-
-typedef struct def_dec_info_struct def_dec_info;
-typedef struct file_info_struct file_info;
-typedef struct f_list_chain_item_struct f_list_chain_item;
-
-#ifndef UNPROTOIZE
-static int is_syscalls_file (const file_info *);
-static void rename_c_file (const hash_table_entry *);
-static const def_dec_info *find_extern_def (const def_dec_info *,
- const def_dec_info *);
-static const def_dec_info *find_static_definition (const def_dec_info *);
-static void connect_defs_and_decs (const hash_table_entry *);
-static void add_local_decl (const def_dec_info *, const char *);
-static void add_global_decls (const file_info *, const char *);
-#endif /* ! UNPROTOIZE */
-static int needs_to_be_converted (const file_info *);
-static void visit_each_hash_node (const hash_table_entry *,
- void (*)(const hash_table_entry *));
-static hash_table_entry *add_symbol (hash_table_entry *, const char *);
-static hash_table_entry *lookup (hash_table_entry *, const char *);
-static void free_def_dec (def_dec_info *);
-static file_info *find_file (const char *, int);
-static void reverse_def_dec_list (const hash_table_entry *);
-static void edit_fn_declaration (const def_dec_info *, const char *);
-static int edit_formals_lists (const char *, unsigned int,
- const def_dec_info *);
-static void edit_fn_definition (const def_dec_info *, const char *);
-static void scan_for_missed_items (const file_info *);
-static void edit_file (const hash_table_entry *);
-
-/* In the struct below, note that the "_info" field has two different uses
- depending on the type of hash table we are in (i.e. either the filenames
- hash table or the function names hash table). In the filenames hash table
- the info fields of the entries point to the file_info struct which is
- associated with each filename (1 per filename). In the function names
- hash table, the info field points to the head of a singly linked list of
- def_dec_info entries which are all defs or decs of the function whose
- name is pointed to by the "symbol" field. Keeping all of the defs/decs
- for a given function name on a special list specifically for that function
- name makes it quick and easy to find out all of the important information
- about a given (named) function. */
-
-struct hash_table_entry_struct {
- hash_table_entry * hash_next; /* -> to secondary entries */
- const char * symbol; /* -> to the hashed string */
- union {
- const def_dec_info * _ddip;
- file_info * _fip;
- } _info;
-};
-#define ddip _info._ddip
-#define fip _info._fip
-
-/* Define a type specifically for our two hash tables. */
-
-typedef hash_table_entry hash_table[HASH_TABLE_SIZE];
-
-/* The following struct holds all of the important information about any
- single filename (e.g. file) which we need to know about. */
-
-struct file_info_struct {
- const hash_table_entry * hash_entry; /* -> to associated hash entry */
- const def_dec_info * defs_decs; /* -> to chain of defs/decs */
- time_t mtime; /* Time of last modification. */
-};
-
-/* Due to the possibility that functions may return pointers to functions,
- (which may themselves have their own parameter lists) and due to the
- fact that returned pointers-to-functions may be of type "pointer-to-
- function-returning-pointer-to-function" (ad nauseum) we have to keep
- an entire chain of ANSI style formal parameter lists for each function.
-
- Normally, for any given function, there will only be one formals list
- on the chain, but you never know.
-
- Note that the head of each chain of formals lists is pointed to by the
- `f_list_chain' field of the corresponding def_dec_info record.
-
- For any given chain, the item at the head of the chain is the *leftmost*
- parameter list seen in the actual C language function declaration. If
- there are other members of the chain, then these are linked in left-to-right
- order from the head of the chain. */
-
-struct f_list_chain_item_struct {
- const f_list_chain_item * chain_next; /* -> to next item on chain */
- const char * formals_list; /* -> to formals list string */
-};
-
-/* The following struct holds all of the important information about any
- single function definition or declaration which we need to know about.
- Note that for unprotoize we don't need to know very much because we
- never even create records for stuff that we don't intend to convert
- (like for instance defs and decs which are already in old K&R format
- and "implicit" function declarations). */
-
-struct def_dec_info_struct {
- const def_dec_info * next_in_file; /* -> to rest of chain for file */
- file_info * file; /* -> file_info for containing file */
- int line; /* source line number of def/dec */
- const char * ansi_decl; /* -> left end of ansi decl */
- hash_table_entry * hash_entry; /* -> hash entry for function name */
- unsigned int is_func_def; /* = 0 means this is a declaration */
- const def_dec_info * next_for_func; /* -> to rest of chain for func name */
- unsigned int f_list_count; /* count of formals lists we expect */
- char prototyped; /* = 0 means already prototyped */
-#ifndef UNPROTOIZE
- const f_list_chain_item * f_list_chain; /* -> chain of formals lists */
- const def_dec_info * definition; /* -> def/dec containing related def */
- char is_static; /* = 0 means visibility is "extern" */
- char is_implicit; /* != 0 for implicit func decl's */
- char written; /* != 0 means written for implicit */
-#else /* !defined (UNPROTOIZE) */
- const char * formal_names; /* -> to list of names of formals */
- const char * formal_decls; /* -> to string of formal declarations */
-#endif /* !defined (UNPROTOIZE) */
-};
-
-/* Pointer to the tail component of the filename by which this program was
- invoked. Used everywhere in error and warning messages. */
-
-static const char *pname;
-
-/* Error counter. Will be nonzero if we should give up at the next convenient
- stopping point. */
-
-static int errors = 0;
-
-/* Option flags. */
-/* ??? The variables are not marked static because some of them have
- the same names as gcc variables declared in options.h. */
-/* ??? These comments should say what the flag mean as well as the options
- that set them. */
-
-/* File name to use for running gcc. Allows GCC 2 to be named
- something other than gcc. */
-static const char *compiler_file_name = "gcc";
-
-int version_flag = 0; /* Print our version number. */
-int quiet_flag = 0; /* Don't print messages normally. */
-int nochange_flag = 0; /* Don't convert, just say what files
- we would have converted. */
-int nosave_flag = 0; /* Don't save the old version. */
-int keep_flag = 0; /* Don't delete the .X files. */
-static const char ** compile_params = 0; /* Option string for gcc. */
-#ifdef UNPROTOIZE
-static const char *indent_string = " "; /* Indentation for newly
- inserted parm decls. */
-#else /* !defined (UNPROTOIZE) */
-int local_flag = 0; /* Insert new local decls (when?). */
-int global_flag = 0; /* set by -g option */
-int cplusplus_flag = 0; /* Rename converted files to *.C. */
-static const char *nondefault_syscalls_dir = 0; /* Dir to look for
- SYSCALLS.c.X in. */
-#endif /* !defined (UNPROTOIZE) */
-
-/* An index into the compile_params array where we should insert the source
- file name when we are ready to exec the C compiler. A zero value indicates
- that we have not yet called munge_compile_params. */
-
-static int input_file_name_index = 0;
-
-/* An index into the compile_params array where we should insert the filename
- for the aux info file, when we run the C compiler. */
-static int aux_info_file_name_index = 0;
-
-/* Count of command line arguments which were "filename" arguments. */
-
-static int n_base_source_files = 0;
-
-/* Points to a malloc'ed list of pointers to all of the filenames of base
- source files which were specified on the command line. */
-
-static const char **base_source_filenames;
-
-/* Line number of the line within the current aux_info file that we
- are currently processing. Used for error messages in case the prototypes
- info file is corrupted somehow. */
-
-static int current_aux_info_lineno;
-
-/* Pointer to the name of the source file currently being converted. */
-
-static const char *convert_filename;
-
-/* Pointer to relative root string (taken from aux_info file) which indicates
- where directory the user was in when he did the compilation step that
- produced the containing aux_info file. */
-
-static const char *invocation_filename;
-
-/* Pointer to the base of the input buffer that holds the original text for the
- source file currently being converted. */
-
-static const char *orig_text_base;
-
-/* Pointer to the byte just beyond the end of the input buffer that holds the
- original text for the source file currently being converted. */
-
-static const char *orig_text_limit;
-
-/* Pointer to the base of the input buffer that holds the cleaned text for the
- source file currently being converted. */
-
-static const char *clean_text_base;
-
-/* Pointer to the byte just beyond the end of the input buffer that holds the
- cleaned text for the source file currently being converted. */
-
-static const char *clean_text_limit;
-
-/* Pointer to the last byte in the cleaned text buffer that we have already
- (virtually) copied to the output buffer (or decided to ignore). */
-
-static const char * clean_read_ptr;
-
-/* Pointer to the base of the output buffer that holds the replacement text
- for the source file currently being converted. */
-
-static char *repl_text_base;
-
-/* Pointer to the byte just beyond the end of the output buffer that holds the
- replacement text for the source file currently being converted. */
-
-static char *repl_text_limit;
-
-/* Pointer to the last byte which has been stored into the output buffer.
- The next byte to be stored should be stored just past where this points
- to. */
-
-static char * repl_write_ptr;
-
-/* Pointer into the cleaned text buffer for the source file we are currently
- converting. This points to the first character of the line that we last
- did a "seek_to_line" to (see below). */
-
-static const char *last_known_line_start;
-
-/* Number of the line (in the cleaned text buffer) that we last did a
- "seek_to_line" to. Will be one if we just read a new source file
- into the cleaned text buffer. */
-
-static int last_known_line_number;
-
-/* The filenames hash table. */
-
-static hash_table filename_primary;
-
-/* The function names hash table. */
-
-static hash_table function_name_primary;
-
-/* The place to keep the recovery address which is used only in cases where
- we get hopelessly confused by something in the cleaned original text. */
-
-static jmp_buf source_confusion_recovery;
-
-/* A pointer to the current directory filename (used by abspath). */
-
-static char *cwd_buffer;
-
-/* A place to save the read pointer until we are sure that an individual
- attempt at editing will succeed. */
-
-static const char * saved_clean_read_ptr;
-
-/* A place to save the write pointer until we are sure that an individual
- attempt at editing will succeed. */
-
-static char * saved_repl_write_ptr;
-\f
-/* Translate and output an error message. */
-static void
-notice (const char *cmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, cmsgid);
- vfprintf (stderr, _(cmsgid), ap);
- va_end (ap);
-}
-
-\f
-/* Make a copy of a string INPUT with size SIZE. */
-
-static char *
-savestring (const char *input, unsigned int size)
-{
- char *output = xmalloc (size + 1);
- strcpy (output, input);
- return output;
-}
-
-\f
-/* Make a duplicate of the first N bytes of a given string in a newly
- allocated area. */
-
-static char *
-dupnstr (const char *s, size_t n)
-{
- char *ret_val = xmalloc (n + 1);
-
- strncpy (ret_val, s, n);
- ret_val[n] = '\0';
- return ret_val;
-}
-\f
-/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
- retrying if necessary. Return the actual number of bytes read. */
-
-static int
-safe_read (int desc, void *ptr, int len)
-{
- int left = len;
- while (left > 0) {
- int nchars = read (desc, ptr, left);
- if (nchars < 0)
- {
-#ifdef EINTR
- if (errno == EINTR)
- continue;
-#endif
- return nchars;
- }
- if (nchars == 0)
- break;
- /* Arithmetic on void pointers is a gcc extension. */
- ptr = (char *) ptr + nchars;
- left -= nchars;
- }
- return len - left;
-}
-
-/* Write LEN bytes at PTR to descriptor DESC,
- retrying if necessary, and treating any real error as fatal. */
-
-static void
-safe_write (int desc, void *ptr, int len, const char *out_fname)
-{
- while (len > 0) {
- int written = write (desc, ptr, len);
- if (written < 0)
- {
- int errno_val = errno;
-#ifdef EINTR
- if (errno_val == EINTR)
- continue;
-#endif
- notice ("%s: error writing file '%s': %s\n",
- pname, shortpath (NULL, out_fname), xstrerror (errno_val));
- return;
- }
- /* Arithmetic on void pointers is a gcc extension. */
- ptr = (char *) ptr + written;
- len -= written;
- }
-}
-\f
-/* Get setup to recover in case the edit we are about to do goes awry. */
-
-static void
-save_pointers (void)
-{
- saved_clean_read_ptr = clean_read_ptr;
- saved_repl_write_ptr = repl_write_ptr;
-}
-
-/* Call this routine to recover our previous state whenever something looks
- too confusing in the source code we are trying to edit. */
-
-static void
-restore_pointers (void)
-{
- clean_read_ptr = saved_clean_read_ptr;
- repl_write_ptr = saved_repl_write_ptr;
-}
-
-/* Return true if the given character is a valid identifier character. */
-
-static int
-is_id_char (int ch)
-{
- return (ISIDNUM (ch) || (ch == '$'));
-}
-
-/* Give a message indicating the proper way to invoke this program and then
- exit with nonzero status. */
-
-static void
-usage (void)
-{
-#ifdef UNPROTOIZE
- notice ("%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'\n",
- pname, pname);
-#else /* !defined (UNPROTOIZE) */
- notice ("%s: usage '%s [ -VqfnkNlgC ] [ -B <dirname> ] [ filename ... ]'\n",
- pname, pname);
-#endif /* !defined (UNPROTOIZE) */
- exit (FATAL_EXIT_CODE);
-}
-
-/* Return true if the given filename (assumed to be an absolute filename)
- designates a file residing anywhere beneath any one of the "system"
- include directories. */
-
-static int
-in_system_include_dir (const char *path)
-{
- const struct default_include *p;
-
- gcc_assert (IS_ABSOLUTE_PATH (path));
-
- for (p = cpp_include_defaults; p->fname; p++)
- if (!strncmp (path, p->fname, strlen (p->fname))
- && IS_DIR_SEPARATOR (path[strlen (p->fname)]))
- return 1;
- return 0;
-}
-\f
-#if 0
-/* Return true if the given filename designates a file that the user has
- read access to and for which the user has write access to the containing
- directory. */
-
-static int
-file_could_be_converted (const char *path)
-{
- char *const dir_name = alloca (strlen (path) + 1);
-
- if (access (path, R_OK))
- return 0;
-
- {
- char *dir_last_slash;
-
- strcpy (dir_name, path);
- dir_last_slash = strrchr (dir_name, DIR_SEPARATOR);
-#ifdef DIR_SEPARATOR_2
- {
- char *slash;
-
- slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
- DIR_SEPARATOR_2);
- if (slash)
- dir_last_slash = slash;
- }
-#endif
- gcc_assert (dir_last_slash);
- *dir_last_slash = '\0';
- }
-
- if (access (path, W_OK))
- return 0;
-
- return 1;
-}
-
-/* Return true if the given filename designates a file that we are allowed
- to modify. Files which we should not attempt to modify are (a) "system"
- include files, and (b) files which the user doesn't have write access to,
- and (c) files which reside in directories which the user doesn't have
- write access to. Unless requested to be quiet, give warnings about
- files that we will not try to convert for one reason or another. An
- exception is made for "system" include files, which we never try to
- convert and for which we don't issue the usual warnings. */
-
-static int
-file_normally_convertible (const char *path)
-{
- char *const dir_name = alloca (strlen (path) + 1);
-
- if (in_system_include_dir (path))
- return 0;
-
- {
- char *dir_last_slash;
-
- strcpy (dir_name, path);
- dir_last_slash = strrchr (dir_name, DIR_SEPARATOR);
-#ifdef DIR_SEPARATOR_2
- {
- char *slash;
-
- slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
- DIR_SEPARATOR_2);
- if (slash)
- dir_last_slash = slash;
- }
-#endif
- gcc_assert (dir_last_slash);
- *dir_last_slash = '\0';
- }
-
- if (access (path, R_OK))
- {
- if (!quiet_flag)
- notice ("%s: warning: no read access for file '%s'\n",
- pname, shortpath (NULL, path));
- return 0;
- }
-
- if (access (path, W_OK))
- {
- if (!quiet_flag)
- notice ("%s: warning: no write access for file '%s'\n",
- pname, shortpath (NULL, path));
- return 0;
- }
-
- if (access (dir_name, W_OK))
- {
- if (!quiet_flag)
- notice ("%s: warning: no write access for dir containing '%s'\n",
- pname, shortpath (NULL, path));
- return 0;
- }
-
- return 1;
-}
-#endif /* 0 */
-\f
-#ifndef UNPROTOIZE
-
-/* Return true if the given file_info struct refers to the special SYSCALLS.c.X
- file. Return false otherwise. */
-
-static int
-is_syscalls_file (const file_info *fi_p)
-{
- char const *f = fi_p->hash_entry->symbol;
- size_t fl = strlen (f), sysl = sizeof (syscalls_filename) - 1;
- return sysl <= fl && strcmp (f + fl - sysl, syscalls_filename) == 0;
-}
-
-#endif /* !defined (UNPROTOIZE) */
-
-/* Check to see if this file will need to have anything done to it on this
- run. If there is nothing in the given file which both needs conversion
- and for which we have the necessary stuff to do the conversion, return
- false. Otherwise, return true.
-
- Note that (for protoize) it is only valid to call this function *after*
- the connections between declarations and definitions have all been made
- by connect_defs_and_decs. */
-
-static int
-needs_to_be_converted (const file_info *file_p)
-{
- const def_dec_info *ddp;
-
-#ifndef UNPROTOIZE
-
- if (is_syscalls_file (file_p))
- return 0;
-
-#endif /* !defined (UNPROTOIZE) */
-
- for (ddp = file_p->defs_decs; ddp; ddp = ddp->next_in_file)
-
- if (
-
-#ifndef UNPROTOIZE
-
- /* ... and if we a protoizing and this function is in old style ... */
- !ddp->prototyped
- /* ... and if this a definition or is a decl with an associated def ... */
- && (ddp->is_func_def || (!ddp->is_func_def && ddp->definition))
-
-#else /* defined (UNPROTOIZE) */
-
- /* ... and if we are unprotoizing and this function is in new style ... */
- ddp->prototyped
-
-#endif /* defined (UNPROTOIZE) */
- )
- /* ... then the containing file needs converting. */
- return -1;
- return 0;
-}
-
-/* Return 1 if the file name NAME is in a directory
- that should be converted. */
-
-static int
-directory_specified_p (const char *name)
-{
- struct string_list *p;
-
- for (p = directory_list; p; p = p->next)
- if (!strncmp (name, p->name, strlen (p->name))
- && IS_DIR_SEPARATOR (name[strlen (p->name)]))
- {
- const char *q = name + strlen (p->name) + 1;
-
- /* If there are more slashes, it's in a subdir, so
- this match doesn't count. */
- while (*q++)
- if (IS_DIR_SEPARATOR (*(q-1)))
- goto lose;
- return 1;
-
- lose: ;
- }
-
- return 0;
-}
-
-/* Return 1 if the file named NAME should be excluded from conversion. */
-
-static int
-file_excluded_p (const char *name)
-{
- struct string_list *p;
- int len = strlen (name);
-
- for (p = exclude_list; p; p = p->next)
- if (!strcmp (name + len - strlen (p->name), p->name)
- && IS_DIR_SEPARATOR (name[len - strlen (p->name) - 1]))
- return 1;
-
- return 0;
-}
-
-/* Construct a new element of a string_list.
- STRING is the new element value, and REST holds the remaining elements. */
-
-static struct string_list *
-string_list_cons (const char *string, struct string_list *rest)
-{
- struct string_list *temp = xmalloc (sizeof (struct string_list));
-
- temp->next = rest;
- temp->name = string;
- return temp;
-}
-\f
-/* ??? The GNU convention for mentioning function args in its comments
- is to capitalize them. So change "hash_tab_p" to HASH_TAB_P below.
- Likewise for all the other functions. */
-
-/* Given a hash table, apply some function to each node in the table. The
- table to traverse is given as the "hash_tab_p" argument, and the
- function to be applied to each node in the table is given as "func"
- argument. */
-
-static void
-visit_each_hash_node (const hash_table_entry *hash_tab_p,
- void (*func) (const hash_table_entry *))
-{
- const hash_table_entry *primary;
-
- for (primary = hash_tab_p; primary < &hash_tab_p[HASH_TABLE_SIZE]; primary++)
- if (primary->symbol)
- {
- hash_table_entry *second;
-
- (*func)(primary);
- for (second = primary->hash_next; second; second = second->hash_next)
- (*func) (second);
- }
-}
-
-/* Initialize all of the fields of a new hash table entry, pointed
- to by the "p" parameter. Note that the space to hold the entry
- is assumed to have already been allocated before this routine is
- called. */
-
-static hash_table_entry *
-add_symbol (hash_table_entry *p, const char *s)
-{
- p->hash_next = NULL;
- p->symbol = xstrdup (s);
- p->ddip = NULL;
- p->fip = NULL;
- return p;
-}
-
-/* Look for a particular function name or filename in the particular
- hash table indicated by "hash_tab_p". If the name is not in the
- given hash table, add it. Either way, return a pointer to the
- hash table entry for the given name. */
-
-static hash_table_entry *
-lookup (hash_table_entry *hash_tab_p, const char *search_symbol)
-{
- int hash_value = 0;
- const char *search_symbol_char_p = search_symbol;
- hash_table_entry *p;
-
- while (*search_symbol_char_p)
- hash_value += *search_symbol_char_p++;
- hash_value &= hash_mask;
- p = &hash_tab_p[hash_value];
- if (! p->symbol)
- return add_symbol (p, search_symbol);
- if (!strcmp (p->symbol, search_symbol))
- return p;
- while (p->hash_next)
- {
- p = p->hash_next;
- if (!strcmp (p->symbol, search_symbol))
- return p;
- }
- p->hash_next = xmalloc (sizeof (hash_table_entry));
- p = p->hash_next;
- return add_symbol (p, search_symbol);
-}
-\f
-/* Throw a def/dec record on the junk heap.
-
- Also, since we are not using this record anymore, free up all of the
- stuff it pointed to. */
-
-static void
-free_def_dec (def_dec_info *p)
-{
- free ((NONCONST void *) p->ansi_decl);
-
-#ifndef UNPROTOIZE
- {
- const f_list_chain_item * curr;
- const f_list_chain_item * next;
-
- for (curr = p->f_list_chain; curr; curr = next)
- {
- next = curr->chain_next;
- free ((NONCONST void *) curr);
- }
- }
-#endif /* !defined (UNPROTOIZE) */
-
- free (p);
-}
-
-/* Unexpand as many macro symbols as we can find.
-
- If the given line must be unexpanded, make a copy of it in the heap and
- return a pointer to the unexpanded copy. Otherwise return NULL. */
-
-static char *
-unexpand_if_needed (const char *aux_info_line)
-{
- static char *line_buf = 0;
- static int line_buf_size = 0;
- const unexpansion *unexp_p;
- int got_unexpanded = 0;
- const char *s;
- char *copy_p = line_buf;
-
- if (line_buf == 0)
- {
- line_buf_size = 1024;
- line_buf = xmalloc (line_buf_size);
- }
-
- copy_p = line_buf;
-
- /* Make a copy of the input string in line_buf, expanding as necessary. */
-
- for (s = aux_info_line; *s != '\n'; )
- {
- for (unexp_p = unexpansions; unexp_p->expanded; unexp_p++)
- {
- const char *in_p = unexp_p->expanded;
- size_t len = strlen (in_p);
-
- if (*s == *in_p && !strncmp (s, in_p, len) && !is_id_char (s[len]))
- {
- int size = strlen (unexp_p->contracted);
- got_unexpanded = 1;
- if (copy_p + size - line_buf >= line_buf_size)
- {
- int offset = copy_p - line_buf;
- line_buf_size *= 2;
- line_buf_size += size;
- line_buf = xrealloc (line_buf, line_buf_size);
- copy_p = line_buf + offset;
- }
- strcpy (copy_p, unexp_p->contracted);
- copy_p += size;
-
- /* Assume that there will not be another replacement required
- within the text just replaced. */
-
- s += len;
- goto continue_outer;
- }
- }
- if (copy_p - line_buf == line_buf_size)
- {
- int offset = copy_p - line_buf;
- line_buf_size *= 2;
- line_buf = xrealloc (line_buf, line_buf_size);
- copy_p = line_buf + offset;
- }
- *copy_p++ = *s++;
-continue_outer: ;
- }
- if (copy_p + 2 - line_buf >= line_buf_size)
- {
- int offset = copy_p - line_buf;
- line_buf_size *= 2;
- line_buf = xrealloc (line_buf, line_buf_size);
- copy_p = line_buf + offset;
- }
- *copy_p++ = '\n';
- *copy_p = '\0';
-
- return (got_unexpanded ? savestring (line_buf, copy_p - line_buf) : 0);
-}
-\f
-/* Return the absolutized filename for the given relative
- filename. Note that if that filename is already absolute, it may
- still be returned in a modified form because this routine also
- eliminates redundant slashes and single dots and eliminates double
- dots to get a shortest possible filename from the given input
- filename. The absolutization of relative filenames is made by
- assuming that the given filename is to be taken as relative to
- the first argument (cwd) or to the current directory if cwd is
- NULL. */
-
-static char *
-abspath (const char *cwd, const char *rel_filename)
-{
- /* Setup the current working directory as needed. */
- const char *const cwd2 = (cwd) ? cwd : cwd_buffer;
- char *const abs_buffer = alloca (strlen (cwd2) + strlen (rel_filename) + 2);
- char *endp = abs_buffer;
- char *outp, *inp;
-
- /* Copy the filename (possibly preceded by the current working
- directory name) into the absolutization buffer. */
-
- {
- const char *src_p;
-
- if (! IS_ABSOLUTE_PATH (rel_filename))
- {
- src_p = cwd2;
- while ((*endp++ = *src_p++))
- continue;
- *(endp-1) = DIR_SEPARATOR; /* overwrite null */
- }
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- else if (IS_DIR_SEPARATOR (rel_filename[0]))
- {
- /* A path starting with a directory separator is considered absolute
- for dos based filesystems, but it's really not -- it's just the
- convention used throughout GCC and it works. However, in this
- case, we still need to prepend the drive spec from cwd_buffer. */
- *endp++ = cwd2[0];
- *endp++ = cwd2[1];
- }
-#endif
- src_p = rel_filename;
- while ((*endp++ = *src_p++))
- continue;
- }
-
- /* Now make a copy of abs_buffer into abs_buffer, shortening the
- filename (by taking out slashes and dots) as we go. */
-
- outp = inp = abs_buffer;
- *outp++ = *inp++; /* copy first slash */
-#if defined (apollo) || defined (_WIN32) || defined (__INTERIX)
- if (IS_DIR_SEPARATOR (inp[0]))
- *outp++ = *inp++; /* copy second slash */
-#endif
- for (;;)
- {
- if (!inp[0])
- break;
- else if (IS_DIR_SEPARATOR (inp[0]) && IS_DIR_SEPARATOR (outp[-1]))
- {
- inp++;
- continue;
- }
- else if (inp[0] == '.' && IS_DIR_SEPARATOR (outp[-1]))
- {
- if (!inp[1])
- break;
- else if (IS_DIR_SEPARATOR (inp[1]))
- {
- inp += 2;
- continue;
- }
- else if ((inp[1] == '.') && (inp[2] == 0
- || IS_DIR_SEPARATOR (inp[2])))
- {
- inp += (IS_DIR_SEPARATOR (inp[2])) ? 3 : 2;
- outp -= 2;
- while (outp >= abs_buffer && ! IS_DIR_SEPARATOR (*outp))
- outp--;
- if (outp < abs_buffer)
- {
- /* Catch cases like /.. where we try to backup to a
- point above the absolute root of the logical file
- system. */
-
- notice ("%s: invalid file name: %s\n",
- pname, rel_filename);
- exit (FATAL_EXIT_CODE);
- }
- *++outp = '\0';
- continue;
- }
- }
- *outp++ = *inp++;
- }
-
- /* On exit, make sure that there is a trailing null, and make sure that
- the last character of the returned string is *not* a slash. */
-
- *outp = '\0';
- if (IS_DIR_SEPARATOR (outp[-1]))
- *--outp = '\0';
-
- /* Make a copy (in the heap) of the stuff left in the absolutization
- buffer and return a pointer to the copy. */
-
- return savestring (abs_buffer, outp - abs_buffer);
-}
-\f
-/* Given a filename (and possibly a directory name from which the filename
- is relative) return a string which is the shortest possible
- equivalent for the corresponding full (absolutized) filename. The
- shortest possible equivalent may be constructed by converting the
- absolutized filename to be a relative filename (i.e. relative to
- the actual current working directory). However if a relative filename
- is longer, then the full absolute filename is returned.
-
- KNOWN BUG:
-
- Note that "simple-minded" conversion of any given type of filename (either
- relative or absolute) may not result in a valid equivalent filename if any
- subpart of the original filename is actually a symbolic link. */
-
-static const char *
-shortpath (const char *cwd, const char *filename)
-{
- char *rel_buffer;
- char *rel_buf_p;
- char *cwd_p = cwd_buffer;
- char *path_p;
- int unmatched_slash_count = 0;
- size_t filename_len = strlen (filename);
-
- path_p = abspath (cwd, filename);
- rel_buf_p = rel_buffer = xmalloc (filename_len);
-
- while (*cwd_p && IS_SAME_PATH_CHAR (*cwd_p, *path_p))
- {
- cwd_p++;
- path_p++;
- }
- if (!*cwd_p && (!*path_p || IS_DIR_SEPARATOR (*path_p)))
- {
- /* whole pwd matched */
- if (!*path_p) /* input *is* the current path! */
- return ".";
- else
- return ++path_p;
- }
- else
- {
- if (*path_p)
- {
- --cwd_p;
- --path_p;
- while (! IS_DIR_SEPARATOR (*cwd_p)) /* backup to last slash */
- {
- --cwd_p;
- --path_p;
- }
- cwd_p++;
- path_p++;
- unmatched_slash_count++;
- }
-
- /* Find out how many directory levels in cwd were *not* matched. */
- while (*cwd_p++)
- if (IS_DIR_SEPARATOR (*(cwd_p-1)))
- unmatched_slash_count++;
-
- /* Now we know how long the "short name" will be.
- Reject it if longer than the input. */
- if (unmatched_slash_count * 3 + strlen (path_p) >= filename_len)
- return filename;
-
- /* For each of them, put a `../' at the beginning of the short name. */
- while (unmatched_slash_count--)
- {
- /* Give up if the result gets to be longer
- than the absolute path name. */
- if (rel_buffer + filename_len <= rel_buf_p + 3)
- return filename;
- *rel_buf_p++ = '.';
- *rel_buf_p++ = '.';
- *rel_buf_p++ = DIR_SEPARATOR;
- }
-
- /* Then tack on the unmatched part of the desired file's name. */
- do
- {
- if (rel_buffer + filename_len <= rel_buf_p)
- return filename;
- }
- while ((*rel_buf_p++ = *path_p++));
-
- --rel_buf_p;
- if (IS_DIR_SEPARATOR (*(rel_buf_p-1)))
- *--rel_buf_p = '\0';
- return rel_buffer;
- }
-}
-\f
-/* Lookup the given filename in the hash table for filenames. If it is a
- new one, then the hash table info pointer will be null. In this case,
- we create a new file_info record to go with the filename, and we initialize
- that record with some reasonable values. */
-
-/* FILENAME was const, but that causes a warning on AIX when calling stat.
- That is probably a bug in AIX, but might as well avoid the warning. */
-
-static file_info *
-find_file (const char *filename, int do_not_stat)
-{
- hash_table_entry *hash_entry_p;
-
- hash_entry_p = lookup (filename_primary, filename);
- if (hash_entry_p->fip)
- return hash_entry_p->fip;
- else
- {
- struct stat stat_buf;
- file_info *file_p = xmalloc (sizeof (file_info));
-
- /* If we cannot get status on any given source file, give a warning
- and then just set its time of last modification to infinity. */
-
- if (do_not_stat)
- stat_buf.st_mtime = (time_t) 0;
- else
- {
- if (stat (filename, &stat_buf) == -1)
- {
- int errno_val = errno;
- notice ("%s: %s: can't get status: %s\n",
- pname, shortpath (NULL, filename),
- xstrerror (errno_val));
- stat_buf.st_mtime = (time_t) -1;
- }
- }
-
- hash_entry_p->fip = file_p;
- file_p->hash_entry = hash_entry_p;
- file_p->defs_decs = NULL;
- file_p->mtime = stat_buf.st_mtime;
- return file_p;
- }
-}
-
-/* Generate a fatal error because some part of the aux_info file is
- messed up. */
-
-static void
-aux_info_corrupted (void)
-{
- notice ("\n%s: fatal error: aux info file corrupted at line %d\n",
- pname, current_aux_info_lineno);
- exit (FATAL_EXIT_CODE);
-}
-
-/* ??? This comment is vague. Say what the condition is for. */
-/* Check to see that a condition is true. This is kind of like an assert. */
-
-static void
-check_aux_info (int cond)
-{
- if (! cond)
- aux_info_corrupted ();
-}
-
-/* Given a pointer to the closing right parenthesis for a particular formals
- list (in an aux_info file) find the corresponding left parenthesis and
- return a pointer to it. */
-
-static const char *
-find_corresponding_lparen (const char *p)
-{
- const char *q;
- int paren_depth;
-
- for (paren_depth = 1, q = p-1; paren_depth; q--)
- {
- switch (*q)
- {
- case ')':
- paren_depth++;
- break;
- case '(':
- paren_depth--;
- break;
- }
- }
- return ++q;
-}
-\f
-/* Given a line from an aux info file, and a time at which the aux info
- file it came from was created, check to see if the item described in
- the line comes from a file which has been modified since the aux info
- file was created. If so, return nonzero, else return zero. */
-
-static int
-referenced_file_is_newer (const char *l, time_t aux_info_mtime)
-{
- const char *p;
- file_info *fi_p;
- char *filename;
-
- check_aux_info (l[0] == '/');
- check_aux_info (l[1] == '*');
- check_aux_info (l[2] == ' ');
-
- {
- const char *filename_start = p = l + 3;
-
- while (*p != ':'
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
-#endif
- )
- p++;
- filename = alloca ((size_t) (p - filename_start) + 1);
- strncpy (filename, filename_start, (size_t) (p - filename_start));
- filename[p-filename_start] = '\0';
- }
-
- /* Call find_file to find the file_info record associated with the file
- which contained this particular def or dec item. Note that this call
- may cause a new file_info record to be created if this is the first time
- that we have ever known about this particular file. */
-
- fi_p = find_file (abspath (invocation_filename, filename), 0);
-
- return (fi_p->mtime > aux_info_mtime);
-}
-\f
-/* Given a line of info from the aux_info file, create a new
- def_dec_info record to remember all of the important information about
- a function definition or declaration.
-
- Link this record onto the list of such records for the particular file in
- which it occurred in proper (descending) line number order (for now).
-
- If there is an identical record already on the list for the file, throw
- this one away. Doing so takes care of the (useless and troublesome)
- duplicates which are bound to crop up due to multiple inclusions of any
- given individual header file.
-
- Finally, link the new def_dec record onto the list of such records
- pertaining to this particular function name. */
-
-static void
-save_def_or_dec (const char *l, int is_syscalls)
-{
- const char *p;
- const char *semicolon_p;
- def_dec_info *def_dec_p = xmalloc (sizeof (def_dec_info));
-
-#ifndef UNPROTOIZE
- def_dec_p->written = 0;
-#endif /* !defined (UNPROTOIZE) */
-
- /* Start processing the line by picking off 5 pieces of information from
- the left hand end of the line. These are filename, line number,
- new/old/implicit flag (new = ANSI prototype format), definition or
- declaration flag, and extern/static flag). */
-
- check_aux_info (l[0] == '/');
- check_aux_info (l[1] == '*');
- check_aux_info (l[2] == ' ');
-
- {
- const char *filename_start = p = l + 3;
- char *filename;
-
- while (*p != ':'
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
-#endif
- )
- p++;
- filename = alloca ((size_t) (p - filename_start) + 1);
- strncpy (filename, filename_start, (size_t) (p - filename_start));
- filename[p-filename_start] = '\0';
-
- /* Call find_file to find the file_info record associated with the file
- which contained this particular def or dec item. Note that this call
- may cause a new file_info record to be created if this is the first time
- that we have ever known about this particular file.
-
- Note that we started out by forcing all of the base source file names
- (i.e. the names of the aux_info files with the .X stripped off) into the
- filenames hash table, and we simultaneously setup file_info records for
- all of these base file names (even if they may be useless later).
- The file_info records for all of these "base" file names (properly)
- act as file_info records for the "original" (i.e. un-included) files
- which were submitted to gcc for compilation (when the -aux-info
- option was used). */
-
- def_dec_p->file = find_file (abspath (invocation_filename, filename), is_syscalls);
- }
-
- {
- const char *line_number_start = ++p;
- char line_number[10];
-
- while (*p != ':'
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
-#endif
- )
- p++;
- strncpy (line_number, line_number_start, (size_t) (p - line_number_start));
- line_number[p-line_number_start] = '\0';
- def_dec_p->line = atoi (line_number);
- }
-
- /* Check that this record describes a new-style, old-style, or implicit
- definition or declaration. */
-
- p++; /* Skip over the `:'. */
- check_aux_info ((*p == 'N') || (*p == 'O') || (*p == 'I'));
-
- /* Is this a new style (ANSI prototyped) definition or declaration? */
-
- def_dec_p->prototyped = (*p == 'N');
-
-#ifndef UNPROTOIZE
-
- /* Is this an implicit declaration? */
-
- def_dec_p->is_implicit = (*p == 'I');
-
-#endif /* !defined (UNPROTOIZE) */
-
- p++;
-
- check_aux_info ((*p == 'C') || (*p == 'F'));
-
- /* Is this item a function definition (F) or a declaration (C). Note that
- we treat item taken from the syscalls file as though they were function
- definitions regardless of what the stuff in the file says. */
-
- def_dec_p->is_func_def = ((*p++ == 'F') || is_syscalls);
-
-#ifndef UNPROTOIZE
- def_dec_p->definition = 0; /* Fill this in later if protoizing. */
-#endif /* !defined (UNPROTOIZE) */
-
- check_aux_info (*p++ == ' ');
- check_aux_info (*p++ == '*');
- check_aux_info (*p++ == '/');
- check_aux_info (*p++ == ' ');
-
-#ifdef UNPROTOIZE
- check_aux_info ((!strncmp (p, "static", 6)) || (!strncmp (p, "extern", 6)));
-#else /* !defined (UNPROTOIZE) */
- if (!strncmp (p, "static", 6))
- def_dec_p->is_static = -1;
- else if (!strncmp (p, "extern", 6))
- def_dec_p->is_static = 0;
- else
- check_aux_info (0); /* Didn't find either `extern' or `static'. */
-#endif /* !defined (UNPROTOIZE) */
-
- {
- const char *ansi_start = p;
-
- p += 6; /* Pass over the "static" or "extern". */
-
- /* We are now past the initial stuff. Search forward from here to find
- the terminating semicolon that should immediately follow the entire
- ANSI format function declaration. */
-
- while (*++p != ';')
- continue;
-
- semicolon_p = p;
-
- /* Make a copy of the ansi declaration part of the line from the aux_info
- file. */
-
- def_dec_p->ansi_decl
- = dupnstr (ansi_start, (size_t) ((semicolon_p+1) - ansi_start));
-
- /* Backup and point at the final right paren of the final argument list. */
-
- p--;
-
-#ifndef UNPROTOIZE
- def_dec_p->f_list_chain = NULL;
-#endif /* !defined (UNPROTOIZE) */
-
- while (p != ansi_start && (p[-1] == ' ' || p[-1] == '\t')) p--;
- if (*p != ')')
- {
- free_def_dec (def_dec_p);
- return;
- }
- }
-
- /* Now isolate a whole set of formal argument lists, one-by-one. Normally,
- there will only be one list to isolate, but there could be more. */
-
- def_dec_p->f_list_count = 0;
-
- for (;;)
- {
- const char *left_paren_p = find_corresponding_lparen (p);
-#ifndef UNPROTOIZE
- {
- f_list_chain_item *cip = xmalloc (sizeof (f_list_chain_item));
-
- cip->formals_list
- = dupnstr (left_paren_p + 1, (size_t) (p - (left_paren_p+1)));
-
- /* Add the new chain item at the head of the current list. */
-
- cip->chain_next = def_dec_p->f_list_chain;
- def_dec_p->f_list_chain = cip;
- }
-#endif /* !defined (UNPROTOIZE) */
- def_dec_p->f_list_count++;
-
- p = left_paren_p - 2;
-
- /* p must now point either to another right paren, or to the last
- character of the name of the function that was declared/defined.
- If p points to another right paren, then this indicates that we
- are dealing with multiple formals lists. In that case, there
- really should be another right paren preceding this right paren. */
-
- if (*p != ')')
- break;
- else
- check_aux_info (*--p == ')');
- }
-
-
- {
- const char *past_fn = p + 1;
-
- check_aux_info (*past_fn == ' ');
-
- /* Scan leftwards over the identifier that names the function. */
-
- while (is_id_char (*p))
- p--;
- p++;
-
- /* p now points to the leftmost character of the function name. */
-
- {
- char *fn_string = alloca (past_fn - p + 1);
-
- strncpy (fn_string, p, (size_t) (past_fn - p));
- fn_string[past_fn-p] = '\0';
- def_dec_p->hash_entry = lookup (function_name_primary, fn_string);
- }
- }
-
- /* Look at all of the defs and decs for this function name that we have
- collected so far. If there is already one which is at the same
- line number in the same file, then we can discard this new def_dec_info
- record.
-
- As an extra assurance that any such pair of (nominally) identical
- function declarations are in fact identical, we also compare the
- ansi_decl parts of the lines from the aux_info files just to be on
- the safe side.
-
- This comparison will fail if (for instance) the user was playing
- messy games with the preprocessor which ultimately causes one
- function declaration in one header file to look differently when
- that file is included by two (or more) other files. */
-
- {
- const def_dec_info *other;
-
- for (other = def_dec_p->hash_entry->ddip; other; other = other->next_for_func)
- {
- if (def_dec_p->line == other->line && def_dec_p->file == other->file)
- {
- if (strcmp (def_dec_p->ansi_decl, other->ansi_decl))
- {
- notice ("%s:%d: declaration of function '%s' takes different forms\n",
- def_dec_p->file->hash_entry->symbol,
- def_dec_p->line,
- def_dec_p->hash_entry->symbol);
- exit (FATAL_EXIT_CODE);
- }
- free_def_dec (def_dec_p);
- return;
- }
- }
- }
-
-#ifdef UNPROTOIZE
-
- /* If we are doing unprotoizing, we must now setup the pointers that will
- point to the K&R name list and to the K&R argument declarations list.
-
- Note that if this is only a function declaration, then we should not
- expect to find any K&R style formals list following the ANSI-style
- formals list. This is because GCC knows that such information is
- useless in the case of function declarations (function definitions
- are a different story however).
-
- Since we are unprotoizing, we don't need any such lists anyway.
- All we plan to do is to delete all characters between ()'s in any
- case. */
-
- def_dec_p->formal_names = NULL;
- def_dec_p->formal_decls = NULL;
-
- if (def_dec_p->is_func_def)
- {
- p = semicolon_p;
- check_aux_info (*++p == ' ');
- check_aux_info (*++p == '/');
- check_aux_info (*++p == '*');
- check_aux_info (*++p == ' ');
- check_aux_info (*++p == '(');
-
- {
- const char *kr_names_start = ++p; /* Point just inside '('. */
-
- while (*p++ != ')')
- continue;
- p--; /* point to closing right paren */
-
- /* Make a copy of the K&R parameter names list. */
-
- def_dec_p->formal_names
- = dupnstr (kr_names_start, (size_t) (p - kr_names_start));
- }
-
- check_aux_info (*++p == ' ');
- p++;
-
- /* p now points to the first character of the K&R style declarations
- list (if there is one) or to the star-slash combination that ends
- the comment in which such lists get embedded. */
-
- /* Make a copy of the K&R formal decls list and set the def_dec record
- to point to it. */
-
- if (*p == '*') /* Are there no K&R declarations? */
- {
- check_aux_info (*++p == '/');
- def_dec_p->formal_decls = "";
- }
- else
- {
- const char *kr_decls_start = p;
-
- while (p[0] != '*' || p[1] != '/')
- p++;
- p--;
-
- check_aux_info (*p == ' ');
-
- def_dec_p->formal_decls
- = dupnstr (kr_decls_start, (size_t) (p - kr_decls_start));
- }
-
- /* Handle a special case. If we have a function definition marked as
- being in "old" style, and if its formal names list is empty, then
- it may actually have the string "void" in its real formals list
- in the original source code. Just to make sure, we will get setup
- to convert such things anyway.
-
- This kludge only needs to be here because of an insurmountable
- problem with generating .X files. */
-
- if (!def_dec_p->prototyped && !*def_dec_p->formal_names)
- def_dec_p->prototyped = 1;
- }
-
- /* Since we are unprotoizing, if this item is already in old (K&R) style,
- we can just ignore it. If that is true, throw away the item now. */
-
- if (!def_dec_p->prototyped)
- {
- free_def_dec (def_dec_p);
- return;
- }
-
-#endif /* defined (UNPROTOIZE) */
-
- /* Add this record to the head of the list of records pertaining to this
- particular function name. */
-
- def_dec_p->next_for_func = def_dec_p->hash_entry->ddip;
- def_dec_p->hash_entry->ddip = def_dec_p;
-
- /* Add this new def_dec_info record to the sorted list of def_dec_info
- records for this file. Note that we don't have to worry about duplicates
- (caused by multiple inclusions of header files) here because we have
- already eliminated duplicates above. */
-
- if (!def_dec_p->file->defs_decs)
- {
- def_dec_p->file->defs_decs = def_dec_p;
- def_dec_p->next_in_file = NULL;
- }
- else
- {
- int line = def_dec_p->line;
- const def_dec_info *prev = NULL;
- const def_dec_info *curr = def_dec_p->file->defs_decs;
- const def_dec_info *next = curr->next_in_file;
-
- while (next && (line < curr->line))
- {
- prev = curr;
- curr = next;
- next = next->next_in_file;
- }
- if (line >= curr->line)
- {
- def_dec_p->next_in_file = curr;
- if (prev)
- ((NONCONST def_dec_info *) prev)->next_in_file = def_dec_p;
- else
- def_dec_p->file->defs_decs = def_dec_p;
- }
- else /* assert (next == NULL); */
- {
- ((NONCONST def_dec_info *) curr)->next_in_file = def_dec_p;
- /* assert (next == NULL); */
- def_dec_p->next_in_file = next;
- }
- }
-}
-\f
-/* Set up the vector COMPILE_PARAMS which is the argument list for running GCC.
- Also set input_file_name_index and aux_info_file_name_index
- to the indices of the slots where the file names should go. */
-
-/* We initialize the vector by removing -g, -O, -S, -c, and -o options,
- and adding '-aux-info AUXFILE -S -o /dev/null INFILE' at the end. */
-
-static void
-munge_compile_params (const char *params_list)
-{
- /* Build up the contents in a temporary vector
- that is so big that to has to be big enough. */
- const char **temp_params
- = alloca ((strlen (params_list) + 8) * sizeof (char *));
- int param_count = 0;
- const char *param;
- struct stat st;
-
- temp_params[param_count++] = compiler_file_name;
- for (;;)
- {
- while (ISSPACE ((const unsigned char)*params_list))
- params_list++;
- if (!*params_list)
- break;
- param = params_list;
- while (*params_list && !ISSPACE ((const unsigned char)*params_list))
- params_list++;
- if (param[0] != '-')
- temp_params[param_count++]
- = dupnstr (param, (size_t) (params_list - param));
- else
- {
- switch (param[1])
- {
- case 'g':
- case 'O':
- case 'S':
- case 'c':
- break; /* Don't copy these. */
- case 'o':
- while (ISSPACE ((const unsigned char)*params_list))
- params_list++;
- while (*params_list
- && !ISSPACE ((const unsigned char)*params_list))
- params_list++;
- break;
- default:
- temp_params[param_count++]
- = dupnstr (param, (size_t) (params_list - param));
- }
- }
- if (!*params_list)
- break;
- }
- temp_params[param_count++] = "-aux-info";
-
- /* Leave room for the aux-info file name argument. */
- aux_info_file_name_index = param_count;
- temp_params[param_count++] = NULL;
-
- temp_params[param_count++] = "-S";
- temp_params[param_count++] = "-o";
-
- if ((stat (HOST_BIT_BUCKET, &st) == 0)
- && (!S_ISDIR (st.st_mode))
- && (access (HOST_BIT_BUCKET, W_OK) == 0))
- temp_params[param_count++] = HOST_BIT_BUCKET;
- else
- /* FIXME: This is hardly likely to be right, if HOST_BIT_BUCKET is not
- writable. But until this is rejigged to use make_temp_file(), this
- is the best we can do. */
- temp_params[param_count++] = "/dev/null";
-
- /* Leave room for the input file name argument. */
- input_file_name_index = param_count;
- temp_params[param_count++] = NULL;
- /* Terminate the list. */
- temp_params[param_count++] = NULL;
-
- /* Make a copy of the compile_params in heap space. */
-
- compile_params = xmalloc (sizeof (char *) * (param_count+1));
- memcpy (compile_params, temp_params, sizeof (char *) * param_count);
-}
-
-/* Do a recompilation for the express purpose of generating a new aux_info
- file to go with a specific base source file.
-
- The result is a boolean indicating success. */
-
-static int
-gen_aux_info_file (const char *base_filename)
-{
- if (!input_file_name_index)
- munge_compile_params ("");
-
- /* Store the full source file name in the argument vector. */
- compile_params[input_file_name_index] = shortpath (NULL, base_filename);
- /* Add .X to source file name to get aux-info file name. */
- compile_params[aux_info_file_name_index] =
- concat (compile_params[input_file_name_index], aux_info_suffix, NULL);
-
- if (!quiet_flag)
- notice ("%s: compiling '%s'\n",
- pname, compile_params[input_file_name_index]);
-
- {
- char *errmsg_fmt, *errmsg_arg;
- int wait_status, pid;
-
- pid = pexecute (compile_params[0], (char * const *) compile_params,
- pname, NULL, &errmsg_fmt, &errmsg_arg,
- PEXECUTE_FIRST | PEXECUTE_LAST | PEXECUTE_SEARCH);
-
- if (pid == -1)
- {
- int errno_val = errno;
- fprintf (stderr, "%s: ", pname);
- fprintf (stderr, errmsg_fmt, errmsg_arg);
- fprintf (stderr, ": %s\n", xstrerror (errno_val));
- return 0;
- }
-
- pid = pwait (pid, &wait_status, 0);
- if (pid == -1)
- {
- notice ("%s: wait: %s\n", pname, xstrerror (errno));
- return 0;
- }
- if (WIFSIGNALED (wait_status))
- {
- notice ("%s: subprocess got fatal signal %d\n",
- pname, WTERMSIG (wait_status));
- return 0;
- }
- if (WIFEXITED (wait_status))
- {
- if (WEXITSTATUS (wait_status) != 0)
- {
- notice ("%s: %s exited with status %d\n",
- pname, compile_params[0], WEXITSTATUS (wait_status));
- return 0;
- }
- return 1;
- }
- gcc_unreachable ();
- }
-}
-\f
-/* Read in all of the information contained in a single aux_info file.
- Save all of the important stuff for later. */
-
-static void
-process_aux_info_file (const char *base_source_filename, int keep_it,
- int is_syscalls)
-{
- size_t base_len = strlen (base_source_filename);
- char * aux_info_filename = alloca (base_len + strlen (aux_info_suffix) + 1);
- char *aux_info_base;
- char *aux_info_limit;
- char *aux_info_relocated_name;
- const char *aux_info_second_line;
- time_t aux_info_mtime;
- size_t aux_info_size;
- int must_create;
-
- /* Construct the aux_info filename from the base source filename. */
-
- strcpy (aux_info_filename, base_source_filename);
- strcat (aux_info_filename, aux_info_suffix);
-
- /* Check that the aux_info file exists and is readable. If it does not
- exist, try to create it (once only). */
-
- /* If file doesn't exist, set must_create.
- Likewise if it exists and we can read it but it is obsolete.
- Otherwise, report an error. */
- must_create = 0;
-
- /* Come here with must_create set to 1 if file is out of date. */
-start_over: ;
-
- if (access (aux_info_filename, R_OK) == -1)
- {
- if (errno == ENOENT)
- {
- if (is_syscalls)
- {
- notice ("%s: warning: missing SYSCALLS file '%s'\n",
- pname, aux_info_filename);
- return;
- }
- must_create = 1;
- }
- else
- {
- int errno_val = errno;
- notice ("%s: can't read aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- errors++;
- return;
- }
- }
-#if 0 /* There is code farther down to take care of this. */
- else
- {
- struct stat s1, s2;
- stat (aux_info_file_name, &s1);
- stat (base_source_file_name, &s2);
- if (s2.st_mtime > s1.st_mtime)
- must_create = 1;
- }
-#endif /* 0 */
-
- /* If we need a .X file, create it, and verify we can read it. */
- if (must_create)
- {
- if (!gen_aux_info_file (base_source_filename))
- {
- errors++;
- return;
- }
- if (access (aux_info_filename, R_OK) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't read aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- errors++;
- return;
- }
- }
-
- {
- struct stat stat_buf;
-
- /* Get some status information about this aux_info file. */
-
- if (stat (aux_info_filename, &stat_buf) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't get status of aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- errors++;
- return;
- }
-
- /* Check on whether or not this aux_info file is zero length. If it is,
- then just ignore it and return. */
-
- if ((aux_info_size = stat_buf.st_size) == 0)
- return;
-
- /* Get the date/time of last modification for this aux_info file and
- remember it. We will have to check that any source files that it
- contains information about are at least this old or older. */
-
- aux_info_mtime = stat_buf.st_mtime;
-
- if (!is_syscalls)
- {
- /* Compare mod time with the .c file; update .X file if obsolete.
- The code later on can fail to check the .c file
- if it did not directly define any functions. */
-
- if (stat (base_source_filename, &stat_buf) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't get status of aux info file '%s': %s\n",
- pname, shortpath (NULL, base_source_filename),
- xstrerror (errno_val));
- errors++;
- return;
- }
- if (stat_buf.st_mtime > aux_info_mtime)
- {
- must_create = 1;
- goto start_over;
- }
- }
- }
-
- {
- int aux_info_file;
- int fd_flags;
-
- /* Open the aux_info file. */
-
- fd_flags = O_RDONLY;
-#ifdef O_BINARY
- /* Use binary mode to avoid having to deal with different EOL characters. */
- fd_flags |= O_BINARY;
-#endif
- if ((aux_info_file = open (aux_info_filename, fd_flags, 0444 )) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't open aux info file '%s' for reading: %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- return;
- }
-
- /* Allocate space to hold the aux_info file in memory. */
-
- aux_info_base = xmalloc (aux_info_size + 1);
- aux_info_limit = aux_info_base + aux_info_size;
- *aux_info_limit = '\0';
-
- /* Read the aux_info file into memory. */
-
- if (safe_read (aux_info_file, aux_info_base, aux_info_size) !=
- (int) aux_info_size)
- {
- int errno_val = errno;
- notice ("%s: error reading aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- free (aux_info_base);
- close (aux_info_file);
- return;
- }
-
- /* Close the aux info file. */
-
- if (close (aux_info_file))
- {
- int errno_val = errno;
- notice ("%s: error closing aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- free (aux_info_base);
- close (aux_info_file);
- return;
- }
- }
-
- /* Delete the aux_info file (unless requested not to). If the deletion
- fails for some reason, don't even worry about it. */
-
- if (must_create && !keep_it)
- if (unlink (aux_info_filename) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't delete aux info file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- }
-
- /* Save a pointer into the first line of the aux_info file which
- contains the filename of the directory from which the compiler
- was invoked when the associated source file was compiled.
- This information is used later to help create complete
- filenames out of the (potentially) relative filenames in
- the aux_info file. */
-
- {
- char *p = aux_info_base;
-
- while (*p != ':'
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
-#endif
- )
- p++;
- p++;
- while (*p == ' ')
- p++;
- invocation_filename = p; /* Save a pointer to first byte of path. */
- while (*p != ' ')
- p++;
- *p++ = DIR_SEPARATOR;
- *p++ = '\0';
- while (*p++ != '\n')
- continue;
- aux_info_second_line = p;
- aux_info_relocated_name = 0;
- if (! IS_ABSOLUTE_PATH (invocation_filename))
- {
- /* INVOCATION_FILENAME is relative;
- append it to BASE_SOURCE_FILENAME's dir. */
- char *dir_end;
- aux_info_relocated_name = xmalloc (base_len + (p-invocation_filename));
- strcpy (aux_info_relocated_name, base_source_filename);
- dir_end = strrchr (aux_info_relocated_name, DIR_SEPARATOR);
-#ifdef DIR_SEPARATOR_2
- {
- char *slash;
-
- slash = strrchr (dir_end ? dir_end : aux_info_relocated_name,
- DIR_SEPARATOR_2);
- if (slash)
- dir_end = slash;
- }
-#endif
- if (dir_end)
- dir_end++;
- else
- dir_end = aux_info_relocated_name;
- strcpy (dir_end, invocation_filename);
- invocation_filename = aux_info_relocated_name;
- }
- }
-
-
- {
- const char *aux_info_p;
-
- /* Do a pre-pass on the lines in the aux_info file, making sure that all
- of the source files referenced in there are at least as old as this
- aux_info file itself. If not, go back and regenerate the aux_info
- file anew. Don't do any of this for the syscalls file. */
-
- if (!is_syscalls)
- {
- current_aux_info_lineno = 2;
-
- for (aux_info_p = aux_info_second_line; *aux_info_p; )
- {
- if (referenced_file_is_newer (aux_info_p, aux_info_mtime))
- {
- free (aux_info_base);
- free (aux_info_relocated_name);
- if (keep_it && unlink (aux_info_filename) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't delete file '%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- xstrerror (errno_val));
- return;
- }
- must_create = 1;
- goto start_over;
- }
-
- /* Skip over the rest of this line to start of next line. */
-
- while (*aux_info_p != '\n')
- aux_info_p++;
- aux_info_p++;
- current_aux_info_lineno++;
- }
- }
-
- /* Now do the real pass on the aux_info lines. Save their information in
- the in-core data base. */
-
- current_aux_info_lineno = 2;
-
- for (aux_info_p = aux_info_second_line; *aux_info_p;)
- {
- char *unexpanded_line = unexpand_if_needed (aux_info_p);
-
- if (unexpanded_line)
- {
- save_def_or_dec (unexpanded_line, is_syscalls);
- free (unexpanded_line);
- }
- else
- save_def_or_dec (aux_info_p, is_syscalls);
-
- /* Skip over the rest of this line and get to start of next line. */
-
- while (*aux_info_p != '\n')
- aux_info_p++;
- aux_info_p++;
- current_aux_info_lineno++;
- }
- }
-
- free (aux_info_base);
- free (aux_info_relocated_name);
-}
-\f
-#ifndef UNPROTOIZE
-
-/* Check an individual filename for a .c suffix. If the filename has this
- suffix, rename the file such that its suffix is changed to .C. This
- function implements the -C option. */
-
-static void
-rename_c_file (const hash_table_entry *hp)
-{
- const char *filename = hp->symbol;
- int last_char_index = strlen (filename) - 1;
- char *const new_filename = alloca (strlen (filename)
- + strlen (cplus_suffix) + 1);
-
- /* Note that we don't care here if the given file was converted or not. It
- is possible that the given file was *not* converted, simply because there
- was nothing in it which actually required conversion. Even in this case,
- we want to do the renaming. Note that we only rename files with the .c
- suffix (except for the syscalls file, which is left alone). */
-
- if (filename[last_char_index] != 'c' || filename[last_char_index-1] != '.'
- || IS_SAME_PATH (syscalls_absolute_filename, filename))
- return;
-
- strcpy (new_filename, filename);
- strcpy (&new_filename[last_char_index], cplus_suffix);
-
- if (rename (filename, new_filename) == -1)
- {
- int errno_val = errno;
- notice ("%s: warning: can't rename file '%s' to '%s': %s\n",
- pname, shortpath (NULL, filename),
- shortpath (NULL, new_filename), xstrerror (errno_val));
- errors++;
- return;
- }
-}
-
-#endif /* !defined (UNPROTOIZE) */
-\f
-/* Take the list of definitions and declarations attached to a particular
- file_info node and reverse the order of the list. This should get the
- list into an order such that the item with the lowest associated line
- number is nearest the head of the list. When these lists are originally
- built, they are in the opposite order. We want to traverse them in
- normal line number order later (i.e. lowest to highest) so reverse the
- order here. */
-
-static void
-reverse_def_dec_list (const hash_table_entry *hp)
-{
- file_info *file_p = hp->fip;
- def_dec_info *prev = NULL;
- def_dec_info *current = (def_dec_info *) file_p->defs_decs;
-
- if (!current)
- return; /* no list to reverse */
-
- prev = current;
- if (! (current = (def_dec_info *) current->next_in_file))
- return; /* can't reverse a single list element */
-
- prev->next_in_file = NULL;
-
- while (current)
- {
- def_dec_info *next = (def_dec_info *) current->next_in_file;
-
- current->next_in_file = prev;
- prev = current;
- current = next;
- }
-
- file_p->defs_decs = prev;
-}
-
-#ifndef UNPROTOIZE
-
-/* Find the (only?) extern definition for a particular function name, starting
- from the head of the linked list of entries for the given name. If we
- cannot find an extern definition for the given function name, issue a
- warning and scrounge around for the next best thing, i.e. an extern
- function declaration with a prototype attached to it. Note that we only
- allow such substitutions for extern declarations and never for static
- declarations. That's because the only reason we allow them at all is
- to let un-prototyped function declarations for system-supplied library
- functions get their prototypes from our own extra SYSCALLS.c.X file which
- contains all of the correct prototypes for system functions. */
-
-static const def_dec_info *
-find_extern_def (const def_dec_info *head, const def_dec_info *user)
-{
- const def_dec_info *dd_p;
- const def_dec_info *extern_def_p = NULL;
- int conflict_noted = 0;
-
- /* Don't act too stupid here. Somebody may try to convert an entire system
- in one swell fwoop (rather than one program at a time, as should be done)
- and in that case, we may find that there are multiple extern definitions
- of a given function name in the entire set of source files that we are
- converting. If however one of these definitions resides in exactly the
- same source file as the reference we are trying to satisfy then in that
- case it would be stupid for us to fail to realize that this one definition
- *must* be the precise one we are looking for.
-
- To make sure that we don't miss an opportunity to make this "same file"
- leap of faith, we do a prescan of the list of records relating to the
- given function name, and we look (on this first scan) *only* for a
- definition of the function which is in the same file as the reference
- we are currently trying to satisfy. */
-
- for (dd_p = head; dd_p; dd_p = dd_p->next_for_func)
- if (dd_p->is_func_def && !dd_p->is_static && dd_p->file == user->file)
- return dd_p;
-
- /* Now, since we have not found a definition in the same file as the
- reference, we scan the list again and consider all possibilities from
- all files. Here we may get conflicts with the things listed in the
- SYSCALLS.c.X file, but if that happens it only means that the source
- code being converted contains its own definition of a function which
- could have been supplied by libc.a. In such cases, we should avoid
- issuing the normal warning, and defer to the definition given in the
- user's own code. */
-
- for (dd_p = head; dd_p; dd_p = dd_p->next_for_func)
- if (dd_p->is_func_def && !dd_p->is_static)
- {
- if (!extern_def_p) /* Previous definition? */
- extern_def_p = dd_p; /* Remember the first definition found. */
- else
- {
- /* Ignore definition just found if it came from SYSCALLS.c.X. */
-
- if (is_syscalls_file (dd_p->file))
- continue;
-
- /* Quietly replace the definition previously found with the one
- just found if the previous one was from SYSCALLS.c.X. */
-
- if (is_syscalls_file (extern_def_p->file))
- {
- extern_def_p = dd_p;
- continue;
- }
-
- /* If we get here, then there is a conflict between two function
- declarations for the same function, both of which came from the
- user's own code. */
-
- if (!conflict_noted) /* first time we noticed? */
- {
- conflict_noted = 1;
- notice ("%s: conflicting extern definitions of '%s'\n",
- pname, head->hash_entry->symbol);
- if (!quiet_flag)
- {
- notice ("%s: declarations of '%s' will not be converted\n",
- pname, head->hash_entry->symbol);
- notice ("%s: conflict list for '%s' follows:\n",
- pname, head->hash_entry->symbol);
- fprintf (stderr, "%s: %s(%d): %s\n",
- pname,
- shortpath (NULL, extern_def_p->file->hash_entry->symbol),
- extern_def_p->line, extern_def_p->ansi_decl);
- }
- }
- if (!quiet_flag)
- fprintf (stderr, "%s: %s(%d): %s\n",
- pname,
- shortpath (NULL, dd_p->file->hash_entry->symbol),
- dd_p->line, dd_p->ansi_decl);
- }
- }
-
- /* We want to err on the side of caution, so if we found multiple conflicting
- definitions for the same function, treat this as being that same as if we
- had found no definitions (i.e. return NULL). */
-
- if (conflict_noted)
- return NULL;
-
- if (!extern_def_p)
- {
- /* We have no definitions for this function so do the next best thing.
- Search for an extern declaration already in prototype form. */
-
- for (dd_p = head; dd_p; dd_p = dd_p->next_for_func)
- if (!dd_p->is_func_def && !dd_p->is_static && dd_p->prototyped)
- {
- extern_def_p = dd_p; /* save a pointer to the definition */
- if (!quiet_flag)
- notice ("%s: warning: using formals list from %s(%d) for function '%s'\n",
- pname,
- shortpath (NULL, dd_p->file->hash_entry->symbol),
- dd_p->line, dd_p->hash_entry->symbol);
- break;
- }
-
- /* Gripe about unprototyped function declarations that we found no
- corresponding definition (or other source of prototype information)
- for.
-
- Gripe even if the unprototyped declaration we are worried about
- exists in a file in one of the "system" include directories. We
- can gripe about these because we should have at least found a
- corresponding (pseudo) definition in the SYSCALLS.c.X file. If we
- didn't, then that means that the SYSCALLS.c.X file is missing some
- needed prototypes for this particular system. That is worth telling
- the user about! */
-
- if (!extern_def_p)
- {
- const char *file = user->file->hash_entry->symbol;
-
- if (!quiet_flag)
- if (in_system_include_dir (file))
- {
- /* Why copy this string into `needed' at all?
- Why not just use user->ansi_decl without copying? */
- char *needed = alloca (strlen (user->ansi_decl) + 1);
- char *p;
-
- strcpy (needed, user->ansi_decl);
- p = strstr (needed, user->hash_entry->symbol)
- + strlen (user->hash_entry->symbol) + 2;
- /* Avoid having ??? in the string. */
- *p++ = '?';
- *p++ = '?';
- *p++ = '?';
- strcpy (p, ");");
-
- notice ("%s: %d: '%s' used but missing from SYSCALLS\n",
- shortpath (NULL, file), user->line,
- needed+7); /* Don't print "extern " */
- }
-#if 0
- else
- notice ("%s: %d: warning: no extern definition for '%s'\n",
- shortpath (NULL, file), user->line,
- user->hash_entry->symbol);
-#endif
- }
- }
- return extern_def_p;
-}
-\f
-/* Find the (only?) static definition for a particular function name in a
- given file. Here we get the function-name and the file info indirectly
- from the def_dec_info record pointer which is passed in. */
-
-static const def_dec_info *
-find_static_definition (const def_dec_info *user)
-{
- const def_dec_info *head = user->hash_entry->ddip;
- const def_dec_info *dd_p;
- int num_static_defs = 0;
- const def_dec_info *static_def_p = NULL;
-
- for (dd_p = head; dd_p; dd_p = dd_p->next_for_func)
- if (dd_p->is_func_def && dd_p->is_static && (dd_p->file == user->file))
- {
- static_def_p = dd_p; /* save a pointer to the definition */
- num_static_defs++;
- }
- if (num_static_defs == 0)
- {
- if (!quiet_flag)
- notice ("%s: warning: no static definition for '%s' in file '%s'\n",
- pname, head->hash_entry->symbol,
- shortpath (NULL, user->file->hash_entry->symbol));
- }
- else if (num_static_defs > 1)
- {
- notice ("%s: multiple static defs of '%s' in file '%s'\n",
- pname, head->hash_entry->symbol,
- shortpath (NULL, user->file->hash_entry->symbol));
- return NULL;
- }
- return static_def_p;
-}
-
-/* Find good prototype style formal argument lists for all of the function
- declarations which didn't have them before now.
-
- To do this we consider each function name one at a time. For each function
- name, we look at the items on the linked list of def_dec_info records for
- that particular name.
-
- Somewhere on this list we should find one (and only one) def_dec_info
- record which represents the actual function definition, and this record
- should have a nice formal argument list already associated with it.
-
- Thus, all we have to do is to connect up all of the other def_dec_info
- records for this particular function name to the special one which has
- the full-blown formals list.
-
- Of course it is a little more complicated than just that. See below for
- more details. */
-
-static void
-connect_defs_and_decs (const hash_table_entry *hp)
-{
- const def_dec_info *dd_p;
- const def_dec_info *extern_def_p = NULL;
- int first_extern_reference = 1;
-
- /* Traverse the list of definitions and declarations for this particular
- function name. For each item on the list, if it is a function
- definition (either old style or new style) then GCC has already been
- kind enough to produce a prototype for us, and it is associated with
- the item already, so declare the item as its own associated "definition".
-
- Also, for each item which is only a function declaration, but which
- nonetheless has its own prototype already (obviously supplied by the user)
- declare the item as its own definition.
-
- Note that when/if there are multiple user-supplied prototypes already
- present for multiple declarations of any given function, these multiple
- prototypes *should* all match exactly with one another and with the
- prototype for the actual function definition. We don't check for this
- here however, since we assume that the compiler must have already done
- this consistency checking when it was creating the .X files. */
-
- for (dd_p = hp->ddip; dd_p; dd_p = dd_p->next_for_func)
- if (dd_p->prototyped)
- ((NONCONST def_dec_info *) dd_p)->definition = dd_p;
-
- /* Traverse the list of definitions and declarations for this particular
- function name. For each item on the list, if it is an extern function
- declaration and if it has no associated definition yet, go try to find
- the matching extern definition for the declaration.
-
- When looking for the matching function definition, warn the user if we
- fail to find one.
-
- If we find more that one function definition also issue a warning.
-
- Do the search for the matching definition only once per unique function
- name (and only when absolutely needed) so that we can avoid putting out
- redundant warning messages, and so that we will only put out warning
- messages when there is actually a reference (i.e. a declaration) for
- which we need to find a matching definition. */
-
- for (dd_p = hp->ddip; dd_p; dd_p = dd_p->next_for_func)
- if (!dd_p->is_func_def && !dd_p->is_static && !dd_p->definition)
- {
- if (first_extern_reference)
- {
- extern_def_p = find_extern_def (hp->ddip, dd_p);
- first_extern_reference = 0;
- }
- ((NONCONST def_dec_info *) dd_p)->definition = extern_def_p;
- }
-
- /* Traverse the list of definitions and declarations for this particular
- function name. For each item on the list, if it is a static function
- declaration and if it has no associated definition yet, go try to find
- the matching static definition for the declaration within the same file.
-
- When looking for the matching function definition, warn the user if we
- fail to find one in the same file with the declaration, and refuse to
- convert this kind of cross-file static function declaration. After all,
- this is stupid practice and should be discouraged.
-
- We don't have to worry about the possibility that there is more than one
- matching function definition in the given file because that would have
- been flagged as an error by the compiler.
-
- Do the search for the matching definition only once per unique
- function-name/source-file pair (and only when absolutely needed) so that
- we can avoid putting out redundant warning messages, and so that we will
- only put out warning messages when there is actually a reference (i.e. a
- declaration) for which we actually need to find a matching definition. */
-
- for (dd_p = hp->ddip; dd_p; dd_p = dd_p->next_for_func)
- if (!dd_p->is_func_def && dd_p->is_static && !dd_p->definition)
- {
- const def_dec_info *dd_p2;
- const def_dec_info *static_def;
-
- /* We have now found a single static declaration for which we need to
- find a matching definition. We want to minimize the work (and the
- number of warnings), so we will find an appropriate (matching)
- static definition for this declaration, and then distribute it
- (as the definition for) any and all other static declarations
- for this function name which occur within the same file, and which
- do not already have definitions.
-
- Note that a trick is used here to prevent subsequent attempts to
- call find_static_definition for a given function-name & file
- if the first such call returns NULL. Essentially, we convert
- these NULL return values to -1, and put the -1 into the definition
- field for each other static declaration from the same file which
- does not already have an associated definition.
- This makes these other static declarations look like they are
- actually defined already when the outer loop here revisits them
- later on. Thus, the outer loop will skip over them. Later, we
- turn the -1's back to NULL's. */
-
- ((NONCONST def_dec_info *) dd_p)->definition =
- (static_def = find_static_definition (dd_p))
- ? static_def
- : (const def_dec_info *) -1;
-
- for (dd_p2 = dd_p->next_for_func; dd_p2; dd_p2 = dd_p2->next_for_func)
- if (!dd_p2->is_func_def && dd_p2->is_static
- && !dd_p2->definition && (dd_p2->file == dd_p->file))
- ((NONCONST def_dec_info *) dd_p2)->definition = dd_p->definition;
- }
-
- /* Convert any dummy (-1) definitions we created in the step above back to
- NULL's (as they should be). */
-
- for (dd_p = hp->ddip; dd_p; dd_p = dd_p->next_for_func)
- if (dd_p->definition == (def_dec_info *) -1)
- ((NONCONST def_dec_info *) dd_p)->definition = NULL;
-}
-
-#endif /* !defined (UNPROTOIZE) */
-
-/* Give a pointer into the clean text buffer, return a number which is the
- original source line number that the given pointer points into. */
-
-static int
-identify_lineno (const char *clean_p)
-{
- int line_num = 1;
- const char *scan_p;
-
- for (scan_p = clean_text_base; scan_p <= clean_p; scan_p++)
- if (*scan_p == '\n')
- line_num++;
- return line_num;
-}
-
-/* Issue an error message and give up on doing this particular edit. */
-
-static void
-declare_source_confusing (const char *clean_p)
-{
- if (!quiet_flag)
- {
- if (clean_p == 0)
- notice ("%s: %d: warning: source too confusing\n",
- shortpath (NULL, convert_filename), last_known_line_number);
- else
- notice ("%s: %d: warning: source too confusing\n",
- shortpath (NULL, convert_filename),
- identify_lineno (clean_p));
- }
- longjmp (source_confusion_recovery, 1);
-}
-
-/* Check that a condition which is expected to be true in the original source
- code is in fact true. If not, issue an error message and give up on
- converting this particular source file. */
-
-static void
-check_source (int cond, const char *clean_p)
-{
- if (!cond)
- declare_source_confusing (clean_p);
-}
-
-/* If we think of the in-core cleaned text buffer as a memory mapped
- file (with the variable last_known_line_start acting as sort of a
- file pointer) then we can imagine doing "seeks" on the buffer. The
- following routine implements a kind of "seek" operation for the in-core
- (cleaned) copy of the source file. When finished, it returns a pointer to
- the start of a given (numbered) line in the cleaned text buffer.
-
- Note that protoize only has to "seek" in the forward direction on the
- in-core cleaned text file buffers, and it never needs to back up.
-
- This routine is made a little bit faster by remembering the line number
- (and pointer value) supplied (and returned) from the previous "seek".
- This prevents us from always having to start all over back at the top
- of the in-core cleaned buffer again. */
-
-static const char *
-seek_to_line (int n)
-{
- gcc_assert (n >= last_known_line_number);
-
- while (n > last_known_line_number)
- {
- while (*last_known_line_start != '\n')
- check_source (++last_known_line_start < clean_text_limit, 0);
- last_known_line_start++;
- last_known_line_number++;
- }
- return last_known_line_start;
-}
-
-/* Given a pointer to a character in the cleaned text buffer, return a pointer
- to the next non-whitespace character which follows it. */
-
-static const char *
-forward_to_next_token_char (const char *ptr)
-{
- for (++ptr; ISSPACE ((const unsigned char)*ptr);
- check_source (++ptr < clean_text_limit, 0))
- continue;
- return ptr;
-}
-
-/* Copy a chunk of text of length `len' and starting at `str' to the current
- output buffer. Note that all attempts to add stuff to the current output
- buffer ultimately go through here. */
-
-static void
-output_bytes (const char *str, size_t len)
-{
- if ((repl_write_ptr + 1) + len >= repl_text_limit)
- {
- size_t new_size = (repl_text_limit - repl_text_base) << 1;
- char *new_buf = xrealloc (repl_text_base, new_size);
-
- repl_write_ptr = new_buf + (repl_write_ptr - repl_text_base);
- repl_text_base = new_buf;
- repl_text_limit = new_buf + new_size;
- }
- memcpy (repl_write_ptr + 1, str, len);
- repl_write_ptr += len;
-}
-
-/* Copy all bytes (except the trailing null) of a null terminated string to
- the current output buffer. */
-
-static void
-output_string (const char *str)
-{
- output_bytes (str, strlen (str));
-}
-
-/* Copy some characters from the original text buffer to the current output
- buffer.
-
- This routine takes a pointer argument `p' which is assumed to be a pointer
- into the cleaned text buffer. The bytes which are copied are the `original'
- equivalents for the set of bytes between the last value of `clean_read_ptr'
- and the argument value `p'.
-
- The set of bytes copied however, comes *not* from the cleaned text buffer,
- but rather from the direct counterparts of these bytes within the original
- text buffer.
-
- Thus, when this function is called, some bytes from the original text
- buffer (which may include original comments and preprocessing directives)
- will be copied into the output buffer.
-
- Note that the request implied when this routine is called includes the
- byte pointed to by the argument pointer `p'. */
-
-static void
-output_up_to (const char *p)
-{
- size_t copy_length = (size_t) (p - clean_read_ptr);
- const char *copy_start = orig_text_base+(clean_read_ptr-clean_text_base)+1;
-
- if (copy_length == 0)
- return;
-
- output_bytes (copy_start, copy_length);
- clean_read_ptr = p;
-}
-
-/* Given a pointer to a def_dec_info record which represents some form of
- definition of a function (perhaps a real definition, or in lieu of that
- perhaps just a declaration with a full prototype) return true if this
- function is one which we should avoid converting. Return false
- otherwise. */
-
-static int
-other_variable_style_function (const char *ansi_header)
-{
-#ifdef UNPROTOIZE
-
- /* See if we have a stdarg function, or a function which has stdarg style
- parameters or a stdarg style return type. */
-
- return strstr (ansi_header, "...") != 0;
-
-#else /* !defined (UNPROTOIZE) */
-
- /* See if we have a varargs function, or a function which has varargs style
- parameters or a varargs style return type. */
-
- const char *p;
- int len = strlen (varargs_style_indicator);
-
- for (p = ansi_header; p; )
- {
- const char *candidate;
-
- if ((candidate = strstr (p, varargs_style_indicator)) == 0)
- return 0;
- else
- if (!is_id_char (candidate[-1]) && !is_id_char (candidate[len]))
- return 1;
- else
- p = candidate + 1;
- }
- return 0;
-#endif /* !defined (UNPROTOIZE) */
-}
-
-/* Do the editing operation specifically for a function "declaration". Note
- that editing for function "definitions" are handled in a separate routine
- below. */
-
-static void
-edit_fn_declaration (const def_dec_info *def_dec_p,
- const char *volatile clean_text_p)
-{
- const char *start_formals;
- const char *end_formals;
- const char *function_to_edit = def_dec_p->hash_entry->symbol;
- size_t func_name_len = strlen (function_to_edit);
- const char *end_of_fn_name;
-
-#ifndef UNPROTOIZE
-
- const f_list_chain_item *this_f_list_chain_item;
- const def_dec_info *definition = def_dec_p->definition;
-
- /* If we are protoizing, and if we found no corresponding definition for
- this particular function declaration, then just leave this declaration
- exactly as it is. */
-
- if (!definition)
- return;
-
- /* If we are protoizing, and if the corresponding definition that we found
- for this particular function declaration defined an old style varargs
- function, then we want to issue a warning and just leave this function
- declaration unconverted. */
-
- if (other_variable_style_function (definition->ansi_decl))
- {
- if (!quiet_flag)
- notice ("%s: %d: warning: varargs function declaration not converted\n",
- shortpath (NULL, def_dec_p->file->hash_entry->symbol),
- def_dec_p->line);
- return;
- }
-
-#endif /* !defined (UNPROTOIZE) */
-
- /* Setup here to recover from confusing source code detected during this
- particular "edit". */
-
- save_pointers ();
- if (setjmp (source_confusion_recovery))
- {
- restore_pointers ();
- notice ("%s: declaration of function '%s' not converted\n",
- pname, function_to_edit);
- return;
- }
-
- /* We are editing a function declaration. The line number we did a seek to
- contains the comma or semicolon which follows the declaration. Our job
- now is to scan backwards looking for the function name. This name *must*
- be followed by open paren (ignoring whitespace, of course). We need to
- replace everything between that open paren and the corresponding closing
- paren. If we are protoizing, we need to insert the prototype-style
- formals lists. If we are unprotoizing, we need to just delete everything
- between the pairs of opening and closing parens. */
-
- /* First move up to the end of the line. */
-
- while (*clean_text_p != '\n')
- check_source (++clean_text_p < clean_text_limit, 0);
- clean_text_p--; /* Point to just before the newline character. */
-
- /* Now we can scan backwards for the function name. */
-
- do
- {
- for (;;)
- {
- /* Scan leftwards until we find some character which can be
- part of an identifier. */
-
- while (!is_id_char (*clean_text_p))
- check_source (--clean_text_p > clean_read_ptr, 0);
-
- /* Scan backwards until we find a char that cannot be part of an
- identifier. */
-
- while (is_id_char (*clean_text_p))
- check_source (--clean_text_p > clean_read_ptr, 0);
-
- /* Having found an "id break", see if the following id is the one
- that we are looking for. If so, then exit from this loop. */
-
- if (!strncmp (clean_text_p+1, function_to_edit, func_name_len))
- {
- char ch = *(clean_text_p + 1 + func_name_len);
-
- /* Must also check to see that the name in the source text
- ends where it should (in order to prevent bogus matches
- on similar but longer identifiers. */
-
- if (! is_id_char (ch))
- break; /* exit from loop */
- }
- }
-
- /* We have now found the first perfect match for the function name in
- our backward search. This may or may not be the actual function
- name at the start of the actual function declaration (i.e. we could
- have easily been mislead). We will try to avoid getting fooled too
- often by looking forward for the open paren which should follow the
- identifier we just found. We ignore whitespace while hunting. If
- the next non-whitespace byte we see is *not* an open left paren,
- then we must assume that we have been fooled and we start over
- again accordingly. Note that there is no guarantee, that even if
- we do see the open paren, that we are in the right place.
- Programmers do the strangest things sometimes! */
-
- end_of_fn_name = clean_text_p + strlen (def_dec_p->hash_entry->symbol);
- start_formals = forward_to_next_token_char (end_of_fn_name);
- }
- while (*start_formals != '(');
-
- /* start_of_formals now points to the opening left paren which immediately
- follows the name of the function. */
-
- /* Note that there may be several formals lists which need to be modified
- due to the possibility that the return type of this function is a
- pointer-to-function type. If there are several formals lists, we
- convert them in left-to-right order here. */
-
-#ifndef UNPROTOIZE
- this_f_list_chain_item = definition->f_list_chain;
-#endif /* !defined (UNPROTOIZE) */
-
- for (;;)
- {
- {
- int depth;
-
- end_formals = start_formals + 1;
- depth = 1;
- for (; depth; check_source (++end_formals < clean_text_limit, 0))
- {
- switch (*end_formals)
- {
- case '(':
- depth++;
- break;
- case ')':
- depth--;
- break;
- }
- }
- end_formals--;
- }
-
- /* end_formals now points to the closing right paren of the formals
- list whose left paren is pointed to by start_formals. */
-
- /* Now, if we are protoizing, we insert the new ANSI-style formals list
- attached to the associated definition of this function. If however
- we are unprotoizing, then we simply delete any formals list which
- may be present. */
-
- output_up_to (start_formals);
-#ifndef UNPROTOIZE
- if (this_f_list_chain_item)
- {
- output_string (this_f_list_chain_item->formals_list);
- this_f_list_chain_item = this_f_list_chain_item->chain_next;
- }
- else
- {
- if (!quiet_flag)
- notice ("%s: warning: too many parameter lists in declaration of '%s'\n",
- pname, def_dec_p->hash_entry->symbol);
- check_source (0, end_formals); /* leave the declaration intact */
- }
-#endif /* !defined (UNPROTOIZE) */
- clean_read_ptr = end_formals - 1;
-
- /* Now see if it looks like there may be another formals list associated
- with the function declaration that we are converting (following the
- formals list that we just converted. */
-
- {
- const char *another_r_paren = forward_to_next_token_char (end_formals);
-
- if ((*another_r_paren != ')')
- || (*(start_formals = forward_to_next_token_char (another_r_paren)) != '('))
- {
-#ifndef UNPROTOIZE
- if (this_f_list_chain_item)
- {
- if (!quiet_flag)
- notice ("\n%s: warning: too few parameter lists in declaration of '%s'\n",
- pname, def_dec_p->hash_entry->symbol);
- check_source (0, start_formals); /* leave the decl intact */
- }
-#endif /* !defined (UNPROTOIZE) */
- break;
-
- }
- }
-
- /* There does appear to be yet another formals list, so loop around
- again, and convert it also. */
- }
-}
-
-/* Edit a whole group of formals lists, starting with the rightmost one
- from some set of formals lists. This routine is called once (from the
- outside) for each function declaration which is converted. It is
- recursive however, and it calls itself once for each remaining formal
- list that lies to the left of the one it was originally called to work
- on. Thus, a whole set gets done in right-to-left order.
-
- This routine returns nonzero if it thinks that it should not be trying
- to convert this particular function definition (because the name of the
- function doesn't match the one expected). */
-
-static int
-edit_formals_lists (const char *end_formals, unsigned int f_list_count,
- const def_dec_info *def_dec_p)
-{
- const char *start_formals;
- int depth;
-
- start_formals = end_formals - 1;
- depth = 1;
- for (; depth; check_source (--start_formals > clean_read_ptr, 0))
- {
- switch (*start_formals)
- {
- case '(':
- depth--;
- break;
- case ')':
- depth++;
- break;
- }
- }
- start_formals++;
-
- /* start_formals now points to the opening left paren of the formals list. */
-
- f_list_count--;
-
- if (f_list_count)
- {
- const char *next_end;
-
- /* There should be more formal lists to the left of here. */
-
- next_end = start_formals - 1;
- check_source (next_end > clean_read_ptr, 0);
- while (ISSPACE ((const unsigned char)*next_end))
- check_source (--next_end > clean_read_ptr, 0);
- check_source (*next_end == ')', next_end);
- check_source (--next_end > clean_read_ptr, 0);
- check_source (*next_end == ')', next_end);
- if (edit_formals_lists (next_end, f_list_count, def_dec_p))
- return 1;
- }
-
- /* Check that the function name in the header we are working on is the same
- as the one we would expect to find. If not, issue a warning and return
- nonzero. */
-
- if (f_list_count == 0)
- {
- const char *expected = def_dec_p->hash_entry->symbol;
- const char *func_name_start;
- const char *func_name_limit;
- size_t func_name_len;
-
- for (func_name_limit = start_formals-1;
- ISSPACE ((const unsigned char)*func_name_limit); )
- check_source (--func_name_limit > clean_read_ptr, 0);
-
- for (func_name_start = func_name_limit++;
- is_id_char (*func_name_start);
- func_name_start--)
- check_source (func_name_start > clean_read_ptr, 0);
- func_name_start++;
- func_name_len = func_name_limit - func_name_start;
- if (func_name_len == 0)
- check_source (0, func_name_start);
- if (func_name_len != strlen (expected)
- || strncmp (func_name_start, expected, func_name_len))
- {
- notice ("%s: %d: warning: found '%s' but expected '%s'\n",
- shortpath (NULL, def_dec_p->file->hash_entry->symbol),
- identify_lineno (func_name_start),
- dupnstr (func_name_start, func_name_len),
- expected);
- return 1;
- }
- }
-
- output_up_to (start_formals);
-
-#ifdef UNPROTOIZE
- if (f_list_count == 0)
- output_string (def_dec_p->formal_names);
-#else /* !defined (UNPROTOIZE) */
- {
- unsigned f_list_depth;
- const f_list_chain_item *flci_p = def_dec_p->f_list_chain;
-
- /* At this point, the current value of f_list count says how many
- links we have to follow through the f_list_chain to get to the
- particular formals list that we need to output next. */
-
- for (f_list_depth = 0; f_list_depth < f_list_count; f_list_depth++)
- flci_p = flci_p->chain_next;
- output_string (flci_p->formals_list);
- }
-#endif /* !defined (UNPROTOIZE) */
-
- clean_read_ptr = end_formals - 1;
- return 0;
-}
-
-/* Given a pointer to a byte in the clean text buffer which points to
- the beginning of a line that contains a "follower" token for a
- function definition header, do whatever is necessary to find the
- right closing paren for the rightmost formals list of the function
- definition header. */
-
-static const char *
-find_rightmost_formals_list (const char *clean_text_p)
-{
- const char *end_formals;
-
- /* We are editing a function definition. The line number we did a seek
- to contains the first token which immediately follows the entire set of
- formals lists which are part of this particular function definition
- header.
-
- Our job now is to scan leftwards in the clean text looking for the
- right-paren which is at the end of the function header's rightmost
- formals list.
-
- If we ignore whitespace, this right paren should be the first one we
- see which is (ignoring whitespace) immediately followed either by the
- open curly-brace beginning the function body or by an alphabetic
- character (in the case where the function definition is in old (K&R)
- style and there are some declarations of formal parameters). */
-
- /* It is possible that the right paren we are looking for is on the
- current line (together with its following token). Just in case that
- might be true, we start out here by skipping down to the right end of
- the current line before starting our scan. */
-
- for (end_formals = clean_text_p; *end_formals != '\n'; end_formals++)
- continue;
- end_formals--;
-
-#ifdef UNPROTOIZE
-
- /* Now scan backwards while looking for the right end of the rightmost
- formals list associated with this function definition. */
-
- {
- char ch;
- const char *l_brace_p;
-
- /* Look leftward and try to find a right-paren. */
-
- while (*end_formals != ')')
- {
- if (ISSPACE ((unsigned char)*end_formals))
- while (ISSPACE ((unsigned char)*end_formals))
- check_source (--end_formals > clean_read_ptr, 0);
- else
- check_source (--end_formals > clean_read_ptr, 0);
- }
-
- ch = *(l_brace_p = forward_to_next_token_char (end_formals));
- /* Since we are unprotoizing an ANSI-style (prototyped) function
- definition, there had better not be anything (except whitespace)
- between the end of the ANSI formals list and the beginning of the
- function body (i.e. the '{'). */
-
- check_source (ch == '{', l_brace_p);
- }
-
-#else /* !defined (UNPROTOIZE) */
-
- /* Now scan backwards while looking for the right end of the rightmost
- formals list associated with this function definition. */
-
- while (1)
- {
- char ch;
- const char *l_brace_p;
-
- /* Look leftward and try to find a right-paren. */
-
- while (*end_formals != ')')
- {
- if (ISSPACE ((const unsigned char)*end_formals))
- while (ISSPACE ((const unsigned char)*end_formals))
- check_source (--end_formals > clean_read_ptr, 0);
- else
- check_source (--end_formals > clean_read_ptr, 0);
- }
-
- ch = *(l_brace_p = forward_to_next_token_char (end_formals));
-
- /* Since it is possible that we found a right paren before the starting
- '{' of the body which IS NOT the one at the end of the real K&R
- formals list (say for instance, we found one embedded inside one of
- the old K&R formal parameter declarations) we have to check to be
- sure that this is in fact the right paren that we were looking for.
-
- The one we were looking for *must* be followed by either a '{' or
- by an alphabetic character, while others *cannot* validly be followed
- by such characters. */
-
- if ((ch == '{') || ISALPHA ((unsigned char) ch))
- break;
-
- /* At this point, we have found a right paren, but we know that it is
- not the one we were looking for, so backup one character and keep
- looking. */
-
- check_source (--end_formals > clean_read_ptr, 0);
- }
-
-#endif /* !defined (UNPROTOIZE) */
-
- return end_formals;
-}
-
-#ifndef UNPROTOIZE
-
-/* Insert into the output file a totally new declaration for a function
- which (up until now) was being called from within the current block
- without having been declared at any point such that the declaration
- was visible (i.e. in scope) at the point of the call.
-
- We need to add in explicit declarations for all such function calls
- in order to get the full benefit of prototype-based function call
- parameter type checking. */
-
-static void
-add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
-{
- const char *start_of_block;
- const char *function_to_edit = def_dec_p->hash_entry->symbol;
-
- /* Don't insert new local explicit declarations unless explicitly requested
- to do so. */
-
- if (!local_flag)
- return;
-
- /* Setup here to recover from confusing source code detected during this
- particular "edit". */
-
- save_pointers ();
- if (setjmp (source_confusion_recovery))
- {
- restore_pointers ();
- notice ("%s: local declaration for function '%s' not inserted\n",
- pname, function_to_edit);
- return;
- }
-
- /* We have already done a seek to the start of the line which should
- contain *the* open curly brace which begins the block in which we need
- to insert an explicit function declaration (to replace the implicit one).
-
- Now we scan that line, starting from the left, until we find the
- open curly brace we are looking for. Note that there may actually be
- multiple open curly braces on the given line, but we will be happy
- with the leftmost one no matter what. */
-
- start_of_block = clean_text_p;
- while (*start_of_block != '{' && *start_of_block != '\n')
- check_source (++start_of_block < clean_text_limit, 0);
-
- /* Note that the line from the original source could possibly
- contain *no* open curly braces! This happens if the line contains
- a macro call which expands into a chunk of text which includes a
- block (and that block's associated open and close curly braces).
- In cases like this, we give up, issue a warning, and do nothing. */
-
- if (*start_of_block != '{')
- {
- if (!quiet_flag)
- notice ("\n%s: %d: warning: can't add declaration of '%s' into macro call\n",
- def_dec_p->file->hash_entry->symbol, def_dec_p->line,
- def_dec_p->hash_entry->symbol);
- return;
- }
-
- /* Figure out what a nice (pretty) indentation would be for the new
- declaration we are adding. In order to do this, we must scan forward
- from the '{' until we find the first line which starts with some
- non-whitespace characters (i.e. real "token" material). */
-
- {
- const char *ep = forward_to_next_token_char (start_of_block) - 1;
- const char *sp;
-
- /* Now we have ep pointing at the rightmost byte of some existing indent
- stuff. At least that is the hope.
-
- We can now just scan backwards and find the left end of the existing
- indentation string, and then copy it to the output buffer. */
-
- for (sp = ep; ISSPACE ((const unsigned char)*sp) && *sp != '\n'; sp--)
- continue;
-
- /* Now write out the open { which began this block, and any following
- trash up to and including the last byte of the existing indent that
- we just found. */
-
- output_up_to (ep);
-
- /* Now we go ahead and insert the new declaration at this point.
-
- If the definition of the given function is in the same file that we
- are currently editing, and if its full ANSI declaration normally
- would start with the keyword `extern', suppress the `extern'. */
-
- {
- const char *decl = def_dec_p->definition->ansi_decl;
-
- if ((*decl == 'e') && (def_dec_p->file == def_dec_p->definition->file))
- decl += 7;
- output_string (decl);
- }
-
- /* Finally, write out a new indent string, just like the preceding one
- that we found. This will typically include a newline as the first
- character of the indent string. */
-
- output_bytes (sp, (size_t) (ep - sp) + 1);
- }
-}
-
-/* Given a pointer to a file_info record, and a pointer to the beginning
- of a line (in the clean text buffer) which is assumed to contain the
- first "follower" token for the first function definition header in the
- given file, find a good place to insert some new global function
- declarations (which will replace scattered and imprecise implicit ones)
- and then insert the new explicit declaration at that point in the file. */
-
-static void
-add_global_decls (const file_info *file_p, const char *clean_text_p)
-{
- const def_dec_info *dd_p;
- const char *scan_p;
-
- /* Setup here to recover from confusing source code detected during this
- particular "edit". */
-
- save_pointers ();
- if (setjmp (source_confusion_recovery))
- {
- restore_pointers ();
- notice ("%s: global declarations for file '%s' not inserted\n",
- pname, shortpath (NULL, file_p->hash_entry->symbol));
- return;
- }
-
- /* Start by finding a good location for adding the new explicit function
- declarations. To do this, we scan backwards, ignoring whitespace
- and comments and other junk until we find either a semicolon, or until
- we hit the beginning of the file. */
-
- scan_p = find_rightmost_formals_list (clean_text_p);
- for (;; --scan_p)
- {
- if (scan_p < clean_text_base)
- break;
- check_source (scan_p > clean_read_ptr, 0);
- if (*scan_p == ';')
- break;
- }
-
- /* scan_p now points either to a semicolon, or to just before the start
- of the whole file. */
-
- /* Now scan forward for the first non-whitespace character. In theory,
- this should be the first character of the following function definition
- header. We will put in the added declarations just prior to that. */
-
- scan_p++;
- while (ISSPACE ((const unsigned char)*scan_p))
- scan_p++;
- scan_p--;
-
- output_up_to (scan_p);
-
- /* Now write out full prototypes for all of the things that had been
- implicitly declared in this file (but only those for which we were
- actually able to find unique matching definitions). Avoid duplicates
- by marking things that we write out as we go. */
-
- {
- int some_decls_added = 0;
-
- for (dd_p = file_p->defs_decs; dd_p; dd_p = dd_p->next_in_file)
- if (dd_p->is_implicit && dd_p->definition && !dd_p->definition->written)
- {
- const char *decl = dd_p->definition->ansi_decl;
-
- /* If the function for which we are inserting a declaration is
- actually defined later in the same file, then suppress the
- leading `extern' keyword (if there is one). */
-
- if (*decl == 'e' && (dd_p->file == dd_p->definition->file))
- decl += 7;
-
- output_string ("\n");
- output_string (decl);
- some_decls_added = 1;
- ((NONCONST def_dec_info *) dd_p->definition)->written = 1;
- }
- if (some_decls_added)
- output_string ("\n\n");
- }
-
- /* Unmark all of the definitions that we just marked. */
-
- for (dd_p = file_p->defs_decs; dd_p; dd_p = dd_p->next_in_file)
- if (dd_p->definition)
- ((NONCONST def_dec_info *) dd_p->definition)->written = 0;
-}
-
-#endif /* !defined (UNPROTOIZE) */
-
-/* Do the editing operation specifically for a function "definition". Note
- that editing operations for function "declarations" are handled by a
- separate routine above. */
-
-static void
-edit_fn_definition (const def_dec_info *def_dec_p,
- const char *volatile clean_text_p)
-{
- const char *end_formals;
- const char *function_to_edit = def_dec_p->hash_entry->symbol;
-
- /* Setup here to recover from confusing source code detected during this
- particular "edit". */
-
- save_pointers ();
- if (setjmp (source_confusion_recovery))
- {
- restore_pointers ();
- notice ("%s: definition of function '%s' not converted\n",
- pname, function_to_edit);
- return;
- }
-
- end_formals = find_rightmost_formals_list (clean_text_p);
-
- /* end_of_formals now points to the closing right paren of the rightmost
- formals list which is actually part of the `header' of the function
- definition that we are converting. */
-
- /* If the header of this function definition looks like it declares a
- function with a variable number of arguments, and if the way it does
- that is different from that way we would like it (i.e. varargs vs.
- stdarg) then issue a warning and leave the header unconverted. */
-
- if (other_variable_style_function (def_dec_p->ansi_decl))
- {
- if (!quiet_flag)
- notice ("%s: %d: warning: definition of %s not converted\n",
- shortpath (NULL, def_dec_p->file->hash_entry->symbol),
- identify_lineno (end_formals),
- other_var_style);
- output_up_to (end_formals);
- return;
- }
-
- if (edit_formals_lists (end_formals, def_dec_p->f_list_count, def_dec_p))
- {
- restore_pointers ();
- notice ("%s: definition of function '%s' not converted\n",
- pname, function_to_edit);
- return;
- }
-
- /* Have to output the last right paren because this never gets flushed by
- edit_formals_list. */
-
- output_up_to (end_formals);
-
-#ifdef UNPROTOIZE
- {
- const char *decl_p;
- const char *semicolon_p;
- const char *limit_p;
- const char *scan_p;
- int had_newlines = 0;
-
- /* Now write out the K&R style formal declarations, one per line. */
-
- decl_p = def_dec_p->formal_decls;
- limit_p = decl_p + strlen (decl_p);
- for (;decl_p < limit_p; decl_p = semicolon_p + 2)
- {
- for (semicolon_p = decl_p; *semicolon_p != ';'; semicolon_p++)
- continue;
- output_string ("\n");
- output_string (indent_string);
- output_bytes (decl_p, (size_t) ((semicolon_p + 1) - decl_p));
- }
-
- /* If there are no newlines between the end of the formals list and the
- start of the body, we should insert one now. */
-
- for (scan_p = end_formals+1; *scan_p != '{'; )
- {
- if (*scan_p == '\n')
- {
- had_newlines = 1;
- break;
- }
- check_source (++scan_p < clean_text_limit, 0);
- }
- if (!had_newlines)
- output_string ("\n");
- }
-#else /* !defined (UNPROTOIZE) */
- /* If we are protoizing, there may be some flotsam & jetsam (like comments
- and preprocessing directives) after the old formals list but before
- the following { and we would like to preserve that stuff while effectively
- deleting the existing K&R formal parameter declarations. We do so here
- in a rather tricky way. Basically, we white out any stuff *except*
- the comments/pp-directives in the original text buffer, then, if there
- is anything in this area *other* than whitespace, we output it. */
- {
- const char *end_formals_orig;
- const char *start_body;
- const char *start_body_orig;
- const char *scan;
- const char *scan_orig;
- int have_flotsam = 0;
- int have_newlines = 0;
-
- for (start_body = end_formals + 1; *start_body != '{';)
- check_source (++start_body < clean_text_limit, 0);
-
- end_formals_orig = orig_text_base + (end_formals - clean_text_base);
- start_body_orig = orig_text_base + (start_body - clean_text_base);
- scan = end_formals + 1;
- scan_orig = end_formals_orig + 1;
- for (; scan < start_body; scan++, scan_orig++)
- {
- if (*scan == *scan_orig)
- {
- have_newlines |= (*scan_orig == '\n');
- /* Leave identical whitespace alone. */
- if (!ISSPACE ((const unsigned char)*scan_orig))
- *((NONCONST char *) scan_orig) = ' '; /* identical - so whiteout */
- }
- else
- have_flotsam = 1;
- }
- if (have_flotsam)
- output_bytes (end_formals_orig + 1,
- (size_t) (start_body_orig - end_formals_orig) - 1);
- else
- if (have_newlines)
- output_string ("\n");
- else
- output_string (" ");
- clean_read_ptr = start_body - 1;
- }
-#endif /* !defined (UNPROTOIZE) */
-}
-
-/* Clean up the clean text buffer. Do this by converting comments and
- preprocessing directives into spaces. Also convert line continuations
- into whitespace. Also, whiteout string and character literals. */
-
-static void
-do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
-{
- char *scan_p;
- int non_whitespace_since_newline = 0;
-
- for (scan_p = new_clean_text_base; scan_p < new_clean_text_limit; scan_p++)
- {
- switch (*scan_p)
- {
- case '/': /* Handle comments. */
- if (scan_p[1] != '*')
- goto regular;
- non_whitespace_since_newline = 1;
- scan_p[0] = ' ';
- scan_p[1] = ' ';
- scan_p += 2;
- while (scan_p[1] != '/' || scan_p[0] != '*')
- {
- if (!ISSPACE ((const unsigned char)*scan_p))
- *scan_p = ' ';
- ++scan_p;
- gcc_assert (scan_p < new_clean_text_limit);
- }
- *scan_p++ = ' ';
- *scan_p = ' ';
- break;
-
- case '#': /* Handle pp directives. */
- if (non_whitespace_since_newline)
- goto regular;
- *scan_p = ' ';
- while (scan_p[1] != '\n' || scan_p[0] == '\\')
- {
- if (!ISSPACE ((const unsigned char)*scan_p))
- *scan_p = ' ';
- ++scan_p;
- gcc_assert (scan_p < new_clean_text_limit);
- }
- *scan_p++ = ' ';
- break;
-
- case '\'': /* Handle character literals. */
- non_whitespace_since_newline = 1;
- while (scan_p[1] != '\'' || scan_p[0] == '\\')
- {
- if (scan_p[0] == '\\'
- && !ISSPACE ((const unsigned char) scan_p[1]))
- scan_p[1] = ' ';
- if (!ISSPACE ((const unsigned char)*scan_p))
- *scan_p = ' ';
- ++scan_p;
- gcc_assert (scan_p < new_clean_text_limit);
- }
- *scan_p++ = ' ';
- break;
-
- case '"': /* Handle string literals. */
- non_whitespace_since_newline = 1;
- while (scan_p[1] != '"' || scan_p[0] == '\\')
- {
- if (scan_p[0] == '\\'
- && !ISSPACE ((const unsigned char) scan_p[1]))
- scan_p[1] = ' ';
- if (!ISSPACE ((const unsigned char)*scan_p))
- *scan_p = ' ';
- ++scan_p;
- gcc_assert (scan_p < new_clean_text_limit);
- }
- if (!ISSPACE ((const unsigned char)*scan_p))
- *scan_p = ' ';
- scan_p++;
- break;
-
- case '\\': /* Handle line continuations. */
- if (scan_p[1] != '\n')
- goto regular;
- *scan_p = ' ';
- break;
-
- case '\n':
- non_whitespace_since_newline = 0; /* Reset. */
- break;
-
- case ' ':
- case '\v':
- case '\t':
- case '\r':
- case '\f':
- case '\b':
- break; /* Whitespace characters. */
-
- default:
-regular:
- non_whitespace_since_newline = 1;
- break;
- }
- }
-}
-
-/* Given a pointer to the closing right parenthesis for a particular formals
- list (in the clean text buffer) find the corresponding left parenthesis
- and return a pointer to it. */
-
-static const char *
-careful_find_l_paren (const char *p)
-{
- const char *q;
- int paren_depth;
-
- for (paren_depth = 1, q = p-1; paren_depth; check_source (--q >= clean_text_base, 0))
- {
- switch (*q)
- {
- case ')':
- paren_depth++;
- break;
- case '(':
- paren_depth--;
- break;
- }
- }
- return ++q;
-}
-
-/* Scan the clean text buffer for cases of function definitions that we
- don't really know about because they were preprocessed out when the
- aux info files were created.
-
- In this version of protoize/unprotoize we just give a warning for each
- one found. A later version may be able to at least unprotoize such
- missed items.
-
- Note that we may easily find all function definitions simply by
- looking for places where there is a left paren which is (ignoring
- whitespace) immediately followed by either a left-brace or by an
- upper or lower case letter. Whenever we find this combination, we
- have also found a function definition header.
-
- Finding function *declarations* using syntactic clues is much harder.
- I will probably try to do this in a later version though. */
-
-static void
-scan_for_missed_items (const file_info *file_p)
-{
- static const char *scan_p;
- const char *limit = clean_text_limit - 3;
- static const char *backup_limit;
-
- backup_limit = clean_text_base - 1;
-
- for (scan_p = clean_text_base; scan_p < limit; scan_p++)
- {
- if (*scan_p == ')')
- {
- static const char *last_r_paren;
- const char *ahead_p;
-
- last_r_paren = scan_p;
-
- for (ahead_p = scan_p + 1; ISSPACE ((const unsigned char)*ahead_p); )
- check_source (++ahead_p < limit, limit);
-
- scan_p = ahead_p - 1;
-
- if (ISALPHA ((const unsigned char)*ahead_p) || *ahead_p == '{')
- {
- const char *last_l_paren;
- const int lineno = identify_lineno (ahead_p);
-
- if (setjmp (source_confusion_recovery))
- continue;
-
- /* We know we have a function definition header. Now skip
- leftwards over all of its associated formals lists. */
-
- do
- {
- last_l_paren = careful_find_l_paren (last_r_paren);
- for (last_r_paren = last_l_paren-1;
- ISSPACE ((const unsigned char)*last_r_paren); )
- check_source (--last_r_paren >= backup_limit, backup_limit);
- }
- while (*last_r_paren == ')');
-
- if (is_id_char (*last_r_paren))
- {
- const char *id_limit = last_r_paren + 1;
- const char *id_start;
- size_t id_length;
- const def_dec_info *dd_p;
-
- for (id_start = id_limit-1; is_id_char (*id_start); )
- check_source (--id_start >= backup_limit, backup_limit);
- id_start++;
- backup_limit = id_start;
- if ((id_length = (size_t) (id_limit - id_start)) == 0)
- goto not_missed;
-
- {
- char *func_name = alloca (id_length + 1);
- static const char * const stmt_keywords[]
- = { "if", "else", "do", "while", "for", "switch", "case", "return", 0 };
- const char * const *stmt_keyword;
-
- strncpy (func_name, id_start, id_length);
- func_name[id_length] = '\0';
-
- /* We must check here to see if we are actually looking at
- a statement rather than an actual function call. */
-
- for (stmt_keyword = stmt_keywords; *stmt_keyword; stmt_keyword++)
- if (!strcmp (func_name, *stmt_keyword))
- goto not_missed;
-
-#if 0
- notice ("%s: found definition of '%s' at %s(%d)\n",
- pname,
- func_name,
- shortpath (NULL, file_p->hash_entry->symbol),
- identify_lineno (id_start));
-#endif /* 0 */
- /* We really should check for a match of the function name
- here also, but why bother. */
-
- for (dd_p = file_p->defs_decs; dd_p; dd_p = dd_p->next_in_file)
- if (dd_p->is_func_def && dd_p->line == lineno)
- goto not_missed;
-
- /* If we make it here, then we did not know about this
- function definition. */
-
- notice ("%s: %d: warning: '%s' excluded by preprocessing\n",
- shortpath (NULL, file_p->hash_entry->symbol),
- identify_lineno (id_start), func_name);
- notice ("%s: function definition not converted\n",
- pname);
- }
- not_missed: ;
- }
- }
- }
- }
-}
-
-/* Do all editing operations for a single source file (either a "base" file
- or an "include" file). To do this we read the file into memory, keep a
- virgin copy there, make another cleaned in-core copy of the original file
- (i.e. one in which all of the comments and preprocessing directives have
- been replaced with whitespace), then use these two in-core copies of the
- file to make a new edited in-core copy of the file. Finally, rename the
- original file (as a way of saving it), and then write the edited version
- of the file from core to a disk file of the same name as the original.
-
- Note that the trick of making a copy of the original sans comments &
- preprocessing directives make the editing a whole lot easier. */
-
-static void
-edit_file (const hash_table_entry *hp)
-{
- struct stat stat_buf;
- const file_info *file_p = hp->fip;
- char *new_orig_text_base;
- char *new_orig_text_limit;
- char *new_clean_text_base;
- char *new_clean_text_limit;
- size_t orig_size;
- size_t repl_size;
- int first_definition_in_file;
-
- /* If we are not supposed to be converting this file, or if there is
- nothing in there which needs converting, just skip this file. */
-
- if (!needs_to_be_converted (file_p))
- return;
-
- convert_filename = file_p->hash_entry->symbol;
-
- /* Convert a file if it is in a directory where we want conversion
- and the file is not excluded. */
-
- if (!directory_specified_p (convert_filename)
- || file_excluded_p (convert_filename))
- {
- if (!quiet_flag
-#ifdef UNPROTOIZE
- /* Don't even mention "system" include files unless we are
- protoizing. If we are protoizing, we mention these as a
- gentle way of prodding the user to convert his "system"
- include files to prototype format. */
- && !in_system_include_dir (convert_filename)
-#endif /* defined (UNPROTOIZE) */
- )
- notice ("%s: '%s' not converted\n",
- pname, shortpath (NULL, convert_filename));
- return;
- }
-
- /* Let the user know what we are up to. */
-
- if (nochange_flag)
- notice ("%s: would convert file '%s'\n",
- pname, shortpath (NULL, convert_filename));
- else
- notice ("%s: converting file '%s'\n",
- pname, shortpath (NULL, convert_filename));
- fflush (stderr);
-
- /* Find out the size (in bytes) of the original file. */
-
- /* The cast avoids an erroneous warning on AIX. */
- if (stat (convert_filename, &stat_buf) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't get status for file '%s': %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- return;
- }
- orig_size = stat_buf.st_size;
-
- /* Allocate a buffer to hold the original text. */
-
- orig_text_base = new_orig_text_base = xmalloc (orig_size + 2);
- orig_text_limit = new_orig_text_limit = new_orig_text_base + orig_size;
-
- /* Allocate a buffer to hold the cleaned-up version of the original text. */
-
- clean_text_base = new_clean_text_base = xmalloc (orig_size + 2);
- clean_text_limit = new_clean_text_limit = new_clean_text_base + orig_size;
- clean_read_ptr = clean_text_base - 1;
-
- /* Allocate a buffer that will hopefully be large enough to hold the entire
- converted output text. As an initial guess for the maximum size of the
- output buffer, use 125% of the size of the original + some extra. This
- buffer can be expanded later as needed. */
-
- repl_size = orig_size + (orig_size >> 2) + 4096;
- repl_text_base = xmalloc (repl_size + 2);
- repl_text_limit = repl_text_base + repl_size - 1;
- repl_write_ptr = repl_text_base - 1;
-
- {
- int input_file;
- int fd_flags;
-
- /* Open the file to be converted in READ ONLY mode. */
-
- fd_flags = O_RDONLY;
-#ifdef O_BINARY
- /* Use binary mode to avoid having to deal with different EOL characters. */
- fd_flags |= O_BINARY;
-#endif
- if ((input_file = open (convert_filename, fd_flags, 0444)) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't open file '%s' for reading: %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- return;
- }
-
- /* Read the entire original source text file into the original text buffer
- in one swell fwoop. Then figure out where the end of the text is and
- make sure that it ends with a newline followed by a null. */
-
- if (safe_read (input_file, new_orig_text_base, orig_size) !=
- (int) orig_size)
- {
- int errno_val = errno;
- close (input_file);
- notice ("\n%s: error reading input file '%s': %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- return;
- }
-
- close (input_file);
- }
-
- if (orig_size == 0 || orig_text_limit[-1] != '\n')
- {
- *new_orig_text_limit++ = '\n';
- orig_text_limit++;
- }
-
- /* Create the cleaned up copy of the original text. */
-
- memcpy (new_clean_text_base, orig_text_base,
- (size_t) (orig_text_limit - orig_text_base));
- do_cleaning (new_clean_text_base, new_clean_text_limit);
-
-#if 0
- {
- int clean_file;
- size_t clean_size = orig_text_limit - orig_text_base;
- char *const clean_filename = alloca (strlen (convert_filename) + 6 + 1);
-
- /* Open (and create) the clean file. */
-
- strcpy (clean_filename, convert_filename);
- strcat (clean_filename, ".clean");
- if ((clean_file = creat (clean_filename, 0666)) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't create/open clean file '%s': %s\n",
- pname, shortpath (NULL, clean_filename),
- xstrerror (errno_val));
- return;
- }
-
- /* Write the clean file. */
-
- safe_write (clean_file, new_clean_text_base, clean_size, clean_filename);
-
- close (clean_file);
- }
-#endif /* 0 */
-
- /* Do a simplified scan of the input looking for things that were not
- mentioned in the aux info files because of the fact that they were
- in a region of the source which was preprocessed-out (via #if or
- via #ifdef). */
-
- scan_for_missed_items (file_p);
-
- /* Setup to do line-oriented forward seeking in the clean text buffer. */
-
- last_known_line_number = 1;
- last_known_line_start = clean_text_base;
-
- /* Now get down to business and make all of the necessary edits. */
-
- {
- const def_dec_info *def_dec_p;
-
- first_definition_in_file = 1;
- def_dec_p = file_p->defs_decs;
- for (; def_dec_p; def_dec_p = def_dec_p->next_in_file)
- {
- const char *clean_text_p = seek_to_line (def_dec_p->line);
-
- /* clean_text_p now points to the first character of the line which
- contains the `terminator' for the declaration or definition that
- we are about to process. */
-
-#ifndef UNPROTOIZE
-
- if (global_flag && def_dec_p->is_func_def && first_definition_in_file)
- {
- add_global_decls (def_dec_p->file, clean_text_p);
- first_definition_in_file = 0;
- }
-
- /* Don't edit this item if it is already in prototype format or if it
- is a function declaration and we have found no corresponding
- definition. */
-
- if (def_dec_p->prototyped
- || (!def_dec_p->is_func_def && !def_dec_p->definition))
- continue;
-
-#endif /* !defined (UNPROTOIZE) */
-
- if (def_dec_p->is_func_def)
- edit_fn_definition (def_dec_p, clean_text_p);
- else
-#ifndef UNPROTOIZE
- if (def_dec_p->is_implicit)
- add_local_decl (def_dec_p, clean_text_p);
- else
-#endif /* !defined (UNPROTOIZE) */
- edit_fn_declaration (def_dec_p, clean_text_p);
- }
- }
-
- /* Finalize things. Output the last trailing part of the original text. */
-
- output_up_to (clean_text_limit - 1);
-
- /* If this is just a test run, stop now and just deallocate the buffers. */
-
- if (nochange_flag)
- {
- free (new_orig_text_base);
- free (new_clean_text_base);
- free (repl_text_base);
- return;
- }
-
- /* Change the name of the original input file. This is just a quick way of
- saving the original file. */
-
- if (!nosave_flag)
- {
- char *new_filename
- = xmalloc (strlen (convert_filename) + strlen (save_suffix) + 2);
-
- strcpy (new_filename, convert_filename);
-#ifdef __MSDOS__
- /* MSDOS filenames are restricted to 8.3 format, so we save `foo.c'
- as `foo.<save_suffix>'. */
- new_filename[(strlen (convert_filename) - 1] = '\0';
-#endif
- strcat (new_filename, save_suffix);
-
- /* Don't overwrite existing file. */
- if (access (new_filename, F_OK) == 0)
- {
- if (!quiet_flag)
- notice ("%s: warning: file '%s' already saved in '%s'\n",
- pname,
- shortpath (NULL, convert_filename),
- shortpath (NULL, new_filename));
- }
- else if (rename (convert_filename, new_filename) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't link file '%s' to '%s': %s\n",
- pname,
- shortpath (NULL, convert_filename),
- shortpath (NULL, new_filename),
- xstrerror (errno_val));
- return;
- }
- }
-
- if (unlink (convert_filename) == -1)
- {
- int errno_val = errno;
- /* The file may have already been renamed. */
- if (errno_val != ENOENT)
- {
- notice ("%s: can't delete file '%s': %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- return;
- }
- }
-
- {
- int output_file;
-
- /* Open (and create) the output file. */
-
- if ((output_file = creat (convert_filename, 0666)) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't create/open output file '%s': %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- return;
- }
-#ifdef O_BINARY
- /* Use binary mode to avoid changing the existing EOL character. */
- setmode (output_file, O_BINARY);
-#endif
-
- /* Write the output file. */
-
- {
- unsigned int out_size = (repl_write_ptr + 1) - repl_text_base;
-
- safe_write (output_file, repl_text_base, out_size, convert_filename);
- }
-
- close (output_file);
- }
-
- /* Deallocate the conversion buffers. */
-
- free (new_orig_text_base);
- free (new_clean_text_base);
- free (repl_text_base);
-
- /* Change the mode of the output file to match the original file. */
-
- /* The cast avoids an erroneous warning on AIX. */
- if (chmod (convert_filename, stat_buf.st_mode) == -1)
- {
- int errno_val = errno;
- notice ("%s: can't change mode of file '%s': %s\n",
- pname, shortpath (NULL, convert_filename),
- xstrerror (errno_val));
- }
-
- /* Note: We would try to change the owner and group of the output file
- to match those of the input file here, except that may not be a good
- thing to do because it might be misleading. Also, it might not even
- be possible to do that (on BSD systems with quotas for instance). */
-}
-
-/* Do all of the individual steps needed to do the protoization (or
- unprotoization) of the files referenced in the aux_info files given
- in the command line. */
-
-static void
-do_processing (void)
-{
- const char * const *base_pp;
- const char * const * const end_pps
- = &base_source_filenames[n_base_source_files];
-
-#ifndef UNPROTOIZE
- int syscalls_len;
-#endif /* !defined (UNPROTOIZE) */
-
- /* One-by-one, check (and create if necessary), open, and read all of the
- stuff in each aux_info file. After reading each aux_info file, the
- aux_info_file just read will be automatically deleted unless the
- keep_flag is set. */
-
- for (base_pp = base_source_filenames; base_pp < end_pps; base_pp++)
- process_aux_info_file (*base_pp, keep_flag, 0);
-
-#ifndef UNPROTOIZE
-
- /* Also open and read the special SYSCALLS.c aux_info file which gives us
- the prototypes for all of the standard system-supplied functions. */
-
- if (nondefault_syscalls_dir)
- {
- syscalls_absolute_filename
- = xmalloc (strlen (nondefault_syscalls_dir) + 1
- + sizeof (syscalls_filename));
- strcpy (syscalls_absolute_filename, nondefault_syscalls_dir);
- }
- else
- {
- GET_ENVIRONMENT (default_syscalls_dir, "GCC_EXEC_PREFIX");
- if (!default_syscalls_dir)
- {
- default_syscalls_dir = standard_exec_prefix;
- }
- syscalls_absolute_filename
- = xmalloc (strlen (default_syscalls_dir) + 0
- + strlen (target_machine) + 1
- + strlen (target_version) + 1
- + sizeof (syscalls_filename));
- strcpy (syscalls_absolute_filename, default_syscalls_dir);
- strcat (syscalls_absolute_filename, target_machine);
- strcat (syscalls_absolute_filename, "/");
- strcat (syscalls_absolute_filename, target_version);
- strcat (syscalls_absolute_filename, "/");
- }
-
- syscalls_len = strlen (syscalls_absolute_filename);
- if (! IS_DIR_SEPARATOR (*(syscalls_absolute_filename + syscalls_len - 1)))
- {
- *(syscalls_absolute_filename + syscalls_len++) = DIR_SEPARATOR;
- *(syscalls_absolute_filename + syscalls_len) = '\0';
- }
- strcat (syscalls_absolute_filename, syscalls_filename);
-
- /* Call process_aux_info_file in such a way that it does not try to
- delete the SYSCALLS aux_info file. */
-
- process_aux_info_file (syscalls_absolute_filename, 1, 1);
-
-#endif /* !defined (UNPROTOIZE) */
-
- /* When we first read in all of the information from the aux_info files
- we saved in it descending line number order, because that was likely to
- be faster. Now however, we want the chains of def & dec records to
- appear in ascending line number order as we get further away from the
- file_info record that they hang from. The following line causes all of
- these lists to be rearranged into ascending line number order. */
-
- visit_each_hash_node (filename_primary, reverse_def_dec_list);
-
-#ifndef UNPROTOIZE
-
- /* Now do the "real" work. The following line causes each declaration record
- to be "visited". For each of these nodes, an attempt is made to match
- up the function declaration with a corresponding function definition,
- which should have a full prototype-format formals list with it. Once
- these match-ups are made, the conversion of the function declarations
- to prototype format can be made. */
-
- visit_each_hash_node (function_name_primary, connect_defs_and_decs);
-
-#endif /* !defined (UNPROTOIZE) */
-
- /* Now convert each file that can be converted (and needs to be). */
-
- visit_each_hash_node (filename_primary, edit_file);
-
-#ifndef UNPROTOIZE
-
- /* If we are working in cplusplus mode, try to rename all .c files to .C
- files. Don't panic if some of the renames don't work. */
-
- if (cplusplus_flag && !nochange_flag)
- visit_each_hash_node (filename_primary, rename_c_file);
-
-#endif /* !defined (UNPROTOIZE) */
-}
-\f
-static const struct option longopts[] =
-{
- {"version", 0, 0, 'V'},
- {"file_name", 0, 0, 'p'},
- {"quiet", 0, 0, 'q'},
- {"silent", 0, 0, 'q'},
- {"force", 0, 0, 'f'},
- {"keep", 0, 0, 'k'},
- {"nosave", 0, 0, 'N'},
- {"nochange", 0, 0, 'n'},
- {"compiler-options", 1, 0, 'c'},
- {"exclude", 1, 0, 'x'},
- {"directory", 1, 0, 'd'},
-#ifdef UNPROTOIZE
- {"indent", 1, 0, 'i'},
-#else
- {"local", 0, 0, 'l'},
- {"global", 0, 0, 'g'},
- {"c++", 0, 0, 'C'},
- {"syscalls-dir", 1, 0, 'B'},
-#endif
- {0, 0, 0, 0}
-};
-
-extern int main (int, char **const);
-
-int
-main (int argc, char **const argv)
-{
- int longind;
- int c;
- const char *params = "";
-
- pname = strrchr (argv[0], DIR_SEPARATOR);
-#ifdef DIR_SEPARATOR_2
- {
- char *slash;
-
- slash = strrchr (pname ? pname : argv[0], DIR_SEPARATOR_2);
- if (slash)
- pname = slash;
- }
-#endif
- pname = pname ? pname+1 : argv[0];
-
-#ifdef SIGCHLD
- /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
- receive the signal. A different setting is inheritable */
- signal (SIGCHLD, SIG_DFL);
-#endif
-
- /* Unlock the stdio streams. */
- unlock_std_streams ();
-
- gcc_init_libintl ();
-
- cwd_buffer = getpwd ();
- if (!cwd_buffer)
- {
- notice ("%s: cannot get working directory: %s\n",
- pname, xstrerror(errno));
- return (FATAL_EXIT_CODE);
- }
-
- /* By default, convert the files in the current directory. */
- directory_list = string_list_cons (cwd_buffer, NULL);
-
- while ((c = getopt_long (argc, argv,
-#ifdef UNPROTOIZE
- "c:d:i:knNp:qvVx:",
-#else
- "B:c:Cd:gklnNp:qvVx:",
-#endif
- longopts, &longind)) != EOF)
- {
- if (c == 0) /* Long option. */
- c = longopts[longind].val;
- switch (c)
- {
- case 'p':
- compiler_file_name = optarg;
- break;
- case 'd':
- directory_list
- = string_list_cons (abspath (NULL, optarg), directory_list);
- break;
- case 'x':
- exclude_list = string_list_cons (optarg, exclude_list);
- break;
-
- case 'v':
- case 'V':
- version_flag = 1;
- break;
- case 'q':
- quiet_flag = 1;
- break;
-#if 0
- case 'f':
- force_flag = 1;
- break;
-#endif
- case 'n':
- nochange_flag = 1;
- keep_flag = 1;
- break;
- case 'N':
- nosave_flag = 1;
- break;
- case 'k':
- keep_flag = 1;
- break;
- case 'c':
- params = optarg;
- break;
-#ifdef UNPROTOIZE
- case 'i':
- indent_string = optarg;
- break;
-#else /* !defined (UNPROTOIZE) */
- case 'l':
- local_flag = 1;
- break;
- case 'g':
- global_flag = 1;
- break;
- case 'C':
- cplusplus_flag = 1;
- break;
- case 'B':
- nondefault_syscalls_dir = optarg;
- break;
-#endif /* !defined (UNPROTOIZE) */
- default:
- usage ();
- }
- }
-
- /* Set up compile_params based on -p and -c options. */
- munge_compile_params (params);
-
- n_base_source_files = argc - optind;
-
- /* Now actually make a list of the base source filenames. */
-
- base_source_filenames
- = xmalloc ((n_base_source_files + 1) * sizeof (char *));
- n_base_source_files = 0;
- for (; optind < argc; optind++)
- {
- const char *path = abspath (NULL, argv[optind]);
- int len = strlen (path);
-
- if (path[len-1] == 'c' && path[len-2] == '.')
- base_source_filenames[n_base_source_files++] = path;
- else
- {
- notice ("%s: input file names must have .c suffixes: %s\n",
- pname, shortpath (NULL, path));
- errors++;
- }
- }
-
-#ifndef UNPROTOIZE
- /* We are only interested in the very first identifier token in the
- definition of `va_list', so if there is more junk after that first
- identifier token, delete it from the `varargs_style_indicator'. */
- {
- const char *cp;
-
- for (cp = varargs_style_indicator; ISIDNUM (*cp); cp++)
- continue;
- if (*cp != 0)
- varargs_style_indicator = savestring (varargs_style_indicator,
- cp - varargs_style_indicator);
- }
-#endif /* !defined (UNPROTOIZE) */
-
- if (errors)
- usage ();
- else
- {
- if (version_flag)
- fprintf (stderr, "%s %s%s\n", pname, pkgversion_string,
- version_string);
- do_processing ();
- }
-
- return (errors ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
-}
+++ /dev/null
-/* scan-decls.c - Extracts declarations from cpp output.
- Copyright (C) 1993, 1995, 1997, 1998,
- 1999, 2000, 2003, 2004, 2007 Free Software Foundation, Inc.
-
- 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, 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; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>.
-
- Written by Per Bothner <bothner@cygnus.com>, July 1993. */
-
-#include "bconfig.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "cpplib.h"
-#include "scan.h"
-
-static void skip_to_closing_brace (cpp_reader *);
-static const cpp_token *get_a_token (cpp_reader *);
-
-int brace_nesting = 0;
-
-/* The first extern_C_braces_length elements of extern_C_braces
- indicate the (brace nesting levels of) left braces that were
- prefixed by extern "C". */
-int extern_C_braces_length = 0;
-/* 20 is not enough anymore on Solaris 9. */
-#define MAX_EXTERN_C_BRACES 200
-char extern_C_braces[MAX_EXTERN_C_BRACES];
-#define in_extern_C_brace (extern_C_braces_length>0)
-
-/* True if the function declaration currently being scanned is
- prefixed by extern "C". */
-int current_extern_C = 0;
-
-/* Get a token but skip padding. */
-static const cpp_token *
-get_a_token (cpp_reader *pfile)
-{
- for (;;)
- {
- const cpp_token *result = cpp_get_token (pfile);
- if (result->type != CPP_PADDING)
- return result;
- }
-}
-
-static void
-skip_to_closing_brace (cpp_reader *pfile)
-{
- int nesting = 1;
- for (;;)
- {
- enum cpp_ttype token = get_a_token (pfile)->type;
-
- if (token == CPP_EOF)
- break;
- if (token == CPP_OPEN_BRACE)
- nesting++;
- if (token == CPP_CLOSE_BRACE && --nesting == 0)
- break;
- }
-}
-
-/* This function scans a C source file (actually, the output of cpp),
- reading from FP. It looks for function declarations, and
- external variable declarations.
-
- The following grammar (as well as some extra stuff) is recognized:
-
- declaration:
- (decl-specifier)* declarator ("," declarator)* ";"
- decl-specifier:
- identifier
- keyword
- extern "C"
- declarator:
- (ptr-operator)* dname [ "(" argument-declaration-list ")" ]
- ptr-operator:
- ("*" | "&") ("const" | "volatile")*
- dname:
- identifier
-
-Here dname is the actual name being declared.
-*/
-
-int
-scan_decls (cpp_reader *pfile, int argc ATTRIBUTE_UNUSED,
- char **argv ATTRIBUTE_UNUSED)
-{
- int saw_extern, saw_inline;
- cpp_token prev_id;
- const cpp_token *token;
-
- new_statement:
- token = get_a_token (pfile);
-
- handle_statement:
- current_extern_C = 0;
- saw_extern = 0;
- saw_inline = 0;
- if (token->type == CPP_OPEN_BRACE)
- {
- /* Pop an 'extern "C"' nesting level, if appropriate. */
- if (extern_C_braces_length
- && extern_C_braces[extern_C_braces_length - 1] == brace_nesting)
- extern_C_braces_length--;
- brace_nesting--;
- goto new_statement;
- }
- if (token->type == CPP_OPEN_BRACE)
- {
- brace_nesting++;
- goto new_statement;
- }
-
- if (token->type == CPP_EOF)
- return 0;
-
- if (token->type == CPP_SEMICOLON)
- goto new_statement;
- if (token->type != CPP_NAME)
- goto new_statement;
-
- prev_id.type = CPP_EOF;
- for (;;)
- {
- switch (token->type)
- {
- default:
- goto handle_statement;
- case CPP_MULT:
- case CPP_AND:
- /* skip */
- break;
-
- case CPP_COMMA:
- case CPP_SEMICOLON:
- if (prev_id.type != CPP_EOF && saw_extern)
- {
- recognized_extern (&prev_id);
- }
- if (token->type == CPP_COMMA)
- break;
- /* ... fall through ... */
- case CPP_OPEN_BRACE: case CPP_CLOSE_BRACE:
- goto new_statement;
-
- case CPP_EOF:
- return 0;
-
- case CPP_OPEN_PAREN:
- /* Looks like this is the start of a formal parameter list. */
- if (prev_id.type != CPP_EOF)
- {
- int nesting = 1;
- int have_arg_list = 0;
- const struct line_map *map;
- unsigned int line;
- for (;;)
- {
- token = get_a_token (pfile);
- if (token->type == CPP_OPEN_PAREN)
- nesting++;
- else if (token->type == CPP_CLOSE_PAREN)
- {
- nesting--;
- if (nesting == 0)
- break;
- }
- else if (token->type == CPP_EOF)
- break;
- else if (token->type == CPP_NAME
- || token->type == CPP_ELLIPSIS)
- have_arg_list = 1;
- }
- map = linemap_lookup (&line_table, token->src_loc);
- line = SOURCE_LINE (map, token->src_loc);
- recognized_function (&prev_id, line,
- (saw_inline ? 'I'
- : in_extern_C_brace || current_extern_C
- ? 'F' : 'f'), have_arg_list);
- token = get_a_token (pfile);
- if (token->type == CPP_OPEN_BRACE)
- {
- /* skip body of (normally) inline function */
- skip_to_closing_brace (pfile);
- goto new_statement;
- }
-
- /* skip a possible __attribute__ or throw expression after the
- parameter list */
- while (token->type != CPP_SEMICOLON && token->type != CPP_EOF)
- token = get_a_token (pfile);
- if (token->type == CPP_EOF)
- return 0;
- goto new_statement;
- }
- break;
- case CPP_NAME:
- /* "inline" and "extern" are recognized but skipped */
- if (cpp_ideq (token, "inline"))
- {
- saw_inline = 1;
- }
- else if (cpp_ideq (token, "extern"))
- {
- saw_extern = 1;
- token = get_a_token (pfile);
- if (token->type == CPP_STRING
- && token->val.str.len == 1
- && token->val.str.text[0] == 'C')
- {
- current_extern_C = 1;
- token = get_a_token (pfile);
- if (token->type == CPP_OPEN_BRACE)
- {
- brace_nesting++;
- extern_C_braces[extern_C_braces_length++]
- = brace_nesting;
- if (extern_C_braces_length >= MAX_EXTERN_C_BRACES)
- {
- fprintf (stderr,
- "Internal error: out-of-bounds index\n");
- exit (FATAL_EXIT_CODE);
- }
- goto new_statement;
- }
- }
- else
- continue;
- break;
- }
- /* This may be the name of a variable or function. */
- prev_id = *token;
- break;
- }
- token = get_a_token (pfile);
- }
-}
+++ /dev/null
-#! /bin/sh
-# Deduce values of standard ANSI and POSIX types (e.g. size_t, pid_t).
-# Emits macros definitions for these, and some other types.
-# Intended to be used to massage the sys-protos.h file.
-# Expects one arg, which is the GCC source directory.
-
-CC=${CC-"./xgcc -B$1/"}
-CPP=${CPP-`echo ${CC} -E -I"$1/"`}
-SED=sed
-
-# Generate definitions for the standard types (such as mode_t)
-# compatible with those in the standard C header files.
-# It works by a dummy program through the C pre-processor, and then
-# using sed to search for typedefs in the output.
-
-cat >st-dummy.c <<!EOF!
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <time.h>
-#include <signal.h>
-#ifdef size_t
-typedef size_t Xsize_t;
-#elif defined(__SIZE_TYPE__)
-typedef __SIZE_TYPE__ Xsize_t;
-#endif
-#ifdef va_list
-typedef va_list XXXva_list;
-#endif
-!EOF!
-
-if ${CPP} st-dummy.c >TMP ; then true
-else
- echo "scan-types: could not invoke ${CPP} on st-dummy.c" 1>&2 ; exit 1
-fi
-tr ' ' ' ' <TMP >st-dummy.out
-
-for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t size_t ssize_t time_t uid_t va_list int32_t uint_32_t ; do
- IMPORTED=`eval 'echo $'"$TYPE"`
- if [ -n "${IMPORTED}" ] ; then
- eval "$TYPE='$IMPORTED"
- else
- # Search st-dummy.out for a typedef for $TYPE, and write it out
- # to TMP in #define syntax.
- rm -f TMP
- ${SED} -n -e "s|.*typedef *\(.*\) X*$TYPE *;.*|\1|w TMP" <st-dummy.out>/dev/null
- # Now select the first definition.
- if [ -s TMP ]; then
- # VALUE is now the typedef'd definition of $TYPE.
- eval "VALUE='`${SED} -e 's| *$||' -e '2,$d' <TMP`'"
- # Unless VALUE contains a blank, look for a typedef for it
- # in turn (this could be a loop, but that would be over-kill).
- # Ensure $VALUE is double quoted to protect cases where it
- # contains an asterisk and would cause filename expansion.
- # E.g. when va_list is "char *".
- if echo "$VALUE" | grep " " >/dev/null ; then true
- else
- rm -f TMP
- ${SED} -n -e "s|.*typedef[ ][ ]*\(.*[^a-zA-Z0-9_]\)${VALUE}[ ]*;.*|\1|w TMP" <st-dummy.out>/dev/null
- if [ -s TMP ]; then
- eval "VALUE='`${SED} -e '2,$d' -e 's|[ ]*$||' <TMP`'"
- fi
- fi
- eval "$TYPE='$VALUE'"
- fi
- fi
-done
-
-cat <<!EOF!
-#define ${macro_prefix}clock_t ${clock_t-int /* default */}
-#define ${macro_prefix}dev_t ${dev_t-int /* default */}
-#define ${macro_prefix}fpos_t ${fpos_t-long /* default */}
-#define ${macro_prefix}gid_t ${gid_t-int /* default */}
-#define ${macro_prefix}ino_t ${ino_t-int /* default */}
-#define ${macro_prefix}mode_t ${mode_t-int /* default */}
-#define ${macro_prefix}nlink_t ${nlink_t-int /* default */}
-#define ${macro_prefix}off_t ${off_t-long /* default */}
-#define ${macro_prefix}pid_t ${pid_t-int /* default */}
-#define ${macro_prefix}ptrdiff_t __PTRDIFF_TYPE__
-#define ${macro_prefix}size_t __SIZE_TYPE__
-#define ${macro_prefix}time_t ${time_t-int /* default */}
-#define ${macro_prefix}uid_t ${uid_t-int /* default */}
-#define ${macro_prefix}wchar_t __WCHAR_TYPE__
-#define ${macro_prefix}int32_t ${int32_t-int /* default */}
-#define ${macro_prefix}uint32_t ${uint32_t-unsigned int /* default */}
-!EOF!
-
-# (wait_arg_t*) should be (int*), according to Posix, but
-# BSD traditionally used (union wait*). Use (void*) to allow either usage.
-echo "#define ${macro_prefix}wait_arg_t void"
-
-# ssize_t is the signed version of size_t
-if [ -n "${ssize_t}" ] ; then
- echo "#define ${macro_prefix}ssize_t ${ssize_t}"
-elif [ -z "${size_t}" ] ; then
- echo "#define ${macro_prefix}ssize_t long"
-else
- # Remove "unsigned" from ${size_t} to get ${ssize_t}.
- tmp="`echo ${size_t} | ${SED} -e 's|unsigned||g' -e 's| | |g'`"
- if [ -z "$tmp" ] ; then
- tmp=int
- else
- # check $tmp doesn't conflict with <unistd.h>
- echo "#include <unistd.h>
- extern $tmp read();" >st-dummy.c
- ${CC} -c st-dummy.c >/dev/null 2>&1 || tmp=int
- fi
- echo "#define ${macro_prefix}ssize_t $tmp /* default */"
-fi
-
-# va_list can cause problems (e.g. some systems have va_list as a struct).
-# Check to see if ${va_list-char*} really is compatible with stdarg.h.
-cat >st-dummy.c <<!EOF!
-#define X_va_list ${va_list-char* /* default */}
-extern long foo(X_va_list ap); /* Check that X_va_list compiles on its own */
-#include <stdarg.h>
-long foo(X_va_list ap) { return va_arg(ap, long); }
-long bar(int i, ...)
-{ va_list ap; long j; va_start(ap, i); j = foo(ap); va_end(ap); return j; }
-!EOF!
-if ${CC} -c st-dummy.c >/dev/null 2>&1 ; then
- # Ok: We have something that works.
- echo "#define ${macro_prefix}va_list ${va_list-char* /* default */}"
-else
- # No, it breaks. Indicate that <stdarg.h> must be included.
- echo "#define ${macro_prefix}NEED_STDARG_H
-#define ${macro_prefix}va_list va_list"
-fi
-
-# stuff needed for curses.h
-
-# This isn't correct for SVR4 (for example). However, we only
-# use this when adding a missing prototype, so it shouldn't matter.
-echo "#define chtype int"
-# sys-protos.h uses non-standard names (due to the CHTYPE argument problem).
-echo "#define box32 box"
-echo "#define initscr32 initscr"
-echo "#define w32addch waddch"
-echo "#define w32insch winsch"
-
-rm -f st-dummy.c st-dummy.o TMP st-dummy.out
+++ /dev/null
-/* Utility functions for scan-decls and fix-header programs.
- Copyright (C) 1993, 1994, 1998, 2002, 2003, 2007, 2008
- Free Software Foundation, Inc.
-
- 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, 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; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-#include "bconfig.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "scan.h"
-
-int lineno = 1;
-int source_lineno = 1;
-sstring source_filename;
-
-void
-make_sstring_space (sstring *str, int count)
-{
- int cur_pos = str->ptr - str->base;
- int cur_size = str->limit - str->base;
- int new_size = cur_pos + count + 100;
-
- if (new_size <= cur_size)
- return;
-
- str->base = (char *) xrealloc (str->base, new_size);
- str->ptr = str->base + cur_size;
- str->limit = str->base + new_size;
-}
-
-void
-sstring_append (sstring *dst, sstring *src)
-{
- char *d, *s;
- int count = SSTRING_LENGTH (src);
-
- MAKE_SSTRING_SPACE (dst, count + 1);
- d = dst->ptr;
- s = src->base;
- while (--count >= 0) *d++ = *s++;
- dst->ptr = d;
- *d = 0;
-}
-
-int
-scan_ident (FILE *fp, sstring *s, int c)
-{
- s->ptr = s->base;
- if (ISIDST (c))
- {
- for (;;)
- {
- SSTRING_PUT (s, c);
- c = getc (fp);
- if (c == EOF || ! ISIDNUM (c))
- break;
- }
- }
- MAKE_SSTRING_SPACE (s, 1);
- *s->ptr = 0;
- return c;
-}
-
-int
-scan_string (FILE *fp, sstring *s, int init)
-{
- int c;
-
- for (;;)
- {
- c = getc (fp);
- if (c == EOF || c == '\n')
- break;
- if (c == init)
- {
- c = getc (fp);
- break;
- }
- if (c == '\\')
- {
- c = getc (fp);
- if (c == EOF)
- break;
- if (c == '\n')
- continue;
- }
- SSTRING_PUT (s, c);
- }
- MAKE_SSTRING_SPACE (s, 1);
- *s->ptr = 0;
- return c;
-}
-
-/* Skip horizontal white spaces (spaces, tabs, and C-style comments). */
-
-int
-skip_spaces (FILE *fp, int c)
-{
- for (;;)
- {
- if (c == ' ' || c == '\t')
- c = getc (fp);
- else if (c == '/')
- {
- c = getc (fp);
- if (c != '*')
- {
- ungetc (c, fp);
- return '/';
- }
- c = getc (fp);
- for (;;)
- {
- if (c == EOF)
- return EOF;
- else if (c != '*')
- {
- if (c == '\n')
- source_lineno++, lineno++;
- c = getc (fp);
- }
- else if ((c = getc (fp)) == '/')
- return getc (fp);
- }
- }
- else
- break;
- }
- return c;
-}
-
-int
-read_upto (FILE *fp, sstring *str, int delim)
-{
- int ch;
-
- for (;;)
- {
- ch = getc (fp);
- if (ch == EOF || ch == delim)
- break;
- SSTRING_PUT (str, ch);
- }
- MAKE_SSTRING_SPACE (str, 1);
- *str->ptr = 0;
- return ch;
-}
-
-int
-get_token (FILE *fp, sstring *s)
-{
- int c;
-
- s->ptr = s->base;
- retry:
- c = ' ';
- c = skip_spaces (fp, c);
- if (c == '\n')
- {
- source_lineno++;
- lineno++;
- goto retry;
- }
- if (c == '#')
- {
- c = get_token (fp, s);
- if (c == INT_TOKEN)
- {
- source_lineno = atoi (s->base) - 1; /* '\n' will add 1 */
- get_token (fp, &source_filename);
- }
- for (;;)
- {
- c = getc (fp);
- if (c == EOF)
- return EOF;
- if (c == '\n')
- {
- source_lineno++;
- lineno++;
- goto retry;
- }
- }
- }
- if (c == EOF)
- return EOF;
- if (ISDIGIT (c))
- {
- do
- {
- SSTRING_PUT (s, c);
- c = getc (fp);
- } while (c != EOF && ISDIGIT (c));
- ungetc (c, fp);
- c = INT_TOKEN;
- goto done;
- }
- if (ISIDST (c))
- {
- c = scan_ident (fp, s, c);
- ungetc (c, fp);
- return IDENTIFIER_TOKEN;
- }
- if (c == '\'' || c == '"')
- {
- c = scan_string (fp, s, c);
- ungetc (c, fp);
- return c == '\'' ? CHAR_TOKEN : STRING_TOKEN;
- }
- SSTRING_PUT (s, c);
- done:
- MAKE_SSTRING_SPACE (s, 1);
- *s->ptr = 0;
- return c;
-}
-
-unsigned int
-hashstr (const char *str, unsigned int len)
-{
- unsigned int n = len;
- unsigned int r = 0;
- const unsigned char *s = (const unsigned char *) str;
-
- do
- r = r * 67 + (*s++ - 113);
- while (--n);
- return r + len;
-}
+++ /dev/null
-/* scan.h - Utility declarations for scan-decls and fix-header programs.
- Copyright (C) 1993, 1998, 1999, 2003, 2004, 2007, 2008 Free Software
- Foundation, Inc.
-
- 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, 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; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-#include <stdio.h>
-
-typedef struct sstring
-{
- char *base;
- char *ptr;
- char *limit;
-} sstring;
-
-#define INIT_SSTRING(STR) ((STR)->base = 0, (STR)->ptr = 0, (STR)->limit = 0)
-#define FREE_SSTRING(STR) do { if ((STR)->base) free (STR)->base; } while(0)
-#define SSTRING_PUT(STR, C) do {\
- if ((STR)->limit <= (STR)->ptr) make_sstring_space (STR, 1); \
- *(STR)->ptr++ = (C); } while (0)
-#define SSTRING_LENGTH(STR) ((STR)->ptr - (STR)->base)
-#define MAKE_SSTRING_SPACE(STR, COUNT) \
- if ((STR)->limit - (STR)->ptr < (COUNT)) make_sstring_space (STR, COUNT);
-
-struct partial_proto;
-struct fn_decl
-{
- const char *fname;
- const char *rtype;
- const char *params;
- struct partial_proto *partial;
-};
-
-struct cpp_token;
-
-extern void sstring_append (sstring *, sstring *);
-extern void make_sstring_space (sstring *, int);
-extern int skip_spaces (FILE *, int);
-extern int scan_ident (FILE *, sstring *, int);
-extern int scan_string (FILE *, sstring *, int);
-extern int read_upto (FILE *, sstring *, int);
-extern unsigned long hash (const char *);
-extern void recognized_function (const struct cpp_token *,
- unsigned int, int, int);
-extern void recognized_extern (const struct cpp_token *);
-extern unsigned int hashstr (const char *, unsigned int);
-
-extern int scan_decls (struct cpp_reader *, int, char **);
-
-/* get_token is a simple C lexer. */
-#define IDENTIFIER_TOKEN 300
-#define CHAR_TOKEN 301
-#define STRING_TOKEN 302
-#define INT_TOKEN 303
-extern int get_token (FILE *, sstring *);
-
-/* Current file and line number, taking #-directives into account */
-extern int source_lineno;
-extern sstring source_filename;
-/* Current physical line number */
-extern int lineno;
-
-extern struct line_maps line_table;
+++ /dev/null
-#!/bin/sh
-# Sort the sys-protos.h file in its usual order.
-# Invoke as `sort-protos sys-protos.h'.
-
-input=$1
-
-sed 's/\(.*[ \*]\)\([a-zA-Z0-9_][a-zA-Z0-9_]*\)[ ]*\(([^\*].*\)$/\2%\1%\3/' $input | sort -u | awk -F% '{printf "%-30.30s%s%s\n", $2, $1, $3}' > tmp.$input
-
-mv -f tmp.$input $input
+++ /dev/null
-extern int TLappend(/* ??? */);
-extern int TLassign(/* ??? */);
-extern int TLclose(/* ??? */);
-extern int TLdelete(/* ??? */);
-extern int TLfreeentry(/* ??? */);
-extern ENTRY TLgetentry(/* ??? */);
-extern unsigned char * TLgetfield(/* ??? */);
-extern int TLopen(/* ??? */);
-extern int TLread(/* ??? */);
-extern int TLsearch1(/* ??? */);
-extern int TLsubst(/* ??? */);
-extern int TLsync(/* ??? */);
-extern int TLwrite(/* ??? */);
-extern int __acancel(int, const long int *, int);
-extern int __aread(int, int, char *, uint, ecb_t *);
-extern void __assert(const char *, const char *, int);
-extern int __asyncio(int, aioop_t *, int);
-extern int __awrite(int, int, char *, uint, ecb_t *);
-extern int __evcntl(evver_t, evcntlcmds_t, long int, long int);
-extern int __evexit(evver_t, idtype_t, id_t, const ecb_t *);
-extern int __evexitset(evver_t, const procset_t *, hostid_t, const ecb_t *);
-extern int __evpoll(evver_t, evpollcmds_t, event_t *, int, const hrtime_t *);
-extern int __evpollmore(evver_t, event_t *, int);
-extern int __evpost(evver_t, event_t *, int, int);
-extern int __evqcntl(evver_t, int, evqcntlcmds_t, long int);
-extern int __evsig(evver_t, const sigset_t *, const ecb_t *, evsiginfo_t *, int);
-extern int __evtrap(evver_t, evpollcmds_t, event_t *, int, long int, void (*) (event_t *, int, long int, evcontext_t *), const evta_t *);
-extern int __evtrapcancel(evver_t, long int *, int);
-extern int __filbuf(FILE *);
-extern int __flsbuf(int, FILE *);
-extern major_t __major(int, dev_t);
-extern dev_t __makedev(int, major_t, minor_t);
-extern minor_t __minor(int, dev_t);
-extern long int __priocntl(/* ??? */);
-extern long int __priocntlset(/* ??? */);
-extern void _exit(int);
-extern int _filbuf(FILE *);
-extern int _flsbuf(unsigned int, FILE *);
-extern int _fxstat(int, int, struct stat *);
-extern u_long _getlong(/* ??? */);
-extern u_short _getshort(/* ??? */);
-extern int _getsyx(int *, int *);
-extern int _longjmp(jmp_buf, int);
-extern int _lxstat(int, const char *, struct stat *);
-extern int _meta(int);
-extern struct nd_hostservlist _netdir_getbyaddr(struct netconfig *, struct netbuf *);
-extern struct nd_addrlist * _netdir_getbyname(struct netconfig *, struct nd_hostserv *);
-extern int _overlay(WINDOW *, WINDOW *, int);
-extern int _ring(int);
-extern int _rpc_dtbsize(/* ??? */);
-extern int _rpc_endconf(/* ??? */);
-extern u_int _rpc_get_a_size(/* ??? */);
-extern u_int _rpc_get_t_size(/* ??? */);
-extern struct netconfig * _rpc_getconf(/* ??? */);
-extern struct netconfig * _rpc_getconfip(/* ??? */);
-extern char * _rpc_gethostname(/* ??? */);
-extern int _rpc_setconf(/* ??? */);
-extern void _s_aligned_copy(/* ??? */);
-extern struct _si_user * _s_checkfd(/* ??? */);
-extern void _s_close(/* ??? */);
-extern int _s_do_ioctl(/* ??? */);
-extern int _s_getfamily(/* ??? */);
-extern int _s_getudata(/* ??? */);
-extern int _s_is_ok(/* ??? */);
-extern struct netconfig * _s_match(/* ??? */);
-extern int _s_max(/* ??? */);
-extern int _s_min(/* ??? */);
-extern struct _si_user * _s_open(/* ??? */);
-extern int _s_soreceive(/* ??? */);
-extern int _s_sosend(/* ??? */);
-extern int _s_uxpathlen(/* ??? */);
-extern int _setecho(int);
-extern int _setjmp(jmp_buf);
-extern int _setnonl(int);
-extern void _setqiflush(int);
-extern char * _taddr2uaddr(struct netconfig *, struct netbuf *);
-extern int _tolower(int);
-extern int _toupper(int);
-extern struct netbuf * _uaddr2taddr(struct netconfig *, char *);
-extern bool _xdr_yprequest(/* ??? */);
-extern bool _xdr_ypresponse(/* ??? */);
-extern int _xftw(int, const char *, int (*) (const char *, const struct stat *, int), int);
-extern int _xmknod(int, const char *, mode_t, dev_t);
-extern int _xstat(int, const char *, struct stat *);
-extern int _yp_dobind(/* ??? */);
-extern long int a64l(const char *);
-extern char * aatos(char *, struct address *, int);
-extern void abort(void);
-extern int abs(int);
-extern int access(const char *, int);
-extern int acct(const char *);
-extern double acos(double);
-extern float acosf(float);
-extern double acosh(double);
-extern int addexportent(FILE *, char *, char *);
-extern int addseverity(int, const char *);
-extern int adjtime(struct timeval *, struct timeval *);
-extern int advance(const char *, const char *);
-extern unsigned int alarm(unsigned int);
-extern void * alloca(size_t);
-extern int and(void);
-extern int ascftime(char *, const char *, const struct tm *);
-extern char * asctime(const struct tm *);
-extern double asin(double);
-extern float asinf(float);
-extern double asinh(double);
-extern struct address * astoa(char *, struct address *);
-extern double atan(double);
-extern double atan2(double, double);
-extern float atan2f(float, float);
-extern float atanf(float);
-extern double atanh(double);
-extern int atexit(void (*) (void));
-extern double atof(const char *);
-extern int atoi(const char *);
-extern long int atol(const char *);
-extern char * atos(char *, struct netbuf *, int);
-extern void auth_destroy(AUTH *);
-extern AUTH * authdes_create(/* ??? */);
-extern void authdes_getcred(struct authdes_cred *, short *, short *, short *, int *);
-extern AUTH * authdes_seccreate(/* ??? */);
-extern AUTH * authnone_create(void);
-extern AUTH * authsys_create(char *, int, int, int, int *);
-extern AUTH * authsys_create_default(void);
-extern AUTH * authunix_create(char *, int, int, int, int *);
-extern AUTH * authunix_create_default(void);
-extern char * basename(char *);
-extern int baudrate(void);
-extern int bcmp(const void *, const void *, size_t);
-extern void bcopy(const void *, void *, size_t);
-extern int beep(void);
-extern void (* berk_signal(int, void (*) (int, ...))) (int, ...);
-extern char * bgets(char *, size_t, FILE *, char *);
-extern int bottom_panel(PANEL *);
-extern int box32(WINDOW *, chtype, chtype);
-extern int brk(void *);
-extern void * bsearch(const void *, const void *, size_t, size_t, int (*) (const void *, const void *));
-extern size_t bufsplit(char *, size_t, char *);
-extern void bzero(void *, size_t);
-extern long int calchash(/* ??? */);
-extern void * calloc(size_t, size_t);
-extern void callrpc(char *, unsigned long, unsigned long, unsigned long, xdrproc_t, char *, xdrproc_t, char *);
-extern bool can_change_color(void);
-extern int catclose(nl_catd);
-extern char * catgets(nl_catd, int, int, char *);
-extern nl_catd catopen(const char *, int);
-extern int cbreak(void);
-extern double cbrt(double);
-extern double ceil(double);
-extern float ceilf(float);
-extern speed_t cfgetispeed(const struct termios *);
-extern speed_t cfgetospeed(const struct termios *);
-extern void cfree(void *);
-extern int cfsetispeed(struct termios *, speed_t);
-extern int cfsetospeed(struct termios *, speed_t);
-extern int cftime(char *, char *, const time_t *);
-extern int chdir(const char *);
-extern int chmod(const char *, mode_t);
-extern int chown(const char *, uid_t, gid_t);
-extern int chroot(const char *);
-extern void clean_GEN_rd(/* ??? */);
-extern void cleanup(/* ??? */);
-extern void clearerr(FILE *);
-extern int clearok(WINDOW *, int);
-extern enum clnt_stat clnt_broadcast(unsigned long, unsigned long, unsigned long, xdrproc_t, char *, xdrproc_t, char *, resultproc_t);
-extern enum clnt_stat clnt_call(CLIENT *, unsigned long, xdrproc_t, char *, xdrproc_t, char *, struct timeval);
-extern bool_t clnt_control(CLIENT *, int, char *);
-extern CLIENT * clnt_create(char *, unsigned long, unsigned long, char *);
-extern void clnt_destroy(CLIENT *);
-extern int clnt_freeres(CLIENT *, xdrproc_t, char *);
-extern void clnt_geterr(CLIENT *, struct rpc_err *);
-extern void clnt_pcreateerror(char *);
-extern void clnt_perrno(enum clnt_stat);
-extern void clnt_perror(CLIENT *, char *);
-extern char * clnt_spcreateerror(char *);
-extern char * clnt_sperrno(enum clnt_stat);
-extern char * clnt_sperror(CLIENT *, char *);
-extern CLIENT * clnt_tli_create(/* ??? */);
-extern CLIENT * clnt_tp_create(/* ??? */);
-extern CLIENT * clnt_vc_create(/* ??? */);
-extern CLIENT * clntraw_create(unsigned long, unsigned long);
-extern CLIENT * clnttcp_create(struct sockaddr_in *, unsigned long, unsigned long, int *, unsigned int, unsigned int *);
-extern CLIENT * clntudp_bufcreate(struct sockaddr_in *, unsigned long, unsigned long, struct timeval, int *, unsigned int, unsigned int);
-extern CLIENT * clntudp_create(struct sockaddr_in *, unsigned long, unsigned long, struct timeval, int *);
-extern clock_t clock(void);
-extern int close(int);
-extern int closedir(DIR *);
-extern int color_content(int, short int *, short int *, short int *);
-extern char * compile(const char *, char *, char *);
-extern char * copylist(const char *, off_t *);
-extern double copysign(double, double);
-extern int copywin(WINDOW *, WINDOW *, int, int, int, int, int, int, int);
-extern double cos(double);
-extern float cosf(float);
-extern double cosh(double);
-extern float coshf(float);
-extern struct rd_user * cr_rduser(/* ??? */);
-extern int creat(const char *, mode_t);
-extern int crmode(void);
-extern char * crypt(const char *, const char *);
-extern int crypt_close(int *);
-extern char * ctermid(char *);
-extern char * ctime(const time_t *);
-extern FIELD * current_field(FORM *);
-extern ITEM * current_item(MENU *);
-extern int curs_set(int);
-extern void curserr(void);
-extern char * cuserid(char *);
-extern int data_ahead(FORM *);
-extern int data_behind(FORM *);
-extern void dbmclose(void);
-extern void dbminit(const char *);
-extern int def_prog_mode(void);
-extern int def_shell_mode(void);
-extern char * defread(/* ??? */);
-extern int del_panel(PANEL *);
-extern void del_rduser(/* ??? */);
-extern void delay(long int);
-extern int delay_output(int);
-extern void delete(datum);
-extern void delscreen(SCREEN *);
-extern int delterm(TERMINAL *);
-extern int delwin(WINDOW *);
-extern WINDOW * derwin(WINDOW *, int, int, int, int);
-extern char * des_crypt(const char *, const char *);
-extern void des_encrypt(char *, int);
-extern void des_setkey(const char *);
-extern char * devattr(/* ??? */);
-extern int devfree(/* ??? */);
-extern char ** devreserv(/* ??? */);
-extern int dial(CALL);
-extern double difftime(time_t, time_t);
-extern char * dirname(char *);
-extern div_t div(int, int);
-extern int dlclose(void *);
-extern char * dlerror(void);
-extern void * dlopen(char *, int);
-extern void * dlsym(void *, char *);
-extern void dma_access(u_char, u_int, u_int, u_char, u_char);
-extern int doupdate(void);
-extern int drainio(int);
-extern double drand48(void);
-extern double drem(double, double);
-extern int drv_getevtoken(/* ??? */);
-extern void drv_relevtoken(/* ??? */);
-extern int dup(int);
-extern int dup2(int, int);
-extern FIELD * dup_field(FIELD *, int, int);
-extern WINDOW * dupwin(WINDOW *);
-extern int dynamic_field_info(FIELD *, int *, int *, int *);
-extern int dysize(int);
-extern int eaccess(const char *, int);
-extern int echo(void);
-extern char * ecvt(double, int, int *, int *);
-extern size_t elf32_fsize(Elf_Type, size_t, unsigned int);
-extern Elf32_Ehdr * elf32_getehdr(Elf *);
-extern Elf32_Phdr * elf32_getphdr(Elf *);
-extern Elf32_Shdr * elf32_getshdr(Elf_Scn *);
-extern Elf32_Ehdr * elf32_newehdr(Elf *);
-extern Elf32_Phdr * elf32_newphdr(Elf *, size_t);
-extern Elf_Data * elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned int);
-extern Elf_Data * elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned int);
-extern Elf * elf_begin(int, Elf_Cmd, Elf *);
-extern int elf_cntl(Elf *, Elf_Cmd);
-extern int elf_end(Elf *);
-extern const char * elf_errmsg(int);
-extern int elf_errno(void);
-extern void elf_fill(int);
-extern unsigned int elf_flagdata(Elf_Data *, Elf_Cmd, unsigned int);
-extern unsigned int elf_flagehdr(Elf *, Elf_Cmd, unsigned int);
-extern unsigned int elf_flagelf(Elf *, Elf_Cmd, unsigned int);
-extern unsigned int elf_flagphdr(Elf *, Elf_Cmd, unsigned int);
-extern unsigned int elf_flagscn(Elf_Scn *, Elf_Cmd, unsigned int);
-extern unsigned int elf_flagshdr(Elf_Scn *, Elf_Cmd, unsigned int);
-extern Elf_Arhdr * elf_getarhdr(Elf *);
-extern Elf_Arsym * elf_getarsym(Elf *, size_t *);
-extern off_t elf_getbase(Elf *);
-extern Elf_Data * elf_getdata(Elf_Scn *, Elf_Data *);
-extern char * elf_getident(Elf *, size_t *);
-extern Elf_Scn * elf_getscn(Elf *, size_t);
-extern long unsigned int elf_hash(const char *);
-extern Elf_Kind elf_kind(Elf *);
-extern size_t elf_ndxscn(Elf_Scn *);
-extern Elf_Data * elf_newdata(Elf_Scn *);
-extern Elf_Scn * elf_newscn(Elf *);
-extern Elf_Cmd elf_next(Elf *);
-extern Elf_Scn * elf_nextscn(Elf *, Elf_Scn *);
-extern size_t elf_rand(Elf *, size_t);
-extern Elf_Data * elf_rawdata(Elf_Scn *, Elf_Data *);
-extern char * elf_rawfile(Elf *, size_t *);
-extern char * elf_strptr(Elf *, size_t, size_t);
-extern off_t elf_update(Elf *, Elf_Cmd);
-extern unsigned int elf_version(unsigned int);
-extern void encrypt(char *, int);
-extern void endgrent(void);
-extern int endnetconfig(void *);
-extern int endnetpath(void *);
-extern void endpwent(void);
-extern void endrpcent(void);
-extern void endspent(void);
-extern void endutent(void);
-extern void endutxent(void);
-extern int endwin(void);
-extern double erand(short *);
-extern double erand48(short unsigned int *);
-extern char erasechar(void);
-extern double erf(double);
-extern double erfc(double);
-extern int execl(const char *, const char *, ...);
-extern int execle(const char *, const char *, ...);
-extern int execlp(const char *, const char *, ...);
-extern int exect(const char *, const char **, char **);
-extern int execv(const char *, char *const *);
-extern int execve(const char *, char *const *, char *const *);
-extern int execvp(const char *, char *const *);
-extern void exit(int);
-extern double exp(double);
-extern float expf(float);
-extern double fabs(double);
-extern float fabsf(float);
-extern int fattach(int, const char *);
-extern int fchdir(int);
-extern int fchmod(int, mode_t);
-extern int fchown(int, uid_t, gid_t);
-extern int fclose(FILE *);
-extern int fcntl(int, int, ...);
-extern char * fcvt(double, int, int *, int *);
-extern int fdetach(const char *);
-extern FILE * fdopen(int, const char *);
-extern int feof(FILE *);
-extern int ferror(FILE *);
-extern datum fetch(datum);
-extern int fflush(FILE *);
-extern int ffs(int);
-extern int fgetc(FILE *);
-extern struct group * fgetgrent(FILE *);
-extern int fgetpos(FILE *, fpos_t *);
-extern struct passwd * fgetpwent(FILE *);
-extern char * fgets(char *, int, FILE *);
-extern struct spwd * fgetspent(FILE *);
-extern char * field_arg(FIELD *);
-extern chtype field_back(FIELD *);
-extern char * field_buffer(FIELD *, int);
-extern int field_count(FORM *);
-extern chtype field_fore(FIELD *);
-extern int field_index(FIELD *);
-extern int field_info(FIELD *, int *, int *, int *, int *, int *, int *);
-extern PTF_void field_init(FORM *);
-extern int field_just(FIELD *);
-extern OPTIONS field_opts(FIELD *);
-extern int field_opts_off(FIELD *, OPTIONS);
-extern int field_opts_on(FIELD *, OPTIONS);
-extern int field_pad(FIELD *);
-extern int field_status(FIELD *);
-extern PTF_void field_term(FORM *);
-extern FIELDTYPE * field_type(FIELD *);
-extern char * field_userptr(FIELD *);
-extern int fileno(FILE *);
-extern int filter(void);
-extern int finite(double);
-extern datum firsthash(/* ??? */);
-extern datum firstkey(void);
-extern int flash(void);
-extern int flock(int, int);
-extern double floor(double);
-extern float floorf(float);
-extern int flushinp(void);
-extern double fmod(double, double);
-extern float fmodf(float, float);
-extern int fmtmsg(long int, const char *, int, const char *, const char *, const char *);
-extern FILE * fopen(const char *, const char *);
-extern pid_t fork(void);
-extern int form_driver(FORM *, int);
-extern FIELD ** form_fields(FORM *);
-extern PTF_void form_init(FORM *);
-extern OPTIONS form_opts(FORM *);
-extern int form_opts_off(FORM *, OPTIONS);
-extern int form_opts_on(FORM *, OPTIONS);
-extern int form_page(FORM *);
-extern WINDOW * form_sub(FORM *);
-extern PTF_void form_term(FORM *);
-extern char * form_userptr(FORM *);
-extern WINDOW * form_win(FORM *);
-extern long int fpathconf(int, int);
-extern fpclass_t fpclass(double);
-extern int fpgetmask(void);
-extern fp_rnd fpgetround(void);
-extern int fpgetsticky(void);
-extern int fprintf(FILE *, const char *, ...);
-extern int fpsetmask(int);
-extern fp_rnd fpsetround(fp_rnd);
-extern int fpsetsticky(int);
-extern int fputc(int, FILE *);
-extern int fputs(const char *, FILE *);
-extern size_t fread(void *, size_t, size_t, FILE *);
-extern void free(void *);
-extern int free_field(FIELD *);
-extern int free_fieldtype(FIELDTYPE *);
-extern int free_form(FORM *);
-extern int free_item(ITEM *);
-extern int free_menu(MENU *);
-extern void freenetconfigent(struct netconfig *);
-extern FILE * freopen(const char *, const char *, FILE *);
-extern double frexp(double, int *);
-extern int fscanf(FILE *, const char *, ...);
-extern int fseek(FILE *, long int, int);
-extern int fsetpos(FILE *, const fpos_t *);
-extern int fstat(int, struct stat *);
-extern int fstatfs(int, struct statfs *, int, int);
-extern int fstatvfs(int, struct statvfs *);
-extern int fsync(int);
-extern long int ftell(FILE *);
-extern key_t ftok(const char *, int);
-extern int ftruncate(int, off_t);
-extern int ftw(const char *, int (*) (const char *, const struct stat *, int), int);
-extern size_t fwrite(const void *, size_t, size_t, FILE *);
-extern double gamma(double);
-extern char * gcvt(double, int, char *);
-extern int get_error(/* ??? */);
-extern chtype getattrs(WINDOW *);
-extern int getbegx(WINDOW *);
-extern int getbegy(WINDOW *);
-extern chtype getbkgd(WINDOW *);
-extern long unsigned int getbmap(void);
-extern int getc(FILE *);
-extern char * getcap(/* ??? */);
-extern int getchar(void);
-extern int getcontext(ucontext_t *);
-extern int getcurx(WINDOW *);
-extern int getcury(WINDOW *);
-extern char * getcwd(char *, size_t);
-extern struct tm * getdate(const char *);
-extern int getdents(int, struct dirent *, unsigned int);
-extern char ** getdev(/* ??? */);
-extern char ** getdgrp(/* ??? */);
-extern int getdomainname(char *, int);
-extern int getdtablesize(void);
-extern gid_t getegid(void);
-extern char * getenv(const char *);
-extern struct errhdr * geterec(/* ??? */);
-extern struct errhdr * geteslot(/* ??? */);
-extern uid_t geteuid(void);
-extern gid_t getgid(void);
-extern struct group * getgrent(void);
-extern struct group * getgrgid(gid_t);
-extern struct group * getgrnam(const char *);
-extern int getgroups(int, TARGET_GETGROUPS_T []);
-extern struct hostent * gethostbyaddr(/* ??? */);
-extern struct hostent * gethostbyname(/* ??? */);
-extern struct hostent * gethostent(/* ??? */);
-#ifdef __alpha__
-extern int gethostid(void);
-#else
-extern long gethostid(void);
-#endif
-extern int gethostname(char *, size_t);
-extern int getitimer(int, struct itimerval *);
-extern char * getlogin(void);
-extern int getmaxx(WINDOW *);
-extern int getmaxy(WINDOW *);
-extern int getmntany(FILE *, struct mnttab *, struct mnttab *);
-extern int getmntent(/* ??? */);
-extern long unsigned int getmouse(void);
-extern int getmsg(int, struct strbuf *, struct strbuf *, int *);
-extern struct netent * getnetbyaddr(/* ??? */);
-extern struct netent * getnetbyname(/* ??? */);
-extern struct netconfig * getnetconfig(void *);
-extern struct netconfig * getnetconfigent(char *);
-extern struct netent * getnetent(/* ??? */);
-extern struct netconfig * getnetpath(void *);
-extern int getopt(int, char *const *, const char *);
-extern int getpagesize(void);
-extern int getparx(WINDOW *);
-extern int getpary(WINDOW *);
-extern char * getpass(const char *);
-extern pid_t getpgid(pid_t);
-extern pid_t getpgrp(void);
-extern pid_t getpgrp2(pid_t);
-extern pid_t getpid(void);
-extern int getpmsg(int, struct strbuf *, struct strbuf *, int *, int *);
-extern pid_t getppid(void);
-extern int getpriority(int, int);
-extern struct protoent * getprotobyname(/* ??? */);
-extern struct protoent * getprotobynumber(/* ??? */);
-extern struct protoent * getprotoent(/* ??? */);
-extern int getpw(int, char *);
-extern struct passwd * getpwent(void);
-extern struct passwd * getpwnam(const char *);
-extern struct passwd * getpwuid(uid_t);
-extern int getrlimit(int, struct rlimit *);
-extern int getrnge(char *);
-extern struct rpcent * getrpcbyname(const char *);
-extern struct rpcent * getrpcbynumber(int);
-extern struct rpcent * getrpcent(void);
-extern int getrusage(int, struct rusage *);
-extern char * gets(char *);
-extern struct servent * getservbyname(/* ??? */);
-extern struct servent * getservbyport(/* ??? */);
-extern struct servent * getservent(/* ??? */);
-extern pid_t getsid(pid_t);
-extern struct spwd * getspent(void);
-extern struct spwd * getspnam(const char *);
-extern int getsubopt(char **, char *const *, char **);
-extern int gettmode(void);
-extern char * gettxt(const char *, const char *);
-extern uid_t getuid(void);
-extern struct utmp * getutent(void);
-extern struct utmp * getutid(const struct utmp *);
-extern struct utmp * getutline(const struct utmp *);
-extern void getutmp(const struct utmpx *, struct utmp *);
-extern void getutmpx(const struct utmp *, struct utmpx *);
-extern struct utmpx * getutxent(void);
-extern struct utmpx * getutxid(const struct utmpx *);
-extern struct utmpx * getutxline(const struct utmpx *);
-extern int getvfsany(FILE *, struct vfstab *, struct vfstab *);
-extern int getvfsent(FILE *, struct vfstab *);
-extern int getvfsfile(FILE *, struct vfstab *, char *);
-extern int getvfsspec(FILE *, struct vfstab *, char *);
-extern int getvol(/* ??? */);
-extern int getw(FILE *);
-extern char * getwd(char *);
-extern void getwidth(eucwidth_t *);
-extern WINDOW * getwin(FILE *);
-extern int gmatch(const char *, const char *);
-extern struct tm * gmtime(const time_t *);
-extern int gsignal(int);
-extern int halfdelay(int);
-extern bool has_colors(void);
-extern int has_ic(void);
-extern int has_il(void);
-extern long int hashinc(/* ??? */);
-extern char * hasmntopt(/* ??? */);
-extern int hcreate(size_t);
-extern void hdestroy(void);
-extern int hide_panel(PANEL *);
-extern int host2netname(char *, char *, char *);
-extern int hrtalarm(hrtcmd_t *, int);
-extern int hrtcancel(const long int *, int);
-extern int hrtcntl(int, int, interval_t *, hrtime_t *);
-extern int hrtsleep(hrtcmd_t *);
-extern ENTRY * hsearch(ENTRY, ACTION);
-extern long unsigned int htonl(long unsigned int);
-extern short unsigned int htons(unsigned int);
-extern double hypot(double, double);
-extern void idcok(WINDOW *, int);
-extern int idlok(WINDOW *, int);
-extern void immedok(WINDOW *, int);
-extern char * index(const char *, int);
-extern long unsigned int inet_addr(/* ??? */);
-extern struct in_addr inet_makeaddr(/* ??? */);
-extern long unsigned int inet_network(/* ??? */);
-extern char * inet_ntoa(/* ??? */);
-extern int init_color(int, int, int, int);
-extern int init_pair(int, int, int);
-extern int initgroups(const char *, gid_t);
-extern WINDOW * initscr(/* ??? */);
-extern WINDOW * initscr32(void);
-extern char * initstate(unsigned, char *, int);
-extern void insque(struct qelem *, struct qelem *);
-extern int intrflush(WINDOW *, int);
-extern int ioctl(int, int, ...);
-extern int is_linetouched(WINDOW *, int);
-extern int is_wintouched(WINDOW *);
-extern int isalnum(int);
-extern int isalpha(int);
-extern int isascii(int);
-extern int isatty(int);
-extern int iscntrl(int);
-extern int isdigit(int);
-extern int isencrypt(const char *, size_t);
-extern int isendwin(void);
-extern int isgraph(int);
-extern int isinf(double);
-extern int islower(int);
-extern int isnan(double);
-extern int isnand(double);
-extern int isnanf(float);
-extern int isprint(int);
-extern int ispunct(int);
-extern int isspace(int);
-extern int isupper(int);
-extern int isxdigit(int);
-extern int item_count(MENU *);
-extern char * item_description(ITEM *);
-extern int item_index(ITEM *);
-extern PTF_void item_init(MENU *);
-extern char * item_name(ITEM *);
-extern OPTIONS item_opts(ITEM *);
-extern int item_opts_off(ITEM *, OPTIONS);
-extern int item_opts_on(ITEM *, OPTIONS);
-extern PTF_void item_term(MENU *);
-extern char * item_userptr(ITEM *);
-extern int item_value(ITEM *);
-extern int item_visible(ITEM *);
-extern long int itol(/* ??? */);
-extern double j0(double);
-extern double j1(double);
-extern double jn(int, double);
-extern long int jrand48(short unsigned int *);
-extern char * keyname(int);
-extern int keypad(WINDOW *, int);
-extern int kill(pid_t, int);
-extern char killchar(void);
-extern int killpg(int, int);
-extern void l3tol(long int *, const char *, int);
-extern char * l64a(long int);
-extern long int labs(long int);
-extern dl_t ladd(/* ??? */);
-extern int lchown(const char *, uid_t, gid_t);
-extern int lckpwdf(void);
-extern void lcong48(short unsigned int *);
-extern int ldaclose(struct ldfile *);
-extern int ldahread(struct ldfile *, archdr *);
-extern struct ldfile * ldaopen(const char *, struct ldfile *);
-extern int ldclose(struct ldfile *);
-extern double ldexp(double, int);
-extern int ldfhread(struct ldfile *, struct filehdr *);
-extern char * ldgetname(struct ldfile *, const struct syment *);
-extern ldiv_t ldiv(long int, long int);
-extern dl_t ldivide(/* ??? */);
-extern int ldlinit(struct ldfile *, long int);
-extern int ldlitem(struct ldfile *, unsigned int, struct lineno *);
-extern int ldlread(struct ldfile *, long int, unsigned int, struct lineno *);
-extern int ldlseek(struct ldfile *, unsigned int);
-extern int ldnlseek(struct ldfile *, const char *);
-extern int ldnrseek(struct ldfile *, const char *);
-extern int ldnshread(struct ldfile *, const char *, struct scnhdr *);
-extern int ldnsseek(struct ldfile *, const char *);
-extern int ldohseek(struct ldfile *);
-extern struct ldfile * ldopen(const char *, struct ldfile *);
-extern int ldrseek(struct ldfile *, unsigned int);
-extern int ldshread(struct ldfile *, unsigned int, struct scnhdr *);
-extern int ldsseek(struct ldfile *, unsigned int);
-extern long int ldtbindex(struct ldfile *);
-extern int ldtbread(struct ldfile *, long int, struct syment *);
-extern int ldtbseek(struct ldfile *);
-extern int leaveok(WINDOW *, int);
-extern dl_t lexp10(/* ??? */);
-extern void * lfind(const void *, const void *, size_t *, size_t, int (*) (const void *, const void *));
-extern double lgamma(double);
-extern int link(const char *, const char *);
-extern FIELD * link_field(FIELD *, int, int);
-extern FIELDTYPE * link_fieldtype(FIELDTYPE *, FIELDTYPE *);
-extern char ** listdev(/* ??? */);
-extern char ** listdgrp(/* ??? */);
-extern dl_t llog10(/* ??? */);
-extern dl_t lmul(/* ??? */);
-extern struct lconv * localeconv(void);
-extern struct tm * localtime(const time_t *);
-extern int lock(int, int, long);
-extern int lockf(int, int, off_t);
-extern double log(double);
-extern double log10(double);
-extern float log10f(float);
-extern double logb(double);
-extern float logf(float);
-extern char * logname(void);
-extern void longjmp(jmp_buf, int);
-extern char * longname(void);
-extern long int lrand48(void);
-extern void * lsearch(const void *, void *, size_t *, size_t, int (*) (const void *, const void *));
-extern off_t lseek(int, off_t, int);
-extern dl_t lshiftl(/* ??? */);
-extern int lstat(const char *, struct stat *);
-extern dl_t lsub(/* ??? */);
-extern void ltol3(char *, const long int *, int);
-extern int m_addch(int);
-extern int m_addstr(char *);
-extern int m_clear(void);
-extern int m_erase(void);
-extern WINDOW * m_initscr(void);
-extern int m_move(int, int);
-extern SCREEN * m_newterm(char *, FILE *, FILE *);
-extern int m_refresh(void);
-extern int maillock(char *, int);
-extern int mailunlock(void);
-extern major_t major(dev_t);
-extern datum makdatum(/* ??? */);
-extern void makecontext(ucontext_t *, void (*) (/* ??? */), int, ...);
-extern dev_t makedev(major_t, minor_t);
-extern struct utmpx * makeutx(const struct utmpx *);
-extern struct mallinfo mallinfo(void);
-extern void * malloc(size_t);
-extern int mallopt(int, int);
-extern int map_button(long unsigned int);
-extern int matherr(struct exception *);
-extern int mbftowc(char *, wchar_t *, int (*) (/* ??? */), int *);
-extern int mblen(const char *, size_t);
-extern size_t mbstowcs(wchar_t *, const char *, size_t);
-extern int mbtowc(wchar_t *, const char *, size_t);
-extern void * memalign(size_t, size_t);
-extern void * memccpy(void *, const void *, int, size_t);
-extern void * memchr(const void *, int, size_t);
-extern int memcmp(const void *, const void *, size_t);
-extern void * memcpy(void *, const void *, size_t);
-extern int memlock(/* ??? */);
-extern int memlocked(/* ??? */);
-extern void * memmove(void *, const void *, size_t);
-extern void * memset(void *, int, size_t);
-extern int memunlock(/* ??? */);
-extern chtype menu_back(MENU *);
-extern int menu_driver(MENU *, int);
-extern chtype menu_fore(MENU *);
-extern void menu_format(MENU *, int *, int *);
-extern chtype menu_grey(MENU *);
-extern PTF_void menu_init(MENU *);
-extern ITEM ** menu_items(MENU *);
-extern char * menu_mark(MENU *);
-extern OPTIONS menu_opts(MENU *);
-extern int menu_opts_off(MENU *, OPTIONS);
-extern int menu_opts_on(MENU *, OPTIONS);
-extern int menu_pad(MENU *);
-extern char * menu_pattern(MENU *);
-extern WINDOW * menu_sub(MENU *);
-extern PTF_void menu_term(MENU *);
-extern char * menu_userptr(MENU *);
-extern WINDOW * menu_win(MENU *);
-extern int meta(WINDOW *, int);
-extern void mfree(struct map *, size_t, u_long);
-extern int mincore(caddr_t, size_t, char *);
-extern minor_t minor(dev_t);
-extern int mkdir(const char *, mode_t);
-extern int mkdirp(const char *, mode_t);
-extern int mkfifo(const char *, mode_t);
-extern int mknod(const char *, mode_t, dev_t);
-extern int mkstemp(char *);
-extern char * mktemp(char *);
-extern time_t mktime(struct tm *);
-extern caddr_t mmap(/* ??? */);
-extern double modf(double, double *);
-extern float modff(float, float *);
-extern struct utmpx * modutx(const struct utmpx *);
-extern void monitor(int (*) (/* ??? */), int (*) (/* ??? */), WORD *, int, int);
-extern int mount(const char *, const char *, int, ...);
-extern int mouse_off(long int);
-extern int mouse_on(long int);
-extern int mouse_set(long int);
-extern int move_field(FIELD *, int, int);
-extern int move_panel(PANEL *, int, int);
-extern int mprotect(/* ??? */);
-extern long int mrand48(void);
-extern int msgctl(int, int, ...);
-extern int msgget(key_t, int);
-extern int msgrcv(int, void *, size_t, long int, int);
-extern int msgsnd(int, const void *, size_t, int);
-extern int munmap(/* ??? */);
-extern int mvcur(int, int, int, int);
-extern int mvderwin(WINDOW *, int, int);
-extern int mvprintw(int, int, ...);
-extern int mvscanw(int, int, ...);
-extern int mvwin(WINDOW *, int, int);
-extern int mvwprintw(WINDOW *, int, int, ...);
-extern int mvwscanw(WINDOW *, int, int, ...);
-extern int napms(int);
-extern void netdir_free(char *, int);
-extern int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **, struct netbuf *);
-extern int netdir_getbyname(struct netconfig *, struct nd_hostserv *, struct nd_addrlist **);
-extern int netdir_options(struct netconfig *, int, int, char *);
-extern void netdir_perror(char *);
-extern char * netdir_sperror(/* ??? */);
-extern FIELD * new_field(int, int, int, int, int, int);
-extern FIELDTYPE * new_fieldtype(PTF_int, PTF_int);
-extern FORM * new_form(FIELD **);
-extern ITEM * new_item(char *, char *);
-extern MENU * new_menu(ITEM **);
-extern int new_page(FIELD *);
-extern PANEL * new_panel(WINDOW *);
-extern int newkey(char *, int, int);
-extern WINDOW * newpad(int, int);
-extern SCREEN * newscreen(char *, int, int, int, FILE *, FILE *);
-extern SCREEN * newterm32(char *, FILE *, FILE *);
-extern WINDOW * newwin(int, int, int, int);
-extern double nextafter(double, double);
-extern datum nextkey(datum);
-extern int nftw(const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int);
-extern int nice(int);
-extern int nl(void);
-extern char * nl_langinfo(nl_item);
-extern int nlist(const char *, struct nlist *);
-extern int nocbreak(void);
-extern int nocrmode(void);
-extern int nodelay(WINDOW *, int);
-extern int noecho(void);
-extern int nonl(void);
-extern int noraw(void);
-extern int notimeout(WINDOW *, int);
-extern long int nrand48(short unsigned int *);
-extern int ns_close(/* ??? */);
-extern struct nssend * ns_rcv(/* ??? */);
-extern int ns_send(/* ??? */);
-extern int ns_setup(/* ??? */);
-extern long unsigned int ntohl(long unsigned int);
-extern short unsigned int ntohs(unsigned int);
-extern int nuname(struct utsname *);
-extern int open(const char *, int, ...);
-extern DIR * opendir(const char *);
-extern int openprivwait(/* ??? */);
-extern int openwait(/* ??? */);
-extern int overlay(WINDOW *, WINDOW *);
-extern int overwrite(WINDOW *, WINDOW *);
-extern int p2close(FILE **);
-extern int p2open(const char *, FILE **);
-extern int p32echochar(WINDOW *, chtype);
-extern char * p_cdname(/* ??? */);
-extern char * p_class(/* ??? */);
-extern char * p_rr(/* ??? */);
-extern char * p_type(/* ??? */);
-extern int pair_content(int, short int *, short int *);
-extern PANEL * panel_above(PANEL *);
-extern PANEL * panel_below(PANEL *);
-extern char * panel_userptr(PANEL *);
-extern WINDOW * panel_window(PANEL *);
-extern long int pathconf(const char *, int);
-extern char * pathfind(const char *, const char *, const char *);
-extern int pause(void);
-extern int pclose(FILE *);
-extern void perror(const char *);
-extern struct pfdat * pfind(/* ??? */);
-extern int pglstlk(/* ??? */);
-extern int pglstunlk(/* ??? */);
-extern int pid_slot(proc_t *);
-extern int pipe(int *);
-extern int plock(int);
-extern struct pmaplist * pmap_getmaps(/* ??? */);
-extern u_short pmap_getport(/* ??? */);
-extern enum clnt_stat pmap_rmtcall(/* ??? */);
-extern int pmap_set(/* ??? */);
-extern int pmap_unset(/* ??? */);
-extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
-extern int poll(struct pollfd *, long unsigned int, int);
-extern FILE * popen(const char *, const char *);
-extern int pos_form_cursor(FORM *);
-extern int pos_menu_cursor(MENU *);
-extern int post_form(FORM *);
-extern int post_menu(MENU *);
-extern double pow(double, double);
-extern float powf(float, float);
-extern int prefresh(WINDOW *, int, int, int, int, int, int);
-extern int printf(const char *, ...);
-extern int printw(char *, ...);
-extern void privsig(/* ??? */);
-extern void profil(short unsigned int *, size_t, int, unsigned int);
-extern void psiginfo(siginfo_t *, char *);
-extern void psignal(int, const char *);
-extern int ptrace(int, pid_t, int, int);
-extern int putc(int, FILE *);
-extern int putchar(int);
-extern int putenv(char *);
-extern int putmsg(int, const struct strbuf *, const struct strbuf *, int);
-extern int putp(char *);
-extern int putpmsg(int, const struct strbuf *, const struct strbuf *, int, int);
-extern int putpwent(const struct passwd *, FILE *);
-extern int puts(const char *);
-extern int putspent(const struct spwd *, FILE *);
-extern struct utmp * pututline(const struct utmp *);
-extern struct utmpx * pututxline(const struct utmpx *);
-extern int putw(int, FILE *);
-extern int putwin(WINDOW *, FILE *);
-extern void qsort(void *, size_t, size_t, int (*) (const void *, const void *));
-extern int raise(int);
-extern int rand(void);
-extern long random(void);
-extern int raw(void);
-extern ssize_t read(int, void *, size_t);
-extern struct dirent * readdir(DIR *);
-extern ssize_t readlink(const char *, char *, size_t);
-extern void * realloc(void *, size_t);
-extern char * realpath(char *, char *);
-extern int redrawwin(WINDOW *);
-extern char * regcmp(const char *, ...);
-extern char * regex(const char *, const char *, ...);
-extern double remainder(double, double);
-extern int remio(/* ??? */);
-extern int remove(const char *);
-extern void remque(struct qelem *);
-extern int rename(const char *, const char *);
-extern int replace_panel(PANEL *, WINDOW *);
-extern int request_mouse_pos(void);
-extern struct reservdev ** reservdev(/* ??? */);
-extern int reset_prog_mode(void);
-extern int reset_shell_mode(void);
-extern int resetty(void);
-extern int restartterm(char *, int, int *);
-extern void rewind(FILE *);
-extern void rewinddir(DIR *);
-extern int rf_falloc(/* ??? */);
-extern char * rindex(const char *, int);
-extern double rint(double);
-extern int ripoffline(int, int (*) (WINDOW *, int));
-extern int rmdir(const char *);
-extern int rmdirp(char *, char *);
-extern enum clnt_stat rpc_broadcast(/* ??? */);
-extern enum clnt_stat rpc_call(/* ??? */);
-extern int rpcb_getaddr(/* ??? */);
-extern RPCBLIST * rpcb_getmaps(/* ??? */);
-extern int rpcb_gettime(/* ??? */);
-extern enum clnt_stat rpcb_rmtcall(/* ??? */);
-extern int rpcb_set(/* ??? */);
-extern char * rpcb_taddr2uaddr(/* ??? */);
-extern struct netbuf * rpcb_uaddr2taddr(/* ??? */);
-extern int rpcb_unset(/* ??? */);
-extern void rpctest_service(/* ??? */);
-extern int run_crypt(long int, char *, unsigned int, int *);
-extern int run_setkey(int *, const char *);
-extern int savetty(void);
-extern void * sbrk(int);
-extern double scalb(double, double);
-extern int scale_form(FORM *, int *, int *);
-extern int scale_menu(MENU *, int *, int *);
-extern int scanf(const char *, ...);
-extern int scanw(char *, ...);
-extern int scr_dump(char *);
-extern int scr_init(char *);
-extern int scr_restore(char *);
-extern int scroll(WINDOW *);
-extern int scrollok(WINDOW *, int);
-extern int scrwidth(wchar_t);
-extern int sdfree(char *);
-extern char * sdget(char *, int, ...);
-extern short unsigned int * seed48(short unsigned int *);
-extern void seekdir(DIR *, long int);
-extern int semctl(int, int, int, ...);
-extern int semget(key_t, int, int);
-extern int semop(int, struct sembuf *, unsigned int);
-extern int send(int, char *, int, int);
-extern int set_current_field(FORM *, FIELD *);
-extern int set_current_item(MENU *, ITEM *);
-extern int set_field_back(FIELD *, chtype);
-extern int set_field_buffer(FIELD *, int, char *);
-extern int set_field_fore(FIELD *, chtype);
-extern int set_field_init(FORM *, PTF_void);
-extern int set_field_just(FIELD *, int);
-extern int set_field_opts(FIELD *, OPTIONS);
-extern int set_field_pad(FIELD *, int);
-extern int set_field_status(FIELD *, int);
-extern int set_field_term(FORM *, PTF_void);
-extern int set_field_type(FIELD *, FIELDTYPE *, ...);
-extern int set_field_userptr(FIELD *, char *);
-extern int set_fieldtype_arg(FIELDTYPE *, PTF_charP, PTF_charP, PTF_void);
-extern int set_fieldtype_choice(FIELDTYPE *, PTF_int, PTF_int);
-extern int set_form_fields(FORM *, FIELD **);
-extern int set_form_init(FORM *, PTF_void);
-extern int set_form_opts(FORM *, OPTIONS);
-extern int set_form_page(FORM *, int);
-extern int set_form_sub(FORM *, WINDOW *);
-extern int set_form_term(FORM *, PTF_void);
-extern int set_form_userptr(FORM *, char *);
-extern int set_form_win(FORM *, WINDOW *);
-extern int set_item_init(MENU *, PTF_void);
-extern int set_item_opts(ITEM *, OPTIONS);
-extern int set_item_term(MENU *, PTF_void);
-extern int set_item_userptr(ITEM *, char *);
-extern int set_item_value(ITEM *, int);
-extern int set_max_field(FIELD *, int);
-extern int set_menu_back(MENU *, chtype);
-extern int set_menu_fore(MENU *, chtype);
-extern int set_menu_format(MENU *, int, int);
-extern int set_menu_grey(MENU *, chtype);
-extern int set_menu_init(MENU *, PTF_void);
-extern int set_menu_items(MENU *, ITEM **);
-extern int set_menu_mark(MENU *, char *);
-extern int set_menu_opts(MENU *, OPTIONS);
-extern int set_menu_pad(MENU *, int);
-extern int set_menu_pattern(MENU *, char *);
-extern int set_menu_sub(MENU *, WINDOW *);
-extern int set_menu_term(MENU *, PTF_void);
-extern int set_menu_userptr(MENU *, char *);
-extern int set_menu_win(MENU *, WINDOW *);
-extern int set_new_page(FIELD *, int);
-extern int set_panel_userptr(PANEL *, char *);
-extern int set_top_row(MENU *, int);
-extern void setbuf(FILE *, char *);
-extern int setcontext(ucontext_t *);
-extern SCREEN * setcurscreen(SCREEN *);
-extern TERMINAL * setcurterm(TERMINAL *);
-extern FILE * setexportent(void);
-extern int setgid(gid_t);
-extern void setgrent(void);
-extern int setgroups(int, const gid_t *);
-extern int sethostname(char *, int);
-extern int setitimer(int, struct itimerval *, struct itimerval *);
-extern int setjmp(jmp_buf);
-extern void setkey(const char *);
-extern char * setlocale(int, const char *);
-extern FILE * setmntent(char *, char *);
-extern void * setnetconfig(void);
-extern void * setnetpath(void);
-extern int setpgid(pid_t, pid_t);
-extern pid_t setpgrp(void);
-extern int setpgrp2(pid_t, pid_t);
-extern int setpriority(int, int, int);
-extern int setprivwait(/* ??? */);
-extern void setpwent(void);
-extern int setregid(gid_t, gid_t);
-extern int setreuid(uid_t, uid_t);
-extern int setrlimit(int, struct rlimit *);
-extern int setrpcent(int);
-extern pid_t setsid(void);
-extern void setspent(void);
-extern char * setstate(char *);
-extern int setsyx(int, int);
-extern int setterm(char *);
-extern int setuid(uid_t);
-extern int setupterm(char *, int, int *);
-extern void setutent(void);
-extern void setutxent(void);
-extern int setvbuf(FILE *, char *, int, size_t);
-extern long int sgetl(const char *);
-extern void * shmat(int, void *, int);
-extern int shmctl(int, int, ...);
-extern int shmdt(void *);
-extern int shmget(key_t, int, int);
-extern int show_panel(PANEL *);
-extern int sigaction(int, const struct sigaction *, struct sigaction *);
-extern int sigaddset(sigset_t *, int);
-extern int sigaltstack(const stack_t *, stack_t *);
-extern int sigblock(int);
-extern int sigdelset(sigset_t *, int);
-extern int sigemptyset(sigset_t *);
-extern int sigfillset(sigset_t *);
-extern int sighold(int);
-extern int sigignore(int);
-extern int siginterrupt(int, int);
-extern int sigismember(const sigset_t *, int);
-extern void siglongjmp(sigjmp_buf, int);
-extern signal_ret_t (* signal(int, signal_ret_t (*) (int))) (int);
-extern int sigpause(int);
-extern int sigpending(sigset_t *);
-extern int sigprocmask(int, const sigset_t *, sigset_t *);
-extern int sigrelse(int);
-extern int sigsend(idtype_t, id_t, int);
-extern int sigsendset(const procset_t *, int);
-extern void (* sigset(int, void (*) (int))) (int);
-extern int sigsetjmp(sigjmp_buf, int);
-extern int sigsetmask(int);
-extern int sigsuspend(sigset_t *);
-extern double sin(double);
-extern float sinf(float);
-extern double sinh(double);
-extern float sinhf(float);
-extern unsigned int sleep(unsigned int);
-extern int slk_attroff(chtype);
-extern int slk_attron(chtype);
-extern int slk_attrset(chtype);
-extern int slk_clear(void);
-extern int slk_init(int);
-extern char * slk_label(int);
-extern int slk_noutrefresh(void);
-extern int slk_refresh(void);
-extern int slk_restore(void);
-extern int slk_set(int, char *, int);
-extern int slk_start(int, int *);
-extern int slk_touch(void);
-extern int socket (int, int, int);
-extern void * sprayproc_clear_1(/* ??? */);
-extern spraycumul * sprayproc_get_1(/* ??? */);
-extern void * sprayproc_spray_1(/* ??? */);
-extern int sprintf(char *, const char *, ...);
-extern void sputl(long int, char *);
-extern double sqrt(double);
-extern float sqrtf(float);
-extern void srand(unsigned int);
-extern void srand48(long int);
-extern void srandom(int);
-extern int sscanf(const char *, const char *, ...);
-extern int (* ssignal(int, int (*) (int))) (int);
-extern int start_color(void);
-extern int stat(const char *, struct stat *);
-extern int statfs(const char *, struct statfs *, int, int);
-extern int statvfs(const char *, struct statvfs *);
-extern int step(const char *, const char *);
-extern int stime(const time_t *);
-extern struct netbuf * stoa(char *, struct netbuf *);
-extern void store(datum, datum);
-extern char * strcadd(char *, const char *);
-extern int strcasecmp(const char *, const char *);
-extern char * strcat(char *, const char *);
-extern char * strccpy(char *, const char *);
-extern char * strchr(const char *, int);
-extern void strclearctty(/* ??? */);
-extern void strclearpg(/* ??? */);
-extern void strclearsid(/* ??? */);
-extern int strcmp(const char *, const char *);
-extern int strcoll(const char *, const char *);
-extern char * strcpy(char *, const char *);
-extern size_t strcspn(const char *, const char *);
-extern char * strdup(const char *);
-extern char * streadd(char *, const char *, const char *);
-extern char * strecpy(char *, const char *, const char *);
-extern char * strerror(int);
-extern int strfind(const char *, const char *);
-extern size_t strftime(char *, size_t, const char *, const struct tm *);
-extern size_t strlen(const char *);
-extern int strncasecmp(const char *, const char *, size_t);
-extern char * strncat(char *, const char *, size_t);
-extern int strncmp(const char *, const char *, size_t);
-extern char * strncpy(char *, const char *, size_t);
-extern char * strpbrk(const char *, const char *);
-extern char * strrchr(const char *, int);
-extern char * strrspn(const char *, const char *);
-extern size_t strspn(const char *, const char *);
-extern char * strstr(const char *, const char *);
-extern double strtod(const char *, char **);
-extern char * strtok(char *, const char *);
-extern long int strtol(const char *, char **, int);
-extern long unsigned int strtoul(const char *, char **, int);
-extern char * strtrns(const char *, const char *, const char *, char *);
-extern size_t strxfrm(char *, const char *, size_t);
-extern WINDOW * subpad(WINDOW *, int, int, int, int);
-extern WINDOW * subwin(WINDOW *, int, int, int, int);
-extern int svc_create(/* ??? */);
-extern SVCXPRT * svc_fd_create(/* ??? */);
-extern void svc_getreqset(/* ??? */);
-extern SVCXPRT * svc_raw_create(/* ??? */);
-extern int svc_reg(/* ??? */);
-extern SVCXPRT * svc_tli_create(/* ??? */);
-extern SVCXPRT * svc_tp_create(/* ??? */);
-extern void svc_unreg(/* ??? */);
-extern SVCXPRT * svc_vc_create(/* ??? */);
-extern void svcerr_systemerr(/* ??? */);
-extern SVCXPRT * svcfd_create(/* ??? */);
-extern SVCXPRT * svcraw_create(/* ??? */);
-extern SVCXPRT * svctcp_create(/* ??? */);
-extern SVCXPRT * svcudp_bufcreate(/* ??? */);
-extern SVCXPRT * svcudp_create(/* ??? */);
-extern void swab(const char *, char *, int);
-extern int swapcontext(ucontext_t *, ucontext_t *);
-extern int symlink(const char *, const char *);
-extern void sync(void);
-extern int syncok(WINDOW *, int);
-extern int syscall(int, ...);
-extern long int sysconf(int);
-extern int sysfs(int, ...);
-extern int sysinfo(int, char *, long int);
-extern int system(const char *);
-extern char * taddr2uaddr(struct netconfig *, struct netbuf *);
-extern double tan(double);
-extern float tanf(float);
-extern double tanh(double);
-extern float tanhf(float);
-extern int tcdrain(int);
-extern int tcflow(int, int);
-extern int tcflush(int, int);
-extern int tcgetattr(int, struct termios *);
-extern pid_t tcgetpgrp(int);
-extern pid_t tcgetsid(int);
-extern int tcsendbreak(int, int);
-extern int tcsetattr(int, int, const struct termios *);
-extern int tcsetpgrp(int, pid_t);
-extern void * tdelete(const void *, void **, int (*) (const void *, const void *));
-extern long int telldir(DIR *);
-extern char * tempnam(const char *, const char *);
-extern chtype termattrs(void);
-extern void termerr(void);
-extern char * termname(void);
-extern void * tfind(const void *, void *const *, int (*) (const void *, const void *));
-extern int tgetent(char *, char *);
-extern int tgetflag(char *);
-extern int tgetnum(char *);
-extern char * tgetstr(char *, char **);
-extern char * tgoto(char *, int, int);
-extern char * tigetstr(char *);
-extern time_t time(time_t *);
-extern clock_t times(struct tms *);
-extern char * timezone(int, int);
-extern void tinputfd(int);
-extern FILE * tmpfile(void);
-extern char * tmpnam(char *);
-extern int toascii(int);
-extern int tolower(int);
-extern int top_panel(PANEL *);
-extern int top_row(MENU *);
-extern int touchline(WINDOW *, int, int);
-extern int touchwin(WINDOW *);
-extern int toupper(int);
-extern char * tparm(/* ??? */);
-extern int tputs(char *, int, int (*) (char));
-extern int traceoff(void);
-extern int traceon(void);
-extern int truncate(const char *, off_t);
-extern void * tsearch(const void *, void **, int (*) (const void *, const void *));
-extern char * ttyname(int);
-extern int ttyslot(void);
-extern void twalk(void *, void (*) (void *, VISIT, int));
-extern int typeahead(int);
-extern void tzset(void);
-extern struct netbuf * uaddr2taddr(struct netconfig *, char *);
-extern int uadmin(int, int, int);
-extern unsigned ualarm(unsigned, unsigned);
-extern int ulckpwdf(void);
-extern long int ulimit(int, ...);
-extern mode_t umask(mode_t);
-extern int umount(const char *);
-extern int uname(struct utsname *);
-extern char * unctrl(int);
-extern void undial(int);
-extern int ungetc(int, FILE *);
-extern int ungetch(int);
-extern int unlink(const char *);
-extern int unordered(double, double);
-extern int unpost_form(FORM *);
-extern int unpost_menu(MENU *);
-extern int unremio(/* ??? */);
-extern int untouchwin(WINDOW *);
-extern void update_panels(void);
-extern void updwtmp(const char *, struct utmp *);
-extern void updwtmpx(const char *, struct utmpx *);
-extern void use_env(int);
-extern unsigned usleep(unsigned);
-extern int ustat(dev_t, struct ustat *);
-extern int utime(const char *, const struct utimbuf *);
-extern int utmpname(const char *);
-extern int utmpxname(const char *);
-extern void va_end(__gnuc_va_list);
-extern int vadvise(int);
-extern void * valloc(size_t);
-extern pid_t vfork(void);
-extern int vfprintf(FILE *, const char *, __gnuc_va_list);
-extern int vhangup(void);
-extern int vid32attr(chtype);
-extern int vid32puts(chtype, int (*) (char));
-extern void vidupdate(chtype, chtype, int (*) (char));
-extern int vn_close(/* ??? */);
-extern int vprintf(const char *, __gnuc_va_list);
-extern int vsprintf(char *, const char *, __gnuc_va_list);
-extern int vwprintw(WINDOW *, char *, void *);
-extern int vwscanw(WINDOW *, char *, void *);
-extern int w32addch(WINDOW *, chtype);
-extern int w32attroff(WINDOW *, chtype);
-extern int w32attron(WINDOW *, chtype);
-extern int w32attrset(WINDOW *, chtype);
-extern int w32echochar(WINDOW *, chtype);
-extern int w32insch(WINDOW *, chtype);
-extern int waddchnstr(WINDOW *, chtype *, int);
-extern int waddnstr(WINDOW *, char *, int);
-extern int waddstr(WINDOW *, char *);
-extern pid_t wait(wait_arg_t *);
-extern pid_t wait3(union wait *, int, struct rusage *);
-extern int waitid(idtype_t, id_t, siginfo_t *, int);
-extern pid_t waitpid(pid_t, int *, int);
-extern void * wallproc_wall_1(/* ??? */);
-extern int wbkgd(WINDOW *, chtype);
-extern void wbkgdset(WINDOW *, chtype);
-extern int wborder(WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype);
-extern int wclear(WINDOW *);
-extern int wclrtobot(WINDOW *);
-extern int wclrtoeol(WINDOW *);
-extern size_t wcstombs(char *, const wchar_t *, size_t);
-extern int wctomb(char *, wchar_t);
-extern void wcursyncup(WINDOW *);
-extern int wdelch(WINDOW *);
-extern int wdeleteln(WINDOW *);
-extern int werase(WINDOW *);
-extern int wgetch(WINDOW *);
-extern int wgetnstr(WINDOW *, char *, int);
-extern int wgetstr(WINDOW *, char *);
-extern int whline(WINDOW *, chtype, int);
-extern chtype winch(WINDOW *);
-extern int winchnstr(WINDOW *, chtype *, int);
-extern int winchstr(WINDOW *, chtype *);
-extern int winnstr(WINDOW *, char *, int);
-extern int winsdelln(WINDOW *, int);
-extern int winsertln(WINDOW *);
-extern int winsnstr(WINDOW *, char *, int);
-extern int winstr(WINDOW *, char *);
-extern int wisprint(wchar_t);
-extern void wmouse_position(WINDOW *, int *, int *);
-extern int wmove(WINDOW *, int, int);
-extern int wnoutrefresh(WINDOW *);
-extern int wprintw(WINDOW *, ...);
-extern int wredrawln(WINDOW *, int, int);
-extern int wrefresh(WINDOW *);
-extern ssize_t write(int, const void *, size_t);
-extern int wscanw(WINDOW *, ...);
-extern int wscrl(WINDOW *, int);
-extern int wsetscrreg(WINDOW *, int, int);
-extern int wstandend(WINDOW *);
-extern int wstandout(WINDOW *);
-extern void wsyncdown(WINDOW *);
-extern void wsyncup(WINDOW *);
-extern void wtimeout(WINDOW *, int);
-extern int wtouchln(WINDOW *, int, int, int);
-extern int wvline(WINDOW *, chtype, int);
-extern bool xdr_datum(/* ??? */);
-extern int xdr_double(/* ??? */);
-extern int xdr_exports(/* ??? */);
-extern int xdr_fhstatus(/* ??? */);
-extern int xdr_float(/* ??? */);
-extern int xdr_keybuf(/* ??? */);
-extern int xdr_mountlist(/* ??? */);
-extern int xdr_netbuf(/* ??? */);
-extern int xdr_path(/* ??? */);
-extern int xdr_pmap(/* ??? */);
-extern int xdr_pmaplist(/* ??? */);
-extern int xdr_pointer(/* ??? */);
-extern int xdr_reference(/* ??? */);
-extern int xdr_rmtcall_args(/* ??? */);
-extern int xdr_rmtcallres(/* ??? */);
-extern int xdr_rpcb(/* ??? */);
-extern int xdr_rpcb_rmtcallargs(/* ??? */);
-extern int xdr_rpcb_rmtcallres(/* ??? */);
-extern int xdr_rpcblist(/* ??? */);
-extern int xdr_sprayarr(/* ??? */);
-extern int xdr_spraycumul(/* ??? */);
-extern int xdr_spraytimeval(/* ??? */);
-extern int xdr_u_char(/* ??? */);
-extern int xdr_utmparr(/* ??? */);
-extern int xdr_utmpidlearr(/* ??? */);
-extern int xdr_vector(/* ??? */);
-extern int xdr_yp_buf(/* ??? */);
-extern bool xdr_yp_inaddr(/* ??? */);
-extern bool xdr_ypall(/* ??? */);
-extern int xdr_ypdelete_args(/* ??? */);
-extern bool xdr_ypdomain_wrap_string(/* ??? */);
-extern bool xdr_ypmap_parms(/* ??? */);
-extern bool xdr_ypmap_wrap_string(/* ??? */);
-extern bool xdr_ypowner_wrap_string(/* ??? */);
-extern bool xdr_yppushresp_xfr(/* ??? */);
-extern bool xdr_ypreq_key(/* ??? */);
-extern bool xdr_ypreq_newxfr(/* ??? */);
-extern bool xdr_ypreq_nokey(/* ??? */);
-extern bool xdr_ypreq_xfr(/* ??? */);
-extern bool xdr_ypresp_key_val(/* ??? */);
-extern bool xdr_ypresp_maplist(/* ??? */);
-extern bool xdr_ypresp_master(/* ??? */);
-extern bool xdr_ypresp_order(/* ??? */);
-extern bool xdr_ypresp_val(/* ??? */);
-extern int xdr_ypupdate_args(/* ??? */);
-extern void xdrrec_create(/* ??? */);
-extern int xdrrec_endofrecord(/* ??? */);
-extern int xdrrec_eof(/* ??? */);
-extern int xdrrec_skiprecord(/* ??? */);
-extern void xdrstdio_create(/* ??? */);
-extern void xprt_register(/* ??? */);
-extern void xprt_unregister(/* ??? */);
-extern double y0(double);
-extern double y1(double);
-extern double yn(int, double);
-extern int yp_all(char *, char *, struct ypall_callback *);
-extern int yp_bind(const char *);
-extern int yp_first(char *, char *, char **, int *, char **, int *);
-extern int yp_get_default_domain(char **);
-extern int yp_master(char *, char *, char **);
-extern int yp_match(char *, char *, char *, int, char **, int *);
-extern int yp_next(char *, char *, char *, int, char **, int *, char **, int *);
-extern int yp_order(char *, char *, int *);
-extern void yp_unbind(const char *);
-extern char * yperr_string(int);
-extern int ypprot_err(unsigned int);
-extern u_int * ypu_change_1(/* ??? */);
-extern u_int * ypu_delete_1(/* ??? */);
-extern u_int * ypu_insert_1(/* ??? */);
-extern u_int * ypu_store_1(/* ??? */);
+++ /dev/null
-enum clnt_stat { ___fake1 };
-enum auth_stat { ___fake2 };
-
-struct netconfig;
-struct netbuf;
-struct address;
-struct tm;
-struct ldfile;
-struct syment;
-struct stat;
-struct timeval;
-struct termios;
-struct tms;
-struct dma_cb;
-struct cred;
-struct vnode;
-struct vattr;
-struct uarg;
-struct statfs;
-struct statvfs;
-struct dirent;
-struct itimerval;
-struct mnttab;
-struct strbuf;
-struct vfstab;
-struct ldfile;
-struct syment;
-struct scnhdr;
-struct exception;
-struct nd_hostservlist;
-struct nd_hostserv;
-struct utsname;
-struct uio;
-struct pid;
-struct pollfd;
-struct nlist;
-struct passwd;
-struct spwd;
-struct flock;
-struct seg;
-struct sembuf;
-struct sigaction;
-struct utimbuf;
-struct map;
-struct filehdr;
-struct lineno;
-struct nd_addrlist;
-struct FTW;
-struct buf;
-struct ustat;
-struct qelem;
-struct prpsinfo;
-struct user;
-struct qelem;
-struct execenv;
-struct utmpx;
-
-struct direct;
-struct tm;
-struct stat;
-struct rlimit;
-struct rusage;
-struct sockaddr;
-struct sockaddr_in;
-struct timeval { int i; };
-struct exportent;
-struct fstab;
-struct hostent;
-struct in_addr { int i; };
-struct ldfile;
-struct mallinfo { int i; };
-struct mint;
-struct nmtent;
-struct netent;
-struct pmaplist;
-struct protoent;
-struct rpcent;
-struct servent;
-struct authdes_cred;
-struct rpc_err;
-struct ypall_callback;
-
-union wait;
-
-/* Get size_t and wchar_t. */
-#include <stddef.h>
-
-/* #include "sys/types.h" */
-#define ssize_t int
-
-/* The actual types used here are mostly wrong,
- but it is not supposed to matter what types we use here. */
-
-typedef int dev_t;
-typedef int pid_t;
-typedef int gid_t;
-typedef int off_t;
-typedef int mode_t;
-typedef int uid_t;
-
-typedef int proc_t;
-typedef int time_t;
-typedef int addr_t;
-typedef int caddr_t;
-typedef int clock_t;
-typedef int div_t;
-typedef int ldiv_t;
-typedef int dl_t;
-typedef int major_t;
-typedef int minor_t;
-typedef int emcp_t;
-typedef int fpclass_t;
-typedef int index_t;
-typedef int ecb_t;
-typedef int aioop_t;
-typedef int evver_t;
-typedef int evcntlcmds_t;
-typedef int idtype_t;
-typedef int id_t;
-typedef int procset_t;
-typedef int hostid_t;
-typedef int evpollcmds_t;
-typedef int event_t;
-typedef int hrtime_t;
-typedef int evqcntlcmds_t;
-typedef int sigset_t;
-typedef int evsiginfo_t;
-typedef int evcontext_t;
-typedef int evta_t;
-typedef int speed_t;
-typedef int rlim_t;
-typedef int cred_t;
-typedef int file_t;
-typedef int vnode_t;
-typedef int vfs_t;
-typedef int fpos_t;
-typedef int exhda_t;
-typedef int ucontext_t;
-typedef int sess_t;
-typedef int hrtcmd_t;
-typedef int interval_t;
-typedef int key_t;
-typedef int daddr_t;
-typedef int stack_t;
-typedef int sigaction_t;
-typedef int siginfo_t;
-typedef int mblk_t;
-typedef int paddr_t;
-typedef int qband_t;
-typedef int queue_t;
-typedef int rf_resource_t;
-typedef int sr_mount_t;
-typedef int timer_t;
-typedef int fpregset_t;
-typedef int prstatus_t;
-typedef int vfssw_t;
-typedef int eucwidth_t;
-typedef int page_t;
-
-typedef int u_int;
-typedef int u_short;
-typedef int u_long;
-typedef int u_char;
-
-typedef int ushort;
-typedef int ulong;
-typedef int uint;
-
-typedef int __gnuc_va_list;
-
-typedef int archdr;
-typedef int AUTH;
-typedef int CLIENT;
-typedef int DIR;
-typedef int ENTRY;
-typedef int Elf;
-typedef int Elf32_Ehdr;
-typedef int Elf32_Phdr;
-typedef int Elf32_Shdr;
-typedef int Elf_Arhdr;
-typedef int Elf_Arsym;
-typedef int Elf_Cmd;
-typedef int Elf_Data;
-typedef int Elf_Scn;
-typedef int Elf_Type;
-typedef int Elf_Kind;
-typedef int FIELD;
-typedef int FIELDTYPE;
-typedef int PTF_int;
-typedef int PTF_void;
-typedef int PTF_charP;
-typedef int FILE;
-typedef int FORM;
-typedef int ITEM;
-typedef int MENU;
-typedef int OPTIONS;
-typedef int PANEL;
-typedef int FTP_void;
-typedef int RPCBLIST;
-typedef int SCREEN;
-typedef int SVCXPRT;
-typedef int TERMINAL;
-typedef int WINDOW;
-typedef int bool;
-typedef int nl_catd;
-typedef int nl_item;
-typedef int chtype;
-typedef int datum;
-typedef int fp_rnd;
-typedef int spraycumul;
-typedef int WORD;
-typedef int VISIT;
-typedef int ACTION;
-
-typedef int *jmp_buf;
-typedef int *sigjmp_buf;
-typedef int xdrproc_t;
-typedef int CALL;
-typedef int bool_t;
-typedef int DBM;
-typedef int des_block;
-typedef int resultproc_t;
-
-
-#ifdef BSD
-
-#define mode_t int
-#define uid_t int
-#define gid_t int
-#define time_t long
-#define pid_t int
-#define signal_ret_t int
-#define wait_arg_t union wait
-
-#else
-
-#define signal_ret_t void
-#define wait_arg_t int
-
-#endif
+2009-03-28 Joseph Myers <joseph@codesourcery.com>
+
+ * g++.old-deja/g++.ext/attrib5.C, g++.old-deja/g++.jason/thunk3.C,
+ gcc.c-torture/compile/981006-1.c: Don't XFAIL or add special
+ options for removed targets.
+
2009-03-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/39120
-// { dg-do run { xfail alpha*-dec-osf* *-*-hms i?86-pc-cygwin *-*-coff } }
+// { dg-do run { xfail alpha*-dec-osf* i?86-pc-cygwin } }
// Test that attributes weak and alias coexist.
// { dg-require-weak "" }
// { dg-require-alias "" }
-// { dg-do run { xfail rs6000-*-* powerpc-*-eabi m68k-*-coff mn10300-*-* v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa*-*-* m32r*-*-* } }
+// { dg-do run { xfail rs6000-*-* powerpc-*-eabi mn10300-*-* v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa*-*-* m32r*-*-* } }
// Test that variadic function calls using thunks work right.
// Note that this will break on any target that uses the generic thunk
// support, because it doesn't support variadic functions.
/* { dg-do assemble } */
/* For MIPS at least, pic is needed to trigger the problem. */
/* { dg-options "-w -Wuninitialized -Werror -fpic" } */
-/* { dg-options "-w -Wuninitialized -Werror" { target { { rs6000-*-aix* powerpc*-*-aix* arm*-*-* fr30-*-* sh-*-hms sh-*-coff h8300*-*-* cris-*-elf* mmix-*-* } || { ! fpic } } } } */
+/* { dg-options "-w -Wuninitialized -Werror" { target { { rs6000-*-aix* powerpc*-*-aix* arm*-*-* fr30-*-* sh-*-hms h8300*-*-* cris-*-elf* mmix-*-* } || { ! fpic } } } } */
int foo (int a, int b)
{
/* Get common system includes and various definitions and declarations
based on target macros.
- Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
This file is part of GCC.
extern int errno;
#endif
-/* GCC (fixproto) guarantees these system headers exist. */
+/* If these system headers do not exist, fixincludes must create them. */
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
/* GCC supplies this header. */
#include <limits.h>
-/* GCC (fixproto) guarantees this system headers exists. */
+/* If these system headers do not exist, fixincludes must create them. */
#include <time.h>
#endif /* inhibit_libc */
+2009-03-28 Joseph Myers <joseph@codesourcery.com>
+
+ * config.host (arm-*-coff*, armel-*-coff*, arm-semi-aof,
+ armel-semi-aof, h8300-*-*, i[34567]86-*-aout*, i[34567]86-*-coff*,
+ m68k-*-aout*, m68k-*-coff*, pdp11-*-bsd, rs6000-ibm-aix4.[12]*,
+ powerpc-ibm-aix4.[12]*, sh-*-*): Remove.
+
2009-02-12 Uros Bizjak <ubizjak@gmail.com>
* config.host (ia64*-*-linux*): Add t-softfp to tmake_file.
# libgcc host-specific configuration file.
# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-# 2008 Free Software Foundation, Inc.
+# 2008, 2009 Free Software Foundation, Inc.
#This file is part of GCC.
;;
arc-*-elf*)
;;
-arm-*-coff* | armel-*-coff*)
- ;;
-arm-semi-aof | armel-semi-aof)
- ;;
arm-wrs-vxworks)
;;
arm*-*-freebsd*)
;;
h8300-*-elf*)
;;
-h8300-*-*)
- ;;
hppa*64*-*-linux*)
;;
hppa*-*-linux*)
;;
x86_64-*-elf*)
;;
-i[34567]86-*-aout*)
- ;;
i[34567]86-*-freebsd*)
;;
x86_64-*-freebsd*)
;;
i[34567]86-*-openbsd*)
;;
-i[34567]86-*-coff*)
- ;;
i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu*)
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm"
;;
m68hc12-*-*|m6812-*-*)
;;
-m68k-*-aout*)
- ;;
-m68k-*-coff*)
- ;;
m68k-*-elf*)
;;
m68k*-*-netbsdelf*)
;;
mn10300-*-*)
;;
-pdp11-*-bsd)
- ;;
pdp11-*-*)
;;
picochip-*-*)
;;
powerpcle-*-eabi*)
;;
-rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4.[12]*)
- ;;
rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
;;
rs6000-ibm-aix5.1.* | powerpc-ibm-aix5.1.*)
;;
sh-wrs-vxworks)
;;
-sh-*-*)
- ;;
sparc-*-netbsdelf*)
;;
sparc64-*-openbsd*)