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 "TcpStream.h"
|
||||
#ifndef _WIN32
|
||||
#include "UnixStream.h"
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include "Win32PipeStream.h"
|
||||
#endif
|
||||
|
||||
#include "OpenglRender/render_api.h"
|
||||
|
||||
|
|
@ -59,11 +54,7 @@ RenderServer *RenderServer::create(char* addr, size_t addrLen)
|
|||
if (gRendererStreamMode == RENDER_API_STREAM_MODE_TCP) {
|
||||
server->m_listenSock = new TcpStream();
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
server->m_listenSock = new Win32PipeStream();
|
||||
#else
|
||||
server->m_listenSock = new UnixStream();
|
||||
#endif
|
||||
}
|
||||
|
||||
char addrstr[SocketStream::MAX_ADDRSTR_LEN];
|
||||
|
|
@ -89,12 +80,6 @@ intptr_t RenderServer::main()
|
|||
{
|
||||
RenderThreadsSet threads;
|
||||
|
||||
#ifndef _WIN32
|
||||
sigset_t set;
|
||||
sigfillset(&set);
|
||||
pthread_sigmask(SIG_SETMASK, &set, NULL);
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
SocketStream *stream = m_listenSock->accept();
|
||||
if (!stream) {
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
|
@ -214,11 +212,9 @@ public:
|
|||
|
||||
virtual intptr_t main() {
|
||||
D("Entering render window thread thread\n");
|
||||
#ifndef _WIN32
|
||||
sigset_t set;
|
||||
sigfillset(&set);
|
||||
pthread_sigmask(SIG_SETMASK, &set, NULL);
|
||||
#endif
|
||||
bool running = true;
|
||||
while (running) {
|
||||
RenderWindowMessage msg;
|
||||
|
|
|
|||
|
|
@ -19,14 +19,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/un.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
SocketStream::SocketStream(size_t bufSize) :
|
||||
IOStream(bufSize),
|
||||
|
|
@ -48,10 +43,8 @@ SocketStream::~SocketStream()
|
|||
{
|
||||
if (m_sock >= 0) {
|
||||
forceStop();
|
||||
#ifndef _WIN32
|
||||
if(close(m_sock) < 0)
|
||||
perror("Closing SocketStream failed");
|
||||
#endif
|
||||
// DBG("SocketStream::~close @ %d \n", m_sock);
|
||||
m_sock = -1;
|
||||
}
|
||||
|
|
@ -169,15 +162,5 @@ int SocketStream::recv(void *buf, size_t len)
|
|||
|
||||
void SocketStream::forceStop() {
|
||||
// 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);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,8 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#define LISTEN_BACKLOG 4
|
||||
|
||||
|
|
|
|||
|
|
@ -15,55 +15,21 @@
|
|||
*/
|
||||
#include "TimeUtils.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#elif defined(__linux__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
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;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL;
|
||||
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)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(p_mili);
|
||||
#else
|
||||
usleep(p_mili * 1000);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue