From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 943 invoked from network); 12 Dec 1996 17:52:52 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 12 Dec 1996 17:52:52 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA08202; Thu, 12 Dec 1996 12:42:50 -0500 (EST) Resent-Date: Thu, 12 Dec 1996 12:42:50 -0500 (EST) Message-Id: <199612121741.SAA17525@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: zsh-3.0.1-test2 compilation problem In-reply-to: "Zoltan Hidvegi"'s message of "Thu, 12 Dec 1996 15:36:49 MET." <199612121436.PAA10835@bolyai.cs.elte.hu> Date: Thu, 12 Dec 1996 18:41:17 +0100 From: Peter Stephenson Resent-Message-ID: <"qe0P-.0.402.QG4io"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2565 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zoltan Hidvegi wrote: > I know this preprocessor trickery is ugly but the alternatives are not much > better either. We can generate limits with an awk script but it took more > than a year to make the awk script generating signames.h portable. And for > that we have to find out where are the RLIMIT_ macros defined (that seems > to be always in /usr/include/sys/resource.h but on Linux it is under asm). Certainly true, but (1) we can start from that other awk script. I hacked up the following which worked fine on a random sample of Sgi, HPUX, SunOS 4, Solaris 2 and OSF/1 workstations with the standard awk. The worst problem may be sneaky definitions which define the signal in terms of some other cpp token instead of an integer directly. I think we can only suck it and see. (Do `awk -f rlimits.awk /usr/include/sys/resource.h' unless the limits are elsewhere.) Note I've made the script exit with the status containing the number of limits it failed to find, so configure can print a warning, but supplied the bit of the CPP token (e.g. RSS, CORE, ... although those are of course handled) as the name, so it can compile anyway. (2) it shouldn't be too hard to make a list of possible locations for RLIMITS, let configure decide whether they exist (which it may well do anyway, thought we might have to check for files included from other files) and awk through the list of those which do exist. I thought I'd better see what people made of the script first, though. # # $Id:$ # # rlimits.awk: {g,n}awk script to generate rlimits.h # rewritten by Peter Stephenson from Geoff Wing # 's signames.awk # NB: On SunOS 4.1.3 - user-functions don't work properly, also \" problems # Without 0 + hacks some nawks compare numbers as strings # /^[\t ]*#[\t ]*define[\t _]*RLIMIT_[A-Z]*[\t ]*[0-9][0-9]*/ { limindex = index($0, "RLIMIT_") limtail = substr($0, limindex, 80) split(limtail, tmp) limnam = substr(tmp[1], 8, 20) limnum = tmp[2] limrev[limnam] = limnum if (lim[limnum] == "") { lim[limnum] = limnam if (limnum ~ /^[0-9]*$/) { if (limnam == "MEMLOCK") { msg[limnum] = "memorylocked" } if (limnam == "RSS") { msg[limnum] = "resident" } if (limnam == "VMEM") { msg[limnum] = "vmemorysize" } if (limnam == "NOFILE") { msg[limnum] = "descriptors" } if (limnam == "CORE") { msg[limnum] = "coredumpsize" } if (limnam == "STACK") { msg[limnum] = "stacksize" } if (limnam == "DATA") { msg[limnum] = "datasize" } if (limnam == "FSIZE") { msg[limnum] = "filesize" } if (limnam == "CPU") { msg[limnum] = "cputime" } if (limnam == "NPROC") { msg[limnum] = "maxproc" } if (limnam == "AS") { msg[limnum] = "addressspace" } if (limnam == "TCACHE") { msg[limnum] = "cachethreads" } } } } /^[\t ]*#[\t ]*define[\t _]*RLIM_NLIMITS[\t ]*[0-9][0-9]*/ { limindex = index($0, "RLIM_") limtail = substr($0, limindex, 80) split(limtail, tmp) nlimits = tmp[2] } END { if (limrev["MEMLOCK"] != "") { irss = limrev["RSS"] msg[irss] = "memoryuse" } ps = "%s" printf("%s\n%s\n\n%s\n", "/** rlimits.h **/", "/** architecture-customized rlimits.h for zsh **/", "static char *recs[RLIM_NLIMITS+1] = {") for (i = 0; i < 0 + nlimits; i++) if (msg[i] == "") { badlimit = badlimit + 1 printf("\t%c%s%c,\n", 034, lim[i], 034) } else printf("\t%c%s%c,\n", 034, msg[i], 034) print "\tNULL" print "};" print "" exit(badlimit) } -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.