source: rtems/testsuites/psxtests/include/pmacros.h @ 700b9116

4.104.115
Last change on this file since 700b9116 was 700b9116, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/29/10 at 05:31:46

2010-05-29 Ralf Corsépius <ralf.corsepius@…>

  • configure.ac: Add AC_CHECK_SIZEOF(off_t).
  • include/pmacros.h: Add PRIdoff_t.
  • Property mode set to 100644
File size: 2.3 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.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#ifndef __POSIX_TEST_MACROS_h
13#define __POSIX_TEST_MACROS_h
14
15#if defined(__rtems__)
16#include <bsp.h>
17#endif
18#include <pthread.h>
19#include <stdio.h>
20#include <string.h>
21#include <time.h>
22#include <unistd.h>
23
24#include <tmacros.h>
25#include <buffer_test_io.h>
26
27/*
28 *  These help manipulate the "struct tm" form of time
29 */
30
31#define TM_SUNDAY    0
32#define TM_MONDAY    1
33#define TM_TUESDAY   2
34#define TM_WEDNESDAY 3
35#define TM_THURSDAY  4
36#define TM_FRIDAY    5
37#define TM_SATURDAY  6
38
39#define TM_JANUARY     0
40#define TM_FEBRUARY    1
41#define TM_MARCH       2
42#define TM_APRIL       3
43#define TM_MAY         4
44#define TM_JUNE        5
45#define TM_JULY        6
46#define TM_AUGUST      7
47#define TM_SEPTEMBER   8
48#define TM_OCTOBER     9
49#define TM_NOVEMBER   10
50#define TM_DECEMBER   11
51
52#ifndef tm_build_time
53#define tm_build_time( TM, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
54  { (TM)->tm_year = YR;  \
55    (TM)->tm_mon  = MON; \
56    (TM)->tm_mday = DAY; \
57    (TM)->tm_wday  = WEEKDAY; \
58    (TM)->tm_hour = HR;  \
59    (TM)->tm_min  = MIN; \
60    (TM)->tm_sec  = SEC; }
61#endif
62
63#define set_time( WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
64  do { \
65    struct tm tm; \
66    struct timespec tv; \
67    int status; \
68    \
69    tm_build_time( &tm, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ); \
70    \
71    tv.tv_sec = mktime( &tm ); \
72    tv.tv_nsec = 0; \
73    rtems_test_assert(  tv.tv_sec != -1 ); \
74    \
75    status = clock_settime( CLOCK_REALTIME, &tv ); \
76    rtems_test_assert(  !status ); \
77  } while ( 0 )
78
79#define print_current_time(s1, s2) \
80  do { \
81    char _time_buffer[32]; \
82    int  _status; \
83    struct timespec _tv; \
84    \
85    _status = clock_gettime( CLOCK_REALTIME, &_tv ); \
86    rtems_test_assert(  !_status ); \
87    \
88    (void) ctime_r( &_tv.tv_sec, _time_buffer ); \
89    _time_buffer[ strlen( _time_buffer ) - 1 ] = 0; \
90    printf( "%s%s%s\n", s1, _time_buffer, s2 ); \
91    fflush(stdout); \
92  } while ( 0 )
93
94#define empty_line() puts( "" )
95
96#if SIZEOF_OFF_T == 8
97#define PRIdoff_t PRIo64
98#elif SIZEOF_OFF_T == 4
99#define PRIdoff_t PRIo32
100#else
101#error "unsupported size of off_t"
102#endif
103
104#endif
105
106/* end of file */
Note: See TracBrowser for help on using the repository browser.