Exemplo n.º 1
0
int main (int argc, char **argv, char **envp)
{
  HyPortLibrary hyportLibrary;
  HyPortLibraryVersion portLibraryVersion;
  int ret;

  printf("hymem:\n");

  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return 1;
  }

  printf("  portlib initialized\n");
  
  Hytest_init(&hyportLibrary, "Portlib.Hymem");
  Hytest_func(&hyportLibrary, test_hymem_allocate_memory, "hymem_allocate_memory");
  Hytest_func(&hyportLibrary, test_hymem_allocate_memory_callSite, "hymem_allocate_memory_callSite");
  Hytest_func(&hyportLibrary, test_hymem_free_memory, "hymem_free_memory");
  Hytest_func(&hyportLibrary, test_hymem_reallocate_memory, "hymem_reallocate_memory");
  Hytest_func(&hyportLibrary, test_hymem_shutdown, "hymem_shutdown");
  Hytest_func(&hyportLibrary, test_hymem_startup, "hymem_startup");
  ret = Hytest_close_and_output(&hyportLibrary);
  
  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
    fprintf(stderr, "portlib shutdown failed\n");
    return 1;
  }
  
  printf("  portlib shutdown\n");
  return ret;
}
Exemplo n.º 2
0
Arquivo: init.c Projeto: freeVM/freeVM
int main (int argc, char **argv, char **envp)
{
  HyPortLibrary hyportLibrary;
  HyPortLibraryVersion portLibraryVersion;

  printf("init:\n");

  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return 1;
  }

  printf("  portlib initialized\n");
  
  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
    fprintf(stderr, "portlib shutdown failed\n");
    return 1;
  }
  printf("  portlib shutdown\n");

  return 0;
}
Exemplo n.º 3
0
int test_hyport_isFunctionOverridden(struct HyPortLibrary *hyportLibrary)
{
  HyPortLibrary portLibrary2;
  HyPortLibraryVersion portLibraryVersion;
  I_32 ret;
  UDATA offset;
  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  
  if (0 != hyport_init_library (&portLibrary2, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    Hytest_setErrMsg(hyportLibrary, "portlib init failed(%s) \n",HY_GET_CALLSITE());
    return -1;
  }
  offset = offsetof(HyPortLibrary,port_isFunctionOverridden);
  printf("offset:\t%d\n",offset);
  ret = hyportLibrary->port_isFunctionOverridden(&portLibrary2,offset);
  if(ret != 0)
  {
    Hytest_setErrMsg(hyportLibrary, "hyport_isFunctionOverridden Output shoule be [%d] but [%d] (%s) \n",0,ret,HY_GET_CALLSITE());
    return -1;
  }
  portLibrary2.port_isFunctionOverridden = NULL;
  
  ret = hyportLibrary->port_isFunctionOverridden(&portLibrary2,offset);
  
  if(ret != 1)
  {
    Hytest_setErrMsg(hyportLibrary, "hyport_isFunctionOverridden Output shoule be [%d] but [%d] (%s) \n",1,ret,HY_GET_CALLSITE());
    return -1;
  }
  return 0;
}
Exemplo n.º 4
0
int test_hyport_shutdown_library(struct HyPortLibrary *hyportLibrary)
{
  HyPortLibraryVersion portLibraryVersion;
  HyPortLibrary hyportLibrary2;
  
  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary2, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    Hytest_setErrMsg(hyportLibrary, "portlib init failed (%s)\n",HY_GET_CALLSITE());
    return -1;
  }
  if (0 != hyportLibrary->port_shutdown_library (&hyportLibrary2)) {
    Hytest_setErrMsg(hyportLibrary, "portlib shutdown failed (%s)\n",HY_GET_CALLSITE());
    return -1;
  }
  return 0;
}
Exemplo n.º 5
0
int test_hyport_getVersion(struct HyPortLibrary *hyportLibrary)
{
  HyPortLibrary portLibrary2;
  HyPortLibraryVersion portLibraryVersion;
  I_32 ret;
  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&portLibrary2, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    Hytest_setErrMsg(hyportLibrary, "portlib init failed(%s) \n",HY_GET_CALLSITE());
    return -1;
  }
  ret = hyport_getVersion(&portLibrary2,&portLibraryVersion);
  if(ret!=0)
  {
    Hytest_setErrMsg(hyportLibrary, "hyport getVersion failed(%s) \n",HY_GET_CALLSITE());
    return -1;
  }
  return 0;
}
Exemplo n.º 6
0
int main (int argc, char **argv, char **envp)
{
  HyPortLibrary hyportLibrary;
  HyPortLibraryVersion portLibraryVersion;
  int ret;

  printf("hytime:\n");

  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return 1;
  }

  printf("  portlib initialized\n");

#ifdef HY_NO_THR
  privateThreadLibrary = hyportLibrary.port_get_thread_library(&hyportLibrary);
#endif

  Hytest_init(&hyportLibrary, "Portlib.Hytime");
  Hytest_func(&hyportLibrary, test_hytime_current_time_millis, "hytime_current_time_millis");
  Hytest_func(&hyportLibrary, test_hytime_msec_clock, "hytime_msec_clock");
  Hytest_func(&hyportLibrary, test_hytime_hires_clock, "hytime_hires_clock");
  Hytest_func(&hyportLibrary, test_hytime_hires_delta, "hytime_hires_delta");
  Hytest_func(&hyportLibrary, test_hytime_hires_frequency, "hytime_hires_frequency");
  Hytest_func(&hyportLibrary, test_hytime_usec_clock, "hytime_usec_clock");
  Hytest_func(&hyportLibrary, test_hytime_shutdown, "hytime_shutdown");
  Hytest_func(&hyportLibrary, test_hytime_startup, "hytime_startup");
  ret = Hytest_close_and_output(&hyportLibrary);
  
  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
    fprintf(stderr, "portlib shutdown failed\n");
    return 1;
  }
  printf("  portlib shutdown\n");

  return ret;
}
Exemplo n.º 7
0
int test_hytime_startup(struct HyPortLibrary *hyportLibrary)
{
  HyPortLibrary hyportLibrary2;
  HyPortLibraryVersion portLibraryVersion;
  I_32 rc;
  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary2, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return -1;
  }
  rc =
    hyportLibrary2.time_startup (&hyportLibrary2);
  if (0 != rc)
  {
    Hytest_setErrMsg(hyportLibrary, "time startup failed: %s (%s)\n",
    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
    return -1;
  }
  return 0;
}
Exemplo n.º 8
0
int main (int argc, char **argv, char **envp)
{
  HyPortLibrary hyportLibrary;
  HyPortLibraryVersion portLibraryVersion;
  int ret;
  
  printf("hyport:\n");

  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return 1;
  }
  
  printf("  portlib initialized\n");
  
  Hytest_init(&hyportLibrary, "Portlib.Hyport");
  Hytest_func(&hyportLibrary, test_hyport_init_library, "hyport_init_library");
  Hytest_func(&hyportLibrary, test_hyport_shutdown_library, "hyport_shutdown_library");
  Hytest_func(&hyportLibrary, test_hyport_getSize, "hyport_getSize");
  Hytest_func(&hyportLibrary, test_hyport_create_library, "hyport_create_library");
  Hytest_func(&hyportLibrary, test_hyport_allocate_library, "hyport_allocate_library");
  Hytest_func(&hyportLibrary, test_hyport_getVersion, "hyport_getVersion");
  Hytest_func(&hyportLibrary, test_hyport_isCompatible, "hyport_isCompatible");
  Hytest_func(&hyportLibrary, test_hyport_isFunctionOverridden, "hyport_isFunctionOverridden");
  
  ret = Hytest_close_and_output(&hyportLibrary);
    
  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
    fprintf(stderr, "portlib shutdown failed\n");
    return 1;
  }
  printf("  portlib shutdown\n");

  return ret;
}
Exemplo n.º 9
0
int test_hymem_startup(struct HyPortLibrary *hyportLibrary)
{
  HyPortLibrary hyportLibrary2;
  HyPortLibraryVersion portLibraryVersion;
  I_32 rc;
  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
  if (0 != hyport_init_library (&hyportLibrary2, &portLibraryVersion,
                                sizeof (HyPortLibrary)))
  {
    fprintf(stderr, "portlib init failed\n");
    return 1;
  }
  rc =
    hyportLibrary2.mem_startup (&hyportLibrary2, sizeof (hyportLibrary2.portGlobals));
  if (0 != rc)
  {
    Hytest_setErrMsg(hyportLibrary, "failed to reallocate memory: %s (%s)\n",
    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
    return -1;
  }
  hyportLibrary2.mem_shutdown (&hyportLibrary2);
  return 0;
}