~ubuntu-branches/ubuntu/lucid/hal/lucid-proposed

« back to all changes in this revision

Viewing changes to hald/freebsd/libprobe/hfp.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-12-03 01:21:24 UTC
  • mto: (1.1.18 squeeze)
  • mto: This revision was merged to the branch mainline in revision 165.
  • Revision ID: james.westby@ubuntu.com-20091203012124-3573qknop973uvc2
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
  dbus_error_init(&hfp_error);
71
71
  hfp_ctx = libhal_ctx_init_direct(&hfp_error);
72
 
  dbus_error_free(&hfp_error);
 
72
  LIBHAL_FREE_DBUS_ERROR(&hfp_error);
73
73
 
74
74
  return TRUE;
75
75
}
216
216
}
217
217
 
218
218
void
219
 
hfp_gettimeofday (struct timeval *t)
 
219
hfp_clock_gettime (struct timespec *t)
220
220
{
221
221
  int status;
222
222
 
223
223
  assert(t != NULL);
224
224
 
225
 
  status = gettimeofday(t, NULL);
 
225
#ifdef CLOCK_MONOTONIC_FAST
 
226
  status = clock_gettime(CLOCK_MONOTONIC_FAST, t);
 
227
#else
 
228
  status = clock_gettime(CLOCK_MONOTONIC, t);
 
229
#endif
226
230
  assert(status == 0);
227
231
}
228
232
 
229
 
/* timeval functions from sys/kern/kern_time.c */
 
233
/* timespec functions from sys/kern/kern_time.c */
230
234
 
231
235
static void
232
 
hfp_timevalfix (struct timeval *t)
 
236
hfp_timespecfix (struct timespec *t)
233
237
{
234
238
  assert(t != NULL);
235
239
 
236
 
  if (t->tv_usec < 0)
 
240
  if (t->tv_nsec < 0)
237
241
    {
238
242
      t->tv_sec--;
239
 
      t->tv_usec += 1000000;
 
243
      t->tv_nsec += 1000000000;
240
244
    }
241
 
  if (t->tv_usec >= 1000000)
 
245
  if (t->tv_nsec >= 1000000000)
242
246
    {
243
247
      t->tv_sec++;
244
 
      t->tv_usec -= 1000000;
 
248
      t->tv_nsec -= 1000000000;
245
249
    }
246
250
}
247
251
 
248
252
void
249
 
hfp_timevaladd (struct timeval *t1, const struct timeval *t2)
 
253
hfp_timespecadd (struct timespec *t1, const struct timespec *t2)
250
254
{
251
255
  assert(t1 != NULL);
252
256
  assert(t2 != NULL);
253
257
 
254
258
  t1->tv_sec += t2->tv_sec;
255
 
  t1->tv_usec += t2->tv_usec;
 
259
  t1->tv_nsec += t2->tv_nsec;
256
260
 
257
 
  hfp_timevalfix(t1);
 
261
  hfp_timespecfix(t1);
258
262
}
259
263
 
260
264
void
261
 
hfp_timevalsub (struct timeval *t1, const struct timeval *t2)
 
265
hfp_timespecsub (struct timespec *t1, const struct timespec *t2)
262
266
{
263
267
  assert(t1 != NULL);
264
268
  assert(t2 != NULL);
265
269
 
266
270
  t1->tv_sec -= t2->tv_sec;
267
 
  t1->tv_usec -= t2->tv_usec;
 
271
  t1->tv_nsec -= t2->tv_nsec;
268
272
 
269
 
  hfp_timevalfix(t1);
 
273
  hfp_timespecfix(t1);
270
274
}