@@ -14,3 +14,151 @@ fn t2() -> libcc2rs::Timeval {
1414fn t3 ( ) -> libcc2rs:: Timespec {
1515 Default :: default ( )
1616}
17+
18+ fn f1 ( a0 : Ptr < :: libc:: time_t > ) -> :: libc:: time_t {
19+ let __out = a0;
20+ match nix:: time:: clock_gettime ( nix:: time:: ClockId :: CLOCK_REALTIME ) {
21+ Ok ( __ts) => {
22+ let __s = __ts. tv_sec ( ) ;
23+ if !__out. is_null ( ) {
24+ __out. write ( __s) ;
25+ }
26+ __s
27+ }
28+ Err ( __e) => {
29+ libcc2rs:: cpp2rust_errno ( ) . write ( __e as i32 ) ;
30+ -1
31+ }
32+ }
33+ }
34+
35+ fn f2 ( a0 : :: libc:: clockid_t , a1 : Ptr < Timespec > ) -> i32 {
36+ match nix:: time:: clock_gettime ( nix:: time:: ClockId :: from_raw ( a0) ) {
37+ Ok ( __ts) => {
38+ a1. with_mut ( |__t| {
39+ * __t. tv_sec . borrow_mut ( ) = __ts. tv_sec ( ) as i64 ;
40+ * __t. tv_nsec . borrow_mut ( ) = __ts. tv_nsec ( ) as i64 ;
41+ } ) ;
42+ 0
43+ }
44+ Err ( __e) => {
45+ libcc2rs:: cpp2rust_errno ( ) . write ( __e as i32 ) ;
46+ -1
47+ }
48+ }
49+ }
50+
51+ fn f4 ( a0 : Ptr < :: libc:: time_t > , a1 : Ptr < Tm > ) -> Ptr < Tm > {
52+ let __res = a1;
53+ match jiff:: Timestamp :: from_second ( a0. read ( ) ) {
54+ Ok ( __ts) => {
55+ let __dt = __ts. to_zoned ( jiff:: tz:: TimeZone :: UTC ) ;
56+ __res. with_mut ( |__tm| {
57+ * __tm. tm_sec . borrow_mut ( ) = __dt. second ( ) as i32 ;
58+ * __tm. tm_min . borrow_mut ( ) = __dt. minute ( ) as i32 ;
59+ * __tm. tm_hour . borrow_mut ( ) = __dt. hour ( ) as i32 ;
60+ * __tm. tm_mday . borrow_mut ( ) = __dt. day ( ) as i32 ;
61+ * __tm. tm_mon . borrow_mut ( ) = __dt. month ( ) as i32 - 1 ;
62+ * __tm. tm_year . borrow_mut ( ) = __dt. year ( ) as i32 - 1900 ;
63+ * __tm. tm_wday . borrow_mut ( ) = __dt. weekday ( ) . to_sunday_zero_offset ( ) as i32 ;
64+ * __tm. tm_yday . borrow_mut ( ) = __dt. day_of_year ( ) as i32 - 1 ;
65+ * __tm. tm_isdst . borrow_mut ( ) = 0 ;
66+ * __tm. tm_gmtoff . borrow_mut ( ) = 0 ;
67+ * __tm. tm_zone . borrow_mut ( ) = Ptr :: from_string_literal ( b"GMT" ) ;
68+ } ) ;
69+ __res
70+ }
71+ Err ( _) => {
72+ libcc2rs:: cpp2rust_errno ( ) . write ( :: libc:: EOVERFLOW ) ;
73+ Ptr :: null ( )
74+ }
75+ }
76+ }
77+
78+ fn f6 ( a0 : Ptr < u8 > , a1 : usize , a2 : Ptr < u8 > , a3 : Ptr < Tm > ) -> usize {
79+ let __dt = a3. with ( |__tm| {
80+ jiff:: civil:: DateTime :: new (
81+ ( * __tm. tm_year . borrow ( ) + 1900 ) as i16 ,
82+ ( * __tm. tm_mon . borrow ( ) + 1 ) as i8 ,
83+ * __tm. tm_mday . borrow ( ) as i8 ,
84+ * __tm. tm_hour . borrow ( ) as i8 ,
85+ * __tm. tm_min . borrow ( ) as i8 ,
86+ * __tm. tm_sec . borrow ( ) as i8 ,
87+ 0 ,
88+ )
89+ } ) ;
90+ let __text = match __dt {
91+ Ok ( __d) => {
92+ jiff:: fmt:: strtime:: format ( a2. to_rust_string ( ) . as_str ( ) , __d) . unwrap_or_default ( )
93+ }
94+ Err ( _) => String :: new ( ) ,
95+ } ;
96+ if __text. is_empty ( ) || __text. len ( ) + 1 > a1 {
97+ 0
98+ } else {
99+ let mut __dst = a0. clone ( ) ;
100+ for __b in __text. as_bytes ( ) {
101+ __dst. write ( * __b) ;
102+ __dst += 1 ;
103+ }
104+ __dst. write ( 0 ) ;
105+ __text. len ( )
106+ }
107+ }
108+
109+ fn f7 ( a0 : Ptr < u8 > , a1 : Ptr < Timeval > ) -> i32 {
110+ let __times = a1;
111+ let __at = __times. with ( |__tv| {
112+ nix:: sys:: time:: TimeVal :: new (
113+ * __tv. tv_sec . borrow ( ) as :: libc:: time_t ,
114+ * __tv. tv_usec . borrow ( ) as :: libc:: suseconds_t ,
115+ )
116+ } ) ;
117+ let __mt = __times. offset ( 1 ) . with ( |__tv| {
118+ nix:: sys:: time:: TimeVal :: new (
119+ * __tv. tv_sec . borrow ( ) as :: libc:: time_t ,
120+ * __tv. tv_usec . borrow ( ) as :: libc:: suseconds_t ,
121+ )
122+ } ) ;
123+ match nix:: sys:: stat:: utimes ( a0. to_rust_string ( ) . as_str ( ) , & __at, & __mt) {
124+ Ok ( ( ) ) => 0 ,
125+ Err ( __e) => {
126+ libcc2rs:: cpp2rust_errno ( ) . write ( __e as i32 ) ;
127+ -1
128+ }
129+ }
130+ }
131+
132+ #[ cfg( target_os = "linux" ) ]
133+ fn f8 ( a0 : Ptr < Timeval > , a1 : Ptr < :: libc:: timezone > ) -> i32 {
134+ match nix:: time:: clock_gettime ( nix:: time:: ClockId :: CLOCK_REALTIME ) {
135+ Ok ( __ts) => {
136+ a0. with_mut ( |__tv| {
137+ * __tv. tv_sec . borrow_mut ( ) = __ts. tv_sec ( ) as i64 ;
138+ * __tv. tv_usec . borrow_mut ( ) = ( __ts. tv_nsec ( ) / 1000 ) as i64 ;
139+ } ) ;
140+ 0
141+ }
142+ Err ( __e) => {
143+ libcc2rs:: cpp2rust_errno ( ) . write ( __e as i32 ) ;
144+ -1
145+ }
146+ }
147+ }
148+
149+ #[ cfg( target_os = "macos" ) ]
150+ fn f8 ( a0 : Ptr < Timeval > , a1 : AnyPtr ) -> i32 {
151+ match nix:: time:: clock_gettime ( nix:: time:: ClockId :: CLOCK_REALTIME ) {
152+ Ok ( __ts) => {
153+ a0. with_mut ( |__tv| {
154+ * __tv. tv_sec . borrow_mut ( ) = __ts. tv_sec ( ) as i64 ;
155+ * __tv. tv_usec . borrow_mut ( ) = ( __ts. tv_nsec ( ) / 1000 ) as i64 ;
156+ } ) ;
157+ 0
158+ }
159+ Err ( __e) => {
160+ libcc2rs:: cpp2rust_errno ( ) . write ( __e as i32 ) ;
161+ -1
162+ }
163+ }
164+ }
0 commit comments