mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
runtime: fix prototype for openbsd thrsleep
- Fix function prototype for thrsleep(). - Provide enums for clock identifiers. - Provide timespec structure for use with thrsleep(). R=golang-dev, dave, rsc CC=golang-dev https://golang.org/cl/5360042
This commit is contained in:
parent
986ad31b2d
commit
a1c622dfea
|
@ -97,6 +97,12 @@ struct StackT {
|
||||||
int32 ss_flags;
|
int32 ss_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct Timespec Timespec;
|
||||||
|
struct Timespec {
|
||||||
|
int32 tv_sec;
|
||||||
|
int32 tv_nsec;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct Timeval Timeval;
|
typedef struct Timeval Timeval;
|
||||||
struct Timeval {
|
struct Timeval {
|
||||||
int32 tv_sec;
|
int32 tv_sec;
|
||||||
|
|
|
@ -100,6 +100,13 @@ struct StackT {
|
||||||
byte pad_godefs_0[4];
|
byte pad_godefs_0[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct Timespec Timespec;
|
||||||
|
struct Timespec {
|
||||||
|
int32 tv_sec;
|
||||||
|
byte pad_godefs_0[4];
|
||||||
|
int64 tv_nsec;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct Timeval Timeval;
|
typedef struct Timeval Timeval;
|
||||||
struct Timeval {
|
struct Timeval {
|
||||||
int64 tv_sec;
|
int64 tv_sec;
|
||||||
|
|
|
@ -93,6 +93,7 @@ typedef union sigval $Sigval;
|
||||||
|
|
||||||
typedef stack_t $StackT;
|
typedef stack_t $StackT;
|
||||||
|
|
||||||
|
typedef struct timespec $Timespec;
|
||||||
typedef struct timeval $Timeval;
|
typedef struct timeval $Timeval;
|
||||||
typedef struct itimerval $Itimerval;
|
typedef struct itimerval $Itimerval;
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,19 @@ enum
|
||||||
|
|
||||||
ESRCH = 3,
|
ESRCH = 3,
|
||||||
ENOTSUP = 91,
|
ENOTSUP = 91,
|
||||||
|
|
||||||
|
// From OpenBSD's sys/time.h
|
||||||
|
CLOCK_REALTIME = 0,
|
||||||
|
CLOCK_VIRTUAL = 1,
|
||||||
|
CLOCK_PROF = 2,
|
||||||
|
CLOCK_MONOTONIC = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SigTab runtime·sigtab[];
|
extern SigTab runtime·sigtab[];
|
||||||
|
|
||||||
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
|
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
|
||||||
extern int32 runtime·thrsleep(void *, void *, void*, void *);
|
extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock);
|
||||||
extern int32 runtime·thrwakeup(void *, int32);
|
extern int32 runtime·thrwakeup(void *ident, int32 n);
|
||||||
|
|
||||||
// From OpenBSD's <sys/sysctl.h>
|
// From OpenBSD's <sys/sysctl.h>
|
||||||
#define CTL_HW 6
|
#define CTL_HW 6
|
||||||
|
@ -65,7 +71,7 @@ retry:
|
||||||
runtime·osyield();
|
runtime·osyield();
|
||||||
if(m->waitsemacount == 0) {
|
if(m->waitsemacount == 0) {
|
||||||
// the function unlocks the spinlock
|
// the function unlocks the spinlock
|
||||||
runtime·thrsleep(&m->waitsemacount, 0, 0, &m->waitsemalock);
|
runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
m->waitsemacount--;
|
m->waitsemacount--;
|
||||||
|
|
Loading…
Reference in a new issue