~ubuntu-branches/ubuntu/precise/wine1.3/precise

« back to all changes in this revision

Viewing changes to dlls/msvcp60/misc.c

  • Committer: Package Import Robot
  • Author(s): Scott Ritchie
  • Date: 2012-01-17 09:00:34 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120117090034-eyhpp02jawlvrrkc
Tags: 1.3.37-0ubuntu1
* New upstream release
  - Many changes
* Convert to 3.0 source format
* debian/control:
  - Remove pre-multiarch amd64 build depends
  - Remove quilt build depends
  - Recommend proper gecko versions
* debian/rules:
  - Remove manual dh_quilt patch and unpatch
  - No need to uuencode/uudecode anymore with new source format

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Piotr Caban for CodeWeavers
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <stdarg.h>
 
22
#include <limits.h>
 
23
 
 
24
#include "msvcp.h"
 
25
 
 
26
#include "windef.h"
 
27
#include "winbase.h"
 
28
#include "wine/debug.h"
 
29
WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
 
30
 
 
31
/* ??0_Mutex@std@@QAE@XZ */
 
32
/* ??0_Mutex@std@@QEAA@XZ */
 
33
DEFINE_THISCALL_WRAPPER(mutex_ctor, 4)
 
34
mutex* __thiscall mutex_ctor(mutex *this)
 
35
{
 
36
    this->mutex = CreateMutexW(NULL, FALSE, NULL);
 
37
    return this;
 
38
}
 
39
 
 
40
/* ??1_Mutex@std@@QAE@XZ */
 
41
/* ??1_Mutex@std@@QEAA@XZ */
 
42
DEFINE_THISCALL_WRAPPER(mutex_dtor, 4)
 
43
void __thiscall mutex_dtor(mutex *this)
 
44
{
 
45
    CloseHandle(this->mutex);
 
46
}
 
47
 
 
48
/* ?_Lock@_Mutex@std@@QAEXXZ */
 
49
/* ?_Lock@_Mutex@std@@QEAAXXZ */
 
50
DEFINE_THISCALL_WRAPPER(mutex_lock, 4)
 
51
void __thiscall mutex_lock(mutex *this)
 
52
{
 
53
    WaitForSingleObject(this->mutex, INFINITE);
 
54
}
 
55
 
 
56
/* ?_Unlock@_Mutex@std@@QAEXXZ */
 
57
/* ?_Unlock@_Mutex@std@@QEAAXXZ */
 
58
DEFINE_THISCALL_WRAPPER(mutex_unlock, 4)
 
59
void __thiscall mutex_unlock(mutex *this)
 
60
{
 
61
    ReleaseMutex(this->mutex);
 
62
}
 
63
 
 
64
/* ?_Mutex_Lock@_Mutex@std@@CAXPAV12@@Z */
 
65
/* ?_Mutex_Lock@_Mutex@std@@CAXPEAV12@@Z */
 
66
void CDECL mutex_mutex_lock(mutex *m)
 
67
{
 
68
    mutex_lock(m);
 
69
}
 
70
 
 
71
/* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
 
72
/* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
 
73
void CDECL mutex_mutex_unlock(mutex *m)
 
74
{
 
75
    mutex_unlock(m);
 
76
}
 
77
 
 
78
/* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
 
79
/* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
 
80
void CDECL mutex_mutex_ctor(mutex *m)
 
81
{
 
82
    mutex_ctor(m);
 
83
}
 
84
 
 
85
/* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
 
86
/* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
 
87
void CDECL mutex_mutex_dtor(mutex *m)
 
88
{
 
89
    mutex_dtor(m);
 
90
}
 
91
 
 
92
static CRITICAL_SECTION lockit_cs[_MAX_LOCK];
 
93
 
 
94
/* ?_Lockit_ctor@_Lockit@std@@SAXH@Z */
 
95
void __cdecl _Lockit_init(int locktype) {
 
96
    InitializeCriticalSection(&lockit_cs[locktype]);
 
97
    lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
 
98
}
 
99
 
 
100
/* ?_Lockit_dtor@_Lockit@std@@SAXH@Z */
 
101
void __cdecl _Lockit_free(int locktype)
 
102
{
 
103
    lockit_cs[locktype].DebugInfo->Spare[0] = 0;
 
104
    DeleteCriticalSection(&lockit_cs[locktype]);
 
105
}
 
106
 
 
107
void init_lockit(void) {
 
108
    int i;
 
109
 
 
110
    for(i=0; i<_MAX_LOCK; i++)
 
111
        _Lockit_init(i);
 
112
}
 
113
 
 
114
void free_lockit(void) {
 
115
    int i;
 
116
 
 
117
    for(i=0; i<_MAX_LOCK; i++)
 
118
        _Lockit_free(i);
 
119
}
 
120
 
 
121
/* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@H@Z */
 
122
/* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@H@Z */
 
123
void __cdecl _Lockit__Lockit_ctor_locktype(_Lockit *lockit, int locktype)
 
124
{
 
125
    lockit->locktype = locktype;
 
126
    EnterCriticalSection(&lockit_cs[locktype]);
 
127
}
 
128
 
 
129
/* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@@Z */
 
130
/* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@@Z */
 
131
void __cdecl _Lockit__Lockit_ctor(_Lockit *lockit)
 
132
{
 
133
    _Lockit__Lockit_ctor_locktype(lockit, 0);
 
134
}
 
135
 
 
136
/* ??0_Lockit@std@@QAE@H@Z */
 
137
/* ??0_Lockit@std@@QEAA@H@Z */
 
138
DEFINE_THISCALL_WRAPPER(_Lockit_ctor_locktype, 8)
 
139
_Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
 
140
{
 
141
    _Lockit__Lockit_ctor_locktype(this, locktype);
 
142
    return this;
 
143
}
 
144
 
 
145
/* ??0_Lockit@std@@QAE@XZ */
 
146
/* ??0_Lockit@std@@QEAA@XZ */
 
147
DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
 
148
_Lockit* __thiscall _Lockit_ctor(_Lockit *this)
 
149
{
 
150
    _Lockit__Lockit_ctor_locktype(this, 0);
 
151
    return this;
 
152
}
 
153
 
 
154
/* ?_Lockit_dtor@_Lockit@std@@CAXPAV12@@Z */
 
155
/* ?_Lockit_dtor@_Lockit@std@@CAXPEAV12@@Z */
 
156
void __cdecl _Lockit__Lockit_dtor(_Lockit *lockit)
 
157
{
 
158
    LeaveCriticalSection(&lockit_cs[lockit->locktype]);
 
159
}
 
160
 
 
161
/* ??1_Lockit@std@@QAE@XZ */
 
162
/* ??1_Lockit@std@@QEAA@XZ */
 
163
DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
 
164
void __thiscall _Lockit_dtor(_Lockit *this)
 
165
{
 
166
    _Lockit__Lockit_dtor(this);
 
167
}
 
168
 
 
169
/* wctype */
 
170
unsigned short __cdecl wctype(const char *property)
 
171
{
 
172
    static const struct {
 
173
        const char *name;
 
174
        unsigned short mask;
 
175
    } properties[] = {
 
176
        { "alnum", _DIGIT|_ALPHA },
 
177
        { "alpha", _ALPHA },
 
178
        { "cntrl", _CONTROL },
 
179
        { "digit", _DIGIT },
 
180
        { "graph", _DIGIT|_PUNCT|_ALPHA },
 
181
        { "lower", _LOWER },
 
182
        { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
 
183
        { "punct", _PUNCT },
 
184
        { "space", _SPACE },
 
185
        { "upper", _UPPER },
 
186
        { "xdigit", _HEX }
 
187
    };
 
188
    int i;
 
189
 
 
190
    for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
 
191
        if(!strcmp(property, properties[i].name))
 
192
            return properties[i].mask;
 
193
 
 
194
    return 0;
 
195
}
 
196
 
 
197
typedef void (__cdecl *MSVCP_new_handler_func)(void);
 
198
static MSVCP_new_handler_func MSVCP_new_handler;
 
199
static int __cdecl new_handler_wrapper(MSVCP_size_t unused)
 
200
{
 
201
    MSVCP_new_handler();
 
202
    return 1;
 
203
}
 
204
 
 
205
/* ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z */
 
206
MSVCP_new_handler_func __cdecl set_new_handler(MSVCP_new_handler_func new_handler)
 
207
{
 
208
    MSVCP_new_handler_func old_handler = MSVCP_new_handler;
 
209
 
 
210
    TRACE("%p\n", new_handler);
 
211
 
 
212
    MSVCP_new_handler = new_handler;
 
213
    MSVCRT_set_new_handler(new_handler ? new_handler_wrapper : NULL);
 
214
    return old_handler;
 
215
}
 
216
 
 
217
/* ?set_new_handler@std@@YAP6AXXZH@Z */
 
218
MSVCP_new_handler_func __cdecl set_new_handler_reset(int unused)
 
219
{
 
220
    return set_new_handler(NULL);
 
221
}