PostgreSQL Source Code git master
Loading...
Searching...
No Matches
private.h File Reference
#include "pgtime.h"
#include <limits.h>
#include <unistd.h>
Include dependency graph for private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TZDEFAULT   "/etc/localtime"
 
#define static_assert(cond)   extern int static_assert_check[(cond) ? 1 : -1]
 
#define GRANDPARENTED   "Local time zone must be set--see zic manual page"
 
#define ATTRIBUTE_FALLTHROUGH   pg_fallthrough
 
#define ATTRIBUTE_MAYBE_UNUSED   pg_attribute_unused()
 
#define ATTRIBUTE_NORETURN   pg_noreturn
 
#define ATTRIBUTE_PURE_114833
 
#define ATTRIBUTE_PURE_114833_HACK
 
#define EINVAL   ERANGE
 
#define ELOOP   EINVAL
 
#define ENAMETOOLONG   EINVAL
 
#define ENOMEM   EINVAL
 
#define ENOTCAPABLE   EINVAL
 
#define ENOTSUP   EINVAL
 
#define EOVERFLOW   EINVAL
 
#define INDEX_MAX   ((ptrdiff_t) min(PTRDIFF_MAX, SIZE_MAX))
 
#define TM_GMTOFF   tm_gmtoff
 
#define TM_ZONE   tm_zone
 
#define TYPE_BIT(type)   (CHAR_BIT * (ptrdiff_t) sizeof(type))
 
#define TYPE_SIGNED(type)   (((type) -1) < 0)
 
#define TWOS_COMPLEMENT(type)   (TYPE_SIGNED (type) && (! ~ (type) -1))
 
#define max(a, b)   ((a) > (b) ? (a) : (b))
 
#define min(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAXVAL(t, b)
 
#define MINVAL(t, b)    ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
 
#define TIME_T_MIN   MINVAL(pg_time_t, TYPE_BIT(pg_time_t))
 
#define TIME_T_MAX   MAXVAL(pg_time_t, TYPE_BIT(pg_time_t))
 
#define INT_STRLEN_MAXIMUM(type)
 
#define INITIALIZE(x)   ((x) = 0)
 
#define unreachable()   pg_unreachable()
 
#define _(msgid)   (msgid)
 
#define N_(msgid)   (msgid)
 
#define TWO_31_MINUS_1   2147483647
 
#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
 
#define DAYSPERREPEAT   ((int_fast32_t) 400 * 365 + 100 - 4 + 1)
 
#define SECSPERREPEAT   ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
 
#define AVGSECSPERYEAR   (SECSPERREPEAT / YEARSPERREPEAT)
 
#define isleap(y)   (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
 
#define isleap_sum(a, b)   isleap((a) % 400 + (b) % 400)
 

Enumerations

enum  {
  SECSPERMIN = 60 , MINSPERHOUR = 60 , SECSPERHOUR = SECSPERMIN * MINSPERHOUR , HOURSPERDAY = 24 ,
  DAYSPERWEEK = 7 , DAYSPERNYEAR = 365 , DAYSPERLYEAR = DAYSPERNYEAR + 1 , MONSPERYEAR = 12 ,
  YEARSPERREPEAT = 400
}
 
enum  { years_of_observations = YEARSPERREPEAT + 2 }
 
enum  {
  TM_SUNDAY , TM_MONDAY , TM_TUESDAY , TM_WEDNESDAY ,
  TM_THURSDAY , TM_FRIDAY , TM_SATURDAY
}
 
enum  {
  TM_JANUARY , TM_FEBRUARY , TM_MARCH , TM_APRIL ,
  TM_MAY , TM_JUNE , TM_JULY , TM_AUGUST ,
  TM_SEPTEMBER , TM_OCTOBER , TM_NOVEMBER , TM_DECEMBER
}
 
enum  { TM_YEAR_BASE = 1900 , TM_WDAY_BASE = TM_MONDAY , EPOCH_YEAR = 1970 , EPOCH_WDAY = TM_THURSDAY }
 

Macro Definition Documentation

◆ _

#define _ (   msgid)    (msgid)

Definition at line 199 of file private.h.

◆ ATTRIBUTE_FALLTHROUGH

#define ATTRIBUTE_FALLTHROUGH   pg_fallthrough

Definition at line 52 of file private.h.

◆ ATTRIBUTE_MAYBE_UNUSED

#define ATTRIBUTE_MAYBE_UNUSED   pg_attribute_unused()

Definition at line 53 of file private.h.

◆ ATTRIBUTE_NORETURN

#define ATTRIBUTE_NORETURN   pg_noreturn

Definition at line 54 of file private.h.

◆ ATTRIBUTE_PURE_114833

#define ATTRIBUTE_PURE_114833

Definition at line 55 of file private.h.

◆ ATTRIBUTE_PURE_114833_HACK

#define ATTRIBUTE_PURE_114833_HACK

Definition at line 56 of file private.h.

◆ AVGSECSPERYEAR

#define AVGSECSPERYEAR   (SECSPERREPEAT / YEARSPERREPEAT)

Definition at line 224 of file private.h.

◆ DAYSPERREPEAT

#define DAYSPERREPEAT   ((int_fast32_t) 400 * 365 + 100 - 4 + 1)

Definition at line 222 of file private.h.

◆ EINVAL

#define EINVAL   ERANGE

Definition at line 69 of file private.h.

◆ ELOOP

#define ELOOP   EINVAL

Definition at line 73 of file private.h.

◆ ENAMETOOLONG

#define ENAMETOOLONG   EINVAL

Definition at line 76 of file private.h.

◆ ENOMEM

#define ENOMEM   EINVAL

Definition at line 79 of file private.h.

◆ ENOTCAPABLE

#define ENOTCAPABLE   EINVAL

Definition at line 82 of file private.h.

◆ ENOTSUP

#define ENOTSUP   EINVAL

Definition at line 85 of file private.h.

◆ EOVERFLOW

#define EOVERFLOW   EINVAL

Definition at line 88 of file private.h.

◆ GRANDPARENTED

#define GRANDPARENTED   "Local time zone must be set--see zic manual page"

Definition at line 44 of file private.h.

◆ INDEX_MAX

#define INDEX_MAX   ((ptrdiff_t) min(PTRDIFF_MAX, SIZE_MAX))

Definition at line 99 of file private.h.

◆ INITIALIZE

#define INITIALIZE (   x)    ((x) = 0)

Definition at line 185 of file private.h.

◆ INT_STRLEN_MAXIMUM

#define INT_STRLEN_MAXIMUM (   type)
Value:
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
#define TYPE_BIT(type)
Definition private.h:144
#define TYPE_SIGNED(type)
Definition private.h:145
const char * type

Definition at line 178 of file private.h.

207{
208 SECSPERMIN = 60,
209 MINSPERHOUR = 60,
211 HOURSPERDAY = 24,
212 DAYSPERWEEK = 7,
213 DAYSPERNYEAR = 365,
215 MONSPERYEAR = 12,
216 YEARSPERREPEAT = 400 /* years before a Gregorian repeat */
217};
218
219#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
220
221#define DAYSPERREPEAT ((int_fast32_t) 400 * 365 + 100 - 4 + 1)
222#define SECSPERREPEAT ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
223#define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT)
224
225/*
226 * How many years to generate (in zic.c) or search through (in localtime.c).
227 * This is two years larger than the obvious 400, to avoid edge cases.
228 * E.g., suppose a rule applies from 2012 on with transitions
229 * in March and September, plus one-off transitions in November 2013,
230 * and suppose the rule cannot be expressed as a proleptic TZ string.
231 * If zic looked only at the last 400 years, it would set max_year=2413,
232 * with the intent that the 400 years 2014 through 2413 will be repeated.
233 * The last transition listed in the tzfile would be in 2413-09,
234 * less than 400 years after the last one-off transition in 2013-11.
235 * Two years is not overkill for localtime.c, as a one-year bump
236 * would mishandle 2023d's America/Ciudad_Juarez for November 2422.
237 */
238enum
239{
241
242enum
243{
244 TM_SUNDAY,
245 TM_MONDAY,
249 TM_FRIDAY,
251};
252
253enum
254{
257 TM_MARCH,
258 TM_APRIL,
259 TM_MAY,
260 TM_JUNE,
261 TM_JULY,
262 TM_AUGUST,
267};
268
269enum
270{
271 TM_YEAR_BASE = 1900,
273 EPOCH_YEAR = 1970,
275};
276
277#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
278
279/*
280 * Since everything in isleap is modulo 400 (or a factor of 400), we know that
281 * isleap(y) == isleap(y % 400)
282 * and so
283 * isleap(a + b) == isleap((a + b) % 400)
284 * or
285 * isleap(a + b) == isleap(a % 400 + b % 400)
286 * This is true even if % means modulo rather than Fortran remainder
287 * (which is allowed by C89 but not by C99 or later).
288 * We use this to avoid addition overflow problems.
289 */
290
291#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
292
293#endif /* !defined PRIVATE_H */
@ DAYSPERNYEAR
Definition private.h:214
@ DAYSPERLYEAR
Definition private.h:215
@ DAYSPERWEEK
Definition private.h:213
@ SECSPERMIN
Definition private.h:209
@ MONSPERYEAR
Definition private.h:216
@ YEARSPERREPEAT
Definition private.h:217
@ SECSPERHOUR
Definition private.h:211
@ MINSPERHOUR
Definition private.h:210
@ HOURSPERDAY
Definition private.h:212
@ TM_SUNDAY
Definition private.h:245
@ TM_TUESDAY
Definition private.h:247
@ TM_SATURDAY
Definition private.h:251
@ TM_FRIDAY
Definition private.h:250
@ TM_THURSDAY
Definition private.h:249
@ TM_MONDAY
Definition private.h:246
@ TM_WEDNESDAY
Definition private.h:248
@ TM_JANUARY
Definition private.h:256
@ TM_MAY
Definition private.h:260
@ TM_DECEMBER
Definition private.h:267
@ TM_MARCH
Definition private.h:258
@ TM_APRIL
Definition private.h:259
@ TM_OCTOBER
Definition private.h:265
@ TM_NOVEMBER
Definition private.h:266
@ TM_SEPTEMBER
Definition private.h:264
@ TM_JULY
Definition private.h:262
@ TM_FEBRUARY
Definition private.h:257
@ TM_JUNE
Definition private.h:261
@ TM_AUGUST
Definition private.h:263
@ TM_WDAY_BASE
Definition private.h:273
@ EPOCH_WDAY
Definition private.h:275
@ EPOCH_YEAR
Definition private.h:274
@ TM_YEAR_BASE
Definition private.h:272
@ years_of_observations
Definition private.h:241

◆ isleap

#define isleap (   y)    (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))

Definition at line 278 of file private.h.

◆ isleap_sum

#define isleap_sum (   a,
  b 
)    isleap((a) % 400 + (b) % 400)

Definition at line 292 of file private.h.

◆ max

#define max (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 154 of file private.h.

◆ MAXVAL

#define MAXVAL (   t,
  b 
)
Value:
((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
- 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
int b
Definition isn.c:74

Definition at line 162 of file private.h.

◆ min

#define min (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 155 of file private.h.

◆ MINVAL

#define MINVAL (   t,
  b 
)     ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))

Definition at line 165 of file private.h.

166 : 0))

◆ N_

#define N_ (   msgid)    (msgid)

Definition at line 200 of file private.h.

◆ SECSPERDAY

#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)

Definition at line 220 of file private.h.

◆ SECSPERREPEAT

#define SECSPERREPEAT   ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)

Definition at line 223 of file private.h.

◆ static_assert

#define static_assert (   cond)    extern int static_assert_check[(cond) ? 1 : -1]

Definition at line 39 of file private.h.

◆ TIME_T_MAX

#define TIME_T_MAX   MAXVAL(pg_time_t, TYPE_BIT(pg_time_t))

Definition at line 170 of file private.h.

◆ TIME_T_MIN

#define TIME_T_MIN   MINVAL(pg_time_t, TYPE_BIT(pg_time_t))

Definition at line 169 of file private.h.

◆ TM_GMTOFF

#define TM_GMTOFF   tm_gmtoff

Definition at line 136 of file private.h.

◆ TM_ZONE

#define TM_ZONE   tm_zone

Definition at line 137 of file private.h.

◆ TWO_31_MINUS_1

#define TWO_31_MINUS_1   2147483647

Definition at line 205 of file private.h.

◆ TWOS_COMPLEMENT

#define TWOS_COMPLEMENT (   type)    (TYPE_SIGNED (type) && (! ~ (type) -1))

Definition at line 146 of file private.h.

◆ TYPE_BIT

#define TYPE_BIT (   type)    (CHAR_BIT * (ptrdiff_t) sizeof(type))

Definition at line 144 of file private.h.

◆ TYPE_SIGNED

#define TYPE_SIGNED (   type)    (((type) -1) < 0)

Definition at line 145 of file private.h.

◆ TZDEFAULT

#define TZDEFAULT   "/etc/localtime"

Definition at line 27 of file private.h.

◆ unreachable

#define unreachable ( )    pg_unreachable()

Definition at line 189 of file private.h.

Enumeration Type Documentation

◆ anonymous enum

Enumerator
SECSPERMIN 
MINSPERHOUR 
SECSPERHOUR 
HOURSPERDAY 
DAYSPERWEEK 
DAYSPERNYEAR 
DAYSPERLYEAR 
MONSPERYEAR 
YEARSPERREPEAT 

Definition at line 207 of file private.h.

208{
209 SECSPERMIN = 60,
210 MINSPERHOUR = 60,
212 HOURSPERDAY = 24,
213 DAYSPERWEEK = 7,
214 DAYSPERNYEAR = 365,
216 MONSPERYEAR = 12,
217 YEARSPERREPEAT = 400 /* years before a Gregorian repeat */
218};

◆ anonymous enum

Enumerator
years_of_observations 

Definition at line 239 of file private.h.

◆ anonymous enum

Enumerator
TM_SUNDAY 
TM_MONDAY 
TM_TUESDAY 
TM_WEDNESDAY 
TM_THURSDAY 
TM_FRIDAY 
TM_SATURDAY 

Definition at line 243 of file private.h.

244{
245 TM_SUNDAY,
246 TM_MONDAY,
250 TM_FRIDAY,
252};

◆ anonymous enum

Enumerator
TM_JANUARY 
TM_FEBRUARY 
TM_MARCH 
TM_APRIL 
TM_MAY 
TM_JUNE 
TM_JULY 
TM_AUGUST 
TM_SEPTEMBER 
TM_OCTOBER 
TM_NOVEMBER 
TM_DECEMBER 

Definition at line 254 of file private.h.

255{
258 TM_MARCH,
259 TM_APRIL,
260 TM_MAY,
261 TM_JUNE,
262 TM_JULY,
263 TM_AUGUST,
268};

◆ anonymous enum

Enumerator
TM_YEAR_BASE 
TM_WDAY_BASE 
EPOCH_YEAR 
EPOCH_WDAY 

Definition at line 270 of file private.h.

271{
272 TM_YEAR_BASE = 1900,
274 EPOCH_YEAR = 1970,
276};