xref: /haiku/src/system/libroot/posix/time/stime.c (revision 47a21c5c89fc9fd155a3929e5a8f6056b92a2053)
15af32e75SAxel Dörfler /*
25af32e75SAxel Dörfler ** Copyright 2004, Jérôme Duval. All rights reserved.
3*47a21c5cSAugustin Cavalier ** Distributed under the terms of the MIT License.
45af32e75SAxel Dörfler */
55af32e75SAxel Dörfler 
65af32e75SAxel Dörfler #include <time.h>
75af32e75SAxel Dörfler #include <errno.h>
85af32e75SAxel Dörfler #include "syscalls.h"
95af32e75SAxel Dörfler 
10ae901935SOliver Tappe #include <errno_private.h>
11ae901935SOliver Tappe 
125af32e75SAxel Dörfler 
135af32e75SAxel Dörfler int
stime(const time_t * tp)145af32e75SAxel Dörfler stime(const time_t *tp)
155af32e75SAxel Dörfler {
165af32e75SAxel Dörfler 	status_t status;
175af32e75SAxel Dörfler 
185af32e75SAxel Dörfler 	if (tp == NULL) {
19ae901935SOliver Tappe 		__set_errno(EINVAL);
205af32e75SAxel Dörfler 		return -1;
215af32e75SAxel Dörfler 	}
2224df6592SIngo Weinhold 
2324df6592SIngo Weinhold 	status = _kern_set_real_time_clock((bigtime_t)*tp * 1000000);
245af32e75SAxel Dörfler 	if (status < B_OK) {
25ae901935SOliver Tappe 		__set_errno(status);
265af32e75SAxel Dörfler 		return -1;
275af32e75SAxel Dörfler 	}
285af32e75SAxel Dörfler 	return 0;
295af32e75SAxel Dörfler }
305af32e75SAxel Dörfler 
31