pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Patch for devel/netbsd-iscsi-lib on Mac OS X 10.10 / clang



Hi,

Wanting to try the iscsi target software for Mac OS X (for serving files to a NetBSD virtual host), I found that net/netbsd-iscsi-lib fails to compile with a cast error (compiler is clang):

disk.c:810:38: error: assignment to cast is illegal, lvalue casts are not
      supported
                *((uint64_t *) (void *)data + 8) = (uint64_t) ISCSI_HTONLL(key);
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
*** Error code 1

The following patch fixes the problem

--- ./include/compat.h.orig     2015-01-25 12:41:29.000000000 -0700
+++ ./include/compat.h  2015-01-25 15:38:17.000000000 -0700
@@ -51,11 +51,11 @@ size_t strlcpy(char *, const char *, siz
 #  define ISCSI_BE64TOH(x)     be64toh(x)
 #else
 #  if defined(HAVE_LIBKERN_OSBYTEORDER_H)
-#    define ISCSI_HTOBE64(x)   (x) = OSSwapBigToHostInt64((u_int64_t)(x))
+#    define ISCSI_HTOBE64(x)   ((x) = (OSSwapBigToHostInt64((u_int64_t)(x))))
 #  elif _BYTE_ORDER == _BIG_ENDIAN
 #    define ISCSI_HTOBE64(x)   (x)
 #  elif defined(HAVE___BSWAP64)
-#    define ISCSI_HTOBE64(x)   (x) = __bswap64((u_int64_t)(x))
+#    define ISCSI_HTOBE64(x)   ((x) = __bswap64((u_int64_t)(x)))
 #  else   /* LITTLE_ENDIAN */
 #    define ISCSI_HTOBE64(x)   (((uint64_t)(ISCSI_NTOHL((uint32_t)(((x) << 32) >> 32))) << 32) | (uint32_t)ISCSI_NTOHL(((uint32_t)((x) >> 32))))
 #  endif  /* LITTLE_ENDIAN */

(The second change is not necessary for the Mac but should probably be there for consistency.)

I have used NFS and vnconfig to provide small file systems containing NetBSD source code to the virtual host. Switching from NFS to iscsi I see around 20% improvement in compilation speed. Here are times for compiling a NetBSD kernel:

NFS:
real    7m18.050s
user    12m39.457s
sys     2m54.518s

ISCSI:
real    5m4.033s
user    10m15.174s
sys     2m2.209s

Regards,
Sverre



Home | Main Index | Thread Index | Old Index