diff --git a/README.md b/README.md index 7bdf9fd7..1a03739f 100644 --- a/README.md +++ b/README.md @@ -5901,7 +5901,7 @@ Return a constant string constructed based on the printf-liked formated string and its arguments. The string is constructed at run time and uses a temporary space on the stack. -If the constructed string is longer than M\_USE\_CSTR\_ALLOC (default 256), +If the constructed string is longer than M\_USE\_CSTR\_ALLOC-1, the string is truncated. Example: strcmp( M_CSTR("Len=%d", 17) , "Len=17" ) == 0 @@ -6503,13 +6503,13 @@ The full C definition are: that needs multiple calls (array, map, ...) It is common to all calls to the same object */ typedef struct m_serial_local_s { - m_serial_ll_t data[M_SERIAL_MAX_DATA_SIZE]; + m_serial_ll_t data[M_USE_SERIAL_MAX_DATA_SIZE]; } m_serial_local_t[1]; // Object to handle the generic serial read of an object. typedef struct m_serial_read_s { const struct m_serial_read_interface_s *m_interface; - m_serial_ll_t data[M_SERIAL_MAX_DATA_SIZE]; + m_serial_ll_t data[M_USE_SERIAL_MAX_DATA_SIZE]; } m_serial_read_t[1]; // Interface exported by the serial read object. @@ -6533,7 +6533,7 @@ The full C definition are: // Object to handle the generic serial write of an object. typedef struct m_serial_write_s { const struct m_serial_write_interface_s *m_interface; - m_serial_ll_t data[M_SERIAL_MAX_DATA_SIZE]; + m_serial_ll_t data[M_USE_SERIAL_MAX_DATA_SIZE]; } m_serial_write_t[1]; // Interface exported by the serial write object. @@ -6714,14 +6714,6 @@ Thread Local Storage variables have to be reinitialized properly with the reset function. This may result in subtle difference between the serial code and the parallel code. -#### Global Conditional Code - -##### M\_USE\_WORKER - -This macro indicates if the multi-thread code shall be used (=1) or not (=0). -It can be overloaded by the user code before including any headers of M\*LIB. -If it is not defined, the default is to use the multi-thread code. - #### methods The following methods are available: @@ -7524,6 +7516,134 @@ otherwise the behavior of the object is undefined. Clear the serialization object 'serial'. +# Global User Customization + +The behavior of M\*LIB can be customized globally by defining the following macros +before including any headers of M\*LIB. +If a macro is not defined before including any M\*LIB header, +the default value will be used. + +Theses macros shall not be defined after including any M\*LIB header. + +## M\_USE\_UNDEF\_ATOMIC + +Undefine the macro _Atomic in m-atomic.h if stdatomic.h is included. +It is needed on MSYS2 due to a bug in their headers which is not fixed yet. + +Default value: 1 (undef) on MSYS2, 0 otherwise. + +## M\_USE\_STDIO + +This macro indicates if the system header stdio.h shall be included +and the FILE functions be defined (=1) or not (=0). + +Default value: 1 + +## M\_USE\_STDARG + +This macro indicates if the system header stdarg.h shall be included +and the va\_args functions be defined (=1) or not (=0). + +Default value: 1 (true) + +## M\_USE\_CSTR\_ALLOC + +Define the allocation size of the temporary strings created by M\_CSTR +(including the final nul char). + +Default value: 256. + +## M\_USE\_IDENTIFIER\_ALLOC + +Define the allocation size of a C identifier in the source code +(excluding the final nul char). +It is used to represent a C identifier by a C string. + +Default value: 128 + +## M\_USE\_THREAD\_BACKEND + +Define the thread backend to use by m-mutex.h: + +* 1: for C11 header threads.h +* 2: for WINDOWS header windows.h +* 3: for POSIX THREAD header pthread.h + +Default value: autodetect in function of the running system. + +## M\_USE\_WORKER + +This macro indicates if the multi-thread code of m-worker.h shall be used (=1) or not (=0) +- In this case, a single-thread code is used -. + +Default value: 1 + +## M\_USE\_WORKER\_CLANG\_BLOCK + +This macro indicates if the workers shall use the CLANG block extension (=1) or not (=0). + +Default value: 1 (on clang), 0 (otherwise) + +## M\_USE\_WORKER\_CPP\_FUNCTION + +This macro indicates if the workers shall use the C++ lambda function (=1) or not (=0). + +Default value: 1 (compiled in C++), 0 (otherwise) + +## M\_USE\_BACKOFF\_MAX\_COUNT + +Define the maximum iteration of the backoff exponential scheme +for the synchronization waiting loop of multithreading code. + +Default value: 6 + +## M\_USE\_SERIAL\_MAX\_DATA\_SIZE + +Define the size of the private data (reserved to the serial implementation) in a serial object +(as a number of pointers or equivalent objects). + +Default value: 4 + +## M\_USE\_MEMPOOL\_MAX\_PER\_SEGMENT(type) + +Define the number of elements to allocate in a segment per object of type 'type'. + +Default value: number of elements that fits in a 16KB page. + +## M\_USE\_DEQUE\_DEFAULT\_SIZE + +Define the default size of a segment for a deque structure. + +Default value: 8 elements. + +## M\_MEMORY\_ALLOC + +See [m-core.h](#m-core) + +## M\_MEMORY\_REALLOC + +See [m-core.h](#m-core) + +## M\_MEMORY\_FULL + +See [m-core.h](#m-core) + +## M\_ASSERT + +See [m-core.h](#m-core) + +## M\_ASSERT\_SLOW + +See [m-core.h](#m-core) + +## M\_ASSERT\_INIT + +See [m-core.h](#m-core) + +## M\_ASSERT\_INDEX + +See [m-core.h](#m-core) + # License