added 64 bit atomic functions (implementation still pending),

removed non atomic functions from this file


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-08-20 02:19:42 +00:00
parent 414ecbd490
commit 6f54d569e9
+65 -87
View File
@@ -1,4 +1,7 @@
/*
** Copyright 2003, Marcus Overhagen. All rights reserved.
** Distributed under the terms of the OpenBeOS license.
**
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
@@ -7,104 +10,79 @@
.text
/* int atomic_add(int *val, int incr) */
FUNCTION(atomic_add):
movl 4(%esp),%edx
movl 8(%esp),%eax
lock
xaddl %eax,(%edx)
ret
/* int atomic_and(int *val, int incr) */
FUNCTION(atomic_and):
movl 4(%esp),%edx
_atomic_and1:
movl 8(%esp),%ecx
movl (%edx),%eax
andl %eax,%ecx
lock
cmpxchgl %ecx,(%edx)
jnz _atomic_and1
ret
/* int atomic_or(int *val, int incr) */
FUNCTION(atomic_or):
movl 4(%esp),%edx
_atomic_or1:
movl 8(%esp),%ecx
movl (%edx),%eax
orl %eax,%ecx
lock
cmpxchgl %ecx,(%edx)
jnz _atomic_or1
ret
/* int atomic_set(int *val, int set_to) */
/* int32 atomic_set(vint32 *value, int32 newValue) */
FUNCTION(atomic_set):
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 4(%esp),%edx
movl 8(%esp),%eax
lock
xchg %eax,(%edx)
xchg %eax,(%edx)
ret
/* int test_and_set(int *val, int set_to, int test_val) */
FUNCTION(test_and_set):
movl 4(%esp),%edx
movl 8(%esp),%ecx
movl 12(%esp),%eax
/* int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst) */
FUNCTION(atomic_test_and_set):
movl 4(%esp),%edx
movl 8(%esp),%ecx
movl 12(%esp),%eax
lock
cmpxchgl %ecx,(%edx)
ret
/* saves the conversion factor needed for system_time */
cv_factor:
.word 0
FUNCTION(setup_system_time):
movl 4(%esp),%eax
movl %eax,cv_factor
/* int32 atomic_add(vint32 *value, int32 addValue) */
FUNCTION(atomic_add):
movl 4(%esp),%edx
movl 8(%esp),%eax
lock
xaddl %eax,(%edx)
ret
/* long long system_time(); */
FUNCTION(system_time):
/* load 64-bit factor into %eax (low), %edx (high) */
rdtsc /* time in %edx,%eax */
pushl %ebx
pushl %ecx
movl cv_factor, %ebx
movl %edx, %ecx /* save high half */
mull %ebx /* truncate %eax, but keep %edx */
movl %ecx, %eax
movl %edx, %ecx /* save high half of low */
mull %ebx /*, %eax*/
/* now compute [%edx, %eax] + [%ecx], propagating carry */
subl %ebx, %ebx /* need zero to propagate carry */
addl %ecx, %eax
adc %ebx, %edx
popl %ecx
popl %ebx
/* int32 atomic_and(vint32 *value, int32 andValue) */
FUNCTION(atomic_and):
movl 4(%esp),%edx
_atomic_and1:
movl 8(%esp),%ecx
movl (%edx),%eax
andl %eax,%ecx
lock
cmpxchgl %ecx,(%edx)
jnz _atomic_and1
ret
/* void i386_switch_stack_and_call(addr stack, void (*func)(void *), void *arg); */
FUNCTION(i386_switch_stack_and_call):
movl 4(%esp),%eax // new stack
movl 8(%esp),%ecx // func
movl 12(%esp),%edx // args
/* int32 atomic_or(vint32 *value, int32 orValue) */
FUNCTION(atomic_or):
movl 4(%esp),%edx
_atomic_or1:
movl 8(%esp),%ecx
movl (%edx),%eax
orl %eax,%ecx
lock
cmpxchgl %ecx,(%edx)
jnz _atomic_or1
ret
/* int32 atomic_read(vint32 *value) */
FUNCTION(atomic_read):
ret
movl %eax,%esp // switch the stack
pushl %edx // push the argument
call *%ecx // call the target function
_loop:
jmp _loop
/* int64 atomic_set64(vint64 *value, int64 newValue) */
FUNCTION(atomic_set64):
ret
/* int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) */
FUNCTION(atomic_test_and_set64):
ret
/* int64 atomic_add64(vint64 *value, int64 addValue) */
FUNCTION(atomic_add64):
ret
/* int64 atomic_and64(vint64 *value, int64 andValue) */
FUNCTION(atomic_and64):
ret
/* int64 atomic_or64(vint64 *value, int64 orValue) */
FUNCTION(atomic_or64):
ret
/* int64 atomic_read64(vint64 *value) */
FUNCTION(atomic_read64):
ret