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. 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. I'd be grateful for any help explaining how to do
this correctly. Thanks very much.
- Jon
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.
Thanks for responding Nelson, and sorry I didn't provide more detail.
If I look at how _PR_MD_ACCEPT is implemented I see
in file primpl.h
extern PROsfd _PR_MD_ACCCEPT(...);
#define _PR_MD_ACCEPT _MD_ACCEPT
in file _win95.h
extern PROsfd _MD_Accept(...);
#define _MD_ACCEPT _MD_Accept
in file wsock95.c
PROsfd _MD_Accept(...) {...}
I tried to mimic this in Mac OS X with _PR_MD_SCTP_RECVMSG by adding the
following
in file primpl.h
extern PRInt32 _PR_MD_SCTP_RECVMSG(...);
#define _PR_MD_SCTP_RECVMSG _MD_SCTP_RECVMSG
in file _darwin.h
extern PRInt32 _MD_Sctp_Recvmsg(...);
#define _MD_SCTP_RECVMSG _MD_Sctp_Recvmsg
in file darwin.c
PRInt32 _MD_Sctp_Recvmsg(...) {...}
When I try to build I end up with a warning about an implicit definition
of _PR_MD_SCTP_RECVMSG in ptio.c (where I call the function), and the
build fails on nspr.dylib stating that _PR_MD_SCTP_RECV is an undefined
symbol. I can include the compiler output if that would be helpful.
- Jon
> I tried to mimic this in Mac OS X with _PR_MD_SCTP_RECVMSG by adding the
> following
>
> in file primpl.h
> extern PRInt32 _PR_MD_SCTP_RECVMSG(...);
> #define _PR_MD_SCTP_RECVMSG _MD_SCTP_RECVMSG
> When I try to build I end up with a warning about an implicit definition
> of _PR_MD_SCTP_RECVMSG in ptio.c (where I call the function), and the
> build fails on nspr.dylib stating that _PR_MD_SCTP_RECV is an undefined
> symbol. I can include the compiler output if that would be helpful.
The obvious implication of that warning/error is that one of the following
is true:
1) ptio.c did not include primpl.h or
2) the lines you added to primpl.h were inside a #if that was false, or
3) the copy of primpl.h that the compiler used did not contain your changes.
Did you do a full rebuild of NSPR after making your changes?
I'd suggest you start by doing a full rebuild.
Go into mozilla/nsprpub and find the directory in there that is created
by the build (name ends in .OBJ) and rm -rf it. Then rebuild.
If that doesn't fix it, then the next step is to look at the output of
the c pre-processor for ptio.c, and look for your changes. You won't see
the #defines, but you should see your other additions. If you don't then
you need to figure out why. The answer is likely #if or #ifdef.
--
12345678901234567890123456789012345678901234567890123456789012345678901234567890
00000000011111111112222222222333333333344444444445555555555666666666677777777778
Thank you! This was exactly the problem. I had mistakenly interpreted
#else /* defined(_PR_PTHREADS) */
to indicate the beginning of the _PR_PTHREADS=1 block, rather than the
end of that block. The code compiles and runs as expected now.
> 3) the copy of primpl.h that the compiler used did not contain your changes.
>
> Did you do a full rebuild of NSPR after making your changes?
> I'd suggest you start by doing a full rebuild.
> Go into mozilla/nsprpub and find the directory in there that is created
> by the build (name ends in .OBJ) and rm -rf it. Then rebuild.
I'm curious about the .OBJ files. I couldn't find either .OBJ or .obj
files anywhere in my builds for Darwin, FreeBSD, Solaris or Linux,
though I did find some objs.mk files. Are the .OBJ files generated on
all platforms?