mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 19:58:30 +00:00
Get rid of .internal.h convention in LIBC_INTRIN
This commit is contained in:
parent
0ed916ad5c
commit
86d884cce2
591 changed files with 773 additions and 773 deletions
22
libc/intrin/xchg.h
Normal file
22
libc/intrin/xchg.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_XCHG_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_XCHG_H_
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Exchanges *MEMORY into *LOCALVAR.
|
||||
*
|
||||
* @return *MEMORY
|
||||
* todo(jart): what's the point of this?
|
||||
*/
|
||||
#define xchg(MEMORY, LOCALVAR) \
|
||||
({ \
|
||||
autotype(MEMORY) Memory = (MEMORY); \
|
||||
typeof(Memory) LocalVar = (LOCALVAR); \
|
||||
typeof(*Memory) Temp; \
|
||||
memcpy(&Temp, Memory, sizeof(Temp)); \
|
||||
memcpy(Memory, LocalVar, sizeof(Temp)); \
|
||||
memcpy(LocalVar, &Temp, sizeof(Temp)); \
|
||||
Temp; \
|
||||
})
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_XCHG_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue