10-25-04 10:52 PM
I am creating a synchronization class that uses pthread stuff.
I include <pthread.h>
On compilation, I get the error:
error: `EINTR' undeclared (first use this function)
There are no errors on the use of pthread functions. No other errors
at all, actually.
Am I missing some crucial include statement?
Here is a standalone function that exhibits the behavior when compiled
with gcc 3.3.3, on Fedora.
#include <pthread.h>
#include <sys/time.h>
int wait(long alongWaitTimeout)
{
int rc = 0;
pthread_mutex_t mutex;
pthread_cond_t cond;
pthread_mutex_lock(&mutex);
if(0 == alongWaitTimeout)
{
pthread_cond_wait(&cond, &mutex);
}
else
{
struct timespec timeout;
struct timeval now;
gettimeofday(&now, NULL);
timeout.tv_sec = now.tv_sec + alongWaitTimeout / 1000;
timeout.tv_nsec = now.tv_usec + (alongWaitTimeout % 1000) * 1000;
rc = pthread_cond_timedwait(&cond, &mutex, &timeout);
}
pthread_mutex_unlock(&mutex);
if(0 == alongWaitTimeout)
return 0;
else
{
if (rc != EINTR)
{
return -1;
}
else
return 0;
}
}
Thanks in advance,
Dave
[ Post a follow-up to this message ]
|