Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 946 → Rev 947

/shark/trunk/ports/first/fsf_include/tests/common/timespec_operations.h
0,0 → 1,107
/*----------------------------------------------------------------------------
*------------------------- M a R T E O S ------------------------
*----------------------------------------------------------------------------
* V1.0 Dec 2001
*
* 't i m e s p e c _ o p e r a t i o n s'
*
* H
*
* File 'timespec_operations.h' by MAR.
* (july 2002) transformed into macros by Jul.
* Some basic operations with the type 'timespec'.
*
* ----------------------------------------------------------------------
* Copyright (C) 2001 Universidad de Cantabria, SPAIN
*
* Authors: Mario Aldea Rivas aldeam@ctr.unican.es
* Michael Gonzalez Harbour mgh@ctr.unican.es
*
* MaRTE OS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* MaRTE OS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* distributed with MaRTE OS; see file COPYING. If not, write to the
* Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* As a special exception, if you link this unit with other files to
* produce an executable, this unit does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* This exception does not however invalidate any other reasons why the
* executable file might be covered by the GNU Public License.
*
*---------------------------------------------------------------------------*/
 
#ifndef _MARTE_MISC_TIMESPEC_OPERATIONS_H_
#define _MARTE_MISC_TIMESPEC_OPERATIONS_H_
 
#include <time.h>
 
#define smaller_timespec(t1, t2) \
( \
(t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec && \
(t1)->tv_nsec < (t2)->tv_nsec) \
)
 
#define smaller_or_equal_timespec(t1, t2) \
( \
(t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec && \
(t1)->tv_nsec <= (t2)->tv_nsec) \
)
 
#define incr_timespec(t1, t2) \
{ \
(t1)->tv_sec += (t2)->tv_sec; \
(t1)->tv_nsec += (t2)->tv_nsec; \
if ((t1)->tv_nsec >= 1000000000) { \
(t1)->tv_sec ++; \
(t1)->tv_nsec -= 1000000000; \
} \
}
 
#define decr_timespec(t1, t2) \
{ \
if ((t1)->tv_nsec < (t2)->tv_nsec) { \
(t1)->tv_sec -= (t2)->tv_sec + 1; \
(t1)->tv_nsec = (t1)->tv_nsec + 1000000000 - (t2)->tv_nsec; \
} else { \
(t1)->tv_sec -= (t2)->tv_sec; \
(t1)->tv_nsec -= (t2)->tv_nsec; \
} \
}
 
 
#define add_timespec( sum , t1 , t2 ) \
{ \
(sum)->tv_sec = (t1)->tv_sec + (t2)->tv_sec; \
(sum)->tv_nsec = (t1)->tv_nsec + (t2)->tv_nsec; \
if ((sum)->tv_nsec >= 1000000000) { \
(sum)->tv_sec ++; \
(sum)->tv_nsec -= 1000000000; \
} \
}
 
#define float_to_timespec( f1 , t1 ) \
( \
(t1)->tv_sec = (int)(f1), \
(t1)->tv_nsec = (int)(((f1)-(float)((t1)->tv_sec))*1000000000.0), \
(t1) \
)
 
#define float_to_timespec_value(f1, t1) \
( \
(t1).tv_sec = (int)(f1), \
(t1).tv_nsec = (int)(((f1)-(float)((t1).tv_sec))*1000000000.0), \
(t1) \
)
 
#endif /* _MARTE_MISC_TIMESPEC_OPERATIONS_H_ */
 
/shark/trunk/ports/first/fsf_include/tests/common/fsf_os_compatibility.h
0,0 → 1,67
// Header file that allows a general testing code to be used for calling
// the FSF primitives in both platforms: MaRTE_OS and SHARK
 
#ifndef _FSF_OS_COMPATIBILITY_H_
#define _FSF_OS_COMPATIBILITY_H_
#define SHARK_FSF
/////////////////////////////SHARK SECTION /////////////////////////////
#ifdef SHARK_FSF
 
#define INITIALIZATION_CODE \
{ \
fsf_init(); \
calibrate_cycle(); \
}
 
#define printf cprintf
/*
double
t2d(struct timespec time)
{
return time.tv_nsec*0.000000001 + (double)time.tv_sec;
}
*/
#define t2d( ts ) ((ts).tv_nsec*0.000000001 + (double)((ts).tv_sec))
 
#define ERROR(nn, ss) { if(errno==0) errno=nn ; kern_printf(ss); exit(nn);}
 
#define STANDARD_CONSOLE_INIT { }
#define SERIAL_CONSOLE_INIT { }
#endif /* SHARK_FSF */
//////////////////////////END OF SHARK SECTION /////////////////////////
 
 
/////////////////////////////MARTE SECTION /////////////////////////////
#ifdef MARTE_FSF
 
#include <misc/serial_console.h>
#include <misc/load.h>
 
//#include <debug_marte.h>
#include "fsf_contract.h"
#include "fsf_types.h"
 
 
#define INITIALIZATION_CODE \
{ \
SERIAL_CONSOLE_INIT; /*marte1.26i+ */\
/*init_serial_communication_with_gdb(SERIAL_PORT_1); */\
/*printf("max_prio = %d\n", sched_get_priority_max(SCHED_FIFO));*/\
/*printf("min_prio = %d\n", sched_get_priority_min(SCHED_FIFO));*/\
\
adjust(); \
/*set_break_point_here; */\
}
 
#define ERROR(nn, ss) {if(errno==0) errno=(nn); perror(ss); exit (nn);}
 
int
fsf_priority_map (unsigned long plevel)
{
return plevel;
}
 
#endif /* MARTE_FSF */
//////////////////////////END OF MARTE SECTION /////////////////////////
 
#endif /* _FSF_OS_COMPATIBILITY_H_ */