void print_map(t_info *s) { t_point p1; t_point p2; while (s->y < s->x_lines) { while (s->x < s->y_lines) { p1 = calcul(s->x, s->y, s->tab[s->y][s->x], s); s->x++; init_color(s, s->tab[s->y][s->x]); if (s->x < s->y_lines) { p2 = calcul(s->x, s->y, s->tab[s->y][s->x], s); print_trace(p1, p2, s); } if (s->y < s->x_lines - 1) { p2 = calcul(s->x - 1, s->y + 1, s->tab[s->y + 1][s->x - 1], s); print_trace(p1, p2, s); } } s->x = 0; s->y++; } }
void rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer, void *ptr_data) { struct rte_keepalive *keepcfg = ptr_data; int idx_core; for (idx_core = 0; idx_core < RTE_KEEPALIVE_MAXCORES; idx_core++) { if (keepcfg->active_cores[idx_core] == 0) continue; switch (keepcfg->state_flags[idx_core]) { case ALIVE: /* Alive */ keepcfg->state_flags[idx_core] = MISSING; keepcfg->last_alive[idx_core] = rte_rdtsc(); break; case MISSING: /* MIA */ print_trace("Core MIA. ", keepcfg, idx_core); keepcfg->state_flags[idx_core] = DEAD; break; case DEAD: /* Dead */ keepcfg->state_flags[idx_core] = GONE; print_trace("Core died. ", keepcfg, idx_core); if (keepcfg->callback) keepcfg->callback( keepcfg->callback_data, idx_core ); break; case GONE: /* Buried */ break; } } }
static pset_family do_minimize(pset_family F, pset_family D, pset_family R, int exact_cover, int weighted) { pset_family newF, E, Rt, Rp; pset p, last; int heur, level, *weights; sm_matrix *table; sm_row *cover; sm_element *pe; int debug_save = debug; if (debug & 0x0400) { debug |= (0x0020 | 0x0800); } if (debug & 0x0800) { setlinebuf((&_iob[1])); } level = (debug & 0x0800) ? 4 : 0; heur = ! exact_cover; {long t=util_cpu_time();F = primes_consensus(cube2list(F, D));if(trace)print_trace( F, "PRIMES ",util_cpu_time()-t);}; {long t=util_cpu_time();irred_split_cover(F, D, &E, &Rt, &Rp);if(trace)print_trace( E, "ESSENTIALS ",util_cpu_time()-t);}; {long t=util_cpu_time();table = irred_derive_table(D, E, Rp);if(trace)print_trace( Rp, "PI-TABLE ",util_cpu_time()-t);}; if (weighted) { weights = ((int *) malloc(sizeof(int) * ( F->count))); for( p=Rp->data, last= p+Rp->count*Rp->wsize; p< last; p+=Rp->wsize) { weights[(p[0] >> 16)] = cube.size - set_ord(p); } } else {
// RFU (Reserved for Future Use) : the only information available yet is the LE_Encryption... int8_t hci_LE_read_local_supported_features(hci_socket_t *hci_socket, hci_controller_t *hci_controller, uint8_t *features) { //p1056 char new_socket = 0; CHECK_HCI_CONTROLLER_PTR(hci_controller, "hci_LE_read_local_supported_features"); CHECK_HCI_CONTROLLER_INTERRUPTED(hci_controller, hci_socket); CHECK_HCI_CONTROLLER_OPEN(hci_controller, "hci_LE_read_local_supported_features"); if (!features) { print_trace(TRACE_ERROR, "hci_LE_read_local_supported_features : invalid reference.\n"); goto fail; } struct hci_request rq; memset(&rq, 0, sizeof(rq)); le_read_local_supported_features_rp rp; memset(&rp, 0, sizeof(rp)); rq.ogf = OGF_LE_CTL; rq.ocf = OCF_LE_READ_LOCAL_SUPPORTED_FEATURES; rq.rparam = &rp; rq.rlen = LE_READ_LOCAL_SUPPORTED_FEATURES_RP_SIZE; char socket_err = 0; check_hci_socket_ptr(&hci_socket, hci_controller, &new_socket, &socket_err); if (socket_err) { goto fail; } hci_change_state(hci_controller, HCI_STATE_READING); if (hci_send_req(hci_socket->sock, &rq, HCI_CONTROLLER_DEFAULT_TIMEOUT) < 0) { perror("hci_LE_read_local_supported_features"); goto fail; } hci_change_state(hci_controller, HCI_STATE_OPEN); if (rp.status) { print_trace(TRACE_ERROR, "hci_LE_read_supported_features : 0x%X\n", rp.status); goto fail; } memcpy(features, rp.features, 8); if (new_socket) { close_hci_socket(hci_socket); free(hci_socket); } return 0; fail: hci_change_state(hci_controller, HCI_STATE_OPEN); if (new_socket) { hci_close_socket_controller(hci_controller, hci_socket); } return -1; }
ssize_t writev(int fd, const struct iovec *vector, int count) { ssize_t retval; #ifdef X_BUF print_trace ("%*swritev(%d, {", indent, "", fd); for (int i=0; i<count; i++) { print_msg ("{\"%s\", %d}%s", vector[i].iov_base, vector[i].iov_len, i==count-1 ? "" : ", "); } print_msg ("}, %d)=...\n", count); #else print_trace ("%*swritev(%d, %p, %d)=...\n", indent, "", fd, vector, count); #endif indent+=2; /* call the real writev function */ retval = real_writev (fd, vector, count); indent-=2; print_trace ("%*swritev(%d, %p, %d)=%d\n", indent, "", fd, vector, count, retval); return retval; }
int8_t l2cap_client_send(l2cap_client_t *client, int16_t timeout, uint8_t req_type) { if (!client) { print_trace(TRACE_ERROR, "l2cap_client_send : invalid client.\n"); return -1; } if (client->connected) { memset(client->buffer, 0, strlen(client->buffer)); client->send_request(*client, req_type); int8_t n = 0; int8_t bytes_read; struct pollfd p; p.fd = client->l2cap_socket.sock; p.events = POLLIN; while ((n = poll(&p, 1, timeout)) < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } if (errno == ENOTCONN) { client->connected = 0; l2cap_client_close(client); } perror("l2cap_client_send : error while polling socket"); return -1; } if (!n) { errno = ETIMEDOUT; perror("l2cap_client_send : error while polling socket"); return -1; } while((bytes_read = read(client->l2cap_socket.sock, client->buffer, client->buffer_length)) < 0) { if (errno == EAGAIN || errno == EINTR) continue; if (errno == ENOTCONN) { client->connected = 0; l2cap_client_close(client); } perror("l2cap_client_send : error while reading socket.\n"); return -1; } if (bytes_read == 0) { // 0 Bytes read means that the connection has been lost. print_trace(TRACE_WARNING, "l2cap_client: connection reset by peer.\n"); client->connected = 0; return -1; } client->treat_buffer(*client); } else { print_trace(TRACE_ERROR, "l2cap_client_send : invalid connexion.\n"); return -1; } return 0; }
void exit(int status) throw() { print_trace ("%*sexit(%d)...\n", indent, "", status); indent+=2; /* call the real exit function */ real_exit (status); indent-=2; print_trace ("%*sexit(%d)\n", indent, "", status); }
/* The functions below are invoked automatically by code generated * by the compiler. These are the entry points of the library. */ void __cyg_profile_func_enter(void *self, void *callsite) { if (!Tracing) return; if (print_trace(self, "ENTER")) Callstack_depth++; }
/* Fetch a message from queue 'q' and store it in 'm' */ int mbox_recv(int q, msg_t * m) { lock_acquire(&Q[q].l); print_trace("Recv", q, -1); /* If no messages available, wait until there is one */ while (Q[q].count == 0) { condition_wait(&Q[q].l, &Q[q].moreData); } /* copy header from mbox.buffer to m */ buffer_to_msg(Q[q].buffer, Q[q].tail, (char *) &m->size, MSG_T_HEADER_SIZE); /* Move tail to the body of message */ Q[q].tail = (Q[q].tail + MSG_T_HEADER_SIZE) % BUFFER_SIZE; /* Copy body of message from mbox.buffer to m->body */ buffer_to_msg(Q[q].buffer, Q[q].tail, (char *) &m->body[0], m->size); /* Move tail to the next message */ Q[q].tail = (Q[q].tail + MSG_SIZE(m) - MSG_T_HEADER_SIZE) % BUFFER_SIZE; /* Freeing space can satisy more than one writter */ condition_broadcast(&Q[q].moreSpace); Q[q].count--; lock_release(&Q[q].l); return 1; }
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); if (UseG1GC) { return; } print_trace("drop_scavenge_root", nm); nmethod* last = NULL; nmethod* cur = scavenge_root_nmethods(); while (cur != NULL) { nmethod* next = cur->scavenge_root_link(); if (cur == nm) { if (last != NULL) last->set_scavenge_root_link(next); else set_scavenge_root_nmethods(next); nm->set_scavenge_root_link(NULL); nm->clear_on_scavenge_root_list(); return; } last = cur; cur = next; } assert(false, "should have been on list"); }
static int init(void) { int ret; print_trace("in\n"); print_info("kfabric/ibv provider initializing: version %d.%d.\n", FI_MAJOR(ibvp.version), FI_MINOR(ibvp.version)); ret = kfi_register_provider(ibvp.version, &ibvp); if (ret) { print_err("register returned %d for KFI %s provider\n", ret, ibvp.name); return ret; } // ret = init_driver(); if (ret) { print_err("init_driver returned %d for KFI %s provider\n", ret, ibvp.name); kfi_deregister_provider(&ibvp); return ret; } initialized++; print_dbg("KFI provider '%s' registered.\n", ibvp.name); print_info("kfabric/ibv provider loaded\n"); return 0; }
gpointer g_object_ref (gpointer object) { gpointer (* real_g_object_ref) (gpointer); GObject *obj = G_OBJECT (object); const char *obj_name; guint ref_count; GObject *ret; real_g_object_ref = get_func ("g_object_ref"); obj_name = G_OBJECT_TYPE_NAME (obj); ref_count = obj->ref_count; ret = real_g_object_ref (object); if (object_filter (obj_name) && display_filter (DISPLAY_FLAG_REFS)) { g_print (" + Reffed object %p, %s; ref_count: %d -> %d\n", obj, obj_name, ref_count, obj->ref_count); print_trace(); } return ret; }
void sigquit() { print_trace(); printf("My DADDY has Killed me!!!\n"); exit(0); }
void CodeCache::prune_scavenge_root_nmethods() { assert_locked_or_safepoint(CodeCache_lock); debug_only(mark_scavenge_root_nmethods()); nmethod* last = NULL; nmethod* cur = scavenge_root_nmethods(); while (cur != NULL) { nmethod* next = cur->scavenge_root_link(); debug_only(cur->clear_scavenge_root_marked()); assert(cur->scavenge_root_not_marked(), ""); assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); if (!cur->is_zombie() && !cur->is_unloaded() && cur->detect_scavenge_root_oops()) { // Keep it. Advance 'last' to prevent deletion. last = cur; } else { // Prune it from the list, so we don't have to look at it any more. print_trace("prune_scavenge_root", cur); cur->set_scavenge_root_link(NULL); cur->clear_on_scavenge_root_list(); if (last != NULL) last->set_scavenge_root_link(next); else set_scavenge_root_nmethods(next); } cur = next; } // Check for stray marks. debug_only(verify_perm_nmethods(NULL)); }
CodeBlob* CodeCache::allocate(int size) { // Do not seize the CodeCache lock here--if the caller has not // already done so, we are going to lose bigtime, since the code // cache will contain a garbage CodeBlob until the caller can // run the constructor for the CodeBlob subclass he is busy // instantiating. guarantee(size >= 0, "allocation request must be reasonable"); assert_locked_or_safepoint(CodeCache_lock); CodeBlob* cb = NULL; _number_of_blobs++; while (true) { cb = (CodeBlob*)_heap->allocate(size); if (cb != NULL) break; if (!_heap->expand_by(CodeCacheExpansionSize)) { // Expansion failed return NULL; } if (PrintCodeCacheExtension) { ResourceMark rm; tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)", (intptr_t)_heap->begin(), (intptr_t)_heap->end(), (address)_heap->end() - (address)_heap->begin()); } } verify_if_often(); print_trace("allocation", cb, size); return cb; }
void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); nm->set_on_scavenge_root_list(); nm->set_scavenge_root_link(_scavenge_root_nmethods); set_scavenge_root_nmethods(nm); print_trace("add_scavenge_root", nm); }
int8_t hci_compute_device_name(hci_socket_t *hci_socket, hci_controller_t *hci_controller, bt_device_t *bt_device) { CHECK_HCI_CONTROLLER_PTR(hci_controller, "hci_compute_device_name"); CHECK_HCI_CONTROLLER_INTERRUPTED(hci_controller, hci_socket); CHECK_HCI_CONTROLLER_OPEN(hci_controller, "hci_compute_device_name"); if (!bt_device) { print_trace(TRACE_ERROR, "hci_compute_device_name : invalid device's reference.\n"); return -1; } char new_socket = 0; char socket_err = 0; check_hci_socket_ptr(&hci_socket, hci_controller, &new_socket, &socket_err); if (socket_err) { strcpy(bt_device->real_name, "[UNKNOWN]"); } hci_change_state(hci_controller, HCI_STATE_SCANNING); if (hci_read_remote_name(hci_socket->sock, &(bt_device->mac), BT_NAME_LENGTH, bt_device->real_name, HCI_CONTROLLER_DEFAULT_TIMEOUT) < 0) { perror("hci_read_remote_name"); strcpy(bt_device->real_name, "[UNKNOWN]"); } hci_change_state(hci_controller, HCI_STATE_OPEN); if (new_socket) { close_hci_socket(hci_socket); free(hci_socket); } return 0; }
/* iperf_udp_connect * * connect to a TCP stream listener */ int iperf_udp_connect(struct iperf_test *test) { int s, buf, sz; if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->server_hostname, test->server_port)) < 0) { i_errno = IESTREAMCONNECT; return -1; } /* Write to the UDP stream to let the server know we're here. */ buf = 123456789; if (write(s, &buf, sizeof(buf)) < 0) { // XXX: Should this be changed to IESTREAMCONNECT? print_trace(); i_errno = IESTREAMWRITE; return -1; } /* Wait until the server confirms the client UDP write */ // XXX: Should this read be TCP instead? if ((sz = recv(s, &buf, sizeof(buf), 0)) < 0) { i_errno = IESTREAMREAD; return -1; } return s; }
/* Static function trying to catch if a CMD_COMPLETE event has occured or not. Please note that, due to BlueZ implementation, the huge majority of functions don't need to catch such an event. In fact, each BlueZ function using "hci_send_req" already does this verification. Nevertheless, if we use a function calling "hci_send_cmd" we have to do the verification by ourselves. To know wether or not a function needs to be verified, please refer to the BlueZ file "hci.c". */ static char check_cmd_complete(hci_socket_t *hci_socket, hci_controller_t *hci_controller) { //http://forum.hardware.fr/hfr/Programmation/C/poll-sockets-sujet_86846_1.htm //http://code.metager.de/source/xref/linux/bluetooth/bluez/lib/hci.c struct pollfd p; int n; unsigned char buf[HCI_MAX_EVENT_SIZE]; hci_event_hdr *hdr; char new_socket = 0; char socket_err = 0; check_hci_socket_ptr(&hci_socket, hci_controller, &new_socket, &socket_err); if (socket_err) { goto fail; } uint8_t try = 10; while (try--) { p.fd = hci_socket->sock; p.events = POLLIN; while ((n = poll(&p, 1, HCI_CONTROLLER_DEFAULT_TIMEOUT)) < 0) { if (errno == EAGAIN || errno == EINTR) continue; perror("check_cmd_complete : error while polling socket"); goto fail; } if (!n) { errno = ETIMEDOUT; perror("check_cmd_complete : error while polling socket"); goto fail; } int8_t len; while ((len = read(hci_socket->sock, buf, sizeof(buf))) < 0) { if (errno == EAGAIN || errno == EINTR) continue; perror("check_cmd_complete : error while reading socket"); goto fail; } hdr = (void *) (buf + 1); switch (hdr->evt) { case EVT_CMD_COMPLETE: return 1; break; default: print_trace(TRACE_WARNING, "check_cmd_complete warning : an unknown event occured.\n"); break; } } errno = ETIMEDOUT; fail: if (new_socket) { close_hci_socket(hci_socket); free(hci_socket); } return 0; }
int main(int argc, char *argv[]) { double dt; // largest change in t int i, j; // grid indexes int niter; // number of iterations int iter; // current iteration printf("How many iterations [100-1000]? "); scanf("%d", &niter); initialize(); // initialize grid set_bcs(); // set boundary conditions // initialize t_old for(i = 0; i <= NR+1; i++){ for(j=0; j<=NC+1; j++){ t_old[i][j] = t[i][j]; } } double start_time = omp_get_wtime(); // do the computation for niter steps #pragma omp parallel shared(t, t_old) private(i,j,iter) firstprivate(niter) reduction(max:dt) for(iter = 1; iter <= niter; iter++) { // main calculation: average my four neighbors #pragma omp for for(i = 1; i <= NR; i++) { for(j = 1; j <= NC; j++) { t[i][j] = 0.25 * (t_old[i+1][j] + t_old[i-1][j] + t_old[i][j+1] + t_old[i][j-1]); } } // reset greatest temp change dt = 0.0; // copy grid to old grid for next iteration and find dt #pragma omp for for(i = 1; i <= NR; i++){ for(j = 1; j <= NC; j++){ dt = fmax( fabs(t[i][j]-t_old[i][j]), dt); t_old[i][j] = t[i][j]; } } // periodically print test values #pragma omp master if((iter % 100) == 0) { print_trace(iter); } #pragma omp barrier } double end_time = omp_get_wtime(); printf("Time taken: %f\n", end_time - start_time); }
int caml_failed_assert (char * expr, char * file, int line) { fprintf (stderr, "[%02d] file %s; line %d ### Assertion failed: %s\n", Caml_state ? Caml_state->id : -1, file, line, expr); print_trace (); fflush (stderr); abort(); }
void __cyg_profile_func_exit(void *self, void *callsite) { if (!Tracing) return; Callstack_depth--; if (!print_trace(self, "LEAVE")) Callstack_depth++; }
void print_traces() { struct instruction_trace* i = traces; while(NULL != i) { i = print_trace(i); } }
pid_t getpid(void) throw() { pid_t retval; print_trace ("%*sgetpid()=...\n", indent, "" ); indent+=2; /* call the real getpid function */ retval = real_getpid (); indent-=2; print_trace ("%*sgetpid()=%d\n", indent, "" , retval); return retval; }
ssize_t read(int fd, void *buf, size_t count) { ssize_t retval; print_trace ("%*sread(%d, %p, %d)=...\n", indent, "", fd, buf, count); indent+=2; /* call the real read function */ retval = real_read (fd, buf, count); indent-=2; print_trace ("%*sread(%d, %p, %d)=%d\n", indent, "", fd, buf, count, retval); return retval; }
ssize_t write(int fd, const void *buf, size_t count) { ssize_t retval; print_trace ("%*swrite(%d, %p, %d)=...\n", indent, "", fd, buf, count); indent+=2; /* call the real write function */ retval = real_write (fd, buf, count); indent-=2; print_trace ("%*swrite(%d, %p, %d)=%d\n", indent, "", fd, buf, count, retval); return retval; }
pid_t fork(void) throw() { pid_t retval; print_trace ("%*sfork()=...\n", indent, "" ); indent+=2; /* call the real fork function */ retval = real_fork (); indent-=2; print_trace ("%*sfork()=%d\n", indent, "" , retval); return retval; }
/* Aborts the program with a printf-formatted message upon event of an * unrecoverable program error */ void Die_(PCSZ pszFunction, PCSZ pszFormat, ...) { va_list args; va_start(args, pszFormat); print_trace(stderr, pszFunction); fprintf(stderr, "ERROR (%s): ", pszFunction); vfprintf(stderr, pszFormat, args); fprintf(stderr, "\n"); abort(); }
int execve(const char *filename, char *const argv[], char *const envp[]) throw() { int retval; print_trace ("%*sexecve(%s, %s, %s)=...\n", indent, "", filename, argv, envp); indent+=2; /* call the real execve function */ retval = real_execve (filename, argv, envp); indent-=2; print_trace ("%*sexecve(%p, %s, %s)=%d\n", indent, "", filename, argv, envp, retval); return retval; }
ssize_t sendmsg(int s, const struct msghdr *msg, int flags) { ssize_t retval; print_trace ("%*ssendmsg(%d, %p, %d)=...\n", indent, "", s, msg, flags); indent+=2; /* call the real sendmsg function */ retval = real_sendmsg (s, msg, flags); indent-=2; print_trace ("%*ssendmsg(%d, %p, %d)=%d\n", indent, "", s, msg, flags, retval); return retval; }