File: issue151.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (27 lines) | stat: -rw-r--r-- 384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include "test.h"

static int
ngx_atomic_fetch_add(char *value, int add)
{

int *ptr = &add;
    __asm__ volatile (

         
    "    xaddq  %0, %1;   "

    : "+r" (ptr) : "m" (*value) : "cc", "memory");

    return add;
}

int main () {
    int a = 10;
    int *b = 8;
    int res =  ngx_atomic_fetch_add(&b, a);
    printf("res=%d\n", res);
    ASSERT(10, res);
    return 0;

}