mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 19:58:30 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
26
libc/intrin/repmovsb.h
Normal file
26
libc/intrin/repmovsb.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
static void repmovsb(void **dest, const void **src, size_t cx) {
|
||||
char *di = (char *)*dest;
|
||||
const char *si = (const char *)*src;
|
||||
while (cx) *di++ = *si++, cx--;
|
||||
*dest = di, *src = si;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
#define repmovsb(DI, SI, CX) \
|
||||
({ \
|
||||
void *Di = *(DI); \
|
||||
const void *Si = *(SI); \
|
||||
size_t Cx = (CX); \
|
||||
asm("rep movsb" \
|
||||
: "=D"(Di), "=S"(Si), "=c"(Cx), "=m"(*(char(*)[Cx])Di) \
|
||||
: "0"(Di), "1"(Si), "2"(Cx), "m"(*(const char(*)[Cx])Si)); \
|
||||
*(DI) = Di, *(SI) = Si; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue