This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #70337] perldiag: localtime(...) too large
[perl5.git] / win32 / wincesck.c
index 8f2a90b..7f9e0df 100644 (file)
@@ -3,7 +3,7 @@
 /* wincesck.c
  *
  * (c) 1995 Microsoft Corporation. All rights reserved.
- *             Developed by hip communications inc., http://info.hip.com/info/
+ *             Developed by hip communications inc.
  * Portions (c) 1993 Intergraph Corporation. All rights reserved.
  *
  *    You may distribute under the terms of either the GNU General Public
@@ -59,10 +59,8 @@ XCE_EXPORT struct protoent *xcegetprotobynumber(int number);
 
 #define StartSockets() \
     STMT_START {                                       \
-       if (!wsock_started) {                           \
+       if (!wsock_started)                             \
            start_sockets();                            \
-           set_socktype();                             \
-       }                                               \
     } STMT_END
 
 #define SOCKET_TEST(x, y) \
@@ -109,11 +107,6 @@ start_sockets(void)
     wsock_started = 1;
 }
 
-void
-set_socktype(void)
-{
-}
-
 u_long
 win32_htonl(u_long hostlong)
 {
@@ -343,15 +336,19 @@ int
 win32_ioctl(int i, unsigned int u, char *data)
 {
     dTHX;
-    u_long argp = (u_long)data;
+    u_long u_long_arg; 
     int retval;
-
+    
     if (!wsock_started) {
        Perl_croak_nocontext("ioctl implemented only on sockets");
        /* NOTREACHED */
     }
 
-    retval = ioctlsocket(TO_SOCKET(i), (long)u, &argp);
+    /* mauke says using memcpy avoids alignment issues */
+    memcpy(&u_long_arg, data, sizeof u_long_arg); 
+    retval = ioctlsocket(TO_SOCKET(i), (long)u, &u_long_arg);
+    memcpy(data, &u_long_arg, sizeof u_long_arg);
+    
     if (retval == SOCKET_ERROR) {
        if (WSAGetLastError() == WSAENOTSOCK) {
            Perl_croak_nocontext("ioctl implemented only on sockets");