Commit 0fe38318 authored by Daniel Salzman's avatar Daniel Salzman

rename knot/common.h to knot/knot.h and remove duplicate code

parent 0a37ccb6
......@@ -88,7 +88,6 @@ src/common/slab/slab.c
src/common/slab/slab.h
src/common/sockaddr.c
src/common/sockaddr.h
src/knot/common.h
src/knot/conf/cf-lex.l
src/knot/conf/cf-parse.y
src/knot/conf/conf.c
......@@ -104,6 +103,7 @@ src/knot/ctl/process.c
src/knot/ctl/process.h
src/knot/ctl/remote.c
src/knot/ctl/remote.h
src/knot/knot.h
src/knot/main.c
src/knot/other/debug.h
src/knot/server/dthreads.c
......@@ -201,6 +201,7 @@ src/libknot/zone/zone.c
src/libknot/zone/zone.h
src/libknot/zone/zonedb.c
src/libknot/zone/zonedb.h
src/tests/Makefile.am
src/tests/common/acl_tests.c
src/tests/common/acl_tests.h
src/tests/common/base32hex_tests.c
......
......@@ -242,8 +242,7 @@ libknotd_la_SOURCES = \
knot/stat/gatherer.h \
knot/stat/stat.h \
knot/stat/stat-common.h \
knot/common.h \
common/latency.h \
knot/knot.h \
knot/other/debug.h \
knot/conf/cf-lex.l \
knot/conf/cf-parse.y \
......
......@@ -25,7 +25,6 @@
#include "common/log.h"
#include "common/lists.h"
#include "knot/common.h"
#include "knot/conf/conf.h"
/*! Log source table. */
......
......@@ -28,7 +28,7 @@
#include <urcu.h>
#include "knot/conf/conf.h"
#include "knot/conf/extra.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/ctl/remote.h"
/*
......
......@@ -26,7 +26,7 @@
#include "knot/conf/conf.h"
#include "common/log.h"
#include "common/lists.h"
#include "knot/common.h"
#include "knot/knot.h"
int log_conf_hook(const struct conf_t *conf, void *data)
{
......
......@@ -32,7 +32,7 @@
#include <sys/wait.h>
#endif
#include "knot/common.h"
#include "knot/knot.h"
#include "common/descriptor.h"
#include "knot/ctl/process.h"
#include "knot/ctl/remote.h"
......
......@@ -27,7 +27,7 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/ctl/process.h"
#include "knot/conf/conf.h"
#include "common/mempattern.h"
......
......@@ -19,7 +19,7 @@
#include "common/log.h"
#include "common/fdset.h"
#include "common/prng.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/conf/conf.h"
#include "knot/server/socket.h"
#include "knot/server/tcp-handler.h"
......
......@@ -14,18 +14,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file src/knot/common.h
* \file knot.h
*
* \author Lubos Slovak <lubos.slovak@nic.cz>
*
* \brief Common macros, includes and utilities.
*
* \addtogroup utils
* \addtogroup server
* @{
*/
#ifndef _KNOTD_COMMON_H_
#define _KNOTD_COMMON_H_
#ifndef _KNOTD_KNOT_H_
#define _KNOTD_KNOT_H_
#include <signal.h>
#include <stdint.h>
......@@ -34,11 +34,6 @@
* Common types and constants.
*/
#ifndef UINT_DEFINED
typedef unsigned int uint; /*!< \brief Unsigned. */
#define UINT_DEFINED
#endif
#define PROJECT_EXENAME "knotd"
#define PROJECT_EXEC SBINDIR "/" PROJECT_EXENAME /*!< \brief Project executable. */
#define PID_FILE "knot.pid" /*!< \brief Server PID file name. */
......@@ -60,50 +55,11 @@ typedef unsigned int uint; /*!< \brief Unsigned. */
* Common includes.
*/
#include "common/latency.h"
#include "common/print.h"
#include "common/log.h"
#include "common/errcode.h"
#include "knot/other/debug.h"
/*! \brief Eliminate compiler warning with unused parameters. */
#define UNUSED(param) (void)(param)
/* Optimisation macros. */
#ifndef knot_likely
/*! \brief Optimize for x to be true value. */
#define knot_likely(x) __builtin_expect((x),1)
#endif
#ifndef knot_unlikely
/*! \brief Optimize for x to be false value. */
#define knot_unlikely(x) __builtin_expect((x),0)
#endif
/*! \todo Refactor theese. We should have an allocator function handling this.*/
#ifndef ERR_ALLOC_FAILED
#define ERR_ALLOC_FAILED fprintf(stderr, "Allocation failed at %s:%d (%s)\n", \
__FILE__, __LINE__, PACKAGE_STRING)
#endif
#ifndef CHECK_ALLOC_LOG
#define CHECK_ALLOC_LOG(var, ret) \
do { \
if ((var) == NULL) { \
ERR_ALLOC_FAILED; \
return (ret); \
} \
} while (0)
#endif
#ifndef CHECK_ALLOC
#define CHECK_ALLOC(var, ret) \
do { \
if ((var) == NULL) { \
return (ret); \
} \
} while (0)
#endif
/* Workarounds for clock_gettime() not available on some platforms. */
#ifdef HAVE_CLOCK_GETTIME
#define time_now(x) clock_gettime(CLOCK_MONOTONIC, (x))
......@@ -115,6 +71,6 @@ typedef struct timeval timev_t;
#error Neither clock_gettime() nor gettimeofday() found. At least one is required.
#endif
#endif /* _KNOTD_COMMON_H_ */
#endif /* _KNOTD_KNOT_H_ */
/*! @} */
......@@ -27,7 +27,7 @@
#include "common.h"
#include "common/evqueue.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/server.h"
#include "knot/ctl/process.h"
#include "knot/ctl/remote.h"
......
......@@ -30,7 +30,7 @@
#include <pthread_np.h>
#endif /* HAVE_PTHREAD_NP_H */
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/dthreads.h"
#include "common/log.h"
......
......@@ -22,7 +22,7 @@
#include <assert.h>
#include "knot/server/rrl.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "libknot/consts.h"
#include "libknot/util/wire.h"
#include "common/hattrie/murmurhash3.h"
......
......@@ -24,7 +24,7 @@
#include <assert.h>
#include "common/prng.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/server.h"
#include "knot/server/udp-handler.h"
#include "knot/server/tcp-handler.h"
......
......@@ -36,7 +36,6 @@
#ifndef _KNOTD_SERVER_H_
#define _KNOTD_SERVER_H_
#include "knot/common.h"
#include "libknot/nameserver/name-server.h"
#include "knot/server/xfr-handler.h"
#include "knot/server/socket.h"
......
......@@ -32,7 +32,7 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/socket.h"
int socket_create(int family, int type, int proto)
......
......@@ -32,7 +32,7 @@
#include "common/sockaddr.h"
#include "common/skip-list.h"
#include "common/fdset.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/tcp-handler.h"
#include "knot/server/xfr-handler.h"
#include "knot/server/zones.h"
......
......@@ -41,7 +41,7 @@
#include "common/sockaddr.h"
#include "common/mempattern.h"
#include "common/mempool.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/udp-handler.h"
#include "libknot/nameserver/name-server.h"
#include "knot/stat/stat.h"
......
......@@ -28,7 +28,7 @@
#include <assert.h>
#include <urcu.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/xfr-handler.h"
#include "libknot/nameserver/name-server.h"
#include "knot/server/socket.h"
......
......@@ -22,7 +22,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/other/debug.h"
#include "libknot/libknot.h"
#include "libknot/sign/key.h"
......
......@@ -41,7 +41,7 @@ typedef unsigned int uint; /*!< \brief Unsigned. */
/*! \brief Eliminate compiler warning with unused parameters. */
#define UNUSED(param) (void)(param)
#if 0 // Disabled due to a conflict with system MIN and MAX on BSDs.
#ifndef MIN
/*! \brief Type-safe minimum macro. */
#define MIN(a, b) \
({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
......@@ -61,20 +61,11 @@ typedef unsigned int uint; /*!< \brief Unsigned. */
#define knot_unlikely(x) __builtin_expect((x),0)
#endif
/* Optimisation macros. */
#ifndef knot_likely
/*! \brief Optimize for x to be true value. */
#define knot_likely(x) __builtin_expect((x),1)
#endif
#ifndef knot_unlikely
/*! \brief Optimize for x to be false value. */
#define knot_unlikely(x) __builtin_expect((x),0)
#endif
/*! \todo Refactor theese. We should have an allocator function handling this.*/
#ifndef ERR_ALLOC_FAILED
#define ERR_ALLOC_FAILED fprintf(stderr, "Allocation failed at %s:%d (%s ver.%s)\n", \
__FILE__, __LINE__, KNOT_NAME, KNOT_VER)
#define ERR_ALLOC_FAILED fprintf(stderr, \
"Allocation failed at %s:%d (%s ver.%s)\n", \
__FILE__, __LINE__, KNOT_NAME, KNOT_VER)
#endif
#ifndef CHECK_ALLOC_LOG
......
......@@ -22,7 +22,6 @@
#include "tests/common/slab_tests.h"
#include "common/slab/slab.h"
#include "knot/common.h"
/*! \brief Type-safe maximum macro. */
#define SLAB_MAX(a, b) \
......
......@@ -19,7 +19,7 @@
#include "tests/knot/journal_tests.h"
#include "knot/server/journal.h"
#include "knot/common.h"
#include "knot/knot.h"
static int journal_tests_count(int argc, char *argv[]);
static int journal_tests_run(int argc, char *argv[]);
......
......@@ -20,7 +20,7 @@
#include "tests/knot/rrl_tests.h"
#include "knot/server/rrl.h"
#include "knot/server/dthreads.h"
#include "knot/common.h"
#include "knot/knot.h"
#include "libknot/packet/response.h"
#include "libknot/packet/query.h"
#include "libknot/nameserver/name-server.h"
......
......@@ -15,7 +15,7 @@
*/
#include <config.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "common/libtap/tap_unit.h"
// Units to test
......
......@@ -29,7 +29,7 @@
#include <getopt.h>
#include <assert.h>
#include "knot/common.h"
#include "knot/knot.h"
#include "knot/server/server.h"
#include "knot/ctl/process.h"
#include "knot/conf/conf.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment