summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-12 22:28:39 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-12 22:28:39 +0100
commitbfef6800268cdcf0b9118d89f1ce7c3541bd0309 (patch)
treec43a44135953914a42dfe9666e85552fa4a35d17
parent530d3ee20a06f2a128b1eddaf2398011d3f1d119 (diff)
Stop forcing 64 bit variables on 32 bit targets where a long would do just fineHEADmaster
-rw-r--r--src/ot_fdstate.c12
-rw-r--r--src/ot_fdstate.h8
-rw-r--r--src/ot_stats.c2
-rw-r--r--src/trackerlogic.h2
4 files changed, 12 insertions, 12 deletions
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 };
24typedef struct { 24typedef struct {
25 _Atomic uint64_t state; 25 _Atomic uint64_t state;
26 _Atomic(void *) cookie; 26 _Atomic(void *) cookie;
27 _Atomic ot_time expiry; 27 _Atomic unsigned long expiry;
28} ot_fdslot; 28} ot_fdslot;
29 29
30/* A descriptor the kernel can hand out is below the limit it was handed out 30/* 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) {
72 return g_slots + fd; 72 return g_slots + fd;
73} 73}
74 74
75uint32_t fdstate_open(int fd, void *cookie, ot_time expiry) { 75uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry) {
76 ot_fdslot *slot = fdstate_slot(fd); 76 ot_fdslot *slot = fdstate_slot(fd);
77 uint64_t word; 77 uint64_t word;
78 78
@@ -132,10 +132,10 @@ void fdstate_release(int fd) {
132 atomic_store_explicit(&slot->state, FD_SET_ST(word, FD_IDLE), memory_order_release); 132 atomic_store_explicit(&slot->state, FD_SET_ST(word, FD_IDLE), memory_order_release);
133} 133}
134 134
135int fdstate_claim_expired(int fd, ot_time now) { 135int fdstate_claim_expired(int fd, unsigned long now) {
136 ot_fdslot *slot = fdstate_slot(fd); 136 ot_fdslot *slot = fdstate_slot(fd);
137 uint64_t word; 137 uint64_t word;
138 ot_time expiry; 138 unsigned long expiry;
139 139
140 if (!slot) 140 if (!slot)
141 return 0; 141 return 0;
@@ -168,7 +168,7 @@ void fdstate_close(int fd) {
168 atomic_store_explicit(&slot->state, FD_WORD(FD_GEN(word) + 1, FD_FREE), memory_order_release); 168 atomic_store_explicit(&slot->state, FD_WORD(FD_GEN(word) + 1, FD_FREE), memory_order_release);
169} 169}
170 170
171int fdstate_next_expired(ot_time now, int *cursor) { 171int fdstate_next_expired(unsigned long now, int *cursor) {
172 size_t highest = atomic_load_explicit(&g_slot_highest, memory_order_relaxed); 172 size_t highest = atomic_load_explicit(&g_slot_highest, memory_order_relaxed);
173 173
174 for (; (size_t)*cursor <= highest; ++*cursor) 174 for (; (size_t)*cursor <= highest; ++*cursor)
@@ -194,7 +194,7 @@ void fdstate_set_cookie(int fd, void *cookie) {
194 atomic_store_explicit(&slot->cookie, cookie, memory_order_release); 194 atomic_store_explicit(&slot->cookie, cookie, memory_order_release);
195} 195}
196 196
197void fdstate_set_expiry(int fd, ot_time expiry) { 197void fdstate_set_expiry(int fd, unsigned long expiry) {
198 ot_fdslot *slot = fdstate_slot(fd); 198 ot_fdslot *slot = fdstate_slot(fd);
199 199
200 if (slot) 200 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);
27 27
28/* Take a freshly accepted descriptor into the table and return the 28/* Take a freshly accepted descriptor into the table and return the
29 generation to quote when asking for it back. expiry of 0 never expires. */ 29 generation to quote when asking for it back. expiry of 0 never expires. */
30uint32_t fdstate_open(int fd, void *cookie, ot_time expiry); 30uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry);
31 31
32/* Which generation a descriptor currently carries, to check an event that 32/* Which generation a descriptor currently carries, to check an event that
33 was handed out earlier against the connection living there now. */ 33 was handed out earlier against the connection living there now. */
@@ -40,7 +40,7 @@ void fdstate_release(int fd);
40 40
41/* The cleaner's side of the same thing: takes the descriptor only if nobody 41/* The cleaner's side of the same thing: takes the descriptor only if nobody
42 is working on it and it really has expired. Never waits. */ 42 is working on it and it really has expired. Never waits. */
43int fdstate_claim_expired(int fd, ot_time now); 43int fdstate_claim_expired(int fd, unsigned long now);
44 44
45/* Give the descriptor up. The generation is bumped here, which has to happen 45/* Give the descriptor up. The generation is bumped here, which has to happen
46 before close(2) so that the kernel cannot reissue the number while events 46 before close(2) so that the kernel cannot reissue the number while events
@@ -50,13 +50,13 @@ void fdstate_close(int fd);
50/* Walks the table for descriptors that have expired, handing back one at a 50/* Walks the table for descriptors that have expired, handing back one at a
51 time until it returns -1. The cursor belongs to the caller, so several 51 time until it returns -1. The cursor belongs to the caller, so several
52 sweepers can run without sharing anything. */ 52 sweepers can run without sharing anything. */
53int fdstate_next_expired(ot_time now, int *cursor); 53int fdstate_next_expired(unsigned long now, int *cursor);
54 54
55/* Both only valid while the caller holds the descriptor. */ 55/* Both only valid while the caller holds the descriptor. */
56void *fdstate_cookie(int fd); 56void *fdstate_cookie(int fd);
57 57
58/* Hand the slot a different cookie, for a connection whose state has moved */ 58/* Hand the slot a different cookie, for a connection whose state has moved */
59void fdstate_set_cookie(int fd, void *cookie); 59void fdstate_set_cookie(int fd, void *cookie);
60void fdstate_set_expiry(int fd, ot_time expiry); 60void fdstate_set_expiry(int fd, unsigned long expiry);
61 61
62#endif 62#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) {
83 pthread_mutex_unlock(&g_counter_mutex); 83 pthread_mutex_unlock(&g_counter_mutex);
84} 84}
85 85
86#define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long long)(by), memory_order_relaxed) 86#define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long)(by), memory_order_relaxed)
87 87
88static const char *ot_failed_request_names[] = { 88static const char *ot_failed_request_names[] = {
89 "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest", 89 "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 {
221}; 221};
222 222
223/* One statistic. Used when workers report stats to their workstruct */ 223/* One statistic. Used when workers report stats to their workstruct */
224typedef _Atomic unsigned long long ot_counter; 224typedef _Atomic unsigned long ot_counter;
225 225
226/* What each thread counts for itself. The two runs at the end are indexed by 226/* What each thread counts for itself. The two runs at the end are indexed by
227 the http error code and by the age in minutes of a renewed peer */ 227 the http error code and by the age in minutes of a renewed peer */