コード例 #1
0
int write_out_backing_fd(int ofd, int bfd) {
  char *mmap_buf;
  u_int16_t outlen;
  struct stat buf;

  if(fstat(bfd, &buf) == -1) {
    mtevL(nldeb, "external: fstat error: %s\n", strerror(errno));
    goto bail;
  }
  /* Our output length is limited to 64k (including a \0) */
  /* So, we'll limit the mapping of the file to 0xfffe */
  if(buf.st_size > 0xfffe) outlen = 0xfffe;
  else outlen = buf.st_size & 0xffff;
  /* If we have no length, we can skip all this nonsense */
  if(outlen == 0) goto bail;

  mmap_buf = mmap(NULL, outlen, PROT_READ, MAP_SHARED, bfd, 0);
  if(mmap_buf == (char *)-1) {
    mtevL(nldeb, "external: mmap error: %s\n", strerror(errno));
    goto bail;
  }
  outlen++; /* no null on the end, but we're reporting one */
  assert_write(ofd, &outlen, sizeof(outlen));
  outlen--; /* set it back to write and munmap */
  assert_write(ofd, mmap_buf, outlen);
  assert_write(ofd, "", 1);
  munmap(mmap_buf, outlen);
  return outlen+1;

 bail:
  outlen = 1;
  assert_write(ofd, &outlen, sizeof(outlen));
  assert_write(ofd, "", 1);
  return 1;
}
コード例 #2
0
ファイル: timer.test.c プロジェクト: antongulenko/TankOS
void test_timer_10_set_value() {
    t = newTimer(OCR, TimerResolution10);
    assert_write(10, 0, 1);
    assert_write(63, 0, 2);
    assert_write(64, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, 3000 >> 6, 5);
    assert_write(10000, 10000 >> 6, 6);
}
コード例 #3
0
ファイル: timer.test.c プロジェクト: antongulenko/TankOS
void test_timer_9_set_value() {
    t = newTimer(OCR, TimerResolution9);
    assert_write(10, 0, 1);
    assert_write(127, 0, 2);
    assert_write(128, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, 3000 >> 7, 5);
    assert_write(10000, 10000 >> 7, 6);
}
コード例 #4
0
static void finish_procs() {
  struct proc_state *ps;
  process_siglist();
  mtevL(noit_debug, "%d done procs to cleanup\n", done_procs.size);
  while((ps = mtev_skiplist_pop(&done_procs, NULL)) != NULL) {
    mtevL(noit_debug, "finished %lld/%d\n", (long long int)ps->check_no, ps->pid);
    if(ps->cancelled == 0) {
      assert_write(out_fd, &ps->check_no,
                   sizeof(ps->check_no));
      assert_write(out_fd, &ps->status,
                   sizeof(ps->status));
      write_out_backing_fd(out_fd, ps->stdout_fd);
      write_out_backing_fd(out_fd, ps->stderr_fd);
    }
    proc_state_free(ps);
  }
}
コード例 #5
0
ファイル: external.c プロジェクト: Icarus-xx/reconnoiter
static int external_enqueue(eventer_t e, int mask, void *closure,
                            struct timeval *now) {
  external_closure_t *ecl = (external_closure_t *)closure;
  struct check_info *ci = (struct check_info *)ecl->check->closure;
  external_data_t *data;
  int fd, i;

  if(mask == EVENTER_ASYNCH_CLEANUP) {
    e->mask = 0;
    return 0;
  }
  if(!(mask & EVENTER_ASYNCH_WORK)) return 0;
  data = noit_module_get_userdata(ecl->self);
  fd = data->pipe_n2e[1];
  assert_write(fd, &ci->check_no, sizeof(ci->check_no));
  assert_write(fd, &ci->argcnt, sizeof(ci->argcnt));
  assert_write(fd, ci->arglens, sizeof(*ci->arglens)*ci->argcnt);
  for(i=0; i<ci->argcnt; i++)
    assert_write(fd, ci->args[i], ci->arglens[i]);
  assert_write(fd, &ci->envcnt, sizeof(ci->envcnt));
  assert_write(fd, ci->envlens, sizeof(*ci->envlens)*ci->envcnt);
  for(i=0; i<ci->envcnt; i++)
    assert_write(fd, ci->envs[i], ci->envlens[i]);
  return 0;
}
コード例 #6
0
ファイル: timer.test.c プロジェクト: antongulenko/TankOS
void test_timer_8_set_value() {
    t = newTimer(OCR, TimerResolution8);
    assert_write(10, 0, 1);
    assert_write(255, 0, 2);
    assert_write(256, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, HIBYTE(3000), 5);
    assert_write(10000, HIBYTE(10000), 6);
}
コード例 #7
0
ファイル: timer.test.c プロジェクト: antongulenko/TankOS
void test_timer_16_set_value() {
    t = newTimer(OCR, TimerResolution16);
    assert_write(10, 10, 1);
    assert_write(0, 0, 2);
    assert_write(255, 255, 3);
    assert_write(256, 256, 4);
    assert_write(3000, 3000, 5);
    assert_write(10000, 10000, 6);
}
コード例 #8
0
ファイル: assert.c プロジェクト: ArmstrongJ/MiNTLib
void
__assert_fail (const char *assertion, const char *file, unsigned int line,
	       const char *function)
{
  char _numbuf[11];
  char* numbuf;
  
  _numbuf[10] = '\0';
  numbuf = _itoa_word (line, &_numbuf[10], 10, 0);
  
#define COLONSPACE ": "
#define COLON ":"
#define ASSERTION "Assertion `"
#define FAILED "' failed.\r\n"

  /* Print the message.  */
  if (strcmp (program_invocation_short_name, "unknown application") != 0) {
    assert_write (STDERR_FILENO, program_invocation_short_name,
             strlen (program_invocation_short_name));
    assert_write (STDERR_FILENO, COLONSPACE, sizeof COLONSPACE - 1);
  }
  
  assert_write (STDERR_FILENO, file, strlen (file));
  assert_write (STDERR_FILENO, COLON, sizeof COLON - 1);
  assert_write (STDERR_FILENO, numbuf, strlen (numbuf));
  assert_write (STDERR_FILENO, COLONSPACE, sizeof COLONSPACE - 1);
  if (function != NULL) {
    assert_write (STDERR_FILENO, function, strlen (function));
    assert_write (STDERR_FILENO, COLONSPACE, sizeof COLONSPACE - 1);
  }
  assert_write (STDERR_FILENO, ASSERTION, sizeof ASSERTION - 1);
  assert_write (STDERR_FILENO, assertion, strlen (assertion));
  assert_write (STDERR_FILENO, FAILED, sizeof FAILED - 1);
  
  abort ();
}