From ed8110e101db5a8ea4dde43a3ec38fe40e6fe7e2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 21 Jan 2015 14:25:23 +0100 Subject: [PATCH] Avoid reinterpret_cast to same type ...as GCC 4.6 reports "error: invalid cast from type 'pthread_t {aka long unsigned int}' to type 'long unsigned int'" despite [expr.reinterpret.cast]/2: "An expression of integral, enumeration, pointer, or pointer-to-member type can be explicitly converted to its own type; such a cast yields the value of its operand." Change-Id: I26f1a3e6df2f0e55c665ad4f49185e0ebf432e95 --- sal/osl/unx/system.hxx | 7 +++++-- sal/osl/unx/thread.cxx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sal/osl/unx/system.hxx b/sal/osl/unx/system.hxx index 3013e91c6341..75c3d9d90d36 100644 --- a/sal/osl/unx/system.hxx +++ b/sal/osl/unx/system.hxx @@ -309,9 +309,12 @@ int macxp_resolveAlias(char *path, int buflen); # define INIT_GROUPS(name, gid) ((setgid((gid)) == 0) && (initgroups((name), (gid)) == 0)) #endif -#ifndef PTHREAD_VALUE -# define PTHREAD_VALUE(t) (t) +#if defined MACOSX +#define PTHREAD_VALUE(t) reinterpret_cast(t) +#else +#define PTHREAD_VALUE(t) (t) #endif + #ifndef PTHREAD_NONE # define PTHREAD_NONE _pthread_none_ # ifndef PTHREAD_NONE_INIT diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx index 2dc913c3c554..0ca411383c27 100644 --- a/sal/osl/unx/thread.cxx +++ b/sal/osl/unx/thread.cxx @@ -551,7 +551,7 @@ void SAL_CALL osl_setThreadName(char const * name) { /* osl_getThreadIdentifier @@@ see TODO @@@ */ /*****************************************************************************/ -#define HASHID(x) (reinterpret_cast(PTHREAD_VALUE(x)) % HashSize) +#define HASHID(x) ((unsigned long)PTHREAD_VALUE(x) % HashSize) typedef struct _HashEntry {