本文整理汇总了C++中BIF_RET函数的典型用法代码示例。如果您正苦于以下问题:C++ BIF_RET函数的具体用法?C++ BIF_RET怎么用?C++ BIF_RET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BIF_RET函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lists_reverse_2
BIF_RETTYPE lists_reverse_2(BIF_ALIST_2)
{
/* Handle legal and illegal non-lists quickly. */
if (is_nil(BIF_ARG_1)) {
BIF_RET(BIF_ARG_2);
} else if (is_not_list(BIF_ARG_1)) {
BIF_ERROR(BIF_P, BADARG);
}
/* We build the reversal on the unused part of the heap if possible to save
* us the trouble of having to figure out the list size. We fall back to
* lists_reverse_alloc when we run out of space. */
if (HeapWordsLeft(BIF_P) > 8) {
return lists_reverse_onheap(BIF_P, BIF_ARG_1, BIF_ARG_2);
}
return lists_reverse_alloc(BIF_P, BIF_ARG_1, BIF_ARG_2);
}
开发者ID:matwey,项目名称:otp,代码行数:18,代码来源:erl_bif_lists.c
示例2: erts_internal_port_info_2
BIF_RETTYPE erts_internal_port_info_2(BIF_ALIST_2)
{
Eterm retval;
Port* prt;
if (is_internal_port(BIF_ARG_1) || is_atom(BIF_ARG_1)) {
prt = sig_lookup_port(BIF_P, BIF_ARG_1);
if (!prt)
BIF_RET(am_undefined);
}
else if (is_external_port(BIF_ARG_1)) {
if (external_port_dist_entry(BIF_ARG_1) == erts_this_dist_entry)
BIF_RET(am_undefined);
else
BIF_RET(am_badarg);
}
else {
BIF_RET(am_badarg);
}
switch (erts_port_info(BIF_P, prt, BIF_ARG_2, &retval)) {
case ERTS_PORT_OP_CALLER_EXIT:
case ERTS_PORT_OP_BADARG:
BIF_RET(am_badarg);
case ERTS_PORT_OP_DROPPED:
BIF_RET(am_undefined);
case ERTS_PORT_OP_SCHEDULED:
ASSERT(is_internal_ordinary_ref(retval));
BIF_RET(retval);
case ERTS_PORT_OP_DONE:
ASSERT(is_not_internal_ref(retval));
BIF_RET(retval);
default:
ERTS_INTERNAL_ERROR("Unexpected erts_port_info() result");
BIF_RET(am_internal_error);
}
}
开发者ID:rickard-green,项目名称:otp,代码行数:37,代码来源:erl_bif_port.c
示例3: port_connect_2
BIF_RETTYPE port_connect_2(BIF_ALIST_2)
{
Port* prt;
Process* rp;
Eterm pid = BIF_ARG_2;
if (is_not_internal_pid(pid)) {
error:
BIF_ERROR(BIF_P, BADARG);
}
prt = id_or_name2port(BIF_P, BIF_ARG_1);
if (!prt) {
goto error;
}
rp = erts_pid2proc(BIF_P, ERTS_PROC_LOCK_MAIN,
pid, ERTS_PROC_LOCK_LINK);
if (!rp) {
erts_smp_port_unlock(prt);
ERTS_SMP_ASSERT_IS_NOT_EXITING(BIF_P);
goto error;
}
erts_add_link(&(rp->nlinks), LINK_PID, prt->id);
erts_add_link(&(prt->nlinks), LINK_PID, pid);
erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_LINK);
prt->connected = pid; /* internal pid */
erts_smp_port_unlock(prt);
#ifdef USE_VM_PROBES
if (DTRACE_ENABLED(port_connect)) {
DTRACE_CHARBUF(process_str, DTRACE_TERM_BUF_SIZE);
DTRACE_CHARBUF(port_str, DTRACE_TERM_BUF_SIZE);
DTRACE_CHARBUF(newprocess_str, DTRACE_TERM_BUF_SIZE);
dtrace_pid_str(prt->connected, process_str);
erts_snprintf(port_str, sizeof(port_str), "%T", prt->id);
dtrace_proc_str(rp, newprocess_str);
DTRACE4(port_connect, process_str, port_str, prt->name, newprocess_str);
}
#endif
BIF_RET(am_true);
}
开发者ID:Korn1699,项目名称:otp,代码行数:44,代码来源:erl_bif_port.c
示例4: erts_debug_copy_shared_1
BIF_RETTYPE
erts_debug_copy_shared_1(BIF_ALIST_1)
{
Process* p = BIF_P;
Eterm term = BIF_ARG_1;
Uint size;
Eterm* hp;
Eterm copy;
erts_shcopy_t info;
INITIALIZE_SHCOPY(info);
size = copy_shared_calculate(term, &info);
if (size > 0) {
hp = HAlloc(p, size);
}
copy = copy_shared_perform(term, size, &info, &hp, &p->off_heap);
DESTROY_SHCOPY(info);
BIF_RET(copy);
}
开发者ID:c-bik,项目名称:otp,代码行数:19,代码来源:beam_debug.c
示例5: port_get_data_1
BIF_RETTYPE port_get_data_1(BIF_ALIST_1)
{
BIF_RETTYPE res;
Port* prt;
Eterm portid = BIF_ARG_1;
prt = id_or_name2port(BIF_P, portid);
if (!prt) {
BIF_ERROR(BIF_P, BADARG);
}
if (prt->bp == NULL) { /* MUST be CONST! */
res = prt->data;
} else {
Eterm* hp = HAlloc(BIF_P, prt->bp->used_size);
res = copy_struct(prt->data, prt->bp->used_size, &hp, &MSO(BIF_P));
}
erts_smp_port_unlock(prt);
BIF_RET(res);
}
开发者ID:Korn1699,项目名称:otp,代码行数:19,代码来源:erl_bif_port.c
示例6: os_putenv_2
Eterm
os_putenv_2(Process* p, Eterm key, Eterm value)
{
char def_buf[1024];
char *buf = NULL;
int sep_ix, i, key_len, value_len, tot_len;
key_len = is_string(key);
if (!key_len) {
error:
if (buf)
erts_free(ERTS_ALC_T_TMP, (void *) buf);
BIF_ERROR(p, BADARG);
}
if (is_nil(value))
value_len = 0;
else {
value_len = is_string(value);
if (!value_len)
goto error;
}
tot_len = key_len + 1 + value_len + 1;
if (tot_len <= sizeof(def_buf))
buf = &def_buf[0];
else
buf = erts_alloc(ERTS_ALC_T_TMP, tot_len);
i = intlist_to_buf(key, buf, key_len);
if (i != key_len)
erl_exit(1, "%s:%d: Internal error\n", __FILE__, __LINE__);
sep_ix = i;
buf[i++] = '=';
if (is_not_nil(value))
i += intlist_to_buf(value, &buf[i], value_len);
if (i != key_len + 1 + value_len)
erl_exit(1, "%s:%d: Internal error\n", __FILE__, __LINE__);
buf[i] = '\0';
if (erts_sys_putenv(buf, sep_ix)) {
goto error;
}
if (buf != &def_buf[0])
erts_free(ERTS_ALC_T_TMP, (void *) buf);
BIF_RET(am_true);
}
开发者ID:ask,项目名称:erlang-otp,代码行数:42,代码来源:erl_bif_os.c
示例7: abs_1
BIF_RETTYPE abs_1(BIF_ALIST_1)
{
Eterm res;
Sint i0, i;
Eterm* hp;
/* integer arguments */
if (is_small(BIF_ARG_1)) {
i0 = signed_val(BIF_ARG_1);
i = ERTS_SMALL_ABS(i0);
if (i0 == MIN_SMALL) {
hp = HAlloc(BIF_P, BIG_UINT_HEAP_SIZE);
BIF_RET(uint_to_big(i, hp));
} else {
BIF_RET(make_small(i));
}
} else if (is_big(BIF_ARG_1)) {
if (!big_sign(BIF_ARG_1)) {
BIF_RET(BIF_ARG_1);
} else {
int sz = big_arity(BIF_ARG_1) + 1;
Uint* x;
hp = HAlloc(BIF_P, sz); /* See note at beginning of file */
sz--;
res = make_big(hp);
x = big_val(BIF_ARG_1);
*hp++ = make_pos_bignum_header(sz);
x++; /* skip thing */
while(sz--)
*hp++ = *x++;
BIF_RET(res);
}
} else if (is_float(BIF_ARG_1)) {
FloatDef f;
GET_DOUBLE(BIF_ARG_1, f);
if (f.fd < 0.0) {
hp = HAlloc(BIF_P, FLOAT_SIZE_OBJECT);
f.fd = fabs(f.fd);
res = make_float(hp);
PUT_DOUBLE(f, hp);
BIF_RET(res);
}
else
BIF_RET(BIF_ARG_1);
}
BIF_ERROR(BIF_P, BADARG);
}
开发者ID:0x00evil,项目名称:otp,代码行数:49,代码来源:erl_bif_guard.c
示例8: os_putenv_2
BIF_RETTYPE os_putenv_2(BIF_ALIST_2)
{
char def_buf_key[STATIC_BUF_SIZE];
char def_buf_value[STATIC_BUF_SIZE];
char *key_buf, *value_buf;
key_buf = erts_convert_filename_to_native(BIF_ARG_1,def_buf_key,
STATIC_BUF_SIZE,
ERTS_ALC_T_TMP,0,0,NULL);
if (!key_buf) {
BIF_ERROR(BIF_P, BADARG);
}
value_buf = erts_convert_filename_to_native(BIF_ARG_2,def_buf_value,
STATIC_BUF_SIZE,
ERTS_ALC_T_TMP,1,0,
NULL);
if (!value_buf) {
if (key_buf != def_buf_key) {
erts_free(ERTS_ALC_T_TMP, key_buf);
}
BIF_ERROR(BIF_P, BADARG);
}
if (erts_sys_putenv(key_buf, value_buf)) {
if (key_buf != def_buf_key) {
erts_free(ERTS_ALC_T_TMP, key_buf);
}
if (value_buf != def_buf_value) {
erts_free(ERTS_ALC_T_TMP, value_buf);
}
BIF_ERROR(BIF_P, BADARG);
}
if (key_buf != def_buf_key) {
erts_free(ERTS_ALC_T_TMP, key_buf);
}
if (value_buf != def_buf_value) {
erts_free(ERTS_ALC_T_TMP, value_buf);
}
BIF_RET(am_true);
}
开发者ID:3112517927,项目名称:otp,代码行数:41,代码来源:erl_bif_os.c
示例9: check_old_code_1
BIF_RETTYPE
check_old_code_1(BIF_ALIST_1)
{
ErtsCodeIndex code_ix;
Module* modp;
Eterm res = am_false;
if (is_not_atom(BIF_ARG_1)) {
BIF_ERROR(BIF_P, BADARG);
}
code_ix = erts_active_code_ix();
modp = erts_get_module(BIF_ARG_1, code_ix);
if (modp != NULL) {
erts_rlock_old_code(code_ix);
if (modp->old.code_hdr) {
res = am_true;
}
erts_runlock_old_code(code_ix);
}
BIF_RET(res);
}
开发者ID:3112517927,项目名称:otp,代码行数:21,代码来源:beam_bif_load.c
示例10: purge_module_1
BIF_RETTYPE purge_module_1(BIF_ALIST_1)
{
int purge_res;
if (is_not_atom(BIF_ARG_1)) {
BIF_ERROR(BIF_P, BADARG);
}
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
erts_smp_block_system(0);
erts_export_consolidate();
purge_res = purge_module(atom_val(BIF_ARG_1));
erts_smp_release_system();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
if (purge_res < 0) {
BIF_ERROR(BIF_P, BADARG);
}
BIF_RET(am_true);
}
开发者ID:system,项目名称:erlang-otp,代码行数:22,代码来源:beam_bif_load.c
示例11: os_unsetenv_1
BIF_RETTYPE os_unsetenv_1(BIF_ALIST_1)
{
char *key_buf;
char buf[STATIC_BUF_SIZE];
key_buf = erts_convert_filename_to_native(BIF_ARG_1,buf,STATIC_BUF_SIZE,
ERTS_ALC_T_TMP,0,0,NULL);
if (!key_buf) {
BIF_ERROR(BIF_P, BADARG);
}
if (erts_sys_unsetenv(key_buf)) {
if (key_buf != buf) {
erts_free(ERTS_ALC_T_TMP, key_buf);
}
BIF_ERROR(BIF_P, BADARG);
}
if (key_buf != buf) {
erts_free(ERTS_ALC_T_TMP, key_buf);
}
BIF_RET(am_true);
}
开发者ID:3112517927,项目名称:otp,代码行数:22,代码来源:erl_bif_os.c
示例12: erl_ddll_loaded_drivers_0
/*
* Return list of loaded drivers {ok,[string()]}
*/
BIF_RETTYPE erl_ddll_loaded_drivers_0(BIF_ALIST_0)
{
Eterm *hp;
int need = 3;
Eterm res = NIL;
erts_driver_t *drv;
lock_drv_list();
for (drv = driver_list; drv; drv = drv->next) {
need += sys_strlen(drv->name)*2+2;
}
hp = HAlloc(BIF_P, need);
for (drv = driver_list; drv; drv = drv->next) {
Eterm l;
l = buf_to_intlist(&hp, drv->name, sys_strlen(drv->name), NIL);
res = CONS(hp,l,res);
hp += 2;
}
res = TUPLE2(hp,am_ok,res);
/* hp += 3 */
unlock_drv_list();
BIF_RET(res);
}
开发者ID:aronisstav,项目名称:otp,代码行数:25,代码来源:erl_bif_ddll.c
示例13: port_set_data_2
BIF_RETTYPE port_set_data_2(BIF_ALIST_2)
{
/*
* This is not a signal. See comment above.
*/
erts_aint_t data;
Port* prt;
prt = data_lookup_port(BIF_P, BIF_ARG_1);
if (!prt)
BIF_ERROR(BIF_P, BADARG);
if (is_immed(BIF_ARG_2)) {
data = (erts_aint_t) BIF_ARG_2;
ASSERT((data & 0x3) != 0);
}
else {
ErtsPortDataHeap *pdhp;
Uint hsize;
Eterm *hp;
hsize = size_object(BIF_ARG_2);
pdhp = erts_alloc(ERTS_ALC_T_PORT_DATA_HEAP,
sizeof(ErtsPortDataHeap) + hsize*(sizeof(Eterm)-1));
hp = &pdhp->heap[0];
pdhp->off_heap.first = NULL;
pdhp->off_heap.overhead = 0;
pdhp->data = copy_struct(BIF_ARG_2, hsize, &hp, &pdhp->off_heap);
data = (erts_aint_t) pdhp;
ASSERT((data & 0x3) == 0);
}
data = erts_smp_atomic_xchg_wb(&prt->data, data);
cleanup_old_port_data(data);
BIF_RET(am_true);
}
开发者ID:Oregionality,项目名称:otp,代码行数:38,代码来源:erl_bif_port.c
示例14: delete_module_1
BIF_RETTYPE delete_module_1(BIF_ALIST_1)
{
int res;
if (is_not_atom(BIF_ARG_1))
goto badarg;
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
erts_smp_block_system(0);
{
Module *modp = erts_get_module(BIF_ARG_1);
if (!modp) {
res = am_undefined;
}
else if (modp->old_code != 0) {
erts_dsprintf_buf_t *dsbufp = erts_create_logger_dsbuf();
erts_dsprintf(dsbufp, "Module %T must be purged before loading\n",
BIF_ARG_1);
erts_send_error_to_logger(BIF_P->group_leader, dsbufp);
res = am_badarg;
}
else {
delete_export_references(BIF_ARG_1);
delete_code(BIF_P, 0, modp);
res = am_true;
}
}
erts_smp_release_system();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
if (res == am_badarg) {
badarg:
BIF_ERROR(BIF_P, BADARG);
}
BIF_RET(res);
}
开发者ID:system,项目名称:erlang-otp,代码行数:38,代码来源:beam_bif_load.c
示例15: hipe_bifs_show_term_1
BIF_RETTYPE hipe_bifs_show_term_1(BIF_ALIST_1)
{
Eterm obj = BIF_ARG_1;
printf("0x%0*lx\r\n", 2*(int)sizeof(long), obj);
do {
Eterm *objp;
int i, ary;
if (is_list(obj)) {
objp = list_val(obj);
ary = 2;
} else if (is_boxed(obj)) {
Eterm header;
objp = boxed_val(obj);
header = objp[0];
if (is_thing(header))
ary = thing_arityval(header);
else if (is_arity_value(header))
ary = arityval(header);
else {
printf("bad header %#lx\r\n", header);
break;
}
ary += 1;
} else
break;
for (i = 0; i < ary; ++i)
printf("0x%0*lx: 0x%0*lx\r\n",
2*(int)sizeof(long), (unsigned long)&objp[i],
2*(int)sizeof(long), objp[i]);
} while (0);
erts_printf("%T", obj);
printf("\r\n");
BIF_RET(am_true);
}
开发者ID:Chylis,项目名称:otp,代码行数:37,代码来源:hipe_bif2.c
示例16: hipe_bifs_stop_hrvtime_0
BIF_RETTYPE hipe_bifs_stop_hrvtime_0(BIF_ALIST_0)
{
stop_hrvtime();
BIF_RET(am_true);
}
开发者ID:0x00evil,项目名称:otp,代码行数:5,代码来源:hipe_bif1.c
示例17: hipe_bifs_trap_count_clear_0
BIF_RETTYPE hipe_bifs_trap_count_clear_0(BIF_ALIST_0)
{
unsigned int count = hipe_trap_count;
hipe_trap_count = 0;
BIF_RET(make_small(count));
}
开发者ID:0x00evil,项目名称:otp,代码行数:6,代码来源:hipe_bif1.c
示例18: hipe_bifs_trap_count_get_0
BIF_RETTYPE hipe_bifs_trap_count_get_0(BIF_ALIST_0)
{
BIF_RET(make_small(hipe_trap_count));
}
开发者ID:0x00evil,项目名称:otp,代码行数:4,代码来源:hipe_bif1.c
示例19: erl_ddll_format_error_int_1
/*
* Backend for erl_ddll:format_error, handles all "soft" errors returned by builtins,
* possibly by calling the system specific error handler
*/
BIF_RETTYPE erl_ddll_format_error_int_1(BIF_ALIST_1)
{
Process *p = BIF_P;
Eterm code_term = BIF_ARG_1;
char *errstring = NULL;
int errint;
int len;
Eterm ret = NIL;
Eterm *hp;
/* These errors can only appear in the erlang interface, not in the interface provided
to drivers... */
switch (code_term) {
case am_inconsistent:
errstring = "Driver name and/or driver options are inconsistent with "
"currently loaded driver";
break;
case am_linked_in_driver:
errstring = "Driver is statically linked and "
"cannot be loaded/unloaded";
break;
case am_permanent:
errstring = "DDLL driver is permanent an can not be unloaded/loaded";
break;
case am_not_loaded:
errstring = "DDLL driver is not loaded";
break;
case am_not_loaded_by_this_process:
errstring = "DDLL driver was not loaded by this process";
break;
case am_not_pending:
errstring = "DDLL load not pending for this driver name";
break;
case am_already_loaded:
errstring = "DDLL driver is already loaded successfully";
break;
case am_pending_reload:
errstring = "Driver reloading is already pending";
break;
case am_pending_process:
errstring = "Driver is loaded by others when attempting "
"option {reload, pending_driver}";
break;
default:
/* A "real" error, we translate the atom to a code and translate the code
to a string in the same manner as in the interface provided to drivers... */
if (errdesc_to_code(code_term,&errint) != 0) {
goto error;
}
lock_drv_list();
errstring = erts_ddll_error(errint);
unlock_drv_list();
break;
}
if (errstring == NULL) {
goto error;
}
len = sys_strlen(errstring);
hp = HAlloc(p, 2 * len);
ret = buf_to_intlist(&hp, errstring, len, NIL);
BIF_RET(ret);
error:
BIF_ERROR(p,BADARG);
}
开发者ID:aronisstav,项目名称:otp,代码行数:68,代码来源:erl_bif_ddll.c
示例20: erl_ddll_info_2
/*
* More detailed info about loaded drivers:
* item is processes, driver_options, port_count, linked_in_driver,
* permanent, awaiting_load, awaiting_unload
*/
BIF_RETTYPE erl_ddll_info_2(BIF_ALIST_2)
{
Process *p = BIF_P;
Eterm name_term = BIF_ARG_1;
Eterm item = BIF_ARG_2;
char *name = NULL;
Eterm res = NIL;
erts_driver_t *drv;
ProcEntryInfo *pei = NULL;
int num_pei;
Eterm *hp;
int i;
Uint filter;
int have_lock = 0;
if ((name = pick_list_or_atom(name_term)) == NULL) {
goto error;
}
if (!is_atom(item)) {
goto error;
}
lock_drv_list();
have_lock = 1;
if ((drv = lookup_driver(name)) == NULL) {
goto error;
}
switch (item) {
case am_processes:
filter = ERL_DE_PROC_LOADED;
break;
case am_driver_options:
if (drv->handle == NULL) {
res = am_linked_in_driver;
} else {
Uint start_flags = drv->handle->flags & ERL_FL_CONSISTENT_MASK;
/* Cheating, only one flag for now... */
if (start_flags & ERL_DE_FL_KILL_PORTS) {
Eterm *myhp;
myhp = HAlloc(p,2);
res = CONS(myhp,am_kill_ports,NIL);
} else {
res = NIL;
}
}
goto done;
case am_port_count:
if (drv->handle == NULL) {
res = am_linked_in_driver;
} else if (drv->handle->status == ERL_DE_PERMANENT) {
res = am_permanent;
} else {
res = make_small(erts_atomic32_read_nob(&drv->handle->port_count));
}
goto done;
case am_linked_in_driver:
if (drv->handle == NULL){
res = am_true;
} else {
res = am_false;
}
goto done;
case am_permanent:
if (drv->handle != NULL && drv->handle->status == ERL_DE_PERMANENT) {
res = am_true;
} else {
res = am_false;
}
goto done;
case am_awaiting_load:
filter = ERL_DE_PROC_AWAIT_LOAD;
break;
case am_awaiting_unload:
filter = ERL_DE_PROC_AWAIT_UNLOAD;
break;
default:
goto error;
}
if (drv->handle == NULL) {
res = am_linked_in_driver;
goto done;
} else if (drv->handle->status == ERL_DE_PERMANENT) {
res = am_permanent;
goto done;
}
num_pei = build_proc_info(drv->handle, &pei, filter);
if (!num_pei) {
goto done;
}
hp = HAlloc(p,num_pei * (2+3));
for (i = 0; i < num_pei; ++ i) {
Eterm tpl = TUPLE2(hp,pei[i].pid,make_small(pei[i].count));
//.........这里部分代码省略.........
开发者ID:aronisstav,项目名称:otp,代码行数:101,代码来源:erl_bif_ddll.c
注:本文中的BIF_RET函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论