Example #1
0
void SymbolSlab::Builder::insert(const Symbol &S) {
  auto R = SymbolIndex.try_emplace(S.ID, Symbols.size());
  if (R.second) {
    Symbols.push_back(S);
    own(Symbols.back(), UniqueStrings);
  } else {
    auto &Copy = Symbols[R.first->second] = S;
    own(Copy, UniqueStrings);
  }
}
Example #2
0
        expressionist(
            const string &op,
            unique_ptr<const abstract_mapper_base> &lhs,
            unique_ptr<const abstract_mapper_base> &rhs
        ) :
#ifdef __clang__
            _op(op.c_str()),
#else
            _op(op),
#endif
            _lhs(own(lhs)),
            _rhs(own(rhs))
        {}
Example #3
0
void
table_base::specify_foreign_impl(
    unique_ptr<const abstract_mapper_base> foreign,
    const binomen &target_table,
    unique_ptr<const abstract_mapper_base> target_mapper
) {
    if (_is_open)  throw table_open_exception();

    _foreign_specs.emplace_back(
        &own(foreign),
        target_table,
        &own(target_mapper)
    );
}
Example #4
0
vector<const abstract_mapper_base *>
abstract_expressionist::own_all(vector<unique_ptr<const abstract_mapper_base>> &&v) {
    return transform(
        std::move(v),
        [this](unique_ptr<const abstract_mapper_base> &m)  { return &own(m); }
    );
}
Example #5
0
int main(int argc, char *argv[]) {


	if (argc < 2) {
		printf("Usage: %s <iface>\n", argv[0]);
		exit(1);
	}

	init_globals();

	initscr(); cbreak(); noecho();
	
	nonl();
	intrflush(stdscr, FALSE);
	keypad(stdscr, TRUE);

	curs_set(0);

	clear();
	refresh();

	signal(SIGINT, cleanup);
	signal(SIGTERM, cleanup);
	
	own(argv[1]);

	cleanup(0);
	exit(0);
}
Example #6
0
        expressionist(const string &op, unique_ptr<const abstract_mapper_base> &operand) :
#ifdef __clang__
            _op(op.c_str()),
#else
            _op(op),
#endif
            _operand(own(operand))
        {}
Example #7
0
int main()
{
	char *x = malloc(2000);

	own(&x);

	x = malloc(1000);

	free(x);
	return 0;
}
Example #8
0
void
diy::Collection::
clear()
{
  if (own())
    for (size_t i = 0; i < size(); ++i)
      destroy(i);
  elements_.clear();
  external_.clear();
  *in_memory_.access() = 0;
}
Example #9
0
SymbolSlab SymbolSlab::Builder::build() && {
  Symbols = {Symbols.begin(), Symbols.end()}; // Force shrink-to-fit.
  // Sort symbols so the slab can binary search over them.
  llvm::sort(Symbols,
             [](const Symbol &L, const Symbol &R) { return L.ID < R.ID; });
  // We may have unused strings from overwritten symbols. Build a new arena.
  BumpPtrAllocator NewArena;
  UniqueStringSaver Strings(NewArena);
  for (auto &S : Symbols)
    own(S, Strings);
  return SymbolSlab(std::move(NewArena), std::move(Symbols));
}
Example #10
0
void toBrowserSynonymWidget::changeParams(QString const& schema, QString const& object, QString const& type)
{
    int pos = object.indexOf(".");
    QString own("PUBLIC");
    QString name(object);

    if (pos >= 0)
    {
        own = object.mid(0, pos);
        name = object.mid(pos + 1);
    }

    toBrowserBaseWidget::changeParams(own, name);
}
Example #11
0
void
table_base::specify_index_impl(bool is_unique, vector<unique_ptr<const abstract_mapper_base>> &&mappers) {
    if (_is_open)  throw table_open_exception();

    const index_spec spec(
        transform(
            std::move(mappers),
            [this](unique_ptr<const abstract_mapper_base> &m)  { return &own(m); }
        ),
        is_unique
    );
    if (! get_database().supports_index(spec))  throw unsupported_exception();
    _index_specs.push_back(spec);
}
Example #12
0
int main(int argc, char *argv[])
{
	struct params p;
	char *iface = "wlan0";
	char *tap = "tap0";
	int ch;

	memset(&p, 0, sizeof(p));
	memcpy(p.mac, "\x00\x00\xde\xfa\xce\xd", 6);
	p.seq = getpid();
	memcpy(p.mcast, "\x01\x00\x5e\x00\x00", 5);

	while ((ch = getopt(argc, argv, "hb:t:")) != -1) {
		switch (ch) {
		case 't':
			tap = optarg;
			break;

		case 'b':
			if (str2mac(p.ap, optarg) == -1) {
				printf("Can't parse BSSID\n");
				exit(1);
			}
			break;

		case 'h':
		default:
			usage(argv[0]);
			break;
		}
	}

	if ((p.rx = open_rx(iface)) == -1)
		err(1, "open_rx()");
	if ((p.tx = open_tx(iface)) == -1)
		err(1, "open_tx()");

	if ((p.tap = open_tap(tap)) == -1)
		err(1, "open_tap()");
	if (set_iface_mac(tap, p.mac) == -1)
		err(1, "set_iface_mac()");

	p.state = S_START;
	while (1)
		own(&p);

	exit(0);
}
Example #13
0
std::string type_name(){
	using TR = typename std::remove_reference<T>;
	std::unique_ptr<char, void(*)(void*)> own(
	#ifndef __GNU__
		nullptr,
	#else
		abi::__cxa_demangle(typeid(TR).name(), nullptr, nullptr, nullptr),
	#endif
		std::free
	);
	std::string r = own ? own.get() : typeid(TR).name();
	if (std::is_const<TR>::value)r += " const";
	if (std::is_volatile<TR>::value)r += " volatile";
	if (std::is_lvalue_reference<TR>::value)r += "&";
	else if (std::is_rvalue_reference<TR>::value)r += "&&";
	return r;
}
Example #14
0
exprn_mapper_base::exprn_mapper_base(unique_ptr<const abstract_expressionist> e) :
    abstract_mapper_base(boost::none),
    column_mapper(boost::none),
    _expressionist(&own(e))
{}
Example #15
0
 expressionist(unique_ptr<const abstract_mapper_base> &delegate) :
     _delegate(own(delegate))
 {}
Example #16
0
int main(int argc, char *argv[])
{
	own();
	exit(0);
}
Example #17
0
int main(int argc, char * argv[])
{
  int policy; /* replacement policy */
  int current;  /* current page accessed */
  FILE * fp; /* The file containing the page accesses */
  FILE * rp; /* output file */
  char filename[30]={""};
  const char * extension[] ={".fifo", ".lru", "new"};
  float num_accesses = 0.0; /* total number of page accesses */
  float page_faults = 0.0;
  unsigned victim = 0;  /* page to be replaced */
  
  /* Getting and checking the input from the command line */
  if(argc != 4)
  {
    printf("usage: pager policy size filename\n");
    exit(1);
  }
  
  policy = atoi(argv[1]);
  mem_size = atoi(argv[2]);
  
  if( policy < 0 || policy > 2)
  { 
    printf("policy must be 0, 1, or 2\n");
    exit(1);
  }
  
  if(mem_size <= 0 )
  {
    printf("Size must be a positive integer.\n");
    exit(1);
  }
  
  /* Allocate and initialize the memory */
  mem = (int *)calloc(mem_size, sizeof(int));
  if(!mem)
  {
    printf("Cannot allocate mem\n");
    exit(1);
  }
  
  /* open the memory access file */
  fp = fopen(argv[3], "r");
  if(!fp)
  {
    printf("Cannot open file %s\n", argv[3]);
    exit(1);
  }
  
  /* Create the output file */
  strcat(filename, argv[3]);
  strcat(filename,extension[policy]);
  rp = fopen(filename, "w");
  if(!rp)
  {
    printf("Cannot create file %s\n", filename);
    exit(1);
  }
  
  /* The main loop of the program */
  fscanf(fp,"%d", &current);
  while(!feof(fp))
  {
    num_accesses++;
    if(mem_check(current) == PAGEMISS)
      page_faults++;
    
    switch(policy)
    {
      case 0: if( IsFull())
	      {
		victim = fifo();
		mem[victim] = current;
	      }
	      else
		insert(current);
	      break;
	     
      case 1: if( IsFull())
	      {
		victim = lru();
		mem[victim] = current;
	      }
	      else
		insert(current);
	      break;
	      
      case 2: if( IsFull())
	      {
		victim = own();
		mem[victim] = current;
	      }
	      else
		insert(current);
	      break;
	      
	      
      default: printf("Unknown policy ... Exiting\n");
	       exit(1);
      
    }/* end switch-case */
    
    print_mem(rp);
    fscanf(fp,"%d", &current);

  }/* end while */
  fprintf(rp,"percentage of page faults = %f", page_faults/num_accesses);
  
  /* wrap-up */
  fclose(fp);
  fclose(rp);
  free(mem);
  
  return 1;

}
Example #18
0
 expressionist(unique_ptr<const abstract_mapper_base> &arg, column_type_finder ctf) :
     _arg(own(arg)),
     _ctf(ctf)
 {}
Example #19
0
int main(int argc, char* argv[]) {
	int port = 6969;
	struct sockaddr_in s_in;
	int s;
	int rd;
	int len;
	char buf[64];
	struct timeval tv;
	int do_it = 0;
	fd_set rfds;
	char ip[17];

	if( argc > 1)
		pps = atoi(argv[1]);

	printf("Packets per second=%d\n", pps);	

	s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if( s < 0)
		err(1, "socket()");

	s_in.sin_family = PF_INET;
	s_in.sin_port = htons(port);
	s_in.sin_addr.s_addr = INADDR_ANY;

	if( bind(s, (struct sockaddr*)&s_in, sizeof(s_in)) < 0) {
		perror("bind()");
		exit(1);
	}

	while(1) {
		assert(do_it >= 0);
		len = sizeof(struct sockaddr_in);

		memset(&tv, 0, sizeof(tv));
		tv.tv_usec = 1000*10;
		FD_ZERO(&rfds);
		FD_SET(s, &rfds);
		rd = select(s + 1, &rfds, NULL ,NULL ,&tv);
		if (rd == -1) {
			perror("select()");
			exit(1);
		}
		if (rd == 1 && FD_ISSET(s, &rfds)) {
			rd = recvfrom(s, buf, 64, 0, (struct sockaddr*)&s_in, &len);

			if(rd < 0) {
				perror("read died");
				exit(1);
			}

			if(rd == 5 && memcmp(buf, "sorbo", 5) == 0) {
				sprintf(ip, "%s", inet_ntoa(s_in.sin_addr));
				printf("Got signal from %s\n", ip);
#ifdef INSANE
				do_it = 10;
#else				
				do_it = 2;
#endif				
			}	
		}		

		if (do_it) {	
			printf("Sending stuff to %s\n", ip);

			own(s, &s_in);
			do_it--;

			if(do_it == 0)
			printf("Stopping send\n");
		}
	}
}
Example #20
0
 expressionist(unique_ptr<const query_base> &query) :
     _query(own(query))
 {}