PR debug/47620
[official-gcc.git] / libgo / runtime / go-nanotime.c
blob8cd42301054cac4bbcc2af1528eea5d496d04508
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Return time in nanoseconds. This is only used for computing runtime.
7 #include <sys/time.h>
9 #include "go-assert.h"
10 #include "runtime.h"
12 int64
13 runtime_nanotime (void)
15 int i;
16 struct timeval tv;
18 i = gettimeofday (&tv, NULL);
19 __go_assert (i == 0);
21 return (int64) tv.tv_sec * 1000000000 + (int64) tv.tv_usec * 1000;