forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will allow us to reimplpement atomic ops with lock/touch/unlock way if underlying hosts don't support a particular atomic ops. Signed-off-by: Hajime Tazaki <[email protected]>
- Loading branch information
Showing
6 changed files
with
105 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
extra-y := vmlinux.lds | ||
|
||
obj-y = setup.o threads.o irq.o time.o syscalls.o misc.o console.o \ | ||
syscalls_32.o cpu.o | ||
syscalls_32.o cpu.o atomic.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <linux/kernel.h> | ||
#include <linux/init.h> | ||
#include <asm/host_ops.h> | ||
|
||
#if defined(__ARMEL__) | ||
static void *atomic_lock; | ||
|
||
long lkl__sync_fetch_and_or(long *ptr, long value) | ||
{ | ||
lkl_ops->sem_down(atomic_lock); | ||
*ptr = value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return 0; | ||
} | ||
|
||
long lkl__sync_fetch_and_and(long *ptr, long value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr *= value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
int lkl__sync_fetch_and_add(int *ptr, int value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr += value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
int lkl__sync_fetch_and_sub(int *ptr, int value) | ||
{ | ||
int tmp; | ||
|
||
lkl_ops->sem_down(atomic_lock); | ||
tmp = *ptr; | ||
*ptr -= value; | ||
lkl_ops->sem_up(atomic_lock); | ||
return tmp; | ||
} | ||
|
||
void lkl__sync_synchronize(void) | ||
{ | ||
} | ||
|
||
static int __init lkl_atomic_ops_init(void) | ||
{ | ||
atomic_lock = lkl_ops->sem_alloc(1); | ||
return 0; | ||
} | ||
early_initcall(lkl_atomic_ops_init); | ||
|
||
#else | ||
long lkl__sync_fetch_and_or(long *ptr, long value) | ||
{ | ||
return __sync_fetch_and_or(ptr, value); | ||
} | ||
|
||
long lkl__sync_fetch_and_and(long *ptr, long value) | ||
{ | ||
return __sync_fetch_and_and(ptr, value); | ||
} | ||
|
||
int lkl__sync_fetch_and_add(int *ptr, int value) | ||
{ | ||
return __sync_fetch_and_add(ptr, value); | ||
} | ||
|
||
int lkl__sync_fetch_and_sub(int *ptr, int value) | ||
{ | ||
return __sync_fetch_and_sub(ptr, value); | ||
} | ||
|
||
void lkl__sync_synchronize(void) | ||
{ | ||
return __sync_synchronize(); | ||
} | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters