[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] qemu-thread-posix: Fix build against older glib

From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] qemu-thread-posix: Fix build against older glibc version
Date: Tue, 11 Mar 2014 17:51:16 +0000

On 11 March 2014 16:36, Dr. David Alan Gilbert <address@hidden> wrote:
> * Peter Maydell (address@hidden) wrote:
>> On 11 March 2014 16:13, Dr. David Alan Gilbert <address@hidden> wrote:
>> > * Peter Maydell (address@hidden) wrote:
>> >> Can we have a configure test for the function instead, please?
>> >> We don't generally do tests for specific glibc versions
>> >> (among other things, glibc is not the only C library we
>> >> might be compiled against -- consider MacOSX, the BSDs,
>> >> and occasionally somebody tries to compile against one
>> >> of the embedded libcs).
>> >
>> > Except pthread_setname_np is not portable and was previously
>> > ifdef'd _GNU_SOURCE anyway
>> I still think it's a generally worse way to do checks.
>> We currently have only one check against __GLIBC_MINOR__
>> in the tree (and that's in extremely Linux-specific
>> code).
>> > the parameters on other OSs
>> > maybe different (freebsd has got a 3rd parameter for no
>> > apparent reason).
>> This rather suggests we should abstract the "set thread
>> name" functionality out into its own function so we
>> can easily provide other implementations for those
>> other OSes later.
> OK, well there is already a
> void os_set_proc_name(const char *s)
> in os-posix.c but it has ~2 problems:
>   1) If the OS doesn't support doing it that way it exit(1)'s
>   2) it uses prctl to set it on the current thread, where
>      pthread_setname_np has the advantage that it sets it on
>      something you have a pthread* for.
>   3) There isn't a matching entry in os-win32.c
> is the best thing to add another function to os-posix and os-win
> then?

Given this function's only for use in qemu-thread-posix.c
I think it would be reasonable to just have it live there.
It would be nicer to have an

static void qemu_thread_set_name(QemuThread *thread, const char *name)
    pthread_setname_np(thread->thread, name);

rather than #ifdefs in the middle of functions,
that's all.

-- PMM

reply via email to

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