Commit cdbac34c authored by Witold Krecicki's avatar Witold Krecicki
Browse files

Get rid of isc_bind9 conditional

parent 60f22ff4
......@@ -51,30 +51,14 @@ isc_app_register(isc_appctxcreatefunc_t createfunc) {
isc_result_t
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_result_t result;
if (isc_bind9)
return (isc__appctx_create(mctx, ctxp));
LOCK(&createlock);
REQUIRE(appctx_createfunc != NULL);
result = (*appctx_createfunc)(mctx, ctxp);
UNLOCK(&createlock);
return (result);
return (isc__appctx_create(mctx, ctxp));
}
void
isc_appctx_destroy(isc_appctx_t **ctxp) {
REQUIRE(ctxp != NULL && ISCAPI_APPCTX_VALID(*ctxp));
if (isc_bind9)
isc__appctx_destroy(ctxp);
else
(*ctxp)->methods->ctxdestroy(ctxp);
isc__appctx_destroy(ctxp);
ENSURE(*ctxp == NULL);
}
......@@ -82,20 +66,14 @@ isc_result_t
isc_app_ctxstart(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxstart(ctx));
return (ctx->methods->ctxstart(ctx));
return (isc__app_ctxstart(ctx));
}
isc_result_t
isc_app_ctxrun(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxrun(ctx));
return (ctx->methods->ctxrun(ctx));
return (isc__app_ctxrun(ctx));
}
isc_result_t
......@@ -105,40 +83,28 @@ isc_app_ctxonrun(isc_appctx_t *ctx, isc_mem_t *mctx,
{
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxonrun(ctx, mctx, task, action, arg));
return (ctx->methods->ctxonrun(ctx, mctx, task, action, arg));
return (isc__app_ctxonrun(ctx, mctx, task, action, arg));
}
isc_result_t
isc_app_ctxsuspend(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxsuspend(ctx));
return (ctx->methods->ctxsuspend(ctx));
return (isc__app_ctxsuspend(ctx));
}
isc_result_t
isc_app_ctxshutdown(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxshutdown(ctx));
return (ctx->methods->ctxshutdown(ctx));
return (isc__app_ctxshutdown(ctx));
}
void
isc_app_ctxfinish(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
isc__app_ctxfinish(ctx);
ctx->methods->ctxfinish(ctx);
isc__app_ctxfinish(ctx);
}
void
......@@ -146,10 +112,7 @@ isc_appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(taskmgr != NULL);
if (isc_bind9)
isc__appctx_settaskmgr(ctx, taskmgr);
ctx->methods->settaskmgr(ctx, taskmgr);
isc__appctx_settaskmgr(ctx, taskmgr);
}
void
......@@ -157,10 +120,7 @@ isc_appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(socketmgr != NULL);
if (isc_bind9)
isc__appctx_setsocketmgr(ctx, socketmgr);
ctx->methods->setsocketmgr(ctx, socketmgr);
isc__appctx_setsocketmgr(ctx, socketmgr);
}
void
......@@ -168,43 +128,30 @@ isc_appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(timermgr != NULL);
if (isc_bind9)
isc__appctx_settimermgr(ctx, timermgr);
ctx->methods->settimermgr(ctx, timermgr);
isc__appctx_settimermgr(ctx, timermgr);
}
isc_result_t
isc_app_start(void) {
if (isc_bind9)
return (isc__app_start());
return (ISC_R_NOTIMPLEMENTED);
return (isc__app_start());
}
isc_result_t
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
if (isc_bind9)
return (isc__app_onrun(mctx, task, action, arg));
return (ISC_R_NOTIMPLEMENTED);
return (isc__app_onrun(mctx, task, action, arg));
}
isc_result_t
isc_app_run() {
if (isc_bind9) {
isc_result_t result;
is_running = true;
result = isc__app_run();
is_running = false;
isc_result_t result;
return (result);
}
is_running = ISC_TRUE;
result = isc__app_run();
is_running = ISC_FALSE;
return (ISC_R_NOTIMPLEMENTED);
return (result);
}
bool
......@@ -214,40 +161,25 @@ isc_app_isrunning() {
isc_result_t
isc_app_shutdown(void) {
if (isc_bind9)
return (isc__app_shutdown());
return (ISC_R_NOTIMPLEMENTED);
return (isc__app_shutdown());
}
isc_result_t
isc_app_reload(void) {
if (isc_bind9)
return (isc__app_reload());
return (ISC_R_NOTIMPLEMENTED);
return (isc__app_reload());
}
void
isc_app_finish(void) {
if (!isc_bind9)
return;
isc__app_finish();
}
void
isc_app_block(void) {
if (!isc_bind9)
return;
isc__app_block();
}
void
isc_app_unblock(void) {
if (!isc_bind9)
return;
isc__app_unblock();
}
......@@ -94,29 +94,6 @@ typedef isc_event_t isc_appevent_t;
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
/*%
* app module methods. Only app driver implementations use this structure.
* Other clients should use the top-level interfaces (i.e., isc_app_xxx
* functions). magic must be ISCAPI_APPMETHODS_MAGIC.
*/
typedef struct isc_appmethods {
void (*ctxdestroy)(isc_appctx_t **ctxp);
isc_result_t (*ctxstart)(isc_appctx_t *ctx);
isc_result_t (*ctxrun)(isc_appctx_t *ctx);
isc_result_t (*ctxsuspend)(isc_appctx_t *ctx);
isc_result_t (*ctxshutdown)(isc_appctx_t *ctx);
void (*ctxfinish)(isc_appctx_t *ctx);
void (*settaskmgr)(isc_appctx_t *ctx,
isc_taskmgr_t *timermgr);
void (*setsocketmgr)(isc_appctx_t *ctx,
isc_socketmgr_t *timermgr);
void (*settimermgr)(isc_appctx_t *ctx,
isc_timermgr_t *timermgr);
isc_result_t (*ctxonrun)(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg);
} isc_appmethods_t;
/*%
* This structure is actually just the common prefix of an application context
* implementation's version of an isc_appctx_t.
......@@ -129,7 +106,6 @@ typedef struct isc_appmethods {
struct isc_appctx {
unsigned int impmagic;
unsigned int magic;
isc_appmethods_t *methods;
};
#define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c')
......
......@@ -181,44 +181,6 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
* \endcode
*/
/*% memory and memory pool methods */
typedef struct isc_memmethods {
void (*attach)(isc_mem_t *source, isc_mem_t **targetp);
void (*detach)(isc_mem_t **mctxp);
void (*destroy)(isc_mem_t **mctxp);
void *(*memget)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void (*memput)(isc_mem_t *mctx, void *ptr, size_t size _ISC_MEM_FLARG);
void (*memputanddetach)(isc_mem_t **mctxp, void *ptr,
size_t size _ISC_MEM_FLARG);
void *(*memallocate)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void *(*memreallocate)(isc_mem_t *mctx, void *ptr,
size_t size _ISC_MEM_FLARG);
char *(*memstrdup)(isc_mem_t *mctx, const char *s _ISC_MEM_FLARG);
void (*memfree)(isc_mem_t *mctx, void *ptr _ISC_MEM_FLARG);
void (*setdestroycheck)(isc_mem_t *mctx, bool flag);
void (*setwater)(isc_mem_t *ctx, isc_mem_water_t water,
void *water_arg, size_t hiwater, size_t lowater);
void (*waterack)(isc_mem_t *ctx, int flag);
size_t (*inuse)(isc_mem_t *mctx);
size_t (*maxinuse)(isc_mem_t *mctx);
size_t (*total)(isc_mem_t *mctx);
bool (*isovermem)(isc_mem_t *mctx);
isc_result_t (*mpcreate)(isc_mem_t *mctx, size_t size,
isc_mempool_t **mpctxp);
} isc_memmethods_t;
typedef struct isc_mempoolmethods {
void (*destroy)(isc_mempool_t **mpctxp);
void *(*get)(isc_mempool_t *mpctx _ISC_MEM_FLARG);
void (*put)(isc_mempool_t *mpctx, void *mem _ISC_MEM_FLARG);
unsigned int (*getallocated)(isc_mempool_t *mpctx);
void (*setmaxalloc)(isc_mempool_t *mpctx, unsigned int limit);
void (*setfreemax)(isc_mempool_t *mpctx, unsigned int limit);
void (*setname)(isc_mempool_t *mpctx, const char *name);
void (*associatelock)(isc_mempool_t *mpctx, isc_mutex_t *lock);
void (*setfillcount)(isc_mempool_t *mpctx, unsigned int limit);
} isc_mempoolmethods_t;
/*%
* This structure is actually just the common prefix of a memory context
* implementation's version of an isc_mem_t.
......@@ -231,7 +193,6 @@ typedef struct isc_mempoolmethods {
struct isc_mem {
unsigned int impmagic;
unsigned int magic;
isc_memmethods_t *methods;
};
#define ISCAPI_MCTX_MAGIC ISC_MAGIC('A','m','c','x')
......@@ -245,7 +206,6 @@ struct isc_mem {
struct isc_mempool {
unsigned int impmagic;
unsigned int magic;
isc_mempoolmethods_t *methods;
};
#define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l')
......
......@@ -333,60 +333,6 @@ typedef enum {
#define ISC_SOCKFDWATCH_WRITE 0x00000002 /*%< watch for writable */
/*@}*/
/*% Socket and socket manager methods */
typedef struct isc_socketmgrmethods {
void (*destroy)(isc_socketmgr_t **managerp);
isc_result_t (*socketcreate)(isc_socketmgr_t *manager, int pf,
isc_sockettype_t type,
isc_socket_t **socketp);
isc_result_t (*fdwatchcreate)(isc_socketmgr_t *manager, int fd,
int flags,
isc_sockfdwatch_t callback,
void *cbarg, isc_task_t *task,
isc_socket_t **socketp);
} isc_socketmgrmethods_t;
typedef struct isc_socketmethods {
void (*attach)(isc_socket_t *socket,
isc_socket_t **socketp);
void (*detach)(isc_socket_t **socketp);
isc_result_t (*bind)(isc_socket_t *sock,
const isc_sockaddr_t *sockaddr,
isc_socket_options_t options);
isc_result_t (*sendto)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action,
void *arg,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo);
isc_result_t (*sendto2)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo,
isc_socketevent_t *event,
unsigned int flags);
isc_result_t (*connect)(isc_socket_t *sock,
const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action,
void *arg);
isc_result_t (*recv)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t (*recv2)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_socketevent_t *event, unsigned int flags);
void (*cancel)(isc_socket_t *sock, isc_task_t *task,
unsigned int how);
isc_result_t (*getsockname)(isc_socket_t *sock,
isc_sockaddr_t *addressp);
isc_sockettype_t (*gettype)(isc_socket_t *sock);
void (*ipv6only)(isc_socket_t *sock, bool yes);
isc_result_t (*fdwatchpoke)(isc_socket_t *sock, int flags);
isc_result_t (*dup)(isc_socket_t *socket,
isc_socket_t **socketp);
int (*getfd)(isc_socket_t *socket);
void (*dscp)(isc_socket_t *socket, isc_dscp_t dscp);
} isc_socketmethods_t;
/*%
* This structure is actually just the common prefix of a socket manager
* object implementation's version of an isc_socketmgr_t.
......@@ -404,7 +350,6 @@ typedef struct isc_socketmethods {
struct isc_socketmgr {
unsigned int impmagic;
unsigned int magic;
isc_socketmgrmethods_t *methods;
};
#endif
......@@ -420,7 +365,6 @@ struct isc_socketmgr {
struct isc_socket {
unsigned int impmagic;
unsigned int magic;
isc_socketmethods_t *methods;
};
#endif
......
......@@ -77,21 +77,7 @@ isc_lib_initmsgcat(void) {
}
}
static isc_once_t register_once = ISC_ONCE_INIT;
static void
do_register(void) {
isc_bind9 = false;
RUNTIME_CHECK(isc__mem_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__app_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__task_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__socket_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__timer_register() == ISC_R_SUCCESS);
}
void
isc_lib_register(void) {
RUNTIME_CHECK(isc_once_do(&register_once, do_register)
== ISC_R_SUCCESS);
printf("ISC_LIB_REGISTER\n");
}
......@@ -309,71 +309,6 @@ isc__mem_printactive(isc_mem_t *ctx0, FILE *file);
unsigned int
isc__mem_references(isc_mem_t *ctx0);
static struct isc__memmethods {
isc_memmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *createx, *create, *create2, *stats,
*setquota, *getquota, *setname, *getname, *gettag;
} memmethods = {
{
isc__mem_attach,
isc__mem_detach,
isc__mem_destroy,
isc___mem_get,
isc___mem_put,
isc___mem_putanddetach,
isc___mem_allocate,
isc___mem_reallocate,
isc___mem_strdup,
isc___mem_free,
isc__mem_setdestroycheck,
isc__mem_setwater,
isc__mem_waterack,
isc__mem_inuse,
isc__mem_maxinuse,
isc__mem_total,
isc__mem_isovermem,
isc__mempool_create
},
(void *)isc_mem_createx,
(void *)isc_mem_create,
(void *)isc_mem_create2,
(void *)isc_mem_stats,
(void *)isc_mem_setquota,
(void *)isc_mem_getquota,
(void *)isc_mem_setname,
(void *)isc_mem_getname,
(void *)isc_mem_gettag
};
static struct isc__mempoolmethods {
isc_mempoolmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *getfreemax, *getfreecount, *getmaxalloc, *getfillcount;
} mempoolmethods = {
{
isc__mempool_destroy,
isc___mempool_get,
isc___mempool_put,
isc__mempool_getallocated,
isc__mempool_setmaxalloc,
isc__mempool_setfreemax,
isc__mempool_setname,
isc__mempool_associatelock,
isc__mempool_setfillcount
},
(void *)isc_mempool_getfreemax,
(void *)isc_mempool_getfreecount,
(void *)isc_mempool_getmaxalloc,
(void *)isc_mempool_getfillcount
};
#if ISC_MEM_TRACKLINES
/*!
* mctx must be locked.
......@@ -923,7 +858,6 @@ isc_mem_createx2(size_t init_max_size, size_t target_size,
ctx->water_arg = NULL;
ctx->common.impmagic = MEM_MAGIC;
ctx->common.magic = ISCAPI_MCTX_MAGIC;
ctx->common.methods = (isc_memmethods_t *)&memmethods;
ctx->memalloc = memalloc;
ctx->memfree = memfree;
ctx->arg = arg;
......@@ -1801,7 +1735,6 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
if (mpctx == NULL)
return (ISC_R_NOMEMORY);
mpctx->common.methods = (isc_mempoolmethods_t *)&mempoolmethods;
mpctx->common.impmagic = MEMPOOL_MAGIC;
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
mpctx->lock = NULL;
......@@ -2684,32 +2617,15 @@ isc__mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
isc_result_t
isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
isc_result_t result;
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock);
REQUIRE(mem_createfunc != NULL);
result = (*mem_createfunc)(init_max_size, target_size, mctxp,
isc_mem_defaultflags);
UNLOCK(&createlock);
return (result);
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags));
}
isc_result_t
isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
unsigned int flags)
{
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, flags));
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, flags));
......@@ -2720,10 +2636,7 @@ isc_mem_attach(isc_mem_t *source, isc_mem_t **targetp) {
REQUIRE(ISCAPI_MCTX_VALID(source));
REQUIRE(targetp != NULL && *targetp == NULL);
if (isc_bind9)
isc__mem_attach(source, targetp);
else
source->methods->attach(source, targetp);
isc__mem_attach(source, targetp);
ENSURE(*targetp == source);
}
......@@ -2732,10 +2645,7 @@ void
isc_mem_detach(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_detach(mctxp);
else
(*mctxp)->methods->detach(mctxp);
isc__mem_detach(mctxp);
ENSURE(*mctxp == NULL);
}
......@@ -2744,10 +2654,7 @@ void
isc_mem_destroy(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_destroy(mctxp);
else
(*mctxp)->methods->destroy(mctxp);
isc__mem_destroy(mctxp);
ENSURE(*mctxp == NULL);
}
......@@ -2756,7 +2663,7 @@ void
isc_mem_setdestroycheck(isc_mem_t *mctx, bool flag) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
mctx->methods->setdestroycheck(mctx, flag);
isc__mem_setdestroycheck(mctx, flag);
}
void
......@@ -2765,60 +2672,42 @@ isc_mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg,
{
REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_setwater(ctx, water, water_arg, hiwater, lowater);
else
ctx->methods->setwater(ctx, water, water_arg, hiwater, lowater);
isc__mem_setwater(ctx, water, water_arg, hiwater, lowater);
}
void
isc_mem_waterack(isc_mem_t *ctx, int flag) {
REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_waterack(ctx, flag);
else
ctx->methods->waterack(ctx, flag);
isc__mem_waterack(ctx, flag);
}
size_t
isc_mem_inuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_inuse(mctx));
return (mctx->methods->inuse(mctx));
return (isc__mem_inuse(mctx));
}
size_t
isc_mem_maxinuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_maxinuse(mctx));
return (mctx->methods->maxinuse(mctx));
return (isc__mem_maxinuse(mctx));
}
size_t
isc_mem_total(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));