2 * msvcr90 specific functions
4 * Copyright 2010 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msvcr90
);
34 #ifdef __i386__ /* thiscall functions are i386-specific */
36 #define THISCALL(func) __thiscall_ ## func
37 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
38 #define __thiscall __stdcall
39 #define DEFINE_THISCALL_WRAPPER(func,args) \
40 extern void THISCALL(func)(void); \
41 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
45 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
49 #define THISCALL(func) func
50 #define THISCALL_NAME(func) __ASM_NAME(#func)
51 #define __thiscall __cdecl
52 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
56 struct __type_info_node
59 struct __type_info_node
* next
;
62 typedef struct __type_info
65 char *name
; /* Unmangled name, allocated lazily */
66 char mangled
[32]; /* Variable length, but we declare it large enough for static RTTI */
69 typedef void* (*__cdecl malloc_func_t
)(size_t);
70 typedef void (*__cdecl free_func_t
)(void*);
72 extern char* __cdecl
__unDName(char *,const char*,int,malloc_func_t
,free_func_t
,unsigned short int);
74 /*********************************************************************
75 * msvcr90_stat64_to_stat32 [internal]
77 static void msvcr90_stat64_to_stat32(const struct _stat64
*buf64
, struct _stat32
*buf
)
79 buf
->st_dev
= buf64
->st_dev
;
80 buf
->st_ino
= buf64
->st_ino
;
81 buf
->st_mode
= buf64
->st_mode
;
82 buf
->st_nlink
= buf64
->st_nlink
;
83 buf
->st_uid
= buf64
->st_uid
;
84 buf
->st_gid
= buf64
->st_gid
;
85 buf
->st_rdev
= buf64
->st_rdev
;
86 buf
->st_size
= buf64
->st_size
;
87 buf
->st_atime
= buf64
->st_atime
;
88 buf
->st_mtime
= buf64
->st_mtime
;
89 buf
->st_ctime
= buf64
->st_ctime
;
92 /*********************************************************************
95 BOOL WINAPI
DllMain(HINSTANCE hdll
, DWORD reason
, LPVOID reserved
)
99 case DLL_WINE_PREATTACH
:
100 return FALSE
; /* prefer native version */
102 case DLL_PROCESS_ATTACH
:
103 DisableThreadLibraryCalls(hdll
);
108 /*********************************************************************
109 * _decode_pointer (MSVCR90.@)
111 * cdecl version of DecodePointer
114 void * CDECL
MSVCR90_decode_pointer(void * ptr
)
116 return DecodePointer(ptr
);
119 /*********************************************************************
120 * _encode_pointer (MSVCR90.@)
122 * cdecl version of EncodePointer
125 void * CDECL
MSVCR90_encode_pointer(void * ptr
)
127 return EncodePointer(ptr
);
130 /*********************************************************************
131 * _encoded_null (MSVCR90.@)
133 void * CDECL
_encoded_null(void)
137 return MSVCR90_encode_pointer(NULL
);
140 /*********************************************************************
141 * _invalid_parameter_noinfo (MSVCR90.@)
143 void CDECL
_invalid_parameter_noinfo(void)
145 _invalid_parameter( NULL
, NULL
, NULL
, 0, 0 );
148 /*********************************************************************
149 * __sys_nerr (MSVCR90.@)
151 int* CDECL
__sys_nerr(void)
153 return (int*)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "_sys_nerr");
156 /*********************************************************************
157 * __sys_errlist (MSVCR90.@)
159 char** CDECL
__sys_errlist(void)
161 return (char**)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "_sys_errlist");
164 /*********************************************************************
165 * __clean_type_info_names_internal (MSVCR90.@)
167 void CDECL
__clean_type_info_names_internal(void *p
)
169 FIXME("(%p) stub\n", p
);
172 /*********************************************************************
173 * _recalloc (MSVCR90.@)
175 void* CDECL
_recalloc(void* mem
, size_t num
, size_t size
)
181 return calloc(num
, size
);
184 old_size
= _msize(mem
);
186 ret
= realloc(mem
, size
);
193 memset((BYTE
*)mem
+old_size
, 0, size
-old_size
);
197 /*********************************************************************
198 * _fstat32 (MSVCR90.@)
200 int CDECL
_fstat32(int fd
, struct _stat32
* buf
)
203 struct _stat64 buf64
;
205 ret
= _fstat64(fd
, &buf64
);
207 msvcr90_stat64_to_stat32(&buf64
, buf
);
211 /*********************************************************************
212 * _stat32 (MSVCR90.@)
214 int CDECL
_stat32(const char *path
, struct _stat32
* buf
)
217 struct _stat64 buf64
;
219 ret
= _stat64(path
, &buf64
);
221 msvcr90_stat64_to_stat32(&buf64
, buf
);
225 /*********************************************************************
226 * _wstat32 (MSVCR90.@)
228 int CDECL
_wstat32(const wchar_t *path
, struct _stat32
* buf
)
231 struct _stat64 buf64
;
233 ret
= _wstat64(path
, &buf64
);
235 msvcr90_stat64_to_stat32(&buf64
, buf
);
239 /*********************************************************************
240 * _fstat64i32 (MSVCRT.@)
243 static void msvcrt_stat64_to_stat64i32(const struct _stat64
*buf64
, struct _stat64i32
*buf
)
245 buf
->st_dev
= buf64
->st_dev
;
246 buf
->st_ino
= buf64
->st_ino
;
247 buf
->st_mode
= buf64
->st_mode
;
248 buf
->st_nlink
= buf64
->st_nlink
;
249 buf
->st_uid
= buf64
->st_uid
;
250 buf
->st_gid
= buf64
->st_gid
;
251 buf
->st_rdev
= buf64
->st_rdev
;
252 buf
->st_size
= buf64
->st_size
;
253 buf
->st_atime
= buf64
->st_atime
;
254 buf
->st_mtime
= buf64
->st_mtime
;
255 buf
->st_ctime
= buf64
->st_ctime
;
258 int CDECL
_fstat64i32(int fd
, struct _stat64i32
* buf
)
261 struct _stat64 buf64
;
263 ret
= _fstat64(fd
, &buf64
);
265 msvcrt_stat64_to_stat64i32(&buf64
, buf
);
269 /*********************************************************************
270 * _stat64i32 (MSVCRT.@)
272 int CDECL
_stat64i32(const char* path
, struct _stat64i32
* buf
)
275 struct _stat64 buf64
;
277 ret
= _stat64(path
, &buf64
);
279 msvcrt_stat64_to_stat64i32(&buf64
, buf
);
283 /*********************************************************************
284 * _wstat64i32 (MSVCRT.@)
286 int CDECL
_wstat64i32(const wchar_t *path
, struct _stat64i32
*buf
)
289 struct _stat64 buf64
;
291 ret
= _wstat64(path
, &buf64
);
293 msvcrt_stat64_to_stat64i32(&buf64
, buf
);
297 /*********************************************************************
298 * _atoflt (MSVCR90.@)
300 int CDECL
_atoflt( _CRT_FLOAT
*value
, char *str
)
302 return _atoflt_l( value
, str
, NULL
);
305 /*********************************************************************
306 * ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z (MSVCR90.@)
308 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_name_internal_method
,8)
309 const char * __thiscall
MSVCRT_type_info_name_internal_method(type_info
* _this
, struct __type_info_node
*node
)
313 if (node
&& !once
++) FIXME("type_info_node parameter ignored\n");
317 /* Create and set the demangled name */
318 /* Note: mangled name in type_info struct always starts with a '.', while
319 * it isn't valid for mangled name.
320 * Is this '.' really part of the mangled name, or has it some other meaning ?
322 char* name
= __unDName(0, _this
->mangled
+ 1, 0, malloc
, free
, 0x2800);
325 unsigned int len
= strlen(name
);
327 /* It seems _unDName may leave blanks at the end of the demangled name */
328 while (len
&& name
[--len
] == ' ')
331 if (InterlockedCompareExchangePointer((void**)&_this
->name
, name
, NULL
))
333 /* Another thread set this member since we checked above - use it */
338 TRACE("(%p) returning %s\n", _this
, _this
->name
);