├── .gitignore ├── .project ├── CMakeLists.txt ├── LICENSE ├── README ├── README.md ├── TODO ├── docs ├── graffle │ ├── Proactor Architecture Diagram.graffle │ ├── Proactor Loop Flow Chart copy.graffle │ ├── Proactor Loop Flow Chart.graffle │ ├── Reactor Architecture Diagram.graffle │ ├── Reactor Loop Flow Chart.graffle │ └── Thread Model.graffle ├── html │ ├── cardinal2.png │ ├── index.html │ ├── pod.css │ ├── pod.html │ ├── proactor_architecture.png │ ├── proactor_flowchart.png │ ├── reactor_architecture.png │ ├── reactor_flowchart.png │ └── worker_thread.png ├── lcov │ ├── amber.png │ ├── emerald.png │ ├── examples │ │ ├── index-sort-b.html │ │ ├── index-sort-f.html │ │ ├── index-sort-l.html │ │ ├── index.html │ │ ├── proactor_bench.c.func-sort-c.html │ │ ├── proactor_bench.c.func.html │ │ └── proactor_bench.c.gcov.html │ ├── gcov.css │ ├── glass.png │ ├── index-sort-b.html │ ├── index-sort-f.html │ ├── index-sort-l.html │ ├── index.html │ ├── lcov.info │ ├── lcov0.info │ ├── lcov1.info │ ├── ruby.png │ ├── snow.png │ ├── src │ │ └── gwrl │ │ │ ├── event.c.func-sort-c.html │ │ │ ├── event.c.func.html │ │ │ ├── event.c.gcov.html │ │ │ ├── event_kqueue.c.func-sort-c.html │ │ │ ├── event_kqueue.c.func.html │ │ │ ├── event_kqueue.c.gcov.html │ │ │ ├── event_poll.c.func-sort-c.html │ │ │ ├── event_poll.c.func.html │ │ │ ├── event_poll.c.gcov.html │ │ │ ├── event_select.c.func-sort-c.html │ │ │ ├── event_select.c.func.html │ │ │ ├── event_select.c.gcov.html │ │ │ ├── event_wake_pipe.c.func-sort-c.html │ │ │ ├── event_wake_pipe.c.func.html │ │ │ ├── event_wake_pipe.c.gcov.html │ │ │ ├── index-sort-b.html │ │ │ ├── index-sort-f.html │ │ │ ├── index-sort-l.html │ │ │ ├── index.html │ │ │ ├── lock.c.func-sort-c.html │ │ │ ├── lock.c.func.html │ │ │ ├── lock.c.gcov.html │ │ │ ├── proactor.c.func-sort-c.html │ │ │ ├── proactor.c.func.html │ │ │ ├── proactor.c.gcov.html │ │ │ ├── proactor_imp.c.func-sort-c.html │ │ │ ├── proactor_imp.c.func.html │ │ │ ├── proactor_imp.c.gcov.html │ │ │ ├── socket.c.func-sort-c.html │ │ │ ├── socket.c.func.html │ │ │ ├── socket.c.gcov.html │ │ │ ├── time.c.func-sort-c.html │ │ │ ├── time.c.func.html │ │ │ └── time.c.gcov.html │ ├── test │ │ ├── index-sort-b.html │ │ ├── index-sort-f.html │ │ ├── index-sort-l.html │ │ ├── index.html │ │ ├── proactor_buf.c.func-sort-c.html │ │ ├── proactor_buf.c.func.html │ │ ├── proactor_buf.c.gcov.html │ │ ├── proactor_cb.c.func-sort-c.html │ │ ├── proactor_cb.c.func.html │ │ ├── proactor_cb.c.gcov.html │ │ ├── proactor_filters.c.func-sort-c.html │ │ ├── proactor_filters.c.func.html │ │ ├── proactor_filters.c.gcov.html │ │ ├── proactor_free1.c.func-sort-c.html │ │ ├── proactor_free1.c.func.html │ │ ├── proactor_free1.c.gcov.html │ │ ├── proactor_gwpr_src_activity_write_qitem_result.c.func-sort-c.html │ │ ├── proactor_gwpr_src_activity_write_qitem_result.c.func.html │ │ ├── proactor_gwpr_src_activity_write_qitem_result.c.gcov.html │ │ ├── proactor_gwprwrq_get.c.func-sort-c.html │ │ ├── proactor_gwprwrq_get.c.func.html │ │ ├── proactor_gwprwrq_get.c.gcov.html │ │ ├── proactor_mem_errors.c.func-sort-c.html │ │ ├── proactor_mem_errors.c.func.html │ │ ├── proactor_mem_errors.c.gcov.html │ │ ├── proactor_src.c.func-sort-c.html │ │ ├── proactor_src.c.func.html │ │ ├── proactor_src.c.gcov.html │ │ ├── proactor_tcp.c.func-sort-c.html │ │ ├── proactor_tcp.c.func.html │ │ ├── proactor_tcp.c.gcov.html │ │ ├── proactor_udp.c.func-sort-c.html │ │ ├── proactor_udp.c.func.html │ │ ├── proactor_udp.c.gcov.html │ │ ├── proactor_wrq.c.func-sort-c.html │ │ ├── proactor_wrq.c.func.html │ │ ├── proactor_wrq.c.gcov.html │ │ ├── reactor_custom_gathering.c.func-sort-c.html │ │ ├── reactor_custom_gathering.c.func.html │ │ ├── reactor_custom_gathering.c.gcov.html │ │ ├── reactor_del_pers_timeouts.c.func-sort-c.html │ │ ├── reactor_del_pers_timeouts.c.func.html │ │ ├── reactor_del_pers_timeouts.c.gcov.html │ │ ├── reactor_del_pers_timeouts2.c.func-sort-c.html │ │ ├── reactor_del_pers_timeouts2.c.func.html │ │ ├── reactor_del_pers_timeouts2.c.gcov.html │ │ ├── reactor_del_pers_timeouts3.c.func-sort-c.html │ │ ├── reactor_del_pers_timeouts3.c.func.html │ │ ├── reactor_del_pers_timeouts3.c.gcov.html │ │ ├── reactor_events.c.func-sort-c.html │ │ ├── reactor_events.c.func.html │ │ ├── reactor_events.c.gcov.html │ │ ├── reactor_free1.c.func-sort-c.html │ │ ├── reactor_free1.c.func.html │ │ ├── reactor_free1.c.gcov.html │ │ ├── reactor_free2.c.func-sort-c.html │ │ ├── reactor_free2.c.func.html │ │ ├── reactor_free2.c.gcov.html │ │ ├── reactor_free3.c.func-sort-c.html │ │ ├── reactor_free3.c.func.html │ │ ├── reactor_free3.c.gcov.html │ │ ├── reactor_free4.c.func-sort-c.html │ │ ├── reactor_free4.c.func.html │ │ ├── reactor_free4.c.gcov.html │ │ ├── reactor_gatherfunc.c.func-sort-c.html │ │ ├── reactor_gatherfunc.c.func.html │ │ ├── reactor_gatherfunc.c.gcov.html │ │ ├── reactor_mem_errors.c.func-sort-c.html │ │ ├── reactor_mem_errors.c.func.html │ │ ├── reactor_mem_errors.c.gcov.html │ │ ├── reactor_no_sleep.c.func-sort-c.html │ │ ├── reactor_no_sleep.c.func.html │ │ ├── reactor_no_sleep.c.gcov.html │ │ ├── reactor_options.c.func-sort-c.html │ │ ├── reactor_options.c.func.html │ │ ├── reactor_options.c.gcov.html │ │ ├── reactor_pers_timeouts.c.func-sort-c.html │ │ ├── reactor_pers_timeouts.c.func.html │ │ ├── reactor_pers_timeouts.c.gcov.html │ │ ├── reactor_safely.c.func-sort-c.html │ │ ├── reactor_safely.c.func.html │ │ ├── reactor_safely.c.gcov.html │ │ ├── reactor_src.c.func-sort-c.html │ │ ├── reactor_src.c.func.html │ │ ├── reactor_src.c.gcov.html │ │ ├── reactor_timeout_rearm.c.func-sort-c.html │ │ ├── reactor_timeout_rearm.c.func.html │ │ ├── reactor_timeout_rearm.c.gcov.html │ │ ├── reactor_timer_interval.c.func-sort-c.html │ │ ├── reactor_timer_interval.c.func.html │ │ ├── reactor_timer_interval.c.gcov.html │ │ ├── reactor_timers.c.func-sort-c.html │ │ ├── reactor_timers.c.func.html │ │ ├── reactor_timers.c.gcov.html │ │ ├── reactor_wake_pipe.c.func-sort-c.html │ │ ├── reactor_wake_pipe.c.func.html │ │ ├── reactor_wake_pipe.c.gcov.html │ │ ├── reactor_wake_reinit.c.func-sort-c.html │ │ ├── reactor_wake_reinit.c.func.html │ │ ├── reactor_wake_reinit.c.gcov.html │ │ ├── time_fncs.c.func-sort-c.html │ │ ├── time_fncs.c.func.html │ │ └── time_fncs.c.gcov.html │ ├── updown.png │ └── usr │ │ └── include │ │ ├── secure │ │ ├── _string.h.func-sort-c.html │ │ ├── _string.h.func.html │ │ ├── _string.h.gcov.html │ │ ├── index-sort-b.html │ │ ├── index-sort-f.html │ │ ├── index-sort-l.html │ │ └── index.html │ │ └── sys │ │ ├── _structs.h.func-sort-c.html │ │ ├── _structs.h.func.html │ │ ├── _structs.h.gcov.html │ │ ├── index-sort-b.html │ │ ├── index-sort-f.html │ │ ├── index-sort-l.html │ │ └── index.html └── pod │ ├── doc.pod │ ├── doc.txt │ ├── docs.html │ ├── pod2htmd.tmp │ └── pod2htmi.tmp ├── examples ├── CMakeLists.txt ├── proactor_echo.c └── reactor_echo.c ├── scripts ├── coverage.sh ├── coverage_clean.sh ├── lcov.py ├── pod.sh ├── runtest.py └── runtests.py ├── src └── gwrl │ ├── ._shared_config.h.in │ ├── CMakeLists.txt │ ├── event.c │ ├── event.h │ ├── event_epoll.c │ ├── event_iocp.c │ ├── event_iocp.h │ ├── event_kqueue.c │ ├── event_poll.c │ ├── event_private.h │ ├── event_select.c │ ├── event_wake_pipe.c │ ├── gettimeofday.c │ ├── lock.c │ ├── lock.h │ ├── proactor.c │ ├── proactor.h │ ├── proactor_imp.c │ ├── proactor_imp.h │ ├── proactor_imp_iocp.c │ ├── proactor_imp_iocp.h │ ├── shared_config.h.in │ ├── shared_include.h │ ├── shared_types.h │ ├── socket.c │ ├── socket.h │ ├── string.h │ ├── time.c │ └── time.h └── test ├── CMakeLists.txt ├── proactor_buf.c ├── proactor_cb.c ├── proactor_filters.c ├── proactor_free1.c ├── proactor_gwpr_src_activity_write_qitem_result.c ├── proactor_gwprwrq_get.c ├── proactor_src.c ├── proactor_tcp.c ├── proactor_thread_specific_nix.c ├── proactor_udp.c ├── proactor_wrq.c ├── reactor_custom_gathering.c ├── reactor_events.c ├── reactor_free1.c ├── reactor_free2.c ├── reactor_free3.c ├── reactor_free4.c ├── reactor_gatherfunc.c ├── reactor_no_sleep.c ├── reactor_options.c ├── reactor_pers_timeouts.c ├── reactor_safely.c ├── reactor_src.c ├── reactor_timeout_rearm.c ├── reactor_timer_interval.c ├── reactor_timers.c ├── reactor_wake_iocp.c ├── reactor_wake_pipe.c ├── reactor_wake_reinit.c └── time_fncs.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | autom4te.cache/ 3 | stamp-h1 4 | config.h.in~ 5 | Makefile 6 | autoscan.log 7 | config.log 8 | config.status 9 | configure.scan 10 | libgw.a 11 | *.o 12 | libgw-*.tar.gz 13 | libgw-1.0/ 14 | *.dSYM/ 15 | build/ 16 | src/config.h 17 | src/gwc/config.h 18 | *_config.h 19 | docs/reference/ 20 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | gwc 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.7) 2 | project(gwrl) 3 | option(GWRL_BUILD_EXAMPLES "Whether or not to build the examples portion of the library." ON) 4 | option(GWRL_BUILD_TEST "Whether or not to build the test directory." OFF) 5 | option(GWRL_BUILD_COVERAGE "Whether or not to build lcov coverate report." OFF) 6 | option(GWRL_FORCE_KQUEUE "If you know you have kqueue or want to force it's use." OFF) 7 | option(GWRL_FORCE_EPOLL "If you know you have epoll or want to force it's use." OFF) 8 | option(GWRL_FORCE_POLL "If you know you have poll or want to force it's use." OFF) 9 | option(GWRL_FORCE_SELECT "If you know you have select or want to force it's use." OFF) 10 | option(GWRL_FORCE_IOCP "If you know you have IOCP and want to use it." OFF) 11 | set(gwrl_mem_calloc "calloc(n,s)" CACHE STRING "The default calloc allocator.") 12 | set(gwrl_mem_free "free(mm)" CACHE STRING "The default free function.") 13 | set(GWRL_EPOLL_EVENT_COUNT 64 CACHE STRING "The number of events to accept from epoll_wait function when polling.") 14 | set(GWRL_EVENT_CACHE_MAX 128 CACHE STRING "Internal gwrlevt structure cache count.") 15 | set(GWPR_FILTERS_MAX 0 CACHE STRING "The maximum amount of read or write filters for file input sources.") 16 | set(GWRL_GATHER_FUNCS_MAX 0 CACHE STRING "The maximum amount of user-provided gather functions required.") 17 | set(GWRL_KQUEUE_KEVENT_COUNT 512 CACHE STRING "The number of events to accept from kevent function when polling.") 18 | set(GWPR_MAX_ACCEPT 256 CACHE STRING "Maximum amount of clients to accept in one runloop iteration.") 19 | set(GWRL_POLLFD_COUNT 64 CACHE STRING "The initial struct pollfd * size and grow by size to accept events from poll backend.") 20 | set(GWRL_REDISPATCH_MAX 5 CACHE STRING "The maximum amount of times to re-dispatch events created by the user during the dispatch phase.") 21 | set(GWRL_SRC_TYPES_COUNT 2 CACHE STRING "The number of supported input sources.") 22 | set(GWPR_SYNCHRONOUS_WRITE_MAX_BYTES 512 CACHE STRING "The maximum bytes allowed to try in a synchronous write.") 23 | set(GWPR_WRQUEUE_CACHE_MAX 256 CACHE STRING "Internal cache size for gwpr_wrqueue structures.") 24 | if(GWRL_BUILD_COVERAGE AND "${CMAKE_GENERATOR}" MATCHES "Make") 25 | set(GWRL_COVERAGE_INTERNAL_ASSERT_VARS 1) 26 | set(GWRL_HIDE_FROM_COVERAGE 1) 27 | endif() 28 | add_subdirectory(src/gwrl) 29 | if(GWRL_BUILD_EXAMPLES) 30 | add_subdirectory(examples/) 31 | endif() 32 | if(GWRL_BUILD_TEST) 33 | add_subdirectory(test/) 34 | endif() 35 | if(USING_KQUEUE_BACKEND) 36 | message("KQUEUE") 37 | endif() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | libgwrl is Copyright 2012 by Aaron Smith (gngrwzrd@gmail.com) 2 | 3 | -You are free to modify for private studying. 4 | -You are free to use in commercial software. 5 | -You are free to re-distribute modified versions of the source. 6 | -You are free to derive or fork other versions of the source. 7 | -You are not free to re-distribute source or object libraries 8 | under a different license. 9 | 10 | If you release a modified, derived, or forked version, the author 11 | Aaron Smith must be notified by email at gngrwzrd@gmail.com. The 12 | new version must contain the above copyright notice. 13 | 14 | Commercial and non-commercial executable software must contain 15 | the above copyright notice in a user accessible window, help, or 16 | about notice. 17 | 18 | Aaron Smith is not liable for damage resulting from this code. 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | LIBGWRL 2 | 3 | A high performance cross platform event reactor and proactor written in C. 4 | Featuring kqueue, epoll, poll, select, IO Completion Ports for Windows, 5 | and a small code base with minimal #ifdef source splitting. 6 | 7 | WEBSITE 8 | 9 | http://gngrwzrd.com/libgwrl/ 10 | 11 | DOCUMENTATION 12 | 13 | http://gngrwzrd.com/libgwrl/pod.html 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LIBGWRL 2 | 3 | A high performance cross platform event reactor and proactor written in C. 4 | Featuring kqueue, epoll, poll, select, IO Completion Ports for Windows, 5 | and a small code base with minimal #ifdef source splitting. 6 | 7 | # WEBSITE 8 | 9 | http://gngrwzrd.com/libgwrl/ 10 | 11 | # DOCUMENTATION 12 | 13 | http://gngrwzrd.com/libgwrl/pod.html 14 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | -switch *_create to *_new 2 | -test gwpr_synchronous_write_result 3 | -gwrl_del_persistent_timeouts can use pointer to pointer like I did in gwrl_src_del 4 | -gwpr_free on Windows 5 | -valgrind, callgrind 6 | 7 | DOCS: 8 | -Coverage Testing pod 9 | -freeing a proactor 10 | -Making connections pod 11 | 12 | OTHER: 13 | -Need another pair of eyes on windows error logic 14 | 15 | FEATURES: 16 | -sendfile 17 | -linux splice() 18 | -signal sources 19 | -PID sources 20 | -stat sources 21 | -eventfd, signalfd 22 | -devpoll 23 | -eventport 24 | -handle poll/select max fds reached error 25 | -------------------------------------------------------------------------------- /docs/html/cardinal2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/cardinal2.png -------------------------------------------------------------------------------- /docs/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | GWRL - Ginger Wizards Reactor and Proactor 4 | 16 | 17 | 18 |
19 | 20 | 21 | 24 | 53 | 54 |
22 | 23 | 25 |
26 |

LIBGWRL

27 |

28 | A high performance cross platform event reactor and proactor written in C. 29 | Featuring kqueue, epoll, poll, select, IO Completion Ports for Windows, 30 | and a small but elegant code base with minimal #ifdef source splitting. 31 |

32 |
33 |

34 | 35 | Documentation  36 | 37 | Source  38 | Compiling  39 | Code Coverage  40 | License 41 | 42 |

43 |
44 |

WANNA HELP?

45 |

46 | Checkout the issue tracker 47 | on github for outstanding tasks, and the 48 | TODO list for more tasks. 49 |

50 |
51 |

Copyright Aaron Smith 2012

52 |
55 |
56 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /docs/html/pod.css: -------------------------------------------------------------------------------- 1 | body { 2 | color:black; 3 | background:white; 4 | font-family:"Lucida Grande", Verdana, Arial, sans-serif; 5 | margin:1ex; 6 | padding:1ex; 7 | max-width:120ex; 8 | text-align:justify; 9 | } 10 | 11 | img { border: 0; } 12 | form { margin: 0; } 13 | input { margin: 2px; } 14 | 15 | a {color:black;} 16 | a:visited {color:black;} 17 | td {margin:0;padding:0;} 18 | div {border-width:0;} 19 | 20 | div[name=index] { 21 | font-size:85%; 22 | } 23 | 24 | div[name=index] ul li { 25 | margin-bottom:6px; 26 | } 27 | 28 | dt { 29 | margin-top: 0.5ex; 30 | margin-left: 2ex; 31 | margin-bottom: 0.4ex; 32 | padding-bottom: 0; 33 | font-weight: bold; 34 | } 35 | 36 | dd { 37 | margin-left: 4ex; 38 | padding-left: 1em; 39 | margin-right: 2ex; 40 | padding-right: 1ex; 41 | margin-top: 0.4ex; 42 | padding-top: 0.5ex; 43 | margin-bottom: 1em; 44 | padding-bottom: 0.3ex; 45 | border-left: 1px solid #ccccee; 46 | border-bottom: 1px solid #ccccee; 47 | border-collapse: collapse; 48 | } 49 | 50 | dd > p { 51 | margin-left: 0; 52 | padding-left: 0; 53 | margin-top: 0; 54 | padding-top: 0; 55 | margin-bottom: 1ex; 56 | padding-bottom: 0; 57 | } 58 | 59 | code { 60 | color: #006600; 61 | font-family: Andale Mono, monospace; 62 | font-size:12px; 63 | } 64 | 65 | pre { 66 | background: #F0F0F0; 67 | border: 2px solid #DDDDDD; 68 | color: black; 69 | padding-left: 0ex; 70 | padding-top: 1em; 71 | padding-bottom: 1em; 72 | white-space: pre; 73 | font-family: Andale Mono, monospace; 74 | font-size:80%; 75 | width: 120ex; 76 | margin-left:0; 77 | width:100%; 78 | } 79 | 80 | #TOP { 81 | margin-left: 3em; 82 | color: #006699; 83 | margin-top: 2ex; 84 | font-size: 80%; 85 | font-weight: bold; 86 | border: 0; 87 | padding-bottom: 0; 88 | } 89 | 90 | div.pod > ul { 91 | font-size: 80%; 92 | margin-left: 3em; 93 | } 94 | 95 | div.pod > hr { 96 | display: none; 97 | } 98 | 99 | div.pod > ul > li { 100 | font-size: 100%; 101 | font-weight: bold; 102 | } 103 | 104 | div.pod > ul > li > ul > li { 105 | font-size: 100%; 106 | font-weight: normal; 107 | } 108 | 109 | div.pod > ul > li > ul > li > ul > li { 110 | font-size: 40%; 111 | font-weight: normal; 112 | } 113 | 114 | h1 { 115 | margin-top: 5ex; 116 | font-size: 280%; 117 | font-weight: bold; 118 | border-bottom: 2px solid #BBB; 119 | padding-bottom: 0px; 120 | } 121 | 122 | h2 { 123 | font-size: 175%; 124 | margin-top: 3ex; 125 | border-bottom: 2px solid #BBB; 126 | padding-bottom: 0; 127 | } 128 | 129 | h3 { 130 | font-size: 95%; 131 | margin-top: 3ex; 132 | border-bottom: 2px solid #BBB; 133 | padding-bottom: 0; 134 | } 135 | 136 | h4 { 137 | font-size: 80%; 138 | margin-top: 3ex; 139 | border-bottom: 2px solid #BBB; 140 | padding-bottom: 0; 141 | } 142 | 143 | img { 144 | vertical-align: top; 145 | } 146 | 147 | li { 148 | line-height: 1.2em; 149 | list-style-type: none; 150 | } 151 | 152 | a.item { 153 | font-weight:normal; 154 | } 155 | 156 | table { 157 | margin-left: 3em; 158 | margin-top: 1ex; 159 | margin-bottom: 1ex; 160 | border-spacing: 0px; 161 | border-width: 2px; 162 | border-collapse: collapse; 163 | border-color: #88e; 164 | border-style: solid; 165 | } 166 | 167 | td { 168 | padding: 2px 1ex 2px 1ex; 169 | border-width: 2px; 170 | border-color: #88e; 171 | border-style: solid; 172 | } 173 | 174 | hr { 175 | display:none; 176 | border:solid 1px #BBB; 177 | width:100%; 178 | } 179 | -------------------------------------------------------------------------------- /docs/html/proactor_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/proactor_architecture.png -------------------------------------------------------------------------------- /docs/html/proactor_flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/proactor_flowchart.png -------------------------------------------------------------------------------- /docs/html/reactor_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/reactor_architecture.png -------------------------------------------------------------------------------- /docs/html/reactor_flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/reactor_flowchart.png -------------------------------------------------------------------------------- /docs/html/worker_thread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/html/worker_thread.png -------------------------------------------------------------------------------- /docs/lcov/amber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/amber.png -------------------------------------------------------------------------------- /docs/lcov/emerald.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/emerald.png -------------------------------------------------------------------------------- /docs/lcov/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/glass.png -------------------------------------------------------------------------------- /docs/lcov/ruby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/ruby.png -------------------------------------------------------------------------------- /docs/lcov/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/snow.png -------------------------------------------------------------------------------- /docs/lcov/test/proactor_buf.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_buf.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_buf.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1515100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:71450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main27
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_buf.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_buf.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_buf.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1515100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:71450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main27
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_gwprwrq_get.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_gwprwrq_get.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_gwprwrq_get.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1515100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:2450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main22
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_gwprwrq_get.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_gwprwrq_get.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_gwprwrq_get.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1515100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:2450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main22
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_mem_errors.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_mem_errors.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_mem_errors.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-09-25Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main23
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_mem_errors.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_mem_errors.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_mem_errors.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-09-25Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main23
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_wrq.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_wrq.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_wrq.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:5656100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:316250.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main19
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/proactor_wrq.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/proactor_wrq.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - proactor_wrq.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:5656100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:316250.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main19
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_del_pers_timeouts2.c.gcov.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_del_pers_timeouts2.c 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_del_pers_timeouts2.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1313100.0 %
Date:2012-10-17Functions:33100.0 %
Branches:00-
58 |
63 | 64 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_events.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_events.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_events.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:2929100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:111861.1 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main16
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_events.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_events.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_events.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:2929100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:111861.1 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main16
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_free1.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_free1.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_free1.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
timeout15
main15
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_free1.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_free1.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_free1.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
main15
timeout15
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_free4.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_free4.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_free4.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
timeout12
main12
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_free4.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_free4.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_free4.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:99100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
main12
timeout12
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_gatherfunc.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_gatherfunc.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_gatherfunc.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1717100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:4850.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
custom_gather22
main11
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_gatherfunc.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_gatherfunc.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_gatherfunc.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1717100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:4850.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
custom_gather22
main11
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_mem_errors.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_mem_errors.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_mem_errors.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:2121100.0 %
Date:2012-09-25Functions:11100.0 %
Branches:3650.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main10
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_mem_errors.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_mem_errors.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_mem_errors.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:2121100.0 %
Date:2012-09-25Functions:11100.0 %
Branches:3650.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main10
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_no_sleep.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_no_sleep.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_no_sleep.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:88100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main10
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_no_sleep.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_no_sleep.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_no_sleep.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:88100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main10
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_options.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_options.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_options.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1717100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:2450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main9
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_options.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_options.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_options.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1717100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:2450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main9
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_safely.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_safely.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_safely.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:3232100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:5862.5 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
event8
main8
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_safely.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_safely.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_safely.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:3232100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:5862.5 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
event8
main8
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_src.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_src.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_src.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:4343100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:122450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main7
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_src.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_src.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_src.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:4343100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:122450.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main7
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_timeout_rearm.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_timeout_rearm.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_timeout_rearm.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1313100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
timeout160
main6
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_timeout_rearm.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_timeout_rearm.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_timeout_rearm.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1313100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
main6
timeout160
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/reactor_timer_interval.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/reactor_timer_interval.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - reactor_timer_interval.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:1111100.0 %
Date:2012-10-17Functions:22100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

Function Name Sort by function nameHit count Sort by hit count
interval50
main5
80 |
81 |
82 | 83 | 84 | 85 |
Generated by: LCOV version 1.9
86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/lcov/test/time_fncs.c.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/time_fncs.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - time_fncs.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:6464100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:193850.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main1
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/test/time_fncs.c.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - test/time_fncs.c - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - test - time_fncs.c (source / functions)HitTotalCoverage
Test:lcov1.infoLines:6464100.0 %
Date:2012-10-17Functions:11100.0 %
Branches:193850.0 %
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
main1
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/updown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/docs/lcov/updown.png -------------------------------------------------------------------------------- /docs/lcov/usr/include/secure/_string.h.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov0.info - /usr/include/secure/_string.h - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - usr/include/secure - _string.h (source / functions)HitTotalCoverage
Test:lcov0.infoLines:22100.0 %
Date:2012-09-24Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
__inline_memcpy_chk446
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/usr/include/secure/_string.h.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov0.info - /usr/include/secure/_string.h - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - usr/include/secure - _string.h (source / functions)HitTotalCoverage
Test:lcov0.infoLines:22100.0 %
Date:2012-09-24Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
__inline_memcpy_chk446
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/usr/include/sys/_structs.h.func-sort-c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - /usr/include/sys/_structs.h - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - usr/include/sys - _structs.h (source / functions)HitTotalCoverage
Test:lcov1.infoLines:22100.0 %
Date:2012-10-02Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
__darwin_fd_isset1371
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/lcov/usr/include/sys/_structs.h.func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LCOV - lcov1.info - /usr/include/sys/_structs.h - functions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
LCOV - code coverage report
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 |
Current view:top level - usr/include/sys - _structs.h (source / functions)HitTotalCoverage
Test:lcov1.infoLines:22100.0 %
Date:2012-10-02Functions:11100.0 %
Branches:00-
58 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

Function Name Sort by function nameHit count Sort by hit count
__darwin_fd_isset1371
76 |
77 |
78 | 79 | 80 | 81 |
Generated by: LCOV version 1.9
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/pod/pod2htmd.tmp: -------------------------------------------------------------------------------- 1 | 2 | . 3 | -------------------------------------------------------------------------------- /docs/pod/pod2htmi.tmp: -------------------------------------------------------------------------------- 1 | 2 | . 3 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${gwrl_BINARY_DIR}") 2 | include_directories("${gwrl_SOURCE_DIR}/src") 3 | 4 | if(NOT PLATFORM_WINDOWS) 5 | add_executable(reactor_echo reactor_echo.c) 6 | target_link_libraries(reactor_echo gwrl) 7 | endif() 8 | 9 | add_executable(proactor_echo proactor_echo.c) 10 | target_link_libraries(proactor_echo gwrl) 11 | -------------------------------------------------------------------------------- /examples/reactor_echo.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | #define MAXLINE 1024 5 | 6 | char * mode; 7 | char * node; 8 | char * service; 9 | char * protocol; 10 | bool istcp; 11 | bool isserver; 12 | 13 | gwrl * rl = NULL; 14 | skctlinfo sockcntl; 15 | 16 | int c = 0; 17 | gwrlsrc * intsrc = NULL; 18 | 19 | void interval_test(gwrl * rl, gwrlevt* evt) { 20 | //printf("interval_test\n"); 21 | if(c == 10) gwrl_src_del(rl,intsrc,NULL,true); 22 | c++; 23 | } 24 | 25 | void client_socket_activity(gwrl * rl, gwrlevt * evt) { 26 | printf("client_socket_activity\n"); 27 | if(evt->flags & GWRL_RD) { 28 | printf("GWRL_RD\n"); 29 | char buf[MAXLINE]; 30 | int amnt = read(evt->fd,buf,MAXLINE-1); 31 | if(amnt <= 0) { 32 | printf("disconnected\n"); 33 | if(errno == ECONNRESET) { 34 | printf("ECONNRESET\n"); 35 | } 36 | if(errno == ENOTCONN) { 37 | printf("ENOTCONN\n"); 38 | } 39 | if(errno == ETIMEDOUT) { 40 | printf("ETIMEDOUT\n"); 41 | } 42 | //shutdown(evt->fd,SHUT_RDWR); 43 | printf("closing fd: %i\n",evt->fd); 44 | close(evt->fd); 45 | gwrl_src_del(rl,evt->src,NULL,true); 46 | return; 47 | } 48 | write(evt->fd,buf,amnt); 49 | } 50 | else if(evt->flags & GWRL_WR) { 51 | printf("GWRL_WR!\n"); 52 | } else { 53 | printf("!!!!!!!!!!!!!!!\n"); 54 | } 55 | } 56 | 57 | void server_socket_activity(gwrl * rl, gwrlevt * evt) { 58 | printf("server_socket_activity\n"); 59 | if(evt->flags & GWRL_RD) { 60 | printf("GWRL_RD\n"); 61 | if(istcp) { 62 | struct sockaddr_storage sockaddr; 63 | socklen_t clsize = sizeof(sockaddr); 64 | int clientfd = gwsk_accept(evt->fd,&sockaddr,&clsize); 65 | gwrl_set_fd(rl,clientfd,GWRL_RD,&client_socket_activity,NULL); 66 | } else { 67 | char buf[MAXLINE]; 68 | struct sockaddr_storage sockaddr; 69 | socklen_t socklen = sizeof(sockaddr); 70 | int res = recvfrom(evt->fd,buf,MAXLINE-1,0,(struct sockaddr *)&sockaddr,&socklen); 71 | if(res > 0) { 72 | gwsk_sockaddr_print(&sockaddr); 73 | int res2 = sendto(evt->fd,buf,res,0,(struct sockaddr *)&sockaddr,socklen); 74 | if(res2 < 0) { 75 | gwprintsyserr("sendto error",errno) 76 | } 77 | } else { 78 | gwprintsyserr("recvfrom error",errno) 79 | } 80 | } 81 | } else { 82 | printf("GWRL_BADF!!!!!!!!!!!!!!!!!!!!!!!\n"); 83 | } 84 | } 85 | 86 | void setup_server() { 87 | sockcntl.node = NULL; 88 | sockcntl.service = service; 89 | sockcntl.flags |= SKCTL_NOBLOCK; 90 | sockcntl.hints.ai_family = AF_UNSPEC; 91 | sockcntl.hints.ai_flags = AI_PASSIVE; 92 | 93 | if(istcp) { 94 | sockcntl.hints.ai_protocol = IPPROTO_TCP; 95 | sockcntl.hints.ai_socktype = SOCK_STREAM; 96 | sockcntl.flags |= SKCTL_TCP_SERVER|SKCTL_PRINTADDR; 97 | } else { 98 | sockcntl.hints.ai_protocol = IPPROTO_UDP; 99 | sockcntl.hints.ai_socktype = SOCK_DGRAM; 100 | sockcntl.flags |= SKCTL_UDP_SERVER|SKCTL_PRINTADDR; 101 | } 102 | 103 | if(skctl(&sockcntl) < 0) exit(0); 104 | gwrl_set_fd(rl,sockcntl.sockfd,GWRL_RD,&server_socket_activity,NULL); 105 | } 106 | 107 | void setup_socket() { 108 | if(strcmp(mode,"s") == 0) setup_server(); 109 | intsrc = gwrl_set_interval(rl,1000,&interval_test,NULL); 110 | } 111 | 112 | int main(int argc, char ** argv) { 113 | if(argc < 5) { 114 | printf("usage: echo c|s tcp|udp host|ip port|service\n"); 115 | exit(0); 116 | } 117 | 118 | mode = argv[1]; 119 | protocol = argv[2]; 120 | node = argv[3]; 121 | service = argv[4]; 122 | istcp = (strcmp(protocol,"tcp") == 0); 123 | isserver = (strcmp(mode,"s") == 0); 124 | printf("%s %s %s %s %s\n",argv[0],argv[1],argv[2],argv[3],argv[4]); 125 | 126 | rl = gwrl_create(); 127 | gwrl_post_function(rl,&setup_socket,NULL); 128 | gwrl_run(rl); 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ../../scripts/runtests.py -s ./ -g ../gcov_files/$1/ -t ./test/ -x ../../scripts/ 3 | ../../scripts/lcov.py -g ../gcov_files/ -o ../../docs/lcov -r _OSByteOrder.h -r _string.h 4 | -------------------------------------------------------------------------------- /scripts/coverage_clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ../../scripts/runtest.py -s ./ -d 1 3 | rm -rf ../gcov_files/ -------------------------------------------------------------------------------- /scripts/lcov.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import subprocess,argparse 3 | parser = argparse.ArgumentParser("Generate the lcov html files.") 4 | parser.add_argument("-g","--gcovbasedir",type=str,dest="gcovbasedir",help="Set the base directory where all gcov files are.") 5 | parser.add_argument("-o","--output",type=str,dest="output",help="Set the output directory where html will be generated.") 6 | parser.add_argument("-r","--remove",type=str,dest="remove",action="append",help="Set one or more patters to remove from the generate lcov html.") 7 | args = parser.parse_args() 8 | gcovbasedir = args.gcovbasedir 9 | output = args.output 10 | remove = args.remove 11 | lcov_info = "%s/lcov.info" % output 12 | if remove: 13 | subprocess.call(["geninfo","-o",lcov_info,gcovbasedir]) 14 | lcov_file_in = "lcov.info" 15 | for i in range(0,len(remove)): 16 | lcov_file_out = "lcov%i.info" % (i) 17 | subprocess.call(["lcov","-o","%s/%s"%(output,lcov_file_out),"-r","%s/%s"%(output,lcov_file_in),remove[i]]) 18 | lcov_file_in = lcov_file_out 19 | subprocess.call(["genhtml","-o",output,"%s/%s"%(output,lcov_file_out)]) 20 | else: 21 | subprocess.call(["geninfo","-o",lcov_info,gcovbasedir]) 22 | subprocess.call(["genhtml","-o",output,lcov_info]) 23 | -------------------------------------------------------------------------------- /scripts/pod.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pod2html ../../docs/pod/doc.pod --css=pod.css > ../../docs/html/pod.html -------------------------------------------------------------------------------- /scripts/runtest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | This script is used to execute one test, then copy all gcno and gcda 4 | files into a folder. The gcov files are seperated into specific folders 5 | for lcov generation later. Because each test only covers a small amount 6 | of code, all these tests need to be combined by lcov later. 7 | """ 8 | import glob, subprocess, sys, os, fnmatch, shutil, argparse, re 9 | def recursive_glob(rootdir='.', pattern='*'): 10 | return [os.path.join(rootdir, filename) 11 | for rootdir, dirnames, filenames in os.walk(rootdir) 12 | for filename in filenames 13 | if fnmatch.fnmatch(filename, pattern)] 14 | parser = argparse.ArgumentParser(description="Run a test executable and gather gcov (gcno,gcda) files afterwords.") 15 | parser.add_argument("-s",'--searchdir',dest="searchdir",type=str,help="The directory to recursively search for gcno and gcda files.") 16 | parser.add_argument("-i","--ignoredir",dest="ignoredirs",type=str,action="append",help="Directories with gcno or gcda files to ignore.") 17 | parser.add_argument("-g",'--gcovdir',dest="gcovdir",type=str,help="The directory to store discovered gcov files.") 18 | parser.add_argument("-e","--execfile",dest="execfile",type=str,help="The test executable to run.") 19 | parser.add_argument("-a","--execargs",nargs="*",dest="execargs",type=str,help="The test executable arguments") 20 | parser.add_argument("-d",dest="delgcov",type=bool,help="Delete discovered gcov files instead of copying.") 21 | parser.add_argument("-p",dest="printlogs",type=bool,help="Print some debug logs for this script.") 22 | args = parser.parse_args() 23 | gcovdir = args.gcovdir 24 | searchdir = args.searchdir 25 | ignoredirs = args.ignoredirs or [] 26 | executable = args.execfile 27 | execargs = args.execargs 28 | delgcov = args.delgcov 29 | printlogs = args.printlogs 30 | if executable: 31 | cmd = [executable] 32 | if execargs: cmd.extend(execargs) 33 | print " ".join(cmd) 34 | subprocess.call(cmd) 35 | if gcovdir: 36 | try: os.makedirs(gcovdir) 37 | except: pass 38 | gcno = recursive_glob(rootdir=searchdir,pattern="*.gcno") 39 | gcda = recursive_glob(rootdir=searchdir,pattern="*.gcda") 40 | def copy_to_gcov(f): 41 | global delgcov, gcovdir, searchdir, printlogs, ignoredirs 42 | fl = f.split("/")[-1] 43 | for i in range(0,len(ignoredirs)): 44 | if(re.match(ignoredirs[i],f)): 45 | if printlogs: print "ignoring %s" % (f) 46 | return 47 | if printlogs: print f 48 | if delgcov: 49 | if printlogs: print "deleting: %s" % (f) 50 | os.remove(f) 51 | else: 52 | if os.path.exists("%s/%s" % (gcovdir,fl)): 53 | if printlogs: 54 | print f 55 | print "exists: %s/%s" % (gcovdir,fl) 56 | print "" 57 | try: shutil.copy2(f,gcovdir) 58 | except: pass 59 | if printlogs: print "" 60 | for f in gcno: copy_to_gcov(f) 61 | for f in gcda: copy_to_gcov(f) 62 | -------------------------------------------------------------------------------- /scripts/runtests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import subprocess,argparse 3 | parser = argparse.ArgumentParser(description="Run all tests gathering gcov data into seperate folders for each test.") 4 | parser.add_argument("-x","--scriptsdir",dest="scriptsdir",type=str,help="Set the scripts directory path.") 5 | parser.add_argument("-s","--searchdir",dest="searchdir",type=str,help="Set the base directory for gcov file searching.") 6 | parser.add_argument("-g","--gcovdir",dest="gcovdir",type=str,help="Set the base directory to save gcov data in.") 7 | parser.add_argument("-t","--testdir",dest="testdir",type=str,help="Set the test directory path.") 8 | args = parser.parse_args() 9 | scriptsdir = args.scriptsdir 10 | searchdir = args.searchdir 11 | gcovdir = args.gcovdir 12 | testdir = args.testdir 13 | tests = [] 14 | 15 | def add_test(testname): 16 | global tests,basedir,gcovdir 17 | tests.append([ 18 | "%sruntest.py" % (scriptsdir), 19 | "-s","%s" % (searchdir), 20 | "-i","%ssrc/gwrl/CMakeFiles/gwrl_dyld.dir/" % (searchdir), 21 | "-g","%s%s/" % (gcovdir,testname), 22 | "-e","%s%s" % (testdir,testname), 23 | ]) 24 | 25 | #add_test("proactor_thread_specific_nix") 26 | 27 | add_test("proactor_buf") 28 | add_test("proactor_cb") 29 | add_test("proactor_filters") 30 | add_test("proactor_free1") 31 | add_test("proactor_gwpr_src_activity_write_qitem_result") 32 | add_test("proactor_gwprwrq_get"); 33 | add_test("proactor_src") 34 | add_test("proactor_tcp") 35 | #add_test("proactor_udp") 36 | add_test("proactor_wrq") 37 | add_test("reactor_custom_gathering") 38 | add_test("reactor_pers_timeouts") 39 | add_test("reactor_events") 40 | add_test("reactor_free1") 41 | add_test("reactor_free2") 42 | add_test("reactor_free3") 43 | add_test("reactor_free4") 44 | add_test("reactor_gatherfunc") 45 | add_test("reactor_no_sleep") 46 | add_test("reactor_options") 47 | add_test("reactor_safely") 48 | add_test("reactor_src") 49 | add_test("reactor_timeout_rearm") 50 | add_test("reactor_timer_interval") 51 | add_test("reactor_timers") 52 | add_test("reactor_wake_pipe") 53 | add_test("reactor_wake_reinit") 54 | add_test("time_fncs") 55 | for i in range(0,len(tests)): subprocess.call(tests[i]) 56 | -------------------------------------------------------------------------------- /src/gwrl/._shared_config.h.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gngrwzrd/libgwrl/900b7ecbeb90a4a729c20bf40dc7d5bb35d92190/src/gwrl/._shared_config.h.in -------------------------------------------------------------------------------- /src/gwrl/event_iocp.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | typedef struct gwrlbkd_iocp { 5 | gwrlbkd _; 6 | fileid_t iocp; 7 | bool (*AcceptEx)(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED); 8 | bool (*ConnectEx)(SOCKET,struct sockaddr *,int,PVOID,DWORD,LPDWORD,LPOVERLAPPED); 9 | } gwrlbkd_iocp; 10 | 11 | #define _gwrlbkdi(o) ((gwrlbkd_iocp *)o) 12 | #define _gwprovlp(o) ((gwpr_ovlp *)o) 13 | 14 | #define PRINT_ERROR_FM(res,compare,chk,err,ret,fre)\ 15 | if(res compare chk) {\ 16 | LPSTR msg;\ 17 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER,0,err,0,(LPSTR)&msg,0,0);\ 18 | fprintf(stderr,"IOCP Backend Init Error(%i): %s\n",err,msg);\ 19 | LocalFree(msg);\ 20 | if(fre) free(fre);\ 21 | return ret;\ 22 | }\ 23 | 24 | -------------------------------------------------------------------------------- /src/gwrl/event_wake_pipe.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void gwrl_wake(gwrl * rl) { 5 | if(flisset(rl->flags,GWRL_SLEEPING)) { 6 | ssize_t res = 0; 7 | while(1) { 8 | res = write(rl->fds[1],"wake",4); 9 | #ifndef GWRL_HIDE_FROM_COVERAGE 10 | if(res < 0 && errno == EINTR) { 11 | continue; 12 | } 13 | #endif 14 | break; 15 | } 16 | } 17 | } 18 | 19 | void gwrl_wake_init(gwrl * rl) { 20 | gwrlsrc * fsrc = NULL; 21 | 22 | #ifdef GWRL_HIDE_FROM_COVERAGE 23 | pipe((int *)rl->fds); 24 | #endif 25 | 26 | #ifndef GWRL_HIDE_FROM_COVERAGE 27 | int res = pipe((int *)rl->fds); 28 | while(res < 0) { 29 | pipe((int *)rl->fds); 30 | gwprintsyserr("(3FG9D) pipe error",errno); 31 | } 32 | #endif 33 | 34 | fcntl(rl->fds[0],F_SETFL,O_NONBLOCK); 35 | fcntl(rl->fds[1],F_SETFL,O_NONBLOCK); 36 | fsrc = gwrl_src_file_create((fileid_t)rl->fds[0],GWRL_RD,&gwrl_wake_activity,NULL); 37 | 38 | #ifndef GWRL_HIDE_FROM_COVERAGE 39 | if(!fsrc) { 40 | gwerr("(3FDli) gwrl_wake_init couldn't create file input source"); 41 | return; 42 | } 43 | #endif 44 | 45 | gwrl_src_add(rl,fsrc); 46 | } 47 | 48 | void gwrl_wake_free(gwrl * rl) { 49 | close((int)rl->fds[0]); 50 | close((int)rl->fds[1]); 51 | } 52 | 53 | void gwrl_wake_activity(gwrl * rl, gwrlevt * evt) { 54 | int res = 0; 55 | bool reinit = false; 56 | if(flisset(evt->flags,GWRL_RD)) { 57 | char buf[4]; 58 | while(1) { 59 | res = read(evt->fd,buf,4); 60 | 61 | if(res > 0) { 62 | continue; 63 | } 64 | 65 | if(res <= 0 && errno != EAGAIN && errno != EWOULDBLOCK) { 66 | reinit = true; 67 | } 68 | 69 | break; 70 | } 71 | if(reinit) { 72 | #ifdef GWRL_COVERAGE_INTERNAL_ASSERT_VARS 73 | if(asserts_var1 == gwrl_assert_wake_reinit) { 74 | asserts_var2 = true; 75 | } 76 | #endif 77 | 78 | close(rl->fds[0]); 79 | close(rl->fds[1]); 80 | gwrl_src_del(rl,evt->src,NULL,true); 81 | gwrl_wake_init(rl); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/gwrl/gettimeofday.c: -------------------------------------------------------------------------------- 1 | 2 | //http://suacommunity.com/dictionary/gettimeofday-entry.php 3 | 4 | #include 5 | #include 6 | 7 | #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) 8 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 9 | #else 10 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 11 | #endif 12 | 13 | struct timezone { 14 | int tz_minuteswest; /* minutes W of Greenwich */ 15 | int tz_dsttime; /* type of dst correction */ 16 | }; 17 | 18 | int gettimeofday(struct timeval * tv, struct timezone * tz) { 19 | //define a structure to receive the current Windows filetime 20 | FILETIME ft; 21 | 22 | //initialize the present time to 0 and the timezone to UTC 23 | unsigned __int64 tmpres = 0; 24 | static int tzflag = 0; 25 | 26 | if(NULL != tv) { 27 | GetSystemTimeAsFileTime(&ft); 28 | tmpres |= ft.dwHighDateTime; 29 | tmpres <<= 32; 30 | tmpres |= ft.dwLowDateTime; 31 | tmpres /= 10; 32 | tmpres -= DELTA_EPOCH_IN_MICROSECS; 33 | tv->tv_sec = (long)(tmpres / 1000000UL); 34 | tv->tv_usec = (long)(tmpres % 1000000UL); 35 | } 36 | 37 | if(NULL != tz) { 38 | long tzdiff; 39 | int tzdaylight; 40 | if(!tzflag) { 41 | _tzset(); 42 | tzflag++; 43 | } 44 | //Adjust for the timezone west of Greenwich 45 | _get_timezone(&tzdiff); 46 | _get_daylight(&tzdaylight); 47 | //tz->tz_minuteswest = _timezone / 60; 48 | //tz->tz_dsttime = _daylight; 49 | tz->tz_minuteswest = tzdiff / 60; 50 | tz->tz_dsttime = tzdaylight; 51 | } 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/gwrl/lock.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/lock.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void 9 | lockid_init(lockid_t * lk) { 10 | #if defined(PLATFORM_WINDOWS) 11 | InitializeCriticalSection((LPCRITICAL_SECTION)lk); 12 | #elif defined(PLATFORM_LINUX) 13 | pthread_spin_init(lk,PTHREAD_PROCESS_PRIVATE); 14 | #endif 15 | } 16 | 17 | void 18 | lockid_lock(lockid_t * lk) { 19 | #if defined(PLATFORM_DARWIN) 20 | OSSpinLockLock(lk); 21 | #elif defined(PLATFORM_WINDOWS) 22 | EnterCriticalSection((LPCRITICAL_SECTION)lk); 23 | #elif defined(PLATFORM_LINUX) 24 | pthread_spin_lock(lk); 25 | #endif 26 | } 27 | 28 | void 29 | lockid_unlock(lockid_t * lk) { 30 | #if defined(PLATFORM_DARWIN) 31 | OSSpinLockUnlock(lk); 32 | #elif defined(PLATFORM_WINDOWS) 33 | LeaveCriticalSection((LPCRITICAL_SECTION)lk); 34 | #elif defined(PLATFORM_LINUX) 35 | pthread_spin_unlock(lk); 36 | #endif 37 | } 38 | 39 | void 40 | lockid_free(lockid_t * lk) { 41 | #if defined(PLATFORM_WINDOWS) 42 | DeleteCriticalSection((LPCRITICAL_SECTION)lk); 43 | #elif defined(PLATFORM_LINUX) 44 | pthread_spin_destroy(lk); 45 | #endif 46 | } 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/gwrl/lock.h: -------------------------------------------------------------------------------- 1 | 2 | #define INCLUDE_PTHREAD 3 | #define INCLUDE_WINDOWS 4 | #define INCLUDE_LIBKERN_OSATOMIC 5 | #include "gwrl/shared_config.h" 6 | #include "gwrl/shared_include.h" 7 | #include "gwrl/shared_types.h" 8 | 9 | //define the lockid_t type. 10 | #if defined(PLATFORM_DARWIN) 11 | typedef OSSpinLock lockid_t; 12 | #elif defined(PLATFORM_WINDOWS) 13 | typedef CRITICAL_SECTION lockid_t; 14 | #elif defined(PLATFORM_LINUX) 15 | typedef pthread_spinlock_t lockid_t; 16 | #endif 17 | 18 | void lockid_init(lockid_t * lk); 19 | void lockid_lock(lockid_t * lk); 20 | void lockid_unlock(lockid_t * lk); 21 | void lockid_free(lockid_t * lk); -------------------------------------------------------------------------------- /src/gwrl/proactor_imp.h: -------------------------------------------------------------------------------- 1 | 2 | //proactor 3 | typedef struct gwpr { 4 | size_t nwrqcache; 5 | struct gwpr_options options; 6 | gwrl * rl; 7 | gwprbufctl * bufctl; 8 | struct gwprwrq * wrqcache; 9 | } gwpr; 10 | 11 | //write queue 12 | typedef struct gwprwrq { 13 | socklen_t peerlen; 14 | gwpr_io_op_id wrop; 15 | struct sockaddr_storage peer; 16 | gwprbuf * buf; 17 | struct gwprwrq * next; 18 | } gwprwrq; 19 | 20 | //proactor data for each gwrlsrc_file 21 | typedef struct gwprdata { 22 | size_t rdbufsize; 23 | gwpr_io_op_id rdop; 24 | struct gwprwrq * wrq; 25 | struct gwprwrq * wrqlast; 26 | gwpr_io_cb ** rdfilters; 27 | gwpr_io_cb ** wrfilters; 28 | gwpr_io_cb * acceptcb; 29 | gwpr_io_cb * connectcb; 30 | gwpr_io_cb * closedcb; 31 | gwpr_io_cb * didreadcb; 32 | gwpr_io_cb * didwritecb; 33 | gwpr_error_cb * errorcb; 34 | } gwprdata; 35 | 36 | gwprwrq * gwprwrq_get(gwpr * pr, gwrlsrc_file * fsrc); 37 | void gwprwrq_free(gwpr * pr, gwrlsrc_file * fsrc, gwprwrq * wrq); 38 | void gwprwrq_add(gwpr * pr, gwrlsrc_file * fsrc, gwprwrq * wrq); 39 | void gwprwrq_putback(gwpr * pr, gwrlsrc_file * fsrc, gwprwrq * q); 40 | void io_activity(gwpr * pr, gwpr_io_info * info); 41 | void gwpr_src_activity(gwrl * rl, gwrlevt * evt); 42 | void gwpr_write_buffer(gwpr * pr, gwrlsrc * src, gwprbuf * buf, 43 | gwpr_io_op_id op, struct sockaddr_storage * peer, socklen_t peerlen, 44 | size_t * written, int * errnm); 45 | bool gwpr_synchronous_write(gwpr * pr, gwrlsrc * src, gwprbuf * buf, gwpr_io_op_id op, struct sockaddr_storage * peer, socklen_t peerlen); 46 | void gwpr_asynchronous_write(gwpr * pr, gwrlsrc * src, gwprbuf * buf, gwpr_io_op_id op, struct sockaddr_storage * peer, socklen_t peerlen); 47 | int gwpr_asynchronous_read(gwpr * pr, gwrlsrc * src, size_t bufsize, gwpr_io_op_id op); 48 | void gwprwrq_free_list_no_cache(gwpr * pr, gwprwrq * wrq); 49 | -------------------------------------------------------------------------------- /src/gwrl/proactor_imp_iocp.h: -------------------------------------------------------------------------------- 1 | 2 | //forwards 3 | struct gwpr_ovlp; 4 | 5 | //op codes for overlap structures with iocp. only used internally. 6 | typedef enum gwpr_ovlp_op { 7 | gwpr_ovlp_op_wake, 8 | gwpr_ovlp_op_accept, 9 | gwpr_ovlp_op_connect, 10 | gwpr_ovlp_op_read, 11 | gwpr_ovlp_op_recv, 12 | gwpr_ovlp_op_recvfrom, 13 | gwpr_ovlp_op_write, 14 | gwpr_ovlp_op_send, 15 | gwpr_ovlp_op_sendto 16 | } gwpr_ovlp_op; 17 | 18 | //proactor 19 | typedef struct gwpr { 20 | size_t novlpcache; 21 | gwrl * rl; 22 | gwprbufctl * bufctl; 23 | struct gwpr_ovlp * ovlpcache; 24 | struct gwpr_options options; 25 | } gwpr; 26 | 27 | //overlapped io for completion port 28 | typedef struct gwpr_ovlp { 29 | OVERLAPPED _; 30 | uint8_t op; 31 | gwpr * pr; 32 | gwrlsrc_file * src; 33 | gwprbuf * buf; 34 | WSABUF wsabuf; 35 | socklen_t peerlen; 36 | struct sockaddr_storage peer; 37 | fileid_t acceptsock; 38 | struct gwpr_ovlp * next; 39 | } gwpr_ovlp; 40 | 41 | //proactor data for each gwrlsrc_file 42 | typedef struct gwprdata { 43 | int accept_count; 44 | size_t rdbufsize; 45 | gwprbuf * rdbuf; 46 | gwpr_io_cb ** rdfilters; 47 | gwpr_io_cb ** wrfilters; 48 | gwpr_ovlp * rdovlp; 49 | gwpr_io_cb * acceptcb; 50 | gwpr_io_cb * connectcb; 51 | gwpr_io_cb * closedcb; 52 | gwpr_io_cb * didreadcb; 53 | gwpr_io_cb * didwritecb; 54 | gwpr_error_cb * errorcb; 55 | } gwprdata; 56 | 57 | gwpr_ovlp * gwpr_ovlp_get(gwpr * pr); 58 | void gwpr_ovlp_free(gwpr * pr, gwpr_ovlp * ovlp); 59 | int gwpr_asynchronous_read(gwpr * pr, gwrlsrc_file * fsrc, gwprbuf * buf, gwpr_ovlp_op op); 60 | int gwpr_asynchronous_write(gwpr * pr, gwrlsrc_file * fsrc, gwprbuf * buf, struct sockaddr_storage * peer, socklen_t peerlen, gwpr_ovlp_op op); -------------------------------------------------------------------------------- /src/gwrl/shared_config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef GW_SHARED_CONFIG_H 2 | #define GW_SHARED_CONFIG_H 3 | 4 | //machine order 5 | #define BIG_ENDIAN ${BIG_ENDIAN} 6 | 7 | //platform 8 | #cmakedefine PLATFORM_DARWIN 9 | #cmakedefine PLATFORM_LINUX 10 | #cmakedefine PLATFORM_FREEBSD 11 | #cmakedefine PLATFORM_SUN 12 | #cmakedefine PLATFORM_WINDOWS 13 | 14 | //headers 15 | #cmakedefine HAVE_ASSERT_H 16 | #cmakedefine HAVE_ERRNO_H 17 | #cmakedefine HAVE_FCNTL_H 18 | #cmakedefine HAVE_LIMITS_H 19 | #cmakedefine HAVE_MATH_H 20 | #cmakedefine HAVE_STDBOOL_H 21 | #cmakedefine HAVE_STDINT_H 22 | #cmakedefine HAVE_STDIO_H 23 | #cmakedefine HAVE_STDLIB_H 24 | #cmakedefine HAVE_STRING_H 25 | #cmakedefine HAVE_STRINGS_H 26 | #cmakedefine HAVE_TIME_H 27 | #cmakedefine HAVE_SYS_TIME_H 28 | #cmakedefine HAVE_SYS_TYPES_H 29 | #cmakedefine HAVE_SYS_UIO_H 30 | #cmakedefine HAVE_UNISTD_H 31 | #cmakedefine HAVE_ARPA_INET_H 32 | #cmakedefine HAVE_NETINET_IN_H 33 | #cmakedefine HAVE_NET_ROUTE_H 34 | #cmakedefine HAVE_NETDB_H 35 | #cmakedefine HAVE_SYS_SOCKET_H 36 | #cmakedefine HAVE_SYS_SYSCTL_H 37 | #cmakedefine HAVE_WINBASE_H 38 | #cmakedefine HAVE_WINDOWS_H 39 | #cmakedefine HAVE_WINSOCK2_H 40 | #cmakedefine HAVE_PTHREAD_H 41 | 42 | //types 43 | #cmakedefine HAVE_BOOL 44 | #cmakedefine HAVE_SIZE_T 45 | #cmakedefine HAVE_SSIZE_T 46 | #cmakedefine HAVE_INT8_T 47 | #cmakedefine HAVE_INT16_T 48 | #cmakedefine HAVE_INT32_T 49 | #cmakedefine HAVE_INT64_T 50 | #cmakedefine HAVE_UINT8_T 51 | #cmakedefine HAVE_UINT16_T 52 | #cmakedefine HAVE_UINT32_T 53 | #cmakedefine HAVE_UINT64_T 54 | #cmakedefine HAVE_SOCKLEN_T 55 | #cmakedefine HAVE__SOCKLEN_T 56 | #cmakedefine HAVE_SA_FAMILY_T 57 | #cmakedefine HAVE__SA_FAMILY_T 58 | #cmakedefine HAVE_WS_ADDRESS_FAMILY 59 | 60 | //structures 61 | #cmakedefine HAVE_STRUCT_TIMEVAL 62 | #cmakedefine HAVE_STRUCT_TIMESPEC 63 | #cmakedefine HAVE_STRUCT_SOCKADDR_STORAGE 64 | 65 | //functions or macros 66 | #cmakedefine HAVE_FCNTL 67 | #cmakedefine HAVE_KQUEUE 68 | #cmakedefine HAVE_EPOLL 69 | #cmakedefine HAVE_POLL 70 | #cmakedefine HAVE_SELECT 71 | #cmakedefine HAVE_SYSCTL 72 | #cmakedefine HAVE_BZERO 73 | #cmakedefine HAVE_GETTIMEOFDAY 74 | 75 | //whether or not a backend was found in configure 76 | #cmakedefine HAVE_BACKEND 77 | 78 | //backends 79 | #cmakedefine GWRL_KQUEUE_KEVENT_COUNT @GWRL_KQUEUE_KEVENT_COUNT@ 80 | #cmakedefine GWRL_EPOLL_EVENT_COUNT @GWRL_EPOLL_EVENT_COUNT@ 81 | #cmakedefine GWRL_POLLFD_COUNT @GWRL_POLLFD_COUNT@ 82 | #cmakedefine KQUEUE_BACKEND 83 | #cmakedefine USING_KQUEUE_BACKEND 84 | #cmakedefine EPOLL_BACKEND 85 | #cmakedefine USING_EPOLL_BACKEND 86 | #cmakedefine POLL_BACKEND 87 | #cmakedefine USING_POLL_BACKEND 88 | #cmakedefine SELECT_BACKEND 89 | #cmakedefine USING_SELECT_BACKEND 90 | #cmakedefine IOCP_BACKEND 91 | #cmakedefine USING_IOCP_BACKEND 92 | 93 | //reactor 94 | #cmakedefine GWRL_SRC_TYPES_COUNT @GWRL_SRC_TYPES_COUNT@ 95 | #cmakedefine GWRL_EVENT_CACHE_MAX @GWRL_EVENT_CACHE_MAX@ 96 | #cmakedefine GWRL_GATHER_FUNCS_MAX @GWRL_GATHER_FUNCS_MAX@ 97 | #cmakedefine GWRL_REDISPATCH_MAX @GWRL_REDISPATCH_MAX@ 98 | 99 | //proactor 100 | #cmakedefine GWPR_WRQUEUE_CACHE_MAX @GWPR_WRQUEUE_CACHE_MAX@ 101 | #cmakedefine GWPR_MAX_ACCEPT @GWPR_MAX_ACCEPT@ 102 | #cmakedefine GWPR_TRY_SYNCHRONOUS_WRITE_UNIX 103 | #cmakedefine GWPR_SYNCHRONOUS_WRITE_MAX_BYTES @GWPR_SYNCHRONOUS_WRITE_MAX_BYTES@ 104 | #cmakedefine GWPR_FILTERS_MAX @GWPR_FILTERS_MAX@ 105 | 106 | //memory allocation 107 | #cmakedefine gwrl_mem_calloc(n,s) (@gwrl_mem_calloc@) 108 | #cmakedefine gwrl_mem_free(mm) (@gwrl_mem_free@) 109 | 110 | //coverage 111 | #cmakedefine GWRL_HIDE_FROM_COVERAGE 112 | #cmakedefine GWRL_COVERAGE_INTERNAL_ASSERT_VARS 113 | 114 | //errors 115 | #cmakedefine GWRL_HIDE_ERRORS 116 | 117 | #endif -------------------------------------------------------------------------------- /src/gwrl/shared_types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef TYPES_BOOL 3 | #if defined(PLATFORM_WINDOWS) && !defined(HAVE_TRUE_FALSE_LC) 4 | #define HAVE_TRUE_FALSE_LC 5 | #define true 1 6 | #define false 0 7 | #endif 8 | #ifndef HAVE_BOOL 9 | #define HAVE_bool 10 | typedef char bool; 11 | #endif 12 | #endif 13 | 14 | #ifdef TYPES_STDINT 15 | #ifndef HAVE_INT8_T 16 | #error stdint types need to be defined 17 | #endif 18 | #endif 19 | 20 | #ifdef TYPES_FILEID_T 21 | #if defined(PLATFORM_WINDOWS) && !defined(_fileid_t) 22 | #define _fileid_t 23 | typedef HANDLE fileid_t; 24 | #elif !defined(PLATFORM_WINDOWS) && !defined(_fileid_t) 25 | #define _fileid_t 26 | typedef int fileid_t; 27 | #endif 28 | #endif 29 | 30 | #ifdef TYPES_SOCKID_T 31 | #if defined(PLATFORM_WINDOWS) && !defined(_sockid_t) 32 | #define _sockid_t 33 | typedef SOCKET sockid_t; 34 | #elif !defined(PLATFORM_WINDOWS) && !defined(_sockid_t) 35 | #define _sockid_t 36 | typedef int sockid_t; 37 | #endif 38 | #endif 39 | 40 | #ifdef TYPES_SSIZE_T 41 | #ifndef HAVE_SSIZE_T 42 | #if defined(PLATFORM_WINDOWS) 43 | #define HAVE_SSIZE_T 44 | typedef LONG_PTR ssize_t; 45 | #else 46 | #error ssize_t needs to be defined 47 | #endif 48 | #endif 49 | #endif 50 | 51 | #ifdef TYPES_STRUCT_TIMEVAL 52 | #if !defined(HAVE_STRUCT_TIMEVAL) 53 | #define HAVE_STRUCT_TIMEVAL 54 | struct timeval { 55 | long tv_sec; 56 | int tv_usec; 57 | }; 58 | #endif 59 | #endif 60 | 61 | #ifdef TYPES_STRUCT_TIMESPEC 62 | #ifndef HAVE_STRUCT_TIMESPEC 63 | #ifdef HAVE_STDINT_H 64 | #define HAVE_STRUCT_TIMESPEC 65 | struct timespec { 66 | long tv_sec; 67 | long tv_nsec; 68 | }; 69 | #endif 70 | #endif 71 | #endif 72 | 73 | #ifdef TYPES_SOCKLEN_T 74 | #if !defined(HAVE_SOCKLEN_T) && !defined(HAVE__SOCKLEN_T) 75 | #define HAVE_SOCKLEN_T 76 | typedef int socklen_t; 77 | #endif 78 | #endif 79 | 80 | #ifdef TYPES_SA_FAMILY_T 81 | #if !defined(HAVE_SA_FAMILY_T) && !defined(HAVE__SA_FAMILY_T) 82 | #if defined(PLATFORM_WINDOWS) && defined(HAVE_WS_ADDRESS_FAMILY) 83 | #define HAVE_SA_FAMILY_T 84 | typedef ADDRESS_FAMILY sa_family_t; 85 | #else 86 | #error sa_family_t needs to be defined 87 | #endif 88 | #endif 89 | #endif 90 | 91 | #ifdef TYPES_STRUCT_SOCKADDR_STORAGE 92 | #if !defined(HAVE_STRUCT_SOCKADDR_STORAGE) 93 | #error struct sockaddr_storage needs to be defined 94 | #endif 95 | #endif 96 | -------------------------------------------------------------------------------- /src/gwrl/string.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GW_STRING_H 3 | #define GW_STRING_H 4 | 5 | #ifndef HAVE_BZERO 6 | # define HAVE_BZERO 7 | # define bzero(buf,sz) (memset(buf,0,sz)) 8 | #endif 9 | 10 | #ifndef gwerr 11 | # define gwerr(str) fprintf(stderr,"gwrl error: %s\n",str) 12 | #endif 13 | 14 | #ifndef gwwrn 15 | # define gwwrn(str) fprintf(stderr,"gwrl warning: %s\n",str) 16 | #endif 17 | 18 | #ifndef gwprintsyserr 19 | # if !defined(PLATFORM_WINDOWS) 20 | # define gwprintsyserr(prefix,errnm) fprintf(stderr,"%s: (%i), %s\n",prefix,errnm,strerror(errnm)); 21 | # else 22 | # define gwprintsyserr(prefix,errnm) LPSTR msg;\ 23 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER,0,errnm,0,(LPSTR)&msg,0,0);\ 24 | fprintf(stderr,"%s: (%i), %s\n",prefix,errnm,msg);\ 25 | LocalFree(msg);\ 26 | 27 | # endif 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/gwrl/time.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/time.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void gwtm_gettimeofday_timespec(struct timespec * ts) { 9 | struct timeval tv; 10 | gettimeofday(&tv,NULL); 11 | gwtm_timeval_to_timespec(&tv,ts); 12 | } 13 | 14 | void gwtm_ms_to_timeval(int64_t ms, struct timeval * tv) { 15 | tv->tv_sec = (long)(ms/1000); 16 | tv->tv_usec = 1000*(ms%1000); 17 | if(tv->tv_usec >= _MICROSECONDS_WC) { 18 | tv->tv_sec += 1; 19 | tv->tv_usec -= _MICROSECONDS_WC; 20 | } 21 | } 22 | 23 | void gwtm_ms_to_timespec(int64_t ms, struct timespec * ts) { 24 | ts->tv_sec = (long)(ms/1000); 25 | ts->tv_nsec = 1000000 * (ms%1000); 26 | if(ts->tv_nsec >= _NANOSECONDS_WC) { 27 | ts->tv_sec += 1; 28 | ts->tv_nsec -= _NANOSECONDS_WC; 29 | } 30 | } 31 | 32 | void gwtm_timeval_to_ms(struct timeval * tv, int64_t * ms) { 33 | if(tv->tv_sec == 0 && tv->tv_usec == 0) { 34 | *ms = 0; 35 | return; 36 | } 37 | *ms = ((int64_t)tv->tv_sec)*1000; 38 | *ms += tv->tv_usec/1000; 39 | } 40 | 41 | void gwtm_timespec_to_ms(struct timespec * ts, int64_t * ms) { 42 | if(ts->tv_sec == 0 && ts->tv_nsec == 0) { 43 | *ms = 0; 44 | return; 45 | } 46 | *ms = ((int64_t)ts->tv_sec)*1000; 47 | *ms += ts->tv_nsec/1000000; 48 | } 49 | 50 | void gwtm_add_ms_to_timeval(int64_t ms, struct timeval * tv) { 51 | if(ms == 0) return; 52 | tv->tv_sec += (long)(ms/1000); 53 | tv->tv_usec += 1000*(ms%1000); 54 | while(tv->tv_usec >= _MICROSECONDS_WC) { 55 | tv->tv_sec += 1; 56 | tv->tv_usec -= _MICROSECONDS_WC; 57 | } 58 | } 59 | 60 | void gwtm_add_ms_to_timespec(int64_t ms, struct timespec * ts) { 61 | if(ms == 0) return; 62 | ts->tv_sec += (long)(ms/1000); 63 | ts->tv_nsec += 1000000*(ms%1000); 64 | while(ts->tv_nsec >= _NANOSECONDS_WC) { 65 | ts->tv_sec += 1; 66 | ts->tv_nsec -= _NANOSECONDS_WC; 67 | } 68 | } 69 | 70 | struct timespec * gwtm_timespec_cmp(struct timespec * ts1, struct timespec * ts2) { 71 | if(ts1->tv_sec < ts2->tv_sec) return ts1; 72 | if(ts1->tv_sec == ts2->tv_sec) { 73 | if(ts1->tv_nsec < ts2->tv_nsec) return ts1; 74 | else if(ts1->tv_nsec == ts2->tv_nsec) return NULL; 75 | } 76 | return ts2; 77 | } 78 | 79 | bool gwtm_timespec_copy_if_smaller(struct timespec * source, struct timespec * update) { 80 | struct timespec * smaller = gwtm_timespec_cmp(source,update); 81 | if(smaller == source) { 82 | memcpy(update,smaller,sizeof(struct timespec)); 83 | return true; 84 | } 85 | return false; 86 | } 87 | 88 | void gwtm_timespec_sub_into(struct timespec * ts1, struct timespec * ts2, struct timespec * into) { 89 | into->tv_sec = ts1->tv_sec - ts2->tv_sec; 90 | into->tv_nsec = ts1->tv_nsec - ts2->tv_nsec; 91 | while(into->tv_nsec < 0) { 92 | into->tv_sec -= 1; 93 | into->tv_nsec += _NANOSECONDS_WC; 94 | } 95 | } 96 | 97 | bool gwtm_timespec_is_expired(struct timespec * ts1) { 98 | if(ts1->tv_sec < 0) return true; 99 | if(ts1->tv_sec <= 0 && ts1->tv_nsec <= 0) return true; 100 | return false; 101 | } 102 | 103 | void gwtm_timeval_to_timespec(struct timeval * tv, struct timespec * ts) { 104 | ts->tv_sec = tv->tv_sec; 105 | ts->tv_nsec = ((int64_t)tv->tv_usec)*1000; 106 | } 107 | 108 | void gwtm_timespec_to_timeval(struct timespec * ts, struct timeval * tv) { 109 | tv->tv_sec = ts->tv_sec; 110 | tv->tv_usec = ((long)ts->tv_nsec)/1000; 111 | } 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | -------------------------------------------------------------------------------- /src/gwrl/time.h: -------------------------------------------------------------------------------- 1 | 2 | #define INCLUDE_STDBOOL 3 | #define INCLUDE_STDINT 4 | #define INCLUDE_STDIO 5 | #define INCLUDE_STRING 6 | #define INCLUDE_SYS_TIME 7 | #define INCLUDE_WINDOWS 8 | #define INCLUDE_WINSOCK2 9 | #define TYPES_BOOL 10 | #define TYPES_STRUCT_TIMEVAL 11 | #define TYPES_STRUCT_TIMESPEC 12 | #include "gwrl/shared_config.h" 13 | #include "gwrl/shared_include.h" 14 | #include "gwrl/shared_types.h" 15 | 16 | #ifndef GWTM_H 17 | #define GWTM_H 18 | 19 | //units per wall clock second 20 | #define _MILLISECONDS_WC 1000 21 | #define _MICROSECONDS_WC 1000000 22 | #define _NANOSECONDS_WC 1000000000 23 | 24 | void gwtm_ms_to_timeval(int64_t ms, struct timeval * tv); 25 | void gwtm_ms_to_timespec(int64_t ms, struct timespec * ts); 26 | void gwtm_timeval_to_ms(struct timeval * tv, int64_t * ms); 27 | void gwtm_timespec_to_ms(struct timespec * ts, int64_t * ms); 28 | void gwtm_add_ms_to_timeval(int64_t ms, struct timeval * tv); 29 | void gwtm_add_ms_to_timespec(int64_t ms, struct timespec * ts); 30 | void gwtm_gettimeofday_timespec(struct timespec * ts); 31 | void gwtm_timeval_to_timespec(struct timeval * tv, struct timespec * ts); 32 | void gwtm_timespec_to_timeval(struct timespec * ts, struct timeval * tv); 33 | void gwtm_timespec_sub_into(struct timespec * ts1, struct timespec * ts2, struct timespec * into); 34 | bool gwtm_timespec_is_expired(struct timespec * ts1); 35 | bool gwtm_timespec_copy_if_smaller(struct timespec * source, struct timespec * update); 36 | struct timespec * gwtm_timespec_cmp(struct timespec * ts1, struct timespec * ts2); 37 | 38 | #ifndef HAVE_GETTIMEOFDAY 39 | int gettimeofday(struct timeval *, struct timezone * tz); 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${gwrl_BINARY_DIR}") 2 | include_directories("${gwrl_SOURCE_DIR}/src") 3 | 4 | add_executable(time_fncs time_fncs.c) 5 | target_link_libraries(time_fncs gwrl) 6 | 7 | add_executable(reactor_src reactor_src.c) 8 | target_link_libraries(reactor_src gwrl) 9 | 10 | add_executable(reactor_gatherfunc reactor_gatherfunc.c) 11 | target_link_libraries(reactor_gatherfunc gwrl) 12 | 13 | add_executable(reactor_events reactor_events.c) 14 | target_link_libraries(reactor_events gwrl) 15 | 16 | add_executable(reactor_options reactor_options.c) 17 | target_link_libraries(reactor_options gwrl) 18 | 19 | add_executable(reactor_timers reactor_timers.c) 20 | target_link_libraries(reactor_timers gwrl) 21 | 22 | add_executable(reactor_custom_gathering reactor_custom_gathering.c) 23 | target_link_libraries(reactor_custom_gathering gwrl) 24 | 25 | add_executable(reactor_timeout_rearm reactor_timeout_rearm.c) 26 | target_link_libraries(reactor_timeout_rearm gwrl) 27 | 28 | add_executable(reactor_free1 reactor_free1.c) 29 | target_link_libraries(reactor_free1 gwrl) 30 | 31 | add_executable(reactor_free2 reactor_free2.c) 32 | target_link_libraries(reactor_free2 gwrl) 33 | 34 | add_executable(reactor_free3 reactor_free3.c) 35 | target_link_libraries(reactor_free3 gwrl) 36 | 37 | add_executable(reactor_free4 reactor_free4.c) 38 | target_link_libraries(reactor_free4 gwrl) 39 | 40 | add_executable(reactor_pers_timeouts reactor_pers_timeouts.c) 41 | target_link_libraries(reactor_pers_timeouts gwrl) 42 | 43 | add_executable(reactor_timer_interval reactor_timer_interval.c) 44 | target_link_libraries(reactor_timer_interval gwrl) 45 | 46 | add_executable(reactor_safely reactor_safely.c) 47 | target_link_libraries(reactor_safely gwrl) 48 | 49 | add_executable(reactor_no_sleep reactor_no_sleep.c) 50 | target_link_libraries(reactor_no_sleep gwrl) 51 | 52 | add_executable(reactor_wake_reinit reactor_wake_reinit.c) 53 | target_link_libraries(reactor_wake_reinit gwrl) 54 | 55 | if(NOT PLATFORM_WINDOWS) 56 | add_executable(reactor_wake_pipe reactor_wake_pipe.c) 57 | target_link_libraries(reactor_wake_pipe gwrl pthread) 58 | 59 | add_executable(proactor_wrq proactor_wrq.c) 60 | target_link_libraries(proactor_wrq gwrl) 61 | 62 | add_executable(proactor_gwprwrq_get proactor_gwprwrq_get.c) 63 | target_link_libraries(proactor_gwprwrq_get gwrl) 64 | 65 | add_executable(proactor_thread_specific_nix proactor_thread_specific_nix.c) 66 | target_link_libraries(proactor_thread_specific_nix gwrl pthread) 67 | 68 | add_executable(proactor_gwpr_src_activity_write_qitem_result proactor_gwpr_src_activity_write_qitem_result.c) 69 | target_link_libraries(proactor_gwpr_src_activity_write_qitem_result gwrl) 70 | endif() 71 | 72 | if(${WIN32}) 73 | add_executable(reactor_wake_iocp reactor_wake_iocp.c) 74 | target_link_libraries(reactor_wake_iocp gwrl) 75 | endif() 76 | 77 | add_executable(proactor_buf proactor_buf.c) 78 | target_link_libraries(proactor_buf gwrl) 79 | 80 | add_executable(proactor_filters proactor_filters.c) 81 | target_link_libraries(proactor_filters gwrl) 82 | 83 | add_executable(proactor_free1 proactor_free1.c) 84 | target_link_libraries(proactor_free1 gwrl) 85 | 86 | add_executable(proactor_tcp proactor_tcp.c) 87 | target_link_libraries(proactor_tcp gwrl) 88 | 89 | add_executable(proactor_udp proactor_udp.c) 90 | target_link_libraries(proactor_udp gwrl) 91 | 92 | add_executable(proactor_src proactor_src.c) 93 | target_link_libraries(proactor_src gwrl) 94 | 95 | add_executable(proactor_cb proactor_cb.c) 96 | target_link_libraries(proactor_cb gwrl) -------------------------------------------------------------------------------- /test/proactor_buf.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | int main(int argc, char ** argv) { 5 | gwrl * rl = gwrl_create(); 6 | gwpr * pr = gwpr_create(rl); 7 | gwprbuf * buf1 = gwpr_buf_get(pr,128); 8 | gwprbuf * buf2 = gwpr_buf_get(pr,256); 9 | gwprbuf * buf3 = gwpr_buf_get(pr,512); 10 | 11 | assert(buf1 && buf2 && buf3); 12 | assert(buf1->bufsize == 128); 13 | assert(buf2->bufsize == 256); 14 | assert(buf3->bufsize == 512); 15 | 16 | buf1 = gwpr_buf_get_tagged(pr,128,10); 17 | assert(buf1->tag == 10); 18 | 19 | buf1 = gwpr_buf_get_with_data(pr,10,"word",100); 20 | assert(buf1 == NULL); 21 | 22 | buf1 = gwpr_buf_get_with_data(pr,5,"word",5); 23 | assert(strcmp(buf1->buf,"word") == 0); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /test/proactor_cb.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | void cb1(gwpr * pr, gwpr_io_info * info){} 5 | void cb2(gwpr * pr, gwpr_io_info * info){} 6 | void cb3(gwpr * pr, gwpr_io_info * info){} 7 | void cb4(gwpr * pr, gwpr_io_info * info){} 8 | void cb5(gwpr * pr, gwpr_io_info * info){} 9 | void cb6(gwpr * pr, gwpr_io_info * info){} 10 | 11 | int main(int argc, char ** argv) { 12 | gwrl * rl = gwrl_create(); 13 | gwpr * pr = gwpr_create(rl); 14 | gwrlsrc * fsrc = gwpr_set_fd(pr,STDIN_FILENO,NULL); 15 | gwpr_set_cb(pr,fsrc,gwpr_error_cb_id,&cb1); 16 | gwpr_set_cb(pr,fsrc,gwpr_accept_cb_id,&cb2); 17 | gwpr_set_cb(pr,fsrc,gwpr_did_read_cb_id,&cb3); 18 | gwpr_set_cb(pr,fsrc,gwpr_did_write_cb_id,&cb4); 19 | gwpr_set_cb(pr,fsrc,gwpr_closed_cb_id,&cb5); 20 | gwpr_set_cb(pr,fsrc,gwpr_connect_cb_id,&cb6); 21 | cb1(NULL,NULL); 22 | cb2(NULL,NULL); 23 | cb3(NULL,NULL); 24 | cb4(NULL,NULL); 25 | cb5(NULL,NULL); 26 | cb6(NULL,NULL); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /test/proactor_filters.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | void filter(gwpr * pr, gwpr_io_info * info){} 5 | void filter2(gwpr * pr, gwpr_io_info * info){} 6 | void filter3(gwpr * pr, gwpr_io_info * info){} 7 | 8 | int main(int argc, char ** argv) { 9 | gwrl * rl = gwrl_create(); 10 | gwpr * pr = gwpr_create(rl); 11 | gwrlsrc * src1 = gwrl_src_file_create(0,0,NULL,NULL); 12 | gwrlsrc_file * fsrc = _gwrlsrcf(src1); 13 | 14 | if(GWPR_FILTERS_MAX < 2) { 15 | printf("error: GWPR_FILTERS_MAX must be at least 2 for this test.\n"); 16 | return -1; 17 | } 18 | 19 | gwpr_src_add(pr,src1); 20 | gwpr_filter_add(pr,src1,gwpr_rdfilter_id,&filter); 21 | assert(((gwprdata *)fsrc->pdata)->rdfilters != NULL); 22 | assert(((gwprdata *)fsrc->pdata)->rdfilters[0] == &filter); 23 | 24 | gwpr_filter_add(pr,src1,gwpr_rdfilter_id,&filter2); 25 | assert(_gwprdata(fsrc->pdata)->rdfilters != NULL); 26 | assert(_gwprdata(fsrc->pdata)->rdfilters[1] == &filter2); 27 | 28 | gwpr_filter_reset(pr,src1,gwpr_rdfilter_id); 29 | gwpr_filter_reset(pr,src1,gwpr_wrfilter_id); 30 | assert(((gwprdata *)fsrc->pdata)->rdfilters[0] == NULL); 31 | assert(((gwprdata *)fsrc->pdata)->wrfilters[0] == NULL); 32 | 33 | filter(NULL,NULL); 34 | filter2(NULL,NULL); 35 | filter3(NULL,NULL); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /test/proactor_free1.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | void didrd(gwpr * pr, gwpr_io_info * info) { 5 | } 6 | 7 | void stop(gwrl * rl, gwrlevt * evt) { 8 | gwrl_stop(rl); 9 | } 10 | 11 | int main(int argc, char ** argv) { 12 | gwrl * rl = gwrl_create(); 13 | gwpr * pr = gwpr_create(rl); 14 | gwrlsrc * fsrc = gwpr_set_fd(pr,STDIN_FILENO,NULL); 15 | gwrlsrc * sources = NULL; 16 | gwrlsrc * del = NULL; 17 | 18 | //setup proactor and run 19 | gwpr_set_cb(pr,fsrc,gwpr_did_read_cb_id,&didrd); 20 | gwpr_read(pr,fsrc,128); 21 | gwrl_post_function(rl,&stop,NULL); 22 | gwrl_run(rl); 23 | 24 | //free everything 25 | gwpr_free(pr); 26 | gwrl_free(rl,&sources); 27 | del = sources; 28 | while(del) { 29 | if(del->type == GWRL_SRC_TYPE_FILE) { 30 | close(_gwrlsrcf(del)->fd); 31 | } 32 | del = del->next; 33 | } 34 | gwrl_free(NULL,&sources); 35 | didrd(NULL,NULL); 36 | 37 | rl = gwrl_create(); 38 | pr = gwpr_create(rl); 39 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 40 | fsrc = gwrl_src_file_create(STDIN_FILENO,0,NULL,NULL); 41 | gwpr_src_add_safely(pr,fsrc); 42 | fsrc = gwrl_src_file_create(STDIN_FILENO,0,NULL,NULL); 43 | gwpr_src_add_safely(pr,fsrc); 44 | gwpr_free(pr); 45 | gwrl_free(rl,NULL); 46 | 47 | rl = gwrl_create(); 48 | pr = gwpr_create(rl); 49 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 50 | fsrc = gwrl_src_file_create(STDIN_FILENO,0,NULL,NULL); 51 | gwpr_src_add_safely(pr,fsrc); 52 | fsrc = gwrl_src_file_create(STDIN_FILENO,0,NULL,NULL); 53 | gwpr_src_add_safely(pr,fsrc); 54 | gwpr_free(pr); 55 | gwrl_free(rl,&sources); 56 | gwrl_free(NULL,&sources); 57 | 58 | return 0; 59 | } -------------------------------------------------------------------------------- /test/proactor_gwprwrq_get.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main(int argc, char ** argv) { 5 | gwrl * rl = gwrl_create(); 6 | gwpr * pr = gwpr_create(rl); 7 | gwrlsrc * src1 = gwpr_set_fd(pr,STDIN_FILENO,NULL); 8 | gwrlsrc_file * fsrc1 = _gwrlsrcf(src1); 9 | gwprwrq * q1 = gwprwrq_get(pr,fsrc1); 10 | gwprwrq * q2 = gwprwrq_get(pr,fsrc1); 11 | gwprwrq_free(pr,fsrc1,q1); 12 | gwprwrq_free(pr,fsrc1,q2); 13 | q1 = gwprwrq_get(pr,fsrc1); 14 | assert(q1); 15 | q2 = gwprwrq_get(pr,fsrc1); 16 | assert(q2); 17 | assert(pr->wrqcache == NULL); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/proactor_src.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | gwrl * rl; 5 | gwpr * pr; 6 | gwrlsrc * src1; 7 | 8 | void timeout(gwrl * rl, gwrlevt * evt) { 9 | gwpr_src_remove(pr,src1); 10 | gwrl_stop(rl); 11 | } 12 | 13 | void timeout2(gwrl * rl, gwrlevt * evt) { 14 | gwrl_stop(rl); 15 | } 16 | 17 | int main(int argc, char ** argv) { 18 | rl = gwrl_create(); 19 | pr = gwpr_create(rl); 20 | 21 | src1 = gwpr_set_fd(pr,STDIN_FILENO,NULL); 22 | gwpr_src_remove(pr,src1); 23 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == NULL); 24 | gwpr_src_add(pr,src1); 25 | gwpr_src_del(pr,src1); 26 | src1 = NULL; 27 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == NULL); 28 | 29 | src1 = gwpr_set_fd(pr,STDIN_FILENO,NULL); 30 | gwrl_set_timeout(rl,10,false,&timeout,NULL); 31 | gwrl_run(rl); 32 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == NULL); 33 | 34 | src1 = gwpr_set_fd(pr,STDIN_FILENO,NULL); 35 | gwpr_src_add_safely(pr,src1); 36 | gwrl_set_timeout(rl,10,false,&timeout2,NULL); 37 | gwrl_run(rl); 38 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next != NULL); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /test/proactor_tcp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | gwrl * rl; 5 | gwpr * pr; 6 | gwrlsrc * rdsrc = NULL; 7 | gwrlsrc * wrsrc = NULL; 8 | int rdcount = 0; 9 | int sockets[2]; 10 | bool called_wrfilter1 = false; 11 | bool called_wrfilter2 = false; 12 | bool called_rdfilter1 = false; 13 | bool called_rdfilter2 = false; 14 | 15 | void didrd(gwpr * pr, gwpr_io_info * info) { 16 | assert(strcmp(info->buf->buf,"hello world") == 0); 17 | gwpr_buf_free(pr,info->buf); 18 | if(rdcount == 100) { 19 | gwrl_stop(rl); 20 | } 21 | rdcount++; 22 | } 23 | 24 | void didwr(gwpr * pr, gwpr_io_info * info) { 25 | gwpr_buf_free(pr,info->buf); 26 | } 27 | 28 | void rdfilter1(gwpr * pr, gwpr_io_info * info) { 29 | assert(info->buf->buf[11] == '!'); 30 | info->buf->buf[11] = '\0'; 31 | called_rdfilter1 = true; 32 | } 33 | 34 | void rdfilter2(gwpr * pr, gwpr_io_info * info) { 35 | assert(info->buf->buf[12] == '!'); 36 | info->buf->buf[12] = '\0'; 37 | info->buf->len--; 38 | called_rdfilter2 = true; 39 | } 40 | 41 | void write_data(gwrl * rl, gwrlevt * evt) { 42 | gwprbuf * buf = gwpr_buf_get_with_data(pr,32,"hello world",12); 43 | buf->buf[11] = '\0'; 44 | if(rdcount > 10) { 45 | pr->options.gwpr_synchronous_write_max_bytes = 0; 46 | gwpr_write(pr,wrsrc,buf); 47 | } else if(rdcount > 25) { 48 | pr->options.gwpr_synchronous_write_max_bytes = 256; 49 | gwpr_recv(pr,rdsrc,128); 50 | gwpr_send(pr,wrsrc,buf); 51 | } else if(rdcount > 50) { 52 | pr->options.gwpr_synchronous_write_max_bytes = 0; 53 | } else { 54 | gwpr_write(pr,wrsrc,buf); 55 | } 56 | } 57 | 58 | void wrfilter1(gwpr * pr, gwpr_io_info * info) { 59 | info->buf->buf[11] = '!'; 60 | info->buf->buf[12] = '\0'; 61 | called_wrfilter1 = true; 62 | } 63 | 64 | void wrfilter2(gwpr * pr, gwpr_io_info * info) { 65 | info->buf->buf[12] = '!'; 66 | info->buf->buf[13] = '\0'; 67 | info->buf->len++; 68 | called_wrfilter2 = true; 69 | } 70 | 71 | void timeout(gwrl * rl, gwrlevt * evt) { 72 | assert(rdcount > 0); 73 | gwrl_stop(rl); 74 | } 75 | 76 | int main(int argc, char ** argv) { 77 | socketpair(AF_UNIX,SOCK_STREAM,0,sockets); 78 | 79 | rl = gwrl_create(); 80 | pr = gwpr_create(rl); 81 | 82 | rdsrc = gwpr_set_fd(pr,sockets[0],NULL); 83 | wrsrc = gwpr_set_fd(pr,sockets[1],NULL); 84 | 85 | gwpr_filter_add(pr,wrsrc,gwpr_wrfilter_id,&wrfilter1); 86 | gwpr_filter_add(pr,wrsrc,gwpr_wrfilter_id,&wrfilter2); 87 | gwpr_filter_add(pr,rdsrc,gwpr_rdfilter_id,&rdfilter1); 88 | gwpr_filter_add(pr,rdsrc,gwpr_rdfilter_id,&rdfilter2); 89 | 90 | gwpr_set_cb(pr,wrsrc,gwpr_did_write_cb_id,&didwr); 91 | gwpr_set_cb(pr,rdsrc,gwpr_did_read_cb_id,&didrd); 92 | gwpr_read(pr,rdsrc,128); 93 | 94 | gwrl_set_interval(rl,0,&write_data,NULL); 95 | //gwrl_set_timeout(rl,10000,false,&timeout,NULL); 96 | gwrl_run(rl); 97 | 98 | timeout(rl,NULL); 99 | 100 | assert(called_rdfilter1); 101 | assert(called_rdfilter2); 102 | assert(called_wrfilter1); 103 | assert(called_wrfilter2); 104 | 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /test/proactor_thread_specific_nix.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | #include 4 | 5 | pthread_t th1; 6 | pthread_key_t th1key; 7 | 8 | typedef struct thdata { 9 | gwrl * rl; 10 | gwpr * pr; 11 | } thdata; 12 | 13 | void stdin_read(gwpr * pr, gwpr_io_info * info) { 14 | gwpr_buf_free(pr,info->buf); 15 | thdata * data = (thdata *)pthread_getspecific(th1key); 16 | gwrl * rl = data->rl; 17 | gwrl_stop(rl); 18 | } 19 | 20 | void testThreadSpecificData() { 21 | thdata * data = (thdata *)pthread_getspecific(th1key); 22 | gwpr * pr = data->pr; 23 | gwrlsrc * fsrc = gwpr_set_fd(pr,STDIN_FILENO,NULL); 24 | gwpr_set_cb(pr,fsrc,gwpr_did_read_cb_id,&stdin_read); 25 | gwpr_read(pr,fsrc,128); 26 | } 27 | 28 | void setupReactor(gwrl * rl, gwrlevt * evt) { 29 | testThreadSpecificData(); 30 | } 31 | 32 | void teardown_reactor(gwrl * rl) { 33 | gwrlsrc * src = NULL; 34 | gwrlsrc * hsrc = NULL; 35 | gwrl_free(rl,&hsrc); 36 | src = hsrc; 37 | while(src) { 38 | if(src->type == GWRL_SRC_TYPE_FILE) close(_gwrlsrcf(src)->fd); 39 | src = src->next; 40 | } 41 | gwrl_free(NULL,&hsrc); 42 | } 43 | 44 | void * threadMain(void * arg) { 45 | gwrl * rl = gwrl_create(); 46 | gwpr * pr = gwpr_create(rl); 47 | thdata * data = malloc(sizeof(thdata)); 48 | data->rl = rl; 49 | data->pr = pr; 50 | pthread_key_create(&th1key,NULL); 51 | pthread_setspecific(th1key,data); 52 | gwrl_post_function(rl,&setupReactor,NULL); 53 | gwrl_run(rl); 54 | teardown_reactor(rl); 55 | return NULL; 56 | } 57 | 58 | int main(int argc, char ** argv) { 59 | pthread_create(&th1,NULL,&threadMain,NULL); 60 | pthread_join(th1,NULL); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /test/proactor_udp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | gwrl * rl = NULL; 5 | gwpr * pr = NULL; 6 | gwrlsrc * rdsrc = NULL; 7 | gwrlsrc * wrsrc = NULL; 8 | int rdcount = 0; 9 | int sockets[2]; 10 | struct sockaddr_storage peer; 11 | socklen_t peerlen = 0; 12 | 13 | void didrd(gwpr * pr, gwpr_io_info * info) { 14 | rdcount++; 15 | gwpr_buf_free(pr,info->buf); 16 | if(rdcount == 100) { 17 | gwrl_stop(rl); 18 | } 19 | } 20 | 21 | void didwr(gwpr * pr, gwpr_io_info * info) { 22 | gwpr_buf_free(pr,info->buf); 23 | } 24 | 25 | void error(gwpr * pr, gwpr_error_info * info) { 26 | gwprintsyserr("error:",info->errnm); 27 | } 28 | 29 | void write_data(gwrl * rl, gwrlevt * evt) { 30 | gwprbuf * buf = gwpr_buf_get_with_data(pr,12,"hello world",12); 31 | gwpr_sendto(pr,wrsrc,buf,&peer,peerlen); 32 | } 33 | 34 | int main(int argc, char ** argv) { 35 | bzero(&peer,sizeof(peer)); 36 | 37 | struct skctlinfo server = {0}; 38 | struct skctlinfo client = {0}; 39 | skctl_udp_server(&server,0,"13009",AF_INET,true); 40 | skctl_udp_client(&client,0,"13009",AF_INET,true); 41 | 42 | peerlen = sizeof(struct sockaddr_storage); 43 | memcpy(&peer,server.used->ai_addr,server.used->ai_addrlen); 44 | 45 | gwsk_sockaddr_print(&peer); 46 | 47 | rl = gwrl_create(); 48 | pr = gwpr_create(rl); 49 | rdsrc = gwpr_set_fd(pr,server.sockfd,NULL); 50 | wrsrc = gwpr_set_fd(pr,client.sockfd,NULL); 51 | 52 | gwrl_set_interval(rl,0,&write_data,NULL); 53 | 54 | gwpr_set_cb(pr,rdsrc,gwpr_did_read_cb_id,&didrd); 55 | gwpr_set_cb(pr,wrsrc,gwpr_did_write_cb_id,&didwr); 56 | gwpr_set_cb(pr,wrsrc,gwpr_error_cb_id,&error); 57 | gwpr_recvfrom(pr,rdsrc,128); 58 | 59 | gwrl_run(rl); 60 | assert(rdcount == 100); 61 | 62 | return 0; 63 | } -------------------------------------------------------------------------------- /test/proactor_wrq.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/proactor.h" 3 | 4 | int main(int argc, char ** argv) { 5 | 6 | gwrl * rl = gwrl_create(); 7 | gwpr * pr = gwpr_create(rl); 8 | gwrlsrc * src = gwpr_set_fd(pr,STDIN_FILENO,NULL); 9 | gwrlsrc_file * fsrc = _gwrlsrcf(src); 10 | 11 | gwprwrq * q1 = gwprwrq_get(pr,fsrc); 12 | gwprwrq * q2 = gwprwrq_get(pr,fsrc); 13 | gwprwrq * q3 = gwprwrq_get(pr,fsrc); 14 | gwprwrq * q4 = gwprwrq_get(pr,fsrc); 15 | gwprdata * pdata = fsrc->pdata; 16 | 17 | assert(pr->nwrqcache == 0); 18 | assert(q1 && q2 && q3); 19 | 20 | //testing adding some 21 | gwprwrq_add(pr,fsrc,q1); 22 | gwprwrq_add(pr,fsrc,q2); 23 | assert(pdata->wrq == q1); 24 | assert(pdata->wrq->next == q2); 25 | assert(pdata->wrqlast == q2); 26 | 27 | //assert one more add 28 | gwprwrq_add(pr,fsrc,q3); 29 | assert(pdata->wrqlast == q3); 30 | assert(pdata->wrq->next->next == q3); 31 | 32 | //assert posting a q back. 33 | pdata->wrq = NULL; 34 | gwprwrq_putback(pr,fsrc,q1); 35 | assert(pdata->wrq == q1); 36 | assert(pdata->wrq->next == q2); 37 | assert(pdata->wrqlast == q3); 38 | assert(pdata->wrq->next->next == q3); 39 | 40 | //assert putting a q back when one already existed 41 | pdata->wrq = q4; 42 | gwprwrq_putback(pr,fsrc,q1); 43 | assert(pdata->wrq == q1); 44 | assert(pdata->wrq->next == q2); 45 | assert(pdata->wrq->next->next == q3); 46 | assert(pdata->wrq->next->next->next == q4); 47 | assert(pdata->wrqlast == q4); 48 | 49 | //assert free/cache 50 | pdata->wrq = NULL; 51 | gwprwrq_free(pr,fsrc,q1); 52 | assert(pr->nwrqcache == 1); 53 | assert(pr->wrqcache == q1); 54 | assert(pr->wrqcache->next == NULL); 55 | assert(q1->next == NULL); 56 | 57 | gwprwrq_free(pr,fsrc,q2); 58 | assert(pr->nwrqcache == 2); 59 | assert(pr->wrqcache == q2); 60 | assert(pr->wrqcache->next == q1); 61 | assert(pr->wrqcache->next->next == NULL); 62 | 63 | gwprwrq_free(pr,fsrc,q3); 64 | assert(pr->nwrqcache == 3); 65 | assert(pr->wrqcache == q3); 66 | assert(pr->wrqcache->next == q2); 67 | assert(pr->wrqcache->next->next == q1); 68 | assert(pr->wrqcache->next->next->next == NULL); 69 | 70 | q4 = pr->wrqcache; 71 | pr->wrqcache = NULL; 72 | pr->nwrqcache = 0; 73 | gwprwrq_free_list_no_cache(pr,q4); 74 | assert(pr->wrqcache == NULL); 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /test/reactor_custom_gathering.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | #define MY_SOURCE_TYPE 2 5 | 6 | typedef struct my_source { 7 | gwrlsrc _; 8 | int something; 9 | } my_source; 10 | 11 | void my_gather(gwrl * rl) { 12 | gwrlsrc * src = rl->sources[MY_SOURCE_TYPE]; 13 | my_source * msrc = NULL; 14 | while(src) { 15 | msrc = (my_source *)src; 16 | msrc->something++; 17 | if(msrc->something == 10) { 18 | msrc->something = 0; 19 | gwrlevt * evt = gwrl_evt_create(rl,src,src->callback,src->userdata,0,0); 20 | gwrl_post_evt(rl,evt); 21 | } 22 | src = src->next; 23 | } 24 | } 25 | 26 | void my_callback(gwrl * rl, gwrlevt * evt) { 27 | //printf("custom gather fired an event for a custom input source.\n"); 28 | gwrl_stop(rl); 29 | } 30 | 31 | int main(int argc, char ** argv) { 32 | gwrl * rl = gwrl_create(); 33 | my_source * msrc = gwrl_mem_calloc(1,sizeof(my_source)); 34 | gwrlsrc * src = _gwrlsrc(msrc); 35 | 36 | #if GWRL_SRC_TYPES_COUNT < 3 37 | printf("error: GWRL_SRC_TYPES_COUNT must be at least 3 for this example.\n"); 38 | exit(-1); 39 | #endif 40 | 41 | #if GWRL_GATHER_FUNCS_MAX < 1 42 | printf("error: GWRL_GATHER_FUNCS_MAX must be at least 1 for this example\n"); 43 | exit(-1); 44 | #endif 45 | 46 | msrc->something = 0; 47 | src->type = MY_SOURCE_TYPE; 48 | src->callback = &my_callback; 49 | gwrl_add_gather_fnc(rl,&my_gather); 50 | gwrl_allow_poll_sleep(rl,0); 51 | gwrl_src_add(rl,src); 52 | gwrl_run(rl); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /test/reactor_events.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int main(int argc, char ** argv) { 5 | gwrl * rl = gwrl_create(); 6 | gwrlevt * evt = NULL; 7 | gwrlevt * evt_tmp = NULL; 8 | int i = 0; 9 | 10 | evt = gwrl_evt_create(rl,NULL,NULL,NULL,0,0); 11 | gwrl_post_evt(rl,evt); 12 | assert(rl->events != NULL); 13 | gwrl_post_evt(rl,evt); 14 | assert(rl->events->next != NULL); 15 | 16 | rl->events = NULL; 17 | gwrl_evt_free(rl,evt); 18 | assert(rl->cevents != NULL); 19 | assert(rl->ncevents == 1); 20 | 21 | evt = gwrl_evt_create(rl,NULL,NULL,NULL,0,0); 22 | gwrl_post_evt(rl,evt); 23 | assert(rl->events != NULL); 24 | assert(rl->cevents == NULL); 25 | assert(rl->ncevents == 0); 26 | gwrl_evt_free(rl,evt); 27 | 28 | while(i < GWRL_EVENT_CACHE_MAX + 100) { 29 | i++; 30 | evt = gwrl_evt_create(rl,NULL,NULL,NULL,0,0); 31 | if(evt_tmp) evt->next = evt_tmp; 32 | evt_tmp = evt; 33 | } 34 | 35 | gwrl_evt_free_list(rl,evt); 36 | assert(rl->ncevents == GWRL_EVENT_CACHE_MAX); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /test/reactor_free1.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void timeout(gwrl * rl, gwrlevt * evt) { 5 | gwrl_stop(rl); 6 | } 7 | 8 | int main(int argc, char ** argv) { 9 | gwrl * rl = gwrl_create(); 10 | gwrl_set_timeout(rl,10,false,&timeout,NULL); 11 | gwrl_run(rl); 12 | gwrl_free(rl,NULL); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/reactor_free2.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void stdin_activity(gwrl * rl, gwrlevt * evt) { 5 | } 6 | 7 | void timeout(gwrl * rl, gwrlevt * evt) { 8 | gwrl_stop(rl); 9 | } 10 | 11 | int main(int argc, char ** argv) { 12 | gwrl * rl = gwrl_create(); 13 | gwrl_set_fd(rl,STDIN_FILENO,GWRL_RD,&stdin_activity,NULL); 14 | gwrl_set_timeout(rl,100,false,&timeout,NULL); 15 | gwrl_run(rl); 16 | gwrl_free(rl,NULL); 17 | stdin_activity(NULL,NULL); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/reactor_free3.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void stdin_activity(gwrl * rl, gwrlevt * evt) { 5 | } 6 | 7 | void timeout(gwrl * rl, gwrlevt * evt) { 8 | gwrl_stop(rl); 9 | } 10 | 11 | int main(int argc, char ** argv) { 12 | gwrl * rl = gwrl_create(); 13 | gwrlsrc * sources = NULL; 14 | gwrl_set_fd(rl,STDIN_FILENO,GWRL_RD,&stdin_activity,NULL); 15 | gwrl_set_timeout(rl,100,false,&timeout,NULL); 16 | gwrl_run(rl); 17 | gwrl_free(rl,&sources); 18 | while(sources) { 19 | if(sources->type == GWRL_SRC_TYPE_FILE) { 20 | close(_gwrlsrcf(sources)->fd); 21 | } 22 | sources = sources->next; 23 | } 24 | gwrl_free(NULL,&sources); 25 | stdin_activity(NULL,NULL); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /test/reactor_free4.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void timeout(gwrl * rl, gwrlevt * evt) { 5 | gwrl_stop(rl); 6 | } 7 | 8 | int main(int argc, char ** argv) { 9 | gwrl * rl = gwrl_create(); 10 | gwrl_set_timeout(rl,100,false,&timeout,NULL); 11 | gwrl_run(rl); 12 | gwrl_free(rl,NULL); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/reactor_gatherfunc.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int gather_count = 0; 5 | bool did_gather = false; 6 | 7 | void custom_gather(gwrl * rl) { 8 | did_gather = true; 9 | gather_count++; 10 | } 11 | 12 | int main(int argc, char ** argv) { 13 | gwrl * rl = gwrl_create(); 14 | 15 | #if GWRL_GATHER_FUNCS_MAX < 2 16 | printf("error: GWRL_GATHER_FUNCS_MAX must be at least 2 for this test.\n"); 17 | exit(-1); 18 | #endif 19 | 20 | gwrl_add_gather_fnc(rl,&custom_gather); 21 | gwrl_add_gather_fnc(rl,&custom_gather); 22 | assert(rl->gatherfncs[0] != NULL); 23 | assert(rl->gatherfncs[1] != NULL); 24 | gwrl_allow_poll_sleep(rl,0); 25 | gwrl_run_once(rl); 26 | assert(did_gather == true); 27 | assert(gather_count == 2); 28 | gwrl_reset_gather_fncs(rl); 29 | assert(rl->gatherfncs[0] == NULL); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /test/reactor_no_sleep.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int main(int argc, char ** argv) { 5 | 6 | #ifdef GWRL_COVERAGE_INTERNAL_ASSERT_VARS 7 | gwrl * rl = gwrl_create(); 8 | asserts_var2 = false; 9 | asserts_var1 = gwrlbkd_no_sleep_assert_true; 10 | gwrl_allow_poll_sleep(rl,0); 11 | gwrl_run_once(rl); 12 | assert(asserts_var2); 13 | #else 14 | printf(stderr,"reactor_no_sleep requires GWRL_COVERAGE_INTERNAL_ASSERT_VARS to be on in CMake."); 15 | #endif 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/reactor_options.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int main(int argc, char ** argv) { 5 | gwrl * rl = gwrl_create(); 6 | 7 | gwrl_options opts = GWRL_DEFAULT_OPTIONS; 8 | opts.gwrl_gather_funcs_max = 10; 9 | gwrl_set_options(rl,&opts); 10 | assert(rl->gatherfncs != NULL); 11 | 12 | opts.gwrl_gather_funcs_max = 20; 13 | gwrl_set_options(rl,&opts); 14 | assert(rl->gatherfncs != NULL); 15 | 16 | gwrl_options opts2 = GWRL_DEFAULT_OPTIONS; 17 | free(rl->gatherfncs); 18 | rl->gatherfncs = NULL; 19 | rl->options.gwrl_gather_funcs_max = 0; 20 | opts2.gwrl_gather_funcs_max = 10; 21 | gwrl_set_options(rl,&opts2); 22 | assert(rl->gatherfncs != NULL); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /test/reactor_pers_timeouts.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void timeout3(gwrl * rl, gwrlevt * evt) { 5 | gwrl_del_persistent_timeouts(rl); 6 | gwrl_stop(rl); 7 | } 8 | 9 | void timeout2(gwrl * rl, gwrlevt * evt) { 10 | gwrl_set_timeout(rl,10,true,&timeout3,NULL); 11 | } 12 | 13 | void timeout1(gwrl * rl, gwrlevt * evt) { 14 | gwrl_set_timeout(rl,10,false,&timeout2,NULL); 15 | } 16 | 17 | int main(int argc, char ** argv) { 18 | gwrl * rl = gwrl_create(); 19 | gwrl_set_timeout(rl,10,true,&timeout1,NULL); 20 | gwrl_run(rl); 21 | assert(rl->sources[GWRL_SRC_TYPE_TIME] == NULL); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /test/reactor_safely.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | bool fired = false; 5 | 6 | void event(gwrl * rl, gwrlevt * evt) { 7 | gwrl_stop(rl); 8 | fired = true; 9 | } 10 | 11 | int main(int argc, char ** argv) { 12 | int count = 0; 13 | gwrl * rl = gwrl_create(); 14 | gwrlsrc * src = gwrl_src_file_create(STDIN_FILENO,GWRL_RD,NULL,NULL); 15 | gwrlevt * evt = gwrl_evt_create(rl,src,&event,NULL,STDIN_FILENO,GWRL_RD); 16 | gwrlsrc * src2 = NULL; 17 | gwrl_src_add_safely(rl,src); 18 | gwrl_post_evt_safely(rl,evt); 19 | 20 | //this clears the internal wake mechanism, just for testing only 21 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 22 | 23 | //run and assert stuff fired and was added. 24 | gwrl_run(rl); 25 | assert(fired == true); 26 | assert(rl->sources[GWRL_SRC_TYPE_FILE] != NULL); 27 | 28 | //add more queued data so it uses the internal queue freeing logic 29 | src = gwrl_src_file_create(STDIN_FILENO,GWRL_RD,NULL,NULL); 30 | evt = gwrl_evt_create(rl,src,&event,NULL,STDIN_FILENO,GWRL_RD); 31 | gwrl_src_add_safely(rl,src); 32 | gwrl_post_evt_safely(rl,evt); 33 | 34 | //now free 35 | gwrl_free(rl,&src); 36 | src2 = src; 37 | while(src2) { 38 | count++; 39 | if(src2->type == GWRL_SRC_TYPE_FILE) { 40 | close(_gwrlsrcf(src)->fd); 41 | } 42 | src2 = src2->next; 43 | } 44 | assert(count == 2); 45 | gwrl_free(NULL,&src); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /test/reactor_src.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int main(int argc, char ** argv) { 5 | gwrl * rl = NULL; 6 | gwrlsrc * src = NULL; 7 | gwrlsrc * src2 = NULL; 8 | gwrlsrc * src3 = NULL; 9 | 10 | rl = gwrl_create(); 11 | 12 | //clear sources 13 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 14 | src = gwrl_src_file_create(0,0,NULL,NULL); 15 | gwrl_src_add(rl,src); 16 | assert(rl->sources[GWRL_SRC_TYPE_FILE] != NULL); 17 | gwrl_src_remove(rl,src); 18 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == NULL); 19 | gwrl_src_add(rl,src); 20 | assert(rl->sources[GWRL_SRC_TYPE_FILE] != NULL); 21 | gwrl_src_del(rl,src,NULL,true); 22 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == NULL); 23 | src = NULL; 24 | 25 | //clear sources 26 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 27 | src = gwrl_src_file_create(0,0,NULL,NULL); 28 | src2 = gwrl_src_file_create(0,0,NULL,NULL); 29 | gwrl_src_add(rl,src); 30 | gwrl_src_add(rl,src2); 31 | assert(rl->sources[GWRL_SRC_TYPE_FILE] != NULL); 32 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == src2); 33 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == src); 34 | gwrl_src_remove(rl,src); 35 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == src2); 36 | gwrl_src_add(rl,src); 37 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == src2); 38 | gwrl_src_remove(rl,src2); 39 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == src); 40 | 41 | rl->sources[GWRL_SRC_TYPE_FILE] = NULL; 42 | src = gwrl_src_file_create(0,0,NULL,NULL); 43 | src2 = gwrl_src_file_create(0,0,NULL,NULL); 44 | src3 = gwrl_src_file_create(0,0,NULL,NULL); 45 | gwrl_src_add(rl,src); 46 | gwrl_src_add(rl,src2); 47 | gwrl_src_add(rl,src3); 48 | gwrl_src_remove(rl,src2); 49 | assert(rl->sources[GWRL_SRC_TYPE_FILE] == src3); 50 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next == src); 51 | assert(rl->sources[GWRL_SRC_TYPE_FILE]->next->next == NULL); 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /test/reactor_timeout_rearm.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int count = 0; 5 | 6 | void timeout1(gwrl * rl, gwrlevt * evt) { 7 | count++; 8 | if(count == 10) { 9 | gwrl_stop(rl); 10 | } else { 11 | gwrl_src_enable(rl,evt->src); 12 | } 13 | } 14 | 15 | int main(int argc, char ** argv) { 16 | gwrl * rl = gwrl_create(); 17 | gwrl_set_timeout(rl,10,true,&timeout1,NULL); 18 | gwrl_run(rl); 19 | assert(count == 10); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /test/reactor_timer_interval.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int count = 0; 5 | 6 | void interval(gwrl * rl, gwrlevt * evt) { 7 | count++; 8 | if(count == 10) { 9 | gwrl_stop(rl); 10 | } 11 | } 12 | 13 | int main(int argc, char ** argv) { 14 | gwrl * rl = gwrl_create(); 15 | gwrl_set_interval(rl,10,&interval,NULL); 16 | gwrl_run(rl); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/reactor_timers.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | gwrl * rl1 = NULL; 5 | gwrlsrc * tsrc1 = NULL; 6 | bool future_timeout = false; 7 | bool timeout = false; 8 | bool interval = false; 9 | bool delayed = false; 10 | bool funccall = false; 11 | 12 | void functionCall(gwrl * rl, gwrlevt * evt) { 13 | //printf("> function call!\n"); 14 | funccall = true; 15 | } 16 | 17 | void delayedFunctionCall(gwrl * rl, gwrlevt * evt) { 18 | //printf("> delayed function call!\n"); 19 | delayed = true; 20 | } 21 | 22 | void futureTimeout(gwrl *rl, gwrlevt *evt) { 23 | //printf("fiture timeout!\n"); 24 | gwrl_stop(rl); 25 | future_timeout = true; 26 | } 27 | 28 | void timeout1(gwrl * rl, gwrlevt * evt) { 29 | interval = true; 30 | //printf("> timeout1\n"); 31 | } 32 | 33 | void timeout2(gwrl * rl, gwrlevt * evt) { 34 | //printf("> timeout2\n"); 35 | gwrl_set_timeout(rl1,3000,false,&timeout2,NULL); 36 | timeout = true; 37 | } 38 | 39 | void timeout3(gwrl * rl, gwrlevt * evt) { 40 | //printf("> timeout3\n"); 41 | timeout = true; 42 | } 43 | 44 | int main(int argc, char ** argv) { 45 | struct timeval tv = {0}; 46 | int64_t ms = 0; 47 | 48 | rl1 = gwrl_create(); 49 | gwrl_post_function(rl1,&functionCall,NULL); 50 | gwrl_post_function(rl1,&functionCall,NULL); 51 | gwrl_post_function(rl1,&functionCall,NULL); 52 | gwrl_post_function(rl1,&functionCall,NULL); 53 | gwrl_set_timeout(rl1,200,false,&delayedFunctionCall,NULL); 54 | gwrl_set_interval(rl1,125,&timeout1,NULL); 55 | gwrl_set_timeout(rl1,300,false,&timeout2,NULL); 56 | tsrc1 = gwrl_set_timeout(rl1,100,true,&timeout3,NULL); 57 | 58 | gettimeofday(&tv,NULL); 59 | //printf("now: %ld.%ld\n",tv.tv_sec,tv.tv_usec); 60 | 61 | gwtm_add_ms_to_timeval(600,&tv); 62 | //printf("future time: %ld.%ld\n",tv.tv_sec,tv.tv_usec); 63 | 64 | gwtm_timeval_to_ms(&tv,&ms); 65 | //printf("future ms timeout: %lld\n",ms); 66 | 67 | gwrl_set_date_timeout(rl1,ms,&futureTimeout,NULL); 68 | gwrl_run(rl1); 69 | 70 | assert(timeout); 71 | assert(interval); 72 | assert(future_timeout); 73 | assert(funccall); 74 | assert(delayed); 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /test/reactor_wake_iocp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | gwrl * rl; 5 | bool did_timeout = false; 6 | HANDLE thread1; 7 | 8 | void timeout(gwrl * rl, gwrlevt * evt) { 9 | did_timeout = true; 10 | gwrl_stop(rl); 11 | } 12 | 13 | DWORD threadmain(LPVOID args) { 14 | Sleep(1000); 15 | gwrl_post_function_safely(rl,&timeout,NULL); 16 | return 0; 17 | } 18 | 19 | void create_thread(gwrl * rl, gwrlevt * evt) { 20 | thread1 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&threadmain,NULL,0,NULL); 21 | } 22 | 23 | int main(int argc, char ** argv) { 24 | rl = gwrl_create(); 25 | gwrl_post_function(rl,&create_thread,NULL); 26 | gwrl_run(rl); 27 | assert(did_timeout); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/reactor_wake_pipe.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | #include 4 | 5 | gwrl * rl; 6 | pthread_t th1; 7 | bool did_timeout; 8 | 9 | void timeout(gwrl * rl, gwrlevt * evt) { 10 | did_timeout = true; 11 | gwrl_stop(rl); 12 | } 13 | 14 | void * threadMain(void * arg) { 15 | sleep(1); 16 | gwrl_post_function_safely(rl,&timeout,NULL); 17 | return NULL; 18 | } 19 | 20 | void start_thread(gwrl * rl, gwrlevt * evt) { 21 | pthread_create(&th1,NULL,&threadMain,NULL); 22 | } 23 | 24 | int main(int argc, char ** argv) { 25 | rl = gwrl_create(); 26 | gwrl_post_function(rl,&start_thread,NULL); 27 | gwrl_run(rl); 28 | pthread_join(th1,NULL); 29 | assert(did_timeout); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /test/reactor_wake_reinit.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | void timeout2(gwrl * rl, gwrlevt * evt) { 5 | gwrl_stop(rl); 6 | } 7 | 8 | void timeout(gwrl * rl, gwrlevt * evt) { 9 | asserts_var1 = gwrl_assert_wake_reinit; 10 | close(rl->fds[1]); 11 | gwrl_set_timeout(rl,100,false,&timeout2,NULL); 12 | } 13 | 14 | int main(int argc, char ** argv) { 15 | #ifdef GWRL_COVERAGE_INTERNAL_ASSERT_VARS 16 | gwrl * rl = gwrl_create(); 17 | gwrl_set_timeout(rl,10,false,&timeout,NULL); 18 | gwrl_run(rl); 19 | assert(asserts_var2 == true); 20 | #else 21 | fprintf(stderr,"reactor_wake_reinit.c requires GWRL_COVERAGE_INTERNAL_ASSERT_VARS to be on in CMake."); 22 | #endif 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /test/time_fncs.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gwrl/event.h" 3 | 4 | int main(int argc, char ** argv) { 5 | int64_t ms1 = 1345223184123; 6 | struct timeval tv1; 7 | struct timeval tv2; 8 | struct timespec ts1; 9 | struct timespec ts2; 10 | struct timespec ts3; 11 | 12 | gwtm_ms_to_timeval(ms1,&tv1); 13 | assert(tv1.tv_sec == 1345223184); 14 | assert(tv1.tv_usec == 123000); 15 | 16 | gwtm_timeval_to_ms(&tv1,&ms1); 17 | assert(ms1 == 1345223184123); 18 | 19 | ms1 = 10; 20 | tv1.tv_sec = 0; 21 | tv1.tv_usec = 0; 22 | gwtm_timeval_to_ms(&tv1,&ms1); 23 | assert(ms1 == 0); 24 | 25 | ms1 = 10; 26 | ts1.tv_sec = 0; 27 | ts1.tv_nsec = 0; 28 | gwtm_timespec_to_ms(&ts1,&ms1); 29 | assert(ms1 == 0); 30 | 31 | gwtm_gettimeofday_timespec(&ts1); 32 | memcpy(&ts2,&ts1,sizeof(ts2)); 33 | 34 | gwtm_timespec_to_ms(&ts1,&ms1); 35 | assert(ms1 >= (ts1.tv_sec*1000)); 36 | assert(ms1 < ((int64_t)(ts1.tv_sec+1)*1000)); 37 | 38 | gwtm_ms_to_timespec(ms1,&ts1); 39 | assert(ts1.tv_sec == ts2.tv_sec); 40 | assert(ts2.tv_nsec >= ts1.tv_nsec); 41 | assert(ts2.tv_nsec < (ts1.tv_nsec+1000000)); 42 | 43 | gettimeofday(&tv1,NULL); 44 | memcpy(&tv2,&tv1,sizeof(tv2)); 45 | gwtm_add_ms_to_timeval(2000,&tv2); 46 | gwtm_add_ms_to_timeval(0,&tv2); 47 | assert(tv2.tv_sec == (tv1.tv_sec+2)); 48 | 49 | gwtm_gettimeofday_timespec(&ts1); 50 | memcpy(&ts2,&ts1,sizeof(ts2)); 51 | gwtm_add_ms_to_timespec(2000,&ts2); 52 | assert(ts2.tv_sec == (ts1.tv_sec+2)); 53 | 54 | gwtm_gettimeofday_timespec(&ts1); 55 | sleep(.2); 56 | gwtm_gettimeofday_timespec(&ts2); 57 | assert((gwtm_timespec_cmp(&ts1,&ts2) == &ts1)); 58 | 59 | gwtm_gettimeofday_timespec(&ts1); 60 | gwtm_timespec_to_timeval(&ts1,&tv1); 61 | assert(tv1.tv_sec == ts1.tv_sec); 62 | assert(tv1.tv_usec == ((long)ts1.tv_nsec)/1000); 63 | 64 | gettimeofday(&tv1,0); 65 | gwtm_timeval_to_timespec(&tv1,&ts1); 66 | assert(tv1.tv_sec == ts1.tv_sec); 67 | //assert(ts2.tv_nsec == (tv1.tv_usec*1000)); 68 | 69 | gwtm_gettimeofday_timespec(&ts1); 70 | sleep(.2); 71 | gwtm_gettimeofday_timespec(&ts2); 72 | assert( gwtm_timespec_copy_if_smaller(&ts2,&ts1) == false); 73 | gwtm_timespec_copy_if_smaller(&ts1,&ts2); 74 | 75 | assert(ts1.tv_sec == ts2.tv_sec); 76 | assert(ts1.tv_nsec == ts2.tv_nsec); 77 | 78 | gwtm_gettimeofday_timespec(&ts1); 79 | sleep(.2); 80 | gwtm_gettimeofday_timespec(&ts2); 81 | gwtm_timespec_sub_into(&ts1,&ts2,&ts3); 82 | assert(gwtm_timespec_is_expired(&ts3)); 83 | 84 | return 0; 85 | } 86 | --------------------------------------------------------------------------------