| 1 | /*
|
|---|
| 2 | * interlocked functions
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright 1996 Alexandre Julliard
|
|---|
| 5 | *
|
|---|
| 6 | * This library is free software; you can redistribute it and/or
|
|---|
| 7 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 8 | * License as published by the Free Software Foundation; either
|
|---|
| 9 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 10 | *
|
|---|
| 11 | * This library is distributed in the hope that it will be useful,
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | * Lesser General Public License for more details.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 17 | * License along with this library; if not, write to the Free Software
|
|---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include "windef.h"
|
|---|
| 22 | extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
|
|---|
| 23 |
|
|---|
| 24 | __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare) {
|
|---|
| 25 | __asm(
|
|---|
| 26 | "push %ebx\n\t"
|
|---|
| 27 | "push %esi\n\t"
|
|---|
| 28 | "movl 12(%esp),%esi\n\t"
|
|---|
| 29 | "movl 16(%esp),%ebx\n\t"
|
|---|
| 30 | "movl 20(%esp),%ecx\n\t"
|
|---|
| 31 | "movl 24(%esp),%eax\n\t"
|
|---|
| 32 | "movl 28(%esp),%edx\n\t"
|
|---|
| 33 | "lock; cmpxchg8b (%esi)\n\t"
|
|---|
| 34 | "pop %esi\n\t"
|
|---|
| 35 | "pop %ebx\n\t"
|
|---|
| 36 | "ret");
|
|---|
| 37 | }
|
|---|