| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Update timezone to C99 |
| Date: | 2025-11-14 21:11:21 |
| Message-ID: | 3235596.1763154681@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> On 12.11.25 19:02, Tom Lane wrote:
>> Hm, I've had "re-sync TZ code with upstream" on my TODO list for
>> several years now. I believe there's been quite a bit of churn
>> upstream since tzcode2020d, some of it oriented towards this same
>> issue of code modernization. Maybe we should try to sync with
>> a newer release while we're at it.
> My idea was to do this C99 adjustment first so that the differences to
> upstream are reduced, which would hopefully simplify updating to that
> newer code.
Fair enough. I looked through the patch briefly and had a couple of
minor quibbles:
@@ -905,7 +906,7 @@ transtime(const int year, const struct rule *const rulep,
for (i = 1; i < rulep->r_week; ++i)
{
if (d + DAYSPERWEEK >=
- mon_lengths[(int) leapyear][rulep->r_mon - 1])
+ mon_lengths[leapyear][rulep->r_mon - 1])
break;
d += DAYSPERWEEK;
}
@@ -915,7 +916,7 @@ transtime(const int year, const struct rule *const rulep,
*/
value = d * SECSPERDAY;
for (i = 0; i < rulep->r_mon - 1; ++i)
- value += mon_lengths[(int) leapyear][i] * SECSPERDAY;
+ value += mon_lengths[leapyear][i] * SECSPERDAY;
break;
}
"leapyear" is bool, and I believe these casts-to-int were put in to
suppress compiler bleats about up-casting that to int. This probably
dates from when we equated bool to char, and maybe it's moot now,
but I'm not sure.
@@ -47,12 +49,15 @@ typedef int64 zic_t;
static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));
#endif
-/*
- * The type for line numbers. In Postgres, use %d to format them; upstream
- * uses PRIdMAX but we prefer not to rely on that, not least because it
- * results in platform-dependent strings to be translated.
- */
-typedef int lineno_t;
+/* The minimum alignment of a type, for pre-C11 platforms. */
+#if __STDC_VERSION__ < 201112
+#define _Alignof(type) offsetof(struct { char a; type b; }, b)
+#endif
Since we've dropped pre-C11 support, I wonder why we'd include this
upstream workaround for that.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | jian he | 2025-11-14 21:24:59 | Re: ON CONFLICT DO SELECT (take 3) |
| Previous Message | Bruce Momjian | 2025-11-14 21:07:36 | Re: should we have a fast-path planning for OLTP starjoins? |