예제 #1
0
static void recheck_sessions(void)
{
	GHashTableIter iter;
	gpointer value, key;
	struct policy_group *group = NULL;
	GSList *list;

	g_hash_table_iter_init(&iter, session_hash);
	while (g_hash_table_iter_next(&iter, &key, &value)) {
		struct policy_config *policy = value;

		if (policy->group)
			continue;

		group = g_hash_table_lookup(selinux_hash, policy->selinux);
		if (group) {
			policy->config->id_type = CONNMAN_SESSION_ID_TYPE_LSM;
			g_free(policy->config->id);
			policy->config->id = g_strdup(policy->selinux_context);
			update_session(policy);
			continue;
		}

		group = g_hash_table_lookup(uid_hash, policy->uid);
		if (group) {
			set_policy(policy, group);

			policy->config->id_type = CONNMAN_SESSION_ID_TYPE_UID;
			g_free(policy->config->id);
			policy->config->id = g_strdup(policy->uid);
			update_session(policy);
			continue;
		}

		for (list = policy->gids; list; list = list->next) {
			char *gid = list->data;
			group = g_hash_table_lookup(gid_hash, gid);
			if (group) {
				set_policy(policy, group);

				policy->config->id_type = CONNMAN_SESSION_ID_TYPE_GID;
				g_free(policy->config->id);
				policy->config->id = g_strdup(gid);
				update_session(policy);
			}
		}
	}
}
예제 #2
0
ModuleWindow::ModuleWindow(Module* module, MainWindow* parent, 
                               Manager* manager)
{
    m_pModule = module;
    m_pParent = parent;
    m_pManager = manager;

    /* Create a new scrolled window, with scrollbars only if needed */
    set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    add(m_TreeView);

    /* create tree store */
    m_refTreeModel = Gtk::TreeStore::create(m_Columns);
    m_TreeView.set_model(m_refTreeModel);

    //Add the Model’s column to the View’s columns: 
    Gtk::CellRendererText* cellText = Gtk::manage(new Gtk::CellRendererText());
    Gtk::CellRendererPixbuf* cellPix = Gtk::manage(new Gtk::CellRendererPixbuf()); 
    Gtk::TreeViewColumn* col = Gtk::manage(new Gtk::TreeViewColumn("Item"));
    col->pack_start(*cellPix, false);
    col->pack_start(*cellText, true);
    col->add_attribute(*cellText, "text", 1);
    col->add_attribute(*cellPix, "pixbuf", 0);
    m_TreeView.append_column(*col);
    m_TreeView.get_column(0)->set_resizable(true);

    m_TreeView.append_column("Value", m_Columns.m_col_value);
    m_TreeView.get_column(1)->set_resizable(true);
    
    updateWidget();
    show_all_children();
}
예제 #3
0
/* cache_sim_init */
cache_handle_t* cache_sim_init(const unsigned int total_size,
                               const unsigned int line_size, const unsigned int associativity,
                               const char *policy) {
    /* safety checks */
    if ((0 >= total_size) || (0 >= line_size) || (0 >= associativity)) {
        return NULL;
    }

    /* variables declaration and initialization */
    cache_handle_t *cache = NULL;

    printf("--------------------------------\n");

    /* create the cache */
    if (NULL == (cache = cache_create(total_size, line_size, associativity))) {
        return NULL;
    }

    /* set the cache replacement policy (or algorithm) */
    if (CACHE_SIM_SUCCESS != (set_policy(cache, policy))) {
        cache_destroy(cache);
        return NULL;
    }

    printf(" Cache initialized successfully \n");
    printf("--------------------------------\n");

    return cache;
}
예제 #4
0
CIconView::CIconView () :
	ThreadLoadThumbs()
	{
	// connect to the cross-thread signal which tells us to fetch a new thumbnail
	ThreadLoadThumbs.signal_new_thumb_ready_.connect( sigc::mem_fun( *this, &CIconView::on_new_thumb_ready ) );
	//ThreadLoadThumbs.signal_terminating_.connect( sigc::mem_fun( *this, &CIconView::on_terminating ) );
	//ThreadLoadThumbs.signal_terminated_.connect( sigc::mem_fun( *this, &CIconView::on_terminated ) );
	
	// when the iconview has loaded completely, select the current image and set the bool
	ThreadLoadThumbs.signal_done_.connect( sigc::mem_fun( *this, &CIconView::on_done ) );
	
	add( ThumbsIconView );
	set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
	
	// set up the treemodel for the iconview and connect the view to the model
	refImageList = Gtk::ListStore::create( ImageListColumns );
	ThumbsIconView.set_model(refImageList);
	ThumbsIconView.set_text_column( ImageListColumns.basenames_column );
	ThumbsIconView.set_pixbuf_column( ImageListColumns.thumbnails_column );
	ThumbsIconView.set_selection_mode(Gtk::SELECTION_MULTIPLE);	
	
	
	listTargets.push_back( Gtk::TargetEntry("text/uri-list") );
  	listTargets.push_back( Gtk::TargetEntry("STRING") );	
	ThumbsIconView.enable_model_drag_source(listTargets);
	
	ThumbsIconView.signal_drag_data_get().connect( sigc::mem_fun( *this, &CIconView::on_drag_data_get ));
	
	terminating = false;
	loaded = false;
	}
/*
 *******************************************************************************************************
 * Wrapper function to perform an aerospike_key_remove within the C client.
 *
 * @param as_object_p           The C client's aerospike object.
 * @param as_key_p              The C client's as_key that identifies the record.
 * @param error_p               The as_error to be populated by the function
 *                              with the encountered error if any.
 * @param options_p             The user's optional policy options to be used if set, else defaults.
 *
 *******************************************************************************************************
 */
extern as_status 
aerospike_record_operations_remove(aerospike* as_object_p,
                                   as_key* as_key_p,
                                   as_error *error_p,
                                   zval* options_p)
{
    as_status                   status = AEROSPIKE_OK;
    as_policy_remove            remove_policy;

    if ( (!as_key_p) || (!error_p) ||
         (!as_object_p)) {
        status = AEROSPIKE_ERR;
        goto exit;
    }

    set_policy(NULL, NULL, NULL, &remove_policy, NULL, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (status = (error_p->code))) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    if (AEROSPIKE_OK != (status = aerospike_key_remove(as_object_p, error_p,
                    &remove_policy, as_key_p))) {
        goto exit;
    }
exit: 
    return(status);
}
예제 #6
0
/*
 ******************************************************************************************************
 Get the code of registered UDF module.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param module_p                  The name of the UDF module to get from the
 *                                  server.
 * @param module_len                Length of UDF module name.
 * @param udf_code_p                Code of the UDF to be populated by this
 *                                  function.
 * @param language                  The Aerospike::UDF_TYPE_* constant.
 * @param options_p                 The optional policy.
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_get_registered_udf_module_code(Aerospike_object* aerospike_obj_p,
        as_error* error_p, char* module_p, zval* udf_code_p,
        long language, zval* options_p)
{
    uint32_t                init_udf_file = 0;
    as_udf_file             udf_file;
    as_policy_info          info_policy;
    TSRMLS_FETCH_FROM_CTX(aerospike_obj_p->ts);

    set_policy(&aerospike_obj_p->as_ref_p->as_p->config, NULL, NULL,
            NULL, NULL, &info_policy, NULL, NULL, NULL, options_p,
            error_p TSRMLS_CC);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    as_udf_file_init(&udf_file);
    init_udf_file = 1;
    
    if (AEROSPIKE_OK != aerospike_udf_get(aerospike_obj_p->as_ref_p->as_p,
                error_p, &info_policy, module_p, language, &udf_file)) {
        DEBUG_PHP_EXT_ERROR("%s", error_p->message);
        goto exit;
    }

    ZVAL_STRINGL(udf_code_p, (char*) udf_file.content.bytes, udf_file.content.size, 1);
exit:
    if (init_udf_file) {
        as_udf_file_destroy(&udf_file);
    }
    return error_p->code;
}
예제 #7
0
static void finish_create(struct policy_config *policy,
				connman_session_config_func_t cb,
				void *user_data)
{
	struct policy_group *group = NULL;
	GSList *list;

	if (policy->selinux)
		group = g_hash_table_lookup(selinux_hash, policy->selinux);

	if (group) {
		set_policy(policy, group);

		policy->config->id_type = CONNMAN_SESSION_ID_TYPE_LSM;
		policy->config->id = g_strdup(policy->selinux_context);
		goto done;
	}

	if (policy->uid)
		group = g_hash_table_lookup(uid_hash, policy->uid);

	if (group) {
		set_policy(policy, group);

		policy->config->id_type = CONNMAN_SESSION_ID_TYPE_UID;
		policy->config->id = g_strdup(policy->uid);
		goto done;
	}

	for (list = policy->gids; list; list = list->next) {
		char *gid = list->data;

		group = g_hash_table_lookup(gid_hash, gid);
		if (!group)
			continue;

		set_policy(policy, group);

		policy->config->id_type = CONNMAN_SESSION_ID_TYPE_GID;
		policy->config->id = g_strdup(gid);
		break;
	}
done:
	g_hash_table_replace(session_hash, policy->session, policy);

	(*cb)(policy->session, policy->config, user_data, 0);
}
MessageText::MessageText()
{
  set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);

  add(m_TextView);
  insert_text();

  show_all_children();
}
 MachineListScrolledWindow::MachineListScrolledWindow(Gtk::Window &parent)
   : mpMachineListViewWithPopup(Gtk::manage(new MachineListViewWithPopup(parent))),
     m_width(0),
     m_height(0)
 {
   set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
   add(*mpMachineListViewWithPopup);
   
   signal_size_allocate().connect(sigc::mem_fun(*this, &MachineListScrolledWindow::OnSizeAllocate));
 }
예제 #10
0
/*
 ******************************************************************************************************
 Applies a UDF to a record at the Aerospike DB.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param as_key_p                  The C client's as_key that identifies the
 *                                  record on which UDF will be applied.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param module_p                  The name of the UDF module registered
 *                                  against the Aerospike DB.
 * @param function_p                The name of the function to be applied to
 *                                  the record.
 * @param args_pp                   An array of arguments for the UDF.
 * @param return_value_p            It will contain result value of calling the
 *                                  UDF.
 * @param options_p                 The optional policy.
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_udf_apply(Aerospike_object* aerospike_obj_p,
        as_key* as_key_p, as_error* error_p, char* module_p, char* function_p,
        zval** args_pp, zval* return_value_p, zval* options_p)
{
    as_arraylist                args_list;
    as_arraylist*               args_list_p = NULL;
    as_static_pool              udf_pool = {0};
    as_val*                     udf_result_p = NULL;
    foreach_callback_udata      udf_result_callback_udata;
    uint32_t                    serializer_policy = -1;
    as_policy_write             write_policy;

    set_policy(NULL, &write_policy, NULL, NULL, NULL, &serializer_policy,
            options_p, error_p);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    if ((*args_pp)) {
        as_arraylist_inita(&args_list,
                zend_hash_num_elements(Z_ARRVAL_PP(args_pp)));
        args_list_p = &args_list;
        AS_LIST_PUT(NULL, args_pp, args_list_p, &udf_pool, serializer_policy, error_p);
    }

    if (AEROSPIKE_OK != (aerospike_key_apply(aerospike_obj_p->as_ref_p->as_p,
                    error_p, &write_policy, as_key_p, module_p, function_p,
                    args_list_p, &udf_result_p))) {
        DEBUG_PHP_EXT_DEBUG(error_p->message);
        goto exit;
    }

    if (return_value_p) {
        udf_result_callback_udata.udata_p = return_value_p;
        udf_result_callback_udata.error_p = error_p;
        AS_DEFAULT_GET(NULL, udf_result_p, &udf_result_callback_udata);
    }
     
exit:
    if (udf_result_p) {
        as_val_destroy(udf_result_p);
    }
    
    if (args_list_p) {
        as_arraylist_destroy(args_list_p);
    }

    /* clean up the as_* objects that were initialised */
    aerospike_helper_free_static_pool(&udf_pool);

    return error_p->code;
}
예제 #11
0
파일: 5-1.c 프로젝트: 1587/ltp
int main(void)
{
	int rc;

	rc = set_policy("SCHED_FIFO", SCHED_FIFO);
	if (rc)
		goto done;

	rc = set_policy("SCHED_RR", SCHED_RR);
	if (rc)
		goto done;

	rc = set_policy("SCHED_OTHER", SCHED_OTHER);
	if (rc)
		goto done;

	printf("Test PASSED\n");

done:
	return rc;
}
예제 #12
0
TilesetImage::TilesetImage()
  : ScrolledWindow()
{
  // Always show the scrollbars to prevet changing the size of
  // the draw area on larger images
  set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);

  create_layout();
  setup_event_handlers();

  show_all_children();
}
예제 #13
0
/*
 ******************************************************************************************************
 Lists the UDF modules registered with the server.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param array_of_modules_p        An array of registered UDF modules
 *                                  against the Aerospike DB to be populated by
 *                                  this function.
 * @param language                  Optionally filters a subset of modules
 *                                  matching the given type.
 * @options_p                       The optional parameters to the
 *                                  Aerospike::listRegistered().
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_list_registered_udf_modules(Aerospike_object* aerospike_obj_p,
        as_error* error_p, zval* array_of_modules_p, long language,
        zval* options_p)
{
    as_udf_files            udf_files;
    uint32_t                init_udf_files = 0; 
    uint32_t                i=0;
    as_policy_info          info_policy;

    if ((language != -1) && ((language & AS_UDF_TYPE) != AS_UDF_TYPE)) {
            PHP_EXT_SET_AS_ERR(error_p, AEROSPIKE_ERR_PARAM,
                    "Invalid Value for language");
            DEBUG_PHP_EXT_ERROR("Invalid value for language");
            goto exit;
    }

    set_policy(NULL, NULL, NULL, NULL, &info_policy, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    as_udf_files_init(&udf_files, 0);
    init_udf_files = 1;
    if (AEROSPIKE_OK != aerospike_udf_list(aerospike_obj_p->as_ref_p->as_p,
                error_p, &info_policy, &udf_files)) {
        DEBUG_PHP_EXT_ERROR(error_p->message);
        goto exit;
    }

    for (i = 0; i < udf_files.size; i++) {
        if ((language != -1) && ((udf_files.entries[i].type) != 
                    (language - AS_UDF_TYPE))) {
                continue;
        }
        zval* module_p = NULL;
        MAKE_STD_ZVAL(module_p);
        array_init(module_p);
        add_assoc_stringl(module_p, UDF_MODULE_NAME, udf_files.entries[i].name,
                strlen(udf_files.entries[i].name), 1);
        add_assoc_long(module_p, UDF_MODULE_TYPE,
                (udf_files.entries[i].type + AS_UDF_TYPE));
        add_next_index_zval(array_of_modules_p, module_p);
    }

exit:
    if (init_udf_files) {
        as_udf_files_destroy(&udf_files);
    }
    return error_p->code;
}
예제 #14
0
AboutDialog::AboutDialog () : OK("OK"), canvas() {
  set_title ("About EOGI");
  set_usize (400, 200);
  // don't allow resizing
  set_policy ( false, false, false );

  get_vbox()->add( &canvas );
  get_action_area()->add( &OK );

  connect_to_method ( OK.clicked, this, &AboutDialog::ok_clicked );
	
  OK.show();
  canvas.show();
}
/*
 *******************************************************************************************************
 * Wrapper function to remove bin(s) from a record.
 *
 * @param as_object_p           The C client's aerospike object.
 * @param as_key_p              The C client's as_key that identifies the record.
 * @param bins_p                The PHP array of bins to be removed from the record.
 * @param error_p               The as_error to be populated by the function
 *                              with the encountered error if any.
 * @param options_p             The user's optional policy options to be used if set, else defaults.
 *
 *******************************************************************************************************
 */
extern as_status 
aerospike_record_operations_remove_bin(aerospike* as_object_p,
                                       as_key* as_key_p,
                                       zval* bins_p,
                                       as_error* error_p,
                                       zval* options_p)
{
    as_status           status = AEROSPIKE_OK;
    as_record           rec;
    HashTable           *bins_array_p = Z_ARRVAL_P(bins_p);
    HashPosition        pointer;
    zval                **bin_names;
    as_policy_write     write_policy;

    as_record_inita(&rec, zend_hash_num_elements(bins_array_p));
    
    if ((!as_object_p) || (!error_p) || (!as_key_p) || (!bins_array_p)) {
        status = AEROSPIKE_ERR;
        goto exit;
    }

    set_policy(NULL, &write_policy, NULL, NULL, NULL, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (status = (error_p->code))) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }


    foreach_hashtable(bins_array_p, pointer, bin_names) {
        if (IS_STRING == Z_TYPE_PP(bin_names)) {
            if (!(as_record_set_nil(&rec, Z_STRVAL_PP(bin_names)))) {
                status = AEROSPIKE_ERR;
                goto exit;
            }
        } else {
             status = AEROSPIKE_ERR;
             goto exit;
        }
    }         

    if (AEROSPIKE_OK != (status = aerospike_key_put(as_object_p, error_p,
                    NULL, as_key_p, &rec))) {
         goto exit;
    }

exit:
    as_record_destroy(&rec);
    return(status);
}
scrolledLogWindow::scrolledLogWindow(const Glib::ustring & title) {

	/* Create a new scrolled window, with scrollbars only if needed */
	set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	add(m_TreeView);

	/* create list store */
	m_refListStore = Gtk::ListStore::create(m_Columns);
	m_TreeView.set_model(m_refListStore);

	//Add the unique column with title
	m_TreeView.append_column(title, m_Columns.m_col_text);

	std::ostringstream text;
	text << "welcome to the yield curve analyser...";
	Gtk::TreeModel::Row row = *(m_refListStore->append());
	row[m_Columns.m_col_text] = text.str();
	show_all_children();

}
예제 #17
0
/*
 ******************************************************************************************************
 Remove a UDF module from the aerospike DB.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param module_p                  The name of the UDF module to remove from the Aerospike DB.
 * @param module_len                The module name length.
 * @param options_p                 The optional policy.
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_udf_deregister(Aerospike_object* aerospike_obj_p,
        as_error* error_p, char* module_p, zval* options_p)
{
    as_policy_info          info_policy;
    
    set_policy(NULL, NULL, NULL, NULL, &info_policy, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    if (AEROSPIKE_OK != aerospike_udf_remove(aerospike_obj_p->as_ref_p->as_p,
                error_p, NULL, module_p)) {
        DEBUG_PHP_EXT_ERROR(error_p->message);
        goto exit;
    }
exit:
    return error_p->code;
}
예제 #18
0
/*
 ******************************************************************************************************
 Get the code of registered UDF module.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param module_p                  The name of the UDF module to get from the
 *                                  server.
 * @param module_len                Length of UDF module name.
 * @param udf_code_p                Code of the UDF to be populated by this
 *                                  function.
 * @param language                  The Aerospike::UDF_TYPE_* constant.
 * @param options_p                 The optional policy.
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_get_registered_udf_module_code(Aerospike_object* aerospike_obj_p,
        as_error* error_p, char* module_p, zval* udf_code_p,
        long language, zval* options_p)
{
    uint32_t                init_udf_file = 0;
    as_udf_file             udf_file;
    as_policy_info          info_policy;

    if ((language & AS_UDF_TYPE) != AS_UDF_TYPE) {
            PHP_EXT_SET_AS_ERR(error_p, AEROSPIKE_ERR_PARAM,
                    "Invalid Value for language");
            DEBUG_PHP_EXT_ERROR("Invalid value for language");
            goto exit;
    }

    set_policy(NULL, NULL, NULL, NULL, &info_policy, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    as_udf_file_init(&udf_file);
    init_udf_file = 1;
    
    if (AEROSPIKE_OK != aerospike_udf_get(aerospike_obj_p->as_ref_p->as_p,
                error_p, &info_policy, module_p, (language - AS_UDF_TYPE),
                &udf_file)) {
        DEBUG_PHP_EXT_ERROR(error_p->message);
        goto exit;
    }

    ZVAL_STRINGL(udf_code_p, udf_file.content.bytes, udf_file.content.size, 1);
exit:
    if (init_udf_file) {
        as_udf_file_destroy(&udf_file);
    }
    return error_p->code;
}
/*
 *******************************************************************************************************
 * Wrapper function to perform an aerospike_key_exists within the C client.
 *
 * @param as_object_p           The C client's aerospike object.
 * @param as_key_p              The C client's as_key that identifies the record.
 * @param error_p               The as_error to be populated by the function
 *                              with the encountered error if any.
 * @param metadata_p            The return metadata for the exists/getMetadata API to be 
 *                              populated by this function.
 * @param options_p             The user's optional policy options to be used if set, else defaults.
 *
 *******************************************************************************************************
 */
extern as_status aerospike_record_operations_exists(aerospike* as_object_p,
                                                    as_key* as_key_p,
                                                    as_error *error_p,
                                                    zval* metadata_p,
                                                    zval* options_p)
{
    as_status                   status = AEROSPIKE_OK;
    as_policy_read              read_policy;
    as_record*                  record_p = NULL;

    if ( (!as_key_p) || (!error_p) ||
         (!as_object_p) || (!metadata_p)) {
        status = AEROSPIKE_ERR;
        goto exit;
    }

    set_policy(&read_policy, NULL, NULL, NULL, NULL, NULL, options_p, error_p);
    if (AEROSPIKE_OK != (status = (error_p->code))) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }
  
    if (AEROSPIKE_OK != (status = aerospike_key_exists(as_object_p, error_p,
                    &read_policy, as_key_p, &record_p))) {
        goto exit;
    }

    add_assoc_long(metadata_p, "generation", record_p->gen);
    add_assoc_long(metadata_p, "ttl", record_p->ttl);

exit:
    if (record_p) {
        as_record_destroy(record_p);
    }

    return(status);   
}
예제 #20
0
PreferencesDialogImpl::PreferencesDialogImpl() : Gtk::Dialog()
{
    m_editorEntry = NULL;
    m_ctagsEntry = NULL;

    // dialog properties
    set_title("Preferences");
    set_position(GTK_WIN_POS_CENTER);
    set_modal(true);
    set_border_width(10);
    set_policy(false, false, true);

    // create the Default button
    Gtk::Button* defaultButton = manage(new Gtk::Button("Default"));
    defaultButton->clicked.connect(SigC::slot(this, &PreferencesDialogImpl::defaultButtonCB));
    defaultButton->set_usize(80, -1);
    defaultButton->set_flags(GTK_CAN_DEFAULT);
    defaultButton->show();

    // create the Apply button
    Gtk::Button* applyButton = manage(new Gtk::Button("Apply"));
    applyButton->clicked.connect(SigC::slot(this, &PreferencesDialogImpl::applyButtonCB));
    applyButton->set_usize(80, -1);
    applyButton->set_flags(GTK_CAN_DEFAULT);
    applyButton->show();

    // create the OK button and make it default
    Gtk::Button* okButton = manage(new Gtk::Button("OK"));
    okButton->clicked.connect(SigC::slot(this, &PreferencesDialogImpl::okButtonCB));
    okButton->set_usize(80, -1);
    okButton->set_flags(GTK_CAN_DEFAULT);
    okButton->grab_default();
    okButton->show();

    // create the Cancel button
    Gtk::Button* cancelButton = manage(new Gtk::Button("Cancel"));
    cancelButton->clicked.connect(SigC::slot(this, &PreferencesDialogImpl::cancelButtonCB));
    cancelButton->set_usize(80, -1);
    cancelButton->set_flags(GTK_CAN_DEFAULT);
    cancelButton->show();

    // add the buttons to the hbox
    Gtk::HBox* hbox = get_action_area();
    hbox->set_spacing(10);
    hbox->pack_start(*defaultButton, false, false);
    hbox->pack_start(*applyButton, false, false);
    hbox->pack_start(*okButton, false, false);
    hbox->pack_start(*cancelButton, false, false);

    // editor stuff
    Gtk::HBox* editorBox = manage(new Gtk::HBox());
    Gtk::Label* editorLabel = manage(new Gtk::Label("Editor Command: "));
    editorLabel->show();
    editorBox->pack_start(*editorLabel, false, false);
    m_editorEntry = manage(new Gtk::Entry());
    m_editorEntry->set_text(g_configMap[Config::EDITOR[0]]);
    m_editorEntry->show();
    editorBox->pack_end(*m_editorEntry);
    editorBox->show();

    // ctags stuff
    Gtk::HBox* ctagsBox = manage(new Gtk::HBox());
    Gtk::Label* ctagsLabel = manage(new Gtk::Label("Ctags Command: "));
    ctagsLabel->show();
    ctagsBox->pack_start(*ctagsLabel, false, false);
    m_ctagsEntry = manage(new Gtk::Entry());
    m_ctagsEntry->set_text(g_configMap[Config::CTAGS[0]]);
    m_ctagsEntry->show();
    ctagsBox->pack_end(*m_ctagsEntry);
    ctagsBox->show();

    // add everything to the vbox
    Gtk::VBox* vbox = get_vbox();
    vbox->set_spacing(5);
    vbox->pack_start(*editorBox, false, false);
    vbox->pack_start(*ctagsBox, false, false);

    show();
    Gtk::Main::run();
}
예제 #21
0
/*
 ******************************************************************************************************
 Registers a UDF module.
 *
 * @param aerospike_obj_p           The C client's aerospike object.
 * @param error_p                   The C client's as_error to be set to the encountered error.
 * @param path_p                    The path to the module on the client side
 * @param language                  The Aerospike::UDF_TYPE_* constant.
 * @param options_p                 The optional policy.
 *
 * @return AEROSPIKE_OK if success. Otherwise AEROSPIKE_x.
 ******************************************************************************************************
 */
extern as_status
aerospike_udf_register(Aerospike_object* aerospike_obj_p, as_error* error_p,
        char* path_p, char* module_p, long language, zval* options_p)
{
    FILE*                   file_p = NULL;
    uint32_t                size = 0;
    uint32_t                content_size;
    uint8_t*                bytes_p = NULL;
    uint8_t*                buff_p = NULL;
    uint32_t                read;
    as_bytes                udf_content;
    as_bytes*               udf_content_p = NULL;
    as_policy_info          info_policy;
    TSRMLS_FETCH_FROM_CTX(aerospike_obj_p->ts);

    set_policy(&aerospike_obj_p->as_ref_p->as_p->config, NULL,
            NULL, NULL, NULL, &info_policy, NULL, NULL, NULL,
            options_p, error_p TSRMLS_CC);
    if (AEROSPIKE_OK != (error_p->code)) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    file_p = fopen(path_p, "r");

    if (!file_p) {
        PHP_EXT_SET_AS_ERR(error_p, AEROSPIKE_ERR_UDF_NOT_FOUND,
                "Cannot open script file");
        DEBUG_PHP_EXT_DEBUG("Cannot open script file");
        goto exit;
    }

    fseek(file_p, 0L, SEEK_END);
    content_size = ftell(file_p);
    fseek(file_p, 0L, SEEK_SET);

    /*
     * Using emalloc here to maintain consistency of PHP extension.
     * malloc can also be used for C-SDK.
     * if emalloc is used, pass parameter 4 of function as_bytes_init_wrap as
     * "false" and handle the freeing up of the same here.
     */
    if (NULL == (bytes_p = (uint8_t *) emalloc(content_size + 1))) {
        PHP_EXT_SET_AS_ERR(error_p, AEROSPIKE_ERR,
                "Memory allocation failed for contents of UDF");
        DEBUG_PHP_EXT_DEBUG("Memory allocation failed for contents of UDF");
        goto exit;
    }

    buff_p = bytes_p;
    read = (int) fread(buff_p, 1, LUA_FILE_BUFFER_FRAME, file_p);
    while (read) {
        size += read;
        buff_p += read;
        read = (int) fread(buff_p, 1, LUA_FILE_BUFFER_FRAME, file_p);
    }

    as_bytes_init_wrap(&udf_content, bytes_p, size, false);
    udf_content_p = &udf_content;
    /*
     * Register the UDF file in the database cluster.
     */
    if (AEROSPIKE_OK != aerospike_udf_put(aerospike_obj_p->as_ref_p->as_p,
                error_p, &info_policy, module_p, language,
                      udf_content_p)) {
        DEBUG_PHP_EXT_DEBUG("%s", error_p->message);
        goto exit;
    } else if (AEROSPIKE_OK !=
            aerospike_udf_put_wait(aerospike_obj_p->as_ref_p->as_p,
                error_p, &info_policy, module_p, 0)) {
        DEBUG_PHP_EXT_DEBUG("%s", error_p->message);
        goto exit;
    }

exit:
    if (file_p) {
        fclose(file_p);
    }

    if (bytes_p) {
        efree(bytes_p);
    }

    if (udf_content_p) {
        as_bytes_destroy(udf_content_p);
    }

    return error_p->code;
}
예제 #22
0
TDialogInit::TDialogInit(unsigned _max, 
			 unsigned *_generaciones, unsigned *_tamPop, 
			 unsigned *_numGenes, unsigned *_bitXgen,
			 unsigned *_rangeVal,
			 float *_rate, float *_select,
			 unsigned *_OkCancel) :
  OK("OK"), Cancel("Cancel"), 
  frameG("Number of Generations"), cajaG(false, 5),
  frameP("Initial Pop. Size"), cajaP(false, 5),
  frameNG("Num. Genes"), cajaNG(false, 5),
  frameBG("Bits x Gen"), cajaBG(false, 5),
  frameR("Rate to kill"), cajaR(false, 5),
  frameS("\% to reproduce"), cajaS(false, 5),
  devG(_generaciones), devP(_tamPop), devNG(_numGenes), devBG(_bitXgen),
  devR(_rate), devS(_select),
  OkCancel(_OkCancel), max(_max)
{
  set_title ("Initial Parameters");
  set_policy ( false, false, false );

  set_border_width(3);

  cajaG.set_border_width (7);
  cajaP.set_border_width (7);
  cajaNG.set_border_width (7);
  cajaBG.set_border_width (7);
  cajaR.set_border_width (7);
  cajaS.set_border_width (7);
  
  // value, lower, upper, step incr, page incr, page size
  //number of generations.
  AdjG = new Gtk_Adjustment ( (*devG), 0,max, 1,10, 0 );
  ScaleG = new Gtk_HScale(*AdjG);
  ScaleG->set_digits(0); // make scales use integers
  ScalesBoxG = new Gtk_VBox(false, 0);
  ScalesBoxG->pack_end (*ScaleG);
  ScaleG->show();
  ScalesBoxG->show();

  //pop. size
  AdjP = new Gtk_Adjustment ( (*devP), 0,max, 1,10, 0 );
  ScaleP = new Gtk_HScale(*AdjP);
  ScaleP->set_digits(0);
  ScalesBoxP = new Gtk_VBox(false, 0);
  ScalesBoxP->pack_end (*ScaleP);
  ScaleP->show();
  ScalesBoxP->show();

  //number of genes
  AdjNG = new Gtk_Adjustment ( (*devNG), 1,100, 1,10, 0 );
  ScaleNG = new Gtk_HScale(*AdjNG);
  ScaleNG->set_digits(0); // make scales use integers
  ScalesBoxNG = new Gtk_VBox(false, 0);
  ScalesBoxNG->pack_end (*ScaleNG);
  ScaleNG->show();
  ScalesBoxNG->show();

  //bits x gen
  AdjBG = new Gtk_Adjustment ( (*devBG), 1,100, 1,10, 0 );
  ScaleBG = new Gtk_HScale(*AdjBG);
  ScaleBG->set_digits(0); // make scales use integers
  ScalesBoxBG = new Gtk_VBox(false, 0);
  ScalesBoxBG->pack_end (*ScaleBG);
  ScaleBG->show();
  ScalesBoxBG->show();

  //rate for the coach
  AdjR = new Gtk_Adjustment ( (*devR), 0.0,1.0, 0.1,0.2, 0 );
  ScaleR = new Gtk_HScale(*AdjR);
  ScaleR->set_digits(1);
  ScalesBoxR = new Gtk_VBox(false, 0);
  ScalesBoxR->pack_end (*ScaleR);
  ScaleR->show();
  ScalesBoxR->show();

  //select for the chaperon
  AdjS = new Gtk_Adjustment ( (*devS), 0.0,100.0, 1.0,10.0, 0 );
  ScaleS = new Gtk_HScale(*AdjS);
  ScaleS->set_digits(1);
  ScalesBoxS = new Gtk_VBox(false, 0);
  ScalesBoxS->pack_end (*ScaleS);
  ScaleS->show();
  ScalesBoxS->show();

  // More assembly...
  Gtk_HBox * aa = get_action_area();
  aa->add(&OK);
  aa->add(&Cancel);
  OK.show();
  Cancel.show();

  Gtk_VBox * v = get_vbox();
  v->add(&frameG);
  v->add(&frameP);
  v->add(&frameNG);
  v->add(&frameBG);
  v->add(&frameR);
  v->add(&frameS);
  frameG.add(&cajaG);
  frameP.add(&cajaP);
  frameNG.add(&cajaNG);
  frameBG.add(&cajaBG);
  frameR.add(&cajaR);
  frameS.add(&cajaS);
  cajaG.pack_start(*ScalesBoxG);
  cajaP.pack_start(*ScalesBoxP);
  cajaNG.pack_start(*ScalesBoxNG);
  cajaBG.pack_start(*ScalesBoxBG);
  cajaR.pack_start(*ScalesBoxR);
  cajaS.pack_start(*ScalesBoxS);

  cajaG.show();
  cajaP.show();
  cajaNG.show();
  cajaBG.show();
  cajaR.show();
  cajaS.show();

  frameG.show();
  frameP.show();
  frameNG.show();
  frameBG.show();
  frameR.show();
  frameS.show();

  connect_to_method( OK.clicked,this,&TDialogInit::ok_clicked );
  connect_to_method( Cancel.clicked,this,&TDialogInit::cancel_clicked );

}

void TDialogInit::ok_clicked() {
  *devG=(unsigned) AdjG->get_value();
  *devP=(unsigned) AdjP->get_value();
  //  *devNG=(unsigned) AdjNG->get_value();
  //  *devBG=(unsigned) AdjBG->get_value();
  *devR=(float) AdjR->get_value();
  *devS=(float) AdjS->get_value();
  *OkCancel = 1;
  closed();
}
예제 #23
0
파일: sched_pp.c 프로젝트: mbehr1/sched_pp
int main (int argc, char **argv)
{
	int do_get = 0;
	int do_set = 0;
	char *pvalue = NULL;
	pid_t pid=0;
	int priority=0;
	int policy = -1;
	int index;
	int c;

	printf("sched_pp (V1.0) (c) M.Behr, 2013\n");
	opterr = 0;

	while ((c = getopt (argc, argv, "gs:p:P:")) != -1)
		switch (c)
		{
		case 'g':
			do_get = 1;
			break;
		case 's':
			do_set = 1;
			priority = atol(optarg);
			break;
		case 'p':
			pvalue = optarg;
			pid=atol(pvalue);
			break;
		case 'P':
			if (!strcmp(optarg, "SCHED_FIFO")) policy = SCHED_FIFO;
			else if (!strcmp(optarg, "SCHED_RR")) policy = SCHED_RR;
			else if (!strcmp(optarg, "SCHED_OTHER")) policy = SCHED_OTHER;
			else{
				fprintf(stderr, "Unknown policy <%s>.\n", optarg);
				return 2;
			}
			break;
		case '?':
			if (optopt == 'p' || optopt == 's' || optopt == 'P')
				fprintf (stderr, "Option -%c requires an argument.\n", optopt);
			else if (isprint (optopt))
				fprintf (stderr, "Unknown option `-%c'.\n", optopt);
			else
				fprintf (stderr,
						"Unknown option character `\\x%x'.\n",
						optopt);
			return 1;
		default:
			abort ();
		}

	for (index = optind; index < argc; index++)
		printf ("Non-option argument %s\n", argv[index]);

	if (!do_get && !do_set){
		printf("Usage:\nsched_pp -p <pid> [-g] [-s <priority>] [-P<policy=SCHED_FIFO|SCHED_RR|SCHED_OTHER>]\n");
	}

	if (do_get){
		print_params(pid, 0);
	}

	if (do_set){
		int cur_policy;
		/* print before */
		print_params(pid, &cur_policy);

		if (policy != -1){
			printf("trying to change pid %d to policy %d and priority %d:\n", pid, policy, priority);
			if (policy != SCHED_OTHER)
				set_policy(pid, policy, priority);
			else{
				set_policy(pid, policy, 0); /* SCHED_OTHER only allows 0 for that priority */
				set_priority(pid, policy, priority);
			}

		}else{
			printf("trying to change pid %d to priority %d:\n Params now:\n", pid, priority);
			set_priority(pid, cur_policy, priority);
		}
		/* print afterwards */
		print_params(pid, 0);
	}

	return 0;
}
예제 #24
0
Dock::Dock()
{
  set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
  add(m_vbox);
}
예제 #25
0
/**
 Constructor.
 @param ig, InterfaGovocitos.
 @param pd, PanelDibujado.
 */
PanelPropiedades::PanelPropiedades(InterfazGovocitos &ig, PanelDibujado &pd)
{
	panelDibuj = &pd;
	interfazPrincipal = &ig;

	micras = 1;
	//Iniciamos el panel derecho y a continuacion lo añadimos al scrollPanDer
	iniciadorPanelDer();
	
	set_policy(Gtk::POLICY_NEVER,Gtk::POLICY_AUTOMATIC);
	add(*panDer);	
	
	//Establece la seleccion de tipos y clases a ""
	selecionaClase.set_active(0);
	selecionaEstado.set_active(0);
	selecionaClase.set_sensitive(false);
	selecionaEstado.set_sensitive(false);
	
	cierraPanel->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::cierraPaneLateral));
	EliminaCelula->signal_clicked().connect(sigc::mem_fun(*panelDibuj, &PanelDibujado::eliminaCelula));
	EliminaCelula2->signal_clicked().connect(sigc::mem_fun(*panelDibuj, &PanelDibujado::eliminaCelula));
	UnePuntos->signal_clicked().connect(sigc::mem_fun(*panelDibuj, &PanelDibujado::unePuntosPintado));
	activaCapaRejR->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::activaRejilla));
	activaBordeRejR->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::activaBordeRejilla));
	SelecCel->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	SelecCel2->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	AnhadirCel->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	ModifCel->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	AnhadirCelPT->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	AnhadirCelManoAL->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	Drawcircle->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	calcDiamet->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PanelPropiedades::activaVistaDatos), 1));
	calcDiamet2->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PanelPropiedades::activaVistaDatos), 1));
	calcEstadist->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PanelPropiedades::activaVistaDatos), 3));
	calcTodosDiam->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PanelPropiedades::activaVistaDatos), 2));
	calcTodosDiam2->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PanelPropiedades::activaVistaDatos), 2));
	selecionaClase.signal_changed().connect(sigc::mem_fun(*this, &PanelPropiedades::estableceClase));
	selecionaEstado.signal_changed().connect(sigc::mem_fun(*this, &PanelPropiedades::estableceEstado));
	confRej->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::configurarRejilla));
	rejillaDefec->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	rejillaPersonal->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	activCapaCelE->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::activaCapaCelulas));
	activCapaCelR->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::activaCapaCelulas));
	activCapaCelE2->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::activaCapaCelulas));
	printDataG->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::exportCsvDatosCell));
	selectAllG->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::seleccionaTodasCelulas));
	selectAllG2->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::seleccionaTodasCelulas));
	printDataG1->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::exportCsvStadisticalData));
	printDataG2->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::exportCsvDatosCell));
	
	//Modo panel deteccion no supervisada
	printDataGNSup->signal_clicked().connect(sigc::mem_fun(*interfazPrincipal, &InterfazGovocitos::finalDetecNoSupervisada));
	EliminaCelulaNSup->signal_clicked().connect(sigc::mem_fun(*panelDibuj, &PanelDibujado::eliminaCelula));
	ModifCelNSup->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	AnhadirCelManoALNSup->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	AnhadirCelPTNSup->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	SelecCelNSup->signal_clicked().connect(sigc::mem_fun(*this, &PanelPropiedades::setSensiblePanel));
	UnePuntosNSup->signal_clicked().connect(sigc::mem_fun(*panelDibuj, &PanelDibujado::unePuntosPintado));
		
	show_all();
}
/*
 *******************************************************************************************************
 * Wrapper function to perform an aerospike_key_oeprate within the C client.
 *
 * @param as_object_p           The C client's aerospike object.
 * @param as_key_p              The C client's as_key that identifies the record.
 * @param options_p             The user's optional policy options to be used if set, else defaults.
 * @param error_p               The as_error to be populated by the function
 *                              with the encountered error if any.
 * @param bin_name_p            The bin name to perform operation upon.
 * @param str                   The string to be appended in case of operation: append.
 * @param offset                The offset to be incremented by in case of operation: increment.
 * @param initial_value         The initial value to be set if record is absent
 *                              in case of operation: increment.
 * @param time_to_live          The ttl for the record in case of operation: touch.
 * @param operation             The operation type.
 *
 *******************************************************************************************************
 */
extern as_status
aerospike_record_operations_ops(aerospike* as_object_p,
                                as_key* as_key_p,
                                zval* options_p,
                                as_error* error_p,
                                int8_t* bin_name_p,
                                int8_t* str,
                                u_int64_t offset,
                                u_int64_t initial_value,
                                u_int64_t time_to_live,
                                u_int64_t operation)
{
    as_status           status = AEROSPIKE_OK;
    as_policy_operate   operate_policy;
    uint32_t            serializer_policy;
    as_record*          get_rec = NULL;
    as_operations       ops;
    as_val*             value_p = NULL;
    as_integer          initial_int_val;
    int16_t             initialize_int = 0;
    const char *select[] = {bin_name_p, NULL};

    as_operations_inita(&ops, 1);
    as_policy_operate_init(&operate_policy);

    if ((!as_object_p) || (!error_p) || (!as_key_p)) {
        status = AEROSPIKE_ERR;
        goto exit;
    }

    set_policy(NULL, NULL, &operate_policy, NULL, NULL, &serializer_policy,
            options_p, error_p);
    if (AEROSPIKE_OK != (status = (error_p->code))) {
        DEBUG_PHP_EXT_DEBUG("Unable to set policy");
        goto exit;
    }

    switch(operation) {
        case AS_OPERATOR_APPEND:
            as_operations_add_append_str(&ops, bin_name_p, str);
            break;
        case AS_OPERATOR_PREPEND:
            as_operations_add_prepend_str(&ops, bin_name_p, str);
            break;
        case AS_OPERATOR_INCR:
            if (AEROSPIKE_OK != (status = aerospike_key_select(as_object_p,
                            error_p, NULL, as_key_p, select, &get_rec))) {
                goto exit;
            } else {
                if (NULL != (value_p = (as_val *) as_record_get (get_rec, bin_name_p))) {
                   if (AS_NIL == value_p->type) {
                       as_integer_init(&initial_int_val, initial_value);
                       initialize_int = 1;
                       if (!as_operations_add_write(&ops, bin_name_p,
                                   (as_bin_value*) &initial_int_val)) {
                           status = AEROSPIKE_ERR;
                           goto exit;
                       }
                   } else {
                       as_operations_add_incr(&ops, bin_name_p, offset);
                   }
                } else {
                    status = AEROSPIKE_ERR;
                    goto exit;
                }
            }
            break;
        case AS_OPERATOR_TOUCH:
            ops.ttl = time_to_live;
            as_operations_add_touch(&ops);
            break;
        default:
            status = AEROSPIKE_ERR;
            goto exit;
            break;
    }

    if (AEROSPIKE_OK != (status = aerospike_key_operate(as_object_p, error_p,
                    &operate_policy, as_key_p, &ops, &get_rec))) {
        goto exit;
    }

exit:
     as_operations_destroy(&ops);
     if (get_rec) {
         as_record_destroy(get_rec);
     }
     if (initialize_int) { 
         as_integer_destroy(&initial_int_val);
     }
     return status;
}
예제 #27
0
int main(int argc, char** argv) {
  int n = 0;
  int i;
  const int MAX = atoi(argv[1]);
  const int CORES = atoi(argv[2]);
  int ncpus=0;

  int apps[1024];

/**/
        extern char *optarg;
	extern int optind, opterr, optopt;
	int ret = 0, cont = 1;
	unsigned int cpu = 0;
	//unsigned int cpu_defined = 0;
        unsigned long  min_available_freq = 0;
        unsigned long max_available_freq = 0;  
        unsigned long current_freq = 0;
        unsigned long initial_freq = 0;
        struct cpufreq_available_frequencies *freqs;
        int retr =0;

	setlinebuf(stdout);

   ncpus=get_cpus();

if(!CORES){
           CORES == ncpus;
           }


if (CORES > ncpus){
 printf("Wrong number of inital cores");
 exit(2);
}

  ret= get_hardware_limits(cpu);

  min_available_freq = min;
  max_available_freq = max;

  ret= set_policy(CORES);

  freqs = cpufreq_get_available_frequencies(0);

/*if (freqs==null){
  goto out;
}*/

  current = get_available_freqs_size(freqs);

  unsigned long* available_freqs = (unsigned long *) malloc(current*sizeof(unsigned long));


  ret = store_available_freqs( freqs, available_freqs, current);

  int current_counter = get_init_frequency(available_freqs, cpu);

  /*if (ret!=0){
               goto out;
                }*/


  current_freq = cpufreq_get_freq_kernel(cpu);


   if(getenv("HEARTBEAT_ENABLED_DIR") == NULL) {
     fprintf(stderr, "ERROR: need to define environment variable HEARTBEAT_ENABLED_DIR (see README)\n");
     return 1;
   }

  heart_data_t* records = (heart_data_t*) malloc(MAX*sizeof(heart_data_t));
  int last_tag = -1;

  while(n == 0) {
    n = get_heartbeat_apps(apps);
  }

  printf("apps[0] = %d\n", apps[0]);

  // For this test we only allow one heartbeat enabled app
 // assert(n==1);
  if (n>1) {
     printf("too many apps!!!!!!!!!!!!!!\n");
     exit(2);
  }

/*  sleep(5);*/

#if 1
  int rc = heart_rate_monitor_init(&heart, apps[0]);

  if (rc != 0)
    printf("Error attaching memory\n");

  printf("buffer depth is %lld\n", (long long int) heart.state->buffer_depth);

  i = 0;
      printf(" rate interval is %f - %f\n", hrm_get_min_rate(&heart), hrm_get_max_rate(&heart));


printf("beat\trate\tfreq\tcores\ttact\twait\n");

  int64_t window_size =  hrm_get_window_size(&heart);
  int wait_for = (int) window_size;
  int current_beat = 0;
  int current_beat_prev= 0;
  int nprocs = 1;
  unsigned int set_freq = min;
 

  // return 1;  
    
  while(current_beat < MAX) {
    int rc = -1;
    heartbeat_record_t record;
    char command[256];


      while (rc != 0 || record.window_rate == 0.0000 ){
	rc = hrm_get_current(&heart, &record);
	current_beat = record.beat;
      }
        
       
      if(current_beat_prev == current_beat)
      continue;
    /*  printf(" rc: %d, current_beat:%d \n", rc,current_beat);*/
    /*Situation where doesn't happen nothing*/   
      if( current_beat < wait_for){
          current_beat_prev= current_beat;
         /* printf("I am in situation wait_for\n");*/
                current_freq = cpufreq_get_freq_kernel(0);
		print_status(&record, wait_for, current_freq, '.', CORES);
        continue;
      }


    /*  printf("Current beat is %d, wait_for = %d, %f\n", current_beat, wait_for, record.window_rate);*/

       /*Situation where frequency is up-scaled*/
      if(record.window_rate < hrm_get_min_rate(&heart)) {  
 

  	wait_for = current_beat + window_size;      
        

         if (current_counter > 0){

          int cpu;
              current_counter--;  
             set_freq = get_speed(available_freqs[current_counter]);

             for (cpu=0; cpu <=CORES; cpu++) {
	    /*   sprintf(command, "cpufreq-set -c %d -f %luMHZ", cpu,set_freq);*/
	       /* printf("Executing %s\n", command);*/
             /*  system(command);*/
		cpufreq_set_frequency(cpu, available_freqs[current_counter]);

             }

             current_freq = cpufreq_get_freq_kernel(0);
		print_status(&record, wait_for, current_freq, '+', CORES);
            }

       else {
          current_freq = cpufreq_get_freq_kernel(0);
		print_status(&record, wait_for, current_freq, 'M', CORES);

         }
      }

     /*Situation where frequency is downscaled*/

      else if(record.window_rate > hrm_get_max_rate(&heart)) {
	wait_for = current_beat + window_size;       
       if (current_counter < current){
          current_counter++;
          set_freq = get_speed(available_freqs[current_counter]);
          for (cpu=0; cpu <=CORES; cpu++) {
         /* sprintf(command, " cpufreq-set -c %d -f %uMHZ", cpu,set_freq);*/
	 /* printf("Executing %s\n", command);*/
	  /*system(command);*/
		cpufreq_set_frequency(cpu, available_freqs[current_counter]);
          }
        
         current_freq = cpufreq_get_freq_kernel(0);
		print_status(&record, wait_for, current_freq, '-', CORES);
          }
	

        else {
          current_freq = cpufreq_get_freq_kernel(0);
		print_status(&record, wait_for, current_freq, 'm', CORES);

        }
		

      }

      else {
	wait_for = current_beat+1;
	print_status(&record, wait_for, current_freq, '=', CORES);
      }
      current_beat_prev= current_beat;
      records[i].tag = current_beat;
      records[i].rate = record.window_rate;
      i++;
   

  }

  //printf("System: Global heart rate: %f, Current heart rate: %f\n", heart.global_heartrate, heart.window_heartrate);

/*  for(i = 0; i < MAX; i++) {
    printf("%d, %f\n", records[i].tag, records[i].rate);
  }*/
  heart_rate_monitor_finish(&heart);
#endif

  return 0;
}