msvcirt: Implement ios static locking.
[wine.git] / dlls / msvcirt / msvcirt.c
blobe46f57412019ef097e8c1fc12fb418171a893069
1 /*
2 * Copyright (C) 2007 Alexandre Julliard
3 * Copyright (C) 2015 Iván Matellanes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
22 #include <stdarg.h>
23 #include <stdio.h>
25 #include "msvcirt.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
32 #define RESERVE_SIZE 512
34 /* ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A */
35 extern CRITICAL_SECTION ios_static_lock;
36 CRITICAL_SECTION_DEBUG ios_static_lock_debug =
38 0, 0, &ios_static_lock,
39 { &ios_static_lock_debug.ProcessLocksList, &ios_static_lock_debug.ProcessLocksList },
40 0, 0, { (DWORD_PTR)(__FILE__ ": ios_static_lock") }
42 CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 };
44 /* class streambuf */
45 typedef struct {
46 const vtable_ptr *vtable;
47 int allocated;
48 int unbuffered;
49 int stored_char;
50 char *base;
51 char *ebuf;
52 char *pbase;
53 char *pptr;
54 char *epptr;
55 char *eback;
56 char *gptr;
57 char *egptr;
58 int do_lock;
59 CRITICAL_SECTION lock;
60 } streambuf;
62 void __thiscall streambuf_setb(streambuf*, char*, char*, int);
63 streambuf* __thiscall streambuf_setbuf(streambuf*, char*, int);
64 void __thiscall streambuf_setg(streambuf*, char*, char*, char*);
65 void __thiscall streambuf_setp(streambuf*, char*, char*);
67 /* class ios */
68 struct _ostream;
69 typedef struct {
70 const vtable_ptr *vtable;
71 streambuf *sb;
72 ios_io_state state;
73 int special[4];
74 int delbuf;
75 struct _ostream *tie;
76 ios_flags flags;
77 int precision;
78 char fill;
79 int width;
80 int do_lock;
81 CRITICAL_SECTION lock;
82 } ios;
84 ios* __thiscall ios_assign(ios*, const ios*);
86 /* class ostream */
87 typedef struct _ostream {
88 const vtable_ptr *vtable;
89 } ostream;
91 typedef struct {
92 LPVOID VTable;
93 } class_strstreambuf;
95 /* ??_7streambuf@@6B@ */
96 extern const vtable_ptr MSVCP_streambuf_vtable;
97 /* ??_7ios@@6B@ */
98 extern const vtable_ptr MSVCP_ios_vtable;
100 #ifndef __GNUC__
101 void __asm_dummy_vtables(void) {
102 #endif
103 __ASM_VTABLE(streambuf,
104 VTABLE_ADD_FUNC(streambuf_vector_dtor)
105 VTABLE_ADD_FUNC(streambuf_sync)
106 VTABLE_ADD_FUNC(streambuf_setbuf)
107 VTABLE_ADD_FUNC(streambuf_seekoff)
108 VTABLE_ADD_FUNC(streambuf_seekpos)
109 VTABLE_ADD_FUNC(streambuf_xsputn)
110 VTABLE_ADD_FUNC(streambuf_xsgetn)
111 VTABLE_ADD_FUNC(streambuf_overflow)
112 VTABLE_ADD_FUNC(streambuf_underflow)
113 VTABLE_ADD_FUNC(streambuf_pbackfail)
114 VTABLE_ADD_FUNC(streambuf_doallocate));
115 __ASM_VTABLE(ios,
116 VTABLE_ADD_FUNC(ios_vector_dtor));
117 #ifndef __GNUC__
119 #endif
121 DEFINE_RTTI_DATA0(streambuf, 0, ".?AVstreambuf@@")
122 DEFINE_RTTI_DATA0(ios, 0, ".?AVios@@")
124 /* ??0streambuf@@IAE@PADH@Z */
125 /* ??0streambuf@@IEAA@PEADH@Z */
126 DEFINE_THISCALL_WRAPPER(streambuf_reserve_ctor, 12)
127 streambuf* __thiscall streambuf_reserve_ctor(streambuf *this, char *buffer, int length)
129 TRACE("(%p %p %d)\n", this, buffer, length);
130 this->vtable = &MSVCP_streambuf_vtable;
131 this->allocated = 0;
132 this->stored_char = EOF;
133 this->do_lock = -1;
134 this->base = NULL;
135 streambuf_setbuf(this, buffer, length);
136 streambuf_setg(this, NULL, NULL, NULL);
137 streambuf_setp(this, NULL, NULL);
138 InitializeCriticalSection(&this->lock);
139 return this;
142 /* ??0streambuf@@IAE@XZ */
143 /* ??0streambuf@@IEAA@XZ */
144 DEFINE_THISCALL_WRAPPER(streambuf_ctor, 4)
145 streambuf* __thiscall streambuf_ctor(streambuf *this)
147 streambuf_reserve_ctor(this, NULL, 0);
148 this->unbuffered = 0;
149 return this;
152 /* ??0streambuf@@QAE@ABV0@@Z */
153 /* ??0streambuf@@QEAA@AEBV0@@Z */
154 DEFINE_THISCALL_WRAPPER(streambuf_copy_ctor, 8)
155 streambuf* __thiscall streambuf_copy_ctor(streambuf *this, const streambuf *copy)
157 TRACE("(%p %p)\n", this, copy);
158 *this = *copy;
159 this->vtable = &MSVCP_streambuf_vtable;
160 return this;
163 /* ??1streambuf@@UAE@XZ */
164 /* ??1streambuf@@UEAA@XZ */
165 DEFINE_THISCALL_WRAPPER(streambuf_dtor, 4)
166 void __thiscall streambuf_dtor(streambuf *this)
168 TRACE("(%p)\n", this);
169 if (this->allocated)
170 MSVCRT_operator_delete(this->base);
171 DeleteCriticalSection(&this->lock);
174 /* ??4streambuf@@QAEAAV0@ABV0@@Z */
175 /* ??4streambuf@@QEAAAEAV0@AEBV0@@Z */
176 DEFINE_THISCALL_WRAPPER(streambuf_assign, 8)
177 streambuf* __thiscall streambuf_assign(streambuf *this, const streambuf *rhs)
179 streambuf_dtor(this);
180 return streambuf_copy_ctor(this, rhs);
183 /* ??_Estreambuf@@UAEPAXI@Z */
184 DEFINE_THISCALL_WRAPPER(streambuf_vector_dtor, 8)
185 #define call_streambuf_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0,\
186 streambuf*, (streambuf*, unsigned int), (this, flags))
187 streambuf* __thiscall streambuf_vector_dtor(streambuf *this, unsigned int flags)
189 TRACE("(%p %x)\n", this, flags);
190 if (flags & 2) {
191 /* we have an array, with the number of elements stored before the first object */
192 INT_PTR i, *ptr = (INT_PTR *)this-1;
194 for (i = *ptr-1; i >= 0; i--)
195 streambuf_dtor(this+i);
196 MSVCRT_operator_delete(ptr);
197 } else {
198 streambuf_dtor(this);
199 if (flags & 1)
200 MSVCRT_operator_delete(this);
202 return this;
205 /* ??_Gstreambuf@@UAEPAXI@Z */
206 DEFINE_THISCALL_WRAPPER(streambuf_scalar_dtor, 8)
207 streambuf* __thiscall streambuf_scalar_dtor(streambuf *this, unsigned int flags)
209 TRACE("(%p %x)\n", this, flags);
210 streambuf_dtor(this);
211 if (flags & 1) MSVCRT_operator_delete(this);
212 return this;
215 /* ?doallocate@streambuf@@MAEHXZ */
216 /* ?doallocate@streambuf@@MEAAHXZ */
217 DEFINE_THISCALL_WRAPPER(streambuf_doallocate, 4)
218 #define call_streambuf_doallocate(this) CALL_VTBL_FUNC(this, 40, int, (streambuf*), (this))
219 int __thiscall streambuf_doallocate(streambuf *this)
221 char *reserve;
223 TRACE("(%p)\n", this);
224 reserve = MSVCRT_operator_new(RESERVE_SIZE);
225 if (!reserve)
226 return EOF;
228 streambuf_setb(this, reserve, reserve + RESERVE_SIZE, 1);
229 return 1;
232 /* ?allocate@streambuf@@IAEHXZ */
233 /* ?allocate@streambuf@@IEAAHXZ */
234 DEFINE_THISCALL_WRAPPER(streambuf_allocate, 4)
235 int __thiscall streambuf_allocate(streambuf *this)
237 TRACE("(%p)\n", this);
238 if (this->base != NULL || this->unbuffered)
239 return 0;
240 return call_streambuf_doallocate(this);
243 /* ?base@streambuf@@IBEPADXZ */
244 /* ?base@streambuf@@IEBAPEADXZ */
245 DEFINE_THISCALL_WRAPPER(streambuf_base, 4)
246 char* __thiscall streambuf_base(const streambuf *this)
248 TRACE("(%p)\n", this);
249 return this->base;
252 /* ?blen@streambuf@@IBEHXZ */
253 /* ?blen@streambuf@@IEBAHXZ */
254 DEFINE_THISCALL_WRAPPER(streambuf_blen, 4)
255 int __thiscall streambuf_blen(const streambuf *this)
257 TRACE("(%p)\n", this);
258 return this->ebuf - this->base;
261 /* ?eback@streambuf@@IBEPADXZ */
262 /* ?eback@streambuf@@IEBAPEADXZ */
263 DEFINE_THISCALL_WRAPPER(streambuf_eback, 4)
264 char* __thiscall streambuf_eback(const streambuf *this)
266 TRACE("(%p)\n", this);
267 return this->eback;
270 /* ?ebuf@streambuf@@IBEPADXZ */
271 /* ?ebuf@streambuf@@IEBAPEADXZ */
272 DEFINE_THISCALL_WRAPPER(streambuf_ebuf, 4)
273 char* __thiscall streambuf_ebuf(const streambuf *this)
275 TRACE("(%p)\n", this);
276 return this->ebuf;
279 /* ?egptr@streambuf@@IBEPADXZ */
280 /* ?egptr@streambuf@@IEBAPEADXZ */
281 DEFINE_THISCALL_WRAPPER(streambuf_egptr, 4)
282 char* __thiscall streambuf_egptr(const streambuf *this)
284 TRACE("(%p)\n", this);
285 return this->egptr;
288 /* ?epptr@streambuf@@IBEPADXZ */
289 /* ?epptr@streambuf@@IEBAPEADXZ */
290 DEFINE_THISCALL_WRAPPER(streambuf_epptr, 4)
291 char* __thiscall streambuf_epptr(const streambuf *this)
293 TRACE("(%p)\n", this);
294 return this->epptr;
297 /* ?gptr@streambuf@@IBEPADXZ */
298 /* ?gptr@streambuf@@IEBAPEADXZ */
299 DEFINE_THISCALL_WRAPPER(streambuf_gptr, 4)
300 char* __thiscall streambuf_gptr(const streambuf *this)
302 TRACE("(%p)\n", this);
303 return this->gptr;
306 /* ?pbase@streambuf@@IBEPADXZ */
307 /* ?pbase@streambuf@@IEBAPEADXZ */
308 DEFINE_THISCALL_WRAPPER(streambuf_pbase, 4)
309 char* __thiscall streambuf_pbase(const streambuf *this)
311 TRACE("(%p)\n", this);
312 return this->pbase;
315 /* ?pptr@streambuf@@IBEPADXZ */
316 /* ?pptr@streambuf@@IEBAPEADXZ */
317 DEFINE_THISCALL_WRAPPER(streambuf_pptr, 4)
318 char* __thiscall streambuf_pptr(const streambuf *this)
320 TRACE("(%p)\n", this);
321 return this->pptr;
324 /* ?clrlock@streambuf@@QAEXXZ */
325 /* ?clrlock@streambuf@@QEAAXXZ */
326 DEFINE_THISCALL_WRAPPER(streambuf_clrlock, 4)
327 void __thiscall streambuf_clrlock(streambuf *this)
329 TRACE("(%p)\n", this);
330 if (this->do_lock <= 0)
331 this->do_lock++;
334 /* ?lock@streambuf@@QAEXXZ */
335 /* ?lock@streambuf@@QEAAXXZ */
336 DEFINE_THISCALL_WRAPPER(streambuf_lock, 4)
337 void __thiscall streambuf_lock(streambuf *this)
339 TRACE("(%p)\n", this);
340 if (this->do_lock < 0)
341 EnterCriticalSection(&this->lock);
344 /* ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
345 /* ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
346 DEFINE_THISCALL_WRAPPER(streambuf_lockptr, 4)
347 CRITICAL_SECTION* __thiscall streambuf_lockptr(streambuf *this)
349 TRACE("(%p)\n", this);
350 return &this->lock;
353 /* ?gbump@streambuf@@IAEXH@Z */
354 /* ?gbump@streambuf@@IEAAXH@Z */
355 DEFINE_THISCALL_WRAPPER(streambuf_gbump, 8)
356 void __thiscall streambuf_gbump(streambuf *this, int count)
358 TRACE("(%p %d)\n", this, count);
359 this->gptr += count;
362 /* ?pbump@streambuf@@IAEXH@Z */
363 /* ?pbump@streambuf@@IEAAXH@Z */
364 DEFINE_THISCALL_WRAPPER(streambuf_pbump, 8)
365 void __thiscall streambuf_pbump(streambuf *this, int count)
367 TRACE("(%p %d)\n", this, count);
368 this->pptr += count;
371 /* ?in_avail@streambuf@@QBEHXZ */
372 /* ?in_avail@streambuf@@QEBAHXZ */
373 DEFINE_THISCALL_WRAPPER(streambuf_in_avail, 4)
374 int __thiscall streambuf_in_avail(const streambuf *this)
376 TRACE("(%p)\n", this);
377 return this->egptr - this->gptr;
380 /* ?out_waiting@streambuf@@QBEHXZ */
381 /* ?out_waiting@streambuf@@QEBAHXZ */
382 DEFINE_THISCALL_WRAPPER(streambuf_out_waiting, 4)
383 int __thiscall streambuf_out_waiting(const streambuf *this)
385 TRACE("(%p)\n", this);
386 return this->pptr - this->pbase;
389 /* Unexported */
390 DEFINE_THISCALL_WRAPPER(streambuf_overflow, 8)
391 #define call_streambuf_overflow(this, c) CALL_VTBL_FUNC(this, 28, int, (streambuf*, int), (this, c))
392 int __thiscall streambuf_overflow(streambuf *this, int c)
394 ERR("overflow is not implemented in streambuf\n");
395 return EOF;
398 /* ?pbackfail@streambuf@@UAEHH@Z */
399 /* ?pbackfail@streambuf@@UEAAHH@Z */
400 DEFINE_THISCALL_WRAPPER(streambuf_pbackfail, 8)
401 #define call_streambuf_pbackfail(this, c) CALL_VTBL_FUNC(this, 36, int, (streambuf*, int), (this, c))
402 int __thiscall streambuf_pbackfail(streambuf *this, int c)
404 TRACE("(%p %d)\n", this, c);
405 if (this->gptr <= this->eback)
406 return EOF;
407 return *--this->gptr = c;
410 /* ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z */
411 /* ?seekoff@streambuf@@UEAAJJW4seek_dir@ios@@H@Z */
412 DEFINE_THISCALL_WRAPPER(streambuf_seekoff, 16)
413 #define call_streambuf_seekoff(this, off, dir, mode) CALL_VTBL_FUNC(this, 12, streampos, (streambuf*, streamoff, ios_seek_dir, int), (this, off, dir, mode))
414 streampos __thiscall streambuf_seekoff(streambuf *this, streamoff offset, ios_seek_dir dir, int mode)
416 TRACE("(%p %d %d %d)\n", this, offset, dir, mode);
417 return EOF;
420 /* ?seekpos@streambuf@@UAEJJH@Z */
421 /* ?seekpos@streambuf@@UEAAJJH@Z */
422 DEFINE_THISCALL_WRAPPER(streambuf_seekpos, 12)
423 streampos __thiscall streambuf_seekpos(streambuf *this, streampos pos, int mode)
425 TRACE("(%p %d %d)\n", this, pos, mode);
426 return call_streambuf_seekoff(this, pos, SEEKDIR_beg, mode);
429 /* ?setb@streambuf@@IAEXPAD0H@Z */
430 /* ?setb@streambuf@@IEAAXPEAD0H@Z */
431 DEFINE_THISCALL_WRAPPER(streambuf_setb, 16)
432 void __thiscall streambuf_setb(streambuf *this, char *ba, char *eb, int delete)
434 TRACE("(%p %p %p %d)\n", this, ba, eb, delete);
435 if (this->allocated)
436 MSVCRT_operator_delete(this->base);
437 this->allocated = delete;
438 this->base = ba;
439 this->ebuf = eb;
442 /* ?setbuf@streambuf@@UAEPAV1@PADH@Z */
443 /* ?setbuf@streambuf@@UEAAPEAV1@PEADH@Z */
444 DEFINE_THISCALL_WRAPPER(streambuf_setbuf, 12)
445 streambuf* __thiscall streambuf_setbuf(streambuf *this, char *buffer, int length)
447 TRACE("(%p %p %d)\n", this, buffer, length);
448 if (this->base != NULL)
449 return NULL;
451 if (buffer == NULL || !length) {
452 this->unbuffered = 1;
453 this->base = this->ebuf = NULL;
454 } else {
455 this->unbuffered = 0;
456 this->base = buffer;
457 this->ebuf = buffer + length;
459 return this;
462 /* ?setg@streambuf@@IAEXPAD00@Z */
463 /* ?setg@streambuf@@IEAAXPEAD00@Z */
464 DEFINE_THISCALL_WRAPPER(streambuf_setg, 16)
465 void __thiscall streambuf_setg(streambuf *this, char *ek, char *gp, char *eg)
467 TRACE("(%p %p %p %p)\n", this, ek, gp, eg);
468 this->eback = ek;
469 this->gptr = gp;
470 this->egptr = eg;
473 /* ?setlock@streambuf@@QAEXXZ */
474 /* ?setlock@streambuf@@QEAAXXZ */
475 DEFINE_THISCALL_WRAPPER(streambuf_setlock, 4)
476 void __thiscall streambuf_setlock(streambuf *this)
478 TRACE("(%p)\n", this);
479 this->do_lock--;
482 /* ?setp@streambuf@@IAEXPAD0@Z */
483 /* ?setp@streambuf@@IEAAXPEAD0@Z */
484 DEFINE_THISCALL_WRAPPER(streambuf_setp, 12)
485 void __thiscall streambuf_setp(streambuf *this, char *pb, char *ep)
487 TRACE("(%p %p %p)\n", this, pb, ep);
488 this->pbase = this->pptr = pb;
489 this->epptr = ep;
492 /* ?sync@streambuf@@UAEHXZ */
493 /* ?sync@streambuf@@UEAAHXZ */
494 DEFINE_THISCALL_WRAPPER(streambuf_sync, 4)
495 int __thiscall streambuf_sync(streambuf *this)
497 TRACE("(%p)\n", this);
498 return (this->gptr >= this->egptr && this->pbase >= this->pptr) ? 0 : EOF;
501 /* ?unbuffered@streambuf@@IAEXH@Z */
502 /* ?unbuffered@streambuf@@IEAAXH@Z */
503 DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_set, 8)
504 void __thiscall streambuf_unbuffered_set(streambuf *this, int buf)
506 TRACE("(%p %d)\n", this, buf);
507 this->unbuffered = buf;
510 /* ?unbuffered@streambuf@@IBEHXZ */
511 /* ?unbuffered@streambuf@@IEBAHXZ */
512 DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_get, 4)
513 int __thiscall streambuf_unbuffered_get(const streambuf *this)
515 TRACE("(%p)\n", this);
516 return this->unbuffered;
519 /* Unexported */
520 DEFINE_THISCALL_WRAPPER(streambuf_underflow, 4)
521 #define call_streambuf_underflow(this) CALL_VTBL_FUNC(this, 32, int, (streambuf*), (this))
522 int __thiscall streambuf_underflow(streambuf *this)
524 ERR("underflow is not implemented in streambuf\n");
525 return EOF;
528 /* ?unlock@streambuf@@QAEXXZ */
529 /* ?unlock@streambuf@@QEAAXXZ */
530 DEFINE_THISCALL_WRAPPER(streambuf_unlock, 4)
531 void __thiscall streambuf_unlock(streambuf *this)
533 TRACE("(%p)\n", this);
534 if (this->do_lock < 0)
535 LeaveCriticalSection(&this->lock);
538 /* ?xsgetn@streambuf@@UAEHPADH@Z */
539 /* ?xsgetn@streambuf@@UEAAHPEADH@Z */
540 DEFINE_THISCALL_WRAPPER(streambuf_xsgetn, 12)
541 #define call_streambuf_xsgetn(this, buffer, count) CALL_VTBL_FUNC(this, 24, int, (streambuf*, char*, int), (this, buffer, count))
542 int __thiscall streambuf_xsgetn(streambuf *this, char *buffer, int count)
544 int copied = 0, chunk;
546 TRACE("(%p %p %d)\n", this, buffer, count);
548 if (this->unbuffered) {
549 if (this->stored_char == EOF)
550 this->stored_char = call_streambuf_underflow(this);
551 while (copied < count && this->stored_char != EOF) {
552 buffer[copied++] = this->stored_char;
553 this->stored_char = call_streambuf_underflow(this);
555 } else {
556 while (copied < count) {
557 if (call_streambuf_underflow(this) == EOF)
558 break;
559 chunk = this->egptr - this->gptr;
560 if (chunk > count - copied)
561 chunk = count - copied;
562 memcpy(buffer+copied, this->gptr, chunk);
563 this->gptr += chunk;
564 copied += chunk;
567 return copied;
570 /* ?xsputn@streambuf@@UAEHPBDH@Z */
571 /* ?xsputn@streambuf@@UEAAHPEBDH@Z */
572 DEFINE_THISCALL_WRAPPER(streambuf_xsputn, 12)
573 #define call_streambuf_xsputn(this, data, length) CALL_VTBL_FUNC(this, 20, int, (streambuf*, const char*, int), (this, data, length))
574 int __thiscall streambuf_xsputn(streambuf *this, const char *data, int length)
576 int copied = 0, chunk;
578 TRACE("(%p %p %d)\n", this, data, length);
580 while (copied < length) {
581 if (this->unbuffered || this->pptr == this->epptr) {
582 if (call_streambuf_overflow(this, data[copied]) == EOF)
583 break;
584 copied++;
585 } else {
586 chunk = this->epptr - this->pptr;
587 if (chunk > length - copied)
588 chunk = length - copied;
589 memcpy(this->pptr, data+copied, chunk);
590 this->pptr += chunk;
591 copied += chunk;
594 return copied;
597 /* ?sgetc@streambuf@@QAEHXZ */
598 /* ?sgetc@streambuf@@QEAAHXZ */
599 DEFINE_THISCALL_WRAPPER(streambuf_sgetc, 4)
600 int __thiscall streambuf_sgetc(streambuf *this)
602 TRACE("(%p)\n", this);
603 if (this->unbuffered) {
604 if (this->stored_char == EOF)
605 this->stored_char = call_streambuf_underflow(this);
606 return this->stored_char;
607 } else
608 return call_streambuf_underflow(this);
611 /* ?sputc@streambuf@@QAEHH@Z */
612 /* ?sputc@streambuf@@QEAAHH@Z */
613 DEFINE_THISCALL_WRAPPER(streambuf_sputc, 8)
614 int __thiscall streambuf_sputc(streambuf *this, int ch)
616 TRACE("(%p %d)\n", this, ch);
617 return (this->pptr < this->epptr) ? *this->pptr++ = ch : call_streambuf_overflow(this, ch);
620 /* ?sgetn@streambuf@@QAEHPADH@Z */
621 /* ?sgetn@streambuf@@QEAAHPEADH@Z */
622 DEFINE_THISCALL_WRAPPER(streambuf_sgetn, 12)
623 int __thiscall streambuf_sgetn(streambuf *this, char *buffer, int count)
625 return call_streambuf_xsgetn(this, buffer, count);
628 /* ?sputn@streambuf@@QAEHPBDH@Z */
629 /* ?sputn@streambuf@@QEAAHPEBDH@Z */
630 DEFINE_THISCALL_WRAPPER(streambuf_sputn, 12)
631 int __thiscall streambuf_sputn(streambuf *this, const char *data, int length)
633 return call_streambuf_xsputn(this, data, length);
636 /* ?snextc@streambuf@@QAEHXZ */
637 /* ?snextc@streambuf@@QEAAHXZ */
638 DEFINE_THISCALL_WRAPPER(streambuf_snextc, 4)
639 int __thiscall streambuf_snextc(streambuf *this)
641 TRACE("(%p)\n", this);
642 if (this->unbuffered) {
643 if (this->stored_char == EOF)
644 call_streambuf_underflow(this);
645 return this->stored_char = call_streambuf_underflow(this);
646 } else {
647 if (this->gptr >= this->egptr)
648 call_streambuf_underflow(this);
649 this->gptr++;
650 return (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
654 /* ?sbumpc@streambuf@@QAEHXZ */
655 /* ?sbumpc@streambuf@@QEAAHXZ */
656 DEFINE_THISCALL_WRAPPER(streambuf_sbumpc, 4)
657 int __thiscall streambuf_sbumpc(streambuf *this)
659 int ret;
661 TRACE("(%p)\n", this);
663 if (this->unbuffered) {
664 ret = this->stored_char;
665 this->stored_char = EOF;
666 if (ret == EOF)
667 ret = call_streambuf_underflow(this);
668 } else {
669 ret = (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
670 this->gptr++;
672 return ret;
675 /* ?stossc@streambuf@@QAEXXZ */
676 /* ?stossc@streambuf@@QEAAXXZ */
677 DEFINE_THISCALL_WRAPPER(streambuf_stossc, 4)
678 void __thiscall streambuf_stossc(streambuf *this)
680 TRACE("(%p)\n", this);
681 if (this->unbuffered) {
682 if (this->stored_char == EOF)
683 call_streambuf_underflow(this);
684 else
685 this->stored_char = EOF;
686 } else {
687 if (this->gptr >= this->egptr)
688 call_streambuf_underflow(this);
689 if (this->gptr < this->egptr)
690 this->gptr++;
694 /* ?sputbackc@streambuf@@QAEHD@Z */
695 /* ?sputbackc@streambuf@@QEAAHD@Z */
696 DEFINE_THISCALL_WRAPPER(streambuf_sputbackc, 8)
697 int __thiscall streambuf_sputbackc(streambuf *this, char ch)
699 TRACE("(%p %d)\n", this, ch);
700 return call_streambuf_pbackfail(this, ch);
703 /* ?dbp@streambuf@@QAEXXZ */
704 /* ?dbp@streambuf@@QEAAXXZ */
705 DEFINE_THISCALL_WRAPPER(streambuf_dbp, 4)
706 void __thiscall streambuf_dbp(streambuf *this)
708 printf("\nSTREAMBUF DEBUG INFO: this=%p, ", this);
709 if (this->unbuffered) {
710 printf("unbuffered\n");
711 } else {
712 printf("_fAlloc=%d\n", this->allocated);
713 printf(" base()=%p, ebuf()=%p, blen()=%d\n", this->base, this->ebuf, streambuf_blen(this));
714 printf("pbase()=%p, pptr()=%p, epptr()=%d\n", this->pbase, this->pptr, this->epptr);
715 printf("eback()=%p, gptr()=%p, egptr()=%d\n", this->eback, this->gptr, this->egptr);
719 /* ??0ios@@IAE@ABV0@@Z */
720 /* ??0ios@@IEAA@AEBV0@@Z */
721 DEFINE_THISCALL_WRAPPER(ios_copy_ctor, 8)
722 ios* __thiscall ios_copy_ctor(ios *this, const ios *copy)
724 TRACE("(%p %p)\n", this, copy);
725 this->vtable = &MSVCP_ios_vtable;
726 this->sb = NULL;
727 this->delbuf = 0;
728 InitializeCriticalSection(&this->lock);
729 return ios_assign(this, copy);
732 /* ??0ios@@QAE@PAVstreambuf@@@Z */
733 /* ??0ios@@QEAA@PEAVstreambuf@@@Z */
734 DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
735 ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
737 TRACE("(%p %p)\n", this, sb);
738 this->vtable = &MSVCP_ios_vtable;
739 this->sb = sb;
740 this->state = sb ? IOSTATE_goodbit : IOSTATE_badbit;
741 this->special[0] = this->special[1] = 0;
742 this->delbuf = 0;
743 this->tie = NULL;
744 this->flags = 0;
745 this->precision = 6;
746 this->fill = ' ';
747 this->width = 0;
748 this->do_lock = -1;
749 InitializeCriticalSection(&this->lock);
750 return this;
753 /* ??0ios@@IAE@XZ */
754 /* ??0ios@@IEAA@XZ */
755 DEFINE_THISCALL_WRAPPER(ios_ctor, 4)
756 ios* __thiscall ios_ctor(ios *this)
758 return ios_sb_ctor(this, NULL);
761 /* ??1ios@@UAE@XZ */
762 /* ??1ios@@UEAA@XZ */
763 DEFINE_THISCALL_WRAPPER(ios_dtor, 4)
764 void __thiscall ios_dtor(ios *this)
766 TRACE("(%p)\n", this);
767 if (this->delbuf && this->sb)
768 call_streambuf_vector_dtor(this->sb, 1);
769 this->sb = NULL;
770 this->state = IOSTATE_badbit;
771 DeleteCriticalSection(&this->lock);
774 /* ??4ios@@IAEAAV0@ABV0@@Z */
775 /* ??4ios@@IEAAAEAV0@AEBV0@@Z */
776 DEFINE_THISCALL_WRAPPER(ios_assign, 8)
777 ios* __thiscall ios_assign(ios *this, const ios *rhs)
779 TRACE("(%p %p)\n", this, rhs);
780 this->state = rhs->state;
781 if (!this->sb)
782 this->state |= IOSTATE_badbit;
783 this->tie = rhs->tie;
784 this->flags = rhs->flags;
785 this->precision = (char) rhs->precision;
786 this->fill = rhs->fill;
787 this->width = (char) rhs->width;
788 return this;
791 /* ??7ios@@QBEHXZ */
792 /* ??7ios@@QEBAHXZ */
793 DEFINE_THISCALL_WRAPPER(ios_op_not, 4)
794 int __thiscall ios_op_not(const ios *this)
796 FIXME("(%p) stub\n", this);
797 return 0;
800 /* ??Bios@@QBEPAXXZ */
801 /* ??Bios@@QEBAPEAXXZ */
802 DEFINE_THISCALL_WRAPPER(ios_op_void, 4)
803 void* __thiscall ios_op_void(const ios *this)
805 FIXME("(%p) stub\n", this);
806 return NULL;
809 /* ??_Eios@@UAEPAXI@Z */
810 DEFINE_THISCALL_WRAPPER(ios_vector_dtor, 8)
811 ios* __thiscall ios_vector_dtor(ios *this, unsigned int flags)
813 TRACE("(%p %x)\n", this, flags);
814 if (flags & 2) {
815 /* we have an array, with the number of elements stored before the first object */
816 INT_PTR i, *ptr = (INT_PTR *)this-1;
818 for (i = *ptr-1; i >= 0; i--)
819 ios_dtor(this+i);
820 MSVCRT_operator_delete(ptr);
821 } else {
822 ios_dtor(this);
823 if (flags & 1)
824 MSVCRT_operator_delete(this);
826 return this;
829 /* ??_Gios@@UAEPAXI@Z */
830 DEFINE_THISCALL_WRAPPER(ios_scalar_dtor, 8)
831 ios* __thiscall ios_scalar_dtor(ios *this, unsigned int flags)
833 TRACE("(%p %x)\n", this, flags);
834 ios_dtor(this);
835 if (flags & 1) MSVCRT_operator_delete(this);
836 return this;
839 /* ?bad@ios@@QBEHXZ */
840 /* ?bad@ios@@QEBAHXZ */
841 DEFINE_THISCALL_WRAPPER(ios_bad, 4)
842 int __thiscall ios_bad(const ios *this)
844 FIXME("(%p) stub\n", this);
845 return 0;
848 /* ?bitalloc@ios@@SAJXZ */
849 LONG __cdecl ios_bitalloc(void)
851 FIXME("() stub\n");
852 return 0;
855 /* ?clear@ios@@QAEXH@Z */
856 /* ?clear@ios@@QEAAXH@Z */
857 DEFINE_THISCALL_WRAPPER(ios_clear, 8)
858 void __thiscall ios_clear(ios *this, int state)
860 FIXME("(%p %d) stub\n", this, state);
863 /* ?clrlock@ios@@QAAXXZ */
864 /* ?clrlock@ios@@QEAAXXZ */
865 void __cdecl ios_clrlock(ios *this)
867 TRACE("(%p)\n", this);
868 if (this->do_lock <= 0)
869 this->do_lock++;
870 if (this->sb)
871 streambuf_clrlock(this->sb);
874 /* ?delbuf@ios@@QAEXH@Z */
875 /* ?delbuf@ios@@QEAAXH@Z */
876 DEFINE_THISCALL_WRAPPER(ios_delbuf_set, 8)
877 void __thiscall ios_delbuf_set(ios *this, int delete)
879 FIXME("(%p %d) stub\n", this, delete);
882 /* ?delbuf@ios@@QBEHXZ */
883 /* ?delbuf@ios@@QEBAHXZ */
884 DEFINE_THISCALL_WRAPPER(ios_delbuf_get, 4)
885 int __thiscall ios_delbuf_get(const ios *this)
887 FIXME("(%p) stub\n", this);
888 return 0;
891 /* ?dec@@YAAAVios@@AAV1@@Z */
892 /* ?dec@@YAAEAVios@@AEAV1@@Z */
893 ios* __cdecl ios_dec(ios *this)
895 FIXME("(%p) stub\n", this);
896 return this;
899 /* ?eof@ios@@QBEHXZ */
900 /* ?eof@ios@@QEBAHXZ */
901 DEFINE_THISCALL_WRAPPER(ios_eof, 4)
902 int __thiscall ios_eof(const ios *this)
904 FIXME("(%p) stub\n", this);
905 return 0;
908 /* ?fail@ios@@QBEHXZ */
909 /* ?fail@ios@@QEBAHXZ */
910 DEFINE_THISCALL_WRAPPER(ios_fail, 4)
911 int __thiscall ios_fail(const ios *this)
913 FIXME("(%p) stub\n", this);
914 return 0;
917 /* ?fill@ios@@QAEDD@Z */
918 /* ?fill@ios@@QEAADD@Z */
919 DEFINE_THISCALL_WRAPPER(ios_fill_set, 8)
920 char __thiscall ios_fill_set(ios *this, char fill)
922 FIXME("(%p %d) stub\n", this, fill);
923 return EOF;
926 /* ?fill@ios@@QBEDXZ */
927 /* ?fill@ios@@QEBADXZ */
928 DEFINE_THISCALL_WRAPPER(ios_fill_get, 4)
929 char __thiscall ios_fill_get(const ios *this)
931 FIXME("(%p) stub\n", this);
932 return EOF;
935 /* ?flags@ios@@QAEJJ@Z */
936 /* ?flags@ios@@QEAAJJ@Z */
937 DEFINE_THISCALL_WRAPPER(ios_flags_set, 8)
938 LONG __thiscall ios_flags_set(ios *this, LONG flags)
940 FIXME("(%p %x) stub\n", this, flags);
941 return 0;
944 /* ?flags@ios@@QBEJXZ */
945 /* ?flags@ios@@QEBAJXZ */
946 DEFINE_THISCALL_WRAPPER(ios_flags_get, 4)
947 LONG __thiscall ios_flags_get(const ios *this)
949 FIXME("(%p) stub\n", this);
950 return 0;
953 /* ?good@ios@@QBEHXZ */
954 /* ?good@ios@@QEBAHXZ */
955 DEFINE_THISCALL_WRAPPER(ios_good, 4)
956 int __thiscall ios_good(const ios *this)
958 FIXME("(%p) stub\n", this);
959 return 0;
962 /* ?hex@@YAAAVios@@AAV1@@Z */
963 /* ?hex@@YAAEAVios@@AEAV1@@Z */
964 ios* __cdecl ios_hex(ios *this)
966 FIXME("(%p) stub\n", this);
967 return this;
970 /* ?init@ios@@IAEXPAVstreambuf@@@Z */
971 /* ?init@ios@@IEAAXPEAVstreambuf@@@Z */
972 DEFINE_THISCALL_WRAPPER(ios_init, 8)
973 void __thiscall ios_init(ios *this, streambuf *sb)
975 TRACE("(%p %p)\n", this, sb);
976 if (this->delbuf && this->sb)
977 call_streambuf_vector_dtor(this->sb, 1);
978 this->sb = sb;
979 if (sb == NULL)
980 this->state |= IOSTATE_badbit;
981 else
982 this->state &= ~IOSTATE_badbit;
985 /* ?iword@ios@@QBEAAJH@Z */
986 /* ?iword@ios@@QEBAAEAJH@Z */
987 DEFINE_THISCALL_WRAPPER(ios_iword, 8)
988 LONG* __thiscall ios_iword(const ios *this, int index)
990 FIXME("(%p %d) stub\n", this, index);
991 return NULL;
994 /* ?lock@ios@@QAAXXZ */
995 /* ?lock@ios@@QEAAXXZ */
996 void __cdecl ios_lock(ios *this)
998 TRACE("(%p)\n", this);
999 if (this->do_lock < 0)
1000 EnterCriticalSection(&this->lock);
1003 /* ?lockbuf@ios@@QAAXXZ */
1004 /* ?lockbuf@ios@@QEAAXXZ */
1005 void __cdecl ios_lockbuf(ios *this)
1007 TRACE("(%p)\n", this);
1008 streambuf_lock(this->sb);
1011 /* ?lockc@ios@@KAXXZ */
1012 void __cdecl ios_lockc(void)
1014 TRACE("()\n");
1015 EnterCriticalSection(&ios_static_lock);
1018 /* ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
1019 /* ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
1020 DEFINE_THISCALL_WRAPPER(ios_lockptr, 4)
1021 CRITICAL_SECTION* __thiscall ios_lockptr(ios *this)
1023 TRACE("(%p)\n", this);
1024 return &this->lock;
1027 /* ?oct@@YAAAVios@@AAV1@@Z */
1028 /* ?oct@@YAAEAVios@@AEAV1@@Z */
1029 ios* __cdecl ios_oct(ios *this)
1031 FIXME("(%p) stub\n", this);
1032 return this;
1035 /* ?precision@ios@@QAEHH@Z */
1036 /* ?precision@ios@@QEAAHH@Z */
1037 DEFINE_THISCALL_WRAPPER(ios_precision_set, 8)
1038 int __thiscall ios_precision_set(ios *this, int prec)
1040 FIXME("(%p %d) stub\n", this, prec);
1041 return 0;
1044 /* ?precision@ios@@QBEHXZ */
1045 /* ?precision@ios@@QEBAHXZ */
1046 DEFINE_THISCALL_WRAPPER(ios_precision_get, 4)
1047 int __thiscall ios_precision_get(const ios *this)
1049 FIXME("(%p) stub\n", this);
1050 return 0;
1053 /* ?pword@ios@@QBEAAPAXH@Z */
1054 /* ?pword@ios@@QEBAAEAPEAXH@Z */
1055 DEFINE_THISCALL_WRAPPER(ios_pword, 8)
1056 void** __thiscall ios_pword(const ios *this, int index)
1058 FIXME("(%p %d) stub\n", this, index);
1059 return NULL;
1062 /* ?rdbuf@ios@@QBEPAVstreambuf@@XZ */
1063 /* ?rdbuf@ios@@QEBAPEAVstreambuf@@XZ */
1064 DEFINE_THISCALL_WRAPPER(ios_rdbuf, 4)
1065 streambuf* __thiscall ios_rdbuf(const ios *this)
1067 FIXME("(%p) stub\n", this);
1068 return NULL;
1071 /* ?rdstate@ios@@QBEHXZ */
1072 /* ?rdstate@ios@@QEBAHXZ */
1073 DEFINE_THISCALL_WRAPPER(ios_rdstate, 4)
1074 int __thiscall ios_rdstate(const ios *this)
1076 FIXME("(%p) stub\n", this);
1077 return 0;
1080 /* ?setf@ios@@QAEJJ@Z */
1081 /* ?setf@ios@@QEAAJJ@Z */
1082 DEFINE_THISCALL_WRAPPER(ios_setf, 8)
1083 LONG __thiscall ios_setf(ios *this, LONG flags)
1085 FIXME("(%p %x) stub\n", this, flags);
1086 return 0;
1089 /* ?setf@ios@@QAEJJJ@Z */
1090 /* ?setf@ios@@QEAAJJJ@Z */
1091 DEFINE_THISCALL_WRAPPER(ios_setf_mask, 12)
1092 LONG __thiscall ios_setf_mask(ios *this, LONG flags, LONG mask)
1094 FIXME("(%p %x %x) stub\n", this, flags, mask);
1095 return 0;
1098 /* ?setlock@ios@@QAAXXZ */
1099 /* ?setlock@ios@@QEAAXXZ */
1100 void __cdecl ios_setlock(ios *this)
1102 TRACE("(%p)\n", this);
1103 this->do_lock--;
1104 if (this->sb)
1105 streambuf_setlock(this->sb);
1108 /* ?sync_with_stdio@ios@@SAXXZ */
1109 void __cdecl ios_sync_with_stdio(void)
1111 FIXME("() stub\n");
1114 /* ?tie@ios@@QAEPAVostream@@PAV2@@Z */
1115 /* ?tie@ios@@QEAAPEAVostream@@PEAV2@@Z */
1116 DEFINE_THISCALL_WRAPPER(ios_tie_set, 8)
1117 ostream* __thiscall ios_tie_set(ios *this, ostream *ostr)
1119 FIXME("(%p %p) stub\n", this, ostr);
1120 return NULL;
1123 /* ?tie@ios@@QBEPAVostream@@XZ */
1124 /* ?tie@ios@@QEBAPEAVostream@@XZ */
1125 DEFINE_THISCALL_WRAPPER(ios_tie_get, 4)
1126 ostream* __thiscall ios_tie_get(const ios *this)
1128 FIXME("(%p) stub\n", this);
1129 return NULL;
1132 /* ?unlock@ios@@QAAXXZ */
1133 /* ?unlock@ios@@QEAAXXZ */
1134 void __cdecl ios_unlock(ios *this)
1136 TRACE("(%p)\n", this);
1137 if (this->do_lock < 0)
1138 LeaveCriticalSection(&this->lock);
1141 /* ?unlockbuf@ios@@QAAXXZ */
1142 /* ?unlockbuf@ios@@QEAAXXZ */
1143 void __cdecl ios_unlockbuf(ios *this)
1145 TRACE("(%p)\n", this);
1146 streambuf_unlock(this->sb);
1149 /* ?unlockc@ios@@KAXXZ */
1150 void __cdecl ios_unlockc(void)
1152 TRACE("()\n");
1153 LeaveCriticalSection(&ios_static_lock);
1156 /* ?unsetf@ios@@QAEJJ@Z */
1157 /* ?unsetf@ios@@QEAAJJ@Z */
1158 DEFINE_THISCALL_WRAPPER(ios_unsetf, 8)
1159 LONG __thiscall ios_unsetf(ios *this, LONG flags)
1161 FIXME("(%p %x) stub\n", this, flags);
1162 return 0;
1165 /* ?width@ios@@QAEHH@Z */
1166 /* ?width@ios@@QEAAHH@Z */
1167 DEFINE_THISCALL_WRAPPER(ios_width_set, 8)
1168 int __thiscall ios_width_set(ios *this, int width)
1170 FIXME("(%p %d) stub\n", this, width);
1171 return 0;
1174 /* ?width@ios@@QBEHXZ */
1175 /* ?width@ios@@QEBAHXZ */
1176 DEFINE_THISCALL_WRAPPER(ios_width_get, 4)
1177 int __thiscall ios_width_get(const ios *this)
1179 FIXME("(%p) stub\n", this);
1180 return 0;
1183 /* ?xalloc@ios@@SAHXZ */
1184 int __cdecl ios_xalloc(void)
1186 FIXME("() stub\n");
1187 return 0;
1190 /******************************************************************
1191 * ??0ostrstream@@QAE@XZ (MSVCRTI.@)
1193 DEFINE_THISCALL_WRAPPER(MSVCIRT_ostrstream_ctor,8)
1194 void * __thiscall MSVCIRT_ostrstream_ctor(ostream *this, BOOL virt_init)
1196 FIXME("(%p %x) stub\n", this, virt_init);
1197 return this;
1200 /******************************************************************
1201 * ??1ostrstream@@UAE@XZ (MSVCRTI.@)
1203 DEFINE_THISCALL_WRAPPER(MSVCIRT_ostrstream_dtor,4)
1204 void __thiscall MSVCIRT_ostrstream_dtor(ios *base)
1206 FIXME("(%p) stub\n", base);
1209 /******************************************************************
1210 * ??6ostream@@QAEAAV0@E@Z (MSVCRTI.@)
1211 * class ostream & __thiscall ostream::operator<<(unsigned char)
1213 DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_uchar,8)
1214 void * __thiscall MSVCIRT_operator_sl_uchar(ostream * _this, unsigned char ch)
1216 FIXME("(%p)->(%c) stub\n", _this, ch);
1217 return _this;
1220 /******************************************************************
1221 * ??6ostream@@QAEAAV0@H@Z (MSVCRTI.@)
1222 * class ostream & __thiscall ostream::operator<<(int)
1224 DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_int,8)
1225 void * __thiscall MSVCIRT_operator_sl_int(ostream * _this, int integer)
1227 FIXME("(%p)->(%d) stub\n", _this, integer);
1228 return _this;
1231 /******************************************************************
1232 * ??6ostream@@QAEAAV0@PBD@Z (MSVCRTI.@)
1233 * class ostream & __thiscall ostream::operator<<(char const *)
1235 DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_pchar,8)
1236 void * __thiscall MSVCIRT_operator_sl_pchar(ostream * _this, const char * string)
1238 FIXME("(%p)->(%s) stub\n", _this, debugstr_a(string));
1239 return _this;
1242 /******************************************************************
1243 * ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z (MSVCRTI.@)
1244 * class ostream & __thiscall ostream::operator<<(class ostream & (__cdecl*)(class ostream &))
1246 DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_callback,8)
1247 void * __thiscall MSVCIRT_operator_sl_callback(ostream * _this, ostream * (__cdecl*func)(ostream*))
1249 TRACE("%p, %p\n", _this, func);
1250 return func(_this);
1253 /******************************************************************
1254 * ?endl@@YAAAVostream@@AAV1@@Z (MSVCRTI.@)
1255 * class ostream & __cdecl endl(class ostream &)
1257 void * CDECL MSVCIRT_endl(ostream * _this)
1259 FIXME("(%p)->() stub\n", _this);
1260 return _this;
1263 /******************************************************************
1264 * ?ends@@YAAAVostream@@AAV1@@Z (MSVCRTI.@)
1265 * class ostream & __cdecl ends(class ostream &)
1267 void * CDECL MSVCIRT_ends(ostream * _this)
1269 FIXME("(%p)->() stub\n", _this);
1270 return _this;
1273 /******************************************************************
1274 * ?str@strstreambuf@@QAEPADXZ (MSVCRTI.@)
1275 * class strstreambuf & __thiscall strstreambuf::str(class strstreambuf &)
1277 DEFINE_THISCALL_WRAPPER(MSVCIRT_str_sl_void,4)
1278 char * __thiscall MSVCIRT_str_sl_void(class_strstreambuf * _this)
1280 FIXME("(%p)->() stub\n", _this);
1281 return 0;
1284 #ifdef __i386__
1286 #define DEFINE_VTBL_WRAPPER(off) \
1287 __ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
1288 "popl %eax\n\t" \
1289 "popl %ecx\n\t" \
1290 "pushl %eax\n\t" \
1291 "movl 0(%ecx), %eax\n\t" \
1292 "jmp *" #off "(%eax)\n\t")
1294 DEFINE_VTBL_WRAPPER(0);
1295 DEFINE_VTBL_WRAPPER(4);
1296 DEFINE_VTBL_WRAPPER(8);
1297 DEFINE_VTBL_WRAPPER(12);
1298 DEFINE_VTBL_WRAPPER(16);
1299 DEFINE_VTBL_WRAPPER(20);
1300 DEFINE_VTBL_WRAPPER(24);
1301 DEFINE_VTBL_WRAPPER(28);
1302 DEFINE_VTBL_WRAPPER(32);
1303 DEFINE_VTBL_WRAPPER(36);
1304 DEFINE_VTBL_WRAPPER(40);
1305 DEFINE_VTBL_WRAPPER(44);
1306 DEFINE_VTBL_WRAPPER(48);
1307 DEFINE_VTBL_WRAPPER(52);
1308 DEFINE_VTBL_WRAPPER(56);
1310 #endif
1312 void* (__cdecl *MSVCRT_operator_new)(SIZE_T);
1313 void (__cdecl *MSVCRT_operator_delete)(void*);
1315 static void init_cxx_funcs(void)
1317 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
1319 if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
1321 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
1322 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
1324 else
1326 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
1327 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
1331 static void init_io(void *base)
1333 #ifdef __x86_64__
1334 init_streambuf_rtti(base);
1335 init_ios_rtti(base);
1336 #endif
1339 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
1341 switch (reason)
1343 case DLL_WINE_PREATTACH:
1344 return FALSE; /* prefer native version */
1345 case DLL_PROCESS_ATTACH:
1346 init_cxx_funcs();
1347 init_exception(inst);
1348 init_io(inst);
1349 DisableThreadLibraryCalls( inst );
1350 break;
1352 return TRUE;