MessageWell, this happens to be 32-bit mode. The need for a 64-bit field comes from the need to correctly represent video memory entities such as buffers (the current board has a maximum of 4Gb of memory on board, and we can expect this value to grow in the years to come) and other board-side objects. This is a unique situation, where the video board has way more memory than the motherboard! That particular 64-bit field doesn’t need to be aligned but it’d have been nice to have the same alignment in both compilers! My solution was to sort the fields in those data structures by width, 64-bit first, 32-bit next, and so on: that fixes the problem, and it only took one day of work or so to do the conversion. But still, I’d have felt better if I hadn’t had the problem to begin with.
Alberto.
----- Original Message -----
From: David R. Cattley
To: Windows System Software Devs Interest List
Sent: Thursday, June 09, 2005 11:37 PM
Subject: RE: [ntdev] Funky compiler issue
While I agree with all of the tool feature requests in Alberto’s statement below I can’t help but throw in 2 cents and say that regardless of the compiler choices, passing information between two disparate components, especially betweeen usermode and kernel mode, is always a design problem requiring a precise and unambiguous ‘in memory representation’ of the information. A language like C or C++ is a way of expressing the representation and a compiler is a tool for interpreting the expression. If you want it to be precise (and you must for IOCTL buffers or on wire representations) you cannot leave *anything* to chance, whim, or default settings in the compiler. This is not a class of problem to be fixed by having one compiler. It is an example of a problem to be fixed by having one precise representation that is expressed in a way that the compiler has no wiggle room to misintrepret, regardless of the compiler, revision, or settings. It may be ugly (due to the language extensions required to control it) but alignment directives and packing (or dummy fields to explicitly express the packing and force alignment) would be required to be precise enough even if only one compiler existed. This becomes even more critical with 32bit/64bit hybrid environments where alignment and packing rules may differ between user mode and kernel mode. The statement that the DDK compiler ‘correctly’ set the offset to 4 for the 64bit field is a matter of opinion and likely true only in a 32bit kernel mode. In my unqualified opinion, neither 4 nor 8 is ‘correct’ unless one of them is the one that was designed for and specified. If the same driver were compiled for AMD64 of IA64, suddenly the MSVC.NET choice of aligning to 8 bytes would not seem like such a bad idea. If the design called for not wasting the 4 bytes, both the AMD64 and IA64 drivers could be coerced into dealing with the misalligned field (although with a performance penalty). The trade offs in are not about what the compiler does but what the design calls for. It is systems level software. Don’t leave it up to the compiler to decide what that means.
Respectfully,
Dave Cattley
Consulting Engineer
Systems Software Development
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alberto Moreira
Sent: Thursday, June 09, 2005 11:08 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Funky compiler issue
I hear so many people arguing that one should use the DDK compiler to build drivers, well, because, and inevitably the bogeyman follows promptly: do it the legit way or it’ll bite you good and hard.
Well, I just bumped into this situation, bear with me. My chip - a large volume-rendering graphics engine that implements voxel rendering in hardware - requires a set of relatively involuted data structures that are shared by the user-side library, by the hardware-level diagnostics, and by the device driver. The problem is, the library is and the diags are built with MSVC.NET; the driver uses the DDK compiler. In all three cases, the build is pretty standard, we use the standard makefile and build.exe for the driver and an off-the-shelf .sln and dsp made for the app and for the diags.
Now, a 32-bit data field was recently upgraded to 64-bit, for a number of reasons. As soon as that was done, the diags started to fail. I went down to trace the error, and I had a number of structs that look like this:
struct BLAH { uint32 a; uint64 b; … };
Guess what ? The offset of field b is correctly generated in the DDK compiler (equal to 4) but MSVC.NET aligns it to a quadword boundary, hence its offset is 8. In other words, field a is extended with 4 bytes of slop. Now, I could go to either compiler and fiddle with command line options, but hey, that’s not the way it should be, is it ?
If I could use the same compiler, with the same default command line options, or at least with the differences clearly and well documented, to build all three pieces of software, I wouldn’t have that problem. While I’m busy protecting myself of a chicken little issue that may never become true, and insist in only using the DDK compiler for driver development, I’m leaving my house open to the sneaky thief to come in and cause me harm.
So, Microsoft, one suggestion: next release of MSVC.NET, how about making sure that it can correctly build drivers too ? If nothing else, how about a build button that, when clicked, runs build.exe on the solution ? Or better, a “Kernel Driver Project” pick when we choose New/Project ? With a kernel-side safe version of the standard C/C++ runtime library ? Generating kernel-side safe code ? Golly, that would be nice.
Alberto.
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com —
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com