Re: Need help implementing a machine dependent function

Nelson Bolyard <[email protected]> Sun, 24 May 2009 15:47:01 -0700
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
Jonathan Leighton wrote, On 2009-05-20 22:17:
> I'm trying to add a machine dependent function to NSPR, but I'm having 
> some trouble understanding how the existing code translates from a 
> function like _PR_MD_FUNCTION() to the platform specific function 
> _MD_function().  In my case I'm using a function called 
> _PR_MD_SCTP_RECVMSG() in pr/src/pthreads/ptio.c and I want that to 
> translate to different MD_sctp_recvmsg() functions defined in the various
> pr/src/md files.  For example, on Solaris I'd expect 
> _PR_MD_SCTP_RECVMSG() to use the _MD_sctp_recvmsg() that I've added to 
> pr/src/md/unix/solaris.c.
> 
> I've tried to mimic the existing approach using several #define's and 
> extern function prototypes in various files, but I haven't been able to 
> make it work. 

Why not?  In what manner does it fail?
We can't help you solve the problem if you don't describe it.

> As a fallback, I've simply specified an extern function prototype for
> _PR_MD_SCTP_RECVMSG() in pr/include/private/primpl.h and then defined
> _PR_MD_SCTP_RECVMSG() as extern in the various pr/src/md files such as
> solaris.c.  This works but it doesn't seem like the "right" way to do it.

You're right.  It's not.

> I'd be grateful for any help explaining how to do this correctly.  Thanks
> very much.
> 
> - Jon