Blame lib/msvc-nothrow.c

Packit 8f70b4
/* Wrappers that don't throw invalid parameter notifications
Packit 8f70b4
   with MSVC runtime libraries.
Packit 8f70b4
   Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 8f70b4
Packit 8f70b4
   This program is free software; you can redistribute it and/or modify
Packit 8f70b4
   it under the terms of the GNU General Public License as published by
Packit 8f70b4
   the Free Software Foundation; either version 3, or (at your option)
Packit 8f70b4
   any later version.
Packit 8f70b4
Packit 8f70b4
   This program is distributed in the hope that it will be useful,
Packit 8f70b4
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
   GNU General Public License for more details.
Packit 8f70b4
Packit 8f70b4
   You should have received a copy of the GNU General Public License along
Packit 8f70b4
   with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit 8f70b4
Packit 8f70b4
#include <config.h>
Packit 8f70b4
Packit 8f70b4
/* Specification.  */
Packit 8f70b4
#include "msvc-nothrow.h"
Packit 8f70b4
Packit 8f70b4
/* Get declarations of the native Windows API functions.  */
Packit 8f70b4
#define WIN32_LEAN_AND_MEAN
Packit 8f70b4
#include <windows.h>
Packit 8f70b4
Packit 8f70b4
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
Packit 8f70b4
# include "msvc-inval.h"
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
#undef _get_osfhandle
Packit 8f70b4
Packit 8f70b4
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
Packit 8f70b4
intptr_t
Packit 8f70b4
_gl_nothrow_get_osfhandle (int fd)
Packit 8f70b4
{
Packit 8f70b4
  intptr_t result;
Packit 8f70b4
Packit 8f70b4
  TRY_MSVC_INVAL
Packit 8f70b4
    {
Packit 8f70b4
      result = _get_osfhandle (fd);
Packit 8f70b4
    }
Packit 8f70b4
  CATCH_MSVC_INVAL
Packit 8f70b4
    {
Packit 8f70b4
      result = (intptr_t) INVALID_HANDLE_VALUE;
Packit 8f70b4
    }
Packit 8f70b4
  DONE_MSVC_INVAL;
Packit 8f70b4
Packit 8f70b4
  return result;
Packit 8f70b4
}
Packit 8f70b4
#endif