• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Int32_val函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Int32_val函数的典型用法代码示例。如果您正苦于以下问题:C++ Int32_val函数的具体用法?C++ Int32_val怎么用?C++ Int32_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Int32_val函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: caml_int32_compare

CAMLprim value caml_int32_compare(value v1, value v2)
{
  int32 i1 = Int32_val(v1);
  int32 i2 = Int32_val(v2);
  int res = (i1 > i2) - (i1 < i2);
  return Val_int(res);
}
开发者ID:dirkdokter,项目名称:pprz-installer-fedora,代码行数:7,代码来源:ints.c


示例2: caml_int32_mod

CAMLprim value caml_int32_mod(value v1, value v2)
{
  int32 dividend = Int32_val(v1);
  int32 divisor = Int32_val(v2);
  if (divisor == 0) caml_raise_zero_divide();
  /* PR#4740: on some processors, modulus crashes if division overflows.
     Implement the same behavior as for type "int". */
  if (dividend == (1<<31) && divisor == -1) return caml_copy_int32(0);
#ifdef NONSTANDARD_DIV_MOD
  return caml_copy_int32(caml_safe_mod(dividend, divisor));
#else
  return caml_copy_int32(dividend % divisor);
#endif
}
开发者ID:dirkdokter,项目名称:pprz-installer-fedora,代码行数:14,代码来源:ints.c


示例3: caml_sfIpAddress_fromInteger

CAMLprim value
caml_sfIpAddress_fromInteger(value int_addr)
{
    sfUint32 address = Int32_val(int_addr);
    sfIpAddress addr = sfIpAddress_fromInteger(address);
    return Val_sfIpAddress(addr);
}
开发者ID:LorantK,项目名称:PC2R,代码行数:7,代码来源:SFIpAddress_cstub.c


示例4: ml_gdk_property_change

CAMLprim value ml_gdk_property_change (value window, value property, value type,
                              value mode, value xdata)
{
    int format = Xdata_val (Field(xdata,0));
    value data = Field(xdata,1);
    int nelems = (format == 8 ? string_length (data) : Wosize_val(data));
    guchar *sdata;
    int i;
    switch (format) {
    case 16:
        sdata = calloc(nelems, sizeof(short)); 
        for (i=0; i<nelems; i++)
            ((gushort*)sdata)[i] = Int_val(Field(data,i));
        break;
    case 32:
        sdata = calloc(nelems, sizeof(long));
        for (i=0; i<nelems; i++)
            ((gulong*)sdata)[i] = Int32_val(Field(data,i)); 
        break;
    default:
        sdata = (guchar*)data;
    }
    gdk_property_change (GdkWindow_val(window), GdkAtom_val(property),
                         GdkAtom_val(type), format, Property_mode_val(mode),
                         sdata, nelems);
    if (format != 8) free(sdata);
    return Val_unit;
}
开发者ID:CRogers,项目名称:obc,代码行数:28,代码来源:ml_gdk.c


示例5: caml_udpv4_bind

/* Bind a UDP socket to a local v4 addr and return it */
CAMLprim value
caml_udpv4_bind(value v_ipaddr, value v_port)
{
  CAMLparam2(v_ipaddr, v_port);
  CAMLlocal2(v_ret, v_err);
  int s = socket(PF_INET, SOCK_DGRAM, 0);
  if (s < 0) {
    v_err = caml_copy_string(strerror(errno));
    Val_Err(v_ret, v_err);
    CAMLreturn(v_ret);
  }
  setnonblock(s);
  struct sockaddr_in sa;
  bzero(&sa, sizeof sa);
  sa.sin_family = AF_INET;
  sa.sin_addr.s_addr = ntohl(Int32_val(v_ipaddr));
  sa.sin_port = htons(Int_val(v_port));
 
  int r = bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr));
  if (r < 0) {
    v_err = caml_copy_string(strerror(errno));
    Val_Err(v_ret, v_err);
    close(s);
    CAMLreturn(v_ret);
  }
  Val_OK(v_ret, Val_int(s));
  CAMLreturn(v_ret);
}
开发者ID:blackswanburst,项目名称:mirage,代码行数:29,代码来源:socket_stubs.c


示例6: caml_udpv4_sendto

CAMLprim value
caml_udpv4_sendto(value v_fd, value v_str, value v_off, value v_len, value v_dst)
{
  CAMLparam5(v_fd, v_str, v_off, v_len, v_dst);
  CAMLlocal2(v_ret, v_err);
  unsigned char *buf = String_val(v_str) + Int_val(v_off);
  size_t len = Int_val(v_len);
  int fd = Int_val(v_fd);
  struct sockaddr_in sa;
  socklen_t sa_len = sizeof(sa);
  bzero(&sa, sizeof sa);
  sa.sin_family = AF_INET;
  sa.sin_addr.s_addr = htonl(Int32_val(Field(v_dst, 0)));
  sa.sin_port = htons(Int_val(Field(v_dst, 1)));

  int r = sendto(fd, buf, len, MSG_DONTWAIT, (struct sockaddr *)&sa, sa_len);
  if (r < 0) {
    if (errno == EAGAIN || errno==EWOULDBLOCK)
      Val_WouldBlock(v_ret);
    else {
      v_err = caml_copy_string(strerror(errno));
      Val_Err(v_ret, v_err);
    }
  } else {
    Val_OK(v_ret, Val_int(r));
  }
  CAMLreturn(v_ret);
}
开发者ID:blackswanburst,项目名称:mirage,代码行数:28,代码来源:socket_stubs.c


示例7: caml_tcpv4_connect

CAMLprim value
caml_tcpv4_connect(value v_ipaddr, value v_port)
{
  CAMLparam2(v_ipaddr, v_port);
  CAMLlocal2(v_ret, v_err);
  int s,r;
  struct sockaddr_in sa;
  bzero(&sa, sizeof sa);
  sa.sin_family = AF_INET;
  sa.sin_port = htons(Int_val(v_port));
  sa.sin_addr.s_addr = ntohl(Int32_val(v_ipaddr));
  s = socket(PF_INET, SOCK_STREAM, 0);
  if (s < 0) {
    v_err = caml_copy_string(strerror(errno));
    Val_Err(v_ret, v_err);
    CAMLreturn(v_ret);
  }
  setnonblock(s); 
  r = connect(s, (struct sockaddr *)&sa, sizeof(struct sockaddr));
  if (r == 0 || (r == -1 && errno == EINPROGRESS)) {
    Val_OK(v_ret, Val_int(s));
  } else {
    v_err = caml_copy_string(strerror(errno));
    Val_Err(v_ret, v_err);
    close(s);
  }
  CAMLreturn(v_ret);
}
开发者ID:blackswanburst,项目名称:mirage,代码行数:28,代码来源:socket_stubs.c


示例8: c_sprint_int32

value
c_sprint_int32(value s, value index, value x) {
  CAMLparam3 (s, index, x);
  int32_t *p = (int32_t*) (String_val(s) + Int_val(index));
  *p = (int32_t)Int32_val(x);
  CAMLreturn (Val_unit);
}
开发者ID:AE4317group07,项目名称:paparazzi,代码行数:7,代码来源:convert.c


示例9: set_ipaddr

static void
set_ipaddr(struct sockaddr *sa, value ipaddr)
{
  struct sockaddr_in *sin = (struct sockaddr_in *)sa;
  sin->sin_family = AF_INET;
  sin->sin_addr.s_addr = Int32_val(ipaddr);
  return;
}
开发者ID:jkilburg,项目名称:ocaml-lldp,代码行数:8,代码来源:netdevice_stub.c


示例10: tbstub_change_cell

void tbstub_change_cell(value caml_x, value caml_y, value caml_ch, value caml_fg, value caml_bg) {

	CAMLparam5(caml_x, caml_y, caml_ch, caml_fg, caml_bg);

	tb_change_cell(Int_val(caml_x), Int_val(caml_y), Int32_val(caml_ch), Int_val(caml_fg), Int_val(caml_bg));

	CAMLreturn0;
}
开发者ID:pacemkr,项目名称:ocaml-termbox,代码行数:8,代码来源:termbox_stubs.c


示例11: ml_pixelColor

CAMLprim value ml_pixelColor(value dst,value x,value y, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  int r;
  r=pixelColor(sur,Int_val(x),Int_val(y),Int32_val(col));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:8,代码来源:sdlgfx_stub.c


示例12: caml_epoll_ctl_mod

CAMLprim void caml_epoll_ctl_mod(value epfd, value fd, value flags)
{
    struct epoll_event ev;
    ev.events = Int32_val(flags);
    ev.data.fd = Int_val(fd);

    int ret = epoll_ctl(Int_val(epfd), EPOLL_CTL_MOD, Int_val(fd), &ev);
    if (ret == -1) uerror("epoll_ctl_mod", Nothing);
    return;
}
开发者ID:camlspotter,项目名称:echoserver,代码行数:10,代码来源:server_ocaml_epoll.c


示例13: caml_gnttab_grant_access

CAMLprim value
caml_gnttab_grant_access(value v_ref, value v_bs, value v_domid, value v_readonly)
{
    CAMLparam4(v_ref, v_bs, v_domid, v_readonly);
    grant_ref_t ref = Int32_val(v_ref);
    char *page = String_val(Field(v_bs, 0)) + (Int_val(Field(v_bs,1)) / 8);
    ASSERT(((unsigned long)page) % PAGE_SIZE == 0);
    gnttab_grant_access(ref, page, Int_val(v_domid), Bool_val(v_readonly));
    CAMLreturn(Val_unit);
}
开发者ID:cgreenhalgh,项目名称:mirage,代码行数:10,代码来源:gnttab_stubs.c


示例14: caml_ba_set_aux

static value caml_ba_set_aux(value vb, value * vind, intnat nind, value newval)
{
  struct caml_ba_array * b = Caml_ba_array_val(vb);
  intnat index[CAML_BA_MAX_NUM_DIMS];
  int i;
  intnat offset;

  /* Check number of indices = number of dimensions of array
     (maybe not necessary if ML typing guarantees this) */
  if (nind != b->num_dims)
    caml_invalid_argument("Bigarray.set: wrong number of indices");
  /* Compute offset and check bounds */
  for (i = 0; i < b->num_dims; i++) index[i] = Long_val(vind[i]);
  offset = caml_ba_offset(b, index);
  /* Perform write */
  switch (b->flags & CAML_BA_KIND_MASK) {
  default:
    Assert(0);
#ifdef _KERNEL
#else
  case CAML_BA_FLOAT32:
    ((float *) b->data)[offset] = Double_val(newval); break;
  case CAML_BA_FLOAT64:
    ((double *) b->data)[offset] = Double_val(newval); break;
#endif
  case CAML_BA_SINT8:
  case CAML_BA_UINT8:
    ((int8 *) b->data)[offset] = Int_val(newval); break;
  case CAML_BA_SINT16:
  case CAML_BA_UINT16:
    ((int16 *) b->data)[offset] = Int_val(newval); break;
  case CAML_BA_INT32:
    ((int32 *) b->data)[offset] = Int32_val(newval); break;
  case CAML_BA_INT64:
    ((int64 *) b->data)[offset] = Int64_val(newval); break;
  case CAML_BA_NATIVE_INT:
    ((intnat *) b->data)[offset] = Nativeint_val(newval); break;
  case CAML_BA_CAML_INT:
    ((intnat *) b->data)[offset] = Long_val(newval); break;
#ifdef _KERNEL
#else
  case CAML_BA_COMPLEX32:
    { float * p = ((float *) b->data) + offset * 2;
      p[0] = Double_field(newval, 0);
      p[1] = Double_field(newval, 1);
      break; }
  case CAML_BA_COMPLEX64:
    { double * p = ((double *) b->data) + offset * 2;
      p[0] = Double_field(newval, 0);
      p[1] = Double_field(newval, 1);
      break; }
#endif
  }
  return Val_unit;
}
开发者ID:avsm,项目名称:mirage-kfreebsd,代码行数:55,代码来源:bigarray_stubs.c


示例15: ml_filledCircleColor

CAMLprim value ml_filledCircleColor(value dst,value p,value ra, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect prect;
  int r;

  SDLRect_of_value(&prect,p);
  r=filledCircleColor(sur,prect.x,prect.y,Int_val(ra),Int32_val(col));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:11,代码来源:sdlgfx_stub.c


示例16: caml_SDL_SetColorKey

CAMLprim value
caml_SDL_SetColorKey(value surface, value flag, value key)
{
    /* TODO:
     *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
     */
    int r = SDL_SetColorKey(
        SDL_Surface_val(surface), Bool_val(flag), Int32_val(key));
    if (r) caml_failwith("Sdlsurface.set_color_key");
    return Val_unit;
}
开发者ID:fccm,项目名称:OCamlSDL2,代码行数:11,代码来源:sdlsurface_stub.c


示例17: ml_characterColor

CAMLprim value ml_characterColor(value dst,value p,value c,value color)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect rect;
  int r;

  SDLRect_of_value(&rect,p);
  r=characterColor(sur,rect.x,rect.y,(char) c,Int32_val(color));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:11,代码来源:sdlgfx_stub.c


示例18: ml_stringColor

CAMLprim value ml_stringColor(value dst,value p,value c,value color)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect rect;
  int r;

  SDLRect_of_value(&rect,p);
  r=stringColor(sur,rect.x,rect.y,String_val(c),Int32_val(color));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:11,代码来源:sdlgfx_stub.c


示例19: ml_aaellipseColor

CAMLprim value ml_aaellipseColor(value dst,value p,value rp, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect prect,rprect;
  int r;

  SDLRect_of_value(&prect,p);
  SDLRect_of_value(&rprect,rp);
  r=aaellipseColor(sur,prect.x,prect.y,rprect.x,rprect.y,Int32_val(col));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:12,代码来源:sdlgfx_stub.c


示例20: ml_boxColor

CAMLprim value ml_boxColor(value dst,value p1,value p2, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect rect1,rect2;
  int r;

  SDLRect_of_value(&rect1,p1);
  SDLRect_of_value(&rect2,p2);
  r=boxColor(sur,rect1.x,rect1.y,rect2.x,rect2.y,Int32_val(col));

  return Val_bool(r);
}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:12,代码来源:sdlgfx_stub.c



注:本文中的Int32_val函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Int32x32To64函数代码示例发布时间:2022-05-30
下一篇:
C++ Int32函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap