mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
fa20edc44d
- Remove most __ASSEMBLER__ __LINKER__ ifdefs - Rename libc/intrin/bits.h to libc/serialize.h - Block pthread cancelation in fchmodat() polyfill - Remove `clang-format off` statements in third_party
24 lines
818 B
C
24 lines
818 B
C
#ifndef COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_
|
|
#define COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_
|
|
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
#ifdef _COSMO_SOURCE
|
|
|
|
/**
|
|
* Reads scalar from memory, offset by segment.
|
|
*
|
|
* @return *(MEM) relative to segment
|
|
* @see pushpop()
|
|
*/
|
|
#define fs(MEM) __peek("fs", MEM)
|
|
#define gs(MEM) __peek("gs", MEM)
|
|
|
|
#define __peek(SEGMENT, ADDRESS) \
|
|
({ \
|
|
typeof(*(ADDRESS)) Pk; \
|
|
asm("mov\t%%" SEGMENT ":%1,%0" : "=r"(Pk) : "m"(*(ADDRESS))); \
|
|
Pk; \
|
|
})
|
|
|
|
#endif /* _COSMO_SOURCE */
|
|
#endif /* __GNUC__ && !__STRICT_ANSI__ */
|
|
#endif /* COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_ */
|