amiga-ntimed/ntimed_platform.h

142 lines
3.8 KiB
C

/*
* 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 NTIMED_PLATFROM_H
#define NTIMED_PLATFROM_H
#if defined(AROS) || defined(AOS3)
# ifndef AMIGA
# define AMIGA
# endif
#endif
#ifdef AMIGA
# include <proto/dos.h>
# include <proto/intuition.h>
# include <resources/battclock.h>
# include <clib/battclock_protos.h>
# include <clib/utility_protos.h>
#endif
#ifdef AROS
# ifdef Debug
# undef Debug
# endif
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
# include <sys/param.h>
# include <sys/ioctl.h>
# include <errno.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"
#ifdef AOS3
# define ARGPTR STRPTR
# define ARGS_FORMAT ARGSFORMAT
# define BSDLIB_NAME "bsdsocket.library"
# define BSDLIB_REV 04L
# define UTILLIB_NAME "utility.library"
# define UTILLIB_REV 33L
# define LOCALELIB_NAME "locale.library"
# define LOCALELIB_REV 33L
# define TIMER_NAME TIMERNAME
# define BATTCLOCK_NAME BATTCLOCKNAME
#endif
#ifdef AROS
# define ARGPTR CONST_STRPTR
# define ARGS_FORMAT (CONST_STRPTR)ARGSFORMAT
# define BSDLIB_NAME (CONST_STRPTR)"bsdsocket.library"
# define BSDLIB_REV 04L
# define UTILLIB_NAME (CONST_STRPTR)"utility.library"
# define UTILLIB_REV 33L
# define LOCALELIB_NAME (CONST_STRPTR)"locale.library"
# define LOCALELIB_REV 33L
# define TIMER_NAME (CONST_STRPTR)TIMERNAME
# define BATTCLOCK_NAME (CONST_STRPTR)BATTCLOCKNAME
# define APRT IPRT
#endif
#ifndef AMIGA
struct timeval {
ULONG tv_secs;
ULONG tv_micro;
};
#endif
#ifndef HAVE_POLL
#define POLLIN 0x0001
struct pollfd {
int fd;
short events;
short revents;
};
typedef unsigned int nfds_t;
int poll(struct pollfd *, nfds_t, int);
#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
# define settimeofday ntimed_settimeofday
# define gettimeofday ntimed_gettimeofday
int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv, const struct timezone *tz);
#endif
#ifdef AMIGA
# define Time_Amiga Time_Unix
# define Time_Amiga_Passive Time_Unix_Passive
# define Time_Amiga_Save amiga_save_time
# define SetSyncTime amiga_sync_time
#endif
#ifdef Debug
# undef Debug
#endif
#endif