Index: arch/hppa/hppa/sys_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/hppa/hppa/sys_machdep.c,v retrieving revision 1.3 diff -u -p -r1.3 sys_machdep.c --- arch/hppa/hppa/sys_machdep.c 2 Jun 2003 23:27:46 -0000 1.3 +++ arch/hppa/hppa/sys_machdep.c 26 Jun 2015 06:57:55 -0000 @@ -56,3 +56,68 @@ sys_sysarch(p, v, retval) } return (error); } + +#include +#include + +struct rwlock sys_cas_lock = RWLOCK_INITIALIZER("cas"); + +int +sys_cas_uint(struct proc *p, void *v, register_t *retval) +{ + struct sys_cas_uint_args /* { + syscallarg(u_int *) p; + syscallarg(u_int) e; + syscallarg(u_int) n; + } */ *uap = v; + u_int *uip = SCARG(uap, p); + u_int n, o = 0; + int error; + + rw_enter_write(&sys_cas_lock); + error = copyin(uip, &o, sizeof(*uip)); + if (error == 0 && o == SCARG(uap, e)) { + n = SCARG(uap, n); + error = copyout(&n, uip, sizeof(*uip)); + } + rw_exit_write(&sys_cas_lock); + + if (error) { + KERNEL_LOCK(); + psignal(p, SIGSEGV); + KERNEL_UNLOCK(); + } + + *retval = o; + return (error); +} + +int +sys_cas_ulong(struct proc *p, void *v, register_t *retval) +{ + struct sys_cas_ulong_args /* { + syscallarg(u_int *) p; + syscallarg(u_int) e; + syscallarg(u_int) n; + } */ *uap = v; + u_long *uip = SCARG(uap, p); + u_long n, o = 0; + int error; + + rw_enter_write(&sys_cas_lock); + error = copyin(uip, &o, sizeof(*uip)); + if (error == 0 && o == SCARG(uap, e)) { + n = SCARG(uap, n); + error = copyout(&n, uip, sizeof(*uip)); + } + rw_exit_write(&sys_cas_lock); + + if (error) { + KERNEL_LOCK(); + psignal(p, SIGSEGV); + KERNEL_UNLOCK(); + } + + *retval = o; + return (error); +} Index: arch/hppa/include/param.h =================================================================== RCS file: /cvs/src/sys/arch/hppa/include/param.h,v retrieving revision 1.45 diff -u -p -r1.45 param.h --- arch/hppa/include/param.h 26 Mar 2013 05:04:10 -0000 1.45 +++ arch/hppa/include/param.h 26 Jun 2015 06:57:55 -0000 @@ -68,4 +68,6 @@ #define MACHINE_STACK_GROWS_UP 1 /* stack grows to higher addresses */ #define __SWAP_BROKEN +#define SYS_CAS + #endif /* _MACHINE_PARAM_H_ */ Index: kern/syscalls.master =================================================================== RCS file: /cvs/src/sys/kern/syscalls.master,v retrieving revision 1.153 diff -u -p -r1.153 syscalls.master --- kern/syscalls.master 6 May 2015 11:20:07 -0000 1.153 +++ kern/syscalls.master 26 Jun 2015 06:58:06 -0000 @@ -303,8 +303,13 @@ 163 OBSOL osetdomainname 164 UNIMPL ouname 165 STD { int sys_sysarch(int op, void *parms); } +#ifdef SYS_CAS +166 STD NOLOCK { u_int sys_cas_uint(u_int *p, u_int e, u_int n); } +167 STD NOLOCK { u_long sys_cas_ulong(u_long *p, u_long e, u_long n); } +#else 166 UNIMPL 167 UNIMPL +#endif 168 UNIMPL 169 OBSOL semsys10 170 OBSOL msgsys10