dump
dump copied to clipboard
'__atomic_load_8' error on 32 bit machine
Hello,
While trying to compile the 'how-to-receive-a-million-packets' code, I got the following error.
$ ./build.sh
/tmp/udpreceiver1-4ee1c6.o: In function `main':
udpreceiver1.c:143: undefined reference to `__atomic_load_8'
udpreceiver1.c:144: undefined reference to `__atomic_load_8'
/tmp/udpreceiver1-4ee1c6.o: In function `thread_loop':
udpreceiver1.c:67: undefined reference to `__atomic_fetch_add_8'
udpreceiver1.c:68: undefined reference to `__atomic_fetch_add_8'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
A quick google search revealed that the possible cause is incompatibility with 32 bit OS. So, I did the following changes and it worked fine (however, I am not very sure about any side effects).
--- a/udpreceiver1.c 2015-09-21 12:35:54.002816478 +0530
+++ b/udpreceiver1.c 2015-09-21 17:04:36.236634027 +0530
@@ -18,12 +18,12 @@
struct state {
int fd;
- volatile uint64_t bps;
- volatile uint64_t pps;
+ volatile uint32_t bps;
+ volatile uint32_t pps;
struct mmsghdr messages[MAX_MSG];
char buffers[MAX_MSG][MTU_SIZE];
struct iovec iovecs[MAX_MSG];
-} __attribute__ ((aligned (64)));
+} __attribute__ ((aligned (32)));
struct state *state_init(struct state *s) {
int i;
@@ -121,8 +121,8 @@
thread_spawn(thread_loop, state);
}
- uint64_t last_pps = 0;
- uint64_t last_bps = 0;
+ uint32_t last_pps = 0;
+ uint32_t last_bps = 0;
while (1) {
struct timeval timeout =
@@ -137,7 +137,7 @@
}
}
- uint64_t now_pps = 0, now_bps = 0;
+ uint32_t now_pps = 0, now_bps = 0;
for (t = 0; t < thread_num; t++) {
struct state *state = &array_of_states[t];
now_pps += __atomic_load_n(&state->pps, 0);