What happens to dynload initialization when compiled into shared library?

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao

In ATS I currently have:
val global = some_init_call()

If I were to do the initialization somewhere else, presumably in a local
scope of some function, how do I keep the value global? Do I then have to
declare it var instead of val?On Friday, January 24, 2014 9:25:52 AM UTC-8, gmhwxi wrote:

If you produce a library that requires proper initialization, it is
probably better to do it on your own.

On Friday, January 24, 2014 11:55:22 AM UTC-5, gmhwxi wrote:

Add the following line at the top:

#define ATS_DYNLOADFLAG 0

On Friday, January 24, 2014 11:53:28 AM UTC-5, H Zhang wrote:

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao

What happens to global value initialization? With main0, ATS appears to
generate an initialization routine that is called from main. Who will call
it when compiled with -shared? Or will it be generated differently, maybe
called from C global initialization (as in “int dummy = init_call();”)?On Friday, January 24, 2014 8:55:22 AM UTC-8, gmhwxi wrote:

Add the following line at the top:

#define ATS_DYNLOADFLAG 0

On Friday, January 24, 2014 11:53:28 AM UTC-5, H Zhang wrote:

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao

Try to make a statically allocated reference:

https://github.com/githwxi/ATS-Postiats/blob/master/contrib/libats-hwxi/globals/HATS/gcount.hats

Say the type of the value in ‘global’ is T.

Then you can have

extern val global: ref(Option(T))

Initialization is done like this:

!global := Some(some_init_call())On Friday, January 24, 2014 12:55:10 PM UTC-5, H Zhang wrote:

In ATS I currently have:
val global = some_init_call()

If I were to do the initialization somewhere else, presumably in a local
scope of some function, how do I keep the value global? Do I then have to
declare it var instead of val?

On Friday, January 24, 2014 9:25:52 AM UTC-8, gmhwxi wrote:

If you produce a library that requires proper initialization, it is
probably better to do it on your own.

On Friday, January 24, 2014 11:55:22 AM UTC-5, gmhwxi wrote:

Add the following line at the top:

#define ATS_DYNLOADFLAG 0

On Friday, January 24, 2014 11:53:28 AM UTC-5, H Zhang wrote:

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao

Add the following line at the top:

#define ATS_DYNLOADFLAG 0On Friday, January 24, 2014 11:53:28 AM UTC-5, H Zhang wrote:

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao

If you produce a library that requires proper initialization, it is
probably better to do it on your own.On Friday, January 24, 2014 11:55:22 AM UTC-5, gmhwxi wrote:

Add the following line at the top:

#define ATS_DYNLOADFLAG 0

On Friday, January 24, 2014 11:53:28 AM UTC-5, H Zhang wrote:

ATS generates initialization routines that are called before main0 is
called. What happens if I don’t have main0 and compile the file with gcc
-shared?

Haitao