diff options
Diffstat (limited to 'src/gallium/auxiliary/os')
-rw-r--r-- | src/gallium/auxiliary/os/os_memory.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/os/os_memory_win32k.h | 123 | ||||
-rw-r--r-- | src/gallium/auxiliary/os/os_misc.c | 120 | ||||
-rw-r--r-- | src/gallium/auxiliary/os/os_misc.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/os/os_time.c | 50 |
5 files changed, 6 insertions, 293 deletions
diff --git a/src/gallium/auxiliary/os/os_memory.h b/src/gallium/auxiliary/os/os_memory.h index 91a84a24bc8..46a6b6e4572 100644 --- a/src/gallium/auxiliary/os/os_memory.h +++ b/src/gallium/auxiliary/os/os_memory.h @@ -71,10 +71,6 @@ os_free_aligned(void *ptr); # include "os_memory_debug.h" -#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) - -# include "os_memory_win32k.h" - #else # include "os_memory_stdc.h" diff --git a/src/gallium/auxiliary/os/os_memory_win32k.h b/src/gallium/auxiliary/os/os_memory_win32k.h deleted file mode 100644 index d56d6908722..00000000000 --- a/src/gallium/auxiliary/os/os_memory_win32k.h +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** - * - * Copyright 2008-2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -/* - * OS memory management abstractions for Windows kernel. - */ - - -#ifndef _OS_MEMORY_H_ -#error "Must not be included directly. Include os_memory.h instead" -#endif - - -#include "pipe/p_compiler.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) - -void * __stdcall -EngAllocMem(unsigned long Flags, - unsigned long MemSize, - unsigned long Tag); - -void __stdcall -EngFreeMem(void *Mem); - -#define os_malloc(_size) EngAllocMem(0, _size, 'D3AG') -#define os_calloc(_count, _size) EngAllocMem(1, (_count)*(_size), 'D3AG') -#define _os_free(_ptr) EngFreeMem(_ptr) - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) - -void * -ExAllocatePool(unsigned long PoolType, - size_t NumberOfBytes); - -void -ExFreePool(void *P); - -#define os_malloc(_size) ExAllocatePool(0, _size) -#define _os_free(_ptr) ExFreePool(_ptr) - -static INLINE void * -os_calloc(unsigned count, unsigned size) -{ - void *ptr = os_malloc(count * size); - if (ptr) { - memset(ptr, 0, count * size); - } - return ptr; -} - -#else - -#error "Unsupported subsystem" - -#endif - - -static INLINE void -os_free( void *ptr ) -{ - if (ptr) { - _os_free(ptr); - } -} - - -static INLINE void * -os_realloc(void *old_ptr, unsigned old_size, unsigned new_size) -{ - void *new_ptr = NULL; - - if (new_size != 0) { - unsigned copy_size = old_size < new_size ? old_size : new_size; - new_ptr = os_malloc( new_size ); - if (new_ptr && old_ptr && copy_size) { - memcpy(new_ptr, old_ptr, copy_size); - } - } - - os_free(old_ptr); - - return new_ptr; -} - - -#ifdef __cplusplus -} -#endif - - -#include "os_memory_aligned.h" diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c index 384988017b7..5744dd5b4fc 100644 --- a/src/gallium/auxiliary/os/os_misc.c +++ b/src/gallium/auxiliary/os/os_misc.c @@ -31,19 +31,7 @@ #include <stdarg.h> -#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY - -#include <windows.h> -#include <winddi.h> - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) - -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> -#include <types.h> - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers @@ -59,44 +47,16 @@ #endif -#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY -static INLINE void -_EngDebugPrint(const char *format, ...) -{ - va_list ap; - va_start(ap, format); - EngDebugPrint("", (PCHAR)format, ap); - va_end(ap); -} -#endif - - void os_log_message(const char *message) { -#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) - _EngDebugPrint("%s", message); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) OutputDebugStringA(message); if(GetConsoleWindow() && !IsDebuggerPresent()) { fflush(stdout); fputs(message, stderr); fflush(stderr); } -#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) - wchar_t *wide_format; - long wide_str_len; - /* Format is ascii - needs to be converted to wchar_t for printing */ - wide_str_len = MultiByteToWideChar(CP_ACP, 0, message, -1, NULL, 0); - wide_format = (wchar_t *) malloc((wide_str_len+1) * sizeof(wchar_t)); - if (wide_format) { - MultiByteToWideChar(CP_ACP, 0, message, -1, - wide_format, wide_str_len); - NKDbgPrintfW(wide_format, wide_format); - free(wide_format); - } -#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) - /* TODO */ #else /* !PIPE_SUBSYSTEM_WINDOWS */ fflush(stdout); fputs(message, stderr); @@ -104,85 +64,9 @@ os_log_message(const char *message) } -#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY -static const char * -find(const char *start, const char *end, char c) -{ - const char *p; - for(p = start; !end || p != end; ++p) { - if(*p == c) - return p; - if(*p < 32) - break; - } - return NULL; -} - -static int -compare(const char *start, const char *end, const char *s) -{ - const char *p, *q; - for(p = start, q = s; p != end && *q != '\0'; ++p, ++q) { - if(*p != *q) - return 0; - } - return p == end && *q == '\0'; -} - -static void -copy(char *dst, const char *start, const char *end, size_t n) -{ - const char *p; - char *q; - for(p = start, q = dst, n = n - 1; p != end && n; ++p, ++q, --n) - *q = *p; - *q = '\0'; -} -#endif - - const char * os_get_option(const char *name) { -#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) - /* EngMapFile creates the file if it does not exists, so it must either be - * disabled on release versions (or put in a less conspicuous place). */ -#ifdef DEBUG - const char *result = NULL; - ULONG_PTR iFile = 0; - const void *pMap = NULL; - const char *sol, *eol, *sep; - static char output[1024]; - - pMap = EngMapFile(L"\\??\\c:\\gallium.cfg", 0, &iFile); - if(pMap) { - sol = (const char *)pMap; - while(1) { - /* TODO: handle LF line endings */ - eol = find(sol, NULL, '\r'); - if(!eol || eol == sol) - break; - sep = find(sol, eol, '='); - if(!sep) - break; - if(compare(sol, sep, name)) { - copy(output, sep + 1, eol, sizeof(output)); - result = output; - break; - } - sol = eol + 2; - } - EngUnmapFile(iFile); - } - return result; -#else - return NULL; -#endif -#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) - /* TODO: implement */ - return NULL; -#else return getenv(name); -#endif } diff --git a/src/gallium/auxiliary/os/os_misc.h b/src/gallium/auxiliary/os/os_misc.h index 48522dac4d7..5029ab96aac 100644 --- a/src/gallium/auxiliary/os/os_misc.h +++ b/src/gallium/auxiliary/os/os_misc.h @@ -66,7 +66,7 @@ extern "C" { /* * Abort the program. */ -#if defined(DEBUG) || defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) +#if defined(DEBUG) # define os_abort() os_break() #else # define os_abort() abort() diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c index 73d86296d91..3e9d50a598a 100644 --- a/src/gallium/auxiliary/os/os_time.c +++ b/src/gallium/auxiliary/os/os_time.c @@ -37,13 +37,7 @@ #if defined(PIPE_OS_UNIX) # include <sys/time.h> /* timeval */ -#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) -# include <windows.h> -# include <winddi.h> -#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) -# include <windows.h> -extern VOID KeQuerySystemTime(PLARGE_INTEGER); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) # include <windows.h> #else # error Unsupported OS @@ -61,16 +55,7 @@ os_time_get(void) gettimeofday(&tv, NULL); return tv.tv_usec + tv.tv_sec*1000000LL; -#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) - - static LONGLONG frequency; - LONGLONG counter; - if(!frequency) - EngQueryPerformanceFrequency(&frequency); - EngQueryPerformanceCounter(&counter); - return counter*INT64_C(1000000)/frequency; - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) static LARGE_INTEGER frequency; LARGE_INTEGER counter; @@ -79,40 +64,11 @@ os_time_get(void) QueryPerformanceCounter(&counter); return counter.QuadPart*INT64_C(1000000)/frequency.QuadPart; -#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) - - /* Updated every 10 miliseconds, measured in units of 100 nanoseconds. - * http://msdn.microsoft.com/en-us/library/ms801642.aspx */ - LARGE_INTEGER counter; - KeQuerySystemTime(&counter); - return counter.QuadPart/10; - #endif } -#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) - -void -os_time_sleep(int64_t usecs) -{ - static LONGLONG frequency; - LONGLONG start, curr, end; - - EngQueryPerformanceCounter(&start); - - if(!frequency) - EngQueryPerformanceFrequency(&frequency); - - end = start + (usecs * frequency + 999999LL)/1000000LL; - - do { - EngQueryPerformanceCounter(&curr); - } while(start <= curr && curr < end || - end < start && (curr < end || start <= curr)); -} - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) void os_time_sleep(int64_t usecs) |