Okay, here's what I did. Instead of continuing to work with my example, I took the 
syslib sample code from the prc-tools-samples and modified it minimally to demonstrate 
the problem. It creates a sample library called GaussLib-syslib.prc. Here's the header 
file for it (not modified by me):

GaussLib.h
----------------------------------------------------------
#ifndef GAUSSLIB_H
#define GAUSSLIB_H

#include <LibTraps.h>

/* Note that these must be evaluated by the preprocessor.  In particular,
   they must be #defines not enum values.  In fact, it's perfectly valid
   just to write SYS_TRAP(sysLibTrapCustom+1) etc in the function
   declarations below.  */

#define GaussLibCreate_trapno   sysLibTrapCustom
#define GaussLibRead_trapno     sysLibTrapCustom+1
#define GaussLibAdd_trapno      sysLibTrapCustom+2
#define GaussLibMul_trapno      sysLibTrapCustom+3

#ifndef GAUSSLIB_TRAP
#define GAUSSLIB_TRAP(trapno)   SYS_TRAP(trapno)
#endif

typedef struct {
  Int32 re, im;
  } Gauss_t;

Err GaussLibOpen (UInt16 refNum)
        GAUSSLIB_TRAP(sysLibTrapOpen);

Err GaussLibClose (UInt16 refNum, UInt16 *numappsP)
        GAUSSLIB_TRAP(sysLibTrapClose);

void GaussLibCreate (UInt16 refNum, Gauss_t *val, Int32 re, Int32 im)
        GAUSSLIB_TRAP(GaussLibCreate_trapno);

void GaussLibRead (UInt16 refNum, const Gauss_t *val, Int32 *re, Int32 *im)
        GAUSSLIB_TRAP(GaussLibRead_trapno);

void GaussLibAdd (UInt16 refNum, Gauss_t *sum,
                  const Gauss_t *a, const Gauss_t *b)
        GAUSSLIB_TRAP(GaussLibAdd_trapno);

void GaussLibMul (UInt16 refNum, Gauss_t *prod,
                  const Gauss_t *a, const Gauss_t *b)
        GAUSSLIB_TRAP(GaussLibMul_trapno);

#endif
-----------------------------------------------------------

Here's the implementation. I modified GaussLibCreate() by adding the first three lines 
in the function body (float a,b; a=2.0; b=3.0*a;).

GaussLib.c:
-----------------------------------------------------------
#include <SystemMgr.h>

#define GAUSSLIB_TRAP(trapno)

#include "GaussLib.h"

Err
start (UInt16 refnum, SysLibTblEntryPtr entryP) {
  extern void *jmptable ();
  entryP->dispatchTblP = (void *) jmptable;
  entryP->globalsP = NULL;
  return 0;
  }

typedef struct {
  UInt16 refcount;
  } GaussLib_globals;

Err
GaussLibOpen (UInt16 refnum) {
  SysLibTblEntryPtr entryP = SysLibTblEntry (refnum);
  GaussLib_globals *gl = entryP->globalsP;

  if (!gl) {
    /* We need to allocate space for the globals.  */
    gl = entryP->globalsP = MemPtrNew (sizeof (GaussLib_globals));
    MemPtrSetOwner (gl, 0);
    gl->refcount = 0;
    }

  gl->refcount++;

  return 0;
  }

Err
GaussLibClose (UInt16 refnum, UInt16 *numappsP) {
  SysLibTblEntryPtr entryP = SysLibTblEntry (refnum);
  GaussLib_globals *gl = entryP->globalsP;

  if (!gl) {
    /* We're not open! */
    return 1;
    }
  
  /* Clean up.  */

  *numappsP = --gl->refcount;
  if (*numappsP == 0) {
    MemChunkFree (entryP->globalsP);
    entryP->globalsP = NULL;
    }

  return 0;
  }

Err
nothing (UInt16 refnum) {
  return 0;
  }

void
GaussLibCreate (UInt16 refNum, Gauss_t *val, Int32 re, Int32 im) {
        float a,b;
        a=2.0;
        b=3.0*a;

        val->re = re;
  val->im = im;
  }

void
GaussLibRead (UInt16 refNum, const Gauss_t *val, Int32 *re, Int32 *im) {
  *re = val->re;
  *im = val->im;
  }

void
GaussLibAdd (UInt16 refNum, Gauss_t *sum, const Gauss_t *a, const Gauss_t *b) {
  sum->re = a->re + b->re;
  sum->im = a->im + b->im;
  }

void
GaussLibMul (UInt16 refNum, Gauss_t *prod, const Gauss_t *a, const Gauss_t *b) {
  Int32 re = (a->re*b->re)-(a->im*b->im);
  prod->im = (a->re*b->im)+(a->im*b->re);
  prod->re = re;
  }
-----------------------------------------------------------

Here's what's in GaussLib.def (used by stubgen), which I did not modify:

--------------------------------------------------
syslib { "Gauss SysLib Library" GauS }

export {
  GaussLibOpen GaussLibClose nothing nothing
  GaussLibCreate GaussLibRead GaussLibAdd GaussLibMul
  }
----------------------------------------------------


Here's the makefile:
--------------------------------------------------
CC = m68k-palmos-gcc
AS = m68k-palmos-as
CFLAGS = -Wall -O2

GaussLib-syslib.prc: GaussLib.def GaussLib
        build-prc -o $@ GaussLib.def GaussLib

GaussLib_objs = GaussLib.o GaussLib-dispatch.o
GaussLib: $(GaussLib_objs)
        $(CC) -nostartfiles -o $@ $(GaussLib_objs)

GaussLib.o: GaussLib.c GaussLib.h

GaussLib-dispatch.o: GaussLib-dispatch.s

GaussLib-dispatch.s: GaussLib.def
        m68k-palmos-stubgen GaussLib.def
--------------------------------------------------

Here's the output from the make:
-------------------------------------------------------
m68k-palmos-gcc -Wall -O2   -c -o GaussLib.o GaussLib.c
m68k-palmos-stubgen GaussLib.def
m68k-palmos-as   -o GaussLib-dispatch.o GaussLib-dispatch.s
m68k-palmos-gcc -nostartfiles -o GaussLib GaussLib.o GaussLib-dispatch.o
build-prc -o GaussLib-syslib.prc GaussLib.def GaussLib
GaussLib: warning: global data ignored
-------------------------------------------------------

Here's the output from running m68k-palmos-objdump --section-headers on GaussLib:

-------------------------------------------------------
GaussLib:     file format coff-m68k

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000e90  00000000  00000000  000000a8  2**2
                  CONTENTS, ALLOC, LOAD, CODE
  1 .data         0000001c  00000000  00000000  00000f38  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  0000001c  0000001c  00000000  2**2
                  ALLOC
--------------------------------------------------------

Any ideas on how to fix this would be greatly appreciated.

Dave


-------Original Message-------
From: Aaron Ardiri <[EMAIL PROTECTED]>
Sent: 03/10/03 01:09 PM
To: Palm Developer Forum <[EMAIL PROTECTED]>
Subject: Re: Re: floats in syslib shared library under prc-tools 2.2?

> 
> > I gave that a try but it didn't work. The linker complained about not 
> being able to resolve the reference to the function from the jump table. 

> I tried "static" on both the declaration and definition, and then on 
> each separately, with the same result each time.
> 
> I went back to the original GaussLib example (which I was able to 
> build successfully) and added the following three lines of code 
> to the GaussLibCreate function:
> 
> float a,b;
> a=2.0;
> b=3.0*a;
> 
> This was enough to generate the "global data ignored" message from 
> build-prc. If I comment out the third line, the message goes away. Why 
> would this line cause global data to be created? Arghhhh. Is it a 
> compiler or linker switch set wrong?

what eror are you getting exactly (show us the output from the shell)
what are your compiler/linker switches? :) need to give us info for us
to be able to help you in any way..

---
Aaron Ardiri                           [EMAIL PROTECTED]
CEO - CTO                                              +46 70 656 1143
Mobile Wizardry                         <a target=_blank
href="http://www.mobilewizardry.com/";>http://www.mobilewizardry.com/</a>

-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see <a target=_blank
href="http://www.palmos.com/dev/support/forums/";>http://www.palmos.com/dev/support/forums/</a>
> 

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

Reply via email to