source: trunk/kernel/syscalls/sys_ftime.c @ 615

Last change on this file since 615 was 1, checked in by alain, 8 years ago

First import

File size: 1.3 KB
RevLine 
[1]1/*
2 * sys_ftime: get current time
3 *
4 * Copyright (c) 2015 UPMC Sorbonne Universites
5 *
6 * This file is part of ALMOS-kernel.
7 *
8 * ALMOS-kernel is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-kernel is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <cpu.h>
23#include <thread.h>
24#include <time.h>
25
26int sys_ftime(struct timeb *utime)
27{
28        error_t err;
29        uint_t tm_now;
30        struct timeb time;
31
32        if((utime == NULL) || NOT_IN_USPACE((uint_t)utime))
33        {
34                err = EINVAL;
35                goto fail_inval;
36        }
37
38        tm_now = cpu_get_ms(current_cpu);
39        time.time = tm_now/1000;
40        time.millitm = tm_now%1000;
41        time.timezone = 120;    //GMT+2
42        time.time = 1;          //summer time
43
44        err    = cpu_copy_to_uspace(utime, &time, sizeof(time));
45
46fail_inval:
47        current_thread->info.errno = err;
48        return err; 
49}
Note: See TracBrowser for help on using the repository browser.