static ssize_t store_control(struct device *d,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct modemctl *mc = dev_get_drvdata(d);

	if (!strncmp(buf, "on", 2)) {
		modem_on(mc);
		return count;
	}

	if (!strncmp(buf, "off", 3)) {
		modem_off(mc);
		return count;
	}

	if (!strncmp(buf, "reset", 5)) {
		modem_reset(mc);
		return count;
	}

	if (!strncmp(buf, "boot", 4)) {
		modem_boot(mc);
		return count;
	}

	if (!strncmp(buf, "renum", 6)) {
		enumeration(mc);
		return count;
	}
	if (!strncmp(buf, "phon", 4)) {
		gpio_set_value(mc->gpio_phone_on, 0);
		mdelay(1);
		gpio_set_value(mc->gpio_phone_on, 1);
		return count;
	}
	if (!strncmp(buf, "gsw=0", 5)) {
		gpio_set_value(mc->gpio_ipc_slave_wakeup, 0);
		return count;
	}
	if (!strncmp(buf, "gsw=1", 5)) {
		gpio_set_value(mc->gpio_ipc_slave_wakeup, 1);
		return count;
	}
	if (!strncmp(buf, "gat=0", 5)) {
		gpio_set_value(mc->gpio_active_state, 0);
		return count;
	}
	if (!strncmp(buf, "gat=1", 5)) {
		gpio_set_value(mc->gpio_active_state, 1);
		return count;
	}	
	return count;
}
void SPGEnumerator::enumeration() {
    std::map<int, std::set<int> > curAdjSet;
    constructAdjSet(curAdjSet);
    std::set<int> edge;
    int a, b;

    for (std::map<int, std::set<int> >::iterator it = curAdjSet.begin(); it != curAdjSet.end(); it++) {
        a = it->first;
        for (std::set<int>::iterator sit = (it->second).begin();
                sit != (it->second).end(); sit++) {
            b = *sit;
            edge.clear();
            edge.insert(a);
            edge.insert(b);

            g.addNewEdge(edge, e2n[edge]);
            if (graphVisited.find(g.hashEdgeSet()) == graphVisited.end()) {

                graphVisited.insert(g.hashEdgeSet());
#ifdef DEBUG
                std::cout << "SUB-GRAPH:"<< std::endl;
                g.printGraph();
#endif
                enumeration();
                if (!isSPG) {
                    spgi.initialization(g.realEdgeSet);
                    if (spgi.identify()) {
                        counting();
                        enumeration();
                    }
                } else {
                    counting();
                    enumeration();
                }
            }
            g.removeEdge(edge, e2n[edge]);
        }
    }

}
void SPGEnumerator::start() {
    std::map<int, std::set<int> > curAdjSet;
    for (std::set<int>::iterator it = edgeSet.begin(); it != edgeSet.end(); it++) {
        g.addNewEdge(n2e[*it], *it);
        graphVisited.insert(g.hashEdgeSet());
#ifdef DEBUG
        std::cout << "SUB-GRAPH:"<< std::endl;
        g.printGraph();
#endif
        counting();
        enumeration();
        g.removeEdge(n2e[*it], *it);
    }
}
Ejemplo n.º 4
0
int main(void)
{
    //[enumerate_example
    std::shared_ptr<boost::afio::async_file_io_dispatcher_base> dispatcher=
        boost::afio::make_async_file_io_dispatcher();
    
    // Schedule an opening of the root directory
    boost::afio::async_io_op rootdir(dispatcher->dir(boost::afio::async_path_op_req("/")));
    
    std::pair<std::vector<boost::afio::directory_entry>, bool> list;
    // This is used to reset the enumeration to the start
    bool restart=true;
    do
    {
        // Schedule an enumeration of an open directory handle
        // Note it returns a future to the results and an op ref 
        std::pair<
            boost::afio::future<std::pair<std::vector<boost::afio::directory_entry>, bool>>,
            boost::afio::async_io_op
        >  enumeration(
            dispatcher->enumerate(boost::afio::async_enumerate_op_req(
                /* This is the handle to enumerate */
                rootdir,
                /* This is the maximum entries to enumerate. Note
                the use of compatibility_maximum() which is the
                same value your libc uses. The problem with smaller
                enumerations is that the directory contents can change
                out from underneath you more frequently. */
                boost::afio::directory_entry::compatibility_maximum(),
                /* True if to reset enumeration */
                restart)));
        restart=false;
        
        // People using AFIO often forget that futures can be waited
        // on normally without needing to wait on the op handle
        list=enumeration.first.get();
        for(boost::afio::directory_entry &i : list.first)
        {
#ifdef WIN32
            std::wcout << i.name();
#else
            std::cout << i.name();
#endif
            std::cout << " type " << static_cast<int>(i.st_type()) << std::endl;
        }
    } while(list.second);
    //]
}
Ejemplo n.º 5
0
int main(void){
    int minFlipTimes = 0;
    int initState = 0;

    initState = read();
    if(initState == END_STATE_1 || initState == END_STATE_2){
        printf("%d",0);
        return 0;
    }

    minFlipTimes = enumeration(&initState);
    if(minFlipTimes == 17)
        printf("Impossible");
    else
        printf("%d", minFlipTimes);


    return 0;
}
Ejemplo n.º 6
0
bool usbh_enum_available(void)
{
	return !enumeration();
}
Ejemplo n.º 7
0
oop Profiler::copy_call_graph(oop method_pt, oop block_pt, oop access_pt,
                              oop prim_pt,   oop leaf_pt,  oop fold_pt,
                              oop unknown_oop,
                              smi cutoff_pct) {
  ResourceMark rm;

  if ( ProfilerIgnoreCallGraph  ||  !root->edges ) {
    // If the call graph is ignored the root contains the
    // accumulated timing and allocation information
    
    if (!this->root->edges)
      warning("Profiler::copy_call_graph: root edges are NULL, profiled program probably was too brief");
    
    oop node = leaf_pt->clone(CANFAIL);
    if (node == failedAllocationOop) return failedAllocationOop;
    leaf_node_info* leaf_pt_info = new leaf_node_info(leaf_pt);
    leaf_pt_info->fill(node, root);
    return node;
  }
  
  if ( PrintProfiling ) {
    // Old debugging code; checking for multiple roots -- dmu 2/04
    int c; float t;
    graph_totaller::compute_totals(root_edge, c, t);
    lprintf("in copy_call_graph: count = %d, time = %g\n", c, t);
    lprintf(" and root and rootedge are ");
    {
      for (call_graph_edge* e = root_edge;  e; e = e->next) {
        e->callee->print_node(), lprintf("\n");
          for (call_graph_edge* ee = e->callee->edges;  ee; ee = ee->next)
            lprintf("     "),  ee->callee->print_node(), lprintf("\n");
      }
    }
    lprintf("\n\n");
  }

  // Prepare for the enumeration by collecting all referred maps in the graph.
  MapTable graph_maps; 
  { 
    ResourceMark rm2;
    map_collector collector(this->root->edges, &graph_maps);
    _collector = &collector;
    switchToVMStack(cont_collect);
  }

  // Enumerate the maps
  {
    ResourceMark rm2;
    map_enumeration enumeration(&graph_maps);
    enumeration.enumerate();
  }
  
  graph_creator creator(this->root->edges, &graph_maps,
                        method_pt, block_pt, access_pt,
                        prim_pt,   leaf_pt,  fold_pt, unknown_oop, cutoff_pct);

  // Do the recursive graph traversal on the VM stack.
  _creator = &creator;
  switchToVMStack(cont_copy);

  graph_maps.deallocate();
  
  return creator.ran_out_of_memory() ? failedAllocationOop : creator.root();
}