Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
.TH "event2/util.h" 3 "Tue Jan 31 2017" "libevent" \" -*- nroff -*-
.ad l
.nh
.SH NAME
event2/util.h \- Common convenience functions for cross-platform portability and related socket manipulations\&.  

.SH SYNOPSIS
.br
.PP
\fC#include <event2/visibility\&.h>\fP
.br
\fC#include <event2/event\-config\&.h>\fP
.br
\fC#include <stdarg\&.h>\fP
.br
\fC#include <sys/socket\&.h>\fP
.br
\fC#include <time\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBevutil_addrinfo\fP"
.br
.RI "\fIA definition of struct addrinfo for systems that lack it\&. \fP"
.ti -1c
.RI "struct \fBevutil_monotonic_timer\fP"
.br
.RI "\fIStructure to hold information about a monotonic timer\&. \fP"
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBEV_MONOT_FALLBACK\fP   2"
.br
.ti -1c
.RI "#define \fBEV_MONOT_PRECISE\fP   1"
.br
.ti -1c
.RI "#define \fBev_socklen_t\fP   socklen_t"
.br
.ti -1c
.RI "#define \fBEVUTIL_CLOSESOCKET\fP(s)   \fBevutil_closesocket\fP(s)"
.br
.ti -1c
.RI "#define \fBevutil_offsetof\fP(type,  field)   ((off_t)(&((type *)0)\->field))"
.br
.RI "\fIReplacement for offsetof on platforms that don't define it\&. \fP"
.ti -1c
.RI "#define \fBevutil_socket_t\fP   int"
.br
.RI "\fIA type wide enough to hold the output of 'socket()' or 'accept()'\&. \fP"
.ti -1c
.RI "#define \fBevutil_timercmp\fP(tvp,  uvp,  cmp)"
.br
.RI "\fIReturn true iff the tvp is related to uvp according to the relational operator cmp\&. \fP"
.ti -1c
.RI "#define \fBevutil_timerisset\fP(tvp)   ((tvp)\->tv_sec || (tvp)\->tv_usec)"
.br
.in -1c
.PP
.RI "\fBStandard integer types\&.\fP"
.br
Integer type definitions for types that are supposed to be defined in the C99-specified stdint\&.h\&.
.PP
Shamefully, some platforms do not include stdint\&.h, so we need to replace it\&. (If you are on a platform like this, your C headers are now over 10 years out of date\&. You should bug them to do something about this\&.)
.PP
We define:
.PP
.IP "\fBev_uint64_t, ev_uint32_t, ev_uint16_t, ev_uint8_t \fP" 1c
unsigned integer types of exactly 64, 32, 16, and 8 bits respectively\&. 
.IP "\fBev_int64_t, ev_int32_t, ev_int16_t, ev_int8_t \fP" 1c
signed integer types of exactly 64, 32, 16, and 8 bits respectively\&. 
.IP "\fBev_uintptr_t, ev_intptr_t \fP" 1c
unsigned/signed integers large enough to hold a pointer without loss of bits\&. 
.IP "\fBev_ssize_t \fP" 1c
A signed type of the same size as size_t 
.IP "\fBev_off_t \fP" 1c
A signed type typically used to represent offsets within a (potentially large) file 
.PP

.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBev_uint64_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_int64_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_uint32_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_int32_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_uint16_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_int16_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_uint8_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_int8_t\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBev_uintptr_t\fP   ev_uint32_t"
.br
.ti -1c
.RI "#define \fBev_intptr_t\fP   ev_int32_t"
.br
.ti -1c
.RI "#define \fBev_ssize_t\fP   ssize_t"
.br
.ti -1c
.RI "#define \fBev_off_t\fP   \&.\&.\&."
.br
.in -1c
.in -1c
.PP
.RI "\fBLimits for integer types\fP"
.br
These macros hold the largest or smallest values possible for the ev_[u]int*_t types\&. 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEV_UINT64_MAX\fP   ((((ev_uint64_t)0xffffffffUL) << 32) | 0xffffffffUL)"
.br
.ti -1c
.RI "#define \fBEV_INT64_MAX\fP   ((((ev_int64_t) 0x7fffffffL) << 32) | 0xffffffffL)"
.br
.ti -1c
.RI "#define \fBEV_INT64_MIN\fP   ((\-EV_INT64_MAX) \- 1)"
.br
.ti -1c
.RI "#define \fBEV_UINT32_MAX\fP   ((ev_uint32_t)0xffffffffUL)"
.br
.ti -1c
.RI "#define \fBEV_INT32_MAX\fP   ((ev_int32_t) 0x7fffffffL)"
.br
.ti -1c
.RI "#define \fBEV_INT32_MIN\fP   ((\-EV_INT32_MAX) \- 1)"
.br
.ti -1c
.RI "#define \fBEV_UINT16_MAX\fP   ((ev_uint16_t)0xffffUL)"
.br
.ti -1c
.RI "#define \fBEV_INT16_MAX\fP   ((ev_int16_t) 0x7fffL)"
.br
.ti -1c
.RI "#define \fBEV_INT16_MIN\fP   ((\-EV_INT16_MAX) \- 1)"
.br
.ti -1c
.RI "#define \fBEV_UINT8_MAX\fP   255"
.br
.ti -1c
.RI "#define \fBEV_INT8_MAX\fP   127"
.br
.ti -1c
.RI "#define \fBEV_INT8_MIN\fP   ((\-EV_INT8_MAX) \- 1)"
.br
.in -1c
.in -1c
.PP
.RI "\fBLimits for SIZE_T and SSIZE_T\fP"
.br

.in +1c
.in +1c
.ti -1c
.RI "#define \fBEV_SIZE_MAX\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBEV_SSIZE_MAX\fP   \&.\&.\&."
.br
.ti -1c
.RI "#define \fBEV_SSIZE_MIN\fP   ((\-EV_SSIZE_MAX) \- 1)"
.br
.in -1c
.in -1c
.PP
.RI "\fBSocket error functions\fP"
.br
These functions are needed for making programs compatible between Windows and Unix-like platforms\&.
.PP
You see, Winsock handles socket errors differently from the rest of the world\&. Elsewhere, a socket error is like any other error and is stored in errno\&. But winsock functions require you to retrieve the error with a special function, and don't let you use strerror for the error codes\&. And handling EWOULDBLOCK is \&.\&.\&. different\&. 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEVUTIL_SOCKET_ERROR\fP()   \&.\&.\&."
.br
.RI "\fIReturn the most recent socket error\&. \fP"
.ti -1c
.RI "#define \fBEVUTIL_SET_SOCKET_ERROR\fP(errcode)   \&.\&.\&."
.br
.RI "\fIReplace the most recent socket error with errcode\&. \fP"
.ti -1c
.RI "#define \fBevutil_socket_geterror\fP(sock)   \&.\&.\&."
.br
.RI "\fIReturn the most recent socket error to occur on sock\&. \fP"
.ti -1c
.RI "#define \fBevutil_socket_error_to_string\fP(errcode)   \&.\&.\&."
.br
.RI "\fIConvert a socket error to a string\&. \fP"
.in -1c
.in -1c
.PP
.RI "\fBManipulation macros for struct timeval\&.\fP"
.br
We define replacements for timeradd, timersub, timerclear, timercmp, and timerisset\&. 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBevutil_timeradd\fP(tvp,  uvp,  vvp)"
.br
.ti -1c
.RI "#define \fBevutil_timersub\fP(tvp,  uvp,  vvp)"
.br
.ti -1c
.RI "#define \fBevutil_timerclear\fP(tvp)   (tvp)\->tv_sec = (tvp)\->tv_usec = 0"
.br
.in -1c
.in -1c
.PP
.RI "\fBevutil_getaddrinfo() error codes\fP"
.br
These values are possible error codes for \fBevutil_getaddrinfo()\fP and related functions\&. 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEVUTIL_EAI_ADDRFAMILY\fP   \-901"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_AGAIN\fP   \-902"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_BADFLAGS\fP   \-903"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_FAIL\fP   \-904"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_FAMILY\fP   \-905"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_MEMORY\fP   \-906"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_NODATA\fP   \-907"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_NONAME\fP   \-908"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_SERVICE\fP   \-909"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_SOCKTYPE\fP   \-910"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_SYSTEM\fP   \-911"
.br
.ti -1c
.RI "#define \fBEVUTIL_EAI_CANCEL\fP   \-90001"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_PASSIVE\fP   0x1000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_CANONNAME\fP   0x2000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_NUMERICHOST\fP   0x4000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_NUMERICSERV\fP   0x8000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_V4MAPPED\fP   0x10000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_ALL\fP   0x20000"
.br
.ti -1c
.RI "#define \fBEVUTIL_AI_ADDRCONFIG\fP   0x40000"
.br
.in -1c
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_ascii_strcasecmp\fP (const char *str1, const char *str2)"
.br
.RI "\fIAs strcasecmp, but always compares the characters in locale-independent ASCII\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_ascii_strncasecmp\fP (const char *str1, const char *str2, size_t n)"
.br
.RI "\fIAs strncasecmp, but always compares the characters in locale-independent ASCII\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_closesocket\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo the platform-specific call needed to close a socket returned from socket() or accept()\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_configure_monotonic_time\fP (struct \fBevutil_monotonic_timer\fP *timer, int flags)"
.br
.RI "\fISet up a struct \fBevutil_monotonic_timer\fP; flags can include EV_MONOT_PRECISE and EV_MONOT_FALLBACK\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_date_rfc1123\fP (char *date, const size_t datelen, const struct tm *tm)"
.br
.RI "\fIFormat a date string using RFC 1123 format (used in HTTP)\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevutil_freeaddrinfo\fP (struct \fBevutil_addrinfo\fP *ai)"
.br
.RI "\fIRelease storage allocated by evutil_getaddrinfo or evdns_getaddrinfo\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const char * \fBevutil_gai_strerror\fP (int err)"
.br
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_getaddrinfo\fP (const char *nodename, const char *servname, const struct \fBevutil_addrinfo\fP *hints_in, struct \fBevutil_addrinfo\fP **res)"
.br
.RI "\fIThis function clones getaddrinfo for systems that don't have it\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_gettime_monotonic\fP (struct \fBevutil_monotonic_timer\fP *timer, struct timeval *tp)"
.br
.RI "\fIQuery the current monotonic time from a struct \fBevutil_monotonic_timer\fP previously configured with \fBevutil_configure_monotonic_time()\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_gettimeofday\fP (struct timeval *tv, struct timezone *tz)"
.br
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const char * \fBevutil_inet_ntop\fP (int af, const void *src, char *dst, size_t len)"
.br
.RI "\fIReplacement for inet_ntop for platforms which lack it\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_inet_pton\fP (int af, const char *src, void *dst)"
.br
.RI "\fIReplacement for inet_pton for platforms which lack it\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_make_listen_socket_reuseable\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo platform-specific operations to make a listener socket reusable\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_make_listen_socket_reuseable_port\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo platform-specific operations to make a listener port reusable\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_make_socket_closeonexec\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo platform-specific operations as needed to close a socket upon a successful execution of one of the exec*() functions\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_make_socket_nonblocking\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo platform-specific operations as needed to make a socket nonblocking\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_make_tcp_listen_socket_deferred\fP (\fBevutil_socket_t\fP sock)"
.br
.RI "\fIDo platform-specific operations, if possible, to make a tcp listener socket defer accept()s until there is data to read\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevutil_monotonic_timer_free\fP (struct \fBevutil_monotonic_timer\fP *timer)"
.br
.RI "\fIFree a struct \fBevutil_monotonic_timer\fP that was allocated using \fBevutil_monotonic_timer_new()\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevutil_monotonic_timer\fP * \fBevutil_monotonic_timer_new\fP (void)"
.br
.RI "\fIAllocate a new struct \fBevutil_monotonic_timer\fP for use with the \fBevutil_configure_monotonic_time()\fP and \fBevutil_gettime_monotonic()\fP functions\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_parse_sockaddr_port\fP (const char *str, struct sockaddr *out, int *outlen)"
.br
.RI "\fIParse an IPv4 or IPv6 address, with optional port, from a string\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevutil_secure_rng_add_bytes\fP (const char *dat, size_t datlen)"
.br
.RI "\fISeed the random number generator with extra random bytes\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevutil_secure_rng_get_bytes\fP (void *buf, size_t n)"
.br
.RI "\fIGenerate n bytes of secure pseudorandom data, and store them in buf\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_secure_rng_init\fP (void)"
.br
.RI "\fISeed the secure random number generator if needed, and return 0 on success or -1 on failure\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_secure_rng_set_urandom_device_file\fP (char *fname)"
.br
.RI "\fISet a filename to use in place of /dev/urandom for seeding the secure PRNG\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_snprintf\fP (char *buf, size_t buflen, const char *format,\&.\&.\&.)"
.br
.RI "\fIReplacement for snprintf to get consistent behavior on platforms for which the return value of snprintf does not conform to C99\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_sockaddr_cmp\fP (const struct sockaddr *sa1, const struct sockaddr *sa2, int include_port)"
.br
.RI "\fICompare two sockaddrs; return 0 if they are equal, or less than 0 if sa1 preceeds sa2, or greater than 0 if sa1 follows sa2\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_socketpair\fP (int d, int type, int protocol, \fBevutil_socket_t\fP sv[2])"
.br
.RI "\fICreate two new sockets that are connected to each other\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL ev_int64_t \fBevutil_strtoll\fP (const char *s, char **endptr, int base)"
.br
.RI "\fIParse a 64-bit value from a string\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevutil_vsnprintf\fP (char *buf, size_t buflen, const char *format, va_list ap)"
.br
.RI "\fIReplacement for vsnprintf to get consistent behavior on platforms for which the return value of snprintf does not conform to C99\&. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Common convenience functions for cross-platform portability and related socket manipulations\&. 


.SH "Macro Definition Documentation"
.PP 
.SS "#define evutil_offsetof(type, field)   ((off_t)(&((type *)0)\->field))"

.PP
Replacement for offsetof on platforms that don't define it\&. 
.SS "#define EVUTIL_SOCKET_ERROR()   \&.\&.\&."

.PP
Return the most recent socket error\&. Not idempotent on all platforms\&. 
.SS "#define evutil_socket_error_to_string(errcode)   \&.\&.\&."

.PP
Convert a socket error to a string\&. 
.SS "#define evutil_socket_geterror(sock)   \&.\&.\&."

.PP
Return the most recent socket error to occur on sock\&. 
.SS "#define evutil_socket_t   int"

.PP
A type wide enough to hold the output of 'socket()' or 'accept()'\&. On Windows, this is an intptr_t; elsewhere, it is an int\&. 
.SS "#define evutil_timeradd(tvp, uvp, vvp)"
\fBValue:\fP
.PP
.nf
do {                                \
        (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;      \
        (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
        if ((vvp)->tv_usec >= 1000000) {            \
            (vvp)->tv_sec++;                \
            (vvp)->tv_usec -= 1000000;          \
        }                           \
    } while (0)
.fi
.SS "#define evutil_timercmp(tvp, uvp, cmp)"
\fBValue:\fP
.PP
.nf
(((tvp)->tv_sec == (uvp)->tv_sec) ?               \
     ((tvp)->tv_usec cmp (uvp)->tv_usec) :              \
     ((tvp)->tv_sec cmp (uvp)->tv_sec))
.fi
.PP
Return true iff the tvp is related to uvp according to the relational operator cmp\&. Recognized values for cmp are ==, <=, <, >=, and >\&. 
.SS "#define evutil_timersub(tvp, uvp, vvp)"
\fBValue:\fP
.PP
.nf
do {                              \
        (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;      \
        (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;   \
        if ((vvp)->tv_usec < 0) {               \
            (vvp)->tv_sec--;                \
            (vvp)->tv_usec += 1000000;          \
        }                           \
    } while (0)
.fi
.SH "Function Documentation"
.PP 
.SS "EVENT2_EXPORT_SYMBOL int evutil_ascii_strcasecmp (const char * str1, const char * str2)"

.PP
As strcasecmp, but always compares the characters in locale-independent ASCII\&. That's useful if you're handling data in ASCII-based protocols\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_ascii_strncasecmp (const char * str1, const char * str2, size_t n)"

.PP
As strncasecmp, but always compares the characters in locale-independent ASCII\&. That's useful if you're handling data in ASCII-based protocols\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_closesocket (\fBevutil_socket_t\fP sock)"

.PP
Do the platform-specific call needed to close a socket returned from socket() or accept()\&. 
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The socket to be closed 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int evutil_date_rfc1123 (char * date, const size_t datelen, const struct tm * tm)"

.PP
Format a date string using RFC 1123 format (used in HTTP)\&. If \fCtm\fP is NULL, current system's time will be used\&. The number of characters written will be returned\&. One should check if the return value is smaller than \fCdatelen\fP to check if the result is truncated or not\&. 
.SS "EVENT2_EXPORT_SYMBOL void evutil_freeaddrinfo (struct \fBevutil_addrinfo\fP * ai)"

.PP
Release storage allocated by evutil_getaddrinfo or evdns_getaddrinfo\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_getaddrinfo (const char * nodename, const char * servname, const struct \fBevutil_addrinfo\fP * hints_in, struct \fBevutil_addrinfo\fP ** res)"

.PP
This function clones getaddrinfo for systems that don't have it\&. For full details, see RFC 3493, section 6\&.1\&.
.PP
Limitations:
.IP "\(bu" 2
When the system has no getaddrinfo, we fall back to gethostbyname_r or gethostbyname, with their attendant issues\&.
.IP "\(bu" 2
The AI_V4MAPPED and AI_ALL flags are not currently implemented\&.
.PP
.PP
For a nonblocking variant, see evdns_getaddrinfo\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_gettime_monotonic (struct \fBevutil_monotonic_timer\fP * timer, struct timeval * tp)"

.PP
Query the current monotonic time from a struct \fBevutil_monotonic_timer\fP previously configured with \fBevutil_configure_monotonic_time()\fP\&. Monotonic time is guaranteed never to run in reverse, but is not necessarily epoch- based, or relative to any other definite point\&. Use it to make reliable measurements of elapsed time between events even when the system time may be changed\&.
.PP
It is not safe to use this funtion on the same timer from multiple threads\&. 
.SS "EVENT2_EXPORT_SYMBOL const char* evutil_inet_ntop (int af, const void * src, char * dst, size_t len)"

.PP
Replacement for inet_ntop for platforms which lack it\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_inet_pton (int af, const char * src, void * dst)"

.PP
Replacement for inet_pton for platforms which lack it\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_make_listen_socket_reuseable (\fBevutil_socket_t\fP sock)"

.PP
Do platform-specific operations to make a listener socket reusable\&. Specifically, we want to make sure that another program will be able to bind this address right after we've closed the listener\&.
.PP
This differs from Windows's interpretation of 'reusable', which allows multiple listeners to bind the same address at the same time\&.
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The socket to make reusable 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int evutil_make_listen_socket_reuseable_port (\fBevutil_socket_t\fP sock)"

.PP
Do platform-specific operations to make a listener port reusable\&. Specifically, we want to make sure that multiple programs which also set the same socket option will be able to bind, listen at the same time\&.
.PP
This is a feature available only to Linux 3\&.9+
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The socket to make reusable 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int evutil_make_socket_closeonexec (\fBevutil_socket_t\fP sock)"

.PP
Do platform-specific operations as needed to close a socket upon a successful execution of one of the exec*() functions\&. 
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The socket to be closed 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int evutil_make_socket_nonblocking (\fBevutil_socket_t\fP sock)"

.PP
Do platform-specific operations as needed to make a socket nonblocking\&. 
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The socket to make nonblocking 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int evutil_make_tcp_listen_socket_deferred (\fBevutil_socket_t\fP sock)"

.PP
Do platform-specific operations, if possible, to make a tcp listener socket defer accept()s until there is data to read\&. Not all platforms support this\&. You don't want to do this for every listener socket: only the ones that implement a protocol where the client transmits before the server needs to respond\&.
.PP
\fBParameters:\fP
.RS 4
\fIsock\fP The listening socket to to make deferred 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success (whether the operation is supported or not), -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevutil_monotonic_timer\fP* evutil_monotonic_timer_new (void)"

.PP
Allocate a new struct \fBevutil_monotonic_timer\fP for use with the \fBevutil_configure_monotonic_time()\fP and \fBevutil_gettime_monotonic()\fP functions\&. You must configure the timer with \fBevutil_configure_monotonic_time()\fP before using it\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_parse_sockaddr_port (const char * str, struct sockaddr * out, int * outlen)"

.PP
Parse an IPv4 or IPv6 address, with optional port, from a string\&. Recognized formats are:
.IP "\(bu" 2
[IPv6Address]:port
.IP "\(bu" 2
[IPv6Address]
.IP "\(bu" 2
IPv6Address
.IP "\(bu" 2
IPv4Address:port
.IP "\(bu" 2
IPv4Address
.PP
.PP
If no port is specified, the port in the output is set to 0\&.
.PP
\fBParameters:\fP
.RS 4
\fIstr\fP The string to parse\&. 
.br
\fIout\fP A struct sockaddr to hold the result\&. This should probably be a struct sockaddr_storage\&. 
.br
\fIoutlen\fP A pointer to the number of bytes that that 'out' can safely hold\&. Set to the number of bytes used in 'out' on success\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
-1 if the address is not well-formed, if the port is out of range, or if out is not large enough to hold the result\&. Otherwise returns 0 on success\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void evutil_secure_rng_add_bytes (const char * dat, size_t datlen)"

.PP
Seed the random number generator with extra random bytes\&. You should almost never need to call this function; it should be sufficient to invoke \fBevutil_secure_rng_init()\fP, or let Libevent take care of calling \fBevutil_secure_rng_init()\fP on its own\&.
.PP
If you call this function as a \fIreplacement\fP for the regular entropy sources, then you need to be sure that your input contains a fairly large amount of strong entropy\&. Doing so is notoriously hard: most people who try get it wrong\&. Watch out!
.PP
\fBParameters:\fP
.RS 4
\fIdat\fP a buffer full of a strong source of random numbers 
.br
\fIdatlen\fP the number of bytes to read from datlen 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void evutil_secure_rng_get_bytes (void * buf, size_t n)"

.PP
Generate n bytes of secure pseudorandom data, and store them in buf\&. Current versions of Libevent use an ARC4-based random number generator, seeded using the platform's entropy source (/dev/urandom on Unix-like systems; CryptGenRandom on Windows)\&. This is not actually as secure as it should be: ARC4 is a pretty lousy cipher, and the current implementation provides only rudimentary prediction- and backtracking-resistance\&. Don't use this for serious cryptographic applications\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_secure_rng_init (void)"

.PP
Seed the secure random number generator if needed, and return 0 on success or -1 on failure\&. It is okay to call this function more than once; it will still return 0 if the RNG has been successfully seeded and -1 if it can't be seeded\&.
.PP
Ordinarily you don't need to call this function from your own code; Libevent will seed the RNG itself the first time it needs good random numbers\&. You only need to call it if (a) you want to double-check that one of the seeding methods did succeed, or (b) you plan to drop the capability to seed (by chrooting, or dropping capabilities, or whatever), and you want to make sure that seeding happens before your program loses the ability to do it\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_secure_rng_set_urandom_device_file (char * fname)"

.PP
Set a filename to use in place of /dev/urandom for seeding the secure PRNG\&. Return 0 on success, -1 on failure\&.
.PP
Call this function BEFORE calling any other initialization or RNG functions\&.
.PP
(This string will \fINOT\fP be copied internally\&. Do not free it while any user of the secure RNG might be running\&. Don't pass anything other than a real /dev/\&.\&.\&.random device file here, or you might lose security\&.)
.PP
This API is unstable, and might change in a future libevent version\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_sockaddr_cmp (const struct sockaddr * sa1, const struct sockaddr * sa2, int include_port)"

.PP
Compare two sockaddrs; return 0 if they are equal, or less than 0 if sa1 preceeds sa2, or greater than 0 if sa1 follows sa2\&. If include_port is true, consider the port as well as the address\&. Only implemented for AF_INET and AF_INET6 addresses\&. The ordering is not guaranteed to remain the same between Libevent versions\&. 
.SS "EVENT2_EXPORT_SYMBOL int evutil_socketpair (int d, int type, int protocol, \fBevutil_socket_t\fP sv[2])"

.PP
Create two new sockets that are connected to each other\&. On Unix, this simply calls socketpair()\&. On Windows, it uses the loopback network interface on 127\&.0\&.0\&.1, and only AF_INET,SOCK_STREAM are supported\&.
.PP
(This may fail on some Windows hosts where firewall software has cleverly decided to keep 127\&.0\&.0\&.1 from talking to itself\&.)
.PP
Parameters and return values are as for socketpair() 
.SS "EVENT2_EXPORT_SYMBOL ev_int64_t evutil_strtoll (const char * s, char ** endptr, int base)"

.PP
Parse a 64-bit value from a string\&. Arguments are as for strtol\&. 
.SH "Author"
.PP 
Generated automatically by Doxygen for libevent from the source code\&.