~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to src/unix/dlunix.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-06-30 22:02:17 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080630220217-vag3tkfp91t0453d
Tags: 2.8.8.0-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.8.0.tar.bz2, remove upstream debian dir (LP: #244355).
* Add debian/watch file, LP: #242164.
* Edit get-orig-source target to provide a .orig.tar.gz with the same md5 for
  each .orig.tar.gz generated.
* debian/rules: remove get-orig-source from .PHONY target.
* debian/control.in: add python-wxtools in python-wxgtk=V=U Suggests field.
* Do not apply fix_from_upstream_svn_r52465 patch, not needed.
* Regenerate octave_oct, tcl_tk_tcl patches for the new version.
* Fix spelling-error-in-description lintian warning.
* Fix depends-on-obsolete-package lintian error.
* Fix executable-not-elf-or-script lintian warnings.
* Fix script-not-executable lintian warnings.
* Fix missing-dependency-on-libc lintian error.
* Fix dbg-package-missing-depends lintian warnings.
* Fix package-contains-empty-directory lintian warnings.
* Fix manpage-has-errors-from-man lintian warning.
* Fix image-file-in-usr-lib lintian warnings:
  - add editra_pixmaps patch
  - add xrced_bitmaps patch
* Fix unused-override lintian info.
* Fix malformed-override lintian errors.
* Fix extra-license-file lintian warnings.
* Install upstream wx.pth instead of generated file links (LP: #211553).
* Add editra.png, pyshell.png (encoded using uuencode) icons, LP: #236876:
  - debian/rules: use uudecode to decode .png icons.
* Add a new pyshell.xpm icon.
* Fix doc-base-file-references-missing-file lintian error.
* Fix doc-base-unknown-section lintian warning.
* Fix ruby-script-but-no-ruby-dep lintian errors.
* Fix wish-script-but-no-wish-dep lintian errors.
* Fix missing-dep-for-interpreter errors.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Author:      Vadim Zeitlin
5
5
// Modified by:
6
6
// Created:     2005-01-16 (extracted from common/dynlib.cpp)
7
 
// RCS-ID:      $Id: dlunix.cpp 40455 2006-08-04 22:32:08Z VZ $
 
7
// RCS-ID:      $Id: dlunix.cpp 51903 2008-02-19 01:13:48Z DE $
8
8
// Copyright:   (c) 2000-2005 Vadim Zeitlin <vadim@wxwindows.org>
9
9
// Licence:     wxWindows licence
10
10
/////////////////////////////////////////////////////////////////////////////
33
33
    #include "wx/log.h"
34
34
#endif
35
35
 
36
 
// only Mac OS X 10.3+ has dlfcn.h, and it is simpler to always provide our own
37
 
// wrappers using the native functions instead of doing checks for OS version
38
 
#ifndef __DARWIN__
 
36
#ifdef HAVE_DLOPEN
39
37
    #include <dlfcn.h>
40
38
#endif
41
39
 
 
40
#ifdef __DARWIN__
 
41
    #include <AvailabilityMacros.h>
 
42
#endif
 
43
 
42
44
// if some flags are not supported, just ignore them
43
45
#ifndef RTLD_LAZY
44
46
    #define RTLD_LAZY 0
78
80
 
79
81
// ----------------------------------------------------------------------------
80
82
// dlxxx() emulation for Darwin
 
83
// Only useful if the OS X version could be < 10.3 at runtime
81
84
// ----------------------------------------------------------------------------
82
85
 
83
 
#if defined(__DARWIN__)
 
86
#if defined(__DARWIN__) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3)
84
87
// ---------------------------------------------------------------------------
85
88
// For Darwin/Mac OS X
86
89
//   supply the sun style dlopen functions in terms of Darwin NS*
98
101
 
99
102
static char dl_last_error[1024];
100
103
 
101
 
const char *dlerror()
 
104
static const char *wx_darwin_dlerror()
102
105
{
103
106
    return dl_last_error;
104
107
}
105
108
 
106
 
void *dlopen(const char *path, int WXUNUSED(mode) /* mode is ignored */)
 
109
static void *wx_darwin_dlopen(const char *path, int WXUNUSED(mode) /* mode is ignored */)
107
110
{
108
111
    NSObjectFileImage ofile;
109
112
    NSModule handle = NULL;
159
162
    return handle;
160
163
}
161
164
 
162
 
int dlclose(void *handle)
 
165
static int wx_darwin_dlclose(void *handle)
163
166
{
164
167
    NSUnLinkModule((NSModule)handle, NSUNLINKMODULE_OPTION_NONE);
165
168
    return 0;
166
169
}
167
170
 
168
 
void *dlsym(void *handle, const char *symbol)
 
171
static void *wx_darwin_dlsym(void *handle, const char *symbol)
169
172
{
170
173
    // as on many other systems, C symbols have prepended underscores under
171
174
    // Darwin but unlike the normal dlopen(), NSLookupSymbolInModule() is not
179
182
    return nsSymbol ? NSAddressOfSymbol(nsSymbol) : NULL;
180
183
}
181
184
 
 
185
// Add the weak linking attribute to dlopen's declaration
 
186
extern void * dlopen(const char * __path, int __mode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
 
187
 
 
188
// For all of these methods we test dlopen since all of the dl functions we use were added
 
189
// to OS X at the same time.  This also ensures we don't dlopen with the real function then
 
190
// dlclose with the internal implementation.
 
191
 
 
192
static inline void *wx_dlopen(const char *__path, int __mode)
 
193
{
 
194
#ifdef HAVE_DLOPEN
 
195
    if(&dlopen != NULL)
 
196
        return dlopen(__path, __mode);
 
197
    else
 
198
#endif
 
199
        return wx_darwin_dlopen(__path, __mode);
 
200
}
 
201
 
 
202
static inline int wx_dlclose(void *__handle)
 
203
{
 
204
#ifdef HAVE_DLOPEN
 
205
    if(&dlopen != NULL)
 
206
        return dlclose(__handle);
 
207
    else
 
208
#endif
 
209
        return wx_darwin_dlclose(__handle);
 
210
}
 
211
 
 
212
static inline const char *wx_dlerror()
 
213
{
 
214
#ifdef HAVE_DLOPEN
 
215
    if(&dlopen != NULL)
 
216
        return dlerror();
 
217
    else
 
218
#endif
 
219
        return wx_darwin_dlerror();
 
220
}
 
221
 
 
222
static inline void *wx_dlsym(void *__handle, const char *__symbol)
 
223
{
 
224
#ifdef HAVE_DLOPEN
 
225
    if(&dlopen != NULL)
 
226
        return dlsym(__handle, __symbol);
 
227
    else
 
228
#endif
 
229
        return wx_darwin_dlsym(__handle, __symbol);
 
230
}
 
231
 
 
232
#else // __DARWIN__/!__DARWIN__
 
233
 
 
234
// Use preprocessor definitions for non-Darwin or OS X >= 10.3
 
235
#define wx_dlopen(__path,__mode) dlopen(__path,__mode)
 
236
#define wx_dlclose(__handle) dlclose(__handle)
 
237
#define wx_dlerror() dlerror()
 
238
#define wx_dlsym(__handle,__symbol) dlsym(__handle,__symbol)
 
239
 
182
240
#endif // defined(__DARWIN__)
183
241
 
184
242
// ----------------------------------------------------------------------------
188
246
wxDllType wxDynamicLibrary::GetProgramHandle()
189
247
{
190
248
#ifdef USE_POSIX_DL_FUNCS
191
 
   return dlopen(0, RTLD_LAZY);
 
249
   return wx_dlopen(0, RTLD_LAZY);
192
250
#else
193
251
   return PROG_HANDLE;
194
252
#endif
209
267
    if ( flags & wxDL_GLOBAL )
210
268
        rtldFlags |= RTLD_GLOBAL;
211
269
 
212
 
    return dlopen(libname.fn_str(), rtldFlags);
 
270
    return wx_dlopen(libname.fn_str(), rtldFlags);
213
271
#else // !USE_POSIX_DL_FUNCS
214
272
    int shlFlags = 0;
215
273
 
234
292
#endif
235
293
 
236
294
#ifdef USE_POSIX_DL_FUNCS
237
 
    dlclose(handle);
 
295
    wx_dlclose(handle);
238
296
#else // !USE_POSIX_DL_FUNCS
239
297
    shl_unload(handle);
240
298
#endif // USE_POSIX_DL_FUNCS/!USE_POSIX_DL_FUNCS
251
309
    void *symbol;
252
310
 
253
311
#ifdef USE_POSIX_DL_FUNCS
254
 
    symbol = dlsym(handle, name.fn_str());
 
312
    symbol = wx_dlsym(handle, name.fn_str());
255
313
#else // !USE_POSIX_DL_FUNCS
256
314
    // note that shl_findsym modifies the handle argument to indicate where the
257
315
    // symbol was found, but it's ok to modify the local handle copy here
272
330
void wxDynamicLibrary::Error()
273
331
{
274
332
#if wxUSE_UNICODE
275
 
    wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
 
333
    wxWCharBuffer buffer = wxConvLocal.cMB2WC( wx_dlerror() );
276
334
    const wxChar *err = buffer;
277
335
#else
278
 
    const wxChar *err = dlerror();
 
336
    const wxChar *err = wx_dlerror();
279
337
#endif
280
338
 
281
339
    wxLogError(wxT("%s"), err ? err : _("Unknown dynamic library error"));