News for hackers. Stuff that matters.
Re:Rust's unsafe pointer types need an overhaul by Gankra on Sunday March 20, 2022 @01:38AM (#30740436)
hmm i've always just mentally modelled TLS as "yeah the OS slaps a pointer to an array in this one register".

but i guess the difference between "pointer to an array" and "a segment of memory" isn't actually that big?

Re:Rust's unsafe pointer types need an overhaul by amluto on Sunday March 20, 2022 @08:20AM (#30742055)
It’s a funny register: you don’t want to read it (and before Ivy Bridge, user code couldn’t read it). The base is added by the CPU when you dereference the pointer. So code like:

    __thread int array[100];
    array[n] += 5:
Effectively computes the offset portion of array+n and then, using CPU assistance, accesses that memory relative to the segment.