void knapsack_solve(struct problem_t *p) { assert(p->n > 0); print_objects(p); sort_objects(p); print_objects(p); }
bool avsfilter::configure(void) { DEBUG_PRINTF("avsfilter : before dialog init\n"); print_objects(); #define PX(x) &(param.x) diaElemFile wine_app(0,(char**)PX(wine_app), QT_TR_NOOP("_wine app file:"), NULL, QT_TR_NOOP("Select wine filename[wine/cedega/etc.]")); diaElemFile loaderfile(0,(char**)PX(avs_loader), QT_TR_NOOP("_loader file:"), NULL, QT_TR_NOOP("Select loader filename[avsload.exe]")); diaElemFile avsfile(0,(char**)PX(avs_script), QT_TR_NOOP("_avs file:"), NULL, QT_TR_NOOP("Select avs filename[*.avs]")); diaElemUInteger pipe_timeout(PX(pipe_timeout),QT_TR_NOOP("_pipe timeout:"),1,30); diaElem *elems[4]={&wine_app, &loaderfile, &avsfile, &pipe_timeout}; if( diaFactoryRun(QT_TR_NOOP("AvsFilter config"), 4, elems)) { bool res = false; DEBUG_PRINTF("avsfilter : configure before SetParameters\n"); // if script/loader names are exist, then taste config if (param.avs_loader && strlen((const char*)param.avs_loader) && param.avs_script && strlen((const char*)param.avs_script) && param.wine_app && strlen((const char*)param.wine_app)) { struct stat st; if (stat((char*)param.avs_script, &st) != 0) { DEBUG_PRINTF_RED("avsfilter : cannot stat script file\n"); return 0; } param.script_mtime = st.st_mtime; // store timestamp param.script_ctime = st.st_ctime; print_objects(); res = SetParameters(¶m); if (res) avsfilter_config_jserialize(prefs_name, ¶m); DEBUG_PRINTF("avsfilter : configure before save prefs [%s][%s]\n", param.avs_script, param.avs_loader); // if setparameters are ok and (therefore) avs_script and avs_loader exist // we store this parameters in filter preferences DEBUG_PRINTF("avsfilter : after save prefs info : frameIncrement %lu totalDuration %llu\n", info.frameIncrement, info.totalDuration); DEBUG_PRINTF("avsfilter : configure exit ok\n"); return res; } } return 0; }
int main() { init_objects(); printf("Before unions:\n"); print_objects(); join(4, 3); join(0, 1); join(4, 1); printf("After unions:\n"); print_objects(); printf("0 connected to 3: %s\n", is_connected(0, 3) ? "True" : "False"); return 0; }
gint main (gint argc, gchar *argv[]) { GDBusObjectManager *manager; GMainLoop *loop; GError *error; gchar *name_owner; manager = NULL; loop = NULL; loop = g_main_loop_new (NULL, FALSE); error = NULL; manager = example_object_manager_client_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.gtk.GDBus.Examples.ObjectManager", "/example/Animals", NULL, /* GCancellable */ &error); if (manager == NULL) { g_printerr ("Error getting object manager client: %s", error->message); g_error_free (error); goto out; } name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (manager)); g_print ("name-owner: %s\n", name_owner); g_free (name_owner); print_objects (manager); g_signal_connect (manager, "notify::name-owner", G_CALLBACK (on_notify_name_owner), NULL); g_signal_connect (manager, "object-added", G_CALLBACK (on_object_added), NULL); g_signal_connect (manager, "object-removed", G_CALLBACK (on_object_removed), NULL); g_signal_connect (manager, "interface-proxy-properties-changed", G_CALLBACK (on_interface_proxy_properties_changed), NULL); g_main_loop_run (loop); out: if (manager != NULL) g_object_unref (manager); if (loop != NULL) g_main_loop_unref (loop); return 0; }
/* Just for debugging. */ static void print_objects(struct topo_topology *topology, int indent, topo_obj_t obj) { char line[TOPO_CPUSET_STRING_LENGTH+1]; topo_debug("%*s", 2*indent, ""); topo_obj_snprintf(line, sizeof(line), topology, obj, "#", 1); topo_debug("%s", line); topo_cpuset_snprintf(line, sizeof(line), &obj->cpuset); topo_debug(" %s", line); if (obj->arity) topo_debug(" arity %d", obj->arity); topo_debug("\n"); for (obj = obj->first_child; obj; obj = obj->next_sibling) print_objects(topology, indent + 1, obj); }
int main(int argc, char *argv[]) { int opt[PRINT_OPT_END] = {0}; char ch; opt[PRINT_OBJECT] = 1; while ((ch = getopt(argc, argv, "vh")) != -1){ switch (ch) { case 'v': opt[PRINT_ADDRESS] = 1; opt[PRINT_OBJECT] = 1; opt[PRINT_SOURCE] = 1; opt[PRINT_HEADER] = 1; break; case '?' : case 'h' : fprintf(stderr, "Usage: %s [ filename -vh? ]\n", argv[0]); fprintf(stderr, "-v: Verbose output(For human) -h -?: help\n"); return -1; break; } } if (argc - optind > 0){ if((yyin = fopen(argv[optind], "r")) == NULL){ fprintf(stderr,"Cannot open input file.\n"); return -1; } } yyparse(); print_objects(opt); return 0; }
/* Main discovery loop */ static void topo_discover(struct topo_topology *topology) { unsigned l, i=0, taken_i, new_i, j; topo_obj_t *objs, *taken_objs, *new_objs, top_obj; unsigned n_objs, n_taken_objs, n_new_objs; assert(topology!=NULL); if (topology->backend_type == TOPO_BACKEND_SYNTHETIC) { topo_look_synthetic(topology); #ifdef HAVE_XML } else if (topology->backend_type == TOPO_BACKEND_XML) { topo_look_xml(topology); #endif } else { /* Raw detection, from coarser levels to finer levels for more efficiency. */ /* topo_look_* functions should use topo_obj_add to add objects initialized * through topo_setup_object. For node levels, memory_Kb and huge_page_free * must be initialized. For cache levels, memory_kB and attr->cache.depth must be * initialized, for misc levels, attr->misc.depth must be initialized */ /* There must be at least a PROC object for each logical processor, at worse * produced by topo_setup_proc_level() */ /* Each OS type should also fill the bind functions pointers, at least the * set_cpubind one */ # ifdef LINUX_SYS # define HAVE_OS_SUPPORT topo_look_linux(topology); # endif /* LINUX_SYS */ # ifdef AIX_SYS # define HAVE_OS_SUPPORT topo_look_aix(topology); # endif /* AIX_SYS */ # ifdef OSF_SYS # define HAVE_OS_SUPPORT topo_look_osf(topology); # endif /* OSF_SYS */ # ifdef SOLARIS_SYS # define HAVE_OS_SUPPORT topo_look_solaris(topology); # endif /* SOLARIS_SYS */ # ifdef WIN_SYS # define HAVE_OS_SUPPORT topo_look_windows(topology); # endif /* WIN_SYS */ # ifdef DARWIN_SYS # define HAVE_OS_SUPPORT topo_look_darwin(topology); # endif /* DARWIN_SYS */ # ifndef HAVE_OS_SUPPORT topo_setup_proc_level(topology, topo_fallback_nbprocessors (), NULL); # endif /* Unsupported OS */ } print_objects(topology, 0, topology->levels[0][0]); /* First tweak a bit to clean the topology. */ topo_debug("\nComputing the system cpuset by ORing all Proc objects\n"); topo_cpuset_zero(&topology->levels[0][0]->cpuset); traverse(topology, &topology->levels[0][0], NULL, get_proc_cpuset, NULL, &topology->levels[0][0]->cpuset); topo_debug("\nApplying the system cpuset to all nodes\n"); traverse(topology, &topology->levels[0][0], apply_cpuset, apply_cpuset, NULL, &topology->levels[0][0]->cpuset); topo_debug("\nRemoving empty objects except numa nodes\n"); traverse(topology, &topology->levels[0][0], remove_empty, remove_empty, NULL, NULL); print_objects(topology, 0, topology->levels[0][0]); topo_debug("\nRemoving objects whose type has TOPO_IGNORE_TYPE_KEEP_STRUCTURE and have only one child or are the only child\n"); traverse(topology, &topology->levels[0][0], NULL, NULL, merge_useless_child, NULL); topo_debug("\nOk, finished tweaking, now connect\n"); /* Now connect handy pointers. */ topo_connect(topology->levels[0][0]); print_objects(topology, 0, topology->levels[0][0]); /* Explore the resulting topology level by level. */ /* initialize all depth to unknown */ for (l=1; l < TOPO_OBJ_TYPE_MAX; l++) topology->type_depth[l] = TOPO_TYPE_DEPTH_UNKNOWN; topology->type_depth[TOPO_OBJ_SYSTEM] = 0; /* Start with children of the whole system. */ l = 0; n_objs = topology->levels[0][0]->arity; objs = malloc(n_objs * sizeof(objs[0])); assert(objs); memcpy(objs, topology->levels[0][0]->children, n_objs * sizeof(objs[0])); /* Keep building levels while there are objects left in OBJS. */ while (n_objs) { /* First find which type of object is the topmost. */ top_obj = objs[0]; for (i = 1; i < n_objs; i++) { if (topo_type_cmp(top_obj, objs[i]) != TOPO_TYPE_EQUAL) { if (find_same_type(top_obj, objs[i])) { /* OBJTOP is strictly above an object of the same type as OBJ, so it * is above OBJ. */ top_obj = objs[i]; } } } /* Now peek all objects of the same type, build a level with that and * replace them with their children. */ /* First count them. */ n_taken_objs = 0; n_new_objs = 0; for (i = 0; i < n_objs; i++) if (topo_type_cmp(top_obj, objs[i]) == TOPO_TYPE_EQUAL) { n_taken_objs++; n_new_objs += objs[i]->arity; } /* New level. */ taken_objs = malloc((n_taken_objs + 1) * sizeof(taken_objs[0])); /* New list of pending objects. */ new_objs = malloc((n_objs - n_taken_objs + n_new_objs) * sizeof(new_objs[0])); taken_i = 0; new_i = 0; for (i = 0; i < n_objs; i++) if (topo_type_cmp(top_obj, objs[i]) == TOPO_TYPE_EQUAL) { /* Take it, add children. */ taken_objs[taken_i++] = objs[i]; for (j = 0; j < objs[i]->arity; j++) new_objs[new_i++] = objs[i]->children[j]; } else /* Leave it. */ new_objs[new_i++] = objs[i]; /* Make sure we didn't mess up. */ assert(taken_i == n_taken_objs); assert(new_i == n_objs - n_taken_objs + n_new_objs); /* Ok, put numbers in the level. */ for (i = 0; i < n_taken_objs; i++) { taken_objs[i]->depth = topology->nb_levels; taken_objs[i]->logical_index = i; if (i) { taken_objs[i]->prev_cousin = taken_objs[i-1]; taken_objs[i-1]->next_cousin = taken_objs[i]; } } /* One more level! */ if (top_obj->type == TOPO_OBJ_CACHE) topo_debug("--- cache level depth %d", top_obj->attr->cache.depth); else topo_debug("--- %s level", topo_obj_type_string(top_obj->type)); topo_debug(" has number %d\n\n", topology->nb_levels); if (topology->type_depth[top_obj->type] == TOPO_TYPE_DEPTH_UNKNOWN) topology->type_depth[top_obj->type] = topology->nb_levels; else topology->type_depth[top_obj->type] = TOPO_TYPE_DEPTH_MULTIPLE; /* mark as unknown */ taken_objs[n_taken_objs] = NULL; topology->level_nbobjects[topology->nb_levels] = n_taken_objs; topology->levels[topology->nb_levels] = taken_objs; topology->nb_levels++; free(objs); objs = new_objs; n_objs = new_i; } /* It's empty now. */ free(objs); }