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

Re: [Minios-devel] [UNIKRAFT/PTHREAD-EMBEDDED PATCH] pthread.h: Convert pthread_t to unsigned long



Hi Costin, this patch looks good. 

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

On 13.10.19, 15:22, "Costin Lupu" <costin.lupu@xxxxxxxxx> wrote:

    The POSIX standard outlines that pthread_t is an opaque data type and no
    assumption should be made about it. However, we observed that libraries and
    applications assume frequently that pthread_t is a pointer or other 
numerical
    data type and use it to identify the corresponding threads.
    
    pthread-embedded makes the strange decision to define pthread_t as 
structure, a
    decision that, although compliant with POSIX standards, it makes the porting
    process a bit challenging. Therefore we introduce a conversion function 
which
    simply returns the first encapsulated unsigned long value in the structure 
which
    actually points to the underlying thread object.
    
    Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
    ---
     include/pthread.h | 9 +++++++++
     1 file changed, 9 insertions(+)
    
    diff --git a/include/pthread.h b/include/pthread.h
    index c1ebcea..a71fe34 100644
    --- a/include/pthread.h
    +++ b/include/pthread.h
    @@ -29,6 +29,15 @@ extern "C" {
     /* The C code in pthread.h is not guarded for C++ */
     #include_next <pthread.h>
     
    +static inline unsigned long
    +pthread_to_unsigned_long(pthread_t *t)
    +{
    +   unsigned long *_t;
    +
    +   _t = (unsigned long *) t;
    +   return *_t;
    +}
    +
     int pthread_atfork(void (*prepare)(void),
        void (*parent)(void), void (*child)(void));
     
    -- 
    2.20.1
    
    

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.