public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: W.Stuehlmeyer@t-online.de
To: gcc-help@gcc.gnu.org
Subject: dynamic vtables in c-program's on ia64
Date: Wed, 05 Jun 2002 03:36:00 -0000	[thread overview]
Message-ID: <1023273350.3cfde98608434@webmail.t-online.de> (raw)

Hello,

i have dynamically created c-programs with vtable structures.

Example:

typedef struct IMallocVtbl
{
    HRESULT ( *QueryInterface) (IMalloc * pThis, const IID & riid, void
** ppvObject);
    ULONG ( *AddRef) (IMalloc * pThis);
    ULONG ( *Release) (IMalloc * pThis);
    void * ( *Alloc) (IMalloc * pThis, ULONG cb);
...
} IMallocVtbl;

typedef struct CMalloc
{
    IMallocVtbl *lpVtbl;
} CMalloc;
IMallocVtbl * g_lpVtblMalloc = 0;


CMalloc g_CMalloc;
IMalloc * g_pMalloc = (IMalloc *) &g_CMalloc;

IMallocVtbl CRetailMallocVtbl =
{
    CMalloc_QueryInterface,
    CMalloc_AddRef,
    CMalloc_Release,
    CRetailMalloc_Alloc,
...
};

HRESULT MallocInitialize(BOOL fForceLocalAlloc)
{
...
    g_lpVtblMalloc = &CRetailMallocVtbl;
    g_CMalloc.lpVtbl = g_lpVtblMalloc;

    return hr;
}

extern "C" LPVOID CoTaskMemAlloc(ULONG ulcb)
{
  if (g_CMalloc.lpVtbl == 0) {
    MallocInitialize(0);
  }

  //
  // SEGMENTATION VIOLATION
  //
  return g_pMalloc->Alloc(ulcb);
}

I create a function address pointer in CRetailMallocVtbl.
With gcc 3.0.x it works fine, but gcc 3.1 has a new ABI and
g_pMalloc->Alloc(ulcb) needs a <function address; GP address pointer>
pair on a itanium machine.

I have no idea how could create a GP adress pointer or a function
address/GP address pair from a C. I found no information on
www.codesourcecery.org how
could i create these address pairs.

How can i solve this problem?

Only IMallocVtbl could be modified ( typedef struct IMallocVtbl ... and
IMallocVtbl CRetailMallocVtbl = ..) via macros in a header file.

             reply	other threads:[~2002-06-05 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-05  3:36 W.Stuehlmeyer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-06-05  3:36 W.Stuehlmeyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1023273350.3cfde98608434@webmail.t-online.de \
    --to=w.stuehlmeyer@t-online.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).