Commit 79ab7152 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

msvcrt: Implement _get_errno.

parent b7a74d24
......@@ -679,7 +679,7 @@
@ stub _get_daylight
@ stub _get_doserrno
@ stub _get_dstbias
@ stub _get_errno
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
@ cdecl _get_heap_handle() msvcrt._get_heap_handle
@ cdecl _get_invalid_parameter_handler() msvcrt._get_invalid_parameter_handler
......
......@@ -521,7 +521,7 @@
@ stub _get_daylight
@ stub _get_doserrno
@ stub _get_dstbias
@ stub _get_errno
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
@ cdecl _get_heap_handle() msvcrt._get_heap_handle
@ cdecl _get_invalid_parameter_handler() msvcrt._get_invalid_parameter_handler
......
......@@ -513,7 +513,7 @@
@ stub _get_daylight
@ stub _get_doserrno
@ stub _get_dstbias
@ stub _get_errno
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
@ cdecl _get_heap_handle() msvcrt._get_heap_handle
@ cdecl _get_invalid_parameter_handler() msvcrt._get_invalid_parameter_handler
......
......@@ -204,6 +204,18 @@ MSVCRT_ulong* CDECL MSVCRT___doserrno(void)
}
/*********************************************************************
* _get_errno (MSVCRT.@)
*/
int CDECL _get_errno(int *pValue)
{
if (!pValue)
return MSVCRT_EINVAL;
*pValue = *MSVCRT__errno();
return 0;
}
/*********************************************************************
* strerror (MSVCRT.@)
*/
char* CDECL MSVCRT_strerror(int err)
......
......@@ -464,7 +464,7 @@
@ cdecl _gcvt_s(ptr long double long)
# stub _get_doserrno
# stub _get_environ
# stub _get_errno
@ cdecl _get_errno(ptr)
# stub _get_fileinfo
# stub _get_fmode
@ cdecl _get_heap_handle()
......
......@@ -26,6 +26,7 @@ static int (__cdecl *prand_s)(unsigned int *);
static int (__cdecl *pmemcpy_s)(void *, MSVCRT_size_t, void*, MSVCRT_size_t);
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_errno)(int *);
static void init(void)
{
......@@ -35,6 +36,7 @@ static void init(void)
pmemcpy_s = (void*)GetProcAddress(hmod, "memcpy_s");
pI10_OUTPUT = (void*)GetProcAddress(hmod, "$I10_OUTPUT");
pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
}
static void test_rand_s(void)
......@@ -241,6 +243,28 @@ static void test_strerror_s(void)
ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
}
static void test__get_errno(void)
{
int ret, out;
if (!p_get_errno)
{
win_skip("_get_errno is not available\n");
return;
}
errno = EBADF;
ret = p_get_errno(NULL);
ok(ret == EINVAL, "Expected _get_errno to return EINVAL, got %d\n", ret);
ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
errno = EBADF;
out = 0xdeadbeef;
ret = p_get_errno(&out);
ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret);
ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
}
START_TEST(misc)
{
init();
......@@ -249,4 +273,5 @@ START_TEST(misc)
test_memcpy_s();
test_I10_OUTPUT();
test_strerror_s();
test__get_errno();
}
......@@ -128,6 +128,7 @@ extern int* __cdecl _errno(void);
* char** _sys_errlist;
*/
errno_t __cdecl _get_errno(int*);
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