EINTR undeclared - why?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > EINTR undeclared - why?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    EINTR undeclared - why?  
kaatzd@hotmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Re: EINTR undeclared - why?  
Dragan Cvetkovic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-25-04 10: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 !!!





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:51 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register