source: mainline/uspace/lib/posix/time.c@ d3ce33fa

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d3ce33fa was a6d908c1, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Small changes in includes.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2011 Petr Koupy
3 * Copyright (c) 2011 Jiri Zarevucky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libposix
31 * @{
32 */
33/** @file
34 */
35
36#define LIBPOSIX_INTERNAL
37
38#include "internal/common.h"
39#include "time.h"
40
41#include "libc/malloc.h"
42#include "libc/task.h"
43#include "libc/stats.h"
44
45/**
46 *
47 * @param timep
48 * @return
49 */
50struct posix_tm *posix_localtime(const time_t *timep)
51{
52 // TODO
53 static struct posix_tm result = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
54 return &result;
55}
56
57/**
58 *
59 * @param tm
60 * @return
61 */
62char *posix_asctime(const struct posix_tm *tm)
63{
64 // TODO
65 static char result[] = "Sun Jan 01 00:00:00 1900\n";
66 return result;
67}
68
69/**
70 *
71 * @param timep
72 * @return
73 */
74char *posix_ctime(const time_t *timep)
75{
76 return posix_asctime(posix_localtime(timep));
77}
78
79/**
80 *
81 * @param s
82 * @param maxsize
83 * @param format
84 * @param tm
85 * @return
86 */
87size_t posix_strftime(char *s, size_t maxsize, const char *format, const struct posix_tm *tm)
88{
89 // TODO
90 if (maxsize >= 1) {
91 *s = '\0';
92 }
93 return 0;
94}
95
96/**
97 * Get CPU time used since the process invocation.
98 *
99 * @return Consumed CPU cycles by this process or -1 if not available.
100 */
101posix_clock_t posix_clock(void)
102{
103 posix_clock_t total_cycles = -1;
104 stats_task_t *task_stats = stats_get_task(task_get_id());
105 if (task_stats) {
106 total_cycles = (posix_clock_t) (task_stats->kcycles + task_stats->ucycles);
107 }
108 free(task_stats);
109 task_stats = 0;
110
111 return total_cycles;
112}
113
114/** @}
115 */
Note: See TracBrowser for help on using the repository browser.