Skip to content

Commit

Permalink
cfs-sys: Added workaround for pointer constant
Browse files Browse the repository at this point in the history
CFE_ES_TASK_STACK_ALLOCATE turns out to be a constant of a pointer
type... which appears to throw bindgen for a loop. This commit
places our replacement in cfs-shims.c and let the linker sort it out.
  • Loading branch information
zec committed Aug 9, 2023
1 parent 8678514 commit 76ac9fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cfs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ fn main() {
let api_header = pb(&[&in_dir, "cfs-api.h"]).to_string_unwrap();
let shims_header = pb(&[&in_dir, "cfs-shims.h"]).to_string_unwrap();
let out_file = pb(&[&out_dir, "cfs-all.rs"]).to_string_unwrap();
let shims_c = pb(&[&out_dir, "cfs-shims.c"]).to_string_unwrap();

for f in [&api_header, &shims_header] {
for f in [&api_header, &shims_header, &shims_c] {
println!("cargo:rerun-if-changed={}", f);
}

Expand Down
4 changes: 3 additions & 1 deletion cfs-sys/cfs-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,15 @@ X(CFE_ES_COUNTERID_UNDEFINED, CFE_ES_CounterId_t)
X(CFE_ES_LIBID_UNDEFINED, CFE_ES_LibId_t)
X(CFE_ES_MEMHANDLE_UNDEFINED, CFE_ES_MemHandle_t)
X(CFE_ES_TASKID_UNDEFINED, CFE_ES_TaskId_t)
X(CFE_ES_TASK_STACK_ALLOCATE, CFE_ES_StackPointer_t)
X(CFE_RESOURCEID_RESERVED, CFE_ResourceId_t)
X(CFE_RESOURCEID_UNDEFINED, CFE_ResourceId_t)
X(CFE_SB_MSGID_RESERVED, CFE_SB_MsgId_t)
X(CFE_SB_INVALID_MSG_ID, CFE_SB_MsgId_t)
X(CFE_TBL_BAD_TABLE_HANDLE, CFE_TBL_Handle_t)
X(OS_OBJECT_ID_UNDEFINED, osal_id_t)

/* see cfs-shims.c */
extern CFE_ES_StackPointer_t X_CFE_ES_TASK_STACK_ALLOCATE;

const uint8 X_CFE_SB_DEFAULT_QOS_PRIORITY = CFE_SB_DEFAULT_QOS.Priority;
const uint8 X_CFE_SB_DEFAULT_QOS_RELIABILITY = CFE_SB_DEFAULT_QOS.Reliability;
3 changes: 3 additions & 0 deletions cfs-sys/cfs-shims.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
}

#include "cfs-shims.h"

/* Bindgen *really* doesn't want to handle pointer constants. This is a workaround for that. */
CFE_ES_StackPointer_t X_CFE_ES_TASK_STACK_ALLOCATE = CFE_ES_TASK_STACK_ALLOCATE;

0 comments on commit 76ac9fc

Please sign in to comment.