mirror of
https://github.com/simh/simh.git
synced 2026-02-19 05:48:18 +00:00
SCP: Add atomic routines for temporary shmem access
This commit is contained in:
20
sim_fio.c
20
sim_fio.c
@@ -458,6 +458,16 @@ if (shmem->hMapping != INVALID_HANDLE_VALUE)
|
||||
free (shmem);
|
||||
}
|
||||
|
||||
int32 sim_shmem_atomic_add (int32 *p, int32 v)
|
||||
{
|
||||
return InterlockedExchangeAdd ((volatile long *) p,v) + (v);
|
||||
}
|
||||
|
||||
t_bool sim_shmem_atomic_cas (int32 *ptr, int32 oldv, int32 newv)
|
||||
{
|
||||
return (InterlockedCompareExchange ((LONG volatile *) ptr, newv, oldv) == oldv);
|
||||
}
|
||||
|
||||
#else /* !defined(_WIN32) */
|
||||
#include <unistd.h>
|
||||
int sim_set_fsize (FILE *fptr, t_addr size)
|
||||
@@ -604,6 +614,16 @@ if (shmem->shm_fd != -1)
|
||||
free (shmem);
|
||||
}
|
||||
|
||||
int32 sim_shmem_atomic_add (int32 *p, int32 v)
|
||||
{
|
||||
return __sync_add_and_fetch((int *) p, v);
|
||||
}
|
||||
|
||||
t_bool sim_shmem_atomic_cas (int32 *ptr, int32 oldv, int32 newv)
|
||||
{
|
||||
return __sync_bool_compare_and_swap (ptr, oldv, newv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__VAX)
|
||||
|
||||
Reference in New Issue
Block a user