* Re: PATCH: zsh-3.1.5-pws-7: another go at signames @ 1999-02-09 7:01 Matt Armstrong 1999-02-09 11:26 ` PATCH: zsh-3.1.5-pws-7: yet more signames Peter Stephenson 0 siblings, 1 reply; 3+ messages in thread From: Matt Armstrong @ 1999-02-09 7:01 UTC (permalink / raw) To: zsh-workers Peter Stephenson <pws@ibmth.df.unipi.it> writes: > There was another, more drastic problem with what Matt had: it > required you to know all the possible signals, since you never got > to see the names if you didn't know them already. That's pretty > hairy, given the stuff that gets shoved into OSes --- it would have > needed major additions just for AIX here. Yes. I considered this as part of porting zsh to a platform. > This is pretty much Bart's idea above. (It still needs the right > signal.h, but so does every other idea.) Not my original scheme. It always gets the right one because it relies on the compiler to find it, not configure. The signal.h on a cygwin system can be pretty much anywhere. On my machine it is at /cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/include/sys/signal.h. Also, if the point is to support cross compiling, I don't think the fixed list of header locations in configure.in will cut it. It will likely pick up the signal.h for the host system, not the target (though, I have to admit I've never cross compiled from one unix to another -- maybe the same set of headers is typically used?). It took me a while to figure out that zsh's "kill -l" listed only ZERR because configure wasn't finding my signal.h. (maybe I should consider this part of porting zsh to a new platform! :-) > I managed to get an identical signames.c to the one before. Matt, > does this fix your problems? Fortunately, cygwin lets me mount the path mentioned above to /usr/include. This lets configure find the right signal.h. And, what really counts, it creates a correct signames.c! If we stick with the improved AWK based scheme, I'll add a Cygwin section to Etc/MACHINES describing how people should create their /usr/include and that they should do it before running configure. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH: zsh-3.1.5-pws-7: yet more signames 1999-02-09 7:01 PATCH: zsh-3.1.5-pws-7: another go at signames Matt Armstrong @ 1999-02-09 11:26 ` Peter Stephenson 0 siblings, 0 replies; 3+ messages in thread From: Peter Stephenson @ 1999-02-09 11:26 UTC (permalink / raw) To: zsh-workers "Matt Armstrong" wrote: > The signal.h on a cygwin system can be pretty much anywhere. On my > machine it is at > /cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/include/sys/signal.h. Yuk. The trouble is, you definitely need the original list of names. See below. > Also, if the point is to support cross compiling, I don't think the > fixed list of header locations in configure.in will cut it. Yes, no argument here. Plan #3 (which uses plan #2 of yesterday) goes one better by #include'ing signal.h when configuring, and looking at what cpp produces to find out what files are actually included. This list is then checked for signal definitions. In principal this can fix cross-compilation worries, though it requires that $CPP is set to a preprocessor with the correct include path built into it, and that I don't know about. Also, we're at the mercy of output formats for cpp. I've assumed that it will always look like #<space or tab><anything>"<name here>" --- does anyone know of a recalcitrant preprocessor? Anyway, I left the old list there as a backup, so we should be no worse off. One other fix: now that we can rely on the signal number being replaced only for real signals, I have widened the test in signames1.awk so that it will match any #define SIG... without a parenthesis next, and so long as that expands to a number later on we get the signal. Again, it's possible some very unfriendly definitions can mess this about. It requires, for example, that the `real' definition comes first. For example, #define SIGABRT 6 /* (*) abort process */ #define SIGIOT SIGABRT /* abort (terminate) process */ still works OK because it gets to SIGABRT first and so doesn't try to assign SIGIOT to signal 6. (Arguably zsh should know that SIGIOT should be a synonym for SIGABRT, but that's a different question.) Another subtlety I found on SunOS: #define _SIGRTMIN 38 /* first (highest-priority) realtime signal */ #define SIGRTMIN _sysconf(_SC_SIGRT_MIN) /* first realtime signal */ Here, to get anything, we need to use the former --- this corresponds with what's in the native csh. I've allowed signames1.awk to use _SIGXXX as if it were SIGXXX. This used to happen before. The first definition encountered will be used. I have had good results with this on: AIX 3.2, HPUX 10/20, IRIX 6.2, SunOS 5.6 with the comment above (all, however, with gcc, though I checked the form of the cc -E output), but it certainly needs testing as widely as possible. --- Src/signames1.awk.sn3 Mon Feb 8 18:07:02 1999 +++ Src/signames1.awk Tue Feb 9 12:18:56 1999 @@ -1,9 +1,19 @@ +# This is an awk script which finds out what the possibilities for +# the signal names are, and dumps them out so that cpp can turn them +# into numbers. Since we don't need to decide here what the +# real signals are, we can afford to be generous about definitions, +# in case the definitions are in terms of other definitions. +# However, we need to avoid definitions with parentheses, which will +# mess up the syntax. BEGIN { printf "#include <signal.h>\n\n" } -/^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ]*[1-9][0-9]*/ { +/^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ][\t ]*[^(\t ]/ { sigindex = index($0, "SIG") sigtail = substr($0, sigindex, 80) split(sigtail, tmp) signam = substr(tmp[1], 4, 20) - printf("XXNAMES XXSIG%s SIG%s\n", signam, signam) + if (substr($0, sigindex-1, 1) == "_") + printf("XXNAMES XXSIG%s _SIG%s\n", signam, signam) + else + printf("XXNAMES XXSIG%s SIG%s\n", signam, signam) } --- configure.in.sn3 Mon Feb 8 10:43:29 1999 +++ configure.in Tue Feb 9 12:03:49 1999 @@ -664,12 +664,27 @@ dnl Where is <signal.h> located? Needed as input for signals.awk AC_CACHE_CHECK(where signal.h is located, zsh_cv_path_signal_h, -[for SIGNAL_H in /usr/include/bsd/sys/signal.h dnl Next - /usr/include/asm/signum.h dnl alpha-Linux - /usr/include/asm/signal.h dnl Linux 1.3.0 and above - /usr/include/linux/signal.h dnl Linux up to 1.2.11 - /usr/include/sys/signal.h dnl Almost everybody else - /dev/null; dnl Just in case we fall through +[dnl Look at the output from the preprocessor. +dnl We should get lines of the form `# 1 "/usr/include/signal.h"' +dnl The following assumes the real definitions are in a file which +dnl contains the name `sig'; we could relax this if necessary, +dnl but then you can get a rather long list of files to test. +echo "#include <signal.h>" > nametmp.c +sigfile_list="`$CPP nametmp.c | sed -n -e 's/^#[ ].*\"\(.*\)\"/\1/p' | +$AWK '{ if (\$1 ~ \"sig\") files[[\$1]] = \$1 } + END { for (var in files) print var }'`" +rm -f nametmp.c +if test -z "$sigfile_list"; then + dnl In case we don't get the stuff from the preprocesor, use the old + dnl list of standard places. + sigfile_list="/usr/include/bsd/sys/signal.h +/usr/include/asm/signum.h +/usr/include/asm/signal.h +/usr/include/linux/signal.h +/usr/include/sys/signal.h +/dev/null" +fi +for SIGNAL_H in $sigfile_list do test -f $SIGNAL_H && \ grep '#[ ]*define[ ][ ]*SIG[0-9A-Z]*[ ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \ -- Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH zsh-3.1.5-pws-7: cygwin make fixes @ 1999-02-08 16:54 Bart Schaefer 1999-02-08 17:40 ` PATCH: zsh-3.1.5-pws-7: another go at signames Peter Stephenson 0 siblings, 1 reply; 3+ messages in thread From: Bart Schaefer @ 1999-02-08 16:54 UTC (permalink / raw) To: Peter Stephenson, zsh-workers On Feb 8, 11:29am, Peter Stephenson wrote: } Subject: Re: PATCH zsh-3.1.5-pws-7: cygwin make fixes } } As configure.in contains AC_TRY_RUN statements, it looks to me } unlikely that the zsh build system supports cross-compilation anyway I thought that might be it, but: } - signed to unsigned casting } - if tgetent accepts NULL } - if rlim_t is quad_t } - if rlim_t is unsigned These four are just testing compiler capability, and can be done without using the cross-compilation options (though I don't know if they ARE done that way); and as you point out all but } - if named FIFOs work can be turned off (or should be) by specifying no dynamic module loading. Signals are pretty basic to the shell with or without dynamic modules. Seems to me it should be possible to do this particular thing with just the preprocessor, rather than needing to compile and execute a program. use the awk script to generate a bunch of #defines for every possible signal in the header, feed that through "cc -E ...." and then awk or sed the output again to extract the stuff zsh needs. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH: zsh-3.1.5-pws-7: another go at signames 1999-02-08 16:54 PATCH zsh-3.1.5-pws-7: cygwin make fixes Bart Schaefer @ 1999-02-08 17:40 ` Peter Stephenson 0 siblings, 0 replies; 3+ messages in thread From: Peter Stephenson @ 1999-02-08 17:40 UTC (permalink / raw) To: Zsh hackers list "Bart Schaefer" wrote: > Seems to me it should be possible to do this particular thing with just > the preprocessor, rather than needing to compile and execute a program. > use the awk script to generate a bunch of #defines for every possible > signal in the header, feed that through "cc -E ...." and then awk or sed > the output again to extract the stuff zsh needs. This is a good idea. There was another, more drastic problem with what Matt had: it required you to know all the possible signals, since you never got to see the names if you didn't know them already. That's pretty hairy, given the stuff that gets shoved into OSes --- it would have needed major additions just for AIX here. This is pretty much Bart's idea above. (It still needs the right signal.h, but so does every other idea.) signames1.awk does a first pass through the signal header, extracting everything in sight, and dumping lines like XXNAMES XXSIGHUP SIGHUP to sigtmp.c. This gets preprocessed; it's up to cpp to turn the last word, SIGHUP here, into a number, and these get dumped to sigtmp.out. Then signames2.awk runs on that; it's an only slightly modified version of signames.awk which matches only those lines where the substitution of the signal number has taken place. I managed to get an identical signames.c to the one before. Matt, does this fix your problems? You ought to be able to get it to work by running config.status in the top directory, then removing Makemod and Makemod.in in Src and running make there. signames.awk and now signames2.awk seem deliberately to stop before 60. Is this known to be right? I have extra definitions for signals 60..63, separated from the rest. I take it that means somebody's thought about this. The only problem I know of over and above the existing ones is that now $(CPP) has to work, which zsh didn't need before. But configure should make a good job of finding that. I can't think of a good reason why anything more than `#include <signal.h>' should be necessary in sigtmp.c. Note this patch doesn't delete the old signames.awk, which nonetheless becomes redundant. I hope. --- Config/defs.mk.sn2 Mon Feb 8 10:43:29 1999 +++ Config/defs.mk Mon Feb 8 18:12:08 1999 @@ -44,6 +44,7 @@ # compilation CC = @CC@ +CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ DEFS = @DEFS@ CFLAGS = @CFLAGS@ --- Src/zsh.mdd.sn2 Mon Feb 8 10:44:28 1999 +++ Src/zsh.mdd Mon Feb 8 18:14:39 1999 @@ -12,8 +12,11 @@ prototypes.h hashtable.h ztype.h" :<<\Make -signames.c: signames.awk ../config.h @SIGNAL_H@ - $(AWK) -f $(sdir)/signames.awk @SIGNAL_H@ > $@ +signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@ + $(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c + $(CPP) sigtmp.c >sigtmp.out + $(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@ + rm -f sigtmp.c sigtmp.out sigcount.h: signames.c grep 'define.*SIGCOUNT' signames.c > $@ --- /dev/null Mon Feb 8 18:16:14 1999 +++ Src/signames1.awk Mon Feb 8 18:07:02 1999 @@ -0,0 +1,9 @@ +BEGIN { printf "#include <signal.h>\n\n" } + +/^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ]*[1-9][0-9]*/ { + sigindex = index($0, "SIG") + sigtail = substr($0, sigindex, 80) + split(sigtail, tmp) + signam = substr(tmp[1], 4, 20) + printf("XXNAMES XXSIG%s SIG%s\n", signam, signam) +} --- /dev/null Mon Feb 8 18:16:14 1999 +++ Src/signames2.awk Mon Feb 8 18:07:52 1999 @@ -0,0 +1,100 @@ +# +# {g,n}awk script to generate signames.c +# This version relies on the previous output of the preprocessor +# on sigtmp.c, sigtmp.out, which is in turn generated by signames1.awk. +# +# NB: On SunOS 4.1.3 - user-functions don't work properly, also \" problems +# Without 0 + hacks some nawks compare numbers as strings +# +/^XXNAMES XXSIG[A-Z][A-Z0-9]* [1-9][0-9]*/ { + sigindex = index($0, "SIG") + sigtail = substr($0, sigindex, 80) + split(sigtail, tmp) + signam = substr(tmp[1], 4, 20) + signum = tmp[2] + if (sig[signum] == "") { + sig[signum] = signam + if (0 + max < 0 + signum && signum < 60) + max = signum + if (signam == "ABRT") { msg[signum] = "abort" } + if (signam == "ALRM") { msg[signum] = "alarm" } + if (signam == "BUS") { msg[signum] = "bus error" } + if (signam == "CHLD") { msg[signum] = "death of child" } + if (signam == "CLD") { msg[signum] = "death of child" } + if (signam == "CONT") { msg[signum] = "continued" } + if (signam == "EMT") { msg[signum] = "EMT instruction" } + if (signam == "FPE") { msg[signum] = "floating point exception" } + if (signam == "HUP") { msg[signum] = "hangup" } + if (signam == "ILL") { msg[signum] = "illegal hardware instruction" } + if (signam == "INFO") { msg[signum] = "status request from keyboard" } + if (signam == "INT") { msg[signum] = "interrupt" } + if (signam == "IO") { msg[signum] = "i/o ready" } + if (signam == "IOT") { msg[signum] = "IOT instruction" } + if (signam == "KILL") { msg[signum] = "killed" } + if (signam == "LOST") { msg[signum] = "resource lost" } + if (signam == "PIPE") { msg[signum] = "broken pipe" } + if (signam == "POLL") { msg[signum] = "pollable event occurred" } + if (signam == "PROF") { msg[signum] = "profile signal" } + if (signam == "PWR") { msg[signum] = "power fail" } + if (signam == "QUIT") { msg[signum] = "quit" } + if (signam == "SEGV") { msg[signum] = "segmentation fault" } + if (signam == "SYS") { msg[signum] = "invalid system call" } + if (signam == "TERM") { msg[signum] = "terminated" } + if (signam == "TRAP") { msg[signum] = "trace trap" } + if (signam == "URG") { msg[signum] = "urgent condition" } + if (signam == "USR1") { msg[signum] = "user-defined signal 1" } + if (signam == "USR2") { msg[signum] = "user-defined signal 2" } + if (signam == "VTALRM") { msg[signum] = "virtual time alarm" } + if (signam == "WINCH") { msg[signum] = "window size changed" } + if (signam == "XCPU") { msg[signum] = "cpu limit exceeded" } + if (signam == "XFSZ") { msg[signum] = "file size limit exceeded" } + } +} + +END { + ps = "%s" + ifdstr = sprintf("# ifdef USE_SUSPENDED\n\t%csuspended%s%c,\n%s else\n\t%cstopped%s%c,\n# endif\n", 34, ps, 34, "#", 34, ps, 34) + + printf "/** signames.c **/\n" + printf "/** architecture-customized signames.c for zsh **/\n" + printf "\n" + printf "#define SIGCOUNT\t%d\n", max + printf "\n" + printf "#include %czsh.mdh%c\n", 34, 34 + printf "\n" + printf "/**/\n" + printf "char *sigmsg[SIGCOUNT+2] = {\n" + printf "\t%c%s%c,\n", 34, "done", 34 + + for (i = 1; i <= 0 + max; i++) + if (msg[i] == "") { + if (sig[i] == "") + printf("\t%c%c,\n", 34, 34) + else if (sig[i] == "STOP") + printf ifdstr, " (signal)", " (signal)" + else if (sig[i] == "TSTP") + printf ifdstr, "", "" + else if (sig[i] == "TTIN") + printf ifdstr, " (tty input)", " (tty input)" + else if (sig[i] == "TTOU") + printf ifdstr, " (tty output)", " (tty output)" + else + printf("\t%cSIG%s%c,\n", 34, sig[i], 34) + } else + printf("\t%c%s%c,\n", 34, msg[i], 34) + print "\tNULL" + print "};" + print "" + print "/**/" + printf "char *sigs[SIGCOUNT+4] = {\n" + printf("\t%cEXIT%c,\n", 34, 34) + for (i = 1; i <= 0 + max; i++) + if (sig[i] == "") + printf("\t%c%d%c,\n", 34, i, 34) + else + printf("\t%c%s%c,\n", 34, sig[i], 34) + printf("\t%cZERR%c,\n", 34, 34) + printf("\t%cDEBUG%c,\n", 34, 34) + print "\tNULL" + print "};" +} -- Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-02-09 11:43 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1999-02-09 7:01 PATCH: zsh-3.1.5-pws-7: another go at signames Matt Armstrong 1999-02-09 11:26 ` PATCH: zsh-3.1.5-pws-7: yet more signames Peter Stephenson -- strict thread matches above, loose matches on Subject: below -- 1999-02-08 16:54 PATCH zsh-3.1.5-pws-7: cygwin make fixes Bart Schaefer 1999-02-08 17:40 ` PATCH: zsh-3.1.5-pws-7: another go at signames Peter Stephenson
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).