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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [tests/] [psxtests/] [include/] [pmacros.h] - Blame information for rev 1026

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

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

powered by: WebSVN 2.1.0

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