aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-07-09 16:44:39 +0200
committerDavid 'Digit' Turner <digit@google.com>2014-07-09 18:16:17 +0200
commitd50eea1bfe3883072b4f8dfcb663f0d83c36bab1 (patch)
treeb8ea40c428b9d4cf3f842ab1c0cbe52a1fcd883c /emulator/opengl
parent40cc9f9d50e998b0ce965b261ecf4d206a58618e (diff)
downloadsdk-d50eea1bfe3883072b4f8dfcb663f0d83c36bab1.zip
sdk-d50eea1bfe3883072b4f8dfcb663f0d83c36bab1.tar.gz
sdk-d50eea1bfe3883072b4f8dfcb663f0d83c36bab1.tar.bz2
emulator/opengl: Remove out-of-process handling code.
This removes the last pieces of shared/OpenglOsUtils which were never used since the code in render_api.cpp always used thread-based rendering, instead of process-based one. This feature could be re-implemented in the future, if really desirable. Change-Id: I551e0f3d6d5a06ff66cb40b007e2b24c295f1dd8
Diffstat (limited to 'emulator/opengl')
-rw-r--r--emulator/opengl/Android.mk1
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/Android.mk4
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/Android.mk4
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/Android.mk2
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/Android.mk6
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/render_api.cpp124
-rw-r--r--emulator/opengl/host/renderer/Android.mk6
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/Android.mk7
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/Android.mk48
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osProcess.h62
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp210
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp171
12 files changed, 17 insertions, 628 deletions
diff --git a/emulator/opengl/Android.mk b/emulator/opengl/Android.mk
index 6cab042..e566cf1 100644
--- a/emulator/opengl/Android.mk
+++ b/emulator/opengl/Android.mk
@@ -76,7 +76,6 @@ include $(EMUGL_PATH)/host/tools/emugen/Android.mk
include $(EMUGL_PATH)/googletest.mk
include $(EMUGL_PATH)/shared/emugl/common/Android.mk
-include $(EMUGL_PATH)/shared/OpenglOsUtils/Android.mk
include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk
# Host static libraries
diff --git a/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
index 7ab3f0a..e0eca6e 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
@@ -10,7 +10,7 @@ host_common_debug_CFLAGS :=
### host library #########################################
$(call emugl-begin-host-static-library,libGLESv1_dec)
-$(call emugl-import, libOpenglCodecCommon libOpenglOsUtils)
+$(call emugl-import, libOpenglCodecCommon)
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-gen-decoder,$(LOCAL_PATH),gl)
@@ -27,7 +27,7 @@ $(call emugl-end-module)
ifdef EMUGL_BUILD_64BITS
$(call emugl-begin-host64-static-library,lib64GLESv1_dec)
- $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-import, lib64OpenglCodecCommon)
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-gen-decoder,$(LOCAL_PATH),gl)
diff --git a/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
index bc04c25..f658f11 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
@@ -9,7 +9,7 @@ host_common_debug_CFLAGS :=
### host library ##########################################
$(call emugl-begin-host-static-library,libGLESv2_dec)
-$(call emugl-import, libOpenglCodecCommon libOpenglOsUtils)
+$(call emugl-import, libOpenglCodecCommon)
$(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
# For gl2_types.h !
@@ -24,7 +24,7 @@ $(call emugl-end-module)
### host library, 64-bit ####################################
ifdef EMUGL_BUILD_64BITS
$(call emugl-begin-host64-static-library,lib64GLESv2_dec)
- $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-import, lib64OpenglCodecCommon)
$(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
# For gl2_types.h !
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
index b215329..fdbedad 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
@@ -35,7 +35,6 @@ endif
$(call emugl-begin-host-static-library,libGLcommon)
-$(call emugl-import,libOpenglOsUtils)
translator_path := $(LOCAL_PATH)/..
LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
@@ -50,7 +49,6 @@ $(call emugl-end-module)
ifdef EMUGL_BUILD_64BITS
$(call emugl-begin-host64-static-library,lib64GLcommon)
- $(call emugl-import,lib64OpenglOsUtils)
translator_path := $(LOCAL_PATH)/..
LOCAL_SRC_FILES := $(host_common_SRC_FILES)
LOCAL_CFLAGS += -fPIC
diff --git a/emulator/opengl/host/libs/libOpenglRender/Android.mk b/emulator/opengl/host/libs/libOpenglRender/Android.mk
index 787ae83..ca5a08a 100644
--- a/emulator/opengl/host/libs/libOpenglRender/Android.mk
+++ b/emulator/opengl/host/libs/libOpenglRender/Android.mk
@@ -5,7 +5,7 @@ host_common_LDLIBS :=
ifeq ($(HOST_OS),linux)
host_OS_SRCS = NativeLinuxSubWindow.cpp
- host_common_LDLIBS += -lX11
+ host_common_LDLIBS += -lX11 -lrt
endif
ifeq ($(HOST_OS),darwin)
@@ -43,7 +43,7 @@ host_common_CFLAGS :=
### host libOpenglRender #################################################
$(call emugl-begin-host-shared-library,libOpenglRender)
-$(call emugl-import,libGLESv1_dec libGLESv2_dec lib_renderControl_dec libOpenglCodecCommon libOpenglOsUtils)
+$(call emugl-import,libGLESv1_dec libGLESv2_dec lib_renderControl_dec libOpenglCodecCommon)
LOCAL_LDLIBS += $(host_common_LDLIBS)
@@ -65,7 +65,7 @@ $(call emugl-end-module)
ifdef EMUGL_BUILD_64BITS
$(call emugl-begin-host64-shared-library,lib64OpenglRender)
- $(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon)
#LOCAL_LDFLAGS += -m64 # adding -m64 here doesn't work, because it somehow appear BEFORE -m32 in command-line.
LOCAL_LDLIBS += $(host_common_LDLIBS) -m64 # Put -m64 it in LOCAL_LDLIBS instead.
diff --git a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
index 42df668..9586091 100644
--- a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
@@ -17,7 +17,6 @@
#include "IOStream.h"
#include "FrameBuffer.h"
#include "RenderServer.h"
-#include "osProcess.h"
#include "TimeUtils.h"
#include "TcpStream.h"
@@ -31,25 +30,12 @@
#include "GLDispatch.h"
#include "GL2Dispatch.h"
-static osUtils::childProcess *s_renderProc = NULL;
static RenderServer *s_renderThread = NULL;
static char s_renderAddr[256];
static IOStream *createRenderThread(int p_stream_buffer_size,
unsigned int clientFlags);
-//
-// For now run the renderer as a thread inside the calling
-// process instead as running it in a separate process for all
-// platforms.
-// at the future we want it to run as a seperate process except for
-// Mac OS X since it is imposibble on this platform to make one process
-// render to a window created by another process.
-//
-//#ifdef __APPLE__
-#define RENDER_API_USE_THREAD
-//#endif
-
int initLibrary(void)
{
//
@@ -82,11 +68,10 @@ int initOpenGLRenderer(int width, int height, char* addr, size_t addrLen)
//
// Fail if renderer is already initialized
//
- if (s_renderProc || s_renderThread) {
+ if (s_renderThread) {
return false;
}
-#ifdef RENDER_API_USE_THREAD // should be defined for mac
//
// initialize the renderer and listen to connections
// on a thread in the current process.
@@ -104,110 +89,15 @@ int initOpenGLRenderer(int width, int height, char* addr, size_t addrLen)
s_renderThread->start();
-#else
- if (onPost) {
- // onPost callback not supported with separate renderer process.
- //
- // If we ever revive separate process support, we could make the choice
- // between thread and process at runtime instead of compile time, and
- // choose the thread path if an onPost callback is requested. Or, the
- // callback could be supported with a separate process using shmem or
- // other IPC mechanism.
- return false;
- }
-
- //
- // Launch emulator_renderer
- //
- char cmdLine[128];
- snprintf(cmdLine, 128, "emulator_renderer -windowid %d -port %d -x %d -y %d -width %d -height %d",
- (int)window, portNum, x, y, width, height);
-
- s_renderProc = osUtils::childProcess::create(cmdLine, NULL);
- if (!s_renderProc) {
- return false;
- }
-
- //
- // try to connect to the renderer in order to check it
- // was successfully initialized.
- //
- int nTrys = 0;
- IOStream *dummy = NULL;
- do {
- ++nTrys;
-
- //
- // Wait a bit to make the renderer process a chance to be
- // initialized.
- // On Windows we need during this time to handle windows
- // events since the renderer generates a subwindow of this
- // process's window, we need to be responsive for windows
- // during this time to let the renderer generates this subwindow.
- //
-#ifndef _WIN32
- TimeSleepMS(300);
-#else
- long long t0 = GetCurrentTimeMS();
- while( (GetCurrentTimeMS() - t0) < 300 ) {
- MSG msg;
- int n = 0;
- while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
- {
- n++;
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
- if (n == 0) TimeSleepMS(10);
- }
-#endif
-
- dummy = createRenderThread(8, 0);
-
- if (!dummy) {
- // stop if the process is no longer running
- if (!osUtils::isProcessRunning(s_renderProc->getPID())) {
- break;
- }
- }
- } while(!dummy && nTrys < 10); // give up after 3 seconds, XXX: ???
-
- if (!dummy) {
- //
- // Failed - make sure the process is killed
- //
- osUtils::KillProcess(s_renderProc->getPID(), true);
- delete s_renderProc;
- s_renderProc = NULL;
- return false;
- }
-
- // destroy the dummy connection
- delete dummy;
-#endif
-
return true;
}
void setPostCallback(OnPostFn onPost, void* onPostContext)
{
-#ifdef RENDER_API_USE_THREAD // should be defined for mac
FrameBuffer* fb = FrameBuffer::getFB();
if (fb) {
fb->setPostCallback(onPost, onPostContext);
}
-#else
- if (onPost) {
- // onPost callback not supported with separate renderer process.
- //
- // If we ever revive separate process support, we could make the choice
- // between thread and process at runtime instead of compile time, and
- // choose the thread path if an onPost callback is requested. Or, the
- // callback could be supported with a separate process using shmem or
- // other IPC mechanism.
- return false;
- }
-#endif
}
void getHardwareStrings(const char** vendor, const char** renderer, const char** version)
@@ -230,17 +120,7 @@ int stopOpenGLRenderer(void)
IOStream *dummy = createRenderThread(8, IOSTREAM_CLIENT_EXIT_SERVER);
if (!dummy) return false;
- if (s_renderProc) {
- //
- // wait for the process to exit
- //
- int exitStatus;
- ret = s_renderProc->wait(&exitStatus);
-
- delete s_renderProc;
- s_renderProc = NULL;
- }
- else if (s_renderThread) {
+ if (s_renderThread) {
// wait for the thread to exit
ret = s_renderThread->wait(NULL);
diff --git a/emulator/opengl/host/renderer/Android.mk b/emulator/opengl/host/renderer/Android.mk
index 55fcb80..81dcaf7 100644
--- a/emulator/opengl/host/renderer/Android.mk
+++ b/emulator/opengl/host/renderer/Android.mk
@@ -6,9 +6,9 @@ $(call emugl-import,libOpenglRender)
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS += -O0 -g
-#ifeq ($(HOST_OS),windows)
-#LOCAL_LDLIBS += -lws2_32
-#endif
+ifeq ($(HOST_OS),linux)
+LOCAL_LDLIBS += -lX11
+endif
$(call emugl-end-module)
diff --git a/emulator/opengl/shared/OpenglCodecCommon/Android.mk b/emulator/opengl/shared/OpenglCodecCommon/Android.mk
index 83090d8..0c3f827 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/Android.mk
+++ b/emulator/opengl/shared/OpenglCodecCommon/Android.mk
@@ -13,8 +13,11 @@ commonSources := \
host_commonSources := $(commonSources)
+host_commonLdLibs := -lstdc++
+
ifeq ($(HOST_OS),windows)
host_commonSources += Win32PipeStream.cpp
+ host_commonLdLibs += -lws2_32 -lpsapi
else
host_commonSources += UnixStream.cpp
endif
@@ -26,7 +29,7 @@ $(call emugl-begin-host-static-library,libOpenglCodecCommon)
LOCAL_SRC_FILES := $(host_commonSources)
$(call emugl-import, libemugl_common)
$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH))
-$(call emugl-export,LDLIBS,-lstdc++)
+$(call emugl-export,LDLIBS,$(host_commonLdLibs))
$(call emugl-end-module)
@@ -39,6 +42,6 @@ ifdef EMUGL_BUILD_64BITS
$(call emugl-import, lib64emugl_common)
$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH))
$(call emugl-export,CFLAGS,-m64 -fPIC)
- $(call emugl-export,LDLIBS,-lstdc++)
+ $(call emugl-export,LDLIBS,$(host_commonLdLibs))
$(call emugl-end-module)
endif
diff --git a/emulator/opengl/shared/OpenglOsUtils/Android.mk b/emulator/opengl/shared/OpenglOsUtils/Android.mk
deleted file mode 100644
index 4b1b05e..0000000
--- a/emulator/opengl/shared/OpenglOsUtils/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# This build script corresponds to a small library containing
-# OS-specific support functions for:
-# - thread-local storage
-# - dynamic library loading
-# - child process creation and wait (probably not needed in guest)
-#
-LOCAL_PATH := $(call my-dir)
-
-### Host library ##############################################
-
-host_common_SRC_FILES :=
-host_common_LDLIBS :=
-host_common_INCLUDES := $(LOCAL_PATH)
-
-ifeq ($(HOST_OS),windows)
- host_common_SRC_FILES += \
- osProcessWin.cpp \
-
- host_common_LDLIBS += -lws2_32 -lpsapi
-else
- host_common_SRC_FILES += \
- osProcessUnix.cpp \
-
- host_common_LDLIBS += -ldl
-endif
-
-ifeq ($(HOST_OS),linux)
- host_common_LDLIBS += -lpthread -lrt -lX11
-endif
-
-### 32-bit host library ####
-$(call emugl-begin-host-static-library,libOpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
- LOCAL_SRC_FILES = $(host_common_SRC_FILES)
- $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
- $(call emugl-import,libemugl_common)
-$(call emugl-end-module)
-
-### 64-bit host library ####
-ifdef EMUGL_BUILD_64BITS
- $(call emugl-begin-host64-static-library,lib64OpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
- LOCAL_SRC_FILES = $(host_common_SRC_FILES)
- $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
- $(call emugl-import,lib64emugl_common)
- $(call emugl-export,CFLAGS,-m64 -fPIC)
- $(call emugl-end-module)
-endif
diff --git a/emulator/opengl/shared/OpenglOsUtils/osProcess.h b/emulator/opengl/shared/OpenglOsUtils/osProcess.h
deleted file mode 100644
index 82b31b3..0000000
--- a/emulator/opengl/shared/OpenglOsUtils/osProcess.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef _OSUTILS_PROCESS_H
-#define _OSUTILS_PROCESS_H
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-namespace osUtils {
-
-class childProcess
-{
-public:
- static childProcess *create(const char *p_cmdLine, const char *p_startdir);
- ~childProcess();
-
- int getPID()
- {
-#ifdef _WIN32
- return m_proc.dwProcessId;
-#else
- return(m_pid);
-#endif
- }
-
- int tryWait(bool& isAlive);
- bool wait(int *exitStatus);
-
-private:
- childProcess() {};
-
-private:
-#ifdef _WIN32
- PROCESS_INFORMATION m_proc;
-#else
- int m_pid;
-#endif
-};
-
-int ProcessGetPID();
-int ProcessGetTID();
-bool ProcessGetName(char *p_outName, int p_outNameLen);
-int KillProcess(int pid, bool wait);
-bool isProcessRunning(int pid);
-
-} // of namespace osUtils
-
-#endif
diff --git a/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp b/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp
deleted file mode 100644
index c97ff58..0000000
--- a/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "osProcess.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <poll.h>
-#include <pthread.h>
-#include <string.h>
-#include <pwd.h>
-#include <paths.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <assert.h>
-
-namespace osUtils {
-
-//
-// buildArgList converts a command line into null terminated argument list.
-// to be used with execv or execvp.
-// each argument is seperated by space or tab, to specify multiple words
-// at the same argument place it inside single-quoted or double-quoted string.
-//
-static char **buildArgList(const char *command)
-{
- char **argv = NULL;
- int argvSize = 0;
- int nArgs = 0;
- char *tmpcmd = strdup(command);
- char *t = tmpcmd;
- char *strStart = NULL;
- int i = 0;
-
- #define ADD_ARG \
- { \
- nArgs++; \
- if (!argv) { \
- argvSize = 12; \
- argv = (char **)malloc(argvSize * sizeof(char *)); \
- } \
- else if (nArgs > argvSize) { \
- argvSize += 12; \
- argv = (char **)realloc(argv, argvSize * sizeof(char *)); \
- } \
- argv[nArgs-1] = t; \
- t = NULL; \
- }
-
- while( tmpcmd[i] != '\0' ) {
- if (!strStart) {
- if (tmpcmd[i] == '"' || tmpcmd[i] == '\'') {
- strStart = &tmpcmd[i];
- }
- else if (tmpcmd[i] == ' ' || tmpcmd[i] == '\t') {
- tmpcmd[i] = '\0';
- if (t) ADD_ARG;
- }
- else if (!t) {
- t = &tmpcmd[i];
- }
- }
- else if (tmpcmd[i] == *strStart) {
- t = strStart;
- strStart = NULL;
- }
-
- i++;
- }
- if (t) {
- ADD_ARG;
- }
- if (nArgs > 0) {
- ADD_ARG; // for NULL terminating list
- }
-
- return argv;
-}
-
-static pid_t start_process(const char *command,const char *startDir)
-{
- pid_t pid;
-
- pid = fork();
-
- if (pid < 0) {
- return pid;
- }
- else if (pid == 0) {
- //
- // Close all opened file descriptors
- //
- for (int i=3; i<256; i++) {
- close(i);
- }
-
- if (startDir) {
- chdir(startDir);
- }
-
- char **argv = buildArgList(command);
- if (!argv) {
- return -1;
- }
- execvp(argv[0], argv);
-
- perror("execl");
- exit(-101);
- }
-
- return pid;
-}
-
-childProcess *
-childProcess::create(const char *p_cmdLine, const char *p_startdir)
-{
- childProcess *child = new childProcess();
- if (!child) {
- return NULL;
- }
-
- child->m_pid = start_process(p_cmdLine, p_startdir);
- if (child->m_pid < 0) {
- delete child;
- return NULL;
- }
-
- return child;
-}
-
-childProcess::~childProcess()
-{
-}
-
-bool
-childProcess::wait(int *exitStatus)
-{
- int ret=0;
- if (m_pid>0) {
- pid_t pid = waitpid(m_pid,&ret,0);
- if (pid != -1) {
- m_pid=-1;
- if (exitStatus) {
- *exitStatus = ret;
- }
- return true;
- }
- }
- return false;
-}
-
-int
-childProcess::tryWait(bool &isAlive)
-{
- int ret=0;
- isAlive = false;
- if (m_pid>0) {
- pid_t pid = waitpid(m_pid,&ret,WNOHANG);
- if (pid == 0) {
- isAlive = true;
- }
- }
-
- return ((char)WEXITSTATUS(ret));
-}
-
-int ProcessGetPID()
-{
- return getpid();
-}
-
-int KillProcess(int pid, bool wait)
-{
- if (pid<1) {
- return false;
- }
-
- if (0!=kill(pid,SIGTERM)) {
- return false;
- }
-
- if (wait) {
- if (waitpid(pid,NULL,0)<0) {
- return false;
- }
- }
-
- return true;
-}
-
-bool isProcessRunning(int pid)
-{
- return (kill(pid,0) == 0);
-}
-
-} // of namespace osUtils
diff --git a/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp b/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp
deleted file mode 100644
index 6ff0fdf..0000000
--- a/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "osProcess.h"
-#include <windows.h>
-#include <string>
-#include <stdlib.h>
-#include <psapi.h>
-
-namespace osUtils {
-
-childProcess *
-childProcess::create(const char *p_cmdLine, const char *p_startdir)
-{
- childProcess *child = new childProcess();
- if (!child) {
- return NULL;
- }
-
- STARTUPINFOA si;
- ZeroMemory(&si, sizeof(si));
-
- ZeroMemory(&child->m_proc, sizeof(child->m_proc));
- BOOL ret = CreateProcessA(
- NULL ,
- (LPSTR)p_cmdLine,
- NULL,
- NULL,
- FALSE,
- CREATE_DEFAULT_ERROR_MODE,
- NULL,
- (p_startdir != NULL ? p_startdir : ".\\"),
- &si,
- &child->m_proc);
- if (ret == 0) {
- delete child;
- return NULL;
- }
-
- // close the thread handle we do not need it,
- // keep the process handle for wait/trywait operations, will
- // be closed on destruction
- CloseHandle(child->m_proc.hThread);
-
- return child;
-}
-
-childProcess::~childProcess()
-{
- if (m_proc.hProcess) {
- CloseHandle(m_proc.hProcess);
- }
-}
-
-bool
-childProcess::wait(int *exitStatus)
-{
-DWORD _exitStatus;
-
- if (WaitForSingleObject(m_proc.hProcess, INFINITE) == WAIT_FAILED) {
- return false;
- }
-
- if (!GetExitCodeProcess(m_proc.hProcess, &_exitStatus))
- {
- return false;
- }
-
- if (exitStatus) {
- *exitStatus = _exitStatus;
- }
-
- return true;
-}
-
-int
-childProcess::tryWait(bool& isAlive)
-{
- DWORD status = WaitForSingleObject(m_proc.hProcess, 0);
-
- if(status == WAIT_OBJECT_0)
- {
- // process has exited
- isAlive = false;
- GetExitCodeProcess(m_proc.hProcess, &status);
- }
- else if (status == WAIT_TIMEOUT)
- {
- isAlive = true;
- status = 0;
- }
-
- return status;
-
-}
-
-int ProcessGetPID()
-{
- return GetCurrentProcessId();
-}
-
-int ProcessGetTID()
-{
- return GetCurrentThreadId();
-}
-
-bool ProcessGetName(char *p_outName, int p_outNameLen)
-{
- return 0 != GetModuleFileNameEx( GetCurrentProcess(), NULL, p_outName, p_outNameLen);
-}
-
-int KillProcess(int pid, bool wait)
-{
- DWORD exitStatus = 1;
- HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
-
- if (NULL == hProc) {
- return 0;
- }
-
- //
- // Terminate the process
- //
- TerminateProcess(hProc, 0x55);
-
- if (wait) {
- //
- // Wait for it to be terminated
- //
- if(WaitForSingleObject(hProc, INFINITE) == WAIT_FAILED) {
- CloseHandle(hProc);
- return 0;
- }
-
- if (!GetExitCodeProcess(hProc, &exitStatus)) {
- CloseHandle(hProc);
- return 0;
- }
- }
-
- CloseHandle(hProc);
-
- return exitStatus;
-}
-
-bool isProcessRunning(int pid)
-{
- bool isRunning = false;
-
- HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
- if (NULL != process) {
- DWORD ret = WaitForSingleObject(process, 0);
- CloseHandle(process);
- isRunning = (ret == WAIT_TIMEOUT);
- }
- return isRunning;
-}
-
-} // of namespace osUtils