Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965780AbXEGQax (ORCPT ); Mon, 7 May 2007 12:30:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965764AbXEGQax (ORCPT ); Mon, 7 May 2007 12:30:53 -0400 Received: from smtp1.linux-foundation.org ([65.172.181.25]:38683 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965760AbXEGQaw (ORCPT ); Mon, 7 May 2007 12:30:52 -0400 Date: Mon, 7 May 2007 09:28:32 -0700 (PDT) From: Linus Torvalds To: Esben Nielsen cc: Ingo Molnar , Balbir Singh , linux-kernel@vger.kernel.org, Andrew Morton , Con Kolivas , Nick Piggin , Mike Galbraith , Arjan van de Ven , Peter Williams , Thomas Gleixner , caglar@pardus.org.tr, Willy Tarreau , Gene Heskett , Mark Lord , Zach Carter , buddabrod Subject: Re: [patch] CFS scheduler, -v8 In-Reply-To: Message-ID: References: <20070501212223.GA29867@elte.hu> <463854F3.3020403@linux.vnet.ibm.com> <20070502100545.GA6857@elte.hu> <46386F2B.9050307@linux.vnet.ibm.com> <20070502111742.GA18132@elte.hu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1670 Lines: 43 On Mon, 7 May 2007, Esben Nielsen wrote: > > What is (long)(a-b) ? I have tried to look it up in the C99 standeard but I > can't find it. Maybe it is in the referred LIA-1 standeard, which I can't find > with google. I don't worry about non-2's-complement machines (they don't exist, and likely won't exist in the future either). So I worry about compilers rewriting my code. So "(long)(a-b) < 0" (with "a" and "b" being unsigned long) is basically a portable way of testing the high bit of the result. > I think the best would be to use "a-b > ULONG_MAX/2" when you mean "a that should be completely portable. That certainly works too, but the difference is irrelevant, since Linux is unlikely to work on insane machines anyway (ie we do make a lot of other assumptions about the architecture, being two's-complement is the least of those). So you basically shouldn't worry about hardware: everybody is pretty much the same. You should worry about *compilers* - that's where the differences show up. So "(long)(a-b)" may be "implementation defined" (but since implementations are all 2's complement, we don't care), but a signed "(a-b)" that over/overflows is *undefined*, and that is much worse because it means that the compiler can do some funky stuff, and _that_ is a real practical worry. And no, I also don't worry about porting Linux to 18-bit machines, or to ternary CPU's. Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/