2018-01-18 :-)
_ ららぽーと横浜の Japan PIE Week!! でパイを食べました
スイーツだけじゃなくて肉などのパイもありました。お昼にどうぞ。けっこうおなかいっぱいになりました。
_ [OpenBSD][golang]golang の Stat_t
Go 言語仕様よく知らないんだけど、C.hugahoge と書いておくとそのビルドシステムにおける型 hogehoge を参照するらしい。
https://github.com/golang/go/blob/master/src/syscall/types_openbsd.go#L119
type Stat_t C.struct_stat
なので、たとえば以下のように書いておくと
https://github.com/moby/moby/blob/master/pkg/system/stat_openbsd.go
func fromStatT(s *syscall.Stat_t) (*StatT, error) { return &StatT{size: s.Size, mode: uint32(s.Mode), uid: s.Uid, gid: s.Gid, rdev: uint64(s.Rdev), mtim: s.Mtim}, nil }
struct stat のメンバー変数 mtime は time_t であることを前提とした書き方だと思うんだけど、OpenBSD の stat(2) の man には timespec の型が書かれてるのであるが、
https://man.openbsd.org/stat.2
struct timespec st_atim; /* time of last access */ struct timespec st_mtim; /* time of last data modification */ struct timespec st_ctim; /* time of last file status change */
実装では ifdef してるのでコンパイル時に time_t が選択されてるということかな。
https://github.com/openbsd/src/blob/master/sys/sys/stat.h
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE struct timespec st_atim; /* time of last access */ struct timespec st_mtim; /* time of last data modification */ struct timespec st_ctim; /* time of last file status change */ #else time_t st_atime; /* time of last access */ long st_atimensec; /* nsec of last access */ time_t st_mtime; /* time of last data modification */ long st_mtimensec; /* nsec of last data modification */ time_t st_ctime; /* time of last file status change */ long st_ctimensec; /* nsec of last file status change */ #endif /* __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE */
[ツッコミを入れる]