Revision dc786bc9 osdep.c

b/osdep.c
111 111
    return 0;
112 112
}
113 113

  
114
#ifdef _WIN32
115

  
116
/* mingw32 needs ffs for compilations without optimization. */
117
int ffs(int i)
118
{
119
    /* Use gcc's builtin ffs. */
120
    return __builtin_ffs(i);
121
}
122

  
123
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
124
#define _W32_FT_OFFSET (116444736000000000ULL)
125

  
126
int qemu_gettimeofday(qemu_timeval *tp)
127
{
128
  union {
129
    unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
130
    FILETIME ft;
131
  }  _now;
132

  
133
  if(tp)
134
    {
135
      GetSystemTimeAsFileTime (&_now.ft);
136
      tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
137
      tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
138
    }
139
  /* Always return 0 as per Open Group Base Specifications Issue 6.
140
     Do not set errno on error.  */
141
  return 0;
142
}
143
#endif /* _WIN32 */
144

  
145 114

  
146 115
/*
147 116
 * Opens a file with FD_CLOEXEC set

Also available in: Unified diff