Handmade Hero»Forums»Code
Simon Anciaux
1337 posts
b32x, memory_index, umm, smm
In one of the last episodes, Casey tried to use the b32x type which is not defined in the handmade hero code base. What would be the purpose (or conceptual meaning) of that type, and would it be the same typedef as b32 ?

On the same topic what are the different use case for memory_index (size_t) and umm (uintptr_t) as they are defined exactly the same way ?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#ifdef  _WIN64
typedef unsigned __int64    size_t;
#else
typedef _W64 unsigned int   size_t;
#endif

#ifdef  _WIN64
typedef unsigned __int64    uintptr_t;
#else
typedef _W64 unsigned int   uintptr_t;
#endif
39 posts / 1 project
b32x, memory_index, umm, smm
Can't speak to b32x, but size_t and uintptr_t can be defined differently on certain platforms

From cppreference
uintptr_t - unsigned integer type capable of holding a pointer

size_t can store the maximum size of a theoretically possible object of any type (including array).

As I understand it on systems with segmented memory, size_t used as an index would hold only an offset within a segment, but uintptr_t would hold both a segment and an offset.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
b32x, memory_index, umm, smm
b32x is just "boolean value in whatever size is comfortable for the compiler but not less than 32 bits." It's what you use when you're working with s32/u32 and want to store a boolean but don't care if it expands to 64 bits (or more) on some theoretical architecture where that was more efficient.

- Casey
Simon Anciaux
1337 posts
b32x, memory_index, umm, smm
I would like to rephrase my question: Given that memory_index and umm are implemented the same, are there cases where you specifically use memory_index or umm to give additional meaning to some code ?

@cmuratori: So is it
1
typedef int_least32_t b32x
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
b32x, memory_index, umm, smm
We don't really need both, no - we could replace memory_index (and probably should) now that we have umm/smm.

- Casey
14 posts
b32x, memory_index, umm, smm
Btw what does mm stand for?
Mārtiņš Možeiko
2559 posts / 2 projects
b32x, memory_index, umm, smm
memory mapped?
511 posts
b32x, memory_index, umm, smm
bimbinel
Btw what does mm stand for?


It's probably an adaptation from the meaningless MMX initialism
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
b32x, memory_index, umm, smm
It's just a shorthand for "the size that a pointer is". There's no rhyme or reason for it. The "m" stands for "memory" but there's no reason it has to be two of them, I think I just liked the way that looked better than "um" and "sm".

- Casey