Blame lib/msvc-nothrow.c

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