diff --git a/bin/tests/name_test.c b/bin/tests/name_test.c index f5095c422c..97e46b62df 100644 --- a/bin/tests/name_test.c +++ b/bin/tests/name_test.c @@ -31,7 +31,7 @@ #include static void -print_wirename(isc_region_t name) { +print_wirename(isc_region_t *name) { unsigned char *ccurr, *cend; ccurr = name->base; @@ -49,9 +49,9 @@ main(int argc, char *argv[]) { unsigned char c[255]; unsigned int tbytes; dns_result_t result; - struct dns_name name, oname, compname; - struct isc_region source, target, r; - dns_name_t origin, comp; + dns_name_t name, oname, compname; + isc_region_t source, target, r; + dns_name_t *origin, *comp; isc_boolean_t downcase = ISC_FALSE; argc--; diff --git a/bin/tests/sock_test.c b/bin/tests/sock_test.c index 64e39775a8..ecc711b4dd 100644 --- a/bin/tests/sock_test.c +++ b/bin/tests/sock_test.c @@ -37,14 +37,14 @@ #include -isc_memctx_t mctx = NULL; +isc_memctx_t *mctx = NULL; int sockets_active = 0; -static isc_boolean_t my_send(isc_task_t task, isc_event_t event); -static isc_boolean_t my_recv(isc_task_t task, isc_event_t event); +static isc_boolean_t my_send(isc_task_t *task, isc_event_t *event); +static isc_boolean_t my_recv(isc_task_t *task, isc_event_t *event); static isc_boolean_t -my_callback(isc_task_t task, isc_event_t event) +my_callback(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -56,7 +56,7 @@ my_callback(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_shutdown(isc_task_t task, isc_event_t event) +my_shutdown(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -68,15 +68,15 @@ my_shutdown(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_recv(isc_task_t task, isc_event_t event) +my_recv(isc_task_t *task, isc_event_t *event) { - isc_socket_t sock; - isc_socketevent_t dev; - struct isc_region region; + isc_socket_t *sock; + isc_socketevent_t *dev; + isc_region_t region; char buf[1024]; sock = event->sender; - dev = (isc_socketevent_t)event; + dev = (isc_socketevent_t *)event; printf("Socket %s (sock %p, base %p, length %d, n %d, result %d)\n", (char *)(event->arg), sock, @@ -125,13 +125,13 @@ my_recv(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_send(isc_task_t task, isc_event_t event) +my_send(isc_task_t *task, isc_event_t *event) { - isc_socket_t sock; - isc_socketevent_t dev; + isc_socket_t *sock; + isc_socketevent_t *dev; sock = event->sender; - dev = (isc_socketevent_t)event; + dev = (isc_socketevent_t *)event; printf("my_send: %s task %p\n\t(sock %p, base %p, length %d, n %d, result %d)\n", (char *)(event->arg), task, sock, @@ -146,13 +146,13 @@ my_send(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_http_get(isc_task_t task, isc_event_t event) +my_http_get(isc_task_t *task, isc_event_t *event) { - isc_socket_t sock; - isc_socketevent_t dev; + isc_socket_t *sock; + isc_socketevent_t *dev; sock = event->sender; - dev = (isc_socketevent_t)event; + dev = (isc_socketevent_t *)event; printf("my_http_get: %s task %p\n\t(sock %p, base %p, length %d, n %d, result %d)\n", (char *)(event->arg), task, sock, @@ -168,15 +168,15 @@ my_http_get(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_connect(isc_task_t task, isc_event_t event) +my_connect(isc_task_t *task, isc_event_t *event) { - isc_socket_t sock; - isc_socket_connev_t dev; - struct isc_region region; + isc_socket_t *sock; + isc_socket_connev_t *dev; + isc_region_t region; char buf[1024]; sock = event->sender; - dev = (isc_socket_connev_t)event; + dev = (isc_socket_connev_t *)event; printf("%s: Connection result: %d\n", (char *)(event->arg), dev->result); @@ -205,15 +205,15 @@ my_connect(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_listen(isc_task_t task, isc_event_t event) +my_listen(isc_task_t *task, isc_event_t *event) { char *name = event->arg; - isc_socket_newconnev_t dev; - struct isc_region region; - isc_socket_t oldsock; + isc_socket_newconnev_t *dev; + isc_region_t region; + isc_socket_t *oldsock; int ret; - dev = (isc_socket_newconnev_t)event; + dev = (isc_socket_newconnev_t *)event; printf("newcon %s (task %p, oldsock %p, newsock %p, result %d)\n", name, task, event->sender, dev->newsocket, dev->result); @@ -252,14 +252,14 @@ my_listen(isc_task_t task, isc_event_t event) } static isc_boolean_t -timeout(isc_task_t task, isc_event_t event) +timeout(isc_task_t *task, isc_event_t *event) { - isc_socket_t sock = event->arg; + isc_socket_t *sock = event->arg; printf("Timeout, canceling IO on socket %p (task %p)\n", sock, task); isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_ALL); - isc_timer_detach((isc_timer_t *)&event->sender); + isc_timer_detach((isc_timer_t **)&event->sender); return (0); } @@ -267,17 +267,17 @@ timeout(isc_task_t task, isc_event_t event) int main(int argc, char *argv[]) { - isc_taskmgr_t manager = NULL; - isc_task_t t1 = NULL, t2 = NULL; - isc_timermgr_t timgr = NULL; - struct isc_time expires, now; - struct isc_interval interval; - isc_timer_t ti1 = NULL; - isc_event_t event; + isc_taskmgr_t *manager = NULL; + isc_task_t *t1 = NULL, *t2 = NULL; + isc_timermgr_t *timgr = NULL; + isc_time_t expires, now; + isc_interval_t interval; + isc_timer_t *ti1 = NULL; + isc_event_t *event; unsigned int workers; - isc_socketmgr_t socketmgr; - isc_socket_t so1, so2; - struct isc_sockaddr sockaddr; + isc_socketmgr_t *socketmgr; + isc_socket_t *so1, *so2; + isc_sockaddr_t sockaddr; unsigned int addrlen; diff --git a/bin/tests/task_test.c b/bin/tests/task_test.c index ef88c675aa..5a237fdc21 100644 --- a/bin/tests/task_test.c +++ b/bin/tests/task_test.c @@ -28,10 +28,10 @@ #include #include -isc_memctx_t mctx = NULL; +isc_memctx_t *mctx = NULL; static isc_boolean_t -my_callback(isc_task_t task, isc_event_t event) +my_callback(isc_task_t *task, isc_event_t *event) { int i, j; char *name = event->arg; @@ -46,7 +46,7 @@ my_callback(isc_task_t task, isc_event_t event) } static isc_boolean_t -my_shutdown(isc_task_t task, isc_event_t event) { +my_shutdown(isc_task_t *task, isc_event_t *event) { char *name = event->arg; printf("shutdown %s (%p)\n", name, task); @@ -56,7 +56,7 @@ my_shutdown(isc_task_t task, isc_event_t event) { } static isc_boolean_t -my_tick(isc_task_t task, isc_event_t event) +my_tick(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -68,13 +68,13 @@ my_tick(isc_task_t task, isc_event_t event) void main(int argc, char *argv[]) { - isc_taskmgr_t manager = NULL; - isc_task_t t1 = NULL, t2 = NULL; - isc_task_t t3 = NULL, t4 = NULL; - isc_event_t event; + isc_taskmgr_t *manager = NULL; + isc_task_t *t1 = NULL, *t2 = NULL; + isc_task_t *t3 = NULL, *t4 = NULL; + isc_event_t *event; unsigned int workers; - isc_timermgr_t timgr; - isc_timer_t ti1, ti2; + isc_timermgr_t *timgr; + isc_timer_t *ti1, *ti2; struct isc_time absolute; struct isc_interval interval; diff --git a/bin/tests/timer_test.c b/bin/tests/timer_test.c index 4d1c8df65c..f74b91ab45 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/timer_test.c @@ -28,13 +28,13 @@ #include #include -isc_memctx_t mctx = NULL; -isc_task_t t1, t2, t3; -isc_timer_t ti1, ti2, ti3; +isc_memctx_t *mctx = NULL; +isc_task_t *t1, *t2, *t3; +isc_timer_t *ti1, *ti2, *ti3; int tick_count = 0; static isc_boolean_t -shutdown_task(isc_task_t task, isc_event_t event) { +shutdown_task(isc_task_t *task, isc_event_t *event) { char *name = event->arg; printf("task %p shutdown %s\n", task, name); @@ -44,7 +44,7 @@ shutdown_task(isc_task_t task, isc_event_t event) { } static isc_boolean_t -tick(isc_task_t task, isc_event_t event) +tick(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -57,8 +57,8 @@ tick(isc_task_t task, isc_event_t event) isc_timer_touch(ti3); if (ti3 != NULL && tick_count == 7) { - struct isc_time expires, now; - struct isc_interval interval; + isc_time_t expires, now; + isc_interval_t interval; (void)isc_time_get(&now); isc_interval_set(&interval, 5, 0); @@ -76,7 +76,7 @@ tick(isc_task_t task, isc_event_t event) } static isc_boolean_t -timeout(isc_task_t task, isc_event_t event) +timeout(isc_task_t *task, isc_event_t *event) { char *name = event->arg; char *type; @@ -103,11 +103,11 @@ timeout(isc_task_t task, isc_event_t event) void main(int argc, char *argv[]) { - isc_taskmgr_t manager = NULL; - isc_timermgr_t timgr = NULL; + isc_taskmgr_t *manager = NULL; + isc_timermgr_t *timgr = NULL; unsigned int workers; - struct isc_time expires, now; - struct isc_interval interval; + isc_time_t expires, now; + isc_interval_t interval; if (argc > 1) workers = atoi(argv[1]); diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 8eacdedd19..3873b349d0 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -18,6 +18,8 @@ #ifndef DNS_NAME_H #define DNS_NAME_H 1 +#include + /***** ***** Module Info *****/ @@ -93,7 +95,7 @@ *** Properties ***/ -dns_labeltype_t dns_label_type(dns_label_t label); +dns_labeltype_t dns_label_type(dns_label_t *label); /* * Get the type of 'label'. * @@ -111,7 +113,7 @@ dns_labeltype_t dns_label_type(dns_label_t label); *** Bitstring Labels ***/ -unsigned int dns_label_countbits(dns_label_t label); +unsigned int dns_label_countbits(dns_label_t *label); /* * The number of bits in a bitstring label. * @@ -127,7 +129,7 @@ unsigned int dns_label_countbits(dns_label_t label); * The number of bits in the bitstring label. */ -dns_bitlabel_t dns_label_getbit(dns_label_t label, unsigned int n); +dns_bitlabel_t dns_label_getbit(dns_label_t *label, unsigned int n); /* * The 'n'th most significant bit of 'label'. * @@ -179,13 +181,13 @@ struct dns_name { unsigned char offsets[128]; }; -extern dns_name_t dns_rootname; +extern dns_name_t *dns_rootname; /*** *** Initialization ***/ -void dns_name_init(dns_name_t name); +void dns_name_init(dns_name_t *name); /* * Make 'name' empty. * @@ -201,7 +203,7 @@ void dns_name_init(dns_name_t name); *** Properties ***/ -isc_boolean_t dns_name_isabsolute(dns_name_t name); +isc_boolean_t dns_name_isabsolute(dns_name_t *name); /* * Does 'name' end in the root label? * @@ -220,7 +222,7 @@ isc_boolean_t dns_name_isabsolute(dns_name_t name); *** Comparisons ***/ -int dns_name_compare(dns_name_t name1, dns_name_t name2); +int dns_name_compare(dns_name_t *name1, dns_name_t *name2); /* * Determine the relative ordering under the DNSSEC order relation of * 'name1' and 'name2'. @@ -241,7 +243,7 @@ int dns_name_compare(dns_name_t name1, dns_name_t name2); */ isc_boolean_t -dns_name_issubdomain(dns_name_t name1, dns_name_t name2); +dns_name_issubdomain(dns_name_t *name1, dns_name_t *name2); /* * Is 'name1' a subdomain of 'name2'? * @@ -273,7 +275,7 @@ dns_name_issubdomain(dns_name_t name1, dns_name_t name2); *** Labels ***/ -unsigned int dns_name_countlabels(dns_name_t name); +unsigned int dns_name_countlabels(dns_name_t *name); /* * How many labels does 'name' have? * @@ -292,7 +294,7 @@ unsigned int dns_name_countlabels(dns_name_t name); * The number of labels in 'name'. */ -void dns_name_getlabel(dns_name_t name, unsigned int n, dns_label_t label); +void dns_name_getlabel(dns_name_t *name, unsigned int n, dns_label_t *label); /* * Make 'label' refer to the 'n'th least significant label of 'name'. * @@ -309,10 +311,10 @@ void dns_name_getlabel(dns_name_t name, unsigned int n, dns_label_t label); * n < dns_label_countlabels(name) */ -void dns_name_getlabelsequence(dns_name_t source, +void dns_name_getlabelsequence(dns_name_t *source, unsigned int first, unsigned int n, - dns_name_t target); + dns_name_t *target); /* * Make 'target' refer to the 'n' labels including and following 'first' * in 'source'. @@ -332,7 +334,7 @@ void dns_name_getlabelsequence(dns_name_t source, *** Conversions ***/ -void dns_name_fromregion(dns_name_t name, isc_region_t r); +void dns_name_fromregion(dns_name_t *name, isc_region_t *r); /* * Make 'name' refer to region 'r'. * @@ -342,7 +344,7 @@ void dns_name_fromregion(dns_name_t name, isc_region_t r); * The length of 'r' is <= 255. */ -void dns_name_toregion(dns_name_t name, isc_region_t r); +void dns_name_toregion(dns_name_t *name, isc_region_t *r); /* * Make 'r' refer to 'name'. * @@ -353,11 +355,11 @@ void dns_name_toregion(dns_name_t name, isc_region_t r); * 'r' is a valid region. */ -dns_result_t dns_name_fromwire(dns_name_t name, - isc_region_t source, - dns_decompression_t dctx, +dns_result_t dns_name_fromwire(dns_name_t *name, + isc_region_t *source, + dns_decompression_t *dctx, isc_boolean_t downcase, - isc_region_t target); + isc_region_t *target); /* * Copy the possibly-compressed name at source into target, decompressing it. * @@ -404,9 +406,9 @@ dns_result_t dns_name_fromwire(dns_name_t name, * Resource Limit: Not enough space in buffer */ -dns_result_t dns_name_towire(dns_name_t name, - dns_compression_t cctx, - isc_region_t target, unsigned int *bytesp); +dns_result_t dns_name_towire(dns_name_t *name, + dns_compression_t *cctx, + isc_region_t *target, unsigned int *bytesp); /* * Convert 'name' into wire format, compressing it as specified by the * compression context 'cctx', and storing the result in 'target'. @@ -439,11 +441,11 @@ dns_result_t dns_name_towire(dns_name_t name, * Resource Limit: Not enough space in buffer */ -dns_result_t dns_name_fromtext(dns_name_t name, - isc_region_t source, - dns_name_t origin, +dns_result_t dns_name_fromtext(dns_name_t *name, + isc_region_t *source, + dns_name_t *origin, isc_boolean_t downcase, - isc_region_t target); + isc_region_t *target); /* * Convert the textual representation of a DNS name at source * into uncompressed wire form stored in target. @@ -483,9 +485,9 @@ dns_result_t dns_name_fromtext(dns_name_t name, * Resource Limit: Not enough space in buffer */ -dns_result_t dns_name_totext(dns_name_t name, +dns_result_t dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, - isc_region_t target, unsigned int *bytesp); + isc_region_t *target, unsigned int *bytesp); /* * Convert 'name' into text format, storing the result in 'target'. * diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index 761b634754..ec1a9b7eab 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -22,10 +22,10 @@ #include typedef isc_region_t dns_label_t; -typedef struct dns_name * dns_name_t; -typedef struct dns_lex * dns_lex_t; -typedef struct dns_compression * dns_compression_t; -typedef struct dns_decompression * dns_decompression_t; +typedef struct dns_name dns_name_t; +typedef struct dns_lex dns_lex_t; +typedef struct dns_compression dns_compression_t; +typedef struct dns_decompression dns_decompression_t; typedef enum { dns_labeltype_ordinary = 0, diff --git a/lib/dns/name.c b/lib/dns/name.c index cc4765c97a..a94d44df07 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -115,10 +115,10 @@ static unsigned char maptolower[] = { static struct dns_name root = { "", 1, 1 }; -dns_name_t dns_rootname = &root; +dns_name_t *dns_rootname = &root; -static void set_offsets(dns_name_t, isc_boolean_t); -static void compact(dns_name_t); +static void set_offsets(dns_name_t *, isc_boolean_t); +static void compact(dns_name_t *); /* * Yes, get_bit and set_bit are lame. We define them here so they can @@ -150,7 +150,7 @@ set_bit(unsigned char *array, unsigned int index, unsigned int bit) { } dns_labeltype_t -dns_label_type(dns_label_t label) { +dns_label_type(dns_label_t *label) { /* * Get the type of 'label'. */ @@ -167,7 +167,7 @@ dns_label_type(dns_label_t label) { } unsigned int -dns_label_countbits(dns_label_t label) { +dns_label_countbits(dns_label_t *label) { unsigned int count; /* @@ -186,7 +186,7 @@ dns_label_countbits(dns_label_t label) { } dns_bitlabel_t -dns_label_getbit(dns_label_t label, unsigned int n) { +dns_label_getbit(dns_label_t *label, unsigned int n) { unsigned int count, bit; /* @@ -213,7 +213,7 @@ dns_label_getbit(dns_label_t label, unsigned int n) { } void -dns_name_init(dns_name_t name) { +dns_name_init(dns_name_t *name) { /* * Make 'name' empty. */ @@ -224,7 +224,7 @@ dns_name_init(dns_name_t name) { } isc_boolean_t -dns_name_isabsolute(dns_name_t name) { +dns_name_isabsolute(dns_name_t *name) { /* * Does 'name' end in the root label? */ @@ -237,7 +237,7 @@ dns_name_isabsolute(dns_name_t name) { } int -dns_name_compare(dns_name_t name1, dns_name_t name2) { +dns_name_compare(dns_name_t *name1, dns_name_t *name2) { unsigned int l1, l2, l, count1, count2, count; unsigned int b1, b2, n; unsigned char c1, c2; @@ -341,7 +341,7 @@ dns_name_compare(dns_name_t name1, dns_name_t name2) { } isc_boolean_t -dns_name_issubdomain(dns_name_t name1, dns_name_t name2) { +dns_name_issubdomain(dns_name_t *name1, dns_name_t *name2) { isc_boolean_t a1, a2; unsigned int l1, l2, count1, count2; unsigned int b1, b2, n; @@ -417,7 +417,7 @@ dns_name_issubdomain(dns_name_t name1, dns_name_t name2) { } unsigned int -dns_name_countlabels(dns_name_t name) { +dns_name_countlabels(dns_name_t *name) { /* * How many labels does 'name' have? */ @@ -430,7 +430,7 @@ dns_name_countlabels(dns_name_t name) { } void -dns_name_getlabel(dns_name_t name, unsigned int n, dns_label_t label) { +dns_name_getlabel(dns_name_t *name, unsigned int n, dns_label_t *label) { /* * Make 'label' refer to the 'n'th least significant label of 'name'. */ @@ -447,9 +447,9 @@ dns_name_getlabel(dns_name_t name, unsigned int n, dns_label_t label) { } void -dns_name_getlabelsequence(dns_name_t source, +dns_name_getlabelsequence(dns_name_t *source, unsigned int first, unsigned int n, - dns_name_t target) + dns_name_t *target) { /* * Make 'target' refer to the 'n' labels including and following @@ -473,7 +473,7 @@ dns_name_getlabelsequence(dns_name_t source, } void -dns_name_fromregion(dns_name_t name, isc_region_t r) { +dns_name_fromregion(dns_name_t *name, isc_region_t *r) { /* * Make 'name' refer to region 'r'. */ @@ -492,7 +492,7 @@ dns_name_fromregion(dns_name_t name, isc_region_t r) { } void -dns_name_toregion(dns_name_t name, isc_region_t r) { +dns_name_toregion(dns_name_t *name, isc_region_t *r) { /* * Make 'r' refer to 'name'. */ @@ -506,9 +506,9 @@ dns_name_toregion(dns_name_t name, isc_region_t r) { dns_result_t -dns_name_fromtext(dns_name_t name, isc_region_t source, - dns_name_t origin, isc_boolean_t downcase, - isc_region_t target) +dns_name_fromtext(dns_name_t *name, isc_region_t *source, + dns_name_t *origin, isc_boolean_t downcase, + isc_region_t *target) { unsigned char *ndata, *label; char *tdata; @@ -957,8 +957,8 @@ dns_name_fromtext(dns_name_t name, isc_region_t source, } dns_result_t -dns_name_totext(dns_name_t name, isc_boolean_t omit_final_dot, - isc_region_t target, unsigned int *bytesp) +dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, + isc_region_t *target, unsigned int *bytesp) { unsigned char *ndata; char *tdata; @@ -1113,7 +1113,7 @@ dns_name_totext(dns_name_t name, isc_boolean_t omit_final_dot, } static void -set_offsets(dns_name_t name, isc_boolean_t set_labels) { +set_offsets(dns_name_t *name, isc_boolean_t set_labels) { unsigned int offset, count, nlabels, nrem, n; unsigned char *ndata; @@ -1151,7 +1151,7 @@ set_offsets(dns_name_t name, isc_boolean_t set_labels) { } static void -compact(dns_name_t name) { +compact(dns_name_t *name) { unsigned char *head, *curr, *last; unsigned int count, n, bit; unsigned int headbits, currbits, tailbits, newbits; diff --git a/lib/isc/assertions.c b/lib/isc/assertions.c index 70d85ddacd..ff7abaf6f1 100644 --- a/lib/isc/assertions.c +++ b/lib/isc/assertions.c @@ -34,14 +34,14 @@ static void default_callback(char *, int, isc_assertiontype_t, char *); * Public. */ -isc_assertioncallback_t __isc_assertion_failed = default_callback; +isc_assertioncallback_t isc_assertion_failed = default_callback; void isc_assertion_setcallback(isc_assertioncallback_t cb) { if (cb == NULL) - __isc_assertion_failed = default_callback; + isc_assertion_failed = default_callback; else - __isc_assertion_failed = cb; + isc_assertion_failed = cb; } char * diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 94b2f23fa8..3188633f0d 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -25,7 +25,7 @@ #define VALID_BUFFER(b) ((b) != NULL) void -isc_buffer_init(isc_buffer_t b, unsigned char *base, unsigned int length) { +isc_buffer_init(isc_buffer_t *b, unsigned char *base, unsigned int length) { /* * Make 'b' refer to the 'length'-byte region starting at base. */ @@ -40,7 +40,7 @@ isc_buffer_init(isc_buffer_t b, unsigned char *base, unsigned int length) { } void -isc_buffer_region(isc_buffer_t b, isc_region_t r) { +isc_buffer_region(isc_buffer_t *b, isc_region_t *r) { /* * Make 'r' refer to the region of 'b'. */ @@ -53,7 +53,7 @@ isc_buffer_region(isc_buffer_t b, isc_region_t r) { } void -isc_buffer_used(isc_buffer_t b, isc_region_t r) { +isc_buffer_used(isc_buffer_t *b, isc_region_t *r) { /* * Make 'r' refer to the used region of 'b'. */ @@ -66,7 +66,7 @@ isc_buffer_used(isc_buffer_t b, isc_region_t r) { } void -isc_buffer_available(isc_buffer_t b, isc_region_t r) { +isc_buffer_available(isc_buffer_t *b, isc_region_t *r) { /* * Make 'r' refer to the available region of 'b'. */ @@ -80,7 +80,7 @@ isc_buffer_available(isc_buffer_t b, isc_region_t r) { void -isc_buffer_add(isc_buffer_t b, unsigned int n) { +isc_buffer_add(isc_buffer_t *b, unsigned int n) { /* * Increase the 'used' region of 'b' by 'n' bytes. */ @@ -92,7 +92,7 @@ isc_buffer_add(isc_buffer_t b, unsigned int n) { } void -isc_buffer_subtract(isc_buffer_t b, unsigned int n) { +isc_buffer_subtract(isc_buffer_t *b, unsigned int n) { /* * Decrease the 'used' region of 'b' by 'n' bytes. */ @@ -104,7 +104,7 @@ isc_buffer_subtract(isc_buffer_t b, unsigned int n) { } void -isc_buffer_clear(isc_buffer_t b) { +isc_buffer_clear(isc_buffer_t *b) { /* * Make the used region empty. */ @@ -114,7 +114,7 @@ isc_buffer_clear(isc_buffer_t b) { } void -isc_buffer_consumed(isc_buffer_t b, isc_region_t r) { +isc_buffer_consumed(isc_buffer_t *b, isc_region_t *r) { /* * Make 'r' refer to the consumed region of 'b'. */ @@ -127,7 +127,7 @@ isc_buffer_consumed(isc_buffer_t b, isc_region_t r) { } void -isc_buffer_remaining(isc_buffer_t b, isc_region_t r) { +isc_buffer_remaining(isc_buffer_t *b, isc_region_t *r) { /* * Make 'r' refer to the remaining region of 'b'. */ @@ -140,7 +140,7 @@ isc_buffer_remaining(isc_buffer_t b, isc_region_t r) { } void -isc_buffer_first(isc_buffer_t b) { +isc_buffer_first(isc_buffer_t *b) { /* * Make the consumed region empty. */ @@ -151,7 +151,7 @@ isc_buffer_first(isc_buffer_t b) { } void -isc_buffer_forward(isc_buffer_t b, unsigned int n) { +isc_buffer_forward(isc_buffer_t *b, unsigned int n) { /* * Decrease the 'used' region of 'b' by 'n' bytes. */ @@ -163,7 +163,7 @@ isc_buffer_forward(isc_buffer_t b, unsigned int n) { } void -isc_buffer_back(isc_buffer_t b, unsigned int n) { +isc_buffer_back(isc_buffer_t *b, unsigned int n) { /* * Decrease the 'consumed' region of 'b' by 'n' bytes. */ @@ -175,7 +175,7 @@ isc_buffer_back(isc_buffer_t b, unsigned int n) { } void -isc_buffer_compact(isc_buffer_t b) { +isc_buffer_compact(isc_buffer_t *b) { unsigned int length; /* diff --git a/lib/isc/heap.c b/lib/isc/heap.c index eaeb1d054d..7ba48a1829 100644 --- a/lib/isc/heap.c +++ b/lib/isc/heap.c @@ -49,7 +49,7 @@ struct isc_heap { unsigned int magic; - isc_memctx_t mctx; + isc_memctx_t * mctx; unsigned int size; unsigned int size_increment; unsigned int last; @@ -59,11 +59,11 @@ struct isc_heap { }; isc_result_t -isc_heap_create(isc_memctx_t mctx, isc_heapcompare_t compare, +isc_heap_create(isc_memctx_t *mctx, isc_heapcompare_t compare, isc_heapindex_t index, unsigned int size_increment, - isc_heap_t *heapp) + isc_heap_t **heapp) { - isc_heap_t heap; + isc_heap_t *heap; REQUIRE(heapp != NULL && *heapp == NULL); REQUIRE(compare != NULL); @@ -89,8 +89,8 @@ isc_heap_create(isc_memctx_t mctx, isc_heapcompare_t compare, } void -isc_heap_destroy(isc_heap_t *heapp) { - isc_heap_t heap; +isc_heap_destroy(isc_heap_t **heapp) { + isc_heap_t *heap; REQUIRE(heapp != NULL); heap = *heapp; @@ -106,7 +106,7 @@ isc_heap_destroy(isc_heap_t *heapp) { } static isc_boolean_t -resize(isc_heap_t heap) { +resize(isc_heap_t *heap) { void **new_array; size_t new_size; @@ -128,7 +128,7 @@ resize(isc_heap_t heap) { } static void -float_up(isc_heap_t heap, unsigned int i, void *elt) { +float_up(isc_heap_t *heap, unsigned int i, void *elt) { unsigned int p; for ( p = heap_parent(i); @@ -144,7 +144,7 @@ float_up(isc_heap_t heap, unsigned int i, void *elt) { } static void -sink_down(isc_heap_t heap, unsigned int i, void *elt) { +sink_down(isc_heap_t *heap, unsigned int i, void *elt) { unsigned int j, size, half_size; size = heap->last; @@ -168,7 +168,7 @@ sink_down(isc_heap_t heap, unsigned int i, void *elt) { } isc_result_t -isc_heap_insert(isc_heap_t heap, void *elt) { +isc_heap_insert(isc_heap_t *heap, void *elt) { unsigned int i; REQUIRE(VALID_HEAP(heap)); @@ -183,7 +183,7 @@ isc_heap_insert(isc_heap_t heap, void *elt) { } void -isc_heap_delete(isc_heap_t heap, unsigned int i) { +isc_heap_delete(isc_heap_t *heap, unsigned int i) { void *elt; REQUIRE(VALID_HEAP(heap)); @@ -195,7 +195,7 @@ isc_heap_delete(isc_heap_t heap, unsigned int i) { } void -isc_heap_increased(isc_heap_t heap, unsigned int i) { +isc_heap_increased(isc_heap_t *heap, unsigned int i) { REQUIRE(VALID_HEAP(heap)); REQUIRE(i >= 1 && i <= heap->last); @@ -203,7 +203,7 @@ isc_heap_increased(isc_heap_t heap, unsigned int i) { } void -isc_heap_decreased(isc_heap_t heap, unsigned int i) { +isc_heap_decreased(isc_heap_t *heap, unsigned int i) { REQUIRE(VALID_HEAP(heap)); REQUIRE(i >= 1 && i <= heap->last); @@ -211,7 +211,7 @@ isc_heap_decreased(isc_heap_t heap, unsigned int i) { } void * -isc_heap_element(isc_heap_t heap, unsigned int i) { +isc_heap_element(isc_heap_t *heap, unsigned int i) { REQUIRE(VALID_HEAP(heap)); REQUIRE(i >= 1 && i <= heap->last); @@ -219,7 +219,7 @@ isc_heap_element(isc_heap_t heap, unsigned int i) { } void -isc_heap_foreach(isc_heap_t heap, isc_heapaction_t action, void *uap) { +isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap) { unsigned int i; REQUIRE(VALID_HEAP(heap)); diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index 214dcf3185..36c2a94874 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -16,7 +16,7 @@ */ /* - * $Id: assertions.h,v 1.2 1998/12/12 20:47:40 halley Exp $ + * $Id: assertions.h,v 1.3 1998/12/13 23:45:03 halley Exp $ */ #ifndef ISC_ASSERTIONS_H @@ -32,10 +32,7 @@ typedef enum { typedef void (*isc_assertioncallback_t)(char *, int, isc_assertiontype_t, char *); -extern isc_assertioncallback_t __isc_assertion_failed; - -#define isc_assertion_setcallback __isc_assertion_setcallback -#define isc_assertion_typetotext __isc_assertion_typetotext +extern isc_assertioncallback_t isc_assertion_failed; void isc_assertion_setcallback(isc_assertioncallback_t); char *isc_assertion_typetotext(isc_assertiontype_t type); @@ -73,9 +70,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type); #if CHECK_REQUIRE != 0 #define REQUIRE(cond) \ ((void) ((cond) || \ - ((__isc_assertion_failed)(__FILE__, __LINE__, \ - isc_assertiontype_require, \ - #cond), 0))) + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_require, \ + #cond), 0))) #else #define REQUIRE(cond) ((void) 0) #endif /* CHECK_REQUIRE */ @@ -83,9 +80,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type); #if CHECK_ENSURE != 0 #define ENSURE(cond) \ ((void) ((cond) || \ - ((__isc_assertion_failed)(__FILE__, __LINE__, \ - isc_assertiontype_ensure, \ - #cond), 0))) + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_ensure, \ + #cond), 0))) #else #define ENSURE(cond) ((void) 0) #endif /* CHECK_ENSURE */ @@ -93,9 +90,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type); #if CHECK_INSIST != 0 #define INSIST(cond) \ ((void) ((cond) || \ - ((__isc_assertion_failed)(__FILE__, __LINE__, \ - isc_assertiontype_insist, \ - #cond), 0))) + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_insist, \ + #cond), 0))) #else #define INSIST(cond) ((void) 0) #endif /* CHECK_INSIST */ @@ -103,9 +100,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type); #if CHECK_INVARIANT != 0 #define INVARIANT(cond) \ ((void) ((cond) || \ - ((__isc_assertion_failed)(__FILE__, __LINE__, \ - isc_assertiontype_invariant, \ - #cond), 0))) + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_invariant, \ + #cond), 0))) #else #define INVARIANT(cond) ((void) 0) #endif /* CHECK_INVARIANT */ diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 0defc701e2..e913be74c8 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -92,7 +92,7 @@ typedef struct isc_buffer { unsigned char * current; unsigned int length; unsigned int used; -} *isc_buffer_t; +} isc_buffer_t; /*** @@ -101,7 +101,7 @@ typedef struct isc_buffer { void -isc_buffer_init(isc_buffer_t b, unsigned char *base, unsigned int length); +isc_buffer_init(isc_buffer_t *b, unsigned char *base, unsigned int length); /* * Make 'b' refer to the 'length'-byte region starting at base. * @@ -114,7 +114,7 @@ isc_buffer_init(isc_buffer_t b, unsigned char *base, unsigned int length); */ void -isc_buffer_region(isc_buffer_t b, isc_region_t r); +isc_buffer_region(isc_buffer_t *b, isc_region_t *r); /* * Make 'r' refer to the region of 'b'. * @@ -126,7 +126,7 @@ isc_buffer_region(isc_buffer_t b, isc_region_t r); */ void -isc_buffer_used(isc_buffer_t b, isc_region_t r); +isc_buffer_used(isc_buffer_t *b, isc_region_t *r); /* * Make 'r' refer to the used region of 'b'. * @@ -138,7 +138,7 @@ isc_buffer_used(isc_buffer_t b, isc_region_t r); */ void -isc_buffer_available(isc_buffer_t b, isc_region_t r); +isc_buffer_available(isc_buffer_t *b, isc_region_t *r); /* * Make 'r' refer to the available region of 'b'. * @@ -150,7 +150,7 @@ isc_buffer_available(isc_buffer_t b, isc_region_t r); */ void -isc_buffer_add(isc_buffer_t b, unsigned int n); +isc_buffer_add(isc_buffer_t *b, unsigned int n); /* * Increase the 'used' region of 'b' by 'n' bytes. * @@ -164,7 +164,7 @@ isc_buffer_add(isc_buffer_t b, unsigned int n); void -isc_buffer_subtract(isc_buffer_t b, unsigned int n); +isc_buffer_subtract(isc_buffer_t *b, unsigned int n); /* * Decrease the 'used' region of 'b' by 'n' bytes. * @@ -177,7 +177,7 @@ isc_buffer_subtract(isc_buffer_t b, unsigned int n); */ void -isc_buffer_clear(isc_buffer_t b); +isc_buffer_clear(isc_buffer_t *b); /* * Make the used region empty. * @@ -192,7 +192,7 @@ isc_buffer_clear(isc_buffer_t b); */ void -isc_buffer_consumed(isc_buffer_t b, isc_region_t r); +isc_buffer_consumed(isc_buffer_t *b, isc_region_t *r); /* * Make 'r' refer to the consumed region of 'b'. * @@ -204,7 +204,7 @@ isc_buffer_consumed(isc_buffer_t b, isc_region_t r); */ void -isc_buffer_remaining(isc_buffer_t b, isc_region_t r); +isc_buffer_remaining(isc_buffer_t *b, isc_region_t *r); /* * Make 'r' refer to the remaining region of 'b'. * @@ -216,7 +216,7 @@ isc_buffer_remaining(isc_buffer_t b, isc_region_t r); */ void -isc_buffer_first(isc_buffer_t b); +isc_buffer_first(isc_buffer_t *b); /* * Make the consumed region empty. * @@ -231,7 +231,7 @@ isc_buffer_first(isc_buffer_t b); */ void -isc_buffer_forward(isc_buffer_t b, unsigned int n); +isc_buffer_forward(isc_buffer_t *b, unsigned int n); /* * Decrease the 'used' region of 'b' by 'n' bytes. * @@ -244,7 +244,7 @@ isc_buffer_forward(isc_buffer_t b, unsigned int n); */ void -isc_buffer_back(isc_buffer_t b, unsigned int n); +isc_buffer_back(isc_buffer_t *b, unsigned int n); /* * Decrease the 'consumed' region of 'b' by 'n' bytes. * @@ -257,7 +257,7 @@ isc_buffer_back(isc_buffer_t b, unsigned int n); */ void -isc_buffer_compact(isc_buffer_t b); +isc_buffer_compact(isc_buffer_t *b); /* * Compact the used region by moving the remaining region so it occurs * at the start of the buffer. The used region is shrunk by the size of diff --git a/lib/isc/include/isc/heap.h b/lib/isc/include/isc/heap.h index 7cfa90d4ea..ca60db2166 100644 --- a/lib/isc/include/isc/heap.h +++ b/lib/isc/include/isc/heap.h @@ -28,23 +28,14 @@ typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *); typedef void (*isc_heapindex_t)(void *, unsigned int); typedef void (*isc_heapaction_t)(void *, void *); -typedef struct isc_heap *isc_heap_t; +typedef struct isc_heap isc_heap_t; -#define isc_heap_create __isc_heap_create -#define isc_heap_destroy __isc_heap_destroy -#define isc_heap_insert __isc_heap_insert -#define isc_heap_delete __isc_heap_delete -#define isc_heap_increased __isc_heap_increased -#define isc_heap_decreased __isc_heap_decreased -#define isc_heap_element __isc_heap_element -#define isc_heap_foreach __isc_heap_foreach - -isc_result_t isc_heap_create(isc_memctx_t, isc_heapcompare_t, - isc_heapindex_t, unsigned int, isc_heap_t *); -void isc_heap_destroy(isc_heap_t *); -isc_result_t isc_heap_insert(isc_heap_t, void *); -void isc_heap_delete(isc_heap_t, unsigned int); -void isc_heap_increased(isc_heap_t, unsigned int); -void isc_heap_decreased(isc_heap_t, unsigned int); -void * isc_heap_element(isc_heap_t, unsigned int); -void isc_heap_foreach(isc_heap_t, isc_heapaction_t, void *); +isc_result_t isc_heap_create(isc_memctx_t *, isc_heapcompare_t, + isc_heapindex_t, unsigned int, isc_heap_t **); +void isc_heap_destroy(isc_heap_t **); +isc_result_t isc_heap_insert(isc_heap_t *, void *); +void isc_heap_delete(isc_heap_t *, unsigned int); +void isc_heap_increased(isc_heap_t *, unsigned int); +void isc_heap_decreased(isc_heap_t *, unsigned int); +void * isc_heap_element(isc_heap_t *, unsigned int); +void isc_heap_foreach(isc_heap_t *, isc_heapaction_t, void *); diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index 87598730f7..d7be49f5b1 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -24,37 +24,31 @@ #include #include -typedef struct isc_memctx * isc_memctx_t; +typedef struct isc_memctx isc_memctx_t; -#define isc_memctx_create __isc_memctx_create -#define isc_memctx_destroy __isc_memctx_destroy #ifdef ISC_MEMCLUSTER_DEBUG -#define isc_mem_get(c, s) __isc_mem_getdebug(c, s, __FILE__, \ - __LINE__) -#define isc_mem_put(c, p, s) __isc_mem_putdebug(c, p, s, __FILE__, \ - __LINE__) +#define isc_mem_get(c, s) isc_mem_getdebug(c, s, __FILE__, \ + __LINE__) +#define isc_mem_put(c, p, s) isc_mem_putdebug(c, p, s, __FILE__, \ + __LINE__) #else -#define isc_mem_get __isc_mem_get -#define isc_mem_put __isc_mem_put +#define isc_mem_get isc_mem_get +#define isc_mem_put isc_mem_put #endif /* ISC_MEMCLUSTER_DEBUG */ -#define isc_mem_valid __isc_mem_valid -#define isc_mem_stats __isc_mem_stats -#define isc_mem_allocate __isc_mem_allocate -#define isc_mem_free __isc_mem_free isc_result_t isc_memctx_create(size_t, size_t, - isc_memctx_t *); -void isc_memctx_destroy(isc_memctx_t *); -void * __isc_mem_get(isc_memctx_t, size_t); -void __isc_mem_put(isc_memctx_t, void *, size_t); -void * __isc_mem_getdebug(isc_memctx_t, size_t, + isc_memctx_t **); +void isc_memctx_destroy(isc_memctx_t **); +void * isc_mem_get(isc_memctx_t *, size_t); +void isc_mem_put(isc_memctx_t *, void *, size_t); +void * isc_mem_getdebug(isc_memctx_t *, size_t, const char *, int); -void __isc_mem_putdebug(isc_memctx_t, void *, - size_t, const char *, int); -isc_boolean_t isc_mem_valid(isc_memctx_t, void *); -void isc_mem_stats(isc_memctx_t, FILE *); -void * isc_mem_allocate(isc_memctx_t, size_t); -void isc_mem_free(isc_memctx_t, void *); +void isc_mem_putdebug(isc_memctx_t *, void *, + size_t, const char *, int); +isc_boolean_t isc_mem_valid(isc_memctx_t *, void *); +void isc_mem_stats(isc_memctx_t *, FILE *); +void * isc_mem_allocate(isc_memctx_t *, size_t); +void isc_mem_free(isc_memctx_t *, void *); #ifdef ISC_MEMCLUSTER_LEGACY @@ -75,7 +69,7 @@ void isc_mem_free(isc_memctx_t, void *); #define memstats __memstats int meminit(size_t, size_t); -isc_memctx_t mem_default_context(void); +isc_memctx_t * mem_default_context(void); void * __memget(size_t); void __memput(void *, size_t); void * __memget_debug(size_t, const char *, int); diff --git a/lib/isc/include/isc/region.h b/lib/isc/include/isc/region.h index 2d81df37f8..43689e63b1 100644 --- a/lib/isc/include/isc/region.h +++ b/lib/isc/include/isc/region.h @@ -21,12 +21,12 @@ typedef struct isc_region { unsigned char * base; unsigned int length; -} *isc_region_t; +} isc_region_t; typedef struct isc_textregion { char * base; unsigned int length; -} *isc_textregion_t; +} isc_textregion_t; /* * There are no methods which operate on regions. The structure is not diff --git a/lib/isc/include/isc/result.h b/lib/isc/include/isc/result.h index 6ef5b66b3e..a2a21ce981 100644 --- a/lib/isc/include/isc/result.h +++ b/lib/isc/include/isc/result.h @@ -45,8 +45,6 @@ typedef unsigned int isc_result_t; #define ISC_R_UNEXPECTED 0xFFFFFFFFL -#define isc_result_totext __isc_result_totext - char * isc_result_totext(isc_result_t); #endif /* ISC_RESULT_H */ diff --git a/lib/isc/include/isc/sockaddr.h b/lib/isc/include/isc/sockaddr.h new file mode 100644 index 0000000000..49c21c7639 --- /dev/null +++ b/lib/isc/include/isc/sockaddr.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 1998 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_SOCKADDR_H +#define ISC_SOCKADDR_H 1 + +#include + +typedef struct isc_sockaddr { + /* + * XXX Must be big enough for all sockaddr types we care about. + */ + union { + struct sockaddr_in sin; + } type; +} isc_sockaddr_t; + +#endif /* ISC_SOCKADDR_H */ diff --git a/lib/isc/include/isc/socket.h b/lib/isc/include/isc/socket.h index 4955d89496..e5882a9a07 100644 --- a/lib/isc/include/isc/socket.h +++ b/lib/isc/include/isc/socket.h @@ -66,49 +66,36 @@ #include #include #include - -#include +#include /*** *** Types ***/ -typedef struct isc_socket *isc_socket_t; -typedef struct isc_socketmgr *isc_socketmgr_t; - -/* - * XXX Export this as isc/sockaddr.h - */ -typedef struct isc_sockaddr { - /* - * XXX Must be big enough for all sockaddr types we care about. - */ - union { - struct sockaddr_in sin; - } type; -} *isc_sockaddr_t; +typedef struct isc_socket isc_socket_t; +typedef struct isc_socketmgr isc_socketmgr_t; typedef struct isc_socketevent { - struct isc_event common; /* Sender is the socket. */ + isc_event_t common; /* Sender is the socket. */ isc_result_t result; /* OK, EOF, whatever else */ unsigned int n; /* bytes read or written */ - struct isc_region region; /* the region info */ - struct isc_sockaddr address; /* source address */ + isc_region_t region; /* the region info */ + isc_sockaddr_t address; /* source address */ unsigned int addrlength; /* length of address */ -} *isc_socketevent_t; +} isc_socketevent_t; typedef struct isc_socket_newconnev { - struct isc_event common; - isc_socket_t newsocket; + isc_event_t common; + isc_socket_t * newsocket; isc_result_t result; /* OK, EOF, whatever else */ - struct isc_sockaddr address; /* source address */ + isc_sockaddr_t address; /* source address */ unsigned int addrlength; /* length of address */ -} *isc_socket_newconnev_t; +} isc_socket_newconnev_t; typedef struct isc_socket_connev { - struct isc_event common; + isc_event_t common; isc_result_t result; /* OK, EOF, whatever else */ -} *isc_socket_connev_t; +} isc_socket_connev_t; #define ISC_SOCKEVENT_ANYEVENT (0) #define ISC_SOCKEVENT_RECVDONE (ISC_EVENTCLASS_SOCKET + 1) @@ -155,9 +142,9 @@ typedef enum { ***/ isc_result_t -isc_socket_create(isc_socketmgr_t manager, +isc_socket_create(isc_socketmgr_t *manager, isc_sockettype_t type, - isc_socket_t *socketp); + isc_socket_t **socketp); /* * Create a new 'type' socket managed by 'manager'. * @@ -180,7 +167,7 @@ isc_socket_create(isc_socketmgr_t manager, */ void -isc_socket_cancel(isc_socket_t sock, isc_task_t task, +isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how); /* * Cancel pending I/O of the type specified by "how". @@ -212,7 +199,7 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, */ void -isc_socket_shutdown(isc_socket_t sock, unsigned int how); +isc_socket_shutdown(isc_socket_t *sock, unsigned int how); /* * Shutdown 'socket' according to 'how'. * @@ -236,7 +223,7 @@ isc_socket_shutdown(isc_socket_t sock, unsigned int how); */ void -isc_socket_attach(isc_socket_t sock, isc_socket_t *socketp); +isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp); /* * Attach *socketp to socket. * @@ -252,7 +239,7 @@ isc_socket_attach(isc_socket_t sock, isc_socket_t *socketp); */ void -isc_socket_detach(isc_socket_t *socketp); +isc_socket_detach(isc_socket_t **socketp); /* * Detach *socketp from its socket. * @@ -279,7 +266,7 @@ isc_socket_detach(isc_socket_t *socketp); */ isc_result_t -isc_socket_bind(isc_socket_t sock, struct isc_sockaddr *addressp, +isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *addressp, int length); /* * Bind 'socket' to '*addressp'. @@ -303,7 +290,7 @@ isc_socket_bind(isc_socket_t sock, struct isc_sockaddr *addressp, */ isc_result_t -isc_socket_listen(isc_socket_t sock, unsigned int backlog); +isc_socket_listen(isc_socket_t *sock, unsigned int backlog); /* * Set listen mode on the socket. After this call, the only function that * can be used (other than attach and detach) is isc_socket_accept(). @@ -327,8 +314,8 @@ isc_socket_listen(isc_socket_t sock, unsigned int backlog); */ isc_result_t -isc_socket_accept(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg); +isc_socket_accept(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg); /* * Queue accept event. When a new connection is received, the task will * get an ISC_SOCKEVENT_NEWCONN event with the sender set to the listen @@ -350,8 +337,8 @@ isc_socket_accept(isc_socket_t sock, */ isc_result_t -isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addressp, - int length, isc_task_t task, isc_taskaction_t action, +isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addressp, + int length, isc_task_t *task, isc_taskaction_t action, void *arg); /* * Connect 'socket' to peer with address *saddr. When the connection @@ -386,7 +373,7 @@ isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addressp, */ isc_result_t -isc_socket_getpeername(isc_socket_t sock, struct isc_sockaddr *addressp, +isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp, int *lengthp); /* * Get the name of the peer connected to 'socket'. @@ -405,7 +392,7 @@ isc_socket_getpeername(isc_socket_t sock, struct isc_sockaddr *addressp, */ isc_result_t -isc_socket_getsockname(isc_socket_t sock, struct isc_sockaddr *addressp, +isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp, int *lengthp); /* * Get the name of 'socket'. @@ -424,9 +411,9 @@ isc_socket_getsockname(isc_socket_t sock, struct isc_sockaddr *addressp, */ isc_result_t -isc_socket_recv(isc_socket_t sock, isc_region_t region, +isc_socket_recv(isc_socket_t *sock, isc_region_t *region, isc_boolean_t partial, - isc_task_t task, isc_taskaction_t action, void *arg); + isc_task_t *task, isc_taskaction_t action, void *arg); /* * Receive from 'socket', storing the results in region. * @@ -470,12 +457,12 @@ isc_socket_recv(isc_socket_t sock, isc_region_t region, */ isc_result_t -isc_socket_send(isc_socket_t sock, isc_region_t region, - isc_task_t task, isc_taskaction_t action, void *arg); +isc_socket_send(isc_socket_t *sock, isc_region_t *region, + isc_task_t *task, isc_taskaction_t action, void *arg); isc_result_t -isc_socket_sendto(isc_socket_t sock, isc_region_t region, - isc_task_t task, isc_taskaction_t action, void *arg, - isc_sockaddr_t address, unsigned int addrlength); +isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, + isc_task_t *task, isc_taskaction_t action, void *arg, + isc_sockaddr_t *address, unsigned int addrlength); /* * Send the contents of 'region' to the socket's peer. * @@ -516,11 +503,11 @@ isc_socket_sendto(isc_socket_t sock, isc_region_t region, */ isc_result_t -isc_socket_recvmark(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg); +isc_socket_recvmark(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg); isc_result_t -isc_socket_sendmark(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg); +isc_socket_sendmark(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg); /* * Insert a recv/send marker for the socket. * @@ -551,7 +538,7 @@ isc_socket_sendmark(isc_socket_t sock, */ isc_result_t -isc_socketmgr_create(isc_memctx_t mctx, isc_socketmgr_t *managerp); +isc_socketmgr_create(isc_memctx_t *mctx, isc_socketmgr_t **managerp); /* * Create a socket manager. * @@ -577,7 +564,7 @@ isc_socketmgr_create(isc_memctx_t mctx, isc_socketmgr_t *managerp); */ void -isc_socketmgr_destroy(isc_socketmgr_t *managerp); +isc_socketmgr_destroy(isc_socketmgr_t **managerp); /* * Destroy a socket manager. * diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index 8752592347..d7e330dce8 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -31,9 +31,9 @@ *** Core Types. ***/ -typedef struct isc_event * isc_event_t; -typedef struct isc_task * isc_task_t; -typedef struct isc_taskmgr * isc_taskmgr_t; +typedef struct isc_event isc_event_t; +typedef struct isc_task isc_task_t; +typedef struct isc_taskmgr isc_taskmgr_t; /*** @@ -47,15 +47,15 @@ typedef struct isc_taskmgr * isc_taskmgr_t; */ typedef int isc_eventtype_t; -typedef isc_boolean_t (*isc_taskaction_t)(isc_task_t, isc_event_t); -typedef void (*isc_eventdestructor_t)(isc_event_t); +typedef isc_boolean_t (*isc_taskaction_t)(isc_task_t *, isc_event_t *); +typedef void (*isc_eventdestructor_t)(isc_event_t *); /* * This structure is public because "subclassing" it may be useful when * defining new event types. */ struct isc_event { - isc_memctx_t mctx; + isc_memctx_t * mctx; size_t size; void * sender; isc_eventtype_t type; @@ -70,42 +70,42 @@ struct isc_event { typedef LIST(struct isc_event) isc_eventlist_t; -isc_event_t isc_event_allocate(isc_memctx_t, +isc_event_t * isc_event_allocate(isc_memctx_t *, void *, isc_eventtype_t, isc_taskaction_t, void *arg, size_t); -void isc_event_free(isc_event_t *); +void isc_event_free(isc_event_t **); /*** *** Tasks. ***/ -isc_result_t isc_task_create(isc_taskmgr_t, +isc_result_t isc_task_create(isc_taskmgr_t *, isc_taskaction_t, void *, unsigned int, - isc_task_t *); -void isc_task_attach(isc_task_t, - isc_task_t *); -void isc_task_detach(isc_task_t *); -isc_result_t isc_task_send(isc_task_t, - isc_event_t *); -unsigned int isc_task_purge(isc_task_t, void *, + isc_task_t **); +void isc_task_attach(isc_task_t *, + isc_task_t **); +void isc_task_detach(isc_task_t **); +isc_result_t isc_task_send(isc_task_t *, + isc_event_t **); +unsigned int isc_task_purge(isc_task_t *, void *, isc_eventtype_t); -void isc_task_shutdown(isc_task_t); -void isc_task_destroy(isc_task_t *); +void isc_task_shutdown(isc_task_t *); +void isc_task_destroy(isc_task_t **); /*** *** Task Manager. ***/ -isc_result_t isc_taskmgr_create(isc_memctx_t, +isc_result_t isc_taskmgr_create(isc_memctx_t *, unsigned int, unsigned int, - isc_taskmgr_t *); -void isc_taskmgr_destroy(isc_taskmgr_t *); + isc_taskmgr_t **); +void isc_taskmgr_destroy(isc_taskmgr_t **); #endif /* ISC_TASK_H */ diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 269fdf5395..ff8a0f6ac2 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -80,8 +80,8 @@ *** Types ***/ -typedef struct isc_timer *isc_timer_t; -typedef struct isc_timermgr *isc_timermgr_t; +typedef struct isc_timer isc_timer_t; +typedef struct isc_timermgr isc_timermgr_t; typedef enum { isc_timertype_ticker = 0, isc_timertype_once @@ -90,7 +90,7 @@ typedef enum { typedef struct isc_timerevent { struct isc_event common; /* XXX Anything else? XXX */ -} *isc_timerevent_t; +} isc_timerevent_t; #define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1) #define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2) @@ -105,14 +105,14 @@ typedef struct isc_timerevent { ***/ isc_result_t -isc_timer_create(isc_timermgr_t manager, +isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type, - isc_time_t expires, - isc_interval_t interval, - isc_task_t task, + isc_time_t *expires, + isc_interval_t *interval, + isc_task_t *task, isc_taskaction_t action, void *arg, - isc_timer_t *timerp); + isc_timer_t **timerp); /* * Create a new 'type' timer managed by 'manager'. The timers parameters * are specified by 'expires' and 'interval'. Events will be posted to @@ -160,10 +160,10 @@ isc_timer_create(isc_timermgr_t manager, */ isc_result_t -isc_timer_reset(isc_timer_t timer, +isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, - isc_time_t expires, - isc_interval_t interval, + isc_time_t *expires, + isc_interval_t *interval, isc_boolean_t purge); /* * Change the timer's type, expires, and interval values to the given @@ -191,7 +191,7 @@ isc_timer_reset(isc_timer_t timer, */ isc_result_t -isc_timer_touch(isc_timer_t timer); +isc_timer_touch(isc_timer_t *timer); /* * Set the last-touched time of 'timer' to the current time. * @@ -212,7 +212,7 @@ isc_timer_touch(isc_timer_t timer); */ void -isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp); +isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp); /* * Attach *timerp to timer. * @@ -228,7 +228,7 @@ isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp); */ void -isc_timer_detach(isc_timer_t *timerp); +isc_timer_detach(isc_timer_t **timerp); /* * Detach *timerp from its timer. * @@ -251,7 +251,7 @@ isc_timer_detach(isc_timer_t *timerp); */ isc_result_t -isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp); +isc_timermgr_create(isc_memctx_t *mctx, isc_timermgr_t **managerp); /* * Create a timer manager. * @@ -277,7 +277,7 @@ isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp); */ void -isc_timermgr_destroy(isc_timermgr_t *); +isc_timermgr_destroy(isc_timermgr_t **managerp); /* * Destroy a timer manager. * diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 86e0055563..f6dce7323e 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -30,8 +30,8 @@ #include #include "util.h" #else -#define LOCK(ctx) -#define UNLOCK(ctx) +#define LOCK(l) +#define UNLOCK(l) #endif /* @@ -47,7 +47,7 @@ typedef struct { /* * This structure must be ALIGNMENT_SIZE bytes. */ -} *size_info; +} size_info; struct stats { unsigned long gets; @@ -113,9 +113,9 @@ quantize(size_t size) { isc_result_t isc_memctx_create(size_t init_max_size, size_t target_size, - isc_memctx_t *ctxp) + isc_memctx_t **ctxp) { - isc_memctx_t ctx; + isc_memctx_t *ctx; REQUIRE(ctxp != NULL && *ctxp == NULL); @@ -162,9 +162,9 @@ isc_memctx_create(size_t init_max_size, size_t target_size, } void -isc_memctx_destroy(isc_memctx_t *ctxp) { +isc_memctx_destroy(isc_memctx_t **ctxp) { unsigned int i; - isc_memctx_t ctx; + isc_memctx_t *ctx; REQUIRE(ctxp != NULL); ctx = *ctxp; @@ -187,7 +187,7 @@ isc_memctx_destroy(isc_memctx_t *ctxp) { } static void -more_basic_blocks(isc_memctx_t ctx) { +more_basic_blocks(isc_memctx_t *ctx) { void *new; unsigned char *curr, *next; unsigned char *first, *last; @@ -240,7 +240,7 @@ more_basic_blocks(isc_memctx_t ctx) { } void * -__isc_mem_get(isc_memctx_t ctx, size_t size) { +isc_mem_get(isc_memctx_t *ctx, size_t size) { size_t new_size = quantize(size); void *ret; @@ -320,7 +320,7 @@ __isc_mem_get(isc_memctx_t ctx, size_t size) { * so we want to count this as a user "put". */ void -__isc_mem_put(isc_memctx_t ctx, void *mem, size_t size) { +isc_mem_put(isc_memctx_t *ctx, void *mem, size_t size) { size_t new_size = quantize(size); REQUIRE(size > 0); @@ -354,29 +354,29 @@ __isc_mem_put(isc_memctx_t ctx, void *mem, size_t size) { } void * -__isc_mem_getdebug(isc_memctx_t ctx, size_t size, const char *file, int line) { +isc_mem_getdebug(isc_memctx_t *ctx, size_t size, const char *file, int line) { void *ptr; - ptr = __isc_mem_get(ctx, size); + ptr = isc_mem_get(ctx, size); fprintf(stderr, "%s:%d: mem_get(%p, %lu) -> %p\n", file, line, ctx, (unsigned long)size, ptr); return (ptr); } void -__isc_mem_putdebug(isc_memctx_t ctx, void *ptr, size_t size, const char *file, - int line) +isc_mem_putdebug(isc_memctx_t *ctx, void *ptr, size_t size, const char *file, + int line) { fprintf(stderr, "%s:%d: mem_put(%p, %p, %lu)\n", file, line, ctx, ptr, (unsigned long)size); - __isc_mem_put(ctx, ptr, size); + isc_mem_put(ctx, ptr, size); } /* * Print the stats[] on the stream "out" with suitable formatting. */ void -isc_mem_stats(isc_memctx_t ctx, FILE *out) { +isc_mem_stats(isc_memctx_t *ctx, FILE *out) { size_t i; REQUIRE(VALID_CONTEXT(ctx)); @@ -402,7 +402,7 @@ isc_mem_stats(isc_memctx_t ctx, FILE *out) { } isc_boolean_t -isc_mem_valid(isc_memctx_t ctx, void *ptr) { +isc_mem_valid(isc_memctx_t *ctx, void *ptr) { unsigned char *cp = ptr; isc_boolean_t result = ISC_FALSE; @@ -422,8 +422,8 @@ isc_mem_valid(isc_memctx_t ctx, void *ptr) { */ void * -isc_mem_allocate(isc_memctx_t ctx, size_t size) { - size_info si; +isc_mem_allocate(isc_memctx_t *ctx, size_t size) { + size_info *si; size += ALIGNMENT_SIZE; si = isc_mem_get(ctx, size); @@ -434,10 +434,10 @@ isc_mem_allocate(isc_memctx_t ctx, size_t size) { } void -isc_mem_free(isc_memctx_t ctx, void *ptr) { - size_info si; +isc_mem_free(isc_memctx_t *ctx, void *ptr) { + size_info *si; - si = &(((size_info)ptr)[-1]); + si = &(((size_info *)ptr)[-1]); isc_mem_put(ctx, si, si->size); } @@ -447,7 +447,7 @@ isc_mem_free(isc_memctx_t ctx, void *ptr) { * Public Legacy. */ -static isc_memctx_t default_context = NULL; +static isc_memctx_t *default_context = NULL; int meminit(size_t init_max_size, size_t target_size) { diff --git a/lib/isc/pthreads/condition.c b/lib/isc/pthreads/condition.c index a96bc3bede..1259b10bed 100644 --- a/lib/isc/pthreads/condition.c +++ b/lib/isc/pthreads/condition.c @@ -24,12 +24,13 @@ #include isc_result_t -isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t t) +isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) { int presult; struct timespec ts; - isc_time_totimespec(t, &ts); + ts.tv_sec = t->seconds; + ts.tv_nsec = t->nanoseconds; presult = pthread_cond_timedwait(c, m, &ts); if (presult == 0) return (ISC_R_SUCCESS); diff --git a/lib/isc/pthreads/include/isc/condition.h b/lib/isc/pthreads/include/isc/condition.h index e5d56bf2a1..554557fb39 100644 --- a/lib/isc/pthreads/include/isc/condition.h +++ b/lib/isc/pthreads/include/isc/condition.h @@ -48,6 +48,6 @@ typedef pthread_cond_t isc_condition_t; ISC_R_SUCCESS : ISC_R_UNEXPECTED) isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, - isc_time_t); + isc_time_t *); #endif /* ISC_CONDITION_H */ diff --git a/lib/isc/task.c b/lib/isc/task.c index 15d78865aa..d75a81f287 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -51,7 +51,7 @@ typedef enum { struct isc_task { /* Not locked. */ unsigned int magic; - isc_taskmgr_t manager; + isc_taskmgr_t * manager; isc_mutex_t lock; /* Locked by task lock. */ task_state_t state; @@ -59,10 +59,10 @@ struct isc_task { isc_eventlist_t events; unsigned int quantum; isc_boolean_t enqueue_allowed; - isc_event_t shutdown_event; + isc_event_t * shutdown_event; /* Locked by task manager lock. */ - LINK(struct isc_task) link; - LINK(struct isc_task) ready_link; + LINK(isc_task_t) link; + LINK(isc_task_t) ready_link; }; #define TASK_MANAGER_MAGIC 0x54534B4DU /* TSKM. */ @@ -72,14 +72,14 @@ struct isc_task { struct isc_taskmgr { /* Not locked. */ unsigned int magic; - isc_memctx_t mctx; + isc_memctx_t * mctx; isc_mutex_t lock; unsigned int workers; isc_thread_t * threads; /* Locked by task manager lock. */ unsigned int default_quantum; - LIST(struct isc_task) tasks; - LIST(struct isc_task) ready_tasks; + LIST(isc_task_t) tasks; + LIST(isc_task_t) ready_tasks; isc_condition_t work_available; isc_boolean_t exiting; }; @@ -92,11 +92,11 @@ struct isc_taskmgr { *** Events. ***/ -static inline isc_event_t -event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, +static inline isc_event_t * +event_allocate(isc_memctx_t *mctx, void *sender, isc_eventtype_t type, isc_taskaction_t action, void *arg, size_t size) { - isc_event_t event; + isc_event_t *event; event = isc_mem_get(mctx, size); if (event == NULL) @@ -111,8 +111,8 @@ event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, return (event); } -isc_event_t -isc_event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, +isc_event_t * +isc_event_allocate(isc_memctx_t *mctx, void *sender, isc_eventtype_t type, isc_taskaction_t action, void *arg, size_t size) { if (size < sizeof (struct isc_event)) @@ -126,8 +126,8 @@ isc_event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, } void -isc_event_free(isc_event_t *eventp) { - isc_event_t event; +isc_event_free(isc_event_t **eventp) { + isc_event_t *event; REQUIRE(eventp != NULL); event = *eventp; @@ -145,8 +145,8 @@ isc_event_free(isc_event_t *eventp) { ***/ static void -task_free(isc_task_t task) { - isc_taskmgr_t manager = task->manager; +task_free(isc_task_t *task) { + isc_taskmgr_t *manager = task->manager; XTRACE("free task"); REQUIRE(EMPTY(task->events)); @@ -171,10 +171,10 @@ task_free(isc_task_t task) { } isc_result_t -isc_task_create(isc_taskmgr_t manager, isc_taskaction_t shutdown_action, - void *shutdown_arg, unsigned int quantum, isc_task_t *taskp) +isc_task_create(isc_taskmgr_t *manager, isc_taskaction_t shutdown_action, + void *shutdown_arg, unsigned int quantum, isc_task_t **taskp) { - isc_task_t task; + isc_task_t *task; REQUIRE(VALID_MANAGER(manager)); REQUIRE(taskp != NULL && *taskp == NULL); @@ -222,7 +222,7 @@ isc_task_create(isc_taskmgr_t manager, isc_taskaction_t shutdown_action, } void -isc_task_attach(isc_task_t task, isc_task_t *taskp) { +isc_task_attach(isc_task_t *task, isc_task_t **taskp) { REQUIRE(VALID_TASK(task)); REQUIRE(taskp != NULL && *taskp == NULL); @@ -235,9 +235,9 @@ isc_task_attach(isc_task_t task, isc_task_t *taskp) { } void -isc_task_detach(isc_task_t *taskp) { +isc_task_detach(isc_task_t **taskp) { isc_boolean_t free_task = ISC_FALSE; - isc_task_t task; + isc_task_t *task; XTRACE("isc_task_detach"); @@ -259,10 +259,10 @@ isc_task_detach(isc_task_t *taskp) { } isc_result_t -isc_task_send(isc_task_t task, isc_event_t *eventp) { +isc_task_send(isc_task_t *task, isc_event_t **eventp) { isc_boolean_t was_idle = ISC_FALSE; isc_boolean_t discard = ISC_FALSE; - isc_event_t event; + isc_event_t *event; REQUIRE(VALID_TASK(task)); REQUIRE(eventp != NULL); @@ -298,7 +298,7 @@ isc_task_send(isc_task_t task, isc_event_t *eventp) { } if (was_idle) { - isc_taskmgr_t manager; + isc_taskmgr_t *manager; /* * We need to add this task to the ready queue. @@ -335,8 +335,8 @@ isc_task_send(isc_task_t task, isc_event_t *eventp) { } unsigned int -isc_task_purge(isc_task_t task, void *sender, isc_eventtype_t type) { - isc_event_t event, next_event; +isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type) { + isc_event_t *event, *next_event; isc_eventlist_t purgeable; unsigned int purge_count; @@ -377,7 +377,7 @@ isc_task_purge(isc_task_t task, void *sender, isc_eventtype_t type) { } void -isc_task_shutdown(isc_task_t task) { +isc_task_shutdown(isc_task_t *task) { isc_boolean_t was_idle = ISC_FALSE; isc_boolean_t discard = ISC_FALSE; @@ -408,7 +408,7 @@ isc_task_shutdown(isc_task_t task) { return; if (was_idle) { - isc_taskmgr_t manager; + isc_taskmgr_t *manager; manager = task->manager; INSIST(VALID_MANAGER(manager)); @@ -420,7 +420,7 @@ isc_task_shutdown(isc_task_t task) { } void -isc_task_destroy(isc_task_t *taskp) { +isc_task_destroy(isc_task_t **taskp) { REQUIRE(taskp != NULL); @@ -439,8 +439,8 @@ static isc_threadresult_t WINAPI #endif run(void *uap) { - isc_taskmgr_t manager = uap; - isc_task_t task; + isc_taskmgr_t *manager = uap; + isc_task_t *task; XTRACE("start"); @@ -520,7 +520,7 @@ run(void *uap) { isc_boolean_t wants_shutdown; isc_boolean_t is_shutdown; isc_boolean_t free_task = ISC_FALSE; - isc_event_t event; + isc_event_t *event; isc_eventlist_t remaining_events; isc_boolean_t discard_remaining = ISC_FALSE; @@ -626,7 +626,7 @@ run(void *uap) { UNLOCK(&task->lock); if (discard_remaining) { - isc_event_t next_event; + isc_event_t *next_event; for (event = HEAD(remaining_events); event != NULL; @@ -673,7 +673,7 @@ run(void *uap) { } static void -manager_free(isc_taskmgr_t manager) { +manager_free(isc_taskmgr_t *manager) { (void)isc_condition_destroy(&manager->work_available); (void)isc_mutex_destroy(&manager->lock); isc_mem_put(manager->mctx, manager->threads, @@ -683,11 +683,11 @@ manager_free(isc_taskmgr_t manager) { } isc_result_t -isc_taskmgr_create(isc_memctx_t mctx, unsigned int workers, - unsigned int default_quantum, isc_taskmgr_t *managerp) +isc_taskmgr_create(isc_memctx_t *mctx, unsigned int workers, + unsigned int default_quantum, isc_taskmgr_t **managerp) { unsigned int i, started = 0; - isc_taskmgr_t manager; + isc_taskmgr_t *manager; isc_thread_t *threads; REQUIRE(workers > 0); @@ -752,9 +752,9 @@ isc_taskmgr_create(isc_memctx_t mctx, unsigned int workers, } void -isc_taskmgr_destroy(isc_taskmgr_t *managerp) { - isc_taskmgr_t manager; - isc_task_t task; +isc_taskmgr_destroy(isc_taskmgr_t **managerp) { + isc_taskmgr_t *manager; + isc_task_t *task; unsigned int i; REQUIRE(managerp != NULL); diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 36745d1c52..fd2f82a7f9 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -50,21 +50,21 @@ struct isc_timer { /* Not locked. */ unsigned int magic; - isc_timermgr_t manager; + isc_timermgr_t * manager; isc_mutex_t lock; /* Locked by timer lock. */ unsigned int references; - struct isc_time idle; + isc_time_t idle; /* Locked by manager lock. */ isc_timertype_t type; - struct isc_time expires; - struct isc_interval interval; - isc_task_t task; + isc_time_t expires; + isc_interval_t interval; + isc_task_t * task; isc_taskaction_t action; void * arg; unsigned int index; - struct isc_time due; - LINK(struct isc_timer) link; + isc_time_t due; + LINK(isc_timer_t) link; }; #define TIMER_MANAGER_MAGIC 0x54494D4DU /* TIMM. */ @@ -74,23 +74,23 @@ struct isc_timer { struct isc_timermgr { /* Not locked. */ unsigned int magic; - isc_memctx_t mctx; + isc_memctx_t * mctx; isc_mutex_t lock; /* Locked by manager lock. */ isc_boolean_t done; - LIST(struct isc_timer) timers; + LIST(isc_timer_t) timers; unsigned int nscheduled; - struct isc_time due; + isc_time_t due; isc_condition_t wakeup; isc_thread_t thread; - isc_heap_t heap; + isc_heap_t * heap; }; static inline isc_result_t -schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t signal_ok) { +schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { isc_result_t result; - isc_timermgr_t manager; - struct isc_time due; + isc_timermgr_t *manager; + isc_time_t due; int cmp; /* @@ -161,9 +161,9 @@ schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t signal_ok) { } static inline void -deschedule(isc_timer_t timer) { +deschedule(isc_timer_t *timer) { isc_boolean_t need_wakeup = ISC_FALSE; - isc_timermgr_t manager; + isc_timermgr_t *manager; /* * The caller must ensure locking. @@ -185,8 +185,8 @@ deschedule(isc_timer_t timer) { } static void -destroy(isc_timer_t timer) { - isc_timermgr_t manager = timer->manager; +destroy(isc_timer_t *timer) { + isc_timermgr_t *manager = timer->manager; /* * The caller must ensure locking. @@ -207,14 +207,14 @@ destroy(isc_timer_t timer) { } isc_result_t -isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, - isc_time_t expires, isc_interval_t interval, - isc_task_t task, isc_taskaction_t action, void *arg, - isc_timer_t *timerp) +isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type, + isc_time_t *expires, isc_interval_t *interval, + isc_task_t *task, isc_taskaction_t action, void *arg, + isc_timer_t **timerp) { - isc_timer_t timer; + isc_timer_t *timer; isc_result_t result; - struct isc_time now; + isc_time_t now; /* * Create a new 'type' timer managed by 'manager'. The timers @@ -295,12 +295,12 @@ isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, } isc_result_t -isc_timer_reset(isc_timer_t timer, isc_timertype_t type, - isc_time_t expires, isc_interval_t interval, +isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, + isc_time_t *expires, isc_interval_t *interval, isc_boolean_t purge) { - struct isc_time now; - isc_timermgr_t manager; + isc_time_t now; + isc_timermgr_t *manager; isc_result_t result; /* @@ -348,9 +348,9 @@ isc_timer_reset(isc_timer_t timer, isc_timertype_t type, } isc_result_t -isc_timer_touch(isc_timer_t timer) { +isc_timer_touch(isc_timer_t *timer) { isc_result_t result; - struct isc_time now; + isc_time_t now; /* * Set the last-touched time of 'timer' to the current time. @@ -377,7 +377,7 @@ isc_timer_touch(isc_timer_t timer) { } void -isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp) { +isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) { /* * Attach *timerp to timer. */ @@ -393,8 +393,8 @@ isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp) { } void -isc_timer_detach(isc_timer_t *timerp) { - isc_timer_t timer; +isc_timer_detach(isc_timer_t **timerp) { + isc_timer_t *timer; isc_boolean_t free_timer = ISC_FALSE; /* @@ -419,11 +419,11 @@ isc_timer_detach(isc_timer_t *timerp) { } static void -dispatch(isc_timermgr_t manager, isc_time_t now) { +dispatch(isc_timermgr_t *manager, isc_time_t *now) { isc_boolean_t done = ISC_FALSE, post_event, need_schedule; - isc_event_t event; + isc_event_t *event; isc_eventtype_t type = 0; - isc_timer_t timer; + isc_timer_t *timer; isc_result_t result; while (manager->nscheduled > 0 && !done) { @@ -493,8 +493,8 @@ static isc_threadresult_t WINAPI #endif run(void *uap) { - isc_timermgr_t manager = uap; - struct isc_time now; + isc_timermgr_t *manager = uap; + isc_time_t now; isc_result_t result; LOCK(&manager->lock); @@ -524,7 +524,7 @@ run(void *uap) { static isc_boolean_t sooner(void *v1, void *v2) { - isc_timer_t t1, t2; + isc_timer_t *t1, *t2; t1 = v1; t2 = v2; @@ -538,7 +538,7 @@ sooner(void *v1, void *v2) { static void set_index(void *what, unsigned int index) { - isc_timer_t timer; + isc_timer_t *timer; timer = what; REQUIRE(VALID_TIMER(timer)); @@ -547,8 +547,8 @@ set_index(void *what, unsigned int index) { } isc_result_t -isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp) { - isc_timermgr_t manager; +isc_timermgr_create(isc_memctx_t *mctx, isc_timermgr_t **managerp) { + isc_timermgr_t *manager; isc_result_t result; /* @@ -606,8 +606,8 @@ isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp) { } void -isc_timermgr_destroy(isc_timermgr_t *managerp) { - isc_timermgr_t manager; +isc_timermgr_destroy(isc_timermgr_t **managerp) { + isc_timermgr_t *manager; /* * Destroy a timer manager. diff --git a/lib/isc/unix/include/isc/Makefile.in b/lib/isc/unix/include/isc/Makefile.in index 0ab121055c..788e7fc60c 100644 --- a/lib/isc/unix/include/isc/Makefile.in +++ b/lib/isc/unix/include/isc/Makefile.in @@ -5,7 +5,7 @@ top_srcdir = @top_srcdir@ @BIND9_VERSION@ -HEADERS = time.h +HEADERS = sockaddr.h time.h SUBDIRS = TARGETS = diff --git a/lib/isc/unix/include/isc/sockaddr.h b/lib/isc/unix/include/isc/sockaddr.h new file mode 100644 index 0000000000..49c21c7639 --- /dev/null +++ b/lib/isc/unix/include/isc/sockaddr.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 1998 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_SOCKADDR_H +#define ISC_SOCKADDR_H 1 + +#include + +typedef struct isc_sockaddr { + /* + * XXX Must be big enough for all sockaddr types we care about. + */ + union { + struct sockaddr_in sin; + } type; +} isc_sockaddr_t; + +#endif /* ISC_SOCKADDR_H */ diff --git a/lib/isc/unix/include/isc/time.h b/lib/isc/unix/include/isc/time.h index 5b81401241..8a4cc4540d 100644 --- a/lib/isc/unix/include/isc/time.h +++ b/lib/isc/unix/include/isc/time.h @@ -18,7 +18,6 @@ #ifndef ISC_TIME_H #define ISC_TIME_H 1 -#include #include #include @@ -32,16 +31,15 @@ * The contents of this structure are private, and MUST NOT be accessed * directly by callers. * - * The contents are exposed only so that callers may avoid dynamic allocation - * and instead just declare a 'struct isc_interval'. + * The contents are exposed only to allow callers to avoid dynamic allocation. */ typedef struct isc_interval { unsigned int seconds; unsigned int nanoseconds; -} *isc_interval_t; +} isc_interval_t; void -isc_interval_set(isc_interval_t i, +isc_interval_set(isc_interval_t *i, unsigned int seconds, unsigned int nanoseconds); /* * Set 'i' to a value representing an interval of 'seconds' seconds and @@ -56,7 +54,7 @@ isc_interval_set(isc_interval_t i, */ isc_boolean_t -isc_interval_iszero(isc_interval_t i); +isc_interval_iszero(isc_interval_t *i); /* * Returns ISC_TRUE iff. 'i' is the zero interval. * @@ -74,17 +72,16 @@ isc_interval_iszero(isc_interval_t i); * The contents of this structure are private, and MUST NOT be accessed * directly by callers. * - * The contents are exposed only so that callers may avoid dynamic allocation - * and instead just declare a 'struct isc_time'. + * The contents are exposed only to allow callers to avoid dynamic allocation. */ typedef struct isc_time { time_t seconds; unsigned int nanoseconds; -} *isc_time_t; +} isc_time_t; void -isc_time_settoepoch(isc_time_t t); +isc_time_settoepoch(isc_time_t *t); /* * Set 't' to the time of the epoch. * @@ -95,7 +92,7 @@ isc_time_settoepoch(isc_time_t t); */ isc_boolean_t -isc_time_isepoch(isc_time_t t); +isc_time_isepoch(isc_time_t *t); /* * Returns ISC_TRUE iff. 't' is the epoch ("time zero"). * @@ -106,7 +103,7 @@ isc_time_isepoch(isc_time_t t); */ isc_result_t -isc_time_get(isc_time_t t); +isc_time_get(isc_time_t *t); /* * Set 't' to the current absolute time. * @@ -121,7 +118,7 @@ isc_time_get(isc_time_t t); */ int -isc_time_compare(isc_time_t t1, isc_time_t t2); +isc_time_compare(isc_time_t *t1, isc_time_t *t2); /* * Compare the times referenced by 't1' and 't2' * @@ -137,7 +134,7 @@ isc_time_compare(isc_time_t t1, isc_time_t t2); */ void -isc_time_add(isc_time_t t, isc_interval_t i, isc_time_t result); +isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result); /* * Add 'i' to 't', storing the result in 'result'. * @@ -147,7 +144,7 @@ isc_time_add(isc_time_t t, isc_interval_t i, isc_time_t result); */ void -isc_time_subtract(isc_time_t t, isc_interval_t t2, isc_time_t result); +isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result); /* * Subtract 'i' from 't', storing the result in 'result'. * @@ -158,52 +155,4 @@ isc_time_subtract(isc_time_t t, isc_interval_t t2, isc_time_t result); * t >= epoch + i (comparing times, not pointers) */ -/*** - *** UNIX-only - ***/ - -void -isc_time_fromtimeval(isc_time_t t, struct timeval *tv); -/* - * Set 't' to the time given by 'ts'. - * - * Requires: - * - * 't' and 'tv' are a valid. - * - */ - -void -isc_time_totimeval(isc_time_t t, struct timeval *tv); -/* - * Convert 't' to a UNIX timeval. - * - * Requires: - * - * 't' and 'tv' are a valid. - * - */ - -void -isc_time_fromtimespec(isc_time_t t, struct timespec *ts); -/* - * Set 't' to the time given by 'ts'. - * - * Requires: - * - * 't' and 'ts' are a valid. - * - */ - -void -isc_time_totimespec(isc_time_t t, struct timespec *ts); -/* - * Convert 't' to a UNIX timespec. - * - * Requires: - * - * 't' and 'ts' are a valid. - * - */ - #endif /* ISC_TIME_H */ diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 10e53b279b..7f346651cf 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -74,31 +74,31 @@ int trace_level = 0xffffffff; * functions. */ typedef struct rwintev { - struct isc_event common; /* Sender is the socket. */ - isc_task_t task; /* task to send these to */ - isc_socketevent_t done_ev; /* the done event to post */ + isc_event_t common; /* Sender is the socket. */ + isc_task_t * task; /* task to send these to */ + isc_socketevent_t * done_ev; /* the done event to post */ isc_boolean_t partial; /* partial i/o ok */ isc_boolean_t canceled; /* I/O was canceled */ isc_boolean_t posted; /* event posted to task */ LINK(struct rwintev) link; /* next event */ -} *rwintev_t; +} rwintev_t; typedef struct ncintev { - struct isc_event common; /* Sender is the socket */ - isc_task_t task; /* task to send these to */ - isc_socket_newconnev_t done_ev; /* the done event */ + isc_event_t common; /* Sender is the socket */ + isc_task_t * task; /* task to send these to */ + isc_socket_newconnev_t * done_ev; /* the done event */ isc_boolean_t canceled; /* accept was canceled */ isc_boolean_t posted; /* event posted to task */ LINK(struct ncintev) link; /* next event */ -} *ncintev_t; +} ncintev_t; typedef struct cnintev { - struct isc_event common; /* Sender is the socket */ - isc_task_t task; /* task to send these to */ - isc_socket_connev_t done_ev; /* the done event */ + isc_event_t common; /* Sender is the socket */ + isc_task_t * task; /* task to send these to */ + isc_socket_connev_t * done_ev; /* the done event */ isc_boolean_t canceled; /* connect was canceled */ isc_boolean_t posted; /* event posted to task */ -} *cnintev_t; +} cnintev_t; #define SOCKET_MAGIC 0x494f696fU /* IOio */ #define VALID_SOCKET(t) ((t) != NULL && (t)->magic == SOCKET_MAGIC) @@ -106,7 +106,7 @@ typedef struct cnintev { struct isc_socket { /* Not locked. */ unsigned int magic; - isc_socketmgr_t manager; + isc_socketmgr_t * manager; isc_mutex_t lock; isc_sockettype_t type; @@ -115,19 +115,19 @@ struct isc_socket { int fd; isc_result_t recv_result; isc_result_t send_result; - LIST(struct rwintev) recv_list; - LIST(struct rwintev) send_list; - LIST(struct ncintev) accept_list; - cnintev_t connect_ev; + LIST(rwintev_t) recv_list; + LIST(rwintev_t) send_list; + LIST(ncintev_t) accept_list; + cnintev_t * connect_ev; isc_boolean_t pending_recv; isc_boolean_t pending_send; isc_boolean_t pending_accept; isc_boolean_t listener; /* is a listener socket */ isc_boolean_t connecting; /* connect pending */ - rwintev_t riev; /* allocated recv intev */ - rwintev_t wiev; /* allocated send intev */ - cnintev_t ciev; /* allocated accept intev */ - struct isc_sockaddr address; /* remote address */ + rwintev_t * riev; /* allocated recv intev */ + rwintev_t * wiev; /* allocated send intev */ + cnintev_t * ciev; /* allocated accept intev */ + isc_sockaddr_t address; /* remote address */ int addrlength; /* remote addrlen */ }; @@ -137,14 +137,14 @@ struct isc_socket { struct isc_socketmgr { /* Not locked. */ unsigned int magic; - isc_memctx_t mctx; + isc_memctx_t * mctx; isc_mutex_t lock; /* Locked by manager lock. */ unsigned int nsockets; /* sockets managed */ isc_thread_t watcher; fd_set read_fds; fd_set write_fds; - isc_socket_t fds[FD_SETSIZE]; + isc_socket_t * fds[FD_SETSIZE]; int fdstate[FD_SETSIZE]; int maxfd; int pipe_fds[2]; @@ -154,19 +154,19 @@ struct isc_socketmgr { #define MANAGED 1 #define CLOSE_PENDING 2 -static void send_recvdone_event(isc_socket_t, rwintev_t *, - isc_socketevent_t *, isc_result_t); -static void send_senddone_event(isc_socket_t, rwintev_t *, - isc_socketevent_t *, isc_result_t); -static void done_event_destroy(isc_event_t); -static void free_socket(isc_socket_t *); -static isc_result_t allocate_socket(isc_socketmgr_t, isc_sockettype_t, - isc_socket_t *); -static void destroy(isc_socket_t *); -static isc_boolean_t internal_accept(isc_task_t, isc_event_t); -static isc_boolean_t internal_connect(isc_task_t, isc_event_t); -static isc_boolean_t internal_recv(isc_task_t, isc_event_t); -static isc_boolean_t internal_send(isc_task_t, isc_event_t); +static void send_recvdone_event(isc_socket_t *, rwintev_t **, + isc_socketevent_t **, isc_result_t); +static void send_senddone_event(isc_socket_t *, rwintev_t **, + isc_socketevent_t **, isc_result_t); +static void done_event_destroy(isc_event_t *); +static void free_socket(isc_socket_t **); +static isc_result_t allocate_socket(isc_socketmgr_t *, isc_sockettype_t, + isc_socket_t **); +static void destroy(isc_socket_t **); +static isc_boolean_t internal_accept(isc_task_t *, isc_event_t *); +static isc_boolean_t internal_connect(isc_task_t *, isc_event_t *); +static isc_boolean_t internal_recv(isc_task_t *, isc_event_t *); +static isc_boolean_t internal_send(isc_task_t *, isc_event_t *); #define SELECT_POKE_SHUTDOWN (-1) #define SELECT_POKE_NOTHING (-2) @@ -178,7 +178,7 @@ static isc_boolean_t internal_send(isc_task_t, isc_event_t); * queue fully. That is, we will not get partial writes. */ static void -select_poke(isc_socketmgr_t mgr, int msg) +select_poke(isc_socketmgr_t *mgr, int msg) { int cc; @@ -193,7 +193,7 @@ select_poke(isc_socketmgr_t mgr, int msg) * read a message on the internal fd. */ static int -select_readmsg(isc_socketmgr_t mgr) +select_readmsg(isc_socketmgr_t *mgr) { int msg; int cc; @@ -239,10 +239,10 @@ make_nonblock(int fd) #ifdef ISC_SOCKET_DEBUG static void -socket_dump(isc_socket_t sock) +socket_dump(isc_socket_t *sock) { - rwintev_t rwiev; - ncintev_t aiev; + rwintev_t * rwiev; + ncintev_t * aiev; printf("--------\nDump of socket %p\n", sock); printf("fd: %d, references %u\n", sock->fd, sock->references); @@ -250,7 +250,8 @@ socket_dump(isc_socket_t sock) printf("recv queue:\n"); rwiev = HEAD(sock->recv_list); while (rwiev != NULL) { - printf("\tintev %p, done_ev %p, task %p, canceled %d, posted %d", + printf("\tintev %p, done_ev %p, task %p, " + "canceled %d, posted %d", rwiev, rwiev->done_ev, rwiev->task, rwiev->canceled, rwiev->posted); rwiev = NEXT(rwiev, link); @@ -259,7 +260,8 @@ socket_dump(isc_socket_t sock) printf("send queue:\n"); rwiev = HEAD(sock->send_list); while (rwiev != NULL) { - printf("\tintev %p, done_ev %p, task %p, canceled %d, posted %d", + printf("\tintev %p, done_ev %p, task %p, " + "canceled %d, posted %d", rwiev, rwiev->done_ev, rwiev->task, rwiev->canceled, rwiev->posted); rwiev = NEXT(rwiev, link); @@ -268,7 +270,8 @@ socket_dump(isc_socket_t sock) printf("accept queue:\n"); aiev = HEAD(sock->accept_list); while (aiev != NULL) { - printf("\tintev %p, done_ev %p, task %p, canceled %d, posted %d\n", + printf("\tintev %p, done_ev %p, task %p, " + "canceled %d, posted %d\n", aiev, aiev->done_ev, aiev->task, aiev->canceled, aiev->posted); aiev = NEXT(aiev, link); @@ -282,9 +285,9 @@ socket_dump(isc_socket_t sock) * Handle freeing a done event when needed. */ static void -done_event_destroy(isc_event_t ev) +done_event_destroy(isc_event_t *ev) { - isc_socket_t sock = ev->sender; + isc_socket_t *sock = ev->sender; isc_boolean_t kill_socket = ISC_FALSE; /* @@ -304,6 +307,8 @@ done_event_destroy(isc_event_t ev) if (kill_socket) destroy(&sock); + + /* XXXRTH looks like we're leaking the done event here... */ } /* @@ -312,10 +317,10 @@ done_event_destroy(isc_event_t ev) * Caller must ensure locking. */ static void -destroy(isc_socket_t *sockp) +destroy(isc_socket_t **sockp) { - isc_socket_t sock = *sockp; - isc_socketmgr_t manager = sock->manager; + isc_socket_t *sock = *sockp; + isc_socketmgr_t *manager = sock->manager; XTRACE(TRACE_MANAGER, ("destroy sockp = %p, sock = %p\n", sockp, sock)); @@ -342,10 +347,10 @@ destroy(isc_socket_t *sockp) } static isc_result_t -allocate_socket(isc_socketmgr_t manager, isc_sockettype_t type, - isc_socket_t *socketp) +allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, + isc_socket_t **socketp) { - isc_socket_t sock; + isc_socket_t *sock; sock = isc_mem_get(manager->mctx, sizeof *sock); @@ -398,9 +403,9 @@ allocate_socket(isc_socketmgr_t manager, isc_sockettype_t type, * also close the socket. */ static void -free_socket(isc_socket_t *socketp) +free_socket(isc_socket_t **socketp) { - isc_socket_t sock = *socketp; + isc_socket_t *sock = *socketp; REQUIRE(sock->references == 0); REQUIRE(VALID_SOCKET(sock)); @@ -429,10 +434,10 @@ free_socket(isc_socket_t *socketp) * in 'socketp'. */ isc_result_t -isc_socket_create(isc_socketmgr_t manager, isc_sockettype_t type, - isc_socket_t *socketp) +isc_socket_create(isc_socketmgr_t *manager, isc_sockettype_t type, + isc_socket_t **socketp) { - isc_socket_t sock = NULL; + isc_socket_t *sock = NULL; isc_result_t ret; REQUIRE(VALID_MANAGER(manager)); @@ -503,7 +508,7 @@ isc_socket_create(isc_socketmgr_t manager, isc_sockettype_t type, * Attach to a socket. Caller must explicitly detach when it is done. */ void -isc_socket_attach(isc_socket_t sock, isc_socket_t *socketp) +isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) { REQUIRE(VALID_SOCKET(sock)); REQUIRE(socketp != NULL && *socketp == NULL); @@ -520,9 +525,9 @@ isc_socket_attach(isc_socket_t sock, isc_socket_t *socketp) * up by destroying the socket. */ void -isc_socket_detach(isc_socket_t *socketp) +isc_socket_detach(isc_socket_t **socketp) { - isc_socket_t sock; + isc_socket_t *sock; isc_boolean_t kill_socket = ISC_FALSE; REQUIRE(socketp != NULL); @@ -555,13 +560,13 @@ isc_socket_detach(isc_socket_t *socketp) * The socket and manager must be locked before calling this function. */ static void -dispatch_read(isc_socket_t sock) +dispatch_read(isc_socket_t *sock) { - rwintev_t iev; - isc_event_t ev; + rwintev_t *iev; + isc_event_t *ev; iev = HEAD(sock->recv_list); - ev = (isc_event_t)iev; + ev = (isc_event_t *)iev; INSIST(!sock->pending_recv); @@ -576,13 +581,13 @@ dispatch_read(isc_socket_t sock) } static void -dispatch_write(isc_socket_t sock) +dispatch_write(isc_socket_t *sock) { - rwintev_t iev; - isc_event_t ev; + rwintev_t *iev; + isc_event_t *ev; iev = HEAD(sock->send_list); - ev = (isc_event_t)iev; + ev = (isc_event_t *)iev; INSIST(!sock->pending_send); sock->pending_send = ISC_TRUE; @@ -593,13 +598,13 @@ dispatch_write(isc_socket_t sock) } static void -dispatch_listen(isc_socket_t sock) +dispatch_listen(isc_socket_t *sock) { - ncintev_t iev; - isc_event_t ev; + ncintev_t *iev; + isc_event_t *ev; iev = HEAD(sock->accept_list); - ev = (isc_event_t)iev; + ev = (isc_event_t *)iev; INSIST(!sock->pending_accept); @@ -611,9 +616,9 @@ dispatch_listen(isc_socket_t sock) } static void -dispatch_connect(isc_socket_t sock) +dispatch_connect(isc_socket_t *sock) { - cnintev_t iev; + cnintev_t *iev; INSIST(sock->connecting); @@ -621,7 +626,7 @@ dispatch_connect(isc_socket_t sock) iev->posted = ISC_TRUE; - ISC_TASK_SEND(iev->task, (isc_event_t *)&iev); + ISC_TASK_SEND(iev->task, (isc_event_t **)&iev); } /* @@ -632,8 +637,8 @@ dispatch_connect(isc_socket_t sock) * Caller must have the socket locked. */ static void -send_recvdone_event(isc_socket_t sock, rwintev_t *iev, - isc_socketevent_t *dev, isc_result_t resultcode) +send_recvdone_event(isc_socket_t *sock, rwintev_t **iev, + isc_socketevent_t **dev, isc_result_t resultcode) { REQUIRE(!EMPTY(sock->recv_list)); REQUIRE(iev != NULL); @@ -643,13 +648,13 @@ send_recvdone_event(isc_socket_t sock, rwintev_t *iev, DEQUEUE(sock->recv_list, *iev, link); (*dev)->result = resultcode; - ISC_TASK_SEND((*iev)->task, (isc_event_t *)dev); + ISC_TASK_SEND((*iev)->task, (isc_event_t **)dev); (*iev)->done_ev = NULL; - isc_event_free((isc_event_t *)iev); + isc_event_free((isc_event_t **)iev); } static void -send_senddone_event(isc_socket_t sock, rwintev_t *iev, - isc_socketevent_t *dev, isc_result_t resultcode) +send_senddone_event(isc_socket_t *sock, rwintev_t **iev, + isc_socketevent_t **dev, isc_result_t resultcode) { REQUIRE(!EMPTY(sock->send_list)); REQUIRE(iev != NULL); @@ -659,14 +664,14 @@ send_senddone_event(isc_socket_t sock, rwintev_t *iev, DEQUEUE(sock->send_list, *iev, link); (*dev)->result = resultcode; - ISC_TASK_SEND((*iev)->task, (isc_event_t *)dev); + ISC_TASK_SEND((*iev)->task, (isc_event_t **)dev); (*iev)->done_ev = NULL; - isc_event_free((isc_event_t *)iev); + isc_event_free((isc_event_t **)iev); } static void -send_ncdone_event(ncintev_t *iev, - isc_socket_newconnev_t *dev, isc_result_t resultcode) +send_ncdone_event(ncintev_t **iev, + isc_socket_newconnev_t **dev, isc_result_t resultcode) { REQUIRE(iev != NULL); REQUIRE(*iev != NULL); @@ -674,10 +679,10 @@ send_ncdone_event(ncintev_t *iev, REQUIRE(*dev != NULL); (*dev)->result = resultcode; - ISC_TASK_SEND((*iev)->task, (isc_event_t *)dev); + ISC_TASK_SEND((*iev)->task, (isc_event_t **)dev); (*iev)->done_ev = NULL; - isc_event_free((isc_event_t *)iev); + isc_event_free((isc_event_t **)iev); } /* @@ -688,12 +693,12 @@ send_ncdone_event(ncintev_t *iev, * attach to the socket again. The task is not attached at all. */ static isc_boolean_t -internal_accept(isc_task_t task, isc_event_t ev) +internal_accept(isc_task_t *task, isc_event_t *ev) { - isc_socket_t sock; - isc_socketmgr_t manager; - isc_socket_newconnev_t dev; - ncintev_t iev; + isc_socket_t *sock; + isc_socketmgr_t *manager; + isc_socket_newconnev_t *dev; + ncintev_t *iev; struct sockaddr addr; u_int addrlen; int fd; @@ -702,7 +707,7 @@ internal_accept(isc_task_t task, isc_event_t ev) sock = ev->sender; REQUIRE(VALID_SOCKET(sock)); - iev = (ncintev_t)ev; + iev = (ncintev_t *)ev; manager = sock->manager; REQUIRE(VALID_MANAGER(manager)); @@ -722,7 +727,7 @@ internal_accept(isc_task_t task, isc_event_t ev) */ if (iev->canceled) { DEQUEUE(sock->accept_list, iev, link); - isc_event_free((isc_event_t *)iev); + isc_event_free((isc_event_t **)iev); if (!EMPTY(sock->accept_list)) select_poke(sock->manager, sock->fd); @@ -817,11 +822,11 @@ internal_accept(isc_task_t task, isc_event_t ev) } static isc_boolean_t -internal_recv(isc_task_t task, isc_event_t ev) +internal_recv(isc_task_t *task, isc_event_t *ev) { - rwintev_t iev; - isc_socketevent_t dev; - isc_socket_t sock; + rwintev_t *iev; + isc_socketevent_t *dev; + isc_socket_t *sock; int cc; size_t read_count; struct sockaddr addr; @@ -830,7 +835,7 @@ internal_recv(isc_task_t task, isc_event_t ev) /* * Find out what socket this is and lock it. */ - sock = (isc_socket_t)ev->sender; + sock = (isc_socket_t *)ev->sender; LOCK(&sock->lock); INSIST(sock->pending_recv == ISC_TRUE); @@ -862,7 +867,7 @@ internal_recv(isc_task_t task, isc_event_t ev) */ if (iev->canceled) { DEQUEUE(sock->recv_list, iev, link); - isc_event_free((isc_event_t *)&iev); + isc_event_free((isc_event_t **)&iev); continue; } @@ -977,18 +982,18 @@ internal_recv(isc_task_t task, isc_event_t ev) } static isc_boolean_t -internal_send(isc_task_t task, isc_event_t ev) +internal_send(isc_task_t *task, isc_event_t *ev) { - rwintev_t iev; - isc_socketevent_t dev; - isc_socket_t sock; + rwintev_t *iev; + isc_socketevent_t *dev; + isc_socket_t *sock; int cc; size_t write_count; /* * Find out what socket this is and lock it. */ - sock = (isc_socket_t)ev->sender; + sock = (isc_socket_t *)ev->sender; LOCK(&sock->lock); INSIST(sock->pending_send == ISC_TRUE); @@ -1020,7 +1025,7 @@ internal_send(isc_task_t task, isc_event_t ev) */ if (iev->canceled) { DEQUEUE(sock->send_list, iev, link); - isc_event_free((isc_event_t *)&iev); + isc_event_free((isc_event_t **)&iev); continue; } @@ -1123,8 +1128,8 @@ static isc_threadresult_t WINAPI watcher(void *uap) { - isc_socketmgr_t manager = uap; - isc_socket_t sock; + isc_socketmgr_t *manager = uap; + isc_socket_t *sock; isc_boolean_t done; int ctlfd; int cc; @@ -1133,8 +1138,8 @@ watcher(void *uap) int msg; isc_boolean_t unlock_sock; int i; - rwintev_t iev; - ncintev_t nciev; + rwintev_t *iev; + ncintev_t *nciev; int maxfd; /* @@ -1227,7 +1232,8 @@ watcher(void *uap) if (msg >= 0) { INSIST(msg < FD_SETSIZE); - if (manager->fdstate[msg] == CLOSE_PENDING) { + if (manager->fdstate[msg] == + CLOSE_PENDING) { manager->fdstate[msg] = CLOSED; FD_CLR(msg, &manager->read_fds); @@ -1368,9 +1374,9 @@ watcher(void *uap) * Create a new socket manager. */ isc_result_t -isc_socketmgr_create(isc_memctx_t mctx, isc_socketmgr_t *managerp) +isc_socketmgr_create(isc_memctx_t *mctx, isc_socketmgr_t **managerp) { - isc_socketmgr_t manager; + isc_socketmgr_t *manager; REQUIRE(managerp != NULL && *managerp == NULL); @@ -1438,9 +1444,9 @@ isc_socketmgr_create(isc_memctx_t mctx, isc_socketmgr_t *managerp) } void -isc_socketmgr_destroy(isc_socketmgr_t *managerp) +isc_socketmgr_destroy(isc_socketmgr_t **managerp) { - isc_socketmgr_t manager; + isc_socketmgr_t *manager; int i; /* @@ -1487,36 +1493,36 @@ isc_socketmgr_destroy(isc_socketmgr_t *managerp) } isc_result_t -isc_socket_recv(isc_socket_t sock, isc_region_t region, - isc_boolean_t partial, isc_task_t task, +isc_socket_recv(isc_socket_t *sock, isc_region_t *region, + isc_boolean_t partial, isc_task_t *task, isc_taskaction_t action, void *arg) { - isc_socketevent_t ev; - rwintev_t iev; - isc_socketmgr_t manager; - isc_task_t ntask = NULL; + isc_socketevent_t *ev; + rwintev_t *iev; + isc_socketmgr_t *manager; + isc_task_t *ntask = NULL; int cc; manager = sock->manager; - ev = (isc_socketevent_t)isc_event_allocate(manager->mctx, sock, - ISC_SOCKEVENT_RECVDONE, - action, arg, sizeof(*ev)); + ev = (isc_socketevent_t *)isc_event_allocate(manager->mctx, sock, + ISC_SOCKEVENT_RECVDONE, + action, arg, sizeof(*ev)); if (ev == NULL) return (ISC_R_NOMEMORY); LOCK(&sock->lock); if (sock->riev == NULL) { - iev = (rwintev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_INTRECV, - internal_recv, - sock, - sizeof(*iev)); + iev = (rwintev_t *)isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_INTRECV, + internal_recv, + sock, + sizeof(*iev)); if (iev == NULL) { /* no special free routine yet */ - isc_event_free((isc_event_t *)&ev); + isc_event_free((isc_event_t **)&ev); UNLOCK(&sock->lock); return (ISC_R_NOMEMORY); } @@ -1574,7 +1580,7 @@ isc_socket_recv(isc_socket_t sock, isc_region_t region, sock->recv_result = ISC_R_UNEXPECTED; /* XXX */ ev->result = ISC_R_UNEXPECTED; /* XXX */ - ISC_TASK_SEND(task, (isc_event_t *)&ev); + ISC_TASK_SEND(task, (isc_event_t **)&ev); UNLOCK(&sock->lock); return (ISC_R_SUCCESS); @@ -1582,7 +1588,7 @@ isc_socket_recv(isc_socket_t sock, isc_region_t region, if (cc == 0) { ev->result = ISC_R_EOF; - ISC_TASK_SEND(task, (isc_event_t *)&ev); + ISC_TASK_SEND(task, (isc_event_t **)&ev); UNLOCK(&sock->lock); return (ISC_R_SUCCESS); @@ -1599,7 +1605,7 @@ isc_socket_recv(isc_socket_t sock, isc_region_t region, /* * full reads are posted, or partials if partials are ok. */ - ISC_TASK_SEND(task, (isc_event_t *)&ev); + ISC_TASK_SEND(task, (isc_event_t **)&ev); UNLOCK(&sock->lock); @@ -1641,43 +1647,43 @@ isc_socket_recv(isc_socket_t sock, isc_region_t region, } isc_result_t -isc_socket_send(isc_socket_t sock, isc_region_t region, - isc_task_t task, isc_taskaction_t action, void *arg) +isc_socket_send(isc_socket_t *sock, isc_region_t *region, + isc_task_t *task, isc_taskaction_t action, void *arg) { return isc_socket_sendto(sock, region, task, action, arg, NULL, 0); } isc_result_t -isc_socket_sendto(isc_socket_t sock, isc_region_t region, - isc_task_t task, isc_taskaction_t action, void *arg, - isc_sockaddr_t address, unsigned int addrlength) +isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, + isc_task_t *task, isc_taskaction_t action, void *arg, + isc_sockaddr_t *address, unsigned int addrlength) { - isc_socketevent_t ev; - rwintev_t iev; - isc_socketmgr_t manager; - isc_task_t ntask = NULL; + isc_socketevent_t *ev; + rwintev_t *iev; + isc_socketmgr_t *manager; + isc_task_t *ntask = NULL; int cc; manager = sock->manager; - ev = (isc_socketevent_t)isc_event_allocate(manager->mctx, sock, - ISC_SOCKEVENT_SENDDONE, - action, arg, sizeof(*ev)); + ev = (isc_socketevent_t *)isc_event_allocate(manager->mctx, sock, + ISC_SOCKEVENT_SENDDONE, + action, arg, sizeof(*ev)); if (ev == NULL) return (ISC_R_NOMEMORY); LOCK(&sock->lock); if (sock->wiev == NULL) { - iev = (rwintev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_INTSEND, - internal_send, - sock, - sizeof(*iev)); + iev = (rwintev_t *)isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_INTSEND, + internal_send, + sock, + sizeof(*iev)); if (iev == NULL) { /* no special free routine yet */ - isc_event_free((isc_event_t *)&ev); + isc_event_free((isc_event_t **)&ev); return (ISC_R_NOMEMORY); } @@ -1729,7 +1735,8 @@ isc_socket_sendto(isc_socket_t sock, isc_region_t region, ev->region.length, 0); else { UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_socket_send: unknown socket type"); + "isc_socket_send: " + "unknown socket type"); return (ISC_R_UNEXPECTED); } @@ -1749,7 +1756,7 @@ isc_socket_sendto(isc_socket_t sock, isc_region_t region, if (cc == 0) { ev->result = ISC_R_EOF; - ISC_TASK_SEND(task, (isc_event_t *)&ev); + ISC_TASK_SEND(task, (isc_event_t **)&ev); UNLOCK(&sock->lock); return (ISC_R_SUCCESS); @@ -1766,7 +1773,7 @@ isc_socket_sendto(isc_socket_t sock, isc_region_t region, /* * full writes are posted. */ - ISC_TASK_SEND(task, (isc_event_t *)&ev); + ISC_TASK_SEND(task, (isc_event_t **)&ev); UNLOCK(&sock->lock); @@ -1808,7 +1815,7 @@ isc_socket_sendto(isc_socket_t sock, isc_region_t region, } isc_result_t -isc_socket_bind(isc_socket_t sock, struct isc_sockaddr *sockaddr, +isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr, int addrlen) { int on = 1; @@ -1860,7 +1867,7 @@ isc_socket_bind(isc_socket_t sock, struct isc_sockaddr *sockaddr, * as well keep things simple rather than having to track them. */ isc_result_t -isc_socket_listen(isc_socket_t sock, unsigned int backlog) +isc_socket_listen(isc_socket_t *sock, unsigned int backlog) { REQUIRE(VALID_SOCKET(sock)); @@ -1890,14 +1897,14 @@ isc_socket_listen(isc_socket_t sock, unsigned int backlog) * This should try to do agressive accept() */ isc_result_t -isc_socket_accept(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg) +isc_socket_accept(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg) { - ncintev_t iev; - isc_socket_newconnev_t dev; - isc_task_t ntask = NULL; - isc_socketmgr_t manager; - isc_socket_t nsock; + ncintev_t *iev; + isc_socket_newconnev_t *dev; + isc_task_t *ntask = NULL; + isc_socketmgr_t *manager; + isc_socket_t *nsock; isc_result_t ret; XENTER(TRACE_LISTEN, "isc_socket_accept"); @@ -1910,10 +1917,10 @@ isc_socket_accept(isc_socket_t sock, REQUIRE(sock->listener); - iev = (ncintev_t)isc_event_allocate(manager->mctx, sock, - ISC_SOCKEVENT_INTACCEPT, - internal_accept, sock, - sizeof(*iev)); + iev = (ncintev_t *)isc_event_allocate(manager->mctx, sock, + ISC_SOCKEVENT_INTACCEPT, + internal_accept, sock, + sizeof(*iev)); if (iev == NULL) { UNLOCK(&sock->lock); return (ISC_R_NOMEMORY); @@ -1921,15 +1928,16 @@ isc_socket_accept(isc_socket_t sock, iev->posted = ISC_FALSE; - dev = (isc_socket_newconnev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_NEWCONN, - action, - arg, - sizeof (*dev)); + dev = (isc_socket_newconnev_t *) + isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_NEWCONN, + action, + arg, + sizeof (*dev)); if (dev == NULL) { UNLOCK(&sock->lock); - isc_event_free((isc_event_t *)&iev); + isc_event_free((isc_event_t **)&iev); return (ISC_R_NOMEMORY); } @@ -1937,8 +1945,8 @@ isc_socket_accept(isc_socket_t sock, ret = allocate_socket(manager, sock->type, &nsock); if (ret != ISC_R_SUCCESS) { UNLOCK(&sock->lock); - isc_event_free((isc_event_t *)&iev); - isc_event_free((isc_event_t *)&dev); + isc_event_free((isc_event_t **)&iev); + isc_event_free((isc_event_t **)&dev); return (ret); } @@ -1975,12 +1983,12 @@ isc_socket_accept(isc_socket_t sock, } isc_result_t -isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addr, int addrlen, - isc_task_t task, isc_taskaction_t action, void *arg) +isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, int addrlen, + isc_task_t *task, isc_taskaction_t action, void *arg) { - isc_socket_connev_t dev; - isc_task_t ntask = NULL; - isc_socketmgr_t manager; + isc_socket_connev_t *dev; + isc_task_t *ntask = NULL; + isc_socketmgr_t *manager; int cc; XENTER(TRACE_CONNECT, "isc_socket_connect"); @@ -1994,12 +2002,13 @@ isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addr, int addrlen, REQUIRE(!sock->connecting); if (sock->ciev == NULL) { - sock->ciev = (cnintev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_INTCONN, - internal_connect, - sock, - sizeof(*(sock->ciev))); + sock->ciev = (cnintev_t *) + isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_INTCONN, + internal_connect, + sock, + sizeof(*(sock->ciev))); if (sock->ciev == NULL) { UNLOCK(&sock->lock); return (ISC_R_NOMEMORY); @@ -2008,12 +2017,12 @@ isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addr, int addrlen, sock->ciev->posted = ISC_FALSE; } - dev = (isc_socket_connev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_CONNECT, - action, - arg, - sizeof (*dev)); + dev = (isc_socket_connev_t *)isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_CONNECT, + action, + arg, + sizeof (*dev)); if (dev == NULL) { UNLOCK(&sock->lock); return (ISC_R_NOMEMORY); @@ -2046,7 +2055,7 @@ isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addr, int addrlen, */ if (cc == 0) { dev->result = ISC_R_SUCCESS; - ISC_TASK_SEND(task, (isc_event_t *)&dev); + ISC_TASK_SEND(task, (isc_event_t **)&dev); UNLOCK(&sock->lock); return (ISC_R_SUCCESS); @@ -2087,16 +2096,16 @@ isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addr, int addrlen, * Called when a socket with a pending connect() finishes. */ static isc_boolean_t -internal_connect(isc_task_t task, isc_event_t ev) +internal_connect(isc_task_t *task, isc_event_t *ev) { - isc_socket_t sock; - isc_socket_connev_t dev; - cnintev_t iev; + isc_socket_t *sock; + isc_socket_connev_t *dev; + cnintev_t *iev; int cc; int optlen; sock = ev->sender; - iev = (cnintev_t)ev; + iev = (cnintev_t *)ev; REQUIRE(VALID_SOCKET(sock)); @@ -2105,7 +2114,7 @@ internal_connect(isc_task_t task, isc_event_t ev) ("internal_connect called, locked parent sock %p\n", sock)); REQUIRE(sock->connecting); - REQUIRE(sock->connect_ev == (cnintev_t)ev); + REQUIRE(sock->connect_ev == (cnintev_t *)ev); REQUIRE(iev->task == task); sock->connecting = ISC_FALSE; @@ -2114,7 +2123,7 @@ internal_connect(isc_task_t task, isc_event_t ev) * Has this event been canceled? */ if (iev->canceled) { - isc_event_free((isc_event_t *)(sock->connect_ev)); + isc_event_free((isc_event_t **)(sock->connect_ev)); UNLOCK(&sock->lock); @@ -2171,15 +2180,15 @@ internal_connect(isc_task_t task, isc_event_t ev) UNLOCK(&sock->lock); - ISC_TASK_SEND(iev->task, (isc_event_t *)&dev); + ISC_TASK_SEND(iev->task, (isc_event_t **)&dev); iev->done_ev = NULL; - isc_event_free((isc_event_t *)&iev); + isc_event_free((isc_event_t **)&iev); return (ISC_FALSE); } isc_result_t -isc_socket_getpeername(isc_socket_t sock, struct isc_sockaddr *addressp, +isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp, int *lengthp) { REQUIRE(VALID_SOCKET(sock)); @@ -2202,10 +2211,10 @@ isc_socket_getpeername(isc_socket_t sock, struct isc_sockaddr *addressp, } isc_result_t -isc_socket_getsockname(isc_socket_t sock, struct isc_sockaddr *addressp, +isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp, int *lengthp) { - struct isc_sockaddr addr; + isc_sockaddr_t addr; int len; REQUIRE(VALID_SOCKET(sock)); @@ -2240,10 +2249,10 @@ isc_socket_getsockname(isc_socket_t sock, struct isc_sockaddr *addressp, * queued for task "task" of type "how". "how" is a bitmask. */ void -isc_socket_cancel(isc_socket_t sock, isc_task_t task, +isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { - isc_boolean_t poke_needed; + isc_boolean_t poke_needed; REQUIRE(VALID_SOCKET(sock)); @@ -2269,9 +2278,9 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, * o Reset any state needed. */ if ((how & ISC_SOCKCANCEL_RECV) && HEAD(sock->recv_list) != NULL) { - rwintev_t iev; - rwintev_t next; - isc_socketevent_t dev; + rwintev_t * iev; + rwintev_t * next; + isc_socketevent_t * dev; iev = HEAD(sock->recv_list); @@ -2286,7 +2295,7 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, if ((task == NULL || task == iev->task) && iev->posted && !iev->canceled) { if (isc_task_purge(task, sock, - ISC_SOCKEVENT_INTRECV) == 0) { + ISC_SOCKEVENT_INTRECV) == 0) { iev->canceled = ISC_TRUE; /* * pull off the done event and post it. @@ -2295,7 +2304,7 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, iev->done_ev = NULL; dev->result = ISC_R_CANCELED; ISC_TASK_SEND(iev->task, - (isc_event_t *)&dev); + (isc_event_t **)&dev); iev = NEXT(iev, link); } @@ -2321,16 +2330,16 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, } if ((how & ISC_SOCKCANCEL_ACCEPT) && HEAD(sock->accept_list) != NULL) { - ncintev_t iev; - ncintev_t next; - isc_socket_newconnev_t dev; + ncintev_t * iev; + ncintev_t * next; + isc_socket_newconnev_t *dev; iev = HEAD(sock->accept_list); if ((task == NULL || task == iev->task) && iev->posted && !iev->canceled) { if (isc_task_purge(task, sock, - ISC_SOCKEVENT_INTACCEPT) == 0) { + ISC_SOCKEVENT_INTACCEPT) == 0) { iev->canceled = ISC_TRUE; dev = iev->done_ev; iev->done_ev = NULL; @@ -2338,7 +2347,7 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, dev->newsocket->references--; free_socket(&dev->newsocket); ISC_TASK_SEND(iev->task, - (isc_event_t *)&dev); + (isc_event_t **)&dev); iev = NEXT(iev, link); } @@ -2372,19 +2381,20 @@ isc_socket_cancel(isc_socket_t sock, isc_task_t task, } isc_result_t -isc_socket_recvmark(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg) +isc_socket_recvmark(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg) { - isc_socketevent_t dev; - rwintev_t iev; - isc_socketmgr_t manager; - isc_task_t ntask = NULL; + isc_socketevent_t *dev; + rwintev_t *iev; + isc_socketmgr_t *manager; + isc_task_t *ntask = NULL; manager = sock->manager; - dev = (isc_socketevent_t)isc_event_allocate(manager->mctx, sock, - ISC_SOCKEVENT_RECVMARK, - action, arg, sizeof(*dev)); + dev = (isc_socketevent_t *)isc_event_allocate(manager->mctx, sock, + ISC_SOCKEVENT_RECVMARK, + action, arg, + sizeof(*dev)); if (dev == NULL) return (ISC_R_NOMEMORY); @@ -2400,7 +2410,7 @@ isc_socket_recvmark(isc_socket_t sock, dev->common.destroy = done_event_destroy; sock->references++; - ISC_TASK_SEND(task, (isc_event_t *)&dev); + ISC_TASK_SEND(task, (isc_event_t **)&dev); UNLOCK(&sock->lock); @@ -2411,15 +2421,15 @@ isc_socket_recvmark(isc_socket_t sock, * Bad luck. The queue wasn't empty. Insert this in the proper * place. */ - iev = (rwintev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_INTRECV, - internal_recv, - sock, - sizeof(*iev)); + iev = (rwintev_t *)isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_INTRECV, + internal_recv, + sock, + sizeof(*iev)); if (iev == NULL) { - isc_event_free((isc_event_t *)&dev); + isc_event_free((isc_event_t **)&dev); return (ISC_R_NOMEMORY); } @@ -2448,19 +2458,20 @@ isc_socket_recvmark(isc_socket_t sock, } isc_result_t -isc_socket_sendmark(isc_socket_t sock, - isc_task_t task, isc_taskaction_t action, void *arg) +isc_socket_sendmark(isc_socket_t *sock, + isc_task_t *task, isc_taskaction_t action, void *arg) { - isc_socketevent_t dev; - rwintev_t iev; - isc_socketmgr_t manager; - isc_task_t ntask = NULL; + isc_socketevent_t *dev; + rwintev_t *iev; + isc_socketmgr_t *manager; + isc_task_t *ntask = NULL; manager = sock->manager; - dev = (isc_socketevent_t)isc_event_allocate(manager->mctx, sock, - ISC_SOCKEVENT_SENDMARK, - action, arg, sizeof(*dev)); + dev = (isc_socketevent_t *)isc_event_allocate(manager->mctx, sock, + ISC_SOCKEVENT_SENDMARK, + action, arg, + sizeof(*dev)); if (dev == NULL) return (ISC_R_NOMEMORY); @@ -2476,7 +2487,7 @@ isc_socket_sendmark(isc_socket_t sock, dev->common.destroy = done_event_destroy; sock->references++; - ISC_TASK_SEND(task, (isc_event_t *)&dev); + ISC_TASK_SEND(task, (isc_event_t **)&dev); UNLOCK(&sock->lock); @@ -2487,15 +2498,15 @@ isc_socket_sendmark(isc_socket_t sock, * Bad luck. The queue wasn't empty. Insert this in the proper * place. */ - iev = (rwintev_t)isc_event_allocate(manager->mctx, - sock, - ISC_SOCKEVENT_INTSEND, - internal_send, - sock, - sizeof(*iev)); + iev = (rwintev_t *)isc_event_allocate(manager->mctx, + sock, + ISC_SOCKEVENT_INTSEND, + internal_send, + sock, + sizeof(*iev)); if (iev == NULL) { - isc_event_free((isc_event_t *)&dev); + isc_event_free((isc_event_t **)&dev); return (ISC_R_NOMEMORY); } diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 897bb72031..36ec8bceb0 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -17,6 +17,7 @@ #include +#include #include #include @@ -34,7 +35,7 @@ ***/ void -isc_interval_set(isc_interval_t i, +isc_interval_set(isc_interval_t *i, unsigned int seconds, unsigned int nanoseconds) { /* @@ -51,7 +52,7 @@ isc_interval_set(isc_interval_t i, } isc_boolean_t -isc_interval_iszero(isc_interval_t i) { +isc_interval_iszero(isc_interval_t *i) { /* * Returns ISC_TRUE iff. 'i' is the zero interval. @@ -71,7 +72,7 @@ isc_interval_iszero(isc_interval_t i) { ***/ void -isc_time_settoepoch(isc_time_t t) { +isc_time_settoepoch(isc_time_t *t) { /* * Set 't' to the time of the epoch. */ @@ -83,7 +84,7 @@ isc_time_settoepoch(isc_time_t t) { } isc_boolean_t -isc_time_isepoch(isc_time_t t) { +isc_time_isepoch(isc_time_t *t) { /* * Returns ISC_TRUE iff. 't' is the epoch ("time zero"). @@ -98,7 +99,7 @@ isc_time_isepoch(isc_time_t t) { } isc_result_t -isc_time_get(isc_time_t t) { +isc_time_get(isc_time_t *t) { struct timeval tv; /* @@ -119,7 +120,7 @@ isc_time_get(isc_time_t t) { } int -isc_time_compare(isc_time_t t1, isc_time_t t2) { +isc_time_compare(isc_time_t *t1, isc_time_t *t2) { /* * Compare the times referenced by 't1' and 't2' @@ -139,7 +140,7 @@ isc_time_compare(isc_time_t t1, isc_time_t t2) { } void -isc_time_add(isc_time_t t, isc_interval_t i, isc_time_t result) +isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) { /* * Add 't' to 'i', storing the result in 'result'. @@ -156,7 +157,7 @@ isc_time_add(isc_time_t t, isc_interval_t i, isc_time_t result) } void -isc_time_subtract(isc_time_t t, isc_interval_t i, isc_time_t result) { +isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) { /* * Subtract 'i' from 't', storing the result in 'result'. */ @@ -172,61 +173,3 @@ isc_time_subtract(isc_time_t t, isc_interval_t i, isc_time_t result) { result->seconds--; } } - - -/*** - *** UNIX-only - ***/ - - -void -isc_time_fromtimeval(isc_time_t t, struct timeval *tv) { - - /* - * Set 't' to the time given by 'ts'. - */ - - REQUIRE(t != NULL && tv != NULL); - - t->seconds = tv->tv_sec; - t->nanoseconds = tv->tv_usec * 1000; -} - -void -isc_time_totimeval(isc_time_t t, struct timeval *tv) { - - /* - * Convert 't' to a UNIX timeval. - */ - - REQUIRE(t != NULL && tv != NULL); - - tv->tv_sec = t->seconds; - tv->tv_usec = t->nanoseconds / 1000; -} - -void -isc_time_fromtimespec(isc_time_t t, struct timespec *ts) { - - /* - * Set 't' to the time given by 'ts'. - */ - - REQUIRE(t != NULL && ts != NULL); - - t->seconds = ts->tv_sec; - t->nanoseconds = ts->tv_nsec; -} - -void -isc_time_totimespec(isc_time_t t, struct timespec *ts) { - - /* - * Convert 't' to a UNIX timespec. - */ - - REQUIRE(t != NULL && ts != NULL); - - ts->tv_sec = t->seconds; - ts->tv_nsec = t->nanoseconds; -} diff --git a/util/copyrights b/util/copyrights index f55c30ef67..4f033a3070 100644 --- a/util/copyrights +++ b/util/copyrights @@ -28,6 +28,7 @@ ./lib/isc/pthreads/include/isc/mutex.h 1998 ./lib/isc/pthreads/include/isc/thread.h 1998 ./lib/isc/pthreads/condition.c 1998 +./lib/isc/unix/include/isc/sockaddr.h 1998 ./lib/isc/unix/include/isc/time.h 1998 ./lib/isc/unix/time.c 1998 ./lib/isc/win32/include/isc/condition.h 1998