source: rtems/testsuites/psxtests/include/pmacros.h @ 438ca2f

5
Last change on this file since 438ca2f was 438ca2f, checked in by Joel Sherrill <joel@…>, on 04/22/17 at 19:15:22

rtems/inttypes.h: Add blksize_t and blkcnt_t

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009, 2017.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifndef __POSIX_TEST_MACROS_h
11#define __POSIX_TEST_MACROS_h
12
13#if defined(__rtems__)
14#include <bsp.h>
15#endif
16#include <pthread.h>
17#include <stdio.h>
18#include <string.h>
19#include <time.h>
20#include <unistd.h>
21
22#include <tmacros.h>
23#include <buffer_test_io.h>
24
25/*
26 *  These help manipulate the "struct tm" form of time
27 */
28
29#define TM_SUNDAY    0
30#define TM_MONDAY    1
31#define TM_TUESDAY   2
32#define TM_WEDNESDAY 3
33#define TM_THURSDAY  4
34#define TM_FRIDAY    5
35#define TM_SATURDAY  6
36
37#define TM_JANUARY     0
38#define TM_FEBRUARY    1
39#define TM_MARCH       2
40#define TM_APRIL       3
41#define TM_MAY         4
42#define TM_JUNE        5
43#define TM_JULY        6
44#define TM_AUGUST      7
45#define TM_SEPTEMBER   8
46#define TM_OCTOBER     9
47#define TM_NOVEMBER   10
48#define TM_DECEMBER   11
49
50#ifndef tm_build_time
51#define tm_build_time( TM, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
52  { (TM)->tm_year = YR;  \
53    (TM)->tm_mon  = MON; \
54    (TM)->tm_mday = DAY; \
55    (TM)->tm_wday  = WEEKDAY; \
56    (TM)->tm_hour = HR;  \
57    (TM)->tm_min  = MIN; \
58    (TM)->tm_sec  = SEC; }
59#endif
60
61#define set_time( WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
62  do { \
63    struct tm tm; \
64    struct timespec tv; \
65    int status; \
66    \
67    tm_build_time( &tm, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ); \
68    \
69    tv.tv_sec = mktime( &tm ); \
70    tv.tv_nsec = 0; \
71    rtems_test_assert(  tv.tv_sec != -1 ); \
72    \
73    status = clock_settime( CLOCK_REALTIME, &tv ); \
74    rtems_test_assert(  !status ); \
75  } while ( 0 )
76
77#define print_current_time(s1, s2) \
78  do { \
79    char _time_buffer[32]; \
80    int  _status; \
81    struct timespec _tv; \
82    \
83    _status = clock_gettime( CLOCK_REALTIME, &_tv ); \
84    rtems_test_assert(  !_status ); \
85    \
86    (void) ctime_r( &_tv.tv_sec, _time_buffer ); \
87    _time_buffer[ strlen( _time_buffer ) - 1 ] = 0; \
88    printf( "%s%s%s\n", s1, _time_buffer, s2 ); \
89    fflush(stdout); \
90  } while ( 0 )
91
92#define empty_line() puts( "" )
93
94#endif
95
96/* end of file */
Note: See TracBrowser for help on using the repository browser.