| 1 | ############################################################################# | ||
| 2 | # | ||
| 3 | # Win32::ProcFarm::TickCount - method for safely comparing GetTickCount values | ||
| 4 | # | ||
| 5 | # Author: Toby Everett | ||
| 6 | # Revision: 2.15 | ||
| 7 | # Last Change: Patch to enable operations when 2**32 == 0 | ||
| 8 | ############################################################################# | ||
| 9 | # Copyright 1999, 2000, 2001 Toby Everett. All rights reserved. | ||
| 10 | # | ||
| 11 | # This file is distributed under the Artistic License. See | ||
| 12 | # http://www.ActiveState.com/corporate/artistic_license.htm or | ||
| 13 | # the license that comes with your perl distribution. | ||
| 14 | # | ||
| 15 | # For comments, questions, bugs or general interest, feel free to | ||
| 16 | # contact Toby Everett at teverett@alascom.att.com | ||
| 17 | ############################################################################# | ||
| 18 | |||
| 19 | package Win32::ProcFarm::TickCount; | ||
| 20 | |||
| 21 | use strict; | ||
| 22 | use vars qw($VERSION); | ||
| 23 | |||
| 24 | $VERSION = '2.15'; | ||
| 25 | |||
| 26 | sub compare { | ||
| 27 | my($a, $b) = @_; | ||
| 28 | |||
| 29 | $a = (int(($a+($a<0 ? 1-2**31 : 0))/2**31) % 2)*2**31 + $a % 2**31; | ||
| 30 | $b = (int(($b+($b<0 ? 1-2**31 : 0))/2**31) % 2)*2**31 + $b % 2**31; | ||
| 31 | |||
| 32 | $a == $b and return 0; | ||
| 33 | return (abs($a-$b) > 2**31 ? -1 : 1)*($a<=>$b); | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; |