go-nanotime.c 465 B

12345678910111213141516171819202122
  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.
  4. // Return current time in nanoseconds.
  5. #include <sys/time.h>
  6. #include "runtime.h"
  7. int64 runtime_nanotime (void)
  8. __attribute__ ((no_split_stack));
  9. int64
  10. runtime_nanotime (void)
  11. {
  12. struct timeval tv;
  13. gettimeofday (&tv, NULL);
  14. return (int64) tv.tv_sec * 1000000000 + (int64) tv.tv_usec * 1000;
  15. }