Пример #1
0
void add_provider(struct dnet_node *n, stat_provider *provider, const std::string &name) {
	auto real_monitor = get_monitor(n);
	if (real_monitor)
		real_monitor->get_statistics().add_provider(provider, name);
	else
		delete provider;
}
Пример #2
0
/* Monitor wait begins for a thread. */
void Agent::monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
             jthread thread, jobject object, jlong timeout)
{
    get_monitor(jvmti, env, object)->waited();
    get_thread(jvmti, env, thread)->
                monitor_wait(jvmti, env, thread, object, timeout);
}
Пример #3
0
/* Monitor contention begins for a thread. */
void Agent::monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
             jthread thread, jobject object)
{
    get_monitor(jvmti, env, object)->contended();
    get_thread(jvmti, env, thread)->
                monitor_contended_enter(jvmti, env, thread, object);
}
Пример #4
0
/* Monitor wait ends for a thread. */
void Agent::monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
               jthread thread, jobject object, jboolean timed_out)
{
    if ( timed_out ) {
        get_monitor(jvmti, env, object)->timeout();
    }
    get_thread(jvmti, env, thread)->
                monitor_waited(jvmti, env, thread, object, timed_out);
}
Пример #5
0
/**
 * gdk_screen_get_monitor_plug_name:
 * @screen: a #GdkScreen
 * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
 *
 * Returns the output name of the specified monitor.
 * Usually something like VGA, DVI, or TV, not the actual
 * product name of the display device.
 *
 * Returns: (nullable): a newly-allocated string containing the name
 *   of the monitor, or %NULL if the name cannot be determined
 *
 * Since: 2.14
 */
gchar *
gdk_screen_get_monitor_plug_name (GdkScreen *screen,
                                  gint       monitor_num)
{
    GdkMonitor *monitor;

    g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);

    monitor = get_monitor (screen, monitor_num);

    g_return_val_if_fail (monitor != NULL, NULL);

    return g_strdup (gdk_monitor_get_model (monitor));
}
Пример #6
0
/**
 * gdk_screen_get_monitor_height_mm:
 * @screen: a #GdkScreen
 * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
 *
 * Gets the height in millimeters of the specified monitor.
 *
 * Returns: the height of the monitor, or -1 if not available
 *
 * Since: 2.14
 */
gint
gdk_screen_get_monitor_height_mm (GdkScreen *screen,
                                  gint       monitor_num)
{
    GdkMonitor *monitor;

    g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);

    monitor = get_monitor (screen, monitor_num);

    g_return_val_if_fail (monitor != NULL, -1);

    return gdk_monitor_get_height_mm (monitor);
}
Пример #7
0
int before_block_exec(CPUState *env, TranslationBlock *tb) {
    uint64_t count = rr_prog_point.guest_instr_count;
    if (!snipping && count+tb->num_guest_insns > start_count) {
        sassert((oldlog = fopen(rr_nondet_log->name, "r")));
        sassert(fread(&orig_last_prog_point, sizeof(RR_prog_point), 1, oldlog) == 1);
        printf("Original ending prog point: ");
        rr_spit_prog_point(orig_last_prog_point);

        actual_start_count = count;
        printf("Saving snapshot at instr count %lu...\n", count);
        do_savevm_rr(get_monitor(), snp_name);

        printf("Beginning cut-and-paste process at prog point:\n");
        rr_spit_prog_point(rr_prog_point);
        printf("Writing entries to %s...\n", nondet_name);
        newlog = fopen(nondet_name, "w");
        sassert(newlog);
        // We'll fix this up later.
        RR_prog_point prog_point = {0, 0, 0};
        fwrite(&prog_point, sizeof(RR_prog_point), 1, newlog);

        fseek(oldlog, ftell(rr_nondet_log->fp), SEEK_SET);

        RR_log_entry *item = rr_get_queue_head();
        while (item != NULL && item->header.prog_point.guest_instr_count < end_count) {
            write_entry(item);
            item = item->next;
        }
        while (prog_point.guest_instr_count < end_count && !feof(oldlog)) {
            prog_point = copy_entry();
        } 
        if (!feof(oldlog)) { // prog_point is the first one AFTER what we want
            printf("Reached end of old nondet log.\n");
        } else {
            printf("Past desired ending point for log.\n");
        }

        snipping = true;
        printf("Continuing with replay.\n");
    }

    if (snipping && !done && count > end_count) {
        end_snip();

        init_timer_alarm();
        rr_do_end_replay(0);
    }

    return 0;
}
Пример #8
0
/**
 * gdk_screen_get_monitor_geometry:
 * @screen: a #GdkScreen
 * @monitor_num: the monitor number
 * @dest: (out) (allow-none): a #GdkRectangle to be filled with
 *     the monitor geometry
 *
 * Retrieves the #GdkRectangle representing the size and position of
 * the individual monitor within the entire screen area. The returned
 * geometry is in ”application pixels”, not in ”device pixels” (see
 * gdk_screen_get_monitor_scale_factor()).
 *
 * Monitor numbers start at 0. To obtain the number of monitors of
 * @screen, use gdk_screen_get_n_monitors().
 *
 * Note that the size of the entire screen area can be retrieved via
 * gdk_screen_get_width() and gdk_screen_get_height().
 *
 * Since: 2.2
 */
void
gdk_screen_get_monitor_geometry (GdkScreen    *screen,
                                 gint          monitor_num,
                                 GdkRectangle *dest)
{
    GdkMonitor *monitor;

    g_return_if_fail (GDK_IS_SCREEN (screen));

    monitor = get_monitor (screen, monitor_num);

    g_return_if_fail (monitor != NULL);

    gdk_monitor_get_geometry (monitor, dest);
}
Пример #9
0
EXPORT bool device_get_duplicator_monitor_info(gs_device_t *device,
		int monitor_idx, struct gs_monitor_info *info)
{
	DXGI_OUTPUT_DESC desc;
	HRESULT hr;

	try {
		ComPtr<IDXGIOutput> output;

		if (!get_monitor(device, monitor_idx, output.Assign()))
			return false;

		hr = output->GetDesc(&desc);
		if (FAILED(hr))
			throw HRError("GetDesc failed", hr);

	} catch (HRError error) {
		blog(LOG_ERROR, "device_get_duplicator_monitor_info: "
		                "%s (%08lX)", error.str, error.hr);
		return false;
	}

	switch (desc.Rotation) {
	case DXGI_MODE_ROTATION_UNSPECIFIED:
	case DXGI_MODE_ROTATION_IDENTITY:
		info->rotation_degrees = 0;
		break;

	case DXGI_MODE_ROTATION_ROTATE90:
		info->rotation_degrees = 90;
		break;

	case DXGI_MODE_ROTATION_ROTATE180:
		info->rotation_degrees = 180;
		break;

	case DXGI_MODE_ROTATION_ROTATE270:
		info->rotation_degrees = 270;
		break;
	}

	info->x = desc.DesktopCoordinates.left;
	info->y = desc.DesktopCoordinates.top;
	info->cx = desc.DesktopCoordinates.right - info->x;
	info->cy = desc.DesktopCoordinates.bottom - info->y;

	return true;
}
Пример #10
0
void gs_duplicator::Start()
{
	ComPtr<IDXGIOutput1> output1;
	ComPtr<IDXGIOutput> output;
	HRESULT hr;

	if (!get_monitor(device, idx, output.Assign()))
		throw "Invalid monitor index";

	hr = output->QueryInterface(__uuidof(IDXGIOutput1),
			(void**)output1.Assign());
	if (FAILED(hr))
		throw HRError("Failed to query IDXGIOutput1", hr);

	hr = output1->DuplicateOutput(device->device, duplicator.Assign());
	if (FAILED(hr))
		throw HRError("Failed to duplicate output", hr);
}
Пример #11
0
static void init_top_provider(struct dnet_node *n, struct dnet_config *cfg) {
	try {
		bool top_loaded = false;
		const auto monitor = get_monitor(n);
		if (monitor) {
			auto top_stats = monitor->get_statistics().get_top_stats();
			if (top_stats) {
				add_provider(n, new top_provider(top_stats), "top");
				top_loaded = true;
			}
		}

		const auto monitor_cfg = get_monitor_config(n);
		if (top_loaded && monitor_cfg) {
			BH_LOG(*cfg->log, DNET_LOG_INFO, "monitor: top provider loaded: top length: %lu, events size: %lu, period: %d",
			       monitor_cfg->top_length, monitor_cfg->events_size, monitor_cfg->period_in_seconds);
		} else {
			BH_LOG(*cfg->log, DNET_LOG_INFO, "monitor: top provider is disabled");
		}

	} catch (const std::exception &e) {
		BH_LOG(*cfg->log, DNET_LOG_ERROR, "monitor: failed to initialize top_stat_provider: %s.", e.what());
	}
}
Пример #12
0
void remove_provider(dnet_node *n, const std::string &name)
{
	auto real_monitor = get_monitor(n);
	if (real_monitor)
		real_monitor->get_statistics().remove_provider(name);
}
Пример #13
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//snap_windows
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void snap_windows(WINDOWPOS *wp, bool sizing, int *content)
{
	int snapdist    = plugin_snap_dist;
	//int grid        = plugin_snap_usegrid ? plugin_snap_gridsize : 0;
	int padding     = plugin_snap_padding;

	if (snapdist < 1) return;
	// ------------------------------------------------------

	HWND self   = wp->hwnd;
	HWND parent = GetParent(self);

	struct edges h;
	struct edges v;
	struct snap_info si = { &h, &v, sizing, true, padding, self, parent };

	h.dmin = v.dmin = h.def = v.def = snapdist;

	h.from1 = wp->x;
	h.from2 = h.from1 + wp->cx;
	v.from1 = wp->y;
	v.from2 = v.from1 + wp->cy;


	// ------------------------------------------------------
	// snap to grid
	/*
	if (grid > 1 && (parent || sizing))
	{
		snap_to_grid(&h, &v, sizing, grid, padding);
	}
	//else
	*/
	{
		// -----------------------------------------
		if (parent)
		{
			// snap to siblings
			EnumChildWindows(parent, SnapEnumProc, (LPARAM)&si);

			// snap to frame edges
			RECT r;
			GetClientRect(parent, &r);
			h.to1 = r.left;
			h.to2 = r.right;
			v.to1 = r.top;
			v.to2 = r.bottom;
			snap_to_edge(&h, &v, sizing, false, padding);
		}
		else
		{
			// snap to top level windows
			EnumThreadWindows(GetCurrentThreadId(), SnapEnumProc, (LPARAM)&si);

			// snap to screen edges
			RECT r;
			get_mon_rect(get_monitor(self), &r);
			h.to1 = r.left;
			h.to2 = r.right;
			v.to1 = r.top;
			v.to2 = r.bottom;
			snap_to_edge(&h, &v, sizing, false, 0);
		}

		// -----------------------------------------
		if (sizing)
		{
			// snap to button icons
			if (content)
			{
				// images have to be double padded, since they are centered
				h.to2 = (h.to1 = h.from1) + content[0];
				v.to2 = (v.to1 = v.from1) + content[1];
				snap_to_edge(&h, &v, sizing, false, -2*padding);
			}

			// snap frame to childs
			si.same_level = false;
			si.pad = -padding;
			si.self = NULL;
			si.parent = self;
			EnumChildWindows(self, SnapEnumProc, (LPARAM)&si);
		}
	}

	// -----------------------------------------
	// adjust the window-pos

	if (h.dmin < snapdist)
		if (sizing) wp->cx += h.omin;
		else wp->x += h.omin;

	if (v.dmin < snapdist)
		if (sizing) wp->cy += v.omin;
		else wp->y += v.omin;
}
Пример #14
0
int main(int argc, char **argv)
{
	char *dev;
	int oldMonitor, newMonitor;
	u_char packet[4096];
	int pktlen;
	wiviz_cfg cfg;
	int i;
	int defaultHopSeq[] = { 1, 3, 6, 8, 11 };
	int s, one;
	memset(&cfg, 0, sizeof(cfg));
#ifdef HAVE_RT2880
	wl_dev = "ra0";
#elif HAVE_MADWIFI
	wl_dev = nvram_safe_get("wifi_display");
#else
	char tmp[32];
	sprintf(tmp, "%s_ifname", nvram_safe_get("wifi_display"));
	wl_dev = nvram_safe_get(tmp);
#endif
	if (argc > 1)
		if (!strcmp(argv[1], "terminate")) {
#ifdef HAVE_MADWIFI
			// return to original channel
#ifdef HAVE_ATH9K
			if (!is_ath9k(wl_dev))
#endif
			{
				sysprintf("iwconfig %s channel %sM", get_monitor(), nvram_nget("%s_channel", nvram_safe_get("wifi_display")));
				sleep(1);
				sysprintf("ifconfig %s down", get_monitor());
				if (is_ar5008(nvram_safe_get("wifi_display"))) {
					sysprintf("80211n_wlanconfig %s destroy", get_monitor());
				} else {
					sysprintf("wlanconfig %s destroy", get_monitor());
				}
			}
#elif HAVE_RT2880
			nvram_set("wl0_mode", nvram_safe_get("wl0_oldmode"));
			sysprintf("startservice configurewifi");
			if (nvram_match("wl0_mode", "sta") || nvram_match("wl0_mode", "apsta")) {
				sysprintf("startstop wan");
			}
#else
			oldMonitor = 0;
			wl_ioctl(wl_dev, WLC_SET_MONITOR, &oldMonitor, 4);
#endif
			return 0;
		}

	global_cfg = &cfg;
	signal(SIGUSR1, &signal_handler);
	signal(SIGUSR2, &signal_handler);

	printf("Wi-Viz 2 infogathering daemon by Nathan True\n");
	printf("http://wiviz.natetrue.com\n");

	memset(&cfg, 0, sizeof(wiviz_cfg));
	cfg.numHosts = 0;
	cfg.lastKeepAlive = time(NULL);
	cfg.channelHopping = 0;
	cfg.channelDwellTime = 1000;
	cfg.channelHopSeqLen = 5;
	memcpy(cfg.channelHopSeq, defaultHopSeq, sizeof(defaultHopSeq));

#if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880)
	wl_ioctl(wl_dev, WLC_GET_MAGIC, &i, 4);
	if (i != WLC_IOCTL_MAGIC) {
		printf("Wireless magic not correct, not querying wl for info %X!=%X\n", i, WLC_IOCTL_MAGIC);
		cfg.readFromWl = 0;
	} else {
		cfg.readFromWl = 1;
		wl_ioctl(wl_dev, WLC_GET_MONITOR, &oldMonitor, 4);
		newMonitor = 1;
		wl_ioctl(wl_dev, WLC_SET_MONITOR, &newMonitor, 4);
	}

#elif HAVE_RT2880
	nvram_set("wl0_oldmode", nvram_safe_get("wl0_mode"));
	nvram_set("wl0_mode", "sta");
	if (!nvram_match("wl0_oldmode", "sta"))
		sysprintf("startservice configurewifi");
	sysprintf("iwconfig ra0 mode monitor");
	cfg.readFromWl = 1;
#else
#ifdef HAVE_ATH9K
	if (!is_ath9k(nvram_safe_get("wifi_display")))
#endif
	{
		if (is_ar5008(nvram_safe_get("wifi_display"))) {
			sysprintf("80211n_wlanconfig %s create wlandev %s wlanmode monitor", get_monitor(), getWifi(nvram_safe_get("wifi_display")));
		} else {
			sysprintf("wlanconfig %s create wlandev %s wlanmode monitor", get_monitor(), getWifi(nvram_safe_get("wifi_display")));
		}
		sysprintf("ifconfig %s up", get_monitor());
	}
	cfg.readFromWl = 1;
#endif
	reloadConfig();

#if defined(HAVE_MADWIFI) || defined(HAVE_RT2880)
	s = openMonitorSocket(get_monitor());	// for testing we use ath0
#else

	if (nvram_match("wifi_display", "wl1"))
		s = openMonitorSocket("prism1");
	else
		s = openMonitorSocket("prism0");
#endif
	if (s == -1)
		return;
	one = 1;
	ioctl(s, FIONBIO, (char *)&one);

	if (cfg.readFromWl) {
		readWL(&cfg);
	}
#ifdef WIVIZ_GPS
	gps_init(&cfg);
#endif

	while (!stop) {
#ifdef WIVIZ_GPS
		gps_tick();
#else
		if (time(NULL) - cfg.lastKeepAlive > 30)
			stop = 1;
#endif
		pktlen = recv(s, packet, 4096, 0);
		if (pktlen <= 0)
			continue;
		dealWithPacket(&cfg, pktlen, packet);
	}

	signal_handler(SIGUSR1);

	if (cfg.channelHopperPID)
		kill(cfg.channelHopperPID, SIGKILL);

#ifndef WIVIZ_GPS
	for (i = 0; i < MAX_HOSTS; i++) {
		print_host(stderr, cfg.hosts + i);
		if (cfg.hosts[i].occupied)
			printf("\n");
		if (cfg.hosts[i].apInfo)
			free(cfg.hosts[i].apInfo);
		if (cfg.hosts[i].staInfo)
			free(cfg.hosts[i].staInfo);
	}
#endif
	close(s);
	return 0;
}