1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH API
36 // FRSH API is free software; you can redistribute it and/or modify
37 // it under the terms of the GNU General Public License as published by
38 // the Free Software Foundation; either version 2, or (at your option)
41 // FRSH API is distributed in the hope that it will be useful, but
42 // WITHOUT ANY WARRANTY; without even the implied warranty of
43 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 // General Public License for more details.
46 // You should have received a copy of the GNU General Public License
47 // distributed with FRSH API; see file COPYING. If not, write to the
48 // Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
51 // As a special exception, if you include this header file into source
52 // files to be compiled, this header file does not by itself cause
53 // the resulting executable to be covered by the GNU General Public
54 // License. This exception does not however invalidate any other
55 // reasons why the executable file might be covered by the GNU General
57 // -----------------------------------------------------------------------
58 //frsh_spare_capacity_types.h
59 //==============================================
60 // ******** ******* ******** ** **
61 // **///// /**////** **////// /** /**
62 // ** /** /** /** /** /**
63 // ******* /******* /********* /**********
64 // **//// /**///** ////////** /**//////**
65 // ** /** //** /** /** /**
66 // ** /** //** ******** /** /**
67 // // // // //////// // //
69 // FRSH(FRescor ScHeduler), pronounced "fresh"
70 //==============================================
75 #include "frsh_core_types.h"
76 #include "frsh_core.h"
90 /***********************
91 * Relational operations
92 ***********************/
95 * frsh_abs_time_smaller()
97 * Check if an absolute time is smaller than another one.
99 static inline bool frsh_abs_time_smaller(frsh_abs_time_t t1, frsh_abs_time_t t2)
101 return fosa_abs_time_smaller(t1, t2);
105 * frsh_rel_time_smaller()
107 * Check if a relative interval is smaller than another one.
109 static inline bool frsh_rel_time_smaller(frsh_rel_time_t t1, frsh_rel_time_t t2)
111 return fosa_rel_time_smaller(t1, t2);
115 * frsh_abs_time_smaller_or_equal()
117 * Check if an absolute time is smaller than or equal to another one.
119 static inline bool frsh_abs_time_smaller_or_equal(frsh_abs_time_t t1, frsh_abs_time_t t2)
121 return fosa_abs_time_smaller_or_equal(t1, t2);
125 * frsh_rel_time_smaller_or_equal()
127 * Check if a relative interval is smaller than or equal to another one.
129 static inline bool frsh_rel_time_smaller_or_equal(frsh_rel_time_t t1, frsh_rel_time_t t2)
131 return fosa_rel_time_smaller_or_equal(t1, t2);
135 /***********************
136 * Arithmetic operations
137 ***********************/
140 * frsh_abs_time_incr()
142 * Add a relative interval to an absolute time.
144 static inline frsh_abs_time_t frsh_abs_time_incr(frsh_abs_time_t base, frsh_rel_time_t interval)
146 return fosa_abs_time_incr(base, interval);
150 * frsh_rel_time_add()
152 * Add a relative interval to another one.
154 static inline frsh_rel_time_t frsh_rel_time_add(frsh_rel_time_t t1, frsh_rel_time_t t2)
156 return fosa_rel_time_add(t1, t2);
162 * Subtract a relative interval from an absolute time.
164 static inline frsh_abs_time_t frsh_abs_time_decr(frsh_abs_time_t time, frsh_rel_time_t interval)
166 return fosa_abs_time_decr(time, interval);
170 * frsh_rel_time_decr()
172 * Subtract a relative interval from another one.
174 static inline frsh_rel_time_t frsh_rel_time_decr(frsh_rel_time_t total, frsh_rel_time_t part)
176 return fosa_rel_time_decr(total, part);
181 * frsh_abs_time_extract_interval()
183 * Subtract two absolute times to get a relative interval.
185 static inline frsh_rel_time_t frsh_abs_time_extract_interval(frsh_abs_time_t past, frsh_abs_time_t future)
187 return frsh_abs_time_extract_interval(past, future);
191 * frsh_rel_time_times_integer()
193 * Multiplies a relative time by an integer
195 static inline frsh_rel_time_t frsh_rel_time_times_integer(frsh_rel_time_t time, long multiplier)
197 return fosa_rel_time_times_integer(time, multiplier);
201 * frsh_rel_time_times_integer()
203 * Multiplies a relative time by an integer
205 static inline frsh_rel_time_t frsh_rel_time_divided_by_integer(frsh_rel_time_t time, long divider)
207 return fosa_rel_time_divided_by_integer(time, divider);
211 /************************************
212 * Conversion to-from natural formats
213 * Note: Overflows may occur
214 ************************************/
217 * frsh_msec_to_rel_time()
219 * Convert an integer value of milliseconds into a relative time interval.
221 static inline frsh_rel_time_t frsh_msec_to_rel_time(long msec)
223 return fosa_msec_to_rel_time(msec);
227 * frsh_rel_time_to_msec()
229 * Convert a relative interval into an integer number of milliseconds.
231 static inline long frsh_rel_time_to_msec(frsh_rel_time_t interval)
233 return fosa_rel_time_to_msec(interval);
237 * frsh_msec_to_abs_time()
239 * Convert an integer value of milliseconds into an absolute time instant
241 static inline frsh_abs_time_t frsh_msec_to_abs_time(long msec)
243 return fosa_msec_to_abs_time(msec);
247 * frsh_abs_time_to_msec()
249 * Convert an absolute instant into an integer number of milliseconds.
251 static inline long frsh_abs_time_to_msec(frsh_abs_time_t instant)
253 return fosa_abs_time_to_msec(instant);
257 * frsh_usec_to_rel_time()
259 * Convert an integer value of microseconds into an absolute instant.
261 static inline frsh_rel_time_t frsh_usec_to_rel_time(long usec)
263 return fosa_usec_to_rel_time(usec);
268 * frsh_rel_time_to_usec()
270 * Convert a relative interval into an integer number of microseconds.
272 static inline long frsh_rel_time_to_usec(frsh_rel_time_t interval)
274 return fosa_rel_time_to_usec(interval);
278 * frsh_usec_to_abs_time()
280 * Convert an integer value of microseconds into an absolute instant.
282 static inline frsh_abs_time_t frsh_usec_to_abs_time(long usec)
284 return fosa_usec_to_abs_time(usec);
289 * frsh_abs_time_to_usec()
291 * Convert a relative interval into an integer number of microseconds.
293 static inline long frsh_abs_time_to_usec(frsh_abs_time_t interval)
295 return fosa_abs_time_to_usec(interval);
298 /******************************************
299 * Conversion to-from POSIX timespec format
300 ******************************************/
303 * frsh_timespec_to_rel_time()
305 * Convert a POSIX timespec value into a relative time interval.
307 static inline frsh_rel_time_t frsh_timespec_to_rel_time(struct timespec interval)
309 return fosa_timespec_to_rel_time(interval);
313 * frsh_rel_time_to_timespec()
315 * Convert a relative interval into a POSIX timespec value.
317 static inline struct timespec frsh_rel_time_to_timespec(frsh_rel_time_t interval)
319 return fosa_rel_time_to_timespec(interval);
323 * frsh_timespec_to_abs_time()
325 * Convert a POSIX timespec value into an absolute time.
327 static inline frsh_abs_time_t frsh_timespec_to_abs_time(struct timespec time)
329 return fosa_timespec_to_abs_time(time);
333 * frsh_abs_time_to_timespec()
335 * Convert an absolute time into a POSIX timespec value.
337 static inline struct timespec frsh_abs_time_to_timespec(frsh_abs_time_t time)
339 return fosa_abs_time_to_timespec(time);
346 * Keep the thread busy executing for a given period of time.
348 static inline void frsh_eat(frsh_rel_time_t *cpu_time)
357 #endif /* !FOSA_TIME_H_ */