23#ifndef MY_XP_UTIL_INCLUDED
24#define MY_XP_UTIL_INCLUDED
39#ifndef INET_ADDRSTRLEN
44#include <netinet/in.h>
45#include <netinet/tcp.h>
46#include <sys/socket.h>
56#define INT_MAX32 0x7FFFFFFFL
57#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
61#define OFFSET_TO_EPOC ((__int64)134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
98 uint64_t tv_sec = now / 10000000ULL;
99#if SIZEOF_TIME_T < SIZEOF_LONG_LONG
103 abstime->tv_sec = (time_t)tv_sec;
104 abstime->tv_nsec = (now % 10000000ULL) * 100 + (nsec % 100);
123 static inline int cmp_timespec(
struct timespec *ts1,
struct timespec *ts2) {
124 if (ts1->tv_sec > ts2->tv_sec ||
125 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec > ts2->tv_nsec))
127 if (ts1->tv_sec < ts2->tv_sec ||
128 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec < ts2->tv_nsec))
141 struct timespec *ts2) {
142 return static_cast<uint64_t
>(ts1->tv_sec - ts2->tv_sec) * 1000000000ULL +
143 static_cast<uint64_t
>(ts1->tv_nsec) -
144 static_cast<uint32_t
>(ts2->tv_nsec);
Definition: my_xp_util.h:166
~My_xp_socket_util_impl() override=default
My_xp_socket_util_impl()=default
int disable_nagle_in_socket(int fd) override
Disable Nagle algorithm in the specified socket.
Definition: my_xp_util.cc:40
Interface for socket utility methods.
Definition: my_xp_util.h:153
virtual int disable_nagle_in_socket(int fd)=0
Disable Nagle algorithm in the specified socket.
virtual ~My_xp_socket_util()=default
Class where cross platform utilities reside as static methods.
Definition: my_xp_util.h:73
static void set_timespec(struct timespec *abstime, uint64_t sec)
Set the value of the timespec struct equal to the argument in seconds.
Definition: my_xp_util.h:111
static uint64_t diff_timespec(struct timespec *ts1, struct timespec *ts2)
Diff two timespec structs.
Definition: my_xp_util.h:140
static void set_timespec_nsec(struct timespec *abstime, uint64_t nsec)
Set the value of the timespec struct equal to the argument in nanoseconds.
Definition: my_xp_util.h:95
static int cmp_timespec(struct timespec *ts1, struct timespec *ts2)
Compare two timespec structs.
Definition: my_xp_util.h:123
static void sleep_seconds(unsigned int seconds)
Current thread sleeps for the parameterized number of seconds.
Definition: my_xp_util.cc:30
static uint64_t getsystime(void)
Get the system's time.
Definition: my_xp_util.cc:38
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:161
#define MY_MIN(a, b)
Definition: my_xp_util.h:57
#define INT_MAX32
Definition: my_xp_util.h:56
double seconds()
Definition: task.cc:309
Include file for Sun RPC to compile out of the box.