2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 15:05:23 +00:00

the great type change

This commit is contained in:
Bob Halley
1998-12-13 23:45:21 +00:00
parent 26ec6d6655
commit 3740b569ae
31 changed files with 754 additions and 816 deletions

View File

@@ -31,7 +31,7 @@
#include <dns/name.h> #include <dns/name.h>
static void static void
print_wirename(isc_region_t name) { print_wirename(isc_region_t *name) {
unsigned char *ccurr, *cend; unsigned char *ccurr, *cend;
ccurr = name->base; ccurr = name->base;
@@ -49,9 +49,9 @@ main(int argc, char *argv[]) {
unsigned char c[255]; unsigned char c[255];
unsigned int tbytes; unsigned int tbytes;
dns_result_t result; dns_result_t result;
struct dns_name name, oname, compname; dns_name_t name, oname, compname;
struct isc_region source, target, r; isc_region_t source, target, r;
dns_name_t origin, comp; dns_name_t *origin, *comp;
isc_boolean_t downcase = ISC_FALSE; isc_boolean_t downcase = ISC_FALSE;
argc--; argc--;

View File

@@ -37,14 +37,14 @@
#include <arpa/inet.h> #include <arpa/inet.h>
isc_memctx_t mctx = NULL; isc_memctx_t *mctx = NULL;
int sockets_active = 0; int sockets_active = 0;
static isc_boolean_t my_send(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_recv(isc_task_t *task, isc_event_t *event);
static isc_boolean_t 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; char *name = event->arg;
@@ -56,7 +56,7 @@ my_callback(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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; char *name = event->arg;
@@ -68,15 +68,15 @@ my_shutdown(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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_socket_t *sock;
isc_socketevent_t dev; isc_socketevent_t *dev;
struct isc_region region; isc_region_t region;
char buf[1024]; char buf[1024];
sock = event->sender; 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", printf("Socket %s (sock %p, base %p, length %d, n %d, result %d)\n",
(char *)(event->arg), sock, (char *)(event->arg), sock,
@@ -125,13 +125,13 @@ my_recv(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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_socket_t *sock;
isc_socketevent_t dev; isc_socketevent_t *dev;
sock = event->sender; 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", printf("my_send: %s task %p\n\t(sock %p, base %p, length %d, n %d, result %d)\n",
(char *)(event->arg), task, sock, (char *)(event->arg), task, sock,
@@ -146,13 +146,13 @@ my_send(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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_socket_t *sock;
isc_socketevent_t dev; isc_socketevent_t *dev;
sock = event->sender; 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", 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, (char *)(event->arg), task, sock,
@@ -168,15 +168,15 @@ my_http_get(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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_t *sock;
isc_socket_connev_t dev; isc_socket_connev_t *dev;
struct isc_region region; isc_region_t region;
char buf[1024]; char buf[1024];
sock = event->sender; sock = event->sender;
dev = (isc_socket_connev_t)event; dev = (isc_socket_connev_t *)event;
printf("%s: Connection result: %d\n", (char *)(event->arg), printf("%s: Connection result: %d\n", (char *)(event->arg),
dev->result); dev->result);
@@ -205,15 +205,15 @@ my_connect(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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; char *name = event->arg;
isc_socket_newconnev_t dev; isc_socket_newconnev_t *dev;
struct isc_region region; isc_region_t region;
isc_socket_t oldsock; isc_socket_t *oldsock;
int ret; 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", printf("newcon %s (task %p, oldsock %p, newsock %p, result %d)\n",
name, task, event->sender, dev->newsocket, dev->result); 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 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); printf("Timeout, canceling IO on socket %p (task %p)\n", sock, task);
isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_ALL); 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); return (0);
} }
@@ -267,17 +267,17 @@ timeout(isc_task_t task, isc_event_t event)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
isc_taskmgr_t manager = NULL; isc_taskmgr_t *manager = NULL;
isc_task_t t1 = NULL, t2 = NULL; isc_task_t *t1 = NULL, *t2 = NULL;
isc_timermgr_t timgr = NULL; isc_timermgr_t *timgr = NULL;
struct isc_time expires, now; isc_time_t expires, now;
struct isc_interval interval; isc_interval_t interval;
isc_timer_t ti1 = NULL; isc_timer_t *ti1 = NULL;
isc_event_t event; isc_event_t *event;
unsigned int workers; unsigned int workers;
isc_socketmgr_t socketmgr; isc_socketmgr_t *socketmgr;
isc_socket_t so1, so2; isc_socket_t *so1, *so2;
struct isc_sockaddr sockaddr; isc_sockaddr_t sockaddr;
unsigned int addrlen; unsigned int addrlen;

View File

@@ -28,10 +28,10 @@
#include <isc/result.h> #include <isc/result.h>
#include <isc/timer.h> #include <isc/timer.h>
isc_memctx_t mctx = NULL; isc_memctx_t *mctx = NULL;
static isc_boolean_t 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; int i, j;
char *name = event->arg; char *name = event->arg;
@@ -46,7 +46,7 @@ my_callback(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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; char *name = event->arg;
printf("shutdown %s (%p)\n", name, task); 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 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; char *name = event->arg;
@@ -68,13 +68,13 @@ my_tick(isc_task_t task, isc_event_t event)
void void
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
isc_taskmgr_t manager = NULL; isc_taskmgr_t *manager = NULL;
isc_task_t t1 = NULL, t2 = NULL; isc_task_t *t1 = NULL, *t2 = NULL;
isc_task_t t3 = NULL, t4 = NULL; isc_task_t *t3 = NULL, *t4 = NULL;
isc_event_t event; isc_event_t *event;
unsigned int workers; unsigned int workers;
isc_timermgr_t timgr; isc_timermgr_t *timgr;
isc_timer_t ti1, ti2; isc_timer_t *ti1, *ti2;
struct isc_time absolute; struct isc_time absolute;
struct isc_interval interval; struct isc_interval interval;

View File

@@ -28,13 +28,13 @@
#include <isc/result.h> #include <isc/result.h>
#include <isc/timer.h> #include <isc/timer.h>
isc_memctx_t mctx = NULL; isc_memctx_t *mctx = NULL;
isc_task_t t1, t2, t3; isc_task_t *t1, *t2, *t3;
isc_timer_t ti1, ti2, ti3; isc_timer_t *ti1, *ti2, *ti3;
int tick_count = 0; int tick_count = 0;
static isc_boolean_t 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; char *name = event->arg;
printf("task %p shutdown %s\n", task, name); 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 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; char *name = event->arg;
@@ -57,8 +57,8 @@ tick(isc_task_t task, isc_event_t event)
isc_timer_touch(ti3); isc_timer_touch(ti3);
if (ti3 != NULL && tick_count == 7) { if (ti3 != NULL && tick_count == 7) {
struct isc_time expires, now; isc_time_t expires, now;
struct isc_interval interval; isc_interval_t interval;
(void)isc_time_get(&now); (void)isc_time_get(&now);
isc_interval_set(&interval, 5, 0); isc_interval_set(&interval, 5, 0);
@@ -76,7 +76,7 @@ tick(isc_task_t task, isc_event_t event)
} }
static isc_boolean_t 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 *name = event->arg;
char *type; char *type;
@@ -103,11 +103,11 @@ timeout(isc_task_t task, isc_event_t event)
void void
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
isc_taskmgr_t manager = NULL; isc_taskmgr_t *manager = NULL;
isc_timermgr_t timgr = NULL; isc_timermgr_t *timgr = NULL;
unsigned int workers; unsigned int workers;
struct isc_time expires, now; isc_time_t expires, now;
struct isc_interval interval; isc_interval_t interval;
if (argc > 1) if (argc > 1)
workers = atoi(argv[1]); workers = atoi(argv[1]);

View File

@@ -18,6 +18,8 @@
#ifndef DNS_NAME_H #ifndef DNS_NAME_H
#define DNS_NAME_H 1 #define DNS_NAME_H 1
#include <dns/types.h>
/***** /*****
***** Module Info ***** Module Info
*****/ *****/
@@ -93,7 +95,7 @@
*** Properties *** 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'. * Get the type of 'label'.
* *
@@ -111,7 +113,7 @@ dns_labeltype_t dns_label_type(dns_label_t label);
*** Bitstring Labels *** 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. * 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. * 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'. * The 'n'th most significant bit of 'label'.
* *
@@ -179,13 +181,13 @@ struct dns_name {
unsigned char offsets[128]; unsigned char offsets[128];
}; };
extern dns_name_t dns_rootname; extern dns_name_t *dns_rootname;
/*** /***
*** Initialization *** Initialization
***/ ***/
void dns_name_init(dns_name_t name); void dns_name_init(dns_name_t *name);
/* /*
* Make 'name' empty. * Make 'name' empty.
* *
@@ -201,7 +203,7 @@ void dns_name_init(dns_name_t name);
*** Properties *** 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? * Does 'name' end in the root label?
* *
@@ -220,7 +222,7 @@ isc_boolean_t dns_name_isabsolute(dns_name_t name);
*** Comparisons *** 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 * Determine the relative ordering under the DNSSEC order relation of
* 'name1' and 'name2'. * 'name1' and 'name2'.
@@ -241,7 +243,7 @@ int dns_name_compare(dns_name_t name1, dns_name_t name2);
*/ */
isc_boolean_t 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'? * Is 'name1' a subdomain of 'name2'?
* *
@@ -273,7 +275,7 @@ dns_name_issubdomain(dns_name_t name1, dns_name_t name2);
*** Labels *** 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? * 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'. * 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'. * 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) * 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 first,
unsigned int n, unsigned int n,
dns_name_t target); dns_name_t *target);
/* /*
* Make 'target' refer to the 'n' labels including and following 'first' * Make 'target' refer to the 'n' labels including and following 'first'
* in 'source'. * in 'source'.
@@ -332,7 +334,7 @@ void dns_name_getlabelsequence(dns_name_t source,
*** Conversions *** 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'. * 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. * 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'. * 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. * 'r' is a valid region.
*/ */
dns_result_t dns_name_fromwire(dns_name_t name, dns_result_t dns_name_fromwire(dns_name_t *name,
isc_region_t source, isc_region_t *source,
dns_decompression_t dctx, dns_decompression_t *dctx,
isc_boolean_t downcase, isc_boolean_t downcase,
isc_region_t target); isc_region_t *target);
/* /*
* Copy the possibly-compressed name at source into target, decompressing it. * 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 * Resource Limit: Not enough space in buffer
*/ */
dns_result_t dns_name_towire(dns_name_t name, dns_result_t dns_name_towire(dns_name_t *name,
dns_compression_t cctx, dns_compression_t *cctx,
isc_region_t target, unsigned int *bytesp); isc_region_t *target, unsigned int *bytesp);
/* /*
* Convert 'name' into wire format, compressing it as specified by the * Convert 'name' into wire format, compressing it as specified by the
* compression context 'cctx', and storing the result in 'target'. * 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 * Resource Limit: Not enough space in buffer
*/ */
dns_result_t dns_name_fromtext(dns_name_t name, dns_result_t dns_name_fromtext(dns_name_t *name,
isc_region_t source, isc_region_t *source,
dns_name_t origin, dns_name_t *origin,
isc_boolean_t downcase, isc_boolean_t downcase,
isc_region_t target); isc_region_t *target);
/* /*
* Convert the textual representation of a DNS name at source * Convert the textual representation of a DNS name at source
* into uncompressed wire form stored in target. * 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 * 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_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'. * Convert 'name' into text format, storing the result in 'target'.
* *

View File

@@ -22,10 +22,10 @@
#include <isc/boolean.h> #include <isc/boolean.h>
typedef isc_region_t dns_label_t; typedef isc_region_t dns_label_t;
typedef struct dns_name * dns_name_t; typedef struct dns_name dns_name_t;
typedef struct dns_lex * dns_lex_t; typedef struct dns_lex dns_lex_t;
typedef struct dns_compression * dns_compression_t; typedef struct dns_compression dns_compression_t;
typedef struct dns_decompression * dns_decompression_t; typedef struct dns_decompression dns_decompression_t;
typedef enum { typedef enum {
dns_labeltype_ordinary = 0, dns_labeltype_ordinary = 0,

View File

@@ -115,10 +115,10 @@ static unsigned char maptolower[] = {
static struct dns_name root = { "", 1, 1 }; 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 set_offsets(dns_name_t *, isc_boolean_t);
static void compact(dns_name_t); static void compact(dns_name_t *);
/* /*
* Yes, get_bit and set_bit are lame. We define them here so they can * 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_labeltype_t
dns_label_type(dns_label_t label) { dns_label_type(dns_label_t *label) {
/* /*
* Get the type of 'label'. * Get the type of 'label'.
*/ */
@@ -167,7 +167,7 @@ dns_label_type(dns_label_t label) {
} }
unsigned int unsigned int
dns_label_countbits(dns_label_t label) { dns_label_countbits(dns_label_t *label) {
unsigned int count; unsigned int count;
/* /*
@@ -186,7 +186,7 @@ dns_label_countbits(dns_label_t label) {
} }
dns_bitlabel_t 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; unsigned int count, bit;
/* /*
@@ -213,7 +213,7 @@ dns_label_getbit(dns_label_t label, unsigned int n) {
} }
void void
dns_name_init(dns_name_t name) { dns_name_init(dns_name_t *name) {
/* /*
* Make 'name' empty. * Make 'name' empty.
*/ */
@@ -224,7 +224,7 @@ dns_name_init(dns_name_t name) {
} }
isc_boolean_t isc_boolean_t
dns_name_isabsolute(dns_name_t name) { dns_name_isabsolute(dns_name_t *name) {
/* /*
* Does 'name' end in the root label? * Does 'name' end in the root label?
*/ */
@@ -237,7 +237,7 @@ dns_name_isabsolute(dns_name_t name) {
} }
int 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 l1, l2, l, count1, count2, count;
unsigned int b1, b2, n; unsigned int b1, b2, n;
unsigned char c1, c2; unsigned char c1, c2;
@@ -341,7 +341,7 @@ dns_name_compare(dns_name_t name1, dns_name_t name2) {
} }
isc_boolean_t 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; isc_boolean_t a1, a2;
unsigned int l1, l2, count1, count2; unsigned int l1, l2, count1, count2;
unsigned int b1, b2, n; unsigned int b1, b2, n;
@@ -417,7 +417,7 @@ dns_name_issubdomain(dns_name_t name1, dns_name_t name2) {
} }
unsigned int unsigned int
dns_name_countlabels(dns_name_t name) { dns_name_countlabels(dns_name_t *name) {
/* /*
* How many labels does 'name' have? * How many labels does 'name' have?
*/ */
@@ -430,7 +430,7 @@ dns_name_countlabels(dns_name_t name) {
} }
void 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'. * 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 void
dns_name_getlabelsequence(dns_name_t source, dns_name_getlabelsequence(dns_name_t *source,
unsigned int first, unsigned int n, unsigned int first, unsigned int n,
dns_name_t target) dns_name_t *target)
{ {
/* /*
* Make 'target' refer to the 'n' labels including and following * Make 'target' refer to the 'n' labels including and following
@@ -473,7 +473,7 @@ dns_name_getlabelsequence(dns_name_t source,
} }
void 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'. * Make 'name' refer to region 'r'.
*/ */
@@ -492,7 +492,7 @@ dns_name_fromregion(dns_name_t name, isc_region_t r) {
} }
void 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'. * Make 'r' refer to 'name'.
*/ */
@@ -506,9 +506,9 @@ dns_name_toregion(dns_name_t name, isc_region_t r) {
dns_result_t dns_result_t
dns_name_fromtext(dns_name_t name, isc_region_t source, dns_name_fromtext(dns_name_t *name, isc_region_t *source,
dns_name_t origin, isc_boolean_t downcase, dns_name_t *origin, isc_boolean_t downcase,
isc_region_t target) isc_region_t *target)
{ {
unsigned char *ndata, *label; unsigned char *ndata, *label;
char *tdata; char *tdata;
@@ -957,8 +957,8 @@ dns_name_fromtext(dns_name_t name, isc_region_t source,
} }
dns_result_t dns_result_t
dns_name_totext(dns_name_t name, isc_boolean_t omit_final_dot, 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)
{ {
unsigned char *ndata; unsigned char *ndata;
char *tdata; char *tdata;
@@ -1113,7 +1113,7 @@ dns_name_totext(dns_name_t name, isc_boolean_t omit_final_dot,
} }
static void 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 int offset, count, nlabels, nrem, n;
unsigned char *ndata; unsigned char *ndata;
@@ -1151,7 +1151,7 @@ set_offsets(dns_name_t name, isc_boolean_t set_labels) {
} }
static void static void
compact(dns_name_t name) { compact(dns_name_t *name) {
unsigned char *head, *curr, *last; unsigned char *head, *curr, *last;
unsigned int count, n, bit; unsigned int count, n, bit;
unsigned int headbits, currbits, tailbits, newbits; unsigned int headbits, currbits, tailbits, newbits;

View File

@@ -34,14 +34,14 @@ static void default_callback(char *, int, isc_assertiontype_t, char *);
* Public. * Public.
*/ */
isc_assertioncallback_t __isc_assertion_failed = default_callback; isc_assertioncallback_t isc_assertion_failed = default_callback;
void void
isc_assertion_setcallback(isc_assertioncallback_t cb) { isc_assertion_setcallback(isc_assertioncallback_t cb) {
if (cb == NULL) if (cb == NULL)
__isc_assertion_failed = default_callback; isc_assertion_failed = default_callback;
else else
__isc_assertion_failed = cb; isc_assertion_failed = cb;
} }
char * char *

View File

@@ -25,7 +25,7 @@
#define VALID_BUFFER(b) ((b) != NULL) #define VALID_BUFFER(b) ((b) != NULL)
void 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. * 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 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'. * Make 'r' refer to the region of 'b'.
*/ */
@@ -53,7 +53,7 @@ isc_buffer_region(isc_buffer_t b, isc_region_t r) {
} }
void 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'. * 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 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'. * 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 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. * Increase the 'used' region of 'b' by 'n' bytes.
*/ */
@@ -92,7 +92,7 @@ isc_buffer_add(isc_buffer_t b, unsigned int n) {
} }
void 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. * Decrease the 'used' region of 'b' by 'n' bytes.
*/ */
@@ -104,7 +104,7 @@ isc_buffer_subtract(isc_buffer_t b, unsigned int n) {
} }
void void
isc_buffer_clear(isc_buffer_t b) { isc_buffer_clear(isc_buffer_t *b) {
/* /*
* Make the used region empty. * Make the used region empty.
*/ */
@@ -114,7 +114,7 @@ isc_buffer_clear(isc_buffer_t b) {
} }
void 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'. * 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 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'. * 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 void
isc_buffer_first(isc_buffer_t b) { isc_buffer_first(isc_buffer_t *b) {
/* /*
* Make the consumed region empty. * Make the consumed region empty.
*/ */
@@ -151,7 +151,7 @@ isc_buffer_first(isc_buffer_t b) {
} }
void 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. * Decrease the 'used' region of 'b' by 'n' bytes.
*/ */
@@ -163,7 +163,7 @@ isc_buffer_forward(isc_buffer_t b, unsigned int n) {
} }
void 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. * Decrease the 'consumed' region of 'b' by 'n' bytes.
*/ */
@@ -175,7 +175,7 @@ isc_buffer_back(isc_buffer_t b, unsigned int n) {
} }
void void
isc_buffer_compact(isc_buffer_t b) { isc_buffer_compact(isc_buffer_t *b) {
unsigned int length; unsigned int length;
/* /*

View File

@@ -49,7 +49,7 @@
struct isc_heap { struct isc_heap {
unsigned int magic; unsigned int magic;
isc_memctx_t mctx; isc_memctx_t * mctx;
unsigned int size; unsigned int size;
unsigned int size_increment; unsigned int size_increment;
unsigned int last; unsigned int last;
@@ -59,11 +59,11 @@ struct isc_heap {
}; };
isc_result_t 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_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(heapp != NULL && *heapp == NULL);
REQUIRE(compare != NULL); REQUIRE(compare != NULL);
@@ -89,8 +89,8 @@ isc_heap_create(isc_memctx_t mctx, isc_heapcompare_t compare,
} }
void void
isc_heap_destroy(isc_heap_t *heapp) { isc_heap_destroy(isc_heap_t **heapp) {
isc_heap_t heap; isc_heap_t *heap;
REQUIRE(heapp != NULL); REQUIRE(heapp != NULL);
heap = *heapp; heap = *heapp;
@@ -106,7 +106,7 @@ isc_heap_destroy(isc_heap_t *heapp) {
} }
static isc_boolean_t static isc_boolean_t
resize(isc_heap_t heap) { resize(isc_heap_t *heap) {
void **new_array; void **new_array;
size_t new_size; size_t new_size;
@@ -128,7 +128,7 @@ resize(isc_heap_t heap) {
} }
static void 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; unsigned int p;
for ( p = heap_parent(i); for ( p = heap_parent(i);
@@ -144,7 +144,7 @@ float_up(isc_heap_t heap, unsigned int i, void *elt) {
} }
static void 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; unsigned int j, size, half_size;
size = heap->last; size = heap->last;
@@ -168,7 +168,7 @@ sink_down(isc_heap_t heap, unsigned int i, void *elt) {
} }
isc_result_t isc_result_t
isc_heap_insert(isc_heap_t heap, void *elt) { isc_heap_insert(isc_heap_t *heap, void *elt) {
unsigned int i; unsigned int i;
REQUIRE(VALID_HEAP(heap)); REQUIRE(VALID_HEAP(heap));
@@ -183,7 +183,7 @@ isc_heap_insert(isc_heap_t heap, void *elt) {
} }
void void
isc_heap_delete(isc_heap_t heap, unsigned int i) { isc_heap_delete(isc_heap_t *heap, unsigned int i) {
void *elt; void *elt;
REQUIRE(VALID_HEAP(heap)); REQUIRE(VALID_HEAP(heap));
@@ -195,7 +195,7 @@ isc_heap_delete(isc_heap_t heap, unsigned int i) {
} }
void 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(VALID_HEAP(heap));
REQUIRE(i >= 1 && i <= heap->last); REQUIRE(i >= 1 && i <= heap->last);
@@ -203,7 +203,7 @@ isc_heap_increased(isc_heap_t heap, unsigned int i) {
} }
void 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(VALID_HEAP(heap));
REQUIRE(i >= 1 && i <= heap->last); REQUIRE(i >= 1 && i <= heap->last);
@@ -211,7 +211,7 @@ isc_heap_decreased(isc_heap_t heap, unsigned int i) {
} }
void * 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(VALID_HEAP(heap));
REQUIRE(i >= 1 && i <= heap->last); REQUIRE(i >= 1 && i <= heap->last);
@@ -219,7 +219,7 @@ isc_heap_element(isc_heap_t heap, unsigned int i) {
} }
void 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; unsigned int i;
REQUIRE(VALID_HEAP(heap)); REQUIRE(VALID_HEAP(heap));

View File

@@ -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 #ifndef ISC_ASSERTIONS_H
@@ -32,10 +32,7 @@ typedef enum {
typedef void (*isc_assertioncallback_t)(char *, int, isc_assertiontype_t, typedef void (*isc_assertioncallback_t)(char *, int, isc_assertiontype_t,
char *); char *);
extern isc_assertioncallback_t __isc_assertion_failed; extern isc_assertioncallback_t isc_assertion_failed;
#define isc_assertion_setcallback __isc_assertion_setcallback
#define isc_assertion_typetotext __isc_assertion_typetotext
void isc_assertion_setcallback(isc_assertioncallback_t); void isc_assertion_setcallback(isc_assertioncallback_t);
char *isc_assertion_typetotext(isc_assertiontype_t type); char *isc_assertion_typetotext(isc_assertiontype_t type);
@@ -73,9 +70,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type);
#if CHECK_REQUIRE != 0 #if CHECK_REQUIRE != 0
#define REQUIRE(cond) \ #define REQUIRE(cond) \
((void) ((cond) || \ ((void) ((cond) || \
((__isc_assertion_failed)(__FILE__, __LINE__, \ ((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_require, \ isc_assertiontype_require, \
#cond), 0))) #cond), 0)))
#else #else
#define REQUIRE(cond) ((void) 0) #define REQUIRE(cond) ((void) 0)
#endif /* CHECK_REQUIRE */ #endif /* CHECK_REQUIRE */
@@ -83,9 +80,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type);
#if CHECK_ENSURE != 0 #if CHECK_ENSURE != 0
#define ENSURE(cond) \ #define ENSURE(cond) \
((void) ((cond) || \ ((void) ((cond) || \
((__isc_assertion_failed)(__FILE__, __LINE__, \ ((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_ensure, \ isc_assertiontype_ensure, \
#cond), 0))) #cond), 0)))
#else #else
#define ENSURE(cond) ((void) 0) #define ENSURE(cond) ((void) 0)
#endif /* CHECK_ENSURE */ #endif /* CHECK_ENSURE */
@@ -93,9 +90,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type);
#if CHECK_INSIST != 0 #if CHECK_INSIST != 0
#define INSIST(cond) \ #define INSIST(cond) \
((void) ((cond) || \ ((void) ((cond) || \
((__isc_assertion_failed)(__FILE__, __LINE__, \ ((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_insist, \ isc_assertiontype_insist, \
#cond), 0))) #cond), 0)))
#else #else
#define INSIST(cond) ((void) 0) #define INSIST(cond) ((void) 0)
#endif /* CHECK_INSIST */ #endif /* CHECK_INSIST */
@@ -103,9 +100,9 @@ char *isc_assertion_typetotext(isc_assertiontype_t type);
#if CHECK_INVARIANT != 0 #if CHECK_INVARIANT != 0
#define INVARIANT(cond) \ #define INVARIANT(cond) \
((void) ((cond) || \ ((void) ((cond) || \
((__isc_assertion_failed)(__FILE__, __LINE__, \ ((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_invariant, \ isc_assertiontype_invariant, \
#cond), 0))) #cond), 0)))
#else #else
#define INVARIANT(cond) ((void) 0) #define INVARIANT(cond) ((void) 0)
#endif /* CHECK_INVARIANT */ #endif /* CHECK_INVARIANT */

View File

@@ -92,7 +92,7 @@ typedef struct isc_buffer {
unsigned char * current; unsigned char * current;
unsigned int length; unsigned int length;
unsigned int used; unsigned int used;
} *isc_buffer_t; } isc_buffer_t;
/*** /***
@@ -101,7 +101,7 @@ typedef struct isc_buffer {
void 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. * 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 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'. * Make 'r' refer to the region of 'b'.
* *
@@ -126,7 +126,7 @@ isc_buffer_region(isc_buffer_t b, isc_region_t r);
*/ */
void 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'. * 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 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'. * 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 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. * Increase the 'used' region of 'b' by 'n' bytes.
* *
@@ -164,7 +164,7 @@ isc_buffer_add(isc_buffer_t b, unsigned int n);
void 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. * Decrease the 'used' region of 'b' by 'n' bytes.
* *
@@ -177,7 +177,7 @@ isc_buffer_subtract(isc_buffer_t b, unsigned int n);
*/ */
void void
isc_buffer_clear(isc_buffer_t b); isc_buffer_clear(isc_buffer_t *b);
/* /*
* Make the used region empty. * Make the used region empty.
* *
@@ -192,7 +192,7 @@ isc_buffer_clear(isc_buffer_t b);
*/ */
void 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'. * 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 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'. * 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 void
isc_buffer_first(isc_buffer_t b); isc_buffer_first(isc_buffer_t *b);
/* /*
* Make the consumed region empty. * Make the consumed region empty.
* *
@@ -231,7 +231,7 @@ isc_buffer_first(isc_buffer_t b);
*/ */
void 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. * Decrease the 'used' region of 'b' by 'n' bytes.
* *
@@ -244,7 +244,7 @@ isc_buffer_forward(isc_buffer_t b, unsigned int n);
*/ */
void 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. * Decrease the 'consumed' region of 'b' by 'n' bytes.
* *
@@ -257,7 +257,7 @@ isc_buffer_back(isc_buffer_t b, unsigned int n);
*/ */
void 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 * 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 * at the start of the buffer. The used region is shrunk by the size of

View File

@@ -28,23 +28,14 @@ typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *);
typedef void (*isc_heapindex_t)(void *, unsigned int); typedef void (*isc_heapindex_t)(void *, unsigned int);
typedef void (*isc_heapaction_t)(void *, void *); 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 isc_result_t isc_heap_create(isc_memctx_t *, isc_heapcompare_t,
#define isc_heap_destroy __isc_heap_destroy isc_heapindex_t, unsigned int, isc_heap_t **);
#define isc_heap_insert __isc_heap_insert void isc_heap_destroy(isc_heap_t **);
#define isc_heap_delete __isc_heap_delete isc_result_t isc_heap_insert(isc_heap_t *, void *);
#define isc_heap_increased __isc_heap_increased void isc_heap_delete(isc_heap_t *, unsigned int);
#define isc_heap_decreased __isc_heap_decreased void isc_heap_increased(isc_heap_t *, unsigned int);
#define isc_heap_element __isc_heap_element void isc_heap_decreased(isc_heap_t *, unsigned int);
#define isc_heap_foreach __isc_heap_foreach 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 *);

View File

@@ -24,37 +24,31 @@
#include <isc/boolean.h> #include <isc/boolean.h>
#include <isc/result.h> #include <isc/result.h>
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 #ifdef ISC_MEMCLUSTER_DEBUG
#define isc_mem_get(c, s) __isc_mem_getdebug(c, s, __FILE__, \ #define isc_mem_get(c, s) isc_mem_getdebug(c, s, __FILE__, \
__LINE__) __LINE__)
#define isc_mem_put(c, p, s) __isc_mem_putdebug(c, p, s, __FILE__, \ #define isc_mem_put(c, p, s) isc_mem_putdebug(c, p, s, __FILE__, \
__LINE__) __LINE__)
#else #else
#define isc_mem_get __isc_mem_get #define isc_mem_get isc_mem_get
#define isc_mem_put __isc_mem_put #define isc_mem_put isc_mem_put
#endif /* ISC_MEMCLUSTER_DEBUG */ #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_result_t isc_memctx_create(size_t, size_t,
isc_memctx_t *); isc_memctx_t **);
void isc_memctx_destroy(isc_memctx_t *); void isc_memctx_destroy(isc_memctx_t **);
void * __isc_mem_get(isc_memctx_t, size_t); void * isc_mem_get(isc_memctx_t *, size_t);
void __isc_mem_put(isc_memctx_t, void *, size_t); void isc_mem_put(isc_memctx_t *, void *, size_t);
void * __isc_mem_getdebug(isc_memctx_t, size_t, void * isc_mem_getdebug(isc_memctx_t *, size_t,
const char *, int); const char *, int);
void __isc_mem_putdebug(isc_memctx_t, void *, void isc_mem_putdebug(isc_memctx_t *, void *,
size_t, const char *, int); size_t, const char *, int);
isc_boolean_t isc_mem_valid(isc_memctx_t, void *); isc_boolean_t isc_mem_valid(isc_memctx_t *, void *);
void isc_mem_stats(isc_memctx_t, FILE *); void isc_mem_stats(isc_memctx_t *, FILE *);
void * isc_mem_allocate(isc_memctx_t, size_t); void * isc_mem_allocate(isc_memctx_t *, size_t);
void isc_mem_free(isc_memctx_t, void *); void isc_mem_free(isc_memctx_t *, void *);
#ifdef ISC_MEMCLUSTER_LEGACY #ifdef ISC_MEMCLUSTER_LEGACY
@@ -75,7 +69,7 @@ void isc_mem_free(isc_memctx_t, void *);
#define memstats __memstats #define memstats __memstats
int meminit(size_t, size_t); 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 * __memget(size_t);
void __memput(void *, size_t); void __memput(void *, size_t);
void * __memget_debug(size_t, const char *, int); void * __memget_debug(size_t, const char *, int);

View File

@@ -21,12 +21,12 @@
typedef struct isc_region { typedef struct isc_region {
unsigned char * base; unsigned char * base;
unsigned int length; unsigned int length;
} *isc_region_t; } isc_region_t;
typedef struct isc_textregion { typedef struct isc_textregion {
char * base; char * base;
unsigned int length; unsigned int length;
} *isc_textregion_t; } isc_textregion_t;
/* /*
* There are no methods which operate on regions. The structure is not * There are no methods which operate on regions. The structure is not

View File

@@ -45,8 +45,6 @@ typedef unsigned int isc_result_t;
#define ISC_R_UNEXPECTED 0xFFFFFFFFL #define ISC_R_UNEXPECTED 0xFFFFFFFFL
#define isc_result_totext __isc_result_totext
char * isc_result_totext(isc_result_t); char * isc_result_totext(isc_result_t);
#endif /* ISC_RESULT_H */ #endif /* ISC_RESULT_H */

View File

@@ -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 <netinet/in.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;
#endif /* ISC_SOCKADDR_H */

View File

@@ -66,49 +66,36 @@
#include <isc/task.h> #include <isc/task.h>
#include <isc/region.h> #include <isc/region.h>
#include <isc/mem.h> #include <isc/mem.h>
#include <isc/sockaddr.h>
#include <netinet/in.h>
/*** /***
*** Types *** Types
***/ ***/
typedef struct isc_socket *isc_socket_t; typedef struct isc_socket isc_socket_t;
typedef struct isc_socketmgr *isc_socketmgr_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_socketevent { 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 */ isc_result_t result; /* OK, EOF, whatever else */
unsigned int n; /* bytes read or written */ unsigned int n; /* bytes read or written */
struct isc_region region; /* the region info */ isc_region_t region; /* the region info */
struct isc_sockaddr address; /* source address */ isc_sockaddr_t address; /* source address */
unsigned int addrlength; /* length of address */ unsigned int addrlength; /* length of address */
} *isc_socketevent_t; } isc_socketevent_t;
typedef struct isc_socket_newconnev { typedef struct isc_socket_newconnev {
struct isc_event common; isc_event_t common;
isc_socket_t newsocket; isc_socket_t * newsocket;
isc_result_t result; /* OK, EOF, whatever else */ 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 */ unsigned int addrlength; /* length of address */
} *isc_socket_newconnev_t; } isc_socket_newconnev_t;
typedef struct isc_socket_connev { typedef struct isc_socket_connev {
struct isc_event common; isc_event_t common;
isc_result_t result; /* OK, EOF, whatever else */ isc_result_t result; /* OK, EOF, whatever else */
} *isc_socket_connev_t; } isc_socket_connev_t;
#define ISC_SOCKEVENT_ANYEVENT (0) #define ISC_SOCKEVENT_ANYEVENT (0)
#define ISC_SOCKEVENT_RECVDONE (ISC_EVENTCLASS_SOCKET + 1) #define ISC_SOCKEVENT_RECVDONE (ISC_EVENTCLASS_SOCKET + 1)
@@ -155,9 +142,9 @@ typedef enum {
***/ ***/
isc_result_t isc_result_t
isc_socket_create(isc_socketmgr_t manager, isc_socket_create(isc_socketmgr_t *manager,
isc_sockettype_t type, isc_sockettype_t type,
isc_socket_t *socketp); isc_socket_t **socketp);
/* /*
* Create a new 'type' socket managed by 'manager'. * Create a new 'type' socket managed by 'manager'.
* *
@@ -180,7 +167,7 @@ isc_socket_create(isc_socketmgr_t manager,
*/ */
void 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); unsigned int how);
/* /*
* Cancel pending I/O of the type specified by "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 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'. * Shutdown 'socket' according to 'how'.
* *
@@ -236,7 +223,7 @@ isc_socket_shutdown(isc_socket_t sock, unsigned int how);
*/ */
void 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. * Attach *socketp to socket.
* *
@@ -252,7 +239,7 @@ isc_socket_attach(isc_socket_t sock, isc_socket_t *socketp);
*/ */
void void
isc_socket_detach(isc_socket_t *socketp); isc_socket_detach(isc_socket_t **socketp);
/* /*
* Detach *socketp from its socket. * Detach *socketp from its socket.
* *
@@ -279,7 +266,7 @@ isc_socket_detach(isc_socket_t *socketp);
*/ */
isc_result_t 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); int length);
/* /*
* Bind 'socket' to '*addressp'. * Bind 'socket' to '*addressp'.
@@ -303,7 +290,7 @@ isc_socket_bind(isc_socket_t sock, struct isc_sockaddr *addressp,
*/ */
isc_result_t 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 * 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(). * 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_result_t
isc_socket_accept(isc_socket_t sock, isc_socket_accept(isc_socket_t *sock,
isc_task_t task, isc_taskaction_t action, void *arg); isc_task_t *task, isc_taskaction_t action, void *arg);
/* /*
* Queue accept event. When a new connection is received, the task will * 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 * 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_result_t
isc_socket_connect(isc_socket_t sock, struct isc_sockaddr *addressp, isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addressp,
int length, isc_task_t task, isc_taskaction_t action, int length, isc_task_t *task, isc_taskaction_t action,
void *arg); void *arg);
/* /*
* Connect 'socket' to peer with address *saddr. When the connection * 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_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); int *lengthp);
/* /*
* Get the name of the peer connected to 'socket'. * 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_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); int *lengthp);
/* /*
* Get the name of 'socket'. * Get the name of 'socket'.
@@ -424,9 +411,9 @@ isc_socket_getsockname(isc_socket_t sock, struct isc_sockaddr *addressp,
*/ */
isc_result_t 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_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. * 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_result_t
isc_socket_send(isc_socket_t sock, isc_region_t region, isc_socket_send(isc_socket_t *sock, isc_region_t *region,
isc_task_t task, isc_taskaction_t action, void *arg); isc_task_t *task, isc_taskaction_t action, void *arg);
isc_result_t isc_result_t
isc_socket_sendto(isc_socket_t sock, isc_region_t region, isc_socket_sendto(isc_socket_t *sock, isc_region_t *region,
isc_task_t task, isc_taskaction_t action, void *arg, isc_task_t *task, isc_taskaction_t action, void *arg,
isc_sockaddr_t address, unsigned int addrlength); isc_sockaddr_t *address, unsigned int addrlength);
/* /*
* Send the contents of 'region' to the socket's peer. * 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_result_t
isc_socket_recvmark(isc_socket_t sock, isc_socket_recvmark(isc_socket_t *sock,
isc_task_t task, isc_taskaction_t action, void *arg); isc_task_t *task, isc_taskaction_t action, void *arg);
isc_result_t isc_result_t
isc_socket_sendmark(isc_socket_t sock, isc_socket_sendmark(isc_socket_t *sock,
isc_task_t task, isc_taskaction_t action, void *arg); isc_task_t *task, isc_taskaction_t action, void *arg);
/* /*
* Insert a recv/send marker for the socket. * Insert a recv/send marker for the socket.
* *
@@ -551,7 +538,7 @@ isc_socket_sendmark(isc_socket_t sock,
*/ */
isc_result_t 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. * Create a socket manager.
* *
@@ -577,7 +564,7 @@ isc_socketmgr_create(isc_memctx_t mctx, isc_socketmgr_t *managerp);
*/ */
void void
isc_socketmgr_destroy(isc_socketmgr_t *managerp); isc_socketmgr_destroy(isc_socketmgr_t **managerp);
/* /*
* Destroy a socket manager. * Destroy a socket manager.
* *

View File

@@ -31,9 +31,9 @@
*** Core Types. *** Core Types.
***/ ***/
typedef struct isc_event * isc_event_t; typedef struct isc_event isc_event_t;
typedef struct isc_task * isc_task_t; typedef struct isc_task isc_task_t;
typedef struct isc_taskmgr * isc_taskmgr_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 int isc_eventtype_t;
typedef isc_boolean_t (*isc_taskaction_t)(isc_task_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); typedef void (*isc_eventdestructor_t)(isc_event_t *);
/* /*
* This structure is public because "subclassing" it may be useful when * This structure is public because "subclassing" it may be useful when
* defining new event types. * defining new event types.
*/ */
struct isc_event { struct isc_event {
isc_memctx_t mctx; isc_memctx_t * mctx;
size_t size; size_t size;
void * sender; void * sender;
isc_eventtype_t type; isc_eventtype_t type;
@@ -70,42 +70,42 @@ struct isc_event {
typedef LIST(struct isc_event) isc_eventlist_t; 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 *, void *,
isc_eventtype_t, isc_eventtype_t,
isc_taskaction_t, isc_taskaction_t,
void *arg, void *arg,
size_t); size_t);
void isc_event_free(isc_event_t *); void isc_event_free(isc_event_t **);
/*** /***
*** Tasks. *** Tasks.
***/ ***/
isc_result_t isc_task_create(isc_taskmgr_t, isc_result_t isc_task_create(isc_taskmgr_t *,
isc_taskaction_t, isc_taskaction_t,
void *, void *,
unsigned int, unsigned int,
isc_task_t *); isc_task_t **);
void isc_task_attach(isc_task_t, void isc_task_attach(isc_task_t *,
isc_task_t *); isc_task_t **);
void isc_task_detach(isc_task_t *); void isc_task_detach(isc_task_t **);
isc_result_t isc_task_send(isc_task_t, isc_result_t isc_task_send(isc_task_t *,
isc_event_t *); isc_event_t **);
unsigned int isc_task_purge(isc_task_t, void *, unsigned int isc_task_purge(isc_task_t *, void *,
isc_eventtype_t); isc_eventtype_t);
void isc_task_shutdown(isc_task_t); void isc_task_shutdown(isc_task_t *);
void isc_task_destroy(isc_task_t *); void isc_task_destroy(isc_task_t **);
/*** /***
*** Task Manager. *** Task Manager.
***/ ***/
isc_result_t isc_taskmgr_create(isc_memctx_t, isc_result_t isc_taskmgr_create(isc_memctx_t *,
unsigned int, unsigned int,
unsigned int, unsigned int,
isc_taskmgr_t *); isc_taskmgr_t **);
void isc_taskmgr_destroy(isc_taskmgr_t *); void isc_taskmgr_destroy(isc_taskmgr_t **);
#endif /* ISC_TASK_H */ #endif /* ISC_TASK_H */

View File

@@ -80,8 +80,8 @@
*** Types *** Types
***/ ***/
typedef struct isc_timer *isc_timer_t; typedef struct isc_timer isc_timer_t;
typedef struct isc_timermgr *isc_timermgr_t; typedef struct isc_timermgr isc_timermgr_t;
typedef enum { typedef enum {
isc_timertype_ticker = 0, isc_timertype_once isc_timertype_ticker = 0, isc_timertype_once
@@ -90,7 +90,7 @@ typedef enum {
typedef struct isc_timerevent { typedef struct isc_timerevent {
struct isc_event common; struct isc_event common;
/* XXX Anything else? XXX */ /* XXX Anything else? XXX */
} *isc_timerevent_t; } isc_timerevent_t;
#define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1) #define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1)
#define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2) #define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2)
@@ -105,14 +105,14 @@ typedef struct isc_timerevent {
***/ ***/
isc_result_t isc_result_t
isc_timer_create(isc_timermgr_t manager, isc_timer_create(isc_timermgr_t *manager,
isc_timertype_t type, isc_timertype_t type,
isc_time_t expires, isc_time_t *expires,
isc_interval_t interval, isc_interval_t *interval,
isc_task_t task, isc_task_t *task,
isc_taskaction_t action, isc_taskaction_t action,
void *arg, void *arg,
isc_timer_t *timerp); isc_timer_t **timerp);
/* /*
* Create a new 'type' timer managed by 'manager'. The timers parameters * Create a new 'type' timer managed by 'manager'. The timers parameters
* are specified by 'expires' and 'interval'. Events will be posted to * 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_result_t
isc_timer_reset(isc_timer_t timer, isc_timer_reset(isc_timer_t *timer,
isc_timertype_t type, isc_timertype_t type,
isc_time_t expires, isc_time_t *expires,
isc_interval_t interval, isc_interval_t *interval,
isc_boolean_t purge); isc_boolean_t purge);
/* /*
* Change the timer's type, expires, and interval values to the given * 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_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. * Set the last-touched time of 'timer' to the current time.
* *
@@ -212,7 +212,7 @@ isc_timer_touch(isc_timer_t timer);
*/ */
void 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. * Attach *timerp to timer.
* *
@@ -228,7 +228,7 @@ isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp);
*/ */
void void
isc_timer_detach(isc_timer_t *timerp); isc_timer_detach(isc_timer_t **timerp);
/* /*
* Detach *timerp from its timer. * Detach *timerp from its timer.
* *
@@ -251,7 +251,7 @@ isc_timer_detach(isc_timer_t *timerp);
*/ */
isc_result_t 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. * Create a timer manager.
* *
@@ -277,7 +277,7 @@ isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp);
*/ */
void void
isc_timermgr_destroy(isc_timermgr_t *); isc_timermgr_destroy(isc_timermgr_t **managerp);
/* /*
* Destroy a timer manager. * Destroy a timer manager.
* *

View File

@@ -30,8 +30,8 @@
#include <isc/mutex.h> #include <isc/mutex.h>
#include "util.h" #include "util.h"
#else #else
#define LOCK(ctx) #define LOCK(l)
#define UNLOCK(ctx) #define UNLOCK(l)
#endif #endif
/* /*
@@ -47,7 +47,7 @@ typedef struct {
/* /*
* This structure must be ALIGNMENT_SIZE bytes. * This structure must be ALIGNMENT_SIZE bytes.
*/ */
} *size_info; } size_info;
struct stats { struct stats {
unsigned long gets; unsigned long gets;
@@ -113,9 +113,9 @@ quantize(size_t size) {
isc_result_t isc_result_t
isc_memctx_create(size_t init_max_size, size_t target_size, 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); REQUIRE(ctxp != NULL && *ctxp == NULL);
@@ -162,9 +162,9 @@ isc_memctx_create(size_t init_max_size, size_t target_size,
} }
void void
isc_memctx_destroy(isc_memctx_t *ctxp) { isc_memctx_destroy(isc_memctx_t **ctxp) {
unsigned int i; unsigned int i;
isc_memctx_t ctx; isc_memctx_t *ctx;
REQUIRE(ctxp != NULL); REQUIRE(ctxp != NULL);
ctx = *ctxp; ctx = *ctxp;
@@ -187,7 +187,7 @@ isc_memctx_destroy(isc_memctx_t *ctxp) {
} }
static void static void
more_basic_blocks(isc_memctx_t ctx) { more_basic_blocks(isc_memctx_t *ctx) {
void *new; void *new;
unsigned char *curr, *next; unsigned char *curr, *next;
unsigned char *first, *last; unsigned char *first, *last;
@@ -240,7 +240,7 @@ more_basic_blocks(isc_memctx_t ctx) {
} }
void * 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); size_t new_size = quantize(size);
void *ret; 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". * so we want to count this as a user "put".
*/ */
void 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); size_t new_size = quantize(size);
REQUIRE(size > 0); REQUIRE(size > 0);
@@ -354,29 +354,29 @@ __isc_mem_put(isc_memctx_t ctx, void *mem, size_t size) {
} }
void * 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; 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, fprintf(stderr, "%s:%d: mem_get(%p, %lu) -> %p\n", file, line,
ctx, (unsigned long)size, ptr); ctx, (unsigned long)size, ptr);
return (ptr); return (ptr);
} }
void void
__isc_mem_putdebug(isc_memctx_t ctx, void *ptr, size_t size, const char *file, isc_mem_putdebug(isc_memctx_t *ctx, void *ptr, size_t size, const char *file,
int line) int line)
{ {
fprintf(stderr, "%s:%d: mem_put(%p, %p, %lu)\n", file, line, fprintf(stderr, "%s:%d: mem_put(%p, %p, %lu)\n", file, line,
ctx, ptr, (unsigned long)size); 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. * Print the stats[] on the stream "out" with suitable formatting.
*/ */
void void
isc_mem_stats(isc_memctx_t ctx, FILE *out) { isc_mem_stats(isc_memctx_t *ctx, FILE *out) {
size_t i; size_t i;
REQUIRE(VALID_CONTEXT(ctx)); REQUIRE(VALID_CONTEXT(ctx));
@@ -402,7 +402,7 @@ isc_mem_stats(isc_memctx_t ctx, FILE *out) {
} }
isc_boolean_t 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; unsigned char *cp = ptr;
isc_boolean_t result = ISC_FALSE; isc_boolean_t result = ISC_FALSE;
@@ -422,8 +422,8 @@ isc_mem_valid(isc_memctx_t ctx, void *ptr) {
*/ */
void * void *
isc_mem_allocate(isc_memctx_t ctx, size_t size) { isc_mem_allocate(isc_memctx_t *ctx, size_t size) {
size_info si; size_info *si;
size += ALIGNMENT_SIZE; size += ALIGNMENT_SIZE;
si = isc_mem_get(ctx, size); si = isc_mem_get(ctx, size);
@@ -434,10 +434,10 @@ isc_mem_allocate(isc_memctx_t ctx, size_t size) {
} }
void void
isc_mem_free(isc_memctx_t ctx, void *ptr) { isc_mem_free(isc_memctx_t *ctx, void *ptr) {
size_info si; size_info *si;
si = &(((size_info)ptr)[-1]); si = &(((size_info *)ptr)[-1]);
isc_mem_put(ctx, si, si->size); isc_mem_put(ctx, si, si->size);
} }
@@ -447,7 +447,7 @@ isc_mem_free(isc_memctx_t ctx, void *ptr) {
* Public Legacy. * Public Legacy.
*/ */
static isc_memctx_t default_context = NULL; static isc_memctx_t *default_context = NULL;
int int
meminit(size_t init_max_size, size_t target_size) { meminit(size_t init_max_size, size_t target_size) {

View File

@@ -24,12 +24,13 @@
#include <isc/error.h> #include <isc/error.h>
isc_result_t 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; int presult;
struct timespec ts; 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); presult = pthread_cond_timedwait(c, m, &ts);
if (presult == 0) if (presult == 0)
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);

View File

@@ -48,6 +48,6 @@ typedef pthread_cond_t isc_condition_t;
ISC_R_SUCCESS : ISC_R_UNEXPECTED) ISC_R_SUCCESS : ISC_R_UNEXPECTED)
isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *,
isc_time_t); isc_time_t *);
#endif /* ISC_CONDITION_H */ #endif /* ISC_CONDITION_H */

View File

@@ -51,7 +51,7 @@ typedef enum {
struct isc_task { struct isc_task {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
isc_taskmgr_t manager; isc_taskmgr_t * manager;
isc_mutex_t lock; isc_mutex_t lock;
/* Locked by task lock. */ /* Locked by task lock. */
task_state_t state; task_state_t state;
@@ -59,10 +59,10 @@ struct isc_task {
isc_eventlist_t events; isc_eventlist_t events;
unsigned int quantum; unsigned int quantum;
isc_boolean_t enqueue_allowed; isc_boolean_t enqueue_allowed;
isc_event_t shutdown_event; isc_event_t * shutdown_event;
/* Locked by task manager lock. */ /* Locked by task manager lock. */
LINK(struct isc_task) link; LINK(isc_task_t) link;
LINK(struct isc_task) ready_link; LINK(isc_task_t) ready_link;
}; };
#define TASK_MANAGER_MAGIC 0x54534B4DU /* TSKM. */ #define TASK_MANAGER_MAGIC 0x54534B4DU /* TSKM. */
@@ -72,14 +72,14 @@ struct isc_task {
struct isc_taskmgr { struct isc_taskmgr {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
isc_memctx_t mctx; isc_memctx_t * mctx;
isc_mutex_t lock; isc_mutex_t lock;
unsigned int workers; unsigned int workers;
isc_thread_t * threads; isc_thread_t * threads;
/* Locked by task manager lock. */ /* Locked by task manager lock. */
unsigned int default_quantum; unsigned int default_quantum;
LIST(struct isc_task) tasks; LIST(isc_task_t) tasks;
LIST(struct isc_task) ready_tasks; LIST(isc_task_t) ready_tasks;
isc_condition_t work_available; isc_condition_t work_available;
isc_boolean_t exiting; isc_boolean_t exiting;
}; };
@@ -92,11 +92,11 @@ struct isc_taskmgr {
*** Events. *** Events.
***/ ***/
static inline isc_event_t static inline isc_event_t *
event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, event_allocate(isc_memctx_t *mctx, void *sender, isc_eventtype_t type,
isc_taskaction_t action, void *arg, size_t size) isc_taskaction_t action, void *arg, size_t size)
{ {
isc_event_t event; isc_event_t *event;
event = isc_mem_get(mctx, size); event = isc_mem_get(mctx, size);
if (event == NULL) if (event == NULL)
@@ -111,8 +111,8 @@ event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type,
return (event); return (event);
} }
isc_event_t isc_event_t *
isc_event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type, isc_event_allocate(isc_memctx_t *mctx, void *sender, isc_eventtype_t type,
isc_taskaction_t action, void *arg, size_t size) isc_taskaction_t action, void *arg, size_t size)
{ {
if (size < sizeof (struct isc_event)) if (size < sizeof (struct isc_event))
@@ -126,8 +126,8 @@ isc_event_allocate(isc_memctx_t mctx, void *sender, isc_eventtype_t type,
} }
void void
isc_event_free(isc_event_t *eventp) { isc_event_free(isc_event_t **eventp) {
isc_event_t event; isc_event_t *event;
REQUIRE(eventp != NULL); REQUIRE(eventp != NULL);
event = *eventp; event = *eventp;
@@ -145,8 +145,8 @@ isc_event_free(isc_event_t *eventp) {
***/ ***/
static void static void
task_free(isc_task_t task) { task_free(isc_task_t *task) {
isc_taskmgr_t manager = task->manager; isc_taskmgr_t *manager = task->manager;
XTRACE("free task"); XTRACE("free task");
REQUIRE(EMPTY(task->events)); REQUIRE(EMPTY(task->events));
@@ -171,10 +171,10 @@ task_free(isc_task_t task) {
} }
isc_result_t isc_result_t
isc_task_create(isc_taskmgr_t manager, isc_taskaction_t shutdown_action, isc_task_create(isc_taskmgr_t *manager, isc_taskaction_t shutdown_action,
void *shutdown_arg, unsigned int quantum, isc_task_t *taskp) void *shutdown_arg, unsigned int quantum, isc_task_t **taskp)
{ {
isc_task_t task; isc_task_t *task;
REQUIRE(VALID_MANAGER(manager)); REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL); REQUIRE(taskp != NULL && *taskp == NULL);
@@ -222,7 +222,7 @@ isc_task_create(isc_taskmgr_t manager, isc_taskaction_t shutdown_action,
} }
void 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(VALID_TASK(task));
REQUIRE(taskp != NULL && *taskp == NULL); REQUIRE(taskp != NULL && *taskp == NULL);
@@ -235,9 +235,9 @@ isc_task_attach(isc_task_t task, isc_task_t *taskp) {
} }
void void
isc_task_detach(isc_task_t *taskp) { isc_task_detach(isc_task_t **taskp) {
isc_boolean_t free_task = ISC_FALSE; isc_boolean_t free_task = ISC_FALSE;
isc_task_t task; isc_task_t *task;
XTRACE("isc_task_detach"); XTRACE("isc_task_detach");
@@ -259,10 +259,10 @@ isc_task_detach(isc_task_t *taskp) {
} }
isc_result_t 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 was_idle = ISC_FALSE;
isc_boolean_t discard = ISC_FALSE; isc_boolean_t discard = ISC_FALSE;
isc_event_t event; isc_event_t *event;
REQUIRE(VALID_TASK(task)); REQUIRE(VALID_TASK(task));
REQUIRE(eventp != NULL); REQUIRE(eventp != NULL);
@@ -298,7 +298,7 @@ isc_task_send(isc_task_t task, isc_event_t *eventp) {
} }
if (was_idle) { if (was_idle) {
isc_taskmgr_t manager; isc_taskmgr_t *manager;
/* /*
* We need to add this task to the ready queue. * 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 unsigned int
isc_task_purge(isc_task_t task, void *sender, isc_eventtype_t type) { isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type) {
isc_event_t event, next_event; isc_event_t *event, *next_event;
isc_eventlist_t purgeable; isc_eventlist_t purgeable;
unsigned int purge_count; unsigned int purge_count;
@@ -377,7 +377,7 @@ isc_task_purge(isc_task_t task, void *sender, isc_eventtype_t type) {
} }
void 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 was_idle = ISC_FALSE;
isc_boolean_t discard = ISC_FALSE; isc_boolean_t discard = ISC_FALSE;
@@ -408,7 +408,7 @@ isc_task_shutdown(isc_task_t task) {
return; return;
if (was_idle) { if (was_idle) {
isc_taskmgr_t manager; isc_taskmgr_t *manager;
manager = task->manager; manager = task->manager;
INSIST(VALID_MANAGER(manager)); INSIST(VALID_MANAGER(manager));
@@ -420,7 +420,7 @@ isc_task_shutdown(isc_task_t task) {
} }
void void
isc_task_destroy(isc_task_t *taskp) { isc_task_destroy(isc_task_t **taskp) {
REQUIRE(taskp != NULL); REQUIRE(taskp != NULL);
@@ -439,8 +439,8 @@ static isc_threadresult_t
WINAPI WINAPI
#endif #endif
run(void *uap) { run(void *uap) {
isc_taskmgr_t manager = uap; isc_taskmgr_t *manager = uap;
isc_task_t task; isc_task_t *task;
XTRACE("start"); XTRACE("start");
@@ -520,7 +520,7 @@ run(void *uap) {
isc_boolean_t wants_shutdown; isc_boolean_t wants_shutdown;
isc_boolean_t is_shutdown; isc_boolean_t is_shutdown;
isc_boolean_t free_task = ISC_FALSE; isc_boolean_t free_task = ISC_FALSE;
isc_event_t event; isc_event_t *event;
isc_eventlist_t remaining_events; isc_eventlist_t remaining_events;
isc_boolean_t discard_remaining = ISC_FALSE; isc_boolean_t discard_remaining = ISC_FALSE;
@@ -626,7 +626,7 @@ run(void *uap) {
UNLOCK(&task->lock); UNLOCK(&task->lock);
if (discard_remaining) { if (discard_remaining) {
isc_event_t next_event; isc_event_t *next_event;
for (event = HEAD(remaining_events); for (event = HEAD(remaining_events);
event != NULL; event != NULL;
@@ -673,7 +673,7 @@ run(void *uap) {
} }
static void static void
manager_free(isc_taskmgr_t manager) { manager_free(isc_taskmgr_t *manager) {
(void)isc_condition_destroy(&manager->work_available); (void)isc_condition_destroy(&manager->work_available);
(void)isc_mutex_destroy(&manager->lock); (void)isc_mutex_destroy(&manager->lock);
isc_mem_put(manager->mctx, manager->threads, isc_mem_put(manager->mctx, manager->threads,
@@ -683,11 +683,11 @@ manager_free(isc_taskmgr_t manager) {
} }
isc_result_t isc_result_t
isc_taskmgr_create(isc_memctx_t mctx, unsigned int workers, isc_taskmgr_create(isc_memctx_t *mctx, unsigned int workers,
unsigned int default_quantum, isc_taskmgr_t *managerp) unsigned int default_quantum, isc_taskmgr_t **managerp)
{ {
unsigned int i, started = 0; unsigned int i, started = 0;
isc_taskmgr_t manager; isc_taskmgr_t *manager;
isc_thread_t *threads; isc_thread_t *threads;
REQUIRE(workers > 0); REQUIRE(workers > 0);
@@ -752,9 +752,9 @@ isc_taskmgr_create(isc_memctx_t mctx, unsigned int workers,
} }
void void
isc_taskmgr_destroy(isc_taskmgr_t *managerp) { isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
isc_taskmgr_t manager; isc_taskmgr_t *manager;
isc_task_t task; isc_task_t *task;
unsigned int i; unsigned int i;
REQUIRE(managerp != NULL); REQUIRE(managerp != NULL);

View File

@@ -50,21 +50,21 @@
struct isc_timer { struct isc_timer {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
isc_timermgr_t manager; isc_timermgr_t * manager;
isc_mutex_t lock; isc_mutex_t lock;
/* Locked by timer lock. */ /* Locked by timer lock. */
unsigned int references; unsigned int references;
struct isc_time idle; isc_time_t idle;
/* Locked by manager lock. */ /* Locked by manager lock. */
isc_timertype_t type; isc_timertype_t type;
struct isc_time expires; isc_time_t expires;
struct isc_interval interval; isc_interval_t interval;
isc_task_t task; isc_task_t * task;
isc_taskaction_t action; isc_taskaction_t action;
void * arg; void * arg;
unsigned int index; unsigned int index;
struct isc_time due; isc_time_t due;
LINK(struct isc_timer) link; LINK(isc_timer_t) link;
}; };
#define TIMER_MANAGER_MAGIC 0x54494D4DU /* TIMM. */ #define TIMER_MANAGER_MAGIC 0x54494D4DU /* TIMM. */
@@ -74,23 +74,23 @@ struct isc_timer {
struct isc_timermgr { struct isc_timermgr {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
isc_memctx_t mctx; isc_memctx_t * mctx;
isc_mutex_t lock; isc_mutex_t lock;
/* Locked by manager lock. */ /* Locked by manager lock. */
isc_boolean_t done; isc_boolean_t done;
LIST(struct isc_timer) timers; LIST(isc_timer_t) timers;
unsigned int nscheduled; unsigned int nscheduled;
struct isc_time due; isc_time_t due;
isc_condition_t wakeup; isc_condition_t wakeup;
isc_thread_t thread; isc_thread_t thread;
isc_heap_t heap; isc_heap_t * heap;
}; };
static inline isc_result_t 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_result_t result;
isc_timermgr_t manager; isc_timermgr_t *manager;
struct isc_time due; isc_time_t due;
int cmp; int cmp;
/* /*
@@ -161,9 +161,9 @@ schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t signal_ok) {
} }
static inline void static inline void
deschedule(isc_timer_t timer) { deschedule(isc_timer_t *timer) {
isc_boolean_t need_wakeup = ISC_FALSE; isc_boolean_t need_wakeup = ISC_FALSE;
isc_timermgr_t manager; isc_timermgr_t *manager;
/* /*
* The caller must ensure locking. * The caller must ensure locking.
@@ -185,8 +185,8 @@ deschedule(isc_timer_t timer) {
} }
static void static void
destroy(isc_timer_t timer) { destroy(isc_timer_t *timer) {
isc_timermgr_t manager = timer->manager; isc_timermgr_t *manager = timer->manager;
/* /*
* The caller must ensure locking. * The caller must ensure locking.
@@ -207,14 +207,14 @@ destroy(isc_timer_t timer) {
} }
isc_result_t isc_result_t
isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
isc_time_t expires, isc_interval_t interval, isc_time_t *expires, isc_interval_t *interval,
isc_task_t task, isc_taskaction_t action, void *arg, isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t *timerp) isc_timer_t **timerp)
{ {
isc_timer_t timer; isc_timer_t *timer;
isc_result_t result; isc_result_t result;
struct isc_time now; isc_time_t now;
/* /*
* Create a new 'type' timer managed by 'manager'. The timers * 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_result_t
isc_timer_reset(isc_timer_t timer, isc_timertype_t type, 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) isc_boolean_t purge)
{ {
struct isc_time now; isc_time_t now;
isc_timermgr_t manager; isc_timermgr_t *manager;
isc_result_t result; isc_result_t result;
/* /*
@@ -348,9 +348,9 @@ isc_timer_reset(isc_timer_t timer, isc_timertype_t type,
} }
isc_result_t isc_result_t
isc_timer_touch(isc_timer_t timer) { isc_timer_touch(isc_timer_t *timer) {
isc_result_t result; isc_result_t result;
struct isc_time now; isc_time_t now;
/* /*
* Set the last-touched time of 'timer' to the current time. * Set the last-touched time of 'timer' to the current time.
@@ -377,7 +377,7 @@ isc_timer_touch(isc_timer_t timer) {
} }
void 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. * Attach *timerp to timer.
*/ */
@@ -393,8 +393,8 @@ isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp) {
} }
void void
isc_timer_detach(isc_timer_t *timerp) { isc_timer_detach(isc_timer_t **timerp) {
isc_timer_t timer; isc_timer_t *timer;
isc_boolean_t free_timer = ISC_FALSE; isc_boolean_t free_timer = ISC_FALSE;
/* /*
@@ -419,11 +419,11 @@ isc_timer_detach(isc_timer_t *timerp) {
} }
static void 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_boolean_t done = ISC_FALSE, post_event, need_schedule;
isc_event_t event; isc_event_t *event;
isc_eventtype_t type = 0; isc_eventtype_t type = 0;
isc_timer_t timer; isc_timer_t *timer;
isc_result_t result; isc_result_t result;
while (manager->nscheduled > 0 && !done) { while (manager->nscheduled > 0 && !done) {
@@ -493,8 +493,8 @@ static isc_threadresult_t
WINAPI WINAPI
#endif #endif
run(void *uap) { run(void *uap) {
isc_timermgr_t manager = uap; isc_timermgr_t *manager = uap;
struct isc_time now; isc_time_t now;
isc_result_t result; isc_result_t result;
LOCK(&manager->lock); LOCK(&manager->lock);
@@ -524,7 +524,7 @@ run(void *uap) {
static isc_boolean_t static isc_boolean_t
sooner(void *v1, void *v2) { sooner(void *v1, void *v2) {
isc_timer_t t1, t2; isc_timer_t *t1, *t2;
t1 = v1; t1 = v1;
t2 = v2; t2 = v2;
@@ -538,7 +538,7 @@ sooner(void *v1, void *v2) {
static void static void
set_index(void *what, unsigned int index) { set_index(void *what, unsigned int index) {
isc_timer_t timer; isc_timer_t *timer;
timer = what; timer = what;
REQUIRE(VALID_TIMER(timer)); REQUIRE(VALID_TIMER(timer));
@@ -547,8 +547,8 @@ set_index(void *what, unsigned int index) {
} }
isc_result_t 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) {
isc_timermgr_t manager; isc_timermgr_t *manager;
isc_result_t result; isc_result_t result;
/* /*
@@ -606,8 +606,8 @@ isc_timermgr_create(isc_memctx_t mctx, isc_timermgr_t *managerp) {
} }
void void
isc_timermgr_destroy(isc_timermgr_t *managerp) { isc_timermgr_destroy(isc_timermgr_t **managerp) {
isc_timermgr_t manager; isc_timermgr_t *manager;
/* /*
* Destroy a timer manager. * Destroy a timer manager.

View File

@@ -5,7 +5,7 @@ top_srcdir = @top_srcdir@
@BIND9_VERSION@ @BIND9_VERSION@
HEADERS = time.h HEADERS = sockaddr.h time.h
SUBDIRS = SUBDIRS =
TARGETS = TARGETS =

View File

@@ -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 <netinet/in.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;
#endif /* ISC_SOCKADDR_H */

View File

@@ -18,7 +18,6 @@
#ifndef ISC_TIME_H #ifndef ISC_TIME_H
#define ISC_TIME_H 1 #define ISC_TIME_H 1
#include <sys/time.h>
#include <time.h> #include <time.h>
#include <isc/result.h> #include <isc/result.h>
@@ -32,16 +31,15 @@
* The contents of this structure are private, and MUST NOT be accessed * The contents of this structure are private, and MUST NOT be accessed
* directly by callers. * directly by callers.
* *
* The contents are exposed only so that callers may avoid dynamic allocation * The contents are exposed only to allow callers to avoid dynamic allocation.
* and instead just declare a 'struct isc_interval'.
*/ */
typedef struct isc_interval { typedef struct isc_interval {
unsigned int seconds; unsigned int seconds;
unsigned int nanoseconds; unsigned int nanoseconds;
} *isc_interval_t; } isc_interval_t;
void void
isc_interval_set(isc_interval_t i, isc_interval_set(isc_interval_t *i,
unsigned int seconds, unsigned int nanoseconds); unsigned int seconds, unsigned int nanoseconds);
/* /*
* Set 'i' to a value representing an interval of 'seconds' seconds and * 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_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. * 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 * The contents of this structure are private, and MUST NOT be accessed
* directly by callers. * directly by callers.
* *
* The contents are exposed only so that callers may avoid dynamic allocation * The contents are exposed only to allow callers to avoid dynamic allocation.
* and instead just declare a 'struct isc_time'.
*/ */
typedef struct isc_time { typedef struct isc_time {
time_t seconds; time_t seconds;
unsigned int nanoseconds; unsigned int nanoseconds;
} *isc_time_t; } isc_time_t;
void void
isc_time_settoepoch(isc_time_t t); isc_time_settoepoch(isc_time_t *t);
/* /*
* Set 't' to the time of the epoch. * Set 't' to the time of the epoch.
* *
@@ -95,7 +92,7 @@ isc_time_settoepoch(isc_time_t t);
*/ */
isc_boolean_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"). * 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_result_t
isc_time_get(isc_time_t t); isc_time_get(isc_time_t *t);
/* /*
* Set 't' to the current absolute time. * Set 't' to the current absolute time.
* *
@@ -121,7 +118,7 @@ isc_time_get(isc_time_t t);
*/ */
int 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' * Compare the times referenced by 't1' and 't2'
* *
@@ -137,7 +134,7 @@ isc_time_compare(isc_time_t t1, isc_time_t t2);
*/ */
void 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'. * 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 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'. * 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) * 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 */ #endif /* ISC_TIME_H */

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@
#include <config.h> #include <config.h>
#include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <stddef.h> #include <stddef.h>
@@ -34,7 +35,7 @@
***/ ***/
void void
isc_interval_set(isc_interval_t i, isc_interval_set(isc_interval_t *i,
unsigned int seconds, unsigned int nanoseconds) { unsigned int seconds, unsigned int nanoseconds) {
/* /*
@@ -51,7 +52,7 @@ isc_interval_set(isc_interval_t i,
} }
isc_boolean_t 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. * Returns ISC_TRUE iff. 'i' is the zero interval.
@@ -71,7 +72,7 @@ isc_interval_iszero(isc_interval_t i) {
***/ ***/
void void
isc_time_settoepoch(isc_time_t t) { isc_time_settoepoch(isc_time_t *t) {
/* /*
* Set 't' to the time of the epoch. * Set 't' to the time of the epoch.
*/ */
@@ -83,7 +84,7 @@ isc_time_settoepoch(isc_time_t t) {
} }
isc_boolean_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"). * 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_result_t
isc_time_get(isc_time_t t) { isc_time_get(isc_time_t *t) {
struct timeval tv; struct timeval tv;
/* /*
@@ -119,7 +120,7 @@ isc_time_get(isc_time_t t) {
} }
int 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' * Compare the times referenced by 't1' and 't2'
@@ -139,7 +140,7 @@ isc_time_compare(isc_time_t t1, isc_time_t t2) {
} }
void 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'. * 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 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'. * 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--; 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;
}

View File

@@ -28,6 +28,7 @@
./lib/isc/pthreads/include/isc/mutex.h 1998 ./lib/isc/pthreads/include/isc/mutex.h 1998
./lib/isc/pthreads/include/isc/thread.h 1998 ./lib/isc/pthreads/include/isc/thread.h 1998
./lib/isc/pthreads/condition.c 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/include/isc/time.h 1998
./lib/isc/unix/time.c 1998 ./lib/isc/unix/time.c 1998
./lib/isc/win32/include/isc/condition.h 1998 ./lib/isc/win32/include/isc/condition.h 1998