msvc-nothrow.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Wrappers that don't throw invalid parameter notifications
  2. with MSVC runtime libraries.
  3. Copyright (C) 2011-2013 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License along
  13. with this program; if not, see <http://www.gnu.org/licenses/>. */
  14. #include <config.h>
  15. /* Specification. */
  16. #include "msvc-nothrow.h"
  17. /* Get declarations of the native Windows API functions. */
  18. #define WIN32_LEAN_AND_MEAN
  19. #include <windows.h>
  20. #include "msvc-inval.h"
  21. #undef _get_osfhandle
  22. #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
  23. intptr_t
  24. _gl_nothrow_get_osfhandle (int fd)
  25. {
  26. intptr_t result;
  27. TRY_MSVC_INVAL
  28. {
  29. result = _get_osfhandle (fd);
  30. }
  31. CATCH_MSVC_INVAL
  32. {
  33. result = (intptr_t) INVALID_HANDLE_VALUE;
  34. }
  35. DONE_MSVC_INVAL;
  36. return result;
  37. }
  38. #endif