Version 1.02 changes
This commit is contained in:
parent
9a2f08fca2
commit
ae659b1879
12
compiler.h
12
compiler.h
|
@ -33,7 +33,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See also:
|
* See also:
|
||||||
|
@ -51,10 +50,6 @@
|
||||||
typedef uint32_t register_t;
|
typedef uint32_t register_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AROS
|
|
||||||
# define HAVE_WAITSELECT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
# if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
@ -75,19 +70,12 @@ typedef uint32_t register_t;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _ALIGNBYTES
|
|
||||||
# define _ALIGNBYTES (sizeof(register_t) - 1)
|
|
||||||
# define ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define HAVE_ASCTIME
|
# define HAVE_ASCTIME
|
||||||
typedef uint16_t in_port_t;
|
typedef uint16_t in_port_t;
|
||||||
typedef unsigned int sa_family_t;
|
typedef unsigned int sa_family_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Is this needed since we dont use IPv6 ?
|
|
||||||
|
|
||||||
// General socket address holding structure, big enough to hold either
|
// General socket address holding structure, big enough to hold either
|
||||||
// struct sockaddr_in or struct sockaddr_in6 data:
|
// struct sockaddr_in or struct sockaddr_in6 data:
|
||||||
struct sockaddr_storage {
|
struct sockaddr_storage {
|
||||||
|
|
|
@ -172,12 +172,12 @@ if $VALID ; then
|
||||||
echo 'all: ntimed ntimed-poll ntimed-sim ntimed-test'
|
echo 'all: ntimed ntimed-poll ntimed-sim ntimed-test'
|
||||||
echo ''
|
echo ''
|
||||||
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
||||||
echo 'CC = gcc'
|
echo 'CC = m68k-amigaos-gcc'
|
||||||
echo "CFLAGS = -O2 -DAOS3 -DWITHTEST -I. -Wall -Werror"
|
echo "CFLAGS = -O2 -noixemul -DAOS3 -DWITHTEST -DHAVE_LIBTZ -I. -Ilib -Wall -Werror"
|
||||||
echo "LDLIBS = -Llib/aos3 -ltz -lm"
|
echo "LDLIBS = -Llib/aos3 -ltz -lm"
|
||||||
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
|
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
|
||||||
echo 'CC = gcc'
|
echo 'CC = gcc'
|
||||||
echo "CFLAGS = -O2 -DAROS -DWITHTEST -I. -Wall -Werror"
|
echo "CFLAGS = -O2 -DAROS -DWITHTEST -DHAVE_LIBTZ -I. -Ilib -Wall -Werror"
|
||||||
echo "LDLIBS = -Llib/aros-i386 -ltz -lm"
|
echo "LDLIBS = -Llib/aros-i386 -ltz -lm"
|
||||||
else
|
else
|
||||||
echo "CFLAGS = -O2 -Wall -DWITHTEST -Werror"
|
echo "CFLAGS = -O2 -Wall -DWITHTEST -Werror"
|
||||||
|
|
BIN
lib/aos3/libtz.a
BIN
lib/aos3/libtz.a
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,201 @@
|
||||||
|
#ifndef _INLINE_AMITCP_H
|
||||||
|
#define _INLINE_AMITCP_H
|
||||||
|
|
||||||
|
#ifndef __INLINE_MACROS_H
|
||||||
|
#include <inline/macros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AMITCP_BASE_NAME
|
||||||
|
#define AMITCP_BASE_NAME lss->lx_BsdSocketBase
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TCP_Accept(s, addr, addrlen) \
|
||||||
|
LP3(0x30, LONG, TCP_Accept, LONG, s, d0, struct sockaddr *, addr, a0, int *, addrlen, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Bind(s, name, namelen) \
|
||||||
|
LP3(0x24, LONG, TCP_Bind, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_CloseSocket(d) \
|
||||||
|
LP1(0x78, LONG, TCP_CloseSocket, LONG, d, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Connect(s, name, namelen) \
|
||||||
|
LP3(0x36, LONG, TCP_Connect, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Dup2Socket(fd1, fd2) \
|
||||||
|
LP2(0x108, LONG, TCP_Dup2Socket, LONG, fd1, d0, LONG, fd2, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Errno() \
|
||||||
|
LP0(0xa2, LONG, TCP_Errno, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetDTableSize() \
|
||||||
|
LP0(0x8a, LONG, TCP_GetDTableSize, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetHostByAddr(addr, len, type) \
|
||||||
|
LP3(0xd8, struct hostent *, TCP_GetHostByAddr, const UBYTE *, addr, a0, LONG, len, d0, LONG, type, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetHostByName(name) \
|
||||||
|
LP1(0xd2, struct hostent *, TCP_GetHostByName, const UBYTE *, name, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetHostId() \
|
||||||
|
LP0(0x120, ULONG, TCP_GetHostId, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetHostName(hostname, size) \
|
||||||
|
LP2(0x11a, LONG, TCP_GetHostName, STRPTR, hostname, a0, LONG, size, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetNetByAddr(net, type) \
|
||||||
|
LP2(0xe4, struct netent *, TCP_GetNetByAddr, LONG, net, d0, LONG, type, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetNetByName(name) \
|
||||||
|
LP1(0xde, struct netent *, TCP_GetNetByName, const UBYTE *, name, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetPeerName(s, hostname, namelen) \
|
||||||
|
LP3(0x6c, LONG, TCP_GetPeerName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetProtoByName(name) \
|
||||||
|
LP1(0xf6, struct protoent *, TCP_GetProtoByName, const UBYTE *, name, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetProtoByNumber(proto) \
|
||||||
|
LP1(0xfc, struct protoent *, TCP_GetProtoByNumber, LONG, proto, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetServByName(name, proto) \
|
||||||
|
LP2(0xea, struct servent *, TCP_GetServByName, const UBYTE *, name, a0, const UBYTE *, proto, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetServByPort(port, proto) \
|
||||||
|
LP2(0xf0, struct servent *, TCP_GetServByPort, LONG, port, d0, const UBYTE *, proto, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetSockName(s, hostname, namelen) \
|
||||||
|
LP3(0x66, LONG, TCP_GetSockName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetSockOpt(s, level, optname, optval, optlen) \
|
||||||
|
LP5(0x60, LONG, TCP_GetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, void *, optval, a0, int *, optlen, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_GetSocketEvents(eventmaskp) \
|
||||||
|
LP1(0x12c, LONG, TCP_GetSocketEvents, ULONG *, eventmaskp, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_Addr(cp) \
|
||||||
|
LP1(0xb4, ULONG, TCP_Inet_Addr, const UBYTE *, cp, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_LnaOf(in) \
|
||||||
|
LP1(0xba, ULONG, TCP_Inet_LnaOf, LONG, in, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_MakeAddr(net, host) \
|
||||||
|
LP2(0xc6, ULONG, TCP_Inet_MakeAddr, ULONG, net, d0, ULONG, host, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_NetOf(in) \
|
||||||
|
LP1(0xc0, ULONG, TCP_Inet_NetOf, LONG, in, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_Network(cp) \
|
||||||
|
LP1(0xcc, ULONG, TCP_Inet_Network, const UBYTE *, cp, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Inet_NtoA(in) \
|
||||||
|
LP1(0xae, char *, TCP_Inet_NtoA, ULONG, in, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_IoctlSocket(d, request, argp) \
|
||||||
|
LP3(0x72, LONG, TCP_IoctlSocket, LONG, d, d0, ULONG, request, d1, char *, argp, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Listen(s, backlog) \
|
||||||
|
LP2(0x2a, LONG, TCP_Listen, LONG, s, d0, LONG, backlog, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_ObtainSocket(id, domain, type, protocol) \
|
||||||
|
LP4(0x90, LONG, TCP_ObtainSocket, LONG, id, d0, LONG, domain, d1, LONG, type, d2, LONG, protocol, d3, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Recv(s, buf, len, flags) \
|
||||||
|
LP4(0x4e, LONG, TCP_Recv, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_RecvFrom(s, buf, len, flags, from, fromlen) \
|
||||||
|
LP6(0x48, LONG, TCP_RecvFrom, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, struct sockaddr *, from, a1, int *, fromlen, a2, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_RecvMsg(s, msg, flags) \
|
||||||
|
LP3(0x114, LONG, TCP_RecvMsg, LONG, s, d0, struct msghdr *, msg, a0, LONG, flags, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_ReleaseCopyOfSocket(fd, id) \
|
||||||
|
LP2(0x9c, LONG, TCP_ReleaseCopyOfSocket, LONG, fd, d0, LONG, id, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_ReleaseSocket(fd, id) \
|
||||||
|
LP2(0x96, LONG, TCP_ReleaseSocket, LONG, fd, d0, LONG, id, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Send(s, msg, len, flags) \
|
||||||
|
LP4(0x42, LONG, TCP_Send, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SendMsg(s, msg, flags) \
|
||||||
|
LP3(0x10e, LONG, TCP_SendMsg, LONG, s, d0, const struct msghdr *, msg, a0, LONG, flags, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SendTo(s, msg, len, flags, to, tolen) \
|
||||||
|
LP6(0x3c, LONG, TCP_SendTo, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, const struct sockaddr *, to, a1, LONG, tolen, d3, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SetErrnoPtr(errno_p, size) \
|
||||||
|
LP2(0xa8, LONG, TCP_SetErrnoPtr, void *, errno_p, a0, LONG, size, d0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SetSockOpt(s, level, optname, optval, optlen) \
|
||||||
|
LP5(0x5a, LONG, TCP_SetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, const void *, optval, a0, LONG, optlen, d3, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SetSocketSignals(SIGINTR, SIGIO, SIGURG) \
|
||||||
|
LP3NR(0x84, TCP_SetSocketSignals, ULONG, SIGINTR, d0, ULONG, SIGIO, d1, ULONG, SIGURG, d2, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_ShutDown(s, how) \
|
||||||
|
LP2(0x54, LONG, TCP_ShutDown, LONG, s, d0, LONG, how, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_Socket(domain, type, protocol) \
|
||||||
|
LP3(0x1e, LONG, TCP_Socket, LONG, domain, d0, LONG, type, d1, LONG, protocol, d2, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_SocketBaseTagList(taglist) \
|
||||||
|
LP1(0x126, LONG, TCP_SocketBaseTagList, struct TagItem *, taglist, a0, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#ifndef NO_INLINE_STDARG
|
||||||
|
#define TCP_SocketBaseTags(tags...) \
|
||||||
|
({ULONG _tags[] = { tags }; TCP_SocketBaseTagList((struct TagItem *)_tags);})
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TCP_SyslogA(level, format, ap) \
|
||||||
|
LP3NR(0x102, TCP_SyslogA, ULONG, level, d0, const char *, format, a0, va_list, ap, a1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#define TCP_WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp) \
|
||||||
|
LP6(0x7e, LONG, TCP_WaitSelect, LONG, nfds, d0, fd_set *, readfds, a0, fd_set *, writefds, a1, fd_set *, execptfds, a2, struct timeval *, timeout, a3, ULONG *, maskp, d1, \
|
||||||
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Carsten Larsen
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SOCKET_AMITCP_H
|
||||||
|
#define _SOCKET_AMITCP_H
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#define AMITCP_BASE_NAME SocketBase
|
||||||
|
#include "inline_amitcp.h"
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#define socket Socket
|
||||||
|
#define bind Bind
|
||||||
|
#define listen Listen
|
||||||
|
#define accept Accept
|
||||||
|
#define connect Connect
|
||||||
|
#define send Send
|
||||||
|
#define sendto SendTo
|
||||||
|
#define sendmsg SendMsg
|
||||||
|
#define recv Recv
|
||||||
|
#define recvfrom RecvFrom
|
||||||
|
#define recvmsg RecvMsg
|
||||||
|
#define shutdown Shutdown
|
||||||
|
#define setsockopt SetSockOpt
|
||||||
|
#define getsockopt GetSockOpt
|
||||||
|
#define getsockname GetSockName
|
||||||
|
#define getpeername GetPeerName
|
||||||
|
#define inet_addr Inet_Addr
|
||||||
|
#define inet_network Inet_Network
|
||||||
|
#define inet_ntoa Inet_NtoA
|
||||||
|
#define gethostbyname GetHostByName
|
||||||
|
#define gethostbyaddr GetHostByAddr
|
||||||
|
#define getnetbyname GetNetByName
|
||||||
|
#define getnetbyaddr GetNetByAddr
|
||||||
|
#define getservbyname GetServByName
|
||||||
|
#define getservbyport GetServByPort
|
||||||
|
#define getprotobyname GetProtoByName
|
||||||
|
#define getprotobynumber GetProtoByNumber
|
||||||
|
#define getdtablesize GetDTableSize
|
||||||
|
#define gethostname GetHostName
|
||||||
|
#define gethostid GetHostId
|
||||||
|
#define vsyslog SyslogA
|
||||||
|
#define syslog Syslog
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#define Accept TCP_Accept
|
||||||
|
#define Bind TCP_Bind
|
||||||
|
#define CloseSocket TCP_CloseSocket
|
||||||
|
#define Connect TCP_Connect
|
||||||
|
#define Dup2Socket TCP_Dup2Socket
|
||||||
|
#define Errno TCP_Errno
|
||||||
|
#define GetDTableSize TCP_GetDTableSize
|
||||||
|
#define GetHostByAddr TCP_GetHostByAddr
|
||||||
|
#define GetHostByName TCP_GetHostByName
|
||||||
|
#define GetHostId TCP_GetHostId
|
||||||
|
#define GetHostName TCP_GetHostName
|
||||||
|
#define GetNetByAddr TCP_GetNetByAddr
|
||||||
|
#define GetNetByName TCP_GetNetByName
|
||||||
|
#define GetPeerName TCP_GetPeerName
|
||||||
|
#define GetProtoByName TCP_GetProtoByName
|
||||||
|
#define GetProtoByNumber TCP_GetProtoByNumber
|
||||||
|
#define GetServByName TCP_GetServByName
|
||||||
|
#define GetServByPort TCP_GetServByPort
|
||||||
|
#define GetSockName TCP_GetSockName
|
||||||
|
#define GetSockOpt TCP_GetSockOpt
|
||||||
|
#define GetSocketEvents TCP_GetSocketEvents
|
||||||
|
#define Inet_Addr TCP_Inet_Addr
|
||||||
|
#define Inet_LnaOf TCP_Inet_LnaOf
|
||||||
|
#define Inet_MakeAddr TCP_Inet_MakeAddr
|
||||||
|
#define Inet_NetOf TCP_Inet_NetOf
|
||||||
|
#define Inet_Network TCP_Inet_Network
|
||||||
|
#define Inet_NtoA TCP_Inet_NtoA
|
||||||
|
#define IoctlSocket TCP_IoctlSocket
|
||||||
|
#define Listen TCP_Listen
|
||||||
|
#define ObtainSocket TCP_ObtainSocket
|
||||||
|
#define Recv TCP_Recv
|
||||||
|
#define RecvFrom TCP_RecvFrom
|
||||||
|
#define RecvMsg TCP_RecvMsg
|
||||||
|
#define ReleaseCopyOfSocket TCP_ReleaseCopyOfSocket
|
||||||
|
#define ReleaseSocket TCP_ReleaseSocket
|
||||||
|
#define Send TCP_Send
|
||||||
|
#define SendMsg TCP_SendMsg
|
||||||
|
#define SendTo TCP_SendTo
|
||||||
|
#define SetErrnoPtr TCP_SetErrnoPtr
|
||||||
|
#define SetSockOpt TCP_SetSockOpt
|
||||||
|
#define SetSocketSignals TCP_SetSocketSignals
|
||||||
|
#define ShutDown TCP_ShutDown
|
||||||
|
#define Socket TCP_Socket
|
||||||
|
#define SocketBaseTagList TCP_SocketBaseTagList
|
||||||
|
#define SocketBaseTags TCP_SocketBaseTags
|
||||||
|
#define SyslogA TCP_SyslogA
|
||||||
|
#define WaitSelect TCP_WaitSelect
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#endif
|
62
lib/tz.h
62
lib/tz.h
|
@ -43,9 +43,16 @@
|
||||||
* ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/include/time.h
|
* ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/include/time.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _TZ_HEADER
|
||||||
|
#define _TZ_HEADER
|
||||||
|
|
||||||
extern char *tzname[2];
|
extern char *tzname[2];
|
||||||
|
|
||||||
struct tz_tm {
|
#define TZVARIABLE "timezone.prefs"
|
||||||
|
#define TZDIR "LOCALE:Zoneinfo"
|
||||||
|
#define TZDEFAULT "localtime"
|
||||||
|
|
||||||
|
struct tm {
|
||||||
int tm_sec; /* seconds after the minute [0-61] */
|
int tm_sec; /* seconds after the minute [0-61] */
|
||||||
int tm_min; /* minutes after the hour [0-59] */
|
int tm_min; /* minutes after the hour [0-59] */
|
||||||
int tm_hour; /* hours since midnight [0-23] */
|
int tm_hour; /* hours since midnight [0-23] */
|
||||||
|
@ -59,42 +66,31 @@ struct tz_tm {
|
||||||
char *tm_zone; /* timezone abbreviation */
|
char *tm_zone; /* timezone abbreviation */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef long tz_time_t;
|
#ifndef HAVE_TIME_T
|
||||||
|
typedef long time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct state *timezone_t;
|
typedef struct state *timezone_t;
|
||||||
|
|
||||||
void tz_tzset(void);
|
void tzset(void);
|
||||||
void tz_free(const timezone_t);
|
void tzfree(const timezone_t);
|
||||||
timezone_t tz_alloc(const char *);
|
timezone_t tzalloc(const char *);
|
||||||
tz_time_t tz_time(tz_time_t *);
|
time_t time(time_t *);
|
||||||
tz_time_t tz_mktime_z(const timezone_t, struct tz_tm *);
|
time_t mktime_z(const timezone_t, struct tm *);
|
||||||
tz_time_t tz_mktime(struct tz_tm *);
|
time_t mktime(struct tm *);
|
||||||
struct tz_tm *tz_localtime_rz(const timezone_t, const tz_time_t *, struct tz_tm *);
|
struct tm *localtime_rz(const timezone_t, const time_t *, struct tm *);
|
||||||
struct tz_tm *tz_localtime_r(const tz_time_t *, struct tz_tm *);
|
struct tm *localtime_r(const time_t *, struct tm *);
|
||||||
struct tz_tm *tz_localtime(const tz_time_t *);
|
struct tm *localtime(const time_t *);
|
||||||
struct tz_tm *tz_gmtime_r(const tz_time_t *, struct tz_tm *);
|
struct tm *gmtime_r(const time_t *, struct tm *);
|
||||||
struct tz_tm *tz_gmtime(const tz_time_t *);
|
struct tm *gmtime(const time_t *);
|
||||||
char *tz_ctime_r(const tz_time_t *, char *);
|
char *ctime_r(const time_t *, char *);
|
||||||
char *tz_ctime(const tz_time_t *);
|
char *ctime(const time_t *);
|
||||||
char *asctime_r(const struct tz_tm *, char *);
|
double difftime(time_t, time_t);
|
||||||
double tz_difftime(tz_time_t, tz_time_t);
|
time_t time(time_t *x);
|
||||||
|
|
||||||
#ifndef HAVE_ASCTIME
|
#ifndef HAVE_ASCTIME
|
||||||
char *asctime(const struct tz_tm *);
|
char *asctime_r(const struct tm *, char *);
|
||||||
|
char *asctime(const struct tm *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tz_time_t time(tz_time_t *x);
|
|
||||||
|
|
||||||
#ifdef HAVENOSYSTIME
|
|
||||||
#include <clib/timer_protos.h>
|
|
||||||
tz_time_t time(tz_time_t *x)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
GetSysTime(&tv);
|
|
||||||
|
|
||||||
if (x) {
|
|
||||||
*x = (time_t)tv.tv_secs;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (time_t)tv.tv_secs;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,15 +25,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include <proto/exec.h>
|
|
||||||
|
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,SERVERS/M/A,SYNC/S,SAVE/S,SHOW/S,QUIET/S"
|
#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,SERVERS/M/A,SYNC/S,SAVE/S,SHOW/S,QUIET/S"
|
||||||
const char *vers = "\0$VER: ntimed-client 1.01 (18.04.2015)";
|
const char *vers = "\0$VER: ntimed-client" AMIGA_VERSION;
|
||||||
|
|
||||||
#define PARAM_CLIENT PARAM_INSTANCE
|
#define PARAM_CLIENT PARAM_INSTANCE
|
||||||
#define PARAM_TABLE_NAME client_param_table
|
#define PARAM_TABLE_NAME client_param_table
|
||||||
|
@ -42,12 +40,11 @@ const char *vers = "\0$VER: ntimed-client 1.01 (18.04.2015)";
|
||||||
#undef PARAM_CLIENT
|
#undef PARAM_CLIENT
|
||||||
|
|
||||||
extern int validtime;
|
extern int validtime;
|
||||||
|
struct RDArgs *rdargs = NULL;
|
||||||
|
struct ntp_peerset *nps = NULL;
|
||||||
|
struct todolist *tdl = NULL;
|
||||||
|
struct udp_socket *usc = NULL;
|
||||||
int savetime;
|
int savetime;
|
||||||
int started_from_wb;
|
|
||||||
struct RDArgs *rdargs = NULL;
|
|
||||||
struct ntp_peerset *nps = NULL;
|
|
||||||
struct todolist *tdl = NULL;
|
|
||||||
struct udp_socket *usc = NULL;
|
|
||||||
|
|
||||||
struct ntimedargs {
|
struct ntimedargs {
|
||||||
char *params;
|
char *params;
|
||||||
|
@ -64,30 +61,19 @@ static void clean_exit();
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct ntimedargs args = {
|
int result = 0;
|
||||||
NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE
|
struct ntimedargs args = { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE };
|
||||||
};
|
|
||||||
|
atexit(clean_exit);
|
||||||
|
if((result = amiga_open_libs()) != 0) {
|
||||||
|
exit(result);
|
||||||
|
}
|
||||||
|
|
||||||
started_from_wb = (argc == 0);
|
rdargs = ReadArgs((STRPTR)ARGSFORMAT, (APTR)&args, NULL);
|
||||||
atexit(clean_exit);
|
if (!rdargs)
|
||||||
|
{
|
||||||
if(started_from_wb) {
|
PrintFault(IoErr(), (STRPTR)argv[0]);
|
||||||
args.servers = (char *[]) {
|
exit(5);
|
||||||
"0.pool.ntp.org",
|
|
||||||
"1.pool.ntp.org",
|
|
||||||
"2.pool.ntp.org",
|
|
||||||
"3.pool.ntp.org"
|
|
||||||
};
|
|
||||||
args.synchronize = TRUE;
|
|
||||||
args.save = TRUE;
|
|
||||||
args.quiet = TRUE;
|
|
||||||
} else {
|
|
||||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
|
||||||
if (!rdargs)
|
|
||||||
{
|
|
||||||
PrintFault(IoErr(), (ARGPTR)argv[0]);
|
|
||||||
exit(5);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.quiet) {
|
if (!args.quiet) {
|
||||||
|
@ -98,8 +84,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amiga_open_libs();
|
|
||||||
|
|
||||||
if (args.tracefile) {
|
if (args.tracefile) {
|
||||||
ArgTracefile(args.tracefile);
|
ArgTracefile(args.tracefile);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +99,7 @@ int main(int argc, char **argv)
|
||||||
NTP_PeerSet_Poll(NULL, nps, usc, tdl);
|
NTP_PeerSet_Poll(NULL, nps, usc, tdl);
|
||||||
(void)TODO_Run(NULL, tdl);
|
(void)TODO_Run(NULL, tdl);
|
||||||
|
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_params(char *params)
|
static void set_params(char *params)
|
||||||
|
@ -186,6 +170,8 @@ static void init_logic(struct ntimedargs *args)
|
||||||
} else {
|
} else {
|
||||||
Put(NULL, OCX_DEBUG, "Synchronizing ...\n");
|
Put(NULL, OCX_DEBUG, "Synchronizing ...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
amiga_init_offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_exit()
|
static void clean_exit()
|
||||||
|
|
|
@ -31,13 +31,12 @@
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
#define ARGSFORMAT "D=DURATION/N,M=MONITOR/K,T=TRACEFILE/K,SERVERS/M/A,SHOW/S,QUIET/S"
|
#define ARGSFORMAT "D=DURATION/N,M=MONITOR/K,T=TRACEFILE/K,SERVERS/M/A,SHOW/S,QUIET/S"
|
||||||
const char *vers = "\0$VER: ntimed-poll 1.01 (18.04.2015)";
|
const char *vers = "\0$VER: ntimed-poll" AMIGA_VERSION;
|
||||||
|
|
||||||
BOOL started_from_wb;
|
struct RDArgs *rdargs = NULL;
|
||||||
struct RDArgs *rdargs = NULL;
|
struct udp_socket *usc = NULL;
|
||||||
struct udp_socket *usc = NULL;
|
struct ntp_peerset *npl = NULL;
|
||||||
struct ntp_peerset *npl = NULL;
|
struct todolist *tdl = NULL;
|
||||||
struct todolist *tdl = NULL;
|
|
||||||
|
|
||||||
struct ntimedargs {
|
struct ntimedargs {
|
||||||
long *duration;
|
long *duration;
|
||||||
|
@ -53,16 +52,18 @@ static void clean_exit();
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int result = 0;
|
||||||
struct ntimedargs args = { NULL, NULL, NULL, NULL, FALSE, FALSE };
|
struct ntimedargs args = { NULL, NULL, NULL, NULL, FALSE, FALSE };
|
||||||
|
|
||||||
started_from_wb = (BOOL)argc;
|
|
||||||
|
|
||||||
atexit(clean_exit);
|
atexit(clean_exit);
|
||||||
|
if((result = amiga_open_libs()) != 0) {
|
||||||
|
exit(result);
|
||||||
|
}
|
||||||
|
|
||||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
rdargs = ReadArgs((STRPTR)ARGSFORMAT, (APTR)&args, NULL);
|
||||||
if (!rdargs)
|
if (!rdargs)
|
||||||
{
|
{
|
||||||
PrintFault(IoErr(), (ARGPTR)argv[0]);
|
PrintFault(IoErr(), (STRPTR)argv[0]);
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +75,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amiga_open_libs();
|
|
||||||
|
|
||||||
if (args.tracefile) {
|
if (args.tracefile) {
|
||||||
ArgTracefile(args.tracefile);
|
ArgTracefile(args.tracefile);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +84,7 @@ int main(int argc, char **argv)
|
||||||
NTP_PeerSet_Poll(NULL, npl, usc, tdl);
|
NTP_PeerSet_Poll(NULL, npl, usc, tdl);
|
||||||
(void)TODO_Run(NULL, tdl);
|
(void)TODO_Run(NULL, tdl);
|
||||||
|
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -191,6 +190,8 @@ static void init_logic(struct ntimedargs *args)
|
||||||
|
|
||||||
if (mon != NULL)
|
if (mon != NULL)
|
||||||
TODO_ScheduleRel(tdl, mps_mon, mon, 0, 32, "Monitor");
|
TODO_ScheduleRel(tdl, mps_mon, mon, 0, 32, "Monitor");
|
||||||
|
|
||||||
|
amiga_init_offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_exit()
|
static void clean_exit()
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
#define ARGSFORMAT "P=PARAM/K,B=BUMP/K,T=TRACEFILE/K,SIMFILE/A,QUIET/S"
|
#define ARGSFORMAT "P=PARAM/K,B=BUMP/K,T=TRACEFILE/K,SIMFILE/A,QUIET/S"
|
||||||
const char *vers = "\0$VER: ntimed-sim 1.01 (18.04.2015)";
|
const char *vers = "\0$VER: ntimed-sim" AMIGA_VERSION;
|
||||||
|
|
||||||
#define PARAM_CLIENT PARAM_INSTANCE
|
#define PARAM_CLIENT PARAM_INSTANCE
|
||||||
#define PARAM_TABLE_NAME client_param_table
|
#define PARAM_TABLE_NAME client_param_table
|
||||||
|
@ -64,9 +64,8 @@ SimFile_Open(struct ocx *ocx, const char *fn, struct todolist *tdl,
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
BOOL started_from_wb;
|
struct RDArgs *rdargs = NULL;
|
||||||
struct RDArgs *rdargs = NULL;
|
struct todolist *tdl = NULL;
|
||||||
struct todolist *tdl = NULL;
|
|
||||||
|
|
||||||
struct ntimedargs {
|
struct ntimedargs {
|
||||||
char *params;
|
char *params;
|
||||||
|
@ -82,24 +81,25 @@ static void clean_exit();
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int result = 0;
|
||||||
struct ntimedargs args = { NULL, NULL, NULL, NULL, FALSE };
|
struct ntimedargs args = { NULL, NULL, NULL, NULL, FALSE };
|
||||||
started_from_wb = (BOOL)argc;
|
|
||||||
|
|
||||||
atexit(clean_exit);
|
atexit(clean_exit);
|
||||||
|
if((result = amiga_open_libs()) != 0) {
|
||||||
|
exit(result);
|
||||||
|
}
|
||||||
|
|
||||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
rdargs = ReadArgs((STRPTR)ARGSFORMAT, (APTR)&args, NULL);
|
||||||
if (!rdargs)
|
if (!rdargs)
|
||||||
{
|
{
|
||||||
PrintFault(IoErr(), (ARGPTR)argv[0]);
|
PrintFault(IoErr(), (STRPTR)argv[0]);
|
||||||
exit(2);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.quiet) {
|
if (!args.quiet) {
|
||||||
EnableDebug();
|
EnableDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
amiga_close_libs();
|
|
||||||
|
|
||||||
if (args.tracefile) {
|
if (args.tracefile) {
|
||||||
ArgTracefile(args.tracefile);
|
ArgTracefile(args.tracefile);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
(void)TODO_Run(NULL, tdl);
|
(void)TODO_Run(NULL, tdl);
|
||||||
|
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_logic(struct ntimedargs *args)
|
static void init_logic(struct ntimedargs *args)
|
||||||
|
@ -153,6 +153,8 @@ static void init_logic(struct ntimedargs *args)
|
||||||
NF_New(np);
|
NF_New(np);
|
||||||
np->combiner = CD_AddSource(cd, np->hostname, np->ip);
|
np->combiner = CD_AddSource(cd, np->hostname, np->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
amiga_init_offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
|
|
||||||
const char *vers = "\0$VER: ntimed-test 1.01 (18.04.2015)";
|
const char *vers = "\0$VER: ntimed-test" AMIGA_VERSION;
|
||||||
BOOL started_from_wb;
|
|
||||||
|
|
||||||
static void clean_exit()
|
static void clean_exit()
|
||||||
{
|
{
|
||||||
|
@ -40,16 +39,17 @@ static void clean_exit()
|
||||||
|
|
||||||
int main(int argc, char * const *argv)
|
int main(int argc, char * const *argv)
|
||||||
{
|
{
|
||||||
started_from_wb = (BOOL)argc;
|
int result = 0;
|
||||||
|
|
||||||
(void)argc;
|
|
||||||
(void)argv;
|
|
||||||
|
|
||||||
atexit(clean_exit);
|
atexit(clean_exit);
|
||||||
amiga_open_libs();
|
if((result = amiga_open_libs()) != 0) {
|
||||||
|
exit(result);
|
||||||
|
}
|
||||||
|
|
||||||
EnableDebug();
|
EnableDebug();
|
||||||
|
amiga_init_offset();
|
||||||
Time_Amiga_Passive();
|
Time_Amiga_Passive();
|
||||||
TS_RunTest(NULL);
|
TS_RunTest(NULL);
|
||||||
|
|
||||||
return (0);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
#include "net_getaddrinfo.h"
|
#include "net_getaddrinfo.h"
|
||||||
|
|
||||||
|
@ -504,7 +505,11 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_
|
||||||
result = EAI_NONAME;
|
result = EAI_NONAME;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
#ifndef AOS3
|
||||||
ntoa_address = inet_ntoa(sa_in->sin_addr);
|
ntoa_address = inet_ntoa(sa_in->sin_addr);
|
||||||
|
#else
|
||||||
|
ntoa_address = inet_ntoa((ULONG)&sa_in->sin_addr);
|
||||||
|
#endif
|
||||||
if (nodelen <= strlen(ntoa_address)) {
|
if (nodelen <= strlen(ntoa_address)) {
|
||||||
result = EAI_OVERFLOW;
|
result = EAI_OVERFLOW;
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -24,86 +24,84 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NTIMED_PLATFROM_H
|
#ifndef NTIMED_PLATFORM_H
|
||||||
#define NTIMED_PLATFROM_H
|
#define NTIMED_PLATFORM_H
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#if defined(AROS) || defined(AOS3)
|
#if defined(AROS) || defined(AOS3)
|
||||||
|
# define AMIGA_VERSION " 1.02 (10.07.2015)"
|
||||||
# ifndef AMIGA
|
# ifndef AMIGA
|
||||||
# define AMIGA
|
# define AMIGA
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#ifdef HAVE_LIBTZ
|
||||||
|
# define _TIME_H_
|
||||||
|
# define HAVE_TIME_T
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include "tz.h"
|
||||||
|
#endif
|
||||||
|
#define HAVE_WAITSELECT
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
|
# include <exec/io.h>
|
||||||
|
# include <exec/types.h>
|
||||||
|
# include <exec/memory.h>
|
||||||
|
# include <exec/devices.h>
|
||||||
# include <proto/intuition.h>
|
# include <proto/intuition.h>
|
||||||
# include <resources/battclock.h>
|
# include <resources/battclock.h>
|
||||||
# include <clib/battclock_protos.h>
|
# include <clib/battclock_protos.h>
|
||||||
# include <clib/utility_protos.h>
|
# include <clib/utility_protos.h>
|
||||||
# include <clib/dos_protos.h>
|
# include <clib/dos_protos.h>
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AROS
|
#include <stdio.h>
|
||||||
# ifdef Debug
|
#include <stdlib.h>
|
||||||
# undef Debug
|
#include <math.h>
|
||||||
# endif
|
#include <string.h>
|
||||||
# include <sys/types.h>
|
#include <sys/time.h>
|
||||||
# include <sys/socket.h>
|
#include <sys/types.h>
|
||||||
# include <netinet/in.h>
|
#include <sys/param.h>
|
||||||
# include <netdb.h>
|
#include <sys/ioctl.h>
|
||||||
# include <sys/param.h>
|
#include <netinet/in.h>
|
||||||
# include <sys/ioctl.h>
|
#include <arpa/inet.h>
|
||||||
# include <errno.h>
|
#include <netdb.h>
|
||||||
# include <proto/socket.h>
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <bsdsocket/socketbasetags.h>
|
|
||||||
# include <net/if.h>
|
|
||||||
# include <netinet/in.h>
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# ifdef Debug
|
|
||||||
# undef Debug
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#define OPEN_ERROR "Cannot open %s.\n"
|
||||||
|
#define OPEN_VER_ERROR "Cannot open %s (%ld.0)\n"
|
||||||
|
#define DOSLIB_NAME "dos.library"
|
||||||
|
#define DOSLIB_REV 37L
|
||||||
|
#define UTILLIB_NAME "utility.library"
|
||||||
|
#define UTILLIB_REV 37L
|
||||||
|
#define LOCALELIB_NAME "locale.library"
|
||||||
|
#define LOCALELIB_REV 37L
|
||||||
|
#define BSDLIB_NAME "bsdsocket.library"
|
||||||
|
#define BSDLIB_REV 03L
|
||||||
|
#define TIMER_NAME TIMERNAME
|
||||||
|
#define BATTCLOCK_NAME BATTCLOCKNAME
|
||||||
|
#ifdef TZVARIABLE
|
||||||
|
# define TZVARIABLE_NAME TZVARIABLE
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AOS3
|
#ifdef AOS3
|
||||||
# define ARGPTR STRPTR
|
# define REQ_ERROR "Requires Kickstart 2.04 (37.175) or later.\n"
|
||||||
# define ARGS_FORMAT ARGSFORMAT
|
# include "socket_amitcp.h"
|
||||||
# define BSDLIB_NAME "bsdsocket.library"
|
# include <amitcp/socketbasetags.h>
|
||||||
# define BSDLIB_REV 04L
|
|
||||||
# define UTILLIB_NAME "utility.library"
|
|
||||||
# define UTILLIB_REV 33L
|
|
||||||
# define LOCALELIB_NAME "locale.library"
|
|
||||||
# define LOCALELIB_REV 33L
|
|
||||||
# define DOSLIB_NAME "dos.library"
|
|
||||||
# define DOSLIB_REV 36L
|
|
||||||
# define TIMER_NAME TIMERNAME
|
|
||||||
# define BATTCLOCK_NAME BATTCLOCKNAME
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AROS
|
#ifdef AROS
|
||||||
# define ARGPTR CONST_STRPTR
|
# define REQ_ERROR "Requires a newer version of AROS.\n"
|
||||||
# define ARGS_FORMAT (CONST_STRPTR)ARGSFORMAT
|
# include <proto/socket.h>
|
||||||
# define BSDLIB_NAME (CONST_STRPTR)"bsdsocket.library"
|
# include <bsdsocket/socketbasetags.h>
|
||||||
# define BSDLIB_REV 04L
|
# define APRT IPRT
|
||||||
# define UTILLIB_NAME (CONST_STRPTR)"utility.library"
|
|
||||||
# define UTILLIB_REV 33L
|
|
||||||
# define LOCALELIB_NAME (CONST_STRPTR)"locale.library"
|
|
||||||
# define LOCALELIB_REV 33L
|
|
||||||
# define DOSLIB_NAME (CONST_STRPTR)"dos.library"
|
|
||||||
# define DOSLIB_REV 36L
|
|
||||||
# define TIMER_NAME (CONST_STRPTR)TIMERNAME
|
|
||||||
# define BATTCLOCK_NAME (CONST_STRPTR)BATTCLOCKNAME
|
|
||||||
# define APRT IPRT
|
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef AMIGA
|
#ifndef AMIGA
|
||||||
struct timeval {
|
struct timeval {
|
||||||
ULONG tv_secs;
|
ULONG tv_secs;
|
||||||
ULONG tv_micro;
|
ULONG tv_micro;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef HAVE_POLL
|
#ifndef HAVE_POLL
|
||||||
#define POLLIN 0x0001
|
#define POLLIN 0x0001
|
||||||
struct pollfd {
|
struct pollfd {
|
||||||
|
@ -114,32 +112,46 @@ struct pollfd {
|
||||||
typedef unsigned int nfds_t;
|
typedef unsigned int nfds_t;
|
||||||
int poll(struct pollfd *, nfds_t, int);
|
int poll(struct pollfd *, nfds_t, int);
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AMIGA
|
|
||||||
void amiga_open_libs();
|
|
||||||
void amiga_close_libs();
|
|
||||||
void amiga_save_time(void);
|
|
||||||
void amiga_sync_time(int seconds);
|
|
||||||
void EnableDebug();
|
|
||||||
void EnableTraceDebug();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef AROS
|
#ifdef AROS
|
||||||
# define settimeofday ntimed_settimeofday
|
# define settimeofday ntimed_settimeofday
|
||||||
# define gettimeofday ntimed_gettimeofday
|
# define gettimeofday ntimed_gettimeofday
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
int settimeofday(const struct timeval *tv, const struct timezone *tz);
|
int settimeofday(const struct timeval *tv, const struct timezone *tz);
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
# define Time_Amiga Time_Unix
|
# define Time_Amiga Time_Unix
|
||||||
# define Time_Amiga_Passive Time_Unix_Passive
|
# define Time_Amiga_Passive Time_Unix_Passive
|
||||||
# define Time_Amiga_Save amiga_save_time
|
# define Time_Amiga_Save amiga_save_time
|
||||||
# define SetSyncTime amiga_sync_time
|
# define SetSyncTime amiga_sync_time
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef Debug
|
#ifndef _ALIGNBYTES
|
||||||
# undef Debug
|
# define _ALIGNBYTES (sizeof(register_t) - 1)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ALIGN
|
||||||
|
# define ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
||||||
|
#endif
|
||||||
|
#ifndef SO_TIMESTAMPING
|
||||||
|
# define SO_TIMESTAMPING 37
|
||||||
|
#endif
|
||||||
|
#ifndef SO_TIMESTAMPNS
|
||||||
|
# define SO_TIMESTAMPNS 35
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
int amiga_open_libs();
|
||||||
|
void amiga_close_libs();
|
||||||
|
void amiga_init_offset();
|
||||||
|
void amiga_save_time();
|
||||||
|
void amiga_sync_time(int seconds);
|
||||||
|
void EnableDebug();
|
||||||
|
void EnableTraceDebug();
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
extern struct Library *BattClockBase;
|
||||||
|
extern struct Library *DOSBase;
|
||||||
|
extern struct Library *UtilityBase;
|
||||||
|
extern struct Library *LocaleBase;
|
||||||
|
extern struct Library *SocketBase;
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,7 +68,6 @@
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
|
|
||||||
extern BOOL started_from_wb;
|
|
||||||
int repeat_trace = 0;
|
int repeat_trace = 0;
|
||||||
|
|
||||||
static FILE *debugfile = NULL;
|
static FILE *debugfile = NULL;
|
||||||
|
@ -134,16 +133,15 @@ Put(struct ocx *ocx, enum ocx_chan chan, const char *fmt, ...)
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
dst = getdst(chan);
|
dst = getdst(chan);
|
||||||
if (dst != NULL && !(started_from_wb && dst == stdout)) {
|
if (dst != NULL && dst == stdout) {
|
||||||
(void)vfprintf(dst, fmt, ap);
|
(void)vfprintf(dst, fmt, ap);
|
||||||
fflush(dst);
|
fflush(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = getdst(OCX_DEBUG);
|
dst = getdst(OCX_DEBUG);
|
||||||
if (
|
if (
|
||||||
dst != NULL &&
|
dst != NULL && dst == stdout &&
|
||||||
!(started_from_wb && dst == stdout) &&
|
repeat_trace && chan == OCX_TRACE) {
|
||||||
(repeat_trace && chan == OCX_TRACE)) {
|
|
||||||
(void)vfprintf(dst, fmt, ap);
|
(void)vfprintf(dst, fmt, ap);
|
||||||
fflush(dst);
|
fflush(dst);
|
||||||
}
|
}
|
||||||
|
|
194
time_amiga.c
194
time_amiga.c
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
#include "lib/tz.h"
|
|
||||||
|
|
||||||
#ifdef Debug
|
#ifdef Debug
|
||||||
#undef Debug
|
#undef Debug
|
||||||
|
@ -46,13 +45,11 @@
|
||||||
#include <clib/utility_protos.h>
|
#include <clib/utility_protos.h>
|
||||||
#include <clib/battclock_protos.h>
|
#include <clib/battclock_protos.h>
|
||||||
|
|
||||||
#ifdef Debug
|
|
||||||
#undef Debug
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal)
|
// 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal)
|
||||||
#define AMIGAOFFSET 2922 * 24 * 60 * 60
|
#define AMIGAOFFSET 2922 * 24 * 60 * 60
|
||||||
|
|
||||||
|
#define ENVSIZE 256
|
||||||
|
|
||||||
int create_timer();
|
int create_timer();
|
||||||
int delete_timer();
|
int delete_timer();
|
||||||
void adjust_timeval(struct timeval *tv, double offset);
|
void adjust_timeval(struct timeval *tv, double offset);
|
||||||
|
@ -70,61 +67,70 @@ int validtime = 0;
|
||||||
int limited_sync = 0;
|
int limited_sync = 0;
|
||||||
long offset = 0;
|
long offset = 0;
|
||||||
|
|
||||||
void amiga_open_libs()
|
#ifdef AOS3
|
||||||
|
int errno;
|
||||||
|
int h_errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void amiga_open_error(char *name)
|
||||||
{
|
{
|
||||||
if(!(DOSBase = OpenLibrary(DOSLIB_NAME, DOSLIB_REV))) {
|
Put(NULL, OCX_DIAG, OPEN_ERROR, "Locale");
|
||||||
Put(NULL, OCX_DIAG, "Cannot open dos library.\n");
|
FPrintf(Output(), (STRPTR)OPEN_ERROR, name);
|
||||||
exit(10);
|
}
|
||||||
|
|
||||||
|
void amiga_open_lib_error(char *name, int version)
|
||||||
|
{
|
||||||
|
Put(NULL, OCX_DIAG, OPEN_VER_ERROR, name, version);
|
||||||
|
Put(NULL, OCX_DIAG, REQ_ERROR);
|
||||||
|
|
||||||
|
FPrintf(Output(), (STRPTR)OPEN_VER_ERROR, name, version);
|
||||||
|
FPrintf(Output(), (STRPTR)REQ_ERROR, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int amiga_open_libs()
|
||||||
|
{
|
||||||
|
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
||||||
|
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||||
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(LocaleBase = OpenLibrary(LOCALELIB_NAME, LOCALELIB_REV))) {
|
if(!(LocaleBase = OpenLibrary((STRPTR)LOCALELIB_NAME, LOCALELIB_REV))) {
|
||||||
Put(NULL, OCX_DIAG, "Cannot open locale library.\n");
|
amiga_open_lib_error(LOCALELIB_NAME, LOCALELIB_REV);
|
||||||
exit(10);
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(locale = OpenLocale(NULL))) {
|
if(!(locale = OpenLocale(NULL))) {
|
||||||
Put(NULL, OCX_DIAG, "Cannot open current locale.\n");
|
amiga_open_error("Locale");
|
||||||
exit(10);
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(UtilityBase = OpenLibrary(UTILLIB_NAME, UTILLIB_REV))) {
|
if(!(UtilityBase = OpenLibrary((STRPTR)UTILLIB_NAME, UTILLIB_REV))) {
|
||||||
Put(NULL, OCX_DIAG, "Cannot open utility library.\n");
|
amiga_open_lib_error(UTILLIB_NAME, UTILLIB_REV);
|
||||||
exit(10);
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
BattClockBase = OpenResource(BATTCLOCK_NAME);
|
if(!(BattClockBase = OpenResource((STRPTR)BATTCLOCK_NAME))) {
|
||||||
|
amiga_open_error(BATTCLOCK_NAME);
|
||||||
#ifdef AROS
|
return 10;
|
||||||
if(!(SocketBase = OpenLibrary(BSDLIB_NAME, BSDLIB_REV))) {
|
|
||||||
Put(NULL, OCX_DIAG, "No TCP/IP Stack running.\n");
|
|
||||||
exit(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR)&errno,
|
if(!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV))) {
|
||||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR)&h_errno, TAG_DONE)) {
|
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
||||||
Put(NULL, OCX_DIAG, "Error initializing bsdsocket.\n");
|
return 5;
|
||||||
exit(10);
|
}
|
||||||
|
|
||||||
|
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (int)&errno,
|
||||||
|
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (int)&h_errno, TAG_DONE)) {
|
||||||
|
amiga_open_error(BSDLIB_NAME);
|
||||||
|
return 10;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (create_timer() != 0) {
|
if (create_timer() != 0) {
|
||||||
Put(NULL, OCX_DIAG, "Cannot open timer device.\n");
|
amiga_open_error(TIMER_NAME);
|
||||||
exit(10);
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USETZDATABASE
|
return 0;
|
||||||
if (getenv("TZ")) {
|
|
||||||
tz_time_t rawtime;
|
|
||||||
time(&rawtime);
|
|
||||||
struct tz_tm *localtm = tz_localtime(&rawtime);
|
|
||||||
offset = -localtm->tm_gmtoff + AMIGAOFFSET;
|
|
||||||
Put(NULL, OCX_DEBUG, "Using TZ GMT offset %i seconds\n", localtm->tm_gmtoff);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
offset = -locale->loc_GMTOffset * 60 + AMIGAOFFSET;
|
|
||||||
Put(NULL, OCX_DEBUG, "Using locale GMT offset %i minutes\n", locale->loc_GMTOffset );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void amiga_close_libs()
|
void amiga_close_libs()
|
||||||
|
@ -153,16 +159,69 @@ void amiga_close_libs()
|
||||||
DOSBase = NULL;
|
DOSBase = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AROS
|
|
||||||
if (SocketBase != NULL) {
|
if (SocketBase != NULL) {
|
||||||
CloseLibrary(SocketBase);
|
CloseLibrary(SocketBase);
|
||||||
SocketBase = NULL;
|
SocketBase = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
#ifdef HAVE_LIBTZ
|
||||||
|
int amiga_get_gmtoffset_attime(time_t locale_time)
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
timezone_t tz;
|
||||||
|
char *tzvar;
|
||||||
|
int gmtoffset = 0;
|
||||||
|
|
||||||
|
tzvar = AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||||
|
|
||||||
|
GetVar(
|
||||||
|
(STRPTR)TZVARIABLE_NAME,
|
||||||
|
(STRPTR)tzvar,
|
||||||
|
ENVSIZE - 1,
|
||||||
|
GVF_GLOBAL_ONLY
|
||||||
|
);
|
||||||
|
|
||||||
|
tz = tzalloc(tzvar);
|
||||||
|
|
||||||
|
if (tz) {
|
||||||
|
localtime_rz(tz, &locale_time, &tm);
|
||||||
|
tzfree(tz);
|
||||||
|
gmtoffset = tm.tm_gmtoff;
|
||||||
|
} else {
|
||||||
|
gmtoffset = locale->loc_GMTOffset * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
Put(NULL, OCX_DEBUG,
|
||||||
|
"Current time zone offset: UTC/GMT %.1f hour\n",
|
||||||
|
(float)gmtoffset / 60.0 / 60.0);
|
||||||
|
|
||||||
|
FreeVec(tzvar);
|
||||||
|
return gmtoffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amiga_get_gmtoffset()
|
||||||
|
{
|
||||||
|
time_t now = time(NULL);
|
||||||
|
return amiga_get_gmtoffset_attime(now);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**********************************************************************/
|
||||||
|
void amiga_init_offset()
|
||||||
|
{
|
||||||
|
int gmt_offset;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBTZ
|
||||||
|
gmt_offset = amiga_get_gmtoffset();
|
||||||
|
#else
|
||||||
|
gmt_offset = locale->loc_GMTOffset * 60 * 60;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
offset = -gmt_offset + AMIGAOFFSET;
|
||||||
|
}
|
||||||
|
/**********************************************************************/
|
||||||
int create_timer()
|
int create_timer()
|
||||||
{
|
{
|
||||||
LONG error;
|
LONG error;
|
||||||
|
@ -177,7 +236,11 @@ int create_timer()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = OpenDevice(TIMER_NAME, UNIT_MICROHZ, (struct IORequest*)request, 0L);
|
error = OpenDevice(
|
||||||
|
(STRPTR)TIMER_NAME, UNIT_MICROHZ,
|
||||||
|
(struct IORequest*)request, 0L
|
||||||
|
);
|
||||||
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
delete_timer(request);
|
delete_timer(request);
|
||||||
|
@ -205,25 +268,7 @@ int delete_timer()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
#ifdef USETZDATABASE
|
|
||||||
tz_time_t time(tz_time_t *x)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
GetSysTime(&tv);
|
|
||||||
|
|
||||||
if (x) {
|
|
||||||
*x = (time_t)tv.tv_secs + AMIGAOFFSET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (time_t)tv.tv_secs + AMIGAOFFSET;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************/
|
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
#ifdef USESYSTIME
|
#ifdef USESYSTIME
|
||||||
|
@ -247,18 +292,19 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||||
validtime = 1;
|
validtime = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
void amiga_save_time(void)
|
void amiga_save_time(void)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
ResetBattClock();
|
int gmt_offset = 0;
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
WriteBattClock((long)tv.tv_secs - offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************/
|
#ifdef HAVE_LIBTZ
|
||||||
|
gmt_offset = amiga_get_gmtoffset();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
WriteBattClock((long)tv.tv_secs - offset - gmt_offset);
|
||||||
|
}
|
||||||
|
|
||||||
void amiga_sync_time(int seconds)
|
void amiga_sync_time(int seconds)
|
||||||
{
|
{
|
||||||
|
@ -267,8 +313,6 @@ void amiga_sync_time(int seconds)
|
||||||
sync_time.tv_micro = 0;
|
sync_time.tv_micro = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
|
||||||
|
|
||||||
int amiga_sleep_time(double dur)
|
int amiga_sleep_time(double dur)
|
||||||
{
|
{
|
||||||
ULONG sigs, timersig;
|
ULONG sigs, timersig;
|
||||||
|
@ -300,9 +344,7 @@ int amiga_sleep_time(double dur)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
void adjust_timeval(struct timeval *tv, double offset)
|
void adjust_timeval(struct timeval *tv, double offset)
|
||||||
{
|
{
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
|
@ -325,7 +367,6 @@ void adjust_timeval(struct timeval *tv, double offset)
|
||||||
tv->tv_secs = secs;
|
tv->tv_secs = secs;
|
||||||
tv->tv_micro = micro;
|
tv->tv_micro = micro;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
#ifndef HAVE_POLL
|
#ifndef HAVE_POLL
|
||||||
int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
||||||
|
@ -387,3 +428,4 @@ int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/**********************************************************************/
|
||||||
|
|
|
@ -155,7 +155,8 @@ TS_Format(char *buf, size_t len, const struct timestamp *ts)
|
||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
// i = snprintf(buf, len, "%jd.%09jd", (intmax_t)x, (intmax_t)y);
|
// i = snprintf(buf, len, "%jd.%09jd", (intmax_t)x, (intmax_t)y);
|
||||||
i = snprintf(buf, len, "%lld.%09lld", x, y);
|
// i = snprintf(buf, len, "%lld.%09lld", x, y);
|
||||||
|
i = snprintf(buf, len, "%d.%d", (int32_t)x, (int32_t)y);
|
||||||
assert(i < (int)len);
|
assert(i < (int)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include "ntimed.h"
|
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
|
#include "ntimed.h"
|
||||||
|
|
||||||
static double adj_offset = 0;
|
static double adj_offset = 0;
|
||||||
static double adj_duration = 0;
|
static double adj_duration = 0;
|
||||||
|
|
12
udp.c
12
udp.c
|
@ -53,7 +53,19 @@ static int
|
||||||
udp_sock(int fam)
|
udp_sock(int fam)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
int i;
|
||||||
|
|
||||||
fd = socket(fam, SOCK_DGRAM, 0);
|
fd = socket(fam, SOCK_DGRAM, 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return (fd);
|
||||||
|
|
||||||
|
#ifdef SO_TIMESTAMPNS
|
||||||
|
i = 1;
|
||||||
|
(void)setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPNS, &i, sizeof i);
|
||||||
|
#elif defined(SO_TIMESTAMP)
|
||||||
|
i = 1;
|
||||||
|
(void)setsockopt(fd, SOL_SOCKET, SO_TIMESTAMP, &i, sizeof i);
|
||||||
|
#endif
|
||||||
return (fd);
|
return (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue