summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/selectmodule.c.h
blob: 0a53ae2b9199c864c01dae69aad999d97b977943 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
/*[clinic input]
preserve
[clinic start generated code]*/

PyDoc_STRVAR(select_select__doc__,
"select($module, rlist, wlist, xlist, timeout=None, /)\n"
"--\n"
"\n"
"Wait until one or more file descriptors are ready for some kind of I/O.\n"
"\n"
"The first three arguments are sequences of file descriptors to be waited for:\n"
"rlist -- wait until ready for reading\n"
"wlist -- wait until ready for writing\n"
"xlist -- wait for an \"exceptional condition\"\n"
"If only one kind of condition is required, pass [] for the other lists.\n"
"\n"
"A file descriptor is either a socket or file object, or a small integer\n"
"gotten from a fileno() method call on one of those.\n"
"\n"
"The optional 4th argument specifies a timeout in seconds; it may be\n"
"a floating point number to specify fractions of seconds.  If it is absent\n"
"or None, the call will never time out.\n"
"\n"
"The return value is a tuple of three lists corresponding to the first three\n"
"arguments; each contains the subset of the corresponding file descriptors\n"
"that are ready.\n"
"\n"
"*** IMPORTANT NOTICE ***\n"
"On Windows, only sockets are supported; on Unix, all file\n"
"descriptors can be used.");

#define SELECT_SELECT_METHODDEF    \
    {"select", (PyCFunction)(void(*)(void))select_select, METH_FASTCALL, select_select__doc__},

static PyObject *
select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
                   PyObject *xlist, PyObject *timeout_obj);

static PyObject *
select_select(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    PyObject *rlist;
    PyObject *wlist;
    PyObject *xlist;
    PyObject *timeout_obj = Py_None;

    if (!_PyArg_UnpackStack(args, nargs, "select",
        3, 4,
        &rlist, &wlist, &xlist, &timeout_obj)) {
        goto exit;
    }
    return_value = select_select_impl(module, rlist, wlist, xlist, timeout_obj);

exit:
    return return_value;
}

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL))

PyDoc_STRVAR(select_poll_register__doc__,
"register($self, fd, eventmask=POLLIN | POLLPRI | POLLOUT, /)\n"
"--\n"
"\n"
"Register a file descriptor with the polling object.\n"
"\n"
"  fd\n"
"    either an integer, or an object with a fileno() method returning an int\n"
"  eventmask\n"
"    an optional bitmask describing the type of events to check for");

#define SELECT_POLL_REGISTER_METHODDEF    \
    {"register", (PyCFunction)(void(*)(void))select_poll_register, METH_FASTCALL, select_poll_register__doc__},

static PyObject *
select_poll_register_impl(pollObject *self, int fd, unsigned short eventmask);

static PyObject *
select_poll_register(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    int fd;
    unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;

    if (!_PyArg_ParseStack(args, nargs, "O&|O&:register",
        fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
        goto exit;
    }
    return_value = select_poll_register_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL))

PyDoc_STRVAR(select_poll_modify__doc__,
"modify($self, fd, eventmask, /)\n"
"--\n"
"\n"
"Modify an already registered file descriptor.\n"
"\n"
"  fd\n"
"    either an integer, or an object with a fileno() method returning\n"
"    an int\n"
"  eventmask\n"
"    a bitmask describing the type of events to check for");

#define SELECT_POLL_MODIFY_METHODDEF    \
    {"modify", (PyCFunction)(void(*)(void))select_poll_modify, METH_FASTCALL, select_poll_modify__doc__},

static PyObject *
select_poll_modify_impl(pollObject *self, int fd, unsigned short eventmask);

static PyObject *
select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    int fd;
    unsigned short eventmask;

    if (!_PyArg_ParseStack(args, nargs, "O&O&:modify",
        fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
        goto exit;
    }
    return_value = select_poll_modify_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL))

PyDoc_STRVAR(select_poll_unregister__doc__,
"unregister($self, fd, /)\n"
"--\n"
"\n"
"Remove a file descriptor being tracked by the polling object.");

#define SELECT_POLL_UNREGISTER_METHODDEF    \
    {"unregister", (PyCFunction)select_poll_unregister, METH_O, select_poll_unregister__doc__},

static PyObject *
select_poll_unregister_impl(pollObject *self, int fd);

static PyObject *
select_poll_unregister(pollObject *self, PyObject *arg)
{
    PyObject *return_value = NULL;
    int fd;

    if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
        goto exit;
    }
    return_value = select_poll_unregister_impl(self, fd);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL))

PyDoc_STRVAR(select_poll_poll__doc__,
"poll($self, timeout=None, /)\n"
"--\n"
"\n"
"Polls the set of registered file descriptors.\n"
"\n"
"Returns a list containing any descriptors that have events or errors to\n"
"report, as a list of (fd, event) 2-tuples.");

#define SELECT_POLL_POLL_METHODDEF    \
    {"poll", (PyCFunction)(void(*)(void))select_poll_poll, METH_FASTCALL, select_poll_poll__doc__},

static PyObject *
select_poll_poll_impl(pollObject *self, PyObject *timeout_obj);

static PyObject *
select_poll_poll(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    PyObject *timeout_obj = Py_None;

    if (!_PyArg_UnpackStack(args, nargs, "poll",
        0, 1,
        &timeout_obj)) {
        goto exit;
    }
    return_value = select_poll_poll_impl(self, timeout_obj);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_register__doc__,
"register($self, fd, eventmask=POLLIN | POLLPRI | POLLOUT, /)\n"
"--\n"
"\n"
"Register a file descriptor with the polling object.\n"
"\n"
"  fd\n"
"    either an integer, or an object with a fileno() method returning\n"
"    an int\n"
"  eventmask\n"
"    an optional bitmask describing the type of events to check for");

#define SELECT_DEVPOLL_REGISTER_METHODDEF    \
    {"register", (PyCFunction)(void(*)(void))select_devpoll_register, METH_FASTCALL, select_devpoll_register__doc__},

static PyObject *
select_devpoll_register_impl(devpollObject *self, int fd,
                             unsigned short eventmask);

static PyObject *
select_devpoll_register(devpollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    int fd;
    unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;

    if (!_PyArg_ParseStack(args, nargs, "O&|O&:register",
        fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
        goto exit;
    }
    return_value = select_devpoll_register_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_modify__doc__,
"modify($self, fd, eventmask=POLLIN | POLLPRI | POLLOUT, /)\n"
"--\n"
"\n"
"Modify a possible already registered file descriptor.\n"
"\n"
"  fd\n"
"    either an integer, or an object with a fileno() method returning\n"
"    an int\n"
"  eventmask\n"
"    an optional bitmask describing the type of events to check for");

#define SELECT_DEVPOLL_MODIFY_METHODDEF    \
    {"modify", (PyCFunction)(void(*)(void))select_devpoll_modify, METH_FASTCALL, select_devpoll_modify__doc__},

static PyObject *
select_devpoll_modify_impl(devpollObject *self, int fd,
                           unsigned short eventmask);

static PyObject *
select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    int fd;
    unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;

    if (!_PyArg_ParseStack(args, nargs, "O&|O&:modify",
        fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
        goto exit;
    }
    return_value = select_devpoll_modify_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_unregister__doc__,
"unregister($self, fd, /)\n"
"--\n"
"\n"
"Remove a file descriptor being tracked by the polling object.");

#define SELECT_DEVPOLL_UNREGISTER_METHODDEF    \
    {"unregister", (PyCFunction)select_devpoll_unregister, METH_O, select_devpoll_unregister__doc__},

static PyObject *
select_devpoll_unregister_impl(devpollObject *self, int fd);

static PyObject *
select_devpoll_unregister(devpollObject *self, PyObject *arg)
{
    PyObject *return_value = NULL;
    int fd;

    if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
        goto exit;
    }
    return_value = select_devpoll_unregister_impl(self, fd);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_poll__doc__,
"poll($self, timeout=None, /)\n"
"--\n"
"\n"
"Polls the set of registered file descriptors.\n"
"\n"
"Returns a list containing any descriptors that have events or errors to\n"
"report, as a list of (fd, event) 2-tuples.");

#define SELECT_DEVPOLL_POLL_METHODDEF    \
    {"poll", (PyCFunction)(void(*)(void))select_devpoll_poll, METH_FASTCALL, select_devpoll_poll__doc__},

static PyObject *
select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj);

static PyObject *
select_devpoll_poll(devpollObject *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    PyObject *timeout_obj = Py_None;

    if (!_PyArg_UnpackStack(args, nargs, "poll",
        0, 1,
        &timeout_obj)) {
        goto exit;
    }
    return_value = select_devpoll_poll_impl(self, timeout_obj);

exit:
    return return_value;
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the devpoll file descriptor.\n"
"\n"
"Further operations on the devpoll object will raise an exception.");

#define SELECT_DEVPOLL_CLOSE_METHODDEF    \
    {"close", (PyCFunction)select_devpoll_close, METH_NOARGS, select_devpoll_close__doc__},

static PyObject *
select_devpoll_close_impl(devpollObject *self);

static PyObject *
select_devpoll_close(devpollObject *self, PyObject *Py_UNUSED(ignored))
{
    return select_devpoll_close_impl(self);
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Return the file descriptor.");

#define SELECT_DEVPOLL_FILENO_METHODDEF    \
    {"fileno", (PyCFunction)select_devpoll_fileno, METH_NOARGS, select_devpoll_fileno__doc__},

static PyObject *
select_devpoll_fileno_impl(devpollObject *self);

static PyObject *
select_devpoll_fileno(devpollObject *self, PyObject *Py_UNUSED(ignored))
{
    return select_devpoll_fileno_impl(self);
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL))

PyDoc_STRVAR(select_poll__doc__,
"poll($module, /)\n"
"--\n"
"\n"
"Returns a polling object.\n"
"\n"
"This object supports registering and unregistering file descriptors, and then\n"
"polling them for I/O events.");

#define SELECT_POLL_METHODDEF    \
    {"poll", (PyCFunction)select_poll, METH_NOARGS, select_poll__doc__},

static PyObject *
select_poll_impl(PyObject *module);

static PyObject *
select_poll(PyObject *module, PyObject *Py_UNUSED(ignored))
{
    return select_poll_impl(module);
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */

#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H)

PyDoc_STRVAR(select_devpoll__doc__,
"devpoll($module, /)\n"
"--\n"
"\n"
"Returns a polling object.\n"
"\n"
"This object supports registering and unregistering file descriptors, and then\n"
"polling them for I/O events.");

#define SELECT_DEVPOLL_METHODDEF    \
    {"devpoll", (PyCFunction)select_devpoll, METH_NOARGS, select_devpoll__doc__},

static PyObject *
select_devpoll_impl(PyObject *module);

static PyObject *
select_devpoll(PyObject *module, PyObject *Py_UNUSED(ignored))
{
    return select_devpoll_impl(module);
}

#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll__doc__,
"epoll(sizehint=-1, flags=0)\n"
"--\n"
"\n"
"Returns an epolling object.\n"
"\n"
"  sizehint\n"
"    The expected number of events to be registered.  It must be positive,\n"
"    or -1 to use the default.  It is only used on older systems where\n"
"    epoll_create1() is not available; otherwise it has no effect (though its\n"
"    value is still checked).\n"
"  flags\n"
"    Deprecated and completely ignored.  However, when supplied, its value\n"
"    must be 0 or select.EPOLL_CLOEXEC, otherwise OSError is raised.");

static PyObject *
select_epoll_impl(PyTypeObject *type, int sizehint, int flags);

static PyObject *
select_epoll(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
    PyObject *return_value = NULL;
    static const char * const _keywords[] = {"sizehint", "flags", NULL};
    static _PyArg_Parser _parser = {"|ii:epoll", _keywords, 0};
    int sizehint = -1;
    int flags = 0;

    if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
        &sizehint, &flags)) {
        goto exit;
    }
    return_value = select_epoll_impl(type, sizehint, flags);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the epoll control file descriptor.\n"
"\n"
"Further operations on the epoll object will raise an exception.");

#define SELECT_EPOLL_CLOSE_METHODDEF    \
    {"close", (PyCFunction)select_epoll_close, METH_NOARGS, select_epoll_close__doc__},

static PyObject *
select_epoll_close_impl(pyEpoll_Object *self);

static PyObject *
select_epoll_close(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored))
{
    return select_epoll_close_impl(self);
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Return the epoll control file descriptor.");

#define SELECT_EPOLL_FILENO_METHODDEF    \
    {"fileno", (PyCFunction)select_epoll_fileno, METH_NOARGS, select_epoll_fileno__doc__},

static PyObject *
select_epoll_fileno_impl(pyEpoll_Object *self);

static PyObject *
select_epoll_fileno(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored))
{
    return select_epoll_fileno_impl(self);
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_fromfd__doc__,
"fromfd($type, fd, /)\n"
"--\n"
"\n"
"Create an epoll object from a given control fd.");

#define SELECT_EPOLL_FROMFD_METHODDEF    \
    {"fromfd", (PyCFunction)select_epoll_fromfd, METH_O|METH_CLASS, select_epoll_fromfd__doc__},

static PyObject *
select_epoll_fromfd_impl(PyTypeObject *type, int fd);

static PyObject *
select_epoll_fromfd(PyTypeObject *type, PyObject *arg)
{
    PyObject *return_value = NULL;
    int fd;

    if (!PyArg_Parse(arg, "i:fromfd", &fd)) {
        goto exit;
    }
    return_value = select_epoll_fromfd_impl(type, fd);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_register__doc__,
"register($self, /, fd, eventmask=EPOLLIN | EPOLLPRI | EPOLLOUT)\n"
"--\n"
"\n"
"Registers a new fd or raises an OSError if the fd is already registered.\n"
"\n"
"  fd\n"
"    the target file descriptor of the operation\n"
"  eventmask\n"
"    a bit set composed of the various EPOLL constants\n"
"\n"
"The epoll interface supports all file descriptors that support poll.");

#define SELECT_EPOLL_REGISTER_METHODDEF    \
    {"register", (PyCFunction)(void(*)(void))select_epoll_register, METH_FASTCALL|METH_KEYWORDS, select_epoll_register__doc__},

static PyObject *
select_epoll_register_impl(pyEpoll_Object *self, int fd,
                           unsigned int eventmask);

static PyObject *
select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
    PyObject *return_value = NULL;
    static const char * const _keywords[] = {"fd", "eventmask", NULL};
    static _PyArg_Parser _parser = {"O&|I:register", _keywords, 0};
    int fd;
    unsigned int eventmask = EPOLLIN | EPOLLPRI | EPOLLOUT;

    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
        fildes_converter, &fd, &eventmask)) {
        goto exit;
    }
    return_value = select_epoll_register_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_modify__doc__,
"modify($self, /, fd, eventmask)\n"
"--\n"
"\n"
"Modify event mask for a registered file descriptor.\n"
"\n"
"  fd\n"
"    the target file descriptor of the operation\n"
"  eventmask\n"
"    a bit set composed of the various EPOLL constants");

#define SELECT_EPOLL_MODIFY_METHODDEF    \
    {"modify", (PyCFunction)(void(*)(void))select_epoll_modify, METH_FASTCALL|METH_KEYWORDS, select_epoll_modify__doc__},

static PyObject *
select_epoll_modify_impl(pyEpoll_Object *self, int fd,
                         unsigned int eventmask);

static PyObject *
select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
    PyObject *return_value = NULL;
    static const char * const _keywords[] = {"fd", "eventmask", NULL};
    static _PyArg_Parser _parser = {"O&I:modify", _keywords, 0};
    int fd;
    unsigned int eventmask;

    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
        fildes_converter, &fd, &eventmask)) {
        goto exit;
    }
    return_value = select_epoll_modify_impl(self, fd, eventmask);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_unregister__doc__,
"unregister($self, /, fd)\n"
"--\n"
"\n"
"Remove a registered file descriptor from the epoll object.\n"
"\n"
"  fd\n"
"    the target file descriptor of the operation");

#define SELECT_EPOLL_UNREGISTER_METHODDEF    \
    {"unregister", (PyCFunction)(void(*)(void))select_epoll_unregister, METH_FASTCALL|METH_KEYWORDS, select_epoll_unregister__doc__},

static PyObject *
select_epoll_unregister_impl(pyEpoll_Object *self, int fd);

static PyObject *
select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
    PyObject *return_value = NULL;
    static const char * const _keywords[] = {"fd", NULL};
    static _PyArg_Parser _parser = {"O&:unregister", _keywords, 0};
    int fd;

    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
        fildes_converter, &fd)) {
        goto exit;
    }
    return_value = select_epoll_unregister_impl(self, fd);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll_poll__doc__,
"poll($self, /, timeout=None, maxevents=-1)\n"
"--\n"
"\n"
"Wait for events on the epoll file descriptor.\n"
"\n"
"  timeout\n"
"    the maximum time to wait in seconds (as float);\n"
"    a timeout of None or -1 makes poll wait indefinitely\n"
"  maxevents\n"
"    the maximum number of events returned; -1 means no limit\n"
"\n"
"Returns a list containing any descriptors that have events to report,\n"
"as a list of (fd, events) 2-tuples.");

#define SELECT_EPOLL_POLL_METHODDEF    \
    {"poll", (PyCFunction)(void(*)(void))select_epoll_poll, METH_FASTCALL|METH_KEYWORDS, select_epoll_poll__doc__},

static PyObject *
select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj,
                       int maxevents);

static PyObject *
select_epoll_poll(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
    PyObject *return_value = NULL;
    static const char * const _keywords[] = {"timeout", "maxevents", NULL};
    static _PyArg_Parser _parser = {"|Oi:poll", _keywords, 0};
    PyObject *timeout_obj = Py_None;
    int maxevents = -1;

    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
        &timeout_obj, &maxevents)) {
        goto exit;
    }
    return_value = select_epoll_poll_impl(self, timeout_obj, maxevents);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll___enter____doc__,
"__enter__($self, /)\n"
"--\n"
"\n");

#define SELECT_EPOLL___ENTER___METHODDEF    \
    {"__enter__", (PyCFunction)select_epoll___enter__, METH_NOARGS, select_epoll___enter____doc__},

static PyObject *
select_epoll___enter___impl(pyEpoll_Object *self);

static PyObject *
select_epoll___enter__(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored))
{
    return select_epoll___enter___impl(self);
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_EPOLL)

PyDoc_STRVAR(select_epoll___exit____doc__,
"__exit__($self, exc_type=None, exc_value=None, exc_tb=None, /)\n"
"--\n"
"\n");

#define SELECT_EPOLL___EXIT___METHODDEF    \
    {"__exit__", (PyCFunction)(void(*)(void))select_epoll___exit__, METH_FASTCALL, select_epoll___exit____doc__},

static PyObject *
select_epoll___exit___impl(pyEpoll_Object *self, PyObject *exc_type,
                           PyObject *exc_value, PyObject *exc_tb);

static PyObject *
select_epoll___exit__(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    PyObject *exc_type = Py_None;
    PyObject *exc_value = Py_None;
    PyObject *exc_tb = Py_None;

    if (!_PyArg_UnpackStack(args, nargs, "__exit__",
        0, 3,
        &exc_type, &exc_value, &exc_tb)) {
        goto exit;
    }
    return_value = select_epoll___exit___impl(self, exc_type, exc_value, exc_tb);

exit:
    return return_value;
}

#endif /* defined(HAVE_EPOLL) */

#if defined(HAVE_KQUEUE)

PyDoc_STRVAR(select_kqueue__doc__,
"kqueue()\n"
"--\n"
"\n"
"Kqueue syscall wrapper.\n"
"\n"
"For example, to start watching a socket for input:\n"
">>> kq = kqueue()\n"
">>> sock = socket()\n"
">>> sock.connect((host, port))\n"
">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)\n"
"\n"
"To wait one second for it to become writeable:\n"
">>> kq.control(None, 1, 1000)\n"
"\n"
"To stop listening:\n"
">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0)");

static PyObject *
select_kqueue_impl(PyTypeObject *type);

static PyObject *
select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
    PyObject *return_value = NULL;

    if ((type == &kqueue_queue_Type) &&
        !_PyArg_NoPositional("kqueue", args)) {
        goto exit;
    }
    if ((type == &kqueue_queue_Type) &&
        !_PyArg_NoKeywords("kqueue", kwargs)) {
        goto exit;
    }
    return_value = select_kqueue_impl(type);

exit:
    return return_value;
}

#endif /* defined(HAVE_KQUEUE) */

#if defined(HAVE_KQUEUE)

PyDoc_STRVAR(select_kqueue_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the kqueue control file descriptor.\n"
"\n"
"Further operations on the kqueue object will raise an exception.");

#define SELECT_KQUEUE_CLOSE_METHODDEF    \
    {"close", (PyCFunction)select_kqueue_close, METH_NOARGS, select_kqueue_close__doc__},

static PyObject *
select_kqueue_close_impl(kqueue_queue_Object *self);

static PyObject *
select_kqueue_close(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored))
{
    return select_kqueue_close_impl(self);
}

#endif /* defined(HAVE_KQUEUE) */

#if defined(HAVE_KQUEUE)

PyDoc_STRVAR(select_kqueue_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Return the kqueue control file descriptor.");

#define SELECT_KQUEUE_FILENO_METHODDEF    \
    {"fileno", (PyCFunction)select_kqueue_fileno, METH_NOARGS, select_kqueue_fileno__doc__},

static PyObject *
select_kqueue_fileno_impl(kqueue_queue_Object *self);

static PyObject *
select_kqueue_fileno(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored))
{
    return select_kqueue_fileno_impl(self);
}

#endif /* defined(HAVE_KQUEUE) */

#if defined(HAVE_KQUEUE)

PyDoc_STRVAR(select_kqueue_fromfd__doc__,
"fromfd($type, fd, /)\n"
"--\n"
"\n"
"Create a kqueue object from a given control fd.");

#define SELECT_KQUEUE_FROMFD_METHODDEF    \
    {"fromfd", (PyCFunction)select_kqueue_fromfd, METH_O|METH_CLASS, select_kqueue_fromfd__doc__},

static PyObject *
select_kqueue_fromfd_impl(PyTypeObject *type, int fd);

static PyObject *
select_kqueue_fromfd(PyTypeObject *type, PyObject *arg)
{
    PyObject *return_value = NULL;
    int fd;

    if (!PyArg_Parse(arg, "i:fromfd", &fd)) {
        goto exit;
    }
    return_value = select_kqueue_fromfd_impl(type, fd);

exit:
    return return_value;
}

#endif /* defined(HAVE_KQUEUE) */

#if defined(HAVE_KQUEUE)

PyDoc_STRVAR(select_kqueue_control__doc__,
"control($self, changelist, maxevents, timeout=None, /)\n"
"--\n"
"\n"
"Calls the kernel kevent function.\n"
"\n"
"  changelist\n"
"    Must be an iterable of kevent objects describing the changes to be made\n"
"    to the kernel\'s watch list or None.\n"
"  maxevents\n"
"    The maximum number of events that the kernel will return.\n"
"  timeout\n"
"    The maximum time to wait in seconds, or else None to wait forever.\n"
"    This accepts floats for smaller timeouts, too.");

#define SELECT_KQUEUE_CONTROL_METHODDEF    \
    {"control", (PyCFunction)(void(*)(void))select_kqueue_control, METH_FASTCALL, select_kqueue_control__doc__},

static PyObject *
select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
                           int maxevents, PyObject *otimeout);

static PyObject *
select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize_t nargs)
{
    PyObject *return_value = NULL;
    PyObject *changelist;
    int maxevents;
    PyObject *otimeout = Py_None;

    if (!_PyArg_ParseStack(args, nargs, "Oi|O:control",
        &changelist, &maxevents, &otimeout)) {
        goto exit;
    }
    return_value = select_kqueue_control_impl(self, changelist, maxevents, otimeout);

exit:
    return return_value;
}

#endif /* defined(HAVE_KQUEUE) */

#ifndef SELECT_POLL_REGISTER_METHODDEF
    #define SELECT_POLL_REGISTER_METHODDEF
#endif /* !defined(SELECT_POLL_REGISTER_METHODDEF) */

#ifndef SELECT_POLL_MODIFY_METHODDEF
    #define SELECT_POLL_MODIFY_METHODDEF
#endif /* !defined(SELECT_POLL_MODIFY_METHODDEF) */

#ifndef SELECT_POLL_UNREGISTER_METHODDEF
    #define SELECT_POLL_UNREGISTER_METHODDEF
#endif /* !defined(SELECT_POLL_UNREGISTER_METHODDEF) */

#ifndef SELECT_POLL_POLL_METHODDEF
    #define SELECT_POLL_POLL_METHODDEF
#endif /* !defined(SELECT_POLL_POLL_METHODDEF) */

#ifndef SELECT_DEVPOLL_REGISTER_METHODDEF
    #define SELECT_DEVPOLL_REGISTER_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_REGISTER_METHODDEF) */

#ifndef SELECT_DEVPOLL_MODIFY_METHODDEF
    #define SELECT_DEVPOLL_MODIFY_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_MODIFY_METHODDEF) */

#ifndef SELECT_DEVPOLL_UNREGISTER_METHODDEF
    #define SELECT_DEVPOLL_UNREGISTER_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_UNREGISTER_METHODDEF) */

#ifndef SELECT_DEVPOLL_POLL_METHODDEF
    #define SELECT_DEVPOLL_POLL_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_POLL_METHODDEF) */

#ifndef SELECT_DEVPOLL_CLOSE_METHODDEF
    #define SELECT_DEVPOLL_CLOSE_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_CLOSE_METHODDEF) */

#ifndef SELECT_DEVPOLL_FILENO_METHODDEF
    #define SELECT_DEVPOLL_FILENO_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_FILENO_METHODDEF) */

#ifndef SELECT_POLL_METHODDEF
    #define SELECT_POLL_METHODDEF
#endif /* !defined(SELECT_POLL_METHODDEF) */

#ifndef SELECT_DEVPOLL_METHODDEF
    #define SELECT_DEVPOLL_METHODDEF
#endif /* !defined(SELECT_DEVPOLL_METHODDEF) */

#ifndef SELECT_EPOLL_CLOSE_METHODDEF
    #define SELECT_EPOLL_CLOSE_METHODDEF
#endif /* !defined(SELECT_EPOLL_CLOSE_METHODDEF) */

#ifndef SELECT_EPOLL_FILENO_METHODDEF
    #define SELECT_EPOLL_FILENO_METHODDEF
#endif /* !defined(SELECT_EPOLL_FILENO_METHODDEF) */

#ifndef SELECT_EPOLL_FROMFD_METHODDEF
    #define SELECT_EPOLL_FROMFD_METHODDEF
#endif /* !defined(SELECT_EPOLL_FROMFD_METHODDEF) */

#ifndef SELECT_EPOLL_REGISTER_METHODDEF
    #define SELECT_EPOLL_REGISTER_METHODDEF
#endif /* !defined(SELECT_EPOLL_REGISTER_METHODDEF) */

#ifndef SELECT_EPOLL_MODIFY_METHODDEF
    #define SELECT_EPOLL_MODIFY_METHODDEF
#endif /* !defined(SELECT_EPOLL_MODIFY_METHODDEF) */

#ifndef SELECT_EPOLL_UNREGISTER_METHODDEF
    #define SELECT_EPOLL_UNREGISTER_METHODDEF
#endif /* !defined(SELECT_EPOLL_UNREGISTER_METHODDEF) */

#ifndef SELECT_EPOLL_POLL_METHODDEF
    #define SELECT_EPOLL_POLL_METHODDEF
#endif /* !defined(SELECT_EPOLL_POLL_METHODDEF) */

#ifndef SELECT_EPOLL___ENTER___METHODDEF
    #define SELECT_EPOLL___ENTER___METHODDEF
#endif /* !defined(SELECT_EPOLL___ENTER___METHODDEF) */

#ifndef SELECT_EPOLL___EXIT___METHODDEF
    #define SELECT_EPOLL___EXIT___METHODDEF
#endif /* !defined(SELECT_EPOLL___EXIT___METHODDEF) */

#ifndef SELECT_KQUEUE_CLOSE_METHODDEF
    #define SELECT_KQUEUE_CLOSE_METHODDEF
#endif /* !defined(SELECT_KQUEUE_CLOSE_METHODDEF) */

#ifndef SELECT_KQUEUE_FILENO_METHODDEF
    #define SELECT_KQUEUE_FILENO_METHODDEF
#endif /* !defined(SELECT_KQUEUE_FILENO_METHODDEF) */

#ifndef SELECT_KQUEUE_FROMFD_METHODDEF
    #define SELECT_KQUEUE_FROMFD_METHODDEF
#endif /* !defined(SELECT_KQUEUE_FROMFD_METHODDEF) */

#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
    #define SELECT_KQUEUE_CONTROL_METHODDEF
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
/*[clinic end generated code: output=04c4019eb5a4d464 input=a9049054013a1b77]*/