~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/shader/slang/OSDependent/Windows/ossource.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
//Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3
 
//All rights reserved.
4
 
//
5
 
//Redistribution and use in source and binary forms, with or without
6
 
//modification, are permitted provided that the following conditions
7
 
//are met:
8
 
//
9
 
//    Redistributions of source code must retain the above copyright
10
 
//    notice, this list of conditions and the following disclaimer.
11
 
//
12
 
//    Redistributions in binary form must reproduce the above
13
 
//    copyright notice, this list of conditions and the following
14
 
//    disclaimer in the documentation and/or other materials provided
15
 
//    with the distribution.
16
 
//
17
 
//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18
 
//    contributors may be used to endorse or promote products derived
19
 
//    from this software without specific prior written permission.
20
 
//
21
 
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
 
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
 
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
 
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
 
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
 
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
 
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
 
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
 
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
 
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
 
//POSSIBILITY OF SUCH DAMAGE.
33
 
//
34
 
 
35
 
#include "Initialisation.h"
36
 
 
37
 
//
38
 
// This file contains contains the window's specific functions
39
 
//
40
 
 
41
 
#if !(defined(_WIN32) || defined(_WIN64))
42
 
#error Trying to build a windows specific file in a non windows build.
43
 
#endif
44
 
 
45
 
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
46
 
{
47
 
    switch (fdwReason)
48
 
    {
49
 
        case DLL_PROCESS_ATTACH:
50
 
            if (!InitProcess())
51
 
                return false;
52
 
            break;
53
 
        case DLL_THREAD_ATTACH:
54
 
            if (!InitThread())
55
 
                return false;
56
 
            break;
57
 
 
58
 
        case DLL_THREAD_DETACH:
59
 
 
60
 
            if (!DetachThread())
61
 
                return false;
62
 
            break;
63
 
 
64
 
        case DLL_PROCESS_DETACH:
65
 
 
66
 
            DetachProcess();
67
 
            break;
68
 
 
69
 
        default:
70
 
            assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
71
 
            return false;
72
 
    }
73
 
 
74
 
    return true;
75
 
}
76
 
 
77
 
//
78
 
// Thread Local Storage Operations
79
 
//
80
 
OS_TLSIndex OS_AllocTLSIndex()
81
 
{
82
 
    DWORD dwIndex = TlsAlloc();
83
 
    if (dwIndex == TLS_OUT_OF_INDEXES) {
84
 
        assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
85
 
        return (OS_INVALID_TLS_INDEX);
86
 
    }
87
 
 
88
 
    return dwIndex;
89
 
}
90
 
 
91
 
 
92
 
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
93
 
{
94
 
    if (nIndex == OS_INVALID_TLS_INDEX)
95
 
    {
96
 
        assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
97
 
        return false;
98
 
    }
99
 
 
100
 
    if (TlsSetValue(nIndex, lpvValue))
101
 
        return true;
102
 
    else
103
 
        return false;
104
 
}
105
 
 
106
 
 
107
 
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
108
 
{
109
 
    if (nIndex == OS_INVALID_TLS_INDEX) {
110
 
        assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
111
 
        return false;
112
 
    }
113
 
 
114
 
    if (TlsFree(nIndex))
115
 
        return true;
116
 
    else
117
 
        return false;
118
 
}
119