Reentrant Functions

All functions in EWL are thread-safe by defining the EWL_THREADSAFE macro as 1 when compiling EWL itself. When the EWL_THREADSAFE macro is 0, many of the EWL functions lose their thread safe attributes. It may be useful to leave the EWL_THREADSAFE macro as 0 even on a multithreaded system to improve execution speed. The library functions will be faster if they do not have to wait for thread synchronization.

Since many programs are written using only a single thread, it is often advantageous to provide an efficient single threaded library. The GNU Compiler Collection (GCC) and other library vendors provide an assortment of helper functions, all with a r suffix, to indicate they are naturally thread safe. Following this convention, the EWL offers variations of some standard functions that are reentrant. The table below lists reentrant function in standard header files.
Table 1. Reentrant Functions in Standard Headers
Header File Reentrant Function
stdlib.h rand_r()
string.h strerror_r()
time.h asctime_r(), ctime_r(), gmtime_r(), localtime_r()