2 Copyright 2020 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
29 void MILLISLEEP(ULONG a)
32 struct timespec delayTime;
33 delayTime.tv_sec = a / 1000;
34 delayTime.tv_nsec = (a % 1000) * 1000000;
35 nanosleep(&delayTime, NULL);
41 std::string tp2str(const std::chrono::time_point<std::chrono::system_clock>& tp)
43 auto tms = std::chrono::time_point_cast<std::chrono::milliseconds>(tp);
44 std::chrono::milliseconds e = tms.time_since_epoch();
45 long long c = e.count();
48 auto stm = std::localtime(&tt);
50 ss << std::put_time(stm, "%T") << "." << std::setfill('0') << std::setw(3) << ttm;
55 ULLONG htonll(ULLONG a)
57 return (((ULLONG)htonl((ULONG)((a<<32)>> 32))<<32)
58 |(ULONG)htonl(((ULONG) (a >> 32))));
61 ULLONG ntohll(ULLONG a)
66 ULLONG htonll(ULLONG a)
68 #if BYTE_ORDER == BIG_ENDIAN
73 b = ((a << 56) & 0xFF00000000000000ULL)
74 | ((a << 40) & 0x00FF000000000000ULL)
75 | ((a << 24) & 0x0000FF0000000000ULL)
76 | ((a << 8) & 0x000000FF00000000ULL)
77 | ((a >> 8) & 0x00000000FF000000ULL)
78 | ((a >> 24) & 0x0000000000FF0000ULL)
79 | ((a >> 40) & 0x000000000000FF00ULL)
80 | ((a >> 56) & 0x00000000000000FFULL) ;
86 ULLONG ntohll(ULLONG a)