24#ifndef MY_XP_UTIL_INCLUDED
25#define MY_XP_UTIL_INCLUDED
40#ifndef INET_ADDRSTRLEN
45#include <netinet/in.h>
46#include <netinet/tcp.h>
47#include <sys/socket.h>
57#define INT_MAX32 0x7FFFFFFFL
58#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
62#define OFFSET_TO_EPOC ((__int64)134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
99 uint64_t tv_sec = now / 10000000ULL;
100#if SIZEOF_TIME_T < SIZEOF_LONG_LONG
104 abstime->tv_sec = (time_t)tv_sec;
105 abstime->tv_nsec = (now % 10000000ULL) * 100 + (nsec % 100);
124 static inline int cmp_timespec(
struct timespec *ts1,
struct timespec *ts2) {
125 if (ts1->tv_sec > ts2->tv_sec ||
126 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec > ts2->tv_nsec))
128 if (ts1->tv_sec < ts2->tv_sec ||
129 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec < ts2->tv_nsec))
142 struct timespec *ts2) {
143 return static_cast<uint64_t
>(ts1->tv_sec - ts2->tv_sec) * 1000000000ULL +
144 static_cast<uint64_t
>(ts1->tv_nsec) -
145 static_cast<uint32_t
>(ts2->tv_nsec);
Definition: my_xp_util.h:167
~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:41
Interface for socket utility methods.
Definition: my_xp_util.h:154
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:74
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:112
static uint64_t diff_timespec(struct timespec *ts1, struct timespec *ts2)
Diff two timespec structs.
Definition: my_xp_util.h:141
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:96
static int cmp_timespec(struct timespec *ts1, struct timespec *ts2)
Compare two timespec structs.
Definition: my_xp_util.h:124
static void sleep_seconds(unsigned int seconds)
Current thread sleeps for the parameterized number of seconds.
Definition: my_xp_util.cc:31
static uint64_t getsystime(void)
Get the system's time.
Definition: my_xp_util.cc:39
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:162
#define MY_MIN(a, b)
Definition: my_xp_util.h:58
#define INT_MAX32
Definition: my_xp_util.h:57
double seconds()
Definition: task.cc:310
Include file for Sun RPC to compile out of the box.