diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2025-11-21 13:01:30 +0100 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2025-11-21 13:07:40 +0100 |
| commit | e6be84356bbbaf9f88b6a738e690d6fdff6fe483 (patch) | |
| tree | 6040a4040bf0fcffcb21d8f22b0e552bf48de1a5 /src/timezone/private.h | |
| parent | 97e04c74bedb902327b89eb8a9e6aea01aabdad2 (diff) | |
Update timezone to C99
This reverts changes done in PostgreSQL over the upstream code to
avoid relying on C99 <stdint.h> and <inttypes.h>.
In passing, there were a few other minor and cosmetic changes that I
left in to improve alignment with upstream, including some C11 feature
use (_Noreturn).
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/9ad2749f-77ab-4ecb-a321-1ca915480b05%40eisentraut.org
Diffstat (limited to 'src/timezone/private.h')
| -rw-r--r-- | src/timezone/private.h | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/timezone/private.h b/src/timezone/private.h index 39d40e43a9f..ab89028f3e1 100644 --- a/src/timezone/private.h +++ b/src/timezone/private.h @@ -44,10 +44,6 @@ /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) -/* PG doesn't currently rely on <inttypes.h>, so work around strtoimax() */ -#undef strtoimax -#define strtoimax strtoll - /* * Finally, some convenience items. @@ -95,25 +91,25 @@ #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ #define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 #define DAYSPERNYEAR 365 #define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((int32) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 #define TM_SUNDAY 0 #define TM_MONDAY 1 #define TM_TUESDAY 2 #define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 +#define TM_THURSDAY 4 #define TM_FRIDAY 5 -#define TM_SATURDAY 6 +#define TM_SATURDAY 6 #define TM_JANUARY 0 -#define TM_FEBRUARY 1 +#define TM_FEBRUARY 1 #define TM_MARCH 2 #define TM_APRIL 3 #define TM_MAY 4 @@ -122,8 +118,8 @@ #define TM_AUGUST 7 #define TM_SEPTEMBER 8 #define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 #define TM_YEAR_BASE 1900 @@ -153,7 +149,7 @@ #define AVGSECSPERYEAR 31556952L #define SECSPERREPEAT \ - ((int64) YEARSPERREPEAT * (int64) AVGSECSPERYEAR) + ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR) #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */ #endif /* !defined PRIVATE_H */ |
