Port-hpcarm archive

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

-current kernel headers vs. MS VC compiler



Folks:
It looks like changes to the kernel headers over the last couple of months have broken the ability to build things that rely on libsa, etc. with compilers other than GCC & PCC. Specifically, I can no longer build hpcboot.exe with MS eMbedded Visual C++ 4.0 after upgrading my kernel tree to the head of trunk.

The first change that bit me was a change from the old '__attribute__((packed))', which used to be defined away on non-GCC compilers (probably incorrectly, but nonetheless) to using '__packed', in sys/ufs/ffs/fs.h:

        RCS file: /cvsroot/src/sys/ufs/ffs/fs.h,v
        Working file: fs.h
        head: 1.49
        ----------------------------
        revision 1.49
        date: 2007/12/25 18:33:49;  author: perry;  state: Exp;  lines: +2 -2
        Convert many of the uses of __attribute__ to equivalent
        __packed, __unused and __dead macros from cdefs.h

I've 'fixed' this with the following change, because I don't know how to make the MS compiler #pragma pack fit into the syntax we require (nor was I able to find an MS compiler extension which looked it it might help):

Index: cdefs.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cdefs.h,v
retrieving revision 1.66
diff -u -p -r1.66 cdefs.h
--- cdefs.h     26 Nov 2007 14:52:34 -0000      1.66
+++ cdefs.h     6 Mar 2008 02:07:54 -0000
@@ -207,7 +207,7 @@
 #define        __packed        __attribute__((__packed__))
 #define        __aligned(x)    __attribute__((__aligned__(x)))
 #define        __section(x)    __attribute__((__section__(x)))
-#elif defined(__PCC__)
+#elif defined(__PCC__) || defined(_MSC_VER)
 #define        __packed        /* XXX ignore for now */
 #define        __aligned(x)    /* XXX ignore for now */
 #define        __section(x)    /* XXX ignore for now */

The second change that broke the eVC++ build was the exposing of bintime and the various helpers that operate on it in sys/sys/time.h, because eVC++ 4 doesn't grok the 'LL' suffix on some of the numeric constants used in the bintime-wrangling code.

        RCS file: /cvsroot/src/sys/sys/time.h,v
        Working file: time.h
        head: 1.59
        total revisions: 115;   selected revisions: 115
        description:
        revision 1.58
        date: 2007/12/22 01:19:41;  author: yamt;  state: Exp;  lines: +1 -3
        expose bintime for libpthread.
        ----------------------------

Here, I used a big-stick and simply #ifndef _STANDALONE'd the offending code, like so (it used to be #ifdef _KERNEL):

Index: time.h
===================================================================
RCS file: /cvsroot/src/sys/sys/time.h,v
retrieving revision 1.59
diff -u -p -r1.59 time.h
--- time.h      8 Jan 2008 20:56:22 -0000       1.59
+++ time.h      6 Mar 2008 02:07:54 -0000
@@ -99,6 +99,7 @@ struct timezone {
                }                                                       \
        } while (/* CONSTCOND */ 0)

+#ifndef _STANDALONE
 struct bintime {
        time_t  sec;
        uint64_t frac;
@@ -188,6 +189,7 @@ timeval2bintime(const struct timeval *tv
        /* 18446744073709 = int(2^64 / 1000000) */
        bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
 }
+#endif /* !_STANDALONE */

 /* Operations on timespecs. */
#define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L)

Any thoughts on what the right thing to do to keep MV eVC++ compatibility without littering the kernel headers with too much #ifdef-ism is in these cases? The first seems like an easy (if slightly wrong solution), but I'm not sure if the second change will cause any collateral damage (I suspect not, but thought I'd pass it by the lists).

Thanks,
--rafal


Home | Main Index | Thread Index | Old Index