http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0492c/Chdiedfe.html
Thread-safe C library functions
The following table shows the C library functions that are thread-safe.
Table 1. Functions that are thread-safe
Functions | Description |
---|---|
calloc(), free(), malloc(), realloc() | The heap functions are thread-safe if the A single heap is shared between all threads, and mutexes are used to avoid data corruption when there is concurrent access. Each heap implementation is responsible for doing its own locking. If you supply your own allocator, it must also do its own locking. This enables it to do fine-grained locking if required, rather than protecting the entire heap with a single mutex (coarse-grained locking). |
alloca() |
|
abort(), raise(), signal(), fenv.h | The ARM signal handling functions and floating-point exception traps are thread-safe. The settings for signal handlers and floating-point traps are global across the entire process and are protected by locks. Data corruption does not occur if multiple threads call |
clearerr(), fclose(), feof(),ferror(), fflush(), fgetc(),fgetpos(), fgets(), fopen(),fputc(), fputs(), fread(),freopen(), fseek(), fsetpos(),ftell(), fwrite(), getc(),getchar(), gets(), perror(),putc(), putchar(), puts(),rewind(), setbuf(), setvbuf(),tmpfile(), tmpnam(), ungetc() | The Each individual stream is protected by a lock, so two threads can each open their own If two threads both want to read or write the same stream, locking at the Note
|
fprintf(), printf(), vfprintf(), vprintf(), fscanf(), scanf() | When using these functions:
|
clock() | clock() contains static data that is written once at program startup and then only ever read. Therefore, clock() is thread-safe provided no extra threads are already running at the time that the library is initialized. |
errno |
Each thread has its own |
atexit() | The list of exit functions maintained by In the worst case, if more than one thread calls |
abs(), acos(), asin(),atan(), atan2(), atof(),atol(), atoi(), bsearch(),ceil(), cos(), cosh(),difftime(), div(), exp(),fabs(), floor(), fmod(),frexp(), labs(), ldexp(),ldiv(), log(), log10(),memchr(), memcmp(), memcpy(),memmove(), memset(), mktime(),modf(), pow(), qsort(),sin(), sinh(), sqrt(),strcat(), strchr(), strcmp(),strcpy(), strcspn(), strlcat(),strlcpy(), strlen(), strncat(),strncmp(), strncpy(), strpbrk(),strrchr(), strspn(), strstr(),strxfrm(), tan(), tanh() | These functions are inherently thread-safe. |
longjmp(), setjmp() | Although |
remove(), rename(), time() | These functions use interrupts that communicate with the ARM debugging environments. Typically, you have to reimplement these for a real-world application. |
snprintf(), sprintf(), vsnprintf(),vsprintf(), sscanf(), isalnum(),isalpha(), iscntrl(), isdigit(),isgraph(), islower(), isprint(),ispunct(), isspace(), isupper(),isxdigit(), tolower(), toupper(),strcoll(), strtod(), strtol(),strtoul(), strftime() | When using these functions, the string-based functions read the locale settings. Typically, they are thread-safe. However, if you change locale in mid-session, you must ensure that these functions are not affected. The string-based functions, such as |
stdin, stdout, stderr | These functions are thread-safe. |