Crates.io | data_models |
lib.rs | data_models |
version | 0.2.1 |
source | src |
created_at | 2020-05-28 20:59:04.399398 |
updated_at | 2021-10-19 21:04:14.56986 |
description | This library is used to lookup the sizes of various C-types of historical data models. |
homepage | |
repository | https://github.com/goller/data_models |
max_upload_size | |
id | 247155 |
size | 15,133 |
This library is used to lookup the sizes of various C-types of historical data models.
A data model is the choices of bit width of integer types by a specific platform.
use data_models::*;
let model = DataModel::LP64; // e.g. Linux
let p = model.size_of::<Pointer>();
assert_eq!(p, 8);
The C standard defines five base types for integers
The standard does not specify the exact number of bits for each type. A platform or vendor-dependent data model specifies the exact bit widths.
The names of the models are conventions where the type is signified by a letter and its size; for example, ILP32 would mean (I)nteger, (L)ong, and (P)ointer are 32-bits. Although, make note, the naming scheme is not super consistent.
Four data models found wide acceptance:
LP32 or 2/4/4 (int is 16-bit, long and pointer are 32-bit) M68k mac and Win16 API
ILP32 or 4/4/4 (int, long, and pointer are 32-bit); Win32 API Unix and Unix-like systems (Linux, Mac OS X)
LLP64 or 4/4/8 (int and long are 32-bit, pointer is 64-bit) Win64 API
LP64 or 4/8/8 (int is 32-bit, long and pointer are 64-bit) Unix and Unix-like systems (Linux, Mac OS X)