Make internal API more private

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-10-21 12:04:13 +02:00
1 parent 9751be5859
commit 6f5e6e5232
7 files changed
+35 -35

No files matched your search

+3 -3
View File
@@ -72,11 +72,11 @@ int uev_cron_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, time_t when
if (fd < 0)
return -1;
if (uev_watcher_init(ctx, w, UEV_CRON_TYPE, cb, arg, fd, UEV_READ))
if (_uev_watcher_init(ctx, w, UEV_CRON_TYPE, cb, arg, fd, UEV_READ))
goto exit;
if (uev_cron_set(w, when, interval)) {
uev_watcher_stop(w);
_uev_watcher_stop(w);
exit:
close(fd);
return -1;
@@ -132,7 +132,7 @@ int uev_cron_set(uev_t *w, time_t when, time_t interval)
return 1;
}
return uev_watcher_start(w);
return _uev_watcher_start(w);
}
/**
+4 -4
View File
@@ -44,10 +44,10 @@ int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int e
return -1;
}
if (uev_watcher_init(ctx, w, UEV_IO_TYPE, cb, arg, fd, events))
if (_uev_watcher_init(ctx, w, UEV_IO_TYPE, cb, arg, fd, events))
return -1;
return uev_watcher_start(w);
return _uev_watcher_start(w);
}
/**
@@ -62,7 +62,7 @@ int uev_io_set(uev_t *w, int fd, int events)
{
if ((events & UEV_ONESHOT) && w->active)
return uev_watcher_rearm(w);
return _uev_watcher_rearm(w);
/* Ignore any errors, only to clean up anything lingering ... */
uev_io_stop(w);
@@ -89,7 +89,7 @@ int uev_io_start(uev_t *w)
*/
int uev_io_stop(uev_t *w)
{
return uev_watcher_stop(w);
return _uev_watcher_stop(w);
}
/**
+7 -7
View File
@@ -81,13 +81,13 @@ struct uev;
uev_type_t
/* Internal API for dealing with generic watchers */
int uev_watcher_init (uev_ctx_t *ctx, struct uev *w, uev_type_t type,
void (*cb)(struct uev *, void *, int), void *arg,
int fd, int events);
int uev_watcher_start (struct uev *w);
int uev_watcher_stop (struct uev *w);
int uev_watcher_active(struct uev *w);
int uev_watcher_rearm (struct uev *w);
int _uev_watcher_init (uev_ctx_t *ctx, struct uev *w, uev_type_t type,
void (*cb)(struct uev *, void *, int), void *arg,
int fd, int events);
int _uev_watcher_start (struct uev *w);
int _uev_watcher_stop (struct uev *w);
int _uev_watcher_active(struct uev *w);
int _uev_watcher_rearm (struct uev *w);
#endif /* LIBUEV_PRIVATE_H_ */
+4 -4
View File
@@ -56,11 +56,11 @@ int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo
if (fd < 0)
return -1;
if (uev_watcher_init(ctx, w, UEV_SIGNAL_TYPE, cb, arg, fd, UEV_READ))
if (_uev_watcher_init(ctx, w, UEV_SIGNAL_TYPE, cb, arg, fd, UEV_READ))
goto exit;
if (uev_signal_set(w, signo)) {
uev_watcher_stop(w);
_uev_watcher_stop(w);
exit:
close(fd);
return -1;
@@ -109,7 +109,7 @@ int uev_signal_set(uev_t *w, int signo)
if (signalfd(w->fd, &mask, SFD_NONBLOCK) < 0)
return -1;
return uev_watcher_start(w);
return _uev_watcher_start(w);
}
@@ -140,7 +140,7 @@ int uev_signal_start(uev_t *w)
*/
int uev_signal_stop(uev_t *w)
{
if (uev_watcher_stop(w))
if (_uev_watcher_stop(w))
return -1;
close(w->fd);
+5 -5
View File
@@ -76,11 +76,11 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou
if (fd < 0)
return -1;
if (uev_watcher_init(ctx, w, UEV_TIMER_TYPE, cb, arg, fd, UEV_READ))
if (_uev_watcher_init(ctx, w, UEV_TIMER_TYPE, cb, arg, fd, UEV_READ))
goto exit;
if (uev_timer_set(w, timeout, period)) {
uev_watcher_stop(w);
_uev_watcher_stop(w);
exit:
close(fd);
return -1;
@@ -135,7 +135,7 @@ int uev_timer_set(uev_t *w, int timeout, int period)
return 1;
}
return uev_watcher_start(w);
return _uev_watcher_start(w);
}
/**
@@ -152,7 +152,7 @@ int uev_timer_start(uev_t *w)
}
if (-1 != w->fd)
uev_watcher_stop(w);
_uev_watcher_stop(w);
return uev_timer_set(w, w->u.t.timeout, w->u.t.period);
}
@@ -168,7 +168,7 @@ int uev_timer_stop(uev_t *w)
/* Stop kernel timer */
uev_timer_set(w, 0, 0);
if (uev_watcher_stop(w))
if (_uev_watcher_stop(w))
return -1;
/* Close timerfd, will have to be reopened again on reset */
+8 -8
View File
@@ -57,7 +57,7 @@ static int is_valid_fd(int fd)
}
/* Private to libuEv, do not use directly! */
int uev_watcher_init(uev_ctx_t *ctx, uev_t *w, uev_type_t type, uev_cb_t *cb, void *arg, int fd, int events)
int _uev_watcher_init(uev_ctx_t *ctx, uev_t *w, uev_type_t type, uev_cb_t *cb, void *arg, int fd, int events)
{
if (!ctx || !w) {
errno = EINVAL;
@@ -76,7 +76,7 @@ int uev_watcher_init(uev_ctx_t *ctx, uev_t *w, uev_type_t type, uev_cb_t *cb, vo
}
/* Private to libuEv, do not use directly! */
int uev_watcher_start(uev_t *w)
int _uev_watcher_start(uev_t *w)
{
struct epoll_event ev;
@@ -102,7 +102,7 @@ int uev_watcher_start(uev_t *w)
}
/* Private to libuEv, do not use directly! */
int uev_watcher_stop(uev_t *w)
int _uev_watcher_stop(uev_t *w)
{
if (!w) {
errno = EINVAL;
@@ -125,7 +125,7 @@ int uev_watcher_stop(uev_t *w)
}
/* Private to libuEv, do not use directly! */
int uev_watcher_active(uev_t *w)
int _uev_watcher_active(uev_t *w)
{
if (!w)
return 0;
@@ -134,7 +134,7 @@ int uev_watcher_active(uev_t *w)
}
/* Private to libuEv, do not use directly! */
int uev_watcher_rearm(uev_t *w)
int _uev_watcher_rearm(uev_t *w)
{
struct epoll_event ev;
@@ -280,7 +280,7 @@ int uev_run(uev_ctx_t *ctx, int flags)
/* If not valid anymore, try to remove, ignore any errors. */
if (!is_valid_fd(w->fd))
uev_watcher_stop(w);
_uev_watcher_stop(w);
/* Must recreate epoll fd now ... */
if (_init(ctx, 1)) {
@@ -293,10 +293,10 @@ int uev_run(uev_ctx_t *ctx, int flags)
if (w->active) {
w->active = 0;
LIST_REMOVE(w, link);
uev_watcher_start(w);
_uev_watcher_start(w);
}
}
uev_watcher_start(retry);
_uev_watcher_start(retry);
/* New efd, restart everything! */
ctx->errors = 0;
+4 -4
View File
@@ -45,10 +45,10 @@
#define UEV_NONBLOCK 2
/* Macros */
#define uev_io_active(w) uev_watcher_active(w)
#define uev_timer_active(w) uev_watcher_active(w)
#define uev_cron_active(w) uev_watcher_active(w)
#define uev_signal_active(w) uev_watcher_active(w)
#define uev_io_active(w) _uev_watcher_active(w)
#define uev_timer_active(w) _uev_watcher_active(w)
#define uev_cron_active(w) _uev_watcher_active(w)
#define uev_signal_active(w) _uev_watcher_active(w)
/* Event watcher */
typedef struct uev {