Home » U++ Library support » U++ MT-multithreading and servers » Different native pthread.h implementations
Different native pthread.h implementations [message #30766] |
Fri, 21 January 2011 07:04 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello.
There is following error on FreeBSD for multithreading source code, after 3041, 3044 revisions:
Web/socket.cpp: In function 'Upp::String& Upp::SockErrorText()':
Web/socket.cpp:815: error: cast from 'pthread*' to 'int' loses precision
Native implementations of pthread.h are different on BSD operating systems:
DragonFlyBSD:
/*
* Run-time invariant values:
*/
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
#define PTHREAD_KEYS_MAX 256
#define PTHREAD_STACK_MIN 1024
#define PTHREAD_THREADS_MAX ULONG_MAX
#define PTHREAD_BARRIER_SERIAL_THREAD -1
FreeBSD:
/*
* Run-time invariant values:
*/
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
#define PTHREAD_KEYS_MAX 256
#define PTHREAD_STACK_MIN __MINSIGSTKSZ
#define PTHREAD_THREADS_MAX __ULONG_MAX
#define PTHREAD_BARRIER_SERIAL_THREAD -1
OpenBSD:
/*
* Run-time invariant values:
*/
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
#define PTHREAD_KEYS_MAX 256
#define PTHREAD_STACK_MIN 2048
#define PTHREAD_THREADS_MAX ULONG_MAX
Not sure about NetBSD.
I solved it with following source code changes:
diff -ruN uppsrc/Web/socket.cpp uppsrc-fixed/Web/socket.cpp
--- uppsrc/Web/socket.cpp 2011-01-21 09:20:01.000000000 +0600
+++ uppsrc-fixed/Web/socket.cpp 2011-01-21 09:23:27.000000000 +0600
@@ -812,7 +812,11 @@
int tid = GetCurrentThreadId();
#else
#ifdef _MULTITHREADED
- int tid = (int)Thread::GetCurrentId();
+ #ifdef PLATFORM_BSD
+ unsigned long tid = (unsigned long)Thread::GetCurrentId();
+ #else
+ int tid = (int)Thread::GetCurrentId();
+ #endif
#else
int tid = 0;
#endif
May be it possible to use "unsigned long" for all implementations.
|
|
|
Goto Forum:
Current Time: Thu May 09 10:35:46 CEST 2024
Total time taken to generate the page: 0.02876 seconds
|