Browse Source

Add NetBSD support.

Fixes #3, thanks to @gitisihara for providing the initial patch and
testing.
OPENBSD_5_7
Brent Cook 9 years ago
parent
commit
207a65ca0b
7 changed files with 93 additions and 7 deletions
  1. +2
    -0
      .gitignore
  2. +8
    -5
      ChangeLog
  3. +7
    -0
      Makefile.am
  4. +1
    -0
      README
  5. +60
    -0
      compat/adjfreq_netbsd.c
  6. +3
    -0
      compat/arc4random.h
  7. +12
    -2
      configure.ac

+ 2
- 0
.gitignore View File

@ -37,6 +37,7 @@ compat/arc4random.c
compat/arc4random_freebsd.h
compat/arc4random_hpux.h
compat/arc4random_linux.h
compat/arc4random_netbsd.h
compat/arc4random_osx.h
compat/arc4random_solaris.h
compat/arc4random_uniform.c
@ -46,6 +47,7 @@ compat/explicit_bzero.c
compat/getentropy_freebsd.c
compat/getentropy_hpux.c
compat/getentropy_linux.c
compat/getentropy_netbsd.c
compat/getentropy_osx.c
compat/getentropy_solaris.c
compat/getentropy_win.c


+ 8
- 5
ChangeLog View File

@ -10,18 +10,21 @@ the GitHub mirror.
* Added support for setting the process title on Linux and OS X.
The different processes are now possible to tell apart by role in
the process list.
* Import NetBSD support.
* Various bugfixes and refinements from the community.
2015-01-08 OpenNTPD 5.7p1
* Support for a new build infrastructure based on the LibreSSL framework.
Source code is integrated directly from the OpenBSD tree with few manual
changes, easing maintenance.
* Support for a new build infrastructure based on the LibreSSL
framework. Source code is integrated directly from the OpenBSD tree
with few manual changes, easing maintenance.
* Removed support for several OSes pending test reports and updated
portability code.
* Supports the Simple Network Time Protocol version 4 as described in RFC 5905
* Supports the Simple Network Time Protocol version 4 as described in
RFC 5905
* Added route virtualization (rdomain) support.
* Added ntpctl(8), which allows for querying ntpd(8) at runtime.
* Finer-grained clock adjustment via adjfreq / ntp_adjtime where available.
* Finer-grained clock adjustment via adjfreq / ntp_adjtime where
available.
* Improved latency on heavily-loaded machines.

+ 7
- 0
Makefile.am View File

@ -125,6 +125,9 @@ endif
if HOST_LINUX
libcompat_la_SOURCES += compat/adjfreq_linux.c
endif
if HOST_NETBSD
libcompat_la_SOURCES += compat/adjfreq_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += compat/adjfreq_osx.c
endif
@ -197,6 +200,9 @@ if !HAVE_SHA512
libcompat_la_SOURCES += compat/sha2.c
endif
endif
if HOST_NETBSD
libcompat_la_SOURCES += compat/getentropy_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += compat/getentropy_osx.c
if !HAVE_SHA512
@ -219,6 +225,7 @@ endif
noinst_HEADERS = compat/arc4random.h
noinst_HEADERS += compat/arc4random_freebsd.h
noinst_HEADERS += compat/arc4random_linux.h
noinst_HEADERS += compat/arc4random_netbsd.h
noinst_HEADERS += compat/arc4random_osx.h
noinst_HEADERS += compat/arc4random_solaris.h
noinst_HEADERS += compat/arc4random_win.h


+ 1
- 0
README View File

@ -19,6 +19,7 @@ At the time of writing the Portable version is known to build and work on:
- OpenBSD (5.6)
- Linux (Ubuntu 12.04, 14.04)
- FreeBSD (9.x, 10.x)
- NetBSD (6.1.5)
- Solaris (10.x, 11.x)
- Mac OS X (10.9)


+ 60
- 0
compat/adjfreq_netbsd.c View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2007 Sebastian Benoit <benoit-lists@fb12.de>
*
* 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <unistd.h>
#include "ntp.h"
#include "ntpd.h"
/*
* adjfreq (old)freq = nanosec. per seconds shifted left 32 bits
* timex.freq is ppm / left shifted by SHIFT_USEC (16 bits), defined in timex.h
*/
int
adjfreq(const int64_t *freq, int64_t *oldfreq)
{
struct timex txc;
int64_t newfreq;
if (freq != NULL) {
txc.modes = MOD_FREQUENCY;
txc.freq = *freq / 1e3 / (1LL << 16);
if ((ntp_adjtime(&txc)) == -1)
log_warn("ntp_adjtime (2) failed");
log_debug("ntp_adjtime adjusted frequency by %fppm",
((txc.freq * 1e3) * (1LL<<16) / 1e3 / (1LL << 32)));
}
if (oldfreq != NULL) {
txc.modes = 0;
if ((ntp_adjtime(&txc)) == -1) {
log_warn("ntp_adjtime (1) failed");
return -1;
}
newfreq = (txc.freq * 1e3) * (1LL<<16);
log_debug("ntp_adjtime returns frequency of %fppm",
newfreq / 1e3 / (1LL << 32));
*oldfreq = newfreq;
}
return 0;
}

+ 3
- 0
compat/arc4random.h View File

@ -9,6 +9,9 @@
#elif defined(__linux__)
#include "arc4random_linux.h"
#elif defined(__NetBSD__)
#include "arc4random_netbsd.h"
#elif defined(__APPLE__)
#include "arc4random_osx.h"


+ 12
- 2
configure.ac View File

@ -46,6 +46,9 @@ case $host_os in
CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE"
AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
;;
*netbsd*)
HOST_OS=netbsd
;;
*openbsd*)
AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD has __bounded__])
AC_DEFINE([HAVE_ATTRIBUTE__DEAD], [1], [OpenBSD has __dead])
@ -61,6 +64,7 @@ esac
AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin])
AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
AC_CHECK_FUNC([dl_iterate_phdr],,
@ -139,9 +143,15 @@ AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
# overrides for arc4random implementations with known issues
AM_CONDITIONAL([HAVE_ARC4RANDOM],
[test "x$HOST_OS" != xdarwin -a "x$HOST_OS" != xfreebsd -a "x$ac_cv_func_arc4random" = xyes])
[test "x$HOST_OS" != xdarwin \
-a "x$HOST_OS" != xfreebsd \
-a "x$HOST_OS" != xnetbsd \
-a "x$ac_cv_func_arc4random" = xyes])
AM_CONDITIONAL([HAVE_ARC4RANDOM_UNIFORM],
[test "x$HOST_OS" != xdarwin -a "x$HOST_OS" != xfreebsd -a "x$ac_cv_func_arc4random_uniform" = xyes])
[test "x$HOST_OS" != xdarwin \
-a "x$HOST_OS" != xfreebsd \
-a "x$HOST_OS" != xnetbsd \
-a "x$ac_cv_func_arc4random_uniform" = xyes])
AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[


Loading…
Cancel
Save