Fix to compile for Linux

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-11-08 13:48:41 +01:00
parent 9ff15a27a1
commit ee8f54ee5f
10 changed files with 48 additions and 19 deletions

View File

@ -61,6 +61,9 @@
#ifndef _In_reads_bytes_opt_
#define _In_reads_bytes_opt_(p)
#endif
#ifndef _Printf_format_string_
#define _Printf_format_string_
#endif
#ifndef _Printf_format_string_params_
#define _Printf_format_string_params_(n)
#endif
@ -74,6 +77,9 @@
#ifndef _Inout_z_
#define _Inout_z_
#endif
#ifndef _Inout_z_count_
#define _Inout_z_count_(p)
#endif
#ifndef _Inout_cap_
#define _Inout_cap_(p)
#endif
@ -208,3 +214,9 @@ size_t _countof(T (&arr)[N])
#define ftruncate64 ftruncate
#endif
#ifndef _WIN32
typedef int SOCKET;
#define INVALID_SOCKET ((SOCKET)-1)
#define SOCKET_ERROR -1
#define closesocket close
#endif

View File

@ -87,7 +87,7 @@ namespace stdex
///
inline interval<T> operator+(_In_ const interval<T>& other) const
{
return interval<T>(start + other.start, end + other.end);i.
return interval<T>(start + other.start, end + other.end);
}
///

View File

@ -19,11 +19,8 @@
#include <ws2ipdef.h>
#endif
#include <ws2tcpip.h>
#elif defined(__APPLE__)
#include <netinet/in.h>
#else
#include <inaddr.h>
#include <in6addr.h>
#include <netinet/in.h>
#endif
#include <limits>
#include <list>
@ -55,7 +52,7 @@ enum class T : type
#elif defined(__APPLE__)
#define s6_words __u6_addr.__u6_addr16
#else
#error Unsupported platform
#define s6_words s6_addr16
#endif
namespace stdex
@ -173,7 +170,7 @@ namespace stdex
/// \endcond
public:
interval<size_t> interval; ///< Region of the last match
stdex::interval<size_t> interval; ///< Region of the last match
protected:
std::locale m_locale;

View File

@ -130,7 +130,7 @@ namespace stdex
protected:
std::chrono::nanoseconds m_timeout;
std::chrono::steady_clock::time_point m_last;
std::chrono::system_clock::time_point m_last;
T m_start, m_end, m_value;
};

View File

@ -9,6 +9,7 @@
#include "mapping.hpp"
#include "sgml_unicode.hpp"
#include "string.hpp"
#include <string.h>
#include <exception>
#include <string>

View File

@ -22,6 +22,7 @@
#else
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/stat.h>
#endif
#include <chrono>
@ -2364,7 +2365,7 @@ namespace stdex
{
if (this != std::addressof(other)) {
if (m_h != INVALID_SOCKET)
closesocket(m_h);
::closesocket(m_h);
m_h = other.m_h;
other.m_h = INVALID_SOCKET;
}
@ -2388,7 +2389,7 @@ namespace stdex
virtual ~socket()
{
if (m_h != INVALID_SOCKET)
closesocket(m_h);
::closesocket(m_h);
}
///
@ -2448,7 +2449,7 @@ namespace stdex
virtual void close()
{
if (m_h != INVALID_SOCKET) {
closesocket(m_h);
::closesocket(m_h);
m_h = INVALID_SOCKET;
}
m_state = state_t::ok;

View File

@ -11,6 +11,8 @@
#include "windows.h"
#include <stdlib.h>
#include <tchar.h>
#else
#include <sys/utsname.h>
#endif
#include <memory>
@ -23,13 +25,6 @@ namespace stdex
typedef uint16_t platform_id;
#else
typedef const char* platform_id;
inline bool operator ==(_In_ const platform_id a, _In_ const platform_id b) { return a == b; }
inline bool operator !=(_In_ const platform_id a, _In_ const platform_id b) { return a != b; }
inline bool operator <(_In_ const platform_id a, _In_ const platform_id b) { return a == IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) < 0; }
inline bool operator <=(_In_ const platform_id a, _In_ const platform_id b) { return a == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) <= 0; }
inline bool operator >(_In_ const platform_id a, _In_ const platform_id b) { return a != IMAGE_FILE_MACHINE_UNKNOWN && b == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) > 0; }
inline bool operator >=(_In_ const platform_id a, _In_ const platform_id b) { return b == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) >= 0; }
#endif
}
@ -39,6 +34,13 @@ constexpr stdex::platform_id IMAGE_FILE_MACHINE_I386 = "i386";
constexpr stdex::platform_id IMAGE_FILE_MACHINE_AMD64 = "x86_64";
constexpr stdex::platform_id IMAGE_FILE_MACHINE_ARMNT = "arm";
constexpr stdex::platform_id IMAGE_FILE_MACHINE_ARM64 = "aarch64";
inline bool operator ==(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return a == b; }
inline bool operator !=(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return a != b; }
inline bool operator <(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return a == IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) < 0; }
inline bool operator <=(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return a == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) <= 0; }
inline bool operator >(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return a != IMAGE_FILE_MACHINE_UNKNOWN && b == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) > 0; }
inline bool operator >=(_In_ const stdex::platform_id a, _In_ const stdex::platform_id b) { return b == IMAGE_FILE_MACHINE_UNKNOWN || a != IMAGE_FILE_MACHINE_UNKNOWN && b != IMAGE_FILE_MACHINE_UNKNOWN && strcmp(a, b) >= 0; }
#endif
namespace stdex
@ -98,7 +100,9 @@ namespace stdex
sys_info_t() :
os_platform(IMAGE_FILE_MACHINE_UNKNOWN),
#ifdef _WIN32
wow64(false),
#endif
interactive_process(true),
admin(false),
elevated(false)

View File

@ -11,7 +11,9 @@
#include <oaidl.h>
#include <tchar.h>
#else
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE // TODO: Make this -D compile-time project setting
#endif
#include <grp.h>
#include <pwd.h>
#include <string.h>

View File

@ -8,6 +8,7 @@
#include "compat.hpp"
#include "endian.hpp"
#include "math.hpp"
#include "string.hpp"
#include <stdint.h>
#ifndef _WIN32
#include <iconv.h>
@ -17,6 +18,11 @@
#include <memory>
#include <string>
#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace stdex
{
enum class charset_id : uint16_t {
@ -103,7 +109,7 @@ namespace stdex
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src)
{
_Assume_(src || !count_src);
count_src = stdex::strnlen(src, count_src);
count_src = stdex::strnlen<T_from>(src, count_src);
if (!count_src) _Unlikely_
return;
@ -767,3 +773,7 @@ namespace stdex
return wstr2str(src.c_str(), src.size(), charset);
}
}
#ifndef _WIN32
#pragma GCC diagnostic pop
#endif

View File

@ -6,6 +6,8 @@
#pragma once
#include "compat.hpp"
#include <stdexcept>
#include <utility>
namespace stdex
{