+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef __OSINCLUDE_H\r
-#define __OSINCLUDE_H\r
-\r
-//\r
-// This file contains any Linux specific functions.\r
-//\r
-\r
-/* WORKAROUND: linux builds seem not to define "linux" */\r
-/*#if !(defined(linux))\r
-#error Trying to include a Linux specific file in a non-Linux build.\r
-#endif*/\r
-\r
-#include <pthread.h>\r
-#include <semaphore.h>\r
-#include <assert.h>\r
-#include <errno.h>\r
-#include "Include/InitializeGlobals.h"\r
-#include "Include/PoolAlloc.h"\r
-\r
-#define _vsnprintf vsnprintf\r
-\r
-void DetachThreadLinux(void *);\r
-\r
-//\r
-// Thread Local Storage Operations\r
-//\r
-typedef unsigned int OS_TLSIndex;\r
-#define OS_INVALID_TLS_INDEX 0xFFFFFFFF\r
-\r
-OS_TLSIndex OS_AllocTLSIndex();\r
-bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);\r
-bool OS_FreeTLSIndex(OS_TLSIndex nIndex); \r
-\r
-\r
-inline void * OS_GetTLSValue(OS_TLSIndex nIndex)\r
-{\r
- //\r
- // This function should return 0 if nIndex is invalid.\r
- //\r
- assert(nIndex != OS_INVALID_TLS_INDEX);\r
- return (pthread_getspecific(nIndex)); \r
-}\r
-\r
-#endif // __OSINCLUDE_H\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// This file contains the Linux specific functions\r
-//\r
-#include "osinclude.h"\r
-#include "Initialisation.h"\r
-\r
-/*#if !(defined(linux))\r
-#error Trying to build a Linux specific file in a non-Linux build.\r
-#endif*/\r
-\r
-//\r
-// Thread cleanup\r
-//\r
-\r
-//\r
-// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects \r
-// the cleanup routine to return void.\r
-// \r
-void DetachThreadLinux(void *)\r
-{\r
- DetachThread();\r
-}\r
-\r
-\r
-//\r
-// Registers cleanup handler, sets cancel type and state, and excecutes the thread specific\r
-// cleanup handler. This function will be called in the Standalone.cpp for regression \r
-// testing. When OpenGL applications are run with the driver code, Linux OS does the \r
-// thread cleanup.\r
-// \r
-void OS_CleanupThreadData(void)\r
-{\r
- int old_cancel_state, old_cancel_type;\r
- void *cleanupArg = NULL;\r
-\r
- //\r
- // Set thread cancel state and push cleanup handler.\r
- //\r
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);\r
- pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);\r
-\r
- //\r
- // Put the thread in deferred cancellation mode.\r
- //\r
- pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);\r
-\r
- //\r
- // Pop cleanup handler and execute it prior to unregistering the cleanup handler.\r
- //\r
- pthread_cleanup_pop(1);\r
-\r
- //\r
- // Restore the thread's previous cancellation mode.\r
- //\r
- pthread_setcanceltype(old_cancel_state, NULL);\r
-}\r
-\r
-\r
-//\r
-// Thread Local Storage Operations\r
-//\r
-OS_TLSIndex OS_AllocTLSIndex()\r
-{\r
- pthread_key_t pPoolIndex;\r
-\r
- //\r
- // Create global pool key.\r
- //\r
- if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {\r
- assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");\r
- return false;\r
- }\r
- else\r
- return pPoolIndex;\r
-}\r
-\r
-\r
-bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)\r
-{\r
- if (nIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");\r
- return false;\r
- }\r
-\r
- if (pthread_setspecific(nIndex, lpvValue) == 0)\r
- return true;\r
- else\r
- return false;\r
-}\r
-\r
-\r
-bool OS_FreeTLSIndex(OS_TLSIndex nIndex)\r
-{\r
- if (nIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");\r
- return false;\r
- }\r
-\r
- //\r
- // Delete the global pool key.\r
- //\r
- if (pthread_key_delete(nIndex) == 0)\r
- return true;\r
- else\r
- return false;\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef __OSINCLUDE_H\r
-#define __OSINCLUDE_H\r
-\r
-//\r
-// This file contains contains the window's specific datatypes and\r
-// declares any windows specific functions.\r
-//\r
-\r
-#if !(defined(_WIN32) || defined(_WIN64))\r
-#error Trying to include a windows specific file in a non windows build.\r
-#endif\r
-\r
-#define STRICT\r
-#define VC_EXTRALEAN 1\r
-#include <windows.h>\r
-#include <assert.h>\r
-\r
-//\r
-// Thread Local Storage Operations\r
-//\r
-typedef DWORD OS_TLSIndex;\r
-#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)\r
-\r
-OS_TLSIndex OS_AllocTLSIndex();\r
-bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);\r
-bool OS_FreeTLSIndex(OS_TLSIndex nIndex);\r
-\r
-inline void* OS_GetTLSValue(OS_TLSIndex nIndex) \r
-{\r
- assert(nIndex != OS_INVALID_TLS_INDEX);\r
- return TlsGetValue(nIndex);\r
-}\r
-\r
-#endif // __OSINCLUDE_H\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "Initialisation.h"\r
-\r
-//\r
-// This file contains contains the window's specific functions\r
-//\r
-\r
-#if !(defined(_WIN32) || defined(_WIN64))\r
-#error Trying to build a windows specific file in a non windows build.\r
-#endif\r
-\r
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)\r
-{\r
- switch (fdwReason)\r
- {\r
- case DLL_PROCESS_ATTACH:\r
- if (!InitProcess())\r
- return false;\r
- break;\r
- case DLL_THREAD_ATTACH:\r
- if (!InitThread())\r
- return false;\r
- break;\r
-\r
- case DLL_THREAD_DETACH:\r
-\r
- if (!DetachThread())\r
- return false;\r
- break;\r
-\r
- case DLL_PROCESS_DETACH:\r
-\r
- DetachProcess();\r
- break;\r
-\r
- default:\r
- assert(0 && "DllMain(): Reason for calling DLL Main is unknown");\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// Thread Local Storage Operations\r
-//\r
-OS_TLSIndex OS_AllocTLSIndex()\r
-{\r
- DWORD dwIndex = TlsAlloc();\r
- if (dwIndex == TLS_OUT_OF_INDEXES) {\r
- assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");\r
- return (OS_INVALID_TLS_INDEX);\r
- }\r
-\r
- return dwIndex;\r
-}\r
-\r
-\r
-bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)\r
-{\r
- if (nIndex == OS_INVALID_TLS_INDEX)\r
- {\r
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");\r
- return false;\r
- }\r
-\r
- if (TlsSetValue(nIndex, lpvValue))\r
- return true;\r
- else\r
- return false;\r
-}\r
-\r
-\r
-bool OS_FreeTLSIndex(OS_TLSIndex nIndex)\r
-{\r
- if (nIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");\r
- return false;\r
- }\r
-\r
- if (TlsFree(nIndex))\r
- return true;\r
- else\r
- return false;\r
-}\r
-\r