[plt-scheme] Help on a testing about CGC

Chongkai Zhu u0476504 at utah.edu
Mon Sep 4 23:00:58 EDT 2006


Hi all,

Attached is a small PLT program. Would people please help testing it and report the result here with you platform information? Thanks.

The program consists of two modules. The base module is writen in C. To help compiling it, "installer.ss" is also attached. If you have a C compiler, load the installer and then run 

(pre-installer (current-directory))

should be enough. 

To do the testing, please load "mathematica.ss", run (MathKernel) first, and then test to see whether (current-mathlink) always return #<MathLink>.

Here is one of my test interaction:

Welcome to DrScheme, version 352.4.
Language: (module ...).
> (MathKernel)
#<MathLink>
> (current-mathlink)
#<MathLink>
> (current-mathlink)
#<MathLink>
> (current-mathlink)
7.4714817665179e-244
> 

Before each time you run (current-mathlink), please do GC enough time. I do this by hiting the "GC" buttom from DrScheme until the memory counter doesn't change (5-10 times).

Thanks.

Chongkai
-------------- next part --------------
#include "escheme.h"

#define scheme_make_bool(i) (i ? scheme_true : scheme_false)

typedef struct
{
	Scheme_Type type;
	void* val;
}mathlink;

Scheme_Type MathLink_Type;

static Scheme_Object *init_and_openlink(int argc, Scheme_Object **argv)
{
	mathlink *ret;
	ret = scheme_malloc_atomic( sizeof( mathlink));
	ret->type = MathLink_Type;
	ret->val = NULL;
	return ((Scheme_Object*)ret);
}

static Scheme_Object *SCHEME_MathLinkP(int argc, Scheme_Object **argv)
{
	return scheme_make_bool( SCHEME_TYPE( argv[0]) == MathLink_Type);
}


Scheme_Object *scheme_reload(Scheme_Env *env)
{
  Scheme_Env *menv;
  Scheme_Object *proc;

  menv = scheme_primitive_module(scheme_intern_symbol("ml"), env);

  proc = scheme_make_prim_w_arity(init_and_openlink, "init_and_openlink", 0, -1);
  scheme_add_global("init_and_openlink", proc, menv);
  proc = scheme_make_prim_w_arity(SCHEME_MathLinkP, "MathLink?", 1, 1);
  scheme_add_global("MathLink?", proc, menv);

  scheme_finish_primitive_module(menv);
  
  return scheme_void;
}

Scheme_Object *scheme_initialize(Scheme_Env *env)
{
  MathLink_Type = scheme_make_type( "<MathLink>");
  return scheme_reload(env);
}

Scheme_Object *scheme_module_name()
{
  return scheme_intern_symbol("ml");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mathematica.ss
Type: application/octet-stream
Size: 515 bytes
Desc: not available
Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20060904/83184b92/mathematica.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: installer.ss
Type: application/octet-stream
Size: 426 bytes
Desc: not available
Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20060904/83184b92/installer.obj


More information about the plt-scheme mailing list