Drop several win32 specifics from the emugl layer
This commit is contained in:
parent
609d80395c
commit
3e6ac64cd0
5 changed files with 1 additions and 75 deletions
|
|
@ -17,14 +17,9 @@
|
||||||
|
|
||||||
#include "RenderThread.h"
|
#include "RenderThread.h"
|
||||||
#include "TcpStream.h"
|
#include "TcpStream.h"
|
||||||
#ifndef _WIN32
|
|
||||||
#include "UnixStream.h"
|
#include "UnixStream.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "Win32PipeStream.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "OpenglRender/render_api.h"
|
#include "OpenglRender/render_api.h"
|
||||||
|
|
||||||
|
|
@ -59,11 +54,7 @@ RenderServer *RenderServer::create(char* addr, size_t addrLen)
|
||||||
if (gRendererStreamMode == RENDER_API_STREAM_MODE_TCP) {
|
if (gRendererStreamMode == RENDER_API_STREAM_MODE_TCP) {
|
||||||
server->m_listenSock = new TcpStream();
|
server->m_listenSock = new TcpStream();
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
|
||||||
server->m_listenSock = new Win32PipeStream();
|
|
||||||
#else
|
|
||||||
server->m_listenSock = new UnixStream();
|
server->m_listenSock = new UnixStream();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char addrstr[SocketStream::MAX_ADDRSTR_LEN];
|
char addrstr[SocketStream::MAX_ADDRSTR_LEN];
|
||||||
|
|
@ -89,12 +80,6 @@ intptr_t RenderServer::main()
|
||||||
{
|
{
|
||||||
RenderThreadsSet threads;
|
RenderThreadsSet threads;
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
sigset_t set;
|
|
||||||
sigfillset(&set);
|
|
||||||
pthread_sigmask(SIG_SETMASK, &set, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
SocketStream *stream = m_listenSock->accept();
|
SocketStream *stream = m_listenSock->accept();
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,8 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifndef _WIN32
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
|
||||||
|
|
@ -214,11 +212,9 @@ public:
|
||||||
|
|
||||||
virtual intptr_t main() {
|
virtual intptr_t main() {
|
||||||
D("Entering render window thread thread\n");
|
D("Entering render window thread thread\n");
|
||||||
#ifndef _WIN32
|
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
sigfillset(&set);
|
sigfillset(&set);
|
||||||
pthread_sigmask(SIG_SETMASK, &set, NULL);
|
pthread_sigmask(SIG_SETMASK, &set, NULL);
|
||||||
#endif
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running) {
|
while (running) {
|
||||||
RenderWindowMessage msg;
|
RenderWindowMessage msg;
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#else
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SocketStream::SocketStream(size_t bufSize) :
|
SocketStream::SocketStream(size_t bufSize) :
|
||||||
IOStream(bufSize),
|
IOStream(bufSize),
|
||||||
|
|
@ -48,10 +43,8 @@ SocketStream::~SocketStream()
|
||||||
{
|
{
|
||||||
if (m_sock >= 0) {
|
if (m_sock >= 0) {
|
||||||
forceStop();
|
forceStop();
|
||||||
#ifndef _WIN32
|
|
||||||
if(close(m_sock) < 0)
|
if(close(m_sock) < 0)
|
||||||
perror("Closing SocketStream failed");
|
perror("Closing SocketStream failed");
|
||||||
#endif
|
|
||||||
// DBG("SocketStream::~close @ %d \n", m_sock);
|
// DBG("SocketStream::~close @ %d \n", m_sock);
|
||||||
m_sock = -1;
|
m_sock = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -169,15 +162,5 @@ int SocketStream::recv(void *buf, size_t len)
|
||||||
|
|
||||||
void SocketStream::forceStop() {
|
void SocketStream::forceStop() {
|
||||||
// Shutdown socket to force read/write errors.
|
// Shutdown socket to force read/write errors.
|
||||||
#ifdef _WIN32
|
|
||||||
::shutdown(m_sock, SD_BOTH);
|
|
||||||
// As documented by programmers on MSDN, shutdown implementation in Windows does
|
|
||||||
// NOT result to unblocking threads that are blocked on a recv on the socket
|
|
||||||
// being shut down. The only way to actually implement this behavior (expected
|
|
||||||
// by this forceStop() implementation) is to rudely close the socket.
|
|
||||||
::closesocket(m_sock);
|
|
||||||
m_sock = -1;
|
|
||||||
#else
|
|
||||||
::shutdown(m_sock, SHUT_RDWR);
|
::shutdown(m_sock, SHUT_RDWR);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#else
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LISTEN_BACKLOG 4
|
#define LISTEN_BACKLOG 4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,55 +15,21 @@
|
||||||
*/
|
*/
|
||||||
#include "TimeUtils.h"
|
#include "TimeUtils.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#elif defined(__linux__)
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#else
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
long long GetCurrentTimeMS()
|
long long GetCurrentTimeMS()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
static LARGE_INTEGER freq;
|
|
||||||
static bool bNotInit = true;
|
|
||||||
if ( bNotInit ) {
|
|
||||||
bNotInit = (QueryPerformanceFrequency( &freq ) == FALSE);
|
|
||||||
}
|
|
||||||
LARGE_INTEGER currVal;
|
|
||||||
QueryPerformanceCounter( &currVal );
|
|
||||||
|
|
||||||
return currVal.QuadPart / (freq.QuadPart / 1000);
|
|
||||||
|
|
||||||
#elif defined(__linux__)
|
|
||||||
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL;
|
long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL;
|
||||||
return iDiff;
|
return iDiff;
|
||||||
|
|
||||||
#else /* Others, e.g. OS X */
|
|
||||||
|
|
||||||
struct timeval now;
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
long long iDiff = (now.tv_sec * 1000LL) + now.tv_usec/1000LL;
|
|
||||||
return iDiff;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeSleepMS(int p_mili)
|
void TimeSleepMS(int p_mili)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
Sleep(p_mili);
|
|
||||||
#else
|
|
||||||
usleep(p_mili * 1000);
|
usleep(p_mili * 1000);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue