github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/third_party/gofrontend/libgo/runtime/go-now.c (about)

     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  
     5  #include <stddef.h>
     6  #include <stdint.h>
     7  #include <sys/time.h>
     8  
     9  #include "runtime.h"
    10  
    11  // Return current time.  This is the implementation of time.now().
    12  
    13  struct time_now_ret
    14  now()
    15  {
    16    struct timespec ts;
    17    struct time_now_ret ret;
    18  
    19    clock_gettime (CLOCK_REALTIME, &ts);
    20    ret.sec = ts.tv_sec;
    21    ret.nsec = ts.tv_nsec;
    22    return ret;
    23  }