本文整理汇总了C++中Val_long函数的典型用法代码示例。如果您正苦于以下问题:C++ Val_long函数的具体用法?C++ Val_long怎么用?C++ Val_long使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Val_long函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unix_lseek
CAMLprim value unix_lseek(value fd, value ofs, value cmd)
{
file_offset ret;
caml_enter_blocking_section();
ret = lseek(Int_val(fd), Long_val(ofs),
seek_command_table[Int_val(cmd)]);
caml_leave_blocking_section();
if (ret == -1) uerror("lseek", Nothing);
if (ret > Max_long) unix_error(EOVERFLOW, "lseek", Nothing);
return Val_long(ret);
}
示例2: caml_ml_input_char
CAMLprim value caml_ml_input_char(value vchannel)
{
CAMLparam1 (vchannel);
struct channel * channel = Channel(vchannel);
unsigned char c;
Lock(channel);
c = getch(channel);
Unlock(channel);
CAMLreturn (Val_long(c));
}
示例3: bigstring_pwrite_assume_fd_is_nonblocking_stub
CAMLprim value bigstring_pwrite_assume_fd_is_nonblocking_stub(
value v_fd, value v_offset, value v_pos, value v_len, value v_bstr)
{
char *bstr = get_bstr(v_bstr, v_pos);
size_t len = Long_val(v_len);
ssize_t written;
written = pwrite(Int_val(v_fd), bstr, len, Long_val(v_offset));
if (written == -1) uerror("bigstring_pwrite_assume_fd_is_nonblocking_stub", Nothing);
return Val_long(written);
}
示例4: hh_hash_used_slots
CAMLprim value hh_hash_used_slots(void) {
CAMLparam0();
uint64_t count = 0;
uintptr_t i = 0;
for (i = 0; i < hashtbl_size; ++i) {
if (hashtbl[i].addr != NULL) {
count++;
}
}
CAMLreturn(Val_long(count));
}
示例5: caml_sys_get_config
CAMLprim value caml_sys_get_config(value unit)
{
CAMLparam0 (); /* unit is unused */
CAMLlocal2 (result, ostype);
ostype = caml_copy_string(OCAML_OS_TYPE);
result = caml_alloc_small (2, 0);
Field(result, 0) = ostype;
Field(result, 1) = Val_long (8 * sizeof(value));
CAMLreturn (result);
}
示例6: caml_ml_input_scan_line
CAMLprim value caml_ml_input_scan_line(value vchannel)
{
CAMLparam1 (vchannel);
struct channel * channel = Channel(vchannel);
intnat res;
Lock(channel);
res = caml_input_scan_line(channel);
Unlock(channel);
CAMLreturn (Val_long(res));
}
示例7: svec_getvecword
value svec_getvecword (value vec)
{
value res;
res = Val_long(*(unsigned int*) String_val(vec));
if (jit_ffi_debug)
fprintf(stderr,"svec_getvecword returning 0x%8.8x [0x%8.8x].\n",
(unsigned int) Long_val(res), * ((unsigned int*) (String_val(vec))));
return res;
}
示例8: CAMLlocal2
static void invoke_completion_callback
(long id, long len, long errCode, long action) {
CAMLlocal2 (err, name);
value args[4];
err = Val_long(0);
if (errCode != NO_ERROR) {
len = -1;
win32_maperr (errCode);
err = unix_error_of_code(errno);
}
name = copy_string (action_name[action]);
D(printf("Action %s completed: id %ld -> len %ld / err %d (errCode %ld)\n",
action_name[action], id, len, errno, errCode));
args[0] = Val_long(id);
args[1] = Val_long(len);
args[2] = err;
args[3] = name;
caml_callbackN(completionCallback, 4, args);
D(printf("Callback performed\n"));
}
示例9: int_of_string
value int_of_string(value s) /* ML */
{
long res;
int sign;
int base;
char * p;
int c, d;
p = String_val(s);
if (*p == 0) failwith("int_of_string");
sign = 1;
if (*p == '-') {
sign = -1;
p++;
}
base = 10;
if (*p == '0') {
switch (p[1]) {
case 'x':
case 'X':
base = 16;
p += 2;
break;
case 'o':
case 'O':
base = 8;
p += 2;
break;
case 'b':
case 'B':
base = 2;
p += 2;
break;
}
}
res = 0;
while (1) {
c = *p;
if (c >= '0' && c <= '9')
d = c - '0';
else if (c >= 'A' && c <= 'F')
d = c - 'A' + 10;
else if (c >= 'a' && c <= 'f')
d = c - 'a' + 10;
else
break;
if (d >= base) break;
res = base * res + d;
p++;
}
if (*p != 0)
failwith("int_of_string");
return Val_long(sign < 0 ? -res : res);
}
示例10: bigstring_pread_assume_fd_is_nonblocking_stub
CAMLprim value bigstring_pread_assume_fd_is_nonblocking_stub(
value v_fd, value v_offset, value v_pos, value v_len, value v_bstr)
{
char *bstr = get_bstr(v_bstr, v_pos);
size_t len = Long_val(v_len);
ssize_t n_read;
n_read = pread(Int_val(v_fd), bstr, len, Long_val(v_offset));
if (n_read == -1) uerror("bigstring_pread_assume_fd_is_nonblocking_stub", Nothing);
return Val_long(n_read);
}
示例11: hh_dep_used_slots
value hh_dep_used_slots() {
CAMLparam0();
uint64_t count = 0;
uintptr_t slot = 0;
for (slot = 0; slot < DEP_SIZE; ++slot) {
if (deptbl[slot]) {
count++;
}
}
CAMLreturn(Val_long(count));
}
示例12: hh_hash_used_slots
value hh_hash_used_slots() {
CAMLparam0();
uint64_t count = 0;
uintptr_t i = 0;
for (i = 0; i < HASHTBL_SIZE; ++i) {
if (hashtbl[i].addr != NULL) {
count++;
}
}
CAMLreturn(Val_long(count));
}
示例13: caml_gc_major_slice
CAMLprim value caml_gc_major_slice (value v)
{
intnat res;
CAMLassert (Is_long (v));
caml_ev_pause(EV_PAUSE_GC);
caml_empty_minor_heap ();
res = caml_major_collection_slice(Long_val(v), 0);
caml_ev_resume();
caml_handle_gc_interrupt();
return Val_long (res);
}
示例14: unix_lseek
CAMLprim value unix_lseek(value fd, value ofs, value cmd)
{
__int64 ret;
ret = caml_set_file_pointer(Handle_val(fd), Long_val(ofs),
seek_command_table[Int_val(cmd)]);
if (ret > Max_long) {
win32_maperr(ERROR_ARITHMETIC_OVERFLOW);
uerror("lseek", Nothing);
}
return Val_long(ret);
}
示例15: netsys_s_read_int4_64
CAMLprim value netsys_s_read_int4_64(value sv, value pv)
{
char *s;
intnat p;
s = String_val(sv);
p = Long_val(pv);
/* careful: the result of ntohl is unsigned. We first have to
convert it to signed, then extend it to intnat.
*/
return Val_long((int) (ntohl (*((unsigned int *) (s+p)))));
}