本文整理汇总了C++中ERL_COUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ ERL_COUNT函数的具体用法?C++ ERL_COUNT怎么用?C++ ERL_COUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERL_COUNT函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: erl_mk_empty_list
ETERM *erl_mk_estring(const char *s, int len)
{
ETERM *ep;
int i;
if ((!s) || (len < 0)) return NULL;
/*
* ASSERT(s != NULL);
* ASSERT(len >= 0);
*/
ep = erl_mk_empty_list();
for (i = len-1; i >= 0; i--) {
ETERM* integer;
ETERM* cons;
integer = erl_alloc_eterm(ERL_INTEGER);
ERL_COUNT(integer) = 1;
ERL_INT_VALUE(integer) = (unsigned char)s[i];
cons = erl_alloc_eterm(ERL_LIST);
ERL_COUNT(cons) = 1;
HEAD(cons) = integer;
TAIL(cons) = ep;
ep = cons;
}
return ep;
}
开发者ID:billysvensson,项目名称:otp,代码行数:29,代码来源:erl_eterm.c
示例2: erl_alloc_eterm
/*
* Create any kind of reference.
*/
ETERM *__erl_mk_reference (ETERM* t,
const char *node,
size_t len,
unsigned int n[],
unsigned int creation)
{
if (t == NULL) {
if (node == NULL) return NULL;
t = erl_alloc_eterm(ERL_REF);
ERL_COUNT(t) = 1;
if (erl_atom_init_latin1(&t->uval.refval.node, node) == NULL)
{
erl_free_term(t);
erl_errno = ENOMEM;
return NULL;
}
}
ERL_REF_LEN(t) = len;
ERL_REF_NUMBERS(t)[0] = n[0] & 0x3ffff; /* 18 bits */
ERL_REF_NUMBERS(t)[1] = n[1];
ERL_REF_NUMBERS(t)[2] = n[2];
ERL_REF_CREATION(t) = creation; /* 32 bits */
return t;
}
开发者ID:billysvensson,项目名称:otp,代码行数:30,代码来源:erl_eterm.c
示例3: erl_alloc_eterm
/*
* Create a FLOAT.
*/
ETERM *erl_mk_float (double d)
{
ETERM *ep;
ep = erl_alloc_eterm(ERL_FLOAT);
ERL_COUNT(ep) = 1;
ERL_FLOAT_VALUE(ep) = d;
return ep;
}
开发者ID:616050468,项目名称:otp,代码行数:12,代码来源:erl_eterm.c
示例4: return
/*
* Extract the HEAD of a LIST. Bump the reference
* counter on the head object.
*/
ETERM *erl_hd (const ETERM *ep)
{
if (!ep) return NULL;
/* ASSERT(ep != NULL); */
if (ERL_TYPE(ep) != ERL_LIST) {
return (ETERM *) NULL;
}
ERL_COUNT(ERL_CONS_HEAD(ep))++;
return ERL_CONS_HEAD(ep);
}
开发者ID:billysvensson,项目名称:otp,代码行数:15,代码来源:erl_eterm.c
示例5: ERL_COUNT
/*
* Extract an ELEMENT from a TUPLE. Bump the
* reference counter on the extracted object.
*/
ETERM *erl_element (int ix, const ETERM *ep)
{
if ((!ep) || (ix < 0)) return NULL;
/*
* ASSERT(ep != NULL);
* ASSERT(ix >= 0);
*/
if ((ERL_TYPE(ep) == ERL_TUPLE) && (ix <= ERL_TUPLE_SIZE(ep))) {
ERL_COUNT(ERL_TUPLE_ELEMENT(ep, ix-1))++;
return ERL_TUPLE_ELEMENT(ep, ix-1);
}
else
return NULL;
} /* erl_element */
开发者ID:billysvensson,项目名称:otp,代码行数:19,代码来源:erl_eterm.c
示例6: erl_setelement
int erl_setelement (int ix, ETERM *ep, ETERM *vp)
{
if ((!ep) || (!vp)) return 0;
/* ASSERT(ep != NULL);
* ASSERT(vp != NULL);
*/
if ((ERL_TYPE(ep) == ERL_TUPLE) && (ix <= ERL_TUPLE_SIZE(ep))) {
erl_free_term(ERL_TUPLE_ELEMENT(ep, ix-1));
ERL_TUPLE_ELEMENT(ep, ix-1) = vp;
ERL_COUNT(vp)++;
return 1;
}
erl_err_msg("<ERROR> erl_setelement: Bad type to setelement or out of range \n");
return 0;
}
开发者ID:billysvensson,项目名称:otp,代码行数:16,代码来源:erl_eterm.c
示例7: defined
/*
* Create a FLOAT.
*/
ETERM *erl_mk_float (double d)
{
ETERM *ep;
#if defined(HAVE_ISFINITE)
/* Erlang does not handle Inf and NaN, so we return an error
* rather than letting the Erlang VM complain about a bad external
* term. */
if(!isfinite(d)) {
return NULL;
}
#endif
ep = erl_alloc_eterm(ERL_FLOAT);
ERL_COUNT(ep) = 1;
ERL_FLOAT_VALUE(ep) = d;
return ep;
}
开发者ID:billysvensson,项目名称:otp,代码行数:21,代码来源:erl_eterm.c
示例8: switch
/*
* Return the CONTENT of a VARIABLE with NAME.
* If the content is non-nil then bump its
* reference counter.
*/
ETERM *erl_var_content (const ETERM *ep, const char *name)
{
int i;
ETERM *vp;
if ((!ep) || (!name)) return NULL;
/* ASSERT(ep != NULL); */
switch(ERL_TYPE(ep))
{
case ERL_VARIABLE:
if (strcmp(ERL_VAR_NAME(ep), name) == 0) {
if ((vp = ERL_VAR_VALUE(ep)) != NULL) {
ERL_COUNT(vp)++;
return vp;
}
}
break;
case ERL_LIST:
while (ep && (ERL_TYPE(ep) != ERL_EMPTY_LIST)) {
if ((vp = erl_var_content(HEAD(ep), name))) return vp;
ep = TAIL(ep);
}
break;
case ERL_TUPLE:
for (i=0; i < ERL_TUPLE_SIZE(ep); i++)
if ((vp = erl_var_content(ERL_TUPLE_ELEMENT(ep, i), name)))
{
return vp;
}
break;
default:
/* variables can't occur in other types */
break;
}
/* nothing found ! */
return NULL;
}
开发者ID:billysvensson,项目名称:otp,代码行数:48,代码来源:erl_eterm.c
示例9: erl_iolist_length
ETERM *erl_iolist_to_binary (const ETERM* term)
{
ETERM *dest;
int size;
char* ptr;
if (!term) return NULL;
/* ASSERT(term != NULL); */
/*
* Verify that the term is an I/O list and get its length.
*/
size = erl_iolist_length(term);
if (size == -1) {
return NULL;
}
/*
* Allocate the binary and copy the contents of the I/O list into it.
*/
dest = erl_alloc_eterm(ERL_BINARY);
ERL_COUNT(dest) = 1;
ERL_BIN_SIZE(dest) = size;
ptr = (char *)erl_malloc(size);
ERL_BIN_PTR(dest) = (unsigned char *)ptr;
iolist_to_buf(term, &ptr);
/*
* If ptr doesn't point exactly one byte beyond the end of the
* binary, something must be seriously wrong.
*/
if (ERL_BIN_PTR(dest) + size != (unsigned char *) ptr) return NULL;
/* ASSERT(ERL_BIN_PTR(dest) + size == (unsigned char *) ptr); */
return dest;
}
开发者ID:billysvensson,项目名称:otp,代码行数:39,代码来源:erl_eterm.c
示例10: dump_term
/*
* Dump (print for debugging) a term. Useful if/when things go wrong.
*/
void
dump_term (FILE *fp, ETERM *t)
{
if (fp == NULL) return;
fprintf(fp, "#<%p ", t);
if(t != NULL)
{
fprintf(fp, "count:%d, type:%d", ERL_COUNT(t), ERL_TYPE(t));
switch(ERL_TYPE(t))
{
case ERL_UNDEF:
fprintf(fp, "==undef");
break;
case ERL_INTEGER:
fprintf(fp, "==int, val:%d", ERL_INT_VALUE(t));
break;
case ERL_U_INTEGER:
fprintf(fp, "==uint, val:%u", ERL_INT_UVALUE(t));
break;
case ERL_FLOAT:
fprintf(fp, "==float, val:%g", ERL_FLOAT_VALUE(t));
break;
case ERL_ATOM:
fprintf(fp, "==atom, name:%p \"%s\"",
ERL_ATOM_PTR(t), ERL_ATOM_PTR(t));
break;
case ERL_BINARY:
fprintf(fp, "==binary, data:%p,%u",
ERL_BIN_PTR(t), ERL_BIN_SIZE(t));
break;
case ERL_PID:
fprintf(fp, "==pid, node:%p \"%s\"",
ERL_PID_NODE(t), ERL_PID_NODE(t));
break;
case ERL_PORT:
fprintf(fp, "==port, node:%p \"%s\"",
ERL_PORT_NODE(t), ERL_PORT_NODE(t));
break;
case ERL_REF:
fprintf(fp, "==ref, node:%p \"%s\"",
ERL_REF_NODE(t), ERL_REF_NODE(t));
break;
case ERL_CONS:
fprintf(fp, "==cons");
fprintf(fp, ", car:");
dump_term(fp, ERL_CONS_HEAD(t));
fprintf(fp, ", cdr:");
dump_term(fp, ERL_CONS_TAIL(t));
break;
case ERL_NIL:
fprintf(fp, "==nil");
break;
case ERL_TUPLE:
fprintf(fp, "==tuple, elems:%p,%u",
ERL_TUPLE_ELEMS(t), ERL_TUPLE_SIZE(t));
{
size_t i;
for(i = 0; i < ERL_TUPLE_SIZE(t); i++)
{
fprintf(fp, "elem[%u]:", i);
dump_term(fp, ERL_TUPLE_ELEMENT(t, i));
}
}
break;
case ERL_VARIABLE:
fprintf(fp, "==variable, name:%p \"%s\"",
ERL_VAR_NAME(t), ERL_VAR_NAME(t));
fprintf(fp, ", value:");
dump_term(fp, ERL_VAR_VALUE(t));
break;
default:
break;
}
}
fprintf(fp, ">");
}
开发者ID:andreas23,项目名称:otp,代码行数:83,代码来源:eterm_test.c
示例11: main
//.........这里部分代码省略.........
erl_eterm_statistics(ulongp,ulongp);
erl_free_array(etermpp,intx);
erl_free_term(etermp);
erl_free_compound(etermp);
erl_malloc(longx);
erl_free(voidp);
erl_compare_ext(ucharp, ucharp);
erl_decode(ucharp);
erl_decode_buf(ucharpp);
erl_encode(etermp,ucharp);
erl_encode_buf(etermp,ucharpp);
erl_ext_size(ucharp);
erl_ext_type(ucharp);
erl_peek_ext(ucharp,intx);
erl_term_len(etermp);
erl_gethostbyname(charp);
erl_gethostbyaddr(charp, intx, intx);
erl_gethostbyname_r(charp, hostp, charp, intx, intp);
erl_gethostbyaddr_r(charp, intx, intx, hostp, charp, intx, intp);
erl_init_resolve();
erl_distversion(intx);
erl_epmd_connect(inaddrp);
erl_epmd_port(inaddrp, charp, intp);
charp = ERL_ATOM_PTR(etermp);
intx = ERL_ATOM_SIZE(etermp);
ucharp = ERL_BIN_PTR(etermp);
intx = ERL_BIN_SIZE(etermp);
etermp = ERL_CONS_HEAD(etermp);
etermp = ERL_CONS_TAIL(etermp);
intx = ERL_COUNT(etermp);
doublex= ERL_FLOAT_VALUE(etermp);
uintx = ERL_INT_UVALUE(etermp);
intx = ERL_INT_VALUE(etermp);
intx = ERL_IS_ATOM(etermp);
intx = ERL_IS_BINARY(etermp);
intx = ERL_IS_CONS(etermp);
intx = ERL_IS_EMPTY_LIST(etermp);
intx = ERL_IS_FLOAT(etermp);
intx = ERL_IS_INTEGER(etermp);
intx = ERL_IS_LIST(etermp);
intx = ERL_IS_PID(etermp);
intx = ERL_IS_PORT(etermp);
intx = ERL_IS_REF(etermp);
intx = ERL_IS_TUPLE(etermp);
intx = ERL_IS_UNSIGNED_INTEGER(etermp);
uchar = ERL_PID_CREATION(etermp);
charp = ERL_PID_NODE(etermp);
uintx = ERL_PID_NUMBER(etermp);
uintx = ERL_PID_SERIAL(etermp);
uchar = ERL_PORT_CREATION(etermp);
charp = ERL_PORT_NODE(etermp);
uintx = ERL_PORT_NUMBER(etermp);
uchar = ERL_REF_CREATION(etermp);
intx = ERL_REF_LEN(etermp);
charp = ERL_REF_NODE(etermp);
uintx = ERL_REF_NUMBER(etermp);
uintp = ERL_REF_NUMBERS(etermp);
etermp = ERL_TUPLE_ELEMENT(etermp,intx);
intx = ERL_TUPLE_SIZE(etermp);
return
BUFSIZ +
EAGAIN +
EHOSTUNREACH +
EINVAL +
EIO +
EMSGSIZE +
ENOMEM +
ERL_ATOM +
ERL_BINARY +
ERL_ERROR +
ERL_EXIT +
ERL_FLOAT +
ERL_INTEGER +
ERL_LINK +
ERL_LIST +
ERL_MSG +
ERL_NO_TIMEOUT +
ERL_PID +
ERL_PORT +
ERL_REF +
ERL_REG_SEND +
ERL_SEND +
ERL_SMALL_BIG +
ERL_TICK +
ERL_TIMEOUT +
ERL_TUPLE +
ERL_UNLINK +
ERL_U_INTEGER +
ERL_U_SMALL_BIG +
ERL_VARIABLE +
ETIMEDOUT +
MAXNODELEN +
MAXREGLEN;
}
开发者ID:system,项目名称:erlang-otp,代码行数:101,代码来源:erl_fake_prog.c
注:本文中的ERL_COUNT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论