[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix weird _SC_OPEN_MAX usage

From: Jonas 'Sortie' Termansen
Subject: Re: Fix weird _SC_OPEN_MAX usage
Date: Thu, 07 Aug 2014 21:00:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 08/07/2014 06:59 PM, Paul Eggert wrote:
> That shouldn't be a problem, since the modules in question all depend on
> the getdtablesize module, which should supply the getdtablesize function
> on platforms that lack it.

Ah. I missed that.

Some background: I'm porting these modules (as found in bison, gettext,
m4, and such) to a new operating system. It has the standard
sysconf(_SC_OPEN_MAX) interface and it doesn't have the older and
non-standard getdtablesize() interface.

But the gnulib getdtablesize only has implementations for Windows and
Cygwin. This causes an undefined reference error when the spawn faction
modules tries to use it.

We can fix this:

1) Add a getdtablesize () replacement based on sysconf (_SC_OPEN_MAX).
2) Replace __sysconf (_SC_OPEN_MAX) with getdtablesize ().

The modules shouldn't use the __sysconf name as it is in the reserved
namespace and actually likely to collide with a system header. It should
just call getdtablesize directly.

I'm proposing something like this:

+getdtablesize (void)
+  return sysconf (_SC_OPEN_MAX);

-#if !_LIBC
-# define __sysconf(open_max) getdtablesize ()
-  int maxfd = __sysconf (_SC_OPEN_MAX);
+  int maxfd = getdtablesize ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]