MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbsleep.h File Reference
#include "ac/f2c.h"
#include "math.h"
Include dependency graph for mbsleep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MBSLEEP_ISZERO(mbs)   ((mbs) == 0)
 

Typedefs

typedef unsigned long mbsleep_t
 

Functions

mbsleep_t mbsleep_init (long t)
 
int mbsleep_real2sleep (doublereal d, mbsleep_t *t)
 
int mbsleep_sleep2real (const mbsleep_t *t, doublereal *d)
 
int mbsleep (const mbsleep_t *t)
 

Macro Definition Documentation

#define MBSLEEP_ISZERO (   mbs)    ((mbs) == 0)

Definition at line 52 of file mbsleep.h.

Typedef Documentation

typedef unsigned long mbsleep_t

Definition at line 51 of file mbsleep.h.

Function Documentation

int mbsleep ( const mbsleep_t t)

Definition at line 90 of file mbsleep.c.

Referenced by check_flag(), ExtFileHandlerEDGE::CheckFlag(), main(), put_flag(), ExtFileHandlerEDGE::Recv_pre(), ExtFileHandler::Recv_pre(), ExtFileHandlerEDGE::Send_pre(), ExtFileHandler::Send_pre(), and ExtFileHandlerEDGE::SendFlag().

91 {
92 #if defined(HAVE_NANOSLEEP)
93  return nanosleep(t, NULL);
94 #elif defined(HAVE_USLEEP)
95  return usleep(*t);
96 #elif defined(HAVE_SLEEP)
97  return sleep(*t);
98 #endif /* ! SLEEP */
99 
100  return -1;
101 }
mbsleep_t mbsleep_init ( long  t)

Definition at line 38 of file mbsleep.c.

Referenced by main(), ReadExtFileHandler(), ReadExtFileHandlerEDGE(), ReadExtSocketHandler(), and ExtFileHandlerEDGE::SendFlag().

39 {
40 #if defined(HAVE_NANOSLEEP)
41  mbsleep_t v = { t, 0 };
42  return v;
43 #else /* ! HAVE_NANOSLEEP */
44  return t;
45 #endif /* ! HAVE_NANOSLEEP */
46 }
unsigned long mbsleep_t
Definition: mbsleep.h:51
int mbsleep_real2sleep ( doublereal  d,
mbsleep_t t 
)

Definition at line 49 of file mbsleep.c.

Referenced by HighParser::GetTimeout().

50 {
51  if (d < 0) {
52  return -1;
53  }
54 
55 #if defined(HAVE_NANOSLEEP)
56  t->tv_sec = (time_t)floor(d);
57  t->tv_nsec = (long)floor((d - t->tv_sec)*1000000000);
58 #elif defined(HAVE_USLEEP)
59  *t = (unsigned long)floor(d*1000000);
60 #elif defined(HAVE_SLEEP)
61  if (d > 1.) {
62  *t = (unsigned int)floor(d);
63  } else {
64  *t = 1;
65  }
66 #else /* ! SLEEP */
67  *t = 0;
68 #endif /* ! SLEEP */
69 
70  return 0;
71 }
int mbsleep_sleep2real ( const mbsleep_t t,
doublereal d 
)

Definition at line 74 of file mbsleep.c.

Referenced by HighParser::GetTimeout().

75 {
76 #if defined(HAVE_NANOSLEEP)
77  *d = ((doublereal)(t->tv_nsec))/1000000000 + t->tv_sec;
78 #elif defined(HAVE_USLEEP)
79  *d = ((doublereal)*t)/1000000;
80 #elif defined(HAVE_SLEEP)
81  *d = (doublereal)*t;
82 #else /* ! SLEEP */
83  *d = 0.;
84 #endif /* ! SLEEP */
85 
86  return 0;
87 }
double doublereal
Definition: colamd.c:52