1
0
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:
Mark Pizzolato
2018-06-01 23:16:14 -07:00
parent 0e5c60b58f
commit c1f249ec66
2 changed files with 22 additions and 0 deletions

View File

@@ -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)