本文整理汇总了C++中eraise函数的典型用法代码示例。如果您正苦于以下问题:C++ eraise函数的具体用法?C++ eraise怎么用?C++ eraise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eraise函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: en_socket_datagram_connect
void en_socket_datagram_connect (EIF_INTEGER fd, EIF_INTEGER fd1, EIF_POINTER sockaddr) {
SOCKETADDRESS* him;
int family;
EIF_INTEGER fdc = -1;
int ipv6_supported;
int connect_res;
EIF_NET_INITIALIZE;
ipv6_supported = en_ipv6_available();
him = (SOCKETADDRESS*) sockaddr;
family = him->him.sa_family;
if (family == AF_INET6 && !ipv6_supported) {
eraise ("Protocol family not supported", EN_PROG);
return;
}
fdc = (family == AF_INET? fd: fd1);
connect_res = connect(fdc, (struct sockaddr *)him, SOCKETADDRESS_LEN(him));
if ( connect_res == -1) {
eraise("Unable to establish connection", EN_PROG);
}
}
示例2: parsing_store_write
rt_private void parsing_store_write(size_t size)
{
RT_GET_CONTEXT
char* cmps_out_ptr = cmps_general_buffer;
lzo_uint cmps_out_size = (lzo_uint) cmp_buffer_size;
int signed_cmps_out_size;
REQUIRE("cmp_buffer_size not too big", cmp_buffer_size <= 0x7FFFFFFF);
REQUIRE("size not too big", size <= 0x7FFFFFFF);
lzo1x_1_compress (
(unsigned char *) general_buffer, /* Current buffer location */
(lzo_uint) size, /* Current buffer size */
(unsigned char *) cmps_out_ptr, /* Output buffer for compressed data */
&cmps_out_size, /* Size of output buffer and then size of compressed data */
wrkmem); /* Memory allocator */
signed_cmps_out_size = (int) cmps_out_size;
/* Write size of compressed data */
if (parsing_char_write ((char *) &signed_cmps_out_size, sizeof(int)) <= 0)
eraise ("Unable to write compressed data size", EN_IO);
/* Write compressed data */
if (parsing_char_write (cmps_out_ptr, signed_cmps_out_size) <= 0)
eraise ("Unable to write on specified device", EN_IO);
}
示例3: en_socket_datagram_rcv_from
EIF_INTEGER en_socket_datagram_rcv_from (EIF_INTEGER fd, EIF_INTEGER fd1, EIF_INTEGER *a_last_fd, EIF_POINTER buf, EIF_INTEGER len, EIF_INTEGER flags, EIF_INTEGER timeout, SOCKETADDRESS *him) {
int nsockets = 0;
int fduse = 0;
int result;
int lenn = sizeof(SOCKETADDRESS);
int ipv6_supported = en_ipv6_available();
if (fd > 0) {
nsockets++;
}
if (fd1 > 0) {
nsockets++;
}
if (nsockets == 2) { /* need to choose one of them */
int ret, t = (timeout == 0) ? -1: timeout;
ret = net_timeout2 (fd, fd1, t, &fduse);
if (ret == 2) {
fduse = check_last_fd (a_last_fd, fd, fd1);
} else if (ret == 0) {
if (ret == 0) {
eraise("Receive timed out", EN_PROG);
} else {
eraise("Receive error", EN_PROG);
}
return -1;
}
} else if (!ipv6_supported) {
fduse = fd;
} else if (fd >= 0) {
/* ipv6 supported: and this socket bound to an IPV6 only address */
fduse = fd1;
} else {
/* ipv6 supported: and this socket bound to an IPV4 only address */
fduse = fd;
}
if (timeout && nsockets == 1) {
int ret;
ret = net_timeout(fduse, timeout);
if (ret <= 0) {
if (ret == 0) {
eraise("Receive timed out", EN_PROG);
} else {
eraise("Receive error", EN_PROG);
}
return -1;
}
}
result = recvfrom ((SOCKET) fduse, (char *) buf, (int) len, (int) flags, (struct sockaddr *) him, &lenn);
eif_net_check (result);
return (EIF_INTEGER) result;
}
示例4: eif_file_tell
/*
* Current position within file.
*/
EIF_INTEGER eif_file_tell(FILE *f) {
long res;
if (f == (FILE *) 0) {
eraise("invalid file pointer", EN_EXT);
}
res = ftell(f);
if (res == -1) {
eraise("error occurred", EN_EXT);
}
return (EIF_INTEGER) res;
}
示例5: eif_file_fd
/*
* Return the associated file descriptor.
*/
EIF_INTEGER eif_file_fd(FILE *f) {
int res;
if (!f) {
res = 0;
eraise("invalid file pointer", EN_EXT);
} else {
res = fileno(f);
if (res == -1) {
eraise("error occurred", EN_EXT);
}
}
return (EIF_INTEGER) res;
}
示例6: parsing_store_append
rt_private void parsing_store_append(struct rt_store_context *a_context, EIF_REFERENCE object, fnptr mid, fnptr nid)
{
RT_GET_CONTEXT
struct rt_traversal_context traversal_context;
int gc_stopped;
make_index = mid;
need_index = nid;
gc_stopped = !eif_gc_ison();
eif_gc_stop(); /* Procedure `make_index' may call the GC
* while creating objects. */
/* Need to hold mutex here since we are using traversal. */
EIF_EO_STORE_LOCK;
#ifdef DEBUG
(void) nomark(object);
#endif
/* Do the traversal: mark and count the objects to store */
memset(&traversal_context, 0, sizeof(struct rt_traversal_context));
traversal_context.is_for_persistence = 1;
traversal(&traversal_context, object);
current_position = 0;
end_of_buffer = 0;
/* Write in file `file_descriptor' the count of stored objects */
buffer_write((char *) (&traversal_context.obj_nb), sizeof(uint32));
#ifndef DEBUG
(void) pst_store(a_context, object,0L); /* Recursive store process */
#else
{
uint32 nb_stored = pst_store(a_context, object,0L);
if (traversal_context.obj_nb != nb_stored) {
printf("obj_nb = %d nb_stored = %d\n", traversal_context.obj_nb, nb_stored);
eraise ("Eiffel partial store", EN_IO);
}
}
if (traversal_context.obj_nb != nomark(object))
eraise ("Partial store inconsistency", EN_IO);
#endif
a_context->flush_buffer_function(); /* Flush the buffer */
EIF_EO_STORE_UNLOCK; /* Unlock our mutex. */
if (!gc_stopped)
eif_gc_run(); /* Restart GC */
}
示例7: store_append
rt_public long store_append(EIF_INTEGER f_desc, char *object, fnptr mid, fnptr nid, EIF_REFERENCE s)
{
/* Append `object' in file `f', and applies routine `mid'
* on server `s'. Return position in the file where the object is
* stored. */
/* Initialization */
server = s;
if ((file_position = lseek ((int) f_desc, 0, SEEK_END)) == -1)
eraise ("Unable to seek on internal data files", EN_SYS);
/* Initialize store context used to store objects for appending. */
rt_setup_store (&parsing_context, BASIC_STORE);
parsing_store_append(&parsing_context, object, mid, nid);
/* Write `parsing_buffer' onto `f_desc'. If we cannot write `parsing_position' bytes
* we have a failure. */
if (write (f_desc, parsing_buffer, parsing_position) != parsing_position) {
eio();
}
parsing_position = 0;
return file_position;
}
示例8: set_matrix
void set_matrix(SquareBinaryMatrix &m) {
if((uint_t)m.get_size() != key_len)
eraise(InvalidMatrix) << "Size of matrix '" << m.get_size()
<< "' not equal to key length '" << key_len << "'";
hash_matrix = m;
hash_inverse_matrix = m.inverse();
}
示例9: bloom_filter
bloom_filter(size_t m, unsigned long k, const HashPair& fns = HashPair()) :
mem_block_t(super::nb_bytes__(m)),
super(m, k, (unsigned char*)mem_block_t::get_ptr(), fns)
{
if(!mem_block_t::get_ptr())
eraise(std::runtime_error) << "Failed to allocate " << super::nb_bytes__(m) << " bytes of memory for bloom_filter";
}
示例10: parsing_compiler_write
rt_private void parsing_compiler_write(size_t size)
{
RT_GET_CONTEXT
char* cmps_out_ptr = cmps_general_buffer;
lzo_uint cmps_out_size = (lzo_uint) cmp_buffer_size;
int signed_cmps_out_size;
int number_written;
REQUIRE("cmp_buffer_size not too big", cmp_buffer_size <= 0x7FFFFFFF);
REQUIRE("size not too big", size <= 0x7FFFFFFF);
lzo1x_1_compress (
(unsigned char *) general_buffer, /* Current buffer location */
(lzo_uint) size, /* Current buffer size */
(unsigned char *) cmps_out_ptr, /* Output buffer for compressed data */
&cmps_out_size, /* Size of output buffer and then size of compressed data */
wrkmem); /* Memory allocator */
signed_cmps_out_size = (int) cmps_out_size;
/* Write size of compressed data */
if (write (file_descriptor, (char *) &signed_cmps_out_size, sizeof(int)) <= 0)
eraise ("Unable to write compressed data size", EN_IO);
/* Write compressed data */
while (signed_cmps_out_size > 0) {
number_written = write (file_descriptor, cmps_out_ptr, signed_cmps_out_size);
if (number_written <= 0)
eio();
signed_cmps_out_size -= number_written;
cmps_out_ptr += number_written;
}
}
示例11: call_data_sync_pid
void
priv_queue::log_call(processor *client, call_data *call)
{
bool will_sync = call_data_sync_pid (call) != NULL_PROCESSOR_ID;
push (pq_message (pq_message::e_normal, client, call));
if (will_sync)
{
processor *client = registry[call_data_sync_pid (call)];
call_stack_msg = client->result_notify.wait();
for (;
call_stack_msg.type == notify_message::e_callback;
call_stack_msg = client->result_notify.wait())
{
(*client)(call_stack_msg.client, call_stack_msg.call);
call_stack_msg.call = NULL;
}
if (call_stack_msg.type == notify_message::e_dirty)
{
char *msg = "EVE/Qs dirty processor exception";
eraise (msg, 32);
}
}
synced = will_sync;
}
示例12: private_object_id
rt_private EIF_INTEGER private_object_id(EIF_REFERENCE object, struct stack *st, EIF_INTEGER *max_value_ptr)
{
register unsigned int stack_number = 0;
register struct stchunk *end;
register EIF_INTEGER Result;
char *address;
if (-1 == epush(st, object)) { /* Cannot record object */
eraise("object id", EN_MEM); /* No more memory */
return (EIF_INTEGER) 0; /* They ignored it */
}
address = (char *) (st->st_top - 1); /* Was allocated here */
eif_access(address) = object; /* Record object's physical address */
/* Get the stack number */
for(end = st->st_hd;
end != st->st_cur;
stack_number++)
end = end->sk_next;
Result = (EIF_INTEGER) (stack_number*STACK_SIZE+1-(st->st_cur->sk_arena-(char **)address));
if (Result>*max_value_ptr)
*max_value_ptr = Result;
#ifdef DEBUG
dprintf (2) ("eif_object_id %d %lx %lx\n", Result, address, object);
#endif
return Result;
}
示例13: ht_force
/*
doc: <routine name="ht_force" export="shared">
doc: <summary>Put value `val' associated with key `key' in table `ht'. If `ht' is full, we will resize `ht' and try again. If `resizing' failed or if we cannot find a suitable position, an exception is thrown. In other words, it is the same as `ht_safe_force' modulo an exception instead of an error code.</summary>
doc: <param name="ht" type="struct htable *">Table to initialize.</param>
doc: <param name="key" type="rt_uint_ptr">Key to insert in `ht'.</param>
doc: <param name="val" type="void *">Value to insert in `ht'.</param>
doc: <thread_safety>Not Safe</thread_safety>
doc: <synchronization>None</synchronization>
doc: </routine>
*/
rt_shared void ht_force(struct htable *ht, rt_uint_ptr key, void * val)
{
int l_error;
REQUIRE("ht not null", ht);
REQUIRE("key not null", key);
l_error = ht_safe_force (ht, key, val);
if (l_error != 0) {
if (l_error == -1) {
eraise ("Hash table resizing failure", EN_FATAL);
} else {
CHECK("valid error code", l_error == -2);
eraise ("Hash table insertion failure", EN_FATAL);
}
}
}
示例14: map
void map(const char *filename) {
int fd = open(filename, O_RDONLY);
struct stat stat;
if(fd < 0)
eraise(ErrorMMap) << "Can't open file '" << filename << "'" << err::no;
if(fstat(fd, &stat) < 0)
eraise(ErrorMMap) << "Can't stat file '" << filename << "'" << err::no;
_length = stat.st_size;
_base = (char *)mmap(NULL, _length, PROT_READ, MAP_SHARED, fd, 0);
if(_base == MAP_FAILED)
eraise(ErrorMMap) << "Can't mmap file '" << filename << "'" << err::no;
close(fd);
_end = _base + _length;
}
示例15: resize
void resize() {
_capacity *= 2;
void * ndata = realloc(_data, sizeof(T) * _capacity);
if(ndata == 0) {
free(ndata);
_data = 0;
_capacity = _capacity / 2;
eraise(SimpleGrowingArrayError) << "Out of memory" << err::no;
}
_data = (T*)ndata;
}