Beispiel #1
0
unsigned long long sb_timer_split_tmc(sb_timer_t *t)
{
  struct timespec    tmp;
  unsigned long long res;

  switch (t->state) {
    case TIMER_INITIALIZED:
      log_text(LOG_WARNING, "timer was never started");
      return 0;
    case TIMER_STOPPED:
      res = TIMESPEC_DIFF(t->time_end, t->time_split);
      t->time_split = t->time_end;
      if (res)
        return res;
      else
      {
        log_text(LOG_WARNING, "timer was already stopped");
        return 0;
      }
    case TIMER_RUNNING:
      break;
    default:
      log_text(LOG_FATAL, "uninitialized timer queried");
      abort();
  }

  SB_GETTIME(&tmp);
  t->elapsed = TIMESPEC_DIFF(tmp, t->time_start);
  res = TIMESPEC_DIFF(tmp, t->time_split);

  return res;
}
Beispiel #2
0
int main(int argc, char **argv) {
	int i;
	long long diff;
	int *res = NULL;
	int times = 10;
	int clean_avc = 0;
	struct timespec start, end;

	if (argc > 1)
		times = atoi(argv[1]);
	if (argc > 2)
		clean_avc = atoi(argv[2]);

	Hash hmap;
	HashInit(&hmap, HASH_STRING, 0);

	char *scon = "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023";
	char *tcon = "unconfined_u:object_r:sesqlite_public:s0";
	char *clas = "db_column";
	char *perm = "select";
	char *key = "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 unconfined_u:object_r:sesqlite_public:s0 db_column select";

	res = malloc(sizeof(int));
	*res = selinux_check_access(scon, tcon, clas, perm, NULL);
	HashInsert(&hmap, strdup(key), strlen(key), res);

	for (i = 0; i < times; ++i) {

		if ( clean_avc != 0 ){
			cleanavc();
			HashClear(&hmap);
		}

		GETTIME(start)

		res = HashFind(&hmap, key, strlen(key));
		if (res == NULL) {
			res = malloc(sizeof(int));
			*res = selinux_check_access(scon, tcon, clas, perm, NULL);
			HashInsert(&hmap, strdup(key), strlen(key), res);
		}

		GETTIME(end)
		diff = TIMESPEC_DIFF(start, end);
		printf("%lld\n", diff);
	}

	return 0;
}
Beispiel #3
0
static inline void sb_timer_update(sb_timer_t *t)
{
  SB_GETTIME(&t->time_end);
  t->elapsed = TIMESPEC_DIFF(t->time_end, t->time_start);
}