TheMeanPthreadHack

From BRF-Software
Revision as of 07:18, 26 October 2011 by Admin (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A little workaround for packages using the PThread library

Example

When trying to compile some bioconductor packages eg. the affyio packages in Biobase you may experinece compilation errors like undefined symbol PTHREAD_STACK_MIN or undefined symbol PTHREAD_DESTRUCTOR_ITERATIONS. These are symbols used in included pthread.h but they are defined in limits.h. with the given compilation options however these macros are not defined, because of a conditional define checking for a given POSIX_C_SOURCE version. A workaround is to place a mock pthread.h include file in the directory <R-installdirectory>/lib/R/include, which looks like:


#include "/usr/include/pthread.h"
#include <limits.h>
#include <unistd.h>
#warning Using selfdefined PTHREAD_ macros in my own pthread.h in R_HOME/lib/R/include

extern long _sysconf(int);	/* System Private interface to sysconf() */
#ifndef _SC_THREAD_STACK_MIN
#error _SC_THREAD_STACK_MIN is not defined
#endif

#define	PTHREAD_STACK_MIN	((size_t)_sysconf(_SC_THREAD_STACK_MIN))
/* Added for UNIX98 conformance */
#define	PTHREAD_DESTRUCTOR_ITERATIONS	_POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define	PTHREAD_KEYS_MAX		_POSIX_THREAD_KEYS_MAX
#define	PTHREAD_THREADS_MAX		_POSIX_THREAD_THREADS_MAX

This is a bad workaround, because we include the absolute path and define the missing symbols ourselves. If you have abetter idea feel free to fix either the affyio package or the Solaris pthread.h, limits.h