From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.lisp.guile.devel Subject: Re: rfc: [build] Overhaul , cpp symbol extraction/checking. Date: Fri, 25 Jun 2010 14:07:20 +0200 Message-ID: <87ocezfh8n.fsf@ambire.localdomain> References: <874oh1g0sb.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1277495010 4521 80.91.229.12 (25 Jun 2010 19:43:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Jun 2010 19:43:30 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jun 25 21:43:26 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OSEo9-0005IQ-01 for guile-devel@m.gmane.org; Fri, 25 Jun 2010 21:43:26 +0200 Original-Received: from localhost ([127.0.0.1]:35507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSEo8-0003FR-0t for guile-devel@m.gmane.org; Fri, 25 Jun 2010 15:43:24 -0400 Original-Received: from [140.186.70.92] (port=54743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSD35-0004ra-Sn for guile-devel@gnu.org; Fri, 25 Jun 2010 13:50:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OS7lk-0003Uo-0M for guile-devel@gnu.org; Fri, 25 Jun 2010 08:12:29 -0400 Original-Received: from smtp208.alice.it ([82.57.200.104]:45297) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OS7lj-0003Ue-HN for guile-devel@gnu.org; Fri, 25 Jun 2010 08:12:27 -0400 Original-Received: from ambire.localdomain (95.244.64.152) by smtp208.alice.it (8.5.124.08) id 4C1A27160090A59B for guile-devel@gnu.org; Fri, 25 Jun 2010 14:12:24 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.69) (envelope-from ) id 1OS7jL-0004u9-JF for guile-devel@gnu.org; Fri, 25 Jun 2010 14:09:59 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10573 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Andy Wingo () Fri, 18 Jun 2010 10:43:07 +0200 Would you mind sending patches using git-format-patch? It's easier to reply inline that way :-) Ah, ok. I was under the impression that the preferred way was to post a link (to a commit) so that whoever wants to pull can do so, thus avoiding big email messages. Isn't that the "git way"? I don't really understand this patch, or the current makefile foo thb, and would appreciate an explanation. I've just pushed =E2=80=98ttn/janitor=E2=80=99 (and deleted =E2=80=98ttn/mi= sc-maint=E2=80=99), including the patch below, reformulated (slightly) to add a bit of explanation to libguile/Makefile.am. Does that help? I omit explaining the old way there, but here's a summary: "essentially (the basic approach) like the new way , but with more state (files, temporary and permanent) and with unnecessary modularity". The branch =E2=80=98ttn/janitor=E2=80=99 also has some other patches. I wi= ll post them individually for review in other threads. thi ____________________________________________________________ --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-build-Overhaul-errno.h-signal.h-cpp-symbol-extractio.patch Content-Transfer-Encoding: quoted-printable >From aa9afa384168c0509b30be0d5f7c61f24f02c729 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 15 Jun 2010 22:34:27 +0200 Subject: [PATCH 1/8] [build] Overhaul , cpp symbol extr= action/checking. * libguile/Makefile.am (BUILT_SOURCES): Delete cpp_err_symbols.c, cpp_sig_symbols.c; add cpp-E.c, cpp-SIG.c. (EXTRA_DIST): Delete cpp_signal.c, cpp_errno.c, cpp_err_symbols.in, cpp_err_symbols.c, cpp_sig_symbols.c, cpp_sig_symbols.in, cpp_cnvt.awk; add cpp-E.syms, cpp-E.c, cpp-SIG.syms, cpp-SIG.c. (error.x, posix.x): Update prereq list. (cpp_err_symbols.c, cpp_sig_symbols.c): Delete targets. (check_signals, check_errnos): Likewise. (.syms.c): New pattern rule. (chknew-E, chknew-SIG): New targets. (MOSTLYCLEANFILES): Delete cpp_err_symbols_here, cpp_err_symbols_diff, cpp_err_symbols_new, cpp_sig_symbols_here, cpp_sig_symbols_diff, cpp_sig_symbols_new. * libguile/cpp-E.syms: Rename from libguile/cpp_err_symbols.in. * libguile/cpp-SIG.syms: Rename from libguile/cpp_sig_symbols.in. * libguile/error.c (scm_init_error): #include "libguile/cpp-E.c". * libguile/posix.c (scm_init_posix): #include "libguile/cpp-SIG.c". * libguile/cpp_cnvt.awk: Delete file. * libguile/cpp_errno.c: Delete file. * libguile/cpp_signal.c: Delete file. --- libguile/Makefile.am | 102 +++++++++++++++++++----------------- libguile/cpp-E.syms | 122 +++++++++++++++++++++++++++++++++++++++= ++++ libguile/cpp-SIG.syms | 36 +++++++++++++ libguile/cpp_cnvt.awk | 7 --- libguile/cpp_err_symbols.in | 122 ---------------------------------------= ---- libguile/cpp_errno.c | 9 --- libguile/cpp_sig_symbols.in | 36 ------------- libguile/cpp_signal.c | 9 --- libguile/error.c | 2 +- libguile/posix.c | 2 +- 10 files changed, 214 insertions(+), 233 deletions(-) create mode 100644 libguile/cpp-E.syms create mode 100644 libguile/cpp-SIG.syms delete mode 100644 libguile/cpp_cnvt.awk delete mode 100644 libguile/cpp_err_symbols.in delete mode 100644 libguile/cpp_errno.c delete mode 100644 libguile/cpp_sig_symbols.in delete mode 100644 libguile/cpp_signal.c diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 5eea8dc..6a33473 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -415,7 +415,7 @@ DOT_I_FILES =3D vm-i-system.i vm-i-scheme.i vm-i-loader= .i .c.i: $(AM_V_GEN)$(GREP) '^VM_DEFINE' $< > $@ =20 -BUILT_SOURCES =3D cpp_err_symbols.c cpp_sig_symbols.c libpath.h \ +BUILT_SOURCES =3D cpp-E.c cpp-SIG.c libpath.h \ version.h scmconfig.h \ $(DOT_I_FILES) $(DOT_X_FILES) $(EXTRA_DOT_X_FILES) =20 @@ -596,9 +596,8 @@ bin_SCRIPTS =3D guile-snarf noinst_SCRIPTS =3D guile-doc-snarf guile-snarf-docs guile-func-name-check =20 EXTRA_DIST =3D ChangeLog-scm ChangeLog-threads \ - ChangeLog-1996-1999 ChangeLog-2000 ChangeLog-2008 cpp_signal.c \ - cpp_errno.c cpp_err_symbols.in cpp_err_symbols.c \ - cpp_sig_symbols.c cpp_sig_symbols.in cpp_cnvt.awk \ + ChangeLog-1996-1999 ChangeLog-2000 ChangeLog-2008 \ + cpp-E.syms cpp-E.c cpp-SIG.syms cpp-SIG.c \ c-tokenize.lex version.h.in \ scmconfig.h.top libgettext.h unidata_to_charset.pl libguile.map # $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) \ @@ -674,8 +673,8 @@ $(DOT_X_FILES) $(EXTRA_DOT_X_FILES): scmconfig.h snarf.= h guile-snarf.in =20 $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): scmconfig.h snarf.h guile-snarf-d= ocs.in guile_filter_doc_snarfage$(EXEEXT) =20 -error.x: cpp_err_symbols.c -posix.x: cpp_sig_symbols.c +error.x: cpp-E.c +posix.x: cpp-SIG.c load.x: libpath.h =20 alldotdocfiles =3D $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) @@ -710,50 +709,57 @@ schemelib_DATA =3D guile-procedures.txt ## Add -MG to make the .x magic work with auto-dep code. MKDEP =3D gcc -M -MG $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) =20 -cpp_err_symbols.c: cpp_err_symbols.in cpp_cnvt.awk - $(AWK) -f $(srcdir)/cpp_cnvt.awk < $(srcdir)/cpp_err_symbols.in > \ - cpp_err_symbols.tmp - mv cpp_err_symbols.tmp cpp_err_symbols.c - -cpp_sig_symbols.c: cpp_sig_symbols.in cpp_cnvt.awk - $(AWK) -f $(srcdir)/cpp_cnvt.awk < $(srcdir)/cpp_sig_symbols.in > \ - cpp_sig_symbols.tmp - mv cpp_sig_symbols.tmp cpp_sig_symbols.c - -## Create a new version of the cpp_sig_symbols.in file, including all SIGX= XX -## macros defined on this platform. -check_signals: - gcc -undef -dM -E $(srcdir)/cpp_signal.c | $(EGREP) ' SIG[A-Z]+' \ - | cut -f2 -d' ' | sort > cpp_sig_symbols_here - diff -u $(srcdir)/cpp_sig_symbols.in cpp_sig_symbols_here \ - | $(EGREP) '^\+S' \ - | cut -c2- > cpp_sig_symbols_diff - if test -s cpp_sig_symbols_diff ; then \ - cat $(srcdir)/cpp_sig_symbols.in cpp_sig_symbols_diff \ - | sort > cpp_sig_symbols_new ;\ - echo "cpp_sig_symbols_new has the following additions:" ;\ - cat cpp_sig_symbols_diff ;\ - else echo "No new symbols found."; \ - fi - -## Likewise for cpp_err_symbols.in. -check_errnos: - gcc -undef -dM -E $(srcdir)/cpp_errno.c | $(EGREP) ' E.+' \ - | cut -f2 -d' ' | sort > cpp_err_symbols_here - diff -u $(srcdir)/cpp_err_symbols.in cpp_err_symbols_here \ - | $(EGREP) '^\+E' \ - | cut -c2- > cpp_err_symbols_diff - if test -s cpp_err_symbols_diff ; then \ - cat $(srcdir)/cpp_err_symbols.in cpp_err_symbols_diff \ - | sort > cpp_err_symbols_new ;\ - echo "cpp_err_symbols_new has the following additions:" ;\ - cat cpp_err_symbols_diff ;\ - else echo "No new symbols found."; \ - fi + +# This page is for maintenance of the lists of CPP symbols that are eventu= ally +# included in error.c (=E2=80=98errno=E2=80=99 values: E*) and posix.c (si= gnal names: SIG*), +# in the funcs scm_init_{error,posix}, respectively. +# +# The lists (files cpp-{E,SIG}.syms) are not included verbatim, but proces= sed +# (via pattern rule =E2=80=98.syms.c=E2=80=99 below) so that each CPP symb= ol is transformed to +# fragment of #ifdef'd C code that defines a Scheme variable of the same n= ame. +# The resulting files, cpp-{E,SIG}.c, are the ones #include:d. +# +# To maintain the (source) lists of symbols, we use a GCC-specific feature +# to list all symbols #define:d when expanding <{errno,signal}.h>, grep +# the output for {E,SIG}*, massage the result into a usable form, and +# construct a union of the current and new symbols. This is written to +# files cpp-{E,SIG}.syms.NEW for review. If things look ok, you can then +# "mv foo.NEW foo" and commit. Generating the foo.NEW files and showing +# an informative message is the job of targets chknew-{E,SIG}. + +# For each line in foo.syms, transform: +# SYMBOL +# to: +# #ifdef SYMBOL +# scm_c_define ("SYMBOL", scm_from_int (SYMBOL)); +# #endif +# writing output to foo.c. +.syms.c: + sed 's/.*/#ifdef &\nscm_c_define ("&", scm_from_int (&));\n#endif/' \ + $< > $@T + mv $@T $@ + +# Write $(srcdir)/cpp-{E,SIG}.syms.NEW if there are any not-yet-seen +# ("new" to us) E* or SIG* symbols in or , respectivel= y. +chknew-E chknew-SIG: + @bit=3D`echo $@ | sed s/^chknew-//` ; \ + old=3D"$(srcdir)/cpp-$$bit.syms" ; \ + echo "#include <$${bit}.h>" \ + | sed 's/E/errno/;s/SIG/signal/' \ + | gcc -undef -dM -E - \ + | sed 's/^#define //;/^'$$bit'[A-Z][A-Z]*/!d;s/ .*//' \ + | sort | diff -u $$old - | sed '1,2d;/^+/!d;s/^.//' \ + > TMP ; \ + if [ -s TMP ] ; then new=3D"$$old.NEW" ; \ + cat $$old TMP | sort > $$new ; \ + echo "$$new: `sed -n '$$=3D' TMP` new symbol(s)." ; \ + sed 's/^/ /' TMP ; \ + else echo "No new symbols found." ; \ + fi ; rm TMP + + =20 MOSTLYCLEANFILES =3D \ - cpp_err_symbols_here cpp_err_symbols_diff cpp_err_symbols_new \ - cpp_sig_symbols_here cpp_sig_symbols_diff cpp_sig_symbols_new \ version.h version.h.tmp \ scmconfig.h scmconfig.h.tmp =20 diff --git a/libguile/cpp-E.syms b/libguile/cpp-E.syms new file mode 100644 index 0000000..67b897c --- /dev/null +++ b/libguile/cpp-E.syms @@ -0,0 +1,122 @@ +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EADV +EAFNOSUPPORT +EAGAIN +EALREADY +EBADE +EBADF +EBADFD +EBADMSG +EBADR +EBADRQC +EBADSLT +EBFONT +EBUSY +ECHILD +ECHRNG +ECOMM +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDEADLOCK +EDESTADDRREQ +EDOM +EDOTDOT +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +EISNAM +EL2HLT +EL2NSYNC +EL3HLT +EL3RST +ELIBACC +ELIBBAD +ELIBEXEC +ELIBMAX +ELIBSCN +ELNRNG +ELOOP +EMFILE +EMLINK +EMSGSIZE +EMULTIHOP +ENAMETOOLONG +ENAVAIL +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOANO +ENOBUFS +ENOCSI +ENODATA +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOLINK +ENOMEM +ENOMSG +ENONET +ENOPKG +ENOPROTOOPT +ENOSPC +ENOSR +ENOSTR +ENOSYS +ENOTBLK +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTNAM +ENOTSOCK +ENOTTY +ENOTUNIQ +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EREMCHG +EREMOTE +EREMOTEIO +ERESTART +EROFS +ESHUTDOWN +ESOCKTNOSUPPORT +ESPIPE +ESRCH +ESRMNT +ESTALE +ESTRPIPE +ETIME +ETIMEDOUT +ETOOMANYREFS +ETXTBSY +EUCLEAN +EUNATCH +EUSERS +EWOULDBLOCK +EXDEV +EXFULL diff --git a/libguile/cpp-SIG.syms b/libguile/cpp-SIG.syms new file mode 100644 index 0000000..2118d87 --- /dev/null +++ b/libguile/cpp-SIG.syms @@ -0,0 +1,36 @@ +SIGABRT +SIGALRM +SIGBREAK +SIGBUS +SIGCHLD +SIGCLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIO +SIGIOT +SIGKILL +SIGPIPE +SIGPOLL +SIGPROF +SIGPWR +SIGQUIT +SIGSEGV +SIGSTKFLT +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGUNUSED +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ diff --git a/libguile/cpp_cnvt.awk b/libguile/cpp_cnvt.awk deleted file mode 100644 index 1e6c094..0000000 --- a/libguile/cpp_cnvt.awk +++ /dev/null @@ -1,7 +0,0 @@ -# Converts a list of symbols into C expressions which define the symbols -# in Guile. -{ -print "#ifdef " $0; -print "scm_c_define (\""$0"\", scm_from_int ("$0"));"; -print "#endif" -} diff --git a/libguile/cpp_err_symbols.in b/libguile/cpp_err_symbols.in deleted file mode 100644 index 67b897c..0000000 --- a/libguile/cpp_err_symbols.in +++ /dev/null @@ -1,122 +0,0 @@ -E2BIG -EACCES -EADDRINUSE -EADDRNOTAVAIL -EADV -EAFNOSUPPORT -EAGAIN -EALREADY -EBADE -EBADF -EBADFD -EBADMSG -EBADR -EBADRQC -EBADSLT -EBFONT -EBUSY -ECHILD -ECHRNG -ECOMM -ECONNABORTED -ECONNREFUSED -ECONNRESET -EDEADLK -EDEADLOCK -EDESTADDRREQ -EDOM -EDOTDOT -EDQUOT -EEXIST -EFAULT -EFBIG -EHOSTDOWN -EHOSTUNREACH -EIDRM -EILSEQ -EINPROGRESS -EINTR -EINVAL -EIO -EISCONN -EISDIR -EISNAM -EL2HLT -EL2NSYNC -EL3HLT -EL3RST -ELIBACC -ELIBBAD -ELIBEXEC -ELIBMAX -ELIBSCN -ELNRNG -ELOOP -EMFILE -EMLINK -EMSGSIZE -EMULTIHOP -ENAMETOOLONG -ENAVAIL -ENETDOWN -ENETRESET -ENETUNREACH -ENFILE -ENOANO -ENOBUFS -ENOCSI -ENODATA -ENODEV -ENOENT -ENOEXEC -ENOLCK -ENOLINK -ENOMEM -ENOMSG -ENONET -ENOPKG -ENOPROTOOPT -ENOSPC -ENOSR -ENOSTR -ENOSYS -ENOTBLK -ENOTCONN -ENOTDIR -ENOTEMPTY -ENOTNAM -ENOTSOCK -ENOTTY -ENOTUNIQ -ENXIO -EOPNOTSUPP -EOVERFLOW -EPERM -EPFNOSUPPORT -EPIPE -EPROTO -EPROTONOSUPPORT -EPROTOTYPE -ERANGE -EREMCHG -EREMOTE -EREMOTEIO -ERESTART -EROFS -ESHUTDOWN -ESOCKTNOSUPPORT -ESPIPE -ESRCH -ESRMNT -ESTALE -ESTRPIPE -ETIME -ETIMEDOUT -ETOOMANYREFS -ETXTBSY -EUCLEAN -EUNATCH -EUSERS -EWOULDBLOCK -EXDEV -EXFULL diff --git a/libguile/cpp_errno.c b/libguile/cpp_errno.c deleted file mode 100644 index 32556a3..0000000 --- a/libguile/cpp_errno.c +++ /dev/null @@ -1,9 +0,0 @@ -/* this file is processed by gcc with special options to extract - a list of errno codes. */ -#include - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ diff --git a/libguile/cpp_sig_symbols.in b/libguile/cpp_sig_symbols.in deleted file mode 100644 index 2118d87..0000000 --- a/libguile/cpp_sig_symbols.in +++ /dev/null @@ -1,36 +0,0 @@ -SIGABRT -SIGALRM -SIGBREAK -SIGBUS -SIGCHLD -SIGCLD -SIGCONT -SIGFPE -SIGHUP -SIGILL -SIGINT -SIGIO -SIGIOT -SIGKILL -SIGPIPE -SIGPOLL -SIGPROF -SIGPWR -SIGQUIT -SIGSEGV -SIGSTKFLT -SIGSTOP -SIGSYS -SIGTERM -SIGTRAP -SIGTSTP -SIGTTIN -SIGTTOU -SIGUNUSED -SIGURG -SIGUSR1 -SIGUSR2 -SIGVTALRM -SIGWINCH -SIGXCPU -SIGXFSZ diff --git a/libguile/cpp_signal.c b/libguile/cpp_signal.c deleted file mode 100644 index e740ba5..0000000 --- a/libguile/cpp_signal.c +++ /dev/null @@ -1,9 +0,0 @@ -/* this file is processed by gcc with special options to extract - a list of signal numbers. */ -#include - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ diff --git a/libguile/error.c b/libguile/error.c index bcbcd9c..a582c86 100644 --- a/libguile/error.c +++ b/libguile/error.c @@ -285,7 +285,7 @@ scm_misc_error (const char *subr, const char *message, = SCM args) void scm_init_error () { -#include "libguile/cpp_err_symbols.c" +#include "libguile/cpp-E.c" #include "libguile/error.x" } =20 diff --git a/libguile/posix.c b/libguile/posix.c index 6276478..a28cfa3 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -2195,7 +2195,7 @@ scm_init_posix () scm_c_define ("LOCK_NB", scm_from_int (LOCK_NB)); #endif =20 -#include "libguile/cpp_sig_symbols.c" +#include "libguile/cpp-SIG.c" #include "libguile/posix.x" } =20 --=20 1.6.3.2 --=-=-=--