Blame gettext-runtime/gnulib-lib/msvc-nothrow.c

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