File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,44 @@ typedef union {
2929 void (* thepfunc )(void );
3030} z_max_align_t ;
3131
32+ /*
33+ * Offset type
34+ *
35+ * k_off_t, much like the POSIX off_t, is a signed integer type used to represent file sizes and
36+ * offsets.
37+ *
38+ * k_off_t effectively limits the size of files that can be handled by the system, it is
39+ * therefore not tied to the word-size of the architecture.
40+ *
41+ * In order to overcome historical limitations of the off_t type, Zephyr may be configured to
42+ * always define k_off_t as 64-bits.
43+ */
44+ #ifdef CONFIG_OFFSET_64BIT
45+ typedef int64_t k_off_t ;
46+ #else
47+ typedef long k_off_t ;
48+ #endif
49+
50+ /*
51+ * Signed size type
52+ *
53+ * k_ssize_t, much like the POSIX ssize_t, is a signed integer type that effectively limits the
54+ * size of I/O operations on files while still supporting negative return values.
55+ *
56+ * k_ssize_t is usually tied to the word-size of the architecture.
57+ */
58+ #ifdef __SIZE_TYPE__
59+ #define unsigned signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */
60+ typedef __SIZE_TYPE__ k_ssize_t ;
61+ #undef unsigned
62+ #else
63+ #ifdef CONFIG_64BIT
64+ typedef long k_ssize_t ;
65+ #else
66+ typedef int k_ssize_t ;
67+ #endif
68+ #endif
69+
3270#ifdef __cplusplus
3371/* Zephyr requires an int main(void) signature with C linkage for the application main if present */
3472extern int main (void );
Original file line number Diff line number Diff line change @@ -866,6 +866,23 @@ config XIP
866866 supply a linker command file when building your image. Enabling this
867867 option increases both the code and data footprint of the image.
868868
869+ config OFFSET_64BIT
870+ bool "Use 64-bit offsets"
871+ help
872+ Select 'y' here to ensure k_off_t is always 64-bits. This may be
873+ useful on platforms with files, disks, and memories larger than 2 GiB.
874+
875+ If this option is not selected (the default), then the size of k_off_t
876+ will match the architecture word size (like size_t does currently).
877+
878+ On 32-bit platforms, enabling this feature trades space and speed for
879+ flexibiltity, since using 64-bit offsets may require more instructions
880+ for a given operation. For example, a 64-bit load may require two 32-bit
881+ loads, and a 64-bit divide may need to be completed with several
882+ 32-bit instructions (the operation is emulated via a compiler built-in
883+ function).
884+
885+ Note: offsets have a signed integer representation.
869886
870887menu "Security Options"
871888
You can’t perform that action at this time.
0 commit comments