当前位置: 首页>>代码示例>>C++>>正文


C++ Data_custom_val函数代码示例

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


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

示例1: caml_Int64_val

CAMLexport int64 caml_Int64_val(value v)
{
  union { int32 i[2]; int64 j; } buffer;
  buffer.i[0] = ((int32 *) Data_custom_val(v))[0];
  buffer.i[1] = ((int32 *) Data_custom_val(v))[1];
  return buffer.j;
}
开发者ID:dirkdokter,项目名称:pprz-installer-fedora,代码行数:7,代码来源:ints.c

示例2: compare_pointers

static int compare_pointers(value l_, value r_)
{
  /* pointer comparison */
  intptr_t l = (intptr_t)*(void **)Data_custom_val(l_);
  intptr_t r = (intptr_t)*(void **)Data_custom_val(r_);
  return (l > r) - (l < r);
}
开发者ID:braibant,项目名称:ocaml-ctypes,代码行数:7,代码来源:managed_buffer_stubs.c

示例3: serialize_nat

static void serialize_nat(value nat,
                          uintnat * wsize_32,
                          uintnat * wsize_64)
{
  mlsize_t len = Wosize_val(nat) - 1;

#ifdef ARCH_SIXTYFOUR
  len = len * 2; /* two 32-bit words per 64-bit digit  */
  if (len >= ((mlsize_t)1 << 32))
    failwith("output_value: nat too big");
#endif
  serialize_int_4((int32) len);
#if defined(ARCH_SIXTYFOUR) && defined(ARCH_BIG_ENDIAN)
  { int32 * p;
    mlsize_t i;
    for (i = len, p = Data_custom_val(nat); i > 0; i -= 2, p += 2) {
      serialize_int_4(p[1]);    /* low 32 bits of 64-bit digit */
      serialize_int_4(p[0]);    /* high 32 bits of 64-bit digit */
    }
  }
#else
  serialize_block_4(Data_custom_val(nat), len);
#endif
  *wsize_32 = len * 4;
  *wsize_64 = len * 4;
}
开发者ID:retired-camels,项目名称:ocaml,代码行数:26,代码来源:nat_stubs.c

示例4: grappa_CAML_better_capping

value grappa_CAML_better_capping (value c_gene1, value c_gene2, value num_genes)
{
    CAMLparam3(c_gene1,c_gene2,num_genes);
    int NUM_GENES = Int_val(num_genes);
    long dims[1]; dims[0] = NUM_GENES;
    struct genome_struct *g1, *g2;
    g1 = (struct genome_struct *) Data_custom_val (c_gene1);
    g2 = (struct genome_struct *) Data_custom_val (c_gene2);
    struct genome_struct * out_genome_list;

    out_genome_list = (struct genome_struct *) malloc (sizeof (struct genome_struct) );
    if ( out_genome_list == ( struct genome_struct * ) NULL )
        failwith ("ERROR: genome_list in grappa_CAML_better_capping is NULL" );
    out_genome_list[0].gnamePtr =( char * ) malloc ( MAX_NAME * sizeof ( char ) );
    sprintf (out_genome_list[0].gnamePtr, "%i", 0);
    if ( out_genome_list[0].gnamePtr == ( char * ) NULL )
        failwith( "ERROR: gname of genome_list in grappa_CAML_better_capping is NULL" );
    out_genome_list[0].genes =( int * ) malloc ( 3*NUM_GENES * sizeof ( int ) );
    out_genome_list[0].delimiters = (int *) malloc (NUM_GENES * sizeof (int) );
    out_genome_list[0].magic_number = GRAPPA_MAGIC_NUMBER;
    out_genome_list[0].encoding = NULL; //we don't need encoding and gnamePtr;
    better_capping (g1->genes,g2->genes,NUM_GENES,g1->delimiters,g2->delimiters,g1->deli_num,g2->deli_num,out_genome_list);
    struct genome_arr_t *out_genome_arr;
    CAMLlocal1 (c_genome_arr);
    c_genome_arr = alloc_custom(&genomeArrOps, sizeof(struct genome_arr_t), 1, 10000);
    out_genome_arr = (struct genome_arr_t *) Data_custom_val(c_genome_arr);
    out_genome_arr->magic_number = GRAPPA_MAGIC_NUMBER;
    out_genome_arr->genome_ptr = out_genome_list;    
    assert(GRAPPA_MAGIC_NUMBER == out_genome_list[0].magic_number);
    out_genome_arr->num_genome = 1;
    out_genome_arr->num_gene = NUM_GENES;
    CAMLreturn(c_genome_arr); 

}
开发者ID:amnh,项目名称:poy5,代码行数:34,代码来源:grappa_interface.c

示例5: caml_cairo_compare_pointers

static int caml_cairo_compare_pointers(value v1, value v2)
{
  void *p1 = * (void **) Data_custom_val(v1);
  void *p2 = * (void **) Data_custom_val(v2);
  if (p1 == p2) return(0);
  else if (p1 < p2) return(-1);
  else return(1);
}
开发者ID:hcarty,项目名称:ocaml-cairo,代码行数:8,代码来源:cairo_ocaml_types.c

示例6: camlidl_custom_mpq_compare

int camlidl_custom_mpq_compare(value val1, value val2)
{
    int res;
    __mpq_struct* mpq1;
    __mpq_struct* mpq2;

    mpq1 = (__mpq_struct*)(Data_custom_val(val1));
    mpq2 = (__mpq_struct*)(Data_custom_val(val2));
    res = mpq_cmp(mpq1,mpq2);
    res = res > 0 ? 1 : res==0 ? 0 : -1;
    return res;
}
开发者ID:nberth,项目名称:mlgmpidl,代码行数:12,代码来源:gmp_caml.c

示例7: camlidl_custom_mpq2_compare

int camlidl_custom_mpq2_compare(value val1, value val2)
{
    CAMLparam2(val1,val2);
    int res;
    __mpq_struct** mpq1;
    __mpq_struct** mpq2;

    mpq1 = (__mpq_struct**)(Data_custom_val(val1));
    mpq2 = (__mpq_struct**)(Data_custom_val(val2));
    res = mpq_cmp(*mpq1,*mpq2);
    res = res > 0 ? 1 : res==0 ? 0 : -1;
    CAMLreturn(res);
}
开发者ID:nberth,项目名称:mlgmpidl,代码行数:13,代码来源:gmp_caml.c

示例8: caml_copy_int64

CAMLexport value caml_copy_int64(int64 i)
{
  value res = caml_alloc_custom(&caml_int64_ops, 8, 0, 1);
#ifndef ARCH_ALIGN_INT64
  Int64_val(res) = i;
#else
  union { int32 i[2]; int64 j; } buffer;
  buffer.j = i;
  ((int32 *) Data_custom_val(res))[0] = buffer.i[0];
  ((int32 *) Data_custom_val(res))[1] = buffer.i[1];
#endif
  return res;
}
开发者ID:dirkdokter,项目名称:pprz-installer-fedora,代码行数:13,代码来源:ints.c

示例9: camlidl_custom_gmp_randstate2_finalize

void camlidl_custom_gmp_randstate2_finalize(value val)
{
    CAMLparam1(val);
    __gmp_randstate_struct** gmp_randstate = (__gmp_randstate_struct**)(Data_custom_val(val));
    gmp_randclear(*gmp_randstate);
    free(*gmp_randstate);
}
开发者ID:nberth,项目名称:mlgmpidl,代码行数:7,代码来源:gmp_caml.c

示例10: camlidl_custom_mpz2_hash

long camlidl_custom_mpz2_hash(value val)
{
    CAMLparam1(val);
    __mpz_struct** mpz = (__mpz_struct**)(Data_custom_val(val));
    long hash = mpz_get_si(*mpz);
    CAMLreturn(hash);
}
开发者ID:nberth,项目名称:mlgmpidl,代码行数:7,代码来源:gmp_caml.c

示例11: camlidl_custom_mpz2_finalize

void camlidl_custom_mpz2_finalize(value val)
{
    CAMLparam1(val);
    __mpz_struct** mpz = (__mpz_struct**)(Data_custom_val(val));
    mpz_clear(*mpz);
    free(*mpz);
}
开发者ID:nberth,项目名称:mlgmpidl,代码行数:7,代码来源:gmp_caml.c

示例12: caml_copy_semaphore

CAMLprim value caml_copy_semaphore(sem_t *s) {
  CAMLparam0();
  CAMLlocal1(v);
  v = caml_alloc_custom(&semaphore_custom_ops, sizeof(sem_t *), 0, 1);
  memcpy(Data_custom_val(v), &s, sizeof(sem_t *));
  CAMLreturn(v);
}
开发者ID:mwweissmann,项目名称:ocaml-posix-semaphore,代码行数:7,代码来源:semaphore.c

示例13: mmdb_ml_dump_per_ip

CAMLprim value mmdb_ml_dump_per_ip(value ip, value mmdb)
{
  CAMLparam2(ip, mmdb);
  CAMLlocal1(pulled_string);

  unsigned int len = caml_string_length(ip);
  char *as_string = caml_strdup(String_val(ip));

  if (strlen(as_string) != (size_t)len) {
    caml_failwith("Could not copy IP address properly");
  }

  MMDB_s *as_mmdb = (MMDB_s*)Data_custom_val(mmdb);
  int gai_error = 0, mmdb_error = 0;

  MMDB_lookup_result_s *result = caml_stat_alloc(sizeof(*result));
  *result = MMDB_lookup_string(as_mmdb, as_string, &gai_error, &mmdb_error);
  MMDB_entry_data_list_s *entry_data_list = NULL;
  int status = MMDB_get_entry_data_list(&result->entry, &entry_data_list);
  check_status(status);
  char *pulled_from_db = data_from_dump(entry_data_list);
  pulled_string = caml_copy_string(pulled_from_db);
  caml_stat_free(result);
  caml_stat_free(as_string);
  caml_stat_free(pulled_from_db);
  free(entry_data_list);
  as_mmdb = NULL;
  CAMLreturn(pulled_string);
}
开发者ID:fxfactorial,项目名称:ocaml-maxminddb,代码行数:29,代码来源:maxminddb_stubs.c

示例14: caml_extunix_ssi_signo_sys

CAMLprim
value caml_extunix_ssi_signo_sys(value vssi)
{
  CAMLparam1(vssi);
  struct signalfd_siginfo *ssi = (void *)(Data_custom_val(vssi));
  CAMLreturn(Val_int(caml_rev_convert_signal_number(ssi->ssi_signo)));
}
开发者ID:UnixJunkie,项目名称:extunix,代码行数:7,代码来源:signalfd.c

示例15: mmdb_ml_open

CAMLprim value mmdb_ml_open(value s)
{
  CAMLparam1(s);
  CAMLlocal1(mmdb_handle);

  if (polymorphic_variants.poly_bool == 0  ||
      polymorphic_variants.poly_float == 0 ||
      polymorphic_variants.poly_int == 0   ||
      polymorphic_variants.poly_string == 0) {
    polymorphic_variants.poly_bool = caml_hash_variant("Bool");
    polymorphic_variants.poly_float = caml_hash_variant("Float");
    polymorphic_variants.poly_int = caml_hash_variant("Int");
    polymorphic_variants.poly_string = caml_hash_variant("String");
  }

  unsigned int len = caml_string_length(s);
  char *copied = caml_strdup(String_val(s));
  if (strlen(copied) != (size_t)len) {
    caml_failwith("Could not open MMDB database");
  }

  MMDB_s *this_db = caml_stat_alloc(sizeof(*this_db));
  int status = MMDB_open(copied, MMDB_MODE_MMAP, this_db);
  mmdb_handle = caml_alloc_custom(&mmdb_custom_ops, sizeof(*this_db), 0, 1);
  check_status(status);
  memcpy(Data_custom_val(mmdb_handle), this_db, sizeof(*this_db));
  caml_stat_free(this_db);
  caml_stat_free(copied);
  CAMLreturn(mmdb_handle);
}
开发者ID:fxfactorial,项目名称:ocaml-maxminddb,代码行数:30,代码来源:maxminddb_stubs.c


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