Exemple #1
0
static void interrupt_callback(rtems_id timer_id, void *arg)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;

  assert_time(T2);

  rtems_test_assert(
    obtain_try
      && !obtain_done
      && !release_happened
      && !delayed_happened
      && !interrupt_triggered_happened
      && !server_triggered_happened
  );

  sc = rtems_timer_server_fire_after(
    timer [INTERRUPT_TRIGGERED],
    T3 - T2,
    interrupt_triggered_callback,
    NULL
  );
  directive_failed_with_level(sc, "rtems_timer_server_fire_after", -1);

  interrupt_happened = true;
}
Exemple #2
0
static void obtain_callback(rtems_id timer_id, void *arg)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  char buf [1];
  size_t size = sizeof(buf);
  void *new_region_item = NULL;
  rtems_event_set events = 0;

  assert_time(T1);

  rtems_test_assert(
    !release_happened
      && !interrupt_happened
      && !delayed_happened
      && !interrupt_triggered_happened
      && !server_triggered_happened
  );

  obtain_try = true;

  switch (resource_type) {
    case SEMAPHORE:
      sc = rtems_semaphore_obtain(semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
      break;
    case MUTEX:
      sc = rtems_semaphore_obtain(mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
      break;
    case MESSAGE_QUEUE:
      sc = rtems_message_queue_receive(
        message_queue, buf, &size, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
      break;
    case REGION:
      sc = rtems_region_get_segment(
        region, 1, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &new_region_item);
      break;
    case EVENT:
      sc = rtems_event_receive(
        RTEMS_EVENT_0, RTEMS_EVENT_ALL | RTEMS_WAIT, RTEMS_NO_TIMEOUT, &events);
      break;
    case BARRIER:
      sc = rtems_barrier_wait(barrier, RTEMS_NO_TIMEOUT);
      break;
    case TASK_WAKE_AFTER:
      sc = rtems_task_wake_after(T4 - T1);
      break;
    default:
      rtems_test_assert(false);
      break;
  }
  directive_failed(sc, "obtain");

  obtain_done = true;
}
Exemple #3
0
static void server_triggered_callback(rtems_id timer_id, void *arg)
{
  assert_time(T5);

  rtems_test_assert(
    obtain_done
      && release_happened
      && interrupt_happened
      && delayed_happened
      && interrupt_triggered_happened
  );

  server_triggered_happened = true;
}
Exemple #4
0
static void interrupt_triggered_callback(rtems_id timer_id, void *arg)
{
  /*
   * This callback is scheduled to fire at T3, but is delayed due to the
   * blocked obtain callback.
   */
  assert_time(T4);

  rtems_test_assert(
    obtain_done
      && release_happened
      && interrupt_happened
      && !server_triggered_happened
  );

  interrupt_triggered_happened = true;
}
Exemple #5
0
static void release_callback(rtems_id timer_id, void *arg)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  char buf [1];
  size_t size = sizeof(buf);
  uint32_t released = 0;

  assert_time(T4);

  rtems_test_assert(
    obtain_try
      && interrupt_happened
      && !delayed_happened
      && !interrupt_triggered_happened
      && !server_triggered_happened
  );

  switch (resource_type) {
    case SEMAPHORE:
      sc = rtems_semaphore_release(semaphore);
      break;
    case MUTEX:
      sc = rtems_semaphore_release(mutex);
      break;
    case MESSAGE_QUEUE:
      sc = rtems_message_queue_send(message_queue, buf, size);
      break;
    case EVENT:
      sc = rtems_event_send(_Timer_server->thread->Object.id, RTEMS_EVENT_0);
      break;
    case BARRIER:
      sc = rtems_barrier_release(barrier, &released);
      break;
    case TASK_WAKE_AFTER:
      sc = RTEMS_SUCCESSFUL;
      break;
    default:
      rtems_test_assert(false);
      break;
  }
  directive_failed_with_level(sc, "release", 1);

  release_happened = true;
}
Exemple #6
0
static void delayed_callback(rtems_id timer_id, void *arg)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;

  assert_time(T4);

  rtems_test_assert(
    obtain_done
      && release_happened
      && interrupt_happened
      && !server_triggered_happened
  );

  sc = rtems_timer_server_fire_after(
    timer [SERVER_TRIGGERED],
    T5 - T4,
    server_triggered_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_server_fire_after");

  delayed_happened = true;
}
Exemple #7
0
static void test_case(enum resource_type rt)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;

  printf("test case: %s\n", resource_type_desc [rt]);

  resource_type = rt;

  test_reset();

  sc = rtems_timer_server_fire_after(
    timer [OBTAIN],
    T1 - T0,
    obtain_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_server_fire_after");

  sc = rtems_timer_fire_after(
    timer [INTERRUPT],
    T2 - T0,
    interrupt_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_fire_after");

  sc = rtems_timer_server_fire_after(
    timer [DELAYED],
    T3 - T0,
    delayed_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_server_fire_after");

  if (resource_type != REGION) {
    sc = rtems_timer_fire_after(
      timer [RELEASE],
      T4 - T0,
      release_callback,
      NULL
    );
    directive_failed(sc, "rtems_timer_fire_after");

    assert_time(T0);

    sc = rtems_task_wake_after(T6 - T0);
    directive_failed(sc, "task_wake_after");
  } else {
    sc = rtems_task_wake_after(T4 - T0);
    directive_failed(sc, "task_wake_after");

    assert_time(T4);

    rtems_test_assert(
      obtain_try
        && interrupt_happened
        && !delayed_happened
        && !interrupt_triggered_happened
        && !server_triggered_happened
    );

    sc = rtems_region_return_segment(region, region_item);
    directive_failed(sc, "rtems_region_return_segment");

    release_happened = true;

    sc = rtems_task_wake_after(T6 - T4);
    directive_failed(sc, "task_wake_after");
  }

  assert_time(T6);

  rtems_test_assert(
    obtain_done
      && interrupt_happened
      && release_happened
      && delayed_happened
      && interrupt_triggered_happened
      && server_triggered_happened
  );
}
time_t krb5int_gmt_mktime(struct tm *t)
{
  time_t accum;

#define assert_time(cnd) if(!(cnd)) return (time_t) -1

  /*
   * For 32-bit signed time_t centered on 1/1/1970, the range is:
   * time 0x80000000 -> Fri Dec 13 16:45:52 1901
   * time 0x7fffffff -> Mon Jan 18 22:14:07 2038
   *
   * So years 1901 and 2038 are allowable, but we can't encode all
   * dates in those years, and we're not doing overflow/underflow
   * checking for such cases.
   */
  assert_time(t->tm_year>=1);
  assert_time(t->tm_year<=138);

  assert_time(t->tm_mon>=0);
  assert_time(t->tm_mon<=11);
  assert_time(t->tm_mday>=1);
  assert_time(t->tm_mday<=31);
  assert_time(t->tm_hour>=0);
  assert_time(t->tm_hour<=23);
  assert_time(t->tm_min>=0);
  assert_time(t->tm_min<=59);
  assert_time(t->tm_sec>=0);
  assert_time(t->tm_sec<=62);

#undef assert_time


  accum = t->tm_year - 70;
  accum *= 365;			/* 365 days/normal year */

  /* add in leap day for all previous years */
  if (t->tm_year >= 70)
    accum += (t->tm_year - 69) / 4;
  else
    accum -= (72 - t->tm_year) / 4;
  /* add in leap day for this year */
  if(t->tm_mon >= 2)		/* march or later */
    if(hasleapday((t->tm_year + 1900))) accum += 1;

  accum += days_in_month[t->tm_mon];
  accum += t->tm_mday-1;	/* days of month are the only 1-based field */
  accum *= 24;			/* 24 hour/day */
  accum += t->tm_hour;
  accum *= 60;			/* 60 minute/hour */
  accum += t->tm_min;
  accum *= 60;			/* 60 seconds/minute */
  accum += t->tm_sec;

  return accum;
}