Bug#475601: Simple test case
Jurij Smakov
jurij at wooyd.org
Tue Aug 12 15:04:54 UTC 2008
Here's a simple test case, which fails on sparc (compile with
g++ test.cxx -lpt):
---------8<----------
#include <stdio.h>
#include <ptlib.h>
int main() {
PDynaLink *dll = new
PDynaLink("/usr/lib/pwlib/1.11.2/device/videoinput/v4l_pwplugin.so");
unsigned (*GetAPIVersion)();
if (dll->GetFunction("PWLibPlugin_GetAPIVersion",
(PDynaLink::Function &)GetAPIVersion)) {
printf("TRUE GetAPIVersion=%p\n", GetAPIVersion);
} else {
printf("FALSE GetAPIVersion=%p\n", GetAPIVersion);
}
}
---------8<----------
When run on sparc, it gives:
TRUE GetAPIVersion=(nil)
which is pretty surprising, given that the code of GetFunction reads:
BOOL PDynaLink::GetFunction(const PString & fn, Function & func)
{
if (dllHandle == NULL)
return FALSE;
#if defined(P_OPENBSD)
void * p = dlsym(dllHandle, (char *)(const char *)fn);
#else
void * p = dlsym(dllHandle, (const char *)fn);
#endif
if (p == NULL)
return FALSE;
func = (Function &)p;
return TRUE;
}
i.e. there appears to be no way for it to return TRUE and set the
function pointer to NULL simultaneously. For comparison, on my 386 box
it returns
TRUE GetAPIVersion=0xb72eecec
as expected.
Cheers.
--
Jurij Smakov jurij at wooyd.org
Key: http://www.wooyd.org/pgpkey/ KeyID: C99E03CC
More information about the Pkg-voip-maintainers
mailing list