Fixed compiling for msys2
This commit is contained in:
parent
6cd6b1b630
commit
3f97e249e1
1 changed files with 12 additions and 6 deletions
18
src/3rdparty/cpp-httplib/httplib.h
vendored
18
src/3rdparty/cpp-httplib/httplib.h
vendored
|
@ -37,12 +37,18 @@ typedef SOCKET socket_t;
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <cstring>
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
typedef int socket_t;
|
typedef int socket_t;
|
||||||
#endif
|
#endif
|
||||||
|
@ -291,7 +297,7 @@ inline void socket_printf(Stream& strm, const char* fmt, const Args& ...args)
|
||||||
|
|
||||||
inline int close_socket(socket_t sock)
|
inline int close_socket(socket_t sock)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(WIN32)
|
||||||
return closesocket(sock);
|
return closesocket(sock);
|
||||||
#else
|
#else
|
||||||
return close(sock);
|
return close(sock);
|
||||||
|
@ -309,7 +315,7 @@ inline bool read_and_close_socket(socket_t sock, T callback)
|
||||||
|
|
||||||
inline int shutdown_socket(socket_t sock)
|
inline int shutdown_socket(socket_t sock)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(WIN32)
|
||||||
return shutdown(sock, SD_BOTH);
|
return shutdown(sock, SD_BOTH);
|
||||||
#else
|
#else
|
||||||
return shutdown(sock, SHUT_RDWR);
|
return shutdown(sock, SHUT_RDWR);
|
||||||
|
@ -319,7 +325,7 @@ inline int shutdown_socket(socket_t sock)
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0)
|
socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(WIN32)
|
||||||
int opt = SO_SYNCHRONOUS_NONALERT;
|
int opt = SO_SYNCHRONOUS_NONALERT;
|
||||||
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char*)&opt, sizeof(opt));
|
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char*)&opt, sizeof(opt));
|
||||||
#endif
|
#endif
|
||||||
|
@ -830,7 +836,7 @@ inline int SocketStream::write(const char* ptr)
|
||||||
inline Server::Server()
|
inline Server::Server()
|
||||||
: svr_sock_(-1)
|
: svr_sock_(-1)
|
||||||
{
|
{
|
||||||
#ifndef _MSC_VER
|
#if !defined(_MSC_VER) && !defined(WIN32)
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue