Closed Bug 573004 Opened 14 years ago Closed 14 years ago

jsctypes-test: test_closure_cdecl is mangled

Categories

(Core :: js-ctypes, defect)

All
OpenSolaris
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: ginnchen+exoracle, Assigned: ginnchen+exoracle)

Details

Attachments

(1 file, 1 obsolete file)

With Sun Studio compiler, test_closure_cdecl() doesn't match the declaration in header.
extern "C" functor vs. no extern "C" functor.
Attached patch patch (obsolete) — Splinter Review
Attachment #452242 - Flags: review?(dwitte)
I don't get it.

http://mxr.mozilla.org/mozilla-central/source/toolkit/components/ctypes/tests/jsctypes-test.h#191

All the other functions are declared in the 'extern C' block in the header, and inherit that linkage when defined in the cpp. Why is this function different?

If this is a bug in the Sun compiler, I'd suggest wrapping everything in the cpp in NS_EXTERN_C, to keep things consistent and unsurprising.
Also, I'm curious how it's mangled. What's the symbol name?
The mangled name is __1cStest_closure_cdecl6FWpFW_i_i_

Other functions don't use function pointer as a parameter. so ...

A cleaner solution would be using typedef for the functor.

Since it is only a test program, and the functor is only used here, I thought it might not be necessary.
Ah, got it. Anonymous function type. Yeah, let's typedef it.
Attached patch patch v2Splinter Review
Attachment #452242 - Attachment is obsolete: true
Attachment #453688 - Flags: review?(dwitte)
Attachment #452242 - Flags: review?(dwitte)
Attachment #453688 - Flags: review?(dwitte) → review+
Comment on attachment 453688 [details] [diff] [review]
patch v2

>diff --git a/toolkit/components/ctypes/tests/jsctypes-test.cpp b/toolkit/components/ctypes/tests/jsctypes-test.cpp

> #if defined(_WIN32) && !defined(_WIN64)
> PRInt32
> test_closure_cdecl(PRInt8 i, PRInt32 (NS_STDCALL *f)(PRInt8))
> {

Can you also typedef this pointer? Perhaps call it test_func_ptr_stdcall.

>diff --git a/toolkit/components/ctypes/tests/jsctypes-test.h b/toolkit/components/ctypes/tests/jsctypes-test.h

> #if defined(_WIN32) && !defined(_WIN64)
>   NS_EXPORT PRInt32 test_closure_stdcall(PRInt8, PRInt32 (NS_STDCALL *)(PRInt8));
> #endif /* defined(_WIN32) && !defined(_WIN64) */

(Declared here. Note: the declaration will have to be inside the #ifdef.)

Thanks! r=dwitte.
http://hg.mozilla.org/mozilla-central/rev/234a06c6aab6
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: