Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 21 Jun 2015 10:20:18 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: Problem with c++ and std::thread comparison

Am Sonntag, den 21.06.2015, 17:10 +1000 schrieb Comm Unist:
> What happens when you try to call a weak symbol? Do you end up calling 0x000000.....00 depending on your arch?

Why do you ask? Could you be more specific in what problem you encounter?

> I ask because I have C++ program that uses std::threads.
> These use pthreads internally.

You mean you are using a C++ library that maps std::threads to
pthreads, or are you talking about a mapping to the musl C11 threads
implementation, that then shares code with musl's pthread
implementation?

(Mapping std::threads to C11 threads should clearly be the more
appropriate choice.)

> There were two places where I have problems. One was with condtiion
> variables

Just annoncing that you have problems doesn't tell us much. Describe
your problem properly, please.

and the other with comparsion of std::thread ids:

> This changes seems to work, or does c++ not needs to check pthreads being equal?
> 
> 
> diff --git a/include/pthread.h b/include/pthread.h
> index 99a74a5..e97b9e4 100644
> --- a/include/pthread.h
> +++ b/include/pthread.h
> @@ -85,9 +85,7 @@ __attribute__((const))
>  pthread_t pthread_self(void);
>  
>  int pthread_equal(pthread_t, pthread_t);
> -#ifndef __cplusplus
> -#define pthread_equal(x,y) ((x)==(y))
> -#endif
> +inline int pthread_equal(pthread_t a, pthread_t b) { return a == b; }

Why wouldn't just a declaration of the function prototype suffice?

The way you are doing this would clearly not work for C since this
would instantiate a version of the function in every translation unit.

Jens


-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::





Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.