msvcrt: Implement _set_errno.

This commit is contained in:
Andrew Nguyen 2010-09-28 03:48:52 -05:00 committed by Alexandre Julliard
parent c3b127f566
commit ad68c0bd3c
7 changed files with 43 additions and 4 deletions

View File

@ -1071,7 +1071,7 @@
@ stub _set_abort_behavior
@ stub _set_controlfp
@ stub _set_doserrno
@ stub _set_errno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler

View File

@ -924,7 +924,7 @@
@ stub _set_amblksiz
@ stub _set_controlfp
@ stub _set_doserrno
@ stub _set_errno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler

View File

@ -910,7 +910,7 @@
@ stub _set_amblksiz
@ stub _set_controlfp
@ stub _set_doserrno
@ stub _set_errno
@ cdecl _set_errno(long) msvcrt._set_errno
@ cdecl _set_error_mode(long) msvcrt._set_error_mode
@ stub _set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler

View File

@ -227,6 +227,15 @@ int CDECL _get_doserrno(int *pValue)
return 0;
}
/*********************************************************************
* _set_errno (MSVCRT.@)
*/
int CDECL _set_errno(int value)
{
*MSVCRT__errno() = value;
return 0;
}
/*********************************************************************
* strerror (MSVCRT.@)
*/

View File

@ -849,7 +849,7 @@
@ cdecl _set_SSE2_enable(long) MSVCRT__set_SSE2_enable
# stub _set_controlfp
# stub _set_doserrno
# stub _set_errno
@ cdecl _set_errno(long)
@ cdecl _set_error_mode(long)
# stub _set_fileinfo
# stub _set_fmode

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_errno)(int);
static void init(void)
{
@ -39,6 +40,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_errno = (void *)GetProcAddress(hmod, "_set_errno");
}
static void test_rand_s(void)
@ -292,6 +294,32 @@ static void test__get_errno(void)
ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
}
static void test__set_errno(void)
{
int ret;
if (!p_set_errno)
{
win_skip("_set_errno is not available\n");
return;
}
errno = EBADF;
ret = p_set_errno(EINVAL);
ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
errno = EBADF;
ret = p_set_errno(-1);
ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
ok(errno == -1, "Expected errno to be -1, got %d\n", errno);
errno = EBADF;
ret = p_set_errno(0xdeadbeef);
ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
ok(errno == 0xdeadbeef, "Expected errno to be 0xdeadbeef, got %d\n", errno);
}
START_TEST(misc)
{
init();
@ -302,4 +330,5 @@ START_TEST(misc)
test_strerror_s();
test__get_doserrno();
test__get_errno();
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_errno(int);
typedef int (__cdecl *_onexit_t)(void);