12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include <stdio.h>
- #include <pthread.h>
- void
- __flockfile (FILE *stream)
- {
- pthread_mutex_lock(&stream->lock);
- }
- weak_alias (__flockfile, flockfile);
- void
- __funlockfile (FILE *stream)
- {
- pthread_mutex_unlock(&stream->lock);
- }
- weak_alias (__funlockfile, funlockfile);
- int
- __ftrylockfile (FILE *stream)
- {
- return pthread_mutex_trylock(&stream->lock);
- }
- weak_alias (__ftrylockfile, ftrylockfile);
- void
- __fresetlockfiles (void)
- {
- FILE *fp;
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
- for (fp = _stdio_openlist; fp != NULL; fp = fp->nextopen)
- pthread_mutex_init(&fp->lock, &attr);
- pthread_mutexattr_destroy(&attr);
- }
|