double ResDtSolid(struct fe1d *p, matrix *guess, Elem1D *elem, double x, int f1, int f2) { double T = TINIT, C = 0, Ci, Ea, E, lambda, sigma, term1; int i; basis *b; b = p->b; solution *s; s = CreateSolution(p->t, p->dt, guess); for(i=0; i<b->n; i++) { Ci = EvalSoln1D(p, CVAR, elem, s, valV(elem->points, i)); Ci = uscaleTemp(p->chardiff, Ci); C += Ci; } Ea += EA(C, T); E += E1(C, T); lambda += LAMBDA(C, T); sigma += STRESS(C, T); term1 = lambda*(Ea+E) * b->phi[f1](x)*b->phi[f2](x) / IMap1D(p, elem, x); free(s); return term1; }
static ssize_t fd_recv(struct stream *stream, void *buffer, size_t n) { struct stream_fd *s = stream_fd_cast(stream); ssize_t retval; if (STRESS(stream_flaky_recv)) { return -EIO; } retval = read(s->fd, buffer, n); return retval >= 0 ? retval : -errno; }
double ResFSolid(struct fe1d *p, matrix *guess, Elem1D *elem, double x, int f1, int a) { double T = TINIT, C = 0, Cp = 0, Ci, Cpi, lambda, sigma, sigmap, DsigmaDt; int i; solution *s, *sp; basis *b; b = p->b; s = CreateSolution(p->t, p->dt, guess); sp = FetchSolution(p, p->t-1); for(i=0; i<b->n; i++) { Ci = EvalSoln1D(p, CVAR, elem, s, valV(elem->points, i)); Ci = uscaleTemp(p->chardiff, Ci); if(p->t > 1) { Cpi = EvalSoln1D(p, CVAR, elem, sp, valV(elem->points, i)); Cpi = uscaleTemp(p->chardiff, Cpi); } else { Cpi = Ci; } C += Ci; Cp += Cpi; } lambda += LAMBDA(C, T); sigma += STRESS(C, T); sigmap += STRESS(Cp, T); DsigmaDt = (sigma-sigmap)/p->dt; free(s); return sigma - lambda*DsigmaDt; }
static ssize_t fd_send(struct stream *stream, const void *buffer, size_t n) { struct stream_fd *s = stream_fd_cast(stream); ssize_t retval; if (STRESS(stream_flaky_send)) { return -EIO; } retval = write(s->fd, buffer, n); return (retval > 0 ? retval : retval == 0 ? -EAGAIN : -errno); }
static int nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait) { /* We can't accurately predict the size of the data to be received. The * caller is supposed to have allocated enough space in 'buf' to handle the * "typical" case. To handle exceptions, we make available enough space in * 'tail' to allow Netlink messages to be up to 64 kB long (a reasonable * figure since that's the maximum length of a Netlink attribute). */ struct nlmsghdr *nlmsghdr; uint8_t tail[65536]; struct iovec iov[2]; struct msghdr msg; ssize_t retval; assert(buf->allocated >= sizeof *nlmsghdr); ofpbuf_clear(buf); iov[0].iov_base = buf->base; iov[0].iov_len = buf->allocated; iov[1].iov_base = tail; iov[1].iov_len = sizeof tail; memset(&msg, 0, sizeof msg); msg.msg_iov = iov; msg.msg_iovlen = 2; do { retval = recvmsg(sock->fd, &msg, wait ? 0 : MSG_DONTWAIT); } while (retval < 0 && errno == EINTR); if (retval < 0) { int error = errno; if (error == ENOBUFS) { /* Socket receive buffer overflow dropped one or more messages that * the kernel tried to send to us. */ COVERAGE_INC(netlink_overflow); } return error; } if (msg.msg_flags & MSG_TRUNC) { VLOG_ERR_RL(&rl, "truncated message (longer than %zu bytes)", sizeof tail); return E2BIG; } nlmsghdr = buf->data; if (retval < sizeof *nlmsghdr || nlmsghdr->nlmsg_len < sizeof *nlmsghdr || nlmsghdr->nlmsg_len > retval) { VLOG_ERR_RL(&rl, "received invalid nlmsg (%zd bytes < %zu)", retval, sizeof *nlmsghdr); return EPROTO; } if (STRESS(netlink_overflow)) { return ENOBUFS; } buf->size = MIN(retval, buf->allocated); if (retval > buf->allocated) { COVERAGE_INC(netlink_recv_jumbo); ofpbuf_put(buf, tail, retval - buf->allocated); } log_nlmsg(__func__, 0, buf->data, buf->size, sock->protocol); COVERAGE_INC(netlink_received); return 0; }