Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'__atomic_load_8' error on 32 bit machine #3

Open
vigneswaran opened this issue Sep 21, 2015 · 0 comments
Open

'__atomic_load_8' error on 32 bit machine #3

vigneswaran opened this issue Sep 21, 2015 · 0 comments

Comments

@vigneswaran
Copy link

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant