Closed
Bug 76896
Opened 25 years ago
Closed 25 years ago
Missing some PR_CALLBACKs
Categories
(NSPR :: NSPR, defect, P2)
Tracking
(Not tracked)
VERIFIED
FIXED
4.2
People
(Reporter: mkaply, Assigned: larryh)
References
Details
Attachments
(3 files)
|
1.24 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.78 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.97 KB,
patch
|
Details | Diff | Splinter Review |
I'm attaching a diff - a couple PR_CALLBACKs are missing in
some header files
| Reporter | ||
Comment 1•25 years ago
|
||
| Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Comment 2•25 years ago
|
||
Comment 3•25 years ago
|
||
Larry, what's the difference between PR_CALLBACK and PR_CALLBACK_DECL?
| Reporter | ||
Comment 4•25 years ago
|
||
I can answer that one.
Based on what I see in the code, it appears that the DECL was for this case:
typedef void (* MY_CALLBACK_DECL callback)(int a, int b);
and the callback was for this case:
MY_CALLBACK void myfunction(int a, int b);
I'm not sure that it matters anymore. There is only one PR_CALLBACK_DECL
currently in the tree anywhere:
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/include/prtime.h#139
If the general consensus is that PR_CALLBACK_DECL isn't the right thing to do,
the diff would be to remove that PR_CALLBACK_DECL from prtime.h
We are adding a def for PR_CALLBACK_DECL because we were considering using it
in the NSS code (the same as above - DECL for the typedef) but if that's not
the right thing to do, we won't do it.
Comment 5•25 years ago
|
||
Michael: so you still want to add PR_CALLBACK to the function prototypes
of PR_CSetOnMonitorRecycle and PR_CreateThread?
You wrote:
> If the general consensus is that PR_CALLBACK_DECL isn't the right thing
> to do, the diff would be to remove that PR_CALLBACK_DECL from prtime.h
Did you mean removing that PR_CALLBACK_DECL from prtime.h or replacing
that PR_CALLBACK_DECL by PR_CALLBACK?
| Reporter | ||
Comment 6•25 years ago
|
||
> Michael: so you still want to add PR_CALLBACK to the function prototypes
> of PR_CSetOnMonitorRecycle and PR_CreateThread?
We definitely need PR_CALLBACK on these functions.
> Did you mean removing that PR_CALLBACK_DECL from prtime.h or replacing
> that PR_CALLBACK_DECL by PR_CALLBACK?
Changing PR_CALLBACK_DECL to PR_CALLBACK.
This would be the only place that would need to be changed if PR_CALLBACK_DECL
is removed.
I'm not even sure why PR_CALLBACK_DECL exists. Can you think of any technical
reason to differentiate between the typedef and the function?
Comment 7•25 years ago
|
||
I found in the cvs logs (in the Netscape internal cvs repository)
the following comments regarding the use of PR_CALLBACK_DECL in
prtime.h:
Porting NSPR 2.0 to Win16.
Cast PRTimeParameters typedef function to use PR_CALLBACK_DECL.
Win16 requires the explicit declaration; other platforms are no-op.
The diffs for that revision are:
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Index: prtime.h
===================================================================
RCS file: /m/src/ns/nspr20/pr/include/prtime.h,v
retrieving revision 1.3.2.13
retrieving revision 1.3.2.14
diff -u -r1.3.2.13 -r1.3.2.14
--- prtime.h 1997/06/20 01:07:14 1.3.2.13
+++ prtime.h 1997/07/31 20:34:51 1.3.2.14
@@ -128,7 +128,7 @@
* to GMT before applying the DST rules.
*/
-typedef PRTimeParameters (*PRTimeParamFn)(const PRExplodedTime *gmt);
+typedef PRTimeParameters (PR_CALLBACK_DECL *PRTimeParamFn)(const PRExplodedTime
*gmt);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
This still doesn't explain why we only use PR_CALLBACK_DECL in that
function typedef, as there are lots of other function typedefs
(e.g., in prio.h) where we use PR_CALLBACK.
Since we no longer support WIN16, I think it is fine to change
PR_CALLBACK_DECL to PR_CALLBACK in prio.h. I will attach a new patch.
Comment 8•25 years ago
|
||
OK, I just talked to Larry about this. Since it was a long
time ago when he did the WIN16 port, he doesn't remember the
details. But between Larry and me we constructed the theory
that the PRTimeParamFn typedef needs a different callback
specifier because it returns an aggregate type (a struct) as
opposed to an integral type.
Again, we decided to just change PR_CALLBACK_DECL to PR_CALLBACK.
Comment 9•25 years ago
|
||
| Reporter | ||
Comment 10•25 years ago
|
||
Is there any documentation on which is the preferred format:
A) (PR_CALLBACK *start)(
OR
B) (* PR_CALLBACK start)(
Both seem to compile in my compiler, but it looks like B is the most prevalent
usage in Mozilla.
Comment 11•25 years ago
|
||
Michael: PR_CALLBACK is documented at
http://www.mozilla.org/projects/nspr/reference/html/Prtyp.html#14710.
However, the documentation does not describe where it should be
placed in a function pointer declaration.
NSPR always uses form A: (PR_CALLBACK *start)(
Since only OS/2 needs PR_CALLBACK now, I think whatever works for
OS/2 is fine. So, is
(_Optlink *start)(
or
(* _Optlink start)(
more prevalent in the OS/2 world?
In any case, since either form works, I think it is not necessary
to modify existing code but it is a good idea to standardize on
one form for new code.
| Reporter | ||
Comment 12•25 years ago
|
||
Form A is more readable, so we agree. Lets standardize on that.
Comment 13•25 years ago
|
||
I checked in my patch on the trunk and NSPRPUB_CLIENT_BRANCH of
NSPR.
Summary of changes:
- We should not use PR_CALLBACK_DECL. Use PR_CALLBACK for all
callback functions. The distinction between PR_CALLBACK_DECL
and PR_CALLBACK is no longer useful for all the platforms and
compilers that we need to support today.
- When using PR_CALLBACK in a function pointer declaration, use
this format:
(PR_CALLBACK *start)(
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Priority: -- → P2
Resolution: --- → FIXED
Target Milestone: --- → 4.2
Version: 3.0 → 4.0.2
You need to log in
before you can comment on or make changes to this bug.
Description
•