1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
* tclUnixNotify.c --
*
* This file contains the implementation of the select-based
* Unix-specific notifier, which is the lowest-level part of the
* Tcl event loop. This file works together with
* ../generic/tclNotify.c.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclUnixNotfy.c,v 1.4 1999/06/10 04:27:44 stanton Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
#include <signal.h>
/*
* This structure is used to keep track of the notifier info for a
* a registered file.
*/
typedef struct FileHandler {
|
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/*
* tclUnixNotify.c --
*
* This file contains the implementation of the select-based
* Unix-specific notifier, which is the lowest-level part of the
* Tcl event loop. This file works together with
* ../generic/tclNotify.c.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclUnixNotfy.c,v 1.5 1999/07/02 06:05:34 welch Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
#include <signal.h>
extern TclStubs tclStubs;
/*
* This structure is used to keep track of the notifier info for a
* a registered file.
*/
typedef struct FileHandler {
|
| ︙ | | | ︙ | |
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
Tcl_Time *timePtr; /* Timeout value, may be NULL. */
{
/*
* The interval timer doesn't do anything in this implementation,
* because the only event loop is via Tcl_DoOneEvent, which passes
* timeout values to Tcl_WaitForEvent.
*/
}
/*
*----------------------------------------------------------------------
*
* Tcl_ServiceModeHook --
*
|
>
>
>
>
|
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
Tcl_Time *timePtr; /* Timeout value, may be NULL. */
{
/*
* The interval timer doesn't do anything in this implementation,
* because the only event loop is via Tcl_DoOneEvent, which passes
* timeout values to Tcl_WaitForEvent.
*/
if (tclStubs.tcl_SetTimer != Tcl_SetTimer) {
tclStubs.tcl_SetTimer(timePtr);
}
}
/*
*----------------------------------------------------------------------
*
* Tcl_ServiceModeHook --
*
|
| ︙ | | | ︙ | |
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
Tcl_FileProc *proc; /* Procedure to call for each
* selected event. */
ClientData clientData; /* Arbitrary data to pass to proc. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr;
int index, bit;
for (filePtr = tsdPtr->firstFileHandlerPtr; filePtr != NULL;
filePtr = filePtr->nextPtr) {
if (filePtr->fd == fd) {
break;
}
}
|
>
>
>
>
>
|
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
Tcl_FileProc *proc; /* Procedure to call for each
* selected event. */
ClientData clientData; /* Arbitrary data to pass to proc. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr;
int index, bit;
if (tclStubs.tcl_CreateFileHandler != Tcl_CreateFileHandler) {
tclStubs.tcl_CreateFileHandler(fd, mask, proc, clientData);
return;
}
for (filePtr = tsdPtr->firstFileHandlerPtr; filePtr != NULL;
filePtr = filePtr->nextPtr) {
if (filePtr->fd == fd) {
break;
}
}
|
| ︙ | | | ︙ | |
456
457
458
459
460
461
462
463
464
465
466
467
468
469
|
Tcl_DeleteFileHandler(fd)
int fd; /* Stream id for which to remove callback procedure. */
{
FileHandler *filePtr, *prevPtr;
int index, bit, i;
unsigned long flags;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
* Find the entry for the given file (and return if there isn't one).
*/
for (prevPtr = NULL, filePtr = tsdPtr->firstFileHandlerPtr; ;
prevPtr = filePtr, filePtr = filePtr->nextPtr) {
|
>
>
>
>
>
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
Tcl_DeleteFileHandler(fd)
int fd; /* Stream id for which to remove callback procedure. */
{
FileHandler *filePtr, *prevPtr;
int index, bit, i;
unsigned long flags;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (tclStubs.tcl_DeleteFileHandler != Tcl_DeleteFileHandler) {
tclStubs.tcl_DeleteFileHandler(fd);
return;
}
/*
* Find the entry for the given file (and return if there isn't one).
*/
for (prevPtr = NULL, filePtr = tsdPtr->firstFileHandlerPtr; ;
prevPtr = filePtr, filePtr = filePtr->nextPtr) {
|
| ︙ | | | ︙ | |
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
int bit, index, mask;
#ifdef TCL_THREADS
int waitForFiles;
#else
int numFound;
#endif
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
* Set up the timeout structure. Note that if there are no events to
* check for, we return with a negative result rather than blocking
* forever.
*/
|
>
>
>
>
|
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
|
int bit, index, mask;
#ifdef TCL_THREADS
int waitForFiles;
#else
int numFound;
#endif
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (tclStubs.tcl_WaitForEvent != Tcl_WaitForEvent) {
return tclStubs.tcl_WaitForEvent(timePtr);
}
/*
* Set up the timeout structure. Note that if there are no events to
* check for, we return with a negative result rather than blocking
* forever.
*/
|
| ︙ | | | ︙ | |