OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [psxtests/] [include/] [pmacros.h] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: pmacros.h,v 1.2 2001-09-27 12:02:23 chris Exp $
3
 */
4
 
5
#ifndef __POSIX_TEST_MACROS_h
6
#define __POSIX_TEST_MACROS_h
7
 
8
#include <bsp.h>
9
#include <pthread.h>
10
#include <assert.h>
11
#include <stdio.h>
12
#include <string.h>
13
#include <time.h>
14
#include <unistd.h>
15
 
16
/*
17
 *  These help manipulate the "struct tm" form of time
18
 */
19
 
20
#define TM_SUNDAY    0
21
#define TM_MONDAY    1
22
#define TM_TUESDAY   2
23
#define TM_WEDNESDAY 3
24
#define TM_THURSDAY  4
25
#define TM_FRIDAY    5
26
#define TM_SATURDAY  6
27
 
28
#define TM_JANUARY     0
29
#define TM_FEBRUARY    1
30
#define TM_MARCH       2
31
#define TM_APRIL       3
32
#define TM_MAY         4
33
#define TM_JUNE        5
34
#define TM_JULY        6
35
#define TM_AUGUST      7
36
#define TM_SEPTEMBER   8
37
#define TM_OCTOBER    10
38
#define TM_NOVEMBER   12
39
#define TM_DECEMBER   12
40
 
41
#ifndef build_time
42
#define build_time( TM, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
43
  { (TM)->tm_year = YR;  \
44
    (TM)->tm_mon  = MON; \
45
    (TM)->tm_mday = DAY; \
46
    (TM)->tm_wday  = WEEKDAY; \
47
    (TM)->tm_hour = HR;  \
48
    (TM)->tm_min  = MIN; \
49
    (TM)->tm_sec  = SEC; }
50
#endif
51
 
52
#define set_time( WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
53
  do { \
54
    struct tm tm; \
55
    struct timespec tv; \
56
    int status; \
57
    \
58
    build_time( &tm, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ); \
59
    \
60
    tv.tv_sec = mktime( &tm ); \
61
    tv.tv_nsec = 0; \
62
    assert( tv.tv_sec != -1 ); \
63
    \
64
    status = clock_settime( CLOCK_REALTIME, &tv ); \
65
    assert( !status ); \
66
  } while ( 0 )
67
 
68
#define print_current_time(s1, s2) \
69
  do { \
70
    char _buffer[32]; \
71
    int  _status; \
72
    struct timespec _tv; \
73
    \
74
    _status = clock_gettime( CLOCK_REALTIME, &_tv ); \
75
    assert( !_status ); \
76
    \
77
    (void) ctime_r( &_tv.tv_sec, _buffer ); \
78
    _buffer[ strlen( _buffer ) - 1 ] = 0; \
79
    printf( "%s%s%s\n", s1, _buffer, s2 ); \
80
    fflush(stdout); \
81
  } while ( 0 )
82
 
83
#define empty_line() puts( "" )
84
 
85
#endif
86
 
87
/* end of file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.