本文整理汇总了C++中process_block函数的典型用法代码示例。如果您正苦于以下问题:C++ process_block函数的具体用法?C++ process_block怎么用?C++ process_block使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了process_block函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _gvn
LoopInvariantCodeMotion::LoopInvariantCodeMotion(ShortLoopOptimizer *slo, GlobalValueNumbering* gvn, BlockBegin* loop_header, BlockList* loop_blocks)
: _gvn(gvn), _short_loop_optimizer(slo) {
TRACE_VALUE_NUMBERING(tty->print_cr("using loop invariant code motion loop_header = %d", loop_header->block_id()));
TRACE_VALUE_NUMBERING(tty->print_cr("** loop invariant code motion for short loop B%d", loop_header->block_id()));
BlockBegin* insertion_block = loop_header->dominator();
if (insertion_block->number_of_preds() == 0) {
return; // only the entry block does not have a predecessor
}
assert(insertion_block->end()->as_Base() == NULL, "cannot insert into entry block");
_insertion_point = insertion_block->end()->prev();
_insert_is_pred = loop_header->is_predecessor(insertion_block);
BlockEnd *block_end = insertion_block->end();
_state = block_end->state_before();
if (!_state) {
// If, TableSwitch and LookupSwitch always have state_before when
// loop invariant code motion happens..
assert(block_end->as_Goto(), "Block has to be goto");
_state = block_end->state();
}
// the loop_blocks are filled by going backward from the loop header, so this processing order is best
assert(loop_blocks->at(0) == loop_header, "loop header must be first loop block");
process_block(loop_header);
for (int i = loop_blocks->length() - 1; i >= 1; i--) {
process_block(loop_blocks->at(i));
}
}
示例2: accept_client
void accept_client(void) {
char buffer[1024];
struct sockaddr_in cli_addr;
int n;
int client;
socklen_t clilen = sizeof(struct sockaddr_in);
/* Accept a client: */
client = accept(s, (struct sockaddr *)&cli_addr, &clilen);
if(client < 0) {
warn("Error on accept.");
return;
}
ip4_t r_addr = {cli_addr.sin_addr.s_addr};
printf("Got client from %d.%d.%d.%d.\n", r_addr.components.p1, r_addr.components.p2, r_addr.components.p3, r_addr.components.p4);
/* Read data from the client: */
do {
bzero(buffer, 1024);
n = read(client, buffer, 1023);
if(n < 0) {
warn("Error reading from socket; breaking connection.");
close(client);
return;
}
process_block(buffer, n);
} while(n == 1023);
process_block(NULL, 0);
printf("\n");
/* Write data to the client: */
const char * output = "HTTP/1.1 200 OK\nContent-Type: text/html\n\n";
n = write(client, output, strlen(output));
if(n < 0) {
warn("Error writing to socket; breaking connection.");
close(client);
return;
}
if(output_file(client, "public/index.html")) {
close(client);
return;
}
/* Close the connection: */
close(client);
}
示例3: pdfout_text_get_page
void
pdfout_text_get_page (FILE *stream, fz_context *ctx,
pdf_document *doc, int page_number)
{
fz_stext_sheet *sheet;
fz_stext_page *text;
sheet = fz_new_stext_sheet (ctx);
text = fz_new_stext_page_from_page_number (ctx, &doc->super, page_number,
sheet, 0);
/* printf ("in pdfout_text_get_page, page_number: %d, page->len: %d\n", */
/* page_number, text->len); */
for (int i = 0; i < text->len; ++i)
{
fz_page_block *block = &text->blocks[i];
if (block->type == FZ_PAGE_BLOCK_TEXT)
process_block (ctx, stream, block->u.text);
}
fprintf (stream, "\f\n");
/* cleanup */
fz_drop_stext_page (ctx, text);
fz_drop_stext_sheet (ctx, sheet);
}
示例4: CRYPTO_MALLOC
unsigned char *sha1(const unsigned char *data, unsigned int len) {
sha1_ctx *ctx = CRYPTO_MALLOC(sizeof(*ctx));
char *hash = CRYPTO_MALLOC(20);
int i;
ctx->overflow = 0;
ctx->data = data;
ctx->len = len;
ctx->datalen = len * 8;
ctx->next = data;
ctx->H[0] = 0x67452301;
ctx->H[1] = 0xEFCDAB89;
ctx->H[2] = 0x98BADCFE;
ctx->H[3] = 0x10325476;
ctx->H[4] = 0xC3D2E1F0;
do {
process_block(ctx);
} while (ctx->len > 0);
for (i = 0; i < 5; i++) {
unsigned int l = long_swap(ctx->H[i]);
memcpy(hash + i*sizeof(unsigned int), (void *)&l, sizeof(unsigned int));
}
CRYPTO_FREE(ctx);
return hash;
}
示例5: read_block_msg
static bool read_block_msg(struct p2p_message *msg, int64_t fpos)
{
/* unknown records are invalid */
if (strncmp(msg->hdr.command, "block",
sizeof(msg->hdr.command)))
return false;
bool rc = false;
struct bp_block block;
bp_block_init(&block);
struct const_buffer buf = { msg->data, msg->hdr.data_len };
if (!deser_bp_block(&block, &buf)) {
fprintf(plog, "brd: block deser fail\n");
goto out;
}
bp_block_calc_sha256(&block);
if (!bp_block_valid(&block)) {
fprintf(plog, "brd: block not valid\n");
goto out;
}
rc = process_block(&block, fpos);
out:
bp_block_free(&block);
return rc;
}
示例6: isl_ast_node_get_type
void cpp_from_isl::process_node(isl_ast_node *node)
{
auto type = isl_ast_node_get_type(node);
switch(type)
{
case isl_ast_node_for:
process_for(node); break;
case isl_ast_node_if:
process_if(node); break;
case isl_ast_node_block:
process_block(node); break;
case isl_ast_node_user:
process_user(node); break;
case isl_ast_node_mark:
{
// TODO: label the stmt?
auto marked_node = isl_ast_node_mark_get_node(node);
process_node(marked_node);
isl_ast_node_free(marked_node);
break;
}
default:
throw error("Unexpected AST node type.");
}
}
示例7: process_AD
/* ============================== Process Associated Data =================================*/
static void process_AD(
block W, block Delta_1, const block npub, block param,
const u8 *ad, u64 adlen) {
block Delta_2, blk, result;
u8 Is_complete = 1, ozs[16];
int i; for(i=1; i<16; i++){ozs[i]=0x00;} ozs[0] = 0x80;
/* ===== make the first block blk based on npub and param ===== */
load_block(blk, npub, param, 8, 8);
while(1){
/* ============= Process the current Block ==================== */
process_block(Delta_1, Delta_2, result, blk, W, Is_complete, ENCRYPT, 0, AD);
/* === Compute the next Block and updating the pointers and counters ===*/
if(adlen==0) break;
else if(adlen <= 16) {
load_block(blk, ad, ozs, adlen, 16-adlen);
if(adlen != 16) Is_complete = 0;
adlen = 0;
}
else {load_block(blk, ad, ozs, 16, 0); ad +=16; adlen -=16;}
}
}
示例8: sys_sem_wait_x
//----------------------------------------------------------------------------------------------------//
// @func - sys_sem_wait_x
//! @desc
//! Semaphore wait operation
//! - Decrement semaphore value
//! - If value < 0, block
//! @param
//! - sem is the semaphore reference
//! @return
//! - 0 on success, -1 on failure
//! errno set to,
//! EINVAL - If the semaphore identifier does not refer to a valid semaphore
//! EIDRM - If the semaphore was removed forcibly
//! @note
//! - Renamed away from sys_sem_wait because it conflicts with functions in LWIP.
//----------------------------------------------------------------------------------------------------//
int sys_sem_wait_x (sem_t* sem)
{
sem_info_t* seminfo = get_sem_by_semt (sem);
if (seminfo == NULL) {
kerrno = EINVAL;
return -1;
}
seminfo->sem_value-- ; // Decrement the resource count
if (seminfo->sem_value < 0) // If resource unavailable
process_block (&(seminfo->sem_wait_q), PROC_WAIT);
// Return here on unblock
// Special. Not part of posix specification. If the semaphore was force_destroy'ed
// then the process has not really acquired the semaphore when it was unblocked,
// but rather it is in an interrupted situation. Signal error in this case
if (seminfo->sem_id == -1) { // If sem invalidated by now
kerrno = EIDRM;
return -1;
}
return 0 ;
}
示例9: sys_pthread_join
//----------------------------------------------------------------------------------------------------//
// @func - sys_pthread_join
//! @desc
//! Suspend current thread till target thread terminates. Then completely detach target thread.
//! - Verify target is present and is joinable
//! - Block onto target's join queue
//! - When unblocked, if thread not already detached, detach it
//! - if retval is not NULL, then store target's return value in *retval.
//! @param
//! - target is the thread to join with
//! - retval is the location to store return value of target thread.
//! @return
//! - Return 0 on success and return value of target thread in location referenced by retval.
//! - Return ESRCH, EINVAL as appropriate
//! @note
//! - none
//----------------------------------------------------------------------------------------------------//
int sys_pthread_join (pthread_t target, void **retval)
{
pthread_info_t *target_info = pthread_get_info (target);
pthread_t cur = sys_pthread_self ();
pthread_info_t *self = pthread_get_info (cur);
if (target_info == NULL)
return ESRCH;
// @note - Can possibly detect deadlocks here
if (target_info->state == PTHREAD_STATE_ALIVE) {
if (target_info->join_thread != NULL) // Some other thread already waiting to join
return EINVAL; // Therefore invalid to join with this target
target_info->join_thread = self; // Block and yield execution to some other context
process_block (&(target_info->joinq), PROC_WAIT); // Indicate that self wants to join with target.
if (retval != NULL)
*retval = target_info->retval;
} else if (target_info->state == PTHREAD_STATE_DETACHED) // Can potentially return success here.
return ESRCH; // POSIX is not specific about behavior on multiple joins to an already terminated thread.
if (target_info->state != PTHREAD_STATE_DETACHED) { // Target thread already in state PTHREAD_STATE_EXIT. Detach target thread.
if (retval != NULL) // Thread already detached if detachstate was PTHREAD_STATE_DETACHED,
*retval = target_info->retval;
process_invalidate (target_info->parent); // Clear up corresponding parent structure
invalidate_thread_info (target_info);
}
return 0; // Success
}
示例10: process_block
inline void sha1::process_byte(cvc4_uchar8 byte)
{
block_[block_byte_index_++] = byte;
++byte_count_;
if (block_byte_index_ == 64) {
block_byte_index_ = 0;
process_block();
}
}
示例11: parse_stream
int parse_stream (FILE *stream, void *resblock)
{
char buffer[BLOCKSIZE + 72];
size_t sum;
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
while (1)
{
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
sum += n;
if (sum == BLOCKSIZE)
break;
if (n == 0)
{
/* Check for the error flag IFF N == 0, so that we don't
exit the loop after a partial read due to e.g., EAGAIN
or EWOULDBLOCK. */
if (ferror (stream))
return 1;
goto process_partial_block;
}
/* We've read at least one byte, so ignore errors. But always
check for EOF, since feof may be true even though N > 0.
Otherwise, we could end up calling fread after EOF. */
if (feof (stream))
goto process_partial_block;
}
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
process_block (buffer, BLOCKSIZE);
}
process_partial_block:
/* Process any remaining bytes. */
if (sum > 0)
process_bytes (buffer, sum);
return 0;
}
示例12: process_conf
static int
process_conf(struct sc_profile *profile, scconf_context *conf)
{
struct state state;
memset(&state, 0, sizeof(state));
state.filename = conf->filename;
state.profile = profile;
return process_block(&state, &root_ops, "root", conf->root);
}
示例13: cmac_update
static int cmac_update(drew_mac_t *ctx, const uint8_t *data, size_t len)
{
struct cmac *c = ctx->ctx;
const uint8_t *in = data;
if (len == 0)
return 0;
c->nonzero_len = true;
if (c->boff) {
const size_t b = MIN(c->blksize - c->boff, len);
memcpy(c->buf+c->boff, in, b);
if ((c->boff += b) == c->blksize) {
if (len != b) {
process_block(c, c->buf);
c->boff = 0;
}
else
c->boff = 16;
}
len -= b;
in += b;
}
/* The last block must be treated specially, so make sure that this isn't it
* by ensuring that there's at least one more byte than the block size.
*/
while (len >= c->blksize+1) {
process_block(c, in);
len -= c->blksize;
in += c->blksize;
}
if (len) {
memcpy(c->buf, in, len);
c->boff = len;
}
return 0;
}
示例14: process_option
/*
* Process an option block
*/
static int
process_option(struct state *cur, struct block *info,
const char *name, scconf_block *blk)
{
sc_profile_t *profile = cur->profile;
int match = 0, i;
for (i = 0; profile->options[i]; i++)
match |= !strcmp(profile->options[i], name);
if (!match && strcmp("default", name))
return 0;
return process_block(cur, info, name, blk);
}
示例15: process_key
/*
* Process a key block
*/
static int
process_key(struct state *cur, struct block *info,
const char *name, scconf_block *blk)
{
unsigned int type, id;
struct state state;
if (get_authid(cur, name, &type, &id))
return 1;
init_state(cur, &state);
state.key = new_key(cur->profile, type, id);
return process_block(&state, info, name, blk);
}