go-now.c 489 B

123456789101112131415161718192021222324
  1. // Copyright 2011 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. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <sys/time.h>
  7. #include "runtime.h"
  8. // Return current time. This is the implementation of time.now().
  9. struct time_now_ret
  10. now()
  11. {
  12. struct timeval tv;
  13. struct time_now_ret ret;
  14. gettimeofday (&tv, NULL);
  15. ret.sec = tv.tv_sec;
  16. ret.nsec = tv.tv_usec * 1000;
  17. return ret;
  18. }