[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] nanosleep



Just grab the latest mintlib from www.freemint.org

Alan.

On 01/20/13 19:02, Peter Slegg wrote:
Hi all,

I am trying to use a unit that has nanosleep in it.
I see that there is a version in mintlib

How can I add this to my make to avoid this error ?

msleep.o:obj.040/msleep.o:(.text+0x54): undefined reference to `_nanosleep'

Regards,

Peter


#include <unistd.h>

#ifdef _POSIX_VERSION
# if _POSIX_VERSION >= 199309L
#   define USE_NANOSLEEP
# endif
#endif

#ifdef USE_NANOSLEEP
#  include <time.h>
#else
#  include "iopause.h"
#endif
#include "msleep.h"

#define M 1000000
void
msleep(unsigned long x)
{
#ifdef USE_NANOSLEEP
   unsigned long long n;
   struct timespec t1;
   n=M*x;
   t1.tv_sec=n/(1000*M);
   t1.tv_nsec=n%(1000*M);
   nanosleep(&t1,0);
#else
   struct taia now,then;
   taia_now(&now);
   /* x is in 1/1000 seconds */
   taia_uint(&then,x/1000); /* seconds */
   then.nano=(x%1000)*M; /* 1/1000 seconds */
   then.atto=0;
   taia_add(&then,&now,&then);
   iopause(0,0,&then,&now);
#endif
}