mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 18:28:10 +09:00
poll: Fixed building with poll-emulation on UNIX.
This commit is contained in:
@@ -71,27 +71,27 @@ int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
typedef int (*poll_fn)(ssh_pollfd_t *, nfds_t, int);
|
||||||
|
static poll_fn win_poll;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef STRICT
|
#ifndef STRICT
|
||||||
#define STRICT
|
#define STRICT
|
||||||
#endif
|
#endif /* STRICT */
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
||||||
#define WS2_LIBRARY "ws2_32.dll"
|
#define WS2_LIBRARY "ws2_32.dll"
|
||||||
typedef int (*poll_fn)(ssh_pollfd_t *, nfds_t, int);
|
|
||||||
|
|
||||||
static poll_fn win_poll;
|
|
||||||
static HINSTANCE hlib;
|
static HINSTANCE hlib;
|
||||||
|
|
||||||
#else
|
#else /* _WIN32 */
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -214,10 +214,12 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
void ssh_poll_init(void) {
|
void ssh_poll_init(void) {
|
||||||
poll_fn wsa_poll = NULL;
|
poll_fn wsa_poll = NULL;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
hlib = LoadLibrary(WS2_LIBRARY);
|
hlib = LoadLibrary(WS2_LIBRARY);
|
||||||
if (hlib != NULL) {
|
if (hlib != NULL) {
|
||||||
wsa_poll = (poll_fn) GetProcAddress(hlib, "WSAPoll");
|
wsa_poll = (poll_fn) GetProcAddress(hlib, "WSAPoll");
|
||||||
}
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
if (wsa_poll == NULL) {
|
if (wsa_poll == NULL) {
|
||||||
win_poll = bsd_poll;
|
win_poll = bsd_poll;
|
||||||
|
|||||||
@@ -72,8 +72,9 @@ int ssh_socket_init(void) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_poll_init();
|
|
||||||
#endif
|
#endif
|
||||||
|
ssh_poll_init();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user