#ifndef _MTLIB_H
#define _MTLIB_H
#include <thread.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int primary_link_map;
extern void lmutex_lock(mutex_t *);
extern void lmutex_unlock(mutex_t *);
extern void lrw_rdlock(rwlock_t *);
extern void lrw_wrlock(rwlock_t *);
extern void lrw_unlock(rwlock_t *);
extern void sig_mutex_lock(mutex_t *);
extern void sig_mutex_unlock(mutex_t *);
extern int sig_mutex_trylock(mutex_t *);
extern int sig_cond_wait(cond_t *, mutex_t *);
extern int sig_cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
extern void cancel_safe_mutex_lock(mutex_t *);
extern void cancel_safe_mutex_unlock(mutex_t *);
extern int cancel_safe_mutex_trylock(mutex_t *);
extern int cancel_active(void);
extern int _thrp_cancelled(void);
extern void *lmalloc(size_t);
extern void lfree(void *, size_t);
#if defined(DEBUG)
extern void assert_no_libc_locks_held(void);
#else
#define assert_no_libc_locks_held()
#endif
#define _FWRITE _fwrite_unlocked
#define FILENO(s) _fileno(s)
#define FERROR(s) ferror(s)
#define GETC(s) _getc_internal(s)
#define UNGETC(c, s) _ungetc_unlocked(c, s)
#define PUTC(c, s) _putc_internal(c, s)
#define GETWC(s) getwc(s)
#define PUTWC(c, s) putwc(c, s)
extern int __libc_threaded;
#define FILELOCKING(iop) (GET_IONOLOCK(iop) == 0)
#define FLOCKFILE(lk, iop) \
{ \
if (__libc_threaded && FILELOCKING(iop)) \
lk = _flockget((iop)); \
else \
lk = NULL; \
}
#define FUNLOCKFILE(lk) \
{ \
if (lk != NULL) \
_flockrel(lk); \
}
#define FLOCKRETURN(iop, ret) \
{ int r; \
rmutex_t *lk; \
FLOCKFILE(lk, iop); \
r = (ret); \
FUNLOCKFILE(lk); \
return (r); \
}
#ifdef __cplusplus
}
#endif
#endif