Commit ec5f6ebd authored by Marek Vavrusa's avatar Marek Vavrusa

BSD compatibility fixes, not yet fully ported.

Commit refs #827, #831.
parent 2ce13812
......@@ -34,16 +34,19 @@ AC_ARG_ENABLE([ldns],
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
AC_CHECK_LIB([m], [pow])
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([urcu], [rcu_read_lock])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_LIB([crypto], [OpenSSL_add_all_digests])
#AC_CHECK_LIB([ldns], [ldns_rr_list_pop_rrset])
# TODO: check if paths exist before appending
CFLAGS="$CFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthreads not found])])
AC_SEARCH_LIBS([rcu_read_lock], [urcu], [], [AC_MSG_ERROR([liburcu not found])])
AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([librt not found])])
AC_SEARCH_LIBS([OpenSSL_add_all_digests], [crypto],[], [AC_MSG_ERROR([libcrypto not found])])
#AC_SEARCH_LIBS([ldns_rr_list_pop_rrset], [ldns], [], [AC_MSG_ERROR([libldns not found])])
# Checks for header files.
AC_HEADER_RESOLV
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/socket.h sys/time.h syslog.h unistd.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/socket.h sys/time.h syslog.h unistd.h urcu.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
......
......@@ -223,17 +223,17 @@ libknot_la_LIBADD = @LIBOBJS@
# `%'-style pattern rules are a GNU make extension
dnslib/tests/parsed_data.rc: dnslib/tests/files/parsed_data
../resource.sh $< >$@
../resource.sh dnslib/tests/files/parsed_data >$@
dnslib/tests/parsed_data_queries.rc: dnslib/tests/files/parsed_data_queries
../resource.sh $< >$@
../resource.sh dnslib/tests/files/parsed_data_queries >$@
dnslib/tests/raw_data_queries.rc: dnslib/tests/files/raw_data_queries
../resource.sh $< >$@
../resource.sh dnslib/tests/files/raw_data_queries >$@
dnslib/tests/raw_data.rc: dnslib/tests/files/raw_data
../resource.sh $< >$@
../resource.sh dnslib/tests/files/raw_data >$@
tests/sample_conf.rc: tests/files/sample_conf
../resource.sh $< >$@
../resource.sh tests/files/sample_conf >$@
......@@ -240,7 +240,7 @@ cendtodo () {
#include <sys/mman.h>
#include <regex.h>
#ifdef __APPLE__
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
......
......@@ -12,7 +12,13 @@
#ifndef _KNOT_SOCKADDR_H_
#define _KNOT_SOCKADDR_H_
/* BSD IPv6 */
#ifndef __POSIX_VISIBLE
#define __POSIX_VISIBLE = 200112
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
/*! \brief Universal socket address. */
typedef struct sockaddr_t {
......
......@@ -27,24 +27,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define to 1 if you have the `ldns' library (-lldns). */
#undef HAVE_LIBLDNS
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the `urcu' library (-lurcu). */
#undef HAVE_LIBURCU
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
......@@ -144,6 +129,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <urcu.h> header file. */
#undef HAVE_URCU_H
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
......
......@@ -28,8 +28,8 @@
#define _KNOT_UNIVERSAL_SYSTEM_H_
#include <stdint.h>
#include "dnslib/dnslib-common.h"
typedef unsigned int uint;
enum { US_FNC_COUNT = 4 /*!< Number of functions for one generation. */ };
......
#include <config.h>
#include <malloc.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "dnslib/dnslib-common.h"
#include "dnslib/node.h"
......
#include <config.h>
#include <stdint.h>
#include <malloc.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "dnslib/dnslib-common.h"
#include "dnslib/rrset.h"
......
......@@ -660,8 +660,8 @@ uint16_t type_covered_from_rdata(const dnslib_rdata_t *rdata)
static int check_dnskey_rdata(const dnslib_rdata_t *rdata)
{
/* check that Zone key bit it set - position 7 in net order */
/* FIXME endian */
uint16_t mask = 0b0000000100000000;
/*! \todo FIXME: endian? */
uint16_t mask = 1 << 7; //0b0000000100000000;
uint16_t flags =
dnslib_wire_read_u16((uint8_t *)rdata_item_data
......@@ -1083,7 +1083,8 @@ static int check_nsec3_node_in_zone(dnslib_zone_t *zone, dnslib_node_t *node,
uint8_t flags =
((uint8_t *)(previous_rrset->rdata->items[1].raw_data))[2];
uint8_t opt_out_mask = 0b00000001;
/*! \todo FIXME: check this. */
uint8_t opt_out_mask = 1 << 0; //0b00000001;
if (!(flags & opt_out_mask)) {
err_handler_handle_error(handler, node,
......
#define __BSD_VISIBLE //! \todo Only on BSD-like OS.
#include <config.h>
#include <assert.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -839,7 +840,7 @@ int dnslib_zload_needs_update(zloader_t *loader)
}
/* Compare the mtime of the source and file. */
if (timespec_cmp(&st_bin.st_mtim, &st_src.st_mtim) < 0) {
if (timespec_cmp(&st_bin.st_mtime, &st_src.st_mtime) < 0) {
return 1;
}
......
......@@ -12,8 +12,8 @@
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include "common/sockaddr.h"
#include "knot/conf/conf.h"
#include "knot/other/log.h"
#include "libknot_la-cf-parse.h" /* Automake generated header. */
......@@ -24,11 +24,11 @@ extern void cf_error(const char *msg);
extern int (*cf_read_hook)(char *buf, size_t nbytes);
#define YY_INPUT(buf,result,max) result = cf_read_hook(buf, max);
#define YY_NO_UNPUT
/*! \warning Free yy buffers until reentrant parser is made. */
void __attribute__ ((destructor)) yy_deinit()
{
#ifdef YY_CURRENT_BUFFER_LVALUE
/* Pop the buffer stack, destroying each element. */
while (YY_CURRENT_BUFFER) {
yy_delete_buffer(YY_CURRENT_BUFFER);
......@@ -39,6 +39,7 @@ void __attribute__ ((destructor)) yy_deinit()
/* Destroy the stack itself. */
yyfree(yy_buffer_stack);
yy_buffer_stack = NULL;
#endif
}
%}
......
......@@ -63,8 +63,10 @@ static inline int tcp_send(int fd, uint8_t *msg, size_t msglen)
/*! \brief TCP corking.
* \see http://vger.kernel.org/~acme/unbehaved.txt
*/
#ifdef TCP_CORK
int cork = 1;
setsockopt(fd, SOL_TCP, TCP_CORK, &cork, sizeof(cork));
#endif
/* Send message size. */
unsigned short pktsize = htons(msglen);
......@@ -80,8 +82,10 @@ static inline int tcp_send(int fd, uint8_t *msg, size_t msglen)
}
/* Uncork. */
#ifdef TCP_CORK
cork = 0;
setsockopt(fd, SOL_TCP, TCP_CORK, &cork, sizeof(cork));
#endif
return sent;
}
......
......@@ -56,10 +56,12 @@ int udp_master(dthread_t *thread)
#endif
if (handler->type == AF_INET) {
#ifdef IP_PMTUDISC_DONT
/* Disable fragmentation. */
flag = IP_PMTUDISC_DONT;
setsockopt(sock, IPPROTO_IP, IP_MTU_DISCOVER, &flag, sizeof(flag));
flag = 1;
#endif
}
/* in case of STAT_COMPILE the following code will declare thread_stat
......
......@@ -53,17 +53,17 @@ struct gatherer {
/* double mean_latency;
double udp_mean_latency;
double tcp_mean_latency;
uint udp_latency;
uint tcp_latency; */
unsigned udp_latency;
unsigned tcp_latency; */
uint udp_queries; /*!< Total number of UDP queries for SLEEP_TIME. */
uint tcp_queries; /*!< Total number of TCP queries for SLEEP_TIME. */
unsigned udp_queries; /*!< Total number of UDP queries for SLEEP_TIME. */
unsigned tcp_queries; /*!< Total number of TCP queries for SLEEP_TIME. */
/*!
* \brief this variable should be much bigger, preferably sparse array
* with 2**32 elements (for IPv4). It is an array with query
* query frequencies.
*/
uint freq_array[FREQ_BUFFER_SIZE];
unsigned freq_array[FREQ_BUFFER_SIZE];
/*!
* \brief Used for backward mapping.
*/
......
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