From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3381 invoked by alias); 27 Nov 2003 15:33:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 3363 invoked from network); 27 Nov 2003 15:33:47 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by sources.redhat.com with SMTP; 27 Nov 2003 15:33:47 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1APO9L-0007G6-00 for ; Thu, 27 Nov 2003 16:33:47 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1APO9J-0007Fy-00 for ; Thu, 27 Nov 2003 16:33:45 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1APO9J-0007D6-00 for ; Thu, 27 Nov 2003 16:33:45 +0100 From: Jan Vroonhof Subject: Re: avoid unnecessary register saves for setjmp Date: Thu, 27 Nov 2003 15:41:00 -0000 Message-ID: References: <87ekvuup4s.fsf@egil.codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org Cc: gcc-patches@gcc.gnu.org X-Jans-Posting-Style: outside-news User-Agent: Gnus/5.1001 (Gnus v5.10.1) XEmacs/21.4 (Native Windows TTY Support, linux) Cancel-Lock: sha1:6TfGnDozFYII0op+lERHfBCjRHU= X-SW-Source: 2003-11/txt/msg02167.txt.bz2 Chris Lattner writes: >> To be fair, an argument against this change is that it would break >> code that uses setjmp and longjmp to implement coroutine linkage. >> (The set/get/make/swapcontext calls are better for this, but that >> doesn't mean everyone uses them.) Doesn't it also convert longjmp from an O(1) in to an O(nr off stack frames) operation? > > I don't believe that this is actually legal ANSI C. You can only return > to a place that has been setjmp'd to, there is no way to 'construct' a > jmpbuf. Likewise, you cannot setjmp, return from the setjmp'ing function, > then longjmp back to the 'dead' jmpbuf. It might not be ANSI C, but it does work on most systems for user level threading (essentially implementing swapcontext by direct manipulation of the jmbuf). There is lots of useful things people do with C that are not strictly ANSI/ISO C. In fact that kind of low level control is often exactly the reason to use C in the first place. Jan