Reentrant functions can be suspended at any point and restarted; they resume processing with no adverse effects. If a function uses no data that can be accessed by more than one thread, the function is said to be reentrant. In particular, a reentrant function cannot use data on the heap or in static memory. It can use only automatic (stack) and thread-local data. Because the function uses no data that can be modified by other threads, no additional care needs to be taken to serialize access to data or resources.
Note: it is possible to break a reentrant function by passing a pointer to shared data as a parameter to the function. To prevent this from happening, ensure that pointer parameters to library functions point to data whose access is properly serialized.
All functions in the C++ Complex Mathematics Library are reentrant. The I/O Stream Library functions are not.
The following functions are also reentrant:
absolut acos acosf acosl asctime asin asinf asinl assert atan atanf atanl atan2 atan21 atof atoi atol |
fstat _ftime _fullpath fwide fwprintf fwscanf gamma _gcvt _getcwd _getdcwd _getdrive getpid gmtime hypot isalnum isalpha isascii |
memchr memcmp memcpy memicmp memmove memset mkdir mktime modf modff modfl pow powf powl qsort rmdir |
strspn strstr _strtime strtok strtod strtol strtold strtoul strupr strxfrm swab tan tanf tanh tanhf tanhl tanl time _ |
atold bsearch btowc _cabs ceil ceilf ceill chdir _chdrive clock cos cosf cosh coshf coshl cosl ctime _cwait difftime div _ecvt |
iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit _itoa _j0 _j1 _jn labs ldexp ldexpf ldexpl ldiv lfind _loadmod |
_rotl _rotr sin sinf sinh sinhf sinhl _splitpath sprintf sqrt sqrtf sqrtl sscanf stat strcat strchr strcmp strcmpi strcoll strcpy strcspn |
_toascii tolower _tolower toupper _toupper towctrans _tzset _ultoa utime vfwprintf vsprintf vwprintf wait wcsnicmp wmemchr wmemcmp wmemcpy wmemmove wmemset wprintf wscanf |
erf erfc exp expf expl fabs fabsf fabsl _fcvt floor floorf floorl fmod fmodf fmodl _freemod frexp frexpl |
localtime log logf logl log10 log10f log10l _lrotl _lrotr lsearch _ltoa _makepath mblen mbstowcs mbtowc memccpy |
_strdate strerror _strerror strftime stricmp strlen strlwr strncat strncmp strncpy strnicmp strnset strpbrk strrchr strrev strset |
wcscat wcschr wcscmp wcscpy wcscspn wcslen wcsncat wcsncmp wcstold wcstoll wcstoull wcsncpy wcspbrk wcsrchr wcsspn wcstombs wctomb wctrans _y0 _y1 _yn |
![]()
Critical (non-reentrant) Functions
