- Complete the implementation of heap functions
- Forward j0,j1,jn,y0,y1,yn math calls to libc - Add strnextc, pass text flag in creat, winapi_check fixes
This commit is contained in:
parent
9308f640c1
commit
4b43b4d558
|
@ -61,6 +61,16 @@
|
|||
/* windows.h RAND_MAX is smaller than normal RAND_MAX */
|
||||
#define CRTDLL_RAND_MAX 0x7fff
|
||||
|
||||
/* heap function constants */
|
||||
#define _HEAPEMPTY -1
|
||||
#define _HEAPOK -2
|
||||
#define _HEAPBADBEGIN -3
|
||||
#define _HEAPBADNODE -4
|
||||
#define _HEAPEND -5
|
||||
#define _HEAPBADPTR -6
|
||||
#define _FREEENTRY 0
|
||||
#define _USEDENTRY 1
|
||||
|
||||
/* CRTDLL Globals */
|
||||
extern INT CRTDLL_doserrno;
|
||||
extern INT CRTDLL_errno;
|
||||
|
@ -153,6 +163,13 @@ struct complex
|
|||
double imaginary;
|
||||
};
|
||||
|
||||
typedef struct _heapinfo
|
||||
{
|
||||
int * _pentry;
|
||||
size_t _size;
|
||||
int _useflag;
|
||||
} _HEAPINFO;
|
||||
|
||||
typedef VOID (*sig_handler_type)(VOID);
|
||||
|
||||
typedef VOID (*new_handler_type)(VOID);
|
||||
|
@ -308,6 +325,10 @@ LPVOID __cdecl CRTDLL__lsearch( LPVOID match, LPVOID start, LPUINT array_size,
|
|||
LPVOID __cdecl CRTDLL_new( DWORD size );
|
||||
VOID __cdecl CRTDLL_delete( LPVOID ptr );
|
||||
new_handler_type __cdecl CRTDLL_set_new_handler( new_handler_type func );
|
||||
INT __cdecl CRTDLL__heapchk( VOID );
|
||||
INT __cdecl CRTDLL__heapmin( VOID );
|
||||
INT __cdecl CRTDLL__heapset( UINT value );
|
||||
INT __cdecl CRTDLL__heapwalk( struct _heapinfo *next );
|
||||
LPVOID __cdecl CRTDLL__expand( LPVOID ptr, INT size );
|
||||
LONG __cdecl CRTDLL__msize( LPVOID mem );
|
||||
LPVOID __cdecl CRTDLL_calloc( DWORD size, DWORD count );
|
||||
|
@ -323,6 +344,7 @@ INT __cdecl CRTDLL_system( LPSTR x );
|
|||
LPSTR __cdecl CRTDLL__strdec( LPSTR str1, LPSTR str2 );
|
||||
LPSTR __cdecl CRTDLL__strdup( LPCSTR ptr );
|
||||
LPSTR __cdecl CRTDLL__strinc( LPSTR str );
|
||||
UINT __cdecl CRTDLL__strnextc( LPCSTR str );
|
||||
LPSTR __cdecl CRTDLL__strninc( LPSTR str, INT n );
|
||||
LPSTR __cdecl CRTDLL__strnset( LPSTR str, INT c, INT len );
|
||||
LPSTR __cdecl CRTDLL__strrev ( LPSTR str );
|
||||
|
|
|
@ -137,10 +137,10 @@ debug_channels (crtdll)
|
|||
@ stub _getsystime
|
||||
@ stub _getw
|
||||
@ cdecl _global_unwind2(ptr) CRTDLL__global_unwind2
|
||||
@ stub _heapchk
|
||||
@ stub _heapmin
|
||||
@ stub _heapset
|
||||
@ stub _heapwalk
|
||||
@ cdecl _heapchk() CRTDLL__heapchk
|
||||
@ cdecl _heapmin() CRTDLL__heapmin
|
||||
@ cdecl _heapset(long) CRTDLL__heapset
|
||||
@ cdecl _heapwalk(ptr) CRTDLL__heapwalk
|
||||
@ cdecl _hypot(double double) hypot
|
||||
@ cdecl _initterm(ptr ptr) CRTDLL__initterm
|
||||
@ extern _iob __CRTDLL_iob
|
||||
|
@ -174,9 +174,9 @@ debug_channels (crtdll)
|
|||
@ cdecl _isnan(double) CRTDLL__isnan
|
||||
@ forward _itoa ntdll._itoa
|
||||
@ cdecl _itow(long str long) CRTDLL__itow
|
||||
@ cdecl _j0(double) CRTDLL__j0
|
||||
@ cdecl _j1(double) CRTDLL__j1
|
||||
@ cdecl _jn(long double) CRTDLL__jn
|
||||
@ cdecl _j0(double) j0
|
||||
@ cdecl _j1(double) j1
|
||||
@ cdecl _jn(long double) jn
|
||||
@ stub _kbhit
|
||||
@ stub _lfind
|
||||
@ cdecl _loaddll(str) CRTDLL__loaddll
|
||||
|
@ -299,7 +299,7 @@ debug_channels (crtdll)
|
|||
@ cdecl _strinc(str) CRTDLL__strinc
|
||||
@ forward _strlwr ntdll._strlwr
|
||||
@ cdecl _strncnt(str long) CRTDLL__strncnt
|
||||
@ stub _strnextc
|
||||
@ cdecl _strnextc(str) CRTDLL__strnextc
|
||||
@ cdecl _strnicmp(str str long) strncasecmp
|
||||
@ cdecl _strninc(str long) CRTDLL__strninc
|
||||
@ cdecl _strnset(str long long) CRTDLL__strnset
|
||||
|
|
|
@ -545,7 +545,7 @@ LPINT __cdecl CRTDLL__errno( VOID )
|
|||
|
||||
|
||||
/*********************************************************************
|
||||
* _doserrno (CRTDLL.26)
|
||||
* __doserrno (CRTDLL.26)
|
||||
*
|
||||
* Return the address of the DOS errno (holding the last OS error).
|
||||
*
|
||||
|
@ -1022,31 +1022,3 @@ INT __cdecl CRTDLL__isnan(double d)
|
|||
*/
|
||||
return isnan(d)?1:0;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _j0 (CRTDLL.166)
|
||||
*/
|
||||
double CRTDLL__j0(double x)
|
||||
{
|
||||
FIXME(":stub!\n");
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _j1 (CRTDLL.167)
|
||||
*/
|
||||
double CRTDLL__j1(double x)
|
||||
{
|
||||
FIXME(":stub!\n");
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _jn (CRTDLL.168)
|
||||
*/
|
||||
double CRTDLL__jn(LONG x,double y)
|
||||
{
|
||||
FIXME(":stub!\n");
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -278,13 +278,14 @@ INT __cdecl CRTDLL__commit(INT fd)
|
|||
|
||||
|
||||
/*********************************************************************
|
||||
* _creat (CRTDLL.66)
|
||||
* _creat (CRTDLL.066)
|
||||
*
|
||||
* Open a file, creating it if it is not present.
|
||||
*/
|
||||
INT __cdecl CTRDLL__creat(LPCSTR path, INT flags)
|
||||
{
|
||||
return CRTDLL__open(path,_O_CREAT|_O_WRONLY|_O_TRUNC);
|
||||
INT usedFlags = (flags & _O_TEXT)| _O_CREAT| _O_WRONLY| _O_TRUNC;
|
||||
return CRTDLL__open(path, usedFlags);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
*
|
||||
* Implementation Notes:
|
||||
* MT Safe.
|
||||
* heapwalk from win does not work. This is most likely due to internal
|
||||
* differences between wine and win (see memory/heap.c comments). This
|
||||
* version works fine, however.
|
||||
*/
|
||||
|
||||
#include "crtdll.h"
|
||||
|
@ -66,6 +69,100 @@ LPVOID __cdecl CRTDLL__expand(LPVOID ptr, INT size)
|
|||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _heapchk (CRTDLL.130)
|
||||
*
|
||||
* Check the consistency of the process heap.
|
||||
*/
|
||||
INT __cdecl CRTDLL__heapchk(VOID)
|
||||
{
|
||||
if (!HeapValidate( GetProcessHeap(), 0, NULL))
|
||||
{
|
||||
__CRTDLL__set_errno(GetLastError());
|
||||
return _HEAPBADNODE;
|
||||
}
|
||||
return _HEAPOK;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _heapmin (CRTDLL.131)
|
||||
*
|
||||
* Minimise the size of the heap.
|
||||
*/
|
||||
INT __cdecl CRTDLL__heapmin(VOID)
|
||||
{
|
||||
if (!HeapCompact( GetProcessHeap(), 0 ))
|
||||
{
|
||||
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
__CRTDLL__set_errno(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _heapset (CRTDLL.132)
|
||||
*
|
||||
* Fill free memory in the heap with a given value.
|
||||
*/
|
||||
INT __cdecl CRTDLL__heapset(UINT value)
|
||||
{
|
||||
INT retVal;
|
||||
struct _heapinfo heap;
|
||||
|
||||
memset( &heap, 0, sizeof(heap) );
|
||||
|
||||
while ((retVal = CRTDLL__heapwalk(&heap)) == _HEAPOK)
|
||||
{
|
||||
if (heap._useflag == _FREEENTRY)
|
||||
memset(heap._pentry, value, heap._size);
|
||||
}
|
||||
return retVal == _HEAPEND? _HEAPOK : retVal;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _heapwalk (CRTDLL.133)
|
||||
*
|
||||
* Walk the heap block by block.
|
||||
*/
|
||||
INT __cdecl CRTDLL__heapwalk(struct _heapinfo *next)
|
||||
{
|
||||
PROCESS_HEAP_ENTRY phe;
|
||||
|
||||
phe.lpData = next->_pentry;
|
||||
phe.cbData = next->_size;
|
||||
phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
|
||||
|
||||
if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
|
||||
!HeapValidate( GetProcessHeap(), 0, phe.lpData ))
|
||||
{
|
||||
__CRTDLL__set_errno(GetLastError());
|
||||
return _HEAPBADNODE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (!HeapWalk( GetProcessHeap(), &phe ))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_MORE_ITEMS)
|
||||
return _HEAPEND;
|
||||
__CRTDLL__set_errno(GetLastError());
|
||||
if (!phe.lpData)
|
||||
return _HEAPBADBEGIN;
|
||||
return _HEAPBADNODE;
|
||||
}
|
||||
} while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE));
|
||||
|
||||
next->_pentry = phe.lpData;
|
||||
next->_size = phe.cbData;
|
||||
next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? _USEDENTRY : _FREEENTRY;
|
||||
return _HEAPOK;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _msize (CRTDLL.234)
|
||||
*
|
||||
|
|
|
@ -86,6 +86,17 @@ LPSTR __cdecl CRTDLL__strinc(LPSTR str)
|
|||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _strnextc (CRTDLL.290)
|
||||
*
|
||||
* Return an unsigned int from a string.
|
||||
*/
|
||||
UINT __cdecl CRTDLL__strnextc(LPCSTR str)
|
||||
{
|
||||
return (UINT)*str;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _strninc (CRTDLL.292)
|
||||
*
|
||||
|
|
|
@ -51,6 +51,7 @@ struct _stat *
|
|||
struct win_stat *
|
||||
struct _timeb *
|
||||
time_t *
|
||||
struct _heapinfo *
|
||||
fpos_t *
|
||||
diskfree_t *
|
||||
unsigned char *
|
||||
|
|
Loading…
Reference in New Issue