mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
b8a6a989c0
This change greatly reduces the number of modules that need to be compiled. The only issue right now is that sometimes when viewing symbol table entries, the aliased symbol is chosen.
27 lines
996 B
C
27 lines
996 B
C
#ifndef COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_
|
|
#define COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
#ifdef COSMO
|
|
|
|
forceinline void *repstosb(void *dest, unsigned char al, size_t cx) {
|
|
unsigned char *di = (unsigned char *)dest;
|
|
while (cx) *di++ = al, cx--;
|
|
return di;
|
|
}
|
|
|
|
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
#define repstosb(DI, AL, CX) \
|
|
({ \
|
|
void *Di = (DI); \
|
|
size_t Cx = (CX); \
|
|
unsigned char Al = (AL); \
|
|
asm("rep stosb %b5,(%0)" \
|
|
: "=D"(Di), "=c"(Cx), "=m"(*(char(*)[Cx])Di) \
|
|
: "0"(Di), "1"(Cx), "a"(Al)); \
|
|
Di; \
|
|
})
|
|
#endif
|
|
|
|
#endif /* COSMO */
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_ */
|