flockfile
void flockfile (
FILE *file);
Increase the lock count for a
Although most stdio functions, such as printf and fgets, are thread-safe, you may sometimes find that it is important that a sequence of printf calls, for example, from one thread cannot be separated by calls made from another thread. Also, a few
References: 6.4.1 Headers: <stdio.h>
Hint: Use to protect a sequence of
ftrylockfile
int ftrylockfile (
FILE *file);
If the file stream is currently locked by another thread, return a nonzero value. Otherwise, increase the lock count for the file stream, and return the value zero.
References: 6.4.1 Headers: <stdio.h>
Hint: Use to protect a sequence
funlockfile
void funlockfile (
FILE *file);
Decrease the lock count for a
References: 6.4.1 Headers: <stdio.h>
Hint: Use to protect a sequence of
getc_unlocked
int getc_unlocked (
FILE *file);
Return a single character from the
References: 6.4.2 Headers: <stdio.h>
Hint: Replace old calls to getc to retain fastest access.
getchar_unlocked
int getc_unlocked (void);
Return a single character from the
References: 6.4.2 Headers: <stdio.h>
Hint: Replace old calls to getchar to retain fastest access.
putc_unlocked
int putc_unlocked (
int c,
FILE *file);
Write a single character c (interpreted as an unsigned char) to the
References: 6.4.2 Headers: <stdio.h>
Hint: Replace old calls to putc to retain fastest access.
putchar_unlocked
int putchar_unlocked (
int c);
Write a single character c (interpreted as an unsigned char) to the
References: 6.4.2 Headers: <stdio.h>
Hint: Replace old calls to putchar to retain fastest access.
9.3.11 Thread-safe functions
Thread-safe functions provide improved access to traditional features of ANSI C and POSIX that cannot be effectively made thread-safe without interface changes. These routines are designated by the '_r' suffix added to the traditional function name they replace, for example, getlogin_r for getlogin.
getlogin_r
int getlogin_r (
char *name,
size_t namesize);
Write the user name associated with the current process into the buffer pointed to by name. The buffer is namesize bytes long, and should have space for the name and a terminating null character. The maximum size of the login name is LOGIN_
NAME_MAX.
References: 6.5.1 Headers: <unistd.h>
readdir_r
int readdir_r (
DIR *dirp,
struct dirent *entry, struct dirent **result);
Return a pointer (result) to the directory entry at the current position in the directory stream to which dirp refers. Whereas readdir retains the current position using a static variable, readdir_r uses the entry parameter, supplied by the caller.
References: 6.5.2
Headers: <sys/types.h>, <dirent.h>
Errors: [EBADF] dirp is not an open directory stream.
strtok_r
char *strtok_r (
char *s,
const char *sep,
char **lasts);
Return a pointer to the next token in the strings. Whereas strtok retains the current position within a string using a static variable, strtok_r uses the lasts parameter, supplied by the caller.
References: 6.5.3 Headers: <string.h>