From owner-freebsd-arch Mon Jan 7 5:23:40 2002 Delivered-To: freebsd-arch@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id E1C9237B400 for ; Mon, 7 Jan 2002 05:23:36 -0800 (PST) Received: from vigrid.com (pm3-pt52.pcnet.net [206.105.29.126]) by pcnet1.pcnet.com (8.12.1/8.12.1) with ESMTP id g07DMSrU003338; Mon, 7 Jan 2002 08:22:28 -0500 (EST) Message-ID: <3C39A340.81AD7F4C@vigrid.com> Date: Mon, 07 Jan 2002 08:31:44 -0500 From: Dan Eischen X-Mailer: Mozilla 4.74 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en MIME-Version: 1.0 To: Doug Rabson Cc: arch@freebsd.org Subject: Re: Request for review: getcontext, setcontext, etc References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Doug Rabson wrote: > > On Sun, 6 Jan 2002, Dan Eischen wrote: > > > I've got getcontext, setcontext, makecontext, and swapcontext > > implemented and would like to add them to libc. I've made the > > patch available at: > > > > http://people.freebsd.org/~deischen/ucontext/uc-libc-sys.diffs > > > > These are library level versions of these functions. Solaris > > has getcontext and setcontext as system calls. My intent is > > to replace libc_r's use of setjmp/longjmp and jmp_buf munging > > with these functions, so I don't want them as system calls. > > I also want to use them with the KSE-enabled threads library. > > Is there a reason that getcontext and setcontext need to be > > system calls? > > > > For those not familiar with these functions, see: > > > > http://www.opengroup.org/onlinepubs/007908799/xsh/ucontext.h.html > > As far as I can see from reading the code, in makecontext you pass the > value of argc as well as #argc arguments to the new context. The linux > version of makecontext (at least for ia64) doesn't appear to do this - it > just copies #argc longs worth of arguments over to the new stack. Ahh, re-reading the documentation does seem to suggest that the arguments don't include argc. I'll fix that. > The other difference with the linux version is that it uses va_arg(ap, > long) to read the arguments instead of va_arg(ap, int) which makes it > possible to pass 64bit arguments. The SUSv2 spec document does seem to > suggest that the arguments must be integers which makes the linux > behaviour wrong although its probably more useful than truncating > everything to 32bits. Well, even the new IEEE ratified POSIX spec suggests the parameters are integers: "The application shall ensure that the value of argc matches the number of integer arguments passed to func; otherwise, the behavior is undefined." I don't care; if you want to use long arguments, I can change it... -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message