ICU-8171 fix warnings, or at least move them into POSIX portions of code

X-SVN-Rev: 30012
This commit is contained in:
Steven R. Loomis 2011-05-04 04:07:45 +00:00
parent 752c70d6e0
commit 3d44c5dc4b
4 changed files with 41 additions and 29 deletions

View File

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 2009-2010, International Business Machines
* Copyright (C) 2009-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -578,12 +578,8 @@ uplug_initPlugFromLibrary(const char *libName, const char *sym, const char *conf
lib = uplug_openLibrary(libName, status);
if(lib!=NULL && U_SUCCESS(*status)) {
UPlugEntrypoint *entrypoint = NULL;
/*
* ISO forbids the following cast.
* See: http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
*/
entrypoint = (UPlugEntrypoint*)uprv_dl_sym(lib, sym, status);
entrypoint = (UPlugEntrypoint*)uprv_dlsym_func(lib, sym, status);
if(entrypoint!=NULL&&U_SUCCESS(*status)) {
plug = uplug_initPlugFromEntrypointAndLibrary(entrypoint, config, lib, sym, status);
if(plug!=NULL&&U_SUCCESS(*status)) {

View File

@ -2110,11 +2110,16 @@ uprv_dl_close(void *lib, UErrorCode *status) {
dlclose(lib);
}
U_INTERNAL void* U_EXPORT2
uprv_dl_sym(void *lib, const char* sym, UErrorCode *status) {
void *ret = NULL;
U_INTERNAL UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
UVoidFunction* ret = NULL;
if(U_FAILURE(*status)) return ret;
ret = dlsym(lib, sym);
/*
* ISO forbids the following cast, but it's needed for dlsym.
* See: http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html
* See: http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
*/
*(void **)&ret = dlsym(lib, sym);
if(ret == NULL) {
*status = U_MISSING_RESOURCE_ERROR;
}
@ -2140,11 +2145,12 @@ uprv_dl_close(void *lib, UErrorCode *status) {
}
U_INTERNAL void* U_EXPORT2
uprv_dl_sym(void *lib, const char* sym, UErrorCode *status) {
if(U_FAILURE(*status)) return NULL;
*status = U_UNSUPPORTED_ERROR;
return NULL;
U_INTERNAL UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
if(U_SUCCESS(*status)) {
*status = U_UNSUPPORTED_ERROR;
}
return (UVoidFunction*)NULL;
}
@ -2179,14 +2185,14 @@ uprv_dl_close(void *lib, UErrorCode *status) {
}
U_INTERNAL void* U_EXPORT2
uprv_dl_sym(void *lib, const char* sym, UErrorCode *status) {
U_INTERNAL UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
HMODULE handle = (HMODULE)lib;
void * addr = NULL;
UVoidFunction* addr = NULL;
if(U_FAILURE(*status) || lib==NULL) return NULL;
addr = GetProcAddress(handle, sym);
addr = (UVoidFunction*)GetProcAddress(handle, sym);
if(addr==NULL) {
DWORD lastError = GetLastError();
@ -2220,11 +2226,12 @@ uprv_dl_close(void *lib, UErrorCode *status) {
}
U_INTERNAL void* U_EXPORT2
uprv_dl_sym(void *lib, const char* sym, UErrorCode *status) {
if(U_FAILURE(*status)) return NULL;
U_INTERNAL UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
if(U_SUCCESS(*status)) {
*status = U_UNSUPPORTED_ERROR;
return NULL;
}
return (UVoidFunction*)NULL;
}

View File

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 1997-2010, International Business Machines
* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -287,6 +287,8 @@ U_INTERNAL void * U_EXPORT2 uprv_maximumPtr(void *base);
#if U_ENABLE_DYLOAD
/* Dynamic Library Functions */
typedef void (UVoidFunction)(void);
/**
* Load a library
* @internal (ICU 4.4)
@ -300,10 +302,17 @@ U_INTERNAL void * U_EXPORT2 uprv_dl_open(const char *libName, UErrorCode *status
U_INTERNAL void U_EXPORT2 uprv_dl_close( void *lib, UErrorCode *status);
/**
* Extract a symbol from a library
* @internal (ICU 4.4)
* Extract a symbol from a library (function)
* @internal (ICU 4.8)
*/
U_INTERNAL void * U_EXPORT2 uprv_dl_sym( void *lib, const char *symbolName, UErrorCode *status);
U_INTERNAL UVoidFunction* U_EXPORT2 uprv_dlsym_func( void *lib, const char *symbolName, UErrorCode *status);
/**
* Extract a symbol from a library (function)
* Not implemented, no clients.
* @internal
*/
/* U_INTERNAL void * U_EXPORT2 uprv_dlsym_data( void *lib, const char *symbolName, UErrorCode *status); */
#endif

View File

@ -80,7 +80,7 @@ $(TARGET) : $(OBJECTS)
$(LINK.cc) $(OUTOPT)$@ $^ $(LIBS)
$(POST_BUILD_STEP)
PLUGIN=$(LIBPREFIX)plugin.$(SO)
PLUGIN=$(LIBPREFIX)plugin.$(SO)
SO_TARGET=$(PLUGIN)
PLUGINDIR=$(shell pwd)