[PATCH] Add implementations of __readfs{byte, word, dword, qword} to Intrin.h

Hans Wennborg hans at chromium.org
Thu Jan 23 16:28:27 PST 2014


On Thu, Jan 23, 2014 at 3:49 PM, Charles Davis <cdavis5x at gmail.com> wrote:
>
>
> ================
> Comment at: lib/Headers/Intrin.h:781-796
> @@ +780,18 @@
> +
> +static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
> +__readfsbyte(unsigned long __offset) {
> +  return *__ptr_to_addr_space(257, unsigned char, __offset);
> +}
> +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
> +__readfsdword(unsigned long __offset) {
> +  return *__ptr_to_addr_space(257, unsigned long, __offset);
> +}
> +static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))
> +__readfsqword(unsigned long __offset) {
> +  return *__ptr_to_addr_space(257, unsigned __int64, __offset);
> +}
> +static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))
> +__readfsword(unsigned long __offset) {
> +  return *__ptr_to_addr_space(257, unsigned short, __offset);
> +}
> +
> ----------------
> In MSVC, these intrinsics actually aren't available on x64. (They're not needed anyway on Windows/x64, because it uses `GS` for the TEB instead of `FS` as Windows/i386 does.) For this reason (unless you have some pressing need for `FS`-relative access on a non-Windows x86-64 platform), you might consider putting them inside an `#ifndef __x86_64__` block.

Ah, I didn't know that.

OK, put these in #ifdef. I'll also remove the uintptr_t cast now since
the __offset param will be pointer-sized on x86 in MS mode.

Thanks,
Hans




More information about the cfe-commits mailing list