From owner-freebsd-amd64@FreeBSD.ORG Wed Feb 28 07:52:49 2007 Return-Path: X-Original-To: freebsd-amd64@freebsd.org Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5A6C816A47F; Wed, 28 Feb 2007 07:52:49 +0000 (UTC) (envelope-from vd@datamax.bg) Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21]) by mx1.freebsd.org (Postfix) with ESMTP id 1862F13C569; Wed, 28 Feb 2007 07:52:45 +0000 (UTC) (envelope-from vd@datamax.bg) Received: from qlovarnika.bg.datamax (qlovarnika.bg.datamax [192.168.10.2]) by jengal.datamax.bg (Postfix) with SMTP id 59BD1B84A; Wed, 28 Feb 2007 09:52:44 +0200 (EET) Received: (nullmailer pid 36515 invoked by uid 1002); Wed, 28 Feb 2007 07:52:44 -0000 Date: Wed, 28 Feb 2007 09:52:44 +0200 From: Vasil Dimov To: John Baldwin Message-ID: <20070228075244.GA36076@qlovarnika.bg.datamax> References: <200702271920.l1RJK8fo042824@freefall.freebsd.org> <200702271454.14774.jhb@freebsd.org> <20070228064337.GA34966@qlovarnika.bg.datamax> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070228064337.GA34966@qlovarnika.bg.datamax> Cc: Daniel Crandall , bug-followup@FreeBSD.org, freebsd-amd64@freebsd.org, rwatson@freebsd.org, wollman@freebsd.org, kensmith@freebsd.org Subject: Re: amd64/109584: zdump doesn't work X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vd@FreeBSD.org List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2007 07:52:49 -0000 On Wed, Feb 28, 2007 at 08:43:37 +0200, Vasil Dimov wrote: [...] > it hangs in this loop: > > src/lib/libc/stdtime/localtime.c: > 1320 y = EPOCH_YEAR; > 1321 #define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) > 1322 while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) { > 1323 long newy; > 1324 > 1325 newy = y + days / DAYSPERNYEAR; > 1326 if (days < 0) > 1327 --newy; > 1328 days -= (newy - y) * DAYSPERNYEAR + > 1329 LEAPS_THRU_END_OF(newy - 1) - > 1330 LEAPS_THRU_END_OF(y - 1); > 1331 y = newy; > 1332 } > > where days oscillates between -1 and 365, y and newy between > -292277022654 and -292277022655. E.g. try so see what happens if you > enter the loop with days=365 and y=-292277022655. What about this patch: --- localtime.c_infloop.diff begins here --- Index: localtime.c =================================================================== RCS file: /home/ncvs/src/lib/libc/stdtime/localtime.c,v retrieving revision 1.41 diff -u -r1.41 localtime.c --- localtime.c 19 Jan 2007 01:16:35 -0000 1.41 +++ localtime.c 28 Feb 2007 07:40:24 -0000 @@ -1326,8 +1326,8 @@ if (days < 0) --newy; days -= (newy - y) * DAYSPERNYEAR + - LEAPS_THRU_END_OF(newy - 1) - - LEAPS_THRU_END_OF(y - 1); + LEAPS_THRU_END_OF(newy - (newy > 0 ? 1 : -1)) - + LEAPS_THRU_END_OF(y - (y > 0 ? 1 : -1)); y = newy; } tmp->tm_year = y - TM_YEAR_BASE; --- localtime.c_infloop.diff ends here --- -- Vasil Dimov gro.DSBeerF@dv % Everything should be made as simple as possible, but not simpler. -- Albert Einstein