source: rtems/testsuites/psxtests/include/pmacros.h @ 9a4eca5

5
Last change on this file since 9a4eca5 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
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#if SIZEOF_OFF_T == 8
95#define PRIdoff_t PRIo64
96#elif SIZEOF_OFF_T == 4
97#define PRIdoff_t PRIo32
98#else
99#error "unsupported size of off_t"
100#endif
101
102#if SIZEOF_BLKSIZE_T == 8
103#define PRIxblksize_t PRIx64
104#elif SIZEOF_BLKSIZE_T == 4
105#define PRIxblksize_t PRIx32
106#else
107/* Warn and fall back to "long" */
108#warning "unsupported size of blksize_t"
109#define PRIxblksize_t "lx"
110#endif
111
112#if SIZEOF_BLKSIZE_T == 8
113#define PRIxblkcnt_t PRIx64
114#elif SIZEOF_BLKSIZE_T == 4
115#define PRIxblkcnt_t PRIx32
116#else
117/* Warn and fall back to "long" */
118#warning "unsupported size of blkcnt_t"
119#define PRIxblkcnt_t "lx"
120#endif
121
122#endif
123
124/* end of file */
Note: See TracBrowser for help on using the repository browser.