1 #include <windows.h>
2 #include <malloc.h>
3 #include <errno.h>
4 #include <msvcrt.h>
5 #include <io.h>
6
7 static errno_t __cdecl _int_umask_s (int, int *);
8 static errno_t __cdecl _stub (int, int *);
9
10 errno_t __cdecl (*__MINGW_IMP_SYMBOL(_umask_s))(int, int *) =
11 _stub;
12
13 static errno_t __cdecl
_stub(int m,int * pold)14 _stub (int m, int *pold)
15 {
16 errno_t __cdecl (*f)(int, int *) = __MINGW_IMP_SYMBOL(_umask_s);
17
18 if (f == _stub)
19 {
20 f = (errno_t __cdecl (*)(int, int *))
21 GetProcAddress (__mingw_get_msvcrt_handle (), "_umask_s");
22 if (!f)
23 f = _int_umask_s;
24 __MINGW_IMP_SYMBOL(_umask_s) = f;
25 }
26 return (*f)(m, pold);
27 }
28
29 errno_t __cdecl
_umask_s(int m,int * pold)30 _umask_s (int m, int *pold)
31 {
32 return _stub (m, pold);
33 }
34
35 static errno_t __cdecl
_int_umask_s(int m,int * pold)36 _int_umask_s (int m, int *pold)
37 {
38 if (!pold)
39 {
40 errno = EINVAL;
41 return EINVAL;
42 }
43 *pold = _umask (m);
44 return 0;
45 }
46