From bfef6800268cdcf0b9118d89f1ce7c3541bd0309 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 12 Nov 2026 22:28:39 +0100 Subject: Stop forcing 64 bit variables on 32 bit targets where a long would do just fine --- src/ot_fdstate.c | 12 ++++++------ src/ot_fdstate.h | 8 ++++---- src/ot_stats.c | 2 +- src/trackerlogic.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ot_fdstate.c b/src/ot_fdstate.c index 8e4bd89..bbb25d2 100644 --- a/src/ot_fdstate.c +++ b/src/ot_fdstate.c @@ -24,7 +24,7 @@ enum { FD_FREE, FD_IDLE, FD_BUSY, FD_CLOSING }; typedef struct { _Atomic uint64_t state; _Atomic(void *) cookie; - _Atomic ot_time expiry; + _Atomic unsigned long expiry; } ot_fdslot; /* A descriptor the kernel can hand out is below the limit it was handed out @@ -72,7 +72,7 @@ static ot_fdslot *fdstate_slot(int fd) { return g_slots + fd; } -uint32_t fdstate_open(int fd, void *cookie, ot_time expiry) { +uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry) { ot_fdslot *slot = fdstate_slot(fd); uint64_t word; @@ -132,10 +132,10 @@ void fdstate_release(int fd) { atomic_store_explicit(&slot->state, FD_SET_ST(word, FD_IDLE), memory_order_release); } -int fdstate_claim_expired(int fd, ot_time now) { +int fdstate_claim_expired(int fd, unsigned long now) { ot_fdslot *slot = fdstate_slot(fd); uint64_t word; - ot_time expiry; + unsigned long expiry; if (!slot) return 0; @@ -168,7 +168,7 @@ void fdstate_close(int fd) { atomic_store_explicit(&slot->state, FD_WORD(FD_GEN(word) + 1, FD_FREE), memory_order_release); } -int fdstate_next_expired(ot_time now, int *cursor) { +int fdstate_next_expired(unsigned long now, int *cursor) { size_t highest = atomic_load_explicit(&g_slot_highest, memory_order_relaxed); for (; (size_t)*cursor <= highest; ++*cursor) @@ -194,7 +194,7 @@ void fdstate_set_cookie(int fd, void *cookie) { atomic_store_explicit(&slot->cookie, cookie, memory_order_release); } -void fdstate_set_expiry(int fd, ot_time expiry) { +void fdstate_set_expiry(int fd, unsigned long expiry) { ot_fdslot *slot = fdstate_slot(fd); if (slot) diff --git a/src/ot_fdstate.h b/src/ot_fdstate.h index 60fe070..20f469d 100644 --- a/src/ot_fdstate.h +++ b/src/ot_fdstate.h @@ -27,7 +27,7 @@ size_t fdstate_slots(void); /* Take a freshly accepted descriptor into the table and return the generation to quote when asking for it back. expiry of 0 never expires. */ -uint32_t fdstate_open(int fd, void *cookie, ot_time expiry); +uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry); /* Which generation a descriptor currently carries, to check an event that was handed out earlier against the connection living there now. */ @@ -40,7 +40,7 @@ void fdstate_release(int fd); /* The cleaner's side of the same thing: takes the descriptor only if nobody is working on it and it really has expired. Never waits. */ -int fdstate_claim_expired(int fd, ot_time now); +int fdstate_claim_expired(int fd, unsigned long now); /* Give the descriptor up. The generation is bumped here, which has to happen before close(2) so that the kernel cannot reissue the number while events @@ -50,13 +50,13 @@ void fdstate_close(int fd); /* Walks the table for descriptors that have expired, handing back one at a time until it returns -1. The cursor belongs to the caller, so several sweepers can run without sharing anything. */ -int fdstate_next_expired(ot_time now, int *cursor); +int fdstate_next_expired(unsigned long now, int *cursor); /* Both only valid while the caller holds the descriptor. */ void *fdstate_cookie(int fd); /* Hand the slot a different cookie, for a connection whose state has moved */ void fdstate_set_cookie(int fd, void *cookie); -void fdstate_set_expiry(int fd, ot_time expiry); +void fdstate_set_expiry(int fd, unsigned long expiry); #endif diff --git a/src/ot_stats.c b/src/ot_stats.c index ba780d3..95f3cff 100644 --- a/src/ot_stats.c +++ b/src/ot_stats.c @@ -83,7 +83,7 @@ static void counters_total(unsigned long long *total) { pthread_mutex_unlock(&g_counter_mutex); } -#define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long long)(by), memory_order_relaxed) +#define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long)(by), memory_order_relaxed) static const char *ot_failed_request_names[] = { "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest", diff --git a/src/trackerlogic.h b/src/trackerlogic.h index dd8a48c..4086b23 100644 --- a/src/trackerlogic.h +++ b/src/trackerlogic.h @@ -221,7 +221,7 @@ enum { }; /* One statistic. Used when workers report stats to their workstruct */ -typedef _Atomic unsigned long long ot_counter; +typedef _Atomic unsigned long ot_counter; /* What each thread counts for itself. The two runs at the end are indexed by the http error code and by the age in minutes of a renewed peer */ -- cgit v1.3