From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: gdb-patches@sourceware.cygnus.com Subject: RFC: init.c cleanup Date: Sat, 27 Nov 1999 18:50:00 -0000 Message-id: <37E5FCD8.1F6E0DF7@cygnus.com> X-SW-Source: 1999-q4/msg00336.html Hello, The attached patch changes the way init.c is generated. It does the following: o introduces the type ``initialize_file_ftype'' which should be used to declare all _initialize_*() functions. o modifies init.c so that it includes relevant headers (defs.h, call-cmds.h) instead of assuming that it got it right. o uses initialize_file_ftype to declare each _initialize_*() function and puts the declarations out side of the initialize_all_files() function. (this makes init a two pass operation). This significantly tightens the initialization code. comments? Andrew Mon Sep 20 18:19:09 1999 Andrew Cagney * defs.h (initialize_ftype): Add function typedef. * Makefile.in (init.c): Change generated file to include "defs.h" and "call-cmds.h". Use initialize_file_ftype when declaring initialize functions. Index: defs.h =================================================================== RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v retrieving revision 1.254 diff -p -r1.254 defs.h *** defs.h 1999/09/16 21:16:50 1.254 --- defs.h 1999/09/20 09:19:50 *************** extern void symbol_file_command PARAMS ( *** 552,557 **** --- 552,559 ---- /* From top.c */ + typedef void initialize_file_ftype (void); + extern char *skip_quoted PARAMS ((char *)); extern char *gdb_readline PARAMS ((char *)); Index: Makefile.in =================================================================== RCS file: /cvs/cvsfiles/devo/gdb/Makefile.in,v retrieving revision 1.711 diff -p -r1.711 Makefile.in *** Makefile.in 1999/09/20 07:25:19 1.711 --- Makefile.in 1999/09/20 09:19:54 *************** uninstall: force *** 725,736 **** init.c: $(OBS) $(TSOBS) @echo Making init.c ! @rm -f init.c-tmp ! @echo '/* Do not modify this file. */' >init.c-tmp ! @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp ! @echo '#include "ansidecl.h"' >>init.c-tmp ! @echo 'extern void initialize_all_files PARAMS ((void));' >>init.c-tmp ! @echo 'void initialize_all_files PARAMS ((void)) {' >>init.c-tmp @-echo $(OBS) $(TSOBS) | \ tr ' ' '\012' | \ sed -e '/^Onindy.o/d' \ --- 725,731 ---- init.c: $(OBS) $(TSOBS) @echo Making init.c ! @rm -f init.c-tmp init.c-lst @-echo $(OBS) $(TSOBS) | \ tr ' ' '\012' | \ sed -e '/^Onindy.o/d' \ *************** init.c: $(OBS) $(TSOBS) *** 748,755 **** -e 's/\.o/.c/' \ -e 's|\([^ ][^ ]*\)|$(srcdir)/\1|g' | \ while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \ ! sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 PARAMS ((void)); \1 ();}/' >>init.c-tmp @echo '}' >>init.c-tmp @mv init.c-tmp init.c .PRECIOUS: init.c --- 743,760 ---- -e 's/\.o/.c/' \ -e 's|\([^ ][^ ]*\)|$(srcdir)/\1|g' | \ while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \ ! sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/\1/' > init.c-lst ! @echo '/* Do not modify this file. */' >>init.c-tmp ! @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp ! @echo '#include "defs.h"' >>init.c-tmp ! @echo '#include "call-cmds.h"' >>init.c-tmp ! @sed -e 's/\(.*\)/extern initialize_file_ftype \1;/' >init.c-tmp ! @echo 'void' >>init.c-tmp ! @echo 'initialize_all_files (void)' >>init.c-tmp ! @echo '{' >>init.c-tmp ! @sed -e 's/\(.*\)/ \1 ();/' >init.c-tmp @echo '}' >>init.c-tmp + @rm init.c-lst @mv init.c-tmp init.c .PRECIOUS: init.c From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: gdb-patches@sourceware.cygnus.com Subject: RFC: init.c cleanup Date: Mon, 20 Sep 1999 02:31:00 -0000 Message-ID: <37E5FCD8.1F6E0DF7@cygnus.com> X-SW-Source: 1999-q3/msg00258.html Message-ID: <19990920023100.U68Qzvwbg2qPcY6r8NYUw7B_bYMYC_X2RyiIvVtpqgM@z> Hello, The attached patch changes the way init.c is generated. It does the following: o introduces the type ``initialize_file_ftype'' which should be used to declare all _initialize_*() functions. o modifies init.c so that it includes relevant headers (defs.h, call-cmds.h) instead of assuming that it got it right. o uses initialize_file_ftype to declare each _initialize_*() function and puts the declarations out side of the initialize_all_files() function. (this makes init a two pass operation). This significantly tightens the initialization code. comments? Andrew Mon Sep 20 18:19:09 1999 Andrew Cagney * defs.h (initialize_ftype): Add function typedef. * Makefile.in (init.c): Change generated file to include "defs.h" and "call-cmds.h". Use initialize_file_ftype when declaring initialize functions. Index: defs.h =================================================================== RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v retrieving revision 1.254 diff -p -r1.254 defs.h *** defs.h 1999/09/16 21:16:50 1.254 --- defs.h 1999/09/20 09:19:50 *************** extern void symbol_file_command PARAMS ( *** 552,557 **** --- 552,559 ---- /* From top.c */ + typedef void initialize_file_ftype (void); + extern char *skip_quoted PARAMS ((char *)); extern char *gdb_readline PARAMS ((char *)); Index: Makefile.in =================================================================== RCS file: /cvs/cvsfiles/devo/gdb/Makefile.in,v retrieving revision 1.711 diff -p -r1.711 Makefile.in *** Makefile.in 1999/09/20 07:25:19 1.711 --- Makefile.in 1999/09/20 09:19:54 *************** uninstall: force *** 725,736 **** init.c: $(OBS) $(TSOBS) @echo Making init.c ! @rm -f init.c-tmp ! @echo '/* Do not modify this file. */' >init.c-tmp ! @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp ! @echo '#include "ansidecl.h"' >>init.c-tmp ! @echo 'extern void initialize_all_files PARAMS ((void));' >>init.c-tmp ! @echo 'void initialize_all_files PARAMS ((void)) {' >>init.c-tmp @-echo $(OBS) $(TSOBS) | \ tr ' ' '\012' | \ sed -e '/^Onindy.o/d' \ --- 725,731 ---- init.c: $(OBS) $(TSOBS) @echo Making init.c ! @rm -f init.c-tmp init.c-lst @-echo $(OBS) $(TSOBS) | \ tr ' ' '\012' | \ sed -e '/^Onindy.o/d' \ *************** init.c: $(OBS) $(TSOBS) *** 748,755 **** -e 's/\.o/.c/' \ -e 's|\([^ ][^ ]*\)|$(srcdir)/\1|g' | \ while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \ ! sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 PARAMS ((void)); \1 ();}/' >>init.c-tmp @echo '}' >>init.c-tmp @mv init.c-tmp init.c .PRECIOUS: init.c --- 743,760 ---- -e 's/\.o/.c/' \ -e 's|\([^ ][^ ]*\)|$(srcdir)/\1|g' | \ while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \ ! sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/\1/' > init.c-lst ! @echo '/* Do not modify this file. */' >>init.c-tmp ! @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp ! @echo '#include "defs.h"' >>init.c-tmp ! @echo '#include "call-cmds.h"' >>init.c-tmp ! @sed -e 's/\(.*\)/extern initialize_file_ftype \1;/' >init.c-tmp ! @echo 'void' >>init.c-tmp ! @echo 'initialize_all_files (void)' >>init.c-tmp ! @echo '{' >>init.c-tmp ! @sed -e 's/\(.*\)/ \1 ();/' >init.c-tmp @echo '}' >>init.c-tmp + @rm init.c-lst @mv init.c-tmp init.c .PRECIOUS: init.c