From 76ac9fce5eccc84133c1e9fae21510ac026a92bc Mon Sep 17 00:00:00 2001 From: Zachary Catlin Date: Wed, 9 Aug 2023 12:20:21 -0400 Subject: [PATCH] cfs-sys: Added workaround for pointer constant 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. --- cfs-sys/build.rs | 3 ++- cfs-sys/cfs-api.h | 4 +++- cfs-sys/cfs-shims.c | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cfs-sys/build.rs b/cfs-sys/build.rs index 75f18421..4f8fecb0 100644 --- a/cfs-sys/build.rs +++ b/cfs-sys/build.rs @@ -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); } diff --git a/cfs-sys/cfs-api.h b/cfs-sys/cfs-api.h index 719aeac3..de057bc0 100644 --- a/cfs-sys/cfs-api.h +++ b/cfs-sys/cfs-api.h @@ -187,7 +187,6 @@ 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) @@ -195,5 +194,8 @@ 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; diff --git a/cfs-sys/cfs-shims.c b/cfs-sys/cfs-shims.c index 7994e673..214195ab 100644 --- a/cfs-sys/cfs-shims.c +++ b/cfs-sys/cfs-shims.c @@ -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;