From 4040b3bddb086e8230b0d9356297e971729a9c44 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 24 Sep 2011 01:48:27 +0200 Subject: [PATCH] getdtablesize: Support for MSVC 9. * lib/getdtablesize.c: Include msvc-inval.h. (_setmaxstdio_nothrow): New function. (_setmaxstdio): Redefine it. * m4/getdtablesize.m4 (gl_PREREQ_GETDTABLESIZE): New macro. * modules/getdtablesize (Depends-on): Add msvc-inval. (configure.ac): Invoke gl_PREREQ_GETDTABLESIZE. --- ChangeLog | 10 ++++++++++ lib/getdtablesize.c | 23 +++++++++++++++++++++++ m4/getdtablesize.m4 | 7 ++++++- modules/getdtablesize | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ef8dc9294..ae72da716 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-09-23 Bruno Haible + getdtablesize: Support for MSVC 9. + * lib/getdtablesize.c: Include msvc-inval.h. + (_setmaxstdio_nothrow): New function. + (_setmaxstdio): Redefine it. + * m4/getdtablesize.m4 (gl_PREREQ_GETDTABLESIZE): New macro. + * modules/getdtablesize (Depends-on): Add msvc-inval. + (configure.ac): Invoke gl_PREREQ_GETDTABLESIZE. + +2011-09-23 Bruno Haible + signal-h: Rename from signal. * modules/signal-h: Renamed from modules/signal. * modules/pthread_sigmask (Depends-on): Update. diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c index 60e7f5af1..a07c4a2ea 100644 --- a/lib/getdtablesize.c +++ b/lib/getdtablesize.c @@ -24,6 +24,29 @@ #include +#include "msvc-inval.h" + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static inline int +_setmaxstdio_nothrow (int newmax) +{ + int result; + + TRY_MSVC_INVAL + { + result = _setmaxstdio (newmax); + } + CATCH_MSVC_INVAL + { + result = -1; + } + DONE_MSVC_INVAL; + + return result; +} +# define _setmaxstdio _setmaxstdio_nothrow +#endif + /* Cache for the previous getdtablesize () result. */ static int dtablesize; diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index 40a598bc1..5f0fbf266 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -1,4 +1,4 @@ -# getdtablesize.m4 serial 2 +# getdtablesize.m4 serial 3 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,3 +12,8 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE], HAVE_GETDTABLESIZE=0 fi ]) + +# Prerequisites of lib/getdtablesize.c. +AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [ + AC_REQUIRE([AC_C_INLINE]) +]) diff --git a/modules/getdtablesize b/modules/getdtablesize index 3b195c0c8..109be1fda 100644 --- a/modules/getdtablesize +++ b/modules/getdtablesize @@ -7,11 +7,13 @@ m4/getdtablesize.m4 Depends-on: unistd +msvc-inval [test $HAVE_GETDTABLESIZE = 0] configure.ac: gl_FUNC_GETDTABLESIZE if test $HAVE_GETDTABLESIZE = 0; then AC_LIBOBJ([getdtablesize]) + gl_PREREQ_GETDTABLESIZE fi gl_UNISTD_MODULE_INDICATOR([getdtablesize]) -- 2.11.0