2007-04-02 Joel Sherrill <joel@OARcorp.com>

* Makefile.am, configure.ac: Convert from Classic API style TOD_Control
	as fundamental time structure to POSIX struct timespec. Add
	clock_get_uptime().
	* nsecs/.cvsignore, nsecs/Makefile.am, nsecs/init.c, nsecs/nsecs.doc,
	nsecs/nsecs.scn: New files.
This commit is contained in:
Joel Sherrill
2007-04-02 18:24:10 +00:00
parent 812da54688
commit 23a0105a78
8 changed files with 210 additions and 0 deletions
+8
View File
@@ -1,3 +1,11 @@
2007-04-02 Joel Sherrill <joel@OARcorp.com>
* Makefile.am, configure.ac: Convert from Classic API style TOD_Control
as fundamental time structure to POSIX struct timespec. Add
clock_get_uptime().
* nsecs/.cvsignore, nsecs/Makefile.am, nsecs/init.c, nsecs/nsecs.doc,
nsecs/nsecs.scn: New files.
2007-03-26 Joel Sherrill <joel@OARcorp.com>
* loopback/init.c: Add CVS Id.
+2
View File
@@ -13,6 +13,8 @@ endif
SUBDIRS += paranoia
SUBDIRS += nsecs
if CXXTESTS
SUBDIRS += iostream cdtest
endif
+1
View File
@@ -65,6 +65,7 @@ hello/Makefile
loopback/Makefile
minimum/Makefile
fileio/Makefile
nsecs/Makefile
paranoia/Makefile
ticker/Makefile
unlimited/Makefile
+2
View File
@@ -0,0 +1,2 @@
Makefile
Makefile.in
+22
View File
@@ -0,0 +1,22 @@
##
## $Id$
##
rtems_tests_PROGRAMS = nsecs.exe
nsecs_exe_SOURCES = init.c
dist_rtems_tests_DATA = nsecs.scn
dist_rtems_tests_DATA += nsecs.doc
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
LINK_OBJS = $(nsecs_exe_OBJECTS) $(nsecs_exe_LDADD)
LINK_LIBS = $(nsecs_exe_LDLIBS)
nsecs.exe$(EXEEXT): $(nsecs_exe_OBJECTS) $(nsecs_exe_DEPENDENCIES)
@rm -f nsecs.exe$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am
+127
View File
@@ -0,0 +1,127 @@
/*
* Nanoseconds accuracy timestamp test
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#define CONFIGURE_INIT
#include <rtems.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
char *my_ctime( time_t t )
{
static char b[32];
ctime_r(&t, b);
b[ strlen(b) - 1] = '\0';
return b;
}
void subtract_em(
struct timespec *start,
struct timespec *stop,
struct timespec *t
)
{
extern void _POSIX_Timespec_subtract(
const struct timespec *the_start,
const struct timespec *end,
struct timespec *result
);
t->tv_sec = 0;
t->tv_nsec = 0;
_POSIX_Timespec_subtract( start, stop, t );
}
volatile int i;
rtems_task Init(
rtems_task_argument argument
)
{
rtems_status_code status;
rtems_time_of_day time;
int index;
puts( "\n\n*** NANOSECOND CLOCK TEST ***" );
time.year = 2007;
time.month = 03;
time.day = 24;
time.hour = 11;
time.minute = 15;
time.second = 0;
time.ticks = 0;
status = rtems_clock_set( &time );
/*
* Iterate 10 times showing difference in TOD
*/
printf( "10 iterations of getting TOD\n" );
for (index=0 ; index <10 ; index++ ) {
struct timespec start, stop;
struct timespec diff;
clock_gettime( CLOCK_REALTIME, &start );
clock_gettime( CLOCK_REALTIME, &stop );
subtract_em( &start, &stop, &diff );
#if 0
printf( "%d:%d %d:%d ",
start.tv_sec, start.tv_nsec,
stop.tv_sec, stop.tv_nsec,
);
#else
printf( "Start: %s:%d\nStop : %s:%d",
my_ctime(start.tv_sec), start.tv_nsec,
my_ctime(stop.tv_sec), stop.tv_nsec
);
#endif
printf( " --> %d:%d\n", diff.tv_sec, diff.tv_nsec );
}
/*
* Iterate 10 times showing difference in Uptime
*/
printf( "\n10 iterations of getting Uptime\n" );
for (index=0 ; index <10 ; index++ ) {
struct timespec start, stop;
struct timespec diff;
rtems_clock_get_uptime( &start );
rtems_clock_get_uptime( &stop );
subtract_em( &start, &stop, &diff );
printf( "%d:%d %d:%d --> %d:%d\n",
start.tv_sec, start.tv_nsec,
stop.tv_sec, stop.tv_nsec,
diff.tv_sec, diff.tv_nsec
);
}
puts( "*** END OF NANOSECOND CLOCK TEST ***" );
exit(0);
}
#include <bsp.h> /* for device driver prototypes */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#include <rtems/confdefs.h>
+12
View File
@@ -0,0 +1,12 @@
#
# $Id$
#
# COPYRIGHT (c) 1989-1999.
# On-Line Applications Research Corporation (OAR).
#
# The license and distribution terms for this file may be
# found in the file LICENSE in this distribution or at
# http://www.rtems.com/license/LICENSE.
#
+36
View File
@@ -0,0 +1,36 @@
*** NANOSECOND CLOCK TEST ***
10 iterations of getting TOD
Start: Sat Mar 24 11:15:00 2007:540000
Stop : Sat Mar 24 11:15:00 2007:549000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:3974000
Stop : Sat Mar 24 11:15:00 2007:3983000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:7510000
Stop : Sat Mar 24 11:15:00 2007:7519000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:11054000
Stop : Sat Mar 24 11:15:00 2007:11063000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:14638000
Stop : Sat Mar 24 11:15:00 2007:14647000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:18301000
Stop : Sat Mar 24 11:15:00 2007:18310000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:21901000
Stop : Sat Mar 24 11:15:00 2007:21910000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:25526000
Stop : Sat Mar 24 11:15:00 2007:25535000 --> 0:9000
Start: Sat Mar 24 11:15:00 2007:29196000
Stop : Sat Mar 24 11:15:00 2007:29206000 --> 0:10000
Start: Sat Mar 24 11:15:00 2007:32826000
Stop : Sat Mar 24 11:15:00 2007:32835000 --> 0:9000
10 iterations of getting Uptime
0:38977000 0:38986000 --> 0:9000
0:40324000 0:40332000 --> 0:8000
0:41636000 0:41645000 --> 0:9000
0:42949000 0:42958000 --> 0:9000
0:44295000 0:44304000 --> 0:9000
0:45608000 0:45617000 --> 0:9000
0:46921000 0:46930000 --> 0:9000
0:48282000 0:48291000 --> 0:9000
0:49595000 0:49603000 --> 0:8000
0:50908000 0:50917000 --> 0:9000
*** END OF NANOSECOND CLOCK TEST ***