so so it appears i always get this behaviour even in a simple example
with the following defined:
--wrap pthread_mutex_init
--wrap pthread_mutex_lock
--wrap pthread_mutex_unlock
using the following code:
pthread_mutex_t m;
LOG_0("cobalt ");
LOG_0("c init " << pthread_mutex_init(&m,0));
LOG_0("c lock1 " << pthread_mutex_lock(&m));
i get the following output:
cobalt
c init 1
c lock1 1
note: all calls should return 0 for success, but 1 = EPERM
only really the first, pthread_mutex_init, is the real issue as its obviously not initialising the mutex successfully.
(also the second lock does not block, indicating that its not just the error codes, really the lock is not taken)
if I remove the pthread_mutex_* wraps , it all works as expected...
Im using the following compiler options
message(STATUS "BELA optimized")
# /usr/xenomai/bin/xeno-config --skin=cobalt --no-mode-check --cflags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE -D_REENTRANT -D__COBALT__")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,@${PROJECT_SOURCE_DIR}/xenomai.wrappers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize --fast-math")
# /usr/xenomai/bin/xeno-config --skin=cobalt --no-auto-init --no-mode-check --ldflags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt ")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-as-needed -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt ")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt ")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -Wl,--no-as-needed -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt ")
they are defined in cmake, but I can see when I compiled , they are applied correctly.
also, if I use nm on the built binary, I can clearly see the wrap_pthread functions are bound, rather than the underlying pthread functions.
not sure what to try next really ...
EDIT:
so If I remove --wrap pthread_mutex_init , and leave the wrapped lock/unlock this fails on the lock
( I guess this is expected, as the mutex is now a pthread mutex, and wrapped lock is for a cobalt mutex ?!)
i.e.
cobalt
c init 0
c lock1 1