metalsvm/include/metalsvm/time.h
Jacek Galowicz 5a4bd9a069 Fixed some documentation errors across the project.
Changed some stuff in the doxyfile and added a directory structure for
future manual pages.
2011-10-24 19:26:27 +02:00

84 lines
1.8 KiB
C

/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
/**
* @author Stefan Lankes
* @file include/metalsvm/time.h
* @brief Time related functions
*/
#ifndef __TIME_H__
#define __TIME_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef uint32_t clock_t;
struct tms {
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
#ifndef CLOCKS_PER_SEC
// newlib's default value
#define CLOCKS_PER_SEC 1000
#endif
/** @brief Determines the time in CLK_TCK's
*
* System call, which returns the value of time in CLK_TCK's
*/
int sys_times(struct tms*, clock_t* clock);
/** @brief Initialize Timer interrupts
*
* This procedure installs IRQ handlers for timer interrupts
*/
int timer_init(void);
/** @brief Initialized a timer
*
* @param ticks Amount of ticks to wait
* @return
* - 0 on success
*/
int timer_wait(unsigned int ticks);
/** @brief Returns the current number of ticks.
* @return Current number of ticks
*/
uint64_t get_clock_tick(void);
/** @brief sleep some seconds
*
* This function sleeps some seconds
*
* @param sec Amount of seconds to wait
*/
static inline void sleep(unsigned int sec) { timer_wait(sec*TIMER_FREQ); }
#ifdef __cplusplus
}
#endif
#endif