-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement single endianness handling pattern #1209
Comments
Jake,
This is defined in my sample_defs/cpu1_platform_cfg.h file. However, CF seems to be looking for an additional define.
Also, I thought the MCP750 was BIG ENDIAN with vXWorks. The above file has LITTLE set in my repo.
Walt
|
The challenge here is that the C standard (and library) don't want to expose endianness. They actively discourage one from writing endian-specific code, and there is no standardized "marker" to say what endianness the current CPU has. In particular a machine is allowed to arrange the bits however it pleases and still be compliant (see PDP-11). AFAIK There is even a variant that takes the weird PDP-11 order and reverses it. While none of these are common, they do exist. The problem with any "endian" check is that it is usually binary on the common ones (big or little), and does not account for other variations. Rather than introducing another endianness-check to rule them all, I'd rather see migration away from any sort of endian-specific code/dependencies. FWIW, the |
Is your feature request related to a problem? Please describe.
Multiple ways to handle target endian in various contexts:
fsw/cfe-core/src/es/cfe_es_perf.c:CFE_ES_SetupPerfVariables - determines it at runtime
fsw/cfe-core/src/tbl/cfe_tbl_internal.c:CFE_TBL_ReadHeaders - determines it at runtime
fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c:CFE_TBL_DumpToFile - determines it at runtime
fsw/cfe-core/src/fs/cfe_fs_api.c:CFE_FS_ReadHeader (and many other functions in here) - determines it at runtime
fsw/cfe-core/src/inc/ccsds.h has macros for conversion (CFE_MAKE_BIG*) who’s implementation depends on SOFTWARE_BIG_BIT_ORDER
There’s an endian flag in the CCSDS header
osal/src/os/inc/common_types.h defines either SOFTWARE_LITTLE_BIT_ORDER or SOFTWARE_BIG_BIT_ORDER based on 8 possible defines
cfe/cmake/sample_defs/cpu1_platform_cfg.h defines CFE_PLATFORM_ENDIAN as either CCSDS_LITTLE_ENDIAN or CCSDS_BIG_ENDIAN, and also has a separately configurable CFE_PLATFORM_TIME_CFG_BIGENDIAN
CCSDS extended header has an endian bit
Then there’s all the different ways the various defines are used and custom swapping routines, examples:
cFE/modules/fs/fsw/src/cfe_fs_api.c
Lines 310 to 326 in 73c338d
cFE/modules/tbl/fsw/src/cfe_tbl_internal.c
Lines 1210 to 1227 in 73c338d
cFE/modules/core_api/fsw/inc/cfe_endian.h
Lines 61 to 69 in 73c338d
Note some cfe_endian.h macros evaluate
n
multiple times.Describe the solution you'd like
See #202 (comment) for a compile time suggestion:
#define IS_LITTLE_ENDIAN (((union {unsigned x; char c;}){1}).c)
Describe alternatives you've considered
None
Additional context
Triggered from email discussion on setting another endian flag in a toolchain file for an app to use
Requester Info
Jacob Hageman - NASA/GSFC
Ping - @klystron78 @ejtimmon @wmoleski
The text was updated successfully, but these errors were encountered: