From 6c9269b64f0b9f6d294ed483079de62203cdffc2 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 28 Nov 2017 11:15:16 +1100 Subject: [PATCH] [host] removed deprecated MTMemcpy from the project --- host/MTMemcpy.cpp | 97 --------------------------- host/MTMemcpy.h | 55 --------------- host/kvm-ivshmem-host.vcxproj | 2 - host/kvm-ivshmem-host.vcxproj.filters | 6 -- 4 files changed, 160 deletions(-) delete mode 100644 host/MTMemcpy.cpp delete mode 100644 host/MTMemcpy.h diff --git a/host/MTMemcpy.cpp b/host/MTMemcpy.cpp deleted file mode 100644 index cd2a5ca5..00000000 --- a/host/MTMemcpy.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -KVMGFX Client - A KVM Client for VGA Passthrough -Copyright (C) 2017 Geoffrey McRae - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "MTMemcpy.h" - -MTMemcpy::MTMemcpy() : - m_initialized(false) -{ - -} - -MTMemcpy::~MTMemcpy() -{ - DeInitialize(); -} - -DWORD WINAPI MTMemcpy::thread_copy_proc(LPVOID param) -{ - mt_cpy_t * p = (mt_cpy_t *)param; - - while (1) - { - WaitForSingleObject(p->s->hCopyStartSemaphores[p->ct], INFINITE); - memcpy(p->dest, p->src, p->size); - ReleaseSemaphore(p->s->hCopyStopSemaphores[p->ct], 1, NULL); - } - - return 0; -} - -bool MTMemcpy::Initialize() -{ - if (m_initialized) - DeInitialize(); - - for (int ctr = 0; ctr < NUM_CPY_THREADS; ctr++) - { - hCopyStartSemaphores[ctr] = CreateSemaphore(NULL, 0, 1, NULL); - hCopyStopSemaphores[ctr] = CreateSemaphore(NULL, 0, 1, NULL); - mtParamters[ctr].s = this; - mtParamters[ctr].ct = ctr; - hCopyThreads[ctr] = CreateThread(0, 0, thread_copy_proc, &mtParamters[ctr], 0, NULL); - } - - m_initialized = true; - return true; -} - -bool MTMemcpy::Copy(void * dest, void * src, size_t bytes) -{ - if (!m_initialized) - return false; - - //set up parameters - for (int ctr = 0; ctr < NUM_CPY_THREADS; ctr++) - { - mtParamters[ctr].dest = (char *)dest + ctr * bytes / NUM_CPY_THREADS; - mtParamters[ctr].src = (char *)src + ctr * bytes / NUM_CPY_THREADS; - mtParamters[ctr].size = (ctr + 1) * bytes / NUM_CPY_THREADS - ctr * bytes / NUM_CPY_THREADS; - ReleaseSemaphore(hCopyStartSemaphores[ctr], 1, NULL); - } - - //wait for all threads to finish - WaitForMultipleObjects(NUM_CPY_THREADS, hCopyStopSemaphores, TRUE, INFINITE); - - return true; -} - -void MTMemcpy::DeInitialize() -{ - if (!m_initialized) - return; - - for (int ctr = 0; ctr < NUM_CPY_THREADS; ctr++) - { - TerminateThread(hCopyThreads[ctr], 0); - CloseHandle(hCopyStartSemaphores[ctr]); - CloseHandle(hCopyStopSemaphores[ctr]); - } - - m_initialized = false; -} \ No newline at end of file diff --git a/host/MTMemcpy.h b/host/MTMemcpy.h deleted file mode 100644 index 61377f75..00000000 --- a/host/MTMemcpy.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -KVMGFX Client - A KVM Client for VGA Passthrough -Copyright (C) 2017 Geoffrey McRae - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#pragma once - -#define W32_LEAN_AND_MEAN -#include - -#define NUM_CPY_THREADS 4 - -class MTMemcpy -{ -public: - bool MTMemcpy::Initialize(); - void MTMemcpy::DeInitialize(); - bool MTMemcpy::Copy(void * dest, void * src, size_t bytes); - - MTMemcpy(); - ~MTMemcpy(); - -private: - bool m_initialized; - static DWORD WINAPI MTMemcpy::thread_copy_proc(LPVOID param); - - typedef struct - { - MTMemcpy * s; - int ct; - void * src; - void * dest; - size_t size; - } - mt_cpy_t; - - HANDLE hCopyThreads[NUM_CPY_THREADS] = { 0 }; - HANDLE hCopyStartSemaphores[NUM_CPY_THREADS] = { 0 }; - HANDLE hCopyStopSemaphores[NUM_CPY_THREADS] = { 0 }; - - mt_cpy_t mtParamters[NUM_CPY_THREADS] = { 0 }; -}; \ No newline at end of file diff --git a/host/kvm-ivshmem-host.vcxproj b/host/kvm-ivshmem-host.vcxproj index 08e21f9f..61403a50 100644 --- a/host/kvm-ivshmem-host.vcxproj +++ b/host/kvm-ivshmem-host.vcxproj @@ -166,7 +166,6 @@ - @@ -176,7 +175,6 @@ - diff --git a/host/kvm-ivshmem-host.vcxproj.filters b/host/kvm-ivshmem-host.vcxproj.filters index af212012..5c9be6fe 100644 --- a/host/kvm-ivshmem-host.vcxproj.filters +++ b/host/kvm-ivshmem-host.vcxproj.filters @@ -33,9 +33,6 @@ Source Files\Capture - - Source Files - Source Files\Capture @@ -65,9 +62,6 @@ Header Files - - Header Files - Header Files\Capture