Commit 67088eb3 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

msvcrt: Implement _set_doserrno.

parent ad68c0bd
...@@ -1070,7 +1070,7 @@ ...@@ -1070,7 +1070,7 @@
@ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable @ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable
@ stub _set_abort_behavior @ stub _set_abort_behavior
@ stub _set_controlfp @ stub _set_controlfp
@ stub _set_doserrno @ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno @ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode @ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode @ stub _set_fmode
......
...@@ -923,7 +923,7 @@ ...@@ -923,7 +923,7 @@
@ stub _set_abort_behavior @ stub _set_abort_behavior
@ stub _set_amblksiz @ stub _set_amblksiz
@ stub _set_controlfp @ stub _set_controlfp
@ stub _set_doserrno @ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno @ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode @ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode @ stub _set_fmode
......
...@@ -909,7 +909,7 @@ ...@@ -909,7 +909,7 @@
@ stub _set_abort_behavior @ stub _set_abort_behavior
@ stub _set_amblksiz @ stub _set_amblksiz
@ stub _set_controlfp @ stub _set_controlfp
@ stub _set_doserrno @ cdecl _set_doserrno(long) msvcrt._set_doserrno
@ cdecl _set_errno(long) msvcrt._set_errno @ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode @ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode @ stub _set_fmode
......
...@@ -237,6 +237,15 @@ int CDECL _set_errno(int value) ...@@ -237,6 +237,15 @@ int CDECL _set_errno(int value)
} }
/********************************************************************* /*********************************************************************
* _set_doserrno (MSVCRT.@)
*/
int CDECL _set_doserrno(int value)
{
*MSVCRT___doserrno() = value;
return 0;
}
/*********************************************************************
* strerror (MSVCRT.@) * strerror (MSVCRT.@)
*/ */
char* CDECL MSVCRT_strerror(int err) char* CDECL MSVCRT_strerror(int err)
......
...@@ -848,7 +848,7 @@ ...@@ -848,7 +848,7 @@
@ stdcall -i386 _seh_longjmp_unwind(ptr) @ stdcall -i386 _seh_longjmp_unwind(ptr)
@ cdecl _set_SSE2_enable(long) MSVCRT__set_SSE2_enable @ cdecl _set_SSE2_enable(long) MSVCRT__set_SSE2_enable
# stub _set_controlfp # stub _set_controlfp
# stub _set_doserrno @ cdecl _set_doserrno(long)
@ cdecl _set_errno(long) @ cdecl _set_errno(long)
@ cdecl _set_error_mode(long) @ cdecl _set_error_mode(long)
# stub _set_fileinfo # stub _set_fileinfo
......
...@@ -28,6 +28,7 @@ static int (__cdecl *pI10_OUTPUT)(long double, int, int, void*); ...@@ -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 *pstrerror_s)(char *, MSVCRT_size_t, int);
static int (__cdecl *p_get_doserrno)(int *); static int (__cdecl *p_get_doserrno)(int *);
static int (__cdecl *p_get_errno)(int *); static int (__cdecl *p_get_errno)(int *);
static int (__cdecl *p_set_doserrno)(int);
static int (__cdecl *p_set_errno)(int); static int (__cdecl *p_set_errno)(int);
static void init(void) static void init(void)
...@@ -40,6 +41,7 @@ static void init(void) ...@@ -40,6 +41,7 @@ static void init(void)
pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s"); pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno"); p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
p_get_errno = (void *)GetProcAddress(hmod, "_get_errno"); p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
p_set_errno = (void *)GetProcAddress(hmod, "_set_errno"); p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
} }
...@@ -294,6 +296,35 @@ static void test__get_errno(void) ...@@ -294,6 +296,35 @@ static void test__get_errno(void)
ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out); 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) static void test__set_errno(void)
{ {
int ret; int ret;
...@@ -330,5 +361,6 @@ START_TEST(misc) ...@@ -330,5 +361,6 @@ START_TEST(misc)
test_strerror_s(); test_strerror_s();
test__get_doserrno(); test__get_doserrno();
test__get_errno(); test__get_errno();
test__set_doserrno();
test__set_errno(); test__set_errno();
} }
...@@ -130,6 +130,7 @@ extern int* __cdecl _errno(void); ...@@ -130,6 +130,7 @@ extern int* __cdecl _errno(void);
errno_t __cdecl _get_doserrno(int*); errno_t __cdecl _get_doserrno(int*);
errno_t __cdecl _get_errno(int*); errno_t __cdecl _get_errno(int*);
errno_t __cdecl _set_doserrno(int);
errno_t __cdecl _set_errno(int); errno_t __cdecl _set_errno(int);
typedef int (__cdecl *_onexit_t)(void); typedef int (__cdecl *_onexit_t)(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment