| #include "pthread_impl.h" |
| void __do_orphaned_stdio_locks() { |
| for (f = __pthread_self()->stdio_locks; f; f = f->next_locked) |
| a_store(&f->lock, 0x40000000); |
| void __unlist_locked_file(FILE* f) { |
| f->next_locked->prev_locked = f->prev_locked; |
| f->prev_locked->next_locked = f->next_locked; |
| __pthread_self()->stdio_locks = f->next_locked; |
| int ftrylockfile(FILE* f) { |
| pthread_t self = __pthread_self(); |
| if (f->lockcount == LONG_MAX) |
| if (f->lock || a_cas(&f->lock, 0, tid)) |
| f->next_locked = self->stdio_locks; |
| f->next_locked->prev_locked = f; |