summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--unix/tclEpollNotfy.c16
-rw-r--r--unix/tclUnixNotfy.c7
2 files changed, 6 insertions, 17 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
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 17307dc..5bc753a 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -102,11 +102,6 @@ void
Tcl_AlertNotifier(
ClientData clientData)
{
-#ifdef NOTIFIER_EPOLL
-#ifdef HAVE_EVENTFD
- uint64_t eventFdVal;
-#endif /* HAVE_EVENTFD */
-#endif /* NOTIFIER_EPOLL */
if (tclNotifierHooks.alertNotifierProc) {
tclNotifierHooks.alertNotifierProc(clientData);
return;
@@ -128,7 +123,7 @@ Tcl_AlertNotifier(
#else
ThreadSpecificData *tsdPtr = clientData;
#if defined(NOTIFIER_EPOLL) && defined(HAVE_EVENTFD)
- eventFdVal = 1;
+ uint64_t eventFdVal = 1;
if (write(tsdPtr->triggerEventFd, &eventFdVal,
sizeof(eventFdVal)) != sizeof(eventFdVal)) {
Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerEventFd",