logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

casueword, casueword32, casuword, casuword32 — fetch, compare and store data from user-space

Description

       The  casueword  functions  are  designed to perform atomic compare-and-swap operation on the value in the
       usermode memory of the current process.

       The casueword routines reads the value from user memory with address base, and  compare  the  value  read
       with  oldval.   If  the  values  are equal, newval is written to the *base.  In case of casueword32() and
       casueword(), old value is stored into the (kernel-mode) variable  pointed  by  *oldvalp.   The  userspace
       value must be naturally aligned.

       The  callers  of  casuword() and casuword32() functions cannot distinguish between -1 read from userspace
       and function failure.

Name

       casueword, casueword32, casuword, casuword32 — fetch, compare and store data from user-space

Return Values

       The casuword() and casuword32() functions return the data fetched or -1 on failure.  The casueword()  and
       casueword32()  functions  return  0  on success, -1 on failure to access memory, and 1 when comparison or
       store failed.  The store can fail on load-linked/store-conditional architectures.

See Also

atomic(9), fetch(9), store(9)

Debian                                           April 19, 2019                                          CASU(9)

Synopsis

#include<sys/types.h>#include<sys/systm.h>intcasueword(volatileu_long*base, u_longoldval, u_long*oldvalp, u_longnewval);

       intcasueword32(volatileuint32_t*base, uint32_toldval, uint32_t*oldvalp, uint32_tnewval);

       u_longcasuword(volatileu_long*base, u_longoldval, u_longnewval);

       uint32_tcasuword32(volatileuint32_t*base, uint32_toldval, uint32_tnewval);

See Also