Skip to content
Browse files

rearrange dynaload code to avoid some OS X issues

  • Loading branch information...
1 parent 42f8a92 commit d8e0c3baade733ffb5b3549bb36b900460ba615f Tony Cook committed Dec 6, 2007
Showing with 72 additions and 33 deletions.
  1. +4 −0 Changes
  2. +5 −4 Imager.xs
  3. +27 −3 Makefile.PL
  4. +34 −0 dynaload.c
  5. +2 −26 dynaload.h
View
4 Changes
@@ -3,6 +3,10 @@ Imager release history. Older releases can be found in Changes.old
Imager 0.62 - unreleased
===========
+ - Makefile.PL now expands ~/path supplied to --incpath or --libpath
+ to /path under your home directory.
+ http://rt.cpan.org/Ticket/Display.html?id=29484
+
Bug fixes:
- samples/gifscale.pl sourced the base value for gif_top from
View
9 Imager.xs
@@ -3470,17 +3470,18 @@ DSO_funclist(dso_handle_v)
PREINIT:
int i;
DSO_handle *dso_handle;
+ func_ptr *functions;
PPCODE:
dso_handle=(DSO_handle*)dso_handle_v;
+ functions = DSO_funclist(dso_handle);
i=0;
- while( dso_handle->function_list[i].name != NULL) {
+ while( functions[i].name != NULL) {
EXTEND(SP,1);
- PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i].name,0)));
+ PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
EXTEND(SP,1);
- PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i++].pcode,0)));
+ PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
}
-
void
DSO_call(handle,func_index,hv)
void* handle
View
30 Makefile.PL
@@ -412,8 +412,11 @@ sub init {
my @definc = qw(/usr/include);
@definc{@definc}=(1) x @definc;
- @incs=(split(/\Q$Config{path_sep}/, $INCPATH),
- map { split /\Q$Config{path_sep}/} @incpaths );
+ @incs=
+ (
+ split(/\Q$Config{path_sep}/, $INCPATH),
+ map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths
+ );
if ($Config{locincpth}) {
push @incs, grep -d, split ' ', $Config{locincpth};
}
@@ -437,7 +440,7 @@ sub init {
}
@libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
- map { split /\Q$Config{path_sep}/} @libpaths );
+ map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths );
if ($Config{loclibpth}) {
push @libs, grep -d, split ' ', $Config{loclibpth};
}
@@ -995,6 +998,27 @@ YAML
}
}
+my $home;
+sub _tilde_expand {
+ my ($path) = @_;
+
+ if ($path =~ m!^~[/\\]!) {
+ defined $home or $home = $ENV{HOME};
+ if (!defined $home && $^O eq 'MSWin32'
+ && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) {
+ $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH};
+ }
+ unless (defined $home) {
+ $home = eval { (getpwuid($<))[7] };
+ }
+ defined $home or die "You supplied $path, but I can't find your home directory\n";
+ $path =~ s/^~//;
+ $path = File::Spec->catdir($home, $path);
+ }
+
+ $path;
+}
+
# This isn't a module, but some broken tools, like
# Module::Depends::Instrusive insist on treating it like one.
#
View
34 dynaload.c
@@ -1,3 +1,32 @@
+#if defined(OS_hpux)
+#include <dl.h>
+typedef shl_t minthandle_t;
+#elif defined(WIN32)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+typedef HMODULE minthandle_t;
+#undef WIN32_LEAN_AND_MEAN
+#elif defined(OS_darwin)
+#define DL_LOADONCEONLY
+#define DLSYMUN
+#undef environ
+#undef bool
+
+#import <mach-o/dyld.h>
+typedef void *minthandle_t;
+#else
+#include <dlfcn.h>
+typedef void *minthandle_t;
+#endif
+
+#include "plug.h"
+
+struct DSO_handle_tag {
+ minthandle_t handle;
+ char *filename;
+ func_ptr *function_list;
+};
+
#include "imager.h"
#include "dynaload.h"
/* #include "XSUB.h" so we can compile on threaded perls */
@@ -38,6 +67,11 @@ DSO_call(DSO_handle *handle,int func_index,HV* hv) {
(handle->function_list[func_index].iptr)((void*)hv);
}
+func_ptr *
+DSO_funclist(DSO_handle *handle) {
+ return handle->function_list;
+}
+
#if defined( OS_hpux )
View
28 dynaload.h
@@ -3,38 +3,13 @@
#include "log.h"
-#if defined(OS_hpux)
-#include <dl.h>
-typedef shl_t minthandle_t;
-#elif defined(WIN32)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-typedef HMODULE minthandle_t;
-#undef WIN32_LEAN_AND_MEAN
-#elif defined(OS_darwin)
-#define DL_LOADONCEONLY
-#define DLSYMUN
-#undef environ
-#undef bool
-
-#import <mach-o/dyld.h>
-typedef void *minthandle_t;
-#else
-#include <dlfcn.h>
-typedef void *minthandle_t;
-#endif
-
#include "EXTERN.h"
#include "perl.h"
#include "ppport.h"
#include "ext.h"
-typedef struct {
- minthandle_t handle;
- char *filename;
- func_ptr *function_list;
-} DSO_handle;
+typedef struct DSO_handle_tag DSO_handle;
typedef struct {
HV* hv;
@@ -50,6 +25,7 @@ int getvoid(void *hv_t,char *key,void **store);
#endif
void *DSO_open(char* file,char** evalstring);
+func_ptr *DSO_funclist(DSO_handle *handle);
int DSO_close(void *);
void DSO_call(DSO_handle *handle,int func_index,HV* hv);

0 comments on commit d8e0c3b

Please sign in to comment.
Something went wrong with that request. Please try again.