Re: Thread-safe getopt()

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Thread-safe getopt()
Дата
Msg-id 600286f9-fdc3-4d6e-8458-9bfcc729d228@iki.fi
обсуждение исходный текст
Ответ на Re: Thread-safe getopt()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Thread-safe getopt()
Список pgsql-hackers
On 30/03/2026 17:34, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>>>> Here's a patch for a thread-safe version of getopt(). I implemented it
>>>> as two functions, pg_getopt_start() and pg_getopt_next(). Since
>>>> there's no standard to follow, we have freedom on how to implement it,
> 
> Why in the world would we invent our own getopt API rather than
> just replacing the relevant state variables with thread-local ones,
> entirely internally to getopt.c?
> 
> It's not like this is a performance-critical code path.  I think
> the cognitive load for developers of having to learn YA API should
> weigh against doing things this way.

The new API is very similar to the same as the plain getopt() API, it'll 
be quickly recognizable to anyone who's familiar with getopt().

Thread-local variables would work too, but I think we'd need to give 
them different names anyway to avoid conflicting with the plain getopt() 
global variables.

- Heikki




В списке pgsql-hackers по дате отправления: