mirror of https://github.com/ceph/go-ceph
timespec: add a helper function to convert from Timespec to C
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
6900146fc4
commit
29ebb61850
|
@ -28,3 +28,12 @@ func CStructToTimespec(cts CTimespecPtr) Timespec {
|
|||
Nsec: int64(t.tv_nsec),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyToCStruct copies the time values from a Timespec to a previously
|
||||
// allocated C `struct timespec`. Due to restrictions on Cgo the C pointer
|
||||
// must be passed via the CTimespecPtr wrapper.
|
||||
func CopyToCStruct(ts Timespec, cts CTimespecPtr) {
|
||||
t := (*C.struct_timespec)(cts)
|
||||
t.tv_sec = C.time_t(ts.Sec)
|
||||
t.tv_nsec = C.long(ts.Nsec)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue