RE: proposal for ICU tracing

"Carl W. Brown" <[email protected]>
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
Ed,

> As long as the tracing functionality degrades
> gracefuly on non-threading platforms, I think using
> TLS for tracing is a good idea.

#include "unicode/utypes.h"
/* APP_NO_THREADS is an old symbol. We'll honor it if present. */
#ifdef APP_NO_THREADS
# define ICU_USE_THREADS 0
#endif

/* Default: use threads. */
#ifndef ICU_USE_THREADS
# define ICU_USE_THREADS 1
#endif
#if defined(POSIX) && (ICU_USE_THREADS==1)
# include <pthread.h> /* must be first, so that we get the multithread
versions of things. */
#endif

Then:

#if defined(WIN32) && (ICU_USE_THREADS==1)
typedef struct xTLSKey
{
   DWORD key;
} xTLSKey;
#define xiua_get_tls_pointer(x)  TlsGetValue(x.key)

#elif defined(POSIX) && (ICU_USE_THREADS==1)
typedef struct xTLSKey
{
   pthread_key_t key;
} xTLSKey;
   ret = ;
GetRxLocalValue
#define xiua_get_tls_pointer(x)  pthread_getspecific(x.key)
#else
typedef struct xTLSKey
{
   void * key;
} xTLSKey;
#define xiua_get_tls_pointer(x)  (x.key)
#endif
static xTLSKey xiua_tls_key;

Later:

#if defined(WIN32) && (ICU_USE_THREADS==1)

#elif defined(POSIX) && (ICU_USE_THREADS==1)

#else

#endif

Carl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.