|
|
|
|
|
by dapperdrake
5 days ago
|
|
There was an old VAX or something that had a C standard library where function pointers in both C and Fortran were multiple machine words. C was 4 words and Fortran was 6 with everything but the first two being reserved for later. The idea was to provide additional argument and return type information in tag bits in the additional machine words. So, mathematically, pointers still are integers, because "everything" can be encoded as a natural number. Handles like in Windows or UEFI, hardware descriptors like internal to netmap and io_uring for NIC physical memory mapped control registers, 32-bit integer page numbers within sqlite databases, or memory addresses in x86_64 registers. Tagged numbers for counting stuff. Just look at off_t in Linux. Or unix filesescriptor fd numbers into a tiny per-process table of each Linux process. Some with hardware support, some without. And then stuff like ptrdiff_t in the C abstract machine. All the same idea. And it "only works", because they are "just numbers". And then come the implementation details. |
|