Andrew Nguyen : msvcrt: Implement _get_doserrno.
Alexandre Julliard
julliard at winehq.org
Tue Sep 28 11:13:34 CDT 2010
Module: wine
Branch: master
Commit: c3b127f5661bd8958ca3ab6f12003c0356410f54
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3b127f5661bd8958ca3ab6f12003c0356410f54
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Tue Sep 28 03:48:42 2010 -0500
msvcrt: Implement _get_doserrno.
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/errno.c | 12 ++++++++++++
dlls/msvcrt/msvcrt.spec | 2 +-
dlls/msvcrt/tests/misc.c | 28 ++++++++++++++++++++++++++++
include/msvcrt/stdlib.h | 1 +
7 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index bece7c5..b76f19b 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -677,7 +677,7 @@
@ cdecl _gcvt_s(ptr long double long) msvcrt._gcvt_s
@ stub _get_current_locale
@ stub _get_daylight
-@ stub _get_doserrno
+@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index d44ce22..5d47caa 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -519,7 +519,7 @@
@ stub _get_amblksiz
@ stub _get_current_locale
@ stub _get_daylight
-@ stub _get_doserrno
+@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index f7f43fb..78152d2 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -511,7 +511,7 @@
@ stub _get_amblksiz
@ stub _get_current_locale
@ stub _get_daylight
-@ stub _get_doserrno
+@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
@ cdecl _get_errno(ptr) msvcrt._get_errno
@ stub _get_fmode
diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c
index 7d1ebe2..b3f506b 100644
--- a/dlls/msvcrt/errno.c
+++ b/dlls/msvcrt/errno.c
@@ -216,6 +216,18 @@ int CDECL _get_errno(int *pValue)
}
/*********************************************************************
+ * _get_doserrno (MSVCRT.@)
+ */
+int CDECL _get_doserrno(int *pValue)
+{
+ if (!pValue)
+ return MSVCRT_EINVAL;
+
+ *pValue = *MSVCRT___doserrno();
+ return 0;
+}
+
+/*********************************************************************
* strerror (MSVCRT.@)
*/
char* CDECL MSVCRT_strerror(int err)
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index fb30d3d..4cb882b 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -462,7 +462,7 @@
@ varargs _fwscanf_s_l(ptr wstr ptr) MSVCRT__fwscanf_s_l
@ cdecl _gcvt(double long str)
@ cdecl _gcvt_s(ptr long double long)
-# stub _get_doserrno
+@ cdecl _get_doserrno(ptr)
# stub _get_environ
@ cdecl _get_errno(ptr)
# stub _get_fileinfo
diff --git a/dlls/msvcrt/tests/misc.c b/dlls/msvcrt/tests/misc.c
index 21d9b5c..6ad8e59 100644
--- a/dlls/msvcrt/tests/misc.c
+++ b/dlls/msvcrt/tests/misc.c
@@ -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_doserrno)(int *);
static int (__cdecl *p_get_errno)(int *);
static void init(void)
@@ -36,6 +37,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_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
}
@@ -243,6 +245,31 @@ static void test_strerror_s(void)
ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
}
+static void test__get_doserrno(void)
+{
+ int ret, out;
+
+ if (!p_get_doserrno)
+ {
+ win_skip("_get_doserrno is not available\n");
+ return;
+ }
+
+ _doserrno = ERROR_INVALID_CMM;
+ errno = EBADF;
+ ret = p_get_doserrno(NULL);
+ ok(ret == EINVAL, "Expected _get_doserrno to return EINVAL, got %d\n", ret);
+ ok(_doserrno = ERROR_INVALID_CMM, "Expected _doserrno to be ERROR_INVALID_CMM, got %d\n", _doserrno);
+ ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
+
+ _doserrno = ERROR_INVALID_CMM;
+ errno = EBADF;
+ out = 0xdeadbeef;
+ ret = p_get_doserrno(&out);
+ ok(ret == 0, "Expected _get_doserrno to return 0, got %d\n", ret);
+ ok(out == ERROR_INVALID_CMM, "Expected output variable to be ERROR_INVAID_CMM, got %d\n", out);
+}
+
static void test__get_errno(void)
{
int ret, out;
@@ -273,5 +300,6 @@ START_TEST(misc)
test_memcpy_s();
test_I10_OUTPUT();
test_strerror_s();
+ test__get_doserrno();
test__get_errno();
}
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h
index 0eb2a21..707d390 100644
--- a/include/msvcrt/stdlib.h
+++ b/include/msvcrt/stdlib.h
@@ -128,6 +128,7 @@ extern int* __cdecl _errno(void);
* char** _sys_errlist;
*/
+errno_t __cdecl _get_doserrno(int*);
errno_t __cdecl _get_errno(int*);
typedef int (__cdecl *_onexit_t)(void);
More information about the wine-cvs
mailing list