Skip to content

Commit c2d18a9

Browse files
committed
Fix the _ILP32 build.
1 parent 955f68a commit c2d18a9

7 files changed

Lines changed: 157 additions & 37 deletions

File tree

external/mpl/bind/dist/lib/dns/qp.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: qp.c,v 1.2 2025/01/26 16:25:24 christos Exp $ */
1+
/* $NetBSD: qp.c,v 1.3 2025/01/27 02:16:05 christos Exp $ */
22

33
/*
44
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -63,9 +63,33 @@
6363
* XXXFANF for now we're logging GC times, but ideally we should
6464
* accumulate stats more quietly and report via the statschannel
6565
*/
66+
#ifdef _LP64
6667
static atomic_uint_fast64_t compact_time;
6768
static atomic_uint_fast64_t recycle_time;
6869
static atomic_uint_fast64_t rollback_time;
70+
#define ISC_QP_ADD(v, a) atomic_fetch_add_relaxed(&(v), (a))
71+
#define ISC_QP_GET(v) atomic_load_relaxed(v)
72+
#else
73+
static uint64_t compact_time;
74+
static uint64_t recycle_time;
75+
static uint64_t rollback_time;
76+
static isc_mutex_t qp_mutex = PTHREAD_MUTEX_INITIALIZER;
77+
#define ISC_QP_ADD(v, a) \
78+
({ \
79+
isc_mutex_lock(&qp_mutex); \
80+
uint64_t x = (v) + (a); \
81+
isc_mutex_unlock(&qp_mutex); \
82+
x; \
83+
})
84+
#define ISC_QP_GET(v) \
85+
({ \
86+
isc_mutex_lock(&qp_mutex); \
87+
uint64_t x = (v); \
88+
isc_mutex_unlock(&qp_mutex); \
89+
x; \
90+
})
91+
#endif
92+
6993

7094
/* for LOG_STATS() format strings */
7195
#define PRItime " %" PRIu64 " ns "
@@ -680,7 +704,7 @@ recycle(dns_qp_t *qp) {
680704
}
681705

682706
isc_nanosecs_t time = isc_time_monotonic() - start;
683-
atomic_fetch_add_relaxed(&recycle_time, time);
707+
ISC_QP_ADD(recycle_time, time);
684708

685709
if (free > 0) {
686710
LOG_STATS("qp recycle" PRItime "free %u chunks", time, free);
@@ -723,7 +747,7 @@ reclaim_chunks_cb(struct rcu_head *arg) {
723747
STRUCT_FLEX_SIZE(rcuctx, chunk, rcuctx->count));
724748

725749
isc_nanosecs_t time = isc_time_monotonic() - start;
726-
recycle_time += time;
750+
ISC_QP_ADD(recycle_time, time);
727751

728752
if (free > 0) {
729753
LOG_STATS("qp reclaim" PRItime "free %u chunks", time, free);
@@ -816,7 +840,7 @@ marksweep_chunks(dns_qpmulti_t *multi) {
816840
}
817841

818842
isc_nanosecs_t time = isc_time_monotonic() - start;
819-
recycle_time += time;
843+
ISC_QP_ADD(recycle_time, time);
820844

821845
if (free > 0) {
822846
LOG_STATS("qp marksweep" PRItime "free %u chunks", time, free);
@@ -945,7 +969,7 @@ compact(dns_qp_t *qp) {
945969
qp->compact_all = false;
946970

947971
isc_nanosecs_t time = isc_time_monotonic() - start;
948-
atomic_fetch_add_relaxed(&compact_time, time);
972+
ISC_QP_ADD(compact_time, time);
949973

950974
LOG_STATS("qp compact" PRItime
951975
"leaf %u live %u used %u free %u hold %u",
@@ -1073,9 +1097,9 @@ dns_qpmulti_memusage(dns_qpmulti_t *multi) {
10731097
void
10741098
dns_qp_gctime(isc_nanosecs_t *compact_p, isc_nanosecs_t *recycle_p,
10751099
isc_nanosecs_t *rollback_p) {
1076-
*compact_p = atomic_load_relaxed(&compact_time);
1077-
*recycle_p = atomic_load_relaxed(&recycle_time);
1078-
*rollback_p = atomic_load_relaxed(&rollback_time);
1100+
*compact_p = ISC_QP_GET(compact_time);
1101+
*recycle_p = ISC_QP_GET(recycle_time);
1102+
*rollback_p = ISC_QP_GET(rollback_time);
10791103
}
10801104

10811105
/***********************************************************************
@@ -1300,7 +1324,7 @@ dns_qpmulti_rollback(dns_qpmulti_t *multi, dns_qp_t **qptp) {
13001324
INSIST(multi->rollback == NULL);
13011325

13021326
isc_nanosecs_t time = isc_time_monotonic() - start;
1303-
atomic_fetch_add_relaxed(&rollback_time, time);
1327+
ISC_QP_ADD(rollback_time, time);
13041328

13051329
LOG_STATS("qp rollback" PRItime "free %u chunks", time, free);
13061330

external/mpl/bind/dist/lib/dns/xfrin.c

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: xfrin.c,v 1.16 2025/01/26 16:25:26 christos Exp $ */
1+
/* $NetBSD: xfrin.c,v 1.17 2025/01/27 02:16:05 christos Exp $ */
22

33
/*
44
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -84,6 +84,34 @@ typedef enum {
8484
XFRST_AXFR_END
8585
} xfrin_state_t;
8686

87+
#ifdef _LP64
88+
#define ISC_XFRIN_LOAD(a, t) atomic_load_relaxed(a)
89+
#define ISC_XFRIN_STORE(a, b) atomic_store_relaxed(a, b)
90+
#define ISC_XFRIN_ADD(a, b) atomic_fetch_add_relaxed(a, b)
91+
#else
92+
static isc_mutex_t xfrin_lock = PTHREAD_MUTEX_INITIALIZER;
93+
#define ISC_XFRIN_LOAD(a, t) \
94+
({ \
95+
isc_mutex_lock(&xfrin_lock); \
96+
t x = *(a); \
97+
isc_mutex_unlock(&xfrin_lock); \
98+
x; \
99+
})
100+
#define ISC_XFRIN_STORE(a, b) \
101+
({ \
102+
isc_mutex_lock(&xfrin_lock); \
103+
*(a) = (b); \
104+
isc_mutex_unlock(&xfrin_lock); \
105+
})
106+
#define ISC_XFRIN_ADD(a, b) \
107+
({ \
108+
isc_mutex_lock(&xfrin_lock); \
109+
*(a) += (b); \
110+
isc_mutex_unlock(&xfrin_lock); \
111+
})
112+
#endif
113+
114+
87115
/*%
88116
* Incoming zone transfer context.
89117
*/
@@ -153,8 +181,13 @@ struct dns_xfrin {
153181
*/
154182
atomic_uint nmsg; /*%< Number of messages recvd */
155183
atomic_uint nrecs; /*%< Number of records recvd */
184+
#ifdef _LP64
156185
atomic_uint_fast64_t nbytes; /*%< Number of bytes received */
157186
_Atomic(isc_time_t) start; /*%< Start time of the transfer */
187+
#else
188+
atomic_uint_fast32_t nbytes; /*%< Number of bytes received */
189+
isc_time_t start; /*%< Start time of the transfer */
190+
#endif
158191
_Atomic(dns_transport_type_t) soa_transport_type;
159192
atomic_uint_fast32_t end_serial;
160193

@@ -967,7 +1000,7 @@ isc_time_t
9671000
dns_xfrin_getstarttime(dns_xfrin_t *xfr) {
9681001
REQUIRE(VALID_XFRIN(xfr));
9691002

970-
return atomic_load_relaxed(&xfr->start);
1003+
return ISC_XFRIN_LOAD(&xfr->start, isc_time_t);
9711004
}
9721005

9731006
void
@@ -1030,7 +1063,7 @@ dns_xfrin_getstats(dns_xfrin_t *xfr, unsigned int *nmsgp, unsigned int *nrecsp,
10301063

10311064
SET_IF_NOT_NULL(nmsgp, atomic_load_relaxed(&xfr->nmsg));
10321065
SET_IF_NOT_NULL(nrecsp, atomic_load_relaxed(&xfr->nrecs));
1033-
SET_IF_NOT_NULL(nbytesp, atomic_load_relaxed(&xfr->nbytes));
1066+
SET_IF_NOT_NULL(nbytesp, ISC_XFRIN_LOAD(&xfr->nbytes, uint64_t));
10341067
}
10351068

10361069
const isc_sockaddr_t *
@@ -1218,7 +1251,7 @@ xfrin_create(isc_mem_t *mctx, dns_zone_t *zone, dns_db_t *db, isc_loop_t *loop,
12181251
atomic_init(&xfr->state, XFRST_ZONEXFRREQUEST);
12191252
}
12201253

1221-
atomic_init(&xfr->start, isc_time_now());
1254+
ISC_XFRIN_STORE(&xfr->start, isc_time_now());
12221255

12231256
if (tsigkey != NULL) {
12241257
dns_tsigkey_attach(tsigkey, &xfr->tsigkey);
@@ -1588,8 +1621,8 @@ xfrin_send_request(dns_xfrin_t *xfr) {
15881621

15891622
atomic_store_relaxed(&xfr->nmsg, 0);
15901623
atomic_store_relaxed(&xfr->nrecs, 0);
1591-
atomic_store_relaxed(&xfr->nbytes, 0);
1592-
atomic_store_relaxed(&xfr->start, isc_time_now());
1624+
ISC_XFRIN_STORE(&xfr->nbytes, 0);
1625+
ISC_XFRIN_STORE(&xfr->start, isc_time_now());
15931626

15941627
msg->id = xfr->id;
15951628
if (xfr->tsigctx != NULL) {
@@ -1967,7 +2000,7 @@ xfrin_recv_done(isc_result_t result, isc_region_t *region, void *arg) {
19672000
* Update the number of messages and bytes received.
19682001
*/
19692002
atomic_fetch_add_relaxed(&xfr->nmsg, 1);
1970-
atomic_fetch_add_relaxed(&xfr->nbytes, buffer.used);
2003+
ISC_XFRIN_ADD(&xfr->nbytes, buffer.used);
19712004

19722005
/*
19732006
* Take the context back.
@@ -2050,12 +2083,12 @@ xfrin_destroy(dns_xfrin_t *xfr) {
20502083
* Calculate the length of time the transfer took,
20512084
* and print a log message with the bytes and rate.
20522085
*/
2053-
isc_time_t start = atomic_load_relaxed(&xfr->start);
2086+
isc_time_t start = ISC_XFRIN_LOAD(&xfr->start, isc_time_t);
20542087
msecs = isc_time_microdiff(&now, &start) / 1000;
20552088
if (msecs == 0) {
20562089
msecs = 1;
20572090
}
2058-
persec = (atomic_load_relaxed(&xfr->nbytes) * 1000) / msecs;
2091+
persec = (ISC_XFRIN_LOAD(&xfr->nbytes, uint64_t) * 1000) / msecs;
20592092

20602093
if (xfr->expireoptset) {
20612094
sep = ", expire option ";
@@ -2068,7 +2101,7 @@ xfrin_destroy(dns_xfrin_t *xfr) {
20682101
"%u.%03u secs (%u bytes/sec) (serial %" PRIuFAST32 "%s%s)",
20692102
atomic_load_relaxed(&xfr->nmsg),
20702103
atomic_load_relaxed(&xfr->nrecs),
2071-
atomic_load_relaxed(&xfr->nbytes),
2104+
ISC_XFRIN_LOAD(&xfr->nbytes, uint64_t),
20722105
(unsigned int)(msecs / 1000), (unsigned int)(msecs % 1000),
20732106
(unsigned int)persec, atomic_load_relaxed(&xfr->end_serial),
20742107
sep, expireopt);

external/mpl/bind/dist/lib/dns/zone.c

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: zone.c,v 1.21 2025/01/26 16:25:26 christos Exp $ */
1+
/* $NetBSD: zone.c,v 1.22 2025/01/27 02:16:05 christos Exp $ */
22

33
/*
44
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -260,6 +260,9 @@ struct dns_zone {
260260
/* Unlocked */
261261
unsigned int magic;
262262
isc_mutex_t lock;
263+
#ifndef _LP64
264+
isc_mutex_t atomic_lock;
265+
#endif
263266
#ifdef DNS_ZONE_CHECKLOCK
264267
bool locked;
265268
#endif /* ifdef DNS_ZONE_CHECKLOCK */
@@ -289,8 +292,13 @@ struct dns_zone {
289292
int32_t journalsize;
290293
dns_rdataclass_t rdclass;
291294
dns_zonetype_t type;
295+
#ifdef _LP64
292296
atomic_uint_fast64_t flags;
293297
atomic_uint_fast64_t options;
298+
#else
299+
uint64_t flags;
300+
uint64_t options;
301+
#endif
294302
unsigned int db_argc;
295303
char **db_argv;
296304
isc_time_t expiretime;
@@ -431,7 +439,11 @@ struct dns_zone {
431439
/*%
432440
* Autosigning/key-maintenance options
433441
*/
442+
#ifdef _LP64
434443
atomic_uint_fast64_t keyopts;
444+
#else
445+
uint64_t keyopts;
446+
#endif
435447

436448
/*%
437449
* True if added by "rndc addzone"
@@ -518,10 +530,38 @@ struct dns_zone {
518530
(_z)->diff = (d); \
519531
(_z)->offline = false; \
520532
} while (0)
533+
#ifdef _LP64
534+
#define ISC_ZONE_GET(z, f) atomic_load_relaxed(&(z)->f)
535+
#define ISC_ZONE_SET(z, f, o) atomic_fetch_or(&(z)->f, (o))
536+
#define DNS_ZONE_CLR(z, f, o) atomic_fetch_and(&(z)->f, ~(o))
537+
#else
538+
#define ISC_ZONE_GET(z, f) \
539+
({ \
540+
isc_mutex_lock(&(z)->atomic_lock); \
541+
uint64_t x = (z)->f; \
542+
isc_mutex_unlock(&(z)->atomic_lock); \
543+
x; \
544+
})
545+
#define ISC_ZONE_SET(z, f, o) \
546+
({ \
547+
isc_mutex_lock(&(z)->atomic_lock); \
548+
uint64_t x = ((z)->f | (o)); \
549+
isc_mutex_unlock(&(z)->atomic_lock); \
550+
x; \
551+
})
552+
#define ISC_ZONE_CLR(z, f, o) \
553+
({ \
554+
isc_mutex_lock(&(z)->atomic_lock); \
555+
uint64_t x = ((z)->f & ~(o)); \
556+
isc_mutex_unlock(&(z)->atomic_lock); \
557+
x; \
558+
})
559+
#endif
560+
#define ISC_ZONE_TEST(z, f, o) ((ISC_ZONE_GET(z, f) & (o)) != 0)
521561

522-
#define DNS_ZONE_FLAG(z, f) ((atomic_load_relaxed(&(z)->flags) & (f)) != 0)
523-
#define DNS_ZONE_SETFLAG(z, f) atomic_fetch_or(&(z)->flags, (f))
524-
#define DNS_ZONE_CLRFLAG(z, f) atomic_fetch_and(&(z)->flags, ~(f))
562+
#define DNS_ZONE_FLAG(z, f) ISC_ZONE_TEST(z, flags, f)
563+
#define DNS_ZONE_SETFLAG(z, f) ISC_ZONE_SET(z, flags, f)
564+
#define DNS_ZONE_CLRFLAG(z, f) ISC_ZONE_CLR(z, flags, f)
525565
typedef enum {
526566
DNS_ZONEFLG_REFRESH = 0x00000001U, /*%< refresh check in progress */
527567
DNS_ZONEFLG_NEEDDUMP = 0x00000002U, /*%< zone need consolidation */
@@ -571,14 +611,14 @@ typedef enum {
571611
DNS_ZONEFLG___MAX = UINT64_MAX, /* trick to make the ENUM 64-bit wide */
572612
} dns_zoneflg_t;
573613

574-
#define DNS_ZONE_OPTION(z, o) ((atomic_load_relaxed(&(z)->options) & (o)) != 0)
575-
#define DNS_ZONE_SETOPTION(z, o) atomic_fetch_or(&(z)->options, (o))
576-
#define DNS_ZONE_CLROPTION(z, o) atomic_fetch_and(&(z)->options, ~(o))
577614

578-
#define DNS_ZONEKEY_OPTION(z, o) \
579-
((atomic_load_relaxed(&(z)->keyopts) & (o)) != 0)
580-
#define DNS_ZONEKEY_SETOPTION(z, o) atomic_fetch_or(&(z)->keyopts, (o))
581-
#define DNS_ZONEKEY_CLROPTION(z, o) atomic_fetch_and(&(z)->keyopts, ~(o))
615+
#define DNS_ZONE_OPTION(z, o) ISC_ZONE_TEST(z, options, o)
616+
#define DNS_ZONE_SETOPTION(z, o) ISC_ZONE_SET(z, options, o)
617+
#define DNS_ZONE_CLROPTION(z, o) ISC_ZONE_CLR(z, options, o)
618+
#define DNS_ZONEKEY_OPTION(z, o) ISC_ZONE_TEST(z, keyopts, o)
619+
#define DNS_ZONEKEY_SETOPTION(z, o) ISC_ZONE_SET(z, keyopts, o)
620+
#define DNS_ZONEKEY_CLROPTION(z, o) ISC_ZONE_CLR(z, keyopts, o)
621+
582622

583623
/* Flags for zone_load() */
584624
typedef enum {
@@ -1166,6 +1206,9 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
11661206

11671207
isc_mem_attach(mctx, &zone->mctx);
11681208
isc_mutex_init(&zone->lock);
1209+
#ifndef _LP64
1210+
isc_mutex_init(&zone->atomic_lock);
1211+
#endif
11691212
ZONEDB_INITLOCK(&zone->dblock);
11701213

11711214
isc_refcount_init(&zone->references, 1);
@@ -1374,6 +1417,9 @@ zone_free(dns_zone_t *zone) {
13741417
/* last stuff */
13751418
ZONEDB_DESTROYLOCK(&zone->dblock);
13761419
isc_mutex_destroy(&zone->lock);
1420+
#ifndef _LP64
1421+
isc_mutex_destroy(&zone->atomic_lock);
1422+
#endif
13771423
zone->magic = 0;
13781424
isc_mem_putanddetach(&zone->mctx, zone, sizeof(*zone));
13791425
}
@@ -5803,7 +5849,7 @@ dns_zoneopt_t
58035849
dns_zone_getoptions(dns_zone_t *zone) {
58045850
REQUIRE(DNS_ZONE_VALID(zone));
58055851

5806-
return atomic_load_relaxed(&zone->options);
5852+
return ISC_ZONE_GET(zone, options);
58075853
}
58085854

58095855
void
@@ -5821,7 +5867,7 @@ unsigned int
58215867
dns_zone_getkeyopts(dns_zone_t *zone) {
58225868
REQUIRE(DNS_ZONE_VALID(zone));
58235869

5824-
return atomic_load_relaxed(&zone->keyopts);
5870+
return ISC_ZONE_GET(zone, keyopts);
58255871
}
58265872

58275873
isc_result_t
@@ -11431,7 +11477,7 @@ zone_refresh(dns_zone_t *zone) {
1143111477
* in progress at a time.
1143211478
*/
1143311479

11434-
oldflags = atomic_load(&zone->flags);
11480+
oldflags = ISC_ZONE_GET(zone, flags);
1143511481
if (dns_remote_addresses(&zone->primaries) == NULL) {
1143611482
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOPRIMARIES);
1143711483
if ((oldflags & DNS_ZONEFLG_NOPRIMARIES) == 0) {

external/mpl/bind/dist/lib/isc/histo.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: histo.c,v 1.2 2025/01/26 16:25:37 christos Exp $ */
1+
/* $NetBSD: histo.c,v 1.3 2025/01/27 02:16:05 christos Exp $ */
22

33
/*
44
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -62,7 +62,11 @@
6262
#define MAXCHUNK(hg) EXPONENTS(hg)
6363
#define CHUNKSIZE(hg) MANTISSAS(hg)
6464

65+
#ifdef _LP64
6566
typedef atomic_uint_fast64_t hg_bucket_t;
67+
#else
68+
typedef atomic_uint_fast32_t hg_bucket_t;
69+
#endif
6670
typedef atomic_ptr(hg_bucket_t) hg_chunk_t;
6771

6872
struct isc_histo {

0 commit comments

Comments
 (0)