define LIBSHARED_PAL_THREAD_RETURN_TYPE
Source File
└───test_and_benchmark └───libshared └───inc └───libshared libshared_porting_abstraction_layer_compiler.h
Define
#define LIBSHARED_PAL_THREAD_RETURN_TYPE libshared_pal_thread_return_t or #define LIBSHARED_PAL_THREAD_RETURN_TYPE int
Example
#define LIBSHARED_PAL_THREAD_RETURN_TYPE libshared_pal_thread_return_t
Optionality
This define is mandatory and the library cannot compile if it is not set.
Notes
Windows kernel mode threads are unique in that the thread function returns void. As such, two problems are presented; firstly, the existing code, which is cross-platform and so has thread functions which return a variable, often attempts to declare on the stack a variable of the type libshared_pal_thread_return_t, which is set to a value during the course of operation and then returned. However, if libshared_pal_thread_return_t is void, then the compiler throws an error, because it is not possible to declare variables of type void. Secondly, the return from the thread function must be empty - where all the existing threads are returning a value or variable.
To solve this, one define (this define) and one macro (LIBSHARED_PAL_THREAD_RETURN_CAST) are provided. This define provides for Windows kernel a harmless type which will permit the thread function code to compile. The macro LIBSHARED_PAL_THREAD_RETURN_CAST wraps the return argument and on Windows kernel, consumes it - makes it disappear - by being an empty macro. On other platforms, the macro itself disappears, leaving just its argument, which then gives us what we want in both cases.