2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2006 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Brian Shire <shire@php.net> |
16 +----------------------------------------------------------------------+
20 /* $Id: atomic.h,v 1.1 2006/09/29 07:13:01 shire Exp $ */
23 #include <sys/syscall.h>
25 #include <linux/futex.h>
27 /* int sys_futex (void *futex, int op, int val, const struct timespec *timeout); */
28 static inline long int apc_sys_futex(void *futex, int op, int val, const struct timespec *timeout) {
32 /* x86_64 system calls are performed with the faster SYSCALL operation.
33 * the argument order is D, S, d, c, b, a rather than
34 * a, b, c, d, S, D as on the i386 int 80h call.
36 asm volatile ("syscall"
43 : "r11", "rcx", "memory"
51 static inline int apc_cmpxchg(volatile int *ptr, int old, int new) {
55 asm volatile ("LOCK cmpxchgl %1, %2"
66 static inline int apc_xchg(volatile int *ptr, int new) {
70 asm volatile ("LOCK xchgl %[new], %[ptr]"