mingw-w64/mingw-w64-crt/secapi/_umask_s.c
David Wohlferd 5af3b0e59a _SECIMP patch 1 of 3: Update secapi/*.c files to remove dupe prototypes and include correct headers.
A number of the secapi/*.c files (actually all of them) duplicate the function prototypes of the functions they implement (and sometimes some of the functions they use as well) instead of simply including the appropriate header.

Signed-off-by: David Wohlferd <dw@LimeGreenSocks.com>
2016-08-26 17:15:40 -07:00

46 lines
841 B
C

#include <windows.h>
#include <malloc.h>
#include <errno.h>
#include <msvcrt.h>
#include <io.h>
static errno_t __cdecl _int_umask_s (int, int *);
static errno_t __cdecl _stub (int, int *);
errno_t __cdecl (*__MINGW_IMP_SYMBOL(_umask_s))(int, int *) =
_stub;
static errno_t __cdecl
_stub (int m, int *pold)
{
errno_t __cdecl (*f)(int, int *) = __MINGW_IMP_SYMBOL(_umask_s);
if (f == _stub)
{
f = (errno_t __cdecl (*)(int, int *))
GetProcAddress (__mingw_get_msvcrt_handle (), "_umask_s");
if (!f)
f = _int_umask_s;
__MINGW_IMP_SYMBOL(_umask_s) = f;
}
return (*f)(m, pold);
}
errno_t __cdecl
_umask_s (int m, int *pold)
{
return _stub (m, pold);
}
static errno_t __cdecl
_int_umask_s (int m, int *pold)
{
if (!pold)
{
errno = EINVAL;
return EINVAL;
}
*pold = _umask (m);
return 0;
}