NO

Author Topic: PTRDIFF_MAX vs SIZE_MAX interpretations  (Read 2650 times)

Abraham

  • Guest
PTRDIFF_MAX vs SIZE_MAX interpretations
« on: November 06, 2018, 02:05:33 AM »
C90 Standard sort of indirectly requires PTRDIFF_MAX >= SIZE_MAX, but now, with 64-bit processing, and no motherboard supports a full 64-bit RAM, the standard stop this "implicit" requirement.

SIZE_MAX >= 65535
PTRDIFF_MAX >= 131071
SIZE_T must be able to index any array
PTRDIFF_T must be able to take any difference of pointers

Long Mode
48-bit Current Implementation, PTRDIFF_T only needs 49-bits, SIZE_T only needs 48-bits
56-bit Future Implementation, PTRDIFF_T only needs 57-bits, SIZE_T only needs 56-bits
64-bit Far Future Implementation, PTRDIFF_T needs 65-bits, SIZE_T only needs 64-bits

Segmentation
20-bit Addressing (8086 and 80186), SIZE_T is 16-bit, PTRDIFF_T is 32-bit, even though it only needs to be 17-bit. Far Pointers!
24-bit Addressing (80286),, SIZE_T is 16-bit, PTRDIFF_T is 32-bit, even though it only needs to be 17-bit. Far Pointers!
28-bit Addressing (not sure which variant, but one of those laptop motherboard had this limit) (80386 variant), SIZE_T is 16-bit, PTRDIFF_T is 32-bit, even though it only needs to be 17-bit. Far Pointers!

Flat Mode
32-bit Addressing (80386) 4GB Limit.
(80486) New Technology (NT) switch to HDD sector addressing, so 2TB is max. 4G Sectors of 512 Bytes per Sector.

Physical Address Extension (Segmentation for 32-bit)
36-bit Addressing (very first PAE on Windows XP).
48-bit Addressing (current motherboards only support this many) requires Kernel Hacking Windows XP or later (not recommended).