Commit 8c930a7a authored by Eric S. Raymond's avatar Eric S. Raymond

Remove legacy Windows port code.

We might support Windows again someday, but the intelligent way to do it will
be via a C99/POSIX emulation environment such as CYGWIN or the Windows 10
facility for executing Linux binaries that is being demonstrated by Microsoft
(though not yet shipped) at time of writing.
parent 28f8bb8c
......@@ -23,8 +23,6 @@
internal symbols for testing, e.g --define FOO=BAR generates #define
FOO BAR into config.h.
* Add monkeypatch for rmdir, rmtree under Windows.
=== Code ===
* Can the KERNEL_PLL code be removed? It's used by drivers 4, 8, 20, 22, and
......@@ -117,9 +115,6 @@ Neither is ideal, easy pickings for someone to code on.
* We might be able to eliminate a lot of the Linux runtime
droproot code by using file capabilities.
* Better ANSI/POSIX conformance in MinGW and Visual Studio 2013 might
enable us to get rid of the SYS_WINNT code. Should be tried...
* There is a mess around the symbols NO_MAIN_ALLOWED, BUILD_AS_LIB, and
LIBNTP_C that needs to be refactored. ntpd should *always* be built as
a library linked to a main module, these guard symbols should go away.
......
......@@ -183,63 +183,12 @@ __UNUSED__
_STRING_H # In ntpd/ntp_parser.tab.c
__BUILTIN_VA_ARG_INCR # In ntpd/ntp_parser.tab.c
__SIZE_TYPE__ # In ntpd/ntp_parser.tab.c
# Inaccessible port guards
SYS_WINNT # Won't make any sense until we have a Windows port again
SYS_CYGWIN32
# Windows port only - these may need revisiting
# if we can't drop the SYS_WINNT code
NTDDI_.* # Some sort of Windows NT version thing
DOES_NOT_WORK
EREALLOC_.*
HAVE_IO_COMPLETION_PORT # Windows only alternative to signaled I/O
INTPTR_MAX
INTPTR_MIN
ISC_STATIC_WIN
ISC_PLATFORM_QUADFORMAT
ISC_PLATFORM_USEDECLSPEC
LIBBIND9_EXPORTS
LIBDNS_EXPORTS
LIBISCCC_EXPORTS
LIBISCCFG_EXPORTS
LIBISC_EXPORTS
LOG_AUTHPRIV
LOG_CRON
LOG_FTP
LOG_NEWS
LOG_UUCP
MALLOC_LINT
MISSING_STDBOOL_H
MULTICAST_NONEWSOCKET
OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER
PTRDIFF_MAX
PTRDIFF_MIN
STR_PROCESSOR
SIO_UDP_CONNRESET
STR_SYSTEM
STRUCT_NTP_TIMEVAL_HAS_TV_NSEC
INTPTR_MAX # Unity
STRUCT_TIMEX_HAS_MODES
STRUCT_TIMEX_HAS_TIME_TICK
UNICODE
UNUSED$
WRAP_DBG_MALLOC
_CRTDBG_MAP_ALLOC
_CRT_SECURE_NO_WARNINGS
_DEBUG
_INTPTR_T_DEFINED
_IOCTL_H
_MSC_VER1800
_M_IA64
_M_IX86
_M_IX86_FP
_M_X64
_PTRDIFF_T_DEFINED
_UINTPTR_T_DEFINED
_WCTYPE_T_DEFINED
__RPCASYNC_H__
__STDC_CONSTANT_MACROS
__STDC_LIMIT_MACROS
__STDINT_INCLUDED
# Inaccessible port guards
SYS_CYGWIN32
# end
......@@ -18,7 +18,6 @@ include::includes/install.txt[]
* link:#waf[Autoconf has been replaced with waf]
* link:#build[Building and Installing the Distribution]
* link:#unix[Building and Installing for Unix]
* link:#win[Building and Installing for Windows]
* link:#conf[Configuration]
* link:#prob[If You Have Problems]
* link:#additional[Additional +waf+ Commands]
......@@ -69,14 +68,6 @@ configures the build process accordingly. Use the +./waf build+ command to
compile and link the distribution and the +./waf install+ command to install
the executables by default in +/usr/local/bin+.
[[win]]
== Building and Installing for Windows ==
Building for Windows is not presently supported. This may change in a
future release. If you have a requirement for this, you may be able
to accelerate the process by contributing either skilled technical
help or money so we can hire skilled technical help.
[[conf]]
== Configuration ==
......
......@@ -53,7 +53,7 @@ cease operation.
The next most common problem is incorrect DNS names. Check that each DNS
name used in the configuration file exists and that the address responds
to the Unix +ping+ command. The Unix +traceroute+ or Windows +tracert+
to the Unix +ping+ command. The Unix +traceroute+
utility can be used to verify a partial or complete path exists. Most
problems reported to the NTP newsgroup are not NTP problems, but
problems with the network or firewall configuration.
......
......@@ -337,10 +337,6 @@ typical symbolic link command is as follows;
ln -s /dev/ttyUSB0 /dev/jjy0
----------------------------------------------------------------
Windows NT does not support symbolic links to device files. COM__X__: is
the unit used by the driver, based on the refclock unit number, where
unit 1 corresponds to COM1: and unit 3 corresponds to COM3:
== Monitor Data ==
The driver writes sent and received data to/from the JJY receivers, GPS
......
......@@ -258,10 +258,6 @@ refclock nmea mode baud 19200 # All sentences from /dev/gps0 at 19200 baud
refclock nmea path /dev/ttyUSB0 # All sentences from /dev/ttyUSB0 at 9600 baud
------------------------------------------------------------------------------
== Additional Information ==
//+flag1+, +flag2+, and +flag3+ are ignored under Windows.
link:refclock.html[Reference Clock Drivers]
'''''
......
......@@ -104,14 +104,10 @@ synchronization without needing the Internet at all.
Not used by this driver.
+flag2 {0 | 1}+::
Specifies PPS capture on the rising (assert) pulse edge if 0 (default)
or falling (clear) pulse edge if 1. Not used under Windows - if the
special +serialpps.sys+ serial port driver is installed then the
leading edge will _always_ be used.
or falling (clear) pulse edge if 1.
+flag3 {0 | 1}+::
Controls the kernel PPS discipline: 0 for disable (default), 1 for
enable. Not used under Windows - if the special +serialpps.sys+
serial port driver is used then kernel PPS will be available and
used.
enable.
+flag4 {0 | 1}+::
Record a timestamp once for each second if 1. Useful for constructing
Allan deviation plots.
......
......@@ -200,23 +200,12 @@ refclock shm unit 1 prefer refid PPS
== Public vs. Private SHM segments ==
The driver attempts to create a shared memory segment with an identifier
depending on the unit number. This identifier (which can be a numeric
value or a string) clearly depends on the method used, which in turn
depends on the host operating system:
* Windows uses a file mapping to the page file with the name
\'\+Global\NTP+'u'' for public accessible mappings, where _u_ is the clock
unit. Private / non-public mappings are created as \'\+Local\NTP+'u''.
+
Public access assigns a NULL DACL to the memory mapping, while private
access just uses the default DACL of the process creating the mapping.
+
* Unix creates a shared memory segment with a key value of
\0x4E545030+_u_, where _u_ is again the clock unit. (This value could
be hex-decoded as \'NTP0', \'NTP1',..., with funny characters for units >
9.)
+
The driver attempts to create a shared memory segment with an
identifier depending on the unit number. Unix creates a shared memory
segment with a key value of \0x4E545030+_u_, where _u_ is again the
clock unit. (This value could be hex-decoded as \'NTP0', \'NTP1',...,
with funny characters for units > 9.)
Public access means a permission set of 0666, while private access
creates the mapping with a permission set of 0600.
......@@ -231,12 +220,6 @@ SHM segment owned by the runtime-user account. The internal structure of
this is the reason why a mode bit is used for the configuration of a
public segment.
When running under Windows, the chosen user account must be able to
create a SHM segment in the global object name space for SHM clocks with
public access. Otherwise the session isolation used by Windows kernels
after WinXP will get into the way if the client program does not run in
the same session.
== Additional Information ==
link:refclock.html[Reference Clock Drivers]
......
......@@ -45,7 +45,6 @@ hardware platforms:
|=============================================================================
| Platform | Operating System | NTP Sources | Accuracy
| i386 (PC) | Linux | NTP Distribution |10 us
| i386 (PC) | Windows NT | ftp://ftp.trimble.com/pub/ntp|1 ms
| SUN | Solaris 2.x | NTP Distribution |50 us
| Hewlett-Packard | HPUX 9, 10, 11 | http://us-support.external.hp.com|50 us
| Various | Free BSD | NTP Distribution |20 us
......@@ -114,10 +113,6 @@ port device. This is typically performed by a command such as:
ln -s /dev/ttyS0 /dev/trimble0
---------------------------------
Windows NT does not support symbolic links to device files. COM**x**: is
used by the driver, based on the refclock unit number, where unit 1
corresponds to COM**1**: and unit 3 corresponds to COM**3**:.
The Palisade ships 8N1 (no parity). The Thunderbolt ships 8O1 (odd
parity).
......
......@@ -187,13 +187,6 @@ the configuration file +interface+ command, which is more versatile.
Registers as an NTP server with the local mDNS server which allows the
server to be discovered via mDNS client lookup.
+-M+, +--modifymmtimer+::
Modify Multimedia Timer (Windows only).
+
Set the Windows Multimedia Timer to highest resolution. This ensures
the resolution does not change while {ntpd} is running, avoiding
timekeeping glitches associated with changes.
+-n+, +--nofork+::
Do not fork. This option must not appear in combination with any of
the following options: wait-sync.
......@@ -299,21 +292,6 @@ discipline is disabled with this option.
make ARG an ntp variable (RW|DEF). This option may appear an unlimited
number of times.
//+--usepcc+::
// Use CPU cycle counter (Windows only).
//+
//Attempt to substitute the CPU counter for _QueryPerformanceCounter_.
//The CPU counter and _QueryPerformanceCounter_ are compared, and if
//they have the same frequency, the CPU counter (RDTSC on x86) is used
//directly, saving the overhead of a system call.
//+--pccfreq+=_string_::
// Force CPU cycle counter use (Windows only).
//+
//Force substitution the CPU counter for _QueryPerformanceCounter_. The
//CPU counter (RDTSC on x86) is used unconditionally with the given
//frequency (in Hz).
+-V, --version+::
Output version of program and exit. -VV gives more detailed version
information.
......
......@@ -224,6 +224,11 @@ Unix will also serve. The OS must have either a Linux-like
adjtimex(2) call or a BSD-like pair of ntp_gettime(2)/ntp_adjtime(2)
calls.
Legacy Windows support has been removed from the {project-shortname}
codebase. Future Windows support will be conditional on the quality
of POSIX/C99 emulation environments such as Cygwin and/or the support
for Linux binary execution in Windows 10 and later.
If you have a requirement for time service on an OS we don't support,
and its API is reasonably close to our POSIX/C99 conformance baseline,
we'll try to meet you halfway. We're open to development partnerships
......
......@@ -19,7 +19,7 @@ A leap second is inserted following second 59 of the last minute of the
day and becomes second 60 of that day. A leap second is deleted by
omitting second 59 of the last minute of the day, although this has
never happened and is highly unlikely to happen in future. So far as is
known, there are no provisions in the Unix or Windows libraries to
known, there are no provisions in the Unix libraries to
account for this occasion other than to affect the conversion of an NTP
datestamp or timestamp to conventional civil time.
......
......@@ -50,16 +50,6 @@ though this mechanism has been available for about 20 years' time, almost
nobody uses it.
== NTP Client for Windows Contains a Workaround ==
The Windows system time knows nothing about leap seconds, so for many years
the Windows port of ntpd provides a workaround where the system time is
slewed by the client to compensate the leap second.
Thus it is not required to use a smearing NTP server for Windows clients,
but of course the smearing server approach also works.
== The Leap Smear Approach ==
Due to the reasons mentioned above some support for leap smearing has
......
......@@ -112,7 +112,7 @@ initially within 68 years of the correct time. Further discussion on
this issue is in the white paper
{millshome}time.html[NTP Timestamp Calculations].
Ordinarily, these formats are not seen by application programs, which
convert these NTP formats to native Unix or Windows formats.
convert these NTP formats to native formats.
[[arch]]
== 3. Architecture and Algorithms ==
......
......@@ -18,13 +18,7 @@
* Configuration file name
*/
#ifndef CONFIG_FILE
# ifndef SYS_WINNT
# define CONFIG_FILE "/etc/ntp.conf"
# else /* SYS_WINNT */
# define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf"
# define ALT_CONFIG_FILE "%windir%\\ntp.conf"
# define NTP_KEYSDIR "%windir%\\system32\\drivers\\etc"
# endif /* SYS_WINNT */
#endif /* not CONFIG_FILE */
/* Limits */
......
......@@ -380,36 +380,4 @@ extern bool adj_systime (double, int (*adjtime)(const struct timeval *, struct t
typedef void (*time_stepped_callback)(void);
extern time_stepped_callback step_callback;
/*
* Multi-thread locking for get_systime()
*
* On most systems, get_systime() is used solely by the main ntpd
* thread, but on Windows it's also used by the dedicated I/O thread.
* The [Bug 2037] changes to get_systime() have it keep state between
* calls to ensure time moves in only one direction, which means its
* use on Windows needs to be protected against simultaneous execution
* to avoid falsely detecting Lamport violations by ensuring only one
* thread at a time is in get_systime().
*/
#ifdef SYS_WINNT
extern CRITICAL_SECTION get_systime_cs;
# define INIT_GET_SYSTIME_CRITSEC() \
InitializeCriticalSection(&get_systime_cs)
# define ENTER_GET_SYSTIME_CRITSEC() \
EnterCriticalSection(&get_systime_cs)
# define LEAVE_GET_SYSTIME_CRITSEC() \
LeaveCriticalSection(&get_systime_cs)
# define INIT_WIN_PRECISE_TIME() \
init_win_precise_time()
#else /* !SYS_WINNT follows */
# define INIT_GET_SYSTIME_CRITSEC() \
do {} while (false)
# define ENTER_GET_SYSTIME_CRITSEC() \
do {} while (false)
# define LEAVE_GET_SYSTIME_CRITSEC() \
do {} while (false)
# define INIT_WIN_PRECISE_TIME() \
do {} while (false)
#endif
#endif /* GUARD_NTP_FP_H */
......@@ -13,11 +13,6 @@
#include <fcntl.h>
#include <netinet/in.h>
#ifdef SYS_WINNT
# include <io.h>
# include "win32_io.h"
#endif
#include <isc/netaddr.h>
#include "libntp.h" /* This needs Something above for GETDTABLESIZE */
......
......@@ -146,13 +146,8 @@ typedef union {
sizeof(pin6A)->s6_addr)
/* compare two in6_addr for equality only */
#if !defined(SYS_WINNT) || !defined(in_addr6)
#define ADDR6_EQ(pin6A, pin6B) \
(!ADDR6_CMP(pin6A, pin6B))
#else
#define ADDR6_EQ(pin6A, pin6B) \
IN6_ADDR_EQUAL(pin6A, pin6B)
#endif
/* compare a in6_addr with socket address */
#define S_ADDR6_EQ(psau, pin6) \
......
......@@ -157,10 +157,6 @@ struct addrinfo *copy_addrinfo_list_impl(const struct addrinfo *
#ifndef ISC_PLATFORM_HAVEIPV6
#ifdef SYS_WINNT
# define in6_addr in_addr6
#endif
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
......
......@@ -35,9 +35,7 @@
#define LDISC_7O1 0x100 /* 7-bit, odd parity for Z3801A */
/* function prototypes for ntp_tty.c */
#if !defined(SYS_WINNT)
extern int ntp_tty_setup(int, u_int, u_int);
extern int ntp_tty_ioctl(int, u_int);
#endif
#endif /* GUARD_NTP_TTY_H */
......@@ -111,40 +111,10 @@ aligned_ptr(
*/
#define NONEMPTY_TRANSLATION_UNIT extern void exit(int);
/*
* On Unix struct sock_timeval is equivalent to struct timeval.
* On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
* as required by Windows' socket() interface timeout argument, while
* timeval.tv_sec is time_t for the more common use as a UTC time
* within NTP.
*/
#ifndef SYS_WINNT
#define sock_timeval timeval
#endif
/*
* On Unix open() works for tty (serial) devices just fine, while on
* Windows refclock serial devices are opened using CreateFile, a lower
* level than the CRT-provided descriptors, because the C runtime lacks
* tty APIs. For refclocks which wish to use open() as well as or
* instead of refclock_open(), tty_open() is equivalent to open() on
* Unix and implemented in the Windows port similarly to
* refclock_open().
* Similarly, the termios emulation in the Windows code needs to know
* about serial ports being closed, while the Posix systems do not.
*/
#ifndef SYS_WINNT
# define tty_open(f, a, m) open(f, a, m)
# define closeserial(fd) close(fd)
# define closesocket(fd) close(fd)
typedef int SOCKET;
# define INVALID_SOCKET (-1)
# define SOCKET_ERROR (-1)
# define socket_errno() (errno)
#else /* SYS_WINNT follows */
# define socket_errno() (errno = WSAGetLastError())
#endif
#endif /* GUARD_NTP_TYPES_H */
......@@ -9,15 +9,11 @@
* threads implementation of ntp_intres. Such systems are limited
* to using numeric IP addresses.
*/
#if defined(SYS_WINNT)
# define USE_WORK_THREAD
#else
# define USE_WORK_THREAD
# define USE_WORK_PIPE
#endif
#define USE_WORK_THREAD
#define USE_WORK_PIPE
#if defined(USE_WORK_THREAD)
/* Guards are not strictly necessary, bit keep them as documentation */
/* Guards are not strictly necessary, but keep them as documentation */
# define USE_WORKER
#endif
......
......@@ -47,11 +47,6 @@
#endif
/* nt_clockstuff.c */
#ifdef SYS_WINNT
extern void win_time_stepped(void);
#endif
/* ntp_config.c */
#define TAI_1972 10 /* initial TAI offset (s) */
extern char *keysdir; /* crypto keys and leaptable directory */
......@@ -459,9 +454,6 @@ extern bool leap_sec_in_progress;
extern struct leap_smear_info leap_smear;
extern int leap_smear_intv;
#endif
#ifdef SYS_WINNT
HANDLE WaitableTimerHandle;
#endif
/* ntp_util.c */
extern char statsdir[MAXFILENAME];
......@@ -484,11 +476,6 @@ extern int waitsync_fd_to_close; /* -w/--wait-sync */
#endif
extern void finish (int sig);
/* ntservice.c */
#ifdef SYS_WINNT
extern int accept_wildcard_if_for_winnt;
#endif
/* refclock_conf.c */
#ifdef REFCLOCK
/* refclock configuration table */
......
/*
* include/ssl_applink.c -- common NTP code for openssl/applink.c
*
* Each program which uses OpenSSL should include this file in _one_
* of its source files and call ssl_applink() before any OpenSSL
* functions.
*/
#if defined(HAVE_OPENSSL) && defined(SYS_WINNT)
# ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4152)
# endif
# include <openssl/applink.c>
# ifdef _MSC_VER
# pragma warning(pop)
# endif
#endif
#if defined(HAVE_OPENSSL) && defined(_MSC_VER) && defined(_DEBUG)
#define WRAP_DBG_MALLOC
#endif
#ifdef WRAP_DBG_MALLOC
void *wrap_dbg_malloc(size_t s, const char *f, int l);
void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l);
void wrap_dbg_free(void *p);
#endif
#if defined(HAVE_OPENSSL) && defined(SYS_WINNT)
void ssl_applink(void);
void
ssl_applink(void)
{
#ifdef WRAP_DBG_MALLOC
CRYPTO_set_mem_ex_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free);
#else
CRYPTO_malloc_init();
#endif
}
#else /* !HAVE_OPENSSL || !SYS_WINNT */
#define ssl_applink() do {} while (0)
#endif
#ifdef WRAP_DBG_MALLOC
/*
* OpenSSL malloc overriding uses different parameters
* for DEBUG malloc/realloc/free (lacking block type).
* Simple wrappers convert.
*/
void *wrap_dbg_malloc(size_t s, const char *f, int l)
{
void *ret;
ret = _malloc_dbg(s, _NORMAL_BLOCK, f, l);
return ret;
}
void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l)
{
void *ret;
ret = _realloc_dbg(p, s, _NORMAL_BLOCK, f, l);
return ret;
}
void wrap_dbg_free(void *p)
{
_free_dbg(p, _NORMAL_BLOCK);
}
#endif /* WRAP_DBG_MALLOC */
/*
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2001 Internet Software Consortium.
* Copyright 2015 by the NTPsec project contributors
* SPDX-License-Identifier: ISC
*/
#include <windows.h>
#include <stdio.h>
/*
* Called when we enter the DLL
*/
__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
/*
* The DLL is loading due to process
* initialization or a call to LoadLibrary.
*/
case DLL_PROCESS_ATTACH:
break;
/* The attached process creates a new thread. */
case DLL_THREAD_ATTACH:
break;
/* The thread of the attached process terminates. */
case DLL_THREAD_DETACH:
break;
/*
* The DLL is unloading from a process due to
* process termination or a call to FreeLibrary.
*/
case DLL_PROCESS_DETACH:
break;
default:
break;
}
return (TRUE);
}
/*
* Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2002 Internet Software Consortium.
* Copyright 2015 by the NTPsec project contributors
* SPDX-License-Identifier: ISC
*/
#include <config.h>
#include <winsock2.h>
#include "errno2result.h"
#include <isc/result.h>
#include <isc/util.h>
/*
* Convert a POSIX errno value into an isc_result_t. The
* list of supported errno values is not complete; new users
* of this function should add any expected errors that are
* not already there.
*/
isc_result_t
isc__errno2resultx(int posixerrno, const char *file, int line) {
char strbuf[BUFSIZ];
switch (posixerrno) {
case ENOTDIR:
case WSAELOOP:
case WSAEINVAL:
case EINVAL: /* XXX sometimes this is not for files */
case ENAMETOOLONG:
case WSAENAMETOOLONG:
case EBADF:
case WSAEBADF:
return (ISC_R_INVALIDFILE);
case ENOENT:
return (ISC_R_FILENOTFOUND);
case EACCES:
case WSAEACCES:
case EPERM:
return (ISC_R_NOPERM);
case EEXIST:
return (ISC_R_FILEEXISTS);
case EIO:
return (ISC_R_IOERROR);
case ENOMEM:
return (ISC_R_NOMEMORY);
case ENFILE:
case EMFILE:
case WSAEMFILE:
return (ISC_R_TOOMANYOPENFILES);
case ERROR_CANCELLED:
return (ISC_R_CANCELED);
case ERROR_CONNECTION_REFUSED:
case WSAECONNREFUSED:
return (ISC_R_CONNREFUSED);
case WSAENOTCONN: