-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathluv_c_function_descriptions.ml
1801 lines (1432 loc) · 42.6 KB
/
luv_c_function_descriptions.ml
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
(* This file is part of Luv, released under the MIT license. See LICENSE.md for
details, or visit https://github.com/aantron/luv/blob/master/LICENSE.md. *)
(* Everything is in one file to cut down on Dune boilerplate, as it would grow
proportionally in the number of files the bindings are spread over.
https://github.com/ocaml/dune/issues/135. *)
module Types = Luv_c_types
(* We want to be able to call some of the libuv functions with the OCaml runtime
lock released, in some circumstances. For that, we have Ctypes generate
separate stubs that release the lock.
However, releasing the lock is not possible for some kinds of arguments. So,
we can't blindly generate lock-releasing and lock-retaining versions of each
binding.
Instead, we group the lock-releasing bindings in this module [Blocking]. *)
module Blocking (F : Ctypes.FOREIGN) =
struct
open Ctypes
open F
let error_code = int
module Loop =
struct
let run =
foreign "uv_run"
(ptr Types.Loop.t @-> Types.Loop.Run_mode.t @-> returning bool)
end
(* See https://github.com/ocsigen/lwt/issues/230. *)
module Pipe =
struct
let bind =
foreign "uv_pipe_bind"
(ptr Types.Pipe.t @-> string @-> returning error_code)
end
(* Synchronous (callback = NULL) calls to these functions are blocking, so we
have to release the OCaml runtime lock. Technically, asychronous calls are
non-blocking, and we don't have to release the lock. However, supporting
both variants would take a bit of extra code to implement, so it's best to
see if there is a need. For now, we release the runtime lock during the
asychronous calls as well. *)
module File =
struct
let t = int
let uid = int
let gid = int
let request = Types.File.Request.t
type trampoline = (Types.File.Request.t ptr -> unit) static_funptr
let trampoline : trampoline typ =
static_funptr
Ctypes.(ptr request @-> returning void)
let get_trampoline =
foreign "luv_get_fs_trampoline"
(void @-> returning trampoline)
let get_null_callback =
foreign "luv_null_fs_callback_pointer"
(void @-> returning trampoline)
let req_cleanup =
foreign "uv_fs_req_cleanup"
(ptr request @-> returning void)
let close =
foreign "uv_fs_close"
(ptr Types.Loop.t @-> ptr request @-> t @-> trampoline @->
returning error_code)
let open_ =
foreign "uv_fs_open"
(ptr Types.Loop.t @->
ptr request @->
string @->
int @->
int @->
trampoline @->
returning error_code)
let read =
foreign "uv_fs_read"
(ptr Types.Loop.t @->
ptr request @->
t @->
ptr Types.Buf.t @->
uint @->
int64_t @->
trampoline @->
returning error_code)
let write =
foreign "uv_fs_write"
(ptr Types.Loop.t @->
ptr request @->
t @->
ptr Types.Buf.t @->
uint @->
int64_t @->
trampoline @->
returning error_code)
let unlink =
foreign "uv_fs_unlink"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let mkdir =
foreign "uv_fs_mkdir"
(ptr Types.Loop.t @-> ptr request @-> string @-> int @-> trampoline @->
returning error_code)
let mkdtemp =
foreign "uv_fs_mkdtemp"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let mkstemp =
foreign "uv_fs_mkstemp"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let rmdir =
foreign "uv_fs_rmdir"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let opendir =
foreign "uv_fs_opendir"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let closedir =
foreign "uv_fs_closedir"
(ptr Types.Loop.t @->
ptr request @->
ptr Types.File.Dir.t @->
trampoline @->
returning error_code)
let readdir =
foreign "uv_fs_readdir"
(ptr Types.Loop.t @->
ptr request @->
ptr Types.File.Dir.t @->
trampoline @->
returning error_code)
let scandir =
foreign "uv_fs_scandir"
(ptr Types.Loop.t @-> ptr request @-> string @-> int @-> trampoline @->
returning error_code)
let scandir_next =
foreign "uv_fs_scandir_next"
(ptr request @-> ptr Types.File.Dirent.t @-> returning error_code)
let stat =
foreign "uv_fs_stat"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let lstat =
foreign "uv_fs_lstat"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let fstat =
foreign "uv_fs_fstat"
(ptr Types.Loop.t @-> ptr request @-> t @-> trampoline @->
returning error_code)
let statfs =
foreign "uv_fs_statfs"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let rename =
foreign "uv_fs_rename"
(ptr Types.Loop.t @->
ptr request @->
string @->
string @->
trampoline @->
returning error_code)
let fsync =
foreign "uv_fs_fsync"
(ptr Types.Loop.t @-> ptr request @-> t @-> trampoline @->
returning error_code)
let fdatasync =
foreign "uv_fs_fdatasync"
(ptr Types.Loop.t @-> ptr request @-> t @-> trampoline @->
returning error_code)
let ftruncate =
foreign "uv_fs_ftruncate"
(ptr Types.Loop.t @-> ptr request @-> t @-> int64_t @-> trampoline @->
returning error_code)
let copyfile =
foreign "uv_fs_copyfile"
(ptr Types.Loop.t @->
ptr request @->
string @->
string @->
int @->
trampoline @->
returning error_code)
let sendfile =
foreign "uv_fs_sendfile"
(ptr Types.Loop.t @->
ptr request @->
t @->
t @->
int64_t @->
size_t @->
trampoline @->
returning error_code)
let access =
foreign "uv_fs_access"
(ptr Types.Loop.t @-> ptr request @-> string @-> int @-> trampoline @->
returning error_code)
let chmod =
foreign "uv_fs_chmod"
(ptr Types.Loop.t @-> ptr request @-> string @-> int @-> trampoline @->
returning error_code)
let fchmod =
foreign "uv_fs_fchmod"
(ptr Types.Loop.t @-> ptr request @-> t @-> int @-> trampoline @->
returning error_code)
let utime =
foreign "uv_fs_utime"
(ptr Types.Loop.t @->
ptr request @->
string @->
float @->
float @->
trampoline @->
returning error_code)
let futime =
foreign "uv_fs_futime"
(ptr Types.Loop.t @->
ptr request @->
t @->
float @->
float @->
trampoline @->
returning error_code)
let link =
foreign "uv_fs_link"
(ptr Types.Loop.t @->
ptr request @->
string @->
string @->
trampoline @->
returning error_code)
let symlink =
foreign "uv_fs_symlink"
(ptr Types.Loop.t @->
ptr request @->
string @->
string @->
int @->
trampoline @->
returning error_code)
let readlink =
foreign "uv_fs_readlink"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let realpath =
foreign "uv_fs_realpath"
(ptr Types.Loop.t @-> ptr request @-> string @-> trampoline @->
returning error_code)
let chown =
foreign "uv_fs_chown"
(ptr Types.Loop.t @->
ptr request @->
string @->
uid @->
gid @->
trampoline @->
returning error_code)
let fchown =
foreign "uv_fs_fchown"
(ptr Types.Loop.t @->
ptr request @->
t @->
uid @->
gid @->
trampoline @->
returning error_code)
let lchown =
foreign "uv_fs_lchown"
(ptr Types.Loop.t @->
ptr request @->
string @->
uid @->
gid @->
trampoline @->
returning error_code)
let get_result =
foreign "uv_fs_get_result"
(ptr request @-> returning PosixTypes.ssize_t)
let get_ptr =
foreign "uv_fs_get_ptr"
(ptr request @-> returning (ptr void))
let get_ptr_as_string =
foreign "uv_fs_get_ptr"
(ptr request @-> returning string)
let get_path =
foreign "luv_fs_get_path"
(ptr request @-> returning string)
let get_statbuf =
foreign "uv_fs_get_statbuf"
(ptr request @-> returning (ptr Types.File.Stat.t))
end
module Thread =
struct
let join =
foreign "uv_thread_join"
(ptr Types.Thread.t @-> returning error_code)
end
module Mutex =
struct
let lock =
foreign "uv_mutex_lock"
(ptr Types.Mutex.t @-> returning void)
end
module Rwlock =
struct
let rdlock =
foreign "uv_rwlock_rdlock"
(ptr Types.Rwlock.t @-> returning void)
let wrlock =
foreign "uv_rwlock_wrlock"
(ptr Types.Rwlock.t @-> returning void)
end
module Semaphore =
struct
let wait =
foreign "uv_sem_wait"
(ptr Types.Semaphore.t @-> returning void)
end
module Condition =
struct
let wait =
foreign "uv_cond_wait"
(ptr Types.Condition.t @-> ptr Types.Mutex.t @-> returning void)
let timedwait =
foreign "uv_cond_timedwait"
(ptr Types.Condition.t @-> ptr Types.Mutex.t @-> uint64_t @->
returning error_code)
end
module Barrier =
struct
let wait =
foreign "uv_barrier_wait"
(ptr Types.Barrier.t @-> returning bool)
end
module Time =
struct
let sleep =
foreign "uv_sleep"
(int @-> returning void)
end
module Random =
struct
let request = Types.Random.Request.t
let trampoline =
static_funptr
Ctypes.(ptr request @-> error_code @-> ptr void @-> size_t @->
returning void)
let random =
foreign "uv_random"
(ptr Types.Loop.t @->
ptr request @->
ptr char @->
size_t @->
uint @->
trampoline @->
returning error_code)
end
end
module Descriptions (F : Ctypes.FOREIGN) =
struct
open Ctypes
open F
let error_code = int
module Error =
struct
let strerror_r =
foreign "uv_strerror_r"
(error_code @-> ocaml_bytes @-> int @-> returning void)
let err_name_r =
foreign "uv_err_name_r"
(error_code @-> ocaml_bytes @-> int @-> returning void)
let translate_sys_error =
foreign "uv_translate_sys_error"
(int @-> returning error_code)
end
module Version =
struct
let suffix =
foreign "luv_version_suffix"
(void @-> returning string)
let version =
foreign "uv_version"
(void @-> returning int)
let string =
foreign "luv_version_string"
(void @-> returning string)
end
module Loop =
struct
let t = Types.Loop.t
let init =
foreign "uv_loop_init"
(ptr t @-> returning error_code)
let configure =
foreign "uv_loop_configure"
(ptr t @-> int @-> int @-> returning error_code)
let close =
foreign "uv_loop_close"
(ptr t @-> returning error_code)
let default =
foreign "uv_default_loop"
(void @-> returning (ptr t))
let alive =
foreign "uv_loop_alive"
(ptr t @-> returning bool)
let stop =
foreign "uv_stop"
(ptr t @-> returning void)
let backend_fd =
foreign "uv_backend_fd"
(ptr t @-> returning int)
let backend_timeout =
foreign "uv_backend_timeout"
(ptr t @-> returning int)
let now =
foreign "uv_now"
(ptr t @-> returning uint64_t)
let update_time =
foreign "uv_update_time"
(ptr t @-> returning void)
let fork =
foreign "uv_loop_fork"
(ptr t @-> returning error_code)
end
module Handle =
struct
let t = Types.Handle.t
let close_trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let alloc_trampoline =
static_funptr
Ctypes.(ptr t @-> size_t @-> ptr Types.Buf.t @-> returning void)
let get_close_trampoline =
foreign "luv_get_close_trampoline"
(void @-> returning close_trampoline)
let get_alloc_trampoline =
foreign "luv_get_alloc_trampoline"
(void @-> returning alloc_trampoline)
let is_active =
foreign "uv_is_active"
(ptr t @-> returning bool)
let is_closing =
foreign "uv_is_closing"
(ptr t @-> returning bool)
let close =
foreign "uv_close"
(ptr t @-> close_trampoline @-> returning void)
let ref =
foreign "uv_ref"
(ptr t @-> returning void)
let unref =
foreign "uv_unref"
(ptr t @-> returning void)
let has_ref =
foreign "uv_has_ref"
(ptr t @-> returning bool)
let send_buffer_size =
foreign "uv_send_buffer_size"
(ptr t @-> ptr int @-> returning error_code)
let recv_buffer_size =
foreign "uv_recv_buffer_size"
(ptr t @-> ptr int @-> returning error_code)
let fileno =
foreign "uv_fileno"
(ptr t @-> ptr Types.Os_fd.t @-> returning error_code)
let get_loop =
foreign "uv_handle_get_loop"
(ptr t @-> returning (ptr Loop.t))
let get_data =
foreign "uv_handle_get_data"
(ptr t @-> returning (ptr void))
let set_data =
foreign "uv_handle_set_data"
(ptr t @-> ptr void @-> returning void)
end
module Request =
struct
let t = Types.Request.t
let cancel =
foreign "uv_cancel"
(ptr t @-> returning error_code)
let get_data =
foreign "uv_req_get_data"
(ptr t @-> returning (ptr void))
let set_data =
foreign "uv_req_set_data"
(ptr t @-> ptr void @-> returning void)
end
module Timer =
struct
let t = Types.Timer.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let get_trampoline =
foreign "luv_get_timer_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_timer_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let start =
foreign "uv_timer_start"
(ptr t @-> trampoline @-> uint64_t @-> uint64_t @->
returning error_code)
let stop =
foreign "uv_timer_stop"
(ptr t @-> returning error_code)
let again =
foreign "uv_timer_again"
(ptr t @-> returning error_code)
let set_repeat =
foreign "uv_timer_set_repeat"
(ptr t @-> uint64_t @-> returning void)
let get_repeat =
foreign "uv_timer_get_repeat"
(ptr t @-> returning uint64_t)
end
module Prepare =
struct
let t = Types.Prepare.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let get_trampoline =
foreign "luv_get_prepare_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_prepare_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let start =
foreign "uv_prepare_start"
(ptr t @-> trampoline @-> returning error_code)
let stop =
foreign "uv_prepare_stop"
(ptr t @-> returning error_code)
end
module Check =
struct
let t = Types.Check.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let get_trampoline =
foreign "luv_get_check_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_check_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let start =
foreign "uv_check_start"
(ptr t @-> trampoline @-> returning error_code)
let stop =
foreign "uv_check_stop"
(ptr t @-> returning error_code)
end
module Idle =
struct
let t = Types.Idle.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let get_trampoline =
foreign "luv_get_idle_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_idle_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let start =
foreign "uv_idle_start"
(ptr t @-> trampoline @-> returning error_code)
let stop =
foreign "uv_idle_stop"
(ptr t @-> returning error_code)
end
module Async =
struct
let t = Types.Async.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> returning void)
let get_trampoline =
foreign "luv_get_async_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_async_init"
(ptr Loop.t @-> ptr t @-> trampoline @-> returning error_code)
let send =
foreign "uv_async_send"
(ptr t @-> returning error_code)
end
module Poll =
struct
let t = Types.Poll.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> int @-> int @-> returning void)
let get_trampoline =
foreign "luv_get_poll_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_poll_init"
(ptr Loop.t @-> ptr t @-> int @-> returning error_code)
let init_socket =
foreign "uv_poll_init_socket"
(ptr Loop.t @-> ptr t @-> Types.Os_socket.t @-> returning error_code)
let start =
foreign "uv_poll_start"
(ptr t @-> int @-> trampoline @-> returning error_code)
let stop =
foreign "uv_poll_stop"
(ptr t @-> returning error_code)
end
module Signal =
struct
let t = Types.Signal.t
let trampoline =
static_funptr
Ctypes.(ptr t @-> int @-> returning void)
let get_trampoline =
foreign "luv_get_signal_trampoline"
(void @-> returning trampoline)
let init =
foreign "uv_signal_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let start =
foreign "uv_signal_start"
(ptr t @-> trampoline @-> int @-> returning error_code)
let start_oneshot =
foreign "uv_signal_start_oneshot"
(ptr t @-> trampoline @-> int @-> returning error_code)
let stop =
foreign "uv_signal_stop"
(ptr t @-> returning error_code)
end
module Stream =
struct
module Connect_request =
struct
let trampoline =
static_funptr
Ctypes.(ptr Types.Stream.Connect_request.t @-> error_code @->
returning void)
let get_trampoline =
foreign "luv_get_connect_trampoline"
(void @-> returning trampoline)
end
module Shutdown_request =
struct
let trampoline =
static_funptr
Ctypes.(ptr Types.Stream.Shutdown_request.t @-> error_code @->
returning void)
let get_trampoline =
foreign "luv_get_shutdown_trampoline"
(void @-> returning trampoline)
end
module Write_request =
struct
let trampoline =
static_funptr
Ctypes.(ptr Types.Stream.Write_request.t @-> error_code @->
returning void)
let get_trampoline =
foreign "luv_get_write_trampoline"
(void @-> returning trampoline)
end
let t = Types.Stream.t
let connection_trampoline =
static_funptr
Ctypes.(ptr t @-> error_code @-> returning void)
let read_trampoline =
static_funptr
Ctypes.(ptr t @-> PosixTypes.ssize_t @-> ptr Types.Buf.t @->
returning void)
let get_connection_trampoline =
foreign "luv_get_connection_trampoline"
(void @-> returning connection_trampoline)
let get_read_trampoline =
foreign "luv_get_read_trampoline"
(void @-> returning read_trampoline)
let shutdown =
foreign "uv_shutdown"
(ptr Types.Stream.Shutdown_request.t @->
ptr t @->
Shutdown_request.trampoline @->
returning error_code)
let listen =
foreign "uv_listen"
(ptr t @-> int @-> connection_trampoline @-> returning error_code)
let accept =
foreign "uv_accept"
(ptr t @-> ptr t @-> returning error_code)
let read_start =
foreign "luv_read_start"
(ptr t @-> Handle.alloc_trampoline @-> read_trampoline @->
returning error_code)
let read_stop =
foreign "uv_read_stop"
(ptr t @-> returning error_code)
let write2 =
foreign "uv_write2"
(ptr Types.Stream.Write_request.t @->
ptr t @->
ptr Types.Buf.t @->
uint @->
ptr t @->
Write_request.trampoline @->
returning error_code)
let try_write =
foreign "uv_try_write"
(ptr t @-> ptr Types.Buf.t @-> uint @-> returning error_code)
let is_readable =
foreign "uv_is_readable"
(ptr t @-> returning bool)
let is_writable =
foreign "uv_is_writable"
(ptr t @-> returning bool)
let set_blocking =
foreign "uv_stream_set_blocking"
(ptr t @-> bool @-> returning error_code)
let get_write_queue_size =
foreign "uv_stream_get_write_queue_size"
(ptr t @-> returning size_t)
end
module TCP =
struct
let t = Types.TCP.t
let init =
foreign "uv_tcp_init"
(ptr Loop.t @-> ptr t @-> returning error_code)
let init_ex =
foreign "uv_tcp_init_ex"
(ptr Loop.t @-> ptr t @-> uint @-> returning error_code)
let open_ =
foreign "uv_tcp_open"
(ptr t @-> Types.Os_socket.t @-> returning error_code)
let nodelay =
foreign "uv_tcp_nodelay"
(ptr t @-> bool @-> returning error_code)
let keepalive =
foreign "uv_tcp_keepalive"
(ptr t @-> bool @-> int @-> returning error_code)
let simultaneous_accepts =
foreign "uv_tcp_simultaneous_accepts"
(ptr t @-> bool @-> returning error_code)
let bind =
foreign "uv_tcp_bind"
(ptr t @-> ptr Types.Sockaddr.t @-> int @-> returning error_code)
let getsockname =
foreign "uv_tcp_getsockname"
(ptr t @-> ptr Types.Sockaddr.t @-> ptr int @-> returning error_code)
let getpeername =
foreign "uv_tcp_getpeername"
(ptr t @-> ptr Types.Sockaddr.t @-> ptr int @-> returning error_code)
let connect =
foreign "uv_tcp_connect"
(ptr Types.Stream.Connect_request.t @->
ptr t @->
ptr Types.Sockaddr.t @->
Stream.Connect_request.trampoline @->
returning error_code)
let close_reset =
foreign "uv_tcp_close_reset"
(ptr t @-> Handle.close_trampoline @-> returning error_code)
end
module Pipe =
struct
let t = Types.Pipe.t
let init =
foreign "uv_pipe_init"
(ptr Loop.t @-> ptr t @-> bool @-> returning error_code)
let open_ =
foreign "uv_pipe_open"
(ptr t @-> int @-> returning error_code)
let connect =
foreign "uv_pipe_connect"
(ptr Types.Stream.Connect_request.t @->
ptr t @->
ocaml_string @->
Stream.Connect_request.trampoline @->
returning void)
let getsockname =
foreign "uv_pipe_getsockname"
(ptr t @-> ocaml_bytes @-> ptr size_t @-> returning error_code)
let getpeername =
foreign "uv_pipe_getpeername"
(ptr t @-> ocaml_bytes @-> ptr size_t @-> returning error_code)
let pending_instances =
foreign "uv_pipe_pending_instances"
(ptr t @-> int @-> returning void)
let pending_count =
foreign "uv_pipe_pending_count"
(ptr t @-> returning int)
let pending_type =
foreign "uv_pipe_pending_type"
(ptr t @-> returning int)
let chmod =
foreign "uv_pipe_chmod"
(ptr t @-> int @-> returning error_code)
end
module TTY =
struct