unix: move platform init out of loop.c
Move platform-specific initialization logic out of loop.c and into the platform files (freebsd.c, sunos.c, etc).
This commit is contained in:
parent
1b929bfff5
commit
894b0fc0a7
@ -32,6 +32,15 @@
|
||||
#define NANOSEC ((uint64_t) 1e9)
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime() {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
@ -43,6 +43,16 @@
|
||||
|
||||
static char *process_title;
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
/* see: http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
|
||||
uint64_t uv_hrtime() {
|
||||
|
||||
@ -54,6 +54,15 @@
|
||||
static char *process_title;
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
@ -161,6 +161,10 @@ unsigned int uv__next_timeout(uv_loop_t* loop);
|
||||
void uv__signal_close(uv_signal_t* handle);
|
||||
void uv__signal_unregister(uv_loop_t* loop);
|
||||
|
||||
/* platform specific */
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop);
|
||||
void uv__platform_loop_delete(uv_loop_t* loop);
|
||||
|
||||
/* various */
|
||||
void uv__async_close(uv_async_t* handle);
|
||||
void uv__check_close(uv_check_t* handle);
|
||||
|
||||
@ -69,6 +69,21 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||
static unsigned long read_cpufreq(unsigned int cpunum);
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
loop->inotify_watchers = NULL;
|
||||
loop->inotify_fd = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
if (loop->inotify_fd == -1) return;
|
||||
uv__io_stop(loop, &loop->inotify_read_watcher);
|
||||
close(loop->inotify_fd);
|
||||
loop->inotify_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime() {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
@ -62,33 +62,15 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
|
||||
for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++)
|
||||
ngx_queue_init(loop->process_handles + i);
|
||||
|
||||
#if __linux__
|
||||
loop->inotify_watchers = NULL;
|
||||
loop->inotify_fd = -1;
|
||||
#endif
|
||||
#if HAVE_PORTS_FS
|
||||
loop->fs_fd = -1;
|
||||
#endif
|
||||
if (uv__platform_loop_init(loop, default_loop))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__loop_delete(uv_loop_t* loop) {
|
||||
uv__platform_loop_delete(loop);
|
||||
uv__signal_unregister(loop);
|
||||
ev_loop_destroy(loop->ev);
|
||||
|
||||
#if __linux__
|
||||
if (loop->inotify_fd != -1) {
|
||||
uv__io_stop(loop, &loop->inotify_read_watcher);
|
||||
close(loop->inotify_fd);
|
||||
loop->inotify_fd = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_PORTS_FS
|
||||
if (loop->fs_fd != -1) {
|
||||
close(loop->fs_fd);
|
||||
loop->fs_fd = -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -35,6 +35,15 @@
|
||||
#define NANOSEC ((uint64_t) 1e9)
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
@ -43,6 +43,15 @@
|
||||
static char *process_title;
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
@ -63,6 +63,19 @@
|
||||
#endif
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
loop->fs_fd = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
if (loop->fs_fd == -1) return;
|
||||
close(loop->fs_fd);
|
||||
loop->fs_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_hrtime() {
|
||||
return (gethrtime());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user