mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 19:43:32 +00:00
c776a32f75
This change might cause ABI breakages for /opt/cosmos. It's needed to help us better conform to header declaration practices.
26 lines
903 B
C
26 lines
903 B
C
#ifndef COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_
|
|
#define COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
#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 /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_ */
|