Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0514ad1

Browse files
committed
Tweak AbsoluteTimeIsReal() to avoid compiler bugs on machines where
a > comparison against INT_MIN may do the wrong thing. Per suggestionfrom Andreas.
1 parent6ba959e commit0514ad1

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

‎src/include/utils/nabstime.h

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: nabstime.h,v 1.26 2000/06/09 01:11:15 tgl Exp $
10+
* $Id: nabstime.h,v 1.27 2000/11/18 05:41:45 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndefNABSTIME_H
1515
#defineNABSTIME_H
1616

17+
#include<limits.h>
1718
#include<time.h>
1819

1920
#include"fmgr.h"
@@ -78,37 +79,25 @@ typedef TimeIntervalData *TimeInterval;
7879
#defineCURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD)/* 2147483646 (2^31 - 2) */
7980
#defineNOEND_ABSTIME((AbsoluteTime) 0x7FFFFFFC)/* 2147483645 (2^31 - 3) */
8081
#defineBIG_ABSTIME((AbsoluteTime) 0x7FFFFFFB)/* 2147483644 (2^31 - 4) */
81-
82-
#if defined(_AIX)
83-
/*
84-
* AIX considers 2147483648 == -2147483648 (since they have the same bit
85-
* representation) but uses a different sign sense in a comparison to
86-
* these integer constants depending on whether the constant is signed
87-
* or not!
88-
*/
89-
#defineNOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
90-
#else
91-
#defineNOSTART_ABSTIME ((AbsoluteTime) 0x80000001)/* -2147483647 (- 2^31) */
92-
#endif/* _AIX */
82+
#defineNOSTART_ABSTIME((AbsoluteTime) INT_MIN)/* -2147483648 */
9383

9484
#defineINVALID_RELTIME ((RelativeTime) 0x7FFFFFFE)/* 2147483647 (2^31 - 1) */
9585

9686
#defineAbsoluteTimeIsValid(time) \
9787
((bool) ((time) != INVALID_ABSTIME))
9888

89+
/*
90+
* Because NOSTART_ABSTIME is defined as INT_MIN, there can't be any
91+
* AbsoluteTime values less than it. Therefore, we can code the test
92+
* "time > NOSTART_ABSTIME" as "time != NOSTART_ABSTIME", which avoids
93+
* compiler bugs on some platforms. --- tgl & az, 11/2000
94+
*/
9995
#defineAbsoluteTimeIsReal(time) \
100-
((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
101-
((AbsoluteTime) time) > NOSTART_ABSTIME))
96+
((bool) (((AbsoluteTime)(time)) < NOEND_ABSTIME && \
97+
((AbsoluteTime)(time)) != NOSTART_ABSTIME))
10298

10399
#defineRelativeTimeIsValid(time) \
104-
((bool) (((RelativeTime) time) != INVALID_RELTIME))
105-
106-
/*
107-
* getSystemTime
108-
*Returns system time.
109-
*/
110-
#definegetSystemTime() \
111-
((time_t) (time(0l)))
100+
((bool) (((RelativeTime) (time)) != INVALID_RELTIME))
112101

113102

114103
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp