summaryrefslogtreecommitdiffstats
path: root/unix/tclEpollNotfy.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-26 13:48:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-26 13:48:13 (GMT)
commit22a21905e22a2ad6ae86c293bac257eb7db9e68a (patch)
tree432c182c9bce21ae325498b7a1af59cae9df2db6 /unix/tclEpollNotfy.c
parentf596ce75b4b1eeb5b09785d3faf012d4a4587f42 (diff)
downloadtcl-22a21905e22a2ad6ae86c293bac257eb7db9e68a.zip
tcl-22a21905e22a2ad6ae86c293bac257eb7db9e68a.tar.gz
tcl-22a21905e22a2ad6ae86c293bac257eb7db9e68a.tar.bz2
Move some variable declarations closer to where they are used. No change in functionality.
Diffstat (limited to 'unix/tclEpollNotfy.c')
-rw-r--r--unix/tclEpollNotfy.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 28fc834..5ed5d5d 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -354,24 +354,21 @@ PlatformEventsInit(
if (errno) {
Tcl_Panic("Tcl_InitNotifier: %s", "could not create mutex");
}
+ filePtr = ckalloc(sizeof(*filePtr));
#ifdef HAVE_EVENTFD
if ((tsdPtr->triggerEventFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)) <= 0) {
Tcl_Panic("Tcl_InitNotifier: %s", "could not create trigger eventfd");
}
+ filePtr->fd = tsdPtr->triggerEventFd;
#else
if (pipe2(tsdPtr->triggerPipe, O_CLOEXEC | O_NONBLOCK) != 0) {
Tcl_Panic("Tcl_InitNotifier: %s", "could not create trigger pipe");
}
+ filePtr->fd = tsdPtr->triggerPipe[0];
#endif
if ((tsdPtr->eventsFd = epoll_create1(EPOLL_CLOEXEC)) == -1) {
Tcl_Panic("epoll_create1: %s", strerror(errno));
}
- filePtr = ckalloc(sizeof(*filePtr));
-#ifdef HAVE_EVENTFD
- filePtr->fd = tsdPtr->triggerEventFd;
-#else
- filePtr->fd = tsdPtr->triggerPipe[0];
-#endif
filePtr->mask = TCL_READABLE;
PlatformEventsControl(filePtr, tsdPtr, EPOLL_CTL_ADD, 1);
if (!tsdPtr->readyEvents) {
@@ -660,11 +657,6 @@ Tcl_WaitForEvent(
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
int numQueued;
ssize_t i;
-#ifdef HAVE_EVENTFD
- uint64_t eventFdVal;
-#else
- char triggerPipeVal;
-#endif
/*
* Set up the timeout structure. Note that if there are no events to
@@ -760,10 +752,12 @@ Tcl_WaitForEvent(
mask = PlatformEventsTranslate(&tsdPtr->readyEvents[numEvent]);
#ifdef HAVE_EVENTFD
if (filePtr->fd == tsdPtr->triggerEventFd) {
+ uint64_t eventFdVal;
i = read(tsdPtr->triggerEventFd, &eventFdVal, sizeof(eventFdVal));
if ((i != sizeof(eventFdVal)) && (errno != EAGAIN)) {
#else
if (filePtr->fd == tsdPtr->triggerPipe[0]) {
+ char triggerPipeVal;
i = read(tsdPtr->triggerPipe[0], &triggerPipeVal, sizeof(triggerPipeVal));
if ((i != sizeof(triggerPipeVal)) && (errno != EAGAIN)) {
#endif