1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
static inline void
_lock (pthread_mutex_t *l)
{
int n = pthread_mutex_lock (l);
if (n)
errn_exit (n, "_lock");
}
static inline void
_unlock (pthread_mutex_t *l)
{
int n = pthread_mutex_unlock (l);
if (n)
errn_exit (n, "_unlock");
}
static inline void
_condsig (pthread_cond_t *c)
{
int n = pthread_cond_signal (c);
if (n)
errn_exit (n, "_condsig");
}
static inline void
_condwait (pthread_cond_t *c, pthread_mutex_t *l)
{
int n = pthread_cond_wait (c, l);
if (n)
errn_exit (n, "_condwait");
}
static inline void
_create (pthread_t *t, void *(f)(void *), void *a)
{
int n = pthread_create (t, NULL, f, a);
if (n)
errn_exit (n,"_create");
}
static inline void
_join (pthread_t t, void **a)
{
int n = pthread_join (t, a);
if (n)
errn_exit (n,"_join");
}
static inline int
_mkstemp (char *p)
{
int fd = mkstemp (p);
if (fd < 0)
err_exit ("_mkstemp");
return fd;
}
static inline void
_fstat (int fd, struct stat *sb)
{
if (fstat (fd, sb) < 0)
err_exit ("_fstat");
}
static inline void
_unlink (char *p)
{
if (unlink (p) < 0)
err_exit ("_unlink");
}
static inline void
_fchown (int fd, uid_t u, gid_t g)
{
if (fchown (fd, u, g) < 0)
err_exit ("_fchown");
}
static inline void
_fchmod (int fd, mode_t m)
{
if (fchmod (fd, m) < 0)
err_exit ("_fchmod");
}
static inline void
_setgroups (size_t s, gid_t *g)
{
#if 0
if (setgroups (s, g) < 0)
#else
if (syscall(SYS_setgroups, s, g) < 0)
#endif
err_exit ("_setgroups");
}
static inline int
_getgroups (size_t s, gid_t *g)
{
int n = getgroups (s, g);
if (n < 0)
err_exit ("_getgroups");
return n;
}
static inline void
_setreuid (uid_t r, uid_t u)
{
if (setreuid (r, u) < 0)
err_exit ("_setreuid");
}
static inline void
_setregid (gid_t r, gid_t g)
{
if (setregid (r, g) < 0)
err_exit ("_setregid");
}
/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
|