Implemented new syscalls for 32 and 64 bit atomic operations.

They are only used if the architecture doesn't support them directly.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4360 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-08-21 23:02:00 +00:00
parent fb16941a02
commit 50e0ce4bee
13 changed files with 453 additions and 138 deletions
@@ -12,6 +12,8 @@
#define _BIG_ENDIAN 1
#define _LITTLE_ENDIAN 0
#define ATOMIC64_FUNCS_ARE_SYSCALLS 1
struct iframe {
};
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Copyright 2003, Marcus Overhagen. All rights reserved.
** Distributed under the terms of the NewOS License.
** Distributed under the terms of the OpenBeOS license.
*/
#ifndef _KERNEL_ARCH_CPU_H
#define _KERNEL_ARCH_CPU_H
-65
View File
@@ -1,65 +0,0 @@
#ifndef _KERNEL_ATOMIC_H
#define _KERNEL_ATOMIC_H
#include <ktypes.h>
/**
* @file kernel/atomic.h
* @brief Prototypes for kernel and user versions of atomic
* functions.
*/
/**
* @defgroup Kernel_Atomic Atomic Operations
* @ingroup OpenBeOS_Kernel
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/* atomic_add(), atomic_and(), atomic_or() must
* match the definitions in SupportDefs.h
*/
/**
* Atomic add (user version)
* @param val Pointer to an integer
* @param incr The increment to add (may be -ve)
* @note Returns value of val before addition
*/
int32 user_atomic_add(vint32 *val, int32 incr);
/**
* Atomic and (user version)
* @param val Pointer to an integer
* @param incr The increment to add (may be -ve)
* @note Returns value of val before addition
*/
int32 user_atomic_and(vint32 *val, int32 incr);
/**
* Atomic or (user version)
* @param val Pointer to an integer
* @param incr The increment to add (may be -ve)
* @note Returns value of val before addition
*/
int32 user_atomic_or(vint32 *val, int32 incr);
int32 user_atomic_set(vint32 *val, int32 set_to);
/* Compare the value of val with test_val. If they
* are equal then set the value of 'val' to
* 'set_to'
* @note This is the user version and should not be used within
* the kernel.
*/
int32 user_atomic_test_and_set(vint32 *val, int32 set_to, int32 test_val);
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* _KERNEL_ATOMIC_H */
+18 -6
View File
@@ -75,11 +75,11 @@ enum {
SYSCALL_GET_PROC_TABLE,
SYSCALL_GETRLIMIT,
SYSCALL_SETRLIMIT,
SYSCALL_ATOMIC_ADD,
SYSCALL_ATOMIC_AND,
SYSCALL_ATOMIC_OR,
SYSCALL_ATOMIC_SET,
SYSCALL_TEST_AND_SET, /* 70 */
SYSCALL_unused_66,
SYSCALL_unused_67,
SYSCALL_unused_68,
SYSCALL_unused_69,
SYSCALL_unused_70, /* 70 */
SYSCALL_SYSCTL,
SYSCALL_SOCKET,
SYSCALL_ACCESS,
@@ -113,7 +113,7 @@ enum {
SYSCALL_REMOVE_ATTR,
SYSCALL_RENAME_ATTR,
SYSCALL_RETURN_FROM_SIGNAL,
SYSCALL_KILL, // obsolete
SYSCALL_unused_104,
SYSCALL_SIGACTION, /* 105 */
SYSCALL_OPEN_INDEX_DIR,
SYSCALL_CREATE_INDEX,
@@ -135,6 +135,18 @@ enum {
SYSCALL_SET_AREA_PROTECTION,
SYSCALL_RESIZE_AREA,
SYSCALL_AREA_FOR, /* 125 */
SYSCALL_ATOMIC_SET,
SYSCALL_ATOMIC_TEST_AND_SET,
SYSCALL_ATOMIC_ADD,
SYSCALL_ATOMIC_AND,
SYSCALL_ATOMIC_OR, /* 130 */
SYSCALL_ATOMIC_READ,
SYSCALL_ATOMIC_SET64,
SYSCALL_ATOMIC_TEST_AND_SET64,
SYSCALL_ATOMIC_ADD64,
SYSCALL_ATOMIC_AND64, /* 135 */
SYSCALL_ATOMIC_OR64,
SYSCALL_ATOMIC_READ64,
};
int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_ret);
+13 -6
View File
@@ -108,12 +108,19 @@ int sys_port_set_owner(port_id port, team_id team);
int sys_port_write(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size);
int sys_port_write_etc(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size, uint32 flags, bigtime_t timeout);
/* atomic_* ops (needed for cpus that dont support them directly) */
int sys_atomic_add(int *val, int incr);
int sys_atomic_and(int *val, int incr);
int sys_atomic_or(int *val, int incr);
int sys_atomic_set(int *val, int set_to);
int sys_test_and_set(int *val, int set_to, int test_val);
/* atomic_* ops (needed for CPUs that don't support them directly) */
int32 _kern_atomic_set(vint32 *value, int32 newValue);
int32 _kern_atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst);
int32 _kern_atomic_add(vint32 *value, int32 addValue);
int32 _kern_atomic_and(vint32 *value, int32 andValue);
int32 _kern_atomic_or(vint32 *value, int32 orValue);
int32 _kern_atomic_read(vint32 *value);
int64 _kern_atomic_set64(vint64 *value, int64 newValue);
int64 _kern_atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst);
int64 _kern_atomic_add64(vint64 *value, int64 addValue);
int64 _kern_atomic_and64(vint64 *value, int64 andValue);
int64 _kern_atomic_or64(vint64 *value, int64 orValue);
int64 _kern_atomic_read64(vint64 *value);
int sys_sysctl(int *, uint, void *, size_t *, void *, size_t);
int sys_socket(int, int, int);
+26
View File
@@ -0,0 +1,26 @@
/*
** Copyright 2003, Marcus Overhagen. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _KERNEL_USER_ATOMIC_H
#define _KERNEL_USER_ATOMIC_H
/* If the architecture doesn't support atomic functions
* in userspace, they are implemented as these syscalls.
*/
int32 user_atomic_set(vint32 *value, int32 newValue);
int32 user_atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst);
int32 user_atomic_add(vint32 *value, int32 addValue);
int32 user_atomic_and(vint32 *value, int32 andValue);
int32 user_atomic_or(vint32 *value, int32 orValue);
int32 user_atomic_read(vint32 *value);
int64 user_atomic_set64(vint64 *value, int64 newValue);
int64 user_atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst);
int64 user_atomic_add64(vint64 *value, int64 addValue);
int64 user_atomic_and64(vint64 *value, int64 andValue);
int64 user_atomic_or64(vint64 *value, int64 orValue);
int64 user_atomic_read64(vint64 *value);
#endif /* _KERNEL_USER_ATOMIC_H */