void had_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { if (log_level & G_LOG_LEVEL_DEBUG) { if (log_domain) { verbose_printf(9,"%s-Debug: %s\n",log_domain,message); } else { verbose_printf(9,"Debug: %s\n",message); } } else { if (log_domain) { verbose_printf(0,"%s-Message: %s\n",log_domain,message); } else { verbose_printf(0,"Message: %s\n",message); } } }
/* Mark the end of a region */ static void stop(void *fdt) { expect[expect_count].size = fdt_size_dt_struct(fdt) - expect[expect_count].offset; expect[expect_count].offset += fdt_off_dt_struct(fdt); verbose_printf("%x]\n", expect[expect_count].offset + expect[expect_count].size); expect_count++; }
ktap_eventdef_info *ktapc_parse_eventdef(const char *eventdef) { char *str = strdup(eventdef); char *sys, *event, *filter, *next; ktap_eventdef_info *evdef_info; int ret; idmap_init(); parse_next_eventdef: next = get_next_eventdef(str); if (get_sys_event_filter_str(str, &sys, &event, &filter)) goto error; verbose_printf("parse_eventdef: sys[%s], event[%s], filter[%s]\n", sys, event, filter); if (!strcmp(sys, "probe")) ret = parse_events_add_probe(event); else if (!strcmp(sys, "sdt")) ret = parse_events_add_sdt(event); else ret = parse_events_add_tracepoint(sys, event); if (ret) goto error; /* don't trace ftrace:function when all tracepoints enabled */ if (!strcmp(sys, "*")) idmap_clear(1); if (filter && *next != '\0') { fprintf(stderr, "Error: eventdef only can append one filter\n"); goto error; } str = next; if (*next != '\0') goto parse_next_eventdef; evdef_info = malloc(sizeof(*evdef_info)); if (!evdef_info) goto error; evdef_info->nr = id_nr; evdef_info->id_arr = get_id_array(); evdef_info->filter = filter; idmap_free(); return evdef_info; error: idmap_free(); cleanup_event_resources(); return NULL; }
int main(int argc, char *argv[]) { void *fdt; int err; int offset, s1, s2; test_init(argc, argv); fdt = xmalloc(SPACE); /* First create empty tree with SW */ CHECK(fdt_create(fdt, SPACE)); CHECK(fdt_finish_reservemap(fdt)); CHECK(fdt_begin_node(fdt, "")); CHECK(fdt_end_node(fdt)); CHECK(fdt_finish(fdt)); verbose_printf("Built empty tree, totalsize = %d\n", fdt_totalsize(fdt)); CHECK(fdt_open_into(fdt, fdt, SPACE)); CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_1, TEST_SIZE_1)); CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2)); CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1")); CHECK(fdt_setprop_cell(fdt, 0, "prop-int", TEST_VALUE_1)); CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1)); OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1")); s1 = offset; CHECK(fdt_setprop_string(fdt, s1, "compatible", "subnode1")); CHECK(fdt_setprop_cell(fdt, s1, "prop-int", TEST_VALUE_1)); OFF_CHECK(offset, fdt_add_subnode(fdt, s1, "subsubnode")); CHECK(fdt_setprop(fdt, offset, "compatible", "subsubnode1\0subsubnode", 23)); CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1)); OFF_CHECK(offset, fdt_add_subnode(fdt, s1, "ss1")); OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2")); s2 = offset; CHECK(fdt_setprop_cell(fdt, s2, "linux,phandle", PHANDLE_1)); CHECK(fdt_setprop_cell(fdt, s2, "prop-int", TEST_VALUE_2)); OFF_CHECK(offset, fdt_add_subnode(fdt, s2, "subsubnode@0")); CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_2)); CHECK(fdt_setprop(fdt, offset, "compatible", "subsubnode2\0subsubnode", 23)); CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2)); OFF_CHECK(offset, fdt_add_subnode(fdt, s2, "ss2")); CHECK(fdt_pack(fdt)); save_blob("rw_tree1.test.dtb", fdt); PASS(); }
static void do_poke(pid_t pid, void *p) { long err; verbose_printf("Poking..."); err = ptrace(PTRACE_POKEDATA, pid, p, (void *)CONST); if (err) FAIL("ptrace(POKEDATA): %s", strerror(errno)); verbose_printf("done\n"); verbose_printf("Peeking..."); err = ptrace(PTRACE_PEEKDATA, pid, p, NULL); if (err == -1) FAIL("ptrace(PEEKDATA): %s", strerror(errno)); if (err != CONST) FAIL("mismatch (%lx instead of %lx)", err, CONST); verbose_printf("done\n"); }
void list_read_data_callback( void * callback_arg, globus_ftp_control_handle_t * handle, globus_object_t * error, globus_byte_t * buffer, globus_size_t length, globus_off_t offset, globus_bool_t eof) { get_put_info_t * get_put_info; get_put_info = (get_put_info_t *) callback_arg; if(error != GLOBUS_NULL) { verbose_printf(1, "unable to list files\n"); monitor.rc = GLOBUS_FALSE; signal_exit(); } buffer[length] = '\0'; verbose_printf(3, "%s", buffer); if (!eof) { globus_ftp_control_data_read( handle, get_put_info->buffer, get_put_info->buffer_size, list_read_data_callback, (void *) get_put_info); } else { verbose_printf(2, "we have eof\n"); globus_mutex_lock(&data_monitor.mutex); { data_monitor.done = GLOBUS_TRUE; globus_cond_signal(&data_monitor.cond); } globus_mutex_unlock(&data_monitor.mutex); } }
/** * check_regions() - Check that the regions are as we expect * * Call fdt_find_regions() and check that the results are as we expect them, * matching the list of expected regions we created at the same time as * the tree. * * @fdt: Pointer to device tree to check * @flags: Flags value (FDT_REG_...) * @return 0 if ok, -1 on failure */ static int check_regions(const void *fdt, int flags) { struct fdt_region_state state; struct fdt_region reg; int err, ret = 0; char path[1024]; int count; int i; ret = fdt_first_region(fdt, h_include, NULL, ®, path, sizeof(path), flags, &state); if (ret < 0) CHECK(ret); verbose_printf("Regions: %d\n", count); for (i = 0; ; i++) { struct fdt_region *exp = &expect[i]; verbose_printf("%d: %-10x %-10x\n", i, reg.offset, reg.offset + reg.size); if (memcmp(exp, ®, sizeof(reg))) { ret = -1; verbose_printf("exp: %-10x %-10x\n", exp->offset, exp->offset + exp->size); } ret = fdt_next_region(fdt, h_include, NULL, ®, path, sizeof(path), flags, &state); if (ret < 0) { if (ret == -FDT_ERR_NOTFOUND) ret = 0; CHECK(ret); i++; break; } } verbose_printf("expect_count = %d, i=%d\n", expect_count, i); if (expect_count != i) FAIL(); return ret; }
void run_test(char *desc, int base_nr) { verbose_printf("%s...\n", desc); set_nr_hugepages(base_nr); /* untouched, shared mmap */ map(SL_TEST, 1, MAP_SHARED); unmap(SL_TEST, 1, MAP_SHARED); /* untouched, private mmap */ map(SL_TEST, 1, MAP_PRIVATE); unmap(SL_TEST, 1, MAP_PRIVATE); /* touched, shared mmap */ map(SL_TEST, 1, MAP_SHARED); touch(SL_TEST, 1, MAP_SHARED); unmap(SL_TEST, 1, MAP_SHARED); /* touched, private mmap */ map(SL_TEST, 1, MAP_PRIVATE); touch(SL_TEST, 1, MAP_PRIVATE); unmap(SL_TEST, 1, MAP_PRIVATE); /* Explicit resizing during outstanding surplus */ /* Consume surplus when growing pool */ map(SL_TEST, 2, MAP_SHARED); set_nr_hugepages(max(base_nr, 1)); /* Add pages once surplus is consumed */ set_nr_hugepages(max(base_nr, 3)); /* Release free huge pages first */ set_nr_hugepages(max(base_nr, 2)); /* When shrinking beyond committed level, increase surplus */ set_nr_hugepages(base_nr); /* Upon releasing the reservation, reduce surplus counts */ unmap(SL_TEST, 2, MAP_SHARED); verbose_printf("OK.\n"); }
float modify_alpha(read_info *input_image, int ie_bug) { /* IE6 makes colors with even slightest transparency completely transparent, thus to improve situation in IE, make colors that are less than ~10% transparent completely opaque */ rgb_pixel **input_pixels = (rgb_pixel **)input_image->row_pointers; rgb_pixel *pP; int rows= input_image->height, cols = input_image->width; double gamma = input_image->gamma; float min_opaque_val, almost_opaque_val; if (ie_bug) { min_opaque_val = 238.0/256.0; /* rest of the code uses min_opaque_val rather than checking for ie_bug */ almost_opaque_val = min_opaque_val * 169.0/256.0; verbose_printf(" Working around IE6 bug by making image less transparent...\n"); } else { min_opaque_val = almost_opaque_val = 1; } for(int row = 0; row < rows; ++row) { pP = input_pixels[row]; for(int col = 0; col < cols; ++col, ++pP) { f_pixel px = to_f(gamma, *pP); #ifndef NDEBUG rgb_pixel rgbcheck = to_rgb(gamma, px); if (pP->a && (pP->r != rgbcheck.r || pP->g != rgbcheck.g || pP->b != rgbcheck.b || pP->a != rgbcheck.a)) { fprintf(stderr, "Conversion error: expected %d,%d,%d,%d got %d,%d,%d,%d\n", pP->r,pP->g,pP->b,pP->a, rgbcheck.r,rgbcheck.g,rgbcheck.b,rgbcheck.a); return -1; } #endif /* set all completely transparent colors to black */ if (!pP->a) { *pP = (rgb_pixel){0,0,0,pP->a}; } /* ie bug: to avoid visible step caused by forced opaqueness, linearily raise opaqueness of almost-opaque colors */ else if (pP->a < 255 && px.a > almost_opaque_val) { assert((min_opaque_val-almost_opaque_val)>0); float al = almost_opaque_val + (px.a-almost_opaque_val) * (1-almost_opaque_val) / (min_opaque_val-almost_opaque_val); if (al > 1) al = 1; px.a = al; pP->a = to_rgb(gamma, px).a; } } } return min_opaque_val; }
static void handler_kill(void *usr, uint16_t id, comms_channel_t channel, const uint8_t *msg, uint16_t len) { char lcm_channel[20]; snprintf(lcm_channel, 20, "KILL_%d_RX", id); verbose_printf("%s: ", lcm_channel); uint16_t i; for(i = 0; i < len; ++i) { verbose_printf("%x ", msg[i]); } verbose_printf("\n"); kill_t kill; memset(&kill, 0, sizeof(kill_t)); __kill_t_decode_array(msg, 0, len, &kill, 1); kill_t_publish(lcm, lcm_channel, &kill); kill_t_decode_cleanup(&kill); }
static void handler_channels(void *usr, uint16_t id, comms_channel_t channel, const uint8_t *msg, uint16_t len) { char lcm_channel[40]; snprintf(lcm_channel, 40, "CHANNELS_%d_RX", id); verbose_printf("%s: ", lcm_channel); uint16_t i; for(i = 0; i < len; ++i) { verbose_printf("%x ", msg[i]); } verbose_printf("\n"); channels_t channels; memset(&channels, 0, sizeof(channels_t)); __channels_t_decode_array(msg, 0, len, &channels, 1); channels_t_publish(lcm, lcm_channel, &channels); __channels_t_decode_array_cleanup(&channels, 1); }
static void handler_cfg_usb_serial_num(void *usr, uint16_t id, comms_channel_t channel, const uint8_t *msg, uint16_t len) { char lcm_channel[40]; snprintf(lcm_channel, 40, "CFG_USB_SERIAL_NUM_%d_RX", id); verbose_printf("%s: ", lcm_channel); uint16_t i; for(i = 0; i < len; ++i) { verbose_printf("%x ", msg[i]); } verbose_printf("\n"); cfg_usb_serial_num_t cfg_usb_serial_num; memset(&cfg_usb_serial_num, 0, sizeof(cfg_usb_serial_num_t)); __cfg_usb_serial_num_t_decode_array(msg, 0, len, &cfg_usb_serial_num, 1); cfg_usb_serial_num_t_publish(lcm, lcm_channel, &cfg_usb_serial_num); __cfg_usb_serial_num_t_decode_array_cleanup(&cfg_usb_serial_num, 1); }
static void handler_cfg_data_frequency(void *usr, uint16_t id, comms_channel_t channel, const uint8_t *msg, uint16_t len) { char lcm_channel[40]; snprintf(lcm_channel, 40, "CFG_DATA_FREQUENCY_%d_RX", id); verbose_printf("%s: ", lcm_channel); uint16_t i; for(i = 0; i < len; ++i) { verbose_printf("%x ", msg[i]); } verbose_printf("\n"); cfg_data_frequency_t cfg_data_frequency; memset(&cfg_data_frequency, 0, sizeof(cfg_data_frequency_t)); __cfg_data_frequency_t_decode_array(msg, 0, len, &cfg_data_frequency, 1); cfg_data_frequency_t_publish(lcm, lcm_channel, &cfg_data_frequency); __cfg_data_frequency_t_decode_array_cleanup(&cfg_data_frequency, 1); }
void init_slice_boundary(int fd) { unsigned long slice_size; void *p, *heap; int i, rc; #if defined(__LP64__) && !defined(__aarch64__) /* powerpc: 1TB slices starting at 1 TB */ slice_boundary = 0x10000000000; slice_size = 0x10000000000; #else /* powerpc: 256MB slices up to 4GB */ slice_boundary = 0x00000000; slice_size = 0x10000000; #endif /* dummy malloc so we know where is heap */ heap = malloc(1); free(heap); /* Find 2 neighbour slices with couple huge pages free * around slice boundary. * 16 is the maximum number of slices (low/high) */ for (i = 0; i < 16-1; i++) { slice_boundary += slice_size; p = mmap((void *)(slice_boundary-2*hpage_size), 4*hpage_size, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0); if (p == MAP_FAILED) { verbose_printf("can't use slice_boundary: 0x%lx\n", slice_boundary); } else { rc = munmap(p, 4*hpage_size); if (rc != 0) FAIL("munmap(p1): %s", strerror(errno)); break; } } if (p == MAP_FAILED) FAIL("couldn't find 2 free neighbour slices"); verbose_printf("using slice_boundary: 0x%lx\n", slice_boundary); }
static void sig_handler(int signum, siginfo_t *si, void *uc) { if (signum == SIGSEGV) { verbose_printf("SIGSEGV at %p (sig_expected=%p)\n", si->si_addr, sig_expected); if (si->si_addr == sig_expected) { siglongjmp(sig_escape, 1); } FAIL("SIGSEGV somewhere unexpected"); } FAIL("Unexpected signal %s", strsignal(signum)); }
void signal_exit() { verbose_printf(2, "signal_exit() : start\n"); globus_mutex_lock(&monitor.mutex); { monitor.done = GLOBUS_TRUE; monitor.count++; globus_cond_signal(&monitor.cond); } globus_mutex_unlock(&monitor.mutex); }
int drawdd_init(win_draw_callbacks *callbacks) { // dynamically grab the create function from ddraw.dll dllhandle = LoadLibrary(TEXT("ddraw.dll")); if (dllhandle == NULL) { verbose_printf("DirectDraw: Unable to access ddraw.dll\n"); return 1; } // import the create function directdrawcreateex = (directdrawcreateex_ptr)GetProcAddress(dllhandle, "DirectDrawCreateEx"); if (directdrawcreateex == NULL) { verbose_printf("DirectDraw: Unable to find DirectDrawCreateEx\n"); FreeLibrary(dllhandle); dllhandle = NULL; return 1; } // import the enumerate function directdrawenumerateex = (directdrawenumerateex_ptr)GetProcAddress(dllhandle, "DirectDrawEnumerateExA"); if (directdrawenumerateex == NULL) { verbose_printf("DirectDraw: Unable to find DirectDrawEnumerateExA\n"); FreeLibrary(dllhandle); dllhandle = NULL; return 1; } // fill in the callbacks callbacks->exit = drawdd_exit; callbacks->window_init = drawdd_window_init; callbacks->window_get_primitives = drawdd_window_get_primitives; callbacks->window_draw = drawdd_window_draw; callbacks->window_destroy = drawdd_window_destroy; verbose_printf("DirectDraw: Using DirectDraw 7\n"); return 0; }
static void pick_best_mode(win_window_info *window) { dd_info *dd = window->drawdata; mode_enum_info einfo; HRESULT result; // determine the minimum width/height for the selected target // note: technically we should not be calling this from an alternate window // thread; however, it is only done during init time, and the init code on // the main thread is waiting for us to finish, so it is safe to do so here render_target_get_minimum_size(window->target, &einfo.minimum_width, &einfo.minimum_height); // use those as the target for now einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale); einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale); // if we're not stretching, allow some slop on the minimum since we can handle it if (!video_config.hwstretch) { einfo.minimum_width -= 4; einfo.minimum_height -= 4; } // if we are stretching, aim for a mode approximately 2x the game's resolution else if (video_config.prescale <= 1) { einfo.target_width *= 2; einfo.target_height *= 2; } // fill in the rest of the data einfo.window = window; einfo.best_score = 0.0f; // enumerate the modes verbose_printf("DirectDraw: Selecting video mode...\n"); result = IDirectDraw7_EnumDisplayModes(dd->ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback); if (result != DD_OK) verbose_printf("DirectDraw: Error %08X during EnumDisplayModes call\n", (int)result); verbose_printf("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", dd->width, dd->height, dd->refresh); }
void sort_palette(write_info *output_image, colormap *map) { assert(map); assert(output_image); /* ** Step 3.5 [GRR]: remap the palette colors so that all entries with ** the maximal alpha value (i.e., fully opaque) are at the end and can ** therefore be omitted from the tRNS chunk. */ verbose_printf(" eliminating opaque tRNS-chunk entries..."); /* move transparent colors to the beginning to shrink trns chunk */ int num_transparent=0; for(int i=0; i < map->colors; i++) { rgb_pixel px = to_rgb(output_image->gamma, map->palette[i].acolor); if (px.a != 255) { if (i != num_transparent) { colormap_item tmp = map->palette[num_transparent]; map->palette[num_transparent] = map->palette[i]; map->palette[i] = tmp; i--; } num_transparent++; } } verbose_printf("%d entr%s transparent\n", num_transparent, (num_transparent == 1)? "y" : "ies"); /* colors sorted by popularity make pngs slightly more compressible * opaque and transparent are sorted separately */ qsort(map->palette, num_transparent, sizeof(map->palette[0]), compare_popularity); qsort(map->palette+num_transparent, map->colors-num_transparent, sizeof(map->palette[0]), compare_popularity); output_image->num_palette = map->colors; output_image->num_trans = num_transparent; }
int main(int argc, char *argv[]) { int err; int fd; void *p; test_init(argc, argv); struct sigaction sa = { .sa_sigaction = sig_handler, .sa_flags = SA_SIGINFO, }; err = sigaction(SIGSEGV, &sa, NULL); if (err) FAIL("Can't install SIGSEGV handler: %s", strerror(errno)); hpage_size = check_hugepagesize(); fd = hugetlbfs_unlinked_fd(); if (fd < 0) FAIL("hugetlbfs_unlinked_fd()"); verbose_printf("instantiating page\n"); p = mmap(NULL, 2*hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (p == MAP_FAILED) FAIL("mmap(): %s", strerror(errno)); memset(p, 0, hpage_size); munmap(p, hpage_size); /* Basic protection change tests */ test_mprotect(fd, "R->RW", hpage_size, PROT_READ, hpage_size, PROT_READ|PROT_WRITE); test_mprotect(fd, "RW->R", hpage_size, PROT_READ|PROT_WRITE, hpage_size, PROT_READ); /* Tests which require VMA splitting */ test_mprotect(fd, "R->RW 1/2", 2*hpage_size, PROT_READ, hpage_size, PROT_READ|PROT_WRITE); test_mprotect(fd, "RW->R 1/2", 2*hpage_size, PROT_READ|PROT_WRITE, hpage_size, PROT_READ); /* PROT_NONE tests */ test_mprotect(fd, "NONE->R", hpage_size, PROT_NONE, hpage_size, PROT_READ); test_mprotect(fd, "NONE->RW", hpage_size, PROT_NONE, hpage_size, PROT_READ|PROT_WRITE); PASS(); }
void authenticate_callback( void * callback_arg, globus_ftp_control_handle_t * handle, globus_object_t * error, globus_ftp_control_response_t * ftp_response) { globus_result_t result; if(error != GLOBUS_NULL) { verbose_printf(1, "Error : %s\n", globus_object_printable_to_string(error)); exit(1); } if (ftp_response->code == 230) { verbose_printf(2, "%s\n", ftp_response->response_buffer); result = globus_ftp_control_send_command( handle, "PWD\r\n", send_command_callback, GLOBUS_NULL); if (result != GLOBUS_SUCCESS) { verbose_printf(1, "send_command PWD failed\n"); exit(1); } } else { verbose_printf(1, "Error : %s\n", ftp_response->response_buffer); exit(1); } }
static void check_path_offset(void *fdt, char *path, int offset) { int rc; verbose_printf("Checking offset of \"%s\" is %d...\n", path, offset); rc = fdt_path_offset(fdt, path); if (rc < 0) FAIL("fdt_path_offset(\"%s\") failed: %s", path, fdt_strerror(rc)); if (rc != offset) FAIL("fdt_path_offset(\"%s\") returned incorrect offset" " %d instead of %d", path, rc, offset); }
static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) { float size_score, refresh_score, final_score; mode_enum_info *einfo = context; dd_info *dd = einfo->window->drawdata; // skip non-32 bit modes if (desc->ddpfPixelFormat.dwRGBBitCount != 32) return DDENUMRET_OK; // compute initial score based on difference between target and current size_score = 1.0f / (1.0f + fabs((INT32)desc->dwWidth - einfo->target_width) + fabs((INT32)desc->dwHeight - einfo->target_height)); // if the mode is too small, give a big penalty if (desc->dwWidth < einfo->minimum_width || desc->dwHeight < einfo->minimum_height) size_score *= 0.01f; // if mode is smaller than we'd like, it only scores up to 0.1 if (desc->dwWidth < einfo->target_width || desc->dwHeight < einfo->target_height) size_score *= 0.1f; // if we're looking for a particular mode, that's a winner if (desc->dwWidth == einfo->window->maxwidth && desc->dwHeight == einfo->window->maxheight) size_score = 2.0f; // compute refresh score refresh_score = 1.0f / (1.0f + fabs((double)desc->dwRefreshRate - Machine->screen[0].refresh)); // if refresh is smaller than we'd like, it only scores up to 0.1 if ((double)desc->dwRefreshRate < Machine->screen[0].refresh) refresh_score *= 0.1; // if we're looking for a particular refresh, make sure it matches if (desc->dwRefreshRate == einfo->window->refresh) refresh_score = 2.0f; // weight size and refresh equally final_score = size_score + refresh_score; // best so far? verbose_printf(" %4dx%4d@%3dHz -> %f\n", (int)desc->dwWidth, (int)desc->dwHeight, (int)desc->dwRefreshRate, final_score * 1000.0f); if (final_score > einfo->best_score) { einfo->best_score = final_score; dd->width = desc->dwWidth; dd->height = desc->dwHeight; dd->refresh = desc->dwRefreshRate; } return DDENUMRET_OK; }
int main(int argc, char ** argv) { int base_nr; test_init(argc, argv); hpage_size = check_hugepagesize(); saved_nr_hugepages = get_huge_page_counter(hpage_size, HUGEPAGES_TOTAL); verify_dynamic_pool_support(); check_must_be_root(); if ((private_resv = kernel_has_private_reservations()) == -1) FAIL("kernel_has_private_reservations() failed\n"); /* * This test case should require a maximum of 3 huge pages. * Run through the battery of tests multiple times, with an increasing * base pool size. This alters the circumstances under which surplus * pages need to be allocated and increases the corner cases tested. */ for (base_nr = 0; base_nr <= 3; base_nr++) { verbose_printf("Base pool size: %i\n", base_nr); /* Run the tests with a clean slate */ run_test("Clean", base_nr); /* Now with a pre-existing untouched, shared mmap */ map(SL_SETUP, 1, MAP_SHARED); run_test("Untouched, shared", base_nr); unmap(SL_SETUP, 1, MAP_SHARED); /* Now with a pre-existing untouched, private mmap */ map(SL_SETUP, 1, MAP_PRIVATE); run_test("Untouched, private", base_nr); unmap(SL_SETUP, 1, MAP_PRIVATE); /* Now with a pre-existing touched, shared mmap */ map(SL_SETUP, 1, MAP_SHARED); touch(SL_SETUP, 1, MAP_SHARED); run_test("Touched, shared", base_nr); unmap(SL_SETUP, 1, MAP_SHARED); /* Now with a pre-existing touched, private mmap */ map(SL_SETUP, 1, MAP_PRIVATE); touch(SL_SETUP, 1, MAP_PRIVATE); run_test("Touched, private", base_nr); unmap(SL_SETUP, 1, MAP_PRIVATE); } PASS(); }
static void handler_cfg_data_frequency_lcm(const lcm_recv_buf_t *rbuf, const char *channel, const cfg_data_frequency_t *msg, void *user) { uint8_t id = parse_id(channel); verbose_printf("Received msg on lcm channel %s with id %d\n", channel, id); uint32_t maxlen = __cfg_data_frequency_t_encoded_array_size(msg, 1); uint8_t *buf = (uint8_t *) malloc(sizeof(uint8_t) * maxlen); uint32_t len = __cfg_data_frequency_t_encode_array(buf, 0, maxlen, msg, 1); if(usb) comms_publish_id( usb_comms, id, CHANNEL_CFG_DATA_FREQUENCY, buf, 0, len); if(xbee) comms_publish_id(xbee_comms, id, CHANNEL_CFG_DATA_FREQUENCY, buf, 0, len); if(loopback_mode) handler_cfg_data_frequency(NULL, id, CHANNEL_CFG_DATA_FREQUENCY, buf, len); free(buf); }
static int ddraw_verify_caps(dd_info *dd) { int retval = 0; HRESULT result; // get the capabilities dd->ddcaps.dwSize = sizeof(dd->ddcaps); dd->helcaps.dwSize = sizeof(dd->helcaps); result = IDirectDraw7_GetCaps(dd->ddraw, &dd->ddcaps, &dd->helcaps); if (result != DD_OK) { verbose_printf("DirectDraw: Error %08X during IDirectDraw7_GetCaps call\n", (int)result); return 1; } // determine if hardware stretching is available if ((dd->ddcaps.dwCaps & DDCAPS_BLTSTRETCH) == 0) { verbose_printf("DirectDraw: Warning - Device does not support hardware stretching\n"); retval = 1; } return retval; }
void quit_callback( void * callback_arg, globus_ftp_control_handle_t * handle, globus_object_t * error, globus_ftp_control_response_t * ftp_response) { if (ftp_response->code == 221) { verbose_printf(2, "%s\n", ftp_response->response_buffer); globus_mutex_lock(&end_mutex); { end_done = GLOBUS_TRUE; globus_cond_signal(&end_cond); } globus_mutex_unlock(&end_mutex); } else { verbose_printf(1,"Error : %s\n", ftp_response->response_buffer); exit(1); } }
static int child_process(char *self, int index) { int i; ino_t ino; get_link_string(self); shmid = shmget(SHM_KEY, NUM_CHILDREN * NUM_TESTS * sizeof(ino_t), 0666); if (shmid < 0) { verbose_printf("Child's shmget failed: %s", strerror(errno)); exit(RC_FAIL); } shm = shmat(shmid, NULL, 0); if (shm == (void *)-1) { verbose_printf("Child's shmat failed: %s", strerror(errno)); exit(RC_FAIL); } for (i = 0; i < NUM_TESTS; i++) { if (!test_addr_huge(testtab + i)) { /* don't care about non-huge addresses */ shm[index * NUM_TESTS + i] = 0; } else { ino = do_test(testtab + i); if ((int)ino < 0) { shmdt(shm); exit(RC_FAIL); } shm[index * NUM_TESTS + i] = ino; } } shmdt(shm); return 0; }
static void verify_inodes() { int i, j; for (i = 0; i < NUM_TESTS; i++) { ino_t base = shm[i]; for (j = 1; j < NUM_CHILDREN; j++) { ino_t comp = shm[j * NUM_TESTS + i]; if (base != comp) { /* * we care if we mismatch if * sharing only read-only * segments and this is one */ if (sharing == 1 && testtab[i].writable == 0) { shmctl(shmid, IPC_RMID, NULL); shmdt(shm); FAIL("Inodes do not match " "(%u != %u)", (int)base, (int)comp); } } else { /* * we care if we match if * a) not remapping or * b) not sharing or * c) sharing only read-only * segments and this is not one * BUT only if the inode is not * 0 (don't care about the file) */ if (base == 0) continue; if (elfmap_off == 1 || sharing == 0 || (sharing == 1 && testtab[i].writable == 1)) { shmctl(shmid, IPC_RMID, NULL); shmdt(shm); if (sharing == 1 && testtab[i].writable == 1) verbose_printf("Incorrectly sharing a writable segment...\n"); FAIL("Inodes match, but we should not be " "sharing this segment (%d == %d)", (int)base, (int)comp); } } } } }
void do_readback(void *p, size_t size, const char *stage) { unsigned int *q = p; int i; verbose_printf("do_readback(%p, 0x%lx, \"%s\")\n", p, (unsigned long)size, stage); for (i = 0; i < (size / sizeof(*q)); i++) { q[i] = RANDOM_CONSTANT ^ i; } for (i = 0; i < (size / sizeof(*q)); i++) { if (q[i] != (RANDOM_CONSTANT ^ i)) FAIL("Stage \"%s\": Mismatch at offset 0x%x: 0x%x instead of 0x%x", stage, i, q[i], RANDOM_CONSTANT ^ i); } }