msvcp120: Implement _Thrd_equal/lt.
[wine.git] / dlls / msvcp90 / misc.c
blob2ec34fe5e3e03b1886f8a69138f6ce93d071f12e
1 /*
2 * Copyright 2010 Piotr Caban for CodeWeavers
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.
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.
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <limits.h>
24 #include "msvcp90.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
31 struct __Container_proxy;
33 typedef struct {
34 struct __Container_proxy *proxy;
35 } _Container_base12;
37 typedef struct __Iterator_base12 {
38 struct __Container_proxy *proxy;
39 struct __Iterator_base12 *next;
40 } _Iterator_base12;
42 typedef struct __Container_proxy {
43 const _Container_base12 *cont;
44 _Iterator_base12 *head;
45 } _Container_proxy;
47 /* ??0_Mutex@std@@QAE@XZ */
48 /* ??0_Mutex@std@@QEAA@XZ */
49 DEFINE_THISCALL_WRAPPER(mutex_ctor, 4)
50 mutex* __thiscall mutex_ctor(mutex *this)
52 CRITICAL_SECTION *cs = MSVCRT_operator_new(sizeof(*cs));
53 if(!cs) {
54 ERR("Out of memory\n");
55 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
58 InitializeCriticalSection(cs);
59 cs->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Mutex critical section");
60 this->mutex = cs;
61 return this;
64 /* ??1_Mutex@std@@QAE@XZ */
65 /* ??1_Mutex@std@@QEAA@XZ */
66 DEFINE_THISCALL_WRAPPER(mutex_dtor, 4)
67 void __thiscall mutex_dtor(mutex *this)
69 ((CRITICAL_SECTION*)this->mutex)->DebugInfo->Spare[0] = 0;
70 DeleteCriticalSection(this->mutex);
71 MSVCRT_operator_delete(this->mutex);
74 /* ?_Lock@_Mutex@std@@QAEXXZ */
75 /* ?_Lock@_Mutex@std@@QEAAXXZ */
76 DEFINE_THISCALL_WRAPPER(mutex_lock, 4)
77 void __thiscall mutex_lock(mutex *this)
79 EnterCriticalSection(this->mutex);
82 /* ?_Unlock@_Mutex@std@@QAEXXZ */
83 /* ?_Unlock@_Mutex@std@@QEAAXXZ */
84 DEFINE_THISCALL_WRAPPER(mutex_unlock, 4)
85 void __thiscall mutex_unlock(mutex *this)
87 LeaveCriticalSection(this->mutex);
90 /* ?_Mutex_Lock@_Mutex@std@@CAXPAV12@@Z */
91 /* ?_Mutex_Lock@_Mutex@std@@CAXPEAV12@@Z */
92 void CDECL mutex_mutex_lock(mutex *m)
94 mutex_lock(m);
97 /* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
98 /* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
99 void CDECL mutex_mutex_unlock(mutex *m)
101 mutex_unlock(m);
104 /* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
105 /* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
106 void CDECL mutex_mutex_ctor(mutex *m)
108 mutex_ctor(m);
111 /* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
112 /* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
113 void CDECL mutex_mutex_dtor(mutex *m)
115 mutex_dtor(m);
118 static CRITICAL_SECTION lockit_cs[_MAX_LOCK];
120 #if _MSVCP_VER >= 70
121 static inline int get_locktype( _Lockit *lockit ) { return lockit->locktype; }
122 static inline void set_locktype( _Lockit *lockit, int type ) { lockit->locktype = type; }
123 #else
124 static inline int get_locktype( _Lockit *lockit ) { return 0; }
125 static inline void set_locktype( _Lockit *lockit, int type ) { }
126 #endif
128 /* ?_Lockit_ctor@_Lockit@std@@SAXH@Z */
129 void __cdecl _Lockit_init(int locktype) {
130 InitializeCriticalSection(&lockit_cs[locktype]);
131 lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
134 /* ?_Lockit_dtor@_Lockit@std@@SAXH@Z */
135 void __cdecl _Lockit_free(int locktype)
137 lockit_cs[locktype].DebugInfo->Spare[0] = 0;
138 DeleteCriticalSection(&lockit_cs[locktype]);
141 void init_lockit(void) {
142 int i;
144 for(i=0; i<_MAX_LOCK; i++)
145 _Lockit_init(i);
148 void free_lockit(void) {
149 int i;
151 for(i=0; i<_MAX_LOCK; i++)
152 _Lockit_free(i);
155 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@H@Z */
156 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@H@Z */
157 void __cdecl _Lockit__Lockit_ctor_locktype(_Lockit *lockit, int locktype)
159 set_locktype( lockit, locktype );
160 EnterCriticalSection(&lockit_cs[locktype]);
163 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@@Z */
164 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@@Z */
165 void __cdecl _Lockit__Lockit_ctor(_Lockit *lockit)
167 _Lockit__Lockit_ctor_locktype(lockit, 0);
170 /* ??0_Lockit@std@@QAE@H@Z */
171 /* ??0_Lockit@std@@QEAA@H@Z */
172 DEFINE_THISCALL_WRAPPER(_Lockit_ctor_locktype, 8)
173 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
175 _Lockit__Lockit_ctor_locktype(this, locktype);
176 return this;
179 /* ??0_Lockit@std@@QAE@XZ */
180 /* ??0_Lockit@std@@QEAA@XZ */
181 DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
182 _Lockit* __thiscall _Lockit_ctor(_Lockit *this)
184 _Lockit__Lockit_ctor_locktype(this, 0);
185 return this;
188 /* ?_Lockit_dtor@_Lockit@std@@CAXPAV12@@Z */
189 /* ?_Lockit_dtor@_Lockit@std@@CAXPEAV12@@Z */
190 void __cdecl _Lockit__Lockit_dtor(_Lockit *lockit)
192 LeaveCriticalSection(&lockit_cs[get_locktype( lockit )]);
195 /* ??1_Lockit@std@@QAE@XZ */
196 /* ??1_Lockit@std@@QEAA@XZ */
197 DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
198 void __thiscall _Lockit_dtor(_Lockit *this)
200 _Lockit__Lockit_dtor(this);
203 /* wctype */
204 unsigned short __cdecl wctype(const char *property)
206 static const struct {
207 const char *name;
208 unsigned short mask;
209 } properties[] = {
210 { "alnum", _DIGIT|_ALPHA },
211 { "alpha", _ALPHA },
212 { "cntrl", _CONTROL },
213 { "digit", _DIGIT },
214 { "graph", _DIGIT|_PUNCT|_ALPHA },
215 { "lower", _LOWER },
216 { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
217 { "punct", _PUNCT },
218 { "space", _SPACE },
219 { "upper", _UPPER },
220 { "xdigit", _HEX }
222 unsigned int i;
224 for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
225 if(!strcmp(property, properties[i].name))
226 return properties[i].mask;
228 return 0;
231 typedef void (__cdecl *MSVCP_new_handler_func)(void);
232 static MSVCP_new_handler_func MSVCP_new_handler;
233 static int __cdecl new_handler_wrapper(MSVCP_size_t unused)
235 MSVCP_new_handler();
236 return 1;
239 /* ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z */
240 MSVCP_new_handler_func __cdecl set_new_handler(MSVCP_new_handler_func new_handler)
242 MSVCP_new_handler_func old_handler = MSVCP_new_handler;
244 TRACE("%p\n", new_handler);
246 MSVCP_new_handler = new_handler;
247 MSVCRT_set_new_handler(new_handler ? new_handler_wrapper : NULL);
248 return old_handler;
251 /* ?set_new_handler@std@@YAP6AXXZH@Z */
252 MSVCP_new_handler_func __cdecl set_new_handler_reset(int unused)
254 return set_new_handler(NULL);
257 /* _Container_base0 is used by apps compiled without iterator checking
258 * (i.e. with _ITERATOR_DEBUG_LEVEL=0 ).
259 * It provides empty versions of methods used by visual c++'s stl's
260 * iterator checking.
261 * msvcr100 has to provide them in case apps are compiled with /Od
262 * or the optimizer fails to inline those (empty) calls.
265 /* ?_Orphan_all@_Container_base0@std@@QAEXXZ */
266 /* ?_Orphan_all@_Container_base0@std@@QEAAXXZ */
267 DEFINE_THISCALL_WRAPPER(Container_base0_Orphan_all, 4)
268 void __thiscall Container_base0_Orphan_all(void *this)
272 /* ?_Swap_all@_Container_base0@std@@QAEXAAU12@@Z */
273 /* ?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z */
274 DEFINE_THISCALL_WRAPPER(Container_base0_Swap_all, 8)
275 void __thiscall Container_base0_Swap_all(void *this, void *that)
279 /* ??4_Container_base0@std@@QAEAAU01@ABU01@@Z */
280 /* ??4_Container_base0@std@@QEAAAEAU01@AEBU01@@Z */
281 DEFINE_THISCALL_WRAPPER(Container_base0_op_assign, 8)
282 void* __thiscall Container_base0_op_assign(void *this, const void *that)
284 return this;
287 /* ??0_Container_base12@std@@QAE@ABU01@@Z */
288 /* ??0_Container_base12@std@@QEAA@AEBU01@@Z */
289 DEFINE_THISCALL_WRAPPER(_Container_base12_copy_ctor, 8)
290 _Container_base12* __thiscall _Container_base12_copy_ctor(
291 _Container_base12 *this, _Container_base12 *that)
293 this->proxy = NULL;
294 return this;
297 /* ??0_Container_base12@std@@QAE@XZ */
298 /* ??0_Container_base12@std@@QEAA@XZ */
299 DEFINE_THISCALL_WRAPPER(_Container_base12_ctor, 4)
300 _Container_base12* __thiscall _Container_base12_ctor(_Container_base12 *this)
302 this->proxy = NULL;
303 return this;
306 /* ??1_Container_base12@std@@QAE@XZ */
307 /* ??1_Container_base12@std@@QEAA@XZ */
308 DEFINE_THISCALL_WRAPPER(_Container_base12_dtor, 4)
309 void __thiscall _Container_base12_dtor(_Container_base12 *this)
313 /* ??4_Container_base12@std@@QAEAAU01@ABU01@@Z */
314 /* ??4_Container_base12@std@@QEAAAEAU01@AEBU01@@ */
315 DEFINE_THISCALL_WRAPPER(_Container_base12_op_assign, 8)
316 _Container_base12* __thiscall _Container_base12_op_assign(
317 _Container_base12 *this, const _Container_base12 *that)
319 return this;
322 /* ?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@XZ */
323 /* ?_Getpfirst@_Container_base12@std@@QEBAPEAPEAU_Iterator_base12@2@XZ */
324 DEFINE_THISCALL_WRAPPER(_Container_base12__Getpfirst, 4)
325 _Iterator_base12** __thiscall _Container_base12__Getpfirst(_Container_base12 *this)
327 return this->proxy ? &this->proxy->head : NULL;
330 /* ?_Orphan_all@_Container_base12@std@@QAEXXZ */
331 /* ?_Orphan_all@_Container_base12@std@@QEAAXXZ */
332 DEFINE_THISCALL_WRAPPER(_Container_base12__Orphan_all, 4)
333 void __thiscall _Container_base12__Orphan_all(_Container_base12 *this)
337 /* ?_Swap_all@_Container_base12@std@@QAEXAAU12@@Z */
338 /* ?_Swap_all@_Container_base12@std@@QEAAXAEAU12@@Z */
339 DEFINE_THISCALL_WRAPPER(_Container_base12__Swap_all, 8)
340 void __thiscall _Container_base12__Swap_all(
341 _Container_base12 *this, _Container_base12 *that)
343 _Container_proxy *tmp;
345 tmp = this->proxy;
346 this->proxy = that->proxy;
347 that->proxy = tmp;
349 if(this->proxy)
350 this->proxy->cont = this;
351 if(that->proxy)
352 that->proxy->cont = that;
355 #if _MSVCP_VER >= 110
357 #define SECSPERDAY 86400
358 /* 1601 to 1970 is 369 years plus 89 leap days */
359 #define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
360 #define TICKSPERSEC 10000000
361 #define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
362 #define NANOSEC_PER_MILLISEC 1000000
363 #define MILLISEC_PER_SEC 1000
365 typedef int MSVCRT_long;
367 /* xtime */
368 typedef struct {
369 __time64_t sec;
370 MSVCRT_long nsec;
371 } xtime;
373 /* _Xtime_get_ticks */
374 LONGLONG __cdecl _Xtime_get_ticks(void)
376 FILETIME ft;
378 TRACE("\n");
380 GetSystemTimeAsFileTime(&ft);
381 return ((LONGLONG)ft.dwHighDateTime<<32) + ft.dwLowDateTime - TICKS_1601_TO_1970;
384 /* _xtime_get */
385 int __cdecl xtime_get(xtime* t, int unknown)
387 LONGLONG ticks;
389 TRACE("(%p)\n", t);
391 if(unknown != 1)
392 return 0;
394 ticks = _Xtime_get_ticks();
395 t->sec = ticks / TICKSPERSEC;
396 t->nsec = ticks % TICKSPERSEC * 100;
397 return 1;
400 /* _Xtime_diff_to_millis2 */
401 MSVCRT_long __cdecl _Xtime_diff_to_millis2(const xtime *t1, const xtime *t2)
403 __time64_t diff_sec;
404 MSVCRT_long diff_nsec, ret;
406 TRACE("(%p, %p)\n", t1, t2);
408 diff_sec = t1->sec - t2->sec;
409 diff_nsec = t1->nsec - t2->nsec;
410 ret = diff_sec * MILLISEC_PER_SEC +
411 (diff_nsec + NANOSEC_PER_MILLISEC - 1) / NANOSEC_PER_MILLISEC;
412 return ret > 0 ? ret : 0;
415 /* _Xtime_diff_to_millis */
416 MSVCRT_long __cdecl _Xtime_diff_to_millis(const xtime *t)
418 xtime now;
420 TRACE("%p\n", t);
422 xtime_get(&now, 1);
423 return _Xtime_diff_to_millis2(t, &now);
425 #endif
427 #if _MSVCP_VER >= 90
428 unsigned int __cdecl _Random_device(void)
430 unsigned int ret;
432 TRACE("\n");
434 /* TODO: throw correct exception in case of failure */
435 if(rand_s(&ret))
436 throw_exception(EXCEPTION, "random number generator failed\n");
437 return ret;
439 #endif
441 #if _MSVCP_VER >= 110
442 #if defined(__i386__) && !defined(__arm__)
444 extern void *call_thiscall_func;
445 __ASM_GLOBAL_FUNC(call_thiscall_func,
446 "popl %eax\n\t"
447 "popl %edx\n\t"
448 "popl %ecx\n\t"
449 "pushl %eax\n\t"
450 "jmp *%edx\n\t")
452 #define call_func1(func,this) ((void* (WINAPI*)(void*,void*))&call_thiscall_func)(func,this)
454 #else /* __i386__ */
456 #define call_func1(func,this) func(this)
458 #endif /* __i386__ */
460 #define MTX_MULTI_LOCK 0x100
461 #define MTX_LOCKED 3
462 typedef struct
464 DWORD flags;
465 critical_section cs;
466 DWORD thread_id;
467 DWORD count;
468 } *_Mtx_t;
470 int __cdecl _Mtx_init(_Mtx_t *mtx, int flags)
472 if(flags & ~MTX_MULTI_LOCK)
473 FIXME("unknown flags ignorred: %x\n", flags);
475 *mtx = MSVCRT_operator_new(sizeof(**mtx));
476 (*mtx)->flags = flags;
477 call_func1(critical_section_ctor, &(*mtx)->cs);
478 (*mtx)->thread_id = -1;
479 (*mtx)->count = 0;
480 return 0;
483 void __cdecl _Mtx_destroy(_Mtx_t *mtx)
485 call_func1(critical_section_dtor, &(*mtx)->cs);
486 MSVCRT_operator_delete(*mtx);
489 int __cdecl _Mtx_lock(_Mtx_t *mtx)
491 if((*mtx)->thread_id != GetCurrentThreadId()) {
492 call_func1(critical_section_lock, &(*mtx)->cs);
493 (*mtx)->thread_id = GetCurrentThreadId();
494 }else if(!((*mtx)->flags & MTX_MULTI_LOCK)) {
495 return MTX_LOCKED;
498 (*mtx)->count++;
499 return 0;
502 int __cdecl _Mtx_unlock(_Mtx_t *mtx)
504 if(--(*mtx)->count)
505 return 0;
507 (*mtx)->thread_id = -1;
508 call_func1(critical_section_unlock, &(*mtx)->cs);
509 return 0;
512 int __cdecl _Mtx_trylock(_Mtx_t *mtx)
514 if((*mtx)->thread_id != GetCurrentThreadId()) {
515 if(!call_func1(critical_section_trylock, &(*mtx)->cs))
516 return MTX_LOCKED;
517 (*mtx)->thread_id = GetCurrentThreadId();
518 }else if(!((*mtx)->flags & MTX_MULTI_LOCK)) {
519 return MTX_LOCKED;
522 (*mtx)->count++;
523 return 0;
526 critical_section* __cdecl _Mtx_getconcrtcs(_Mtx_t *mtx)
528 return &(*mtx)->cs;
530 #endif
532 #if _MSVCP_VER == 100
533 typedef struct {
534 const vtable_ptr *vtable;
535 } error_category;
537 typedef struct {
538 error_category base;
539 const char *type;
540 } custom_category;
541 static custom_category iostream_category;
543 DEFINE_RTTI_DATA0(error_category, 0, ".?AVerror_category@std@@")
544 DEFINE_RTTI_DATA1(iostream_category, 0, &error_category_rtti_base_descriptor, ".?AV_Iostream_error_category@std@@")
546 extern const vtable_ptr MSVCP_iostream_category_vtable;
548 static void iostream_category_ctor(custom_category *this)
550 this->base.vtable = &MSVCP_iostream_category_vtable;
551 this->type = "iostream";
554 DEFINE_THISCALL_WRAPPER(custom_category_vector_dtor, 8)
555 custom_category* __thiscall custom_category_vector_dtor(custom_category *this, unsigned int flags)
557 TRACE("(%p %x)\n", this, flags);
558 if(flags & 2) {
559 /* we have an array, with the number of elements stored before the first object */
560 INT_PTR i, *ptr = (INT_PTR *)this-1;
562 for(i=*ptr-1; i>=0; i--)
563 MSVCRT_operator_delete(ptr);
564 } else {
565 if(flags & 1)
566 MSVCRT_operator_delete(this);
569 return this;
572 DEFINE_THISCALL_WRAPPER(custom_category_name, 4)
573 const char* __thiscall custom_category_name(const custom_category *this)
575 return this->type;
578 DEFINE_THISCALL_WRAPPER(custom_category_message, 12)
579 basic_string_char* __thiscall custom_category_message(const custom_category *this,
580 basic_string_char *ret, int err)
582 if(err == 1) return MSVCP_basic_string_char_ctor_cstr(ret, "iostream error");
583 return MSVCP_basic_string_char_ctor_cstr(ret, strerror(err));
586 DEFINE_THISCALL_WRAPPER(custom_category_default_error_condition, 12)
587 /*error_condition*/void* __thiscall custom_category_default_error_condition(
588 custom_category *this, /*error_condition*/void *ret, int code)
590 FIXME("(%p %p %x) stub\n", this, ret, code);
591 return NULL;
594 DEFINE_THISCALL_WRAPPER(custom_category_equivalent, 12)
595 MSVCP_bool __thiscall custom_category_equivalent(const custom_category *this,
596 int code, const /*error_condition*/void *condition)
598 FIXME("(%p %x %p) stub\n", this, code, condition);
599 return FALSE;
602 DEFINE_THISCALL_WRAPPER(custom_category_equivalent_code, 12)
603 MSVCP_bool __thiscall custom_category_equivalent_code(custom_category *this,
604 const /*error_code*/void *code, int condition)
606 FIXME("(%p %p %x) stub\n", this, code, condition);
607 return FALSE;
610 /* ?iostream_category@std@@YAABVerror_category@1@XZ */
611 /* ?iostream_category@std@@YAAEBVerror_category@1@XZ */
612 const error_category* __cdecl std_iostream_category(void)
614 TRACE("()\n");
615 return &iostream_category.base;
618 #ifndef __GNUC__
619 void __asm_dummy_vtables(void) {
620 #endif
621 __ASM_VTABLE(iostream_category,
622 VTABLE_ADD_FUNC(custom_category_vector_dtor)
623 VTABLE_ADD_FUNC(custom_category_name)
624 VTABLE_ADD_FUNC(custom_category_message)
625 VTABLE_ADD_FUNC(custom_category_default_error_condition)
626 VTABLE_ADD_FUNC(custom_category_equivalent)
627 VTABLE_ADD_FUNC(custom_category_equivalent_code));
628 #ifndef __GNUC__
630 #endif
631 #endif
633 #if _MSVCP_VER >= 110
634 static CRITICAL_SECTION call_once_cs;
635 static CRITICAL_SECTION_DEBUG call_once_cs_debug =
637 0, 0, &call_once_cs,
638 { &call_once_cs_debug.ProcessLocksList, &call_once_cs_debug.ProcessLocksList },
639 0, 0, { (DWORD_PTR)(__FILE__ ": call_once_cs") }
641 static CRITICAL_SECTION call_once_cs = { &call_once_cs_debug, -1, 0, 0, 0, 0 };
643 void __cdecl _Call_onceEx(int *once, void (__cdecl *func)(void*), void *argv)
645 TRACE("%p %p %p\n", once, func, argv);
647 EnterCriticalSection(&call_once_cs);
648 if(!*once) {
649 /* FIXME: handle exceptions */
650 func(argv);
651 *once = 1;
653 LeaveCriticalSection(&call_once_cs);
656 static void __cdecl call_once_func_wrapper(void *func)
658 ((void (__cdecl*)(void))func)();
661 void __cdecl _Call_once(int *once, void (__cdecl *func)(void))
663 TRACE("%p %p\n", once, func);
664 _Call_onceEx(once, call_once_func_wrapper, func);
667 void __cdecl _Do_call(void *this)
669 CALL_VTBL_FUNC(this, 0, void, (void*), (this));
671 #endif
673 void init_misc(void *base)
675 #ifdef __x86_64__
676 #if _MSVCP_VER == 100
677 init_error_category_rtti(base);
678 init_iostream_category_rtti(base);
679 #endif
680 #endif
682 #if _MSVCP_VER == 100
683 iostream_category_ctor(&iostream_category);
684 #endif
687 #if _MSVCP_VER >= 110
688 typedef struct
690 HANDLE hnd;
691 DWORD id;
692 } _Thrd_t;
694 int __cdecl _Thrd_equal(_Thrd_t a, _Thrd_t b)
696 TRACE("(%p %u %p %u)\n", a.hnd, a.id, b.hnd, b.id);
697 return a.id == b.id;
700 int __cdecl _Thrd_lt(_Thrd_t a, _Thrd_t b)
702 TRACE("(%p %u %p %u)\n", a.hnd, a.id, b.hnd, b.id);
703 return a.id < b.id;
705 #endif