Hi,

yes I have tested an mulit-segment-appl.. The problem is, our software have 
some globale structure/variable, which are bigger as 64KB.
I have define in three segments some big variable around 50.000 KB, but the 
linker cannot link, the size of the appl. exceed the limit of 64KB.

Now I can call a shared lib to antoher lib, like appl. call a shared lib. 
Thanks you.

Well, now I define a globale structure with access in 1st lib and in 2nd lib. 
In the first test I generate an appl. with one lib and use a globale structure 
in the lib. Now I trying the access to the globale structure in lib1 and in 
lib2. The call to lib2 over lib1 succeed. But the access to the globale 
structure in lib2 fail, the access in lib1 succeed. 
In lib1 the function ECLibTest call the function ECLib1Sub in lib2.
In ECLib1Sub the globale structure will be set with a value 10 and return this 
value. The value will be show in the appl.
When I start the appl. like below, it crashs.

What do I wrong?:

in LIB2, in header-file:
========================
typedef struct GlobalsTest
{
  int p[20000]; //40KB 
  int q[20000]; //40KB 
  int r[20000]; //40KB 
}GlobalsTest;

typedef struct ECLib1GlobalsType
{
  /* our library reference number (for convenience and debugging) */
  UInt16 thisLibRefNum;

  /* library open count */
  Int16 openCount;

  /* number of context in existence (for debugging) */
  Int16 contextCount;

  /* TODO: add other library globals here */
  GlobalsTest globalstest;
} ECLib1GlobalsType;


in LIB2, in source-code:
========================
Err ECLib1Sub(UInt16 refNum,int x, int y,double *result)
{
  ECLib1GlobalsType * gP = NULL;
  SysLibTblEntryType * libEntryP;
 
  libEntryP = SysLibTblEntry(refNum);
  ErrFatalDisplayIf(libEntryP == NULL, "invalid ECLib refNum");
 
  if ( libEntryP )
  {
    gP = (ECLib1GlobalsType *)(libEntryP->globalsP);    
  }

  gP->globalstest.p[10]=10;    // initialized
  gP->globalstest.q[10]=10;    // initialized  
  gP->globalstest.r[10]=10;    // initialized 
  
  *result= (double)(gP->globalstest.p[10]);

return errNone;
}

in LIB1, header-file:
=====================
typedef struct GlobalsTest
{
  int p[20000]; //40KB 
  int q[20000]; //40KB 
  int r[20000]; //40KB 
}GlobalsTest;

typedef struct ECLibGlobalsType
{
  /* our library reference number (for convenience and debugging) */
  UInt16 thisLibRefNum;

  /* library open count */
  Int16 openCount;

  /* number of context in existence (for debugging) */
  Int16 contextCount;

  /* TODO: add other library globals here */
  GlobalsTest globalstest;
} ECLibGlobalsType;


in LIB1, source-code:
=====================
Err ECLibTest(UInt16 refNum,int x ,int y,double *result)
{
UInt16 ECLib1Ref=0;
UInt32 ECLib1ClientContextP=0;
double testsub; 
Err error;

        
  ECLibGlobalsType * gP = NULL;
  SysLibTblEntryType * libEntryP;
 
  libEntryP = SysLibTblEntry(refNum);
  ErrFatalDisplayIf(libEntryP == NULL, "invalid ECLib refNum");
 
  if ( libEntryP )
  {
    gP = (ECLibGlobalsType *)(libEntryP->globalsP);     
  }

  //Calling and opening ECLib1  
  {
    ECLib1Ref=sysInvalidRefNum;
    if (errNone != SysLibFind(ECLib1Name, &ECLib1Ref))
    {
      SysLibLoad(ECLib1Type, ECLib1CreatorID, &ECLib1Ref);
    }
                
    if (ECLib1Ref != sysInvalidRefNum)
    {
      if (errNone != ECLib1Open(ECLib1Ref, &ECLib1ClientContextP) )
      {
        /* if error loading library, reset reference */
        ECLib1Ref = sysInvalidRefNum;
      }
    }
  }
 
  // Call  ECLib1Sub function.
  //###################################
  ECLib1Sub(ECLib1Ref,11, 1,&testsub); 
  //###################################
  
  *result= (double)(testsub);  //Moving initialized value to result. 
  
  //Closing the ECLib1 library.
  if (ECLib1Ref != sysInvalidRefNum)
  {
    if (errNone != ECLib1Close(ECLib1Ref, ECLib1ClientContextP))
    {
      /* if error closing library, reset reference */
      ECLib1Ref = sysInvalidRefNum;
    }
    error= SysLibRemove(ECLib1Ref); 
  }
  //End of closing ECLib1 Library
  return errNone;
}    

If you need more information or source-code of this sample, let me know.

Thank you for your help.

Regards,
Boris
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to