msvcrt: Implement _set_doserrno.

This commit is contained in:
Andrew Nguyen 2010-09-28 03:49:03 -05:00 committed by Alexandre Julliard
parent ad68c0bd3c
commit 67088eb34c
7 changed files with 46 additions and 4 deletions

View File

@ -1070,7 +1070,7 @@
@ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable
@ stub _set_abort_behavior
@ stub _set_controlfp
@ stub _set_doserrno
@ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode

View File

@ -923,7 +923,7 @@
@ stub _set_abort_behavior
@ stub _set_amblksiz
@ stub _set_controlfp
@ stub _set_doserrno
@ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode

View File

@ -909,7 +909,7 @@
@ stub _set_abort_behavior
@ stub _set_amblksiz
@ stub _set_controlfp
@ stub _set_doserrno
@ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode

View File

@ -236,6 +236,15 @@ int CDECL _set_errno(int value)
return 0;
}
/*********************************************************************
* _set_doserrno (MSVCRT.@)
*/
int CDECL _set_doserrno(int value)
{
*MSVCRT___doserrno() = value;
return 0;
}
/*********************************************************************
* strerror (MSVCRT.@)
*/

View File

@ -848,7 +848,7 @@
@ stdcall -i386 _seh_longjmp_unwind(ptr)
@ cdecl _set_SSE2_enable(long) MSVCRT__set_SSE2_enable
# stub _set_controlfp
# stub _set_doserrno
@ cdecl _set_doserrno(long)
@ cdecl _set_errno(long)
@ cdecl _set_error_mode(long)
# stub _set_fileinfo

View File

@ -28,6 +28,7 @@ static int (__cdecl *pI10_OUTPUT)(long double, int, int, void*);
static int (__cdecl *pstrerror_s)(char *, MSVCRT_size_t, int);
static int (__cdecl *p_get_doserrno)(int *);
static int (__cdecl *p_get_errno)(int *);
static int (__cdecl *p_set_doserrno)(int);
static int (__cdecl *p_set_errno)(int);
static void init(void)
@ -40,6 +41,7 @@ static void init(void)
pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
}
@ -294,6 +296,35 @@ static void test__get_errno(void)
ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
}
static void test__set_doserrno(void)
{
int ret;
if (!p_set_doserrno)
{
win_skip("_set_doserrno is not available\n");
return;
}
_doserrno = ERROR_INVALID_CMM;
ret = p_set_doserrno(ERROR_FILE_NOT_FOUND);
ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
ok(_doserrno == ERROR_FILE_NOT_FOUND,
"Expected _doserrno to be ERROR_FILE_NOT_FOUND, got %d\n", _doserrno);
_doserrno = ERROR_INVALID_CMM;
ret = p_set_doserrno(-1);
ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
ok(_doserrno == -1,
"Expected _doserrno to be -1, got %d\n", _doserrno);
_doserrno = ERROR_INVALID_CMM;
ret = p_set_doserrno(0xdeadbeef);
ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
ok(_doserrno == 0xdeadbeef,
"Expected _doserrno to be 0xdeadbeef, got %d\n", _doserrno);
}
static void test__set_errno(void)
{
int ret;
@ -330,5 +361,6 @@ START_TEST(misc)
test_strerror_s();
test__get_doserrno();
test__get_errno();
test__set_doserrno();
test__set_errno();
}

View File

@ -130,6 +130,7 @@ extern int* __cdecl _errno(void);
errno_t __cdecl _get_doserrno(int*);
errno_t __cdecl _get_errno(int*);
errno_t __cdecl _set_doserrno(int);
errno_t __cdecl _set_errno(int);
typedef int (__cdecl *_onexit_t)(void);