zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: zsh-3.0.1-test2 compilation problem
Date: Thu, 12 Dec 1996 18:41:17 +0100	[thread overview]
Message-ID: <199612121741.SAA17525@sgi.ifh.de> (raw)
In-Reply-To: "Zoltan Hidvegi"'s message of "Thu, 12 Dec 1996 15:36:49 MET." <199612121436.PAA10835@bolyai.cs.elte.hu>

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 <pws@ifh.de> from Geoff Wing
# <mason@werple.apana.org.au>'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 <pws@ifh.de>       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.


  reply	other threads:[~1996-12-12 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-12 12:56 Thomas Winder
1996-12-12 14:36 ` Zoltan Hidvegi
1996-12-12 17:41   ` Peter Stephenson [this message]
1996-12-13  3:24     ` gwing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199612121741.SAA17525@sgi.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).