source: rtems/c/src/librtems++/src/rtemsTimer.cc @ 7a97f26

4.104.114.84.95
Last change on this file since 7a97f26 was 2936b425, checked in by Joel Sherrill <joel.sherrill@…>, on 01/23/98 at 17:45:05

Solaris port updates from Chris Johns

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2  ------------------------------------------------------------------------
3  $Id$
4  ------------------------------------------------------------------------
5
6  COPYRIGHT (c) 1997
7  Objective Design Systems Ltd Pty (ODS)
8  All rights reserved (R) Objective Design Systems Ltd Pty
9 
10  The license and distribution terms for this file may be found in the
11  file LICENSE in this distribution or at
12  http://www.OARcorp.com/rtems/license.html.
13
14  ------------------------------------------------------------------------
15
16  See header file.
17
18  ------------------------------------------------------------------------
19*/
20
21#include <string.h>
22#include <rtems++/rtemsTimer.h>
23
24/* ----
25    rtemsTimer
26*/
27
28rtemsTimer::rtemsTimer(const char* tname)
29  : name(0),
30    repeat(false),
31    id(0)
32{
33  strcpy(name_str, "    ");
34  create(tname);
35}
36
37rtemsTimer::rtemsTimer()
38  : name(0),
39    repeat(false),
40    id(0)
41{
42  strcpy(name_str, "    ");
43}
44
45rtemsTimer::~rtemsTimer()
46{
47  destroy();
48}
49
50void rtemsTimer::make_invalid()
51{
52  strcpy(name_str, "    ");
53  name = 0;
54  id = 0;
55  repeat = false;
56}
57const rtems_status_code rtemsTimer::create(const char* tname)
58{
59  if (id)
60    return set_status_code(RTEMS_ILLEGAL_ON_SELF);
61
62  strcpy(name_str, "    ");
63  for (int c = 0; (c < 4) && (tname[c] != '\0'); c++)
64    name_str[c] = tname[c];
65  name = rtems_build_name(name_str[0],
66                          name_str[1],
67                          name_str[2],
68                          name_str[3]);
69 
70  set_status_code(rtems_timer_create(name, &id));
71
72  if (unsuccessful())
73  {
74    make_invalid();
75  }
76 
77  return last_status_code();
78}
79
80const rtems_status_code rtemsTimer::destroy()
81{
82  if (id)
83  {
84    set_status_code(rtems_timer_delete(id));
85    make_invalid();
86  }
87  else
88    set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
89 
90  return last_status_code();
91}
92 
93void rtemsTimer::common_handler(rtems_id , void *user_data)
94{
95  rtemsTimer *timer = (rtemsTimer*) user_data;
96 
97  if (timer->repeat)
98    timer->reset();
99
100  timer->triggered();
101}
Note: See TracBrowser for help on using the repository browser.