Subject: | IO::Interface generate ioctl warnings on FreeBSD 6 |
I didn't go through an locate all of the different OS types that would
have the same problem, but the ioctl cmd is an unsigned long on some
systems, not an int. FreeBSD 6 logs each and every invalid ioctl in
dmesg, which can become quite a nuisance.
The attached patch also corrects Makefile.PL so that __USE_BSD is
properly set on Free/Open/Net BSD systems (in my testing it was not
being set on FreeBSD 6)
Subject: | IO-Interface-1.03.diff |
diff -Nur IO-Interface-1.03.orig/Interface.xs IO-Interface-1.03/Interface.xs
--- IO-Interface-1.03.orig/Interface.xs Mon Jan 22 15:37:14 2007
+++ IO-Interface-1.03/Interface.xs Mon Dec 24 15:30:18 2007
@@ -35,11 +35,16 @@
#if !defined(__USE_BSD)
#if defined(__linux__)
+ typedef int IOCTL_CMD_T;
#define __USE_BSD
- #endif
- #if defined (__APPLE__)
+ #elif defined(__APPLE__)
+ typedef unsigned long IOCTL_CMD_T;
#define __USE_BSD
+ #else
+ typedef int IOCTL_CMD_T;
#endif
+#else
+ typedef unsigned long IOCTL_CMD_T;
#endif
#if defined(sun)
@@ -330,7 +335,7 @@
return 0;
}
-int Ioctl (InputStream sock,int operation,void* result) {
+int Ioctl (InputStream sock, IOCTL_CMD_T operation,void* result) {
int fd = PerlIO_fileno(sock);
return ioctl(fd,operation,result) == 0;
}
@@ -396,7 +401,7 @@
PROTOTYPE: $$;$
PREINIT:
STRLEN len;
- int operation;
+ IOCTL_CMD_T operation;
struct ifreq ifr;
char* newaddr;
CODE:
@@ -438,7 +443,7 @@
PROTOTYPE: $$;$
PREINIT:
STRLEN len;
- int operation;
+ IOCTL_CMD_T operation;
struct ifreq ifr;
char* newaddr;
CODE:
@@ -476,7 +481,7 @@
PROTOTYPE: $$;$
PREINIT:
STRLEN len;
- int operation;
+ IOCTL_CMD_T operation;
struct ifreq ifr;
char* newaddr;
CODE:
@@ -514,7 +519,7 @@
PROTOTYPE: $$;$
PREINIT:
STRLEN len;
- int operation;
+ IOCTL_CMD_T operation;
struct ifreq ifr;
char* newaddr;
CODE:
@@ -552,7 +557,7 @@
PROTOTYPE: $$;$
PREINIT:
STRLEN len;
- int operation;
+ IOCTL_CMD_T operation;
struct ifreq ifr;
char *newaddr,hwaddr[128];
CODE:
@@ -588,7 +593,8 @@
char* name
PROTOTYPE: $$;$
PREINIT:
- int operation,flags;
+ IOCTL_CMD_T operation;
+ int flags;
struct ifreq ifr;
CODE:
{
@@ -619,7 +625,8 @@
char* name
PROTOTYPE: $$;$
PREINIT:
- int operation,flags;
+ IOCTL_CMD_T operation;
+ int flags;
struct ifreq ifr;
CODE:
{
@@ -650,7 +657,8 @@
char* name
PROTOTYPE: $$;$
PREINIT:
- int operation,flags;
+ IOCTL_CMD_T operation;
+ int flags;
struct ifreq ifr;
CODE:
{
diff -Nur IO-Interface-1.03.orig/Makefile.PL IO-Interface-1.03/Makefile.PL
--- IO-Interface-1.03.orig/Makefile.PL Thu Sep 14 07:52:04 2006
+++ IO-Interface-1.03/Makefile.PL Mon Dec 24 15:30:21 2007
@@ -4,6 +4,23 @@
my @libs = ();
push @libs,'-lresolv' unless $Config{d_inetaton};
+my $guess_cfg = {
+ 'freebsd' => {
+ 'defs' => '-D__USE_BSD',
+ },
+ 'netbsd' => {
+ 'defs' => '-D__USE_BSD',
+ },
+ 'openbsd' => {
+ 'defs' => '-D__USE_BSD',
+ }
+};
+
+my $guess = $guess_cfg->{$^O};
+unless (ref $guess eq 'HASH') {
+ $guess = {'defs' => ''};
+}
+
WriteMakefile(
'NAME' => 'IO::Interface',
'VERSION_FROM' => 'Interface.pm', # finds $VERSION
@@ -12,12 +29,14 @@
PMLIBDIRS => ['Interface'],
CONFIGURE => sub {
my %attrs;
+ $attrs{DEFINE} = $guess->{'defs'};
+
print "Checking for getifaddrs()...";
eval { require 'ifaddrs.ph' };
if ($@ && !-r "/usr/include/ifaddrs.h") {
print " Nope, will not use it.\n";
} else {
- $attrs{DEFINE} = '-DUSE_GETIFADDRS';
+ $attrs{DEFINE} .= ' -DUSE_GETIFADDRS';
print " Okay, I will use it.\n";
}
\%attrs;