Blame missing.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file missing.h
Packit 9c3e7e
 * @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is free software; you can redistribute it and/or modify
Packit 9c3e7e
 * it under the terms of the GNU General Public License as published by
Packit 9c3e7e
 * the Free Software Foundation; either version 2 of the License, or
Packit 9c3e7e
 * (at your option) any later version.
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is distributed in the hope that it will be useful,
Packit 9c3e7e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9c3e7e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9c3e7e
 * GNU General Public License for more details.
Packit 9c3e7e
 *
Packit 9c3e7e
 * You should have received a copy of the GNU General Public License along
Packit 9c3e7e
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 9c3e7e
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 9c3e7e
 */
Packit 9c3e7e
Packit 9c3e7e
/*
Packit 9c3e7e
 * When glibc offers the syscall, this will go away.
Packit 9c3e7e
 */
Packit 9c3e7e
#ifndef HAVE_MISSING_H
Packit 9c3e7e
#define HAVE_MISSING_H
Packit 9c3e7e
Packit 9c3e7e
#include <time.h>
Packit 9c3e7e
#include <sys/syscall.h>
Packit 9c3e7e
#include <sys/timex.h>
Packit 9c3e7e
#include <unistd.h>
Packit 9c3e7e
Packit 9c3e7e
#ifndef ADJ_TAI
Packit 9c3e7e
#define ADJ_TAI 0x0080
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef ADJ_NANO
Packit 9c3e7e
#define ADJ_NANO 0x2000
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef ADJ_SETOFFSET
Packit 9c3e7e
#define ADJ_SETOFFSET 0x0100
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef CLOCK_INVALID
Packit 9c3e7e
#define CLOCK_INVALID -1
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#define CLOCKFD 3
Packit 9c3e7e
#define FD_TO_CLOCKID(fd)	((clockid_t) ((((unsigned int) ~fd) << 3) | CLOCKFD))
Packit 9c3e7e
#define CLOCKID_TO_FD(clk)	((unsigned int) ~((clk) >> 3))
Packit 9c3e7e
Packit 9c3e7e
#ifndef HAVE_ONESTEP_SYNC
Packit 9c3e7e
enum _missing_hwtstamp_tx_types {
Packit 9c3e7e
	HWTSTAMP_TX_ONESTEP_SYNC = 2,
Packit 9c3e7e
};
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef HAVE_ONESTEP_P2P
Packit 9c3e7e
enum {
Packit 9c3e7e
	HWTSTAMP_TX_ONESTEP_P2P = 3,
Packit 9c3e7e
};
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef LIST_FOREACH_SAFE
Packit 9c3e7e
#define	LIST_FOREACH_SAFE(var, head, field, tvar)			\
Packit 9c3e7e
	for ((var) = LIST_FIRST((head));				\
Packit 9c3e7e
	    (var) && ((tvar) = LIST_NEXT((var), field), 1);		\
Packit 9c3e7e
	    (var) = (tvar))
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef SIOCGHWTSTAMP
Packit 9c3e7e
#define SIOCGHWTSTAMP 0x89b1
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef SO_SELECT_ERR_QUEUE
Packit 9c3e7e
#define SO_SELECT_ERR_QUEUE 45
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef HAVE_CLOCK_ADJTIME
Packit 9c3e7e
static inline int clock_adjtime(clockid_t id, struct timex *tx)
Packit 9c3e7e
{
Packit 9c3e7e
	return syscall(__NR_clock_adjtime, id, tx);
Packit 9c3e7e
}
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#ifndef IFLA_BOND_MAX
Packit 9c3e7e
enum {
Packit 9c3e7e
	IFLA_BOND_UNSPEC,
Packit 9c3e7e
	IFLA_BOND_MODE,
Packit 9c3e7e
	IFLA_BOND_ACTIVE_SLAVE,
Packit 9c3e7e
	IFLA_BOND_MIIMON,
Packit 9c3e7e
	IFLA_BOND_UPDELAY,
Packit 9c3e7e
	IFLA_BOND_DOWNDELAY,
Packit 9c3e7e
	IFLA_BOND_USE_CARRIER,
Packit 9c3e7e
	IFLA_BOND_ARP_INTERVAL,
Packit 9c3e7e
	IFLA_BOND_ARP_IP_TARGET,
Packit 9c3e7e
	IFLA_BOND_ARP_VALIDATE,
Packit 9c3e7e
	IFLA_BOND_ARP_ALL_TARGETS,
Packit 9c3e7e
	IFLA_BOND_PRIMARY,
Packit 9c3e7e
	IFLA_BOND_PRIMARY_RESELECT,
Packit 9c3e7e
	IFLA_BOND_FAIL_OVER_MAC,
Packit 9c3e7e
	IFLA_BOND_XMIT_HASH_POLICY,
Packit 9c3e7e
	IFLA_BOND_RESEND_IGMP,
Packit 9c3e7e
	IFLA_BOND_NUM_PEER_NOTIF,
Packit 9c3e7e
	IFLA_BOND_ALL_SLAVES_ACTIVE,
Packit 9c3e7e
	IFLA_BOND_MIN_LINKS,
Packit 9c3e7e
	IFLA_BOND_LP_INTERVAL,
Packit 9c3e7e
	IFLA_BOND_PACKETS_PER_SLAVE,
Packit 9c3e7e
	IFLA_BOND_AD_LACP_RATE,
Packit 9c3e7e
	IFLA_BOND_AD_SELECT,
Packit 9c3e7e
	IFLA_BOND_AD_INFO,
Packit 9c3e7e
	IFLA_BOND_AD_ACTOR_SYS_PRIO,
Packit 9c3e7e
	IFLA_BOND_AD_USER_PORT_KEY,
Packit 9c3e7e
	IFLA_BOND_AD_ACTOR_SYSTEM,
Packit 9c3e7e
	IFLA_BOND_TLB_DYNAMIC_LB,
Packit 9c3e7e
	__IFLA_BOND_MAX,
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
#define IFLA_BOND_MAX   (__IFLA_BOND_MAX - 1)
Packit 9c3e7e
#endif	/*IFLA_BOND_MAX*/
Packit 9c3e7e
Packit 9c3e7e
#ifdef __UCLIBC__
Packit 9c3e7e
Packit 9c3e7e
#if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \
Packit 9c3e7e
	defined __UCLIBC_HAS_THREADS_NATIVE__
Packit 9c3e7e
Packit 9c3e7e
#include <sys/timerfd.h>
Packit 9c3e7e
Packit 9c3e7e
#else
Packit 9c3e7e
Packit 9c3e7e
#define TFD_TIMER_ABSTIME (1 << 0)
Packit 9c3e7e
Packit 9c3e7e
static inline int clock_nanosleep(clockid_t clock_id, int flags,
Packit 9c3e7e
				  const struct timespec *request,
Packit 9c3e7e
				  struct timespec *remain)
Packit 9c3e7e
{
Packit 9c3e7e
	return syscall(__NR_clock_nanosleep, clock_id, flags, request, remain);
Packit 9c3e7e
}
Packit 9c3e7e
Packit 9c3e7e
static inline int timerfd_create(int clockid, int flags)
Packit 9c3e7e
{
Packit 9c3e7e
	return syscall(__NR_timerfd_create, clockid, flags);
Packit 9c3e7e
}
Packit 9c3e7e
Packit 9c3e7e
static inline int timerfd_settime(int fd, int flags,
Packit 9c3e7e
				  const struct itimerspec *new_value,
Packit 9c3e7e
				  struct itimerspec *old_value)
Packit 9c3e7e
{
Packit 9c3e7e
	return syscall(__NR_timerfd_settime, fd, flags, new_value, old_value);
Packit 9c3e7e
}
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#else /*__UCLIBC__*/
Packit 9c3e7e
Packit 9c3e7e
#include <sys/timerfd.h>
Packit 9c3e7e
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
#endif