Skip to content
Snippets Groups Projects
Commit a9346c7e authored by Maxime Graulich's avatar Maxime Graulich
Browse files

ONELAB2: allow to compile without UDT library

parent d91a19a7
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,18 @@ set(SRC ...@@ -9,6 +9,18 @@ set(SRC
GmshNetworkClient.cpp GmshNetworkClient.cpp
GmshLocalClient.cpp) GmshLocalClient.cpp)
if(HAVE_FLTK)
set(SRC
${SRC}
OnelabWindow.cpp)
endif(HAVE_FLTK)
if(NOT ENABLE_UDT)
set(SRC
${SRC}
noudt.cpp)
endif(ENABLE_UDT)
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
append_gmsh_src(contrib/onelab2 "${SRC};${HDR}") append_gmsh_src(contrib/onelab2 "${SRC};${HDR}")
......
...@@ -19,6 +19,11 @@ typedef int socklen_t; ...@@ -19,6 +19,11 @@ typedef int socklen_t;
typedef int Socket; typedef int Socket;
#endif #endif
#include "GmshConfig.h"
#ifndef HAVE_UDT
#include "noudt.h"
#endif
typedef unsigned char UInt8; typedef unsigned char UInt8;
typedef unsigned short UInt16; typedef unsigned short UInt16;
typedef unsigned int UInt32; typedef unsigned int UInt32;
...@@ -26,6 +31,8 @@ typedef unsigned long long UInt64; ...@@ -26,6 +31,8 @@ typedef unsigned long long UInt64;
typedef struct {unsigned char bytes[16];} UInt128; typedef struct {unsigned char bytes[16];} UInt128;
typedef struct {UInt32 address; UInt16 port;} IPv4; typedef struct {UInt32 address; UInt16 port;} IPv4;
// TODO check double/float size
// host to network (and network to host) order, Reference RFC 791 // host to network (and network to host) order, Reference RFC 791
#define hton64 ntoh64 #define hton64 ntoh64
#define hton32 htonl #define hton32 htonl
...@@ -153,4 +160,9 @@ void ip4_socket_timeout(Socket d, long tos, long tous=0); ...@@ -153,4 +160,9 @@ void ip4_socket_timeout(Socket d, long tos, long tous=0);
inline void ip4_socket_reuse_address(Socket fd, bool reuse=true) {setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof reuse);} inline void ip4_socket_reuse_address(Socket fd, bool reuse=true) {setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof reuse);}
inline void ip4_socket_close(Socket fd) {/*if(-1 == */close(fd);} inline void ip4_socket_close(Socket fd) {/*if(-1 == */close(fd);}
Socket unix_socket(int socketType);
void unix_socket_listen(Socket fd, const char *sockname, int maxconnection=1024);
Socket unix_socket_accept(Socket fd);
Socket unix_socket_connect(Socket fd, const char *sockname);
#endif #endif
#include "noudt.h"
#include <sys/select.h>
#include <sys/types.h>
namespace UDT {
class Epoll
{
private:
std::set<SYSSOCKET> _fds;
static Epoll *_instance;
public:
Epoll() {}
static Epoll* epoll() {
if(!_instance) _instance = new Epoll();
return _instance;
}
void add_ssock(SYSSOCKET s) {_fds.insert(s);}
void remove_ssock(SYSSOCKET s) {
_fds.erase(s);
}
std::set<int>::iterator begin() {return _fds.begin();}
std::set<int>::iterator end() {return _fds.end();}
};
Epoll *Epoll::_instance = NULL;
int startup()
{
return 1;
}
int cleanup()
{
return 1;
}
int epoll_create()
{
return 1;
}
int epoll_add_ssock(int eid, SYSSOCKET s)
{
Epoll::epoll()->add_ssock(s);
return 1;
}
int epoll_remove_ssock(int eid, SYSSOCKET s)
{
Epoll::epoll()->remove_ssock(s);
return 1;
}
int epoll_wait(int eid, void* readfds, void* writefds, long msTimeOut,
std::set<SYSSOCKET>* lrfds, std::set<SYSSOCKET>* wrfds)
{
fd_set fds;
FD_ZERO(&fds);
for(std::set<SYSSOCKET>::const_iterator i = Epoll::epoll()->begin(); i != Epoll::epoll()->end(); i++)
FD_SET(*i, &fds);
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if(select(*Epoll::epoll()->begin()+1, &fds, NULL, NULL, /*&timeout*/NULL) > 0) {
for(std::set<SYSSOCKET>::const_iterator i = Epoll::epoll()->begin(); i != Epoll::epoll()->end(); i++) {
lrfds->insert(*i);
}
}
return 1;
}
}
#include <set>
#include <cstddef>
#ifdef WIN32
#ifndef __MINGW__
typedef SOCKET SYSSOCKET;
#else
typedef int SYSSOCKET;
#endif
#else
typedef int SYSSOCKET;
#endif
namespace UDT {
const int ERROR = -1;
int startup();
int cleanup();
int epoll_create();
int epoll_add_ssock(int eid, SYSSOCKET s);
int epoll_remove_ssock(int eid, SYSSOCKET s);
int epoll_wait(int eid, void* readfds, void* writefds, long msTimeOut,
std::set<SYSSOCKET>* lrfds = NULL, std::set<SYSSOCKET>* wrfds = NULL);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment