本文整理汇总了C++中read_int32函数的典型用法代码示例。如果您正苦于以下问题:C++ read_int32函数的具体用法?C++ read_int32怎么用?C++ read_int32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_int32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute_common_handle
int32_t execute_common_handle(struct data_buffer* dbuf,int socket_fd,MEM_POOL* mem_pool)
{
struct data_buffer rbuf;
//发数据包
if(socket_write(socket_fd,dbuf->data,dbuf->data_len) <= 0)
return -1;
//接受命名
memset(&rbuf,0,sizeof(struct data_buffer));
rbuf.data_len = sizeof(uint32_t);
rbuf.data = (uint8_t *)mem_pool_malloc(mem_pool,sizeof(uint32_t));
rbuf.size = rbuf.data_len;
if(socket_read(socket_fd,rbuf.data,sizeof(uint32_t)) <= 0)
return -1;
rbuf.data_len = read_int32(&rbuf);
rbuf.data = (uint8_t *)mem_pool_malloc(mem_pool,rbuf.data_len);
rbuf.rpos = 0;
rbuf.size = rbuf.data_len;
if(socket_read(socket_fd,rbuf.data,rbuf.data_len) <= 0)
return -1;
rbuf.rpos += MESSAGE_HEAD_LEN;
uint16_t type = message_type(&rbuf);
if (type != MT_DC_EXE_RS)
return -1;
return read_int32(&rbuf);
}
示例2: replay_rt_sigaction
int SCOPE
replay_rt_sigaction(const struct syscall_regs * regs)
{
int32_t eax = read_int32();
if (eax == 0) {
int sigsetsize = read_int32();
ASSERT(sigsetsize == regs->esi, regs, "");
ASSERT(sigsetsize == sizeof(k_sigset_t), regs, "[email protected]@#1\n");
uintptr_t oact = read_uint32();
ASSERT(oact == regs->edx, regs, "oact inconsistent: 0x%x != 0x%x\n",
regs->edx, oact);
uintptr_t act = read_uint32();
ASSERT(act == regs->ecx, regs, "act inconsistent: 0x%x != 0x%x\n",
regs->ecx, act);
if (oact != 0)
read_mem(oact, sizeof(struct k_sigaction));
/* we need trace sighandler even in replay */
if (act != 0)
__dup_mem(&state_vector.sigactions[regs->ebx], act,
sizeof(struct k_sigaction));
}
return eax;
}
示例3: object_class_audioclip_load
struct object_class_audioclip* object_class_audioclip_load(unsigned char* data, size_t start, size_t size)
{
size_t offset = start;
struct object_class_audioclip* object_class = (struct object_class_audioclip*)calloc(1, sizeof(*object_class));
offset += read_int32(data, offset, &object_class->name_len, true);
if (object_class->name_len < 0 || object_class->name_len >(int)size) {
free(object_class);
return NULL;
}
offset += read_buffer(data, offset, &object_class->name, object_class->name_len);
offset = (offset + 3) / 4 * 4;
offset += read_int32(data, offset, &object_class->format, true);
offset += read_int32(data, offset, &object_class->type, true);
offset += read_byte(data, offset, &object_class->is_3d);
offset += read_byte(data, offset, &object_class->use_hardware);
offset = (offset + 3) / 4 * 4;
offset += read_int32(data, offset, &object_class->stream, true);
offset += read_int32(data, offset, &object_class->data_size, true);
offset += read_buffer(data, offset, &object_class->data, object_class->data_size);
return object_class;
}
示例4: process
static void process(ErlDrvData handle, ErlIOVec *ev) {
spidermonkey_drv_t *dd = (spidermonkey_drv_t *) handle;
char *data = ev->binv[1]->orig_bytes;
char *command = read_command(&data);
if (strncmp(command, "ij", 2) == 0) {
char *call_id = read_string(&data);
int thread_stack = read_int32(&data);
if (thread_stack < 8) {
thread_stack = 8;
}
thread_stack = thread_stack * (1024 * 1024);
int heap_size = read_int32(&data) * (1024 * 1024);
dd->vm = sm_initialize(thread_stack, heap_size);
send_ok_response(dd, call_id);
driver_free(call_id);
}
else {
js_call *call_data = (js_call *) driver_alloc(sizeof(js_call));
call_data->driver_data = dd;
call_data->args = ev->binv[1];
driver_binary_inc_refc(call_data->args);
ErlDrvPort port = dd->port;
unsigned long thread_key = (unsigned long) port;
driver_async(dd->port, (unsigned int *) &thread_key, (asyncfun) run_js, (void *) call_data, NULL);
}
driver_free(command);
}
示例5: replay_time
int SCOPE
replay_time(const struct syscall_regs * regs)
{
int32_t eax = read_int32();
int32_t ebx = read_int32();
ASSERT(ebx == regs->ebx, regs, "");
if (ebx != 0)
read_mem(ebx, sizeof(time_t));
return eax;
}
示例6: read_binary
static void read_binary(parse_info *info, numbuf_t *buf, int wide) {
if (wide <= 4) read_int32(info, &buf->i32, wide);
else {
uint32_t lo, hi; /* in big endian */
read_int32(info, &hi, 4);
read_int32(info, &lo, wide - 4);
buf->i64 = info->endian == BIG_ENDIAN ?
((uint64_t)hi << ((wide-4)<<3)) | lo :
((uint64_t)lo << 32) | hi;
}
}
示例7: checkEquality
static bool
checkEquality(char *jqBase, int32 jqPos, int32 type, JsonbValue *jb)
{
int len;
if (type == jqiAny)
return true;
if (jb->type == jbvBinary)
return false;
if (jb->type != type /* see enums */)
return false;
switch(type)
{
case jqiNull:
return true;
case jqiString:
read_int32(len, jqBase, jqPos);
return (len == jb->val.string.len && memcmp(jb->val.string.val, jqBase + jqPos, len) == 0);
case jqiBool:
read_byte(len, jqBase, jqPos);
return (jb->val.boolean == (bool)len);
case jqiNumeric:
return (compareNumeric((Numeric)(jqBase + jqPos), jb->val.numeric) == 0);
default:
elog(ERROR,"Wrong state");
}
}
示例8: test_decompress
void test_decompress(FILE* outFp, FILE* inpFp)
{
static char decBuf[DECODE_RING_BUFFER];
int decOffset = 0;
LZ4_streamDecode_t lz4StreamDecode_body = { 0 };
LZ4_streamDecode_t* lz4StreamDecode = &lz4StreamDecode_body;
for(;;) {
int cmpBytes = 0;
char cmpBuf[LZ4_COMPRESSBOUND(MESSAGE_MAX_BYTES)];
{
const size_t r0 = read_int32(inpFp, &cmpBytes);
if(r0 != 1 || cmpBytes <= 0) break;
const size_t r1 = read_bin(inpFp, cmpBuf, cmpBytes);
if(r1 != (size_t) cmpBytes) break;
}
{
char* const decPtr = &decBuf[decOffset];
const int decBytes = LZ4_decompress_safe_continue(
lz4StreamDecode, cmpBuf, decPtr, cmpBytes, MESSAGE_MAX_BYTES);
if(decBytes <= 0) break;
decOffset += decBytes;
write_bin(outFp, decPtr, decBytes);
// Wraparound the ringbuffer offset
if(decOffset >= DECODE_RING_BUFFER - MESSAGE_MAX_BYTES) decOffset = 0;
}
}
}
示例9: replay__newselect
int SCOPE
replay__newselect(const struct syscall_regs * regs)
{
int32_t eax = read_int32();
int n;
uint32_t inp;
uint32_t outp;
uint32_t exp;
read_obj(n);
read_obj(inp);
read_obj(outp);
read_obj(exp);
ASSERT(n == regs->ebx, regs, "");
ASSERT(inp == regs->ecx, regs, "");
ASSERT(outp == regs->edx, regs, "");
ASSERT(exp == regs->esi, regs, "");
int fd_bytes = FDS_BYTES(n);
if (inp != 0)
read_mem(inp, fd_bytes);
if (outp != 0)
read_mem(outp, fd_bytes);
if (exp != 0)
read_mem(exp, fd_bytes);
return eax;
}
示例10: replay_rt_sigprocmask
int SCOPE
replay_rt_sigprocmask(const struct syscall_regs * regs)
{
int32_t ret = read_int32();
if (ret == 0) {
int sigsetsize = read_int32();
ASSERT(sigsetsize == regs->esi, regs, "");
if (sigsetsize == sizeof(k_sigset_t)) {
int oset = read_int32();
ASSERT(oset == regs->edx, regs, "");
if (oset)
read_mem(oset, sigsetsize);
}
}
return ret;
}
示例11: consume_int32
static int32_t SPICE_GNUC_UNUSED consume_int32(uint8_t **ptr)
{
int32_t val;
val = read_int32(*ptr);
*ptr += 4;
return val;
}
示例12: log_error
struct slave_sync_res *parse_master_response(struct mile_packet *packet) {
struct data_buffer* rbuf = packet->rbuf;
struct mile_message_header header;
if (NULL == rbuf) {
log_error( "read buffer is empty");
return NULL;
}
header.version_major = read_int8(rbuf);
header.version_minor = read_int8(rbuf);
header.message_type = read_int16(rbuf);
header.message_id = read_int32(rbuf);
log_debug(
"数据包包头信息 -- 主版本号: %d, 小版本号: %d, 消息类型: 0x%x, 消息id: %d", header.version_major, header.version_minor, header.message_type, header.message_id);
if (MT_DM_RS != header.message_type) {
log_error( "unknown message type: %hu", header.message_type);
return NULL;
}
// read body
struct slave_sync_res *res = (struct slave_sync_res *) (rbuf->data
+ rbuf->rpos);
rbuf->rpos += res->len + sizeof(struct slave_sync_res);
if (rbuf->rpos > rbuf->data_len) {
log_error( "wrong packet lenght.");
return NULL;
}
return res;
}
示例13: replay_tty_ioctl
SCOPE int
replay_tty_ioctl(int fd, uint32_t cmd, uint32_t arg,
const struct syscall_regs * regs)
{
/* write eax is done in ioctl.c */
int32_t eax = read_int32();
switch (cmd) {
case TCGETS:
if (arg != 0)
read_mem(arg, sizeof(struct termios));
return eax;
case TIOCGWINSZ:
if (arg != 0)
read_mem(arg, sizeof(struct winsize));
return eax;
case FIONREAD:
if (arg != 0)
read_mem(arg, sizeof(int));
return eax;
case FIONBIO:
return eax;
case TCGETA:
if (arg != 0)
read_mem(arg, sizeof(struct termio));
return eax;
case TCSETA:
return eax;
default:
INJ_WARNING("doesn't know such tty ioctl: 0x%x\n", cmd);
__exit(-1);
}
return eax;
}
示例14: read_string_val
const char*
read_string_val(bson_iter_t* it) {
int32_t sz = read_int32(it);
const char* p = (const char*)it->ptr;
it->ptr += sz;
it->size += sz;
return p;
}
示例15: execute_segment_stat_handle
int32_t execute_segment_stat_handle(struct data_buffer* dbuf,int socket_fd,MEM_POOL* mem_pool)
{
struct data_buffer rbuf;
//发数据包
if(socket_write(socket_fd,dbuf->data,dbuf->data_len) <= 0)
return -1;
//接受命名
memset(&rbuf,0,sizeof(struct data_buffer));
rbuf.data_len = sizeof(uint32_t);
rbuf.size = rbuf.data_len;
rbuf.data = (uint8_t *)mem_pool_malloc(mem_pool,sizeof(uint32_t));
if(socket_read(socket_fd,rbuf.data,rbuf.data_len) <= 0)
return -1;
rbuf.data_len = read_int32(&rbuf);
rbuf.data = (uint8_t *)mem_pool_malloc(mem_pool,rbuf.data_len);
rbuf.rpos = 0;
rbuf.size = rbuf.data_len;
if(socket_read(socket_fd,rbuf.data,rbuf.data_len) <= 0)
return -1;
rbuf.rpos += MESSAGE_HEAD_LEN;
uint16_t type = message_type(&rbuf);
if (type != MT_DC_STAT_RS)
return -1;
uint16_t segment_count = read_int16(&rbuf);
uint16_t i;
fprintf(stderr,"%-20s%-20s%-20s%-20s%-20s%-20s%-20s\n","SEGMENT_ID","CREATE_TIME","MODIFY_TIME","CHECKPOINT_TIME","FLAG","ROW_COUNT","DEL_COUNT");
for(i=0; i<segment_count; i++)
{
fprintf(stderr,"%-20u",read_int16(&rbuf));
fprintf(stderr,"%-20llu",read_int64(&rbuf));
fprintf(stderr,"%-20llu",read_int64(&rbuf));
fprintf(stderr,"%-20llu",read_int64(&rbuf));
fprintf(stderr,"%-20u",read_int8(&rbuf));
fprintf(stderr,"%-20u",read_int32(&rbuf));
fprintf(stderr,"%-20u\n",read_int32(&rbuf));
}
return 0;
}