Re: Porting skalibs to GNU Hurd

From: Jens Rehsack <rehsack_at_gmail.com>
Date: Thu, 17 Oct 2019 09:33:41 +0200

> Am 17.10.2019 um 01:07 schrieb Guillermo <gdiazhartusch_at_gmail.com>:
>
> El mié., 16 oct. 2019 a las 14:02, Laurent Bercot escribió:
>>
>>> 1. In src/include/skalibs/nonposix.h,
>>>
>>> #if defined(__linux__) || defined(__GLIBC__)
>>> The if condition seems not working. Of course it's not __linux__, but I am
>>> using glibc.
>>
>> Ah, yes, __GLIBC__ is only defined in features.h, you're right.
>
> If compiler predefined macros like __linux__ or __NetBSD__ are OK for
> <skalibs/nonposix.h>, how about #if defined(__linux__) ||
> defined(__GNU__)? GCC predefines both __GNU__ and __gnu_hurd__ (I
> think, can be checked with 'cpp -dM - </dev/null') when compiling for
> the Hurd, and I suppose no other compiler targets that OS...

A reasonable detection in configure stage is definitively to prefer.

>>> 2. No PATH_MAX macro
>>>
>> What I can promise is to fix every issue that you might
>> get with -DPATH_MAX=4096. And remove the dependencies on PATH_MAX that
>> can be removed painlessly. How does that sound?
>
> Do you mean doing something like:
>
> #ifndef PATH_MAX
> #define PATH_MAX 4096
> #endif
>
> or removing references to PATH_MAX altogether?

If stack allocation is a must, maybe it can be evaluated whether
alloca can be an alternative. When the stack size is assumed to
be large enough, a global variable containing the once computed
size and functions can do:

extern const size_t computed_path_max;
int
foo(...)
{
#ifdef PATH_MAX
    char mypath[PATH_MAX];
#else
    char *mypath = alloca(computed_path_max);
#endif
    ...
}

Yes, not 100% satisfying - but maybe a saner way out than
-DPATH_MAX=4096.

Cheers
--
Jens Rehsack - rehsack_at_gmail.com



Received on Thu Oct 17 2019 - 07:33:41 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC