-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathev.h
5557 lines (4905 loc) · 160 KB
/
ev.h
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
/**
* MIT License
*
* Copyright (c) 2021 qgymib
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
/**
* # Changelog
*
* ## v1.0.0 (2024/11/25)
*
* ### Features
* 1. Support `ev_random()`.
* 2. Add timeout parameter for `ev_loop_run()`.
* 2. Add subset of atomic support.
*
* ### Bug Fixes
* 1. Fix build error when integrate into visual studio unicode build tree.
*
*
* ## v0.1.1 (2024/09/19)
*
* ### BREAKING CHANGES
* 1. merge `ev_file_init()` with `ev_file_open()`.
* 2. rename `ev_file_exit()` to `ev_file_close()`.
* 3. merge `ev_file_read_sync()` with `ev_file_read()`.
* 4. merge `ev_file_pread_sync()` with `ev_file_pread()`.
* 5. merge `ev_file_write_sync()` with `ev_file_write()`.
* 6. merge `ev_file_pwrite_sync()` with `ev_file_pwrite()`.
* 7. merge `ev_file_stat_sync()` with `ev_file_stat()`.
* 8. merge `ev_fs_mkdir_sync()` with `ev_fs_mkdir()`.
* 9. merge `ev_fs_remove_sync()` with `ev_fs_remove()`.
* 10. `ev_file_seek()` now return the resulting offset location as measured in bytes from the beginning of the file.
* 11. rename `ev_file_pread()` to `ev_file_preadv()`.
* 12. rename `ev_file_read()` to `ev_file_readv()`.
* 13. rename `ev_file_pwrite()` to `ev_file_pwritev()`.
* 14. rename `ev_file_write()` to `ev_file_writev()`.
*
* ### Features
* 1. `ev_fs_readdir()` is able to operator in synchronous mode.
* 2. `ev_fs_readfile()` is able to operator in synchronous mode.
* 3. `ev_file_seek()` is able to operator in synchronous mode.
* 4. support normal `ev_file_read()` and `ev_file_write()`.
* 5. support `ev_file_pread()` and `ev_file_pwrite()`.
* 6. support file mapping.
* 7. support get system page size.
*
* ### Bug Fixes
* 1. `ev_hrtime()` no longer require initialize event loop first.
* 2. can not open file in windows if path contains CJK characters.
* 3. Use `ev_fs_readfile()` in synchronous mode may crash in windows.
* 4. `ev_fs_mkdir()` should not fail if already exist in windows.
*
* ## v0.1.0 (2024/08/06)
*
* ### BREAKING CHANGES
* 1. `ev_hrtime()` now return time in nanoseconds.
*
* ### Features
* 1. support handle shared library.
*
* ### Bug Fixes
* 1. only define `dllimport` when `EV_USE_DLL` is defined
*
*
* ## v0.0.9 (2024/07/29)
*
* ### BREAKING CHANGES
* 1. `ev_map_insert()` now return conflict node address
* 2. remove `active_events` field
*
* ### Bug Fixes
* 1. fix: loop may wait infinite with EV_LOOP_MODE_ONCE if there are only endgame events
* 2. fix: memory leak in create process
* 3. fix: thread leak when process exit
* 4. fix: wrong format charster in test
*
*
* ## v0.0.8 (2023/04/07)
*
* ### BREAKING CHANGES
* 1. remove `ev_todo_token_t`
* 2. `ev_process_t` must be exited manually
* 3. rename position read and write to `pread` and `pwrite`
* 4. embed default thread pool
* 5. change thread pool functions
* 6. expose peeraddr in udp recv callback
* 7. reduce parameter in udp send callback
*
* ### Features
* 1. add detail information for `ev_fs_readfile()`
* 2. use `ev_library_shutdown()` to cleanup global resources
* 3. use `ev_loop_walk()` to walk through all handles
* 4. process: support change cwd
* 5. add amalgamate support
* 6. submit threadpool task by loop api
* 7. update test framework to v3.0.0
* 8. use `ev_hrtime()` to get high-resolution time
* 9. support normal file read / write / seek operations
* 10. support remove file and directory
* 11. expose memory allocate functions
* 12. redone error number
* 13. smart convert addr and name
*
* ### Bug Fixes
* 1. fix: use uninitialised value in `ev_exepath()` on Unix
* 2. fix: thread pool not unlink when exit loop
* 3. fix: `ev_process_spawn()` coredump on windows when redirect file
*
*
* ## v0.0.7 (2022/06/07)
*
* ### Features
* 1. Support `ev_getcwd()`
* 2. Support `ev_exepath()`
*
* ### Bug Fixes
* 1. fix: use of enum without previous declaration
* 2. fix: `FindFirstFile()` handle leak
* 3. fix: `ev_fs_readdir()` not working on windows
*
*
* ## v0.0.6 (2022/05/23)
*
* ### BREAKING CHANGES
* 1. change version code rule.
* 2. remove return value for `ev_mutex_init()`.
* 3. remove return value for `ev_sem_init()`.
*
* ### Features
* 1. Support unlink threadpool
* 2. publish `ev_todo_submit()`
*
* ### Bug Fixes
* 1. fix: crash when child process exit
*
*
* ## v0.0.5 (2022/05/13)
*
* ### BREAKING CHANGES
* 1. rename `EV_THREAD_WAIT_INFINITE` to `EV_INFINITE_TIMEOUT`.
* 2. `ev_pipe_make()` now have flags.
*
* ### Features
* 1. Support mkdir
* 2. Support process
* 3. file: synchronous operations
*
*
* ## v0.0.4 (2022/04/12)
*
* ### Bug Fixes
* 1. build error with glibc version lower than `2.28`
*
*
* ## v0.0.3 (2022/04/12)
*
* ### Features
* 1. Add version code
* 2. add file support
*
*
* ## v0.0.2 (2022/03/10)
*
* ### Features
* 1. ThreadPool: is able to link to event loop
* 2. List: support migrate
*
* ### Bug Fixes
* 1. test failure due to incorrect test sequence
*
*
* ## v0.0.1 (2022/02/22)
*
* Initial release
*
*/
/**
* @mainpage libev
*
* \section EV_OVERVIEW Overview
*
* [libev](https://github.com/qgymib/libev) is a rework of
* [libuv](https://github.com/libuv/libuv), with following advantages:
* 1. Strong types without static casts any more.
* 2. Enhanced IPC features.
* 3. Easy to use file system operations.
*
*
* \section EV_DOCUMENTATION Documentation
*
* Located in the docs/ subdirectory. It use [Doxygen](http://www.doxygen.nl/)
* to build documents, which means the source code is well documented and can
* be read directly without build it.
*
* To build html-based documents, in the project root, run:
* ```bash
* doxygen docs/Doxyfile
* ```
*
* Also documents can be browsed online [here](https://qgymib.github.io/libev/).
*
*
* \section EV_BUILD_INSTRUCTIONS Build Instructions
*
* [CMake](https://cmake.org/) is currently the prefer way to build:
*
* ```bash
* # Build:
* $ mkdir -p build
* $ (cd build && cmake .. -DBUILD_TESTING=ON) # generate project with tests
* $ cmake --build build # add `-j <n>` with cmake >= 3.12
*
* # Run tests:
* $ (cd build && ctest -C Debug --output-on-failure)
* ```
*
* \section EV_AMALGAMATE Amalgamate
*
* [libev](https://github.com/qgymib/libev) support amalgamate build, which
* allow to distribute libev's source code using only two files(`ev.h` and `ev.c`).
*
* > Note: Amalgamate requires python3.
*
* To use amalgamation, add `-DEV_AMALGAMATE_BUILD=on` when configurate cmake:
*
* ```bash
* $ cmake -DEV_AMALGAMATE_BUILD=on /path/to/libev
* $ cmake --build .
* ```
*
* In `${CMAKE_CURRENT_BINARY_DIR}/amalgamate` directory, you will find the
* generated files.
*
*/
#ifndef __EV_H__
#define __EV_H__
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdarg.h>
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/expose.h
// SIZE: 1139
// SHA-256: 6e701e3887d5dc60145e4a44032f7ee7fa37b77cd28cffa7612d4008efd80342
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/expose.h"
#ifndef __EV_EXPOSE_H__
#define __EV_EXPOSE_H__
#if defined(_WIN32) || defined(__CYGWIN__)
# if defined(EV_USE_DLL)
# if defined(EV_BUILDING_DLL)
# if defined(__GNUC__) || defined(__clang__)
# define EV_API __attribute__ ((dllexport))
# else
# define EV_API __declspec(dllexport)
# endif
# else
# if defined(__GNUC__) || defined(__clang__)
# define EV_API __attribute__ ((dllimport))
# else
# define EV_API __declspec(dllimport)
# endif
# endif
# else
# define EV_API
# endif
#elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
# define EV_API __attribute__((visibility ("default")))
#else
# define EV_API
#endif
#if defined(EV_AMALGAMATE_BUILD)
# if defined(__GNUC__) || defined(__clang__)
# define EV_LOCAL static __attribute__((unused))
# else
# define EV_LOCAL static
# endif
#elif (defined(__GNUC__) || defined(__clang__)) && !defined(_WIN32)
# define EV_LOCAL __attribute__((visibility ("hidden")))
#else
# define EV_LOCAL
#endif
#endif
// #line 68 "ev.h"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/version.h
// SIZE: 1020
// SHA-256: d305de0458fd00e9caef834cb7f503cb0c02421e84bf48ebb35a6d54b4b402f8
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/version.h"
#ifndef __EV_VERSION_H__
#define __EV_VERSION_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup EV_VERSION Version
* @{
*/
/**
* @brief Major version.
*/
#define EV_VERSION_MAJOR 2
/**
* @brief Minor version.
*/
#define EV_VERSION_MINOR 0
/**
* @brief Patch version.
*/
#define EV_VERSION_PATCH 0
/**
* @brief Version calculate helper macro.
* @param[in] a Major version.
* @param[in] b Minor version.
* @param[in] c Patch version.
*/
#define EV_VERSION(a, b, c) (((a) << 24) + ((b) << 16) + (c))
/**
* @brief Current version code.
*/
#define EV_VERSION_CODE \
EV_VERSION(EV_VERSION_MAJOR, EV_VERSION_MINOR, EV_VERSION_PATCH)
/**
* @brief Get version code as c string.
* @return Version code.
*/
EV_API const char* ev_version_str(void);
/**
* @brief Get version code as number.
* @return Version code
*/
EV_API unsigned ev_version_code(void);
/**
* @} EV_VERSION
*/
#ifdef __cplusplus
}
#endif
#endif
// #line 69 "ev.h"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/list.h
// SIZE: 4329
// SHA-256: a71299aca04efa9160eaa9a748345df2c826bffd67181543c71f6403c12871ad
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/list.h"
#ifndef __EV_LIST_H__
#define __EV_LIST_H__
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup EV_UTILS_LIST List
* @ingroup EV_UTILS
* @{
*/
/**
* @brief Static initializer for #ev_list_t
* @see ev_list_t
*/
#define EV_LIST_INIT { NULL, NULL, 0 }
/**
* @brief Static initializer for #ev_list_node_t
* @see ev_list_node_t
*/
#define EV_LIST_NODE_INIT { NULL, NULL }
/**
* @brief The list node.
* This node must put in your struct.
* @see EV_LIST_NODE_INIT
*/
typedef struct ev_list_node
{
struct ev_list_node* p_after; /**< Pointer to next node */
struct ev_list_node* p_before; /**< Pointer to previous node */
}ev_list_node_t;
/**
* @brief Double Linked List
* @see EV_LIST_INIT
*/
typedef struct ev_list
{
ev_list_node_t* head; /**< Pointer to HEAD node */
ev_list_node_t* tail; /**< Pointer to TAIL node */
size_t size; /**< The number of total nodes */
}ev_list_t;
/**
* @brief Initialize Double Linked List.
* @note It is guarantee that memset() to zero have the same affect.
* @param[out] handler Pointer to list
*/
EV_API void ev_list_init(ev_list_t* handler);
/**
* @brief Insert a node to the head of the list.
* @warning the node must not exist in any list.
* @param[in,out] handler Pointer to list
* @param[in,out] node Pointer to a new node
*/
EV_API void ev_list_push_front(ev_list_t* handler, ev_list_node_t* node);
/**
* @brief Insert a node to the tail of the list.
* @warning the node must not exist in any list.
* @param[in,out] handler Pointer to list
* @param[in,out] node Pointer to a new node
*/
EV_API void ev_list_push_back(ev_list_t* handler, ev_list_node_t* node);
/**
* @brief Insert a node in front of a given node.
* @warning the node must not exist in any list.
* @param[in,out] handler Pointer to list
* @param[in,out] pos Pointer to a exist node
* @param[in,out] node Pointer to a new node
*/
EV_API void ev_list_insert_before(ev_list_t* handler, ev_list_node_t* pos, ev_list_node_t* node);
/**
* @brief Insert a node right after a given node.
* @warning the node must not exist in any list.
* @param[in,out] handler Pointer to list
* @param[in,out] pos Pointer to a exist node
* @param[in,out] node Pointer to a new node
*/
EV_API void ev_list_insert_after(ev_list_t* handler, ev_list_node_t* pos, ev_list_node_t* node);
/**
* @brief Delete a exist node
* @warning The node must already in the list.
* @param[in,out] handler Pointer to list
* @param[in,out] node The node you want to delete
*/
EV_API void ev_list_erase(ev_list_t* handler, ev_list_node_t* node);
/**
* @brief Get the number of nodes in the list.
* @param[in] handler Pointer to list
* @return The number of nodes
*/
EV_API size_t ev_list_size(const ev_list_t* handler);
/**
* @brief Get the first node and remove it from the list.
* @param[in,out] handler Pointer to list
* @return The first node
*/
EV_API ev_list_node_t* ev_list_pop_front(ev_list_t* handler);
/**
* @brief Get the last node and remove it from the list.
* @param[in,out] handler Pointer to list
* @return The last node
*/
EV_API ev_list_node_t* ev_list_pop_back(ev_list_t* handler);
/**
* @brief Get the first node.
* @param[in] handler Pointer to list
* @return The first node
*/
EV_API ev_list_node_t* ev_list_begin(const ev_list_t* handler);
/**
* @brief Get the last node.
* @param[in] handler The handler of list
* @return The last node
*/
EV_API ev_list_node_t* ev_list_end(const ev_list_t* handler);
/**
* @brief Get next node.
* @param[in] node Current node
* @return The next node
*/
EV_API ev_list_node_t* ev_list_next(const ev_list_node_t* node);
/**
* @brief Get previous node.
* @param[in] node current node
* @return previous node
*/
EV_API ev_list_node_t* ev_list_prev(const ev_list_node_t* node);
/**
* @brief Move all elements from \p src into the end of \p dst.
* @param[in] dst Destination list.
* @param[in] src Source list.
*/
EV_API void ev_list_migrate(ev_list_t* dst, ev_list_t* src);
/**
* @} EV_UTILS/EV_UTILS_LIST
*/
#ifdef __cplusplus
}
#endif
#endif
// #line 70 "ev.h"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/map.h
// SIZE: 4416
// SHA-256: 542ea54deebd4836d4f60f717aa45fd177de855895e66df51c0f637e5d5ed47a
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/map.h"
#ifndef __EV_MAP_H__
#define __EV_MAP_H__
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup EV_UTILS_MAP Map
* @ingroup EV_UTILS
* @{
*/
/**
* @brief The node for map
* @see eaf_map_t
* @see EV_MAP_NODE_INIT
*/
typedef struct ev_map_node
{
struct ev_map_node* __rb_parent_color; /**< parent node | color */
struct ev_map_node* rb_right; /**< right node */
struct ev_map_node* rb_left; /**< left node */
} ev_map_node_t;
/**
* @brief Static initializer for #ev_map_t
* @see ev_map_t
* @param[in] cmp Compare function
* @param[in] arg Argument for compare function
*/
#define EV_MAP_INIT(cmp, arg) { NULL, { cmp, arg }, 0 }
/**
* @brief Static initializer for #ev_map_node_t
* @see ev_map_node_t
*/
#define EV_MAP_NODE_INIT { NULL, NULL, NULL }
/**
* @brief Compare function.
* @param key1 The key in the map
* @param key2 The key user given
* @param arg User defined argument
* @return -1 if key1 < key2. 1 if key1 > key2. 0 if key1 == key2.
*/
typedef int(*ev_map_cmp_fn)(const ev_map_node_t* key1, const ev_map_node_t* key2, void* arg);
/**
* @brief Map implemented as red-black tree
* @see EV_MAP_INIT
*/
typedef struct ev_map
{
ev_map_node_t* rb_root; /**< root node */
struct
{
ev_map_cmp_fn cmp; /**< Pointer to compare function */
void* arg; /**< User defined argument, which will passed to compare function */
}cmp; /**< Compare function data */
size_t size; /**< The number of nodes */
} ev_map_t;
/**
* @brief Initialize the map referenced by handler.
* @param handler The pointer to the map
* @param cmp The compare function. Must not NULL
* @param arg User defined argument. Can be anything
*/
EV_API void ev_map_init(ev_map_t* handler, ev_map_cmp_fn cmp, void* arg);
/**
* @brief Insert the node into map.
* @warning the node must not exist in any map.
* @param handler The pointer to the map
* @param node The node
* @return NULL if success, otherwise return the conflict node address.
*/
EV_API ev_map_node_t* ev_map_insert(ev_map_t* handler, ev_map_node_t* node);
/**
* @brief Delete the node from the map.
* @warning The node must already in the map.
* @param handler The pointer to the map
* @param node The node
*/
EV_API void ev_map_erase(ev_map_t* handler, ev_map_node_t* node);
/**
* @brief Get the number of nodes in the map.
* @param handler The pointer to the map
* @return The number of nodes
*/
EV_API size_t ev_map_size(const ev_map_t* handler);
/**
* @brief Finds element with specific key
* @param handler The pointer to the map
* @param key The key
* @return An iterator point to the found node
*/
EV_API ev_map_node_t* ev_map_find(const ev_map_t* handler,
const ev_map_node_t* key);
/**
* @brief Returns an iterator to the first element not less than the given key
* @param handler The pointer to the map
* @param key The key
* @return An iterator point to the found node
*/
EV_API ev_map_node_t* ev_map_find_lower(const ev_map_t* handler,
const ev_map_node_t* key);
/**
* @brief Returns an iterator to the first element greater than the given key
* @param handler The pointer to the map
* @param key The key
* @return An iterator point to the found node
*/
EV_API ev_map_node_t* ev_map_find_upper(const ev_map_t* handler,
const ev_map_node_t* key);
/**
* @brief Returns an iterator to the beginning
* @param handler The pointer to the map
* @return An iterator
*/
EV_API ev_map_node_t* ev_map_begin(const ev_map_t* handler);
/**
* @brief Returns an iterator to the end
* @param handler The pointer to the map
* @return An iterator
*/
EV_API ev_map_node_t* ev_map_end(const ev_map_t* handler);
/**
* @brief Get an iterator next to the given one.
* @param node Current iterator
* @return Next iterator
*/
EV_API ev_map_node_t* ev_map_next(const ev_map_node_t* node);
/**
* @brief Get an iterator before the given one.
* @param node Current iterator
* @return Previous iterator
*/
EV_API ev_map_node_t* ev_map_prev(const ev_map_node_t* node);
/**
* @} EV_UTILS/EV_UTILS_MAP
*/
#ifdef __cplusplus
}
#endif
#endif
// #line 71 "ev.h"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/defines.h
// SIZE: 3268
// SHA-256: def87553c746184a16b6fbcaabae80b298f4a50e485e6098525402a19524ce60
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/defines.h"
#ifndef __EV_DEFINES_H__
#define __EV_DEFINES_H__
/**
* @defgroup EV_DEFINE Defines
* @{
*/
/**
* @brief The maximum number of iov buffers can be support.
*/
#define EV_IOV_MAX 16
/**
* @brief Expand macro.
* @param[in] ... Code to expand.
*/
#define EV_EXPAND(...) __VA_ARGS__
/**
* @brief Repeat code for \p n times.
* @param[in] n How many times to repeat.
* @param[in] ... Code fragment to repeat.
*/
#define EV_INIT_REPEAT(n, ...) EV_INIT_REPEAT2(n, __VA_ARGS__)
/** @cond */
#define EV_INIT_REPEAT2(n, ...) EV_INIT_REPEAT_##n(__VA_ARGS__)
#define EV_INIT_REPEAT_1(...) EV_EXPAND(__VA_ARGS__)
#define EV_INIT_REPEAT_2(...) EV_INIT_REPEAT_1(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_3(...) EV_INIT_REPEAT_2(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_4(...) EV_INIT_REPEAT_3(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_5(...) EV_INIT_REPEAT_4(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_6(...) EV_INIT_REPEAT_5(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_7(...) EV_INIT_REPEAT_6(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_8(...) EV_INIT_REPEAT_7(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_9(...) EV_INIT_REPEAT_8(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_10(...) EV_INIT_REPEAT_9(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_11(...) EV_INIT_REPEAT_10(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_12(...) EV_INIT_REPEAT_11(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_13(...) EV_INIT_REPEAT_12(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_14(...) EV_INIT_REPEAT_13(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_15(...) EV_INIT_REPEAT_14(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
#define EV_INIT_REPEAT_16(...) EV_INIT_REPEAT_15(__VA_ARGS__), EV_INIT_REPEAT_1(__VA_ARGS__)
/** @endcond */
/**
* @def EV_OFFSETOF
* @brief The offset of \p member in \p type.
*/
#if defined(offsetof)
# define EV_OFFSETOF(type, member) offsetof(type, member)
#else
# define EV_OFFSETOF(type, member) ((size_t)&(((type*)0)->member))
#endif
/**
* @def EV_CONTAINER_OF
* @brief cast a member of a structure out to the containing structure.
*/
#if defined(container_of)
# define EV_CONTAINER_OF(ptr, type, member) \
container_of(ptr, type, member)
#elif defined(__GNUC__) || defined(__clang__)
# define EV_CONTAINER_OF(ptr, type, member) \
({ \
const typeof(((type *)0)->member)*__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
})
#else
# define EV_CONTAINER_OF(ptr, type, member) \
((type *) ((char *) (ptr) - EV_OFFSETOF(type, member)))
#endif
/**
* @brief Align \p size to \p align, who's value is larger or equal to \p size
* and can be divided with no remainder by \p align.
* @note \p align must equal to 2^n
*/
#define EV_ALIGN_SIZE(size, align) \
(((uintptr_t)(size) + ((uintptr_t)(align) - 1)) & ~((uintptr_t)(align) - 1))
/**
* @} EV_DEFINE
*/
#endif
// #line 72 "ev.h"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/errno.h
// SIZE: 11153
// SHA-256: 9b13fa73f471ea05908f531a23470f18711bc8f14e558bfb6226fd1d18457ef7
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/errno.h"
#ifndef __EV_ERRNO_H__
#define __EV_ERRNO_H__
#include <errno.h>
#if EDOM > 0
#define EV__ERR(x) (-(x))
#else
#define EV__ERR(x) (x)
#endif
#if defined(EPERM) && !defined(_WIN32)
# define EV__EPERM EV__ERR(EPERM)
#else
# define EV__EPERM (-4093)
#endif
#if defined(ENOENT) && !defined(_WIN32)
# define EV__ENOENT EV__ERR(ENOENT)
#else
# define EV__ENOENT (-4092)
#endif
#if defined(EIO) && !defined(_WIN32)
# define EV__EIO EV__ERR(EIO)
#else
# define EV__EIO (-4089)
#endif
#if defined(E2BIG) && !defined(_WIN32)
# define EV__E2BIG EV__ERR(E2BIG)
#else
# define EV__E2BIG (-4087)
#endif
#if defined(EBADF) && !defined(_WIN32)
# define EV__EBADF EV__ERR(EBADF)
#else
# define EV__EBADF (-4085)
#endif
#if defined(EAGAIN) && !defined(_WIN32)
# define EV__EAGAIN EV__ERR(EAGAIN)
#else
# define EV__EAGAIN (-4083)
#endif
#if defined(ENOMEM) && !defined(_WIN32)
# define EV__ENOMEM EV__ERR(ENOMEM)
#else
# define EV__ENOMEM (-4082)
#endif
#if defined(EACCES) && !defined(_WIN32)
# define EV__EACCES EV__ERR(EACCES)
#else
# define EV__EACCES (-4081)
#endif
#if defined(EFAULT) && !defined(_WIN32)
# define EV__EFAULT EV__ERR(EFAULT)
#else
# define EV__EFAULT (-4080)
#endif
#if defined(EBUSY) && !defined(_WIN32)
# define EV__EBUSY EV__ERR(EBUSY)
#else
# define EV__EBUSY (-4078)
#endif
#if defined(EEXIST) && !defined(_WIN32)
# define EV__EEXIST EV__ERR(EEXIST)
#else
# define EV__EEXIST (-4077)
#endif
#if defined(EXDEV) && !defined(_WIN32)
# define EV__EXDEV EV__ERR(EXDEV)
#else
# define EV__EXDEV (-4076)
#endif
#if defined(ENOTDIR) && !defined(_WIN32)
# define EV__ENOTDIR EV__ERR(ENOTDIR)
#else
# define EV__ENOTDIR (-4074)
#endif
#if defined(EISDIR) && !defined(_WIN32)
# define EV__EISDIR EV__ERR(EISDIR)
#else
# define EV__EISDIR (-4073)
#endif
#if defined(EINVAL) && !defined(_WIN32)
# define EV__EINVAL EV__ERR(EINVAL)
#else
# define EV__EINVAL (-4072)
#endif
#if defined(ENFILE) && !defined(_WIN32)
# define EV__ENFILE EV__ERR(ENFILE)
#else
# define EV__ENFILE (-4071)
#endif
#if defined(EMFILE) && !defined(_WIN32)
# define EV__EMFILE EV__ERR(EMFILE)
#else
# define EV__EMFILE (-4070)
#endif
#if defined(ENOSPC) && !defined(_WIN32)
# define EV__ENOSPC EV__ERR(ENOSPC)
#else
# define EV__ENOSPC (-4066)
#endif
#if defined(EROFS) && !defined(_WIN32)
# define EV__EROFS EV__ERR(EROFS)
#else
# define EV__EROFS (-4064)
#endif
#if defined(EPIPE) && !defined(_WIN32)
# define EV__EPIPE EV__ERR(EPIPE)
#else
# define EV__EPIPE (-4062)
#endif
#if defined(ENAMETOOLONG) && !defined(_WIN32)
# define EV__ENAMETOOLONG EV__ERR(ENAMETOOLONG)
#else
# define EV__ENAMETOOLONG (-4058)
#endif
#if defined(ENOSYS) && !defined(_WIN32)
# define EV__ENOSYS EV__ERR(ENOSYS)
#else
# define EV__ENOSYS (-4056)
#endif
#if defined(ENOTEMPTY) && !defined(_WIN32)
# define EV__ENOTEMPTY EV__ERR(ENOTEMPTY)
#else
# define EV__ENOTEMPTY (-4055)
#endif
#if defined(ELOOP) && !defined(_WIN32)
# define EV__ELOOP EV__ERR(ELOOP)
#else
# define EV__ELOOP (-4054)
#endif
#if defined(EPROTO) && !defined(_WIN32)
# define EV__EPROTO EV__ERR(EPROTO)
#else
# define EV__EPROTO (-4023)
#endif
#if defined(ENOTSOCK) && !defined(_WIN32)
# define EV__ENOTSOCK EV__ERR(ENOTSOCK)
#else
# define EV__ENOTSOCK (-4006)
#endif
#if defined(EMSGSIZE) && !defined(_WIN32)
# define EV__EMSGSIZE EV__ERR(EMSGSIZE)
#else
# define EV__EMSGSIZE (-4004)
#endif
#if defined(EPROTONOSUPPORT) && !defined(_WIN32)
# define EV__EPROTONOSUPPORT EV__ERR(EPROTONOSUPPORT)
#else
# define EV__EPROTONOSUPPORT (-4001)
#endif
#if defined(ENOTSUP) && !defined(_WIN32)
# define EV__ENOTSUP EV__ERR(ENOTSUP)