Blame lib/msvc-nothrow.c

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