|
Home > Archive > Unix Programming > October 2004 > EINTR undeclared - why?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
EINTR undeclared - why?
|
|
| kaatzd@hotmail.com 2004-10-25, 5: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
| |
| Dragan Cvetkovic 2004-10-25, 5:52 pm |
| "kaatzd@hotmail.com" <kaatzd@hotmail.com> writes:
> 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?
You are missing
#include <errno.h>
--
Dragan Cvetkovic,
To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
!!! Sender/From address is bogus. Use reply-to one !!!
|
|
|
|
|