2011-11-02 00:32:40 +08:00
|
|
|
/**
|
|
|
|
* @file missing.h
|
|
|
|
* @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When glibc offers the syscall, this will go away.
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_MISSING_H
|
|
|
|
#define HAVE_MISSING_H
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <sys/timex.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#ifndef ADJ_NANO
|
|
|
|
#define ADJ_NANO 0x2000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ADJ_SETOFFSET
|
|
|
|
#define ADJ_SETOFFSET 0x0100
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CLOCK_INVALID
|
|
|
|
#define CLOCK_INVALID -1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CLOCKFD 3
|
|
|
|
#define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD)
|
|
|
|
#define CLOCKID_TO_FD(clk) ((unsigned int) ~((clk) >> 3))
|
|
|
|
|
2013-09-04 08:19:30 +08:00
|
|
|
#ifndef HAVE_ONESTEP_SYNC
|
|
|
|
enum _missing_hwtstamp_tx_types {
|
|
|
|
HWTSTAMP_TX_ONESTEP_SYNC = 2,
|
2013-09-05 02:55:11 +08:00
|
|
|
};
|
2013-09-04 08:19:30 +08:00
|
|
|
#endif
|
|
|
|
|
2014-05-28 01:34:35 +08:00
|
|
|
#ifndef SIOCGHWTSTAMP
|
|
|
|
#define SIOCGHWTSTAMP 0x89b1
|
|
|
|
#endif
|
|
|
|
|
2012-09-05 23:00:30 +08:00
|
|
|
#ifndef HAVE_CLOCK_ADJTIME
|
2011-11-02 00:32:40 +08:00
|
|
|
static inline int clock_adjtime(clockid_t id, struct timex *tx)
|
|
|
|
{
|
|
|
|
return syscall(__NR_clock_adjtime, id, tx);
|
|
|
|
}
|
2012-09-05 23:00:30 +08:00
|
|
|
#endif
|
2011-11-02 00:32:40 +08:00
|
|
|
|
2012-02-20 01:25:21 +08:00
|
|
|
#ifndef __uClinux__
|
|
|
|
|
|
|
|
#include <sys/timerfd.h>
|
|
|
|
|
|
|
|
#else
|
2011-12-30 15:33:30 +08:00
|
|
|
|
2013-06-14 17:47:58 +08:00
|
|
|
static inline int clock_nanosleep(clockid_t clock_id, int flags,
|
|
|
|
const struct timespec *request,
|
|
|
|
struct timespec *remain)
|
|
|
|
{
|
|
|
|
return syscall(__NR_clock_nanosleep, clock_id, flags, request, remain);
|
|
|
|
}
|
|
|
|
|
2011-12-30 15:33:30 +08:00
|
|
|
static inline int timerfd_create(int clockid, int flags)
|
|
|
|
{
|
|
|
|
return syscall(__NR_timerfd_create, clockid, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int timerfd_settime(int fd, int flags,
|
|
|
|
const struct itimerspec *new_value,
|
|
|
|
struct itimerspec *old_value)
|
|
|
|
{
|
|
|
|
return syscall(__NR_timerfd_settime, fd, flags, new_value, old_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2011-11-02 00:32:40 +08:00
|
|
|
#endif
|