Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions include/zephyr/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,44 @@ typedef union {
void (*thepfunc)(void);
} z_max_align_t;

/*
* Offset type
*
* k_off_t, much like the POSIX off_t, is a signed integer type used to represent file sizes and
* offsets.
*
* k_off_t effectively limits the size of files that can be handled by the system, it is
* therefore not tied to the word-size of the architecture.
*
* In order to overcome historical limitations of the off_t type, Zephyr may be configured to
* always define k_off_t as 64-bits.
*/
#ifdef CONFIG_OFFSET_64BIT
typedef int64_t k_off_t;
#else
typedef long k_off_t;
#endif

/*
* Signed size type
*
* k_ssize_t, much like the POSIX ssize_t, is a signed integer type that effectively limits the
* size of I/O operations on files while still supporting negative return values.
*
* k_ssize_t is usually tied to the word-size of the architecture.
*/
#ifdef __SIZE_TYPE__
#define unsigned signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */
typedef __SIZE_TYPE__ k_ssize_t;
#undef unsigned
#else
#ifdef CONFIG_64BIT
typedef long k_ssize_t;
#else
typedef int k_ssize_t;
#endif
#endif

#ifdef __cplusplus
/* Zephyr requires an int main(void) signature with C linkage for the application main if present */
extern int main(void);
Expand Down
17 changes: 17 additions & 0 deletions kernel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,23 @@ config XIP
supply a linker command file when building your image. Enabling this
option increases both the code and data footprint of the image.

config OFFSET_64BIT
bool "Use 64-bit offsets"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great if this went into its own section in Kconfig (menu), i.e. do not put alongside other features and make it obvious is it a type, maybe others will be added to the same menu later.

OFFSET_64BIT can be confusing, maybe make it obvious we are talking about a type here: TYPE_OFFSET_64BIT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. The closest thing I found to this so far is TIMEOUT_64BIT. Should that be moved as well? It also has to do with a type (k_timeout_t).

help
Select 'y' here to ensure k_off_t is always 64-bits. This may be
useful on platforms with files, disks, and memories larger than 2 GiB.

If this option is not selected (the default), then the size of k_off_t
will match the architecture word size (like size_t does currently).

On 32-bit platforms, enabling this feature trades space and speed for
flexibiltity, since using 64-bit offsets may require more instructions
for a given operation. For example, a 64-bit load may require two 32-bit
loads, and a 64-bit divide may need to be completed with several
32-bit instructions (the operation is emulated via a compiler built-in
function).

Note: offsets have a signed integer representation.

menu "Security Options"

Expand Down